From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.01.org
Subject: [PATCH 3/4] auto-t: fix error handling in testHotspot
Date: Wed, 18 Aug 2021 10:26:02 -0700 [thread overview]
Message-ID: <20210818172603.266294-3-prestwoj@gmail.com> (raw)
In-Reply-To: <20210818172603.266294-1-prestwoj@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 6957 bytes --]
testHotspot suffered from improper cleanup and if a single test failed
all subsequent tests would fail due to IWD still running since IWD()
was never cleaned up.
In addition the PSK agent and hwsim rules are now set onto the cls
object and removed in tearDownClass()
---
autotests/testHotspot/anqp_delay_test.py | 38 ++++++++++++++---------
autotests/testHotspot/autoconnect_test.py | 6 +++-
autotests/testHotspot/hessid_test.py | 6 +++-
autotests/testHotspot/hotspot_test.py | 6 +++-
autotests/testHotspot/roaming_test.py | 14 +++++----
5 files changed, 46 insertions(+), 24 deletions(-)
diff --git a/autotests/testHotspot/anqp_delay_test.py b/autotests/testHotspot/anqp_delay_test.py
index 04e5a1d7..22a5bdbe 100644
--- a/autotests/testHotspot/anqp_delay_test.py
+++ b/autotests/testHotspot/anqp_delay_test.py
@@ -17,19 +17,9 @@ from time import sleep
class Test(unittest.TestCase):
def test_connection_success(self):
- hwsim = Hwsim()
-
- bss_radio = hwsim.get_radio('rad0')
- rule0 = hwsim.rules.create()
- rule0.source = bss_radio.addresses[0]
- rule0.bidirectional = True
-
- wd = IWD(True)
-
- hapd = HostapdCLI(config='ssidHotspot.conf')
-
- psk_agent = PSKAgent('abc', ('domain\\user', 'testpasswd'))
- wd.register_psk_agent(psk_agent)
+ wd = self.wd
+ hapd = self.hapd
+ rule0 = self.rule0
devices = wd.list_devices(1)
device = devices[0]
@@ -82,17 +72,35 @@ class Test(unittest.TestCase):
condition = 'not obj.connected'
wd.wait_for_object_condition(ordered_network.network_object, condition)
- wd.unregister_psk_agent(psk_agent)
-
@classmethod
def setUpClass(cls):
+ cls.hwsim = Hwsim()
+
+ bss_radio = cls.hwsim.get_radio('rad0')
+ cls.rule0 = cls.hwsim.rules.create()
+ cls.rule0.source = bss_radio.addresses[0]
+ cls.rule0.bidirectional = True
+
+ cls.hapd = HostapdCLI(config='ssidHotspot.conf')
+
IWD.copy_to_hotspot('example.conf')
IWD.copy_to_storage('anqp_enabled.conf', storage_dir=IWD_CONFIG_DIR, name='main.conf')
+ cls.wd = IWD(True)
+ cls.psk_agent = PSKAgent('abc', ('domain\\user', 'testpasswd'))
+ cls.wd.register_psk_agent(cls.psk_agent)
+
@classmethod
def tearDownClass(cls):
IWD.clear_storage()
+
+ cls.wd.unregister_psk_agent(cls.psk_agent)
+ cls.psk_agent = None
os.remove('/tmp/main.conf')
+ cls.hwsim.rules.remove_all()
+ cls.hwsim = None
+ cls.wd = None
+
if __name__ == '__main__':
unittest.main(exit=True)
diff --git a/autotests/testHotspot/autoconnect_test.py b/autotests/testHotspot/autoconnect_test.py
index 777a0670..8b718dc7 100644
--- a/autotests/testHotspot/autoconnect_test.py
+++ b/autotests/testHotspot/autoconnect_test.py
@@ -14,7 +14,7 @@ import testutil
class Test(unittest.TestCase):
def test_connection_success(self):
- wd = IWD(True, '/tmp')
+ wd = self.wd
hapd_hotspot = HostapdCLI(config='ssidHotspot.conf')
hapd_wpa = HostapdCLI(config='ssidWPA2-1.conf')
@@ -111,10 +111,14 @@ class Test(unittest.TestCase):
IWD.copy_to_storage('ssidWPA2-1.psk')
IWD.copy_to_storage('anqp_enabled.conf', storage_dir=IWD_CONFIG_DIR, name='main.conf')
+ cls.wd = IWD(True)
+
@classmethod
def tearDownClass(cls):
IWD.clear_storage()
os.remove('/tmp/main.conf')
+ cls.wd = None
+
if __name__ == '__main__':
unittest.main(exit=True)
diff --git a/autotests/testHotspot/hessid_test.py b/autotests/testHotspot/hessid_test.py
index 88e750de..4a47e5c7 100644
--- a/autotests/testHotspot/hessid_test.py
+++ b/autotests/testHotspot/hessid_test.py
@@ -15,7 +15,7 @@ import testutil
class Test(unittest.TestCase):
def test_connection_success(self):
- wd = IWD(True, '/tmp')
+ wd = self.wd
hapd = HostapdCLI(config='ssidHotspot.conf')
@@ -52,10 +52,14 @@ class Test(unittest.TestCase):
IWD.copy_to_hotspot('hessid.conf')
IWD.copy_to_storage('anqp_disabled.conf', storage_dir=IWD_CONFIG_DIR, name='main.conf')
+ cls.wd = IWD(True)
+
@classmethod
def tearDownClass(cls):
IWD.clear_storage()
os.remove('/tmp/main.conf')
+ cls.wd = None
+
if __name__ == '__main__':
unittest.main(exit=True)
diff --git a/autotests/testHotspot/hotspot_test.py b/autotests/testHotspot/hotspot_test.py
index f49477dc..054a1a8f 100644
--- a/autotests/testHotspot/hotspot_test.py
+++ b/autotests/testHotspot/hotspot_test.py
@@ -15,7 +15,7 @@ import testutil
class Test(unittest.TestCase):
def test_connection_success(self):
- wd = IWD(True, '/tmp')
+ wd = self.wd
hapd = HostapdCLI(config='ssidHotspot.conf')
@@ -52,10 +52,14 @@ class Test(unittest.TestCase):
IWD.copy_to_hotspot('example.conf')
IWD.copy_to_storage('anqp_enabled.conf', storage_dir=IWD_CONFIG_DIR, name='main.conf')
+ cls.wd = IWD(True)
+
@classmethod
def tearDownClass(cls):
IWD.clear_storage()
os.remove('/tmp/main.conf')
+ cls.wd = None
+
if __name__ == '__main__':
unittest.main(exit=True)
diff --git a/autotests/testHotspot/roaming_test.py b/autotests/testHotspot/roaming_test.py
index 6cdd6922..1d785700 100644
--- a/autotests/testHotspot/roaming_test.py
+++ b/autotests/testHotspot/roaming_test.py
@@ -15,13 +15,10 @@ import testutil
class Test(unittest.TestCase):
def test_connection_success(self):
- wd = IWD(True, '/tmp')
+ wd = self.wd
hapd = HostapdCLI(config='ssidHotspot.conf')
- psk_agent = PSKAgent('abc', ('domain\\user', 'testpasswd'))
- wd.register_psk_agent(psk_agent)
-
devices = wd.list_devices(1)
device = devices[0]
@@ -45,17 +42,22 @@ class Test(unittest.TestCase):
condition = 'not obj.connected'
wd.wait_for_object_condition(ordered_network.network_object, condition)
- wd.unregister_psk_agent(psk_agent)
-
@classmethod
def setUpClass(cls):
IWD.copy_to_hotspot('roaming.conf')
IWD.copy_to_storage('anqp_disabled.conf', storage_dir=IWD_CONFIG_DIR, name='main.conf')
+ cls.wd = IWD(True)
+ cls.psk_agent = PSKAgent('abc', ('domain\\user', 'testpasswd'))
+ cls.wd.register_psk_agent(cls.psk_agent)
+
@classmethod
def tearDownClass(cls):
IWD.clear_storage()
os.remove('/tmp/main.conf')
+ cls.wd.unregister_psk_agent(cls.psk_agent)
+ cls.wd = None
+
if __name__ == '__main__':
unittest.main(exit=True)
--
2.31.1
next prev parent reply other threads:[~2021-08-18 17:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-18 17:26 [PATCH 1/4] network: handle NULL/hotspot networks when removing secrets James Prestwood
2021-08-18 17:26 ` [PATCH 2/4] hwsim: add Rule.remove_all() James Prestwood
2021-08-18 17:26 ` James Prestwood [this message]
2021-08-18 17:26 ` [PATCH 4/4] test-runner: fix subtest option James Prestwood
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210818172603.266294-3-prestwoj@gmail.com \
--to=prestwoj@gmail.com \
--cc=iwd@lists.01.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox