blob: cafae09b10c3018e57f7adb529ad271432b39cf1 [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)
Yi Huang53fa8712014-06-10 20:14:26 -070029 self.startNrd()
30 time.sleep(1)
jeraldabraham5d4d7352014-03-28 02:49:04 -070031 self.startProcess("ndnpingserver",
32 ["ndnpingserver", "-p 1", "/test/ndntlvping"], "-> Starting Ping Server")
33 time.sleep(1)
34 self.startProcess("ndnping",
35 ["ndnping", "-c 1", "/test/ndntlvping"], "-> Starting Ping Client")
36 time.sleep(1)
37 self.waitForProcessCompletion("ndnping", 10)
38 self.waitForProcessCompletion("ndnpingserver", 10)
jeraldabraham5d4d7352014-03-28 02:49:04 -070039 if self.hasProcessCompleted("ndnping"):
40 if self.getProcessReturnCode("ndnping") != 0:
41 print self.getProcessError("ndnping")
42 self.fail(">> TEST FAILED - received non-zero return code from ndnping")
43 else:
44 self.fail(">> TEST FAILED - ndnping failed to complete")
45 if self.hasProcessCompleted("ndnpingserver"):
46 if self.getProcessReturnCode("ndnpingserver") != 0:
47 print self.getProcessError("ndnpingserver")
48 self.fail(">> TEST FAILED - received non-zero return code from ndnpingserver")
49 else:
50 self.fail(">> TEST FAILED - ndnpingserver failed to complete")
51 print ">> TEST SUCCESSFUL"