X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=test%2Fframework.py;h=789ec1be9b96d923bc413b7b42fe874da4eb678b;hb=7eedb5fb44d5a38cb3ba059d6983e95128b97d36;hp=308842da6bcef97078358eea9f1f26ec90a5137d;hpb=0219b8dfbf25090214573394cf2c9e5e968cfa9a;p=vpp.git diff --git a/test/framework.py b/test/framework.py index 308842da6bc..789ec1be9b9 100644 --- a/test/framework.py +++ b/test/framework.py @@ -23,6 +23,7 @@ from vpp_pg_interface import VppPGInterface from vpp_sub_interface import VppSubInterface from vpp_lo_interface import VppLoInterface from vpp_papi_provider import VppPapiProvider +from vpp_papi.vpp_stats import VPPStats from log import RED, GREEN, YELLOW, double_line_delim, single_line_delim, \ getLogger, colorize from vpp_object import VppObjectRegistry @@ -279,6 +280,8 @@ class VppTestCase(unittest.TestCase): coredump_size, "}", "api-trace", "{", "on", "}", "api-segment", "{", "prefix", cls.shm_prefix, "}", "cpu", "{", "main-core", str(cpu_core_number), "}", + "stats", "{", "socket-name", + cls.tempdir + "/stats.sock", "}", "plugins", "{", "plugin", "dpdk_plugin.so", "{", "disable", "}", "plugin", "unittest_plugin.so", "{", "enable", "}", "}", ] @@ -387,6 +390,7 @@ class VppTestCase(unittest.TestCase): else: hook = PollHook(cls) cls.vapi.register_hook(hook) + cls.statistics = VPPStats(socketname=cls.tempdir+'/stats.sock') cls.sleep(0.1, "after vpp startup, before initial poll") try: hook.poll_vpp() @@ -498,7 +502,7 @@ class VppTestCase(unittest.TestCase): self.logger.debug(self.vapi.cli("show trace")) self.logger.info(self.vapi.ppcli("show interface")) self.logger.info(self.vapi.ppcli("show hardware")) - self.logger.info(self.vapi.ppcli("show error")) + self.logger.info(self.statistics.set_errors_str()) self.logger.info(self.vapi.ppcli("show run")) self.logger.info(self.vapi.ppcli("show log")) self.registry.remove_vpp_config(self.logger) @@ -1015,6 +1019,12 @@ class VppTestResult(unittest.TestResult): if logger: logger.error(e) + def send_results_through_pipe(self): + if hasattr(self, 'test_framework_results_pipe'): + pipe = self.test_framework_results_pipe + if pipe: + pipe.send(self) + def addFailure(self, test, err): """ Record a test failed result @@ -1087,7 +1097,7 @@ class VppTestResult(unittest.TestResult): def stopTest(self, test): """ - Stop a test + Called when the given test has been run :param test: @@ -1101,6 +1111,7 @@ class VppTestResult(unittest.TestResult): else: self.stream.writeln("%-73s%s" % (self.getDescription(test), self.result_string)) + self.send_results_through_pipe() def printErrors(self): """ @@ -1137,7 +1148,8 @@ class VppTestRunner(unittest.TextTestRunner): return VppTestResult def __init__(self, keep_alive_pipe=None, descriptions=True, verbosity=1, - failfast=False, buffer=False, resultclass=None): + results_pipe=None, failfast=False, buffer=False, + resultclass=None): # ignore stream setting here, use hard-coded stdout to be in sync # with prints from VppTestCase methods ... super(VppTestRunner, self).__init__(sys.stdout, descriptions, @@ -1146,6 +1158,8 @@ class VppTestRunner(unittest.TextTestRunner): reporter = KeepAliveReporter() reporter.pipe = keep_alive_pipe + VppTestResult.test_framework_results_pipe = results_pipe + def run(self, test): """ Run the tests