Hash :
df4566fe
Author :
Thomas de Grivel
Date :
2024-07-24T17:49:51
CI :
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
#!/bin/sh
cd "$(dirname $0)/ikc3" || exit
TEST_COLOR_KO="[0;91m"
TEST_COLOR_OK="[0;92m"
TEST_COLOR_RESET="[0m"
TEST_COUNT=0
TEST_KO=0
TEST_OK=0
if [ "x$IKC3" = "x" ]; then
if [ -f ../../ikc3/ikc3 ]; then
IKC3=../../ikc3/ikc3
elif [ -f ../../ikc3 ]; then
IKC3=../../ikc3
fi
fi
test_ko() {
printf "%s" "${TEST_COLOR_KO}F${TEST_COLOR_RESET}"
echo $@ >> .test_ko
echo $@ >> .test
}
test_ok() {
printf "%s" "${TEST_COLOR_OK}.${TEST_COLOR_RESET}"
echo $@ >> .test_ok
echo $@ >> .test
}
if [ $# = 0 ]; then
if [ "x${IKC3_TEST}" = "x" ]; then
TARGETS="$(ls -1 *.kc3 | sed -e 's/[.]kc3$//')"
else
TARGETS="${IKC3_TEST}"
fi
else
TARGETS="$@"
fi
rm -f *.diff *.out *.ret
rm -f .test .test_ko .test_ok
touch .test .test_ko .test_ok
for TARGET in $TARGETS; do
(
RESULT=test_ok
$IKC3 --load ${TARGET}.kc3 --quit > ${TARGET}.out 2>&1
echo $? > ${TARGET}.ret
if ! diff -abu ${TARGET}.out.expected ${TARGET}.out \
> ${TARGET}.diff
then
RESULT=test_ko
fi
if ! diff -abu ${TARGET}.ret.expected ${TARGET}.ret \
>> ${TARGET}.diff
then
RESULT=test_ko
fi
if [ "x$RESULT" = "xtest_ok" ]; then
rm ${TARGET}.diff
test_ok ${TARGET}
else
test_ko ${TARGET}
fi
) &
done
wait
TEST_COUNT=$(echo $(wc -l .test) | cut -f 1 -d ' ')
TEST_KO=$(echo $(wc -l .test_ko) | cut -f 1 -d ' ')
TEST_OK=$(echo $(wc -l .test_ok) | cut -f 1 -d ' ')
echo
DIFFS="$(for TARGET in $TARGETS; do
if [ -f "${TARGET}.diff" ]; then
printf "%s " "${TARGET}.diff"
fi
done)"
if [ "x$DIFFS" != "x" ]; then
ls $DIFFS
less $DIFFS || cat $DIFFS
fi
echo
printf "%s" "Total $TEST_COUNT tests. "
printf "%s" "${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}."
if [ "x$TEST_KO" = "x0" ]; then
exit 0
fi
exit 1