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:
parent
36f682ccd4
commit
d37bff8d16
|
@ -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
|
|
@ -37,7 +37,7 @@ let
|
||||||
defaultScript = ''run_genode_until {child "init" exited with exit value 0} 60'';
|
defaultScript = ''run_genode_until {child "init" exited with exit value 0} 60'';
|
||||||
|
|
||||||
mkTest = { name ? "unamed", testScript ? defaultScript, testConfig, testInputs ? [ ]
|
mkTest = { name ? "unamed", testScript ? defaultScript, testConfig, testInputs ? [ ]
|
||||||
, env ? { }, qemuMem ? 32, ... # TODO: remove ...
|
, env ? { }, ... # TODO: remove ...
|
||||||
}@t:
|
}@t:
|
||||||
let
|
let
|
||||||
manifest = lib.mergeManifests (with testPkgs;
|
manifest = lib.mergeManifests (with testPkgs;
|
||||||
|
@ -89,10 +89,11 @@ let
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
global env
|
||||||
global spawn_id
|
global spawn_id
|
||||||
spawn ${hostPkgs.qemu_test}/bin/qemu-system-x86_64 \
|
spawn ${hostPkgs.qemu_test}/bin/qemu-system-x86_64 \
|
||||||
-machine q35 -serial mon:stdio -nographic \
|
-machine q35 -serial mon:stdio -nographic \
|
||||||
-m size=${toString qemuMem} \
|
-m size=[expr ($env(TEST_RAM) / 1048576) + 16] \
|
||||||
-kernel "${testPkgs.bender}" \
|
-kernel "${testPkgs.bender}" \
|
||||||
-initrd "${image}"
|
-initrd "${image}"
|
||||||
wait_for_output $wait_for_re $timeout_value $spawn_id
|
wait_for_output $wait_for_re $timeout_value $spawn_id
|
||||||
|
@ -109,14 +110,18 @@ let
|
||||||
inherit baseSetup testConfig testScript;
|
inherit baseSetup testConfig testScript;
|
||||||
preferLocalBuild = true;
|
preferLocalBuild = true;
|
||||||
testName = name;
|
testName = name;
|
||||||
|
DHALL_GENODE = "${testPkgs.dhallGenode}/package.dhall";
|
||||||
|
MANIFEST = manifest;
|
||||||
} ''
|
} ''
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
echo "$testScript" > $out/test-script
|
echo "$testScript" > $out/test-script
|
||||||
echo "$baseSetup" > $out/base-setup
|
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/
|
ln -s ${testDriver}/bin/genode-test-driver $out/bin/
|
||||||
wrapProgram $out/bin/genode-test-driver \
|
wrapProgram $out/bin/genode-test-driver \
|
||||||
--run "export testScript=\"\$(cat $out/test-script)\"" \
|
--set testScript "$testScript" \
|
||||||
--run "export baseSetup=\"\$(cat $out/base-setup)\"" \
|
--set baseSetup "$baseSetup" \
|
||||||
|
--set TEST_RAM $TEST_RAM \
|
||||||
'';
|
'';
|
||||||
|
|
||||||
passMeta = drv:
|
passMeta = drv:
|
||||||
|
|
|
@ -37,7 +37,7 @@ let
|
||||||
defaultScript = ''run_genode_until {child "init" exited with exit value 0} 60'';
|
defaultScript = ''run_genode_until {child "init" exited with exit value 0} 60'';
|
||||||
|
|
||||||
mkTest = { name ? "unamed", testScript ? defaultScript, testConfig, testInputs ? [ ]
|
mkTest = { name ? "unamed", testScript ? defaultScript, testConfig, testInputs ? [ ]
|
||||||
, env ? { }, qemuMem ? 32, ... # TODO: remove ...
|
, env ? { }, ... # TODO: remove ...
|
||||||
}@t:
|
}@t:
|
||||||
let
|
let
|
||||||
manifest = lib.mergeManifests (with testPkgs;
|
manifest = lib.mergeManifests (with testPkgs;
|
||||||
|
@ -89,10 +89,11 @@ let
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
global env
|
||||||
global spawn_id
|
global spawn_id
|
||||||
spawn ${hostPkgs.qemu_test}/bin/qemu-system-x86_64 \
|
spawn ${hostPkgs.qemu_test}/bin/qemu-system-x86_64 \
|
||||||
-machine q35 -serial mon:stdio -nographic \
|
-machine q35 -serial mon:stdio -nographic \
|
||||||
-m size=${toString qemuMem} \
|
-m size=[expr ($env(TEST_RAM) / 1048576) + 16] \
|
||||||
-kernel "${testPkgs.bender}" \
|
-kernel "${testPkgs.bender}" \
|
||||||
-initrd "${testPkgs.NOVA}/hypervisor-x86_64 arg=iommu novpid serial,${image}"
|
-initrd "${testPkgs.NOVA}/hypervisor-x86_64 arg=iommu novpid serial,${image}"
|
||||||
wait_for_output $wait_for_re $timeout_value $spawn_id
|
wait_for_output $wait_for_re $timeout_value $spawn_id
|
||||||
|
@ -109,14 +110,18 @@ let
|
||||||
inherit baseSetup testConfig testScript;
|
inherit baseSetup testConfig testScript;
|
||||||
preferLocalBuild = true;
|
preferLocalBuild = true;
|
||||||
testName = name;
|
testName = name;
|
||||||
|
DHALL_GENODE = "${testPkgs.dhallGenode}/package.dhall";
|
||||||
|
MANIFEST = manifest;
|
||||||
} ''
|
} ''
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
echo "$testScript" > $out/test-script
|
echo "$testScript" > $out/test-script
|
||||||
echo "$baseSetup" > $out/base-setup
|
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/
|
ln -s ${testDriver}/bin/genode-test-driver $out/bin/
|
||||||
wrapProgram $out/bin/genode-test-driver \
|
wrapProgram $out/bin/genode-test-driver \
|
||||||
--run "export testScript=\"\$(cat $out/test-script)\"" \
|
--set testScript "$testScript" \
|
||||||
--run "export baseSetup=\"\$(cat $out/base-setup)\"" \
|
--set baseSetup "$baseSetup" \
|
||||||
|
--set TEST_RAM $TEST_RAM \
|
||||||
'';
|
'';
|
||||||
|
|
||||||
passMeta = drv:
|
passMeta = drv:
|
||||||
|
|
|
@ -13,6 +13,5 @@ testEnv.mkTest rec {
|
||||||
noux
|
noux
|
||||||
posix
|
posix
|
||||||
];
|
];
|
||||||
qemuMem = 64;
|
|
||||||
meta.maintainers = with pkgs.stdenv.lib.maintainers; [ ehmry ];
|
meta.maintainers = with pkgs.stdenv.lib.maintainers; [ ehmry ];
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,6 @@ let
|
||||||
testScript = ''
|
testScript = ''
|
||||||
run_genode_until {child "init" exited with exit value 0} 30
|
run_genode_until {child "init" exited with exit value 0} 30
|
||||||
'';
|
'';
|
||||||
qemuMem = 64;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -62,7 +61,6 @@ let
|
||||||
testScript = ''
|
testScript = ''
|
||||||
run_genode_until {child "init" exited with exit value 0} 30
|
run_genode_until {child "init" exited with exit value 0} 30
|
||||||
'';
|
'';
|
||||||
qemuMem = 64;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue