| #!/usr/bin/env bash |
| clean_up() { |
| r=$(sudo killall nfd 2>&1) |
| } |
| mkdir -p logs |
| |
| # start nfd |
| echo "starting nfd..." |
| sudo nfd > logs/nfd.log 2>&1 & |
| sleep 10 |
| |
| # check fib before server starts |
| echo "checking fib before server starts..." |
| fib=$(nfd-status -b) |
| res=$(echo $fib | grep '/test-nrd/A' | wc -l) |
| if [[ $res -ne 0 ]] |
| then |
| echo "the name '/test-nrd/A' already exists" |
| clean_up |
| exit 1 |
| fi |
| res=$(echo $fib | grep '/test-nrd/B' | wc -l) |
| if [[ $res -ne 0 ]] |
| then |
| echo "the name '/test-nrd/B' already exists" |
| exit 2 |
| fi |
| |
| # start server |
| echo "starting server..." |
| ndn-traffic-server NDNTrafficServer.conf > logs/server.log 2>&1 & |
| sleep 3 |
| |
| # check fib after server starts |
| echo "checking fib after server starts..." |
| fib=$(nfd-status -b) |
| res=$(echo $fib | grep '/test-nrd/A' | wc -l) |
| if [[ $res -ne 1 ]] |
| then |
| echo "the name '/test-nrd/A' does not exists after ndn-traffic-server starts" |
| clean_up |
| exit 3 |
| fi |
| res=$(echo $fib | grep '/test-nrd/B' | wc -l) |
| if [[ $res -ne 1 ]] |
| then |
| echo "the name '/test-nrd/B' does not exists after ndn-traffic-server starts" |
| clean_up |
| exit 4 |
| fi |
| |
| # stop ndn-traffic-server |
| echo "stopping ndn-traffic-server..." |
| sudo killall ndn-traffic-server |
| sleep 3 |
| |
| # check fib after server stops |
| echo "checking fib after server stops..." |
| fib=$(nfd-status -b) |
| res=$(echo $fib | grep '/test-nrd/A' | wc -l) |
| if [[ $res -ne 0 ]] |
| then |
| echo "the name '/test-nrd/A' still exists after ndn-traffic-server exit" |
| clean_up |
| exit 5 |
| fi |
| res=$(echo $fib | grep '/test-nrd/B' | wc -l) |
| if [[ $res -ne 0 ]] |
| then |
| echo "the name '/test-nrd/B' still exists after ndn-traffic-server exit" |
| clean_up |
| exit 6 |
| fi |
| clean_up |
| echo "nrd test PASSED" |