mirror of
https://github.com/genodelabs/genode.git
synced 2025-03-13 15:56:32 +00:00
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:
parent
b3bc9bd549
commit
0ab5310b8a
8
repos/base-hw/lib/import/import-core.mk
Normal file
8
repos/base-hw/lib/import/import-core.mk
Normal 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
|
@ -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
|
global run_target
|
||||||
|
|
||||||
# strip binaries
|
# strip binaries
|
||||||
@ -94,7 +105,7 @@ proc build_boot_image {binaries} {
|
|||||||
# generate header for each boot module except core
|
# generate header for each boot module except core
|
||||||
set i 1
|
set i 1
|
||||||
foreach binary $binaries {
|
foreach binary $binaries {
|
||||||
if {$binary == "core"} { continue }
|
if {$binary == $core_bin} { continue }
|
||||||
exec echo -e \
|
exec echo -e \
|
||||||
"\n.long _boot_module_${i}_name" \
|
"\n.long _boot_module_${i}_name" \
|
||||||
"\n.long _boot_module_${i}_begin" \
|
"\n.long _boot_module_${i}_begin" \
|
||||||
@ -111,7 +122,7 @@ proc build_boot_image {binaries} {
|
|||||||
# generate name string for each module except core
|
# generate name string for each module except core
|
||||||
set i 1
|
set i 1
|
||||||
foreach binary $binaries {
|
foreach binary $binaries {
|
||||||
if {$binary == "core"} { continue }
|
if {$binary == $core_bin} { continue }
|
||||||
exec echo -e \
|
exec echo -e \
|
||||||
"\n.p2align DATA_ACCESS_ALIGNM_LOG2" \
|
"\n.p2align DATA_ACCESS_ALIGNM_LOG2" \
|
||||||
"\n_boot_module_${i}_name:" \
|
"\n_boot_module_${i}_name:" \
|
||||||
@ -129,7 +140,7 @@ proc build_boot_image {binaries} {
|
|||||||
# include raw data of modules consecutively but page aligned
|
# include raw data of modules consecutively but page aligned
|
||||||
set i 1
|
set i 1
|
||||||
foreach binary $binaries {
|
foreach binary $binaries {
|
||||||
if {$binary == "core"} { continue }
|
if {$binary == $core_bin} { continue }
|
||||||
exec echo -e \
|
exec echo -e \
|
||||||
"\n.p2align MIN_PAGE_SIZE_LOG2" \
|
"\n.p2align MIN_PAGE_SIZE_LOG2" \
|
||||||
"\n_boot_module_${i}_begin:" \
|
"\n_boot_module_${i}_begin:" \
|
||||||
@ -147,10 +158,10 @@ proc build_boot_image {binaries} {
|
|||||||
exec ln -s $boot_modules boot_modules.s
|
exec ln -s $boot_modules boot_modules.s
|
||||||
|
|
||||||
# recompile core with boot modules
|
# recompile core with boot modules
|
||||||
exec cp -L bin/core core/core.standalone
|
exec cp -L bin/$core_bin $core_target/$core_bin.standalone
|
||||||
exec find . -type f -name "core" -delete
|
exec find . -type f -name $core_bin -delete
|
||||||
set timeout 10000
|
set timeout 10000
|
||||||
set pid [eval "spawn make core"]
|
set pid [eval "spawn make $core_target"]
|
||||||
expect { eof { } }
|
expect { eof { } }
|
||||||
if {[lindex [wait $pid] end] != 0} {
|
if {[lindex [wait $pid] end] != 0} {
|
||||||
clean_boot_modules
|
clean_boot_modules
|
||||||
@ -162,7 +173,7 @@ proc build_boot_image {binaries} {
|
|||||||
|
|
||||||
# offer ELF image
|
# offer ELF image
|
||||||
set elf_img "[run_dir]/image.elf"
|
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
|
exec [cross_dev_prefix]strip $elf_img
|
||||||
|
|
||||||
build_uboot_image $elf_img
|
build_uboot_image $elf_img
|
||||||
@ -178,8 +189,8 @@ proc build_boot_image {binaries} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# retrieve stand-alone core
|
# retrieve stand-alone core
|
||||||
exec cp core/core.standalone bin/core
|
exec cp $core_target/$core_bin.standalone bin/$core_bin
|
||||||
exec rm core/core.standalone
|
exec rm $core_target/$core_bin.standalone
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -73,6 +73,11 @@ namespace Kernel
|
|||||||
Signal_context_pool * signal_context_pool() { return unmanaged_singleton<Signal_context_pool>(); }
|
Signal_context_pool * signal_context_pool() { return unmanaged_singleton<Signal_context_pool>(); }
|
||||||
Signal_receiver_pool * signal_receiver_pool() { return unmanaged_singleton<Signal_receiver_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
|
* Static kernel PD that describes core
|
||||||
*/
|
*/
|
||||||
@ -320,6 +325,7 @@ extern "C" void init_kernel_multiprocessor()
|
|||||||
}
|
}
|
||||||
/* kernel initialization finished */
|
/* kernel initialization finished */
|
||||||
Genode::printf("kernel initialized\n");
|
Genode::printf("kernel initialized\n");
|
||||||
|
test();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
7
repos/base-hw/src/core/kernel/test.cc
Normal file
7
repos/base-hw/src/core/kernel/test.cc
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
/*
|
||||||
|
* \brief Dummy implementation of kernel-internal test
|
||||||
|
* \author Martin Stein
|
||||||
|
* \date 2014-09-30
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Kernel { void test() { } }
|
@ -10,5 +10,5 @@ TARGET = core
|
|||||||
# library that provides the whole configuration
|
# library that provides the whole configuration
|
||||||
LIBS += core
|
LIBS += core
|
||||||
|
|
||||||
# add empty source to trigger build though all config is provided via lib
|
# add C++ sources
|
||||||
SRC_CC += dummy.cc
|
SRC_CC += kernel/test.cc
|
||||||
|
Loading…
x
Reference in New Issue
Block a user