blob: e49adba9b2fd0372e7e232eb110adc609e540ebc [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):
15 """Test case for testing ndn-tlv-peek and ndn-tlv-poke applications"""
16
17 def setUp(self):
18 print "\nTesting ndn-tlv-peek & ndn-tlv-poke"
19 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()
24 self.killProcess("ndn-tlv-poke")
25 self.killProcess("ndn-tlv-peek")
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")
35 self.startProcess("ndn-tlv-poke",
36 ["ndn-tlv-poke", "ndn:/test/peekpoke"],
37 "-> 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")
jeraldabrahama3c97d62014-04-14 01:29:45 -070041 self.startProcess("ndn-tlv-peek",
42 ["ndn-tlv-peek", "ndn:/test/peekpoke"],
43 "-> Starting Peek",
44 outputFile=peekOutputFile)
45 time.sleep(1)
46 self.waitForProcessCompletion("ndn-tlv-peek", 10)
47 self.waitForProcessCompletion("ndn-tlv-poke", 10)
48 if self.hasProcessCompleted("ndn-tlv-peek"):
49 if self.getProcessReturnCode("ndn-tlv-peek") != 0:
50 print self.getProcessReturnCode("ndn-tlv-peek")
51 print self.getProcessError("ndn-tlv-peek")
52 print self.getProcessOutput("ndn-tlv-peek")
53 self.fail(">> TEST FAILED - received non-zero return code from ndn-tlv-peek")
54 else:
55 self.fail(">> TEST FAILED - ndn-tlv-peek failed to complete")
56 if self.hasProcessCompleted("ndn-tlv-poke"):
57 if self.getProcessReturnCode("ndn-tlv-poke") != 0:
58 print self.getProcessError("ndn-tlv-poke")
59 self.fail(">> TEST FAILED - received non-zero return code from ndn-tlv-poke")
60 else:
61 self.fail(">> TEST FAILED - ndn-tlv-poke failed to complete")
62 print ">> TEST SUCCESSFUL"