-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest-tests.sh
More file actions
executable file
·58 lines (55 loc) · 1.95 KB
/
test-tests.sh
File metadata and controls
executable file
·58 lines (55 loc) · 1.95 KB
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
#!/usr/bin/env bash
REPORT_FILE="./test/report.txt"
date --iso-8601=seconds > "$REPORT_FILE"
OK=0
KO=0
TOTAL=0
RUNS=1
printf "%-7s %-40s %15s %s\n" "CC" "Test" "ms?" "Result" >> "$REPORT_FILE"
for TEST in ./test/test_*.c; do
BASENAME=$(basename "${TEST}")
TESTNAME="${BASENAME%.*}"
for CC in gcc clang; do
OUT_FILE="./test/${TESTNAME}.${CC}.out"
ERR_FILE="./test/${TESTNAME}.${CC}.err"
echo -n "Compiling ${TESTNAME} with ${CC}... "
${CC} -m32 -std=c17 -Wall -I./include -Wall -Wextra -Wpedantic -ggdb -O3 -o ./test/test ${TEST} -lm > "$OUT_FILE" 2> "$ERR_FILE"
if [[ $? -ne 0 ]]; then
printf "%-7s %-40s %15s %s\n" "${CC}" "${TESTNAME}" "N/A" "KO (compile error)" >> "$REPORT_FILE"
KO=$((KO + 1))
echo "KO (compile error)"
TOTAL=$((TOTAL + 1))
continue
else
echo "OK"
fi
echo -n "Executing ${TESTNAME} compiled with ${CC}... "
START=$(date +%s%N)
if [[ ${RUNS} -eq 1 ]]; then
{ ./test/test; } > "$OUT_FILE" 2> "$ERR_FILE"
RESULT=$?
else
for I in {1..${RUNS}}; do
echo -n "#$I "
{ ./test/test; } > "$OUT_FILE" 2> "$ERR_FILE"
RESULT=$?
done
fi
END=$(date +%s%N)
rm -f ./test/test
DURATION=$(( (END - START) / (${RUNS} * 1000) )) # Duration in milliseconds?
if [[ ${RESULT} -eq 0 ]]; then
printf "%-7s %-40s %15s %s\n" "${CC}" "${TESTNAME}" "${DURATION}" "OK" >> "$REPORT_FILE"
OK=$((OK + 1))
echo "OK"
else
printf "%-7s %-40s %15s %s\n" "${CC}" "${TESTNAME}" "${DURATION}" "KO (${RESULT})" >> "$REPORT_FILE"
KO=$((KO + 1))
echo "KO"
fi
TOTAL=$((TOTAL + 1))
done
done
echo "Total: $TOTAL, OK $OK, KO $KO" >> "$REPORT_FILE"
date --iso-8601=seconds >> "$REPORT_FILE"
cat ${REPORT_FILE}