about summary refs log tree commit diff
path: root/nixos/tests/initrd-network.nix
blob: f2483b7393de44b8b543925fef4b5043924bbe98 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import ./make-test-python.nix ({ pkgs, lib, ...} : {
  name = "initrd-network";

  meta.maintainers = [ pkgs.lib.maintainers.eelco ];

  nodes.machine = { ... }: {
    imports = [ ../modules/profiles/minimal.nix ];
    boot.initrd.network.enable = true;
    boot.initrd.network.postCommands =
      ''
        ip addr show
        ip route show
        ip addr | grep 10.0.2.15 || exit 1
        ping -c1 10.0.2.2 || exit 1
      '';
    # Check if cleanup was done correctly
    boot.initrd.postMountCommands = lib.mkAfter
      ''
        ip addr show
        ip route show
        ip addr | grep 10.0.2.15 && exit 1
        ping -c1 10.0.2.2 && exit 1
      '';
  };

  testScript =
    ''
      start_all()
      machine.wait_for_unit("multi-user.target")
      machine.succeed("ip addr show >&2")
      machine.succeed("ip route show >&2")
    '';
})