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
|
from hostapd import HostapdCLI
|
||||||
import testutil
|
import testutil
|
||||||
from config import ctx
|
from config import ctx
|
||||||
import os
|
import os, time
|
||||||
|
|
||||||
class Test(unittest.TestCase):
|
class Test(unittest.TestCase):
|
||||||
|
|
||||||
@ -39,6 +39,10 @@ class Test(unittest.TestCase):
|
|||||||
testutil.test_iface_operstate()
|
testutil.test_iface_operstate()
|
||||||
testutil.test_ifaces_connected()
|
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()
|
device.disconnect()
|
||||||
|
|
||||||
condition = 'not obj.connected'
|
condition = 'not obj.connected'
|
||||||
@ -48,12 +52,18 @@ class Test(unittest.TestCase):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
def remove_lease():
|
def remove_lease4():
|
||||||
try:
|
try:
|
||||||
os.remove('/tmp/dhcpd.leases')
|
os.remove('/tmp/dhcpd.leases')
|
||||||
os.remove('/tmp/dhcpd.leases~')
|
os.remove('/tmp/dhcpd.leases~')
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
def remove_lease6():
|
||||||
|
try:
|
||||||
|
os.remove('/tmp/dhcpd6.leases')
|
||||||
|
os.remove('/tmp/dhcpd6.leases~')
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
hapd = HostapdCLI()
|
hapd = HostapdCLI()
|
||||||
# TODO: This could be moved into test-runner itself if other tests ever
|
# 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()
|
ctx.start_process(['touch', '/tmp/dhcpd.leases']).wait()
|
||||||
cls.dhcpd_pid = ctx.start_process(['dhcpd', '-f', '-cf', '/tmp/dhcpd.conf',
|
cls.dhcpd_pid = ctx.start_process(['dhcpd', '-f', '-cf', '/tmp/dhcpd.conf',
|
||||||
'-lf', '/tmp/dhcpd.leases',
|
'-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
|
@classmethod
|
||||||
def tearDownClass(cls):
|
def tearDownClass(cls):
|
||||||
IWD.clear_storage()
|
IWD.clear_storage()
|
||||||
ctx.stop_process(cls.dhcpd_pid)
|
ctx.stop_process(cls.dhcpd_pid)
|
||||||
cls.dhcpd_pid = None
|
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__':
|
if __name__ == '__main__':
|
||||||
unittest.main(exit=True)
|
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]
|
[General]
|
||||||
EnableNetworkConfiguration=true
|
EnableNetworkConfiguration=true
|
||||||
|
|
||||||
|
[Network]
|
||||||
|
EnableIPv6=true
|
||||||
|
Loading…
Reference in New Issue
Block a user