localhost-scope-control-test: /localhost scope control scenario
refs #1391
Change-Id: I5c437dd234f929bcb41d78a8b68f93cad171af42
diff --git a/test_localhost_scope/in-master.sh b/test_localhost_scope/in-master.sh
new file mode 100755
index 0000000..faca555
--- /dev/null
+++ b/test_localhost_scope/in-master.sh
@@ -0,0 +1,51 @@
+#!/usr/bin/env bash
+source ../multi-host.conf
+mkdir -p logs
+workdir=$(pwd)
+
+clean_up() {
+ r=$(mv $HOME/.ndn/client.conf.bk $HOME/.ndn/client.conf 2>&1)
+ r=$(killall socat 2>&1)
+ r=$(ssh $CTRL_B "killall ndn-traffic-server;\
+ sudo killall nfd" 2>&1)
+}
+
+# start nfd and ndn-traffic-server on hostB
+ssh $CTRL_B "mkdir -p $workdir/logs;\
+ sudo nfd &> $workdir/logs/nfd.log &\
+ sleep 2;\
+ ndn-traffic-server $workdir/NDNTrafficServer.conf &> $workdir/logs/server.log &"
+sleep 2
+
+# set up socat on A
+cp $HOME/.ndn/client.conf $HOME/.ndn/client.conf.bk
+socat -v UNIX-LISTEN:/tmp/localhost-test-B.sock,fork TCP:$IP4_B1:6363 &> logs/socat.log &
+sed -i 's/^unix_socket=.*$/unix_socket=\/tmp\/localhost-test-B.sock/g' $HOME/.ndn/client.conf
+sleep 1
+
+# send interest
+response=$(ndn-tlv-peek -p ndn:/localhost/test-in/A 2>&1)
+if [[ ! -z $response ]]
+then
+ echo "FAIL: Expected no data come back for ndn:/localhost/test-in/A, Actual: '$response'"
+ clean_up
+ exit 2
+fi
+
+# copy back the server log
+ssh $CTRL_B "killall ndn-traffic-server"
+scp $CTRL_B:$workdir/logs/server.log $workdir/logs/
+
+# analyze server log
+output=$(grep "Total Interests Received" $workdir/logs/server.log | head -1 | cut -d= -f2 | cut -d' ' -f2)
+if [[ $output != '0' ]]
+then
+ echo "Expected no Interests received on host B. Actual: $output"
+ echo "For more information, please examine the log at \"$(pwd)/logs\""
+ clean_up
+ exit 3
+fi
+
+clean_up
+
+echo "localhost incoming test PASSED"