#!/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.process_manager):
    """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")

    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)
        self.killProcess("ndnping")
        self.killProcess("ndnpingserver")
        self.killNfd()
        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"
