summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.base
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/systemtap.base')
-rw-r--r--testsuite/systemtap.base/alternatives.exp5
-rw-r--r--testsuite/systemtap.base/flightrec3.exp79
-rw-r--r--testsuite/systemtap.base/flightrec3.stp5
-rw-r--r--testsuite/systemtap.base/itrace.exp171
-rw-r--r--testsuite/systemtap.base/skipped.exp6
5 files changed, 231 insertions, 35 deletions
diff --git a/testsuite/systemtap.base/alternatives.exp b/testsuite/systemtap.base/alternatives.exp
index 6cbc1e10..f5dc4513 100644
--- a/testsuite/systemtap.base/alternatives.exp
+++ b/testsuite/systemtap.base/alternatives.exp
@@ -26,10 +26,11 @@ proc stap_run_alternatives {args} {
verbose -log "starting $args"
eval spawn $args
expect {
+ -timeout 60
-re {semantic error: .+ \(alternatives: [a-zA-Z_]} {incr alternatives_found; exp_continue}
-re {[^\r]*\r} { verbose -log $expect_out(0,string); exp_continue }
- eof { }
- timeout { }
+ eof { verbose -log "EOF" }
+ timeout { verbose -log "TIMEOUT" }
}
set results [wait]
verbose -log "wait results: $results"
diff --git a/testsuite/systemtap.base/flightrec3.exp b/testsuite/systemtap.base/flightrec3.exp
new file mode 100644
index 00000000..5b9d8253
--- /dev/null
+++ b/testsuite/systemtap.base/flightrec3.exp
@@ -0,0 +1,79 @@
+set test "flightrec3"
+if {![installtest_p]} { untested $test; return }
+
+# cleanup
+system "rm -f flightlog.out*"
+
+set pid 0
+# check -S option with bulk(percpu file) mode
+spawn stap -F -o flightlog.out -S 1,3 -b $srcdir/$subdir/$test.stp
+expect {
+ -timeout 240
+ -re {([0-9]+)\r\n} {
+ pass "$test (-S option with bulk mode)"
+ set pid $expect_out(1,string)
+ exp_continue}
+ timeout { fail "$test (timeout)"}
+ eof { }
+}
+wait
+if {$pid == 0} {
+ fail "$test (no pid)"
+ return -1
+}
+
+exec sleep 4
+array set cpus {}
+set scnt 0
+# wait for log files
+exec kill -STOP $pid
+exec sleep 1
+eval spawn stat -c \"%n %s\" [glob flightlog.out_cpu*]
+expect {
+ -timeout 100
+ -re {flightlog.out_cpu([0-9]+).[0-9]+ ([0-9]+)\r\n} {
+ set cpuid $expect_out(1,string)
+ set size $expect_out(2,string)
+ if {[array get cpus $cpuid] == ""} {set cpus($cpuid) 0}
+ incr cpus($cpuid);
+ if {$size <= 1048576 } {incr scnt}
+ exp_continue}
+ timeout { fail "$test (logfile timeout)"}
+}
+wait
+exec kill -CONT $pid
+exec sleep 3
+exec kill -STOP $pid
+eval spawn stat -c \"%n %s\" [glob flightlog.out_cpu*]
+expect {
+ -timeout 100
+ -re {flightlog.out_cpu([0-9]+).[0-9]+ ([0-9]+)\r\n} {
+ set cpuid $expect_out(1,string)
+ set size $expect_out(2,string)
+ if {[array get cpus $cpuid] == ""} {set cpus($cpuid) 0}
+ incr cpus($cpuid);
+ if {$size <= 1048576 } {incr scnt}
+ exp_continue}
+ timeout { fail "$test (logfile timeout)"}
+}
+wait
+exec kill -CONT $pid
+# check logfile number
+set cnt 0
+foreach e [array names cpus] {
+ if {$cpus($e) != 6} {
+ fail "$test (log file numbers cpu:$e, cnt:$cpus($e)))"
+ }
+ set cnt [expr $cnt + $cpus($e)]
+}
+# check logfile size
+if {$scnt == $cnt} {
+ pass "$test (log file size limitation with bulk mode)"
+} else {
+ fail "$test (log file size ($scnt != $cnt))"
+}
+exec kill -TERM $pid
+# wait for exiting...
+exec sleep 1
+system "rm -f flightlog.out*"
+
diff --git a/testsuite/systemtap.base/flightrec3.stp b/testsuite/systemtap.base/flightrec3.stp
new file mode 100644
index 00000000..d660793f
--- /dev/null
+++ b/testsuite/systemtap.base/flightrec3.stp
@@ -0,0 +1,5 @@
+probe kernel.function("update_process_times")
+{
+ for (j = 0; j < 100; j++)
+ printf("1234567890\n")
+}
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/skipped.exp b/testsuite/systemtap.base/skipped.exp
index 8c491037..f3048c8a 100644
--- a/testsuite/systemtap.base/skipped.exp
+++ b/testsuite/systemtap.base/skipped.exp
@@ -2,8 +2,8 @@ set test "skip tracking"
if {! [installtest_p]} { untested $test; return }
-set cpus [exec sh -c "grep ^processor /proc/cpuinfo | wc -l"]
-if {$cpus < 2} { unsupported $test; return }
+set nr_cpus [exec sh -c "grep ^processor /proc/cpuinfo | wc -l"]
+if {$nr_cpus < 2} { unsupported $test; return }
set ok 0
spawn stap -e "probe timer.s(5) {exit()} probe timer.profile,syscall.* {f++} global f" -DMAXTRYLOCK=0 -tu
@@ -18,4 +18,4 @@ expect {
catch {close}
catch {wait}
-if {$ok >= 3} { pass "$test ($cpus $ok)" } else { fail "$test ($cpus $ok)" }
+if {$ok >= 3} { pass "$test ($nr_cpus $ok)" } else { fail "$test ($nr_cpus $ok)" }