hw: enable kernel-internal tests via run tool

Kernel tests are done by replacing the implementation of an otherwise
empty function 'Kernel::test' that gets called once at the primary CPU
as soon as all kernel initialization is done. To achieve this, the test
binary that implements 'Kernel::test' must be linked against the core
lib and must then replace the core binary when composing the boot image.
The latter can be done conveniently in a run script by setting the new
argument 'core_type' of the function 'build_boot_image' to the falue
'test'. If no kernel test is needed the argument does not have to be
given - it is set to 'core' by default which results in a "normal"
Genode image.

ref #1225
This commit is contained in:
Martin Stein 2014-10-08 21:26:56 +02:00 committed by Christian Helmuth
parent b3bc9bd549
commit 0ab5310b8a
6 changed files with 44 additions and 12 deletions

View File

@ -0,0 +1,8 @@
#
# \brief Automatically included by targets that depend on the core lib
# \author Martin Stein
# \date 2011-12-16
#
# add include paths
INC_DIR += $(REP_DIR)/src/core/include

View File

@ -52,7 +52,18 @@ proc create_boot_directory { } {
}
proc build_boot_image {binaries} {
proc build_boot_image {binaries {core_type core}} {
if {$core_type == "test"} {
set core_bin "test-[run_name]"
set core_target "test/[run_name]"
} elseif {$core_type == "core"} {
set core_bin "core"
set core_target "core"
} else {
puts stderr "Error: Unknown core type '$core_type'"
exit -1
}
global run_target
# strip binaries
@ -94,7 +105,7 @@ proc build_boot_image {binaries} {
# generate header for each boot module except core
set i 1
foreach binary $binaries {
if {$binary == "core"} { continue }
if {$binary == $core_bin} { continue }
exec echo -e \
"\n.long _boot_module_${i}_name" \
"\n.long _boot_module_${i}_begin" \
@ -111,7 +122,7 @@ proc build_boot_image {binaries} {
# generate name string for each module except core
set i 1
foreach binary $binaries {
if {$binary == "core"} { continue }
if {$binary == $core_bin} { continue }
exec echo -e \
"\n.p2align DATA_ACCESS_ALIGNM_LOG2" \
"\n_boot_module_${i}_name:" \
@ -129,7 +140,7 @@ proc build_boot_image {binaries} {
# include raw data of modules consecutively but page aligned
set i 1
foreach binary $binaries {
if {$binary == "core"} { continue }
if {$binary == $core_bin} { continue }
exec echo -e \
"\n.p2align MIN_PAGE_SIZE_LOG2" \
"\n_boot_module_${i}_begin:" \
@ -147,10 +158,10 @@ proc build_boot_image {binaries} {
exec ln -s $boot_modules boot_modules.s
# recompile core with boot modules
exec cp -L bin/core core/core.standalone
exec find . -type f -name "core" -delete
exec cp -L bin/$core_bin $core_target/$core_bin.standalone
exec find . -type f -name $core_bin -delete
set timeout 10000
set pid [eval "spawn make core"]
set pid [eval "spawn make $core_target"]
expect { eof { } }
if {[lindex [wait $pid] end] != 0} {
clean_boot_modules
@ -162,7 +173,7 @@ proc build_boot_image {binaries} {
# offer ELF image
set elf_img "[run_dir]/image.elf"
exec cp -L bin/core $elf_img
exec cp -L bin/$core_bin $elf_img
exec [cross_dev_prefix]strip $elf_img
build_uboot_image $elf_img
@ -178,8 +189,8 @@ proc build_boot_image {binaries} {
}
# retrieve stand-alone core
exec cp core/core.standalone bin/core
exec rm core/core.standalone
exec cp $core_target/$core_bin.standalone bin/$core_bin
exec rm $core_target/$core_bin.standalone
}

View File

@ -73,6 +73,11 @@ namespace Kernel
Signal_context_pool * signal_context_pool() { return unmanaged_singleton<Signal_context_pool>(); }
Signal_receiver_pool * signal_receiver_pool() { return unmanaged_singleton<Signal_receiver_pool>(); }
/**
* Hook that enables automated testing of kernel internals
*/
void test();
/**
* Static kernel PD that describes core
*/
@ -320,6 +325,7 @@ extern "C" void init_kernel_multiprocessor()
}
/* kernel initialization finished */
Genode::printf("kernel initialized\n");
test();
}
}

View File

@ -0,0 +1,7 @@
/*
* \brief Dummy implementation of kernel-internal test
* \author Martin Stein
* \date 2014-09-30
*/
namespace Kernel { void test() { } }

View File

@ -10,5 +10,5 @@ TARGET = core
# library that provides the whole configuration
LIBS += core
# add empty source to trigger build though all config is provided via lib
SRC_CC += dummy.cc
# add C++ sources
SRC_CC += kernel/test.cc