jeraldabraham | a3c97d6 | 2014-04-14 01:29:45 -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 os |
| 10 | import time |
| 11 | import unittest |
| 12 | import process_manager |
| 13 | |
| 14 | class test_ndnpeekpoke(unittest.TestCase, process_manager.ProcessManager): |
Eric Newberry | d4ed622 | 2015-06-10 14:12:42 -0700 | [diff] [blame] | 15 | """Test case for testing ndnpeek and ndnpoke applications""" |
jeraldabraham | a3c97d6 | 2014-04-14 01:29:45 -0700 | [diff] [blame] | 16 | |
| 17 | def setUp(self): |
Eric Newberry | d4ed622 | 2015-06-10 14:12:42 -0700 | [diff] [blame] | 18 | print "\nTesting ndnpeek & ndnpoke" |
jeraldabraham | a3c97d6 | 2014-04-14 01:29:45 -0700 | [diff] [blame] | 19 | print "***********************************" |
Eric Newberry | d729f35 | 2015-07-19 11:18:51 -0700 | [diff] [blame] | 20 | os.system("mkdir -p test_ndnpeekpoke/logs/") |
jeraldabraham | a3c97d6 | 2014-04-14 01:29:45 -0700 | [diff] [blame] | 21 | |
| 22 | def tearDown(self): |
| 23 | self.killNfd() |
Eric Newberry | d4ed622 | 2015-06-10 14:12:42 -0700 | [diff] [blame] | 24 | self.killProcess("ndnpoke") |
| 25 | self.killProcess("ndnpeek") |
jeraldabraham | a3c97d6 | 2014-04-14 01:29:45 -0700 | [diff] [blame] | 26 | self.cleanupProcesses() |
| 27 | |
| 28 | def test_peekpoke(self): |
| 29 | self.startNfd() |
| 30 | time.sleep(1) |
| 31 | pokeInputFile = os.path.abspath("test_ndnpeekpoke/test-poke-input.txt") |
Eric Newberry | d4ed622 | 2015-06-10 14:12:42 -0700 | [diff] [blame] | 32 | self.startProcess("ndnpoke", |
| 33 | ["ndnpoke", "ndn:/test/peekpoke"], |
jeraldabraham | a3c97d6 | 2014-04-14 01:29:45 -0700 | [diff] [blame] | 34 | "-> Starting Poke", |
| 35 | inputFile=pokeInputFile) |
| 36 | time.sleep(1) |
jeraldabraham | b2a2655 | 2014-04-16 21:08:09 -0700 | [diff] [blame] | 37 | peekOutputFile = os.path.abspath("test_ndnpeekpoke/logs/test-peek-output.txt") |
Eric Newberry | d4ed622 | 2015-06-10 14:12:42 -0700 | [diff] [blame] | 38 | self.startProcess("ndnpeek", |
| 39 | ["ndnpeek", "ndn:/test/peekpoke"], |
jeraldabraham | a3c97d6 | 2014-04-14 01:29:45 -0700 | [diff] [blame] | 40 | "-> Starting Peek", |
| 41 | outputFile=peekOutputFile) |
| 42 | time.sleep(1) |
Eric Newberry | d4ed622 | 2015-06-10 14:12:42 -0700 | [diff] [blame] | 43 | self.waitForProcessCompletion("ndnpeek", 10) |
| 44 | self.waitForProcessCompletion("ndnpoke", 10) |
| 45 | if self.hasProcessCompleted("ndnpeek"): |
| 46 | if self.getProcessReturnCode("ndnpeek") != 0: |
| 47 | print self.getProcessReturnCode("ndnpeek") |
| 48 | print self.getProcessError("ndnpeek") |
| 49 | print self.getProcessOutput("ndnpeek") |
| 50 | self.fail(">> TEST FAILED - received non-zero return code from ndnpeek") |
jeraldabraham | a3c97d6 | 2014-04-14 01:29:45 -0700 | [diff] [blame] | 51 | else: |
Eric Newberry | d4ed622 | 2015-06-10 14:12:42 -0700 | [diff] [blame] | 52 | self.fail(">> TEST FAILED - ndnpeek failed to complete") |
| 53 | if self.hasProcessCompleted("ndnpoke"): |
| 54 | if self.getProcessReturnCode("ndnpoke") != 0: |
| 55 | print self.getProcessError("ndnpoke") |
| 56 | self.fail(">> TEST FAILED - received non-zero return code from ndnpoke") |
jeraldabraham | a3c97d6 | 2014-04-14 01:29:45 -0700 | [diff] [blame] | 57 | else: |
Eric Newberry | d4ed622 | 2015-06-10 14:12:42 -0700 | [diff] [blame] | 58 | self.fail(">> TEST FAILED - ndnpoke failed to complete") |
jeraldabraham | a3c97d6 | 2014-04-14 01:29:45 -0700 | [diff] [blame] | 59 | print ">> TEST SUCCESSFUL" |