2008-09-17 23:41:30 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2009-06-24 16:41:47 +02:00
|
|
|
if [ $# -lt 1 -o $# -gt 3 ]; then
|
|
|
|
echo "Usage: $0 <test> [logfile] [-keeplog]"
|
2008-09-17 23:41:30 +02:00
|
|
|
exit
|
|
|
|
fi
|
2009-06-24 16:41:47 +02:00
|
|
|
|
2008-09-17 23:41:30 +02:00
|
|
|
TEST=$1
|
2009-06-24 16:41:47 +02:00
|
|
|
|
2008-09-29 15:27:43 +02:00
|
|
|
LOGFILE=0
|
2009-06-24 16:41:47 +02:00
|
|
|
if [ $# -gt 1 ]; then
|
2008-09-29 15:27:43 +02:00
|
|
|
LOGFILE=1
|
|
|
|
LOG=$2
|
2009-06-24 16:41:47 +02:00
|
|
|
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
|
2008-09-29 15:27:43 +02:00
|
|
|
fi
|
2008-09-17 23:41:30 +02:00
|
|
|
|
|
|
|
echo ">>>>>>> Starting test: $TEST <<<<<<<<"
|
2008-09-29 15:27:43 +02:00
|
|
|
if [ $LOGFILE -eq 1 ]; then echo -n "[`date '+%F %T'`] $TEST: " >> $LOG; fi
|
2009-06-09 11:49:14 +02:00
|
|
|
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
|
2008-09-17 23:41:30 +02:00
|
|
|
if [ -f "COOJA.log" ]; then
|
|
|
|
mv COOJA.log $TEST.cooja_log
|
|
|
|
fi
|
2009-06-09 11:49:14 +02:00
|
|
|
if [ -f "COOJA.testlog" ]; then
|
|
|
|
mv COOJA.testlog $TEST.log
|
|
|
|
fi
|
2008-09-17 23:41:30 +02:00
|
|
|
|
2008-09-18 17:10:11 +02:00
|
|
|
OK=0
|
2008-09-17 23:41:30 +02:00
|
|
|
if [ -f "$TEST.log" ]; then
|
|
|
|
OK=`grep "TEST OK" $TEST.log | wc -l`
|
2008-09-18 17:10:11 +02:00
|
|
|
fi
|
2008-09-17 23:41:30 +02:00
|
|
|
|
2009-06-24 16:41:47 +02:00
|
|
|
if [ $NO_LOG_PROCESSING -eq 1 ]; then
|
|
|
|
rm $LOG
|
|
|
|
mv $TEST.log $LOG
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2008-09-29 15:27:43 +02:00
|
|
|
if [ $LOGFILE -eq 1 ]; then
|
|
|
|
if [ $OK == 0 ]; then
|
|
|
|
echo "FAIL" >> $LOG
|
|
|
|
if [ -f "$TEST.info" ]; then
|
2008-12-03 17:25:17 +01:00
|
|
|
echo "-- TEST INFO ($TEST.info) --" >> $LOG
|
2008-09-29 15:27:43 +02:00
|
|
|
cat $TEST.info >> $LOG
|
|
|
|
else
|
2008-12-03 17:25:17 +01:00
|
|
|
echo "-- NO TEST INFO AVAILABLE ($TEST.info) --" >> $LOG
|
2008-09-29 15:27:43 +02:00
|
|
|
fi
|
2008-12-03 17:25:17 +01:00
|
|
|
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
|
2009-06-09 11:49:14 +02:00
|
|
|
tail -10 $TEST.cooja_log >> $LOG
|
2008-09-17 23:41:30 +02:00
|
|
|
else
|
2008-09-29 15:27:43 +02:00
|
|
|
echo "OK" >> $LOG
|
2008-09-17 23:41:30 +02:00
|
|
|
fi
|
2008-09-26 16:34:49 +02:00
|
|
|
echo >> $LOG
|
2008-09-17 23:41:30 +02:00
|
|
|
fi
|
2008-09-18 12:22:25 +02:00
|
|
|
|
2008-09-29 15:27:43 +02:00
|
|
|
if [ $OK == 0 ]; then
|
|
|
|
echo ">>>>>>> Finished test: $TEST FAILED <<<<<<<<"
|
2009-06-24 16:41:47 +02:00
|
|
|
echo ""
|
2008-09-29 15:27:43 +02:00
|
|
|
else
|
|
|
|
echo ">>>>>>> Finished test: $TEST OK <<<<<<<<"
|
|
|
|
fi
|