forked from contiki-os/contiki
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimexec.sh
executable file
·87 lines (64 loc) · 1.66 KB
/
simexec.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
# Do not return an error
RUNALL=$1
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
#set -x
while (( "$#" )); do
RANDOMSEED=$1
echo -n "Running test $BASENAME with random Seed $RANDOMSEED: "
java -Xshare:on -jar $CONTIKI/tools/cooja/dist/cooja.jar -nogui=$CSC -contiki=$CONTIKI -random-seed=$RANDOMSEED > $BASENAME.log &
JPID=$!
# 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
# In case of failure
#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.$RANDOMSEED.faillog
shift
done
#All seeds failed
echo " FAIL ಠ_ಠ" | tee -a $BASENAME.$RANDOMSEED.faillog;
# We do not want Make to stop -> Return 0
if [ "$RUNALL" = "true" ] ; then
touch COOJA.testlog;
mv COOJA.testlog $BASENAME.testlog;
exit 0
fi
exit 1