Skip to contentSkip to conversation

auto-t: iwd.py: remove StationDebug out of Device init

PATCH In review James Prestwood 2 participants 4 messages Jan 4, 2022

lore
Share & tools
lore

James Prestwood

author
#0 lore raw

PATCH 1/3 auto-t: iwd.py: remove StationDebug out of Device init

Since a Device class can represent multiple modes (AP, AdHoc, station) move StationDebug out of the init and only create this class when it is used (presumably only when the device is in station mode).

The StationDebug class is now created in a property method consistent with 'station_if'. If Device is not in station mode it is automatically switched if the test tries any StationDebug methods.

If the Device mode is changed from 'station' the StationDebug class instance is destroyed.

---
 autotests/util/iwd.py | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)
autotests/util/iwd.py +17 -7
index e95bd96d..7f511187 100755
@@ -280,17 +280,13 @@ class Device(IWDDBusAbstract):
     '''
     _iface_name = IWD_DEVICE_INTERFACE
 
-    def __init__(self, object_path = None, properties = None,
-                    service=IWD_SERVICE, namespace=ctx):
+    def __init__(self, *args, **kwargs):
         self._wps_manager_if = None
         self._station_if = None
         self._station_props = None
+        self._station_debug_obj = None
 
-        IWDDBusAbstract.__init__(self, object_path, properties, service,
-                                    namespace)
-
-        self._station_debug = StationDebug(object_path=object_path,
-                                            namespace=namespace)
+        IWDDBusAbstract.__init__(self, *args, **kwargs)
 
     @property
     def _wps_manager(self):
@@ -309,6 +305,17 @@ class Device(IWDDBusAbstract):
                                             IWD_STATION_INTERFACE)
         return self._station_if
 
+    @property
+    def _station_debug(self):
+        if self._properties['Mode'] != 'station':
+            self._prop_proxy.Set(IWD_DEVICE_INTERFACE, 'Mode', 'station')
+
+        if self._station_debug_obj is None:
+            self._station_debug_obj = StationDebug(object_path=self._object_path,
+                                                    namespace=self._namespace)
+
+        return self._station_debug_obj
+
     def _station_properties(self):
         if self._station_props is not None:
             return self._station_props
@@ -335,6 +342,9 @@ class Device(IWDDBusAbstract):
             for name, value in changed.items():
                 self._station_props[name] = value
 
+                if name == 'Mode' and value != 'station':
+                    self._station_debug_obj = None
+
     @property
     def device_path(self):
         '''
Signature · 1 line
2.31.1
author
#1 lore raw

PATCH 2/3 test-runner: only include comitted tests for full test runs

If specific tests are not specified with -A, only run tests tracked by git for full test runs.

---
 tools/test-runner | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
tools/test-runner +8 -3
index b5c4f777..4f16bd65 100755
@@ -1100,7 +1100,6 @@ def build_test_list(args):
 	'''
 	tests = []
 	test_root = args.testhome + '/autotests'
-	full_list = sorted(os.listdir(test_root))
 
 	# Run all tests
 	if not args.auto_tests:
@@ -1108,10 +1107,16 @@ def build_test_list(args):
 		if args.shell:
 			return [test_root + '/shell']
 
-		# Pair down any non-tests and append full path
-		tests = [test_root + '/' + t for t in full_list if t.startswith('test')]
+		# Get list of all autotests (committed in git)
+		tests = os.popen('git -C %s ls-files autotests/ | cut -f2 -d"/" \
+					| grep "test*" | uniq' % args.testhome).read() \
+					.strip().split('\n')
+		tests = [test_root + '/' + t for t in tests]
 	else:
 		print("Generating partial test list")
+
+		full_list = sorted(os.listdir(test_root))
+
 		for t in args.auto_tests.split(','):
 			path = '%s/%s' % (test_root, t)
 			if t.endswith('+'):
Signature · 1 line
2.31.1
author
#2 lore raw

PATCH 3/3 test-runner: don't copy __pycache__ in tests

In reply to James Prestwood

This is created by the python interpreter for speed optimization but poses problems if copied to /tmp since previous tests may have already copied it leading to an exception.

---
 tools/test-runner | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/test-runner +2 -1
index 4f16bd65..c35466c1 100755
@@ -1296,7 +1296,8 @@ def pre_test(ctx, test, copied):
 	subtests = [f for f in files if f.startswith('test') or \
 			os.path.splitext(f)[0].endswith('test')]
 	# Everything else (except .py files)
-	to_copy = [f for f in list(set(files) - set(subtests)) if not f.endswith('.py')]
+	to_copy = [f for f in list(set(files) - set(subtests)) if not f.endswith('.py') \
+								and f != '__pycache__']
 	for f in to_copy:
 		if os.path.isdir(f):
 			shutil.copytree(f, '/tmp/' + f)
Signature · 1 line
2.31.1
#3 lore raw
In reply to James Prestwood

Hi James,

Quoted 8 lines · James Prestwood

Since a Device class can represent multiple modes (AP, AdHoc, station) move StationDebug out of the init and only create this class when it is used (presumably only when the device is in station mode).

The StationDebug class is now created in a property method consistent with 'station_if'. If Device is not in station mode it is automatically switched if the test tries any StationDebug methods.

Quoted 6 lines

If the Device mode is changed from 'station' the StationDebug class instance is destroyed.

---
  autotests/util/iwd.py | 24 +++++++++++++++++-------
  1 file changed, 17 insertions(+), 7 deletions(-)

All applied, thanks.

Regards,
-Denis