3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-22 06:29:23 +01:00

auto-t: allow skipping tests is wpa_supplicant is not found

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.
This commit is contained in:
James Prestwood 2022-06-02 11:49:55 -07:00 committed by Denis Kenzior
parent 1296e4eacb
commit df46776046
4 changed files with 17 additions and 6 deletions

View File

@ -99,9 +99,9 @@ class Test(unittest.TestCase):
self.wpas.wait_for_event('DPP-CONF-RECEIVED', timeout=30) self.wpas.wait_for_event('DPP-CONF-RECEIVED', timeout=30)
def setUp(self): def setUp(self):
self.wpas = Wpas('wpas.conf')
self.wd = IWD(True) self.wd = IWD(True)
self.device = self.wd.list_devices(1)[0] self.device = self.wd.list_devices(1)[0]
self.wpas = Wpas('wpas.conf')
self.hapd = HostapdCLI('hostapd.conf') self.hapd = HostapdCLI('hostapd.conf')
self.hapd.disable() self.hapd.disable()
self.hwsim = Hwsim() self.hwsim = Hwsim()
@ -114,7 +114,6 @@ class Test(unittest.TestCase):
self.rule0.drop = True self.rule0.drop = True
def tearDown(self): def tearDown(self):
print("calling Disconnect()")
self.device.disconnect() self.device.disconnect()
self.device.dpp_stop() self.device.dpp_stop()
self.wpas.dpp_configurator_remove() self.wpas.dpp_configurator_remove()

View File

@ -29,8 +29,8 @@ class Test(unittest.TestCase):
self.p2p_connect_test(preauthorize=True, go=True) self.p2p_connect_test(preauthorize=True, go=True)
def p2p_connect_test(self, preauthorize, go): def p2p_connect_test(self, preauthorize, go):
wd = IWD()
wpas = self.wpas = Wpas(p2p=True) wpas = self.wpas = Wpas(p2p=True)
wd = IWD()
wpas_go_intent = 10 if not go else 1 wpas_go_intent = 10 if not go else 1
# Not strictly necessary but prevents the station interface from queuing its scans # Not strictly necessary but prevents the station interface from queuing its scans

View File

@ -1,8 +1,10 @@
#!/usr/bin/python3 #!/usr/bin/python3
import os import os
import socket import socket
import shutil
from gi.repository import GLib from gi.repository import GLib
from config import ctx from config import ctx
from unittest import SkipTest
import binascii import binascii
@ -11,7 +13,16 @@ from utils import Process
ctrl_count = 0 ctrl_count = 0
class Wpas: class Wpas:
io_watch = None
sockets = {}
wpa_supplicant = None
cleanup_paths = []
def _start_wpas(self, config_name=None, p2p=False): 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 main_interface = None
for interface in ctx.wpas_interfaces: for interface in ctx.wpas_interfaces:
if config_name is None or interface.config == config_name: 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_path = '/tmp/' + self.interface.config
self.config = self._get_config() self.config = self._get_config()
self.socket_path = self.config['ctrl_interface'] self.socket_path = self.config['ctrl_interface']
self.io_watch = None
cmd = ['wpa_supplicant', '-i', self.interface.name, '-c', self.config_path] cmd = ['wpa_supplicant', '-i', self.interface.name, '-c', self.config_path]
if Process.is_verbose('wpa_supplicant-dbg'): if Process.is_verbose('wpa_supplicant-dbg'):
@ -40,7 +50,6 @@ class Wpas:
self.wpa_supplicant = ctx.start_process(cmd) self.wpa_supplicant = ctx.start_process(cmd)
self.sockets = {} self.sockets = {}
self.cleanup_paths = []
self.io_watch = GLib.io_add_watch(self._get_socket(), GLib.IO_IN, self._handle_data_in) self.io_watch = GLib.io_add_watch(self._get_socket(), GLib.IO_IN, self._handle_data_in)
self.p2p_peers = {} self.p2p_peers = {}

View File

@ -425,10 +425,13 @@ class TestContext(Namespace):
return frequencies return frequencies
def start_wpas_interfaces(self): def start_wpas_interfaces(self):
if 'WPA_SUPPLICANT' not in self.hw_config: if 'WPA_SUPPLICANT' not in self.hw_config:
return return
if not shutil.which('wpa_supplicant'):
print('wpa_supplicant not found, dependent tests will be skipped')
return
settings = self.hw_config['WPA_SUPPLICANT'] settings = self.hw_config['WPA_SUPPLICANT']
if self.args.hw: if self.args.hw: