Junxiao Shi | a59f207 | 2014-04-27 20:52:25 -0700 | [diff] [blame^] | 1 | #!/usr/bin/env bash |
| 2 | source ../multi-host.conf |
| 3 | mkdir -p logs |
| 4 | workdir=$(pwd) |
| 5 | |
| 6 | clean_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 |
| 14 | ssh $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 &" |
| 18 | sleep 2 |
| 19 | |
| 20 | # set up socat on A |
| 21 | cp $HOME/.ndn/client.conf $HOME/.ndn/client.conf.bk |
| 22 | socat -v UNIX-LISTEN:/tmp/localhost-test-B.sock,fork TCP:$IP4_B1:6363 &> logs/socat.log & |
| 23 | sed -i 's/^unix_socket=.*$/unix_socket=\/tmp\/localhost-test-B.sock/g' $HOME/.ndn/client.conf |
| 24 | sleep 1 |
| 25 | |
| 26 | # send interest |
| 27 | response=$(ndn-tlv-peek -p ndn:/localhost/test-in/A 2>&1) |
| 28 | if [[ ! -z $response ]] |
| 29 | then |
| 30 | echo "FAIL: Expected no data come back for ndn:/localhost/test-in/A, Actual: '$response'" |
| 31 | clean_up |
| 32 | exit 2 |
| 33 | fi |
| 34 | |
| 35 | # copy back the server log |
| 36 | ssh $CTRL_B "killall ndn-traffic-server" |
| 37 | scp $CTRL_B:$workdir/logs/server.log $workdir/logs/ |
| 38 | |
| 39 | # analyze server log |
| 40 | output=$(grep "Total Interests Received" $workdir/logs/server.log | head -1 | cut -d= -f2 | cut -d' ' -f2) |
| 41 | if [[ $output != '0' ]] |
| 42 | then |
| 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 |
| 47 | fi |
| 48 | |
| 49 | clean_up |
| 50 | |
| 51 | echo "localhost incoming test PASSED" |