]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-network: add tests for Mode= setting in [MACVLAN] section
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 20 May 2019 02:39:05 +0000 (11:39 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 22 May 2019 08:58:46 +0000 (17:58 +0900)
test/test-network/systemd-networkd-tests.py

index d257d92e1af79a7ffe129fa0f09d3312ea4a9b2a..5f6e1c5e1dc54a22809b99a2b869442e498cf2c9 100755 (executable)
@@ -515,18 +515,25 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
         self.wait_online(['macvtap99:off', 'test1:degraded'])
 
     def test_macvlan(self):
         self.wait_online(['macvtap99:off', 'test1:degraded'])
 
     def test_macvlan(self):
-        self.copy_unit_to_networkd_unit_path('21-macvlan.netdev', '11-dummy.netdev', 'macvlan.network')
-        self.start_networkd(0)
-
-        self.wait_online(['macvlan99:off', 'test1:degraded'])
-
-        output = subprocess.check_output(['ip', '-d', 'link', 'show', 'test1'], universal_newlines=True).rstrip()
-        print(output)
-        self.assertRegex(output, ' mtu 2000 ')
+        for mode in ['private', 'vepa', 'bridge', 'passthru']:
+            with self.subTest(mode=mode):
+                if mode != 'private':
+                    self.tearDown()
+                self.copy_unit_to_networkd_unit_path('21-macvlan.netdev', '11-dummy.netdev', 'macvlan.network')
+                with open(os.path.join(network_unit_file_path, '21-macvlan.netdev'), mode='a') as f:
+                    f.write('[MACVLAN]\nMode=' + mode)
+                self.start_networkd(0)
+
+                self.wait_online(['macvlan99:off', 'test1:degraded'])
+
+                output = subprocess.check_output(['ip', '-d', 'link', 'show', 'test1'], universal_newlines=True).rstrip()
+                print(output)
+                self.assertRegex(output, ' mtu 2000 ')
 
 
-        output = subprocess.check_output(['ip', '-d', 'link', 'show', 'macvlan99'], universal_newlines=True).rstrip()
-        print(output)
-        self.assertRegex(output, ' mtu 2000 ')
+                output = subprocess.check_output(['ip', '-d', 'link', 'show', 'macvlan99'], universal_newlines=True).rstrip()
+                print(output)
+                self.assertRegex(output, ' mtu 2000 ')
+                self.assertRegex(output, 'macvlan mode ' + mode + ' ')
 
     @expectedFailureIfModuleIsNotAvailable('ipvlan')
     def test_ipvlan(self):
 
     @expectedFailureIfModuleIsNotAvailable('ipvlan')
     def test_ipvlan(self):