diff options
Diffstat (limited to 'testsuite/systemtap.base')
-rw-r--r-- | testsuite/systemtap.base/cache.exp | 4 | ||||
-rw-r--r-- | testsuite/systemtap.base/cmd_parse.exp | 9 | ||||
-rw-r--r-- | testsuite/systemtap.base/maxactive.exp | 6 | ||||
-rw-r--r-- | testsuite/systemtap.base/utrace_p4.exp | 106 | ||||
-rw-r--r-- | testsuite/systemtap.base/utrace_p5.exp | 140 | ||||
-rw-r--r-- | testsuite/systemtap.base/warnings.exp | 4 |
6 files changed, 263 insertions, 6 deletions
diff --git a/testsuite/systemtap.base/cache.exp b/testsuite/systemtap.base/cache.exp index eaa5ca82..26d7b0ef 100644 --- a/testsuite/systemtap.base/cache.exp +++ b/testsuite/systemtap.base/cache.exp @@ -74,8 +74,8 @@ if [info exists env(SYSTEMTAP_DIR)] { set env(SYSTEMTAP_DIR) $local_systemtap_dir # Set up the scripts we'll use. -set basic_script1 "\"probe begin { }\"" -set basic_script2 "\"probe begin, end { }\"" +set basic_script1 "\"probe begin { println(1) }\"" +set basic_script2 "\"probe begin, end { println(2) }\"" set error_script "\"probe XbeginX { }\"" # Check basic functionality. The 1st compilation of a script won't diff --git a/testsuite/systemtap.base/cmd_parse.exp b/testsuite/systemtap.base/cmd_parse.exp index ff347a9d..cbce0455 100644 --- a/testsuite/systemtap.base/cmd_parse.exp +++ b/testsuite/systemtap.base/cmd_parse.exp @@ -75,3 +75,12 @@ expect { eof {fail "cmd_parse7: unexpected EOF"} } wait + +spawn stap -l {vm.*} +expect { + -timeout 60 + -re "vm.*" {pass "cmd_parse8"} + timeout {fail "cmd_parse8: unexpected timeout"} + eof {fail "cmd_parse8: unexpected EOF"} +} +wait diff --git a/testsuite/systemtap.base/maxactive.exp b/testsuite/systemtap.base/maxactive.exp index ca95ac53..7c03a1bf 100644 --- a/testsuite/systemtap.base/maxactive.exp +++ b/testsuite/systemtap.base/maxactive.exp @@ -13,8 +13,9 @@ proc sleep_five_sec {} { # Script1. For 5 seconds, probe the return of "sys_select" and # "sys_read". See if we skip any probes. set script1 { + global foo probe kernel.function("sys_select").return, - kernel.function("sys_read").return { } + kernel.function("sys_read").return { foo++ } probe timer.ms(5000) { exit(); } probe begin { log("systemtap starting probe"); log("systemtap ending probe");} @@ -29,8 +30,9 @@ set skipped1 $skipped_probes # "sys_read", with a limit of 1 probe active at a time. See if we # skip any probes. set script2 { + global foo probe kernel.function("sys_select").return.maxactive(1), - kernel.function("sys_read").return.maxactive(1) { } + kernel.function("sys_read").return.maxactive(1) { foo++ } probe timer.ms(5000) { exit(); } probe begin { log("systemtap starting probe"); log("systemtap ending probe");} diff --git a/testsuite/systemtap.base/utrace_p4.exp b/testsuite/systemtap.base/utrace_p4.exp new file mode 100644 index 00000000..eb6ea685 --- /dev/null +++ b/testsuite/systemtap.base/utrace_p4.exp @@ -0,0 +1,106 @@ +# Utrace compile (pass 4) tests. We can't run these as +# testsuite/buildok tests, since if the current kernel has no utrace +# support, those will fail - but not because of a problem with +# systemtap's utrace probes (but because of the lack of utrace). So, +# this test script checks for the existence of utrace in the kernel. +# If utrace exists in the kernel, it tries some compile tests. If +# utrace doesn't exist in the kernel, marks the tests as 'untested'. + +# stap_compile TEST_NAME flags script args +# - TEST_NAME is the name of the current test +# - compile indicates whether the script is supposed to compile +# - script is the script to compile +# Additional arguments are passed to stap as-is. +proc stap_compile { TEST_NAME compile script args } { + set cmd [concat {stap -v -p4 -e} $script $args] + + verbose -log "running $cmd" + eval spawn $cmd + set compile_errors 0 + expect { + -re {^Pass\ [1234]:[^\r]*\ in\ .*\ ms.\r\n} {exp_continue} + -re {^Pass\ [34]: using cached [^\r\n]+\r\n} {exp_continue} + # pass-4 output + -re {^/[^\r\n]+.ko\r\n} {exp_continue} + -re "parse error" { incr compile_errors 1; exp_continue} + -re "compilation failed" {incr compile_errors 1; exp_continue} + -re "semantic error:" {incr compile_errors 1; exp_continue} + } + catch close + wait + + # If we've got compile errors and the script was supposed to + # compile, fail. + if {$compile_errors > 0} { + if {$compile == 1} { + fail "$TEST_NAME compilation failed" + } else { + pass "$TEST_NAME compilation failed correctly" + } + } else { + if {$compile == 1} { + pass "$TEST_NAME compilation succeeded" + } else { + fail "$TEST_NAME compilation succeeded unexpectedly" + } + } +} + +# Initialize variables +set utrace_support_found 0 + +set clone_script {"probe process(\"/bin/ls\").clone { print(\"ls clone\") }"} +set death_script {"probe process(\"/bin/ls\").death { print(\"ls death\") }"} +set syscall_script {"probe process(\"/bin/ls\").syscall { printf(\"|%d\", \$syscall) }"} +set syscall_return_script {"probe process(\"/bin/ls\").syscall.return { printf(\"|%d\", \$syscall) }"} +set exec_script {"probe process(\"/bin/ls\").exec { print(\"ls exec\") }"} + +# Try to find utrace_attach symbol in /proc/kallsyms +set path "/proc/kallsyms" +if {! [catch {exec grep -q utrace_attach $path} dummy]} { + set utrace_support_found 1 +} + +# +# Do some utrace compile tests. +# + +set TEST_NAME "UTRACE_P4_01" +if {$utrace_support_found == 0} { + untested "$TEST_NAME : no kernel utrace support found" +} else { + # Try compiling a clone script + stap_compile $TEST_NAME 1 $clone_script +} + +set TEST_NAME "UTRACE_P4_02" +if {$utrace_support_found == 0} { + untested "$TEST_NAME : no kernel utrace support found" +} else { + # Try compiling a death script + stap_compile $TEST_NAME 1 $death_script +} + +set TEST_NAME "UTRACE_P4_03" +if {$utrace_support_found == 0} { + untested "$TEST_NAME : no kernel utrace support found" +} else { + # Try compiling a syscall script + stap_compile $TEST_NAME 1 $syscall_script +} + +set TEST_NAME "UTRACE_P4_04" +if {$utrace_support_found == 0} { + untested "$TEST_NAME : no kernel utrace support found" +} else { + # Try compiling a syscall return script + stap_compile $TEST_NAME 1 $syscall_return_script +} + +set TEST_NAME "UTRACE_P4_05" +if {$utrace_support_found == 0} { + untested "$TEST_NAME : no kernel utrace support found" +} else { + # Try compiling an exec script + stap_compile $TEST_NAME 1 $exec_script +} diff --git a/testsuite/systemtap.base/utrace_p5.exp b/testsuite/systemtap.base/utrace_p5.exp new file mode 100644 index 00000000..cbb867d1 --- /dev/null +++ b/testsuite/systemtap.base/utrace_p5.exp @@ -0,0 +1,140 @@ +# Utrace run (pass 5) tests. + +# Initialize variables +set utrace_support_found 0 +set exepath "[pwd]/cat_[pid]" + +set death_script { + global death_probes_fired = 0 + probe begin { printf("systemtap starting probe\n") } + probe process("%s").death { death_probes_fired++ } + probe end { printf("systemtap ending probe\n") + printf("deaths = %%d\n", death_probes_fired) } +} +set death_script_output "deaths = 1\r\n" + +set exec_script { + global exec_probes_fired = 0 + probe begin { printf("systemtap starting probe\n") } + probe process("%s").exec { exec_probes_fired++ } + probe end { printf("systemtap ending probe\n") + printf("execs = %%d\n", exec_probes_fired) } +} +set exec_script_output "execs = 1\r\n" + +set syscall_script { + global syscall_probes_fired = 0 + probe begin { printf("systemtap starting probe\n") } + probe process("%s").syscall { syscall_probes_fired++ } + probe end { printf("systemtap ending probe\n") + if (syscall_probes_fired > 0) { + printf("syscalls = %%d\n", syscall_probes_fired) + } + } +} +set syscall_script_output "syscalls = \\d+\r\n" + +set syscall_return_script { + global syscall_return_probes_fired = 0 + probe begin { printf("systemtap starting probe\n") } + probe process("%s").syscall.return { syscall_return_probes_fired++ } + probe end { printf("systemtap ending probe\n") + if (syscall_return_probes_fired > 0) { + printf("syscall_returns = %%d\n", syscall_return_probes_fired) + } + } +} +set syscall_return_script_output "syscall_returns = \\d+\r\n" + +set clone_script { + global clone_probes_fired = 0 + probe begin { printf("systemtap starting probe\n") } + probe process(%d).clone { clone_probes_fired++ } + probe end { printf("systemtap ending probe\n") + if (clone_probes_fired > 0) { + printf("clones = %%d\n", clone_probes_fired) + } + } +} +set clone_script_output "clones = \\d+\r\n" + +# Try to find utrace_attach symbol in /proc/kallsyms +set path "/proc/kallsyms" +if {! [catch {exec grep -q utrace_attach $path} dummy]} { + set utrace_support_found 1 +} + +# Set up our own copy of /bin/cat, to make testing for a particular +# executable easy. We can't use 'ln' here, since we might be creating +# a cross-device link. We can't use 'ln -s' here, since the kernel +# resolves the symbolic link and reports that /bin/cat is being +# exec'ed (instead of our local copy). +if {[catch {exec cp /bin/cat $exepath} res]} { + fail "unable to copy /bin/cat: $res" + return +} + +# "load" generation function for stap_run. It spawns our own copy of +# /bin/cat, waits 5 seconds, then kills it. +proc run_cat_5_sec {} { + global exepath + + spawn $exepath + set exe_id $spawn_id + after 5000; + exec kill -INT -[exp_pid -i $exe_id] + return 0; +} + +set TEST_NAME "UTRACE_P5_01" +if {$utrace_support_found == 0} { + untested "$TEST_NAME : no kernel utrace support found" +} elseif {![installtest_p]} { + untested "$TEST_NAME" +} else { + set script [format $death_script $exepath] + stap_run $TEST_NAME run_cat_5_sec $death_script_output -e $script +} + +set TEST_NAME "UTRACE_P5_02" +if {$utrace_support_found == 0} { + untested "$TEST_NAME : no kernel utrace support found" +} elseif {![installtest_p]} { + untested "$TEST_NAME" +} else { + set script [format $exec_script $exepath] + stap_run $TEST_NAME run_cat_5_sec $exec_script_output -e $script +} + +set TEST_NAME "UTRACE_P5_03" +if {$utrace_support_found == 0} { + untested "$TEST_NAME : no kernel utrace support found" +} elseif {![installtest_p]} { + untested "$TEST_NAME" +} else { + set script [format $syscall_script $exepath] + stap_run $TEST_NAME run_cat_5_sec $syscall_script_output -e $script +} + +set TEST_NAME "UTRACE_P5_04" +if {$utrace_support_found == 0} { + untested "$TEST_NAME : no kernel utrace support found" +} elseif {![installtest_p]} { + untested "$TEST_NAME" +} else { + set script [format $syscall_return_script $exepath] + stap_run $TEST_NAME run_cat_5_sec $syscall_return_script_output -e $script +} + +set TEST_NAME "UTRACE_P5_05" +if {$utrace_support_found == 0} { + untested "$TEST_NAME : no kernel utrace support found" +} elseif {![installtest_p]} { + untested "$TEST_NAME" +} else { + set script [format $clone_script [pid]] + stap_run $TEST_NAME run_cat_5_sec $clone_script_output -e $script +} + +# Cleanup +exec rm -f $exepath diff --git a/testsuite/systemtap.base/warnings.exp b/testsuite/systemtap.base/warnings.exp index 90409d18..025bde89 100644 --- a/testsuite/systemtap.base/warnings.exp +++ b/testsuite/systemtap.base/warnings.exp @@ -9,8 +9,8 @@ expect { eof { } } wait -if {$ok == 6} { +if {$ok == 9} { pass $test } else { - fail $test + fail "$test ($ok)" } |