summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.base
diff options
context:
space:
mode:
authorMark Wielaard <mjw@redhat.com>2009-02-20 14:56:38 +0100
committerMark Wielaard <mjw@redhat.com>2009-02-20 14:56:38 +0100
commit02615365a92ca2570c1f96abc8a97674aa2ccae1 (patch)
treeebedfd91a0f6d299b39e84295e091e12c0767dc8 /testsuite/systemtap.base
parentc3bad3042df505a3470f1e20b09822a9df1d4761 (diff)
parentadc67597f327cd43d58b1d0cb740dab14a75a058 (diff)
downloadsystemtap-steved-02615365a92ca2570c1f96abc8a97674aa2ccae1.tar.gz
systemtap-steved-02615365a92ca2570c1f96abc8a97674aa2ccae1.tar.xz
systemtap-steved-02615365a92ca2570c1f96abc8a97674aa2ccae1.zip
Merge branch 'master' into pr6866
Conflicts: ChangeLog: Removed runtime/ChangeLog: Removed runtime/sym.c: Merged runtime/task_finder.c: Merged tapset/ChangeLog: Removed testsuite/ChangeLog: Removed
Diffstat (limited to 'testsuite/systemtap.base')
-rw-r--r--testsuite/systemtap.base/arith.exp14
-rw-r--r--testsuite/systemtap.base/arith.stp79
-rw-r--r--testsuite/systemtap.base/arith_limits.exp13
-rw-r--r--testsuite/systemtap.base/arith_limits.stp80
-rwxr-xr-xtestsuite/systemtap.base/bz5274.exp13
-rw-r--r--testsuite/systemtap.base/bz6850.exp13
-rw-r--r--testsuite/systemtap.base/control_limits.exp46
-rw-r--r--testsuite/systemtap.base/control_limits.stp24
-rw-r--r--testsuite/systemtap.base/crash.exp45
-rwxr-xr-xtestsuite/systemtap.base/crash.sh8
-rw-r--r--testsuite/systemtap.base/gtod.c26
-rw-r--r--testsuite/systemtap.base/gtod.exp40
-rwxr-xr-xtestsuite/systemtap.base/gtod.sh4
-rw-r--r--testsuite/systemtap.base/gtod.stp8
-rw-r--r--testsuite/systemtap.base/labels.exp70
-rw-r--r--testsuite/systemtap.base/poll_map.exp14
-rwxr-xr-xtestsuite/systemtap.base/poll_map.stp33
-rw-r--r--testsuite/systemtap.base/static_uprobes.exp197
-rw-r--r--testsuite/systemtap.base/system_func.exp22
-rw-r--r--testsuite/systemtap.base/system_func.stp35
-rw-r--r--testsuite/systemtap.base/uprobes.exp14
21 files changed, 695 insertions, 103 deletions
diff --git a/testsuite/systemtap.base/arith.exp b/testsuite/systemtap.base/arith.exp
new file mode 100644
index 00000000..c4f72793
--- /dev/null
+++ b/testsuite/systemtap.base/arith.exp
@@ -0,0 +1,14 @@
+set test "arith"
+if {![installtest_p]} { untested $test; return }
+
+spawn stap -DMAXNESTING=5 $srcdir/$subdir/arith.stp
+set ok 0
+expect {
+ -timeout 150
+ -re {passes: [0-9]* failures: 0} { incr ok }
+ timeout { fail "$test (timeout)" }
+ eof { }
+}
+close
+wait
+if {$ok == 1} { pass "$test" } { fail "$test" }
diff --git a/testsuite/systemtap.base/arith.stp b/testsuite/systemtap.base/arith.stp
new file mode 100644
index 00000000..59016dcb
--- /dev/null
+++ b/testsuite/systemtap.base/arith.stp
@@ -0,0 +1,79 @@
+global testno, passes, failures
+
+function test (v,n1,n2) {
+ if (n1 == n2) {
+ passes ++
+ result = "pass"
+ } else {
+ failures ++
+ result = "fail"
+ }
+ println ("test " . (sprint (++testno)) . " [" . v . "]\t" . result)
+}
+
+function stest (v,n1,n2) {
+ if (n1 == n2) {
+ passes ++
+ result = "pass"
+ } else {
+ failures ++
+ result = "fail"
+ }
+ println ("test " . (sprint (++testno)) . " [" . v . "]\t" . result)
+}
+
+
+probe begin {
+ test ("+", 0, 0+0)
+ test ("+", 33339999, 33330000+9999)
+ test ("-", -1, 2-3)
+ test ("==", 1, -1==-1)
+ test ("!=", 1, -1!=1)
+ test ("== s", 1, "foobar"=="foobar")
+ test ("<= s", 1, "fooban"<="foobar")
+ test ("> s", 1, "xxx">"aaa")
+ test ("<", 1, -1<0)
+ test ("<", 1, 85723838<8273823892)
+ test ("*", 100300400500, 1003004005 * 100)
+ test ("*", -1*-500, 500)
+ test ("/", 1003004005/1000, 1003004)
+ test ("%", 1003004005%1000, 5)
+ test ("/", -1/-1, 1)
+ test ("%", -1%-1, 0)
+ test ("/", 0/-100, 0)
+ test ("%", 0%-100, 0)
+ test ("/", (-2147483647-1)/-1, 2147483648)
+ test ("%", (-2147483647-1)%-1, 0)
+ # but (-9223372036854775807-1)/-1 may overflow
+ test ("%", (-9223372036854775807-1)%-1, 0)
+ test ("&", 0x555&0xaaa, 0)
+ test ("|", 0x555|0xaaa, 0xfff)
+ test ("^", 0x55f^0xaaf, 0xff0)
+ test ("&&", 0x555&&0xaaa, 1)
+ test ("||", 0x555||0xaaa, 1)
+ test ("<<", 0<<5, 0)
+ test ("<<", 1<<8, 0x100)
+ test ("<<", 120<<-2, 120)
+ test ("<<", 120<<0, 120)
+ test ("<<", -4096<<-3, -4096)
+ test (">>", -4096>>3, -512)
+ test (">>", -4096>>-3, -4096)
+ test (">>", 120>>-2, 120)
+ test (">>", 120>>0, 120)
+ i=1; test ("--i", --i, 0)
+ i=1; test ("++i", ++i, 2)
+ i=1; test ("i--", i--, 1)
+ i=1; test ("i++", i++, 1)
+ i=1; test ("+=", i+=4, 5) test ("after +=", i, 5)
+ i=5; test ("/=", i/=2, 2) test ("after /=", i, 2)
+ a="1" b="2"; stest (".=", a .= b, "12") stest ("after .=", a, "12")
+}
+
+
+probe timer.jiffies(1) { # some time after all the begin probes
+ exit ()
+}
+
+probe end {
+ printf ("passes: %d failures: %d\n", passes, failures)
+}
diff --git a/testsuite/systemtap.base/arith_limits.exp b/testsuite/systemtap.base/arith_limits.exp
new file mode 100644
index 00000000..93794c8e
--- /dev/null
+++ b/testsuite/systemtap.base/arith_limits.exp
@@ -0,0 +1,13 @@
+set test "arith_limits"
+if {![installtest_p]} { untested $test; return }
+
+spawn stap -DMAXNESTING=5 $srcdir/$subdir/arith_limits.stp
+set ok 0
+expect {
+ -timeout 150
+ -re {passes: [0-9]* failures: 0} { incr ok }
+ timeout { fail "$test (timeout)" }
+ eof { }
+}
+wait
+if {$ok == 1} { pass "$test" } { fail "$test" }
diff --git a/testsuite/systemtap.base/arith_limits.stp b/testsuite/systemtap.base/arith_limits.stp
new file mode 100644
index 00000000..6c620830
--- /dev/null
+++ b/testsuite/systemtap.base/arith_limits.stp
@@ -0,0 +1,80 @@
+global testno, passes, failures
+
+function test (v,n1,n2) {
+ if (n1 == n2) {
+ passes ++
+ result = "pass"
+ } else {
+ failures ++
+ result = "fail"
+ }
+ printf ("test %d [%s]\t\t%s\n", testno++, v, result)
+}
+
+# Exactly the same as test() except it will magically work for strings.
+# Wouldn't it be nice if we didn't have to do this?
+
+function teststr (v,n1,n2) {
+ if (n1 == n2) {
+ passes ++
+ result = "pass"
+ } else {
+ failures ++
+ result = "fail"
+ }
+ printf ("test %d [%s]\t\t%s\n", testno++, v, result)
+}
+
+
+
+probe begin {
+ # max/minimum signed 32-bit values.
+ # these could cause problems for 32-bit cpus when overflows
+ # occur into 64-but values
+ lmax = 0x7fffffff
+ lmin = -0x80000000
+
+ # max/minimum signed 64-bit values
+ llmax = 0x7fffffffffffffff
+ llmin = -0x7fffffffffffffff-1
+
+ # 32-bit limit tests
+ teststr ("string lmax", sprint(lmax), "2147483647")
+ teststr ("hex lmax", sprintf("0x%x", lmax), "0x7fffffff")
+ teststr ("string lmin", sprint(lmin), "-2147483648")
+ teststr ("hex lmin", sprintf("0x%x", lmin), "0xffffffff80000000")
+ test ("lmax/-1", lmax/-1, -2147483647);
+ test ("lmin/-1", lmin/-1, 2147483648);
+ test ("lmax +1", lmax+1, 2147483648);
+ test ("lmin -1", lmin-1, -2147483649);
+
+ # 64-bit limits
+ teststr ("string llmax", sprint(llmax), "9223372036854775807")
+ teststr ("hex llmax", sprintf("0x%x", llmax), "0x7fffffffffffffff")
+ teststr ("string llmin", sprint(llmin), "-9223372036854775808")
+ teststr ("hex llmin", sprintf("0x%x", llmin), "0x8000000000000000")
+ test ("llmax/-1", llmax/-1, -llmax)
+ test ("llmax*-1", llmax*-1, -llmax)
+
+ # the next three overflow and produce predictable, although
+ # wrong results
+ test ("llmin/-1", llmin/-1, llmin)
+ test ("llmin*-1", llmin*-1, llmin)
+ test ("llmax +1", llmax+1, llmin)
+ test ("llmin -1", llmin-1, llmax)
+
+ # modulo tests
+ test ("llmax%1", llmax%1, 0)
+ test ("llmin%1", llmin%1, 0)
+ test ("0%1 ", 0%1, 0)
+ test ("0%lmax", 0%lmax, 0)
+ test ("1%lmax", 1%lmax, 1)
+ test ("0%lmin", 0%lmin, 0)
+ test ("1%lmin", 1%lmin, 1)
+
+ exit()
+}
+
+probe end {
+ printf ("passes: %d failures: %d\n", passes, failures)
+}
diff --git a/testsuite/systemtap.base/bz5274.exp b/testsuite/systemtap.base/bz5274.exp
index db0e0a46..92441e9e 100755
--- a/testsuite/systemtap.base/bz5274.exp
+++ b/testsuite/systemtap.base/bz5274.exp
@@ -8,11 +8,14 @@ if {$arch == "ppc64"} {
catch {exec gcc -o $test -g $srcdir/$subdir/$test.c} err
}
-
if {$err == "" && [file exists $test]} then { pass "$test compile"
} else {fail "$test compile"}
-if {! [installtest_p]} { untested "$test -p5"; return }
+if {! [installtest_p]} {
+ catch {exec rm -f $test}
+ untested "$test -p5"
+ return
+}
# Try to find utrace_attach symbol in /proc/kallsyms
# copy from utrace_p5.exp
@@ -21,7 +24,11 @@ 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 -p5"; return }
+if {$utrace_support_found == 0} {
+ catch {exec rm -f $test}
+ untested "$test -p5"
+ return
+}
if {[catch {exec stap $tpath.stp -c "$srcdir/$subdir/$test.sh"} res]} {
untested "$test longjmp to a uretprobed function"
diff --git a/testsuite/systemtap.base/bz6850.exp b/testsuite/systemtap.base/bz6850.exp
index 73fedc8a..b96ed95c 100644
--- a/testsuite/systemtap.base/bz6850.exp
+++ b/testsuite/systemtap.base/bz6850.exp
@@ -10,12 +10,21 @@ 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 -p4"; untested "$test -p5"; return }
+if {$utrace_support_found == 0} {
+ catch {exec rm -f $test}
+ untested "$test -p4"
+ untested "$test -p5"
+ return
+}
set rc [stap_run_batch $srcdir/$subdir/bz6850.stp]
if {$rc == 0} then { pass "$test -p4" } else { fail "$test -p4" }
-if {! [installtest_p]} { untested "$test -p5"; return }
+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]
diff --git a/testsuite/systemtap.base/control_limits.exp b/testsuite/systemtap.base/control_limits.exp
new file mode 100644
index 00000000..513b2c4d
--- /dev/null
+++ b/testsuite/systemtap.base/control_limits.exp
@@ -0,0 +1,46 @@
+set test "control_limits MAXNESTING"
+if {![installtest_p]} { untested $test; return }
+
+spawn stap -u -DMAXNESTING=5 $srcdir/$subdir/control_limits.stp
+set ok 0
+expect {
+ -timeout 150
+ -re {ERROR.*MAXNESTING} { incr ok; exp_continue }
+ timeout { fail "$test (timeout)" }
+ eof { }
+}
+if {$ok == 1} { pass "$test ($ok)" } { fail "$test ($ok)" }
+
+set test "control_limits MAXACTION"
+spawn stap -u -DMAXACTION_INTERRUPTIBLE=500 $srcdir/$subdir/control_limits.stp
+set ok 0
+expect {
+ -timeout 150
+ -re {ERROR.*MAXACTION} { incr ok; exp_continue }
+ timeout { fail "$test (timeout)" }
+ eof { }
+}
+if {$ok == 1} { pass "$test ($ok)" } { fail "$test ($ok)" }
+
+set test "control_limits MAXSTRINGLEN small"
+spawn stap -u -DMAXSTRINGLEN=50 $srcdir/$subdir/control_limits.stp
+set ok 0
+expect {
+ -timeout 150
+ -re {ERROR.*MAXSTRINGLEN reduced} { incr ok; exp_continue }
+ timeout { fail "$test (timeout)" }
+ eof { }
+}
+if {$ok == 1} { pass "$test ($ok)" } { fail "$test ($ok)" }
+
+set test "control_limits MAXSTRINGLEN large"
+spawn stap -u -DMAXSTRINGLEN=500 $srcdir/$subdir/control_limits.stp
+set ok 0
+expect {
+ -timeout 150
+ -re {ERROR.*MAXSTRINGLEN enlarged} { incr ok; exp_continue }
+ timeout { fail "$test (timeout)" }
+ eof { }
+}
+if {$ok == 1} { pass "$test ($ok)" } { fail "$test ($ok)" }
+
diff --git a/testsuite/systemtap.base/control_limits.stp b/testsuite/systemtap.base/control_limits.stp
new file mode 100644
index 00000000..89b0bae4
--- /dev/null
+++ b/testsuite/systemtap.base/control_limits.stp
@@ -0,0 +1,24 @@
+
+# for MAXNESTING testing
+function recurse (n) {
+ if (n > 0) recurse (n-1)
+}
+probe begin {
+ recurse (7)
+}
+
+# for MAXACTION testing
+probe begin {
+ for (i=0; i<498; i++) {}
+}
+
+# for MAXSTRINGLEN testing
+probe begin {
+ s = "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678" # last 8 will be \0'd
+ if (strlen(s) < 127) error ("MAXSTRINGLEN reduced")
+ if (strlen(s) > 127) error ("MAXSTRINGLEN enlarged")
+}
+
+
+probe begin { exit () }
+
diff --git a/testsuite/systemtap.base/crash.exp b/testsuite/systemtap.base/crash.exp
new file mode 100644
index 00000000..9c3e5e05
--- /dev/null
+++ b/testsuite/systemtap.base/crash.exp
@@ -0,0 +1,45 @@
+# Simple test for staplog.so crash(8) extension
+set test "crash"
+
+if {![installtest_p]} { untested $test; return }
+if {![file exists $env(CRASH_LIBDIR)/staplog.so]} { untested "$test - no staplog.so"; return }
+
+# Load a test script
+spawn stap $srcdir/$subdir/testlog.stp -m testlog
+expect {
+ -timeout 120
+ "HelloWorld\r\n" {
+ pass "$test - testlog.stp"
+ # Need to run crash(8) while this script is still running.
+ # Since crash(8) needs /dev/mem access, need it run as_root too.
+ # This [ eval ... \{ \} ] business is necessary because as_root
+ # evals the given list/variables in its own scope.
+ eval as_root \{ $srcdir/$subdir/crash.sh $env(CRASH_LIBDIR) \}
+ }
+ timeout { fail "$test - testlog.stp timeout" }
+ timeout { fail "$test - testlog.stp eof" }
+}
+catch { exec kill -INT -[exp_pid]; close ; wait }
+
+# The crash(8) script creates testlog/global or testlog/cpu<n>
+as_root { chmod -R a+rX testlog }
+
+set ok 0
+foreach f [glob -nocomplain testlog/*] {
+ pass "$test - crash(8) generated $f"
+ set fp [open $f]
+ set chars [read $fp]
+ close $fp
+ if [string match "HelloWorld*" $chars] {
+ incr ok
+ pass "$test - crash(8) data"
+ } else {
+ fail "$test - crash(8) data $chars"
+ }
+}
+if {$ok == 0} {
+ fail "$test - crash(8) data"
+}
+
+as_root { rm -rf testlog testlog.ko }
+
diff --git a/testsuite/systemtap.base/crash.sh b/testsuite/systemtap.base/crash.sh
new file mode 100755
index 00000000..06aa414e
--- /dev/null
+++ b/testsuite/systemtap.base/crash.sh
@@ -0,0 +1,8 @@
+#! /bin/sh
+
+crash --readnow << END
+mod -s testlog testlog.ko
+extend $1/staplog.so
+staplog testlog
+exit
+END
diff --git a/testsuite/systemtap.base/gtod.c b/testsuite/systemtap.base/gtod.c
new file mode 100644
index 00000000..abc08543
--- /dev/null
+++ b/testsuite/systemtap.base/gtod.c
@@ -0,0 +1,26 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/time.h>
+#include <unistd.h>
+
+int main (int argc, char *argv[])
+{
+ int i;
+ struct timeval tv[100][2];
+ int us = 0;
+ if (argc == 2) us = atoi(argv[1]);
+ for (i=0; i<100; i++) {
+ gettimeofday(&tv[i][0], NULL);
+ setsid();
+ gettimeofday(&tv[i][1], NULL);
+ if (us) usleep(us);
+ }
+ for (i=0; i<100; i++) {
+ // change last 4 chars for correctly sorting even if the
+ // time stamps are completely same.
+ printf("%8d%06d :%02d appl\n", tv[i][0].tv_sec, tv[i][0].tv_usec, i);
+ printf("%8d%06d :%02d prog\n", tv[i][1].tv_sec, tv[i][1].tv_usec, i);
+ }
+ return 0;
+}
+
diff --git a/testsuite/systemtap.base/gtod.exp b/testsuite/systemtap.base/gtod.exp
new file mode 100644
index 00000000..a8f3c9d6
--- /dev/null
+++ b/testsuite/systemtap.base/gtod.exp
@@ -0,0 +1,40 @@
+# test for checking monotonic timer (PR3916)
+set test "gtod"
+if {![installtest_p]} { untested $test; continue }
+
+set wd [pwd]
+set filename "$srcdir/$subdir/gtod.c"
+
+target_compile $filename $wd/gtod executable ""
+
+# non interval (check timer drift in short range)
+spawn $srcdir/$subdir/gtod.sh $srcdir/$subdir/gtod.stp $wd/gtod
+set ok 0
+expect {
+ -timeout 120
+ -re {^[0-9]+ \:([0-9]+) appl\r\n[0-9]+ \:\1 kern\r\n[0-9]+ \:\1 prog\r\n} { incr ok; exp_continue }
+ timeout { fail "$test (timeout)" }
+ eof { }
+}
+wait
+#10ms interval (check timer drift in middle range)
+spawn $srcdir/$subdir/gtod.sh $srcdir/$subdir/gtod.stp $wd/gtod 10000
+expect {
+ -timeout 120
+ -re {^[0-9]+ \:([0-9]+) appl\r\n[0-9]+ \:\1 kern\r\n[0-9]+ \:\1 prog\r\n} { incr ok; exp_continue }
+ timeout { fail "$test (timeout)" }
+ eof { }
+}
+wait
+#100ms interval (calm down processors and CPU freq might be changed)
+spawn $srcdir/$subdir/gtod.sh $srcdir/$subdir/gtod.stp $wd/gtod 100000
+expect {
+ -timeout 120
+ -re {^[0-9]+ \:([0-9]+) appl\r\n[0-9]+ \:\1 kern\r\n[0-9]+ \:\1 prog\r\n} { incr ok; exp_continue }
+ timeout { fail "$test (timeout)" }
+ eof { }
+}
+wait
+exec rm -f $wd/gtod
+if {$ok == 300} { pass "$test ($ok)" } { fail "$test ($ok)" }
+
diff --git a/testsuite/systemtap.base/gtod.sh b/testsuite/systemtap.base/gtod.sh
new file mode 100755
index 00000000..4d4a28c2
--- /dev/null
+++ b/testsuite/systemtap.base/gtod.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+stap $1 -c "$2 $3" | sort
+
diff --git a/testsuite/systemtap.base/gtod.stp b/testsuite/systemtap.base/gtod.stp
new file mode 100644
index 00000000..f252dc0a
--- /dev/null
+++ b/testsuite/systemtap.base/gtod.stp
@@ -0,0 +1,8 @@
+global count = 0
+
+probe syscall.setsid {
+ if (pid() == target()) {
+ printf("%014d :%02d kern\n", gettimeofday_us(), count);
+ count ++;
+ }
+}
diff --git a/testsuite/systemtap.base/labels.exp b/testsuite/systemtap.base/labels.exp
new file mode 100644
index 00000000..9c92d69c
--- /dev/null
+++ b/testsuite/systemtap.base/labels.exp
@@ -0,0 +1,70 @@
+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 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)}
+"
+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"
+ catch {exec rm -f $label_srcpath $label_stppath}
+ return
+} else {
+ pass "compiling labels.c -g"
+}
+
+verbose -log "spawn stap -c $label_exepath $label_stppath"
+spawn stap -c $label_exepath $label_stppath
+
+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)" }
+catch {exec rm -f $label_srcpath $label_stppath $label_exepath}
diff --git a/testsuite/systemtap.base/poll_map.exp b/testsuite/systemtap.base/poll_map.exp
new file mode 100644
index 00000000..5ade48e6
--- /dev/null
+++ b/testsuite/systemtap.base/poll_map.exp
@@ -0,0 +1,14 @@
+set test "poll_map"
+if {![installtest_p]} { untested $test; return }
+
+spawn stap -g $srcdir/$subdir/poll_map.stp
+set ok 0
+expect {
+ -timeout 400
+ -ex "SUCCESS" { incr ok }
+ timeout { fail "$test (timeout)" }
+ eof { }
+}
+close
+wait
+if {$ok == 1} { pass "$test ($ok)" } { fail "$test ($ok)" }
diff --git a/testsuite/systemtap.base/poll_map.stp b/testsuite/systemtap.base/poll_map.stp
new file mode 100755
index 00000000..cd39b433
--- /dev/null
+++ b/testsuite/systemtap.base/poll_map.stp
@@ -0,0 +1,33 @@
+#! stap
+
+# test that polling loops do not exit when conflicts happen
+# see PR 1379
+
+global called, num_polls
+
+probe kernel.function( "sys_*" ).call {
+ called[execname(),probefunc()]++
+}
+
+probe timer.ms(1000)
+{
+ print("\n\n")
+ num_to_do = 10
+ foreach ([n,f] in called-) {
+ printf("%s called %s\t%d times\n", n, f, called[n,f])
+ num_to_do--
+ if (num_to_do <= 0)
+ break
+ }
+ delete called
+ num_polls++
+ if (num_polls > 30)
+ exit()
+}
+
+probe end {
+ if (num_polls <= 30)
+ print ("FAIL\n")
+ else
+ print ("SUCCESS\n")
+}
diff --git a/testsuite/systemtap.base/static_uprobes.exp b/testsuite/systemtap.base/static_uprobes.exp
index eb0d1c6e..11fec9b1 100644
--- a/testsuite/systemtap.base/static_uprobes.exp
+++ b/testsuite/systemtap.base/static_uprobes.exp
@@ -1,21 +1,17 @@
+
set test "sduprobes"
-if {![installtest_p]} {untested $test; return}
# Compile a C program to use as the user-space probing target
set sup_srcpath "[pwd]/static_uprobes.c"
set sup_exepath "[pwd]/static_uprobes.x"
-set sup_flags "additional_flags=-iquote$env(SYSTEMTAP_RUNTIME) additional_flags=-L$env(CRASH_LIBDIR) additional_flags=-lsduprobes"
+set supcplus_exepath "[pwd]/static_uprobes_cplus.x"
set fp [open $sup_srcpath "w"]
puts $fp "
#include <stdlib.h>
#define USE_STAP_PROBE 1
#include \"static_uprobes.h\"
-foo ()
-{
- STAP_PROBE(static_uprobes,test_probe_1);
-}
-
+void
bar (int i)
{
if (i == 0)
@@ -23,6 +19,7 @@ bar (int i)
STAP_PROBE1(static_uprobes,test_probe_2,i);
}
+void
baz (int i, char* s)
{
STAP_PROBE1(static_uprobes,test_probe_0,i);
@@ -31,102 +28,31 @@ baz (int i, char* s)
STATIC_UPROBES_TEST_PROBE_3(i,s);
}
+void
buz (int parm)
{
+ if (parm == 0)
+ parm = 1000;
+ DTRACE_PROBE1(static_uprobes,test_probe_4,parm);
}
+int
main ()
{
- sleep(5);
- foo();
bar(2);
- baz(3,\"abc\");
+ baz(3,(char*)\"abc\");
buz(4);
}
"
close $fp
-# set res [target_compile $sup_srcpath $sup_exepath executable $sup_flags]
-# if { $res != "" } {
-# verbose "target_compile failed: $res" 2
-# fail "compiling static_uprobes.c"
-# return
-# } else {
-# pass "compiling static_uprobes.c"
-# }
-
-set fp [open "[pwd]/static_uprobes.stp" "w"]
+set sup_stppath "[pwd]/static_uprobes.stp"
+set fp [open $sup_stppath "w"]
puts $fp "
probe process(\"static_uprobes.x\").mark(\"test_probe_0\")
{
printf(\"In test_probe_0 probe %#x\\n\", \$arg1)
}
-probe process(\"static_uprobes.x\").mark(\"test_probe_1\")
-{
- printf(\"In test_probe_1 probe\\n\")
-}
-probe process(\"static_uprobes.x\").mark(\"test_probe_2\")
-{
- printf(\"In test_probe_2 probe %#x\\n\", \$arg1)
-}
-probe process(\"static_uprobes.x\").mark(\"test_probe_3\")
-{
- printf(\"In test_probe_3 probe %#x %#x\\n\", \$arg1, \$arg2)
-}
-"
-close $fp
-
-# 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 }
-
-set ok 0
-# verbose -log "spawn stap -c $sup_exepath [pwd]/static_uprobes.stp"
-# spawn stap -c $sup_exepath [pwd]/static_uprobes.stp
-# expect {
-# -timeout 180
-# -re {In test_probe_1 probe} { incr ok; exp_continue }
-# -re {In test_probe_2 probe 0x2} { incr ok; exp_continue }
-# -re {In test_probe_0 probe 0x3} { incr ok; exp_continue }
-# -re {In test_probe_3 probe 0x3 0x[0-9a-f][0-9a-f]} { incr ok; exp_continue }
-# timeout { fail "$test (timeout)" }
-# eof { }
-# }
-
-# if {$ok == 4} { pass "$test" } { fail "$test ($ok)" }
-set ok 0
-
-# Now do a debuginfo style probe of the above test
-
-set fp [open "[pwd]/static_uprobes.sh" "w"]
-puts $fp "
-ed $sup_srcpath <<HERE
-/USE_STAP_PROBE/d
-/buz/+1
-a
- DTRACE_PROBE1(static_uprobes,test_probe_4,parm);
-.
-w
-q
-"
-close $fp
-spawn sh [pwd]/static_uprobes.sh
-
-set fp [open "[pwd]/static_uprobes.stp" "w"]
-puts $fp "
-probe process(\"static_uprobes.x\").mark(\"test_probe_0\")
-{
- printf(\"In test_probe_0 probe %#x\\n\", \$arg1)
-}
-probe process(\"static_uprobes.x\").mark(\"test_probe_1\")
-{
- printf(\"In test_probe_1 probe\\n\")
-}
probe process(\"static_uprobes.x\").mark(\"test_probe_2\")
{
printf(\"In test_probe_2 probe %#x\\n\", \$arg1)
@@ -142,7 +68,9 @@ probe process(\"static_uprobes.x\").mark(\"test_probe_4\")
"
close $fp
-set fp [open "[pwd]/static_uprobes.d" "w"]
+set sup_dpath "[pwd]/static_uprobes.d"
+set sup_hpath "[pwd]/static_uprobes.h"
+set fp [open $sup_dpath "w"]
puts $fp "
provider static_uprobes {
probe test_probe_1 ();
@@ -152,20 +80,94 @@ provider static_uprobes {
};
"
close $fp
-spawn dtrace -h -s [pwd]/static_uprobes.d
+if {[installtest_p]} {
+ set dtrace $env(SYSTEMTAP_PATH)/dtrace
+} else {
+ set dtrace $srcdir/../dtrace
+}
+if {[catch {exec $dtrace -h -s $sup_dpath} res]} {
+ verbose -log "unable to run $dtrace: $res"
+}
+if {[file exists $sup_hpath]} then {
+ pass "$test generating header"
+} else {
+ fail "$test generating header"
+ catch {exec rm -f $sup_srcpath $sup_hpath $sup_stppath}
+ return
+}
+
+catch {exec rm -f $sup_dpath}
-set sup_flags "additional_flags=-iquote$env(SYSTEMTAP_RUNTIME) additional_flags=-g additional_flags=-O additional_flags=-I."
+if {[installtest_p]} {
+ set sdtdir $env(SYSTEMTAP_INCLUDES)
+} else {
+ set sdtdir $srcdir/../includes
+}
+
+set sup_flags "additional_flags=-I$sdtdir additional_flags=-g additional_flags=-O additional_flags=-I."
set res [target_compile $sup_srcpath $sup_exepath executable $sup_flags]
if { $res != "" } {
verbose "target_compile failed: $res" 2
- fail "compiling sduprobes.c -g"
+ fail "$test compiling C -g"
+ catch {exec rm -f $sup_srcpath $sup_hpath $sup_stppath}
return
} else {
- pass "compiling sduprobes.c -g"
+ pass "$test compiling C -g"
}
-verbose -log "spawn stap -c $sup_exepath [pwd]/static_uprobes.stp"
-spawn stap -c $sup_exepath [pwd]/static_uprobes.stp
+spawn mv $sup_srcpath "[pwd]/static_uprobes.cc"
+set sup_srcpath "[pwd]/static_uprobes.cc"
+set sup_flags "$sup_flags c++"
+set res [target_compile $sup_srcpath $supcplus_exepath executable $sup_flags]
+if { $res != "" } {
+ verbose "target_compile failed: $res" 2
+ fail "$test compiling C++ -g"
+ catch {exec rm -f $sup_srcpath $sup_exepath $sup_hpath $sup_stppath}
+ return
+} else {
+ pass "$test compiling C++ -g"
+}
+
+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"
+ catch {exec rm -f $sup_srcpath}
+ return
+}
+
+set ok 0
+
+verbose -log "spawn stap -c $sup_exepath $sup_stppath"
+spawn stap -c $sup_exepath $sup_stppath
+expect {
+ -timeout 180
+ -re {In test_probe_2 probe 0x2} { incr ok; exp_continue }
+ -re {In test_probe_0 probe 0x3} { incr ok; exp_continue }
+ -re {In test_probe_3 probe 0x3 0x[0-9a-f][0-9a-f]} { incr ok; exp_continue }
+ -re {In test_probe_4 dtrace probe 0x4} { incr ok; exp_continue }
+ timeout { fail "$test C (timeout)" }
+ eof { }
+}
+
+wait
+
+if {$ok == 4} { pass "$test C" } { fail "$test C ($ok)" }
+
+set ok 0
+
+# spawn objcopy -R .probes $supcplus_exepath $sup_exepath
+verbose -log "cp $supcplus_exepath $sup_exepath"
+spawn cp $supcplus_exepath $sup_exepath
+verbose -log "spawn stap -c $sup_exepath $sup_stppath"
+spawn stap -c $sup_exepath $sup_stppath
expect {
-timeout 180
-re {In test_probe_1 probe} { incr ok; exp_continue }
@@ -173,10 +175,15 @@ expect {
-re {In test_probe_0 probe 0x3} { incr ok; exp_continue }
-re {In test_probe_3 probe 0x3 0x[0-9a-f][0-9a-f]} { incr ok; exp_continue }
-re {In test_probe_4 dtrace probe 0x4} { incr ok; exp_continue }
- timeout { fail "$test (timeout)" }
+ timeout { fail "$test C++ (timeout)" }
eof { }
}
wait
-if {$ok == 5} { pass "$test" } { fail "$test ($ok)" }
+if {$ok == 4} { pass "$test C++" } { fail "$test C++ ($ok)" }
+
+# catch {exec rm -f $sup_srcpath $sup_exepath $supcplus_exepath $sup_hpath $sup_stppath}
+
+# It's not so important to clean up, and it's unhelpful if
+# one needs to diagnose a test failure. \ No newline at end of file
diff --git a/testsuite/systemtap.base/system_func.exp b/testsuite/systemtap.base/system_func.exp
new file mode 100644
index 00000000..ec935783
--- /dev/null
+++ b/testsuite/systemtap.base/system_func.exp
@@ -0,0 +1,22 @@
+set test "system_func"
+if {![installtest_p]} { untested $test; return }
+spawn stap $srcdir/$subdir/system_func.stp
+set open 0
+set done 0
+set saw_user 0
+set user [exec whoami]
+expect {
+ -timeout 30
+ -re "($user|sys_open|DONE)\r" {
+ switch $expect_out(1,string) {
+ sys_open {incr open}
+ DONE {incr done}
+ default {incr saw_user}
+ }
+ exp_continue
+ }
+ timeout { fail "$test (timeout)" }
+ eof { }
+}
+catch {close}; wait
+if {$open == 1 && $saw_user == 1 && $done == 1 } { pass "$test" } { fail "$test ($open,$saw_user,$done)" }
diff --git a/testsuite/systemtap.base/system_func.stp b/testsuite/systemtap.base/system_func.stp
new file mode 100644
index 00000000..d14fb25b
--- /dev/null
+++ b/testsuite/systemtap.base/system_func.stp
@@ -0,0 +1,35 @@
+#! stap
+
+# test the system() function
+
+global saw_echo, did_cat
+
+probe kernel.function("sys_open") {
+ if (!saw_echo) {
+ # very inefficient. Testing only. DO NOT DO THIS
+ msg="echo sys_open"
+ system(msg)
+ saw_echo = 1
+ }
+}
+
+probe timer.ms(100) {
+ # should fail
+ system("cat __xyzzy123ABC__")
+ did_cat = 1
+}
+
+probe timer.ms(150) {
+ if (saw_echo && did_cat)
+ exit()
+}
+
+probe begin {
+ # should succeed
+ system("whoami")
+}
+
+probe end {
+ # should succeed
+ system("echo DONE")
+}
diff --git a/testsuite/systemtap.base/uprobes.exp b/testsuite/systemtap.base/uprobes.exp
index e8318586..89250e7b 100644
--- a/testsuite/systemtap.base/uprobes.exp
+++ b/testsuite/systemtap.base/uprobes.exp
@@ -25,12 +25,20 @@ 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 -p4"; untested "$test -p5"; return }
+if {$utrace_support_found == 0} {
+ untested "$test -p4"; untested "$test -p5"
+ catch {exec rm -f jennie.c jennie}
+ return
+}
set rc [stap_run_batch $srcdir/$subdir/uprobes.stp]
if {$rc == 0} then { pass "$test -p4" } else { fail "$test -p4" }
-if {! [installtest_p]} { untested "$test -p5"; exec rm -f jennie.c jennie; return }
+if {! [installtest_p]} {
+ untested "$test -p5";
+ catch {exec rm -f jennie.c jennie}
+ return
+}
# Pick up the stap being tested.
set stapexe [exec /usr/bin/which stap]
@@ -46,4 +54,4 @@ expect {
if {$ok == 10} then { pass "$test -p5" } else { fail "$test -p5 ($ok)" }
catch {wait; close}
-exec rm -f jennie.c jennie
+catch {exec rm -f jennie.c jennie}