summaryrefslogtreecommitdiff
path: root/tests/test.sh
blob: bb71bd545871b56ebbb69b3b45a66266553c164f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash

if [ ! -f run_tests.sh ]
then
    echo "Test needs to be run from the tests directory" 1>&2
    exit 1
fi
if [ ! -f test_lib.sh ]
then
    echo "Could not find test_lib.sh" 1>&2
    exit 1
fi
if [ ! $(id -u) -eq 0 ] 
then
    echo "Test needs to be run as root" 1>&2
    exit 1
fi
if [ ! -d PATCHES ];
then
    echo "Could not find test patches. Check tests/PATCHES or run tests/gen.sh\
             to generate new patches for testing" 1>&2
    exit 1
fi

error() {
    echo "Failed"
    cd $_TESTFOLDER
#    cleanup_and_exit
    exit 1
}

_TESTFOLDER=`pwd`

. ./test_lib.sh

#trap error ERR

echo -e "\n#### Running Cross-platform Test"

echo -e "\nPreparing Test Environment... "
mkdir balls
cd $_TESTFOLDER/balls
for ((i=0; i<8; i++)); do
    mkdir ${nums[$i]}
done
for ((i=1; i<7; i++)); do
    cd ${nums[$i]} 
    echo -e "\nI'M IN ${nums[$i]}!!\n"
    for ((j=1; j<=i; j++)); do
        tbdiff-deploy $_TESTFOLDER/PATCHES/patch${nums[$j]}.tbd
    done
    cd ..
done

echo -e "\nCreating Patches... "
mkdir -p TESTPATCHES
for ((i=1; i<8; i++)); do
    tbdiff-create TESTPATCHES/primepatch${nums[$i]}.tbd ${nums[$i]} ${nums[$(($i+1))]}
done

for ((i=1; i<7; i++)); do
    echo -en "Checking Patch $ii..."
    diff TESTPATCHES/primepatch${nums[$i]}.tbd $_TESTFOLDER/PATCHES/patch${nums[$j]}.tbd
    if [ $? -eq 0 ]; then
        echo OK
    else
        error
    fi
done