Wireless Daemon for Linux
 help / color / mirror / Atom feed
* [PATCH 1/2] auto-t: increase wait time for blacklist test
@ 2020-07-08 17:48 James Prestwood
  2020-07-08 17:48 ` [PATCH 2/2] auto-t: remove busy wait for eapol reauth James Prestwood
  2020-07-08 23:29 ` [PATCH 1/2] auto-t: increase wait time for blacklist test Denis Kenzior
  0 siblings, 2 replies; 3+ messages in thread
From: James Prestwood @ 2020-07-08 17:48 UTC (permalink / raw)
  To: iwd

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

This test was not reliably passing. Busy waiting is not really reliable,
but in this specific case its really the only option as the blacklist
must expire based on time.
---
 autotests/testBSSBlacklist/connection_test.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/autotests/testBSSBlacklist/connection_test.py b/autotests/testBSSBlacklist/connection_test.py
index 917f3192..7433d5f3 100644
--- a/autotests/testBSSBlacklist/connection_test.py
+++ b/autotests/testBSSBlacklist/connection_test.py
@@ -48,9 +48,11 @@ class Test(unittest.TestCase):
         psk_agent = PSKAgent("secret123")
         wd.register_psk_agent(psk_agent)
 
-        devices = wd.list_devices(1)
+        devices = wd.list_devices(2)
         device = devices[0]
 
+        devices[1].disconnect()
+
         condition = 'not obj.scanning'
         wd.wait_for_object_condition(device, condition)
 
@@ -110,8 +112,8 @@ class Test(unittest.TestCase):
         # Wait for the blacklist to expire (10 seconds)
         elapsed = time.time() - start
 
-        if elapsed < 11:
-            time.sleep(11 - elapsed)
+        if elapsed < 15:
+            wd.wait(15 - elapsed)
 
         device.disconnect()
 
-- 
2.21.1

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

* [PATCH 2/2] auto-t: remove busy wait for eapol reauth
  2020-07-08 17:48 [PATCH 1/2] auto-t: increase wait time for blacklist test James Prestwood
@ 2020-07-08 17:48 ` James Prestwood
  2020-07-08 23:29 ` [PATCH 1/2] auto-t: increase wait time for blacklist test Denis Kenzior
  1 sibling, 0 replies; 3+ messages in thread
From: James Prestwood @ 2020-07-08 17:48 UTC (permalink / raw)
  To: iwd

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

Many tests force a reauth after the initial connection. When the tests
were written there was no way of ensuring the reauth completed except
waiting (IWD.wait()). Now we can wait for hostapd events in the tests,
which is faster and more reliable than busy waiting.
---
 autotests/testEAP-AKA/connection_test.py             | 11 +++--------
 autotests/testEAP-PEAPv0-CryptoBinding/NoISK_test.py | 11 +++--------
 autotests/testEAP-PWD/connection_test.py             | 12 +++---------
 autotests/testEAP-SIM/connection_test.py             | 11 +++--------
 autotests/testEAP-TTLS-CHAP/connection_test.py       | 11 +++--------
 autotests/testEAP-TTLS-MSCHAP/connection_test.py     | 11 +++--------
 autotests/testEAP-TTLS-MSCHAPv2/connection_test.py   |  3 ++-
 autotests/testEAP-TTLS-PAP/connection_test.py        | 11 +++--------
 8 files changed, 23 insertions(+), 58 deletions(-)

diff --git a/autotests/testEAP-AKA/connection_test.py b/autotests/testEAP-AKA/connection_test.py
index 734e0dbb..bcdb1d92 100644
--- a/autotests/testEAP-AKA/connection_test.py
+++ b/autotests/testEAP-AKA/connection_test.py
@@ -15,13 +15,7 @@ from hostapd import hostapd_map
 class Test(unittest.TestCase):
 
     def test_connection_success(self):
-        hostapd = None
-
-        for hostapd_if in list(hostapd_map.values()):
-            hpd = HostapdCLI(hostapd_if)
-            if hpd.get_config_value('ssid') == 'ssidEAP-AKA':
-                hostapd = hpd
-                break
+        hostapd = HostapdCLI(config='ssidEAP-AKA.conf')
 
         self.assertIsNotNone(hostapd)
 
@@ -58,7 +52,8 @@ class Test(unittest.TestCase):
 
         hostapd.eapol_reauth(device.address)
 
-        wd.wait(10)
+        hostapd.wait_for_event('CTRL-EVENT-EAP-STARTED')
+        hostapd.wait_for_event('CTRL-EVENT-EAP-SUCCESS')
 
         condition = 'obj.connected'
         wd.wait_for_object_condition(ordered_network.network_object, condition)
diff --git a/autotests/testEAP-PEAPv0-CryptoBinding/NoISK_test.py b/autotests/testEAP-PEAPv0-CryptoBinding/NoISK_test.py
index fde8bfc2..0f7d432c 100644
--- a/autotests/testEAP-PEAPv0-CryptoBinding/NoISK_test.py
+++ b/autotests/testEAP-PEAPv0-CryptoBinding/NoISK_test.py
@@ -16,13 +16,7 @@ from hostapd import hostapd_map
 class Test(unittest.TestCase):
 
     def validate_connection(self, wd):
-        hostapd = None
-
-        for hostapd_if in list(hostapd_map.values()):
-            hpd = HostapdCLI(hostapd_if)
-            if hpd.get_config_value('ssid') == 'ssidEAP-PEAPv0-NoISK':
-                hostapd = hpd
-                break
+        hostapd = HostapdCLI(config='ssidEAP-PEAPv0-NoISK.conf')
 
         self.assertIsNotNone(hostapd)
 
@@ -52,7 +46,8 @@ class Test(unittest.TestCase):
 
         hostapd.eapol_reauth(device.address)
 
-        wd.wait(10)
+        hostapd.wait_for_event('CTRL-EVENT-EAP-STARTED')
+        hostapd.wait_for_event('CTRL-EVENT-EAP-SUCCESS')
 
         condition = 'obj.connected'
         wd.wait_for_object_condition(ordered_network.network_object, condition)
diff --git a/autotests/testEAP-PWD/connection_test.py b/autotests/testEAP-PWD/connection_test.py
index e5d6e621..0c722c44 100644
--- a/autotests/testEAP-PWD/connection_test.py
+++ b/autotests/testEAP-PWD/connection_test.py
@@ -15,14 +15,7 @@ from hostapd import hostapd_map
 class Test(unittest.TestCase):
 
     def validate_connection(self, wd):
-
-        hostapd = None
-
-        for hostapd_if in list(hostapd_map.values()):
-            hpd = HostapdCLI(hostapd_if)
-            if hpd.get_config_value('ssid') == 'ssidEAP-PWD':
-                hostapd = hpd
-                break
+        hostapd = HostapdCLI(config='ssidEAP-PWD.conf')
 
         self.assertIsNotNone(hostapd)
 
@@ -56,7 +49,8 @@ class Test(unittest.TestCase):
 
         hostapd.eapol_reauth(device.address)
 
-        wd.wait(10)
+        hostapd.wait_for_event('CTRL-EVENT-EAP-STARTED')
+        hostapd.wait_for_event('CTRL-EVENT-EAP-SUCCESS')
 
         condition = 'obj.connected'
         wd.wait_for_object_condition(ordered_network.network_object, condition)
diff --git a/autotests/testEAP-SIM/connection_test.py b/autotests/testEAP-SIM/connection_test.py
index 0ac7da05..97956d0c 100644
--- a/autotests/testEAP-SIM/connection_test.py
+++ b/autotests/testEAP-SIM/connection_test.py
@@ -15,13 +15,7 @@ from hostapd import hostapd_map
 class Test(unittest.TestCase):
 
     def test_connection_success(self):
-        hostapd = None
-
-        for hostapd_if in list(hostapd_map.values()):
-            hpd = HostapdCLI(hostapd_if)
-            if hpd.get_config_value('ssid') == 'ssidEAP-SIM':
-                hostapd = hpd
-                break
+        hostapd = HostapdCLI(config='ssidEAP-SIM.conf')
 
         auth = AuthCenter('/tmp/hlrauc.sock', '/tmp/sim.db')
 
@@ -56,7 +50,8 @@ class Test(unittest.TestCase):
 
         hostapd.eapol_reauth(device.address)
 
-        wd.wait(10)
+        hostapd.wait_for_event('CTRL-EVENT-EAP-STARTED')
+        hostapd.wait_for_event('CTRL-EVENT-EAP-SUCCESS')
 
         condition = 'obj.connected'
         wd.wait_for_object_condition(ordered_network.network_object, condition)
diff --git a/autotests/testEAP-TTLS-CHAP/connection_test.py b/autotests/testEAP-TTLS-CHAP/connection_test.py
index f9633b28..e3719669 100644
--- a/autotests/testEAP-TTLS-CHAP/connection_test.py
+++ b/autotests/testEAP-TTLS-CHAP/connection_test.py
@@ -16,13 +16,7 @@ from hostapd import hostapd_map
 class Test(unittest.TestCase):
 
     def test_connection_success(self):
-        hostapd = None
-
-        for hostapd_if in list(hostapd_map.values()):
-            hpd = HostapdCLI(hostapd_if)
-            if hpd.get_config_value('ssid') == 'ssidEAP-TTLS-CHAP':
-                hostapd = hpd
-                break
+        hostapd = HostapdCLI(config='ssidEAP-TTLS-CHAP.conf')
 
         self.assertIsNotNone(hostapd)
 
@@ -55,7 +49,8 @@ class Test(unittest.TestCase):
 
         hostapd.eapol_reauth(device.address)
 
-        wd.wait(10)
+        hostapd.wait_for_event('CTRL-EVENT-EAP-STARTED')
+        hostapd.wait_for_event('CTRL-EVENT-EAP-SUCCESS')
 
         condition = 'obj.connected'
         wd.wait_for_object_condition(ordered_network.network_object, condition)
diff --git a/autotests/testEAP-TTLS-MSCHAP/connection_test.py b/autotests/testEAP-TTLS-MSCHAP/connection_test.py
index 269f6131..ea245a38 100644
--- a/autotests/testEAP-TTLS-MSCHAP/connection_test.py
+++ b/autotests/testEAP-TTLS-MSCHAP/connection_test.py
@@ -16,13 +16,7 @@ from hostapd import hostapd_map
 class Test(unittest.TestCase):
 
     def test_connection_success(self):
-        hostapd = None
-
-        for hostapd_if in hostapd_map.values():
-            hpd = HostapdCLI(hostapd_if)
-            if hpd.get_config_value('ssid') == 'ssidEAP-TTLS-MSCHAP':
-                hostapd = hpd
-                break
+        hostapd = HostapdCLI(config='ssidEAP-TTLS-MSCHAP.conf')
 
         self.assertIsNotNone(hostapd)
 
@@ -55,7 +49,8 @@ class Test(unittest.TestCase):
 
         hostapd.eapol_reauth(device.address)
 
-        wd.wait(10)
+        hostapd.wait_for_event('CTRL-EVENT-EAP-STARTED')
+        hostapd.wait_for_event('CTRL-EVENT-EAP-SUCCESS')
 
         condition = 'obj.connected'
         wd.wait_for_object_condition(ordered_network.network_object, condition)
diff --git a/autotests/testEAP-TTLS-MSCHAPv2/connection_test.py b/autotests/testEAP-TTLS-MSCHAPv2/connection_test.py
index 66cc440b..918e8d1f 100644
--- a/autotests/testEAP-TTLS-MSCHAPv2/connection_test.py
+++ b/autotests/testEAP-TTLS-MSCHAPv2/connection_test.py
@@ -48,7 +48,8 @@ class Test(unittest.TestCase):
 
         hostapd.eapol_reauth(device.address)
 
-        wd.wait(10)
+        hostapd.wait_for_event('CTRL-EVENT-EAP-STARTED')
+        hostapd.wait_for_event('CTRL-EVENT-EAP-SUCCESS')
 
         condition = 'obj.connected'
         wd.wait_for_object_condition(ordered_network.network_object, condition)
diff --git a/autotests/testEAP-TTLS-PAP/connection_test.py b/autotests/testEAP-TTLS-PAP/connection_test.py
index 07b14aa9..ce787b01 100644
--- a/autotests/testEAP-TTLS-PAP/connection_test.py
+++ b/autotests/testEAP-TTLS-PAP/connection_test.py
@@ -16,13 +16,7 @@ from hostapd import hostapd_map
 class Test(unittest.TestCase):
 
     def test_connection_success(self):
-        hostapd = None
-
-        for hostapd_if in list(hostapd_map.values()):
-            hpd = HostapdCLI(hostapd_if)
-            if hpd.get_config_value('ssid') == 'ssidEAP-TTLS-PAP':
-                hostapd = hpd
-                break
+        hostapd = HostapdCLI(config='ssidEAP-TTLS-PAP.conf')
 
         self.assertIsNotNone(hostapd)
 
@@ -55,7 +49,8 @@ class Test(unittest.TestCase):
 
         hostapd.eapol_reauth(device.address)
 
-        wd.wait(10)
+        hostapd.wait_for_event('CTRL-EVENT-EAP-STARTED')
+        hostapd.wait_for_event('CTRL-EVENT-EAP-SUCCESS')
 
         condition = 'obj.connected'
         wd.wait_for_object_condition(ordered_network.network_object, condition)
-- 
2.21.1

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

* Re: [PATCH 1/2] auto-t: increase wait time for blacklist test
  2020-07-08 17:48 [PATCH 1/2] auto-t: increase wait time for blacklist test James Prestwood
  2020-07-08 17:48 ` [PATCH 2/2] auto-t: remove busy wait for eapol reauth James Prestwood
@ 2020-07-08 23:29 ` Denis Kenzior
  1 sibling, 0 replies; 3+ messages in thread
From: Denis Kenzior @ 2020-07-08 23:29 UTC (permalink / raw)
  To: iwd

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

Hi James,

On 7/8/20 12:48 PM, James Prestwood wrote:
> This test was not reliably passing. Busy waiting is not really reliable,
> but in this specific case its really the only option as the blacklist
> must expire based on time.
> ---
>   autotests/testBSSBlacklist/connection_test.py | 8 +++++---
>   1 file changed, 5 insertions(+), 3 deletions(-)
> 

Both applied, thanks.

Regards,
-Denis

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

end of thread, other threads:[~2020-07-08 23:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-07-08 17:48 [PATCH 1/2] auto-t: increase wait time for blacklist test James Prestwood
2020-07-08 17:48 ` [PATCH 2/2] auto-t: remove busy wait for eapol reauth James Prestwood
2020-07-08 23:29 ` [PATCH 1/2] auto-t: increase wait time for blacklist test Denis Kenzior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox