diff --git a/autotests/testEAP-TLS/connection_test.py b/autotests/testEAP-TLS/connection_test.py index 631d032e..172e3f55 100644 --- a/autotests/testEAP-TLS/connection_test.py +++ b/autotests/testEAP-TLS/connection_test.py @@ -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() diff --git a/autotests/testFT-PSK-roam/test.py b/autotests/testFT-PSK-roam/test.py index 482de5a8..e28db6d9 100644 --- a/autotests/testFT-PSK-roam/test.py +++ b/autotests/testFT-PSK-roam/test.py @@ -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)) diff --git a/autotests/testOpen/connection_test.py b/autotests/testOpen/connection_test.py index a3b8cae3..1e40a346 100644 --- a/autotests/testOpen/connection_test.py +++ b/autotests/testOpen/connection_test.py @@ -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() diff --git a/autotests/testPreauth-roam/test.py b/autotests/testPreauth-roam/test.py index b112a829..2a47b55d 100644 --- a/autotests/testPreauth-roam/test.py +++ b/autotests/testPreauth-roam/test.py @@ -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)) diff --git a/autotests/testWPA2/connection_test.py b/autotests/testWPA2/connection_test.py index 076b84a3..331a0009 100644 --- a/autotests/testWPA2/connection_test.py +++ b/autotests/testWPA2/connection_test.py @@ -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() diff --git a/autotests/util/testutil.py b/autotests/util/testutil.py index 7a46d5dd..4c2c4ac5 100644 --- a/autotests/util/testutil.py +++ b/autotests/util/testutil.py @@ -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()