Wireless Daemon for Linux
 help / color / mirror / Atom feed
* [PATCH 1/3] auto-t: iwd.py: remove StationDebug out of Device init
@ 2022-01-04 17:37 James Prestwood
  0 siblings, 0 replies; 2+ messages in thread
From: James Prestwood @ 2022-01-04 17:37 UTC (permalink / raw)
  To: iwd 

[-- Attachment #1: Type: text/plain, Size: 2626 bytes --]

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(-)

diff --git a/autotests/util/iwd.py b/autotests/util/iwd.py
index e95bd96d..7f511187 100755
--- a/autotests/util/iwd.py
+++ b/autotests/util/iwd.py
@@ -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):
         '''
-- 
2.31.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread
* Re: [PATCH 1/3] auto-t: iwd.py: remove StationDebug out of Device init
@ 2022-01-04 17:44 Denis Kenzior
  0 siblings, 0 replies; 2+ messages in thread
From: Denis Kenzior @ 2022-01-04 17:44 UTC (permalink / raw)
  To: iwd 

[-- Attachment #1: Type: text/plain, Size: 740 bytes --]

Hi James,

On 1/4/22 11:37, James Prestwood wrote:
> 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(-)
> 

All applied, thanks.

Regards,
-Denis

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-01-04 17:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-04 17:37 [PATCH 1/3] auto-t: iwd.py: remove StationDebug out of Device init James Prestwood
  -- strict thread matches above, loose matches on Subject: below --
2022-01-04 17:44 Denis Kenzior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox