2
0
Fork 0
Genode Packages collection https://git.sr.ht/~ehmry/genodepkgs/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
genodepkgs/tests/driver-linux.nix

85 lines
2.4 KiB

# SPDX-FileCopyrightText: Emery Hemingway
#
# SPDX-License-Identifier: LicenseRef-Hippocratic-1.1
{ testPkgs, hostPkgs, lib }:
let
testDriver = with hostPkgs;
stdenv.mkDerivation {
name = "genode-test-driver";
buildInputs = [ makeWrapper expect ];
dontUnpack = true;
preferLocalBuild = 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 {
name = "test-run-${driver.testName}";
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
'';
};
makeTest = { testScript, testConfig, name ? "unamed", ... }@t:
let
baseSetup = with testPkgs; ''
source ${./common-test-driver.exp}
file link -s core ${depot.base-linux}/bin/core
file link -s timer ${genode.base-linux}/bin/linux_timer_drv
file link -s ld.lib.so ${depot.base-linux}/lib/ld.lib.so
file link -s init ${genode.os}/bin/init
file link -s config ${./driver-config.xml}
file link -s test.config $env(testConfig)
'';
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:
makeTest (import path ({
pkgs = testPkgs;
inherit lib;
} // args));
}