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