Debian Codegraph @

doc/SystemTap_Beginners_Guide/testsuite/systemtap.base/utrace_p4.exp

raw
1 # Utrace compile (pass 4) tests. We can't run these as
2 # testsuite/buildok tests, since if the current kernel has no utrace
3 # support, those will fail - but not because of a problem with
4 # systemtap's utrace probes (but because of the lack of utrace). So,
5 # this test script checks for the existence of utrace in the kernel.
6 # If utrace exists in the kernel, it tries some compile tests. If
7 # utrace doesn't exist in the kernel, marks the tests as 'untested'.
8
9 proc dyninst_xfails {test} {
10 # Use setup_xfail <pr number> <target triplet> for known bugs.
11 #
12 # (Note that tcl doesn't like comments directly inside the switch
13 # statement, but comments can go in sub-blocks.)
14 switch $test {
15 "UTRACE_P4_03 (dyninst)" -
16 "UTRACE_P4_03_pid (dyninst)" -
17 "UTRACE_P4_04 (dyninst)" -
18 "UTRACE_P4_04_pid (dyninst)" -
19 "UTRACE_P4_08 (dyninst)" -
20 "UTRACE_P4_09 (dyninst)" {
21 # Use setup_xfail DYNINST <target triplet> for known
22 # failures when running with the dyninst runtime (scripts
23 # that use unimplemented features, like 'process.syscall'
24 # probes).
25 setup_xfail DYNINST *-*-*
26 }
27 }
28 }
29
30 # start a program for probes reliant on a PID
31 set pid [exec sleep 1h &]
32
33 # Initialize variables
34 set begin_script {"probe process(\"/bin/ls\").begin { print(\"ls begin\") }"}
35 set end_script {"probe process(\"/bin/ls\").end { print(\"ls end\") }"}
36 set syscall_script {"probe process(\"/bin/ls\").syscall { printf(\"|%d\", \$syscall) }"}
37 set syscall_parms_script {"probe process(\"/bin/ls\").syscall { printf(\"|%s\", \$\$parms) }"}
38 set syscall_return_script {"probe process(\"/bin/ls\").syscall.return { printf(\"|%d\", \$syscall) }"}
39 set thread_begin_script {"probe process(\"/bin/ls\").thread.begin { print(\"ls thread.begin\") }"}
40 set thread_end_script {"probe process(\"/bin/ls\").thread.end { print(\"ls thread.end\") }"}
41 set all_begin_script {"probe process.begin { print(\"begin\") }"}
42
43 set pid_begin_script [string map "PID $pid" {"probe process(PID).begin { print(\"PID begin\") }"}]
44 set pid_end_script [string map "PID $pid" {"probe process(PID).end { print(\"PID end\") }"}]
45 set pid_syscall_script [string map "PID $pid" {"probe process(PID).syscall { printf(\"|%d\", \$syscall) }"}]
46 set pid_parms_script [string map "PID $pid" {"probe process(PID).syscall { printf(\"|%s\", \$\$parms) }"}]
47 set pid_syscall_return_script [string map "PID $pid" {"probe process(PID).syscall.return { printf(\"|%d\", \$syscall) }"}]
48 set pid_thread_begin_script [string map "PID $pid" {"probe process(PID).thread.begin { print(\"PID thread.begin\") }"}]
49 set pid_thread_end_script [string map "PID $pid" {"probe process(PID).thread.end { print(\"PID thread.end\") }"}]
50
51 #
52 # Do some utrace compile tests.
53 #
54
55 set TEST_NAME "UTRACE_P4_01"
56 if {![utrace_p]} {
57 untested "$TEST_NAME : no kernel utrace support found"
58 } else {
59 # Try compiling a begin script using a path
60 foreach runtime [get_runtime_list] {
61 set test "$TEST_NAME"
62 if {$runtime != ""} {
63 lappend test "($runtime)"
64 ${runtime}_xfails $test
65 stap_compile $test 1 $begin_script --runtime=$runtime
66 } else {
67 stap_compile $test 1 $begin_script
68 }
69 }
70 }
71
72 set TEST_NAME "UTRACE_P4_01_pid"
73 if {![utrace_p]} {
74 untested "$TEST_NAME : no kernel utrace support found"
75 } else {
76 # Try compiling a begin script using a pid
77 foreach runtime [get_runtime_list] {
78 set test "$TEST_NAME"
79 if {$runtime != ""} {
80 lappend test "($runtime)"
81 ${runtime}_xfails $test
82 stap_compile $test 1 $pid_begin_script --runtime=$runtime
83 } else {
84 stap_compile $test 1 $pid_begin_script
85 }
86 }
87 }
88
89 set TEST_NAME "UTRACE_P4_02"
90 if {![utrace_p]} {
91 untested "$TEST_NAME : no kernel utrace support found"
92 } else {
93 # Try compiling a end script using a path
94 foreach runtime [get_runtime_list] {
95 set test "$TEST_NAME"
96 if {$runtime != ""} {
97 lappend test "($runtime)"
98 ${runtime}_xfails $test
99 stap_compile $test 1 $end_script --runtime=$runtime
100 } else {
101 stap_compile $test 1 $end_script
102 }
103 }
104 }
105
106 set TEST_NAME "UTRACE_P4_02_pid"
107 if {![utrace_p]} {
108 untested "$TEST_NAME : no kernel utrace support found"
109 } else {
110 # Try compiling a end script using a pid
111 foreach runtime [get_runtime_list] {
112 set test "$TEST_NAME"
113 if {$runtime != ""} {
114 lappend test "($runtime)"
115 ${runtime}_xfails $test
116 stap_compile $test 1 $pid_end_script --runtime=$runtime
117 } else {
118 stap_compile $test 1 $pid_end_script
119 }
120 }
121 }
122
123 set TEST_NAME "UTRACE_P4_03"
124 if {![utrace_p]} {
125 untested "$TEST_NAME : no kernel utrace support found"
126 } else {
127 # Try compiling a syscall script using a path
128 foreach runtime [get_runtime_list] {
129 set test "$TEST_NAME"
130 if {$runtime != ""} {
131 lappend test "($runtime)"
132 ${runtime}_xfails $test
133 #setup_xfail DYNINST *-*-*
134 stap_compile $test 1 $syscall_script --runtime=$runtime
135 } else {
136 stap_compile $test 1 $syscall_script
137 }
138 }
139 }
140
141 set TEST_NAME "UTRACE_P4_03_pid"
142 if {![utrace_p]} {
143 untested "$TEST_NAME : no kernel utrace support found"
144 } else {
145 # Try compiling a syscall script using a pid
146 foreach runtime [get_runtime_list] {
147 set test "$TEST_NAME"
148 if {$runtime != ""} {
149 lappend test "($runtime)"
150 ${runtime}_xfails $test
151 stap_compile $test 1 $pid_syscall_script --runtime=$runtime
152 } else {
153 stap_compile $test 1 $pid_syscall_script
154 }
155 }
156 }
157
158 set TEST_NAME "UTRACE_P4_04"
159 if {![utrace_p]} {
160 untested "$TEST_NAME : no kernel utrace support found"
161 } else {
162 # Try compiling a syscall return script using a path
163 foreach runtime [get_runtime_list] {
164 set test "$TEST_NAME"
165 if {$runtime != ""} {
166 lappend test "($runtime)"
167 ${runtime}_xfails $test
168 stap_compile $test 1 $syscall_return_script --runtime=$runtime
169 } else {
170 stap_compile $test 1 $syscall_return_script
171 }
172 }
173 }
174
175 set TEST_NAME "UTRACE_P4_04_pid"
176 if {![utrace_p]} {
177 untested "$TEST_NAME : no kernel utrace support found"
178 } else {
179 # Try compiling a syscall return script using a pid
180 foreach runtime [get_runtime_list] {
181 set test "$TEST_NAME"
182 if {$runtime != ""} {
183 lappend test "($runtime)"
184 ${runtime}_xfails $test
185 stap_compile $test 1 $pid_syscall_return_script --runtime=$runtime
186 } else {
187 stap_compile $test 1 $pid_syscall_return_script
188 }
189 }
190 }
191
192 set TEST_NAME "UTRACE_P4_05"
193 if {![utrace_p]} {
194 untested "$TEST_NAME : no kernel utrace support found"
195 } else {
196 # Try compiling an thread.begin script using a path
197 foreach runtime [get_runtime_list] {
198 set test "$TEST_NAME"
199 if {$runtime != ""} {
200 lappend test "($runtime)"
201 ${runtime}_xfails $test
202 stap_compile $test 1 $thread_begin_script --runtime=$runtime
203 } else {
204 stap_compile $test 1 $thread_begin_script
205 }
206 }
207 }
208
209 set TEST_NAME "UTRACE_P4_05_pid"
210 if {![utrace_p]} {
211 untested "$TEST_NAME : no kernel utrace support found"
212 } else {
213 # Try compiling an thread.begin script using a pid
214 foreach runtime [get_runtime_list] {
215 set test "$TEST_NAME"
216 if {$runtime != ""} {
217 lappend test "($runtime)"
218 ${runtime}_xfails $test
219 stap_compile $test 1 $pid_thread_begin_script --runtime=$runtime
220 } else {
221 stap_compile $test 1 $pid_thread_begin_script
222 }
223 }
224 }
225
226 set TEST_NAME "UTRACE_P4_06"
227 if {![utrace_p]} {
228 untested "$TEST_NAME : no kernel utrace support found"
229 } else {
230 # Try compiling an thread.end script using a path
231 foreach runtime [get_runtime_list] {
232 set test "$TEST_NAME"
233 if {$runtime != ""} {
234 lappend test "($runtime)"
235 ${runtime}_xfails $test
236 stap_compile $test 1 $thread_end_script --runtime=$runtime
237 } else {
238 stap_compile $test 1 $thread_end_script
239 }
240 }
241 }
242
243 set TEST_NAME "UTRACE_P4_06_pid"
244 if {![utrace_p]} {
245 untested "$TEST_NAME : no kernel utrace support found"
246 } else {
247 # Try compiling an thread.end script using a pid
248 foreach runtime [get_runtime_list] {
249 set test "$TEST_NAME"
250 if {$runtime != ""} {
251 lappend test "($runtime)"
252 ${runtime}_xfails $test
253 stap_compile $test 1 $pid_thread_end_script --runtime=$runtime
254 } else {
255 stap_compile $test 1 $pid_thread_end_script
256 }
257 }
258 }
259
260 set TEST_NAME "UTRACE_P4_07"
261 if {![utrace_p]} {
262 untested "$TEST_NAME : no kernel utrace support found"
263 } else {
264 # Try compiling an system-wide begin script
265 foreach runtime [get_runtime_list] {
266 set test "$TEST_NAME"
267 if {$runtime != ""} {
268 lappend test "($runtime)"
269 ${runtime}_xfails $test
270 stap_compile $test 1 $all_begin_script --runtime=$runtime
271 } else {
272 stap_compile $test 1 $all_begin_script
273 }
274 }
275 }
276
277 set TEST_NAME "UTRACE_P4_08"
278 if {![utrace_p]} {
279 untested "$TEST_NAME : no kernel utrace support found"
280 } else {
281 # Try compiling a syscall parms script using a path
282 foreach runtime [get_runtime_list] {
283 set test "$TEST_NAME"
284 if {$runtime != ""} {
285 lappend test "($runtime)"
286 ${runtime}_xfails $test
287 stap_compile $test 1 $syscall_parms_script --runtime=$runtime
288 } else {
289 stap_compile $test 1 $syscall_parms_script
290 }
291 }
292 }
293
294 set TEST_NAME "UTRACE_P4_09"
295 if {![utrace_p]} {
296 untested "$TEST_NAME : no kernel utrace support found"
297 } else {
298 # Try compiling a syscall parms script using a pid
299 foreach runtime [get_runtime_list] {
300 set test "$TEST_NAME"
301 if {$runtime != ""} {
302 lappend test "($runtime)"
303 ${runtime}_xfails $test
304 stap_compile $test 1 $pid_parms_script --runtime=$runtime
305 } else {
306 stap_compile $test 1 $pid_parms_script
307 }
308 }
309 }
310
311 # kill the process that we were using for testing probes
312 kill -INT $pid 2
313 catch {exec {}}