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