mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-22 21:22:37 +01:00
auto-t: testutil: add test_ip_address_match
Checks that the the IP address for a given interface matches
This commit is contained in:
parent
18d1c752f4
commit
201763ff7f
@ -125,6 +125,7 @@ def test_ifaces_connected(if0=None, if1=None, group=True):
|
|||||||
raise e
|
raise e
|
||||||
|
|
||||||
SIOCGIFFLAGS = 0x8913
|
SIOCGIFFLAGS = 0x8913
|
||||||
|
SIOCGIFADDR = 0x8915
|
||||||
IFF_UP = 1 << 0
|
IFF_UP = 1 << 0
|
||||||
IFF_RUNNING = 1 << 6
|
IFF_RUNNING = 1 << 6
|
||||||
|
|
||||||
@ -143,3 +144,11 @@ def test_iface_operstate(intf=None):
|
|||||||
raise Exception(intf + ' operstate wrong')
|
raise Exception(intf + ' operstate wrong')
|
||||||
finally:
|
finally:
|
||||||
sock.close()
|
sock.close()
|
||||||
|
|
||||||
|
def test_ip_address_match(intf, ip):
|
||||||
|
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||||
|
addr = fcntl.ioctl(s.fileno(), SIOCGIFADDR, struct.pack('256s', intf.encode('utf-8')))
|
||||||
|
addr = socket.inet_ntoa(addr[20:24])
|
||||||
|
|
||||||
|
if ip != addr:
|
||||||
|
raise Exception('IP for %s did not match %s (was %s)' % (intf, ip, addr))
|
||||||
|
Loading…
Reference in New Issue
Block a user