2013-11-07 15:22:47 +01:00
|
|
|
#!/bin/bash
|
2014-10-08 09:22:37 +02:00
|
|
|
# Do not return an error
|
2013-11-07 15:22:47 +01:00
|
|
|
RUNALL=$1
|
2014-10-08 09:22:37 +02:00
|
|
|
shift
|
|
|
|
# The simulation to run
|
|
|
|
CSC=$1
|
|
|
|
shift
|
|
|
|
#Contiki directory
|
|
|
|
CONTIKI=$1
|
|
|
|
shift
|
|
|
|
#The basename of the experiment
|
|
|
|
BASENAME=$1
|
|
|
|
shift
|
|
|
|
# The test will end on the first successfull run
|
2013-11-07 15:22:47 +01:00
|
|
|
|
|
|
|
#set -x
|
|
|
|
|
2014-10-08 09:22:37 +02:00
|
|
|
while (( "$#" )); do
|
|
|
|
RANDOMSEED=$1
|
|
|
|
echo -n "Running test $BASENAME with random Seed $RANDOMSEED: "
|
2013-11-07 15:22:47 +01:00
|
|
|
|
2014-10-08 09:22:37 +02:00
|
|
|
java -Xshare:on -jar $CONTIKI/tools/cooja/dist/cooja.jar -nogui=$CSC -contiki=$CONTIKI -random-seed=$RANDOMSEED > $BASENAME.log &
|
|
|
|
JPID=$!
|
2013-11-07 15:22:47 +01:00
|
|
|
|
2014-10-08 09:22:37 +02: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
|
|
|
|
if [ $? -ne 0 ]
|
|
|
|
then
|
|
|
|
echo -n "."
|
|
|
|
cp $BASENAME.log $BASENAME.log.prog
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
rm $BASENAME.log.prog
|
|
|
|
|
|
|
|
|
|
|
|
wait $JPID
|
|
|
|
JRV=$?
|
|
|
|
|
|
|
|
if [ $JRV -eq 0 ] ; then
|
|
|
|
touch COOJA.testlog;
|
|
|
|
mv COOJA.testlog $BASENAME.testlog
|
|
|
|
echo " OK"
|
|
|
|
exit 0
|
|
|
|
fi
|
2013-11-07 15:22:47 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2014-10-08 09:22:37 +02:00
|
|
|
# In case of failure
|
2013-11-07 15:22:47 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2014-10-08 09:22:37 +02:00
|
|
|
#Verbose output when using CI
|
2014-10-14 09:55:20 +02:00
|
|
|
if [ "$CI" = "true" ]; then
|
|
|
|
echo "==== COOJA.log ====" ; cat COOJA.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 COOJA.log ;
|
|
|
|
fi;
|
2013-11-07 15:22:47 +01:00
|
|
|
|
2014-10-08 09:22:37 +02:00
|
|
|
mv COOJA.testlog $BASENAME.$RANDOMSEED.faillog
|
|
|
|
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
#All seeds failed
|
|
|
|
echo " FAIL ಠ_ಠ" | tee -a $BASENAME.$RANDOMSEED.faillog;
|
2013-11-07 15:22:47 +01:00
|
|
|
|
|
|
|
# We do not want Make to stop -> Return 0
|
|
|
|
if [ "$RUNALL" = "true" ] ; then
|
2014-10-08 09:22:37 +02:00
|
|
|
touch COOJA.testlog;
|
|
|
|
mv COOJA.testlog $BASENAME.testlog;
|
|
|
|
exit 0
|
2013-11-07 15:22:47 +01:00
|
|
|
fi
|
|
|
|
|
2014-10-08 09:22:37 +02:00
|
|
|
|
2013-11-07 15:22:47 +01:00
|
|
|
exit 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|