summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.base
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/systemtap.base')
-rw-r--r--testsuite/systemtap.base/bz10078.c22
-rw-r--r--testsuite/systemtap.base/bz10078.exp35
-rw-r--r--testsuite/systemtap.base/bz10078.stp4
-rw-r--r--testsuite/systemtap.base/cast.exp6
-rw-r--r--testsuite/systemtap.base/cast.stp21
-rw-r--r--testsuite/systemtap.base/kprobes.exp2
-rw-r--r--testsuite/systemtap.base/kprobes.stp21
-rw-r--r--testsuite/systemtap.base/utrace_syscall_args.stp40
8 files changed, 149 insertions, 2 deletions
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) {