diff options
-rw-r--r-- | testsuite/ChangeLog | 8 | ||||
-rwxr-xr-x | testsuite/buildok/utrace01.stp | 5 | ||||
-rwxr-xr-x | testsuite/buildok/utrace02.stp | 5 | ||||
-rwxr-xr-x | testsuite/buildok/utrace03.stp | 8 | ||||
-rw-r--r-- | testsuite/systemtap.base/utrace_p4.exp | 97 |
5 files changed, 105 insertions, 18 deletions
diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog index afd3140c..86fd83c7 100644 --- a/testsuite/ChangeLog +++ b/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2008-04-18 David Smith <dsmith@redhat.com> + + * buildok/utrace01.stp: Removed. + * buildok/utrace02.stp: Ditto. + * buildok/utrace03.stp: Ditto. + * systemtap.base/utrace_p4.exp: Rewrote buildok tests to check for + kernel utrace support. + 2008-04-17 David Smith <dsmith@redhat.com> * buildok/utrace01.stp: New test. diff --git a/testsuite/buildok/utrace01.stp b/testsuite/buildok/utrace01.stp deleted file mode 100755 index e363420d..00000000 --- a/testsuite/buildok/utrace01.stp +++ /dev/null @@ -1,5 +0,0 @@ -#! stap -p4 - -probe process("/bin/ls").clone { - print("ls clone") -} diff --git a/testsuite/buildok/utrace02.stp b/testsuite/buildok/utrace02.stp deleted file mode 100755 index 26ccdf2a..00000000 --- a/testsuite/buildok/utrace02.stp +++ /dev/null @@ -1,5 +0,0 @@ -#! stap -p4 - -probe process("/bin/ls").death { - print("ls death") -} diff --git a/testsuite/buildok/utrace03.stp b/testsuite/buildok/utrace03.stp deleted file mode 100755 index a0a65312..00000000 --- a/testsuite/buildok/utrace03.stp +++ /dev/null @@ -1,8 +0,0 @@ -#! stap -p4 - -probe process("/bin/ls").syscall { - printf("|%d", $syscall) -} -probe process("/bin/ls").syscall.return { - print("+\n") -} diff --git a/testsuite/systemtap.base/utrace_p4.exp b/testsuite/systemtap.base/utrace_p4.exp new file mode 100644 index 00000000..35a3ba15 --- /dev/null +++ b/testsuite/systemtap.base/utrace_p4.exp @@ -0,0 +1,97 @@ +# 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) }"} + +# 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 +} |