ctf-tools/bin/travis-ci.sh

65 lines
1.5 KiB
Bash
Raw Normal View History

#!/bin/bash -e
export EXPECTFAIL=${EXPECTFAIL:-0}
2017-03-09 09:36:51 +00:00
function flipstatus() {
if [ $EXPECTFAIL -eq 0 ];
then
echo $1
else
case $1 in
FAILED)
echo SUCCEEDED
;;
SUCCEEDED)
echo FAILED
;;
*)
echo $1
;;
esac
fi
}
2017-02-19 11:13:49 +00:00
starttime=$SECONDS
failed=""
for t in $TOOL;
do
set +e
2017-02-19 11:13:49 +00:00
toolstarttime=$SECONDS
2017-02-19 14:38:31 +00:00
echo "[-] TOOL $t TEST STARTED: $((SECONDS - starttime)) seconds since start of script."
if ! docker run -e EXPECTFAIL="$EXPECTFAIL" -e TOOL="$t" --rm ctftools bash -ic 'manage-tools -s -f -v test $TOOL';
then
failed="$failed$t "
2017-03-09 09:36:51 +00:00
echo "[ACCOUNTING]=====[ $DISTRO $t $(flipstatus FAILED) $((SECONDS - toolstarttime)) ]"
2017-03-09 08:30:07 +00:00
else
2017-03-09 09:36:51 +00:00
echo "[ACCOUNTING]=====[ $DISTRO $t $(flipstatus SUCCEEDED) $((SECONDS - toolstarttime)) ]"
fi
2017-02-19 14:38:31 +00:00
echo "[-] TOOL $t TEST ENDED: $((SECONDS - toolstarttime)) seconds, $((SECONDS - starttime)) seconds since start of script."
set -e
done
if [ "$failed" != "" ];
then
echo "==================================================="
failcount=$(echo "$failed" | wc -w)
totalcount=$(echo "$TOOL" | wc -w)
if [ "$EXPECTFAIL" -eq "1" ];
then
echo "ERROR: $failcount/$totalcount tools succeeded while they were expected to fail: $failed"
else
echo "ERROR: $failcount/$totalcount tools failed while they should have succeeded: $failed"
fi
echo "==================================================="
exit 1
fi
if [ "$EXPECTFAIL" -eq "1" ];
then
echo "DONE: $totalcount tools failed as expected."
else
echo "DONE: $totalcount tools succeeded as expected."
fi
exit 0