3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-29 13:59:24 +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:
Andrew Zaborowski 2017-05-30 14:26:20 +02:00 committed by Denis Kenzior
parent 71c15306fd
commit 132d3ac11c
6 changed files with 30 additions and 0 deletions

View File

@ -40,6 +40,7 @@ class Test(unittest.TestCase):
condition = 'obj.connected' condition = 'obj.connected'
wd.wait_for_object_condition(ordered_network.network_object, condition) wd.wait_for_object_condition(ordered_network.network_object, condition)
testutil.test_iface_operstate()
testutil.test_ifaces_connected() testutil.test_ifaces_connected()
device.disconnect() device.disconnect()

View File

@ -110,6 +110,7 @@ class Test(unittest.TestCase):
wd.unregister_psk_agent(psk_agent) wd.unregister_psk_agent(psk_agent)
testutil.test_iface_operstate(device.name)
testutil.test_ifaces_connected(bss_hostapd[0].ifname, device.name) testutil.test_ifaces_connected(bss_hostapd[0].ifname, device.name)
self.assertRaises(Exception, testutil.test_ifaces_connected, self.assertRaises(Exception, testutil.test_ifaces_connected,
(bss_hostapd[1].ifname, device.name)) (bss_hostapd[1].ifname, device.name))
@ -128,6 +129,7 @@ class Test(unittest.TestCase):
self.assertEqual(device.state, iwd.DeviceState.connected) self.assertEqual(device.state, iwd.DeviceState.connected)
self.assertTrue(bss_hostapd[1].list_sta()) self.assertTrue(bss_hostapd[1].list_sta())
testutil.test_iface_operstate(device.name)
testutil.test_ifaces_connected(bss_hostapd[1].ifname, device.name) testutil.test_ifaces_connected(bss_hostapd[1].ifname, device.name)
self.assertRaises(Exception, testutil.test_ifaces_connected, self.assertRaises(Exception, testutil.test_ifaces_connected,
(bss_hostapd[0].ifname, device.name)) (bss_hostapd[0].ifname, device.name))

View File

@ -40,6 +40,7 @@ class Test(unittest.TestCase):
condition = 'obj.connected' condition = 'obj.connected'
wd.wait_for_object_condition(ordered_network.network_object, condition) wd.wait_for_object_condition(ordered_network.network_object, condition)
testutil.test_iface_operstate()
testutil.test_ifaces_connected() testutil.test_ifaces_connected()
device.disconnect() device.disconnect()

View File

@ -101,6 +101,7 @@ class Test(unittest.TestCase):
self.assertTrue(bss_hostapd[0].list_sta()) self.assertTrue(bss_hostapd[0].list_sta())
self.assertFalse(bss_hostapd[1].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) testutil.test_ifaces_connected(bss_hostapd[0].ifname, device.name)
self.assertRaises(Exception, testutil.test_ifaces_connected, self.assertRaises(Exception, testutil.test_ifaces_connected,
(bss_hostapd[1].ifname, device.name)) (bss_hostapd[1].ifname, device.name))
@ -121,6 +122,7 @@ class Test(unittest.TestCase):
self.assertEqual(device.state, iwd.DeviceState.connected) self.assertEqual(device.state, iwd.DeviceState.connected)
self.assertTrue(bss_hostapd[1].list_sta()) self.assertTrue(bss_hostapd[1].list_sta())
testutil.test_iface_operstate(device.name)
testutil.test_ifaces_connected(bss_hostapd[1].ifname, device.name) testutil.test_ifaces_connected(bss_hostapd[1].ifname, device.name)
self.assertRaises(Exception, testutil.test_ifaces_connected, self.assertRaises(Exception, testutil.test_ifaces_connected,
(bss_hostapd[0].ifname, device.name)) (bss_hostapd[0].ifname, device.name))

View File

@ -44,6 +44,7 @@ class Test(unittest.TestCase):
condition = 'obj.connected' condition = 'obj.connected'
wd.wait_for_object_condition(ordered_network.network_object, condition) wd.wait_for_object_condition(ordered_network.network_object, condition)
testutil.test_iface_operstate()
testutil.test_ifaces_connected() testutil.test_ifaces_connected()
device.disconnect() device.disconnect()

View File

@ -100,3 +100,26 @@ def test_ifaces_connected(if0=None, if1=None):
finally: finally:
sock0.close() sock0.close()
sock1.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()