nixos/testing: remove unused function runInMachine

runInMachine and runInMachineWithX are not used for any tests and can be
removed
This commit is contained in:
Matthew Kenigsberg 2021-09-07 11:36:11 -05:00
parent bc06c93905
commit b00d2a8f3e
No known key found for this signature in database
GPG Key ID: 5DFF42F2615122A8
3 changed files with 9 additions and 120 deletions

View File

@ -257,105 +257,18 @@ rec {
inherit test driver driverInteractive nodes;
};
runInMachine =
{ drv
, machine
, preBuild ? ""
, postBuild ? ""
, qemu_pkg ? pkgs.qemu_test
, ... # ???
}:
let
build-vms = import ./build-vms.nix {
inherit system pkgs minimal specialArgs extraConfigurations;
};
vm = build-vms.buildVM { }
[
machine
{
key = "run-in-machine";
networking.hostName = "client";
nix.readOnlyStore = false;
virtualisation.writableStore = false;
}
];
abortForFunction = functionName: abort ''The ${functionName} function was
removed because it is not an essential part of the NixOS testing
infrastructure. It had no usage in NixOS or Nixpkgs and it had no designated
maintainer. You are free to reintroduce it by documenting it in the manual
and adding yourself as maintainer. It was removed in
https://github.com/NixOS/nixpkgs/pull/137013
'';
buildrunner = writeText "vm-build" ''
source $1
${coreutils}/bin/mkdir -p $TMPDIR
cd $TMPDIR
exec $origBuilder $origArgs
'';
testScript = ''
start_all()
client.wait_for_unit("multi-user.target")
${preBuild}
client.succeed("env -i ${bash}/bin/bash ${buildrunner} /tmp/xchg/saved-env >&2")
${postBuild}
client.succeed("sync") # flush all data before pulling the plug
'';
testDriver = pythonTestDriver { inherit qemu_pkg; };
vmRunCommand = writeText "vm-run" ''
xchg=vm-state-client/xchg
${coreutils}/bin/mkdir $out
${coreutils}/bin/mkdir -p $xchg
for i in $passAsFile; do
i2=''${i}Path
_basename=$(${coreutils}/bin/basename ''${!i2})
${coreutils}/bin/cp ''${!i2} $xchg/$_basename
eval $i2=/tmp/xchg/$_basename
${coreutils}/bin/ls -la $xchg
done
unset i i2 _basename
export | ${gnugrep}/bin/grep -v '^xchg=' > $xchg/saved-env
unset xchg
export tests='${testScript}'
${testDriver}/bin/nixos-test-driver --keep-vm-state ${vm.config.system.build.vm}/bin/run-*-vm
''; # */
in
lib.overrideDerivation drv (attrs: {
requiredSystemFeatures = [ "kvm" ];
builder = "${bash}/bin/sh";
args = [ "-e" vmRunCommand ];
origArgs = attrs.args;
origBuilder = attrs.builder;
});
runInMachineWithX = { require ? [ ], ... } @ args:
let
client =
{ ... }:
{
inherit require;
imports = [
../tests/common/auto.nix
];
virtualisation.memorySize = 1024;
services.xserver.enable = true;
test-support.displayManager.auto.enable = true;
services.xserver.displayManager.defaultSession = "none+icewm";
services.xserver.windowManager.icewm.enable = true;
};
in
runInMachine ({
machine = client;
preBuild =
''
client.wait_for_x()
'';
} // args);
runInMachine = abortForFunction "runInMachine";
runInMachineWithX = abortForFunction "runInMachineWithX";
simpleTest = as: (makeTest as).test;

View File

@ -385,7 +385,6 @@ in
rspamd = handleTest ./rspamd.nix {};
rss2email = handleTest ./rss2email.nix {};
rsyslogd = handleTest ./rsyslogd.nix {};
runInMachine = handleTest ./run-in-machine.nix {};
rxe = handleTest ./rxe.nix {};
samba = handleTest ./samba.nix {};
samba-wsdd = handleTest ./samba-wsdd.nix {};

View File

@ -1,23 +0,0 @@
{ system ? builtins.currentSystem,
config ? {},
pkgs ? import ../.. { inherit system config; }
}:
with import ../lib/testing-python.nix { inherit system pkgs; };
let
output = runInMachine {
drv = pkgs.hello;
machine = { ... }: { /* services.sshd.enable = true; */ };
};
test = pkgs.runCommand "verify-output" { inherit output; } ''
if [ ! -e "$output/bin/hello" ]; then
echo "Derivation built using runInMachine produced incorrect output:" >&2
ls -laR "$output" >&2
exit 1
fi
"$output/bin/hello" > "$out"
'';
in test // { inherit test; } # To emulate behaviour of makeTest