X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=test%2Fframework.py;h=604e342a4668ad35c2d122b771a5bdfd1d353c09;hb=23c9a2e5d143de2007a750369e4c796d354ca347;hp=859010cf325d90f9970131244945455defd293a2;hpb=14d7e90788f87a4b7b174bb5a67171f8c9a7f842;p=vpp.git diff --git a/test/framework.py b/test/framework.py index 859010cf325..604e342a466 100644 --- a/test/framework.py +++ b/test/framework.py @@ -40,6 +40,12 @@ if os.name == 'posix' and sys.version_info[0] < 3: else: import subprocess +# Python2/3 compatible +try: + input = raw_input +except NameError: + pass + PASS = 0 FAIL = 1 ERROR = 2 @@ -132,23 +138,31 @@ def pump_output(testclass): # flag will take care of properly terminating the loop -def is_skip_aarch64_set(): +def _is_skip_aarch64_set(): return os.getenv('SKIP_AARCH64', 'n').lower() in ('yes', 'y', '1') +is_skip_aarch64_set = _is_skip_aarch64_set() + -def is_platform_aarch64(): +def _is_platform_aarch64(): return platform.machine() == 'aarch64' +is_platform_aarch64 = _is_platform_aarch64() -def running_extended_tests(): + +def _running_extended_tests(): s = os.getenv("EXTENDED_TESTS", "n") return True if s.lower() in ("y", "yes", "1") else False +running_extended_tests = _running_extended_tests() + -def running_on_centos(): +def _running_on_centos(): os_id = os.getenv("OS_ID", "") return True if "centos" in os_id.lower() else False +running_on_centos = _running_on_centos + class KeepAliveReporter(object): """ @@ -192,6 +206,7 @@ class VppTestCase(unittest.TestCase): """ extra_vpp_punt_config = [] + extra_vpp_plugin_config = [] @property def packet_infos(self): @@ -307,7 +322,7 @@ class VppTestCase(unittest.TestCase): "{", "socket-name", cls.stats_sock, "}", "plugins", "{", "plugin", "dpdk_plugin.so", "{", "disable", "}", "plugin", "unittest_plugin.so", "{", "enable", - "}", "}", ] + "}"] + cls.extra_vpp_plugin_config + ["}", ] if cls.extra_vpp_punt_config is not None: cls.vpp_cmdline.extend(cls.extra_vpp_punt_config) if plugin_path is not None: @@ -338,7 +353,7 @@ class VppTestCase(unittest.TestCase): print("Now is the time to attach a gdb by running the above " "command and set up breakpoints etc.") print(single_line_delim) - raw_input("Press ENTER to continue running the testcase...") + input("Press ENTER to continue running the testcase...") @classmethod def run_vpp(cls): @@ -478,8 +493,8 @@ class VppTestCase(unittest.TestCase): print(double_line_delim) print("VPP or GDB server is still running") print(single_line_delim) - raw_input("When done debugging, press ENTER to kill the " - "process and finish running the testcase...") + input("When done debugging, press ENTER to kill the " + "process and finish running the testcase...") # first signal that we want to stop the pump thread, then wake it up if hasattr(cls, 'pump_thread_stop_flag'): @@ -962,12 +977,7 @@ class VppTestCase(unittest.TestCase): input.add_stream(pkts) self.pg_enable_capture(self.pg_interfaces) self.pg_start() - if isinstance(object, (list,)): - rx = [] - for o in output: - rx.append(output.get_capture(len(pkts))) - else: - rx = output.get_capture(len(pkts)) + rx = output.get_capture(len(pkts)) return rx def send_and_expect_only(self, input, pkts, output, timeout=None): @@ -975,14 +985,8 @@ class VppTestCase(unittest.TestCase): input.add_stream(pkts) self.pg_enable_capture(self.pg_interfaces) self.pg_start() - if isinstance(object, (list,)): - outputs = output - rx = [] - for o in outputs: - rx.append(output.get_capture(len(pkts))) - else: - rx = output.get_capture(len(pkts)) - outputs = [output] + rx = output.get_capture(len(pkts)) + outputs = [output] if not timeout: timeout = 1 for i in self.pg_interfaces: @@ -993,6 +997,11 @@ class VppTestCase(unittest.TestCase): return rx + def runTest(self): + """ unittest calls runTest when TestCase is instantiated without a + test case. Use case: Writing unittests against VppTestCase""" + pass + def get_testcase_doc_name(test): return getdoc(test.__class__).splitlines()[0]