blob: 4ee2c3df7b7829dca5cb8fb2c34bab68ee5c93b5 [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
Eric Newberry86b00b92015-06-07 15:23:51 -070013class test_ndnping(unittest.TestCase, process_manager.ProcessManager):
14 """Test case for testing ndnping application"""
jeraldabraham5d4d7352014-03-28 02:49:04 -070015
16 def setUp(self):
Eric Newberry86b00b92015-06-07 15:23:51 -070017 print "\nTesting ndnping"
jeraldabraham5d4d7352014-03-28 02:49:04 -070018 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 time.sleep(1)
jeraldabraham5d4d7352014-03-28 02:49:04 -070030 self.startProcess("ndnpingserver",
Eric Newberry86b00b92015-06-07 15:23:51 -070031 ["ndnpingserver", "-p1", "/test/ndnping"], "-> Starting Ping Server")
jeraldabraham5d4d7352014-03-28 02:49:04 -070032 time.sleep(1)
33 self.startProcess("ndnping",
Eric Newberry86b00b92015-06-07 15:23:51 -070034 ["ndnping", "-c1", "/test/ndnping"], "-> Starting Ping Client")
jeraldabraham5d4d7352014-03-28 02:49:04 -070035 time.sleep(1)
36 self.waitForProcessCompletion("ndnping", 10)
37 self.waitForProcessCompletion("ndnpingserver", 10)
jeraldabraham5d4d7352014-03-28 02:49:04 -070038 if self.hasProcessCompleted("ndnping"):
39 if self.getProcessReturnCode("ndnping") != 0:
40 print self.getProcessError("ndnping")
41 self.fail(">> TEST FAILED - received non-zero return code from ndnping")
42 else:
43 self.fail(">> TEST FAILED - ndnping failed to complete")
44 if self.hasProcessCompleted("ndnpingserver"):
45 if self.getProcessReturnCode("ndnpingserver") != 0:
46 print self.getProcessError("ndnpingserver")
47 self.fail(">> TEST FAILED - received non-zero return code from ndnpingserver")
48 else:
49 self.fail(">> TEST FAILED - ndnpingserver failed to complete")
50 print ">> TEST SUCCESSFUL"