1a65e0ea75
* 08-border-router-cooja-frag.sh was using 01-border-router-cooja.csc so if the test failed, the summary was wrongly indicating a failed 01-board-router-cooja test * same for 09-native-border-router-cooja-frag.sh which has now it's own cooja configuration * 05-native-ping was using 01-native-ping * homogenizes the mode : all scripts are 644 now
67 lines
1.6 KiB
Bash
Executable File
67 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
source ../utils.sh
|
|
|
|
# Contiki directory
|
|
CONTIKI=$1
|
|
|
|
# Simulation file
|
|
BASENAME=$2
|
|
|
|
# Destination IPv6
|
|
IPADDR=$3
|
|
|
|
# Time allocated for convergence
|
|
WAIT_TIME=$4
|
|
|
|
# Payload len. Default is ping6's default, 56.
|
|
PING_SIZE=${5:-56}
|
|
|
|
# Inter-ping delay. Default is ping6's default, 1s.
|
|
PING_DELAY=${6:-1}
|
|
|
|
# ICMP request-reply count
|
|
COUNT=5
|
|
|
|
# Start simulation
|
|
echo "Starting Cooja simulation $BASENAME.csc"
|
|
java -Xshare:on -jar $CONTIKI/tools/cooja/dist/cooja.jar -nogui=$BASENAME.csc -contiki=$CONTIKI > $BASENAME.coojalog &
|
|
JPID=$!
|
|
sleep 20
|
|
|
|
# Connect to the simulation
|
|
echo "Starting native border-router"
|
|
nohup make -C $CONTIKI/examples/rpl-border-router/ connect-router-cooja TARGET=native >> $BASENAME.nbr.log 2>&1 &
|
|
MPID=$!
|
|
printf "Waiting for network formation (%d seconds)\n" "$WAIT_TIME"
|
|
sleep $WAIT_TIME
|
|
|
|
# Do ping
|
|
echo "Pinging"
|
|
ping6 $IPADDR -c $COUNT -s $PING_SIZE -i $PING_DELAY | tee $BASENAME.scriptlog
|
|
# Fetch ping6 status code (not $? because this is piped)
|
|
STATUS=${PIPESTATUS[0]}
|
|
REPLIES=`grep -c 'icmp_seq=' $BASENAME.scriptlog`
|
|
|
|
echo "Closing simulation and nbr"
|
|
sleep 1
|
|
kill_bg $JPID
|
|
kill_bg $MPID
|
|
sleep 1
|
|
rm COOJA.testlog
|
|
rm COOJA.log
|
|
|
|
if [ $STATUS -eq 0 ] && [ $REPLIES -eq $COUNT ] ; then
|
|
printf "%-32s TEST OK\n" "$BASENAME" | tee $BASENAME.testlog;
|
|
else
|
|
echo "==== $BASENAME.coojalog ====" ; cat $BASENAME.coojalog;
|
|
echo "==== $BASENAME.nbr.log ====" ; cat $BASENAME.nbr.log;
|
|
echo "==== $BASENAME.scriptlog ====" ; cat $BASENAME.scriptlog;
|
|
|
|
printf "%-32s TEST FAIL\n" "$BASENAME" | tee $BASENAME.testlog;
|
|
fi
|
|
|
|
# We do not want Make to stop -> Return 0
|
|
# The Makefile will check if a log contains FAIL at the end
|
|
|
|
exit 0
|