From 416ad05ce7e98895e024c8d0a8778644bc87d258 Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Wed, 30 Mar 2022 13:23:14 -0700 Subject: [PATCH] auto-t: fix up a few issues in testNetconfig - Setting the IP address was resulting in an error: Error: any valid prefix is expected rather than "wln58". This is fixed by reordering the arguments with the IP address first - Remove the sleep, and use non_block_wait to wait for the IPv6 address to be set. --- autotests/testNetconfig/connection_test.py | 22 +++++++++++++++------- autotests/testNetconfig/static_test.py | 3 ++- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/autotests/testNetconfig/connection_test.py b/autotests/testNetconfig/connection_test.py index 91c6eb6b..672efb72 100644 --- a/autotests/testNetconfig/connection_test.py +++ b/autotests/testNetconfig/connection_test.py @@ -17,6 +17,15 @@ import subprocess class Test(unittest.TestCase): def test_connection_success(self): + def check_addr(device): + try: + subprocess.check_output('ip addr show ' + device.name + \ + ' | grep \'inet6 3ffe:501:ffff:100::\'', shell=True) + except: + return False + + return True + wd = IWD(True) psk_agent = PSKAgent("secret123") @@ -40,9 +49,8 @@ class Test(unittest.TestCase): testutil.test_iface_operstate() testutil.test_ifaces_connected() - time.sleep(2) - subprocess.check_output('ip addr show ' + device.name + \ - ' | grep \'inet6 3ffe:501:ffff:100::\'', shell=True) + ctx.non_block_wait(check_addr, 10, device, + exception=Exception("IPv6 address was not set")) device.disconnect() @@ -70,15 +78,15 @@ class Test(unittest.TestCase): # TODO: This could be moved into test-runner itself if other tests ever # require this functionality (p2p, FILS, etc.). Since its simple # enough it can stay here for now. - ctx.start_process(['ip', 'addr','add','dev', hapd.ifname, - '192.168.1.1/255.255.255.0']).wait() + ctx.start_process(['ip', 'addr','add', '192.168.1.1/255.255.255.0', + 'dev', hapd.ifname,]).wait() ctx.start_process(['touch', '/tmp/dhcpd.leases']).wait() cls.dhcpd_pid = ctx.start_process(['dhcpd', '-f', '-cf', '/tmp/dhcpd.conf', '-lf', '/tmp/dhcpd.leases', hapd.ifname], cleanup=remove_lease4) - ctx.start_process(['ip', 'addr', 'add', 'dev', hapd.ifname, - '3ffe:501:ffff:100::1/64']).wait() + ctx.start_process(['ip', 'addr', 'add', '3ffe:501:ffff:100::1/64', + 'dev', hapd.ifname]).wait() ctx.start_process(['touch', '/tmp/dhcpd6.leases']).wait() cls.dhcpd6_pid = ctx.start_process(['dhcpd', '-6', '-f', '-cf', '/tmp/dhcpd-v6.conf', '-lf', '/tmp/dhcpd6.leases', diff --git a/autotests/testNetconfig/static_test.py b/autotests/testNetconfig/static_test.py index 8e29d4eb..bba2c644 100644 --- a/autotests/testNetconfig/static_test.py +++ b/autotests/testNetconfig/static_test.py @@ -81,7 +81,8 @@ class Test(unittest.TestCase): # TODO: This could be moved into test-runner itself if other tests ever # require this functionality (p2p, FILS, etc.). Since its simple # enough it can stay here for now. - ctx.start_process(['ip', 'addr','add', hapd.ifname, '192.168.1.1/255.255.255.0']).wait() + ctx.start_process(['ip', 'addr','add', '192.168.1.1/255.255.255.0', + 'dev', hapd.ifname]).wait() ctx.start_process(['touch', '/tmp/dhcpd.leases']).wait() cls.dhcpd_pid = ctx.start_process(['dhcpd', '-f', '-cf', '/tmp/dhcpd.conf', '-lf', '/tmp/dhcpd.leases',