nes-proj/tests/17-rpl-border-router/test-border-router.sh

59 lines
1.5 KiB
Bash
Raw Normal View History

#!/bin/bash
# Contiki directory
CONTIKI=$1
# Simulation file
BASENAME=$2
# Destination IPv6
IPADDR=$3
# Start simulation
echo "Starting Cooja simulation $BASENAME.csc"
2017-11-11 14:05:27 +00:00
java -Xshare:on -jar $CONTIKI/tools/cooja/dist/cooja.jar -nogui=$BASENAME.csc -contiki=$CONTIKI > $BASENAME.coojalog &
JPID=$!
sleep 20
# Connect to the simlation
echo "Starting tunslip6"
make -C $CONTIKI/tools tunslip6
2017-11-11 14:05:27 +00:00
make -C $CONTIKI/examples/rpl-border-router/ connect-router-cooja TARGET=zoul >> $BASENAME.tunsliplog 2>&1 &
MPID=$!
echo "Waiting for network formation"
sleep 5
# Do ping
echo "Pinging"
2017-11-11 14:05:27 +00:00
ping6 $IPADDR -c 5 | tee $BASENAME.scriptlog
# Fetch ping6 status code (not $? because this is piped)
STATUS=${PIPESTATUS[0]}
echo "Closing simulation and tunslip6"
2017-11-11 14:05:27 +00:00
sleep 1
kill -9 $JPID
kill -9 $MPID
2017-11-11 14:05:27 +00:00
sleep 1
rm COOJA.testlog
rm COOJA.log
if [ $STATUS -eq 0 ] ; then
2017-11-14 09:00:15 +00:00
printf "%-32s TEST OK\n" "$BASENAME" | tee $BASENAME.testlog;
else
2017-11-11 14:05:27 +00:00
# Verbose output when using CI
if [ "$CI" = "true" ]; then
echo "==== $BASENAME.coojalog ====" ; cat $BASENAME.coojalog;
echo "==== $BASENAME.tunsliplog ====" ; cat $BASENAME.tunsliplog;
echo "==== $BASENAME.scriptlog ====" ; cat $BASENAME.scriptlog;
else
echo "==== Check $BASENAME.coojalog, $BASENAME.tunsliplog, and $BASENAME.scriptlog for details ====";
fi;
2017-11-14 09:00:15 +00:00
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