2
0
Fork 0
genodepkgs/tests/driver-linux.nix

98 lines
2.7 KiB
Nix
Raw Normal View History

# SPDX-FileCopyrightText: Emery Hemingway
#
# SPDX-License-Identifier: LicenseRef-Hippocratic-1.1
2019-11-05 17:38:47 +01:00
{ testPkgs, hostPkgs, lib, depot }:
let
testDriver = with hostPkgs;
stdenv.mkDerivation {
name = "genode-test-driver";
2019-10-28 07:23:13 +01:00
preferLocalBuild = true;
buildInputs = [ makeWrapper expect ];
dontUnpack = true;
installPhase = ''
install -Dm555 ${./test-driver.exp} $out/bin/genode-test-driver
wrapProgram $out/bin/genode-test-driver \
--prefix PATH : "${lib.makeBinPath [ expect coreutils ]}"
'';
};
runTests = driver:
hostPkgs.stdenv.mkDerivation {
2019-11-05 17:38:47 +01:00
name = "linux-"+driver.testName;
2019-10-28 07:23:13 +01:00
preferLocalBuild = true;
buildCommand = ''
mkdir -p $out/nix-support
${driver}/bin/genode-test-driver | tee $out/log
touch $out/nix-support
echo "report testlog $out log" >> $out/nix-support/hydra-build-products
'';
};
mkTest = { name ? "unamed", testScript, testConfig, bootModules, ... }@t:
with testPkgs;
let
bootModules' = {
inherit testConfig;
config = ./driver-config.xml;
2019-11-19 16:36:52 +01:00
core = "${base-linux}/bin/core-linux";
init = "${os}/bin/init";
2019-12-02 16:39:52 +01:00
"ld.lib.so" = "${base-linux}/bin/ld-linux.lib.so";
2019-11-19 16:36:52 +01:00
timer = "${base-linux}/bin/linux_timer_drv";
} // bootModules;
baseSetup = with builtins;
lib.concatStrings (map (name: ''
file link -s ${name} ${getAttr name bootModules'}
'') (attrNames bootModules'))
+ ''
source ${./common-test-driver.exp}
'';
driver = with hostPkgs;
runCommand "genode-test-driver-${name}" {
buildInputs = [ makeWrapper expect ];
inherit baseSetup testConfig testScript;
preferLocalBuild = true;
testName = name;
} ''
mkdir -p $out/bin
echo "$testConfig" > $out/test.config
echo "$testScript" > $out/test-script
echo "$baseSetup" > $out/base-setup
ln -s ${testDriver}/bin/genode-test-driver $out/bin/
wrapProgram $out/bin/genode-test-driver \
--run "export testConfig=\"$testConfig\"" \
--run "export testScript=\"\$(cat $out/test-script)\"" \
--run "export baseSetup=\"\$(cat $out/base-setup)\"" \
'';
passMeta = drv:
drv
// lib.optionalAttrs (t ? meta) { meta = (drv.meta or { }) // t.meta; };
test = passMeta (runTests driver);
in test // { inherit driver test; };
in {
callTest = path: args:
(import path ({
testEnv = {
inherit mkTest lib;
isLinux = true;
isNova = false;
};
pkgs = testPkgs;
2019-11-05 17:38:47 +01:00
inherit depot;
} // args));
}