X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=test%2Fframework.py;h=d0191c0dd45dc704c756a718337886aa54b7acd2;hb=16782368979b3af7918e54b6998c0b14dbb16da2;hp=be8c209f4ea277c2b972f668d87463d8a2f37df6;hpb=c8efa29b6f9a91381897b54f1147daf922ed7164;p=vpp.git diff --git a/test/framework.py b/test/framework.py index be8c209f4ea..d0191c0dd45 100644 --- a/test/framework.py +++ b/test/framework.py @@ -83,7 +83,7 @@ def pump_output(testclass): """ pump output from vpp stdout/stderr to proper queues """ stdout_fragment = "" stderr_fragment = "" - while not testclass.pump_thread_stop_flag.wait(0): + while not testclass.pump_thread_stop_flag.is_set(): readable = select.select([testclass.vpp.stdout.fileno(), testclass.vpp.stderr.fileno(), testclass.pump_thread_wakeup_pipe[0]], @@ -391,8 +391,8 @@ class VppTestCase(unittest.TestCase): raw_input("When done debugging, press ENTER to kill the " "process and finish running the testcase...") - os.write(cls.pump_thread_wakeup_pipe[1], 'ding dong wake up') cls.pump_thread_stop_flag.set() + os.write(cls.pump_thread_wakeup_pipe[1], 'ding dong wake up') if hasattr(cls, 'pump_thread'): cls.logger.debug("Waiting for pump thread to stop") cls.pump_thread.join() @@ -558,18 +558,16 @@ class VppTestCase(unittest.TestCase): return result @classmethod - def create_loopback_interfaces(cls, interfaces): + def create_loopback_interfaces(cls, count): """ Create loopback interfaces. - :param interfaces: iterable indexes of the interfaces. + :param count: number of interfaces created. :returns: List of created interfaces. """ - result = [] - for i in interfaces: - intf = VppLoInterface(cls, i) + result = [VppLoInterface(cls) for i in range(count)] + for intf in result: setattr(cls, intf.name, intf) - result.append(intf) cls.lo_interfaces = result return result @@ -839,12 +837,13 @@ class VppTestCase(unittest.TestCase): "Finished sleep (%s) - slept %ss (wanted %ss)" % ( remark, after - before, timeout)) - def send_and_assert_no_replies(self, intf, pkts, remark=""): + def send_and_assert_no_replies(self, intf, pkts, remark="", timeout=None): self.vapi.cli("clear trace") intf.add_stream(pkts) self.pg_enable_capture(self.pg_interfaces) self.pg_start() - timeout = 1 + if not timeout: + timeout = 1 for i in self.pg_interfaces: i.get_capture(0, timeout=timeout) i.assert_nothing_captured(remark=remark) @@ -959,7 +958,25 @@ class VppTestResult(unittest.TestResult): if hasattr(self, 'test_framework_failed_pipe'): pipe = self.test_framework_failed_pipe if pipe: - pipe.send(test.__class__) + if test.__class__.__name__ == "_ErrorHolder": + x = str(test) + if x.startswith("setUpClass"): + # x looks like setUpClass (test_function.test_class) + cls = x.split(".")[1].split(")")[0] + for t in self.test_suite: + if t.__class__.__name__ == cls: + pipe.send(t.__class__) + break + else: + raise Exception("Can't find class name `%s' " + "(from ErrorHolder) in test suite " + "`%s'" % (cls, self.test_suite)) + else: + raise Exception("FIXME: unexpected special case - " + "ErrorHolder description is `%s'" % + str(test)) + else: + pipe.send(test.__class__) def addFailure(self, test, err): """ @@ -1194,6 +1211,8 @@ class VppTestRunner(unittest.TextTestRunner): filtered.countTestCases(), test.countTestCases())) if not running_extended_tests(): print("Not running extended tests (some tests will be skipped)") + # super-ugly hack #2 + VppTestResult.test_suite = filtered return super(VppTestRunner, self).run(filtered)