mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2025-01-03 10:32:33 +01:00
autotests: Test DHCPv6 client in testNetconfig
This commit is contained in:
parent
c473290b47
commit
d30fc97815
@ -11,7 +11,7 @@ from iwd import NetworkType
|
||||
from hostapd import HostapdCLI
|
||||
import testutil
|
||||
from config import ctx
|
||||
import os
|
||||
import os, time
|
||||
|
||||
class Test(unittest.TestCase):
|
||||
|
||||
@ -39,6 +39,10 @@ class Test(unittest.TestCase):
|
||||
testutil.test_iface_operstate()
|
||||
testutil.test_ifaces_connected()
|
||||
|
||||
time.sleep(2)
|
||||
ret = os.system('ip addr show ' + device.name + ' | grep \'inet6 3ffe:501:ffff:100::\'')
|
||||
self.assertEqual(os.waitstatus_to_exitcode(ret), 0)
|
||||
|
||||
device.disconnect()
|
||||
|
||||
condition = 'not obj.connected'
|
||||
@ -48,12 +52,18 @@ class Test(unittest.TestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
def remove_lease():
|
||||
def remove_lease4():
|
||||
try:
|
||||
os.remove('/tmp/dhcpd.leases')
|
||||
os.remove('/tmp/dhcpd.leases~')
|
||||
except:
|
||||
pass
|
||||
def remove_lease6():
|
||||
try:
|
||||
os.remove('/tmp/dhcpd6.leases')
|
||||
os.remove('/tmp/dhcpd6.leases~')
|
||||
except:
|
||||
pass
|
||||
|
||||
hapd = HostapdCLI()
|
||||
# TODO: This could be moved into test-runner itself if other tests ever
|
||||
@ -64,13 +74,31 @@ class Test(unittest.TestCase):
|
||||
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_lease)
|
||||
hapd.ifname], cleanup=remove_lease4)
|
||||
|
||||
ctx.start_process(['ifconfig', hapd.ifname, 'inet6',
|
||||
'add', '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',
|
||||
hapd.ifname], cleanup=remove_lease6)
|
||||
ctx.start_process(['sysctl', 'net.ipv6.conf.' + hapd.ifname + '.forwarding=1']).wait()
|
||||
# Tell clients to use DHCPv6
|
||||
config = open('/tmp/radvd.conf', 'w')
|
||||
config.write('interface ' + hapd.ifname + ' { AdvSendAdvert on; AdvManagedFlag on; };')
|
||||
config.close()
|
||||
cls.radvd_pid = ctx.start_process(['radvd', '-n', '-C', '/tmp/radvd.conf'])
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
IWD.clear_storage()
|
||||
ctx.stop_process(cls.dhcpd_pid)
|
||||
cls.dhcpd_pid = None
|
||||
ctx.stop_process(cls.dhcpd6_pid)
|
||||
cls.dhcpd6_pid = None
|
||||
ctx.stop_process(cls.radvd_pid)
|
||||
cls.radvd_pid = None
|
||||
os.remove('/tmp/radvd.conf')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main(exit=True)
|
||||
|
6
autotests/testNetconfig/dhcpd-v6.conf
Normal file
6
autotests/testNetconfig/dhcpd-v6.conf
Normal file
@ -0,0 +1,6 @@
|
||||
subnet6 3ffe:501:ffff:100::/64
|
||||
{
|
||||
option dhcp6.name-servers 3ffe:501:ffff:100::1;
|
||||
range6 3ffe:501:ffff:100::10 3ffe:501:ffff:100::20;
|
||||
range6 3ffe:501:ffff:100::100 3ffe:501:ffff:100::200;
|
||||
}
|
@ -1,2 +1,5 @@
|
||||
[General]
|
||||
EnableNetworkConfiguration=true
|
||||
|
||||
[Network]
|
||||
EnableIPv6=true
|
||||
|
Loading…
Reference in New Issue
Block a user