summaryrefslogtreecommitdiff
path: root/tests/run.sh
blob: 1a98c5d60af3515a4d13d5652c2a2ec6a92fd463 (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
#!/usr/bin/env bash

pythonexec="/usr/bin/env python" # You can change this variable according to your system
wai=$(dirname $(readlink -f "$0")) # Current script directory
tests=$(ls -d ${wai}/*/) # Find tests
out=$(mktemp)
test_timeout=20
abort=1

for test in ${tests}
do
    printf "%-50s%s %s" "- $(basename $test)" "=>"
    cd $test
    testcmd="${pythonexec} simulator.py"
    [ -e "platform.yaml" ] && testcmd="esds run platform.yaml"
    echo $testcmd
    timeout $test_timeout ${testcmd} &> "$out"

    # Ensure timeout
    if [ $? -eq 124 ]
    then
        echo "failed :("
        echo "------------- Test timeout (should not exceed ${test_timeout}s) -------------"
        cat "$out";
        rm "$out"
        exit 2
    fi

    # Ensure test output
    if [ "$(base64 $out)" = "$(base64 ./out)" ]
    then
        echo "passed"
    else
        echo "failed :("
        echo "------------- Expected -------------"
        cat out
        echo "------------- Got -------------"
        cat "$out";
        rm "$out"
        [ $abort -eq 1 ] && exit 1
    fi

    # Prepare for next test
    cd - &>/dev/null
done

rm "$out"