X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=test%2Fframework.py;h=cd15aec7d341a52ce7066458ed9a0dbb95c6319e;hb=f94c63ea392a79b509a7b8263f5a9372a58786f9;hp=6a5477d2ea732a92c64d977dbcf854bfdab2ac71;hpb=184870ac5a266c37987e4a4d97ab4d4efefacb1f;p=vpp.git diff --git a/test/framework.py b/test/framework.py index 6a5477d2ea7..cd15aec7d34 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 @@ -38,6 +39,13 @@ else: import subprocess +PASS = 0 +FAIL = 1 +ERROR = 2 +SKIP = 3 +TEST_RUN = 4 + + debug_framework = False if os.getenv('TEST_DEBUG', "0") == "1": debug_framework = True @@ -279,6 +287,8 @@ class VppTestCase(unittest.TestCase): coredump_size, "}", "api-trace", "{", "on", "}", "api-segment", "{", "prefix", cls.shm_prefix, "}", "cpu", "{", "main-core", str(cpu_core_number), "}", + "statseg", "{", "socket-name", + cls.tempdir + "/stats.sock", "}", "plugins", "{", "plugin", "dpdk_plugin.so", "{", "disable", "}", "plugin", "unittest_plugin.so", "{", "enable", "}", "}", ] @@ -388,6 +398,7 @@ class VppTestCase(unittest.TestCase): hook = PollHook(cls) cls.vapi.register_hook(hook) cls.sleep(0.1, "after vpp startup, before initial poll") + cls.statistics = VPPStats(socketname=cls.tempdir+'/stats.sock') try: hook.poll_vpp() except VppDiedError: @@ -498,7 +509,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) @@ -973,6 +984,8 @@ class VppTestResult(unittest.TestResult): unittest.TestResult.addSuccess(self, test) self.result_string = colorize("OK", GREEN) + self.send_result_through_pipe(test, PASS) + def addSkip(self, test, reason): """ Record a test skipped. @@ -990,6 +1003,8 @@ class VppTestResult(unittest.TestResult): unittest.TestResult.addSkip(self, test, reason) self.result_string = colorize("SKIP", YELLOW) + self.send_result_through_pipe(test, SKIP) + def symlink_failed(self, test): logger = None if hasattr(test, 'logger'): @@ -1013,6 +1028,12 @@ class VppTestResult(unittest.TestResult): if logger: logger.error(e) + def send_result_through_pipe(self, test, result): + if hasattr(self, 'test_framework_result_pipe'): + pipe = self.test_framework_result_pipe + if pipe: + pipe.send((test.id(), result)) + def addFailure(self, test, err): """ Record a test failed result @@ -1036,6 +1057,8 @@ class VppTestResult(unittest.TestResult): else: self.result_string = colorize("FAIL", RED) + ' [no temp dir]' + self.send_result_through_pipe(test, FAIL) + def addError(self, test, err): """ Record a test error result @@ -1059,6 +1082,8 @@ class VppTestResult(unittest.TestResult): else: self.result_string = colorize("ERROR", RED) + ' [no temp dir]' + self.send_result_through_pipe(test, ERROR) + def getDescription(self, test): """ Get test description @@ -1085,7 +1110,7 @@ class VppTestResult(unittest.TestResult): def stopTest(self, test): """ - Stop a test + Called when the given test has been run :param test: @@ -1100,6 +1125,8 @@ class VppTestResult(unittest.TestResult): self.stream.writeln("%-73s%s" % (self.getDescription(test), self.result_string)) + self.send_result_through_pipe(test, TEST_RUN) + def printErrors(self): """ Print errors from running the test case @@ -1135,7 +1162,8 @@ class VppTestRunner(unittest.TextTestRunner): return VppTestResult def __init__(self, keep_alive_pipe=None, descriptions=True, verbosity=1, - failfast=False, buffer=False, resultclass=None): + result_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, @@ -1144,6 +1172,8 @@ class VppTestRunner(unittest.TextTestRunner): reporter = KeepAliveReporter() reporter.pipe = keep_alive_pipe + VppTestResult.test_framework_result_pipe = result_pipe + def run(self, test): """ Run the tests