| 1 |
set test "listing_mode_sanity" |
| 2 |
|
| 3 |
# This test is a sanity-check that listing mode (-l and -L) works |
| 4 |
# properly. |
| 5 |
|
| 6 |
# Things to check: |
| 7 |
# - no 'semantic error' messages, unless -vv is supplied |
| 8 |
# - no probes found = bad exit code, probes found = good exit code |
| 9 |
# - check verbatim the output of -l/-L for e.g. kernel.function("vfs_read") |
| 10 |
# - arguments to -l are allowed, not treated as a script (but still no -e) |
| 11 |
# - check that -l ** doesn't crash anything (BZ1065757) |
| 12 |
|
| 13 |
proc has_line { output wanted probe } { |
| 14 |
global test subtest |
| 15 |
|
| 16 |
set inlist [lsearch $output $probe] |
| 17 |
if {[expr $wanted && $inlist > 0] \ |
| 18 |
|| [expr !$wanted && $inlist < 0]} { |
| 19 |
pass "$test ($subtest)" |
| 20 |
} else { |
| 21 |
fail "$test ($subtest)" |
| 22 |
} |
| 23 |
} |
| 24 |
|
| 25 |
# Checks that 'semantic error' is only output at -vv |
| 26 |
# Also checks that no probes found = bad exit code |
| 27 |
if {![catch {exec stap -l junk 2>@1} output]} { |
| 28 |
fail "$test (stap -l junk exited successfully)" |
| 29 |
return |
| 30 |
} else { |
| 31 |
pass "$test (stap -l junk exited badly)" |
| 32 |
} |
| 33 |
|
| 34 |
if {![catch {exec stap -v -l junk 2>@1} outputv]} { |
| 35 |
fail "$test (stap -v -l junk exited successfully)" |
| 36 |
return |
| 37 |
} else { |
| 38 |
pass "$test (stap -v -l junk exited badly)" |
| 39 |
} |
| 40 |
|
| 41 |
if {![catch {exec stap -vv -l junk 2>@1} outputvv]} { |
| 42 |
fail "$test (stap -vv -l junk exited successfully)" |
| 43 |
return |
| 44 |
} else { |
| 45 |
pass "$test (stap -vv -l junk exited badly)" |
| 46 |
} |
| 47 |
|
| 48 |
# Split outputs into lines |
| 49 |
set output [split $output "\n"] |
| 50 |
set outputv [split $outputv "\n"] |
| 51 |
set outputvv [split $outputvv "\n"] |
| 52 |
|
| 53 |
set subtest "no error in output" |
| 54 |
has_line $output 0 "semantic error: *" |
| 55 |
|
| 56 |
set subtest "no error in -v output" |
| 57 |
has_line $outputv 0 "semantic error: *" |
| 58 |
|
| 59 |
set subtest "error in -vv output" |
| 60 |
has_line $outputvv 1 "semantic error: *" |
| 61 |
|
| 62 |
# Checks verbatim output of some probes |
| 63 |
# Also checks that probes found = good exit code |
| 64 |
if {[catch {exec stap -l kernel.function("vfs_read") 2>@1} output]} { |
| 65 |
fail "$test (stap -l vfs_read exited badly)" |
| 66 |
return |
| 67 |
} else { |
| 68 |
pass "$test (stap -l vfs_read exited ok)" |
| 69 |
} |
| 70 |
|
| 71 |
# Make sure we use the '.call' version, since on some kernels (like |
| 72 |
# 3.10.0-327.el7.ppc64) vfs_read() can be inlined and we can't find |
| 73 |
# the parameters in the inlined version. |
| 74 |
if {[catch {exec stap -L kernel.function("vfs_read").call 2>@1} outputL]} { |
| 75 |
fail "$test (stap -L vfs_read exited badly)" |
| 76 |
return |
| 77 |
} else { |
| 78 |
pass "$test (stap -L vfs_read exited ok)" |
| 79 |
} |
| 80 |
|
| 81 |
set subtest "verbatim stap -l vfs_read" |
| 82 |
if {[regexp "^kernel\\.function\\(\"vfs_read@\[^\"\]*\"\\)$" $output]} { |
| 83 |
pass "$test ($subtest)" |
| 84 |
} else { |
| 85 |
fail "$test ($subtest)" |
| 86 |
return |
| 87 |
} |
| 88 |
|
| 89 |
set subtest "verbatim stap -L vfs_read" |
| 90 |
verbose -log "output is $outputL" |
| 91 |
if {[regexp "^kernel.function.*vfs_read.*call.*file.*buf.*count.*pos.*ret" $outputL]} { |
| 92 |
pass "$test ($subtest)" |
| 93 |
} else { |
| 94 |
fail "$test ($subtest)" |
| 95 |
return |
| 96 |
} |
| 97 |
|
| 98 |
# Check that arguments to -l work, and aren't treated as have_script |
| 99 |
if {[catch {exec stap -l \$1.function(@2) kernel vfs_read 2>@1}]} { |
| 100 |
fail "$test (using arguments exited badly)" |
| 101 |
return |
| 102 |
} else { |
| 103 |
pass "$test (using arguments exited ok)" |
| 104 |
} |
| 105 |
# but a -e script still conflicts with listing |
| 106 |
if {[catch {exec stap -l \$1.function(@2) kernel vfs_read -e {probe begin {}} 2>@1}]} { |
| 107 |
pass "$test (using arguments and script exited badly)" |
| 108 |
} else { |
| 109 |
fail "$test (using arguments and script exited ok)" |
| 110 |
return |
| 111 |
} |
| 112 |
|
| 113 |
# The following checks are quite costly - require minutes of CPU time |
| 114 |
# and gigabytes of RAM ... so we don't do it on a small machine. |
| 115 |
set kb_avail [lindex [exec grep MemAvailable /proc/meminfo] 1] |
| 116 |
if {$kb_avail < 6000000} then { return } |
| 117 |
|
| 118 |
# Checks that -vvv -l/-L ** doesn't crash anything (RHBZ1065757) |
| 119 |
if {[catch {exec stap -vvv -l \*\* 2>/dev/null}]} { |
| 120 |
fail "$test (stap -l ** exited badly)" |
| 121 |
return |
| 122 |
} else { |
| 123 |
pass "$test (stap -l ** exited ok)" |
| 124 |
} |
| 125 |
if {[catch {exec stap -vvv -L \*\* 2>/dev/null}]} { |
| 126 |
fail "$test (stap -L ** exited badly)" |
| 127 |
return |
| 128 |
} else { |
| 129 |
pass "$test (stap -L ** exited ok)" |
| 130 |
} |
| 131 |
|