rewrite Python tests as Bash tests

correct University of Arizona copyright statements

refs #4410

Change-Id: I2e34b28698336d39b64030f68984b711f4bdbd0d
diff --git a/test_ndnping/README.md b/test_ndnping/README.md
index 46a5ebb..4120e49 100644
--- a/test_ndnping/README.md
+++ b/test_ndnping/README.md
@@ -3,10 +3,10 @@
 
 ## Objective ##
 
-To test the ndnping application on a single host.
+Test the ndnping and ndnpingserver applications on a single host.
 
 ## Description ##
 
-This test case will run NFD, ndnping and ndnpingserver.
-This will report SUCCESS if one ping interest/data is successfully exchanged between the ndnping and ndnpingserver.
-In all other scenarios, the test case will report FAILURE
+This test case will run NFD, ndnping, and ndnpingserver.
+It will succeed if five ping Interest/Data exchanges are completed between the instances of ndnping and ndnpingserver.
+Otherwise, it will fail.
diff --git a/test_ndnping/__init__.py b/test_ndnping/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/test_ndnping/__init__.py
+++ /dev/null
diff --git a/test_ndnping/ndnping-test.sh b/test_ndnping/ndnping-test.sh
new file mode 100755
index 0000000..ae3ac17
--- /dev/null
+++ b/test_ndnping/ndnping-test.sh
@@ -0,0 +1,51 @@
+#!/bin/bash
+source ../multi-host.conf
+
+clean_up() {
+  r=$(sudo killall ndnpingserver 2>&1)
+  r=$(sudo killall ndnping 2>&1)
+  r=$(sudo killall nfd 2>&1)
+}
+
+# A: Start NFD
+workdir=$(pwd)
+echo "Starting nfd on A..."
+mkdir -p $workdir/logs; sudo nfd &> $workdir/logs/nfd.log &
+sleep 1
+
+# A: Start ndnpingserver
+echo "Starting ndnpingserver on A..."
+ndnpingserver -p5 /test/ndnping &> $workdir/logs/ndnpingserver.log &
+serverpid=$!
+sleep 1
+
+# A: Run ndnping
+echo "Running ndnping on A..."
+ndnping -c5 /test/ndnping
+exitcode=$?
+sleep 1
+
+# An exit code of zero indicates the number of received Data packets equals the number of sent Interests
+if [[ $exitcode -ne 0 ]]; then
+  echo "Received non-zero exit code from ndnping - actual: $exitcode"
+  clean_up
+  exit 1
+fi
+
+# Verify that ndnpingserver has exited
+# ps -p returns 1 if no matching process is found
+ps -p $serverpid > /dev/null
+if [[ $? -ne 1 ]]; then
+  echo "ndnpingserver did not exit"
+  clean_up
+  exit 2
+fi
+
+clean_up
+
+nReceivedInterests=$(grep -c "interest received" $workdir/logs/ndnpingserver.log)
+if [[ $nReceivedInterests -ne 5 ]]; then
+  echo "ndnpingserver did not receive 5 Interests - actual: $nReceivedInterests"
+  clean_up
+  exit 3
+fi
diff --git a/test_ndnping/test_ndnping.py b/test_ndnping/test_ndnping.py
index 4ee2c3d..b88ed59 100644
--- a/test_ndnping/test_ndnping.py
+++ b/test_ndnping/test_ndnping.py
@@ -1,50 +1,35 @@
 #!/usr/bin/python2
 # -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
 #
-# Copyright (C) 2014 University of Arizona
+# Copyright (C) 2014-2018 Arizona Board of Regents.
 # Author: Jerald Paul Abraham <jeraldabraham@email.arizona.edu>
+# Author: Eric Newberry <enewberry@cs.arizona.edu>
 # See COPYING for copyright and distribution information.
 #
 
-import time
+import os
 import unittest
-import process_manager
+import subprocess
 
-class test_ndnping(unittest.TestCase, process_manager.ProcessManager):
-    """Test case for testing ndnping application"""
+class test_ndnping(unittest.TestCase):
+    """Test case for the ndnping application"""
 
     def setUp(self):
         print "\nTesting ndnping"
-        print "********************"
+        print "***************"
+        os.chdir("test_ndnping")
 
     def tearDown(self):
-        self.killNfd()
-        self.killProcess("ndnpingserver")
-        self.killProcess("ndnping")
-        self.cleanupProcesses()
+        print "***************"
+        os.chdir("..")
 
-    def test_ping(self):
-        self.startNfd()
-        time.sleep(1)
-        time.sleep(1)
-        self.startProcess("ndnpingserver",
-            ["ndnpingserver", "-p1", "/test/ndnping"], "-> Starting Ping Server")
-        time.sleep(1)
-        self.startProcess("ndnping",
-            ["ndnping", "-c1", "/test/ndnping"], "-> Starting Ping Client")
-        time.sleep(1)
-        self.waitForProcessCompletion("ndnping", 10)
-        self.waitForProcessCompletion("ndnpingserver", 10)
-        if self.hasProcessCompleted("ndnping"):
-            if self.getProcessReturnCode("ndnping") != 0:
-                print self.getProcessError("ndnping")
-                self.fail(">> TEST FAILED - received non-zero return code from ndnping")
-        else:
-            self.fail(">> TEST FAILED - ndnping failed to complete")
-        if self.hasProcessCompleted("ndnpingserver"):
-            if self.getProcessReturnCode("ndnpingserver") != 0:
-                print self.getProcessError("ndnpingserver")
-                self.fail(">> TEST FAILED - received non-zero return code from ndnpingserver")
-        else:
-            self.fail(">> TEST FAILED - ndnpingserver failed to complete")
-        print ">> TEST SUCCESSFUL"
+    def test_ndnping(self):
+        ret = subprocess.call(["./ndnping-test.sh"], shell=True)
+        print "Test script return value:", ret
+        errormsg = {
+            1 : "ndnping did not receive a Data packet satisfying its Interest",
+            2 : "ndnpingserver did not exit after sending 5 Data packets",
+            3 : "ndnpingserver did not receive 5 Interests",
+        }
+        if (ret != 0):
+            self.fail(errormsg[ret])