From cf2742ffae0f4333eb3a69a768c8a3b7aa319c49 Mon Sep 17 00:00:00 2001 From: David Smith Date: Mon, 18 May 2009 13:05:01 -0500 Subject: PR10091 fixes. * runtime/itrace.c (usr_itrace_report_signal): Add a workaround for ppc-specific problem. * testsuite/systemtap.base/itrace.exp: Improved tests. Improved test completeness. Will also no longer give fails for systems that don't support single or block step (will give xfails instead). --- testsuite/systemtap.base/itrace.exp | 171 +++++++++++++++++++++++++++++------- 1 file changed, 141 insertions(+), 30 deletions(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/itrace.exp b/testsuite/systemtap.base/itrace.exp index 5da0dfaf..ddd1b07b 100644 --- a/testsuite/systemtap.base/itrace.exp +++ b/testsuite/systemtap.base/itrace.exp @@ -1,53 +1,55 @@ # itrace test - # Initialize variables set exepath "[pwd]/ls_[pid]" -set itrace1_script { +# Why check for 1000 instructions executed? We can't know the actual +# number to look for, so we just look for a reasonable number that +# should work for all platforms. + +set itrace_single1_script { global instrs = 0 probe begin { printf("systemtap starting probe\n") } probe process("%s").insn { instrs += 1 - if (instrs == 5) - exit() } - - - probe end { printf("systemtap ending probe\n") - printf("itraced = %%d\n", instrs) + probe end { + printf("systemtap ending probe\n") + if (instrs > 1000) { + printf("instrs > 1000 (%%d)\n", instrs) + } + else { + printf("instrs <= 1000 (%%d)\n", instrs) + } } } -set itrace1_script_output "itraced = 5\r\n" +set itrace_single1_script_output "instrs > 1000 \\(\[0-9\]\[0-9\]*\\)\r\n" -set itrace2_script { +set itrace_single2_script { global instrs = 0, itrace_on = 0, start_timer = 0 probe begin { start_timer = 1; printf("systemtap starting probe\n") } probe process("%s").insn if (itrace_on) { instrs += 1 if (instrs == 5) - exit() + exit() } - - probe timer.ms(1) if (start_timer) { itrace_on = 1 } - probe timer.ms(10) if (start_timer) { itrace_on = 0 } probe end { printf("systemtap ending probe\n") - printf("itraced = %%d\n", instrs) + printf("itraced = %%d\n", instrs) } } -set itrace2_script_output "itraced = 5\r\n" +set itrace_single2_script_output "itraced = 5\r\n" -set itrace3_script { +set itrace_block1_script { global branches = 0 probe begin { @@ -59,14 +61,80 @@ set itrace3_script { if (branches == 5) exit() } - - probe end { printf("systemtap ending probe\n") printf("itraced block mode = %%d\n", branches) } } -set itrace3_script_output "itraced block mode = 5\r\n" +set itrace_block1_script_output "itraced block mode = 5\r\n" + +set itrace_block2_script { + global instrs = 0, itrace_on = 0, start_timer = 0 + probe begin { start_timer = 1; printf("systemtap starting probe\n") } + probe process("%s").insn.block if (itrace_on) + { + instrs += 1 + if (instrs == 5) + exit() + } + probe timer.ms(1) if (start_timer) + { + itrace_on = 1 + } + probe timer.ms(10) if (start_timer) + { + itrace_on = 0 + } + probe end { printf("systemtap ending probe\n") + printf("itraced = %%d\n", instrs) + } +} +set itrace_block2_script_output "itraced = 5\r\n" + +set itrace_single_step_script { + %{ + #include "ptrace_compatibility.h" + %} + + function has_single_step() %{ + THIS->__retvalue = arch_has_single_step(); /* pure */ + %} + + probe begin { + printf("has_single_step: %d\n", has_single_step()) + exit() + } +} +set itrace_block_step_script { + %{ + #include "ptrace_compatibility.h" + %} + + function has_block_step() %{ + THIS->__retvalue = arch_has_block_step(); /* pure */ + %} + + probe begin { + printf("has_block_step: %d\n", has_block_step()) + exit() + } +} + +proc stap_check_feature { test_name script feature } { + set rc -1 + verbose -log "stap -g -e \"$script\"" + spawn stap -g -e "$script" + expect { + -timeout 60 + -re "^$feature: 0" { set rc 0; pass $test_name } + -re "^$feature: 1" { set rc 1; pass $test_name } + eof { fail "$test_name (eof)" } + timeout { fail "$test_name (timeout)" } + } + catch {close} + catch {wait} + return $rc +} # Set up our own copy of /bin/ls, to make testing for a particular # executable easy. We can't use 'ln' here, since we might be creating @@ -90,37 +158,80 @@ proc run_ls_5_sec {} { return 0; } +# figure out if this system supports single stepping (if we've got +# utrace and we're doing install testing) +set TEST_NAME "itrace single step check" +set single_step_p 0 +if {![utrace_p]} { + untested "$TEST_NAME : no kernel utrace support found" +} elseif {![installtest_p]} { + untested $TEST_NAME +} else { + set single_step_p [stap_check_feature $TEST_NAME \ + $itrace_single_step_script "has_single_step"] +} + +# figure out if this system supports block stepping (if we've got +# utrace and we're doing install testing) +set TEST_NAME "itrace block step check" +set block_step_p 0 +if {![utrace_p]} { + untested "$TEST_NAME : no kernel utrace support found" +} elseif {![installtest_p]} { + untested $TEST_NAME +} else { + set block_step_p [stap_check_feature $TEST_NAME \ + $itrace_block_step_script "has_block_step"] +} -set TEST_NAME "itrace1" +# Run the single step tests +set TEST_NAME "itrace_single1" if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } elseif {![installtest_p]} { untested $TEST_NAME +} elseif {$single_step_p != 1} { + xfail "$TEST_NAME : no kernel single step support" } else { - set script [format $itrace1_script $exepath] - stap_run $TEST_NAME run_ls_5_sec $itrace1_script_output -e $script + set script [format $itrace_single1_script $exepath] + stap_run $TEST_NAME run_ls_5_sec $itrace_single1_script_output -e $script } +set TEST_NAME "itrace_single2" +if {![utrace_p]} { + untested "$TEST_NAME : no kernel utrace support found" +} elseif {![installtest_p]} { + untested $TEST_NAME +} elseif {$single_step_p != 1} { + xfail "$TEST_NAME : no kernel single step support" +} else { + set script [format $itrace_single2_script $exepath] + stap_run $TEST_NAME run_ls_5_sec $itrace_single2_script_output -e $script +} -set TEST_NAME "itrace2" +# Run the block step tests +set TEST_NAME "itrace_block1" if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } elseif {![installtest_p]} { untested $TEST_NAME +} elseif {$block_step_p != 1} { + xfail "$TEST_NAME : no kernel block step support" } else { - set script [format $itrace2_script $exepath] - stap_run $TEST_NAME run_ls_5_sec $itrace2_script_output -e $script + set script [format $itrace_block1_script $exepath] + stap_run $TEST_NAME run_ls_5_sec $itrace_block1_script_output -e $script } -set TEST_NAME "itrace3" +set TEST_NAME "itrace_block2" if {![utrace_p]} { untested "$TEST_NAME : no kernel utrace support found" } elseif {![installtest_p]} { untested $TEST_NAME +} elseif {$block_step_p != 1} { + xfail "$TEST_NAME : no kernel block step support" } else { - send_log "ATTENTION: if arch_has_block_step is not defined for this arch, this testcase will fail\n" - set script [format $itrace3_script $exepath] - stap_run $TEST_NAME run_ls_5_sec $itrace3_script_output -e $script + set script [format $itrace_block2_script $exepath] + stap_run $TEST_NAME run_ls_5_sec $itrace_block2_script_output -e $script } # Cleanup -- cgit From 29e2616aeeb82605a6efe1dbc574b499781eafbe Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 20 May 2009 14:46:25 -0700 Subject: PR10177: init/kill time in sleepy context only Previously, _stp_init_time and _stp_kill_time were being called from begin/end/error probes, which will run with preemption disabled. The BUG reported on RT kernels showed that cpufreq_unregister_notifier can end up sleeping, which violates our preemption block. This patch moves the init/kill into systemtap_module_init/exit, where it is safe to sleep. The code maintains a new predicate with the define STAP_NEED_GETTIMEOFDAY, so we don't still incur any timer overhead if it's not used. --- testsuite/systemtap.base/gtod_init.exp | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 testsuite/systemtap.base/gtod_init.exp (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/gtod_init.exp b/testsuite/systemtap.base/gtod_init.exp deleted file mode 100644 index 48616b1f..00000000 --- a/testsuite/systemtap.base/gtod_init.exp +++ /dev/null @@ -1,29 +0,0 @@ -# test for checking initialization of the time subsystem -set test "gtod_init" - -# check that init and kill are both present with a gettimeofday -set time_init 0 -set time_kill 0 -spawn stap -p2 -e {probe begin { println(gettimeofday_s()) }} -expect { - -timeout 120 - -re {\n_gettimeofday_init:} { incr time_init; exp_continue } - -re {\n_gettimeofday_kill:} { incr time_kill; exp_continue } - timeout { fail "$test (timeout)" } - eof { - if {$time_init == 1} { pass "$test (init)" } { fail "$test (init $time_init)" } - if {$time_kill == 1} { pass "$test (kill)" } { fail "$test (kill $time_kill)" } - } -} -wait - -# check that init and kill are both NOT present without a gettimeofday -spawn stap -p2 -e {probe begin { println(get_cycles()) }} -expect { - -timeout 120 - -re {\n_gettimeofday_init:} { fail "$test (bad init)" } - -re {\n_gettimeofday_kill:} { fail "$test (bad kill)" } - timeout { fail "$test (timeout)" } - eof { pass "$test (no init/kill)" } -} -wait -- cgit From b350f56b13f4e5acd5744cd71e4b26343aae8e6b Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Fri, 22 May 2009 18:01:18 -0700 Subject: PR10190: Suppress warnings for optional kprobes When a kernel.function or kprobe.function fails in registration, we usually print a WARNING and move on. With this patch, kprobes that have the optional '?' flag will not print any WARNING. --- testsuite/systemtap.base/badkprobe.exp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/badkprobe.exp b/testsuite/systemtap.base/badkprobe.exp index c0815fbe..96ad5a3b 100644 --- a/testsuite/systemtap.base/badkprobe.exp +++ b/testsuite/systemtap.base/badkprobe.exp @@ -19,7 +19,20 @@ foreach bk $bad_kprobes { spawn stap -g -w -e "$script" "$bk" expect { -timeout 60 - -re "^WARNING: probe .*registration error.*\r\ncleanup ok" { pass $test } + -re "^WARNING: probe .*registration error.*\r\ncleanup ok\r\n" { pass $test } + eof { fail "$test (eof)" } + timeout { fail "$test (timeout)" } + } + catch {close} + catch {wait} +} + +foreach bk $bad_kprobes { + set test "bad optional kprobe registration: $bk" + spawn stap -g -w -e "$script" "$bk ?" + expect { + -timeout 60 + -re "^cleanup ok\r\n" { pass $test } eof { fail "$test (eof)" } timeout { fail "$test (timeout)" } } -- cgit From 4cef6bf2c2d86dd3558065784691061793979425 Mon Sep 17 00:00:00 2001 From: Ananth N Mavinakayanahalli Date: Thu, 28 May 2009 11:48:34 +0530 Subject: More testsuite tweaks to make it work with SYSCALL_WRAPPERS --- testsuite/systemtap.base/debugpath.exp | 4 ++-- testsuite/systemtap.base/poll_map.stp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/debugpath.exp b/testsuite/systemtap.base/debugpath.exp index b0f938b6..059b6b07 100644 --- a/testsuite/systemtap.base/debugpath.exp +++ b/testsuite/systemtap.base/debugpath.exp @@ -1,6 +1,6 @@ set test "debugpath-bad" -spawn env SYSTEMTAP_DEBUGINFO_PATH=/dev/null stap -e "probe kernel.function(\"sys_open\") {}" -wp4 +spawn env SYSTEMTAP_DEBUGINFO_PATH=/dev/null stap -e "probe kernel.function(\"vfs_read\") {}" -wp4 expect { -re {^semantic error:.*missing.*debuginfo} { pass $test } timeout { fail "$test (timeout1)" } @@ -21,7 +21,7 @@ if [file isdirectory /usr/lib/debug] { set debuginfo_path "/lib/modules/$uname" } -spawn env SYSTEMTAP_DEBUGINFO_PATH=$debuginfo_path stap -e "probe kernel.function(\"sys_open\") {}" -wp2 +spawn env SYSTEMTAP_DEBUGINFO_PATH=$debuginfo_path stap -e "probe kernel.function(\"vfs_read\") {}" -wp2 expect { -re {kernel.function.*pc=} { pass $test } timeout { fail "$test (timeout2)" } diff --git a/testsuite/systemtap.base/poll_map.stp b/testsuite/systemtap.base/poll_map.stp index cd39b433..e278fc91 100755 --- a/testsuite/systemtap.base/poll_map.stp +++ b/testsuite/systemtap.base/poll_map.stp @@ -5,7 +5,7 @@ global called, num_polls -probe kernel.function( "sys_*" ).call { +probe kernel.function( "vfs_*" ).call { called[execname(),probefunc()]++ } -- cgit From 63a92162205f7c0b6adfef9d91a58806aa33f606 Mon Sep 17 00:00:00 2001 From: David Smith Date: Mon, 1 Jun 2009 13:25:44 -0500 Subject: Better sdt.exp test cleanup. * testsuite/systemtap.base/sdt.exp: Better cleanup. --- testsuite/systemtap.base/sdt.exp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/sdt.exp b/testsuite/systemtap.base/sdt.exp index c3aed91e..d24093e0 100644 --- a/testsuite/systemtap.base/sdt.exp +++ b/testsuite/systemtap.base/sdt.exp @@ -41,6 +41,7 @@ if {[installtest_p] && [utrace_p]} { } else { untested "$test $extra_flag" } +catch {exec rm -f $testprog} # C++ set testprog "sdt.cxx.exe.$i" @@ -66,5 +67,5 @@ if {[installtest_p] && [utrace_p]} { } else { untested "$test c++ $extra_flag" } +catch {exec rm -f $testprog} } - -- cgit From 67146982d334acdb25f43da2a74c02fcabc3c45d Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Tue, 9 Jun 2009 19:58:15 -0700 Subject: Fix condition propagation across aliases When an instance of an alias has a condition, that condition gets propagated to each of the locations that the alias defines. However, the copy of the location list was not a deep copy, and so all other instances of the alias would also incorrectly receive the condition. This patch makes the location list copy a little deeper, and adds a test case which demonstrates the issue. --- testsuite/systemtap.base/alias-condition.exp | 5 +++++ testsuite/systemtap.base/alias-condition.stp | 26 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 testsuite/systemtap.base/alias-condition.exp create mode 100644 testsuite/systemtap.base/alias-condition.stp (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/alias-condition.exp b/testsuite/systemtap.base/alias-condition.exp new file mode 100644 index 00000000..58438340 --- /dev/null +++ b/testsuite/systemtap.base/alias-condition.exp @@ -0,0 +1,5 @@ +# Check that conditions are copied correctly across aliases + +set test "alias-condition" + +stap_run $srcdir/$subdir/$test.stp no_load $all_pass_string diff --git a/testsuite/systemtap.base/alias-condition.stp b/testsuite/systemtap.base/alias-condition.stp new file mode 100644 index 00000000..89708886 --- /dev/null +++ b/testsuite/systemtap.base/alias-condition.stp @@ -0,0 +1,26 @@ +/* + * alias-condition.stp + * + * Check that conditions are copied correctly across aliases + */ + +/* x should be incremented exactly once */ +global x = 0 +probe foo = begin { } +probe foo if (x < 0), foo { ++x } + +probe begin(1) +{ + println("systemtap starting probe") + exit() +} + +probe end +{ + println("systemtap ending probe") + if ( x != 1 ) { + println("systemtap test failure") + } else { + println("systemtap test success") + } +} -- cgit