blob: 632c4fec608eefd78e902547ada19b7f3bd147aa [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_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"