From 94f0bd624bf9a9681e29a6e55302014979548096 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 30 Nov 2021 08:12:28 +0900 Subject: [PATCH] test-network: add more basic tests for network json formats --- test/test-network/systemd-networkd-tests.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index cf8e445b37e..4d4f7927076 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -3432,6 +3432,9 @@ class NetworkdStateFileTests(unittest.TestCase, Utilities): # make link state file updated check_output(*resolvectl_cmd, 'revert', 'dummy98', env=env) + # TODO: check json string + check_output(*networkctl_cmd, '--json=short', 'status', env=env) + with open(path) as f: data = f.read() self.assertRegex(data, r'IPV4_ADDRESS_STATE=routable') @@ -3458,6 +3461,9 @@ class NetworkdStateFileTests(unittest.TestCase, Utilities): check_output(*resolvectl_cmd, 'dnssec', 'dummy98', 'yes', env=env) check_output(*timedatectl_cmd, 'ntp-servers', 'dummy98', '2.fedora.pool.ntp.org', '3.fedora.pool.ntp.org', env=env) + # TODO: check json string + check_output(*networkctl_cmd, '--json=short', 'status', env=env) + with open(path) as f: data = f.read() self.assertRegex(data, r'DNS=10.10.10.12#ccc.com 10.10.10.13 1111:2222::3333') @@ -3470,6 +3476,9 @@ class NetworkdStateFileTests(unittest.TestCase, Utilities): check_output(*timedatectl_cmd, 'revert', 'dummy98', env=env) + # TODO: check json string + check_output(*networkctl_cmd, '--json=short', 'status', env=env) + with open(path) as f: data = f.read() self.assertRegex(data, r'DNS=10.10.10.12#ccc.com 10.10.10.13 1111:2222::3333') @@ -3482,6 +3491,9 @@ class NetworkdStateFileTests(unittest.TestCase, Utilities): check_output(*resolvectl_cmd, 'revert', 'dummy98', env=env) + # TODO: check json string + check_output(*networkctl_cmd, '--json=short', 'status', env=env) + with open(path) as f: data = f.read() self.assertRegex(data, r'DNS=10.10.10.10#aaa.com 10.10.10.11:1111#bbb.com \[1111:2222::3333\]:1234#ccc.com') @@ -4293,6 +4305,9 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities): self.assertNotRegex(output, r'8.8.8.8 via 192.168.5.[0-9]* proto dhcp src 192.168.5.[0-9]* metric 1024') self.assertNotRegex(output, r'9.9.9.9 via 192.168.5.[0-9]* proto dhcp src 192.168.5.[0-9]* metric 1024') + # TODO: check json string + check_output(*networkctl_cmd, '--json=short', 'status', env=env) + def test_dhcp_client_ipv4_ipv6(self): copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-server-veth-peer.network', 'dhcp-client-ipv4-only.network') start_networkd() @@ -4830,6 +4845,9 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities): self.assertRegex(output, '192.168.5.1') self.assertRegex(output, '2600::1') + # TODO: check json string + check_output(*networkctl_cmd, '--json=short', 'status', env=env) + def test_dhcp_client_use_dns_no(self): copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-server-veth-peer.network', 'dhcp-client-use-dns-no.network') @@ -5160,6 +5178,9 @@ class NetworkdIPv6PrefixTests(unittest.TestCase, Utilities): print(output) self.assertIn('example.com', output) + # TODO: check json string + check_output(*networkctl_cmd, '--json=short', 'status', env=env) + def test_ipv6_route_prefix_deny_list(self): copy_unit_to_networkd_unit_path('25-veth.netdev', 'ipv6ra-prefix-client-deny-list.network', 'ipv6ra-prefix.network', '12-dummy.netdev', 'ipv6ra-uplink.network') -- 2.47.3