blob: 7b2325ed51d92257daead110496d68fa3cef7532 [file] [log] [blame]
jeraldabrahama3c97d62014-04-14 01:29:45 -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 os
10import time
11import unittest
12import process_manager
13
14class test_ndnpeekpoke(unittest.TestCase, process_manager.ProcessManager):
Eric Newberryd4ed6222015-06-10 14:12:42 -070015 """Test case for testing ndnpeek and ndnpoke applications"""
jeraldabrahama3c97d62014-04-14 01:29:45 -070016
17 def setUp(self):
Eric Newberryd4ed6222015-06-10 14:12:42 -070018 print "\nTesting ndnpeek & ndnpoke"
jeraldabrahama3c97d62014-04-14 01:29:45 -070019 print "***********************************"
jeraldabrahamb2a26552014-04-16 21:08:09 -070020 os.system("mkdir test_ndnpeekpoke/logs/")
jeraldabrahama3c97d62014-04-14 01:29:45 -070021
22 def tearDown(self):
23 self.killNfd()
Eric Newberryd4ed6222015-06-10 14:12:42 -070024 self.killProcess("ndnpoke")
25 self.killProcess("ndnpeek")
jeraldabrahamb2a26552014-04-16 21:08:09 -070026 os.system("rm -r test_ndnpeekpoke/logs/")
jeraldabrahama3c97d62014-04-14 01:29:45 -070027 self.cleanupProcesses()
28
29 def test_peekpoke(self):
30 self.startNfd()
31 time.sleep(1)
32 pokeInputFile = os.path.abspath("test_ndnpeekpoke/test-poke-input.txt")
Eric Newberryd4ed6222015-06-10 14:12:42 -070033 self.startProcess("ndnpoke",
34 ["ndnpoke", "ndn:/test/peekpoke"],
jeraldabrahama3c97d62014-04-14 01:29:45 -070035 "-> Starting Poke",
36 inputFile=pokeInputFile)
37 time.sleep(1)
jeraldabrahamb2a26552014-04-16 21:08:09 -070038 peekOutputFile = os.path.abspath("test_ndnpeekpoke/logs/test-peek-output.txt")
Eric Newberryd4ed6222015-06-10 14:12:42 -070039 self.startProcess("ndnpeek",
40 ["ndnpeek", "ndn:/test/peekpoke"],
jeraldabrahama3c97d62014-04-14 01:29:45 -070041 "-> Starting Peek",
42 outputFile=peekOutputFile)
43 time.sleep(1)
Eric Newberryd4ed6222015-06-10 14:12:42 -070044 self.waitForProcessCompletion("ndnpeek", 10)
45 self.waitForProcessCompletion("ndnpoke", 10)
46 if self.hasProcessCompleted("ndnpeek"):
47 if self.getProcessReturnCode("ndnpeek") != 0:
48 print self.getProcessReturnCode("ndnpeek")
49 print self.getProcessError("ndnpeek")
50 print self.getProcessOutput("ndnpeek")
51 self.fail(">> TEST FAILED - received non-zero return code from ndnpeek")
jeraldabrahama3c97d62014-04-14 01:29:45 -070052 else:
Eric Newberryd4ed6222015-06-10 14:12:42 -070053 self.fail(">> TEST FAILED - ndnpeek failed to complete")
54 if self.hasProcessCompleted("ndnpoke"):
55 if self.getProcessReturnCode("ndnpoke") != 0:
56 print self.getProcessError("ndnpoke")
57 self.fail(">> TEST FAILED - received non-zero return code from ndnpoke")
jeraldabrahama3c97d62014-04-14 01:29:45 -070058 else:
Eric Newberryd4ed6222015-06-10 14:12:42 -070059 self.fail(">> TEST FAILED - ndnpoke failed to complete")
jeraldabrahama3c97d62014-04-14 01:29:45 -070060 print ">> TEST SUCCESSFUL"