summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.base
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/systemtap.base')
-rw-r--r--testsuite/systemtap.base/bitfield.exp3
-rw-r--r--testsuite/systemtap.base/bitfield.stp46
-rw-r--r--testsuite/systemtap.base/labels.exp41
-rw-r--r--testsuite/systemtap.base/stmt_rel.exp4
-rw-r--r--testsuite/systemtap.base/uprobes_exe.c8
-rw-r--r--testsuite/systemtap.base/uprobes_lib.c3
-rw-r--r--testsuite/systemtap.base/uprobes_lib.exp13
-rw-r--r--testsuite/systemtap.base/uprobes_lib.stp10
-rw-r--r--testsuite/systemtap.base/uprobes_uname.exp46
-rw-r--r--testsuite/systemtap.base/uprobes_uname.stp7
10 files changed, 160 insertions, 21 deletions
diff --git a/testsuite/systemtap.base/bitfield.exp b/testsuite/systemtap.base/bitfield.exp
new file mode 100644
index 00000000..16451369
--- /dev/null
+++ b/testsuite/systemtap.base/bitfield.exp
@@ -0,0 +1,3 @@
+# test that bitfield r/w works correctly
+set test "bitfield"
+stap_run $srcdir/$subdir/$test.stp no_load $all_pass_string -g
diff --git a/testsuite/systemtap.base/bitfield.stp b/testsuite/systemtap.base/bitfield.stp
new file mode 100644
index 00000000..c2ff4929
--- /dev/null
+++ b/testsuite/systemtap.base/bitfield.stp
@@ -0,0 +1,46 @@
+%{
+#include <linux/tcp.h>
+static struct tcphdr foo = {0};
+%}
+
+function get_ptr:long() %{ THIS->__retvalue = (long)&foo; /* pure */ %}
+function get_ack:long() %{ THIS->__retvalue = foo.ack; /* pure */ %}
+function get_urg:long() %{ THIS->__retvalue = foo.urg; /* pure */ %}
+
+function check:long(ack:long, urg:long) {
+ ptr = get_ptr()
+
+ /* set the bits with cast */
+ @cast(ptr, "tcphdr")->ack = ack
+ @cast(ptr, "tcphdr")->urg = urg
+
+ /* check that reading with embedded-C is ok */
+ real_ack = get_ack()
+ real_urg = get_urg()
+ errors = (ack != real_ack) + (urg != real_urg)
+
+ /* check that reading with a cast is ok */
+ cast_ack = @cast(ptr, "tcphdr")->ack
+ cast_urg = @cast(ptr, "tcphdr")->urg
+ errors += (ack != cast_ack) + (urg != cast_urg)
+
+ if (errors)
+ printf("bitfield had %d errors; expect(%d%d), real(%d%d), cast(%d%d)\n",
+ errors, ack, urg, real_ack, real_urg, cast_ack, cast_urg)
+
+ return errors
+}
+
+probe begin {
+ println("systemtap starting probe")
+
+ errors = check(0, 0)
+ errors += check(0, 1)
+ errors += check(1, 0)
+ errors += check(1, 1)
+
+ println("systemtap ending probe")
+ if (errors == 0)
+ println("systemtap test success")
+ exit()
+}
diff --git a/testsuite/systemtap.base/labels.exp b/testsuite/systemtap.base/labels.exp
index 2f79a502..88ed4619 100644
--- a/testsuite/systemtap.base/labels.exp
+++ b/testsuite/systemtap.base/labels.exp
@@ -10,15 +10,22 @@ set label_flags "additional_flags=-g"
set fp [open $label_srcpath "w"]
puts $fp "
int
+foo ()
+{
+init_an_int:
+ return 1;
+}
+int
main ()
{
sleep(5);
+ foo();
int a = 0;
int b = 0;
char *c;
init_an_int:
a = 2;
-init_another_int:
+init_an_int_again:
b = 3;
c = \"abc\";
ptr_inited:
@@ -30,8 +37,9 @@ close $fp
set label_stppath "[pwd]/labels.stp"
set fp [open $label_stppath "w"]
puts $fp "
-probe process(\"labels.x\").function(\"main*@labels.c\").label(\"init_*\") {printf (\"VARS %s\\n\",\$\$vars)}
-probe process(\"labels.x\").function(\"main*@labels.c\").label(\"ptr_inited\") {printf (\"VARS %s\\n\",\$\$vars)}
+probe process(\"labels.x\").function(\"main@labels.c\").label(\"init_*\") {printf (\"VARS %s\\n\",\$\$vars)}
+probe process(\"labels.x\").function(\"main@labels.c\").label(\"ptr_inited\") {printf (\"VARS %s\\n\",\$\$vars)}
+probe process(\"labels.x\").function(\"main@labels.c\").label(\"init_an_int\") {printf (\"init_an_int\\n\")}
"
close $fp
@@ -47,20 +55,35 @@ if { $res != "" } {
pass "compiling labels.c -g"
}
+# list of labels
+
+spawn stap -l "process(\"$label_exepath\").function(\"*\").label(\"*\")"
+
+wait
+expect {
+ -timeout 180
+ -re {process.*function.*labels.c:5...label..init_an_int.*process.*function.*labels.c:16...label..init_an_int.*process.*function.*labels.c:18...label..init_an_int_again} { incr ok; exp_continue }
+ timeout { fail "$test (timeout)" }
+ eof { }
+}
+
+if {$ok == 1} { pass "$test -l .label" } { fail "$test -l .label $ok" }
+
# label in an executable
+set ok 0
verbose -log "spawn stap -c $label_exepath $label_stppath"
spawn stap -c $label_exepath $label_stppath
wait
expect {
-timeout 180
- -re {VARS a=0x0 b=0x0.*VARS a=0x2 b=0x0.*VARS a=0x2 b=0x3 c=0x[a-f01-9]} { incr ok; exp_continue }
+ -re {VARS a=0x0 b=0x0.*init_an_int.*VARS a=0x2 b=0x0.*VARS a=0x2 b=0x3 c=0x[a-f01-9]} { incr ok; exp_continue }
timeout { fail "$test (timeout)" }
eof { }
}
-if {$ok == 1} { pass "$test exe .label" } { fail "$test exe .label" }
+if {$ok == 1} { pass "$test exe .label" } { fail "$test exe .label $ok" }
# address of label in an executable
@@ -68,7 +91,7 @@ set label_shpath "[pwd]/label.sh"
set fp [open $label_shpath "w"]
puts $fp "
readelf --debug-dump $label_exepath | awk \"
-/init_another_int/ {have_label=1}
+/init_an_int_again/ {have_label=1}
/DW_AT_low_pc/ {if (have_label) {print \$3;exit;}}
\"
"
@@ -103,7 +126,7 @@ if { $res != "" } {
# label in a shared object
-spawn stap -p2 -l "process\(\"$label_sopath\"\).function\(\"\*\"\).label\(\"init_another_int\"\)"
+spawn stap -p2 -l "process\(\"$label_sopath\"\).function\(\"\*\"\).label\(\"init_an_int_again\"\)"
expect {
-timeout 180
-re {process.*function} { incr ok; exp_continue }
@@ -111,7 +134,7 @@ expect {
eof { }
}
-if {$ok == 1} { pass "$test so .label" } { fail "$test so .label" }
+if {$ok == 1} { pass "$test so .label" } { fail "$test so .label $ok" }
# address of label in a shared object
@@ -119,7 +142,7 @@ set label_shpath "[pwd]/label.sh"
set fp [open $label_shpath "w"]
puts $fp "
readelf --debug-dump $label_sopath | awk \"
-/init_another_int/ {have_label=1}
+/init_an_int_again/ {have_label=1}
/DW_AT_low_pc/ {if (have_label) {print \$3;exit;}}
\"
"
diff --git a/testsuite/systemtap.base/stmt_rel.exp b/testsuite/systemtap.base/stmt_rel.exp
index ec12e484..619c91a5 100644
--- a/testsuite/systemtap.base/stmt_rel.exp
+++ b/testsuite/systemtap.base/stmt_rel.exp
@@ -33,7 +33,9 @@ expect {
eof { }
}
-if { $ok == 3 } {
+# bio_init drifts a bit in different kernels.
+# maybe 3, 4 or 15 lines in it.
+if { $ok >= 3 } {
pass "$test wildcard"
} else {
fail "$test wildcard ($ok)"
diff --git a/testsuite/systemtap.base/uprobes_exe.c b/testsuite/systemtap.base/uprobes_exe.c
index 447434c6..b4811335 100644
--- a/testsuite/systemtap.base/uprobes_exe.c
+++ b/testsuite/systemtap.base/uprobes_exe.c
@@ -15,13 +15,15 @@ int lib_main (void);
void
main_func (int foo)
{
- ; // nothing here...
+ if (foo > 1)
+ main_func (foo - 1);
+ else
+ lib_main();
}
int
main (int argc, char *argv[], char *envp[])
{
- main_func(1);
- lib_main();
+ main_func (3);
return 0;
}
diff --git a/testsuite/systemtap.base/uprobes_lib.c b/testsuite/systemtap.base/uprobes_lib.c
index c9d70625..25297b6b 100644
--- a/testsuite/systemtap.base/uprobes_lib.c
+++ b/testsuite/systemtap.base/uprobes_lib.c
@@ -10,7 +10,8 @@
void
lib_func (int bar)
{
- ; // nothing here...
+ if (bar > 1)
+ lib_func (bar - 1);
}
void
diff --git a/testsuite/systemtap.base/uprobes_lib.exp b/testsuite/systemtap.base/uprobes_lib.exp
index 63ef957a..313c01b6 100644
--- a/testsuite/systemtap.base/uprobes_lib.exp
+++ b/testsuite/systemtap.base/uprobes_lib.exp
@@ -29,11 +29,14 @@ if { $res != "" } {
pass "$test compile $testsrc"
}
-# XXX main_func needs another/extra test. Disabled for now.
-# Enable (and in uprobes_lib.stp) after PR9940 is fixed.
-# set ::result_string {main_func
-# lib_func}
-set ::result_string {lib_func}
+set ::result_string {main
+main_func
+main_func
+main_func
+lib_main
+lib_func
+lib_func
+lib_func}
# Only run on make installcheck
if {! [installtest_p]} { untested "$test"; return }
diff --git a/testsuite/systemtap.base/uprobes_lib.stp b/testsuite/systemtap.base/uprobes_lib.stp
index bc6cc249..459351a4 100644
--- a/testsuite/systemtap.base/uprobes_lib.stp
+++ b/testsuite/systemtap.base/uprobes_lib.stp
@@ -1,8 +1,14 @@
-/* - Not activated probe... Seems always skipped?
+probe process("uprobes_exe").function("main") {
+ printf("main\n");
+}
+
probe process("uprobes_exe").function("main_func") {
printf("main_func\n");
}
-*/
+
+probe process("libuprobes_lib.so").function("lib_main") {
+ printf("lib_main\n");
+}
probe process("libuprobes_lib.so").function("lib_func") {
printf("lib_func\n");
diff --git a/testsuite/systemtap.base/uprobes_uname.exp b/testsuite/systemtap.base/uprobes_uname.exp
new file mode 100644
index 00000000..65e1ff70
--- /dev/null
+++ b/testsuite/systemtap.base/uprobes_uname.exp
@@ -0,0 +1,46 @@
+set test "uprobes_uname"
+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 }
+stap_run2 $srcdir/$subdir/$test.stp -c $testexe
+
+#exec rm -f $testexe $testso
diff --git a/testsuite/systemtap.base/uprobes_uname.stp b/testsuite/systemtap.base/uprobes_uname.stp
new file mode 100644
index 00000000..a44d78d3
--- /dev/null
+++ b/testsuite/systemtap.base/uprobes_uname.stp
@@ -0,0 +1,7 @@
+probe process("uprobes_exe").function("*") {
+ printf("exe: %s=%s\n",probefunc(), usymname(uaddr()));
+}
+
+probe process("libuprobes_lib.so").function("*") {
+ printf("lib: %s=%s\n",probefunc(), usymname(uaddr()));
+}