blob: faca5559dc943abf865408c5f111e79406dffddc [file] [log] [blame]
Junxiao Shia59f2072014-04-27 20:52:25 -07001#!/usr/bin/env bash
2source ../multi-host.conf
3mkdir -p logs
4workdir=$(pwd)
5
6clean_up() {
7 r=$(mv $HOME/.ndn/client.conf.bk $HOME/.ndn/client.conf 2>&1)
8 r=$(killall socat 2>&1)
9 r=$(ssh $CTRL_B "killall ndn-traffic-server;\
10 sudo killall nfd" 2>&1)
11}
12
13# start nfd and ndn-traffic-server on hostB
14ssh $CTRL_B "mkdir -p $workdir/logs;\
15 sudo nfd &> $workdir/logs/nfd.log &\
16 sleep 2;\
17 ndn-traffic-server $workdir/NDNTrafficServer.conf &> $workdir/logs/server.log &"
18sleep 2
19
20# set up socat on A
21cp $HOME/.ndn/client.conf $HOME/.ndn/client.conf.bk
22socat -v UNIX-LISTEN:/tmp/localhost-test-B.sock,fork TCP:$IP4_B1:6363 &> logs/socat.log &
23sed -i 's/^unix_socket=.*$/unix_socket=\/tmp\/localhost-test-B.sock/g' $HOME/.ndn/client.conf
24sleep 1
25
26# send interest
27response=$(ndn-tlv-peek -p ndn:/localhost/test-in/A 2>&1)
28if [[ ! -z $response ]]
29then
30 echo "FAIL: Expected no data come back for ndn:/localhost/test-in/A, Actual: '$response'"
31 clean_up
32 exit 2
33fi
34
35# copy back the server log
36ssh $CTRL_B "killall ndn-traffic-server"
37scp $CTRL_B:$workdir/logs/server.log $workdir/logs/
38
39# analyze server log
40output=$(grep "Total Interests Received" $workdir/logs/server.log | head -1 | cut -d= -f2 | cut -d' ' -f2)
41if [[ $output != '0' ]]
42then
43 echo "Expected no Interests received on host B. Actual: $output"
44 echo "For more information, please examine the log at \"$(pwd)/logs\""
45 clean_up
46 exit 3
47fi
48
49clean_up
50
51echo "localhost incoming test PASSED"