test-network: add one more test for netdev dropin .conf files
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 26 Nov 2018 13:05:48 +0000 (22:05 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 26 Nov 2018 13:48:27 +0000 (22:48 +0900)
For netdev, config files are loaded twice, and the first time,
only Match and NetDev setions are read. So, the test given by
the previous commit covers only the second loading.
This adds another test that also covers the first loading.

test/test-network/conf/10-dropin-test.netdev [new file with mode: 0644]
test/test-network/conf/10-dropin-test.netdev.d/mac.conf [new file with mode: 0644]
test/test-network/conf/10-dropin-test.netdev.d/name.conf [new file with mode: 0644]
test/test-network/systemd-networkd-tests.py

diff --git a/test/test-network/conf/10-dropin-test.netdev b/test/test-network/conf/10-dropin-test.netdev
new file mode 100644 (file)
index 0000000..d85ea5b
--- /dev/null
@@ -0,0 +1,4 @@
+[NetDev]
+Name=hoge
+Kind=dummy
+MACAddress=00:50:56:c0:00:18
diff --git a/test/test-network/conf/10-dropin-test.netdev.d/mac.conf b/test/test-network/conf/10-dropin-test.netdev.d/mac.conf
new file mode 100644 (file)
index 0000000..0b3f765
--- /dev/null
@@ -0,0 +1,2 @@
+[NetDev]
+MACAddress=00:50:56:c0:00:28
diff --git a/test/test-network/conf/10-dropin-test.netdev.d/name.conf b/test/test-network/conf/10-dropin-test.netdev.d/name.conf
new file mode 100644 (file)
index 0000000..9905932
--- /dev/null
@@ -0,0 +1,2 @@
+[NetDev]
+Name=dropin-test
index 11b4aa1..2525a35 100755 (executable)
@@ -153,7 +153,7 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
     links =['bridge99', 'bond99', 'bond99', 'vlan99', 'test1', 'macvtap99',
             'macvlan99', 'ipvlan99', 'vxlan99', 'veth99', 'vrf99', 'tun99',
             'tap99', 'vcan99', 'geneve99', 'dummy98', 'ipiptun99', 'sittun99', '6rdtun99',
-            'gretap99', 'vtitun99', 'vti6tun99','ip6tnl99', 'gretun99', 'ip6gretap99', 'wg99']
+            'gretap99', 'vtitun99', 'vti6tun99','ip6tnl99', 'gretun99', 'ip6gretap99', 'wg99', 'dropin-test']
 
     units = ['25-bridge.netdev', '25-bond.netdev', '21-vlan.netdev', '11-dummy.netdev', '21-vlan.network',
              '21-macvtap.netdev', 'macvtap.network', '21-macvlan.netdev', 'macvlan.network', 'vxlan.network',
@@ -163,7 +163,7 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
              '25-gre-tunnel.netdev', '25-gretap-tunnel.netdev', '25-vti-tunnel.netdev', '25-vti6-tunnel.netdev',
              '12-dummy.netdev', 'gre.network', 'ipip.network', 'ip6gretap.network', 'gretun.network',
              'ip6tnl.network', '25-tap.netdev', 'vti6.network', 'vti.network', 'gretap.network', 'sit.network',
-             '25-ipip-tunnel-independent.netdev', '25-wireguard.netdev', '6rd.network']
+             '25-ipip-tunnel-independent.netdev', '25-wireguard.netdev', '6rd.network', '10-dropin-test.netdev']
 
     def setUp(self):
         self.link_remove(self.links)
@@ -172,6 +172,17 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
         self.link_remove(self.links)
         self.remove_unit_from_networkd_path(self.units)
 
+    def test_dropin(self):
+        self.copy_unit_to_networkd_unit_path('10-dropin-test.netdev')
+
+        self.start_networkd()
+
+        self.assertTrue(self.link_exits('dropin-test'))
+
+        output = subprocess.check_output(['ip', 'link', 'show', 'dropin-test']).rstrip().decode('utf-8')
+        print(output)
+        self.assertRegex(output, '00:50:56:c0:00:28')
+
     def test_bridge(self):
         self.copy_unit_to_networkd_unit_path('25-bridge.netdev')
         self.start_networkd()