diff options
Diffstat (limited to 'testsuite')
24 files changed, 202 insertions, 35 deletions
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 93da18ef..d30823cd 100755 --- a/testsuite/semok/cast.stp +++ b/testsuite/semok/cast.stp @@ -10,4 +10,8 @@ probe begin { // would be nice to test usermode @cast too, // 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) } 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/bz10078.c b/testsuite/systemtap.base/bz10078.c new file mode 100644 index 00000000..9075fbc7 --- /dev/null +++ b/testsuite/systemtap.base/bz10078.c @@ -0,0 +1,22 @@ +#include <stdlib.h> +#include <stdio.h> + +struct point { int x, y; }; + +struct point mkpoint2(void) +{ + struct point p = { 1, 2 }; + return p; +} + +struct point mkpoint1(void) +{ + return mkpoint2(); +} + +main() +{ + struct point p = mkpoint1(); + printf("%d,%d\n", p.x, p.y); + exit(0); +} diff --git a/testsuite/systemtap.base/bz10078.exp b/testsuite/systemtap.base/bz10078.exp new file mode 100644 index 00000000..cad3a3a8 --- /dev/null +++ b/testsuite/systemtap.base/bz10078.exp @@ -0,0 +1,35 @@ +set test bz10078 + +catch {exec gcc -g -o $test $srcdir/$subdir/$test.c} err +if {$err == "" && [file exists $test]} then { pass "$test compile" } else { fail "$test compile" } + +if {![utrace_p]} { + catch {exec rm -f $test} + untested "$test -p4" + untested "$test -p5" + return +} + +set rc [stap_run_batch $srcdir/$subdir/$test.stp] +if {$rc == 0} then { pass "$test -p4" } else { fail "$test -p4" } + +if {! [installtest_p]} { + catch {exec rm -f $test} + untested "$test -p5" + return +} + +# Pick up the stap being tested. +set stapexe [exec /usr/bin/which stap] +spawn sudo $stapexe $srcdir/$subdir/$test.stp -c ./$test +set ok 0 +expect { + -timeout 60 + -re {mkpoint[^\r\n]* returns\r\n} { incr ok; exp_continue } + -re {1,2\r\n} { incr ok; exp_continue } + timeout { fail "$test (timeout)" } + eof { } +} +wait +if {$ok == 3} then { pass "$test -p5" } else { fail "$test -p5 ($ok)" } +exec rm -f $test diff --git a/testsuite/systemtap.base/bz10078.stp b/testsuite/systemtap.base/bz10078.stp new file mode 100644 index 00000000..0318e4e9 --- /dev/null +++ b/testsuite/systemtap.base/bz10078.stp @@ -0,0 +1,4 @@ +#! stap -p4 +probe process("./bz10078").function("mkpoint*").return { + printf("%s returns\n", probefunc()) +} diff --git a/testsuite/systemtap.base/cast.exp b/testsuite/systemtap.base/cast.exp index df3246e8..74c4d72a 100644 --- a/testsuite/systemtap.base/cast.exp +++ b/testsuite/systemtap.base/cast.exp @@ -1,4 +1,6 @@ set test "cast" set ::result_string {PID OK -execname OK} -stap_run2 $srcdir/$subdir/$test.stp +PID2 OK +execname OK +tv_sec OK} +stap_run2 $srcdir/$subdir/$test.stp -g diff --git a/testsuite/systemtap.base/cast.stp b/testsuite/systemtap.base/cast.stp index bec0cc9b..33a14a28 100644 --- a/testsuite/systemtap.base/cast.stp +++ b/testsuite/systemtap.base/cast.stp @@ -10,6 +10,13 @@ probe begin else 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 + if (pid == cast_pid) + println("PID2 OK") + else + printf("PID2 %d != %d\n", pid, cast_pid) + // Compare execnames name = execname() cast_name = kernel_string(@cast(curr, "task_struct")->comm) @@ -18,5 +25,19 @@ probe begin else printf("execname \"%s\" != \"%s\"\n", name, cast_name) + // Compare tv_sec using a generated user module + sec = 42 + cast_sec = @cast(get_timeval(sec), "timeval", "umod<sys/time.h>")->tv_sec + if (sec == cast_sec) + println("tv_sec OK") + else + printf("tv_sec %d != %d\n", sec, cast_sec) + exit() } + +function get_timeval:long(sec:long) %{ + static struct timeval mytime = {0}; + mytime.tv_sec = THIS->sec; + THIS->__retvalue = (long)&mytime; +%} diff --git a/testsuite/systemtap.base/kprobes.exp b/testsuite/systemtap.base/kprobes.exp new file mode 100644 index 00000000..240ecd82 --- /dev/null +++ b/testsuite/systemtap.base/kprobes.exp @@ -0,0 +1,2 @@ +set test "kprobes" +stap_run $srcdir/$subdir/$test.stp diff --git a/testsuite/systemtap.base/kprobes.stp b/testsuite/systemtap.base/kprobes.stp new file mode 100644 index 00000000..62c18347 --- /dev/null +++ b/testsuite/systemtap.base/kprobes.stp @@ -0,0 +1,21 @@ +/* + * kprobes.stp + * Probe to test the functionality of kprobe-based probes + * (Dwarfless Probing) + */ + +probe begin +{ + println("\n Systemtap starting probe"); +} + +probe kprobe.function("vfs_read") +{ + printf("\n probe point hit"); + exit(); +} + +probe end +{ + println("\n Systemtap starting probe"); +} diff --git a/testsuite/systemtap.base/utrace_syscall_args.stp b/testsuite/systemtap.base/utrace_syscall_args.stp index 166e1ace..6c9e14fc 100644 --- a/testsuite/systemtap.base/utrace_syscall_args.stp +++ b/testsuite/systemtap.base/utrace_syscall_args.stp @@ -113,18 +113,23 @@ probe process("utrace_syscall_args").syscall.return { if (syscalls_seen >= 4) { if (syscalls_seen == 4) { mmap_args[7] = $return + mmap_args[8] = $syscall } else if (syscalls_seen == 5) { munmap_args[3] = $return + munmap_args[4] = $syscall } else if (syscalls_seen == 6) { close_args[2] = $return + close_args[3] = $syscall } else if (syscalls_seen == 7) { dup_args[7] = $return + dup_args[8] = $syscall } else if (syscalls_seen == 8) { bad_syscall_args[7] = $return + bad_syscall_args[8] = $syscall syscalls_seen = 0 } } @@ -159,6 +164,13 @@ probe end failures += 1 printf("mmap bad arg 6: 0x%x vs 0x0\n", mmap_args[6]) } + + # Validate syscall number + if (mmap_args[0] != mmap_args[8]) { + failures += 1 + printf("mmap $syscall mismatch: %d vs. %d\n", + mmap_args[0], mmap_args[8]) + } } # print munmap info @@ -191,6 +203,13 @@ probe end failures += 1 printf("munmap bad return value: 0x%x vs 0x0\n", munmap_args[7]) } + + # Validate syscall number + if (munmap_args[0] != munmap_args[4]) { + failures += 1 + printf("munmap $syscall mismatch: %d vs. %d\n", + munmap_args[0], munmap_args[4]) + } } # print close info @@ -207,6 +226,13 @@ probe end printf("close bad arg 1: 0x%x vs 0x%x\n", close_args[0], mmap_args[5]) } + + # Validate syscall number + if (close_args[0] != close_args[3]) { + failures += 1 + printf("close $syscall mismatch: %d vs. %d\n", + close_args[0], close_args[3]) + } } # print dup info @@ -278,6 +304,13 @@ probe end printf("dup bad arg 6: 0x%x vs 0xe38e38e3\n", dup_args[6]) } } + + # Validate syscall number + if (dup_args[0] != dup_args[8]) { + failures += 1 + printf("dup $syscall mismatch: %d vs. %d\n", + dup_args[0], dup_args[8]) + } } # print bad_syscall info @@ -355,6 +388,13 @@ probe end bad_syscall_args[6]) } } + + # Validate syscall number + if (bad_syscall_args[0] != bad_syscall_args[8]) { + failures += 1 + printf("bad_syscall $syscall mismatch: %d vs. %d\n", + bad_syscall_args[0], bad_syscall_args[8]) + } } if (failures == 0) { diff --git a/testsuite/systemtap.examples/general/grapher.stp b/testsuite/systemtap.examples/general/grapher.stp new file mode 100644 index 00000000..4f326ec1 --- /dev/null +++ b/testsuite/systemtap.examples/general/grapher.stp @@ -0,0 +1,32 @@ +#! /usr/bin/stap + +probe begin +{ +printf ("%%Title:CPU utilization\n"); +printf ("%%XAxisTitle:Time"); +printf ("%%YAxisTitle:Percent"); +printf ("%%DataSet:cpu 100 00ff00 bar"); +printf ("%%DataSet:kbd 100 ff0000 dot"); +} + +# CPU utilization +probe begin { qnames["cpu"] ++; qsq_start ("cpu") } +probe scheduler.cpu_on { if (!idle) {qs_wait ("cpu") qs_run ("cpu") }} +probe scheduler.cpu_off { if (!idle) qs_done ("cpu") } + +global qnames + +function qsq_util_reset(q) { + u=qsq_utilization (q, 100) + qsq_start (q) + return u +} + +probe timer.ms(100) { # collect utilization percentages frequently + foreach (q in qnames) + printf("cpu %d %d\n", gettimeofday_ms(), qsq_util_reset(q)) +} + +probe kernel.function("kbd_event") { + printf("kbd %d %d\n", gettimeofday_ms(), 75) +} diff --git a/testsuite/systemtap.examples/profiling/latencytap.stp b/testsuite/systemtap.examples/profiling/latencytap.stp index 28956129..d202ec81 100755 --- a/testsuite/systemtap.examples/profiling/latencytap.stp +++ b/testsuite/systemtap.examples/profiling/latencytap.stp @@ -23,7 +23,7 @@ function _get_sleep_time:long(rq_param:long, p_param:long) function task_backtrace:string (task:long) %{ _stp_stack_snprint_tsk(THIS->__retvalue, MAXSTRINGLEN, - (struct task_struct *)THIS->task, 0, MAXTRACE); + (struct task_struct *)(unsigned long)THIS->task, 0, MAXTRACE); %} probe kernel.function("enqueue_task_fair") { diff --git a/testsuite/systemtap.printf/basic6.exp b/testsuite/systemtap.printf/basic6.exp new file mode 100644 index 00000000..72bf8f57 --- /dev/null +++ b/testsuite/systemtap.printf/basic6.exp @@ -0,0 +1,3 @@ +set test "basic6" +set ::result_string {Hello%World} +stap_run2 $srcdir/$subdir/$test.stp diff --git a/testsuite/systemtap.printf/basic6.stp b/testsuite/systemtap.printf/basic6.stp new file mode 100644 index 00000000..69721188 --- /dev/null +++ b/testsuite/systemtap.printf/basic6.stp @@ -0,0 +1,5 @@ +probe begin +{ + printf("Hello%%World"); + exit() +} |