Build QEMU script with ISO
This commit is contained in:
parent
410a6522c5
commit
20594a9962
|
@ -38,17 +38,24 @@ in {
|
|||
|
||||
x86_64-genode.buildNovaIso = { name, rom }:
|
||||
let
|
||||
|
||||
inherit (hostPkgs) cdrkit syslinux;
|
||||
coreNovaObj = "${testPkgs.genode-base-nova}/lib/core-nova.o";
|
||||
|
||||
addressType = ".quad"; # TODO: 32 or 64 bit?!
|
||||
rom' = (with testPkgs; {
|
||||
init = "${genode-os}/bin/init";
|
||||
"ld.lib.so" = "${depot.base-nova}/lib/ld.lib.so";
|
||||
timer = "${genode-base-nova}/bin/nova_timer_drv";
|
||||
}) // rom;
|
||||
|
||||
addressType = ".quad"; # TODO: 32bit?!
|
||||
|
||||
map' = with nixpkgs.lib;
|
||||
l: f:
|
||||
concatStrings (imap0 (i: v: (f (toString i) v)) l);
|
||||
|
||||
mapNames = map' (builtins.attrNames rom);
|
||||
mapValues = map' (builtins.attrValues rom);
|
||||
mapNames = map' (builtins.attrNames rom');
|
||||
mapValues = map' (builtins.attrValues rom');
|
||||
|
||||
modulesAsm = ''
|
||||
.set MIN_PAGE_SIZE_LOG2, 12
|
||||
|
@ -96,27 +103,29 @@ in {
|
|||
syslinuxDir = "${syslinux}/share/syslinux";
|
||||
|
||||
in hostPkgs.stdenv.mkDerivation {
|
||||
name = name + ".iso";
|
||||
preferLocalBuild = true;
|
||||
buildInputs = [ testPkgs.stdenv.cc hostPkgs.cdrkit ];
|
||||
dontUnpack = true;
|
||||
dontConfigure = true;
|
||||
dontBuild = true;
|
||||
name = name + "-iso";
|
||||
passthru = rom;
|
||||
passAsFile = [ "modulesAsm" ];
|
||||
inherit modulesAsm;
|
||||
installPhase = ''
|
||||
preferLocalBuild = true;
|
||||
dontUnpack = true;
|
||||
|
||||
buildInputs = [ testPkgs.stdenv.cc hostPkgs.cdrkit ];
|
||||
|
||||
buildPhase = ''
|
||||
mkdir -p boot/syslinux
|
||||
|
||||
# compile the boot modules into one object file
|
||||
$CC -c -x assembler -o boot_modules.o - <<< $modulesAsm
|
||||
$CC -c -x assembler -o boot_modules.o $modulesAsmPath
|
||||
|
||||
# link final image
|
||||
$LD -nostdlib \
|
||||
-T${./genode.ld} \
|
||||
-T${./nova-bss.ld} \
|
||||
-z max-page-size=0x1000 \
|
||||
-Ttext=0x100000 -gc-sections \
|
||||
${coreNovaObj} boot_modules.o \
|
||||
-o boot/image.elf
|
||||
-T${./genode.ld} \
|
||||
-T${./nova-bss.ld} \
|
||||
-z max-page-size=0x1000 \
|
||||
-Ttext=0x100000 -gc-sections \
|
||||
${coreNovaObj} boot_modules.o \
|
||||
-o boot/image.elf
|
||||
|
||||
strip boot/image.elf
|
||||
|
||||
|
@ -130,11 +139,22 @@ in {
|
|||
${syslinuxDir}/mboot.c32 \
|
||||
boot/syslinux
|
||||
chmod +w boot/syslinux/isolinux.bin
|
||||
mkisofs -o $out \
|
||||
-b syslinux/isolinux.bin -c syslinux/boot.cat \
|
||||
-no-emul-boot -boot-load-size 4 -boot-info-table \
|
||||
-iso-level 2 \
|
||||
boot
|
||||
mkisofs -o iso \
|
||||
-b syslinux/isolinux.bin -c syslinux/boot.cat \
|
||||
-no-emul-boot -boot-load-size 4 -boot-info-table \
|
||||
-iso-level 2 \
|
||||
boot
|
||||
|
||||
# build test script
|
||||
cat > boot-qemu << EOF
|
||||
#!/bin/sh
|
||||
${hostPkgs.qemu_test}/bin/qemu-system-x86_64 -cdrom $out/iso -machine q35 \$@
|
||||
EOF
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
install -Dm444 iso $out/iso
|
||||
install -Dm555 boot-qemu $out/bin/boot-qemu
|
||||
'';
|
||||
};
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ let
|
|||
|
||||
runTests = driver:
|
||||
hostPkgs.stdenv.mkDerivation {
|
||||
name = "nova-"+driver.testName;
|
||||
name = "nova-" + driver.testName;
|
||||
preferLocalBuild = true;
|
||||
|
||||
buildCommand = ''
|
||||
|
@ -43,9 +43,6 @@ let
|
|||
{
|
||||
inherit testConfig;
|
||||
config = ./driver-config.xml;
|
||||
init = "${genode-os}/bin/init";
|
||||
"ld.lib.so" = "${depot.base-nova}/lib/ld.lib.so";
|
||||
timer = "${genode-base-nova}/bin/nova_timer_drv";
|
||||
} // bootModules);
|
||||
|
||||
iso = lib.x86_64-genode.buildNovaIso {
|
||||
|
@ -58,52 +55,50 @@ let
|
|||
# Wait for a specific output of a already running spawned proce
|
||||
#
|
||||
proc wait_for_output { wait_for_re timeout_value running_spawn_id } {
|
||||
global output
|
||||
global output
|
||||
|
||||
if {$wait_for_re == "forever"} {
|
||||
set timeout -1
|
||||
interact {
|
||||
\003 {
|
||||
send_user "Expect: 'interact' received 'strg+c' and was cancelled\n";
|
||||
exit
|
||||
}
|
||||
-i $running_spawn_id
|
||||
}
|
||||
} else {
|
||||
set timeout $timeout_value
|
||||
}
|
||||
if {$wait_for_re == "forever"} {
|
||||
set timeout -1
|
||||
interact {
|
||||
\003 {
|
||||
send_user "Expect: 'interact' received 'strg+c' and was cancelled\n";
|
||||
exit
|
||||
}
|
||||
-i $running_spawn_id
|
||||
}
|
||||
} else {
|
||||
set timeout $timeout_value
|
||||
}
|
||||
|
||||
expect {
|
||||
-i $running_spawn_id -re $wait_for_re { }
|
||||
eof { puts stderr "Error: Spawned process died unexpectedly"; exit -1 }
|
||||
timeout { puts stderr "Error: Test execution timed out"; exit -1 }
|
||||
}
|
||||
set output $expect_out(buffer)
|
||||
expect {
|
||||
-i $running_spawn_id -re $wait_for_re { }
|
||||
eof { puts stderr "Error: Spawned process died unexpectedly"; exit -1 }
|
||||
timeout { puts stderr "Error: Test execution timed out"; exit -1 }
|
||||
}
|
||||
set output $expect_out(buffer)
|
||||
}
|
||||
|
||||
|
||||
proc run_genode_until {{wait_for_re forever} {timeout_value 0} {running_spawn_id -1}} {
|
||||
#
|
||||
# If a running_spawn_id is specified, wait for the expected output
|
||||
#
|
||||
if {$running_spawn_id != -1} {
|
||||
wait_for_output $wait_for_re $timeout_value $running_spawn_id
|
||||
return
|
||||
}
|
||||
#
|
||||
# If a running_spawn_id is specified, wait for the expected output
|
||||
#
|
||||
if {$running_spawn_id != -1} {
|
||||
wait_for_output $wait_for_re $timeout_value $running_spawn_id
|
||||
return
|
||||
}
|
||||
|
||||
global spawn_id
|
||||
spawn ${hostPkgs.qemu_test}/bin/qemu-system-x86_64 -cdrom ${iso} -nographic \
|
||||
-machine q35 -m size=${toString qemuMem}
|
||||
wait_for_output $wait_for_re $timeout_value $spawn_id
|
||||
global spawn_id
|
||||
spawn ${iso}/bin/boot-qemu -nographic -m size=${toString qemuMem}
|
||||
wait_for_output $wait_for_re $timeout_value $spawn_id
|
||||
}
|
||||
|
||||
# TODO: not in TCL
|
||||
global env
|
||||
set out $env(out)
|
||||
# TODO: not in TCL
|
||||
global env
|
||||
set out $env(out)
|
||||
|
||||
set fd [open "$out/nix-support/hydra-build-products" w]
|
||||
puts $fd "file iso ${iso}"
|
||||
close $fd
|
||||
set fd [open "$out/nix-support/hydra-build-products" w]
|
||||
puts $fd "file iso ${iso}"
|
||||
close $fd
|
||||
'';
|
||||
|
||||
driver = with hostPkgs;
|
||||
|
|
Loading…
Reference in New Issue