1 import ./make-test-python.nix ({ lib, pkgs, ... }: {
4 nodes.machine = { lib, ... }:
6 environment.stub-ld.enable = true;
8 specialisation.nostub = {
9 inheritParentConfig = true;
11 configuration = { ... }: {
12 environment.stub-ld.enable = lib.mkForce false;
18 libDir = pkgs.stdenv.hostPlatform.libDir;
19 ldsoBasename = lib.last (lib.splitString "/" pkgs.stdenv.cc.bintools.dynamicLinker);
21 check32 = pkgs.stdenv.hostPlatform.isx86_64;
22 pkgs32 = pkgs.pkgsi686Linux;
24 libDir32 = pkgs32.stdenv.hostPlatform.libDir;
25 ldsoBasename32 = lib.last (lib.splitString "/" pkgs32.stdenv.cc.bintools.dynamicLinker);
27 test-exec = builtins.mapAttrs (n: v: pkgs.runCommand "test-exec-${n}" { src = pkgs.fetchurl v; } "mkdir -p $out;cd $out;tar -xzf $src") {
28 x86_64-linux.url = "https://github.com/rustic-rs/rustic/releases/download/v0.6.1/rustic-v0.6.1-x86_64-unknown-linux-gnu.tar.gz";
29 x86_64-linux.hash = "sha256-3zySzx8MKFprMOi++yr2ZGASE0aRfXHQuG3SN+kWUCI=";
30 i686-linux.url = "https://github.com/rustic-rs/rustic/releases/download/v0.6.1/rustic-v0.6.1-i686-unknown-linux-gnu.tar.gz";
31 i686-linux.hash = "sha256-fWNiATFeg0B2pfB5zndlnzGn7Ztl8diVS1rFLEDnSLU=";
32 aarch64-linux.url = "https://github.com/rustic-rs/rustic/releases/download/v0.6.1/rustic-v0.6.1-aarch64-unknown-linux-gnu.tar.gz";
33 aarch64-linux.hash = "sha256-hnldbd2cctQIAhIKoEZLIWY8H3jiFBClkNy2UlyyvAs=";
37 if32 = pythonStatement: if check32 then pythonStatement else "pass";
41 machine.wait_for_unit("multi-user.target")
43 with subtest("Check for stub (enabled, initial)"):
44 machine.succeed('test -L /${libDir}/${ldsoBasename}')
45 ${if32 "machine.succeed('test -L /${libDir32}/${ldsoBasename32}')"}
47 with subtest("Try FHS executable"):
48 machine.copy_from_host('${test-exec.${pkgs.stdenv.hostPlatform.system}}','test-exec')
49 machine.succeed('if test-exec/${exec-name} 2>outfile; then false; else [ $? -eq 127 ];fi')
50 machine.succeed('grep -qi nixos outfile')
51 ${if32 "machine.copy_from_host('${test-exec.${pkgs32.stdenv.hostPlatform.system}}','test-exec32')"}
52 ${if32 "machine.succeed('if test-exec32/${exec-name} 2>outfile32; then false; else [ $? -eq 127 ];fi')"}
53 ${if32 "machine.succeed('grep -qi nixos outfile32')"}
55 with subtest("Disable stub"):
56 machine.succeed("/run/booted-system/specialisation/nostub/bin/switch-to-configuration test")
58 with subtest("Check for stub (disabled)"):
59 machine.fail('test -e /${libDir}/${ldsoBasename}')
60 ${if32 "machine.fail('test -e /${libDir32}/${ldsoBasename32}')"}
62 with subtest("Create file in stub location (to be overwritten)"):
63 machine.succeed('mkdir -p /${libDir};touch /${libDir}/${ldsoBasename}')
64 ${if32 "machine.succeed('mkdir -p /${libDir32};touch /${libDir32}/${ldsoBasename32}')"}
66 with subtest("Re-enable stub"):
67 machine.succeed("/run/booted-system/bin/switch-to-configuration test")
69 with subtest("Check for stub (enabled, final)"):
70 machine.succeed('test -L /${libDir}/${ldsoBasename}')
71 ${if32 "machine.succeed('test -L /${libDir32}/${ldsoBasename32}')"}