| #!/usr/bin/python2 |
| # -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| # |
| # Copyright (C) 2014 University of Arizona |
| # Author: Jerald Paul Abraham <jeraldabraham@email.arizona.edu> |
| # See COPYING for copyright and distribution information. |
| # |
| |
| import os |
| import time |
| import unittest |
| import process_manager |
| |
| class test_ndnpeekpoke(unittest.TestCase, process_manager.ProcessManager): |
| """Test case for testing ndn-tlv-peek and ndn-tlv-poke applications""" |
| |
| def setUp(self): |
| print "\nTesting ndn-tlv-peek & ndn-tlv-poke" |
| print "***********************************" |
| os.system("mkdir test_ndnpeekpoke/logs/") |
| |
| def tearDown(self): |
| self.killNfd() |
| self.killProcess("ndn-tlv-poke") |
| self.killProcess("ndn-tlv-peek") |
| os.system("rm -r test_ndnpeekpoke/logs/") |
| self.cleanupProcesses() |
| |
| def test_peekpoke(self): |
| self.startNfd() |
| time.sleep(1) |
| pokeInputFile = os.path.abspath("test_ndnpeekpoke/test-poke-input.txt") |
| self.startProcess("ndn-tlv-poke", |
| ["ndn-tlv-poke", "ndn:/test/peekpoke"], |
| "-> Starting Poke", |
| inputFile=pokeInputFile) |
| time.sleep(1) |
| peekOutputFile = os.path.abspath("test_ndnpeekpoke/logs/test-peek-output.txt") |
| self.startProcess("ndn-tlv-peek", |
| ["ndn-tlv-peek", "ndn:/test/peekpoke"], |
| "-> Starting Peek", |
| outputFile=peekOutputFile) |
| time.sleep(1) |
| self.waitForProcessCompletion("ndn-tlv-peek", 10) |
| self.waitForProcessCompletion("ndn-tlv-poke", 10) |
| if self.hasProcessCompleted("ndn-tlv-peek"): |
| if self.getProcessReturnCode("ndn-tlv-peek") != 0: |
| print self.getProcessReturnCode("ndn-tlv-peek") |
| print self.getProcessError("ndn-tlv-peek") |
| print self.getProcessOutput("ndn-tlv-peek") |
| self.fail(">> TEST FAILED - received non-zero return code from ndn-tlv-peek") |
| else: |
| self.fail(">> TEST FAILED - ndn-tlv-peek failed to complete") |
| if self.hasProcessCompleted("ndn-tlv-poke"): |
| if self.getProcessReturnCode("ndn-tlv-poke") != 0: |
| print self.getProcessError("ndn-tlv-poke") |
| self.fail(">> TEST FAILED - received non-zero return code from ndn-tlv-poke") |
| else: |
| self.fail(">> TEST FAILED - ndn-tlv-poke failed to complete") |
| print ">> TEST SUCCESSFUL" |