2
0
Fork 0

Derive QEMU memory for tests from init configuration

Boot QEMU tests with the minimum required memory. This value can be
derived from the test configuration rather than set manually.
This commit is contained in:
Emery Hemingway 2020-02-19 13:25:36 +01:00
parent 36f682ccd4
commit d37bff8d16
5 changed files with 27 additions and 11 deletions

9
tests/boot-ram.dhall Normal file
View File

@ -0,0 +1,9 @@
-- SPDX-License-Identifier: CC0-1.0
let Genode = env:DHALL_GENODE
let sumRam =
λ(boot : Genode.Boot.Type)
→ let sum = Genode.Init.sumResources boot.config in sum.ram
in sumRam

View File

@ -37,7 +37,7 @@ let
defaultScript = ''run_genode_until {child "init" exited with exit value 0} 60'';
mkTest = { name ? "unamed", testScript ? defaultScript, testConfig, testInputs ? [ ]
, env ? { }, qemuMem ? 32, ... # TODO: remove ...
, env ? { }, ... # TODO: remove ...
}@t:
let
manifest = lib.mergeManifests (with testPkgs;
@ -89,10 +89,11 @@ let
return
}
global env
global spawn_id
spawn ${hostPkgs.qemu_test}/bin/qemu-system-x86_64 \
-machine q35 -serial mon:stdio -nographic \
-m size=${toString qemuMem} \
-m size=[expr ($env(TEST_RAM) / 1048576) + 16] \
-kernel "${testPkgs.bender}" \
-initrd "${image}"
wait_for_output $wait_for_re $timeout_value $spawn_id
@ -109,14 +110,18 @@ let
inherit baseSetup testConfig testScript;
preferLocalBuild = true;
testName = name;
DHALL_GENODE = "${testPkgs.dhallGenode}/package.dhall";
MANIFEST = manifest;
} ''
mkdir -p $out/bin
echo "$testScript" > $out/test-script
echo "$baseSetup" > $out/base-setup
eval $(${apps.dhall-to-bash.program} --declare "TEST_RAM" <<< "${./boot-ram.dhall} ${testConfig}")
ln -s ${testDriver}/bin/genode-test-driver $out/bin/
wrapProgram $out/bin/genode-test-driver \
--run "export testScript=\"\$(cat $out/test-script)\"" \
--run "export baseSetup=\"\$(cat $out/base-setup)\"" \
--set testScript "$testScript" \
--set baseSetup "$baseSetup" \
--set TEST_RAM $TEST_RAM \
'';
passMeta = drv:

View File

@ -37,7 +37,7 @@ let
defaultScript = ''run_genode_until {child "init" exited with exit value 0} 60'';
mkTest = { name ? "unamed", testScript ? defaultScript, testConfig, testInputs ? [ ]
, env ? { }, qemuMem ? 32, ... # TODO: remove ...
, env ? { }, ... # TODO: remove ...
}@t:
let
manifest = lib.mergeManifests (with testPkgs;
@ -89,10 +89,11 @@ let
return
}
global env
global spawn_id
spawn ${hostPkgs.qemu_test}/bin/qemu-system-x86_64 \
-machine q35 -serial mon:stdio -nographic \
-m size=${toString qemuMem} \
-m size=[expr ($env(TEST_RAM) / 1048576) + 16] \
-kernel "${testPkgs.bender}" \
-initrd "${testPkgs.NOVA}/hypervisor-x86_64 arg=iommu novpid serial,${image}"
wait_for_output $wait_for_re $timeout_value $spawn_id
@ -109,14 +110,18 @@ let
inherit baseSetup testConfig testScript;
preferLocalBuild = true;
testName = name;
DHALL_GENODE = "${testPkgs.dhallGenode}/package.dhall";
MANIFEST = manifest;
} ''
mkdir -p $out/bin
echo "$testScript" > $out/test-script
echo "$baseSetup" > $out/base-setup
eval $(${apps.dhall-to-bash.program} --declare "TEST_RAM" <<< "${./boot-ram.dhall} ${testConfig}")
ln -s ${testDriver}/bin/genode-test-driver $out/bin/
wrapProgram $out/bin/genode-test-driver \
--run "export testScript=\"\$(cat $out/test-script)\"" \
--run "export baseSetup=\"\$(cat $out/base-setup)\"" \
--set testScript "$testScript" \
--set baseSetup "$baseSetup" \
--set TEST_RAM $TEST_RAM \
'';
passMeta = drv:

View File

@ -13,6 +13,5 @@ testEnv.mkTest rec {
noux
posix
];
qemuMem = 64;
meta.maintainers = with pkgs.stdenv.lib.maintainers; [ ehmry ];
}

View File

@ -53,7 +53,6 @@ let
testScript = ''
run_genode_until {child "init" exited with exit value 0} 30
'';
qemuMem = 64;
}
{
@ -62,7 +61,6 @@ let
testScript = ''
run_genode_until {child "init" exited with exit value 0} 30
'';
qemuMem = 64;
}
{