]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-network: remove fou ports on failure
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 24 May 2019 04:39:50 +0000 (13:39 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 28 May 2019 13:21:24 +0000 (22:21 +0900)
test/test-network/systemd-networkd-tests.py

index d809e72abc396942819a99219108bbfc2ae31ed9..32efc229297bf96962fa4570981c3d03025184ad 100755 (executable)
@@ -112,6 +112,10 @@ class Utilities():
                 subprocess.call(['ip', 'link', 'del', 'dev', link])
         time.sleep(1)
 
+    def remove_fou_ports(self, ports):
+        for port in ports:
+            subprocess.call(['ip', 'fou', 'del', 'port', port])
+
     def l2tp_tunnel_remove(self, tunnel_ids):
         output = subprocess.check_output(['ip', 'l2tp', 'show', 'tunnel'], universal_newlines=True).rstrip()
         for tid in tunnel_ids:
@@ -371,10 +375,16 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
         'vxlan-test1.network',
         'vxlan.network']
 
+    fou_ports = [
+        '55555',
+        '55556']
+
     def setUp(self):
+        self.remove_fou_ports(self.fou_ports)
         self.link_remove(self.links)
 
     def tearDown(self):
+        self.remove_fou_ports(self.fou_ports)
         self.link_remove(self.links)
         self.remove_unit_from_networkd_path(self.units)
 
@@ -924,9 +934,6 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
         print(output)
         self.assertRegex(output, 'encap fou encap-sport auto encap-dport 55556')
 
-        subprocess.call(['ip', 'fou', 'del', 'port', '55555'])
-        subprocess.call(['ip', 'fou', 'del', 'port', '55556'])
-
     def test_vxlan(self):
         self.copy_unit_to_networkd_unit_path('25-vxlan.netdev', 'vxlan.network',
                                              '11-dummy.netdev', 'vxlan-test1.network')