diff options
Diffstat (limited to 'testsuite')
-rwxr-xr-x | testsuite/semok/cast.stp | 4 | ||||
-rw-r--r-- | testsuite/systemtap.base/bz10078.c | 22 | ||||
-rw-r--r-- | testsuite/systemtap.base/bz10078.exp | 35 | ||||
-rw-r--r-- | testsuite/systemtap.base/bz10078.stp | 4 | ||||
-rw-r--r-- | testsuite/systemtap.base/cast.exp | 6 | ||||
-rw-r--r-- | testsuite/systemtap.base/cast.stp | 21 | ||||
-rw-r--r-- | testsuite/systemtap.base/kprobes.exp | 2 | ||||
-rw-r--r-- | testsuite/systemtap.base/kprobes.stp | 21 | ||||
-rw-r--r-- | testsuite/systemtap.base/utrace_syscall_args.stp | 40 | ||||
-rw-r--r-- | testsuite/systemtap.examples/general/grapher.stp | 10 | ||||
-rwxr-xr-x | testsuite/systemtap.examples/profiling/latencytap.stp | 2 | ||||
-rw-r--r-- | testsuite/systemtap.printf/basic6.exp | 3 | ||||
-rw-r--r-- | testsuite/systemtap.printf/basic6.stp | 5 |
13 files changed, 167 insertions, 8 deletions
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/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 index 04463979..4f326ec1 100644 --- a/testsuite/systemtap.examples/general/grapher.stp +++ b/testsuite/systemtap.examples/general/grapher.stp @@ -2,11 +2,11 @@ probe begin { -printf ("%s\n", "%Title:CPU utilization"); -printf ("%s\n", "%XAxisTitle:Time"); -printf ("%s\n", "%YAxisTitle:Percent"); -printf ("%s\n", "%DataSet:cpu 100 00ff00 bar"); -printf ("%s\n", "%DataSet:kbd 100 ff0000 dot"); +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 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() +} |