-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·94 lines (80 loc) · 2.69 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
make clean
make all
# Initialize counters
passed=0
failed=0
summary_file=$(mktemp)
test_executables=(
"./build/test_unthreaded_no_wrap/test_simple"
"./build/test_unthreaded_no_wrap/test_complex"
"./build/test_unthreaded_wrap/test_simple"
"./build/test_unthreaded_wrap/test_complex"
)
for test_executable in "${test_executables[@]}"; do
if [ ! -f $test_executable ]; then
echo "echo -e \"\033[0;31mFILE NOT FOUND\033[0m --- $test_executable\"" >> $summary_file
elif [ -x "$test_executable" ]; then
echo -e "\n===> \033[0;34mRUNNING\033[0m $test_executable <===\n"
"$test_executable" > /dev/null
if [ $? -eq 0 ]; then
echo "echo -e \"\033[0;32mPASSED\033[0m --- $test_executable\"" >> $summary_file
passed=$((passed+1))
else
echo "echo -e \"\033[0;31mFAILED\033[0m --- $test_executable\"" >> $summary_file
failed=$((failed+1))
fi
fi
done
test_executables_by_file=(
"./build/test_unthreaded_no_wrap/test_by_file"
"./build/test_unthreaded_wrap/test_by_file"
)
for test_executable in "${test_executables_by_file[@]}"; do
dest_file=$(mktemp)
if [ ! -f $test_executable ]; then
echo "echo -e \"\033[0;31mFILE NOT FOUND\033[0m --- $test_executable\"" >> $summary_file
elif [ -x "$test_executable" ]; then
echo -e "\n===> \033[0;34mRUNNING\033[0m $test_executable <===\n"
timeout 2s "$test_executable" ./test/test_unthreaded_wrap/testfile.txt "$dest_file" > /dev/null
if [ $? -eq 0 ]; then
echo "echo -e \"\033[0;32mPASSED\033[0m --- $test_executable\"" >> $summary_file
passed=$((passed+1))
else
echo "echo -e \"\033[0;31mFAILED\033[0m --- $test_executable\"" >> $summary_file
failed=$((failed+1))
fi
fi
rm -rf $dest_file
done
test_executables_threaded=(
"./build/test_threaded/test"
"./build/test_daemon/test"
)
for test_executable in "${test_executables_threaded[@]}"; do
if [ ! -f $test_executable ]; then
echo "echo -e \"\033[0;31mFILE NOT FOUND\033[0m --- $test_executable\"" >> $summary_file
elif [ -x "$test_executable" ]; then
echo -e "\n===> \033[0;34mRUNNING\033[0m $test_executable <===\n"
timeout 6s "$test_executable" > /dev/null
if [ $? -eq 0 ]; then
echo "echo -e \"\033[0;32mPASSED\033[0m --- $test_executable\"" >> $summary_file
passed=$((passed+1))
else
echo "echo -e \"\033[0;31mFAILED\033[0m --- $test_executable\"" >> $summary_file
failed=$((failed+1))
fi
fi
done
total=$((passed + failed))
echo -e "===SUMMARY===\n"
source $summary_file
rm -rf $summary_file
echo "---"
if [ $failed -ne 0 ]; then
echo -e "\033[0;31mFAILED:\033[0m $failed / $total"
fi
if [ $passed -ne 0 ]; then
echo -e "\033[0;32mPASSED:\033[0m $passed / $total"
fi
exit $failed