Debian Codegraph @

testsuite/systemtap.stress/conversions.exp

raw
1 # Kernel and userspace string and buffer access tests. Only runs in
2 # "installcheck" mode.
3 #
4 # This harness covers user_string, kernel_string, etc via the
5 # individual .stp scripts listed below.
6 #
7 # Run with
8 #
9 # make installcheck RUNTESTFLAGS='conversions.exp'
10 #
11
12 # Run a tapscript with invalid memory addresses to access and
13 # make sure the output is as expected.
14 #
15 proc run_conv_test {filename expected_errs} {
16 foreach value {0 0xffffffff 0xffffffffffffffff} {
17 # PR 4121: address 0 is valid on s390x
18 if {[istarget s390x-*-*] && $value == 0} { set value 0x7777777777 }
19 # PR 4540: ia64 thinks 0xffffffffffffffff okay for character accesses
20 if {[istarget ia64-*-*] && $value == 0xffffffffffffffff } {
21 set value 0xafffffffffffffff
22 }
23
24 set test "[file tail $filename] $value"
25 # Only run for "installcheck"
26 if {![installtest_p]} { untested $test; continue }
27
28 # Turn off the duplication elimination to get an accurate
29 # count (PR12168). Turn off overload protection so that we get
30 # the right errors (not a "probe took too long" error).
31 spawn stap -g --suppress-time-limits -vv -DMAXSKIPPED=99999 -DMAXERRORS=40 $filename $value
32 set errs 0
33 set unexpectedly_reached 0
34 verbose -log "exp $test $errs"
35 # Count output lines beginning with ERROR or WARNING and increment
36 # the error counter. Ignore all other output.
37 expect {
38 -timeout 180
39 -re {(REACHED_UNREACHABLE[^\r\n]*)\r\n} {
40 verbose -log $expect_out(1,string)
41 incr unexpectedly_reached
42 exp_continue
43 }
44 -re {(ERROR|WARNING)[^\r\n]*\r\n} { incr errs; exp_continue }
45 eof { }
46 timeout { fail "$test (timeout)" }
47 }
48 verbose -log "done exp $test $errs"
49 catch {close}; catch {wait}
50 if {$errs == $expected_errs} { pass $test } else { fail "$test (got $errs expected $expected_errs, unexpectedly_reached $unexpectedly_reached)" }
51 verbose -log "done $test errs $errs=$expected_errs unexpectedly_reached $unexpectedly_reached"
52 }
53 }
54
55 # Test memory accesses from begin probes.
56 run_conv_test $srcdir/$subdir/conversions.stp 23
57
58 # Test memory accesses from kernel.trace probes (if the "sched_switch"
59 # tracepoint exists).
60 if {! [catch {exec stap -l "kernel.trace(\"sched_switch\")"} dummy]} {
61 run_conv_test $srcdir/$subdir/conversions_trace.stp 23
62 } else {
63 untested "conversions_trace.stp"
64 }
65
66 # Test memory accesses from timer.profile probes.
67 run_conv_test $srcdir/$subdir/conversions_profile.stp 23
68
69 # Test memory accesses from perf probes (if we've got perf probes).
70 if {[perf_probes_p]} {
71 run_conv_test $srcdir/$subdir/conversions_perf.stp 23
72 } else {
73 untested "conversions_perf.stp"
74 }