From patchwork Wed Jul 6 16:56:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Zaborowski X-Patchwork-Id: 12908345 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CEB72258B for ; Wed, 6 Jul 2022 16:57:16 +0000 (UTC) Received: by mail-wr1-f48.google.com with SMTP id d16so16594750wrv.10 for ; Wed, 06 Jul 2022 09:57:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=gGI1wCmQvj/N+jA37xl5HKk6D75ZqD07F9XxN2vOrLY=; b=lHjWF3tdAop2/i47b/E+76N8/W50p3MDK7g76umU4G6bJa1y+o4YTQXcrz+wHYgEg7 sbqzmtVALmdA0/OzyfUqMUpRUocwUFGe1dSbtGNQVjXEnrFrF61g/+kZgG7ahiO4I3KL NoRl480LSnjDCSmY3VdRp6hou5vvxzpJTVRjbxy7JiznnFspx13Eut//Y5Avb8V5P6Ue G75semyWxA7JzQ0MmnY4zThdSy6UHxVKMXnqSH64t8nOWMszkGoZ4gA2w5RoFbKds5jf 0apnroHtIgC8YdZucNrg8Q3+VOFpNLO6w46Poa5nl1iLrFJAdUElVVi8D7/Focja5reT znuQ== X-Gm-Message-State: AJIora8zbtdn2rJIxSoyt4WZq9JVyWeE+YsGPuoek4L1450z5cq+Ba0+ 1hjd8+lRiyxsCZVzUfIov8uo3A2wR9zUvznj X-Google-Smtp-Source: AGRyM1uYR/3WId05o/IvBIPRx6J8RfpCf/fXyld/uDa7ulbUZvQtXr5sri5F4QLUOfudb2hUs6bhuQ== X-Received: by 2002:a5d:47a5:0:b0:21d:19b8:f8fe with SMTP id 5-20020a5d47a5000000b0021d19b8f8femr38115777wrb.23.1657126634636; Wed, 06 Jul 2022 09:57:14 -0700 (PDT) Received: from localhost.localdomain ([46.222.51.165]) by smtp.gmail.com with ESMTPSA id j8-20020a05600c190800b0039c5642e430sm29147856wmq.20.2022.07.06.09.57.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jul 2022 09:57:14 -0700 (PDT) From: Andrew Zaborowski To: iwd@lists.linux.dev Subject: [PATCH 1/5] test-runner: Support running hostapd in namespaces Date: Wed, 6 Jul 2022 18:56:58 +0200 Message-Id: <20220706165702.3241756-1-andrew.zaborowski@intel.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The kernel will not let us test some scenarios of communication between two hwsim radios (e.g. STA and AP) if they're in the same net namespace. For example, when connected, you can't add normal IPv4 subnet routes for the same subnet on two different interfaces in one namespace (you'd either get an EEXIST or you'd replace the other route), you can set different metrics on the routes but that won't fix IP routing. For testNetconfig the result is that communication works for DHCP before we get the inital lease but renewals won't work because they're unicast. Allow hostapd to run on a radio that has been moved to a different namespace in hw.conf so we don't have to work around these issues. --- tools/run-tests | 80 +++++++++++++++++++++++++++++++------------------ tools/utils.py | 2 +- 2 files changed, 52 insertions(+), 30 deletions(-) diff --git a/tools/run-tests b/tools/run-tests index 565847df..f916fba6 100755 --- a/tools/run-tests +++ b/tools/run-tests @@ -58,16 +58,19 @@ def exit_vm(): runner.stop() class Interface: - def __init__(self, name, config): + def __init__(self, name, config, ns=None): self.name = name self.ctrl_interface = '/var/run/hostapd/' + name self.config = config + self.ns = ns def __del__(self): - Process(['iw', 'dev', self.name, 'del']).wait() + Process(['iw', 'dev', self.name, 'del'], + namespace=self.ns.name if self.ns else None).wait() def set_interface_state(self, state): - Process(['ip', 'link', 'set', self.name, state]).wait() + Process(['ip', 'link', 'set', self.name, state], + namespace=self.ns.name if self.ns else None).wait() class Radio: def __init__(self, name): @@ -75,11 +78,16 @@ class Radio: # hostapd will reset this if this radio is used by it self.use = 'iwd' self.interface = None + self.ns = None def __del__(self): print("Removing radio %s" % self.name) self.interface = None + def set_namespace(self, ns): + self.ns = ns + Process(['iw', 'phy', self.name, 'set', 'netns', 'name', ns.name]).wait() + def create_interface(self, config, use): global intf_id @@ -87,19 +95,21 @@ class Radio: intf_id += 1 - self.interface = Interface(ifname, config) + self.interface = Interface(ifname, config, ns=self.ns) self.use = use Process(['iw', 'phy', self.name, 'interface', 'add', ifname, - 'type', 'managed']).wait() + 'type', 'managed'], namespace=self.ns.name if self.ns else None).wait() return self.interface def __str__(self): ret = self.name + ':\n' - ret += '\tUsed By: %s ' % self.use + ret += '\tUsed By: %s' % self.use if self.interface: - ret += '(%s)' % self.interface.name + ret += ' (%s)' % self.interface.name + if self.ns is not None: + ret += ' (ns=%s)' % self.ns.name ret += '\n' @@ -188,7 +198,7 @@ class Hostapd: A set of running hostapd instances. This is really just a single process since hostapd can be started with multiple config files. ''' - def __init__(self, radios, configs, radius): + def __init__(self, ns, radios, configs, radius): if len(configs) != len(radios): raise Exception("Config (%d) and radio (%d) list length not equal" % \ (len(configs), len(radios))) @@ -198,8 +208,8 @@ class Hostapd: Process(['ip', 'link', 'set', 'eth0', 'up']).wait() Process(['ip', 'link', 'set', 'eth1', 'up']).wait() - self.global_ctrl_iface = '/var/run/hostapd/ctrl' - + self.ns = ns + self.global_ctrl_iface = '/var/run/hostapd/ctrl' + (str(ns.name) if ns.name else 'main') self.instances = [HostapdInstance(c, r) for c, r in zip(configs, radios)] ifaces = [rad.interface.name for rad in radios] @@ -227,7 +237,7 @@ class Hostapd: if Process.is_verbose('hostapd'): args.append('-d') - self.process = Process(args) + self.process = Process(args, namespace=ns.name) self.process.wait_for_socket(self.global_ctrl_iface, 30) @@ -397,32 +407,42 @@ class TestContext(Namespace): # tests. In this case you would not care what # was using each radio, just that there was # enough to run all tests. - nradios = 0 - for k, _ in settings.items(): - if k == 'radius_server': - continue - nradios += 1 - - hapd_radios = self.radios[:nradios] - + hapd_configs = [conf for rad, conf in settings.items() if rad != 'radius_server'] + hapd_processes = [(self, self.radios[:len(hapd_configs)], hapd_configs)] else: - hapd_radios = [rad for rad in self.radios if rad.name in settings] - - hapd_configs = [conf for rad, conf in settings.items() if rad != 'radius_server'] + hapd_processes = [] + for ns in [self] + self.namespaces: + ns_radios = [rad for rad in ns.radios if rad.name in settings] + if len(ns_radios): + ns_configs = [settings[rad.name] for rad in ns_radios] + hapd_processes.append((ns, ns_radios, ns_configs)) radius_config = settings.get('radius_server', None) - self.hostapd = Hostapd(hapd_radios, hapd_configs, radius_config) - self.hostapd.attach_cli() + self.hostapd = [Hostapd(ns, radios, configs, radius_config) + for ns, radios, configs in hapd_processes] + + for hapd in self.hostapd: + hapd.attach_cli() def get_frequencies(self): frequencies = [] - for hapd in self.hostapd.instances: - frequencies.append(hapd.cli.frequency) + for hapd in self.hostapd: + frequencies += [instance.cli.frequency for instance in hapd.instances] return frequencies + def get_hapd_instance(self, config=None): + instances = [i for hapd in self.hostapd for i in hapd.instances] + + if config is None: + return instances[0] + + for hapd in instances: + if hapd.config == config: + return hapd + def start_wpas_interfaces(self): if 'WPA_SUPPLICANT' not in self.hw_config: return @@ -543,11 +563,13 @@ class TestContext(Namespace): for arg in vars(self.args): ret += '\t --%s %s\n' % (arg, str(getattr(self.args, arg))) - ret += 'Hostapd:\n' if self.hostapd: - for h in self.hostapd.instances: - ret += '\t%s\n' % str(h) + for hapd in self.hostapd: + ret += 'Hostapd (ns=%s):\n' % (hapd.ns.name,) + for h in hapd.instances: + ret += '\t%s\n' % (str(h),) else: + ret += 'Hostapd:\n' ret += '\tNo Hostapd instances\n' info = self.meminfo_to_dict() diff --git a/tools/utils.py b/tools/utils.py index f3e12a85..bc030230 100644 --- a/tools/utils.py +++ b/tools/utils.py @@ -324,7 +324,7 @@ class Namespace: Process(['ip', 'netns', 'add', name]).wait() for r in radios: - Process(['iw', 'phy', r.name, 'set', 'netns', 'name', name]).wait() + r.set_namespace(self) self.start_dbus() From patchwork Wed Jul 6 16:56:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Zaborowski X-Patchwork-Id: 12908346 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 007D52F38 for ; Wed, 6 Jul 2022 16:57:18 +0000 (UTC) Received: by mail-wr1-f54.google.com with SMTP id v16so11470613wrd.13 for ; Wed, 06 Jul 2022 09:57:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dLeBLlFb2VWCq8mi5cBvb2tZCHs9jRN+Oh5Yaj39gms=; b=pKJTAPgevxxI/KWrkR4Mgy+Q7qkPQJrSI5wRy5TPxWGqpSjnuovvruuXJ6KIFRSOfc E9VhVG6k2AmQgALvHC4a1jaXMo6WY/ygmy8hlKQNRMXGAE2XJgEJeRNPyt8cn9Mt2Km2 S8Uh0QEQMegZSxL97D/eh2yZ1QkXqQP5hItjEikWUUXqBffiybngLTEkmSgOJtWjodGB ThR8ZNcQ8gtDeUFisF02GKZeIkTCG2kQ5EfOG29KEF+v4ulczvpuaKWZg/teTU7BZIVV 0un2xTtV9E8V4i8DXRCnnRCCCVHv0KNWYUD/4haropxCZEjLw52kG3oqBJln7p78Fyv1 vWSg== X-Gm-Message-State: AJIora+mJPyzkAjE3uoPxTtPXEaI5PpjkJoPjSdEkDv3WRYVH1CJwVrI TSxLpZisXEiuXyFPgUNLL8dInNCYvjPJYcuZ X-Google-Smtp-Source: AGRyM1u3zXGH9vN7MeEgackwQ25Tat5lGs+0mhtvihH6L5Ch6CwOINUBWyNC+4aF6WdU+P6GAT+hIQ== X-Received: by 2002:adf:fb43:0:b0:21a:22eb:da43 with SMTP id c3-20020adffb43000000b0021a22ebda43mr38027339wrs.347.1657126636556; Wed, 06 Jul 2022 09:57:16 -0700 (PDT) Received: from localhost.localdomain ([46.222.51.165]) by smtp.gmail.com with ESMTPSA id j8-20020a05600c190800b0039c5642e430sm29147856wmq.20.2022.07.06.09.57.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jul 2022 09:57:16 -0700 (PDT) From: Andrew Zaborowski To: iwd@lists.linux.dev Subject: [PATCH 2/5] autotests: DHCPv4 renewal/resend test in testNetconfig Date: Wed, 6 Jul 2022 18:56:59 +0200 Message-Id: <20220706165702.3241756-2-andrew.zaborowski@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220706165702.3241756-1-andrew.zaborowski@intel.com> References: <20220706165702.3241756-1-andrew.zaborowski@intel.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Test that the DHCPv4 lease got renewed after the T1 timer runs out. Then also simulate the DHCPREQUEST during renew being lost and retransmitted and the lease eventually getting renewed T1 + 60s later. The main downside is that this test will inevitably take a while if running in Qemu without the time travel ability. Update the test and some utility code to run hostapd in an isolated net namespace for connection_test.py. We now need a second hostapd instance though because in static_test.py we test ACD and we need to produce an IP conflict. Moving the hostapd instance unexpectedly fixes dhcpd's internal mechanism to avoid IP conflicts and it would no longer assign 192.168.1.10 to the second client, it'd notice that address was already in use and assign the next free address, or fail if there was none. So add a second hostapd instance that runs in the main namespace together with the statically-configured client, it turns out the test relies on the kernel being unable to deliver IP traffic to interfaces on the same system. --- .../{ssidTKIP.conf => ap-main.conf} | 2 +- autotests/testNetconfig/ap-ns1.conf | 7 + autotests/testNetconfig/connection_test.py | 195 +++++++++++++++--- autotests/testNetconfig/dhcpd.conf | 14 +- autotests/testNetconfig/hw.conf | 8 +- .../{ssidTKIP.psk => static.psk} | 0 autotests/testNetconfig/static_test.py | 8 +- autotests/util/hostapd.py | 6 +- 8 files changed, 202 insertions(+), 38 deletions(-) rename autotests/testNetconfig/{ssidTKIP.conf => ap-main.conf} (83%) create mode 100644 autotests/testNetconfig/ap-ns1.conf rename autotests/testNetconfig/{ssidTKIP.psk => static.psk} (100%) diff --git a/autotests/testNetconfig/ssidTKIP.conf b/autotests/testNetconfig/ap-main.conf similarity index 83% rename from autotests/testNetconfig/ssidTKIP.conf rename to autotests/testNetconfig/ap-main.conf index 11ef15f0..0ec7fdfa 100644 --- a/autotests/testNetconfig/ssidTKIP.conf +++ b/autotests/testNetconfig/ap-main.conf @@ -1,6 +1,6 @@ hw_mode=g channel=1 -ssid=ssidTKIP +ssid=ap-main wpa=1 wpa_pairwise=TKIP diff --git a/autotests/testNetconfig/ap-ns1.conf b/autotests/testNetconfig/ap-ns1.conf new file mode 100644 index 00000000..5459173f --- /dev/null +++ b/autotests/testNetconfig/ap-ns1.conf @@ -0,0 +1,7 @@ +hw_mode=g +channel=1 +ssid=ap-ns1 + +wpa=1 +wpa_pairwise=TKIP +wpa_passphrase=secret123 diff --git a/autotests/testNetconfig/connection_test.py b/autotests/testNetconfig/connection_test.py index 5481e624..aebb0a2e 100644 --- a/autotests/testNetconfig/connection_test.py +++ b/autotests/testNetconfig/connection_test.py @@ -13,6 +13,7 @@ import testutil from config import ctx import os import socket +import datetime, time class Test(unittest.TestCase): @@ -27,6 +28,14 @@ class Test(unittest.TestCase): return True + def get_ll_addrs6(ns, ifname): + show_ip = ns.start_process(['ip', 'addr', 'show', ifname]) + show_ip.wait() + for l in show_ip.out.split('\n'): + if 'inet6 fe80::' in l: + return socket.inet_pton(socket.AF_INET6, l.split(None, 1)[1].split('/', 1)[0]) + return None + wd = IWD(True) psk_agent = PSKAgent("secret123") @@ -35,7 +44,7 @@ class Test(unittest.TestCase): devices = wd.list_devices(1) device = devices[0] - ordered_network = device.get_ordered_network('ssidTKIP') + ordered_network = device.get_ordered_network('ap-ns1') self.assertEqual(ordered_network.type, NetworkType.psk) @@ -46,18 +55,21 @@ class Test(unittest.TestCase): condition = 'obj.state == DeviceState.connected' wd.wait_for_object_condition(device, condition) + connect_time = time.time() testutil.test_iface_operstate() - testutil.test_ifaces_connected() testutil.test_ip_address_match(device.name, '192.168.1.10', 17, 24) ctx.non_block_wait(check_addr, 10, device, exception=Exception("IPv6 address was not set")) + # Cannot use test_ifaces_connected() across namespaces (implementation details) + testutil.test_ip_connected(('192.168.1.10', ctx), ('192.168.1.1', self.ns1)) + ifname = str(device.name) - router_ll_addr = [addr for addr, _, _ in testutil.get_addrs6(self.hapd.ifname) if addr[0:2] == b'\xfe\x80'][0] + router_ll_addr = get_ll_addrs6(self.ns1, self.hapd.ifname) # Since we're in an isolated VM with freshly created interfaces we know any routes - # will have been created by IWD and don't have to allow for pre-existing routes + # will have been created by IWD and we don't have to allow for pre-existing routes # in the table. # Flags: 1=RTF_UP, 2=RTF_GATEWAY expected_routes4 = { @@ -94,6 +106,67 @@ class Test(unittest.TestCase): # of our log since we care about the end result here. self.assertEqual(expected_rclog, entries[-3:]) + leases_file = self.parse_lease_file('/tmp/dhcpd.leases', socket.AF_INET) + lease = leases_file['leases'][socket.inet_pton(socket.AF_INET, '192.168.1.10')] + self.assertEqual(lease['state'], 'active') + self.assertTrue(lease['starts'] < connect_time) + self.assertTrue(lease['ends'] > connect_time) + # The T1 is 15 seconds per dhcpd.conf. This is the approximate interval between lease + # renewals we should see from the client (+/- 1 second + some jitter). Wait a little + # less than twice that time (25s) so that we can expect the lease was renewed strictly + # once (not 0 or 2 times) by that time, check that the lease timestamps have changed by + # at least 10s so as to leave a lot of margin. + renew_time = lease['starts'] + 15 + now = time.time() + ctx.non_block_wait(lambda: False, renew_time + 10 - now, exception=False) + + leases_file = self.parse_lease_file('/tmp/dhcpd.leases', socket.AF_INET) + new_lease = leases_file['leases'][socket.inet_pton(socket.AF_INET, '192.168.1.10')] + self.assertEqual(new_lease['state'], 'active') + self.assertTrue(new_lease['starts'] > lease['starts'] + 10) + self.assertTrue(new_lease['starts'] < lease['starts'] + 25) + self.assertTrue(new_lease['ends'] > lease['ends'] + 10) + self.assertTrue(new_lease['ends'] < lease['ends'] + 25) + + # Now wait another T1 seconds but don't let our DHCP client get its REQUEST out this + # time so as to test renew timeouts and resends. The retry interval is 60 seconds + # since (T2 - T1) / 2 is shorter than 60s. It is now about 10s since the last + # renewal or 5s before the next DHCPREQUEST frame that is going to be lost. We'll + # wait T1 seconds, so until about 10s after the failed attempt, we'll check that + # there was no renewal by that time, just in case, and we'll reenable frame delivery. + # We'll then wait another 60s and we should see the lease has been successfully + # renewed some 10 seconds earlier on the 1st DHCPREQUEST retransmission. + # + # We can't use hswim to block the frames from reaching the AP because we'd lose + # beacons and get disconnected. We also can't drop our subnet route or IP address + # because IWD's sendto() call would synchronously error out and the DHCP client + # would just give up. Add a false route to break routing to 192.168.1.1 and delete + # it afterwards. + os.system('ip route add 192.168.1.1/32 dev ' + ifname + ' via 192.168.1.100 preference 0') + + lease = new_lease + renew_time = lease['starts'] + 15 + now = time.time() + ctx.non_block_wait(lambda: False, renew_time + 10 - now, exception=False) + + leases_file = self.parse_lease_file('/tmp/dhcpd.leases', socket.AF_INET) + new_lease = leases_file['leases'][socket.inet_pton(socket.AF_INET, '192.168.1.10')] + self.assertEqual(new_lease['starts'], lease['starts']) + + os.system('ip route del 192.168.1.1/32 dev ' + ifname + ' via 192.168.1.100 preference 0') + + retry_time = lease['starts'] + 75 + now = time.time() + ctx.non_block_wait(lambda: False, retry_time + 10 - now, exception=False) + + leases_file = self.parse_lease_file('/tmp/dhcpd.leases', socket.AF_INET) + new_lease = leases_file['leases'][socket.inet_pton(socket.AF_INET, '192.168.1.10')] + self.assertEqual(new_lease['state'], 'active') + self.assertTrue(new_lease['starts'] > lease['starts'] + 70) + self.assertTrue(new_lease['starts'] < lease['starts'] + 85) + self.assertTrue(new_lease['ends'] > lease['ends'] + 70) + self.assertTrue(new_lease['ends'] < lease['ends'] + 85) + device.disconnect() condition = 'not obj.connected' @@ -116,25 +189,27 @@ class Test(unittest.TestCase): except: pass - hapd = HostapdCLI() - cls.hapd = hapd + cls.ns1 = ctx.get_namespace('ns1') + cls.hapd = HostapdCLI('ap-ns1.conf') # TODO: This could be moved into test-runner itself if other tests ever # require this functionality (p2p, FILS, etc.). Since its simple # enough it can stay here for now. - ctx.start_process(['ip', 'addr','add', '192.168.1.1/255.255.128.0', - 'dev', hapd.ifname,]).wait() - ctx.start_process(['touch', '/tmp/dhcpd.leases']).wait() - cls.dhcpd_pid = ctx.start_process(['dhcpd', '-f', '-cf', '/tmp/dhcpd.conf', - '-lf', '/tmp/dhcpd.leases', - hapd.ifname], cleanup=remove_lease4) - - ctx.start_process(['ip', 'addr', 'add', '3ffe:501:ffff:100::1/72', - 'dev', hapd.ifname]).wait() - ctx.start_process(['touch', '/tmp/dhcpd6.leases']).wait() - cls.dhcpd6_pid = ctx.start_process(['dhcpd', '-6', '-f', '-cf', '/tmp/dhcpd-v6.conf', - '-lf', '/tmp/dhcpd6.leases', - hapd.ifname], cleanup=remove_lease6) - ctx.start_process(['sysctl', 'net.ipv6.conf.' + hapd.ifname + '.forwarding=1']).wait() + cls.ns1.start_process(['ip', 'addr','add', '192.168.1.1/17', + 'dev', cls.hapd.ifname]).wait() + cls.ns1.start_process(['touch', '/tmp/dhcpd.leases']).wait() + cls.dhcpd_pid = cls.ns1.start_process(['dhcpd', '-f', '-d', '-cf', '/tmp/dhcpd.conf', + '-lf', '/tmp/dhcpd.leases', + cls.hapd.ifname], cleanup=remove_lease4) + + cls.ns1.start_process(['ip', 'addr', 'add', '3ffe:501:ffff:100::1/72', + 'dev', cls.hapd.ifname]).wait() + cls.ns1.start_process(['touch', '/tmp/dhcpd6.leases']).wait() + cls.dhcpd6_pid = cls.ns1.start_process(['dhcpd', '-6', '-f', '-d', + '-cf', '/tmp/dhcpd-v6.conf', + '-lf', '/tmp/dhcpd6.leases', + cls.hapd.ifname], cleanup=remove_lease6) + cls.ns1.start_process(['sysctl', + 'net.ipv6.conf.' + cls.hapd.ifname + '.forwarding=1']).wait() # Send out Router Advertisements telling clients to use DHCPv6. # Note trying to send the RAs from the router's global IPv6 address by adding a # "AdvRASrcAddress { 3ffe:501:ffff:100::1; };" line will fail because the client @@ -142,7 +217,7 @@ class Test(unittest.TestCase): # with a non-link-local gateway address that is present on another interface in the # same namespace. config = open('/tmp/radvd.conf', 'w') - config.write('interface ' + hapd.ifname + ''' { + config.write('interface ' + cls.hapd.ifname + ''' { AdvSendAdvert on; AdvManagedFlag on; prefix 3ffe:501:ffff:100::/72 { AdvAutonomous off; }; @@ -151,7 +226,8 @@ class Test(unittest.TestCase): route 3ffe:501:ffff:500::/66 { AdvRoutePreference high; }; };''') config.close() - cls.radvd_pid = ctx.start_process(['radvd', '-n', '-d5', '-p', '/tmp/radvd.pid', '-C', '/tmp/radvd.conf']) + cls.radvd_pid = cls.ns1.start_process(['radvd', '-n', '-d5', + '-p', '/tmp/radvd.pid', '-C', '/tmp/radvd.conf']) cls.orig_path = os.environ['PATH'] os.environ['PATH'] = '/tmp/test-bin:' + os.environ['PATH'] @@ -160,14 +236,83 @@ class Test(unittest.TestCase): @classmethod def tearDownClass(cls): IWD.clear_storage() - ctx.stop_process(cls.dhcpd_pid) + cls.ns1.stop_process(cls.dhcpd_pid) cls.dhcpd_pid = None - ctx.stop_process(cls.dhcpd6_pid) + cls.ns1.stop_process(cls.dhcpd6_pid) cls.dhcpd6_pid = None - ctx.stop_process(cls.radvd_pid) + cls.ns1.stop_process(cls.radvd_pid) cls.radvd_pid = None os.system('rm -rf /tmp/radvd.conf /tmp/resolvconf.log /tmp/test-bin') os.environ['PATH'] = cls.orig_path + @staticmethod + def parse_lease_file(path, family): + file = open(path, 'r') + lines = file.readlines() + file.close() + + stack = [[]] + statement = [] + token = '' + for line in lines: + whitespace = False + quote = False + for ch in line: + if not quote and ch in ' \t\r\n;{}=#': + if len(token): + statement.append(token) + token = '' + if not quote and ch in ';{}': + if len(statement): + stack[-1].append(statement) + statement = [] + if ch == '"': + quote = not quote + elif quote or ch not in ' \t\r\n;{}#': + token += ch + if ch == '#': + break + elif ch == '{': + stack.append([]) + elif ch == '}': + statements = stack.pop() + stack[-1][-1].append(statements) + if len(token): + statement.append(token) + token = '' + if len(statement): + stack[-1].append(statement) + statements = stack.pop(0) + if len(stack): + raise Exception('Unclosed block(s)') + + contents = {'leases':{}} + for s in statements: + if s[0] == 'lease': + ip = socket.inet_pton(family, s[1]) + lease = {} + for param in s[2]: + if param[0] in ('starts', 'ends', 'tstp', 'tsfp', 'atsfp', 'cltt'): + weekday = param[1] + year, month, day = param[2].split('/') + hour, minute, second = param[3].split(':') + dt = datetime.datetime( + int(year), int(month), int(day), + int(hour), int(minute), int(second), + tzinfo=datetime.timezone.utc) + lease[param[0]] = dt.timestamp() + elif param[0:2] == ['binding', 'state']: + lease['state'] = param[2] + elif param[0:2] == ['hardware', 'ethernet']: + lease['hwaddr'] = bytes([int(v, 16) for v in param[2].split(':')]) + elif param[0] in ('preferred-life', 'max-life'): + lease[param[0]] = int(param[1]) + elif param[0] in ('client-hostname'): + lease[param[0]] = param[1] + contents['leases'][ip] = lease # New entries overwrite older ones + elif s[0] == 'server-duid': + contents[s[0]] = s[1] + return contents + if __name__ == '__main__': unittest.main(exit=True) diff --git a/autotests/testNetconfig/dhcpd.conf b/autotests/testNetconfig/dhcpd.conf index d8a9d24c..0a154637 100644 --- a/autotests/testNetconfig/dhcpd.conf +++ b/autotests/testNetconfig/dhcpd.conf @@ -1,5 +1,15 @@ -default-lease-time 600; # 10 minutes -max-lease-time 7200; # 2 hours +default-lease-time 120; # 2 minutes +min-lease-time 120; # 2 minutes +max-lease-time 120; # 2 minutes +option dhcp-renewal-time 15; # 15 secs for T1 +# We set a relatively low lease lifetime of 2 minutes but our renewal interval +# (T1) is still unproportionally low to speed the test up -- 12% instead of the +# default 50% lifetime value. We need a lifetime in the order of minutes +# because minimum lease renewal retry interval is 60s per spec. However by +# default dhcpd will not renew leases that are newer than 25% their lifetime. +# Set that threshold to 1% so that we can verify that the lease is renewed +# without waiting too long. +dhcp-cache-threshold 1; option broadcast-address 192.168.127.255; option routers 192.168.1.254; diff --git a/autotests/testNetconfig/hw.conf b/autotests/testNetconfig/hw.conf index d5adc9ad..edf656d6 100644 --- a/autotests/testNetconfig/hw.conf +++ b/autotests/testNetconfig/hw.conf @@ -1,9 +1,11 @@ [SETUP] -num_radios=3 +num_radios=4 start_iwd=0 [HOSTAPD] -rad0=ssidTKIP.conf +rad2=ap-main.conf +rad3=ap-ns1.conf [NameSpaces] -ns0=rad2 +ns0=rad0 +ns1=rad3 diff --git a/autotests/testNetconfig/ssidTKIP.psk b/autotests/testNetconfig/static.psk similarity index 100% rename from autotests/testNetconfig/ssidTKIP.psk rename to autotests/testNetconfig/static.psk diff --git a/autotests/testNetconfig/static_test.py b/autotests/testNetconfig/static_test.py index d9f0b9cb..01d694ca 100644 --- a/autotests/testNetconfig/static_test.py +++ b/autotests/testNetconfig/static_test.py @@ -32,7 +32,7 @@ class Test(unittest.TestCase): dev1 = wd.list_devices(1)[0] dev2 = wd_ns0.list_devices(1)[0] - ordered_network = dev1.get_ordered_network('ssidTKIP') + ordered_network = dev1.get_ordered_network('ap-main') self.assertEqual(ordered_network.type, NetworkType.psk) @@ -80,7 +80,7 @@ class Test(unittest.TestCase): # of the log since we care about the end result here. self.assertEqual(expected_rclog, entries[-3:]) - ordered_network = dev2.get_ordered_network('ssidTKIP') + ordered_network = dev2.get_ordered_network('ap-main') condition = 'not obj.connected' wd_ns0.wait_for_object_condition(ordered_network.network_object, condition) @@ -117,7 +117,7 @@ class Test(unittest.TestCase): except: pass - hapd = HostapdCLI() + hapd = HostapdCLI('ap-main.conf') # TODO: This could be moved into test-runner itself if other tests ever # require this functionality (p2p, FILS, etc.). Since it's simple # enough it can stay here for now. @@ -127,7 +127,7 @@ class Test(unittest.TestCase): cls.dhcpd_pid = ctx.start_process(['dhcpd', '-f', '-cf', '/tmp/dhcpd.conf', '-lf', '/tmp/dhcpd.leases', hapd.ifname], cleanup=remove_lease) - IWD.copy_to_storage('ssidTKIP.psk', '/tmp/storage') + IWD.copy_to_storage('static.psk', '/tmp/storage', 'ap-main.psk') cls.orig_path = os.environ['PATH'] os.environ['PATH'] = '/tmp/test-bin:' + os.environ['PATH'] diff --git a/autotests/util/hostapd.py b/autotests/util/hostapd.py index 758427fe..3ae8ff89 100644 --- a/autotests/util/hostapd.py +++ b/autotests/util/hostapd.py @@ -33,7 +33,7 @@ class HostapdCLI(object): _instances = WeakValueDictionary() def __new__(cls, config=None, *args, **kwargs): - hapd = ctx.hostapd[config] + hapd = ctx.get_hapd_instance(config) if not config: config = hapd.config @@ -58,10 +58,10 @@ class HostapdCLI(object): if not ctx.hostapd: raise Exception("No hostapd instances are configured") - if not config and len(ctx.hostapd.instances) > 1: + if not config and sum([len(hapd.instances) for hapd in ctx.hostapd]) > 1: raise Exception('config must be provided if more than one hostapd instance exists') - hapd = ctx.hostapd[config] + hapd = ctx.get_hapd_instance(config) self.interface = hapd.intf self.config = hapd.config From patchwork Wed Jul 6 16:57:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Zaborowski X-Patchwork-Id: 12908347 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86A9B5390 for ; Wed, 6 Jul 2022 16:57:20 +0000 (UTC) Received: by mail-wr1-f45.google.com with SMTP id f2so17544848wrr.6 for ; Wed, 06 Jul 2022 09:57:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AkRCqMqOAI4MxU+FKUC5JmYcC5eB+RU9kqBfTbQ6TIE=; b=ah7aG1j/lfqhqVR7mid0EsKU6Ce65VhqDEY9RTXygQFDtbxRb3728aJdyz1kwOAEmx 3tFeeWWPliJdNEGCyqHYQaI4q3X20yIq1o+3f5ChB4DgyDN3CEHnz1Qx7Q9Ah6P0KYHD ed66w67Llw4rXWdjdi68S76zk2zE4NW0W1m9cu8X0Da5/zSTAkHlW+BGdLdMezbcQ77/ 1KchT3XcDDvLBweJ9dMw8kgC+/S2r9y+eGGBUUxd7/tJ+7h/fZgE2H97qOABEASnNqs4 mplmugm2gq2hTN8YyyMXx9KeegOI5KKrfkX/yuXOMcKKdT7r934fwvcPvmT+xhoFHcuv OJDg== X-Gm-Message-State: AJIora+EKpQ8rnn9cj46GoNsvjtZ+8UnNMhHJNvsIEQM1hL7DrD/85xZ ffWOIcJ5x/Uz6jLqFbH4aPQnoqlzhxMyWrGu X-Google-Smtp-Source: AGRyM1s+k7HHnJsx69syTrOjhE8kTKsPpUG6q0q0gacAJOVzLoEugfbHw6JSCittUx4rz2sm3MpFpQ== X-Received: by 2002:a5d:6487:0:b0:21b:983c:5508 with SMTP id o7-20020a5d6487000000b0021b983c5508mr37869787wri.185.1657126638375; Wed, 06 Jul 2022 09:57:18 -0700 (PDT) Received: from localhost.localdomain ([46.222.51.165]) by smtp.gmail.com with ESMTPSA id j8-20020a05600c190800b0039c5642e430sm29147856wmq.20.2022.07.06.09.57.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jul 2022 09:57:18 -0700 (PDT) From: Andrew Zaborowski To: iwd@lists.linux.dev Subject: [PATCH 3/5] autotests: Also validate correct hostname sent over DHCPv4 Date: Wed, 6 Jul 2022 18:57:00 +0200 Message-Id: <20220706165702.3241756-3-andrew.zaborowski@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220706165702.3241756-1-andrew.zaborowski@intel.com> References: <20220706165702.3241756-1-andrew.zaborowski@intel.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- autotests/testNetconfig/auto.psk | 5 +++++ autotests/testNetconfig/connection_test.py | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 autotests/testNetconfig/auto.psk diff --git a/autotests/testNetconfig/auto.psk b/autotests/testNetconfig/auto.psk new file mode 100644 index 00000000..4077d65f --- /dev/null +++ b/autotests/testNetconfig/auto.psk @@ -0,0 +1,5 @@ +[IPv4] +SendHostname=true + +[Settings] +AutoConnect=false diff --git a/autotests/testNetconfig/connection_test.py b/autotests/testNetconfig/connection_test.py index aebb0a2e..cf90993a 100644 --- a/autotests/testNetconfig/connection_test.py +++ b/autotests/testNetconfig/connection_test.py @@ -36,6 +36,8 @@ class Test(unittest.TestCase): return socket.inet_pton(socket.AF_INET6, l.split(None, 1)[1].split('/', 1)[0]) return None + os.system("hostname test-sta") + IWD.copy_to_storage('auto.psk', name='ap-ns1.psk') wd = IWD(True) psk_agent = PSKAgent("secret123") @@ -109,6 +111,7 @@ class Test(unittest.TestCase): leases_file = self.parse_lease_file('/tmp/dhcpd.leases', socket.AF_INET) lease = leases_file['leases'][socket.inet_pton(socket.AF_INET, '192.168.1.10')] self.assertEqual(lease['state'], 'active') + self.assertEqual(lease['client-hostname'], 'test-sta') self.assertTrue(lease['starts'] < connect_time) self.assertTrue(lease['ends'] > connect_time) # The T1 is 15 seconds per dhcpd.conf. This is the approximate interval between lease @@ -123,6 +126,7 @@ class Test(unittest.TestCase): leases_file = self.parse_lease_file('/tmp/dhcpd.leases', socket.AF_INET) new_lease = leases_file['leases'][socket.inet_pton(socket.AF_INET, '192.168.1.10')] self.assertEqual(new_lease['state'], 'active') + self.assertEqual(new_lease['client-hostname'], 'test-sta') self.assertTrue(new_lease['starts'] > lease['starts'] + 10) self.assertTrue(new_lease['starts'] < lease['starts'] + 25) self.assertTrue(new_lease['ends'] > lease['ends'] + 10) @@ -162,6 +166,7 @@ class Test(unittest.TestCase): leases_file = self.parse_lease_file('/tmp/dhcpd.leases', socket.AF_INET) new_lease = leases_file['leases'][socket.inet_pton(socket.AF_INET, '192.168.1.10')] self.assertEqual(new_lease['state'], 'active') + self.assertEqual(lease['client-hostname'], 'test-sta') self.assertTrue(new_lease['starts'] > lease['starts'] + 70) self.assertTrue(new_lease['starts'] < lease['starts'] + 85) self.assertTrue(new_lease['ends'] > lease['ends'] + 70) From patchwork Wed Jul 6 16:57:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Zaborowski X-Patchwork-Id: 12908349 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D03702F38 for ; Wed, 6 Jul 2022 16:57:23 +0000 (UTC) Received: by mail-wr1-f50.google.com with SMTP id q9so22909361wrd.8 for ; Wed, 06 Jul 2022 09:57:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1GFiqqMa2YO5HXWDu0dEmxwBCLaqGlCym1bFsiK29vs=; b=YCe96LtOcFMvDw5sk71BvMkjGjLxdeiH+hME4+ww9WvWR66DTKnKBQ3I409WAg8Qqi /yVLmM2Wo+DgVzJ1ci8MWnuXx96Doglyxh6R6P1vfeb6+t+WGV/NhZi29bT7NPQ0PPff ur+cSwMymzQQZxj9d2PTnWlyPajmuFyoqapWyOZys+TXRwgUDC/7+4xmJiuv9CLxjBad LjU5X9yXZWd121oVfQjU9qpPGd0gDufXa+OnAhOO5zjEj+slbnrEZWyybecyvmpsGcC6 dS+uMgVNJ07Rh4FQ1cSI/KxavNNpf+5a4/3WdneuZVcjISj7uT3kjuEaPimlfqf+PMXt VJ2w== X-Gm-Message-State: AJIora+Ie/zroTbA1l/Udeh7fiIbkBBwA/3cxRzKZHpY7eAFDO+OvJIT 3B464jNFVokoPt5R/TXP8GI7hO3gCkmcHSyt X-Google-Smtp-Source: AGRyM1uo7cCTqbViJoulRr/vCd2YT5LtN3NZ2c+eWsr5RL13kuV6e3ctb+qhZj0LO8pltnvpVNeumw== X-Received: by 2002:a5d:6083:0:b0:21b:9e6c:1d1 with SMTP id w3-20020a5d6083000000b0021b9e6c01d1mr39083521wrt.264.1657126641323; Wed, 06 Jul 2022 09:57:21 -0700 (PDT) Received: from localhost.localdomain ([46.222.51.165]) by smtp.gmail.com with ESMTPSA id j8-20020a05600c190800b0039c5642e430sm29147856wmq.20.2022.07.06.09.57.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jul 2022 09:57:20 -0700 (PDT) From: Andrew Zaborowski To: iwd@lists.linux.dev Subject: [PATCH 4/5] autotests: Reuse HostapdCLI objects Date: Wed, 6 Jul 2022 18:57:01 +0200 Message-Id: <20220706165702.3241756-4-andrew.zaborowski@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220706165702.3241756-1-andrew.zaborowski@intel.com> References: <20220706165702.3241756-1-andrew.zaborowski@intel.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 TestContext.start_hostapd() in tools/run-tests already creates HostapdCLI objects for every interface assigned to hostapd, try not to create new HostapdCLI instances for those interfaces in each test. --- autotests/testAP/failure_test.py | 4 ++-- autotests/testAP/validation.py | 4 ++-- autotests/testAPRoam/connection_test.py | 9 ++++----- autotests/testBSSBlacklist/connection_test.py | 8 ++++---- autotests/testChannelSwitch/connection_test.py | 4 ++-- autotests/testDPP/connection_test.py | 3 +-- autotests/testDisconnectByAP/disconnect_by_ap_test.py | 5 ++--- autotests/testEAP-PEAPv0-CryptoBinding/ISK_test.py | 2 -- autotests/testEAP-PEAPv0-CryptoBinding/NoISK_test.py | 5 ++--- autotests/testEAP-WPS-Frag/wps_frag_test.py | 5 ++--- autotests/testEAP-WPS/four_digit_pin_test.py | 3 +-- autotests/testEAP-WPS/pin_test.py | 4 +--- autotests/testEAP-WPS/push_button_test.py | 3 +-- autotests/testEAP/connection_test.py | 3 +-- autotests/testEAPoL-spoofing/connection_test.py | 4 ++-- autotests/testFILS/fils_256_test.py | 4 ++-- autotests/testFILS/fils_384_test.py | 4 ++-- autotests/testFT-8021x-roam/connection_test.py | 6 +++--- autotests/testFT-FILS/connection_test.py | 6 +++--- autotests/testHT-VHT/connection_test.py | 8 ++++---- autotests/testHotspot/autoconnect_test.py | 6 +++--- autotests/testHotspot/hessid_test.py | 4 ++-- autotests/testHotspot/hotspot_test.py | 6 +++--- autotests/testHotspot/roaming_test.py | 4 ++-- autotests/testNetconfig/connection_test.py | 3 +-- autotests/testNetconfig/static_test.py | 3 +-- autotests/testOWE-transition/connection_test.py | 10 +++++----- autotests/testOWE/connection_test.py | 8 ++++---- autotests/testPSK-roam/connection_test.py | 6 +++--- autotests/testPSK-roam/roam_ap_disconnect_test.py | 6 +++--- autotests/testPreauth-roam/connection_test.py | 6 +++--- autotests/testRRM/connection_test.py | 4 ++-- autotests/testRoamRetry/fast_retry_test.py | 6 +++--- autotests/testRoamRetry/stop_retry_test.py | 6 +++--- autotests/testSAE-AntiClogging/clogging_test.py | 4 ++-- autotests/testSAE-roam/connection_test.py | 7 +++---- autotests/testSAE/autoconnect_test.py | 4 ++-- autotests/testSAE/connection_test.py | 4 ++-- autotests/testSAE/failure_test.py | 4 ++-- autotests/testSAE/timeout_test.py | 5 ++--- autotests/testSAQuery-spoofing/connection_test.py | 4 ++-- autotests/testSAQuery/connection_test.py | 4 ++-- autotests/testWPA2-ext-key-id/connection_test.py | 10 ++++------ 43 files changed, 100 insertions(+), 118 deletions(-) diff --git a/autotests/testAP/failure_test.py b/autotests/testAP/failure_test.py index 4bd4a2aa..8888481f 100644 --- a/autotests/testAP/failure_test.py +++ b/autotests/testAP/failure_test.py @@ -8,13 +8,13 @@ import iwd from iwd import IWD from iwd import PSKAgent from iwd import NetworkType -from hostapd import HostapdCLI +from config import ctx import testutil class Test(unittest.TestCase): def client_connect(self, wd, dev): - hostapd = HostapdCLI(config='psk-ccmp.conf') + hostapd = ctx.get_hapd_instance('psk-ccmp.conf').cli ordered_network = dev.get_ordered_network('TestAP1', True) diff --git a/autotests/testAP/validation.py b/autotests/testAP/validation.py index b1b867ef..4b195a55 100644 --- a/autotests/testAP/validation.py +++ b/autotests/testAP/validation.py @@ -1,6 +1,6 @@ from iwd import PSKAgent from iwd import NetworkType -from hostapd import HostapdCLI +from config import ctx import testutil def validate(wd, sta_dev, ap_dev, ssid, passphrase, @@ -45,7 +45,7 @@ def validate(wd, sta_dev, ap_dev, ssid, passphrase, ap_dev.stop_ap() def client_connect(wd, dev, ssid): - hostapd = HostapdCLI(config='psk-ccmp.conf') + hostapd = ctx.get_hapd_instance('psk-ccmp.conf').cli ordered_network = dev.get_ordered_network(ssid) diff --git a/autotests/testAPRoam/connection_test.py b/autotests/testAPRoam/connection_test.py index 41d70f3a..e299810f 100644 --- a/autotests/testAPRoam/connection_test.py +++ b/autotests/testAPRoam/connection_test.py @@ -7,15 +7,14 @@ sys.path.append('../util') import iwd from iwd import IWD from iwd import NetworkType - -from hostapd import HostapdCLI +from config import ctx class Test(unittest.TestCase): def test_connection_success(self): - bss_hostapd = [ HostapdCLI(config='ssid1.conf'), - HostapdCLI(config='ssid2.conf'), - HostapdCLI(config='ssid3.conf') ] + bss_hostapd = [ ctx.get_hapd_instance('ssid1.conf').cli, + ctx.get_hapd_instance('ssid2.conf').cli, + ctx.get_hapd_instance('ssid3.conf').cli ] wd = IWD() diff --git a/autotests/testBSSBlacklist/connection_test.py b/autotests/testBSSBlacklist/connection_test.py index 9631a322..35f33671 100644 --- a/autotests/testBSSBlacklist/connection_test.py +++ b/autotests/testBSSBlacklist/connection_test.py @@ -9,8 +9,8 @@ from iwd import IWD from iwd import PSKAgent from iwd import NetworkType from iwd import IWD_CONFIG_DIR +from config import ctx -from hostapd import HostapdCLI from hwsim import Hwsim import time @@ -271,9 +271,9 @@ class Test(unittest.TestCase): def setUpClass(cls): cls.hwsim = Hwsim() - cls.bss_hostapd = [ HostapdCLI(config='ssid1.conf'), - HostapdCLI(config='ssid2.conf'), - HostapdCLI(config='ssid3.conf') ] + cls.bss_hostapd = [ ctx.get_hapd_instance('ssid1.conf').cli, + ctx.get_hapd_instance('ssid2.conf').cli, + ctx.get_hapd_instance('ssid3.conf').cli ] cls.bss_radio = [ cls.hwsim.get_radio('rad0'), cls.hwsim.get_radio('rad1'), cls.hwsim.get_radio('rad2') ] diff --git a/autotests/testChannelSwitch/connection_test.py b/autotests/testChannelSwitch/connection_test.py index 03d24a77..5a8e8d62 100644 --- a/autotests/testChannelSwitch/connection_test.py +++ b/autotests/testChannelSwitch/connection_test.py @@ -8,13 +8,13 @@ import iwd from iwd import IWD from iwd import PSKAgent from iwd import NetworkType -from hostapd import HostapdCLI +from config import ctx import testutil class Test(unittest.TestCase): def test_connection_success(self): - hapd = HostapdCLI() + hapd = ctx.get_hapd_instance().cli wd = IWD() psk_agent = PSKAgent("secret123") diff --git a/autotests/testDPP/connection_test.py b/autotests/testDPP/connection_test.py index 0cab5ff1..8e2cbf38 100644 --- a/autotests/testDPP/connection_test.py +++ b/autotests/testDPP/connection_test.py @@ -7,7 +7,6 @@ sys.path.append('../util') from iwd import IWD from iwd import DeviceProvisioning from wpas import Wpas -from hostapd import HostapdCLI from hwsim import Hwsim from config import ctx @@ -136,7 +135,7 @@ class Test(unittest.TestCase): self.wpas = Wpas('wpas.conf') self.wd = IWD(True) self.device = self.wd.list_devices(1)[0] - self.hapd = HostapdCLI('hostapd.conf') + self.hapd = ctx.get_hapd_instance('hostapd.conf').cli self.hapd.disable() self.hwsim = Hwsim() diff --git a/autotests/testDisconnectByAP/disconnect_by_ap_test.py b/autotests/testDisconnectByAP/disconnect_by_ap_test.py index f3c71358..d62825b8 100644 --- a/autotests/testDisconnectByAP/disconnect_by_ap_test.py +++ b/autotests/testDisconnectByAP/disconnect_by_ap_test.py @@ -8,8 +8,7 @@ import iwd from iwd import IWD from iwd import DeviceState from iwd import NetworkType - -from hostapd import HostapdCLI +from config import ctx class Test(unittest.TestCase): @@ -19,7 +18,7 @@ class Test(unittest.TestCase): devices = wd.list_devices(1) device = devices[0] - hostapd = HostapdCLI(config='ssidOpen.conf') + hostapd = ctx.get_hapd_instance('ssidOpen.conf').cli ordered_network = device.get_ordered_network('ssidOpen', full_scan=True) diff --git a/autotests/testEAP-PEAPv0-CryptoBinding/ISK_test.py b/autotests/testEAP-PEAPv0-CryptoBinding/ISK_test.py index 07382623..f01de812 100644 --- a/autotests/testEAP-PEAPv0-CryptoBinding/ISK_test.py +++ b/autotests/testEAP-PEAPv0-CryptoBinding/ISK_test.py @@ -10,8 +10,6 @@ from iwd import IWD from iwd import NetworkType import testutil -from hostapd import HostapdCLI - class Test(unittest.TestCase): def validate_connection(self, wd): diff --git a/autotests/testEAP-PEAPv0-CryptoBinding/NoISK_test.py b/autotests/testEAP-PEAPv0-CryptoBinding/NoISK_test.py index 0323fdc1..9248120f 100644 --- a/autotests/testEAP-PEAPv0-CryptoBinding/NoISK_test.py +++ b/autotests/testEAP-PEAPv0-CryptoBinding/NoISK_test.py @@ -9,13 +9,12 @@ import iwd from iwd import IWD from iwd import NetworkType import testutil - -from hostapd import HostapdCLI +from config import ctx class Test(unittest.TestCase): def validate_connection(self, wd): - hostapd = HostapdCLI(config='ssidEAP-PEAPv0-NoISK.conf') + hostapd = ctx.get_hapd_instance('ssidEAP-PEAPv0-NoISK.conf').cli self.assertIsNotNone(hostapd) diff --git a/autotests/testEAP-WPS-Frag/wps_frag_test.py b/autotests/testEAP-WPS-Frag/wps_frag_test.py index dcaf1ae2..8036cc17 100644 --- a/autotests/testEAP-WPS-Frag/wps_frag_test.py +++ b/autotests/testEAP-WPS-Frag/wps_frag_test.py @@ -7,8 +7,7 @@ sys.path.append('../util') import iwd from iwd import IWD from iwd import DeviceState - -from hostapd import HostapdCLI +from config import ctx class Test(unittest.TestCase): @@ -31,7 +30,7 @@ class Test(unittest.TestCase): @classmethod def setUpClass(cls): - cls.hostapd = HostapdCLI(config='ssid-wps-small-mtu.conf') + cls.hostapd = ctx.get_hapd_instance('ssid-wps-small-mtu.conf').cli cls.hostapd.wps_push_button() diff --git a/autotests/testEAP-WPS/four_digit_pin_test.py b/autotests/testEAP-WPS/four_digit_pin_test.py index d30492fb..ba98aac1 100644 --- a/autotests/testEAP-WPS/four_digit_pin_test.py +++ b/autotests/testEAP-WPS/four_digit_pin_test.py @@ -5,7 +5,6 @@ import sys sys.path.append('../util') from iwd import IWD -from hostapd import HostapdCLI from config import ctx class Test(unittest.TestCase): @@ -44,7 +43,7 @@ class Test(unittest.TestCase): @classmethod def setUpClass(cls): - cls.hostapd = HostapdCLI(config='ssidWPS.conf') + cls.hostapd = ctx.get_hapd_instance('ssidWPS.conf').cli @classmethod def tearDownClass(cls): diff --git a/autotests/testEAP-WPS/pin_test.py b/autotests/testEAP-WPS/pin_test.py index e2fef335..57dc07e6 100644 --- a/autotests/testEAP-WPS/pin_test.py +++ b/autotests/testEAP-WPS/pin_test.py @@ -8,8 +8,6 @@ import iwd from iwd import IWD from iwd import DeviceState -from hostapd import HostapdCLI - class Test(unittest.TestCase): def pin_success(self, wd): @@ -41,7 +39,7 @@ class Test(unittest.TestCase): @classmethod def setUpClass(cls): - cls.hostapd = HostapdCLI(config='ssidWPS.conf') + cls.hostapd = ctx.get_hapd_instance('ssidWPS.conf').cli @classmethod def tearDownClass(cls): diff --git a/autotests/testEAP-WPS/push_button_test.py b/autotests/testEAP-WPS/push_button_test.py index e2b4c2b2..bc29fd4c 100644 --- a/autotests/testEAP-WPS/push_button_test.py +++ b/autotests/testEAP-WPS/push_button_test.py @@ -5,7 +5,6 @@ import sys sys.path.append('../util') from iwd import IWD -from hostapd import HostapdCLI from config import ctx class Test(unittest.TestCase): @@ -43,7 +42,7 @@ class Test(unittest.TestCase): @classmethod def setUpClass(cls): - cls.hostapd = HostapdCLI(config='ssidWPS.conf') + cls.hostapd = ctx.get_hapd_instance('ssidWPS.conf').cli @classmethod def tearDownClass(cls): diff --git a/autotests/testEAP/connection_test.py b/autotests/testEAP/connection_test.py index fe048b48..44ba9cae 100644 --- a/autotests/testEAP/connection_test.py +++ b/autotests/testEAP/connection_test.py @@ -11,7 +11,6 @@ from iwd import PSKAgent from hlrauc import AuthCenter from ofono import Ofono from config import ctx -from hostapd import HostapdCLI import testutil import traceback @@ -255,7 +254,7 @@ class Test(unittest.TestCase): @classmethod def setUpClass(cls): cls.wd = IWD() - cls.hostapd = HostapdCLI() + cls.hostapd = ctx.get_hapd_instance().cli @classmethod def tearDownClass(cls): diff --git a/autotests/testEAPoL-spoofing/connection_test.py b/autotests/testEAPoL-spoofing/connection_test.py index ecddddd6..16f0d39f 100644 --- a/autotests/testEAPoL-spoofing/connection_test.py +++ b/autotests/testEAPoL-spoofing/connection_test.py @@ -9,7 +9,7 @@ from iwd import IWD from iwd import PSKAgent from iwd import NetworkType from hwsim import Hwsim -from hostapd import HostapdCLI +from config import ctx from time import sleep @@ -18,7 +18,7 @@ class Test(unittest.TestCase): def test_connection_success(self): hwsim = Hwsim() - hostapd = HostapdCLI(config='ssidCCMP.conf') + hostapd = ctx.get_hapd_instance('ssidCCMP.conf').cli radio = hwsim.get_radio('rad0') wd = IWD() diff --git a/autotests/testFILS/fils_256_test.py b/autotests/testFILS/fils_256_test.py index 5fa371e1..3451932c 100644 --- a/autotests/testFILS/fils_256_test.py +++ b/autotests/testFILS/fils_256_test.py @@ -8,12 +8,12 @@ sys.path.append('../util') import iwd from iwd import IWD from iwd import NetworkType -from hostapd import HostapdCLI +from config import ctx import testutil class Test(unittest.TestCase): def test_connection_success(self): - hapd = HostapdCLI(config='ssidFILS-256.conf') + hapd = ctx.get_hapd_instance('ssidFILS-256.conf').cli wd = IWD(True) diff --git a/autotests/testFILS/fils_384_test.py b/autotests/testFILS/fils_384_test.py index b7174418..43ce6dec 100644 --- a/autotests/testFILS/fils_384_test.py +++ b/autotests/testFILS/fils_384_test.py @@ -8,12 +8,12 @@ sys.path.append('../util') import iwd from iwd import IWD from iwd import NetworkType -from hostapd import HostapdCLI +from config import ctx import testutil class Test(unittest.TestCase): def test_connection_success(self): - hapd = HostapdCLI(config='ssidFILS-384.conf') + hapd = ctx.get_hapd_instance('ssidFILS-384.conf').cli wd = IWD(True) diff --git a/autotests/testFT-8021x-roam/connection_test.py b/autotests/testFT-8021x-roam/connection_test.py index 6853bdb0..a928441a 100644 --- a/autotests/testFT-8021x-roam/connection_test.py +++ b/autotests/testFT-8021x-roam/connection_test.py @@ -6,7 +6,7 @@ import sys, os sys.path.append('../util') from iwd import IWD from iwd import NetworkType -from hostapd import HostapdCLI +from config import ctx import testutil class Test(unittest.TestCase): @@ -63,8 +63,8 @@ class Test(unittest.TestCase): def setUpClass(cls): IWD.copy_to_storage('TestFT.8021x') - cls.bss_hostapd = [ HostapdCLI(config='ft-eap-ccmp-1.conf'), - HostapdCLI(config='ft-eap-ccmp-2.conf') ] + cls.bss_hostapd = [ ctx.get_hapd_instance('ft-eap-ccmp-1.conf').cli, + ctx.get_hapd_instance('ft-eap-ccmp-2.conf').cli ] # Set interface addresses to those expected by hostapd config files os.system('ip link set dev "' + cls.bss_hostapd[0].ifname + '" down') diff --git a/autotests/testFT-FILS/connection_test.py b/autotests/testFT-FILS/connection_test.py index c1deb77c..dc7b0ce9 100644 --- a/autotests/testFT-FILS/connection_test.py +++ b/autotests/testFT-FILS/connection_test.py @@ -6,7 +6,7 @@ import sys, os sys.path.append('../util') from iwd import IWD from iwd import NetworkType -from hostapd import HostapdCLI +from config import ctx import testutil class Test(unittest.TestCase): @@ -125,8 +125,8 @@ class Test(unittest.TestCase): os.system('ip link set lo up') IWD.copy_to_storage('TestFT.8021x') - cls.bss_hostapd = [ HostapdCLI(config='ft-eap-ccmp-1.conf'), - HostapdCLI(config='ft-eap-ccmp-2.conf') ] + cls.bss_hostapd = [ ctx.get_hapd_instance('ft-eap-ccmp-1.conf').cli, + ctx.get_hapd_instance('ft-eap-ccmp-2.conf').cli ] # Set interface addresses to those expected by hostapd config files os.system('ip link set dev "' + cls.bss_hostapd[0].ifname + '" down') diff --git a/autotests/testHT-VHT/connection_test.py b/autotests/testHT-VHT/connection_test.py index 0297cb9b..f24db787 100644 --- a/autotests/testHT-VHT/connection_test.py +++ b/autotests/testHT-VHT/connection_test.py @@ -10,7 +10,7 @@ from iwd import PSKAgent from iwd import NetworkType from hwsim import Hwsim import testutil -from hostapd import HostapdCLI +from config import ctx class Test(unittest.TestCase): def do_connect(self, wd, device, hostapd): @@ -40,9 +40,9 @@ class Test(unittest.TestCase): def test_connection_success(self): hwsim = Hwsim() - non_ht_hostapd = HostapdCLI(config='non-ht-vht.conf') - ht_hostapd = HostapdCLI(config='ht.conf') - vht_hostapd = HostapdCLI(config='vht.conf') + non_ht_hostapd = ctx.get_hapd_instance('non-ht-vht.conf').cli + ht_hostapd = ctx.get_hapd_instance('ht.conf').cli + vht_hostapd = ctx.get_hapd_instance('vht.conf').cli non_ht_radio = hwsim.get_radio('rad0') ht_radio = hwsim.get_radio('rad1') vht_radio = hwsim.get_radio('rad2') diff --git a/autotests/testHotspot/autoconnect_test.py b/autotests/testHotspot/autoconnect_test.py index 8b718dc7..a858e702 100644 --- a/autotests/testHotspot/autoconnect_test.py +++ b/autotests/testHotspot/autoconnect_test.py @@ -8,7 +8,7 @@ sys.path.append('../util') from iwd import IWD from iwd import IWD_CONFIG_DIR from iwd import NetworkType -from hostapd import HostapdCLI +from config import ctx import testutil class Test(unittest.TestCase): @@ -16,8 +16,8 @@ class Test(unittest.TestCase): def test_connection_success(self): wd = self.wd - hapd_hotspot = HostapdCLI(config='ssidHotspot.conf') - hapd_wpa = HostapdCLI(config='ssidWPA2-1.conf') + hapd_hotspot = ctx.get_hapd_instance('ssidHotspot.conf').cli + hapd_wpa = ctx.get_hapd_instance('ssidWPA2-1.conf').cli self.assertEqual(len(wd.list_known_networks()), 2) diff --git a/autotests/testHotspot/hessid_test.py b/autotests/testHotspot/hessid_test.py index 4a47e5c7..1711dc65 100644 --- a/autotests/testHotspot/hessid_test.py +++ b/autotests/testHotspot/hessid_test.py @@ -9,7 +9,7 @@ from iwd import IWD from iwd import IWD_CONFIG_DIR from iwd import PSKAgent from iwd import NetworkType -from hostapd import HostapdCLI +from config import ctx import testutil class Test(unittest.TestCase): @@ -17,7 +17,7 @@ class Test(unittest.TestCase): def test_connection_success(self): wd = self.wd - hapd = HostapdCLI(config='ssidHotspot.conf') + hapd = ctx.get_hapd_instance('ssidHotspot.conf').cli psk_agent = PSKAgent('abc', ('domain\\user', 'testpasswd')) wd.register_psk_agent(psk_agent) diff --git a/autotests/testHotspot/hotspot_test.py b/autotests/testHotspot/hotspot_test.py index ed9ee830..ec075d5a 100644 --- a/autotests/testHotspot/hotspot_test.py +++ b/autotests/testHotspot/hotspot_test.py @@ -9,7 +9,7 @@ from iwd import IWD from iwd import IWD_CONFIG_DIR from iwd import PSKAgent from iwd import NetworkType -from hostapd import HostapdCLI +from config import ctx import testutil class Test(unittest.TestCase): @@ -53,14 +53,14 @@ class Test(unittest.TestCase): wd.unregister_psk_agent(psk_agent) def test_hotspot(self): - hapd = HostapdCLI(config='ssidHotspot.conf') + hapd = ctx.get_hapd_instance('ssidHotspot.conf').cli hapd.set_value('disable_dgaf', '0') hapd.reload() self.validate_connection(self.wd, hapd) def test_dgaf_disabled(self): - hapd = HostapdCLI(config='ssidHotspot.conf') + hapd = ctx.get_hapd_instance('ssidHotspot.conf').cli hapd.set_value('disable_dgaf', '1') hapd.reload() diff --git a/autotests/testHotspot/roaming_test.py b/autotests/testHotspot/roaming_test.py index 1d785700..8ca964ce 100644 --- a/autotests/testHotspot/roaming_test.py +++ b/autotests/testHotspot/roaming_test.py @@ -9,7 +9,7 @@ from iwd import IWD from iwd import IWD_CONFIG_DIR from iwd import PSKAgent from iwd import NetworkType -from hostapd import HostapdCLI +from config import ctx import testutil class Test(unittest.TestCase): @@ -17,7 +17,7 @@ class Test(unittest.TestCase): def test_connection_success(self): wd = self.wd - hapd = HostapdCLI(config='ssidHotspot.conf') + hapd = ctx.get_hapd_instance('ssidHotspot.conf').cli devices = wd.list_devices(1) device = devices[0] diff --git a/autotests/testNetconfig/connection_test.py b/autotests/testNetconfig/connection_test.py index cf90993a..d13be7e0 100644 --- a/autotests/testNetconfig/connection_test.py +++ b/autotests/testNetconfig/connection_test.py @@ -8,7 +8,6 @@ import iwd from iwd import IWD from iwd import PSKAgent from iwd import NetworkType -from hostapd import HostapdCLI import testutil from config import ctx import os @@ -195,7 +194,7 @@ class Test(unittest.TestCase): pass cls.ns1 = ctx.get_namespace('ns1') - cls.hapd = HostapdCLI('ap-ns1.conf') + cls.hapd = ctx.get_hapd_instance('ap-ns1.conf').cli # TODO: This could be moved into test-runner itself if other tests ever # require this functionality (p2p, FILS, etc.). Since its simple # enough it can stay here for now. diff --git a/autotests/testNetconfig/static_test.py b/autotests/testNetconfig/static_test.py index 01d694ca..a4f33614 100644 --- a/autotests/testNetconfig/static_test.py +++ b/autotests/testNetconfig/static_test.py @@ -8,7 +8,6 @@ import iwd from iwd import IWD from iwd import PSKAgent from iwd import NetworkType -from hostapd import HostapdCLI import testutil from config import ctx import os @@ -117,7 +116,7 @@ class Test(unittest.TestCase): except: pass - hapd = HostapdCLI('ap-main.conf') + hapd = ctx.get_hapd_instance('ap-main.conf').cli # TODO: This could be moved into test-runner itself if other tests ever # require this functionality (p2p, FILS, etc.). Since it's simple # enough it can stay here for now. diff --git a/autotests/testOWE-transition/connection_test.py b/autotests/testOWE-transition/connection_test.py index 89f97338..c3878b15 100644 --- a/autotests/testOWE-transition/connection_test.py +++ b/autotests/testOWE-transition/connection_test.py @@ -7,7 +7,7 @@ sys.path.append('../util') import iwd from iwd import IWD from iwd import NetworkType -from hostapd import HostapdCLI +from config import ctx from hwsim import Hwsim import testutil @@ -234,10 +234,10 @@ class Test(unittest.TestCase): def setUp(self): self.wd = IWD(True) - self.hapd_owe = HostapdCLI(config='ssidOWE.conf') - self.hapd_open = HostapdCLI(config='ssidOpen.conf') - self.hapd_owe2 = HostapdCLI(config='ssidOWE-2.conf') - self.hapd_open2 = HostapdCLI(config='ssidOpen-2.conf') + self.hapd_owe = ctx.get_hapd_instance('ssidOWE.conf').cli + self.hapd_open = ctx.get_hapd_instance('ssidOpen.conf').cli + self.hapd_owe2 = ctx.get_hapd_instance('ssidOWE-2.conf').cli + self.hapd_open2 = ctx.get_hapd_instance('ssidOpen-2.conf').cli self.hwsim = Hwsim() diff --git a/autotests/testOWE/connection_test.py b/autotests/testOWE/connection_test.py index 391d8cf5..ac7b954f 100644 --- a/autotests/testOWE/connection_test.py +++ b/autotests/testOWE/connection_test.py @@ -7,13 +7,13 @@ sys.path.append('../util') import iwd from iwd import IWD from iwd import NetworkType -from hostapd import HostapdCLI +from config import ctx import testutil class Test(unittest.TestCase): def test_connection_success(self): - hapd = HostapdCLI(config='ssidOWE-1.conf') + hapd = ctx.get_hapd_instance('ssidOWE-1.conf').cli wd = IWD() @@ -33,8 +33,8 @@ class Test(unittest.TestCase): device.disconnect() def test_reassociate(self): - hapd0 = HostapdCLI(config='ssidOWE-1.conf') - hapd1 = HostapdCLI(config='ssidOWE-2.conf') + hapd0 = ctx.get_hapd_instance('ssidOWE-1.conf').cli + hapd1 = ctx.get_hapd_instance('ssidOWE-2.conf').cli wd = IWD() diff --git a/autotests/testPSK-roam/connection_test.py b/autotests/testPSK-roam/connection_test.py index f1b43130..8a3a6bcc 100644 --- a/autotests/testPSK-roam/connection_test.py +++ b/autotests/testPSK-roam/connection_test.py @@ -9,7 +9,7 @@ from iwd import IWD from iwd import PSKAgent from iwd import NetworkType from hwsim import Hwsim -from hostapd import HostapdCLI +from config import ctx import testutil class Test(unittest.TestCase): @@ -146,8 +146,8 @@ class Test(unittest.TestCase): IWD.copy_to_storage('TestFT.psk') - cls.bss_hostapd = [ HostapdCLI(config='ft-psk-ccmp-1.conf'), - HostapdCLI(config='ft-psk-ccmp-2.conf') ] + cls.bss_hostapd = [ ctx.get_hapd_instance('ft-psk-ccmp-1.conf').cli, + ctx.get_hapd_instance('ft-psk-ccmp-2.conf').cli ] rad2 = hwsim.get_radio('rad2') cls.rule0 = hwsim.rules.create() diff --git a/autotests/testPSK-roam/roam_ap_disconnect_test.py b/autotests/testPSK-roam/roam_ap_disconnect_test.py index 760c25fa..f3fbe658 100644 --- a/autotests/testPSK-roam/roam_ap_disconnect_test.py +++ b/autotests/testPSK-roam/roam_ap_disconnect_test.py @@ -7,7 +7,7 @@ sys.path.append('../util') from iwd import IWD from iwd import NetworkType from hwsim import Hwsim -from hostapd import HostapdCLI +from config import ctx class Test(unittest.TestCase): # @@ -72,8 +72,8 @@ class Test(unittest.TestCase): IWD.copy_to_storage('TestFT.psk') - cls.bss_hostapd = [ HostapdCLI(config='ft-psk-ccmp-1.conf'), - HostapdCLI(config='ft-psk-ccmp-2.conf') ] + cls.bss_hostapd = [ ctx.get_hapd_instance('ft-psk-ccmp-1.conf').cli, + ctx.get_hapd_instance('ft-psk-ccmp-2.conf').cli ] cls.bss_hostapd[1].disable() cls.bss_hostapd[0].set_value('ocv', '0') diff --git a/autotests/testPreauth-roam/connection_test.py b/autotests/testPreauth-roam/connection_test.py index 26475698..857cd51c 100644 --- a/autotests/testPreauth-roam/connection_test.py +++ b/autotests/testPreauth-roam/connection_test.py @@ -6,13 +6,13 @@ import sys, os sys.path.append('../util') from iwd import IWD from iwd import NetworkType -from hostapd import HostapdCLI +from config import ctx import testutil class Test(unittest.TestCase): def test_preauth_success(self): - bss_hostapd = [ HostapdCLI(config='eaptls-preauth-1.conf'), - HostapdCLI(config='eaptls-preauth-2.conf') ] + bss_hostapd = [ ctx.get_hapd_instance('eaptls-preauth-1.conf').cli, + ctx.get_hapd_instance('eaptls-preauth-2.conf').cli ] bss0_addr = bss_hostapd[0].bssid bss1_addr = bss_hostapd[1].bssid diff --git a/autotests/testRRM/connection_test.py b/autotests/testRRM/connection_test.py index 4d894958..412bf6cb 100644 --- a/autotests/testRRM/connection_test.py +++ b/autotests/testRRM/connection_test.py @@ -8,7 +8,7 @@ import iwd from iwd import IWD from iwd import PSKAgent from iwd import NetworkType -from hostapd import HostapdCLI +from config import ctx import testutil # Table beacon with wildcard BSSID @@ -25,7 +25,7 @@ beacon_passive_duration = '510b0000c80000ffffffffffff020100' class Test(unittest.TestCase): def test_connection_success(self): - hapd = HostapdCLI(config='ssidRRM.conf') + hapd = ctx.get_hapd_instance('ssidRRM.conf').cli wd = IWD() psk_agent = PSKAgent("secret123") diff --git a/autotests/testRoamRetry/fast_retry_test.py b/autotests/testRoamRetry/fast_retry_test.py index b45daada..4d9c52f0 100644 --- a/autotests/testRoamRetry/fast_retry_test.py +++ b/autotests/testRoamRetry/fast_retry_test.py @@ -8,10 +8,10 @@ import iwd from iwd import IWD from iwd import PSKAgent from iwd import NetworkType +from config import ctx import testutil -from hostapd import HostapdCLI from hwsim import Hwsim class Test(unittest.TestCase): @@ -21,8 +21,8 @@ class Test(unittest.TestCase): def test_fast_retry(self): hwsim = Hwsim() - bss_hostapd = [ HostapdCLI(config='ssid1.conf'), - HostapdCLI(config='ssid2.conf') ] + bss_hostapd = [ ctx.get_hapd_instance('ssid1.conf').cli, + ctx.get_hapd_instance('ssid2.conf').cli ] bss_radio = [ hwsim.get_radio('rad0'), hwsim.get_radio('rad1') ] diff --git a/autotests/testRoamRetry/stop_retry_test.py b/autotests/testRoamRetry/stop_retry_test.py index 3957d12d..b9b323f1 100644 --- a/autotests/testRoamRetry/stop_retry_test.py +++ b/autotests/testRoamRetry/stop_retry_test.py @@ -8,10 +8,10 @@ import iwd from iwd import IWD from iwd import PSKAgent from iwd import NetworkType +from config import ctx import testutil -from hostapd import HostapdCLI from hwsim import Hwsim class Test(unittest.TestCase): @@ -20,8 +20,8 @@ class Test(unittest.TestCase): def test_stop_retry(self): hwsim = Hwsim() - bss_hostapd = [ HostapdCLI(config='ssid1.conf'), - HostapdCLI(config='ssid2.conf') ] + bss_hostapd = [ ctx.get_hapd_instance('ssid1.conf').cli, + ctx.get_hapd_instance('ssid2.conf').cli ] bss_radio = [ hwsim.get_radio('rad0'), hwsim.get_radio('rad1') ] diff --git a/autotests/testSAE-AntiClogging/clogging_test.py b/autotests/testSAE-AntiClogging/clogging_test.py index 172dfecf..b61f21ee 100644 --- a/autotests/testSAE-AntiClogging/clogging_test.py +++ b/autotests/testSAE-AntiClogging/clogging_test.py @@ -8,7 +8,7 @@ import iwd from iwd import IWD from iwd import PSKAgent from iwd import NetworkType -from hostapd import HostapdCLI +from config import ctx class Test(unittest.TestCase): @@ -65,7 +65,7 @@ class Test(unittest.TestCase): @classmethod def setUpClass(cls): - cls.hostapd = HostapdCLI(config='ssidSAE-Clogging.conf') + cls.hostapd = ctx.get_hapd_instance('ssidSAE-Clogging.conf').cli @classmethod def tearDownClass(cls): diff --git a/autotests/testSAE-roam/connection_test.py b/autotests/testSAE-roam/connection_test.py index 2c8cd799..3fad22b9 100644 --- a/autotests/testSAE-roam/connection_test.py +++ b/autotests/testSAE-roam/connection_test.py @@ -8,7 +8,6 @@ import iwd from iwd import IWD from iwd import PSKAgent from iwd import NetworkType -from hostapd import HostapdCLI import testutil from config import ctx @@ -116,9 +115,9 @@ class Test(unittest.TestCase): @classmethod def setUpClass(cls): - cls.bss_hostapd = [ HostapdCLI(config='ft-sae-1.conf'), - HostapdCLI(config='ft-sae-2.conf'), - HostapdCLI(config='ft-psk-3.conf') ] + cls.bss_hostapd = [ ctx.get_hapd_instance('ft-sae-1.conf').cli, + ctx.get_hapd_instance('ft-sae-2.conf').cli, + ctx.get_hapd_instance('ft-psk-3.conf').cli ] ctx.start_process(['ip', 'link', 'set', 'dev', cls.bss_hostapd[0].ifname, 'down']).wait() ctx.start_process(['ip', 'link', 'set', 'dev', cls.bss_hostapd[0].ifname, \ diff --git a/autotests/testSAE/autoconnect_test.py b/autotests/testSAE/autoconnect_test.py index 64a60e7c..9bfb33ec 100644 --- a/autotests/testSAE/autoconnect_test.py +++ b/autotests/testSAE/autoconnect_test.py @@ -8,7 +8,7 @@ import iwd from iwd import IWD from iwd import PSKAgent from iwd import NetworkType -from hostapd import HostapdCLI +from config import ctx class Test(unittest.TestCase): @@ -53,7 +53,7 @@ class Test(unittest.TestCase): @classmethod def setUpClass(cls): - cls.hostapd = HostapdCLI(config='ssidSAE.conf') + cls.hostapd = ctx.get_hapd_instance('ssidSAE.conf').cli IWD.copy_to_storage('ssidSAE.psk') pass diff --git a/autotests/testSAE/connection_test.py b/autotests/testSAE/connection_test.py index c67f8c83..4e7e98bc 100644 --- a/autotests/testSAE/connection_test.py +++ b/autotests/testSAE/connection_test.py @@ -8,7 +8,7 @@ import iwd from iwd import IWD from iwd import PSKAgent from iwd import NetworkType -from hostapd import HostapdCLI +from config import ctx import testutil class Test(unittest.TestCase): @@ -95,7 +95,7 @@ class Test(unittest.TestCase): @classmethod def setUpClass(cls): - cls.hostapd = HostapdCLI(config='ssidSAE.conf') + cls.hostapd = ctx.get_hapd_instance('ssidSAE.conf').cli @classmethod def tearDownClass(cls): diff --git a/autotests/testSAE/failure_test.py b/autotests/testSAE/failure_test.py index e61bf585..d1efbcf7 100644 --- a/autotests/testSAE/failure_test.py +++ b/autotests/testSAE/failure_test.py @@ -8,7 +8,7 @@ import iwd from iwd import IWD from iwd import PSKAgent from iwd import NetworkType -from hostapd import HostapdCLI +from config import ctx class Test(unittest.TestCase): @@ -37,7 +37,7 @@ class Test(unittest.TestCase): self.validate_connection(wd, 'InvalidSecret') def test_no_supported_groups(self): - hostapd = HostapdCLI(config='ssidSAE.conf') + hostapd = ctx.get_hapd_instance('ssidSAE.conf').cli hostapd.set_value('sae_groups', '1') hostapd.reload() diff --git a/autotests/testSAE/timeout_test.py b/autotests/testSAE/timeout_test.py index 1413bb4a..73342d6c 100644 --- a/autotests/testSAE/timeout_test.py +++ b/autotests/testSAE/timeout_test.py @@ -9,7 +9,6 @@ from iwd import IWD from iwd import PSKAgent from iwd import NetworkType from hwsim import Hwsim -from hostapd import HostapdCLI from config import ctx class Test(unittest.TestCase): @@ -40,7 +39,7 @@ class Test(unittest.TestCase): # needed because the hwsim rule only matches once and must be matched # on the first commit, not during group negotiation. # - hostapd = HostapdCLI(config='ssidSAE.conf') + hostapd = ctx.get_hapd_instance('ssidSAE.conf').cli hostapd.set_value('vendor_elements', 'dd0cf4f5e8050500000000000000') hostapd.set_value('sae_groups', '19') hostapd.reload() @@ -64,7 +63,7 @@ class Test(unittest.TestCase): rule0.remove() def test_sta_confirm_not_acked(self): - hostapd = HostapdCLI(config='ssidSAE.conf') + hostapd = ctx.get_hapd_instance('ssidSAE.conf').cli hostapd.set_value('vendor_elements', 'dd0cf4f5e8050500000000000000') hostapd.set_value('sae_groups', '19') hostapd.reload() diff --git a/autotests/testSAQuery-spoofing/connection_test.py b/autotests/testSAQuery-spoofing/connection_test.py index 0ff0615f..3ec28114 100644 --- a/autotests/testSAQuery-spoofing/connection_test.py +++ b/autotests/testSAQuery-spoofing/connection_test.py @@ -9,7 +9,7 @@ from iwd import IWD from iwd import PSKAgent from iwd import NetworkType from hwsim import Hwsim -from hostapd import HostapdCLI +from config import ctx from time import sleep @@ -18,7 +18,7 @@ class Test(unittest.TestCase): def test_connection_success(self): hwsim = Hwsim() - hostapd = HostapdCLI(config='ssidCCMP.conf') + hostapd = ctx.get_hapd_instance('ssidCCMP.conf').cli radio = hwsim.get_radio('rad0') wd = IWD() diff --git a/autotests/testSAQuery/connection_test.py b/autotests/testSAQuery/connection_test.py index 03280d0e..a4706237 100644 --- a/autotests/testSAQuery/connection_test.py +++ b/autotests/testSAQuery/connection_test.py @@ -8,12 +8,12 @@ import iwd from iwd import IWD from iwd import PSKAgent from iwd import NetworkType -from hostapd import HostapdCLI +from config import ctx class Test(unittest.TestCase): def test_connection_success(self): - hostapd = HostapdCLI(config='ssidCCMP.conf') + hostapd = ctx.get_hapd_instance('ssidCCMP.conf').cli wd = IWD() diff --git a/autotests/testWPA2-ext-key-id/connection_test.py b/autotests/testWPA2-ext-key-id/connection_test.py index afd48149..2b9f5635 100644 --- a/autotests/testWPA2-ext-key-id/connection_test.py +++ b/autotests/testWPA2-ext-key-id/connection_test.py @@ -10,13 +10,11 @@ from iwd import IWD from iwd import PSKAgent from iwd import NetworkType from hwsim import Hwsim -from hostapd import HostapdCLI +from config import ctx import testutil class Test(unittest.TestCase): def validate(self, wd, resend_m3=False): - hapd = HostapdCLI('ssidCCMP.conf') - psk_agent = PSKAgent("secret123") wd.register_psk_agent(psk_agent) @@ -42,10 +40,10 @@ class Test(unittest.TestCase): # Rekey 5 times just to make sure the key ID can be toggled back and # forth without causing problems. for i in range(5): - hapd.rekey(device.address) + self.hapd.rekey(device.address) if resend_m3: - hapd.resend_m3(device.address) + self.hapd.resend_m3(device.address) testutil.test_iface_operstate() testutil.test_ifaces_connected() @@ -101,7 +99,7 @@ class Test(unittest.TestCase): @classmethod def setUpClass(cls): - cls.hapd = HostapdCLI() + cls.hapd = ctx.get_hapd_instance().cli @classmethod def tearDownClass(cls): From patchwork Wed Jul 6 16:57:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Zaborowski X-Patchwork-Id: 12908348 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2E947538E for ; Wed, 6 Jul 2022 16:57:24 +0000 (UTC) Received: by mail-wr1-f54.google.com with SMTP id v16so11470950wrd.13 for ; Wed, 06 Jul 2022 09:57:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OzTh6igeO54jbl7BgIiqX7fqS3m8ywvuTz5lfA1RBQ8=; b=cfmsMWLCBRwPYwuUiQS7FAuYPREh7grHbOnKFvrB8JTHeBjiiMgCBHApTOvrIM9YAm 7iYHVnGz2pXcimYuOxxkAZQKW9lZJMQyMmWw3/TUplY4NWGLmO/KZbKCaxJtnU9MnH/T 9tpj1BeRLS4r/4LV7Vzkx0qL8GQa4HRVAu5Jlch0ozcRwcvL6lOdvKNCfJEt9QX30ZX4 Qsi89LAtnq+71cIIyCl3saUOhBZQXqRINuqX/heCAc8MvyChtWiGaz4zLhIGOioZgoeg r9QVewimxCdopV9E7xZWKfUQK0rWiTjWsmppiA/EiE0b2v3H82p1jYX/4FncF1Hc4jsS zoQw== X-Gm-Message-State: AJIora+YHRmyzcowFVKiXvfsuQOGiqLPX/KRAelT/zIlmdySVvgxUK23 kcMWVKhCDM8uhk8Ab8hCgCRcSMcbI5llr0fW X-Google-Smtp-Source: AGRyM1tVIlIAKxuRodtoXqDJMvPfUPeX6MXemefJRtyD+HR71VrMEZVyt3QVG2tQMzGePugOuKyKsg== X-Received: by 2002:a5d:4889:0:b0:21b:293e:9e43 with SMTP id g9-20020a5d4889000000b0021b293e9e43mr38077095wrq.705.1657126643377; Wed, 06 Jul 2022 09:57:23 -0700 (PDT) Received: from localhost.localdomain ([46.222.51.165]) by smtp.gmail.com with ESMTPSA id j8-20020a05600c190800b0039c5642e430sm29147856wmq.20.2022.07.06.09.57.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jul 2022 09:57:22 -0700 (PDT) From: Andrew Zaborowski To: iwd@lists.linux.dev Subject: [PATCH 5/5] test-runner: Mark source directory as safe for git Date: Wed, 6 Jul 2022 18:57:02 +0200 Message-Id: <20220706165702.3241756-5-andrew.zaborowski@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220706165702.3241756-1-andrew.zaborowski@intel.com> References: <20220706165702.3241756-1-andrew.zaborowski@intel.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Since we use git ls-files to produce the list of all tests (without -A), if the source directory is owned by somebody other than root one might get: fatal: unsafe repository ('/home/balrog/repos/iwd' is owned by someone else) To add an exception for this directory, call: git config --global --add safe.directory /home/balrog/repos/iwd Starting /home/balrog/repos/iwd/tools/..//autotests/ threw an uncaught exception Traceback (most recent call last): File "/home/balrog/repos/iwd/tools/run-tests", line 966, in run_auto_tests subtests = pre_test(ctx, test, copied) File "/home/balrog/repos/iwd/tools/run-tests", line 814, in pre_test raise Exception("No hw.conf found for %s" % test) Exception: No hw.conf found for /home/balrog/repos/iwd/tools/..//autotests/ Mark args.testhome as a safe directory on every run. --- tools/run-tests | 4 +++- tools/runner.py | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/run-tests b/tools/run-tests index f916fba6..c32fbe34 100755 --- a/tools/run-tests +++ b/tools/run-tests @@ -628,8 +628,10 @@ def build_test_list(args): # Run all tests if not args.autotests: # Get list of all autotests (committed in git) + Process(['git', 'config', '--system', '--add', 'safe.directory', + os.path.normpath(args.testhome)]).wait() tests = os.popen('git -C %s ls-files autotests/ | cut -f2 -d"/" \ - | grep "test*" | uniq' % args.testhome).read() \ + | grep "^test" | uniq' % args.testhome).read() \ .strip().split('\n') tests = [test_root + '/' + t for t in tests] else: diff --git a/tools/runner.py b/tools/runner.py index d39b560f..164bc881 100644 --- a/tools/runner.py +++ b/tools/runner.py @@ -36,6 +36,7 @@ mounts_common = [ MountInfo('tmpfs', 'tmpfs', '/run', 'mode=0755', MS_NOSUID|MS_NODEV|MS_STRICTATIME), MountInfo('tmpfs', 'tmpfs', '/tmp', '', 0), + MountInfo('tmpfs', 'tmpfs', '/etc', '', 0), MountInfo('tmpfs', 'tmpfs', '/usr/share/dbus-1', 'mode=0755', MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_STRICTATIME), ]