mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-22 06:29:23 +01:00
auto-t: Test Agent ops
This commit is contained in:
parent
d38bd513c9
commit
cc66050b90
100
autotests/testAgent/agent_test.py
Normal file
100
autotests/testAgent/agent_test.py
Normal file
@ -0,0 +1,100 @@
|
||||
#!/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
|
||||
import subprocess
|
||||
|
||||
class Test(unittest.TestCase):
|
||||
|
||||
def check_connection(self, wd, ssid):
|
||||
|
||||
device = wd.list_devices(1)[0]
|
||||
ordered_network = device.get_ordered_network(ssid, scan_if_needed=True)
|
||||
|
||||
ordered_network.network_object.connect()
|
||||
|
||||
condition = 'obj.state == DeviceState.connected'
|
||||
wd.wait_for_object_condition(device, condition)
|
||||
|
||||
condition = 'obj.connected_network is not None'
|
||||
wd.wait_for_object_condition(device, condition)
|
||||
|
||||
testutil.test_iface_operstate(device.name)
|
||||
device.disconnect()
|
||||
|
||||
condition = 'obj.state == DeviceState.disconnected'
|
||||
wd.wait_for_object_condition(device, condition)
|
||||
|
||||
def test_connection_with_no_agent(self):
|
||||
|
||||
wd = IWD()
|
||||
|
||||
with self.assertRaises(iwd.NoAgentEx):
|
||||
self.check_connection(wd, 'ssid1')
|
||||
|
||||
IWD.clear_storage()
|
||||
|
||||
def test_connection_with_own_agent(self):
|
||||
|
||||
wd = IWD()
|
||||
|
||||
psk_agent = PSKAgent("secret_ssid1")
|
||||
wd.register_psk_agent(psk_agent)
|
||||
|
||||
self.check_connection(wd, 'ssid1')
|
||||
|
||||
wd.unregister_psk_agent(psk_agent)
|
||||
|
||||
IWD.clear_storage()
|
||||
|
||||
def test_connection_with_other_agent(self):
|
||||
wd = IWD()
|
||||
|
||||
iwctl = subprocess.Popen(['iwctl', '-P', 'secret_ssid2'])
|
||||
# Let iwctl to start and register its agent.
|
||||
wd.wait(2)
|
||||
|
||||
self.check_connection(wd, 'ssid2')
|
||||
|
||||
iwctl.terminate()
|
||||
iwctl.communicate()
|
||||
|
||||
IWD.clear_storage()
|
||||
|
||||
def test_connection_use_own_agent_from_multiple_registered(self):
|
||||
|
||||
wd = IWD()
|
||||
|
||||
iwctl = subprocess.Popen(['iwctl', '-P', 'secret_ssid2'])
|
||||
# Let iwctl to start and register its agent.
|
||||
wd.wait(2)
|
||||
|
||||
psk_agent = PSKAgent("secret_ssid1")
|
||||
wd.register_psk_agent(psk_agent)
|
||||
|
||||
self.check_connection(wd, 'ssid1')
|
||||
|
||||
wd.unregister_psk_agent(psk_agent)
|
||||
|
||||
iwctl.terminate()
|
||||
iwctl.communicate()
|
||||
|
||||
IWD.clear_storage()
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
IWD.clear_storage()
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main(exit=True)
|
7
autotests/testAgent/hw.conf
Normal file
7
autotests/testAgent/hw.conf
Normal file
@ -0,0 +1,7 @@
|
||||
[SETUP]
|
||||
num_radios=3
|
||||
max_test_exec_interval_sec=40
|
||||
|
||||
[HOSTAPD]
|
||||
rad0=ssid1.conf
|
||||
rad1=ssid2.conf
|
7
autotests/testAgent/ssid1.conf
Normal file
7
autotests/testAgent/ssid1.conf
Normal file
@ -0,0 +1,7 @@
|
||||
hw_mode=g
|
||||
channel=1
|
||||
ssid=ssid1
|
||||
|
||||
wpa=1
|
||||
wpa_pairwise=TKIP
|
||||
wpa_passphrase=secret_ssid1
|
7
autotests/testAgent/ssid2.conf
Normal file
7
autotests/testAgent/ssid2.conf
Normal file
@ -0,0 +1,7 @@
|
||||
hw_mode=g
|
||||
channel=1
|
||||
ssid=ssid2
|
||||
|
||||
wpa=1
|
||||
wpa_pairwise=TKIP
|
||||
wpa_passphrase=secret_ssid2
|
Loading…
Reference in New Issue
Block a user