2013-11-07 14:22:47 +00:00
|
|
|
#!/bin/bash
|
2014-10-08 07:22:37 +00:00
|
|
|
# The simulation to run
|
|
|
|
CSC=$1
|
|
|
|
shift
|
|
|
|
#Contiki directory
|
|
|
|
CONTIKI=$1
|
|
|
|
shift
|
|
|
|
#The basename of the experiment
|
|
|
|
BASENAME=$1
|
|
|
|
shift
|
2017-11-05 13:57:31 +00:00
|
|
|
#The basename of the experiment
|
|
|
|
RUNCOUNT=$1
|
|
|
|
shift
|
2013-11-07 14:22:47 +00:00
|
|
|
|
2017-11-05 13:57:31 +00:00
|
|
|
# Counts all tests run
|
|
|
|
declare -i TESTCOUNT=0
|
2013-11-07 14:22:47 +00:00
|
|
|
|
2017-11-05 13:57:31 +00:00
|
|
|
# Counts successfull tests
|
|
|
|
declare -i OKCOUNT=0
|
2013-11-07 14:22:47 +00:00
|
|
|
|
2017-11-05 13:57:31 +00:00
|
|
|
for (( SEED=1; SEED<=$RUNCOUNT; SEED++ )); do
|
|
|
|
echo -n "Running test $BASENAME with random Seed $SEED"
|
|
|
|
|
|
|
|
# run simulation
|
|
|
|
java -Xshare:on -jar $CONTIKI/tools/cooja/dist/cooja.jar -nogui=$CSC -contiki=$CONTIKI -random-seed=$SEED > $BASENAME.log &
|
2014-10-08 07:22:37 +00:00
|
|
|
JPID=$!
|
2013-11-07 14:22:47 +00:00
|
|
|
|
2014-10-08 07:22:37 +00:00
|
|
|
# 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
|
2017-11-05 13:57:31 +00:00
|
|
|
if [ $? -ne 0 ]
|
2014-10-08 07:22:37 +00:00
|
|
|
then
|
|
|
|
echo -n "."
|
|
|
|
cp $BASENAME.log $BASENAME.log.prog
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
rm $BASENAME.log.prog
|
|
|
|
|
2017-11-05 13:57:31 +00:00
|
|
|
# wait for end of simulation
|
2014-10-08 07:22:37 +00:00
|
|
|
wait $JPID
|
|
|
|
JRV=$?
|
|
|
|
|
2017-11-05 13:57:31 +00:00
|
|
|
TESTCOUNT+=1
|
2014-10-08 07:22:37 +00:00
|
|
|
if [ $JRV -eq 0 ] ; then
|
2017-11-05 13:57:31 +00:00
|
|
|
touch COOJA.testlog;
|
|
|
|
mv COOJA.testlog $BASENAME.testlog
|
|
|
|
OKCOUNT+=1
|
2014-10-08 07:22:37 +00:00
|
|
|
echo " OK"
|
2014-10-14 07:55:20 +00:00
|
|
|
else
|
2017-11-05 13:57:31 +00:00
|
|
|
# Verbose output when using CI
|
|
|
|
if [ "$CI" = "true" ]; then
|
|
|
|
echo "==== $BASENAME.log ====" ; cat $BASENAME.log;
|
|
|
|
echo "==== COOJA.testlog ====" ; cat COOJA.testlog;
|
|
|
|
echo "==== Files used for simulation (sha1sum) ===="
|
|
|
|
grep "Loading firmware from:" COOJA.log | cut -d " " -f 10 | uniq | xargs -r sha1sum
|
|
|
|
grep "Creating core communicator between Java class" COOJA.log | cut -d " " -f 17 | uniq | xargs -r sha1sum
|
|
|
|
else
|
|
|
|
tail -50 $BASENAME.log ;
|
|
|
|
fi;
|
|
|
|
|
|
|
|
mv COOJA.testlog $BASENAME.$SEED.faillog
|
|
|
|
echo " FAIL ಠ_ಠ" | tee -a $BASENAME.$SEED.faillog;
|
|
|
|
fi
|
2014-10-08 07:22:37 +00:00
|
|
|
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
2017-11-05 13:57:31 +00:00
|
|
|
echo "Test $BASENAME, successfull runs: $OKCOUNT/$TESTCOUNT"
|
2013-11-07 14:22:47 +00:00
|
|
|
|
2017-11-05 13:57:31 +00:00
|
|
|
if [ $TESTCOUNT -ne $OKCOUNT ] ; then
|
|
|
|
# At least one test failed
|
|
|
|
touch COOJA.testlog;
|
|
|
|
mv COOJA.testlog $BASENAME.testlog;
|
2013-11-07 14:22:47 +00:00
|
|
|
fi
|
|
|
|
|
2017-11-05 13:57:31 +00:00
|
|
|
# We do not want Make to stop -> Return 0
|
|
|
|
# The Makefile will check if a log contains FAIL at the end
|
|
|
|
exit 0
|