]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-network: add tests for Mode= setting in [MACVTAP] section
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 20 May 2019 02:47:24 +0000 (11:47 +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 5f6e1c5e1dc54a22809b99a2b869442e498cf2c9..b53fbe651a8a19a690c9be10d9f6e0e8bc5031c5 100755 (executable)
@@ -509,10 +509,20 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
         self.assertRegex(output, 'inet 192.168.23.5/24 brd 192.168.23.255 scope global vlan99')
 
     def test_macvtap(self):
-        self.copy_unit_to_networkd_unit_path('21-macvtap.netdev', '11-dummy.netdev', 'macvtap.network')
-        self.start_networkd(0)
+        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-macvtap.netdev', '11-dummy.netdev', 'macvtap.network')
+                with open(os.path.join(network_unit_file_path, '21-macvtap.netdev'), mode='a') as f:
+                    f.write('[MACVTAP]\nMode=' + mode)
+                self.start_networkd(0)
 
-        self.wait_online(['macvtap99:off', 'test1:degraded'])
+                self.wait_online(['macvtap99:off', 'test1:degraded'])
+
+                output = subprocess.check_output(['ip', '-d', 'link', 'show', 'macvtap99'], universal_newlines=True).rstrip()
+                print(output)
+                self.assertRegex(output, 'macvtap mode ' + mode + ' ')
 
     def test_macvlan(self):
         for mode in ['private', 'vepa', 'bridge', 'passthru']: