blob: 336b74e4e542337fadfce5f7a0708159200900bc [file] [log] [blame]
#!/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 ndnpeek and ndnpoke applications"""
def setUp(self):
print "\nTesting ndnpeek & ndnpoke"
print "***********************************"
os.system("mkdir test_ndnpeekpoke/logs/")
def tearDown(self):
self.killNfd()
self.killProcess("ndnpoke")
self.killProcess("ndnpeek")
os.system("rm -r test_ndnpeekpoke/logs/")
self.cleanupProcesses()
def test_peekpoke(self):
self.startNfd()
time.sleep(1)
self.startNrd()
time.sleep(1)
pokeInputFile = os.path.abspath("test_ndnpeekpoke/test-poke-input.txt")
self.startProcess("ndnpoke",
["ndnpoke", "ndn:/test/peekpoke"],
"-> Starting Poke",
inputFile=pokeInputFile)
time.sleep(1)
peekOutputFile = os.path.abspath("test_ndnpeekpoke/logs/test-peek-output.txt")
self.startProcess("ndnpeek",
["ndnpeek", "ndn:/test/peekpoke"],
"-> Starting Peek",
outputFile=peekOutputFile)
time.sleep(1)
self.waitForProcessCompletion("ndnpeek", 10)
self.waitForProcessCompletion("ndnpoke", 10)
if self.hasProcessCompleted("ndnpeek"):
if self.getProcessReturnCode("ndnpeek") != 0:
print self.getProcessReturnCode("ndnpeek")
print self.getProcessError("ndnpeek")
print self.getProcessOutput("ndnpeek")
self.fail(">> TEST FAILED - received non-zero return code from ndnpeek")
else:
self.fail(">> TEST FAILED - ndnpeek failed to complete")
if self.hasProcessCompleted("ndnpoke"):
if self.getProcessReturnCode("ndnpoke") != 0:
print self.getProcessError("ndnpoke")
self.fail(">> TEST FAILED - received non-zero return code from ndnpoke")
else:
self.fail(">> TEST FAILED - ndnpoke failed to complete")
print ">> TEST SUCCESSFUL"