summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.base
diff options
context:
space:
mode:
authorDave Brolley <brolley@redhat.com>2008-08-08 15:15:19 -0400
committerDave Brolley <brolley@redhat.com>2008-08-08 15:15:19 -0400
commit71906647386a9684086b0542318b536d95ae089c (patch)
treefb0348d7bb34095e95ad830da8e832bad9187a55 /testsuite/systemtap.base
parentd5658775da9fa0ac792eb3f874df9f7c4d60de7e (diff)
parentf1118e1032612170cae8cd979cd529722ad95fdb (diff)
downloadsystemtap-steved-71906647386a9684086b0542318b536d95ae089c.tar.gz
systemtap-steved-71906647386a9684086b0542318b536d95ae089c.tar.xz
systemtap-steved-71906647386a9684086b0542318b536d95ae089c.zip
Merge branch 'master' of ssh://sources.redhat.com/git/systemtap
Conflicts: ChangeLog testsuite/ChangeLog
Diffstat (limited to 'testsuite/systemtap.base')
-rw-r--r--testsuite/systemtap.base/cache.exp1
-rw-r--r--testsuite/systemtap.base/itrace.exp106
-rw-r--r--testsuite/systemtap.base/stmt_rel.stp4
-rw-r--r--testsuite/systemtap.base/utrace_p4.exp41
-rw-r--r--testsuite/systemtap.base/vars.exp32
-rw-r--r--testsuite/systemtap.base/warnings.stp2
6 files changed, 142 insertions, 44 deletions
diff --git a/testsuite/systemtap.base/cache.exp b/testsuite/systemtap.base/cache.exp
index f7ed2786..390af054 100644
--- a/testsuite/systemtap.base/cache.exp
+++ b/testsuite/systemtap.base/cache.exp
@@ -30,6 +30,7 @@ proc stap_compile { TEST_NAME flags script args } {
-timeout 180
-re {^Pass\ [1234]:[^\r]*\ in\ [^\r]*\ ms\.\r\n} {exp_continue}
-re {^Pass\ [34]: using cached [^\r\n]+\r\n} {incr cached 1; exp_continue}
+ -re "^WARNING" {exp_continue}
# pass-4 output
-re {^/[^\r\n]+\.ko\r\n} {exp_continue}
-re "compilation failed" {incr compile_errors 1; exp_continue}
diff --git a/testsuite/systemtap.base/itrace.exp b/testsuite/systemtap.base/itrace.exp
new file mode 100644
index 00000000..f19af977
--- /dev/null
+++ b/testsuite/systemtap.base/itrace.exp
@@ -0,0 +1,106 @@
+# itrace test
+
+# temporarily disabled
+return
+
+
+# Initialize variables
+set utrace_support_found 0
+set exepath "[pwd]/ls_[pid]"
+
+set itrace1_script {
+ global instrs = 0
+ probe begin { printf("systemtap starting probe\n") }
+ probe process("%s").itrace
+ {
+ instrs += 1
+ if (instrs == 5)
+ exit()
+ }
+
+
+ probe end { printf("systemtap ending probe\n")
+ printf("itraced = %%d\n", instrs)
+ }
+}
+set itrace1_script_output "itraced = 5\r\n"
+
+set itrace2_script {
+ global instrs = 0, itrace_on = 0, start_timer = 0
+ probe begin { start_timer = 1; printf("systemtap starting probe\n") }
+ probe process("%s").itrace if (itrace_on)
+ {
+ instrs += 1
+ if (instrs == 5)
+ exit()
+ }
+
+
+ probe timer.ms(1) if (start_timer)
+ {
+ itrace_on = 1
+ }
+
+ probe timer.ms(10) if (start_timer)
+ {
+ itrace_on = 0
+ }
+ probe end { printf("systemtap ending probe\n")
+ printf("itraced = %%d\n", instrs)
+ }
+}
+set itrace2_script_output "itraced = 5\r\n"
+
+
+# Set up our own copy of /bin/ls, to make testing for a particular
+# executable easy. We can't use 'ln' here, since we might be creating
+# a cross-device link. We can't use 'ln -s' here, since the kernel
+# resolves the symbolic link and reports that /bin/ls is being
+# exec'ed (instead of our local copy).
+if {[catch {exec cp /bin/ls $exepath} res]} {
+ fail "unable to copy /bin/ls: $res"
+ return
+}
+
+# "load" generation function for stap_run. It spawns our own copy of
+# /bin/ls, waits 5 seconds, then kills it.
+proc run_ls_5_sec {} {
+ global exepath
+
+ spawn $exepath
+ set exe_id $spawn_id
+ after 5000;
+ exec kill -INT -[exp_pid -i $exe_id]
+ return 0;
+}
+
+
+# Try to find utrace_attach symbol in /proc/kallsyms
+set path "/proc/kallsyms"
+if {! [catch {exec grep -q utrace_attach $path} dummy]} {
+ set utrace_support_found 1
+}
+
+set TEST_NAME "itrace1"
+if {$utrace_support_found == 0} {
+ untested "$TEST_NAME : no kernel utrace support found"
+} elseif {![installtest_p]} {
+ untested $TEST_NAME
+} else {
+ set script [format $itrace1_script $exepath]
+ stap_run $TEST_NAME run_ls_5_sec $itrace1_script_output -e $script
+}
+
+
+set TEST_NAME "itrace2"
+if {$utrace_support_found == 0} {
+ untested "$TEST_NAME : no kernel utrace support found"
+} elseif {![installtest_p]} {
+ untested $TEST_NAME
+} else {
+ set script [format $itrace2_script $exepath]
+ stap_run $TEST_NAME run_ls_5_sec $itrace2_script_output -e $script
+}
+
+# Cleanup
+exec rm -f $exepath
diff --git a/testsuite/systemtap.base/stmt_rel.stp b/testsuite/systemtap.base/stmt_rel.stp
index 13066161..cfe77317 100644
--- a/testsuite/systemtap.base/stmt_rel.stp
+++ b/testsuite/systemtap.base/stmt_rel.stp
@@ -55,11 +55,11 @@ probe kernel.statement("bio_put@fs/bio.c:*") {
# printf ("FAIL address %s %s\n", stack2, stack3)
# }
- # Did wildcard probe hit at least 5 different statements?
+ # Did wildcard probe hit at least 4 different statements?
foreach ([i] in wildcardpp) {
statement_count += 1
}
- if (statement_count >= 5) {
+ if (statement_count >= 4) {
printf ("PASS wildcard\n")
}
else
diff --git a/testsuite/systemtap.base/utrace_p4.exp b/testsuite/systemtap.base/utrace_p4.exp
index 333cff21..3083b97f 100644
--- a/testsuite/systemtap.base/utrace_p4.exp
+++ b/testsuite/systemtap.base/utrace_p4.exp
@@ -6,47 +6,6 @@
# If utrace exists in the kernel, it tries some compile tests. If
# utrace doesn't exist in the kernel, marks the tests as 'untested'.
-# stap_compile TEST_NAME flags script args
-# - TEST_NAME is the name of the current test
-# - compile indicates whether the script is supposed to compile
-# - script is the script to compile
-# Additional arguments are passed to stap as-is.
-proc stap_compile { TEST_NAME compile script args } {
- set cmd [concat {stap -v -p4 -e} $script $args]
-
- verbose -log "running $cmd"
- eval spawn $cmd
- set compile_errors 0
- expect {
- -re {^Pass\ [1234]:[^\r]*\ in\ .*\ ms.\r\n} {exp_continue}
- -re {^Pass\ [34]: using cached [^\r\n]+\r\n} {exp_continue}
- # pass-4 output
- -re {^/[^\r\n]+.ko\r\n} {exp_continue}
- -re "parse error" { incr compile_errors 1; exp_continue}
- -re "compilation failed" {incr compile_errors 1; exp_continue}
- -re "semantic error:" {incr compile_errors 1; exp_continue}
- -re "terminate called" {incr compile_errors 1; exp_continue}
- }
- catch close
- wait
-
- # If we've got compile errors and the script was supposed to
- # compile, fail.
- if {$compile_errors > 0} {
- if {$compile == 1} {
- fail "$TEST_NAME compilation failed"
- } else {
- pass "$TEST_NAME compilation failed correctly"
- }
- } else {
- if {$compile == 1} {
- pass "$TEST_NAME compilation succeeded"
- } else {
- fail "$TEST_NAME compilation succeeded unexpectedly"
- }
- }
-}
-
# Initialize variables
set utrace_support_found 0
diff --git a/testsuite/systemtap.base/vars.exp b/testsuite/systemtap.base/vars.exp
new file mode 100644
index 00000000..7541c01b
--- /dev/null
+++ b/testsuite/systemtap.base/vars.exp
@@ -0,0 +1,32 @@
+# Script for testing $$vars, $$parms, $$locals
+
+set test "vars"
+
+# grab C statement that $$vars yields
+set cmd [concat stap -p3 -e {"probe kernel.statement(\"bio_copy_user@fs/bio.c+1\") \{print (\$\$vars)\}"} 2>&1 | grep {"printf.*="} | sed -e {"s/^.*MAXSTRINGLEN, \"//"} -e {s/..\".*$//}]
+catch {eval exec $cmd} vars
+
+# grab C statement that $$parms yields
+set cmd [regsub "vars" $cmd "parms"]
+catch {eval exec $cmd} parms
+
+# grab C statement that $$locals yields
+set cmd [regsub "parms" $cmd "locals"]
+catch {eval exec $cmd} locals
+
+# syntax check of $$vars C statement
+set vars_ok [regexp "(\[a-z_\]+=%#llx *)+" $vars]
+if {!$vars_ok} {
+ fail "$test"
+} else {
+ pass "$test"
+}
+
+# $$vars should be equivalent to $$parms + $$locals
+if {![string equal [string trim $vars] \
+ [string trim [concat $parms " " $locals]]]} {
+ fail "$test parms/locals"
+} else {
+ pass "$test parms/locals"
+}
+
diff --git a/testsuite/systemtap.base/warnings.stp b/testsuite/systemtap.base/warnings.stp
index 94ed57b3..d71b3034 100644
--- a/testsuite/systemtap.base/warnings.stp
+++ b/testsuite/systemtap.base/warnings.stp
@@ -9,7 +9,7 @@ probe never { print(elide+me1) bar () }
# PR 6611
-probe probea = kernel.statement("bio_init@fs/bio.c:135")
+probe probea = kernel.statement("bio_init@fs/bio.c+3")
{ printf("%d", funca(2)); elide_me6="foo" }
probe probea { printf("%d", funcb(2,3)); printf("%s",var) }