nes-proj/tests/17-tun-rpl-br/06-native-coap.sh
Rehan MALAK 1a65e0ea75 fix some bugs in the RPL border tests
* 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
2018-08-13 13:54:19 +02:00

61 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
source ../utils.sh
# Contiki directory
CONTIKI=$1
# Test basename
BASENAME=$(basename $0 .sh)
IPADDR=fd00::302:304:506:708
declare -i OKCOUNT=0
declare -i TESTCOUNT=0
# Starting Contiki-NG native node
echo "Starting native CoAP server"
make -C $CONTIKI/examples/coap/coap-example-server > make.log 2> make.err
sudo $CONTIKI/examples/coap/coap-example-server/coap-example-server.native > node.log 2> node.err &
CPID=$!
sleep 2
# Send CoAP requests
echo "Sending CoAP requests"
rm -f $BASENAME.log
for TARGET in .well-known/core test/push; do
echo "Get $TARGET" | tee -a $BASENAME.log
coap get coap://[$IPADDR]/$TARGET 2>&1 | tee coap.log
cat coap.log >> $BASENAME.log
# Fetch coap status code (not $? because this is piped)
SUCCESS=`grep -c '(2.05)' coap.log`
if [ $SUCCESS == 1 ]; then
printf "> OK\n"
OKCOUNT+=1
else
printf "> FAIL\n"
fi
TESTCOUNT+=1
done
echo "Closing native node"
sleep 2
kill_bg $CPID
if [ $TESTCOUNT -eq $OKCOUNT ] ; then
printf "%-32s TEST OK %3d/%d\n" "$BASENAME" "$OKCOUNT" "$TESTCOUNT" | tee $BASENAME.testlog;
else
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;
printf "%-32s TEST FAIL %3d/%d\n" "$BASENAME" "$OKCOUNT" "$TESTCOUNT" | tee $BASENAME.testlog;
fi
rm -f make.log make.err node.log node.err coap.log
# We do not want Make to stop -> Return 0
# The Makefile will check if a log contains FAIL at the end
exit 0