jeraldabraham | 5d4d735 | 2014-03-28 02:49:04 -0700 | [diff] [blame] | 1 | #!/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 | |
| 9 | import time |
| 10 | import unittest |
| 11 | import process_manager |
| 12 | |
Eric Newberry | 86b00b9 | 2015-06-07 15:23:51 -0700 | [diff] [blame] | 13 | class test_ndnping(unittest.TestCase, process_manager.ProcessManager): |
| 14 | """Test case for testing ndnping application""" |
jeraldabraham | 5d4d735 | 2014-03-28 02:49:04 -0700 | [diff] [blame] | 15 | |
| 16 | def setUp(self): |
Eric Newberry | 86b00b9 | 2015-06-07 15:23:51 -0700 | [diff] [blame] | 17 | print "\nTesting ndnping" |
jeraldabraham | 5d4d735 | 2014-03-28 02:49:04 -0700 | [diff] [blame] | 18 | print "********************" |
| 19 | |
| 20 | def tearDown(self): |
| 21 | self.killNfd() |
| 22 | self.killProcess("ndnpingserver") |
| 23 | self.killProcess("ndnping") |
jeraldabraham | 3a2466e | 2014-04-09 00:19:45 -0700 | [diff] [blame] | 24 | self.cleanupProcesses() |
jeraldabraham | 5d4d735 | 2014-03-28 02:49:04 -0700 | [diff] [blame] | 25 | |
| 26 | def test_ping(self): |
| 27 | self.startNfd() |
| 28 | time.sleep(1) |
Yi Huang | 53fa871 | 2014-06-10 20:14:26 -0700 | [diff] [blame] | 29 | time.sleep(1) |
jeraldabraham | 5d4d735 | 2014-03-28 02:49:04 -0700 | [diff] [blame] | 30 | self.startProcess("ndnpingserver", |
Eric Newberry | 86b00b9 | 2015-06-07 15:23:51 -0700 | [diff] [blame] | 31 | ["ndnpingserver", "-p1", "/test/ndnping"], "-> Starting Ping Server") |
jeraldabraham | 5d4d735 | 2014-03-28 02:49:04 -0700 | [diff] [blame] | 32 | time.sleep(1) |
| 33 | self.startProcess("ndnping", |
Eric Newberry | 86b00b9 | 2015-06-07 15:23:51 -0700 | [diff] [blame] | 34 | ["ndnping", "-c1", "/test/ndnping"], "-> Starting Ping Client") |
jeraldabraham | 5d4d735 | 2014-03-28 02:49:04 -0700 | [diff] [blame] | 35 | time.sleep(1) |
| 36 | self.waitForProcessCompletion("ndnping", 10) |
| 37 | self.waitForProcessCompletion("ndnpingserver", 10) |
jeraldabraham | 5d4d735 | 2014-03-28 02:49:04 -0700 | [diff] [blame] | 38 | 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" |