summary refs log tree commit diff
path: root/nixos/tests/networking.nix
diff options
context:
space:
mode:
authorrnhmjoj <rnhmjoj@inventati.org>2018-01-31 05:52:22 +0100
committerrnhmjoj <rnhmjoj@inventati.org>2018-01-31 05:52:22 +0100
commitf1cacaf97c4057997a2b4c62be1696650f53203d (patch)
tree1fc1ae68aec10b9f49d4d3c3baece89ca31448b4 /nixos/tests/networking.nix
parent46c158a32f1b920fe0280c7aea3f42670ece7473 (diff)
downloadnixpkgs-f1cacaf97c4057997a2b4c62be1696650f53203d.tar
nixpkgs-f1cacaf97c4057997a2b4c62be1696650f53203d.tar.gz
nixpkgs-f1cacaf97c4057997a2b4c62be1696650f53203d.tar.bz2
nixpkgs-f1cacaf97c4057997a2b4c62be1696650f53203d.tar.lz
nixpkgs-f1cacaf97c4057997a2b4c62be1696650f53203d.tar.xz
nixpkgs-f1cacaf97c4057997a2b4c62be1696650f53203d.tar.zst
nixpkgs-f1cacaf97c4057997a2b4c62be1696650f53203d.zip
nixos/tests: add test for virtual interfaces
Diffstat (limited to 'nixos/tests/networking.nix')
-rw-r--r--nixos/tests/networking.nix43
1 files changed, 43 insertions, 0 deletions
diff --git a/nixos/tests/networking.nix b/nixos/tests/networking.nix
index 7708775f73f..182328b3296 100644
--- a/nixos/tests/networking.nix
+++ b/nixos/tests/networking.nix
@@ -433,6 +433,49 @@ let
           $client2->succeed("ip addr show dev vlan >&2");
         '';
     };
+    virtual = {
+      name = "Virtual";
+      machine = {
+        networking.interfaces."tap0" = {
+          ip4 = [ { address = "192.168.1.1"; prefixLength = 24; } ];
+          ip6 = [ { address = "2001:1470:fffd:2096::"; prefixLength = 64; } ];
+          virtual = true;
+        };
+        networking.interfaces."tun0" = {
+          ip4 = [ { address = "192.168.1.2"; prefixLength = 24; } ];
+          ip6 = [ { address = "2001:1470:fffd:2097::"; prefixLength = 64; } ];
+          virtual = true;
+        };
+      };
+
+      testScript = ''
+        my $targetList = <<'END';
+        tap0: tap UNKNOWN_FLAGS:800 user 0
+        tun0: tun UNKNOWN_FLAGS:800 user 0
+        END
+
+        # Wait for networking to come up
+        $machine->start;
+        $machine->waitForUnit("network.target");
+
+        # Test interfaces set up
+        my $list = $machine->succeed("ip tuntap list | sort");
+        "$list" eq "$targetList" or die(
+          "The list of virtual interfaces does not match the expected one:\n",
+          "Result:\n", "$list\n",
+          "Expected:\n", "$targetList\n"
+        );
+
+        # Test interfaces clean up
+        $machine->succeed("systemctl stop network-addresses-tap0");
+        $machine->succeed("systemctl stop network-addresses-tun0");
+        my $residue = $machine->succeed("ip tuntap list");
+        $residue eq "" or die(
+          "Some virtual interface has not been properly cleaned:\n",
+          "$residue\n"
+        );
+      '';
+    };
   };
 
 in mapAttrs (const (attrs: makeTest (attrs // {