Hash :
865d1524
Author :
Thomas de Grivel
Date :
2022-10-31T00:50:45
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
#!/bin/sh
cd "$(dirname $0)/ic3" || exit
TEST_COLOR_KO="[91m"
TEST_COLOR_OK="[92m"
TEST_COLOR_RESET="[39m"
TEST_COUNT=0
TEST_KO=0
TEST_OK=0
if [ "x$IC3" = "x" ]; then
IC3=../../ic3/ic3
fi
test_ko() {
echo -n "${TEST_COLOR_KO}F${TEST_COLOR_RESET}"
TEST_KO=$(($TEST_KO + 1))
TEST_COUNT=$(($TEST_COUNT + 1))
}
test_ok() {
echo -n "${TEST_COLOR_OK}.${TEST_COLOR_RESET}"
TEST_OK=$(($TEST_OK + 1))
TEST_COUNT=$(($TEST_COUNT + 1))
}
if [ $# = 0 ]; then
if [ "x${IC3_TEST_TARGETS}" = "x" ]; then
TARGETS="$(ls -1 *.in | sed -e 's/[.]in$//')"
else
TARGETS="${IC3_TEST_TARGETS}"
fi
else
TARGETS="$@"
fi
for TARGET in $TARGETS; do
$IC3 < ${TARGET}.in > ${TARGET}.out 2> ${TARGET}.err
echo $? > ${TARGET}.ret
diff -u ${TARGET}.out.expected ${TARGET}.out > ${TARGET}.diff &&
diff -u ${TARGET}.err.expected ${TARGET}.err >> ${TARGET}.diff &&
diff -u ${TARGET}.ret.expected ${TARGET}.ret >> ${TARGET}.diff &&
rm ${TARGET}.diff &&
test_ok ||
test_ko
done
echo
for TARGET in $TARGETS; do
if [ -f "${TARGET}.diff" ]; then
cat "${TARGET}.diff"
fi
done
echo
echo -n "Total $TEST_COUNT tests. "
echo -n "${TEST_COLOR_OK}OK $TEST_OK ($(($TEST_OK * 100 / $TEST_COUNT))%)${TEST_COLOR_RESET}. "
echo "${TEST_COLOR_KO}KO $TEST_KO ($(($TEST_KO * 100 / $TEST_COUNT))%)${TEST_COLOR_RESET}."