summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStan Cox <scox@redhat.com>2009-02-01 21:34:52 -0500
committerStan Cox <scox@redhat.com>2009-02-01 21:34:52 -0500
commitd44d3f7f73e2ef22694e9d2f6c48f77ba2204a59 (patch)
tree1c1c735c7521f4d3228588a38eb699bb53a3970e
parent0f336e95987931dd9fd35de02deee0ce682b987a (diff)
downloadsystemtap-steved-d44d3f7f73e2ef22694e9d2f6c48f77ba2204a59.tar.gz
systemtap-steved-d44d3f7f73e2ef22694e9d2f6c48f77ba2204a59.tar.xz
systemtap-steved-d44d3f7f73e2ef22694e9d2f6c48f77ba2204a59.zip
Add test for .label("label")
-rw-r--r--testsuite/systemtap.base/labels.exp67
1 files changed, 67 insertions, 0 deletions
diff --git a/testsuite/systemtap.base/labels.exp b/testsuite/systemtap.base/labels.exp
new file mode 100644
index 00000000..6c62d576
--- /dev/null
+++ b/testsuite/systemtap.base/labels.exp
@@ -0,0 +1,67 @@
+set test "labels"
+if {![installtest_p]} {untested $test; return}
+
+# Try to find utrace_attach symbol in /proc/kallsyms
+# copy from utrace_p5.exp
+set utrace_support_found 0
+set path "/proc/kallsyms"
+if {! [catch {exec grep -q utrace_attach $path} dummy]} {
+ set utrace_support_found 1
+}
+if {$utrace_support_found == 0} { untested "$test"; return }
+
+# Compile a C program to use as the user-space probing target
+set label_srcpath "[pwd]/labels.c"
+set label_exepath "[pwd]/labels.x"
+set label_flags "additional_flags=-g"
+set fp [open $label_srcpath "w"]
+puts $fp "
+int
+main ()
+{
+ sleep(5);
+ int a = 0;
+ int b = 0;
+ char *c;
+init_an_int:
+ a = 2;
+init_another_int:
+ b = 3;
+ c = \"abc\";
+ptr_inited:
+ return 1;
+}
+"
+close $fp
+
+set fp [open "[pwd]/labels.stp" "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)}
+"
+close $fp
+
+set ok 0
+
+set res [target_compile $label_srcpath $label_exepath executable $label_flags]
+if { $res != "" } {
+ verbose "target_compile failed: $res" 2
+ fail "compiling labels.c -g"
+ return
+} else {
+ pass "compiling labels.c -g"
+}
+
+verbose -log "spawn stap -c $label_exepath [pwd]/labels.stp"
+spawn stap -c $label_exepath [pwd]/labels.stp
+
+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 }
+ timeout { fail "$test (timeout)" }
+ eof { }
+}
+
+wait
+
+if {$ok == 1} { pass "$test" } { fail "$test ($ok)" }