blob: 336b74e4e542337fadfce5f7a0708159200900bc [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)
Yi Huang53fa8712014-06-10 20:14:26 -070032 self.startNrd()
33 time.sleep(1)
jeraldabrahama3c97d62014-04-14 01:29:45 -070034 pokeInputFile = os.path.abspath("test_ndnpeekpoke/test-poke-input.txt")
Eric Newberryd4ed6222015-06-10 14:12:42 -070035 self.startProcess("ndnpoke",
36 ["ndnpoke", "ndn:/test/peekpoke"],
jeraldabrahama3c97d62014-04-14 01:29:45 -070037 "-> Starting Poke",
38 inputFile=pokeInputFile)
39 time.sleep(1)
jeraldabrahamb2a26552014-04-16 21:08:09 -070040 peekOutputFile = os.path.abspath("test_ndnpeekpoke/logs/test-peek-output.txt")
Eric Newberryd4ed6222015-06-10 14:12:42 -070041 self.startProcess("ndnpeek",
42 ["ndnpeek", "ndn:/test/peekpoke"],
jeraldabrahama3c97d62014-04-14 01:29:45 -070043 "-> Starting Peek",
44 outputFile=peekOutputFile)
45 time.sleep(1)
Eric Newberryd4ed6222015-06-10 14:12:42 -070046 self.waitForProcessCompletion("ndnpeek", 10)
47 self.waitForProcessCompletion("ndnpoke", 10)
48 if self.hasProcessCompleted("ndnpeek"):
49 if self.getProcessReturnCode("ndnpeek") != 0:
50 print self.getProcessReturnCode("ndnpeek")
51 print self.getProcessError("ndnpeek")
52 print self.getProcessOutput("ndnpeek")
53 self.fail(">> TEST FAILED - received non-zero return code from ndnpeek")
jeraldabrahama3c97d62014-04-14 01:29:45 -070054 else:
Eric Newberryd4ed6222015-06-10 14:12:42 -070055 self.fail(">> TEST FAILED - ndnpeek failed to complete")
56 if self.hasProcessCompleted("ndnpoke"):
57 if self.getProcessReturnCode("ndnpoke") != 0:
58 print self.getProcessError("ndnpoke")
59 self.fail(">> TEST FAILED - received non-zero return code from ndnpoke")
jeraldabrahama3c97d62014-04-14 01:29:45 -070060 else:
Eric Newberryd4ed6222015-06-10 14:12:42 -070061 self.fail(">> TEST FAILED - ndnpoke failed to complete")
jeraldabrahama3c97d62014-04-14 01:29:45 -070062 print ">> TEST SUCCESSFUL"