Eric Newberry | c22afde | 2018-06-19 01:28:31 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | source ../multi-host.conf |
| 3 | |
| 4 | clean_up() { |
| 5 | r=$(sudo killall ndnpingserver 2>&1) |
| 6 | r=$(sudo killall ndnping 2>&1) |
| 7 | r=$(sudo killall nfd 2>&1) |
| 8 | } |
| 9 | |
| 10 | # A: Start NFD |
| 11 | workdir=$(pwd) |
| 12 | echo "Starting nfd on A..." |
| 13 | mkdir -p $workdir/logs; sudo nfd &> $workdir/logs/nfd.log & |
| 14 | sleep 1 |
| 15 | |
| 16 | # A: Start ndnpingserver |
| 17 | echo "Starting ndnpingserver on A..." |
| 18 | ndnpingserver -p5 /test/ndnping &> $workdir/logs/ndnpingserver.log & |
| 19 | serverpid=$! |
| 20 | sleep 1 |
| 21 | |
| 22 | # A: Run ndnping |
| 23 | echo "Running ndnping on A..." |
| 24 | ndnping -c5 /test/ndnping |
| 25 | exitcode=$? |
| 26 | sleep 1 |
| 27 | |
| 28 | # An exit code of zero indicates the number of received Data packets equals the number of sent Interests |
| 29 | if [[ $exitcode -ne 0 ]]; then |
| 30 | echo "Received non-zero exit code from ndnping - actual: $exitcode" |
| 31 | clean_up |
| 32 | exit 1 |
| 33 | fi |
| 34 | |
| 35 | # Verify that ndnpingserver has exited |
| 36 | # ps -p returns 1 if no matching process is found |
| 37 | ps -p $serverpid > /dev/null |
| 38 | if [[ $? -ne 1 ]]; then |
| 39 | echo "ndnpingserver did not exit" |
| 40 | clean_up |
| 41 | exit 2 |
| 42 | fi |
| 43 | |
| 44 | clean_up |
| 45 | |
| 46 | nReceivedInterests=$(grep -c "interest received" $workdir/logs/ndnpingserver.log) |
| 47 | if [[ $nReceivedInterests -ne 5 ]]; then |
| 48 | echo "ndnpingserver did not receive 5 Interests - actual: $nReceivedInterests" |
| 49 | clean_up |
| 50 | exit 3 |
| 51 | fi |