summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.base
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/systemtap.base')
-rw-r--r--testsuite/systemtap.base/alias-condition.exp5
-rw-r--r--testsuite/systemtap.base/alias-condition.stp26
-rw-r--r--testsuite/systemtap.base/badkprobe.exp15
-rw-r--r--testsuite/systemtap.base/debugpath.exp4
-rw-r--r--testsuite/systemtap.base/gtod_init.exp29
-rw-r--r--testsuite/systemtap.base/itrace.exp171
-rwxr-xr-xtestsuite/systemtap.base/poll_map.stp2
-rw-r--r--testsuite/systemtap.base/sdt.exp3
8 files changed, 191 insertions, 64 deletions
diff --git a/testsuite/systemtap.base/alias-condition.exp b/testsuite/systemtap.base/alias-condition.exp
new file mode 100644
index 00000000..58438340
--- /dev/null
+++ b/testsuite/systemtap.base/alias-condition.exp
@@ -0,0 +1,5 @@
+# Check that conditions are copied correctly across aliases
+
+set test "alias-condition"
+
+stap_run $srcdir/$subdir/$test.stp no_load $all_pass_string
diff --git a/testsuite/systemtap.base/alias-condition.stp b/testsuite/systemtap.base/alias-condition.stp
new file mode 100644
index 00000000..89708886
--- /dev/null
+++ b/testsuite/systemtap.base/alias-condition.stp
@@ -0,0 +1,26 @@
+/*
+ * alias-condition.stp
+ *
+ * Check that conditions are copied correctly across aliases
+ */
+
+/* x should be incremented exactly once */
+global x = 0
+probe foo = begin { }
+probe foo if (x < 0), foo { ++x }
+
+probe begin(1)
+{
+ println("systemtap starting probe")
+ exit()
+}
+
+probe end
+{
+ println("systemtap ending probe")
+ if ( x != 1 ) {
+ println("systemtap test failure")
+ } else {
+ println("systemtap test success")
+ }
+}
diff --git a/testsuite/systemtap.base/badkprobe.exp b/testsuite/systemtap.base/badkprobe.exp
index c0815fbe..96ad5a3b 100644
--- a/testsuite/systemtap.base/badkprobe.exp
+++ b/testsuite/systemtap.base/badkprobe.exp
@@ -19,7 +19,20 @@ foreach bk $bad_kprobes {
spawn stap -g -w -e "$script" "$bk"
expect {
-timeout 60
- -re "^WARNING: probe .*registration error.*\r\ncleanup ok" { pass $test }
+ -re "^WARNING: probe .*registration error.*\r\ncleanup ok\r\n" { pass $test }
+ eof { fail "$test (eof)" }
+ timeout { fail "$test (timeout)" }
+ }
+ catch {close}
+ catch {wait}
+}
+
+foreach bk $bad_kprobes {
+ set test "bad optional kprobe registration: $bk"
+ spawn stap -g -w -e "$script" "$bk ?"
+ expect {
+ -timeout 60
+ -re "^cleanup ok\r\n" { pass $test }
eof { fail "$test (eof)" }
timeout { fail "$test (timeout)" }
}
diff --git a/testsuite/systemtap.base/debugpath.exp b/testsuite/systemtap.base/debugpath.exp
index b0f938b6..059b6b07 100644
--- a/testsuite/systemtap.base/debugpath.exp
+++ b/testsuite/systemtap.base/debugpath.exp
@@ -1,6 +1,6 @@
set test "debugpath-bad"
-spawn env SYSTEMTAP_DEBUGINFO_PATH=/dev/null stap -e "probe kernel.function(\"sys_open\") {}" -wp4
+spawn env SYSTEMTAP_DEBUGINFO_PATH=/dev/null stap -e "probe kernel.function(\"vfs_read\") {}" -wp4
expect {
-re {^semantic error:.*missing.*debuginfo} { pass $test }
timeout { fail "$test (timeout1)" }
@@ -21,7 +21,7 @@ if [file isdirectory /usr/lib/debug] {
set debuginfo_path "/lib/modules/$uname"
}
-spawn env SYSTEMTAP_DEBUGINFO_PATH=$debuginfo_path stap -e "probe kernel.function(\"sys_open\") {}" -wp2
+spawn env SYSTEMTAP_DEBUGINFO_PATH=$debuginfo_path stap -e "probe kernel.function(\"vfs_read\") {}" -wp2
expect {
-re {kernel.function.*pc=} { pass $test }
timeout { fail "$test (timeout2)" }
diff --git a/testsuite/systemtap.base/gtod_init.exp b/testsuite/systemtap.base/gtod_init.exp
deleted file mode 100644
index 48616b1f..00000000
--- a/testsuite/systemtap.base/gtod_init.exp
+++ /dev/null
@@ -1,29 +0,0 @@
-# test for checking initialization of the time subsystem
-set test "gtod_init"
-
-# check that init and kill are both present with a gettimeofday
-set time_init 0
-set time_kill 0
-spawn stap -p2 -e {probe begin { println(gettimeofday_s()) }}
-expect {
- -timeout 120
- -re {\n_gettimeofday_init:} { incr time_init; exp_continue }
- -re {\n_gettimeofday_kill:} { incr time_kill; exp_continue }
- timeout { fail "$test (timeout)" }
- eof {
- if {$time_init == 1} { pass "$test (init)" } { fail "$test (init $time_init)" }
- if {$time_kill == 1} { pass "$test (kill)" } { fail "$test (kill $time_kill)" }
- }
-}
-wait
-
-# check that init and kill are both NOT present without a gettimeofday
-spawn stap -p2 -e {probe begin { println(get_cycles()) }}
-expect {
- -timeout 120
- -re {\n_gettimeofday_init:} { fail "$test (bad init)" }
- -re {\n_gettimeofday_kill:} { fail "$test (bad kill)" }
- timeout { fail "$test (timeout)" }
- eof { pass "$test (no init/kill)" }
-}
-wait
diff --git a/testsuite/systemtap.base/itrace.exp b/testsuite/systemtap.base/itrace.exp
index 5da0dfaf..ddd1b07b 100644
--- a/testsuite/systemtap.base/itrace.exp
+++ b/testsuite/systemtap.base/itrace.exp
@@ -1,53 +1,55 @@
# itrace test
-
# Initialize variables
set exepath "[pwd]/ls_[pid]"
-set itrace1_script {
+# Why check for 1000 instructions executed? We can't know the actual
+# number to look for, so we just look for a reasonable number that
+# should work for all platforms.
+
+set itrace_single1_script {
global instrs = 0
probe begin { printf("systemtap starting probe\n") }
probe process("%s").insn
{
instrs += 1
- if (instrs == 5)
- exit()
}
-
-
- probe end { printf("systemtap ending probe\n")
- printf("itraced = %%d\n", instrs)
+ probe end {
+ printf("systemtap ending probe\n")
+ if (instrs > 1000) {
+ printf("instrs > 1000 (%%d)\n", instrs)
+ }
+ else {
+ printf("instrs <= 1000 (%%d)\n", instrs)
+ }
}
}
-set itrace1_script_output "itraced = 5\r\n"
+set itrace_single1_script_output "instrs > 1000 \\(\[0-9\]\[0-9\]*\\)\r\n"
-set itrace2_script {
+set itrace_single2_script {
global instrs = 0, itrace_on = 0, start_timer = 0
probe begin { start_timer = 1; printf("systemtap starting probe\n") }
probe process("%s").insn if (itrace_on)
{
instrs += 1
if (instrs == 5)
- exit()
+ 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)
+ printf("itraced = %%d\n", instrs)
}
}
-set itrace2_script_output "itraced = 5\r\n"
+set itrace_single2_script_output "itraced = 5\r\n"
-set itrace3_script {
+set itrace_block1_script {
global branches = 0
probe begin
{
@@ -59,14 +61,80 @@ set itrace3_script {
if (branches == 5)
exit()
}
-
-
probe end { printf("systemtap ending probe\n")
printf("itraced block mode = %%d\n", branches)
}
}
-set itrace3_script_output "itraced block mode = 5\r\n"
+set itrace_block1_script_output "itraced block mode = 5\r\n"
+
+set itrace_block2_script {
+ global instrs = 0, itrace_on = 0, start_timer = 0
+ probe begin { start_timer = 1; printf("systemtap starting probe\n") }
+ probe process("%s").insn.block 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 itrace_block2_script_output "itraced = 5\r\n"
+
+set itrace_single_step_script {
+ %{
+ #include "ptrace_compatibility.h"
+ %}
+
+ function has_single_step() %{
+ THIS->__retvalue = arch_has_single_step(); /* pure */
+ %}
+
+ probe begin {
+ printf("has_single_step: %d\n", has_single_step())
+ exit()
+ }
+}
+set itrace_block_step_script {
+ %{
+ #include "ptrace_compatibility.h"
+ %}
+
+ function has_block_step() %{
+ THIS->__retvalue = arch_has_block_step(); /* pure */
+ %}
+
+ probe begin {
+ printf("has_block_step: %d\n", has_block_step())
+ exit()
+ }
+}
+
+proc stap_check_feature { test_name script feature } {
+ set rc -1
+ verbose -log "stap -g -e \"$script\""
+ spawn stap -g -e "$script"
+ expect {
+ -timeout 60
+ -re "^$feature: 0" { set rc 0; pass $test_name }
+ -re "^$feature: 1" { set rc 1; pass $test_name }
+ eof { fail "$test_name (eof)" }
+ timeout { fail "$test_name (timeout)" }
+ }
+ catch {close}
+ catch {wait}
+ return $rc
+}
# 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
@@ -90,37 +158,80 @@ proc run_ls_5_sec {} {
return 0;
}
+# figure out if this system supports single stepping (if we've got
+# utrace and we're doing install testing)
+set TEST_NAME "itrace single step check"
+set single_step_p 0
+if {![utrace_p]} {
+ untested "$TEST_NAME : no kernel utrace support found"
+} elseif {![installtest_p]} {
+ untested $TEST_NAME
+} else {
+ set single_step_p [stap_check_feature $TEST_NAME \
+ $itrace_single_step_script "has_single_step"]
+}
+
+# figure out if this system supports block stepping (if we've got
+# utrace and we're doing install testing)
+set TEST_NAME "itrace block step check"
+set block_step_p 0
+if {![utrace_p]} {
+ untested "$TEST_NAME : no kernel utrace support found"
+} elseif {![installtest_p]} {
+ untested $TEST_NAME
+} else {
+ set block_step_p [stap_check_feature $TEST_NAME \
+ $itrace_block_step_script "has_block_step"]
+}
-set TEST_NAME "itrace1"
+# Run the single step tests
+set TEST_NAME "itrace_single1"
if {![utrace_p]} {
untested "$TEST_NAME : no kernel utrace support found"
} elseif {![installtest_p]} {
untested $TEST_NAME
+} elseif {$single_step_p != 1} {
+ xfail "$TEST_NAME : no kernel single step support"
} else {
- set script [format $itrace1_script $exepath]
- stap_run $TEST_NAME run_ls_5_sec $itrace1_script_output -e $script
+ set script [format $itrace_single1_script $exepath]
+ stap_run $TEST_NAME run_ls_5_sec $itrace_single1_script_output -e $script
}
+set TEST_NAME "itrace_single2"
+if {![utrace_p]} {
+ untested "$TEST_NAME : no kernel utrace support found"
+} elseif {![installtest_p]} {
+ untested $TEST_NAME
+} elseif {$single_step_p != 1} {
+ xfail "$TEST_NAME : no kernel single step support"
+} else {
+ set script [format $itrace_single2_script $exepath]
+ stap_run $TEST_NAME run_ls_5_sec $itrace_single2_script_output -e $script
+}
-set TEST_NAME "itrace2"
+# Run the block step tests
+set TEST_NAME "itrace_block1"
if {![utrace_p]} {
untested "$TEST_NAME : no kernel utrace support found"
} elseif {![installtest_p]} {
untested $TEST_NAME
+} elseif {$block_step_p != 1} {
+ xfail "$TEST_NAME : no kernel block step support"
} else {
- set script [format $itrace2_script $exepath]
- stap_run $TEST_NAME run_ls_5_sec $itrace2_script_output -e $script
+ set script [format $itrace_block1_script $exepath]
+ stap_run $TEST_NAME run_ls_5_sec $itrace_block1_script_output -e $script
}
-set TEST_NAME "itrace3"
+set TEST_NAME "itrace_block2"
if {![utrace_p]} {
untested "$TEST_NAME : no kernel utrace support found"
} elseif {![installtest_p]} {
untested $TEST_NAME
+} elseif {$block_step_p != 1} {
+ xfail "$TEST_NAME : no kernel block step support"
} else {
- send_log "ATTENTION: if arch_has_block_step is not defined for this arch, this testcase will fail\n"
- set script [format $itrace3_script $exepath]
- stap_run $TEST_NAME run_ls_5_sec $itrace3_script_output -e $script
+ set script [format $itrace_block2_script $exepath]
+ stap_run $TEST_NAME run_ls_5_sec $itrace_block2_script_output -e $script
}
# Cleanup
diff --git a/testsuite/systemtap.base/poll_map.stp b/testsuite/systemtap.base/poll_map.stp
index cd39b433..e278fc91 100755
--- a/testsuite/systemtap.base/poll_map.stp
+++ b/testsuite/systemtap.base/poll_map.stp
@@ -5,7 +5,7 @@
global called, num_polls
-probe kernel.function( "sys_*" ).call {
+probe kernel.function( "vfs_*" ).call {
called[execname(),probefunc()]++
}
diff --git a/testsuite/systemtap.base/sdt.exp b/testsuite/systemtap.base/sdt.exp
index c3aed91e..d24093e0 100644
--- a/testsuite/systemtap.base/sdt.exp
+++ b/testsuite/systemtap.base/sdt.exp
@@ -41,6 +41,7 @@ if {[installtest_p] && [utrace_p]} {
} else {
untested "$test $extra_flag"
}
+catch {exec rm -f $testprog}
# C++
set testprog "sdt.cxx.exe.$i"
@@ -66,5 +67,5 @@ if {[installtest_p] && [utrace_p]} {
} else {
untested "$test c++ $extra_flag"
}
+catch {exec rm -f $testprog}
}
-