blob: 8cc3c4d8144d512d92dba095c4ffc7e539548dce [file] [log] [blame]
jeraldabraham5d4d7352014-03-28 02:49:04 -07001#!/usr/bin/python2
2# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
3#
4# Copyright (C) 2014 University of Arizona
5# Author: Jerald Paul Abraham <jeraldabraham@email.arizona.edu>
6# See COPYING for copyright and distribution information.
7#
8
9import time
10import unittest
11import process_manager
12
jeraldabraham3a2466e2014-04-09 00:19:45 -070013class test_ndntlvping(unittest.TestCase, process_manager.ProcessManager):
jeraldabraham5d4d7352014-03-28 02:49:04 -070014 """Test case for testing ndn-tlv-ping application"""
15
16 def setUp(self):
17 print "\nTesting ndn-tlv-ping"
18 print "********************"
19
20 def tearDown(self):
21 self.killNfd()
22 self.killProcess("ndnpingserver")
23 self.killProcess("ndnping")
jeraldabraham3a2466e2014-04-09 00:19:45 -070024 self.cleanupProcesses()
jeraldabraham5d4d7352014-03-28 02:49:04 -070025
26 def test_ping(self):
27 self.startNfd()
28 time.sleep(1)
29 self.startProcess("ndnpingserver",
30 ["ndnpingserver", "-p 1", "/test/ndntlvping"], "-> Starting Ping Server")
31 time.sleep(1)
32 self.startProcess("ndnping",
33 ["ndnping", "-c 1", "/test/ndntlvping"], "-> Starting Ping Client")
34 time.sleep(1)
35 self.waitForProcessCompletion("ndnping", 10)
36 self.waitForProcessCompletion("ndnpingserver", 10)
jeraldabraham5d4d7352014-03-28 02:49:04 -070037 if self.hasProcessCompleted("ndnping"):
38 if self.getProcessReturnCode("ndnping") != 0:
39 print self.getProcessError("ndnping")
40 self.fail(">> TEST FAILED - received non-zero return code from ndnping")
41 else:
42 self.fail(">> TEST FAILED - ndnping failed to complete")
43 if self.hasProcessCompleted("ndnpingserver"):
44 if self.getProcessReturnCode("ndnpingserver") != 0:
45 print self.getProcessError("ndnpingserver")
46 self.fail(">> TEST FAILED - received non-zero return code from ndnpingserver")
47 else:
48 self.fail(">> TEST FAILED - ndnpingserver failed to complete")
49 print ">> TEST SUCCESSFUL"