#!/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 time
import unittest
import process_manager

class test_ndntlvping(unittest.TestCase, process_manager.ProcessManager):
    """Test case for testing ndn-tlv-ping application"""

    def setUp(self):
        print "\nTesting ndn-tlv-ping"
        print "********************"

    def tearDown(self):
        self.killNfd()
        self.killProcess("ndnpingserver")
        self.killProcess("ndnping")
        self.cleanupProcesses()

    def test_ping(self):
        self.startNfd()
        time.sleep(1)
        self.startProcess("ndnpingserver",
            ["ndnpingserver", "-p 1", "/test/ndntlvping"], "-> Starting Ping Server")
        time.sleep(1)
        self.startProcess("ndnping",
            ["ndnping", "-c 1", "/test/ndntlvping"], "-> Starting Ping Client")
        time.sleep(1)
        self.waitForProcessCompletion("ndnping", 10)
        self.waitForProcessCompletion("ndnpingserver", 10)
        if self.hasProcessCompleted("ndnping"):
            if self.getProcessReturnCode("ndnping") != 0:
                print self.getProcessError("ndnping")
                self.fail(">> TEST FAILED - received non-zero return code from ndnping")
        else:
            self.fail(">> TEST FAILED - ndnping failed to complete")
        if self.hasProcessCompleted("ndnpingserver"):
            if self.getProcessReturnCode("ndnpingserver") != 0:
                print self.getProcessError("ndnpingserver")
                self.fail(">> TEST FAILED - received non-zero return code from ndnpingserver")
        else:
            self.fail(">> TEST FAILED - ndnpingserver failed to complete")
        print ">> TEST SUCCESSFUL"
