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.
95 lines
2.6 KiB
95 lines
2.6 KiB
# SPDX-License-Identifier: CC0-1.0 |
|
|
|
{ testPkgs, hostPkgs, lib, depot }: |
|
|
|
let |
|
testDriver = with hostPkgs; |
|
stdenv.mkDerivation { |
|
name = "genode-test-driver"; |
|
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 { |
|
name = "linux-"+driver.testName; |
|
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' = with testPkgs.genode; { |
|
inherit testConfig; |
|
config = ./driver-config.xml; |
|
core = "${base-linux}/bin/core-linux"; |
|
init = "${os}/bin/init"; |
|
"ld.lib.so" = "${base-linux}/bin/ld-linux.lib.so"; |
|
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; |
|
inherit depot; |
|
} // args)); |
|
}
|
|
|