mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2025-02-01 22:34:07 +01:00
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 collections
|
||||
import datetime
|
||||
import weakref
|
||||
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from enum import Enum
|
||||
@ -834,6 +835,7 @@ class IWD(AsyncOpAbstract):
|
||||
_agent_manager_if = None
|
||||
_iwd_proc = None
|
||||
_devices = None
|
||||
_instance = None
|
||||
|
||||
def __init__(self, start_iwd_daemon = False,
|
||||
iwd_config_dir = IWD_CONFIG_DIR):
|
||||
@ -875,6 +877,10 @@ class IWD(AsyncOpAbstract):
|
||||
|
||||
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):
|
||||
if self._iwd_proc is None:
|
||||
return
|
||||
@ -1004,3 +1010,7 @@ class IWD(AsyncOpAbstract):
|
||||
reply_handler=self._success,
|
||||
error_handler=self._failure)
|
||||
self._wait_for_async_op()
|
||||
|
||||
@staticmethod
|
||||
def get_instance():
|
||||
return IWD._instance()
|
||||
|
@ -6,6 +6,7 @@ import struct
|
||||
import select
|
||||
|
||||
import wiphy
|
||||
import iwd
|
||||
|
||||
HWSIM_ETHERTYPE = 0x0800
|
||||
HWSIM_PACKETLEN = 250
|
||||
@ -51,8 +52,11 @@ def tx(fromsock, tosock, src, dst):
|
||||
return (frame, fromsock, tosock, src, dst)
|
||||
|
||||
def test_connected(if0=None, if1=None):
|
||||
for wname in wiphy.wiphy_map:
|
||||
for intf in wiphy.wiphy_map[wname]:
|
||||
if if0 is None or if1 is None:
|
||||
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:
|
||||
if0 = intf
|
||||
elif if1 is None and intf != if0:
|
||||
@ -120,11 +124,8 @@ IFF_UP = 1 << 0
|
||||
IFF_RUNNING = 1 << 6
|
||||
|
||||
def test_iface_operstate(intf=None):
|
||||
for wname in wiphy.wiphy_map:
|
||||
w = wiphy.wiphy_map[wname]
|
||||
for ifname in w:
|
||||
if intf is None and w[ifname].use == 'iwd':
|
||||
intf = ifname
|
||||
if not intf:
|
||||
intf = iwd.IWD.get_instance().list_devices()[0].name
|
||||
|
||||
sock = socket.socket(socket.PF_PACKET, socket.SOCK_RAW)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user