autotests: In testutil obtain interface list dynamically
For the interface connectivity tests obtain the lists of interfaces in use directly from the IWD class, which has the current list from DBus properties.
This commit is contained in:
parent
14d69873b0
commit
576d8ad123
|
@ -10,6 +10,7 @@ import threading
|
||||||
import time
|
import time
|
||||||
import collections
|
import collections
|
||||||
import datetime
|
import datetime
|
||||||
|
import weakref
|
||||||
|
|
||||||
from abc import ABCMeta, abstractmethod
|
from abc import ABCMeta, abstractmethod
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
@ -834,6 +835,7 @@ class IWD(AsyncOpAbstract):
|
||||||
_agent_manager_if = None
|
_agent_manager_if = None
|
||||||
_iwd_proc = None
|
_iwd_proc = None
|
||||||
_devices = None
|
_devices = None
|
||||||
|
_instance = None
|
||||||
|
|
||||||
def __init__(self, start_iwd_daemon = False,
|
def __init__(self, start_iwd_daemon = False,
|
||||||
iwd_config_dir = IWD_CONFIG_DIR):
|
iwd_config_dir = IWD_CONFIG_DIR):
|
||||||
|
@ -875,6 +877,10 @@ class IWD(AsyncOpAbstract):
|
||||||
|
|
||||||
self._devices = DeviceList(self)
|
self._devices = DeviceList(self)
|
||||||
|
|
||||||
|
# Weak to make sure the test's reference to @self is the only counted
|
||||||
|
# reference so that __del__ gets called when it's released
|
||||||
|
IWD._instance = weakref.ref(self)
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
if self._iwd_proc is None:
|
if self._iwd_proc is None:
|
||||||
return
|
return
|
||||||
|
@ -1004,3 +1010,7 @@ class IWD(AsyncOpAbstract):
|
||||||
reply_handler=self._success,
|
reply_handler=self._success,
|
||||||
error_handler=self._failure)
|
error_handler=self._failure)
|
||||||
self._wait_for_async_op()
|
self._wait_for_async_op()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_instance():
|
||||||
|
return IWD._instance()
|
||||||
|
|
|
@ -6,6 +6,7 @@ import struct
|
||||||
import select
|
import select
|
||||||
|
|
||||||
import wiphy
|
import wiphy
|
||||||
|
import iwd
|
||||||
|
|
||||||
HWSIM_ETHERTYPE = 0x0800
|
HWSIM_ETHERTYPE = 0x0800
|
||||||
HWSIM_PACKETLEN = 250
|
HWSIM_PACKETLEN = 250
|
||||||
|
@ -51,8 +52,11 @@ def tx(fromsock, tosock, src, dst):
|
||||||
return (frame, fromsock, tosock, src, dst)
|
return (frame, fromsock, tosock, src, dst)
|
||||||
|
|
||||||
def test_connected(if0=None, if1=None):
|
def test_connected(if0=None, if1=None):
|
||||||
for wname in wiphy.wiphy_map:
|
if if0 is None or if1 is None:
|
||||||
for intf in wiphy.wiphy_map[wname]:
|
iwd_list = [dev.name for dev in iwd.IWD.get_instance().list_devices()]
|
||||||
|
non_iwd_list = [ifname for w in wiphy.wiphy_map.values()
|
||||||
|
for ifname in w.interface_map]
|
||||||
|
for intf in iwd_list + non_iwd_list:
|
||||||
if if0 is None:
|
if if0 is None:
|
||||||
if0 = intf
|
if0 = intf
|
||||||
elif if1 is None and intf != if0:
|
elif if1 is None and intf != if0:
|
||||||
|
@ -120,11 +124,8 @@ IFF_UP = 1 << 0
|
||||||
IFF_RUNNING = 1 << 6
|
IFF_RUNNING = 1 << 6
|
||||||
|
|
||||||
def test_iface_operstate(intf=None):
|
def test_iface_operstate(intf=None):
|
||||||
for wname in wiphy.wiphy_map:
|
if not intf:
|
||||||
w = wiphy.wiphy_map[wname]
|
intf = iwd.IWD.get_instance().list_devices()[0].name
|
||||||
for ifname in w:
|
|
||||||
if intf is None and w[ifname].use == 'iwd':
|
|
||||||
intf = ifname
|
|
||||||
|
|
||||||
sock = socket.socket(socket.PF_PACKET, socket.SOCK_RAW)
|
sock = socket.socket(socket.PF_PACKET, socket.SOCK_RAW)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue