3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-21 22:09:23 +01:00

auto-t: prepare autotests for test-runner re-write

The tests basically remained the same with a few minor changes.
The wiphy_map and in turn hostapd_map are no longer used. This
was already partially converted a long time ago when the 'config'
parameter was added to HostapdCLI. This patch fully converts all
autotests to use 'config' rather than looking up by interface.

Some test scripts were named 'test.py' which was fine before but
the new rewrite actually loads each python test as a module. The
name 'test' is too ambiguous and causes issues due to a native
python module with the same name. All of these files were
renamed to 'connection_test.py'.
This commit is contained in:
James Prestwood 2020-09-10 16:12:22 -07:00 committed by Denis Kenzior
parent c7b072ff21
commit 9594b03a35
41 changed files with 56 additions and 117 deletions

View File

@ -3,17 +3,17 @@
import unittest
import sys, os
sys.path.append('../util')
import iwd
from iwd import IWD
from iwd import PSKAgent
from iwd import NetworkType
import hostapd
from hostapd import HostapdCLI
import testutil
class Test(unittest.TestCase):
def client_connect(self, wd, dev):
hostapd = HostapdCLI(config='psk-ccmp.conf')
ordered_network = dev.get_ordered_network('TestAP1', True)
@ -30,8 +30,7 @@ class Test(unittest.TestCase):
wd.unregister_psk_agent(psk_agent)
testutil.test_iface_operstate(dev.name)
testutil.test_ifaces_connected(list(hostapd.hostapd_map.keys())[0],
dev.name)
testutil.test_ifaces_connected(hostapd.ifname, dev.name)
dev.disconnect()
@ -57,6 +56,7 @@ class Test(unittest.TestCase):
wd.wait_for_object_condition(dev2, condition)
ordered_networks = dev2.get_ordered_networks()
networks = { n.name: n for n in ordered_networks }
self.assertEqual(networks['TestAP1'].type, NetworkType.psk)
self.assertEqual(networks['TestAP2'].type, NetworkType.psk)
@ -66,6 +66,7 @@ class Test(unittest.TestCase):
try:
dev2.disconnect()
condition = 'not obj.connected'
wd.wait_for_object_condition(dev2, condition)
except:

View File

@ -8,12 +8,13 @@ import iwd
from iwd import IWD
from iwd import PSKAgent
from iwd import NetworkType
import hostapd
from hostapd import HostapdCLI
import testutil
class Test(unittest.TestCase):
def client_connect(self, wd, dev):
hostapd = HostapdCLI(config='psk-ccmp.conf')
ordered_network = dev.get_ordered_network('TestAP1', True)
@ -30,8 +31,7 @@ class Test(unittest.TestCase):
wd.unregister_psk_agent(psk_agent)
testutil.test_iface_operstate(dev.name)
testutil.test_ifaces_connected(list(hostapd.hostapd_map.keys())[0],
dev.name)
testutil.test_ifaces_connected(hostapd.ifname, dev.name)
dev.disconnect()

View File

@ -10,8 +10,6 @@ from iwd import PSKAgent
from iwd import NetworkType
from hostapd import HostapdCLI
from hostapd import hostapd_map
from hwsim import Hwsim
class Test(unittest.TestCase):

View File

@ -10,12 +10,8 @@ from iwd import PSKAgent
from iwd import NetworkType
from hostapd import HostapdCLI
from hostapd import hostapd_map
from hwsim import Hwsim
import time
class Test(unittest.TestCase):
def test_connection_success(self):

View File

@ -10,12 +10,8 @@ from iwd import PSKAgent
from iwd import NetworkType
from hostapd import HostapdCLI
from hostapd import hostapd_map
from hwsim import Hwsim
import time
class Test(unittest.TestCase):
def test_connection_success(self):

View File

@ -10,7 +10,6 @@ from iwd import PSKAgent
from iwd import NetworkType
from hostapd import HostapdCLI
from hostapd import hostapd_map
from hwsim import Hwsim

View File

@ -10,12 +10,8 @@ from iwd import PSKAgent
from iwd import NetworkType
from hostapd import HostapdCLI
from hostapd import hostapd_map
from hwsim import Hwsim
import time
class Test(unittest.TestCase):
def test_connection_success(self):

View File

@ -12,29 +12,25 @@ import subprocess
class Test(unittest.TestCase):
def check_connection_success(self, ssid):
wd = IWD()
device = wd.list_devices(1)[0]
device = self.wd.list_devices(1)[0]
condition = 'not obj.scanning'
wd.wait_for_object_condition(device, condition)
self.wd.wait_for_object_condition(device, condition)
ordered_network = device.get_ordered_network(ssid)
condition = 'obj.connected'
wd.wait_for_object_condition(ordered_network.network_object, condition)
self.wd.wait_for_object_condition(ordered_network.network_object, condition)
device.disconnect()
condition = 'not obj.connected'
wd.wait_for_object_condition(ordered_network.network_object, condition)
self.wd.wait_for_object_condition(ordered_network.network_object, condition)
def test_connection_with_passphrase(self):
ssid = 'ssidPassphrase'
wd = IWD()
device = wd.list_devices(1)[0]
device = self.wd.list_devices(1)[0]
# Use --dontaks cmd-line option
with self.assertRaises(subprocess.CalledProcessError):
@ -49,9 +45,7 @@ class Test(unittest.TestCase):
def test_connection_with_username_and_password(self):
ssid = 'ssidUNameAndPWord'
wd = IWD()
device = wd.list_devices(1)[0]
device = self.wd.list_devices(1)[0]
subprocess.check_call(['iwctl', '-u', 'user', '-p', 'password',
'station', device.name, 'connect', ssid])
@ -61,9 +55,7 @@ class Test(unittest.TestCase):
def test_connection_with_password(self):
ssid = 'ssidPWord'
wd = IWD()
device = wd.list_devices(1)[0]
device = self.wd.list_devices(1)[0]
subprocess.check_call(['iwctl', '-p', 'password',
'station', device.name, 'connect', ssid])
@ -73,9 +65,7 @@ class Test(unittest.TestCase):
def test_connection_failure(self):
ssid = 'ssidPassphrase'
wd = IWD()
device = wd.list_devices(1)[0]
device = self.wd.list_devices(1)[0]
with self.assertRaises(subprocess.CalledProcessError):
subprocess.check_call(['iwctl', '-P', 'incorrect_passphrase',
@ -84,18 +74,14 @@ class Test(unittest.TestCase):
def test_invalid_command_line_option(self):
ssid = 'ssidPassphrase'
wd = IWD()
device = wd.list_devices(1)[0]
device = self.wd.list_devices(1)[0]
with self.assertRaises(subprocess.CalledProcessError):
subprocess.check_call(['iwctl', '-z',
'station', device.name, 'connect', ssid])
def test_invalid_command(self):
wd = IWD()
device = wd.list_devices(1)[0]
device = self.wd.list_devices(1)[0]
with self.assertRaises(subprocess.CalledProcessError):
subprocess.check_call(['iwctl', 'inexistent', 'command'])
@ -105,17 +91,17 @@ class Test(unittest.TestCase):
IWD.copy_to_storage('ssidUNameAndPWord.8021x')
IWD.copy_to_storage('ssidPWord.8021x')
wd = IWD()
cls.wd = IWD()
device = wd.list_devices(1)[0]
device = cls.wd.list_devices(1)[0]
condition = 'not obj.scanning'
wd.wait_for_object_condition(device, condition)
cls.wd.wait_for_object_condition(device, condition)
device.scan()
condition = 'not obj.scanning'
wd.wait_for_object_condition(device, condition)
cls.wd.wait_for_object_condition(device, condition)
@classmethod
def tearDownClass(cls):

View File

@ -10,7 +10,6 @@ from iwd import DeviceState
from iwd import NetworkType
from hostapd import HostapdCLI
from hostapd import hostapd_map
class Test(unittest.TestCase):
@ -20,8 +19,7 @@ class Test(unittest.TestCase):
devices = wd.list_devices(1)
device = devices[0]
hostapd_if = list(hostapd_map.values())[0]
hostapd = HostapdCLI(hostapd_if)
hostapd = HostapdCLI(config='ssidOpen.conf')
device.scan()

View File

@ -10,7 +10,6 @@ from iwd import NetworkType
from hlrauc import AuthCenter
from hostapd import HostapdCLI
from hostapd import hostapd_map
class Test(unittest.TestCase):

View File

@ -11,7 +11,6 @@ from iwd import NetworkType
import testutil
from hostapd import HostapdCLI
from hostapd import hostapd_map
class Test(unittest.TestCase):

View File

@ -11,7 +11,6 @@ from iwd import NetworkType
import testutil
from hostapd import HostapdCLI
from hostapd import hostapd_map
class Test(unittest.TestCase):

View File

@ -1,2 +0,0 @@
[General]
UseDefaultInterface=true

View File

@ -10,7 +10,6 @@ from iwd import PSKAgent
from iwd import NetworkType
from hostapd import HostapdCLI
from hostapd import hostapd_map
class Test(unittest.TestCase):

View File

@ -10,7 +10,6 @@ from iwd import NetworkType
from hlrauc import AuthCenter
from hostapd import HostapdCLI
from hostapd import hostapd_map
class Test(unittest.TestCase):

View File

@ -9,23 +9,18 @@ from iwd import IWD
from iwd import PSKAgent
from iwd import NetworkType
import testutil
import hostapd
from hostapd import HostapdCLI
class Test(unittest.TestCase):
def do_test_connection_success(self, ssid, passphrase=None):
hostapd = HostapdCLI(config=ssid + '.conf')
wd = IWD()
if passphrase:
psk_agent = PSKAgent(passphrase)
wd.register_psk_agent(psk_agent)
hostapd_ifname = None
for ifname in hostapd.hostapd_map:
if ssid + '.conf' in hostapd.hostapd_map[ifname].config:
hostapd_ifname = ifname
break
devices = wd.list_devices(1)
device = devices[0]
@ -52,7 +47,7 @@ class Test(unittest.TestCase):
wd.wait_for_object_condition(ordered_network.network_object, condition)
testutil.test_iface_operstate()
testutil.test_ifaces_connected(hostapd_ifname, device.name)
testutil.test_ifaces_connected(hostapd.ifname, device.name)
device.disconnect()

View File

@ -11,7 +11,6 @@ from iwd import PSKAgent
from iwd import NetworkType
from hostapd import HostapdCLI
from hostapd import hostapd_map
class Test(unittest.TestCase):

View File

@ -11,7 +11,6 @@ from iwd import PSKAgent
from iwd import NetworkType
from hostapd import HostapdCLI
from hostapd import hostapd_map
class Test(unittest.TestCase):

View File

@ -11,7 +11,6 @@ from iwd import PSKAgent
from iwd import NetworkType
from hostapd import HostapdCLI
from hostapd import hostapd_map
class Test(unittest.TestCase):

View File

@ -9,7 +9,6 @@ from iwd import IWD
from iwd import DeviceState
from hostapd import HostapdCLI
from hostapd import hostapd_map
class Test(unittest.TestCase):
@ -32,8 +31,7 @@ class Test(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.hostapd_if = list(hostapd_map.values())[0]
cls.hostapd = HostapdCLI(cls.hostapd_if)
cls.hostapd = HostapdCLI(config='ssid-wps-small-mtu.conf')
cls.hostapd.wps_push_button()

View File

@ -9,7 +9,6 @@ from iwd import IWD
from iwd import DeviceState
from hostapd import HostapdCLI
from hostapd import hostapd_map
class Test(unittest.TestCase):
@ -39,8 +38,7 @@ class Test(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.hostapd_if = list(hostapd_map.values())[0]
cls.hostapd = HostapdCLI(cls.hostapd_if)
cls.hostapd = HostapdCLI(config='ssidWPS.conf')
@classmethod
def tearDownClass(cls):

View File

@ -9,7 +9,6 @@ from iwd import IWD
from iwd import DeviceState
from hostapd import HostapdCLI
from hostapd import hostapd_map
class Test(unittest.TestCase):
@ -42,8 +41,7 @@ class Test(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.hostapd_if = list(hostapd_map.values())[0]
cls.hostapd = HostapdCLI(cls.hostapd_if)
cls.hostapd = HostapdCLI(config='ssidWPS.conf')
@classmethod
def tearDownClass(cls):

View File

@ -9,8 +9,6 @@ from iwd import IWD
from iwd import DeviceState
from hostapd import HostapdCLI
from hostapd import hostapd_map
class Test(unittest.TestCase):
def push_button_success(self, wd):
@ -38,8 +36,7 @@ class Test(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.hostapd_if = list(hostapd_map.values())[0]
cls.hostapd = HostapdCLI(cls.hostapd_if)
cls.hostapd = HostapdCLI(config='ssidWPS.conf')
@classmethod
def tearDownClass(cls):

View File

@ -9,7 +9,6 @@ import iwd
from iwd import IWD
from iwd import PSKAgent
from iwd import NetworkType
from hostapd import hostapd_map
from hostapd import HostapdCLI
import testutil

View File

@ -9,7 +9,6 @@ import iwd
from iwd import IWD
from iwd import PSKAgent
from iwd import NetworkType
from hostapd import hostapd_map
from hostapd import HostapdCLI
import testutil

View File

@ -8,7 +8,7 @@ import iwd
from iwd import IWD
from iwd import NetworkType
from hwsim import Hwsim
from hostapd import HostapdCLI, hostapd_map
from hostapd import HostapdCLI
import testutil
class Test(unittest.TestCase):

View File

@ -9,7 +9,7 @@ from iwd import IWD
from iwd import PSKAgent
from iwd import NetworkType
from hwsim import Hwsim
from hostapd import HostapdCLI, hostapd_map
from hostapd import HostapdCLI
import testutil
class Test(unittest.TestCase):

View File

@ -9,7 +9,7 @@ from iwd import IWD
from iwd import PSKAgent
from iwd import NetworkType
from hwsim import Hwsim
from hostapd import HostapdCLI, hostapd_map
from hostapd import HostapdCLI
import testutil
class Test(unittest.TestCase):

View File

@ -9,7 +9,7 @@ from iwd import IWD
from iwd import PSKAgent
from iwd import NetworkType
from hwsim import Hwsim
from hostapd import HostapdCLI, hostapd_map
from hostapd import HostapdCLI
import testutil
class Test(unittest.TestCase):

View File

@ -9,7 +9,7 @@ from iwd import IWD
from iwd import PSKAgent
from iwd import NetworkType
from hwsim import Hwsim
from hostapd import HostapdCLI, hostapd_map
from hostapd import HostapdCLI
import testutil
class Test(unittest.TestCase):
@ -24,12 +24,14 @@ class Test(unittest.TestCase):
rule1.source = self.bss_radio[1].addresses[0]
rule1.bidirectional = True
wd = IWD()
wd = self.wd
psk_agent = PSKAgent("EasilyGuessedPassword")
wd.register_psk_agent(psk_agent)
device = wd.list_devices(1)[0]
# prevent autoconnect
device.disconnect()
# Check that iwd selects BSS 0 first
rule0.signal = -2000
@ -107,12 +109,14 @@ class Test(unittest.TestCase):
rule1.source = self.bss_radio[1].addresses[0]
rule1.bidirectional = True
wd = IWD()
wd = self.wd
psk_agent = PSKAgent("EasilyGuessedPassword")
wd.register_psk_agent(psk_agent)
device = wd.list_devices(1)[0]
# prevent autoconnect
device.disconnect()
# Check that iwd selects BSS 0 first
rule0.signal = -2000
@ -176,6 +180,8 @@ class Test(unittest.TestCase):
testutil.test_ifaces_connected(self.bss_hostapd[1].ifname, device.name)
self.assertRaises(Exception, testutil.test_ifaces_connected,
(self.bss_hostapd[0].ifname, device.name))
def setUp(self):
self.wd = IWD()
def tearDown(self):
os.system('ifconfig "' + self.bss_hostapd[0].ifname + '" down')
@ -184,15 +190,14 @@ class Test(unittest.TestCase):
os.system('ifconfig "' + self.bss_hostapd[1].ifname + '" up')
hwsim = Hwsim()
wd = IWD()
device = wd.list_devices(1)[0]
device = self.wd.list_devices(1)[0]
try:
device.disconnect()
except:
pass
condition = 'obj.state == DeviceState.disconnected'
wd.wait_for_object_condition(device, condition)
self.wd.wait_for_object_condition(device, condition)
for rule in list(hwsim.rules.keys()):
del hwsim.rules[rule]

View File

@ -9,7 +9,7 @@ from iwd import IWD
from iwd import PSKAgent
from iwd import NetworkType
from hwsim import Hwsim
from hostapd import HostapdCLI, hostapd_map
from hostapd import HostapdCLI
import testutil
class Test(unittest.TestCase):

View File

@ -9,9 +9,9 @@ from iwd import IWD
from iwd import PSKAgent
from iwd import NetworkType
from hwsim import Hwsim
from hostapd import HostapdCLI, hostapd_map
import testutil
from time import sleep
from hostapd import HostapdCLI
class Test(unittest.TestCase):
def do_connect(self, wd, device, hostapd):

View File

@ -7,7 +7,6 @@ sys.path.append('../util')
import iwd
from iwd import IWD
from iwd import NetworkType
from hostapd import hostapd_map
from hostapd import HostapdCLI
import testutil

View File

@ -7,7 +7,6 @@ sys.path.append('../util')
import iwd
from iwd import IWD
from iwd import NetworkType
from hostapd import hostapd_map
from hostapd import HostapdCLI
import testutil

View File

@ -9,7 +9,7 @@ from iwd import IWD
from iwd import PSKAgent
from iwd import NetworkType
from hwsim import Hwsim
from hostapd import HostapdCLI, hostapd_map
from hostapd import HostapdCLI
import testutil
class Test(unittest.TestCase):

View File

@ -8,17 +8,13 @@ import iwd
from iwd import IWD
from iwd import PSKAgent
from iwd import NetworkType
from hostapd import hostapd_map
from hostapd import HostapdCLI
import testutil
class Test(unittest.TestCase):
def validate_connection(self, wd):
hostapd_if = None
for hostapd in hostapd_map.values():
if hostapd.config == 'ssidSAE.conf':
hostapd_if = hostapd.name
hostapd = HostapdCLI(config='ssidSAE.conf')
psk_agent = PSKAgent("secret123")
wd.register_psk_agent(psk_agent)
@ -56,7 +52,7 @@ class Test(unittest.TestCase):
wd.wait(2)
testutil.test_iface_operstate(intf=device.name)
testutil.test_ifaces_connected(if0=device.name, if1=hostapd_if)
testutil.test_ifaces_connected(if0=device.name, if1=hostapd.ifname)
device.disconnect()

View File

@ -8,17 +8,13 @@ import iwd
from iwd import IWD
from iwd import PSKAgent
from iwd import NetworkType
from hostapd import hostapd_map
from hostapd import HostapdCLI
import testutil
class Test(unittest.TestCase):
def validate_connection(self, wd):
hostapd_if = None
for hostapd in hostapd_map.values():
if hostapd.config == 'ssidSAE-20.conf':
hostapd_if = hostapd.name
hostapd = HostapdCLI(config='ssidSAE-20.conf')
psk_agent = PSKAgent("secret123")
wd.register_psk_agent(psk_agent)
@ -56,7 +52,7 @@ class Test(unittest.TestCase):
wd.wait(2)
testutil.test_iface_operstate(intf=device.name)
testutil.test_ifaces_connected(if0=device.name, if1=hostapd_if)
testutil.test_ifaces_connected(if0=device.name, if1=hostapd.ifname)
device.disconnect()

View File

@ -9,7 +9,7 @@ from iwd import IWD
from iwd import PSKAgent
from iwd import NetworkType
from hwsim import Hwsim
from hostapd import HostapdCLI, hostapd_map
from hostapd import HostapdCLI
from time import sleep

View File

@ -8,7 +8,7 @@ import iwd
from iwd import IWD
from iwd import PSKAgent
from iwd import NetworkType
from hostapd import HostapdCLI, hostapd_map
from hostapd import HostapdCLI
class Test(unittest.TestCase):