summaryrefslogtreecommitdiffstats
path: root/nixos/tests/systemd-initrd-modprobe.nix
blob: 894de6e29ffd3ea18dbef60b87f530fd78295c25 (plain)
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
{ lib, pkgs, ... }:
{
  name = "systemd-initrd-modprobe";

  nodes.machine =
    { pkgs, ... }:
    {
      testing.initrdBackdoor = true;
      boot.initrd.systemd.enable = true;
      boot.initrd.kernelModules = [ "tcp_hybla" ]; # Load module in initrd.
      boot.extraModprobeConfig = ''
        options tcp_hybla rtt0=42
      '';
    };

  testScript = ''
    machine.wait_for_unit("initrd.target")
    rtt = machine.succeed("cat /sys/module/tcp_hybla/parameters/rtt0")
    assert int(rtt) == 42, "Parameter should be respected for initrd kernel modules"

    with subtest("modprobe@ services work"):
      modprobe_service_status = machine.succeed("systemctl show --property ExecMainStatus modprobe@9pnet_virtio.service")
      t.assertEqual("ExecMainStatus=0\n", modprobe_service_status)

    # Make sure it sticks in stage 2
    machine.switch_root()
    machine.wait_for_unit("multi-user.target")
    rtt = machine.succeed("cat /sys/module/tcp_hybla/parameters/rtt0")
    assert int(rtt) == 42, "Parameter should be respected for initrd kernel modules"
  '';
}