From dcbd7936ad8144eb4347cbd42bf2fb3bf1f7d7b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20=27Morty=27=20Str=C3=BCbe?= Date: Thu, 7 Nov 2013 15:22:47 +0100 Subject: [PATCH] Move simulation execution from Makefile to Bash script; show Progress Additional code is needed to show the progress. Otherwise Travis is likely to become unhappy and terminates the job. This was no fun within the Makefile. Moving the execution to a Bash script allows better maintainability. In case of an error the error all logs will be printed when using a CI. --- regression-tests/Makefile.simulation-test | 13 +---- regression-tests/simexec.sh | 68 +++++++++++++++++++++++ 2 files changed, 70 insertions(+), 11 deletions(-) create mode 100755 regression-tests/simexec.sh diff --git a/regression-tests/Makefile.simulation-test b/regression-tests/Makefile.simulation-test index 466664f89..5c8b99e40 100644 --- a/regression-tests/Makefile.simulation-test +++ b/regression-tests/Makefile.simulation-test @@ -56,17 +56,8 @@ else RUNALL=false endif -%.testlog: %.csc cooja - @echo -n Running test $(basename $<) ... "" - @(java -Xshare:on -jar $(CONTIKI)/tools/cooja/dist/cooja.jar \ - -nogui=$< -contiki=$(CONTIKI) -random-seed=$(RANDOMSEED) > $(basename $@).log || \ - (echo " FAIL ಠ_ಠ" | tee -a COOJA.testlog; \ - tail -50 COOJA.log; \ - mv COOJA.testlog $(basename $<).faillog; \ - $(RUNALL))) && \ - (touch COOJA.testlog; \ - mv COOJA.testlog $@; \ - echo " OK") +%.testlog: %.csc cooja + @$(CONTIKI)/regression-tests/simexec.sh "$(RUNALL)" "$<" "$(CONTIKI)" "$(basename $@)" "$(RANDOMSEED)" clean: @rm -f $(TESTLOGS) $(LOGS) $(FAILLOGS) COOJA.log COOJA.testlog \ diff --git a/regression-tests/simexec.sh b/regression-tests/simexec.sh new file mode 100755 index 000000000..1d1e46b7f --- /dev/null +++ b/regression-tests/simexec.sh @@ -0,0 +1,68 @@ +#!/bin/bash +RUNALL=$1 +CSC=$2 +CONTIKI=$3 +BASENAME=$4 +RANDOMSEED=$5 + +#set -x + +echo -n "Running test $BASENAME " + +java -Xshare:on -jar $CONTIKI/tools/cooja/dist/cooja.jar -nogui=$CSC -contiki=$CONTIKI -random-seed=$RANDOMSEED > $BASENAME.log & +JPID=$! + +# Copy the log and only print "." if it changed +touch $BASENAME.log.prog +while kill -0 $JPID 2> /dev/null +do + sleep 1 + diff $BASENAME.log $BASENAME.log.prog > /dev/null + if [ $? -ne 0 ] + then + echo -n "." + cp $BASENAME.log $BASENAME.log.prog + fi +done +rm $BASENAME.log.prog + + +wait $JPID +JRV=$? + +if [ $JRV -eq 0 ] ; then + touch COOJA.testlog; + mv COOJA.testlog $BASENAME.testlog + echo " OK" + exit 0 +fi + + + +# In case of failure + +echo " FAIL ಠ_ಠ" | tee -a COOJA.testlog; + +#Verbose output when using CI +if [ "$CI" = "true" ]; then + echo "==== COOJA.log ====" ; cat COOJA.log; + echo "==== COOJA.testlog ====" ; cat COOJA.testlog; +else + tail -50 COOJA.log ; +fi; + +mv COOJA.testlog $BASENAME.faillog + +# We do not want Make to stop -> Return 0 +if [ "$RUNALL" = "true" ] ; then + touch COOJA.testlog; + mv COOJA.testlog $BASENAME.testlog; + exit 0 +fi + +#This is a failure +exit 1 + + + +