tests: fix worker thread initialization 03/23803/4
authorPaul Vinciguerra <pvinci@vinciconsulting.com>
Thu, 5 Dec 2019 00:43:53 +0000 (19:43 -0500)
committerDave Wallace <dwallacelf@gmail.com>
Tue, 14 Jan 2020 19:33:23 +0000 (19:33 +0000)
from threading.thread __init__:

    This constructor should always be called with keyword arguments.

    If a subclass overrides the constructor, it must make sure to invoke
    the base class constructor (Thread.__init__()) before doing anything
    else to the thread.

Type: test
Change-Id: Ifa89202e97053a4baf19e9a0ca0913430d5087a3
Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
src/plugins/quic/test/test_quic.py
src/vcl/test/test_vcl.py
test/framework.py

index 152fa5e..4534c8e 100644 (file)
@@ -14,14 +14,17 @@ class QUICAppWorker(Worker):
     """ QUIC Test Application Worker """
     process = None
 
-    def __init__(self, build_dir, appname, args, logger, role, testcase,
-                 env={}):
+    def __init__(self, build_dir, appname, executable_args, logger, role,
+                 testcase, env=None, *args, **kwargs):
+        if env is None:
+            env = {}
         app = "%s/vpp/bin/%s" % (build_dir, appname)
-        self.args = [app] + args
+        self.args = [app] + executable_args
         self.role = role
         self.wait_for_gdb = 'wait-for-gdb'
         self.testcase = testcase
-        super(QUICAppWorker, self).__init__(self.args, logger, env)
+        super(QUICAppWorker, self).__init__(self.args, logger, env,
+                                            *args, **kwargs)
 
     def run(self):
         super(QUICAppWorker, self).run()
index 804e745..d7a44ed 100644 (file)
@@ -26,7 +26,11 @@ _have_iperf3 = have_app(iperf3)
 class VCLAppWorker(Worker):
     """ VCL Test Application Worker """
 
-    def __init__(self, build_dir, appname, args, logger, env={}):
+    def __init__(self, build_dir, appname, executable_args, logger, env=None,
+                 *args, **kwargs):
+
+        if env is None:
+            env = {}
         vcl_lib_dir = "%s/vpp/lib" % build_dir
         if "iperf" in appname:
             app = appname
@@ -38,8 +42,9 @@ class VCLAppWorker(Worker):
                         "%s/libvcl_ldpreload.so" % vcl_lib_dir})
         else:
             app = "%s/vpp/bin/%s" % (build_dir, appname)
-        self.args = [app] + args
-        super(VCLAppWorker, self).__init__(self.args, logger, env)
+        self.args = [app] + executable_args
+        super(VCLAppWorker, self).__init__(self.args, logger, env,
+                                           *args, **kwargs)
 
 
 class VCLTestCase(VppTestCase):
index e08c9a1..ba45765 100644 (file)
@@ -1496,16 +1496,17 @@ class VppTestRunner(unittest.TextTestRunner):
 
 
 class Worker(Thread):
-    def __init__(self, args, logger, env=None):
+    def __init__(self, executable_args, logger, env=None, *args, **kwargs):
+        super(Worker, self).__init__(*args, **kwargs)
         self.logger = logger
-        self.args = args
+        self.args = executable_args
         if hasattr(self, 'testcase') and self.testcase.debug_all:
             if self.testcase.debug_gdbserver:
                 self.args = ['/usr/bin/gdbserver', 'localhost:{port}'
                              .format(port=self.testcase.gdbserver_port)] + args
             elif self.testcase.debug_gdb and hasattr(self, 'wait_for_gdb'):
                 self.args.append(self.wait_for_gdb)
-        self.app_bin = args[0]
+        self.app_bin = executable_args[0]
         self.app_name = os.path.basename(self.app_bin)
         if hasattr(self, 'role'):
             self.app_name += ' {role}'.format(role=self.role)
@@ -1513,7 +1514,6 @@ class Worker(Thread):
         self.result = None
         env = {} if env is None else env
         self.env = copy.deepcopy(env)
-        super(Worker, self).__init__()
 
     def wait_for_enter(self):
         if not hasattr(self, 'testcase'):