test_interest_loop: no longer passes when commands fail

refs #2386

Change-Id: I71deb55f3655ef7dba11e6532e91ee34309fa32d
diff --git a/test_interest_loop/interest-loop-test.sh b/test_interest_loop/interest-loop-test.sh
index 93c5b94..9df944c 100755
--- a/test_interest_loop/interest-loop-test.sh
+++ b/test_interest_loop/interest-loop-test.sh
@@ -14,10 +14,12 @@
 
 clean_up() {
     echo "cleaning up..."
-    r=$(sudo killall nfd 2>&1)
-    r=$(ssh $b_ipaddr "sudo killall nfd 2>&1" 2>&1)
-    r=$(ssh $c_ipaddr "sudo killall nfd 2>&1" 2>&1)
+    sudo killall nfd 2>&1
+    ssh $b_ipaddr "sudo killall nfd 2>&1" 2>&1
+    ssh $c_ipaddr "sudo killall nfd 2>&1" 2>&1
 }
+trap clean_up EXIT
+
 # generate nfd.conf: disable multicast faces
 cp /usr/local/etc/ndn/nfd.conf $workdir/nfd.conf
 ssh $CTRL_B "sed 's/mcast yes/mcast no/' /usr/local/etc/ndn/nfd.conf > $workdir/nfd.conf"
@@ -39,9 +41,9 @@
     sleep 2"
 sudo nfd --config $workdir/nfd.conf &> $workdir/logs/${logprefix}_nfd.log &
 sleep 5
-ssh $CTRL_B "$workdir/add-nexthop.sh $c_ipaddr $strategy"
-ssh $CTRL_C "$workdir/add-nexthop.sh $a_ipaddr $strategy"
-$workdir/add-nexthop.sh $b_ipaddr $strategy
+ssh $CTRL_B "$workdir/add-nexthop.sh $c_ipaddr $strategy" || exit 3
+ssh $CTRL_C "$workdir/add-nexthop.sh $a_ipaddr $strategy" || exit 3
+$workdir/add-nexthop.sh $b_ipaddr $strategy || exit 3
 
 # use ndn-traffic client to send 100 interests
 echo "using ndn-traffic client to send 100 interests..."
@@ -49,11 +51,11 @@
 
 # collect nfd-status from B and C
 echo "collecting nfd-status from B and C..."
-ssh $CTRL_B "nfd-status -f > $workdir/logs/${logprefix}_nfd-status-B.log 2>&1"
+ssh $CTRL_B "nfd-status -f > $workdir/logs/${logprefix}_nfd-status-B.log 2>&1" || exit 4
 scp $CTRL_B:$workdir/logs/${logprefix}_nfd-status-B.log  $workdir/logs/${logprefix}_nfd-status-B.log
-ssh $CTRL_C "nfd-status -f > $workdir/logs/${logprefix}_nfd-status-C.log 2>&1"
+ssh $CTRL_C "nfd-status -f > $workdir/logs/${logprefix}_nfd-status-C.log 2>&1" || exit 4
 scp $CTRL_C:$workdir/logs/${logprefix}_nfd-status-C.log  $workdir/logs/${logprefix}_nfd-status-C.log
-nfd-status -f > $workdir/logs/${logprefix}_nfd-status-A.log 2>&1
+nfd-status -f > $workdir/logs/${logprefix}_nfd-status-A.log 2>&1 || exit 4
 
 # analyze results
 echo "analyzing results..."
@@ -69,14 +71,12 @@
         then
             echo "FAIL: counter for incoming interest on host $host is greater than 200"
             echo "$line"
-            clean_up
             exit 1
         fi
         if [[ $outi -gt 200 ]]
         then
             echo "FAIL: counter for outgoing interest on host $host is greater than 200"
             echo "$line"
-            clean_up
             exit 2
         fi
     done