diff options
Diffstat (limited to 'testsuite')
28 files changed, 335 insertions, 46 deletions
diff --git a/testsuite/buildok/ustack.stp b/testsuite/buildok/ustack.stp new file mode 100755 index 00000000..23af0bff --- /dev/null +++ b/testsuite/buildok/ustack.stp @@ -0,0 +1,10 @@ +#! stap -p4 +# +# Test the translatability for ubacktrace(), print_ustack() +# and print_ubacktrace() +# +probe begin +{ + print_ustack(ubacktrace()); + print_ubacktrace(); +} diff --git a/testsuite/parseko/utrace01.stp b/testsuite/parseko/utrace01.stp index 1cb4227f..9f3619b5 100755 --- a/testsuite/parseko/utrace01.stp +++ b/testsuite/parseko/utrace01.stp @@ -1,4 +1,4 @@ #! stap -p2 # process NAME must be a string -probe process(/bin/cat).death { } +probe process(/bin/cat).end { } diff --git a/testsuite/semko/utrace01.stp b/testsuite/semko/utrace01.stp deleted file mode 100755 index a4707008..00000000 --- a/testsuite/semko/utrace01.stp +++ /dev/null @@ -1,4 +0,0 @@ -#! stap -p2 - -# missing process NAME|PID -probe process.death { } diff --git a/testsuite/semko/utrace03.stp b/testsuite/semko/utrace03.stp index c682410b..92177ffd 100755 --- a/testsuite/semko/utrace03.stp +++ b/testsuite/semko/utrace03.stp @@ -1,4 +1,4 @@ #! stap -p2 # invalid probe type -probe process("/bin/cat").death.return { } +probe process("/bin/cat").end.return { } diff --git a/testsuite/semko/utrace04.stp b/testsuite/semko/utrace04.stp index 6345f9f6..1d26a43c 100755 --- a/testsuite/semko/utrace04.stp +++ b/testsuite/semko/utrace04.stp @@ -1,4 +1,4 @@ #! stap -p2 -# death probes don't support target symbols -probe process("/bin/cat").death.return { print($syscall) } +# end probes don't support target symbols +probe process("/bin/cat").end { print($syscall) } diff --git a/testsuite/semko/utrace08.stp b/testsuite/semko/utrace08.stp deleted file mode 100755 index a558a5be..00000000 --- a/testsuite/semko/utrace08.stp +++ /dev/null @@ -1,4 +0,0 @@ -#! stap -p2 - -# process path must be absolute -probe process("cat").death { } diff --git a/testsuite/semko/utrace09.stp b/testsuite/semko/utrace09.stp deleted file mode 100755 index 60c49cd2..00000000 --- a/testsuite/semko/utrace09.stp +++ /dev/null @@ -1,4 +0,0 @@ -#! stap -p2 - -# process path must be absolute -probe process("/foo/../bar").death { } diff --git a/testsuite/semko/utrace10.stp b/testsuite/semko/utrace10.stp deleted file mode 100755 index b46baea9..00000000 --- a/testsuite/semko/utrace10.stp +++ /dev/null @@ -1,4 +0,0 @@ -#! stap -p2 - -# path can't contain an empty component -probe process("/foo//bar").death { } diff --git a/testsuite/semko/utrace11.stp b/testsuite/semko/utrace11.stp deleted file mode 100755 index d78b602c..00000000 --- a/testsuite/semko/utrace11.stp +++ /dev/null @@ -1,4 +0,0 @@ -#! stap -p2 - -# path can't end with '/' -probe process("/foo/bar/").death { } diff --git a/testsuite/semko/utrace12.stp b/testsuite/semko/utrace12.stp deleted file mode 100755 index 478aa1d3..00000000 --- a/testsuite/semko/utrace12.stp +++ /dev/null @@ -1,4 +0,0 @@ -#! stap -p2 - -# path can't end with '.' -probe process("/foo/bar/.").death { } diff --git a/testsuite/semko/utrace13.stp b/testsuite/semko/utrace13.stp deleted file mode 100755 index 16cc0391..00000000 --- a/testsuite/semko/utrace13.stp +++ /dev/null @@ -1,4 +0,0 @@ -#! stap -p2 - -# path can't end with '..' -probe process("/foo/bar/..").death { } diff --git a/testsuite/semok/cast.stp b/testsuite/semok/cast.stp index d30823cd..769335f2 100755 --- a/testsuite/semok/cast.stp +++ b/testsuite/semok/cast.stp @@ -12,6 +12,6 @@ probe begin { // but who knows what debuginfo is installed... // check modules generated from headers - println(@cast(0, "task_struct", "kmod<linux/sched.h>")->tgid) - println(@cast(0, "timeval", "umod<sys/time.h>")->tv_sec) + println(@cast(0, "task_struct", "kernel<linux/sched.h>")->tgid) + println(@cast(0, "timeval", "<sys/time.h>")->tv_sec) } diff --git a/testsuite/semok/utrace01.stp b/testsuite/semok/utrace01.stp new file mode 100755 index 00000000..864bdf15 --- /dev/null +++ b/testsuite/semok/utrace01.stp @@ -0,0 +1,4 @@ +#! stap -p2 + +# process path doesn't need to be absolute +probe process("cat").end { } diff --git a/testsuite/systemtap.base/cast.stp b/testsuite/systemtap.base/cast.stp index 33a14a28..6298a06d 100644 --- a/testsuite/systemtap.base/cast.stp +++ b/testsuite/systemtap.base/cast.stp @@ -11,7 +11,7 @@ probe begin printf("PID %d != %d\n", pid, cast_pid) // Compare PIDs using a generated kernel module - cast_pid = @cast(curr, "task_struct", "kmod<linux/sched.h>")->tgid + cast_pid = @cast(curr, "task_struct", "kernel<linux/sched.h>")->tgid if (pid == cast_pid) println("PID2 OK") else @@ -27,7 +27,7 @@ probe begin // Compare tv_sec using a generated user module sec = 42 - cast_sec = @cast(get_timeval(sec), "timeval", "umod<sys/time.h>")->tv_sec + cast_sec = @cast(get_timeval(sec), "timeval", "<sys/time.h>")->tv_sec if (sec == cast_sec) println("tv_sec OK") else diff --git a/testsuite/systemtap.base/flightrec1.exp b/testsuite/systemtap.base/flightrec1.exp new file mode 100644 index 00000000..c32a77f2 --- /dev/null +++ b/testsuite/systemtap.base/flightrec1.exp @@ -0,0 +1,43 @@ +set test "flightrec1" +if {![installtest_p]} { untested $test; return } + +# run stapio in background mode +spawn stap -F -o $test.out -we {probe begin {}} +# check whether stap outputs stapio pid +set pid 0 +expect { + -timeout 240 + -re {([0-9]+)\r\n} { + pass "$test (flight recorder option)" + set pid $expect_out(1,string) + exp_continue} + timeout { fail "$test (timeout)" } + eof { } +} +wait +if {$pid == 0} { + fail "$test (no pid)" + return -1 +} + +# check whether stapio is running in background +spawn ps -o cmd hc $pid +expect { + -timeout 10 + "stapio" {pass "$test (stapio in background)"} # don't contine + timeout { fail "$test (timeout)"} + eof { fail "$test (stapio was not found)" } +} +wait + +exec kill -TERM $pid + +# check output file +if {[catch {exec rm $test.out}]} { + fail "$test (no output file)" + return -1 +} else { + pass "$test (output file)" +} + + diff --git a/testsuite/systemtap.base/flightrec2.exp b/testsuite/systemtap.base/flightrec2.exp new file mode 100644 index 00000000..a22ef415 --- /dev/null +++ b/testsuite/systemtap.base/flightrec2.exp @@ -0,0 +1,69 @@ +set test "flightrec2" +if {![installtest_p]} { untested $test; return } + +# cleanup +system "rm -f flightlog.out*" + +set pid 0 +# check -S option +spawn stap -F -o flightlog.out -S 1,3 $srcdir/$subdir/$test.stp +expect { + -timeout 240 + -re {([0-9]+)\r\n} { + pass "$test (-S option)" + set pid $expect_out(1,string) + exp_continue} + timeout { fail "$test (timeout)"} + eof { } +} +wait +if {$pid == 0} { + fail "$test (no pid)" + return -1 +} + +exec sleep 4 +set scnt 0 +set cnt1 0 +# wait for log files +spawn ls -sk1 +expect { + -timeout 100 + -re {([0-9]+) flightlog\.out\.[0-9]+} { + incr cnt1; + if {$expect_out(1,string) <= 1028} {incr scnt} + # 1024 + 4(for inode blocks?) + exp_continue} + timeout { fail "$test (logfile timeout)"} +} +wait +exec sleep 3 +set cnt2 0 +# wait for log files +spawn ls -sk1 +expect { + -timeout 100 + -re {([0-9]+) flightlog\.out\.[0-9]+} { + incr cnt2; + if {$expect_out(1,string) <= 1028} {incr scnt} + exp_continue} + timeout { fail "$test (logfile timeout)"} +} +wait +# check logfile number +if {$cnt1 == 3 && $cnt2 == 3} { + pass "$test (log file numbers limitation)" +} else { + fail "$test (log file numbers ($cnt1, $cnt2))" +} +# check logfile size +if {$scnt == 6} { + pass "$test (log file size limitation)" +} else { + fail "$test (log file size ($scnt))" +} +exec kill -TERM $pid +# wait for exiting... +exec sleep 1 +system "rm -f flightlog.out*" + diff --git a/testsuite/systemtap.base/flightrec2.stp b/testsuite/systemtap.base/flightrec2.stp new file mode 100644 index 00000000..9d745f4b --- /dev/null +++ b/testsuite/systemtap.base/flightrec2.stp @@ -0,0 +1,5 @@ +probe timer.ms(1) +{ + for (j = 0; j < 100; j++) + printf("1234567890\n") +} diff --git a/testsuite/systemtap.base/kprobes.exp b/testsuite/systemtap.base/kprobes.exp index 240ecd82..635930f8 100644 --- a/testsuite/systemtap.base/kprobes.exp +++ b/testsuite/systemtap.base/kprobes.exp @@ -1,2 +1,2 @@ set test "kprobes" -stap_run $srcdir/$subdir/$test.stp +stap_run $srcdir/$subdir/$test.stp no_load "probe point hit" diff --git a/testsuite/systemtap.base/kprobes.stp b/testsuite/systemtap.base/kprobes.stp index 62c18347..884b321c 100644 --- a/testsuite/systemtap.base/kprobes.stp +++ b/testsuite/systemtap.base/kprobes.stp @@ -3,19 +3,23 @@ * Probe to test the functionality of kprobe-based probes * (Dwarfless Probing) */ +global hit_str probe begin { - println("\n Systemtap starting probe"); + println("systemtap starting probe"); + hit_str = "" } probe kprobe.function("vfs_read") { - printf("\n probe point hit"); + hit_str = "probe point hit" exit(); } probe end { - println("\n Systemtap starting probe"); + println("systemtap ending probe"); + println(hit_str); + delete hit_str; } diff --git a/testsuite/systemtap.base/strftime.exp b/testsuite/systemtap.base/strftime.exp new file mode 100644 index 00000000..ad9e471d --- /dev/null +++ b/testsuite/systemtap.base/strftime.exp @@ -0,0 +1,49 @@ +set test "strftime" +if {![installtest_p]} { untested $test; return } +# cleanup +system "rm -f %*" + +# check %S and %T +set format %%%S_%T +exec stap -o $format -we {probe begin {println("hello");exit()}} + +spawn ls -1 +set ok 0 +expect { + -re {%([0-9][0-9])_[0-9][0-9]:[0-9][0-9]:\1} {incr ok} + eof { } +} +wait + +if {$ok == 1} { + pass "$test (%S and %T)" +} else { + fail "$test (%S and %T)" +} + +# check except for %S and %T +set format %%,%C,%Y,%y,%m,%d,%e,%F,%H,%I,%j,%k,%l,%M,%R,%u,%w + +set date1 [exec date +$format] +# run stapio with strftime +exec stap -o $format -we {probe begin {println("hello");exit()}} +# check whether stap outputs stapio pid +set date2 [exec date +$format] + +spawn ls -1 +set ok 0 +expect { + $date1 {incr ok} + $date2 {incr ok} + eof { } +} +wait + +if {$ok == 1} { + pass "$test (except %S and %T)" +} else { + fail "$test (except %S and %T)" +} + +# cleanup +system "rm -f %*" diff --git a/testsuite/systemtap.base/uprobes_ustack.exp b/testsuite/systemtap.base/uprobes_ustack.exp new file mode 100644 index 00000000..bfc435e9 --- /dev/null +++ b/testsuite/systemtap.base/uprobes_ustack.exp @@ -0,0 +1,97 @@ +set test "uprobes_ustack" +set testpath "$srcdir/$subdir" +set testsrc "$testpath/uprobes_exe.c" +set testsrclib "$testpath/uprobes_lib.c" +set testexe "./uprobes_exe" +set testlibname "uprobes_lib" +set testlibdir "." +set testso "$testlibdir/lib${testlibname}.so" +set testflags "additional_flags=-g additional_flags=-O" +set testlibflags "$testflags additional_flags=-fPIC additional_flags=-shared" +set maintestflags "$testflags additional_flags=-L$testlibdir additional_flags=-l$testlibname additional_flags=-Wl,-rpath,$testlibdir" + +# Compile our test program and library. +set res [target_compile $testsrclib $testso executable $testlibflags] +if { $res != "" } { + verbose "target_compile for $testso failed: $res" 2 + fail "$test compile $testsrclib" + return +} else { + pass "$test compile $testsrclib" +} + +set res [target_compile $testsrc $testexe executable $maintestflags] +if { $res != "" } { + verbose "target_compile failed: $res" 2 + fail "$test compile $testsrc" + return +} else { + pass "$test compile $testsrc" +} + +set ::result_string {exe: main=main +exe: main_func=main_func +exe: main_func=main_func +exe: main_func=main_func +lib: lib_main=lib_main +lib: lib_func=lib_func +lib: lib_func=lib_func +lib: lib_func=lib_func} + +# Only run on make installcheck +if {! [installtest_p]} { untested "$test"; return } +if {! [utrace_p]} { untested $test; return } + +# Output is: +#print_ubacktrace exe 0 +# 0x080484ba : main_func+0xa/0x29 [.../uprobes_exe] +# 0x080484f6 : main+0x1d/0x37 [.../uprobes_exe] +#print_ustack exe 1 +# 0x080484ba : main_func+0xa/0x29 [.../uprobes_exe] +# 0x080484c9 : main_func+0x19/0x29 [.../uprobes_exe] +# 0x080484f6 : main+0x1d/0x37 [.../uprobes_exe] +#print_ubacktrace lib 2 +# 0x00db2422 : lib_func+0x16/0x2b [.../libuprobes_lib.so] +# 0x00db2455 : lib_main+0x1e/0x29 [.../libuprobes_lib.so] +# 0x080484d0 : main_func+0x20/0x29 [.../uprobes_exe] +# 0x080484c9 : main_func+0x19/0x29 [.../uprobes_exe] +# 0x080484c9 : main_func+0x19/0x29 [.../uprobes_exe] +# 0x080484f6 : main+0x1d/0x37 [.../uprobes_exe] +#print_ustack lib 3 +# 0x00db2422 : lib_func+0x16/0x2b [.../libuprobes_lib.so] +# 0x00db2431 : lib_func+0x25/0x2b [.../libuprobes_lib.so] +# 0x00db2455 : lib_main+0x1e/0x29 [.../libuprobes_lib.so] +# 0x080484d0 : main_func+0x20/0x29 [.../uprobes_exe] +# 0x080484c9 : main_func+0x19/0x29 [.../uprobes_exe] +# 0x080484c9 : main_func+0x19/0x29 [.../uprobes_exe] +# 0x080484f6 : main+0x1d/0x37 [.../uprobes_exe] + +set print 0 +set main 0 +set main_func 0 +set lib_main 0 +set lib_func 0 +# Needs extra space since on 64bit the last ubacktrace string is +# 7 entries * (16 hex + 2 for 0x + 1 space) = 133 chars. +# Default MAXSTRINGLEN is 128 chars. +spawn stap -DMAXSTRINGLEN=133 $srcdir/$subdir/$test.stp -c $testexe + +wait +expect { + -timeout 60 + -re {^print_[^\r\n]+\r\n} {incr print; exp_continue} + -re {^ 0x[a-f0-9]+ : main\+0x[^\r\n]+\r\n} {incr main; exp_continue} + -re {^ 0x[a-f0-9]+ : main_func\+0x[^\r\n]+\r\n} {incr main_func; exp_continue} + -re {^ 0x[a-f0-9]+ : lib_main\+0x[^\r\n]+\r\n} {incr lib_main; exp_continue} + -re {^ 0x[a-f0-9]+ : lib_func\+0x[^\r\n]+\r\n} {incr lib_func; exp_continue} + timeout { fail "$test (timeout)" } + eof { } +} + +if {$print == 4} {pass "$test print"} {fail "$test print ($print)"} +if {$main == 4} {pass "$test main"} {fail "$test main ($main)"} +if {$main_func == 9} {pass "$test main_func"} {fail "$test main_func ($main_func)"} +if {$lib_main == 2} {pass "$test lib_main"} {fail "$test lib_main ($lib_main)"} +if {$lib_func == 3} {pass "$test lib_func"} {fail "$test lib_func ($lib_func)"} + +#exec rm -f $testexe $testso diff --git a/testsuite/systemtap.base/uprobes_ustack.stp b/testsuite/systemtap.base/uprobes_ustack.stp new file mode 100644 index 00000000..6de03b42 --- /dev/null +++ b/testsuite/systemtap.base/uprobes_ustack.stp @@ -0,0 +1,35 @@ +// Prints backtrace from lib through exe twice using diffent ustack functions. + +global hits = 0; + +probe process("uprobes_exe").function("main_func") +{ + if (hits == 0) + { + log("print_ubacktrace exe 0"); + print_ubacktrace(); + hits++; + } + else if (hits == 1) + { + log("print_ustack exe 1"); + print_ustack(ubacktrace()); + hits++; + } +} + +probe process("libuprobes_lib.so").function("lib_func") +{ + if (hits == 2) + { + log("print_ubacktrace lib 2"); + print_ubacktrace(); + hits++; + } + else if (hits == 3) + { + log("print_ustack lib 3"); + print_ustack(ubacktrace()); + hits++; + } +} diff --git a/testsuite/systemtap.context/backtrace.tcl b/testsuite/systemtap.context/backtrace.tcl index 6edda812..975e6c4d 100644 --- a/testsuite/systemtap.context/backtrace.tcl +++ b/testsuite/systemtap.context/backtrace.tcl @@ -5,6 +5,7 @@ set m4 0 set m5 0 set m6 0 +#spawn stap -d kernel -d systemtap_test_module1 -DMAXSTRINGLEN=256 $srcdir/$subdir/backtrace.stp spawn stap -DMAXSTRINGLEN=256 $srcdir/$subdir/backtrace.stp #exp_internal 1 expect { diff --git a/testsuite/systemtap.examples/index.html b/testsuite/systemtap.examples/index.html index a2dc7d5c..0df681ac 100644 --- a/testsuite/systemtap.examples/index.html +++ b/testsuite/systemtap.examples/index.html @@ -121,7 +121,7 @@ keywords: <a href="keyword-index.html#SIGNALS">SIGNALS</a> <br> <li><a href="process/sigkill.stp">process/sigkill.stp</a> - Track SIGKILL Signals<br> keywords: <a href="keyword-index.html#SIGNALS">SIGNALS</a> <br> <p>The script traces any SIGKILL signals. When that SIGKILL signal is sent to a process, the script prints out the signal name, the desination executable and process ID, the executable name user ID that sent the signal.</p></li> -<li><a href="process/syscalls_by_pid.stp">process/syscalls_by_pid.stp</a> - System-Wide Count of Syscalls by PID<br> +<li><a href="process/sigmon.stp">process/sigmon.stp</a> - Track a particular signal to a specific process<br> keywords: <a href="keyword-index.html#SIGNALS">SIGNALS</a> <br> <p>The script watches for a particular signal sent to a specific process. When that signal is sent to the specified process, the script prints out the PID and executable of the process sending the signal, the PID and executable name of the process receiving the signal, and the signal number and name.</p></li> <li><a href="process/sleepingBeauties.stp">process/sleepingBeauties.stp</a> - Generating Backtraces of Threads Waiting for IO Operations<br> diff --git a/testsuite/systemtap.examples/index.txt b/testsuite/systemtap.examples/index.txt index 2f85628a..fa344933 100644 --- a/testsuite/systemtap.examples/index.txt +++ b/testsuite/systemtap.examples/index.txt @@ -245,7 +245,7 @@ keywords: signals that sent the signal. -process/syscalls_by_pid.stp - System-Wide Count of Syscalls by PID +process/sigmon.stp - Track a particular signal to a specific process keywords: signals The script watches for a particular signal sent to a specific diff --git a/testsuite/systemtap.examples/keyword-index.html b/testsuite/systemtap.examples/keyword-index.html index 473c0091..7edbec21 100644 --- a/testsuite/systemtap.examples/keyword-index.html +++ b/testsuite/systemtap.examples/keyword-index.html @@ -234,7 +234,7 @@ keywords: <a href="keyword-index.html#SIGNALS">SIGNALS</a> <br> <li><a href="process/sigkill.stp">process/sigkill.stp</a> - Track SIGKILL Signals<br> keywords: <a href="keyword-index.html#SIGNALS">SIGNALS</a> <br> <p>The script traces any SIGKILL signals. When that SIGKILL signal is sent to a process, the script prints out the signal name, the desination executable and process ID, the executable name user ID that sent the signal.</p></li> -<li><a href="process/syscalls_by_pid.stp">process/syscalls_by_pid.stp</a> - System-Wide Count of Syscalls by PID<br> +<li><a href="process/sigmon.stp">process/sigmon.stp</a> - Track a particular signal to a specific process<br> keywords: <a href="keyword-index.html#SIGNALS">SIGNALS</a> <br> <p>The script watches for a particular signal sent to a specific process. When that signal is sent to the specified process, the script prints out the PID and executable of the process sending the signal, the PID and executable name of the process receiving the signal, and the signal number and name.</p></li> </ul> diff --git a/testsuite/systemtap.examples/keyword-index.txt b/testsuite/systemtap.examples/keyword-index.txt index 1d5add5f..b53e776f 100644 --- a/testsuite/systemtap.examples/keyword-index.txt +++ b/testsuite/systemtap.examples/keyword-index.txt @@ -449,7 +449,7 @@ keywords: signals that sent the signal. -process/syscalls_by_pid.stp - System-Wide Count of Syscalls by PID +process/sigmon.stp - Track a particular signal to a specific process keywords: signals The script watches for a particular signal sent to a specific diff --git a/testsuite/systemtap.examples/process/sigmon.meta b/testsuite/systemtap.examples/process/sigmon.meta index 18834997..fe192248 100644 --- a/testsuite/systemtap.examples/process/sigmon.meta +++ b/testsuite/systemtap.examples/process/sigmon.meta @@ -1,5 +1,5 @@ -title: System-Wide Count of Syscalls by PID -name: syscalls_by_pid.stp +title: Track a particular signal to a specific process +name: sigmon.stp version: 1.0 author: IBM keywords: signals |