| 1 |
set test "tracepoints_list" |
| 2 |
|
| 3 |
# Make sure we're root. |
| 4 |
set am_root [expr 0 == [exec id -u]] |
| 5 |
if {!$am_root} { |
| 6 |
untested "${test} (running as non-root)" |
| 7 |
return |
| 8 |
} |
| 9 |
|
| 10 |
# First, does 'perf' exist on this system? |
| 11 |
if {[catch { exec which perf } res]} { |
| 12 |
untested "${test} (no perf)" |
| 13 |
return |
| 14 |
} |
| 15 |
pass "$test found 'perf'" |
| 16 |
|
| 17 |
# Next, gather perf's tracepoint list. Note we need to set PAGER so |
| 18 |
# that perf won't try to page the output. |
| 19 |
set perf_tracepoints {} |
| 20 |
set env(PAGER) "" |
| 21 |
spawn perf list tracepoint |
| 22 |
expect { |
| 23 |
-timeout 60 |
| 24 |
-re {^[ \t]+([^ \t]+:[^ \t]+)[ \t]+\[Tracepoint event\]\r\n} { |
| 25 |
set tp $expect_out(1,string) |
| 26 |
# Note that we're ignoring several tracepoints below. |
| 27 |
switch -regexp $tp { |
| 28 |
{^syscalls:sys_(enter|exit)} { |
| 29 |
# Skip virtual tracepoint unusable by stap. |
| 30 |
exp_continue |
| 31 |
} |
| 32 |
{^ftrace:function$} { |
| 33 |
# Skip virtual tracepoint unusable by stap. |
| 34 |
exp_continue |
| 35 |
} |
| 36 |
{^powerpc:hcall_(entry|exit)$} { |
| 37 |
# Skip ppc64-specific tracepoints on the blocklist. |
| 38 |
exp_continue |
| 39 |
} |
| 40 |
{^(u|k)probes:$} { |
| 41 |
# Skip active probes |
| 42 |
exp_continue |
| 43 |
} |
| 44 |
default { |
| 45 |
lappend perf_tracepoints $expect_out(1,string) |
| 46 |
exp_continue |
| 47 |
} |
| 48 |
} |
| 49 |
} |
| 50 |
-re {^[^\r\n]+\r\n} { |
| 51 |
# ignore output we're not interested in |
| 52 |
exp_continue |
| 53 |
} |
| 54 |
timeout {} |
| 55 |
eof {} |
| 56 |
} |
| 57 |
catch {close}; catch {wait} |
| 58 |
if ([llength $perf_tracepoints]) { |
| 59 |
pass "$test perf list ([llength $perf_tracepoints])" |
| 60 |
} else { |
| 61 |
fail "$test perf list" |
| 62 |
return |
| 63 |
} |
| 64 |
|
| 65 |
# Now gather stap's tracepoint list. |
| 66 |
set stap_tracepoints {} |
| 67 |
spawn stap --disable-cache -l {kernel.trace("*")} |
| 68 |
expect { |
| 69 |
-timeout 180 |
| 70 |
-re {^kernel.trace\("([^\r\n]+:[^\r\n]+)"\)\r\n} { |
| 71 |
lappend stap_tracepoints $expect_out(1,string) |
| 72 |
exp_continue |
| 73 |
} |
| 74 |
timeout {} |
| 75 |
eof {} |
| 76 |
} |
| 77 |
catch {close}; catch {wait} |
| 78 |
if ([llength $stap_tracepoints]) { |
| 79 |
pass "$test stap list ([llength $stap_tracepoints])" |
| 80 |
} else { |
| 81 |
fail "$test stap list" |
| 82 |
return |
| 83 |
} |
| 84 |
|
| 85 |
# Sort both lists. |
| 86 |
set $perf_tracepoints [lsort -increasing $perf_tracepoints] |
| 87 |
set $stap_tracepoints [lsort -increasing $stap_tracepoints] |
| 88 |
|
| 89 |
# Look for perf tracepoints not found by stap. Note that stap will |
| 90 |
# find more tracepoints than perf, since stap will find tracepoints in |
| 91 |
# modules that aren't loaded. |
| 92 |
set tp_found 0 |
| 93 |
foreach ptp $perf_tracepoints { |
| 94 |
if {[lsearch -exact -sorted -increasing $stap_tracepoints $ptp] >= 0} { |
| 95 |
incr tp_found |
| 96 |
} else { |
| 97 |
fail "$test: perf tracepoint $ptp not found by systemtap" |
| 98 |
} |
| 99 |
} |
| 100 |
if {$tp_found > 0} { |
| 101 |
pass "$test: $tp_found common tracepoints found by perf and systemtap" |
| 102 |
} else { |
| 103 |
fail "$test: no common tracepoints found by perf and systemtap" |
| 104 |
} |
| 105 |
|
| 106 |
# |
| 107 |
# Now test the first tracepoint in each group, to make sure compile |
| 108 |
# requirements for each group is sufficient in itself. |
| 109 |
# |
| 110 |
# First, we'll populate the cache directory with the result of |
| 111 |
# building the entire tracepoint query module. |
| 112 |
catch { exec stap -l {kernel.trace("*")} } |
| 113 |
|
| 114 |
# Now test each group individually. |
| 115 |
set last_group "" |
| 116 |
set script_template {"probe kernel.trace(\"%s\") { exit() }"} |
| 117 |
foreach stp $stap_tracepoints { |
| 118 |
regexp {^([^:]+):([^:]+)$} $stp dummy group tracepoint |
| 119 |
if {$last_group == $group} { continue } |
| 120 |
set last_group $group |
| 121 |
|
| 122 |
set script [format $script_template "${group}:${tracepoint}"] |
| 123 |
stap_compile "$test: group '$group' solo" 1 $script |
| 124 |
} |