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