mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-22 06:29:23 +01:00
autotests: Test operstate is IF_OPER_UP when state == connected
Test that iwd correctly sets the interface's operstate before and after a roam, in the same autotests which run the connectivity check.
This commit is contained in:
parent
71c15306fd
commit
132d3ac11c
@ -40,6 +40,7 @@ class Test(unittest.TestCase):
|
||||
condition = 'obj.connected'
|
||||
wd.wait_for_object_condition(ordered_network.network_object, condition)
|
||||
|
||||
testutil.test_iface_operstate()
|
||||
testutil.test_ifaces_connected()
|
||||
|
||||
device.disconnect()
|
||||
|
@ -110,6 +110,7 @@ class Test(unittest.TestCase):
|
||||
|
||||
wd.unregister_psk_agent(psk_agent)
|
||||
|
||||
testutil.test_iface_operstate(device.name)
|
||||
testutil.test_ifaces_connected(bss_hostapd[0].ifname, device.name)
|
||||
self.assertRaises(Exception, testutil.test_ifaces_connected,
|
||||
(bss_hostapd[1].ifname, device.name))
|
||||
@ -128,6 +129,7 @@ class Test(unittest.TestCase):
|
||||
self.assertEqual(device.state, iwd.DeviceState.connected)
|
||||
self.assertTrue(bss_hostapd[1].list_sta())
|
||||
|
||||
testutil.test_iface_operstate(device.name)
|
||||
testutil.test_ifaces_connected(bss_hostapd[1].ifname, device.name)
|
||||
self.assertRaises(Exception, testutil.test_ifaces_connected,
|
||||
(bss_hostapd[0].ifname, device.name))
|
||||
|
@ -40,6 +40,7 @@ class Test(unittest.TestCase):
|
||||
condition = 'obj.connected'
|
||||
wd.wait_for_object_condition(ordered_network.network_object, condition)
|
||||
|
||||
testutil.test_iface_operstate()
|
||||
testutil.test_ifaces_connected()
|
||||
|
||||
device.disconnect()
|
||||
|
@ -101,6 +101,7 @@ class Test(unittest.TestCase):
|
||||
self.assertTrue(bss_hostapd[0].list_sta())
|
||||
self.assertFalse(bss_hostapd[1].list_sta())
|
||||
|
||||
testutil.test_iface_operstate(device.name)
|
||||
testutil.test_ifaces_connected(bss_hostapd[0].ifname, device.name)
|
||||
self.assertRaises(Exception, testutil.test_ifaces_connected,
|
||||
(bss_hostapd[1].ifname, device.name))
|
||||
@ -121,6 +122,7 @@ class Test(unittest.TestCase):
|
||||
self.assertEqual(device.state, iwd.DeviceState.connected)
|
||||
self.assertTrue(bss_hostapd[1].list_sta())
|
||||
|
||||
testutil.test_iface_operstate(device.name)
|
||||
testutil.test_ifaces_connected(bss_hostapd[1].ifname, device.name)
|
||||
self.assertRaises(Exception, testutil.test_ifaces_connected,
|
||||
(bss_hostapd[0].ifname, device.name))
|
||||
|
@ -44,6 +44,7 @@ class Test(unittest.TestCase):
|
||||
condition = 'obj.connected'
|
||||
wd.wait_for_object_condition(ordered_network.network_object, condition)
|
||||
|
||||
testutil.test_iface_operstate()
|
||||
testutil.test_ifaces_connected()
|
||||
|
||||
device.disconnect()
|
||||
|
@ -100,3 +100,26 @@ def test_ifaces_connected(if0=None, if1=None):
|
||||
finally:
|
||||
sock0.close()
|
||||
sock1.close()
|
||||
|
||||
SIOCGIFFLAGS = 0x8913
|
||||
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
|
||||
|
||||
sock = socket.socket(socket.PF_PACKET, socket.SOCK_RAW)
|
||||
|
||||
try:
|
||||
ifreq = struct.pack('16sh', intf.encode('utf8'), 0)
|
||||
flags = struct.unpack('16sh', fcntl.ioctl(sock, SIOCGIFFLAGS, ifreq))[1]
|
||||
|
||||
# IFF_LOWER_UP and IFF_DORMANT not returned by SIOCGIFFLAGS
|
||||
if flags & (IFF_UP | IFF_RUNNING) != IFF_UP | IFF_RUNNING:
|
||||
raise Exception(intf + ' operstate wrong')
|
||||
finally:
|
||||
sock.close()
|
||||
|
Loading…
Reference in New Issue
Block a user