All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] auto-t: add netconfig autotest
@ 2020-09-16  0:00 James Prestwood
  2020-09-16  1:21 ` Denis Kenzior
  0 siblings, 1 reply; 2+ messages in thread
From: James Prestwood @ 2020-09-16  0:00 UTC (permalink / raw)
  To: iwd

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

Tests that DHCP using IWD's internal netconfig functions properly.
The actual IP address assignment is not verified, but since IWD does
not signal the connection as successful unless DHCP succeeds we
can assume it was successful by checking that the device is connected.

The process of actually starting dhcpd and configuring the interfaces
is quite simple so it was left in the autotest itself. If (or when)
more tests require IP capabilities (p2p, FILS, etc) this could be
moved into test-runner itself and be made common. The reason I did not
put it in there now is a) because this is the only test and b) more
complex DHCP cases are likely to develop and may require more than this
simplistic setup (like multiple APs/interfaces)
---
 autotests/testNetconfig/connection_test.py | 70 ++++++++++++++++++++++
 autotests/testNetconfig/dhcpd.conf         | 16 +++++
 autotests/testNetconfig/hw.conf            |  6 ++
 autotests/testNetconfig/main.conf          |  2 +
 autotests/testNetconfig/ssidTKIP.conf      |  7 +++
 5 files changed, 101 insertions(+)
 create mode 100644 autotests/testNetconfig/connection_test.py
 create mode 100644 autotests/testNetconfig/dhcpd.conf
 create mode 100644 autotests/testNetconfig/hw.conf
 create mode 100644 autotests/testNetconfig/main.conf
 create mode 100644 autotests/testNetconfig/ssidTKIP.conf

-v2:
 * Removed dhcpd.leases. Its an empty file anyways which caused issues with applying
   the patches. Instead we can just touch /tmp/dhcpd.leases before starting dhcpd.

diff --git a/autotests/testNetconfig/connection_test.py b/autotests/testNetconfig/connection_test.py
new file mode 100644
index 00000000..3a590aeb
--- /dev/null
+++ b/autotests/testNetconfig/connection_test.py
@@ -0,0 +1,70 @@
+#!/usr/bin/python3
+
+import unittest
+import sys
+
+sys.path.append('../util')
+import iwd
+from iwd import IWD
+from iwd import PSKAgent
+from iwd import NetworkType
+import testutil
+from config import ctx
+
+class Test(unittest.TestCase):
+
+    def test_connection_success(self):
+        wd = IWD()
+
+        psk_agent = PSKAgent("secret123")
+        wd.register_psk_agent(psk_agent)
+
+        devices = wd.list_devices(1)
+        device = devices[0]
+
+        condition = 'not obj.scanning'
+        wd.wait_for_object_condition(device, condition)
+
+        device.scan()
+
+        condition = 'not obj.scanning'
+        wd.wait_for_object_condition(device, condition)
+
+        ordered_network = device.get_ordered_network('ssidTKIP')
+
+        self.assertEqual(ordered_network.type, NetworkType.psk)
+
+        condition = 'not obj.connected'
+        wd.wait_for_object_condition(ordered_network.network_object, condition)
+
+        ordered_network.network_object.connect()
+
+        condition = 'obj.state == DeviceState.connected'
+        wd.wait_for_object_condition(device, condition)
+
+        testutil.test_iface_operstate()
+        testutil.test_ifaces_connected()
+
+        device.disconnect()
+
+        condition = 'not obj.connected'
+        wd.wait_for_object_condition(ordered_network.network_object, condition)
+
+        wd.unregister_psk_agent(psk_agent)
+
+    @classmethod
+    def setUpClass(cls):
+        # 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(['ifconfig', 'wln0', '192.168.1.1', 'netmask', '255.255.255.0'],
+                                wait=True)
+        ctx.start_process(['touch', '/tmp/dhcpd.leases'], wait=True)
+        ctx.start_process(['dhcpd', '-cf', '/tmp/dhcpd.conf', '-lf', '/tmp/dhcpd.leases'])
+
+    @classmethod
+    def tearDownClass(cls):
+        IWD.clear_storage()
+
+if __name__ == '__main__':
+    unittest.main(exit=True)
diff --git a/autotests/testNetconfig/dhcpd.conf b/autotests/testNetconfig/dhcpd.conf
new file mode 100644
index 00000000..77b4da1c
--- /dev/null
+++ b/autotests/testNetconfig/dhcpd.conf
@@ -0,0 +1,16 @@
+default-lease-time 600;         # 10 minutes
+max-lease-time 7200;            # 2  hours
+
+option broadcast-address 192.168.1.255;
+option routers 192.168.1.254;
+option subnet-mask 255.255.255.0;
+
+subnet 192.168.1.0 netmask 255.255.255.0
+ {
+  option routers 192.168.1.1;
+  option subnet-mask 255.255.255.0;
+  option domain-name-servers 192.168.1.1;
+  interface wln0;
+  range 192.168.1.10 192.168.1.20;
+  range 192.168.1.100 192.168.1.200;
+ }
diff --git a/autotests/testNetconfig/hw.conf b/autotests/testNetconfig/hw.conf
new file mode 100644
index 00000000..75c5ac6e
--- /dev/null
+++ b/autotests/testNetconfig/hw.conf
@@ -0,0 +1,6 @@
+[SETUP]
+num_radios=2
+max_test_exec_interval_sec=40
+
+[HOSTAPD]
+rad0=ssidTKIP.conf
diff --git a/autotests/testNetconfig/main.conf b/autotests/testNetconfig/main.conf
new file mode 100644
index 00000000..982e5445
--- /dev/null
+++ b/autotests/testNetconfig/main.conf
@@ -0,0 +1,2 @@
+[General]
+EnableNetworkConfiguration=true
diff --git a/autotests/testNetconfig/ssidTKIP.conf b/autotests/testNetconfig/ssidTKIP.conf
new file mode 100644
index 00000000..11ef15f0
--- /dev/null
+++ b/autotests/testNetconfig/ssidTKIP.conf
@@ -0,0 +1,7 @@
+hw_mode=g
+channel=1
+ssid=ssidTKIP
+
+wpa=1
+wpa_pairwise=TKIP
+wpa_passphrase=secret123
-- 
2.26.2

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

* Re: [PATCH v2] auto-t: add netconfig autotest
  2020-09-16  0:00 [PATCH v2] auto-t: add netconfig autotest James Prestwood
@ 2020-09-16  1:21 ` Denis Kenzior
  0 siblings, 0 replies; 2+ messages in thread
From: Denis Kenzior @ 2020-09-16  1:21 UTC (permalink / raw)
  To: iwd

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

Hi James,

On 9/15/20 7:00 PM, James Prestwood wrote:
> Tests that DHCP using IWD's internal netconfig functions properly.
> The actual IP address assignment is not verified, but since IWD does
> not signal the connection as successful unless DHCP succeeds we
> can assume it was successful by checking that the device is connected.
> 
> The process of actually starting dhcpd and configuring the interfaces
> is quite simple so it was left in the autotest itself. If (or when)
> more tests require IP capabilities (p2p, FILS, etc) this could be
> moved into test-runner itself and be made common. The reason I did not
> put it in there now is a) because this is the only test and b) more
> complex DHCP cases are likely to develop and may require more than this
> simplistic setup (like multiple APs/interfaces)
> ---
>   autotests/testNetconfig/connection_test.py | 70 ++++++++++++++++++++++
>   autotests/testNetconfig/dhcpd.conf         | 16 +++++
>   autotests/testNetconfig/hw.conf            |  6 ++
>   autotests/testNetconfig/main.conf          |  2 +
>   autotests/testNetconfig/ssidTKIP.conf      |  7 +++
>   5 files changed, 101 insertions(+)
>   create mode 100644 autotests/testNetconfig/connection_test.py
>   create mode 100644 autotests/testNetconfig/dhcpd.conf
>   create mode 100644 autotests/testNetconfig/hw.conf
>   create mode 100644 autotests/testNetconfig/main.conf
>   create mode 100644 autotests/testNetconfig/ssidTKIP.conf
> 
> -v2:
>   * Removed dhcpd.leases. Its an empty file anyways which caused issues with applying
>     the patches. Instead we can just touch /tmp/dhcpd.leases before starting dhcpd.
> 

Applied, thanks.

Regards,
-Denis

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

end of thread, other threads:[~2020-09-16  1:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-16  0:00 [PATCH v2] auto-t: add netconfig autotest James Prestwood
2020-09-16  1:21 ` 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.