mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-25 01:19:23 +01:00
auto-t: Verify DNS entries added from DHCP/static
Add a fake resolvconf executable to verify that the right nameserver addresses were actually committed by iwd. Again use unique nameserver addresses to reduce the possibility that the test succeeds by pure luck.
This commit is contained in:
parent
c4fe900a71
commit
2c0bb06d1a
@ -77,6 +77,14 @@ class Test(unittest.TestCase):
|
|||||||
self.assertEqual(expected_routes4, set(testutil.get_routes4(ifname)))
|
self.assertEqual(expected_routes4, set(testutil.get_routes4(ifname)))
|
||||||
self.assertEqual(expected_routes6, set(testutil.get_routes6(ifname)))
|
self.assertEqual(expected_routes6, set(testutil.get_routes6(ifname)))
|
||||||
|
|
||||||
|
rclog = open('/tmp/resolvconf.log', 'r')
|
||||||
|
entries = rclog.readlines()
|
||||||
|
rclog.close()
|
||||||
|
expected_rclog = ['-a wlan1.dns\n', 'nameserver 192.168.1.2\n', 'nameserver 3ffe:501:ffff:100::2\n']
|
||||||
|
# Every real resolvconf -a run overwrites the previous settings. Check the last three lines
|
||||||
|
# of our log since we care about the end result here.
|
||||||
|
self.assertEqual(expected_rclog, entries[-3:])
|
||||||
|
|
||||||
device.disconnect()
|
device.disconnect()
|
||||||
|
|
||||||
condition = 'not obj.connected'
|
condition = 'not obj.connected'
|
||||||
@ -133,6 +141,10 @@ class Test(unittest.TestCase):
|
|||||||
config.close()
|
config.close()
|
||||||
cls.radvd_pid = ctx.start_process(['radvd', '-n', '-d5', '-p', '/tmp/radvd.pid', '-C', '/tmp/radvd.conf'])
|
cls.radvd_pid = ctx.start_process(['radvd', '-n', '-d5', '-p', '/tmp/radvd.pid', '-C', '/tmp/radvd.conf'])
|
||||||
|
|
||||||
|
cls.orig_path = os.environ['PATH']
|
||||||
|
os.environ['PATH'] = '/tmp/test-bin:' + os.environ['PATH']
|
||||||
|
IWD.copy_to_storage('resolvconf', '/tmp/test-bin')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def tearDownClass(cls):
|
def tearDownClass(cls):
|
||||||
IWD.clear_storage()
|
IWD.clear_storage()
|
||||||
@ -142,7 +154,8 @@ class Test(unittest.TestCase):
|
|||||||
cls.dhcpd6_pid = None
|
cls.dhcpd6_pid = None
|
||||||
ctx.stop_process(cls.radvd_pid)
|
ctx.stop_process(cls.radvd_pid)
|
||||||
cls.radvd_pid = None
|
cls.radvd_pid = None
|
||||||
os.remove('/tmp/radvd.conf')
|
os.system('rm -rf /tmp/radvd.conf /tmp/resolvconf.log /tmp/test-bin')
|
||||||
|
os.environ['PATH'] = cls.orig_path
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main(exit=True)
|
unittest.main(exit=True)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
subnet6 3ffe:501:ffff:100::/72
|
subnet6 3ffe:501:ffff:100::/72
|
||||||
{
|
{
|
||||||
option dhcp6.name-servers 3ffe:501:ffff:100::1;
|
option dhcp6.name-servers 3ffe:501:ffff:100::2;
|
||||||
range6 3ffe:501:ffff:100::10 3ffe:501:ffff:100::20;
|
range6 3ffe:501:ffff:100::10 3ffe:501:ffff:100::20;
|
||||||
range6 3ffe:501:ffff:100::100 3ffe:501:ffff:100::200;
|
range6 3ffe:501:ffff:100::100 3ffe:501:ffff:100::200;
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ subnet 192.168.0.0 netmask 255.255.128.0
|
|||||||
{
|
{
|
||||||
option routers 192.168.1.1;
|
option routers 192.168.1.1;
|
||||||
option subnet-mask 255.255.128.0;
|
option subnet-mask 255.255.128.0;
|
||||||
option domain-name-servers 192.168.1.1;
|
option domain-name-servers 192.168.1.2;
|
||||||
range 192.168.1.10 192.168.1.20;
|
range 192.168.1.10 192.168.1.20;
|
||||||
range 192.168.1.100 192.168.1.200;
|
range 192.168.1.100 192.168.1.200;
|
||||||
}
|
}
|
||||||
|
@ -3,4 +3,4 @@ EnableNetworkConfiguration=true
|
|||||||
|
|
||||||
[Network]
|
[Network]
|
||||||
EnableIPv6=true
|
EnableIPv6=true
|
||||||
NameResolvingService=none
|
NameResolvingService=resolvconf
|
||||||
|
2
autotests/testNetconfig/resolvconf
Executable file
2
autotests/testNetconfig/resolvconf
Executable file
@ -0,0 +1,2 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
(echo "$*" ; [ "$1" = -a ] && cat) >> /tmp/resolvconf.log 2> /dev/null
|
@ -4,11 +4,13 @@
|
|||||||
Address=192.168.1.10
|
Address=192.168.1.10
|
||||||
Netmask=255.255.255.128
|
Netmask=255.255.255.128
|
||||||
Gateway=192.168.1.3
|
Gateway=192.168.1.3
|
||||||
|
DNS=192.168.1.4
|
||||||
|
|
||||||
[IPv6]
|
[IPv6]
|
||||||
# Use a different subnet than DHCP on purpose
|
# Use a different subnet than DHCP on purpose
|
||||||
Address=3ffe:501:ffff:200::10/80
|
Address=3ffe:501:ffff:200::10/80
|
||||||
Gateway=3ffe:501:ffff:200::3
|
Gateway=3ffe:501:ffff:200::3
|
||||||
|
DNS=3ffe:501:ffff:200::4
|
||||||
|
|
||||||
[Settings]
|
[Settings]
|
||||||
AutoConnect=false
|
AutoConnect=false
|
||||||
|
@ -72,6 +72,14 @@ class Test(unittest.TestCase):
|
|||||||
self.assertEqual(expected_routes4, set(testutil.get_routes4(ifname)))
|
self.assertEqual(expected_routes4, set(testutil.get_routes4(ifname)))
|
||||||
self.assertEqual(expected_routes6, set(testutil.get_routes6(ifname)))
|
self.assertEqual(expected_routes6, set(testutil.get_routes6(ifname)))
|
||||||
|
|
||||||
|
rclog = open('/tmp/resolvconf.log', 'r')
|
||||||
|
entries = rclog.readlines()
|
||||||
|
rclog.close()
|
||||||
|
expected_rclog = ['-a wlan1.dns\n', 'nameserver 192.168.1.4\n', 'nameserver 3ffe:501:ffff:200::4\n']
|
||||||
|
# Every resolvconf -a run overwrites the previous settings. Check the last three lines
|
||||||
|
# of the log since we care about the end result here.
|
||||||
|
self.assertEqual(expected_rclog, entries[-3:])
|
||||||
|
|
||||||
ordered_network = dev2.get_ordered_network('ssidTKIP')
|
ordered_network = dev2.get_ordered_network('ssidTKIP')
|
||||||
|
|
||||||
condition = 'not obj.connected'
|
condition = 'not obj.connected'
|
||||||
@ -121,10 +129,15 @@ class Test(unittest.TestCase):
|
|||||||
hapd.ifname], cleanup=remove_lease)
|
hapd.ifname], cleanup=remove_lease)
|
||||||
IWD.copy_to_storage('ssidTKIP.psk', '/tmp/storage')
|
IWD.copy_to_storage('ssidTKIP.psk', '/tmp/storage')
|
||||||
|
|
||||||
|
cls.orig_path = os.environ['PATH']
|
||||||
|
os.environ['PATH'] = '/tmp/test-bin:' + os.environ['PATH']
|
||||||
|
IWD.copy_to_storage('resolvconf', '/tmp/test-bin')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def tearDownClass(cls):
|
def tearDownClass(cls):
|
||||||
IWD.clear_storage(storage_dir='/tmp/storage')
|
|
||||||
cls.dhcpd_pid.kill()
|
cls.dhcpd_pid.kill()
|
||||||
|
os.system('rm -rf /tmp/resolvconf.log /tmp/test-bin /tmp/storage')
|
||||||
|
os.environ['PATH'] = cls.orig_path
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main(exit=True)
|
unittest.main(exit=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user