3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-22 13:02:44 +01:00

auto-t: replace ifconfig with ip commands

ifconfig has long been deprecated in favor of ip from iproute2.
It is usually no longer installed by default.
This commit is contained in:
Torsten Schmitz 2021-11-11 03:12:02 +01:00 committed by Denis Kenzior
parent fa1c12453b
commit 22c77cc037
12 changed files with 55 additions and 51 deletions

View File

@ -62,7 +62,7 @@ class Test(unittest.TestCase):
@classmethod
def setUpClass(cls):
IWD.copy_to_storage('ssidFILS-256.8021x')
os.system('ifconfig lo up')
os.system('ip link set lo up')
pass
@classmethod

View File

@ -62,7 +62,7 @@ class Test(unittest.TestCase):
@classmethod
def setUpClass(cls):
IWD.copy_to_storage('ssidFILS-384.8021x')
os.system('ifconfig lo up')
os.system('ip link set lo up')
pass
@classmethod

View File

@ -54,10 +54,10 @@ class Test(unittest.TestCase):
(self.bss_hostapd[0].ifname, device.name, True, True))
def tearDown(self):
os.system('ifconfig "' + self.bss_hostapd[0].ifname + '" down')
os.system('ifconfig "' + self.bss_hostapd[1].ifname + '" down')
os.system('ifconfig "' + self.bss_hostapd[0].ifname + '" up')
os.system('ifconfig "' + self.bss_hostapd[1].ifname + '" up')
os.system('ip link set "' + self.bss_hostapd[0].ifname + '" down')
os.system('ip link set "' + self.bss_hostapd[1].ifname + '" down')
os.system('ip link set "' + self.bss_hostapd[0].ifname + '" up')
os.system('ip link set "' + self.bss_hostapd[1].ifname + '" up')
@classmethod
def setUpClass(cls):
@ -67,10 +67,12 @@ class Test(unittest.TestCase):
HostapdCLI(config='ft-eap-ccmp-2.conf') ]
# Set interface addresses to those expected by hostapd config files
os.system('ifconfig "' + cls.bss_hostapd[0].ifname +
'" down hw ether 12:00:00:00:00:01 up')
os.system('ifconfig "' + cls.bss_hostapd[1].ifname +
'" down hw ether 12:00:00:00:00:02 up')
os.system('ip link set dev "' + cls.bss_hostapd[0].ifname + '" down')
os.system('ip link set dev "' + cls.bss_hostapd[0].ifname + \
'" address 12:00:00:00:00:01 up')
os.system('ip link set dev "' + cls.bss_hostapd[1].ifname + '" down')
os.system('ip link set dev "' + cls.bss_hostapd[1].ifname + \
'" address 12:00:00:00:00:02 up')
cls.bss_hostapd[0].reload()
cls.bss_hostapd[0].wait_for_event("AP-ENABLED")

View File

@ -124,24 +124,24 @@ class Test(unittest.TestCase):
self.validate_connection(wd)
def tearDown(self):
os.system('ifconfig "' + self.bss_hostapd[0].ifname + '" down')
os.system('ifconfig "' + self.bss_hostapd[1].ifname + '" down')
os.system('ifconfig "' + self.bss_hostapd[0].ifname + '" up')
os.system('ifconfig "' + self.bss_hostapd[1].ifname + '" up')
os.system('ip link set "' + self.bss_hostapd[0].ifname + '" down')
os.system('ip link set "' + self.bss_hostapd[1].ifname + '" down')
os.system('ip link set "' + self.bss_hostapd[0].ifname + '" up')
os.system('ip link set "' + self.bss_hostapd[1].ifname + '" up')
@classmethod
def setUpClass(cls):
os.system('ifconfig lo up')
os.system('ip link set lo up')
IWD.copy_to_storage('TestFT.8021x')
cls.bss_hostapd = [ HostapdCLI(config='ft-eap-ccmp-1.conf'),
HostapdCLI(config='ft-eap-ccmp-2.conf') ]
# Set interface addresses to those expected by hostapd config files
os.system('ifconfig "' + cls.bss_hostapd[0].ifname +
'" down hw ether 12:00:00:00:00:01 up')
os.system('ifconfig "' + cls.bss_hostapd[1].ifname +
'" down hw ether 12:00:00:00:00:02 up')
os.system('ip link set dev "' + cls.bss_hostapd[0].ifname + '" down')
os.system('ip link set dev "' + cls.bss_hostapd[0].ifname + '" addr 12:00:00:00:00:01 up')
os.system('ip link set dev "' + cls.bss_hostapd[1].ifname + '" down')
os.system('ip link set dev "' + cls.bss_hostapd[1].ifname + '" addr 12:00:00:00:00:02 up')
cls.bss_hostapd[0].reload()
cls.bss_hostapd[0].wait_for_event("AP-ENABLED")

View File

@ -69,15 +69,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(['ifconfig', hapd.ifname, '192.168.1.1',
'netmask', '255.255.255.0']).wait()
ctx.start_process(['ip', 'addr','add','dev', hapd.ifname,
'192.168.1.1/255.255.255.0']).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(['ifconfig', hapd.ifname, 'inet6',
'add', '3ffe:501:ffff:100::1/64']).wait()
ctx.start_process(['ip', 'addr', 'add', 'dev', hapd.ifname,
'3ffe:501:ffff:100::1/64']).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',

View File

@ -86,8 +86,7 @@ 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(['ifconfig', hapd.ifname, '192.168.1.1',
'netmask', '255.255.255.0']).wait()
ctx.start_process(['ip', 'addr','add', hapd.ifname, '192.168.1.1/255.255.255.0']).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',

View File

@ -93,7 +93,7 @@ class Test(unittest.TestCase):
self.assertEqual(wpas.p2p_group['role'], 'GO' if not go else 'client')
if not go:
ctx.start_process(['ifconfig', peer_ifname, '192.168.1.20', 'netmask', '255.255.255.0']).wait()
ctx.start_process(['ip', 'addr', 'add','dev', peer_ifname, '192.168.1.20/255.255.255.0']).wait()
os.system('> /tmp/dhcp.leases')
dhcp = ctx.start_process(['dhcpd', '-f', '-cf', '/tmp/dhcpd.conf', '-lf', '/tmp/dhcp.leases', peer_ifname])
self.dhcp = dhcp

View File

@ -150,10 +150,10 @@ class Test(unittest.TestCase):
self.validate_connection(wd)
def tearDown(self):
os.system('ifconfig "' + self.bss_hostapd[0].ifname + '" down')
os.system('ifconfig "' + self.bss_hostapd[1].ifname + '" down')
os.system('ifconfig "' + self.bss_hostapd[0].ifname + '" up')
os.system('ifconfig "' + self.bss_hostapd[1].ifname + '" up')
os.system('ip link set "' + self.bss_hostapd[0].ifname + '" down')
os.system('ip link set "' + self.bss_hostapd[1].ifname + '" down')
os.system('ip link set "' + self.bss_hostapd[0].ifname + '" up')
os.system('ip link set "' + self.bss_hostapd[1].ifname + '" up')
self.rule0.enabled = False
@ -175,10 +175,10 @@ class Test(unittest.TestCase):
cls.rule0.drop = True
# Set interface addresses to those expected by hostapd config files
os.system('ifconfig "' + cls.bss_hostapd[0].ifname +
'" down hw ether 12:00:00:00:00:01 up')
os.system('ifconfig "' + cls.bss_hostapd[1].ifname +
'" down hw ether 12:00:00:00:00:02 up')
os.system('ip link set dev "' + cls.bss_hostapd[0].ifname + '" down')
os.system('ip link set dev "' + cls.bss_hostapd[0].ifname + '" addr 12:00:00:00:00:01 up')
os.system('ip link set dev "' + cls.bss_hostapd[1].ifname + '" down')
os.system('ip link set dev "' + cls.bss_hostapd[1].ifname + '" addr 12:00:00:00:00:02 up')
cls.bss_hostapd[0].reload()
cls.bss_hostapd[0].wait_for_event("AP-ENABLED")

View File

@ -86,7 +86,7 @@ class Test(unittest.TestCase):
def setUpClass(cls):
IWD.copy_to_storage('TestPreauth.8021x')
os.system('ifconfig lo up')
os.system('ip link set lo up')
@classmethod
def tearDownClass(cls):

View File

@ -111,12 +111,12 @@ class Test(unittest.TestCase):
self.validate_connection(wd, False)
def tearDown(self):
os.system('ifconfig "' + self.bss_hostapd[0].ifname + '" down')
os.system('ifconfig "' + self.bss_hostapd[1].ifname + '" down')
os.system('ifconfig "' + self.bss_hostapd[2].ifname + '" down')
os.system('ifconfig "' + self.bss_hostapd[0].ifname + '" up')
os.system('ifconfig "' + self.bss_hostapd[1].ifname + '" up')
os.system('ifconfig "' + self.bss_hostapd[2].ifname + '" up')
os.system('ip link set "' + self.bss_hostapd[0].ifname + '" down')
os.system('ip link set "' + self.bss_hostapd[1].ifname + '" down')
os.system('ip link set "' + self.bss_hostapd[2].ifname + '" down')
os.system('ip link set "' + self.bss_hostapd[0].ifname + '" up')
os.system('ip link set "' + self.bss_hostapd[1].ifname + '" up')
os.system('ip link set "' + self.bss_hostapd[2].ifname + '" up')
@classmethod
def setUpClass(cls):
@ -124,12 +124,15 @@ class Test(unittest.TestCase):
HostapdCLI(config='ft-sae-2.conf'),
HostapdCLI(config='ft-psk-3.conf') ]
ctx.start_process(['ifconfig', cls.bss_hostapd[0].ifname, 'down', 'hw', \
'ether', '12:00:00:00:00:01', 'up']).wait()
ctx.start_process(['ifconfig', cls.bss_hostapd[1].ifname, 'down', 'hw', \
'ether', '12:00:00:00:00:02', 'up']).wait()
ctx.start_process(['ifconfig', cls.bss_hostapd[2].ifname, 'down', 'hw', \
'ether', '12:00:00:00:00:03', 'up']).wait()
ctx.start_process(['ip', 'link', 'set', 'dev', cls.bss_hostapd[0].ifname, 'down'])
ctx.start_process(['ip', 'link', 'set', 'dev', cls.bss_hostapd[0].ifname, \
'addr', '12:00:00:00:00:01', 'up']).wait()
ctx.start_process(['ip', 'link', 'set', 'dev', cls.bss_hostapd[1].ifname, 'down'])
ctx.start_process(['ip', 'link', 'set', 'dev', cls.bss_hostapd[1].ifname, \
'addr', '12:00:00:00:00:02', 'up']).wait()
ctx.start_process(['ip', 'link', 'set', 'dev', cls.bss_hostapd[2].ifname, 'down'])
ctx.start_process(['ip', 'link', 'set', 'dev', cls.bss_hostapd[2].ifname, \
'addr', '12:00:00:00:00:03', 'up']).wait()
# Set interface addresses to those expected by hostapd config files
cls.bss_hostapd[0].reload()

View File

@ -19,7 +19,7 @@ OS:
1. qemu 2.4.1
2. Linux kernel 4.20+
3. dbus-daemon 1.11.18
4. ifconfig 2.10-alpha
4. iproute2
5. iw 3.17
6. python 3.9
7. haveged no ver. avail.

View File

@ -361,7 +361,7 @@ class Interface:
Process(['iw', 'dev', self.name, 'del']).wait()
def set_interface_state(self, state):
Process(['ifconfig', self.name, state]).wait()
Process(['ip', 'link', 'set', self.name, state]).wait()
class Radio:
def __init__(self, name):
@ -971,7 +971,7 @@ class TestContext(Namespace):
print("Ofono or Phonesim not found, skipping test")
return
Process(['ifconfig', 'lo', 'up']).wait()
Process(['ip', 'link', 'set', 'lo', 'up']).wait()
os.environ['OFONO_PHONESIM_CONFIG'] = '/tmp/phonesim.conf'
@ -1358,7 +1358,7 @@ def post_test(ctx, to_copy):
else:
os.remove('/tmp/' + f)
Process(['ifconfig', 'lo', 'down']).wait()
Process(['ip', 'link', 'set', 'lo', 'down']).wait()
except Exception as e:
print("Exception thrown in post_test")
finally: