Skip to contentSkip to conversation

auto-t: iwd.py: add wait argument to scan()

PATCH In review James Prestwood 2 participants 3 messages Feb 8, 2022 – Feb 10, 2022

lore
Share & tools
lore

James Prestwood

author
#0 lore raw

PATCH 1/2 auto-t: iwd.py: add wait argument to scan()

Lets the test continue without waiting for the method return

---
 autotests/util/iwd.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
autotests/util/iwd.py +3 -2
index 54b4819e..170dd96b 100755
@@ -450,7 +450,7 @@ class Device(IWDDBusAbstract):
         self._station_debug._prop_proxy.Set(IWD_STATION_DEBUG_INTERFACE,
                                             'AutoConnect', value)
 
-    def scan(self):
+    def scan(self, wait=True):
         '''Schedule a network scan.
 
            Possible exception: BusyEx
@@ -460,7 +460,8 @@ class Device(IWDDBusAbstract):
                                reply_handler=self._success,
                                error_handler=self._failure)
 
-        self._wait_for_async_op()
+        if wait:
+            self._wait_for_async_op()
 
     def disconnect(self):
         '''Disconnect from the network
Signature · 1 line
2.31.1
author
#1 lore raw

PATCH 2/2 auto-t: add test for fixed scanning crash

This simulates the conditions that trigger a free-after-use which was fixed with:

2c355db7 ("scan: remove periodic scans from queue on abort")

This behavior can be reproduced reliably using this test with the above patch reverted.

---
 autotests/testScan/remove_iface_test.py | 32 +++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 autotests/testScan/remove_iface_test.py
autotests/testScan/remove_iface_test.py new file +32 -0
new file mode 100644
index 00000000..af36c1e8
@@ -0,0 +1,32 @@
+#!/usr/bin/python3
+
+import unittest
+import sys
+import os
+
+sys.path.append('../util')
+from iwd import IWD
+from config import ctx
+
+class Test(unittest.TestCase):
+    def test_connection_success(self):
+        wd = IWD(True)
+
+        devices = wd.list_devices(1)
+        device = devices[0]
+
+        device.autoconnect = True
+        device.scan(wait=False)
+
+        os.system('ifconfig %s down' % device.name)
+
+    @classmethod
+    def setUpClass(cls):
+        pass
+
+    @classmethod
+    def tearDownClass(cls):
+        IWD.clear_storage()
+
+if __name__ == '__main__':
+    unittest.main(exit=True)
Signature · 1 line
2.31.1
#2 lore raw
In reply to James Prestwood

Hi James,

Quoted 5 lines · James Prestwood

Lets the test continue without waiting for the method return

---
  autotests/util/iwd.py | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)

Both applied, thanks.

Regards,
-Denis