wsd: test: improved single-test runner
The test now runs as many times as requested and doesn't stop on first failure. Instead, it reports the number of passing vs failing runs. Also simplifies the detection of the test result by using the exit code instead of grepping the output file. Change-Id: Ie458b2963411632d566cd87d2dfb9137044d2b4b Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>pull/7292/head
parent
48918f9b3b
commit
4407ac9136
|
@ -13,27 +13,41 @@ if [ -z "$name" ]; then
|
|||
echo "missing parameter: test name"
|
||||
exit 1
|
||||
fi
|
||||
shift # Eat the first argument.
|
||||
|
||||
limit="$2"
|
||||
count=0
|
||||
while true
|
||||
# Maximum number of runs.
|
||||
limit=1
|
||||
if [ $# -ne 0 ];
|
||||
then
|
||||
limit=$1
|
||||
if test $limit -lt 1; then
|
||||
echo "Cannot run $limit times; please enter a positive number."
|
||||
exit 1
|
||||
fi;
|
||||
echo "Will run $name $limit times."
|
||||
shift
|
||||
fi
|
||||
|
||||
pass=0;
|
||||
for ((i=1; i<=$limit; i++))
|
||||
do
|
||||
count=$((count+1))
|
||||
|
||||
(cd test; ./run_unit.sh --test-name $name.la --log-file $name.log --trs-file $name.trs --color-tests yes --enable-hard-errors yes --expect-failure no -- ./$name.la)
|
||||
./coolwsd --disable-cool-user-checking --cleanup
|
||||
if ! grep -q FAIL test/$name.trs; then
|
||||
RET=0
|
||||
break
|
||||
else
|
||||
RET=1
|
||||
fi
|
||||
|
||||
if [ -z "$limit" ] || [ "$count" -eq "$limit" ]; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
echo;
|
||||
echo ">>> $(date +%b-%d) @ $(date +%H:%M:%S) Run #$i (of $limit):";
|
||||
./coolwsd --disable-cool-user-checking --cleanup &> /dev/null
|
||||
(cd test && ./run_unit.sh --test-name $name.la --log-file $name.log --trs-file $name.trs --color-tests yes --enable-hard-errors yes --expect-failure no -- ./$name.la)
|
||||
if test $? -eq 0; then
|
||||
((pass=pass+1));
|
||||
fi;
|
||||
echo;
|
||||
done;
|
||||
((res=pass*100/limit));
|
||||
echo ">>> Passed $pass times out of $limit runs: $res%";
|
||||
if test $pass -ne $limit; then
|
||||
echo ">>> FAILED";
|
||||
RET=1;
|
||||
fi
|
||||
|
||||
./coolwsd --disable-cool-user-checking --cleanup
|
||||
exit $RET
|
||||
|
||||
# vi:set shiftwidth=4 expandtab:
|
||||
|
|
|
@ -90,6 +90,7 @@ if ${trace} \
|
|||
--unitlib="${abs_top_builddir}/test/.libs/$tst.so" 2> "$tst_log" 1>&2; then
|
||||
echo "Test $tst passed. Finished in ${SECONDS}s."
|
||||
echo ":test-result: PASS $tst" >> $test_output
|
||||
exit 0
|
||||
else
|
||||
echo "Test $tst FAILED. Finished in ${SECONDS}s."
|
||||
cat $tst_log
|
||||
|
@ -112,5 +113,6 @@ else
|
|||
echo "============================================================="
|
||||
echo ":test-result: FAIL $tst" >> $test_output
|
||||
fi
|
||||
exit 1
|
||||
|
||||
# vim:set shiftwidth=4 expandtab:
|
||||
|
|
Loading…
Reference in New Issue