test-ndnpeekpoke: test case for testing ndn-tlv-peek and ndn-tlv-poke
on a single host
Change-Id: Ie45f37a5b53fadd70c1f3c7bb29d3dcd91a7fb65
refs: #1387
diff --git a/library_helpers/process_manager.py b/library_helpers/process_manager.py
index fa2fdf3..204d61d 100644
--- a/library_helpers/process_manager.py
+++ b/library_helpers/process_manager.py
@@ -23,22 +23,50 @@
self.subprocesses.clear()
self.results.clear()
- def runProcess(self, processKey, processCallFormat, message, subprocesses, results):
+ def runProcess(self,
+ processKey,
+ processCallFormat,
+ message,
+ subprocesses,
+ results,
+ inputFile,
+ outputFile):
print message
+ stdin = None
+ if inputFile is not None:
+ stdin = open(inputFile, "r")
+ stdout = subprocess.PIPE
+ if outputFile is not None:
+ stdout = open(outputFile, "w")
process = subprocess.Popen(
- processCallFormat, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
+ processCallFormat,
+ stdin=stdin,
+ stdout=stdout,
+ stderr=subprocess.PIPE)
subprocesses[processKey] = process
try:
stdout, stderr = process.communicate()
returnCode = process.returncode
results[processKey] = (returnCode, stdout, stderr)
except IOError as e:
+ print e
pass
- def startProcess(self, processKey, processCallFormat, message):
+ def startProcess(self,
+ processKey,
+ processCallFormat,
+ message,
+ inputFile=None,
+ outputFile=None):
self.processes[processKey] = mp.Process(
- target = self.runProcess,
- args = [processKey, processCallFormat, message, self.subprocesses, self.results])
+ target=self.runProcess,
+ args=[processKey,
+ processCallFormat,
+ message,
+ self.subprocesses,
+ self.results,
+ inputFile,
+ outputFile])
self.processes[processKey].start()
def killProcess(self, processKey):
diff --git a/test_ndnpeekpoke/README.md b/test_ndnpeekpoke/README.md
new file mode 100644
index 0000000..3f9b9d1
--- /dev/null
+++ b/test_ndnpeekpoke/README.md
@@ -0,0 +1,12 @@
+Test Case - ndnpeekpoke
+=======================
+
+## Objective ##
+
+To test the ndn-tlv-peek and ndn-tlv-poke applications on a single host.
+
+## Description ##
+
+This test case will run the NFD, ndn-tlv-peek and ndn-tlv-poke binaries.
+This will report SUCCESS if one interest/data is successfully exchanged between ndn-tlv-peek and ndn-tlv-poke.
+In all other scenarios, the test case will report FAILURE
diff --git a/test_ndnpeekpoke/__init__.py b/test_ndnpeekpoke/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test_ndnpeekpoke/__init__.py
diff --git a/test_ndnpeekpoke/test-poke-input.txt b/test_ndnpeekpoke/test-poke-input.txt
new file mode 100644
index 0000000..72d007b
--- /dev/null
+++ b/test_ndnpeekpoke/test-poke-input.txt
@@ -0,0 +1 @@
+ABCDEFGHIJKLMNOPQRSTUVWXYZ
diff --git a/test_ndnpeekpoke/test_ndnpeekpoke.py b/test_ndnpeekpoke/test_ndnpeekpoke.py
new file mode 100644
index 0000000..257cfbc
--- /dev/null
+++ b/test_ndnpeekpoke/test_ndnpeekpoke.py
@@ -0,0 +1,58 @@
+#!/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_ndnpeekpoke(unittest.TestCase, process_manager.ProcessManager):
+ """Test case for testing ndn-tlv-peek and ndn-tlv-poke applications"""
+
+ def setUp(self):
+ print "\nTesting ndn-tlv-peek & ndn-tlv-poke"
+ print "***********************************"
+
+ def tearDown(self):
+ self.killNfd()
+ self.killProcess("ndn-tlv-poke")
+ self.killProcess("ndn-tlv-peek")
+ self.cleanupProcesses()
+
+ def test_peekpoke(self):
+ self.startNfd()
+ time.sleep(1)
+ pokeInputFile = os.path.abspath("test_ndnpeekpoke/test-poke-input.txt")
+ self.startProcess("ndn-tlv-poke",
+ ["ndn-tlv-poke", "ndn:/test/peekpoke"],
+ "-> Starting Poke",
+ inputFile=pokeInputFile)
+ time.sleep(1)
+ peekOutputFile = os.path.abspath("/tmp/test-peek-output.txt")
+ self.startProcess("ndn-tlv-peek",
+ ["ndn-tlv-peek", "ndn:/test/peekpoke"],
+ "-> Starting Peek",
+ outputFile=peekOutputFile)
+ time.sleep(1)
+ self.waitForProcessCompletion("ndn-tlv-peek", 10)
+ self.waitForProcessCompletion("ndn-tlv-poke", 10)
+ if self.hasProcessCompleted("ndn-tlv-peek"):
+ if self.getProcessReturnCode("ndn-tlv-peek") != 0:
+ print self.getProcessReturnCode("ndn-tlv-peek")
+ print self.getProcessError("ndn-tlv-peek")
+ print self.getProcessOutput("ndn-tlv-peek")
+ self.fail(">> TEST FAILED - received non-zero return code from ndn-tlv-peek")
+ else:
+ self.fail(">> TEST FAILED - ndn-tlv-peek failed to complete")
+ if self.hasProcessCompleted("ndn-tlv-poke"):
+ if self.getProcessReturnCode("ndn-tlv-poke") != 0:
+ print self.getProcessError("ndn-tlv-poke")
+ self.fail(">> TEST FAILED - received non-zero return code from ndn-tlv-poke")
+ else:
+ self.fail(">> TEST FAILED - ndn-tlv-poke failed to complete")
+ print ">> TEST SUCCESSFUL"
diff --git a/test_ndntraffic/README.md b/test_ndntraffic/README.md
index 7f95d2e..9baab20 100644
--- a/test_ndntraffic/README.md
+++ b/test_ndntraffic/README.md
@@ -8,5 +8,5 @@
## Description ##
This test case will run the NFD, ndn-traffic and ndn-traffic-server binaries.
-This will report SUCCESS if one interest/data is successfully exchanged without any data inconsistency between the 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