-
Notifications
You must be signed in to change notification settings - Fork 98
/
run_tests.sh
executable file
·117 lines (103 loc) · 3 KB
/
run_tests.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/sh
#
# NOTE! All the small and ugly projects inside the "tests" directory
# are here used as regression tests / if the projects assemble and link without
# errors, we'll assume that WLA DX is in ok shape. Feel free to add more
# test projects to the lot.
#
set -e
runTest() {
set -e
cd $1
make clean
make
if test -f "testsfile"; then
eval "$BYTE_TESTER testsfile"
fi
make clean
cd ..
}
if [ $# -eq 1 ]; then
if [ "$1" = "-windows-x86" ]; then
export PATH=$PATH:$PWD/windows/Release
elif [ "$1" = "-windows-x64" ]; then
export PATH=$PATH:$PWD/windows/x64/Release
else
export PATH=$PATH:$PWD/binaries:$PWD/build/binaries
fi
else
export PATH=$PATH:$PWD/binaries:$PWD/build/binaries
fi
# byte_tester
echo Building byte_tester...
cd byte_tester
make install
# just in case...
cp byte_tester* ../binaries/
if test -f "byte_tester"; then
BYTE_TESTER="byte_tester"
fi
if test -f "byte_tester.exe"; then
BYTE_TESTER="byte_tester.exe"
fi
SHOW_ALL_OUTPUT=false
if [ $# -eq 1 ]; then
if [ "$1" = "-v" ]; then
SHOW_ALL_OUTPUT=true
fi
fi
# Valgrind test...
# Makefiles in the tests folder use WLAVALGRIND to run Valgrind at the same time
# with WLA and WLALINK
if ! [ -x "$(command -v valgrind)" ]; then
echo
echo '########################################################################'
echo 'WARNING: Valgrind is not installed so we cannot perform memory checks...'
echo '########################################################################'
export WLAVALGRIND=
else
export WLAVALGRIND='valgrind --error-exitcode=1 --tool=memcheck --leak-check=full --errors-for-leak-kinds=all --track-origins=yes -s'
fi
cd ..
echo
echo Running tests...
cd tests
if $SHOW_ALL_OUTPUT; then
echo
fi
set +e
TEST_COUNT=0
for PLATFORM in */; do
cd $PLATFORM
for TEST in */; do
# Skip tests starting with _
FIRST_CHAR=$(echo $TEST | cut -c1)
if [ "$FIRST_CHAR" = "_" ]; then
continue
fi
# Run test
if [ -e "$TEST""makefile" ]; then
OUT=$(runTest $TEST 2>&1)
if [ $? -ne 0 ]; then
printf "\n\n%s\n\n" "$OUT"
echo "########"
echo FAILURE!
echo "########"
echo Test \"$TEST\" of platform \"$PLATFORM\" failed.
exit 1
elif $SHOW_ALL_OUTPUT; then
echo "#####################################################################"
echo Test \"$TEST\" of platform \"$PLATFORM\" succeeded:
echo "#####################################################################"
printf "\n%s\n\n" "$OUT"
else
printf .
fi
# printf "%s" "$OUT"
TEST_COUNT=$((TEST_COUNT+1))
fi
done
cd ..
done
printf "\n\n"
echo "OK ($TEST_COUNT tests)"