rewrite Python tests as Bash tests
correct University of Arizona copyright statements
refs #4410
Change-Id: I2e34b28698336d39b64030f68984b711f4bdbd0d
diff --git a/test_ndntraffic/README.md b/test_ndntraffic/README.md
index 531c651..85384f0 100644
--- a/test_ndntraffic/README.md
+++ b/test_ndntraffic/README.md
@@ -3,10 +3,10 @@
## Objective ##
-To test the ndn-traffic-generator application on a single host.
+Test ndn-traffic-generator application on a single host.
## Description ##
-This test case will run NFD, ndn-traffic and ndn-traffic-server.
-This will report SUCCESS if one interest/data is successfully exchanged without any data inconsistency between ndn-traffic and ndn-traffic-server.
-In all other scenarios, the test case will report FAILURE
+This test case will run NFD, ndn-traffic, and ndn-traffic-server.
+This will report SUCCESS if one Interest/Data exchange is completed without any data inconsistency between ndn-traffic and ndn-traffic-server.
+Otherwise, it will fail.
diff --git a/test_ndntraffic/__init__.py b/test_ndntraffic/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/test_ndntraffic/__init__.py
+++ /dev/null
diff --git a/test_ndntraffic/ndntraffic-test.sh b/test_ndntraffic/ndntraffic-test.sh
new file mode 100755
index 0000000..3f494cd
--- /dev/null
+++ b/test_ndntraffic/ndntraffic-test.sh
@@ -0,0 +1,44 @@
+#!/bin/bash
+source ../multi-host.conf
+
+clean_up() {
+ r=$(sudo killall ndn-traffic-server 2>&1)
+ r=$(sudo killall ndn-traffic 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 ndn-traffic-server
+echo "starting ndn-traffic-server on A..."
+ndn-traffic-server -c 1 $workdir/test-traffic-server.conf &> $workdir/logs/ndn-traffic-server.log &
+serverpid=$!
+sleep 1
+
+# A: Run ndn-traffic
+echo "Running ndn-traffic on A..."
+ndn-traffic -c 1 $workdir/test-traffic-client.conf &> $workdir/logs/ndn-traffic.log
+exitcode=$?
+
+if [[ $exitcode -ne 0 ]]; then
+ echo "Received non-zero exit code from ndn-traffic - actual: $exitcode"
+ clean_up
+ exit 1
+fi
+
+sleep 1
+
+# Verify that ndn-traffic-server has exited
+# ps -p returns 1 if no matching process is found
+ps -p $serverpid > /dev/null
+if [[ $? -ne 1 ]]; then
+ echo "ndn-traffic-server did not exit"
+ clean_up
+ exit 2
+fi
+
+clean_up
diff --git a/test_ndntraffic/test_ndntraffic.py b/test_ndntraffic/test_ndntraffic.py
index 632c4fe..e81c2cc 100644
--- a/test_ndntraffic/test_ndntraffic.py
+++ b/test_ndntraffic/test_ndntraffic.py
@@ -1,54 +1,34 @@
#!/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 os
-import time
import unittest
-import process_manager
+import subprocess
-class test_ndntraffic(unittest.TestCase, process_manager.ProcessManager):
- """Test case for testing ndn-traffic-generator application"""
+class test_ndntraffic(unittest.TestCase):
+ """Test case for ndn-traffic-generator"""
def setUp(self):
print "\nTesting ndn-traffic-generator"
print "*****************************"
+ os.chdir("test_ndntraffic")
def tearDown(self):
- self.killNfd()
- self.killProcess("ndn-traffic-server")
- self.killProcess("ndn-traffic")
- self.cleanupProcesses()
+ print "*****************************"
+ os.chdir("..")
- def test_traffic(self):
- self.startNfd()
- time.sleep(1)
- serverConfigurationFile = os.path.abspath("test_ndntraffic/test-traffic-server.conf")
- self.startProcess("ndn-traffic-server",
- ["ndn-traffic-server", "-c 1", serverConfigurationFile],
- "-> Starting Traffic Server")
- time.sleep(1)
- clientConfigurationFile = os.path.abspath("test_ndntraffic/test-traffic-client.conf")
- self.startProcess("ndn-traffic",
- ["ndn-traffic", "-c 1", clientConfigurationFile],
- "-> Starting Traffic Client")
- time.sleep(1)
- self.waitForProcessCompletion("ndn-traffic", 10)
- self.waitForProcessCompletion("ndn-traffic-server", 10)
- if self.hasProcessCompleted("ndn-traffic"):
- if self.getProcessReturnCode("ndn-traffic") != 0:
- print self.getProcessError("ndn-traffic")
- self.fail(">> TEST FAILED - received non-zero return code from ndn-traffic")
- else:
- self.fail(">> TEST FAILED - ndn-traffic failed to complete")
- if self.hasProcessCompleted("ndn-traffic-server"):
- if self.getProcessReturnCode("ndn-traffic-server") != 0:
- print self.getProcessError("ndn-traffic-server")
- self.fail(">> TEST FAILED - received non-zero return code from ndn-traffic-server")
- else:
- self.fail(">> TEST FAILED - ndn-traffic-server failed to complete")
- print ">> TEST SUCCESSFUL"
+ def test_ndntraffic(self):
+ ret = subprocess.call(["./ndntraffic-test.sh"], shell=True)
+ print "Test script return value:", ret
+ errormsg = {
+ 1 : "ndn-traffic did not receive a Data satisfying its Interest",
+ 2 : "ndn-traffic-server did not exit after sending a Data packet",
+ }
+ if (ret != 0):
+ self.fail(errormsg[ret])