2017-11-29 17:16:04 +00:00
|
|
|
#!/bin/bash
|
2018-05-19 15:50:10 +00:00
|
|
|
source ../utils.sh
|
2017-11-29 17:16:04 +00:00
|
|
|
|
|
|
|
# Contiki directory
|
|
|
|
CONTIKI=$1
|
|
|
|
# Test basename
|
2018-08-13 11:22:00 +00:00
|
|
|
BASENAME=$(basename $0 .sh)
|
2017-11-29 17:16:04 +00:00
|
|
|
|
|
|
|
IPADDR=fd00::302:304:506:708
|
|
|
|
|
|
|
|
declare -i OKCOUNT=0
|
|
|
|
declare -i TESTCOUNT=0
|
|
|
|
|
|
|
|
# Starting Contiki-NG native node
|
|
|
|
echo "Starting native CoAP server"
|
2018-04-13 16:14:52 +00:00
|
|
|
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 &
|
2017-11-29 17:16:04 +00:00
|
|
|
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
|
2018-05-19 15:50:10 +00:00
|
|
|
kill_bg $CPID
|
2017-11-29 17:16:04 +00:00
|
|
|
|
|
|
|
if [ $TESTCOUNT -eq $OKCOUNT ] ; then
|
2018-04-13 16:14:52 +00:00
|
|
|
printf "%-32s TEST OK %3d/%d\n" "$BASENAME" "$OKCOUNT" "$TESTCOUNT" | tee $BASENAME.testlog;
|
2017-11-29 17:16:04 +00:00
|
|
|
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;
|
|
|
|
|
2018-04-13 16:14:52 +00:00
|
|
|
printf "%-32s TEST FAIL %3d/%d\n" "$BASENAME" "$OKCOUNT" "$TESTCOUNT" | tee $BASENAME.testlog;
|
2017-11-29 17:16:04 +00:00
|
|
|
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
|