2017-11-29 21:44:41 +00:00
|
|
|
#!/bin/bash
|
2018-05-19 15:50:10 +00:00
|
|
|
source ../utils.sh
|
2017-11-29 21:44:41 +00:00
|
|
|
|
|
|
|
# Contiki directory
|
|
|
|
CONTIKI=$1
|
|
|
|
# Test basename
|
2018-04-06 16:22:53 +00:00
|
|
|
BASENAME=06-lwm2m-ipso-test
|
2017-11-29 21:44:41 +00:00
|
|
|
|
|
|
|
IPADDR=fd00::302:304:506:708
|
|
|
|
|
|
|
|
# Starting Contiki-NG native node
|
|
|
|
echo "Starting native node - lwm2m/ipso objects"
|
2018-04-07 16:21:54 +00:00
|
|
|
make -C $CONTIKI/examples/lwm2m-ipso-objects clean >/dev/null
|
|
|
|
make -C $CONTIKI/examples/lwm2m-ipso-objects > make.log 2> make.err
|
|
|
|
sudo $CONTIKI/examples/lwm2m-ipso-objects/example-ipso-objects.native > node.log 2> node.err &
|
2017-11-29 21:44:41 +00:00
|
|
|
CPID=$!
|
|
|
|
sleep 10
|
|
|
|
|
|
|
|
echo "Downloading leshan"
|
2018-05-29 16:49:58 +00:00
|
|
|
LESHAN_JAR=leshan-server-demo-1.0.0-SNAPSHOT-jar-with-dependencies.jar
|
|
|
|
wget -nc https://joakimeriksson.github.io/resources/$LESHAN_JAR
|
2017-11-29 21:44:41 +00:00
|
|
|
echo "Starting leshan server"
|
2018-05-29 16:49:58 +00:00
|
|
|
java -jar $LESHAN_JAR >leshan.log 2>leshan.err &
|
2017-11-29 21:44:41 +00:00
|
|
|
LESHID=$!
|
2018-04-06 16:22:53 +00:00
|
|
|
|
|
|
|
COUNTER=10
|
|
|
|
while [ $COUNTER -gt 0 ]; do
|
|
|
|
sleep 5
|
|
|
|
if grep -q 'OK' leshan.err ; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
let COUNTER-=1
|
|
|
|
done
|
2017-11-29 21:44:41 +00:00
|
|
|
|
|
|
|
echo "Closing native node"
|
|
|
|
sleep 1
|
2018-05-19 15:50:10 +00:00
|
|
|
kill_bg $CPID
|
2017-11-29 21:44:41 +00:00
|
|
|
|
|
|
|
echo "Closing leshan"
|
|
|
|
sleep 1
|
2018-05-19 15:50:10 +00:00
|
|
|
kill_bg $LESHID
|
2017-11-29 21:44:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
if grep -q 'OK' leshan.err ; then
|
|
|
|
cp leshan.err $BASENAME.testlog;
|
|
|
|
printf "%-32s TEST OK\n" "$BASENAME" | 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 "==== leshan.log ====" ; cat leshan.log;
|
|
|
|
echo "==== leshan.err ====" ; cat leshan.err;
|
|
|
|
echo "==== $BASENAME.log ====" ; cat $BASENAME.log;
|
|
|
|
|
|
|
|
printf "%-32s TEST FAIL\n" "$BASENAME" | tee $BASENAME.testlog;
|
|
|
|
fi
|
|
|
|
|
|
|
|
rm make.log
|
|
|
|
rm make.err
|
|
|
|
rm node.log
|
|
|
|
rm node.err
|
|
|
|
rm leshan.log
|
|
|
|
rm leshan.err
|
|
|
|
|
|
|
|
# We do not want Make to stop -> Return 0
|
|
|
|
# The Makefile will check if a log contains FAIL at the end
|
|
|
|
exit 0
|