diff options
author | symphorien <symphorien@users.noreply.github.com> | 2018-02-09 18:40:39 +0000 |
---|---|---|
committer | Franz Pletz <fpletz@fnordicwalking.de> | 2018-02-09 18:40:39 +0000 |
commit | 01460745602c2c31f2ce6d7a22ff80602894679b (patch) | |
tree | 47a09f5c8fa604e93e29720ecbb96ecea734d753 /nixos/tests/predictable-interface-names.nix | |
parent | a51cda85ff30876b71fee87b1eef4409af6d4277 (diff) |
nixos/tests: add predictable-interface-names.nix (#34305)
Diffstat (limited to 'nixos/tests/predictable-interface-names.nix')
-rw-r--r-- | nixos/tests/predictable-interface-names.nix | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/nixos/tests/predictable-interface-names.nix b/nixos/tests/predictable-interface-names.nix new file mode 100644 index 0000000000000..b4c2039923cf0 --- /dev/null +++ b/nixos/tests/predictable-interface-names.nix @@ -0,0 +1,27 @@ +{ system ? builtins.currentSystem +, pkgs ? import ../.. { inherit system; } +}: +with import ../lib/testing.nix { inherit system; }; +let boolToString = x: if x then "yes" else "no"; in +let testWhenSetTo = predictable: withNetworkd: +makeTest { + name = "${if predictable then "" else "un"}predictableInterfaceNames${if withNetworkd then "-with-networkd" else ""}"; + meta = {}; + + machine = { config, pkgs, ... }: { + networking.usePredictableInterfaceNames = pkgs.stdenv.lib.mkForce predictable; + networking.useNetworkd = withNetworkd; + networking.dhcpcd.enable = !withNetworkd; + }; + + testScript = '' + print $machine->succeed("ip link"); + $machine->succeed("ip link show ${if predictable then "ens3" else "eth0"}"); + $machine->fail("ip link show ${if predictable then "eth0" else "ens3"}"); + ''; +}; in +with pkgs.stdenv.lib.lists; +with pkgs.stdenv.lib.attrsets; +listToAttrs (map (drv: nameValuePair drv.name drv) ( +crossLists testWhenSetTo [[true false] [true false]] +)) |