Fix install_all issue and failing test cases that fail after NRD becomes part of NFD.

Change-Id: Ic254244be99e289f43af86ecf6c82aad8460c538
Refs: #1641
diff --git a/install_helpers/install_NFD.py b/install_helpers/install_NFD.py
index 171b2e6..cf70d03 100644
--- a/install_helpers/install_NFD.py
+++ b/install_helpers/install_NFD.py
@@ -8,6 +8,7 @@
     os.system("git clone https://github.com/named-data/NFD --depth 1")
     os.chdir("NFD")
     os.system("./waf distclean")
+    os.system("git submodule init && git submodule update")
     os.system("./waf configure")
     os.system("./waf -j1")
     os.system("sudo ./waf install")
diff --git a/install_helpers/install_ndncxx.py b/install_helpers/install_ndncxx.py
index 87ef0ff..d5d6fa0 100644
--- a/install_helpers/install_ndncxx.py
+++ b/install_helpers/install_ndncxx.py
@@ -12,6 +12,4 @@
     os.system("./waf -j1")
     os.system("sudo ./waf install")
     os.system("mkdir -p ~/.ndn")
-    os.system("cp client.conf.sample ~/.ndn/client.conf")
-    os.system("sed -i 's/^protocol=.*$/protocol=nfd-0.1/g' ~/.ndn/client.conf")
     os.chdir("..")
diff --git a/library_helpers/process_manager.py b/library_helpers/process_manager.py
index ac53b0f..10cd076 100644
--- a/library_helpers/process_manager.py
+++ b/library_helpers/process_manager.py
@@ -110,3 +110,6 @@
     def killNfd(self):
         self.killProcess("nfd")
         time.sleep(2)
+
+    def startNrd(self):
+        self.startProcess("nrd", ["nrd"], "-> Starting NRD")
diff --git a/test_broadcast/broadcast-test.sh b/test_broadcast/broadcast-test.sh
index 9cbc763..8d29fd3 100755
--- a/test_broadcast/broadcast-test.sh
+++ b/test_broadcast/broadcast-test.sh
@@ -14,12 +14,23 @@
 # start nfd on all hosts
 echo "starting nfd on all hosts..."
 ssh $CTRL_B "mkdir -p $workdir/logs;\
-    sudo nfd &> $workdir/logs/nfd.log &"
+    sudo nfd &> $workdir/logs/nfd.log &\
+    sleep 3;\
+    nrd &> $workdir/logs/nrd.log &\
+    sleep 3"
 ssh $CTRL_C "mkdir -p $workdir/logs;\
-    sudo nfd &> $workdir/logs/nfd.log &"
+    sudo nfd &> $workdir/logs/nfd.log &\
+    sleep 3;\
+    nrd &> $workdir/logs/nrd.log &\
+    sleep 3"
 ssh $CTRL_D "mkdir -p $workdir/logs;\
-    sudo nfd &> $workdir/logs/nfd.log &"
+    sudo nfd &> $workdir/logs/nfd.log &\
+    sleep 3;\
+    nrd &> $workdir/logs/nrd.log &\
+    sleep 3"
 sudo nfd &> $workdir/logs/nfd.log &
+sleep 3
+nrd &> $workdir/logs/nrd.log &
 sleep 5
 
 # start ndn-traffic-server on B and C
diff --git a/test_cs_freshness/cs-freshness-test.sh b/test_cs_freshness/cs-freshness-test.sh
index f1be323..8a6b6d3 100755
--- a/test_cs_freshness/cs-freshness-test.sh
+++ b/test_cs_freshness/cs-freshness-test.sh
@@ -7,8 +7,10 @@
 }
 
 # Start NFD.
-sudo nfd > logs/nfd.log 2>&1 &
-sleep 1
+sudo nfd &> logs/nfd.log &
+sleep 2
+nrd &> logs/nrd.log &
+sleep 2
 
 # Start ndn-traffic-server to serve `ndn:/test-caching`, FreshnessPeriod=2800ms
 ndn-traffic-server NDNTrafficServer.conf > logs/server.log 2>&1 &
diff --git a/test_fib_matching/test_fib_matching.py b/test_fib_matching/test_fib_matching.py
index 0570f64..34ee731 100644
--- a/test_fib_matching/test_fib_matching.py
+++ b/test_fib_matching/test_fib_matching.py
@@ -54,6 +54,8 @@
         #Start NFD
         self.startNfd()
         time.sleep(1)
+        self.startNrd()
+        time.sleep(1)
 
         #Start ndn-traffic-server to serve ndn:/ with Content "Z", FreshnessPeriod=10ms
         #Prefix registration using NFD FibMgmt
diff --git a/test_interest_aggregation/test_interest_aggregation.py b/test_interest_aggregation/test_interest_aggregation.py
index d1b4482..b52c0b9 100644
--- a/test_interest_aggregation/test_interest_aggregation.py
+++ b/test_interest_aggregation/test_interest_aggregation.py
@@ -69,6 +69,8 @@
         #Start NFD
         self.startNfd()
         time.sleep(1)
+        self.startNrd()
+        time.sleep(1)
 
         #Start ndn-traffic-server to serve ndn:/test-agg, with content delay set to 2000ms
         serverConfigurationFile = os.path.abspath(
diff --git a/test_interest_loop/interest-loop-test.sh b/test_interest_loop/interest-loop-test.sh
index 0cc616e..f917a06 100755
--- a/test_interest_loop/interest-loop-test.sh
+++ b/test_interest_loop/interest-loop-test.sh
@@ -27,10 +27,18 @@
 # start NFD on three nodes and set nexthop to create loop
 echo "start NFD on three nodes and set nexthop to create loop..."
 ssh $CTRL_B "mkdir -p $workdir/logs;\
-    sudo nfd --config $workdir/nfd.conf > $workdir/logs/nfd.log 2>&1 &"
+    sudo nfd --config $workdir/nfd.conf &> $workdir/logs/nfd.log &\
+    sleep 2;\
+    nrd --config $workdir/nfd.conf &> $workdir/logs/nrd.log &\
+    sleep 2"
 ssh $CTRL_C "mkdir -p $workdir/logs;\
-    sudo nfd --config $workdir/nfd.conf > $workdir/logs/nfd.log 2>&1 &"
-sudo nfd --config $workdir/nfd.conf > $workdir/logs/nfd.log 2>&1 &
+    sudo nfd --config $workdir/nfd.conf &> $workdir/logs/nfd.log &\
+    sleep 2;\
+    nrd --config $workdir/nfd.conf &> $workdir/logs/nrd.log &\
+    sleep 2"
+sudo nfd --config $workdir/nfd.conf &> $workdir/logs/nfd.log &
+sleep 2
+nrd --config $workdir/nfd.conf &> $workdir/logs/nrd.log &
 sleep 5
 ssh $CTRL_B "$workdir/add-nexthop.sh $c_ipaddr $strategy"
 ssh $CTRL_C "$workdir/add-nexthop.sh $a_ipaddr $strategy"
diff --git a/test_localhop/hostB.sh b/test_localhop/hostB.sh
index 03710e8..f513915 100755
--- a/test_localhop/hostB.sh
+++ b/test_localhop/hostB.sh
@@ -1,7 +1,9 @@
 #!/bin/bash
 workdir=$1
 c_ipaddr=$2
-sudo nfd > $workdir/logs/nfd.log 2>&1 &
+sudo nfd &> $workdir/logs/nfd.log &
+sleep 3
+nrd &> $workdir/logs/nrd.log &
 sleep 3
 faceid=$(nfdc create udp4://$c_ipaddr | grep -Po 'FaceId: .*?,' | sed 's/FaceId: //' | sed 's/,//')
 nfdc add-nexthop ndn:/localhop $faceid
diff --git a/test_localhop/localhop-test.sh b/test_localhop/localhop-test.sh
index 15bcbd3..2289722 100755
--- a/test_localhop/localhop-test.sh
+++ b/test_localhop/localhop-test.sh
@@ -19,6 +19,8 @@
 ssh $CTRL_C "mkdir -p $workdir/logs;\
     sudo nfd > $workdir/logs/nfd.log 2>&1 &\
     sleep 3;\
+    nrd > $workdir/logs/nrd.log 2>&1 &\
+    sleep 3;\
     ndn-traffic-server $workdir/NDNTrafficServer.conf > $workdir/logs/server.log 2>&1 &"
 
 # start nfd and add nexthop of ndn:/localhop to C on host B
@@ -30,6 +32,8 @@
 echo "starting nfd and adding nexthop of ndn:/localhop to B on host A..."
 sudo nfd > logs/nfd.log 2>&1 &
 sleep 3
+nrd > logs/nrd.log 2>&1 &
+sleep 3
 faceid=$(nfdc create udp4://$b_ipaddr | grep -Po 'FaceId: .*?,' | sed 's/FaceId: //' | sed 's/,//')
 nfdc add-nexthop ndn:/localhop $faceid
 if [[ $? -ne 0 ]]
diff --git a/test_localhost_scope/in-master.sh b/test_localhost_scope/in-master.sh
index faca555..4ddd489 100755
--- a/test_localhost_scope/in-master.sh
+++ b/test_localhost_scope/in-master.sh
@@ -4,7 +4,7 @@
 workdir=$(pwd)
 
 clean_up() {
-    r=$(mv $HOME/.ndn/client.conf.bk $HOME/.ndn/client.conf 2>&1)
+    r=$(rm $HOME/.ndn/client.conf 2>&1)
     r=$(killall socat 2>&1)
     r=$(ssh $CTRL_B "killall ndn-traffic-server;\
         sudo killall nfd" 2>&1)
@@ -14,13 +14,14 @@
 ssh $CTRL_B "mkdir -p $workdir/logs;\
     sudo nfd &> $workdir/logs/nfd.log &\
     sleep 2;\
+    nrd &> $workdir/logs/nrd.log &\
+    sleep 2;\
     ndn-traffic-server $workdir/NDNTrafficServer.conf &> $workdir/logs/server.log &"
 sleep 2
 
 # set up socat on A
-cp $HOME/.ndn/client.conf $HOME/.ndn/client.conf.bk
 socat -v UNIX-LISTEN:/tmp/localhost-test-B.sock,fork TCP:$IP4_B1:6363 &> logs/socat.log &
-sed -i 's/^unix_socket=.*$/unix_socket=\/tmp\/localhost-test-B.sock/g' $HOME/.ndn/client.conf
+echo "unix_socket=/tmp/localhost-test-B.sock" > $HOME/.ndn/client.conf
 sleep 1
 
 # send interest
diff --git a/test_localhost_scope/out-master.sh b/test_localhost_scope/out-master.sh
index 5c3c149..f75cc78 100755
--- a/test_localhost_scope/out-master.sh
+++ b/test_localhost_scope/out-master.sh
@@ -9,7 +9,10 @@
 }
 
 # start NFD on B
-ssh $CTRL_B "sudo nfd > $workdir/logs/nfd.log 2>&1 &"
+ssh $CTRL_B "sudo nfd > $workdir/logs/nfd.log 2>&1 &\
+    sleep 2;\
+    nrd &> $workdir/logs/nrd.log &\
+    sleep 2"
 
 # start netcat on A
 nc -vul 6363 > $workdir/logs/netcat.log 2>&1 &
diff --git a/test_multicast/multicast-test.sh b/test_multicast/multicast-test.sh
index b5a349f..3a2ca00 100755
--- a/test_multicast/multicast-test.sh
+++ b/test_multicast/multicast-test.sh
@@ -19,15 +19,21 @@
 ssh $CTRL_B "mkdir -p $workdir/logs;\
     sudo nfd &> $workdir/logs/nfd.log &\
     sleep 3;\
+    nrd &> $workdir/logs/nrd.log &\
+    sleep 3;\
     ndn-traffic-server $workdir/NDNTrafficServerB.conf &> $workdir/logs/server.log &"
 ssh $CTRL_C "mkdir -p $workdir/logs;\
     sudo nfd &> $workdir/logs/nfd.log &\
     sleep 3;\
+    nrd &> $workdir/logs/nrd.log &\
+    sleep 3;\
     ndn-traffic-server $workdir/NDNTrafficServerC.conf &> $workdir/logs/server.log &"
 
 # start nfd and add nexthop of ndn:/test-mcast to UDP multicast face
 sudo nfd &> $workdir/logs/nfd.log &
 sleep 3
+nrd &> $workdir/logs/nrd.log &
+sleep 3
 faceid=$(nfd-status -f | grep $a_ipaddr | grep -Po 'faceid=.*? ' | sed 's/faceid=//' | sed 's/ //')
 nfdc add-nexthop ndn:/test-mcast $faceid
 
diff --git a/test_ndnpeekpoke/test_ndnpeekpoke.py b/test_ndnpeekpoke/test_ndnpeekpoke.py
index 8e38c78..e49adba 100644
--- a/test_ndnpeekpoke/test_ndnpeekpoke.py
+++ b/test_ndnpeekpoke/test_ndnpeekpoke.py
@@ -29,6 +29,8 @@
     def test_peekpoke(self):
         self.startNfd()
         time.sleep(1)
+        self.startNrd()
+        time.sleep(1)
         pokeInputFile = os.path.abspath("test_ndnpeekpoke/test-poke-input.txt")
         self.startProcess("ndn-tlv-poke",
             ["ndn-tlv-poke", "ndn:/test/peekpoke"],
diff --git a/test_ndntlvping/test_ndntlvping.py b/test_ndntlvping/test_ndntlvping.py
index 8cc3c4d..cafae09 100644
--- a/test_ndntlvping/test_ndntlvping.py
+++ b/test_ndntlvping/test_ndntlvping.py
@@ -26,6 +26,8 @@
     def test_ping(self):
         self.startNfd()
         time.sleep(1)
+        self.startNrd()
+        time.sleep(1)
         self.startProcess("ndnpingserver",
             ["ndnpingserver", "-p 1", "/test/ndntlvping"], "-> Starting Ping Server")
         time.sleep(1)
diff --git a/test_ndntraffic/test_ndntraffic.py b/test_ndntraffic/test_ndntraffic.py
index 632c4fe..a83e450 100644
--- a/test_ndntraffic/test_ndntraffic.py
+++ b/test_ndntraffic/test_ndntraffic.py
@@ -27,6 +27,8 @@
     def test_traffic(self):
         self.startNfd()
         time.sleep(1)
+        self.startNrd()
+        time.sleep(1)
         serverConfigurationFile = os.path.abspath("test_ndntraffic/test-traffic-server.conf")
         self.startProcess("ndn-traffic-server",
             ["ndn-traffic-server", "-c 1", serverConfigurationFile],
diff --git a/test_nrd/nrd-test.sh b/test_nrd/nrd-test.sh
index 7b72005..022cfc3 100755
--- a/test_nrd/nrd-test.sh
+++ b/test_nrd/nrd-test.sh
@@ -1,15 +1,9 @@
 #!/usr/bin/env bash
 clean_up() {
     r=$(sudo killall nfd 2>&1)
-    r=$(mv ~/.ndn/client.conf.bk ~/.ndn/client.conf 2>&1)
 }
 mkdir -p logs
 
-# backup client.conf
-echo "backup client.conf"
-cp ~/.ndn/client.conf ~/.ndn/client.conf.bk
-sed -i 's/^protocol=.*$/protocol=nrd-0.1/g' ~/.ndn/client.conf
-
 # start nfd and nrd
 echo "starting nfd and nrd..."
 sudo nfd > logs/nfd.log 2>&1 &
diff --git a/test_tcp_udp_tunnel/tcp-udp-tunnel-test.sh b/test_tcp_udp_tunnel/tcp-udp-tunnel-test.sh
index c9e7710..96bbd76 100755
--- a/test_tcp_udp_tunnel/tcp-udp-tunnel-test.sh
+++ b/test_tcp_udp_tunnel/tcp-udp-tunnel-test.sh
@@ -24,7 +24,10 @@
 }
 
 # start nfd on host A
-sudo nfd > logs/nfd.log 2>&1 &
+sudo nfd &> logs/nfd.log &
+sleep 2
+nrd &> logs/nrd.log &
+sleep 2
 
 # start nfd and ndn-traffic-server on host D
 echo "starting nfd and ndn-traffic-server on host D..."
@@ -32,6 +35,8 @@
 ssh $CTRL_D "mkdir -p $workdir/logs;\
     sudo nfd &> $workdir/logs/nfd.log &\
     sleep 3;\
+    nrd &> $workdir/logs/nrd.log &\
+    sleep 3;\
     ndn-traffic-server $workdir/NDNTrafficServer.conf > $workdir/logs/server.log 2>&1 &"
 sleep 5
 
@@ -54,8 +59,8 @@
 echo "stopping nfd on host A..."
 sudo killall nfd
 
-# stop ndn-traffic-server and nfd on hostB
-echo "stopping ndn-traffic-server and nfd on host B..."
+# stop ndn-traffic-server and nfd on hostD
+echo "stopping ndn-traffic-server and nfd on host D..."
 clean_up
 
 # examine client log
diff --git a/test_unixface/unix-face-test.sh b/test_unixface/unix-face-test.sh
index 62d64ea..0c25793 100755
--- a/test_unixface/unix-face-test.sh
+++ b/test_unixface/unix-face-test.sh
@@ -4,7 +4,9 @@
     r=$(sudo killall ndn-traffic-server 2>&1)
     r=$(sudo killall nfd 2>&1)
 }
-sudo nfd > logs/nfd.log 2>&1 &
+sudo nfd &> logs/nfd.log &
+sleep 2
+nrd &> logs/nrd.log &
 sleep 2
 ndn-traffic-server NDNTrafficServer.conf > logs/server.log 2>&1 &
 sleep 2