From f8ba49f816122ce5f615ea3ded1d447a73c5bc5c Mon Sep 17 00:00:00 2001 From: Christian Prochaska Date: Thu, 25 Aug 2016 19:18:23 +0200 Subject: [PATCH] cpu_sampler_noux.run script A run script to demonstrate the combination of the cpu_sampler, fs_log, ram_fs and noux components for saving the sampled data in files and accessing these in a Noux environment. When the script is run by the autopilot, it will check if one of the generated sample data files contains the correct instruction pointer. When the script is run interactively, the generated files can be accessed from a Noux Bash shell. Fixes #2078 --- repos/gems/run/cpu_sampler_noux.run | 270 ++++++++++++++++++++++++++++ tool/autopilot.list | 1 + 2 files changed, 271 insertions(+) create mode 100644 repos/gems/run/cpu_sampler_noux.run diff --git a/repos/gems/run/cpu_sampler_noux.run b/repos/gems/run/cpu_sampler_noux.run new file mode 100644 index 0000000000..160f74361c --- /dev/null +++ b/repos/gems/run/cpu_sampler_noux.run @@ -0,0 +1,270 @@ +if { ![have_spec foc] && ![have_spec nova] && + ![have_spec okl4] && ![have_spec sel4] } { + puts "Run script is not supported on this platform" + exit 0 +} + +# +# On OMAP4 where no PS/2 is available, we rely on USB HID +# +proc use_usb_input { } { return [expr ![have_spec ps2] && [have_spec usb]] } + +set build_components { + core init drivers/timer noux/minimal lib/libc_noux + drivers/framebuffer drivers/input + server/terminal server/ram_fs + server/log_terminal + test/libports/ncurses + server/fs_log + server/cpu_sampler + test/cpu_sampler +} + +lappend_if [use_usb_input] build_components drivers/usb +lappend_if [have_spec gpio] build_components drivers/gpio + +# +# Build Noux packages only once +# +foreach pkg {bash coreutils vim diffutils} { + lappend_if [expr ![file exists bin/$pkg]] build_components noux-pkg/$pkg } + +source ${genode_dir}/repos/base/run/platform_drv.inc +append_platform_drv_build_components + +build $build_components + +# write default vimrc file +set vimrc_fd [open "bin/vim/share/vim/vimrc" w] +puts $vimrc_fd { +set noloadplugins +set hls +set nocompatible +set laststatus=2 +set noswapfile +set viminfo=} +close $vimrc_fd + +# strip all binaries prior archiving +exec sh -c "find bin/bash/ bin/vim/ bin/coreutils/ -type f | (xargs [cross_dev_prefix]strip || true) 2>/dev/null" + +exec tar cfv bin/bash.tar -h -C bin/bash . +exec tar cfv bin/coreutils.tar -h -C bin/coreutils . +exec tar cfv bin/vim.tar -h -C bin/vim . +exec tar cfv bin/diffutils.tar -h -C bin/diffutils . + +create_boot_directory + +append config { + + + + + + + + + + + + + + + + + + + } + +append_platform_drv_config + +append_if [expr [have_spec framebuffer] && ![get_cmd_switch --autopilot]] config { + + + + } + +append_if [have_spec ps2] config { + + + + } + +append_if [have_spec gpio] config { + + + + + } + +append_if [use_usb_input] config { + + + + + } + +append_if [get_cmd_switch --autopilot] config { + + + + + } + +append_if [expr ![get_cmd_switch --autopilot]] config { + + + + + + + + } + +append config { + + + + + + + } +append_if [get_cmd_switch --autopilot] config { + FILE=/samples/cpu_sampler/samples/init/test-cpu_sampler/ep.*.log + while true; do if [ -e $FILE ]; then cat $FILE; fi; done } +append_if [expr ![get_cmd_switch --autopilot]] config { + echo "The sample data will appear in the /samples directory" } +append config { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +} + +install_config $config + + +# +# Boot modules +# + +# generic modules +set boot_modules { + core init timer ld.lib.so noux terminal ram_fs log_terminal + libc.lib.so libm.lib.so libc_noux.lib.so ncurses.lib.so + bash.tar coreutils.tar diffutils.tar vim.tar + fs_log cpu_sampler test-cpu_sampler +} + +# platform-specific modules +lappend_if [have_spec ps2] boot_modules ps2_drv +lappend_if [have_spec framebuffer] boot_modules fb_drv +lappend_if [use_usb_input] boot_modules usb_drv +lappend_if [have_spec gpio] boot_modules gpio_drv + +append_platform_drv_boot_modules + +build_boot_image $boot_modules + +if {[have_spec x86_64]} { + # bash.tar is really huge when built for x86_64 + append qemu_args " -m 320 " +} else { + append qemu_args " -m 256 " +} + +if { ![get_cmd_switch --autopilot] } { run_genode_until forever } + +# autopilot test + +append qemu_args " -nographic " + +set match_string "Test started. func: 0x(\[0-9a-f\]+).*\n" + +run_genode_until "$match_string" 120 + +regexp $match_string $output all func + +run_genode_until "\\\[init -> terminal] \[0\]*$func" 60 [output_spawn_id] + +exec rm bin/bash.tar diff --git a/tool/autopilot.list b/tool/autopilot.list index 472044a5cb..511293e22e 100644 --- a/tool/autopilot.list +++ b/tool/autopilot.list @@ -69,3 +69,4 @@ fpu ds_ownership fs_log cpu_sampler +cpu_sampler_noux