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 | |
| 13 | class test_ndntlvping(unittest.TestCase, process_manager.process_manager): |
| 14 | """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") |
| 24 | |
| 25 | def test_ping(self): |
| 26 | self.startNfd() |
| 27 | time.sleep(1) |
| 28 | self.startProcess("ndnpingserver", |
| 29 | ["ndnpingserver", "-p 1", "/test/ndntlvping"], "-> Starting Ping Server") |
| 30 | time.sleep(1) |
| 31 | self.startProcess("ndnping", |
| 32 | ["ndnping", "-c 1", "/test/ndntlvping"], "-> Starting Ping Client") |
| 33 | time.sleep(1) |
| 34 | self.waitForProcessCompletion("ndnping", 10) |
| 35 | self.waitForProcessCompletion("ndnpingserver", 10) |
| 36 | self.killProcess("ndnping") |
| 37 | self.killProcess("ndnpingserver") |
| 38 | self.killNfd() |
| 39 | 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" |