about summary refs log tree commit diff
path: root/nixos/tests/envfs.nix
blob: 3f9cd1edb595afbc75f36bdaf9664ec886edb755 (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
34
35
36
37
38
39
40
41
42
import ./make-test-python.nix ({ lib, pkgs, ... }:
let
  pythonShebang = pkgs.writeScript "python-shebang" ''
    #!/usr/bin/python
    print("OK")
  '';

  bashShebang = pkgs.writeScript "bash-shebang" ''
    #!/usr/bin/bash
    echo "OK"
  '';
in
{
  name = "envfs";
  nodes.machine.services.envfs.enable = true;

  testScript = ''
    start_all()
    machine.wait_until_succeeds("mountpoint -q /usr/bin/")
    machine.succeed(
        "PATH=${pkgs.coreutils}/bin /usr/bin/cp --version",
        # check fallback paths
        "PATH= /usr/bin/sh --version",
        "PATH= /usr/bin/env --version",
        "PATH= test -e /usr/bin/sh",
        "PATH= test -e /usr/bin/env",
        # no stat
        "! test -e /usr/bin/cp",
        # also picks up PATH that was set after execve
        "! /usr/bin/hello",
        "PATH=${pkgs.hello}/bin /usr/bin/hello",
    )

    out = machine.succeed("PATH=${pkgs.python3}/bin ${pythonShebang}")
    print(out)
    assert out == "OK\n"

    out = machine.succeed("PATH=${pkgs.bash}/bin ${bashShebang}")
    print(out)
    assert out == "OK\n"
  '';
})