test-ndntraffic: test case for testing ndn-traffic-generator
Change-Id: I117f38a206f0ae2a9d1d994f17884ae22e2c2f12
refs: #1387
diff --git a/test_ndntraffic/test_ndntraffic.py b/test_ndntraffic/test_ndntraffic.py
new file mode 100644
index 0000000..632c4fe
--- /dev/null
+++ b/test_ndntraffic/test_ndntraffic.py
@@ -0,0 +1,54 @@
+#!/usr/bin/python2
+# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+#
+# Copyright (C) 2014 University of Arizona
+# Author: Jerald Paul Abraham <jeraldabraham@email.arizona.edu>
+# See COPYING for copyright and distribution information.
+#
+
+import os
+import time
+import unittest
+import process_manager
+
+class test_ndntraffic(unittest.TestCase, process_manager.ProcessManager):
+ """Test case for testing ndn-traffic-generator application"""
+
+ def setUp(self):
+ print "\nTesting ndn-traffic-generator"
+ print "*****************************"
+
+ def tearDown(self):
+ self.killNfd()
+ self.killProcess("ndn-traffic-server")
+ self.killProcess("ndn-traffic")
+ self.cleanupProcesses()
+
+ 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"