All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] auto-t: allow skipping tests is wpa_supplicant is not found
@ 2022-06-02 18:49 James Prestwood
  0 siblings, 0 replies; 2+ messages in thread
From: James Prestwood @ 2022-06-02 18:49 UTC (permalink / raw)
  To: iwd

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

Similarly to ofono/phonesim allow tests to be skipped if wpa_supplicant
is not found on the system.

This required some changes to DPP/P2P where Wpas() should be called first
since this can now throw a SkipTest exception.

The Wpas class was also made to allow __del__ to be called without
throwing additional exceptions in case wpa_supplicant was not found.
---
 autotests/testDPP/connection_test.py |  3 +--
 autotests/testP2P/connection_test.py |  2 +-
 autotests/util/wpas.py               | 13 +++++++++++--
 tools/run-tests                      |  5 ++++-
 4 files changed, 17 insertions(+), 6 deletions(-)

v2:
 * Fixed the check in Wpas.py, since wpa_supplicant isn't started yet this
   would always skip
 * Set self.sockets = {} in init since the class variable can remain set and
   stale for subsequent Wpas calls.

diff --git a/autotests/testDPP/connection_test.py b/autotests/testDPP/connection_test.py
index ab3cbf95..0f9b8f1c 100644
--- a/autotests/testDPP/connection_test.py
+++ b/autotests/testDPP/connection_test.py
@@ -99,9 +99,9 @@ class Test(unittest.TestCase):
         self.wpas.wait_for_event('DPP-CONF-RECEIVED', timeout=30)
 
     def setUp(self):
+        self.wpas = Wpas('wpas.conf')
         self.wd = IWD(True)
         self.device = self.wd.list_devices(1)[0]
-        self.wpas = Wpas('wpas.conf')
         self.hapd = HostapdCLI('hostapd.conf')
         self.hapd.disable()
         self.hwsim = Hwsim()
@@ -114,7 +114,6 @@ class Test(unittest.TestCase):
         self.rule0.drop = True
 
     def tearDown(self):
-        print("calling Disconnect()")
         self.device.disconnect()
         self.device.dpp_stop()
         self.wpas.dpp_configurator_remove()
diff --git a/autotests/testP2P/connection_test.py b/autotests/testP2P/connection_test.py
index f22f0682..383e0cef 100644
--- a/autotests/testP2P/connection_test.py
+++ b/autotests/testP2P/connection_test.py
@@ -29,8 +29,8 @@ class Test(unittest.TestCase):
         self.p2p_connect_test(preauthorize=True, go=True)
 
     def p2p_connect_test(self, preauthorize, go):
-        wd = IWD()
         wpas = self.wpas = Wpas(p2p=True)
+        wd = IWD()
         wpas_go_intent = 10 if not go else 1
 
         # Not strictly necessary but prevents the station interface from queuing its scans
diff --git a/autotests/util/wpas.py b/autotests/util/wpas.py
index 67b32d5f..c1a12b62 100644
--- a/autotests/util/wpas.py
+++ b/autotests/util/wpas.py
@@ -1,8 +1,10 @@
 #!/usr/bin/python3
 import os
 import socket
+import shutil
 from gi.repository import GLib
 from config import ctx
+from unittest import SkipTest
 
 import binascii
 
@@ -11,7 +13,16 @@ from utils import Process
 ctrl_count = 0
 
 class Wpas:
+    io_watch = None
+    sockets = {}
+    wpa_supplicant = None
+    cleanup_paths = []
+
     def _start_wpas(self, config_name=None, p2p=False):
+        if not shutil.which('wpa_supplicant'):
+            print('wpa_supplicant not found, skipping test')
+            raise SkipTest
+
         main_interface = None
         for interface in ctx.wpas_interfaces:
             if config_name is None or interface.config == config_name:
@@ -31,7 +42,6 @@ class Wpas:
         self.config_path = '/tmp/' + self.interface.config
         self.config = self._get_config()
         self.socket_path = self.config['ctrl_interface']
-        self.io_watch = None
 
         cmd = ['wpa_supplicant', '-i', self.interface.name, '-c', self.config_path]
         if Process.is_verbose('wpa_supplicant-dbg'):
@@ -40,7 +50,6 @@ class Wpas:
         self.wpa_supplicant = ctx.start_process(cmd)
 
         self.sockets = {}
-        self.cleanup_paths = []
         self.io_watch = GLib.io_add_watch(self._get_socket(), GLib.IO_IN, self._handle_data_in)
 
         self.p2p_peers = {}
diff --git a/tools/run-tests b/tools/run-tests
index a3644ce1..f65daf67 100755
--- a/tools/run-tests
+++ b/tools/run-tests
@@ -425,10 +425,13 @@ class TestContext(Namespace):
 		return frequencies
 
 	def start_wpas_interfaces(self):
-
 		if 'WPA_SUPPLICANT' not in self.hw_config:
 			return
 
+		if not shutil.which('wpa_supplicant'):
+			print('wpa_supplicant not found, dependent tests will be skipped')
+			return
+
 		settings = self.hw_config['WPA_SUPPLICANT']
 
 		if self.args.hw:
-- 
2.34.1

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

* Re: [PATCH v2] auto-t: allow skipping tests is wpa_supplicant is not found
@ 2022-06-02 21:47 Denis Kenzior
  0 siblings, 0 replies; 2+ messages in thread
From: Denis Kenzior @ 2022-06-02 21:47 UTC (permalink / raw)
  To: iwd

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

Hi James,

On 6/2/22 13:49, James Prestwood wrote:
> Similarly to ofono/phonesim allow tests to be skipped if wpa_supplicant
> is not found on the system.
> 
> This required some changes to DPP/P2P where Wpas() should be called first
> since this can now throw a SkipTest exception.
> 
> The Wpas class was also made to allow __del__ to be called without
> throwing additional exceptions in case wpa_supplicant was not found.
> ---
>   autotests/testDPP/connection_test.py |  3 +--
>   autotests/testP2P/connection_test.py |  2 +-
>   autotests/util/wpas.py               | 13 +++++++++++--
>   tools/run-tests                      |  5 ++++-
>   4 files changed, 17 insertions(+), 6 deletions(-)
> 

Applied, thanks.

Regards,
-Denis

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

end of thread, other threads:[~2022-06-02 21:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-02 18:49 [PATCH v2] auto-t: allow skipping tests is wpa_supplicant is not found James Prestwood
2022-06-02 21:47 Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.