multicast-test: multicast scenario
Refs: #1390
Change-Id: I28c713e1511618c3b708342227e858cfb0dfc08e
diff --git a/test_multicast/multicast-test.sh b/test_multicast/multicast-test.sh
new file mode 100755
index 0000000..b5a349f
--- /dev/null
+++ b/test_multicast/multicast-test.sh
@@ -0,0 +1,71 @@
+#!/bin/bash
+source ../multi-host.conf
+if [[ $1 = "udp" ]]
+then
+ a_ipaddr=$IP4_A1
+else
+ a_ipaddr=$(ip addr show to $IP4_A1 | head -1 | cut -d: -f2 | cut -d' ' -f2)
+fi
+mkdir -p logs
+workdir=$(pwd)
+
+clean_up() {
+ r=$(ssh $CTRL_B "sudo killall nfd" 2>&1)
+ r=$(ssh $CTRL_C "sudo killall nfd" 2>&1)
+ r=$(sudo killall nfd 2>&1)
+}
+
+# start nfd and ndn-traffic-server on B and C
+ssh $CTRL_B "mkdir -p $workdir/logs;\
+ sudo nfd &> $workdir/logs/nfd.log &\
+ sleep 3;\
+ ndn-traffic-server $workdir/NDNTrafficServerB.conf &> $workdir/logs/server.log &"
+ssh $CTRL_C "mkdir -p $workdir/logs;\
+ sudo nfd &> $workdir/logs/nfd.log &\
+ sleep 3;\
+ ndn-traffic-server $workdir/NDNTrafficServerC.conf &> $workdir/logs/server.log &"
+
+# start nfd and add nexthop of ndn:/test-mcast to UDP multicast face
+sudo nfd &> $workdir/logs/nfd.log &
+sleep 3
+faceid=$(nfd-status -f | grep $a_ipaddr | grep -Po 'faceid=.*? ' | sed 's/faceid=//' | sed 's/ //')
+nfdc add-nexthop ndn:/test-mcast $faceid
+
+# use ndn-tlv-peek to test multicast feature
+response=$(ndn-tlv-peek -p ndn:/test-mcast/B/1)
+if [[ $response != 'BBBBBBBB' ]]
+then
+ echo "FAIL: Expected data for ndn:/test-mcast/B/1 is: 'BBBBBBBB', Actual: '$response'"
+ clean_up
+ exit 1
+fi
+response=$(ndn-tlv-peek -p ndn:/test-mcast/C/1)
+if [[ $response != 'CCCCCCCC' ]]
+then
+ echo "FAIL: Expected data for ndn:/test-mcast/C/1 is: 'CCCCCCCC', Actual: '$response'"
+ clean_up
+ exit 2
+fi
+response=$(ndn-tlv-peek -p ndn:/test-mcast/Z/1)
+if [[ ( $response != 'ZZZZZZZB' ) && ( $response != 'ZZZZZZZC' ) ]]
+then
+ echo "FAIL: Expected data for ndn:/test-mcast/Z/1 is: 'ZZZZZZZB' or 'ZZZZZZZC', Actual: '$response'"
+ clean_up
+ exit 3
+fi
+
+# kill ndn-traffic-server on host B
+ssh $CTRL_B "sudo killall ndn-traffic-server"
+
+# use ndn-tlv-peek to request ndn:/testmcast/Z/2
+response=$(ndn-tlv-peek -p ndn:/test-mcast/Z/2)
+if [[ $response != 'ZZZZZZZC' ]]
+then
+ echo "FAIL: Expected data for ndn:/test-mcast/Z/2 is: 'ZZZZZZZC', Actual: '$response'"
+ clean_up
+ exit 4
+fi
+
+# clean up
+clean_up
+echo "Multicast Test PASSED"