-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
executable file
·77 lines (64 loc) · 1.49 KB
/
test.sh
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
70
71
72
73
74
75
76
77
#!/bin/bash
test_dir=$(pwd)/tests
full_out=$1
output_time=0.1
wait_for=1
pass=0
fail=0
timeout=0
mkdir -p build
cd build
cmake ..
if ! make >/dev/null 2>/dev/null ; then
make
exit 1
fi
cd bin
RUC=./ruc
function internal_timeout() { perl -e 'alarm shift; exec @ARGV' "$@"; }
for code in ${test_dir}/*.c ${test_dir}/*/*.c ${test_dir}/*/*/*.c
do
rm -f out.txt
out=`internal_timeout $wait_for ${RUC} $code >out.txt 2>out.txt`
case $? in
0)
if ! [[ -z $full_out ]] ; then
sleep $output_time
echo -e "\x1B[1;32m build passing \x1B[1;39m: $code"
fi
let pass++
;;
124)
if ! [[ -z $full_out ]] ; then
sleep $output_time
echo -e "\x1B[1;34m build timeout \x1B[1;39m: $code"
fi
let timeout++
;;
*)
if ! [[ -z $full_out ]] ; then
sleep $output_time
echo -e "\x1B[1;31m build failing \x1B[1;39m: $code"
if [ "${DEBUG_TEST_SCRIPT:-0}" == "1" ] ; then
echo "Output:"
cat out.txt
fi
fi
let fail++
;;
esac
done
rm -f out.txt
if ! [[ -z $full_out ]] ; then
echo
fi
echo -e "\x1B[1;39m pass = $pass, fail = $fail, timeout = $timeout"
if ! [ $pass -eq 0 ] ; then
exit 0
fi
if ! [ $fail -ge 0 ] ; then
if ! [ $timeout -ge 0 ] ; then
exit 0
fi
fi
exit 1