nes-proj/tests/17-tun-rpl-br/05-native-ping.sh

49 lines
1.1 KiB
Bash
Raw Normal View History

2017-11-10 21:57:32 +00:00
#!/bin/bash
source ../utils.sh
2017-11-10 21:57:32 +00:00
# Contiki directory
CONTIKI=$1
# Test basename
BASENAME=$(basename $0 .sh)
2017-11-10 21:57:32 +00:00
IPADDR=fd00::302:304:506:708
# Starting Contiki-NG native node
echo "Starting native node"
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
kill_bg $CPID
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
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