2017-11-10 21:57:32 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Contiki directory
|
|
|
|
CONTIKI=$1
|
|
|
|
# Test basename
|
|
|
|
BASENAME=01-native-ping
|
|
|
|
|
|
|
|
IPADDR=fd00::302:304:506:708
|
|
|
|
|
2017-11-17 19:58:00 +00:00
|
|
|
echo "Enabling IPv6"
|
|
|
|
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0
|
|
|
|
|
2017-11-10 21:57:32 +00:00
|
|
|
# Starting Contiki-NG native node
|
|
|
|
echo "Starting native node"
|
2017-11-17 19:38:33 +00:00
|
|
|
make -C $CONTIKI/examples/hello-world > make.log 2> make.err
|
2017-11-10 21:57:32 +00:00
|
|
|
sudo $CONTIKI/examples/hello-world/hello-world.native > node.log 2> node.err &
|
|
|
|
CPID=$!
|
|
|
|
sleep 2
|
|
|
|
|
|
|
|
# Do ping
|
|
|
|
echo "Pinging"
|
|
|
|
ping6 $IPADDR -c 5 | tee $BASENAME.log
|
|
|
|
# Fetch ping6 status code (not $? because this is piped)
|
|
|
|
STATUS=${PIPESTATUS[0]}
|
|
|
|
|
|
|
|
echo "Closing native node"
|
|
|
|
sleep 2
|
2017-11-17 15:56:01 +00:00
|
|
|
pgrep hello-world | sudo xargs kill -9
|
2017-11-10 21:57:32 +00:00
|
|
|
|
|
|
|
if [ $STATUS -eq 0 ] ; then
|
2017-11-11 14:05:27 +00:00
|
|
|
cp $BASENAME.log $BASENAME.testlog
|
2017-11-17 22:24:28 +00:00
|
|
|
printf "%-32s TEST OK\n" "$BASENAME" | tee $BASENAME.testlog;
|
2017-11-10 21:57:32 +00:00
|
|
|
else
|
2017-11-17 22:24:28 +00:00
|
|
|
echo "==== make.log ====" ; cat make.log;
|
|
|
|
echo "==== make.err ====" ; cat make.err;
|
|
|
|
echo "==== node.log ====" ; cat node.log;
|
|
|
|
echo "==== node.err ====" ; cat node.err;
|
|
|
|
echo "==== $BASENAME.log ====" ; cat $BASENAME.log;
|
2017-11-10 21:57:32 +00:00
|
|
|
|
2017-11-17 22:24:28 +00:00
|
|
|
printf "%-32s TEST FAIL\n" "$BASENAME" | tee $BASENAME.testlog;
|
2017-11-10 21:57:32 +00:00
|
|
|
fi
|
|
|
|
|
2017-11-17 19:38:33 +00:00
|
|
|
rm make.log
|
|
|
|
rm make.err
|
2017-11-17 15:56:01 +00:00
|
|
|
rm node.log
|
|
|
|
rm node.err
|
|
|
|
|
2017-11-10 21:57:32 +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
|