depot/nixos/tests/envfs.nix
Luke Granger-Brown 57725ef3ec Squashed 'third_party/nixpkgs/' content from commit 76612b17c0ce
git-subtree-dir: third_party/nixpkgs
git-subtree-split: 76612b17c0ce71689921ca12d9ffdc9c23ce40b2
2024-11-10 23:59:47 +00:00

42 lines
1.1 KiB
Nix

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"
'';
})