contiki/tools/cooja/contiki_tests/RUN_TEST
2009-06-24 14:41:47 +00:00

85 lines
1.7 KiB
Bash

#!/bin/bash
if [ $# -lt 1 -o $# -gt 3 ]; then
echo "Usage: $0 <test> [logfile] [-keeplog]"
exit
fi
TEST=$1
LOGFILE=0
if [ $# -gt 1 ]; then
LOGFILE=1
LOG=$2
if [ -f "$LOG" ]; then
rm $LOG
fi
fi
NO_LOG_PROCESSING=0
if [ $# -gt 2 ]; then
if [ $3 == "-keeplog" ]; then
NO_LOG_PROCESSING=1
else
echo "Usage: $0 <test> [logfile] [-keeplog]"
exit
fi
fi
echo ">>>>>>> Starting test: $TEST <<<<<<<<"
if [ $LOGFILE -eq 1 ]; then echo -n "[`date '+%F %T'`] $TEST: " >> $LOG; fi
if [ -f "COOJA.log" ]; then
rm COOJA.log
fi
if [ -f "COOJA.testlog" ]; then
rm COOJA.testlog
fi
java -mx512m -jar ../dist/cooja.jar -nogui=$TEST.csc
if [ -f "COOJA.log" ]; then
mv COOJA.log $TEST.cooja_log
fi
if [ -f "COOJA.testlog" ]; then
mv COOJA.testlog $TEST.log
fi
OK=0
if [ -f "$TEST.log" ]; then
OK=`grep "TEST OK" $TEST.log | wc -l`
fi
if [ $NO_LOG_PROCESSING -eq 1 ]; then
rm $LOG
mv $TEST.log $LOG
exit
fi
if [ $LOGFILE -eq 1 ]; then
if [ $OK == 0 ]; then
echo "FAIL" >> $LOG
if [ -f "$TEST.info" ]; then
echo "-- TEST INFO ($TEST.info) --" >> $LOG
cat $TEST.info >> $LOG
else
echo "-- NO TEST INFO AVAILABLE ($TEST.info) --" >> $LOG
fi
if [ -f "$TEST.log" ]; then
echo "-- TEST OUTPUT (tail $TEST.log) --" >> $LOG
tail -5 $TEST.log >> $LOG
else
echo "-- NO TEST OUTPUT AVAILABLE ($TEST.log) --" >> $LOG
fi
echo "-- COOJA OUTPUT (tail $TEST.cooja_log) --" >> $LOG
tail -10 $TEST.cooja_log >> $LOG
else
echo "OK" >> $LOG
fi
echo >> $LOG
fi
if [ $OK == 0 ]; then
echo ">>>>>>> Finished test: $TEST FAILED <<<<<<<<"
echo ""
else
echo ">>>>>>> Finished test: $TEST OK <<<<<<<<"
fi