From 4ea174d31ae2e28499a7964ea3504d08c0e5e05d Mon Sep 17 00:00:00 2001 From: nifi Date: Mon, 29 Sep 2008 13:27:43 +0000 Subject: [PATCH] changed logging to file to be optional --- tools/cooja/contiki_tests/RUN_TEST | 46 ++++++++++++++++++------------ 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/tools/cooja/contiki_tests/RUN_TEST b/tools/cooja/contiki_tests/RUN_TEST index ebe0cd17b..6395c135e 100644 --- a/tools/cooja/contiki_tests/RUN_TEST +++ b/tools/cooja/contiki_tests/RUN_TEST @@ -1,15 +1,18 @@ #!/bin/bash -if [ -z "$2" ]; then - echo "Usage: $0 " +if [ $# -lt 1 -o $# -gt 2 ]; then + echo "Usage: $0 [logfile]" exit fi - TEST=$1 -LOG=$2 +LOGFILE=0 +if [ $# -eq 2 ]; then + LOGFILE=1 + LOG=$2 +fi echo ">>>>>>> Starting test: $TEST <<<<<<<<" -echo -n "[`date '+%F %T'`] $TEST: " >> $LOG +if [ $LOGFILE -eq 1 ]; then echo -n "[`date '+%F %T'`] $TEST: " >> $LOG; fi java -jar ../dist/cooja.jar -nogui -test=$TEST if [ -f "COOJA.log" ]; then mv COOJA.log $TEST.cooja_log @@ -20,21 +23,28 @@ if [ -f "$TEST.log" ]; then OK=`grep "TEST OK" $TEST.log | wc -l` fi -if [ $OK == 0 ]; then - echo "FAIL" >> $LOG - if [ -f "$TEST.info" ]; then - echo "--LOG INFO START ($TEST.info) --" >> $LOG - cat $TEST.info >> $LOG - echo "--LOG INFO END --" >> $LOG +if [ $LOGFILE -eq 1 ]; then + if [ $OK == 0 ]; then + echo "FAIL" >> $LOG + if [ -f "$TEST.info" ]; then + echo "--LOG INFO START ($TEST.info) --" >> $LOG + cat $TEST.info >> $LOG + echo "--LOG INFO END --" >> $LOG + else + echo "-- NO LOG INFO AVAILABLE ($TEST.info) --" >> $LOG + fi + echo "-- OUTPUT TAIL START ($TEST.cooja_log) --" >> $LOG + tail -5 $TEST.cooja_log >> $LOG + echo "-- OUTPUT TAIL END --" >> $LOG + echo >> $LOG else - echo "-- NO LOG INFO AVAILABLE ($TEST.info) --" >> $LOG + echo "OK" >> $LOG fi - echo "-- OUTPUT TAIL START ($TEST.cooja_log) --" >> $LOG - tail -5 $TEST.cooja_log >> $LOG - echo "-- OUTPUT TAIL END --" >> $LOG echo >> $LOG -else - echo "OK" >> $LOG fi -echo >> $LOG +if [ $OK == 0 ]; then + echo ">>>>>>> Finished test: $TEST FAILED <<<<<<<<" +else + echo ">>>>>>> Finished test: $TEST OK <<<<<<<<" +fi