diff options
Diffstat (limited to 'testsuite/systemtap.stress')
-rw-r--r-- | testsuite/systemtap.stress/all_kernel_functions.exp | 59 | ||||
-rw-r--r-- | testsuite/systemtap.stress/current.exp | 26 | ||||
-rw-r--r-- | testsuite/systemtap.stress/current.stp | 97 |
3 files changed, 182 insertions, 0 deletions
diff --git a/testsuite/systemtap.stress/all_kernel_functions.exp b/testsuite/systemtap.stress/all_kernel_functions.exp new file mode 100644 index 00000000..f81b6430 --- /dev/null +++ b/testsuite/systemtap.stress/all_kernel_functions.exp @@ -0,0 +1,59 @@ +load_lib "stap_run.exp" + +proc genload {} { + # if 'genload' from the ltp exists, use it to create a real load + set genload {/usr/local/ltp/testcases/bin/genload} + if [file executable $genload] { + exec $genload -c 10 -i 10 -m 10 -t 10 + # ^^^^^ run for 10 seconds + # ^^^^^ 10 procs spinning on malloc + # ^^^^^ 10 procs spinning on sync + # ^^^^^ 10 procs spinning on sqrt + } else { + # sleep for a bit + after 10000 + } + return 0 +} + +proc probe_ok {probepoint} { + set cmd {exec stap -p2 -e} + lappend cmd "probe $probepoint {}" + return ![catch $cmd] +} + +set systemtap_script { + global stat + probe %s { + stat[probefunc()] <<< 1 + } + probe begin { + log("systemtap starting probe") + } + probe end { + log("systemtap ending probe") + foreach (func in stat) + printf("%%d %%s\n", @count(stat[func]), func) + } +} + +set letters [split {abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ} {}] + +set output_string "(\\d+ \\w+\\r\\n)*(WARNING.*skipped.*)?" + +# Because this test is known to expose system crashes, it is not enabled +# by default. Change the line below to 'if 1' to enable it. +if 0 { + foreach start $letters { + set probepoint "kernel.function(\"$start*\")" + set prefix "all_kernel_functions:" + if [probe_ok $probepoint] { + set script [format $systemtap_script $probepoint] + stap_run $prefix$probepoint genload $output_string -e $script + } else { + unsupported "$prefix no match for $probepoint" + } + } +} else { + untested "all_kernel_functions is disabled" +} diff --git a/testsuite/systemtap.stress/current.exp b/testsuite/systemtap.stress/current.exp new file mode 100644 index 00000000..8f4ebff2 --- /dev/null +++ b/testsuite/systemtap.stress/current.exp @@ -0,0 +1,26 @@ +# Simple function to test that systemtap can generate instument a module +# function, install it, and get some output. + +load_lib "stap_run.exp" + +set test "current" + +proc current_load {} { + # if 'genload' from the ltp exists, use it to create a real load + set genload {/usr/local/ltp/testcases/bin/genload} + if [file executable $genload] { + exec $genload -c 10 -i 10 -m 10 -t 10 + # ^^^^^ run for 10 seconds + # ^^^^^ 10 procs spinning on malloc + # ^^^^^ 10 procs spinning on sync + # ^^^^^ 10 procs spinning on sqrt + } else { + # sleep for a bit + after 10000 + } + return 0 +} + +set output_string "(\\w+ = \\d+\r\n){5}${all_pass_string}(WARNING.*skipped.*)?" + +stap_run $srcdir/$subdir/$test.stp current_load $output_string -g diff --git a/testsuite/systemtap.stress/current.stp b/testsuite/systemtap.stress/current.stp new file mode 100644 index 00000000..40673581 --- /dev/null +++ b/testsuite/systemtap.stress/current.stp @@ -0,0 +1,97 @@ +/* + * current.stp (requires Guru mode) + * + * Test the validity of the current pointer in various contexts. + */ + +global length + +function commlen:long () %{ + THIS->__retvalue = strlen(current->comm); +%} + +function pcommlen:long () %{ + THIS->__retvalue = strlen(current->parent->comm); +%} + +probe begin { log("systemtap starting probe") } + +probe + timer.profile, + %( arch != "x86_64" %? + # __switch_to.return is broken on x86_64 - see PR2068 + %( arch != "ia64" %? + # __switch_to is macro definition in ia64, + # and ia64_switch_to is defined in assemble language + kernel.function("__switch_to"), + kernel.function("__switch_to").return, + %) + %) + + /* XXX + * It would be nice if we could just do this: + * kernel.statement("__switch_to@*:*") + * to probe every line in the function + */ + + /* add other kernels/archs here as desired... */ + %( arch == "x86_64" %? + %( kernel_vr == "2.6.9-22.ELsmp" %? + /* the lines before, at, and after the update of pcurrent */ + kernel.statement("__switch_to@arch/x86_64/kernel/process.c:508"), + kernel.statement("__switch_to@arch/x86_64/kernel/process.c:509"), + kernel.statement("__switch_to@arch/x86_64/kernel/process.c:510"), + %) + %( kernel_vr == "2.6.9-24.ELsmp" %? + /* the lines before, at, and after the update of pcurrent */ + kernel.statement("__switch_to@arch/x86_64/kernel/process.c:501"), + kernel.statement("__switch_to@arch/x86_64/kernel/process.c:502"), + kernel.statement("__switch_to@arch/x86_64/kernel/process.c:503"), + %) + %) + + kernel.function("*@kernel/sched.c"), + kernel.function("*@kernel/sched.c").return, + module("*").function("*interrupt*"), + module("*").function("*interrupt*").return +{ + length <<< commlen() + length <<< pcommlen() +} + +function get_TASK_COMM_LEN:long() %{ + /* TASK_COMM_LEN was introduced in 2.6.11, before which + * the length of the comm string was hard-coded to 16 */ +#ifdef TASK_COMM_LEN + THIS->__retvalue = TASK_COMM_LEN; +#else + THIS->__retvalue = 16; +#endif +%} + +probe end { + log("systemtap ending probe") + printf("count = %d\n", @count(length)) + printf("sum = %d\n", @sum(length)) + printf("min = %d\n", @min(length)) + printf("max = %d\n", @max(length)) + printf("avg = %d\n", @avg(length)) + + /* + * Check that the min & max lengths look reasonable. If any string was + * either empty or too big, then the current pointer probably wasn't + * valid, even though it dereferenced without crashing. + */ + if (@min(length) > 0) { + log("systemtap test success") + } else { + log("unexpected minimum length") + log("systemtap test failure") + } + if (@max(length) < get_TASK_COMM_LEN()) { + log("systemtap test success") + } else { + log("unexpected maximum length") + log("systemtap test failure") + } +} |