about summary refs log tree commit diff
path: root/nixos/tests/networking.nix
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2020-04-13 19:16:12 +0200
committerFlorian Klink <flokli@flokli.de>2020-04-13 22:03:35 +0200
commit1e1945319c2017e0a40a2ea3023d64f282d2b538 (patch)
tree66c3f65a3fb30c020e3dac1be6d07091048ee09c /nixos/tests/networking.nix
parent532528190bdd739fda866645ba0078df28abc025 (diff)
nixosTests.networking: make routing table comparison more reliable
This was whitespace-sensitive, kept fighting with my editor and broke
the tests easily. To fix this, let python convert the output to
individual lines, and strip whitespace from them before comparing.
Diffstat (limited to 'nixos/tests/networking.nix')
-rw-r--r--nixos/tests/networking.nix34
1 files changed, 17 insertions, 17 deletions
diff --git a/nixos/tests/networking.nix b/nixos/tests/networking.nix
index 0a6507d2dc884..5c4aa5c38e11b 100644
--- a/nixos/tests/networking.nix
+++ b/nixos/tests/networking.nix
@@ -602,17 +602,17 @@ let
       };
 
       testScript = ''
-        targetIPv4Table = """
-        10.0.0.0/16 proto static scope link mtu 1500 
-        192.168.1.0/24 proto kernel scope link src 192.168.1.2 
-        192.168.2.0/24 via 192.168.1.1 proto static 
-        """.strip()
-
-        targetIPv6Table = """
-        2001:1470:fffd:2097::/64 proto kernel metric 256 pref medium
-        2001:1470:fffd:2098::/64 via fdfd:b3f0::1 proto static metric 1024 pref medium
-        fdfd:b3f0::/48 proto static metric 1024 pref medium
-        """.strip()
+        targetIPv4Table = [
+            "10.0.0.0/16 proto static scope link mtu 1500",
+            "192.168.1.0/24 proto kernel scope link src 192.168.1.2",
+            "192.168.2.0/24 via 192.168.1.1 proto static",
+        ]
+
+        targetIPv6Table = [
+            "2001:1470:fffd:2097::/64 proto kernel metric 256 pref medium",
+            "2001:1470:fffd:2098::/64 via fdfd:b3f0::1 proto static metric 1024 pref medium",
+            "fdfd:b3f0::/48 proto static metric 1024 pref medium",
+        ]
 
         machine.start()
         machine.wait_for_unit("network.target")
@@ -620,9 +620,9 @@ let
         with subtest("test routing tables"):
             ipv4Table = machine.succeed("ip -4 route list dev eth0 | head -n3").strip()
             ipv6Table = machine.succeed("ip -6 route list dev eth0 | head -n3").strip()
-            assert (
-                ipv4Table == targetIPv4Table
-            ), """
+            assert [
+                l.strip() for l in ipv4Table.splitlines()
+            ] == targetIPv4Table, """
               The IPv4 routing table does not match the expected one:
                 Result:
                   {}
@@ -631,9 +631,9 @@ let
               """.format(
                 ipv4Table, targetIPv4Table
             )
-            assert (
-                ipv6Table == targetIPv6Table
-            ), """
+            assert [
+                l.strip() for l in ipv6Table.splitlines()
+            ] == targetIPv6Table, """
               The IPv6 routing table does not match the expected one:
                 Result:
                   {}