From 295a0c6d6360e0f714e7fc2bc6c5d1ffbdfdc5cc Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sat, 11 Nov 2017 15:05:27 +0100 Subject: [PATCH] CI: simplify script tests --- .../test-border-router.sh | 37 +++++++++---------- tests/18-native-networking/01-native-ping.sh | 7 ++-- tests/Makefile.script-test | 11 ++---- 3 files changed, 24 insertions(+), 31 deletions(-) diff --git a/tests/17-rpl-border-router/test-border-router.sh b/tests/17-rpl-border-router/test-border-router.sh index ab1ef55bd..260f9a4f9 100755 --- a/tests/17-rpl-border-router/test-border-router.sh +++ b/tests/17-rpl-border-router/test-border-router.sh @@ -11,48 +11,45 @@ IPADDR=$3 # Start simulation echo "Starting Cooja simulation $BASENAME.csc" -java -Xshare:on -jar $CONTIKI/tools/cooja/dist/cooja.jar -nogui=$BASENAME.csc -contiki=$CONTIKI > /dev/null & +java -Xshare:on -jar $CONTIKI/tools/cooja/dist/cooja.jar -nogui=$BASENAME.csc -contiki=$CONTIKI > $BASENAME.coojalog & JPID=$! sleep 20 # Connect to the simlation echo "Starting tunslip6" make -C $CONTIKI/tools tunslip6 -make -C $CONTIKI/examples/rpl-border-router/ connect-router-cooja TARGET=zoul > tunslip.log 2> tunslip.err & +make -C $CONTIKI/examples/rpl-border-router/ connect-router-cooja TARGET=zoul >> $BASENAME.tunsliplog 2>&1 & MPID=$! echo "Waiting for network formation" sleep 5 # Do ping echo "Pinging" -ping6 $IPADDR -c 5 | tee $BASENAME.log +ping6 $IPADDR -c 5 | tee $BASENAME.scriptlog # Fetch ping6 status code (not $? because this is piped) STATUS=${PIPESTATUS[0]} echo "Closing simulation and tunslip6" -sleep 2 +sleep 1 kill -9 $JPID kill -9 $MPID +sleep 1 +rm COOJA.testlog +rm COOJA.log if [ $STATUS -eq 0 ] ; then - mv $BASENAME.log $BASENAME.testlog - echo " OK" + echo "$BASENAME: TEST OK" | tee $BASENAME.testlog; else - mv $BASENAME.log $BASENAME.faillog + # Verbose output when using CI + if [ "$CI" = "true" ]; then + echo "==== $BASENAME.coojalog ====" ; cat $BASENAME.coojalog; + echo "==== $BASENAME.tunsliplog ====" ; cat $BASENAME.tunsliplog; + echo "==== $BASENAME.scriptlog ====" ; cat $BASENAME.scriptlog; + else + echo "==== Check $BASENAME.coojalog, $BASENAME.tunsliplog, and $BASENAME.scriptlog for details ===="; + fi; - echo "" - echo "---- COOJA.log" - cat COOJA.log - - echo "" - echo "---- tunslip.log" - cat tunslip.log - - echo "" - echo "---- tunslip.err" - cat tunslip.err - - echo " FAIL ಠ_ಠ" | tee -a $BASENAME.faillog; + echo "$BASENAME: TEST FAIL ಠ_ಠ" | tee $BASENAME.testlog; fi # We do not want Make to stop -> Return 0 diff --git a/tests/18-native-networking/01-native-ping.sh b/tests/18-native-networking/01-native-ping.sh index 46efbf1df..144554499 100755 --- a/tests/18-native-networking/01-native-ping.sh +++ b/tests/18-native-networking/01-native-ping.sh @@ -25,8 +25,8 @@ sleep 2 sudo kill -9 $CPID if [ $STATUS -eq 0 ] ; then - mv $BASENAME.log $BASENAME.testlog - echo " OK" + cp $BASENAME.log $BASENAME.testlog + echo "$BASENAME: TEST OK" | tee -a $BASENAME.testlog; else mv $BASENAME.log $BASENAME.faillog @@ -38,7 +38,8 @@ else echo "---- node.err" cat node.err - echo " FAIL ಠ_ಠ" | tee -a $BASENAME.faillog; + cp $BASENAME.log $BASENAME.faillog + echo "$BASENAME: TEST FAIL ಠ_ಠ" | tee -a $BASENAME.testlog; fi # We do not want Make to stop -> Return 0 diff --git a/tests/Makefile.script-test b/tests/Makefile.script-test index c39ce383c..a14523fe4 100644 --- a/tests/Makefile.script-test +++ b/tests/Makefile.script-test @@ -1,20 +1,15 @@ TESTS=$(wildcard ??-*.sh) TESTLOGS=$(patsubst %.sh,%.testlog,$(TESTS)) -FAILLOGS=$(patsubst %.sh,%.faillog,$(TESTS)) CONTIKI=../.. tests: $(TESTLOGS) -report: clean tests - @echo | grep -s -e '' - $(TESTLOGS) $(FAILLOGS) > $@ || true - -summary: report +summary: clean tests ifeq ($(TESTS),) @echo No tests > $@ else - @egrep -e ' OK| FAIL' $< > $@ - @ls -1 ??-*.faillog > /dev/null 2>&1; [ $$? = 0 ] && tail -v ??-*.log ??-*.faillog >> $@ || true + @cat $(TESTLOGS) > $@ endif all: cooja clean tests @@ -23,7 +18,7 @@ all: cooja clean tests @bash "$(basename $@).sh" "$(CONTIKI)" clean: - @rm -f $(TESTLOGS) $(FAILLOGS) report summary + @rm -f *.*log report summary cooja: $(CONTIKI)/tools/cooja/dist/cooja.jar $(CONTIKI)/tools/cooja/dist/cooja.jar: