Yi Huang | 2d9ec55 | 2014-04-26 03:41:26 -0700 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | clean_up() { |
| 3 | r=$(sudo killall nfd 2>&1) |
Yi Huang | 2d9ec55 | 2014-04-26 03:41:26 -0700 | [diff] [blame] | 4 | } |
| 5 | mkdir -p logs |
| 6 | |
Eric Newberry | b856c77 | 2015-06-16 22:08:38 -0700 | [diff] [blame] | 7 | # start nfd |
| 8 | echo "starting nfd..." |
Yi Huang | 2d9ec55 | 2014-04-26 03:41:26 -0700 | [diff] [blame] | 9 | sudo nfd > logs/nfd.log 2>&1 & |
Yi Huang | 2d9ec55 | 2014-04-26 03:41:26 -0700 | [diff] [blame] | 10 | sleep 10 |
| 11 | |
| 12 | # check fib before server starts |
| 13 | echo "checking fib before server starts..." |
| 14 | fib=$(nfd-status -b) |
| 15 | res=$(echo $fib | grep '/test-nrd/A' | wc -l) |
| 16 | if [[ $res -ne 0 ]] |
| 17 | then |
| 18 | echo "the name '/test-nrd/A' already exists" |
| 19 | clean_up |
| 20 | exit 1 |
| 21 | fi |
| 22 | res=$(echo $fib | grep '/test-nrd/B' | wc -l) |
| 23 | if [[ $res -ne 0 ]] |
| 24 | then |
| 25 | echo "the name '/test-nrd/B' already exists" |
| 26 | exit 2 |
| 27 | fi |
| 28 | |
| 29 | # start server |
| 30 | echo "starting server..." |
| 31 | ndn-traffic-server NDNTrafficServer.conf > logs/server.log 2>&1 & |
| 32 | sleep 3 |
| 33 | |
| 34 | # check fib after server starts |
| 35 | echo "checking fib after server starts..." |
| 36 | fib=$(nfd-status -b) |
| 37 | res=$(echo $fib | grep '/test-nrd/A' | wc -l) |
| 38 | if [[ $res -ne 1 ]] |
| 39 | then |
| 40 | echo "the name '/test-nrd/A' does not exists after ndn-traffic-server starts" |
| 41 | clean_up |
| 42 | exit 3 |
| 43 | fi |
| 44 | res=$(echo $fib | grep '/test-nrd/B' | wc -l) |
| 45 | if [[ $res -ne 1 ]] |
| 46 | then |
| 47 | echo "the name '/test-nrd/B' does not exists after ndn-traffic-server starts" |
| 48 | clean_up |
| 49 | exit 4 |
| 50 | fi |
| 51 | |
| 52 | # stop ndn-traffic-server |
| 53 | echo "stopping ndn-traffic-server..." |
| 54 | sudo killall ndn-traffic-server |
| 55 | sleep 3 |
| 56 | |
| 57 | # check fib after server stops |
| 58 | echo "checking fib after server stops..." |
| 59 | fib=$(nfd-status -b) |
| 60 | res=$(echo $fib | grep '/test-nrd/A' | wc -l) |
| 61 | if [[ $res -ne 0 ]] |
| 62 | then |
| 63 | echo "the name '/test-nrd/A' still exists after ndn-traffic-server exit" |
| 64 | clean_up |
| 65 | exit 5 |
| 66 | fi |
| 67 | res=$(echo $fib | grep '/test-nrd/B' | wc -l) |
| 68 | if [[ $res -ne 0 ]] |
| 69 | then |
| 70 | echo "the name '/test-nrd/B' still exists after ndn-traffic-server exit" |
| 71 | clean_up |
| 72 | exit 6 |
| 73 | fi |
| 74 | clean_up |
| 75 | echo "nrd test PASSED" |