]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-network: add test for bridge MulticastToUnicast 10988/head
authorSusant Sahani <ssahani@gmail.com>
Thu, 6 Dec 2018 06:24:14 +0000 (11:54 +0530)
committerSusant Sahani <ssahani@gmail.com>
Thu, 6 Dec 2018 06:24:14 +0000 (11:54 +0530)
test/test-network/conf/26-bridge-slave-interface-1.network
test/test-network/systemd-networkd-tests.py

index 84f221d538549aaaeec91bf1276f66ff57d4d6b2..81b372fb6d091e78dadd8762001f360544f8d51b 100644 (file)
@@ -9,3 +9,4 @@ Cost=400
 HairPin = true
 FastLeave = true
 UnicastFlood = true
+MulticastToUnicast = true
index 806f4a496c4930e0499609583afed13d8dc4e9c6..729ed17c6e2a8fd7169e9ad584eaf1c791b653a9 100755 (executable)
@@ -61,6 +61,15 @@ class Utilities():
         with open(os.path.join(os.path.join(os.path.join('/sys/class/net/', link), dev), attribute)) as f:
             return f.readline().strip()
 
+    def read_bridge_port_attr(self, bridge, link, attribute):
+
+        path_bridge = os.path.join('/sys/devices/virtual/net', bridge)
+        path_port = 'lower_' + link + '/brport'
+        path = os.path.join(path_bridge, path_port)
+
+        with open(os.path.join(path, attribute)) as f:
+            return f.readline().strip()
+
     def link_exits(self, link):
         return os.path.exists(os.path.join('/sys/class/net', link))
 
@@ -712,10 +721,15 @@ class NetworkdNetWorkBrideTests(unittest.TestCase, Utilities):
 
         output = subprocess.check_output(['bridge', '-d', 'link', 'show', 'dummy98']).rstrip().decode('utf-8')
         print(output)
-        self.assertRegex(output, 'cost 400')
-        self.assertRegex(output, 'hairpin on')
-        self.assertRegex(output, 'flood on')
-        self.assertRegex(output, 'fastleave on')
+
+        self.assertEqual(self.read_bridge_port_attr('bridge99', 'dummy98', 'hairpin_mode'), '1')
+        self.assertEqual(self.read_bridge_port_attr('bridge99', 'dummy98', 'path_cost'), '400')
+        self.assertEqual(self.read_bridge_port_attr('bridge99', 'dummy98', 'unicast_flood'), '1')
+        self.assertEqual(self.read_bridge_port_attr('bridge99', 'dummy98', 'multicast_fast_leave'), '1')
+
+        # CONFIG_BRIDGE_IGMP_SNOOPING=y
+        if (os.path.exists('/sys/devices/virtual/net/bridge00/lower_dummy98/brport/multicast_to_unicast')):
+            self.assertEqual(self.read_bridge_port_attr('bridge99', 'dummy98', 'multicast_to_unicast'), '1')
 
 class NetworkdNetWorkLLDPTests(unittest.TestCase, Utilities):
     links = ['veth99']