Commit | Line | Data |
---|---|---|
8cfcd41c MD |
1 | #!/bin/bash |
2 | # | |
3 | # Copyright (C) - 2013 Christian Babeux <christian.babeux@efficios.com> | |
4 | # Copyright (C) - 2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
5 | # | |
6 | # This program is free software; you can redistribute it and/or modify it | |
7 | # under the terms of the GNU General Public License, version 2 only, as | |
8 | # published by the Free Software Foundation. | |
9 | # | |
10 | # This program is distributed in the hope that it will be useful, but WITHOUT | |
11 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
12 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
13 | # more details. | |
14 | # | |
15 | # You should have received a copy of the GNU General Public License along with | |
16 | # this program; if not, write to the Free Software Foundation, Inc., 51 | |
17 | # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 | ||
19 | TEST_DESC="Kernel tracer - System calls" | |
20 | ||
21 | CURDIR=$(dirname $0)/ | |
22 | TESTDIR=$CURDIR/../.. | |
fac26884 | 23 | NUM_TESTS=157 |
8cfcd41c MD |
24 | |
25 | # test command issues at least open and close system calls | |
26 | TESTCMD="cat /proc/cpuinfo > /dev/null" | |
27 | ||
28 | source $TESTDIR/utils/utils.sh | |
29 | ||
02db71ba DG |
30 | function validate_list() |
31 | { | |
32 | local session_name=$1 | |
33 | local event_name=$2 | |
34 | local opt=$3 | |
35 | ||
36 | out=$($TESTDIR/../src/bin/lttng/$LTTNG_BIN list $session_name $opt | grep $event_name) | |
37 | if [ -z "$out" ]; then | |
38 | fail "Validate syscall listing" | |
39 | diag "$event_name not found when listing $session_name (opt $opt)" | |
40 | else | |
41 | pass "Validate syscall listing. Found $event_name." | |
42 | fi | |
43 | } | |
44 | ||
45 | function test_syscall_event_list() | |
46 | { | |
47 | local EVENT_NAME="getpid" | |
48 | ||
49 | diag "Syscall event listing" | |
50 | ||
51 | validate_list "" $EVENT_NAME "-k --syscall" | |
52 | } | |
53 | ||
54 | function test_syscall_simple_list() | |
55 | { | |
56 | TRACE_PATH=$(mktemp -d) | |
57 | SESSION_NAME="kernel_syscall_simple_list" | |
58 | local EVENT_NAME="close" | |
59 | ||
60 | diag "Syscall simple listing" | |
61 | ||
bf6ae429 | 62 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
02db71ba DG |
63 | |
64 | lttng_enable_kernel_syscall_ok $SESSION_NAME $EVENT_NAME | |
65 | ||
66 | validate_list $SESSION_NAME $EVENT_NAME | |
67 | ||
e563bbdb | 68 | start_lttng_tracing_ok |
02db71ba | 69 | eval ${TESTCMD} |
96340a01 | 70 | stop_lttng_tracing_ok |
02db71ba DG |
71 | |
72 | # ensure each is there. | |
73 | validate_trace_exp "-e syscall_entry_$EVENT_NAME: -e compat_syscall_entry_$EVENT_NAME:" $TRACE_PATH | |
74 | validate_trace_exp "-e syscall_exit_$EVENT_NAME: -e compat_syscall_exit_$EVENT_NAME:" $TRACE_PATH | |
75 | ||
76 | # ensure trace only contains those. | |
77 | validate_trace_only_exp "-e syscall_entry_$EVENT_NAME: -e compat_syscall_entry_$EVENT_NAME: -e syscall_exit_$EVENT_NAME: -e compat_syscall_exit_$EVENT_NAME:" $TRACE_PATH | |
78 | ||
67b4c664 | 79 | destroy_lttng_session_ok $SESSION_NAME |
02db71ba DG |
80 | |
81 | rm -rf $TRACE_PATH | |
82 | } | |
83 | ||
84 | function test_syscall_simple_list_two() | |
85 | { | |
86 | TRACE_PATH=$(mktemp -d) | |
87 | SESSION_NAME="kernel_syscall_simple_list_two" | |
88 | local EVENT_NAME="close" | |
89 | local EVENT_NAME2="read" | |
90 | ||
91 | diag "Syscall simple listing" | |
92 | ||
bf6ae429 | 93 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
02db71ba DG |
94 | |
95 | lttng_enable_kernel_syscall_ok $SESSION_NAME $EVENT_NAME | |
96 | lttng_enable_kernel_syscall_ok $SESSION_NAME $EVENT_NAME2 | |
97 | ||
98 | validate_list $SESSION_NAME $EVENT_NAME | |
99 | validate_list $SESSION_NAME $EVENT_NAME2 | |
100 | ||
e563bbdb | 101 | start_lttng_tracing_ok |
02db71ba | 102 | eval ${TESTCMD} |
96340a01 | 103 | stop_lttng_tracing_ok |
02db71ba DG |
104 | |
105 | # ensure each is there. | |
106 | validate_trace_exp "-e syscall_entry_$EVENT_NAME: -e compat_syscall_entry_$EVENT_NAME:" $TRACE_PATH | |
107 | validate_trace_exp "-e syscall_exit_$EVENT_NAME: -e compat_syscall_exit_$EVENT_NAME:" $TRACE_PATH | |
108 | ||
109 | # ensure each is there. | |
110 | validate_trace_exp "-e syscall_entry_$EVENT_NAME2: -e compat_syscall_entry_$EVENT_NAME2:" $TRACE_PATH | |
111 | validate_trace_exp "-e syscall_exit_$EVENT_NAME2: -e compat_syscall_exit_$EVENT_NAME2:" $TRACE_PATH | |
112 | ||
113 | # ensure trace only contains those. | |
114 | validate_trace_only_exp "-e syscall_entry_$EVENT_NAME: -e compat_syscall_entry_$EVENT_NAME: -e syscall_exit_$EVENT_NAME: -e compat_syscall_exit_$EVENT_NAME: -e syscall_entry_$EVENT_NAME2: -e compat_syscall_entry_$EVENT_NAME2: -e syscall_exit_$EVENT_NAME2: -e compat_syscall_exit_$EVENT_NAME2:" $TRACE_PATH | |
115 | ||
67b4c664 | 116 | destroy_lttng_session_ok $SESSION_NAME |
02db71ba DG |
117 | |
118 | rm -rf $TRACE_PATH | |
119 | } | |
120 | ||
8cfcd41c MD |
121 | function test_syscall_single() |
122 | { | |
123 | TRACE_PATH=$(mktemp -d) | |
124 | SESSION_NAME="kernel_syscall_single" | |
125 | ||
031f232e DG |
126 | diag "Syscall trace single" |
127 | ||
bf6ae429 | 128 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
8cfcd41c MD |
129 | |
130 | lttng_enable_kernel_syscall_ok $SESSION_NAME "open" | |
131 | ||
e563bbdb | 132 | start_lttng_tracing_ok |
8cfcd41c | 133 | eval ${TESTCMD} |
96340a01 | 134 | stop_lttng_tracing_ok |
8cfcd41c MD |
135 | |
136 | # ensure each is there. | |
a39bd0ab MD |
137 | validate_trace_exp "-e syscall_entry_open: -e compat_syscall_entry_open:" $TRACE_PATH |
138 | validate_trace_exp "-e syscall_exit_open: -e compat_syscall_exit_open:" $TRACE_PATH | |
8cfcd41c MD |
139 | |
140 | # ensure trace only contains those. | |
a39bd0ab | 141 | validate_trace_only_exp "-e syscall_entry_open: -e compat_syscall_entry_open: -e syscall_exit_open: -e compat_syscall_exit_open:" $TRACE_PATH |
8cfcd41c | 142 | |
67b4c664 | 143 | destroy_lttng_session_ok $SESSION_NAME |
8cfcd41c MD |
144 | |
145 | rm -rf $TRACE_PATH | |
146 | } | |
147 | ||
148 | function test_syscall_two() | |
149 | { | |
150 | TRACE_PATH=$(mktemp -d) | |
151 | SESSION_NAME="kernel_syscall_two" | |
152 | ||
031f232e DG |
153 | diag "Syscall trace two events" |
154 | ||
bf6ae429 | 155 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
8cfcd41c MD |
156 | |
157 | lttng_enable_kernel_syscall_ok $SESSION_NAME "open" | |
158 | lttng_enable_kernel_syscall_ok $SESSION_NAME "close" | |
159 | ||
e563bbdb | 160 | start_lttng_tracing_ok |
8cfcd41c | 161 | eval ${TESTCMD} |
96340a01 | 162 | stop_lttng_tracing_ok |
8cfcd41c MD |
163 | |
164 | # ensure each is there. | |
a39bd0ab MD |
165 | validate_trace_exp "-e syscall_entry_open: -e compat_syscall_entry_open:" $TRACE_PATH |
166 | validate_trace_exp "-e syscall_exit_open: -e compat_syscall_exit_open:" $TRACE_PATH | |
167 | validate_trace_exp "-e syscall_entry_close: -e compat_syscall_entry_close:" $TRACE_PATH | |
168 | validate_trace_exp "-e syscall_exit_close: -e compat_syscall_exit_close:" $TRACE_PATH | |
8cfcd41c MD |
169 | |
170 | # ensure trace only contains those. | |
a39bd0ab | 171 | validate_trace_only_exp "-e syscall_entry_open: -e compat_syscall_entry_open: -e syscall_exit_open: -e compat_syscall_exit_open: -e syscall_entry_close: -e compat_syscall_entry_close: -e syscall_exit_close: -e compat_syscall_exit_close:" $TRACE_PATH |
8cfcd41c | 172 | |
67b4c664 | 173 | destroy_lttng_session_ok $SESSION_NAME |
8cfcd41c MD |
174 | |
175 | rm -rf $TRACE_PATH | |
176 | } | |
177 | ||
178 | function test_syscall_all() | |
179 | { | |
180 | TRACE_PATH=$(mktemp -d) | |
181 | SESSION_NAME="kernel_syscall_all" | |
182 | ||
031f232e DG |
183 | diag "Syscall trace all events" |
184 | ||
bf6ae429 | 185 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
8cfcd41c MD |
186 | |
187 | # enable all syscalls | |
188 | lttng_enable_kernel_syscall_ok $SESSION_NAME | |
189 | ||
e563bbdb | 190 | start_lttng_tracing_ok |
8cfcd41c | 191 | eval ${TESTCMD} |
96340a01 | 192 | stop_lttng_tracing_ok |
8cfcd41c MD |
193 | |
194 | # ensure at least open and close are there. | |
a39bd0ab MD |
195 | validate_trace_exp "-e syscall_entry_open: -e compat_syscall_entry_open:" $TRACE_PATH |
196 | validate_trace_exp "-e syscall_exit_open: -e compat_syscall_exit_open:" $TRACE_PATH | |
197 | validate_trace_exp "-e syscall_entry_close: -e compat_syscall_entry_close:" $TRACE_PATH | |
198 | validate_trace_exp "-e syscall_exit_close: -e compat_syscall_exit_close:" $TRACE_PATH | |
8cfcd41c MD |
199 | # trace may contain other syscalls. |
200 | ||
67b4c664 | 201 | destroy_lttng_session_ok $SESSION_NAME |
8cfcd41c MD |
202 | |
203 | rm -rf $TRACE_PATH | |
204 | } | |
205 | ||
206 | function test_syscall_all_disable_one() | |
207 | { | |
208 | TRACE_PATH=$(mktemp -d) | |
209 | SESSION_NAME="kernel_syscall_all_disable_one" | |
210 | ||
031f232e DG |
211 | diag "Syscall trace all events and disable one" |
212 | ||
bf6ae429 | 213 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
8cfcd41c MD |
214 | |
215 | # enable all syscalls | |
216 | lttng_enable_kernel_syscall_ok $SESSION_NAME | |
fac26884 MD |
217 | # try to disable open system call: fails because enabler semantic of |
218 | # "all syscalls" is not "the open" system call. | |
219 | lttng_disable_kernel_syscall_fail $SESSION_NAME "open" | |
8cfcd41c | 220 | |
e563bbdb | 221 | start_lttng_tracing_ok |
8cfcd41c | 222 | eval ${TESTCMD} |
96340a01 | 223 | stop_lttng_tracing_ok |
8cfcd41c | 224 | |
fac26884 MD |
225 | # ensure "open" syscall is there. |
226 | validate_trace_exp "-e syscall_entry_open: -e compat_syscall_entry_open: -e syscall_exit_open: -e compat_syscall_exit_open:" $TRACE_PATH | |
8cfcd41c MD |
227 | |
228 | # ensure "close" syscall is there. | |
a39bd0ab MD |
229 | validate_trace_exp "-e syscall_entry_close: -e compat_syscall_entry_close:" $TRACE_PATH |
230 | validate_trace_exp "-e syscall_exit_close: -e compat_syscall_exit_close:" $TRACE_PATH | |
8cfcd41c | 231 | |
67b4c664 | 232 | destroy_lttng_session_ok $SESSION_NAME |
8cfcd41c MD |
233 | |
234 | rm -rf $TRACE_PATH | |
235 | } | |
236 | ||
237 | function test_syscall_all_disable_two() | |
238 | { | |
239 | TRACE_PATH=$(mktemp -d) | |
240 | SESSION_NAME="kernel_syscall_all_disable_two" | |
241 | ||
031f232e DG |
242 | diag "Syscall trace all events and disable two" |
243 | ||
bf6ae429 | 244 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
8cfcd41c MD |
245 | |
246 | # enable all syscalls | |
247 | lttng_enable_kernel_syscall_ok $SESSION_NAME | |
fac26884 MD |
248 | # try to disable open and close system calls: fails because enabler |
249 | # semantic of "all syscalls" is not "the open" system call. | |
250 | lttng_disable_kernel_syscall_fail $SESSION_NAME "open" | |
251 | lttng_disable_kernel_syscall_fail $SESSION_NAME "close" | |
8cfcd41c | 252 | |
e563bbdb | 253 | start_lttng_tracing_ok |
8cfcd41c MD |
254 | # generates open, close, execve (at least) |
255 | eval ${TESTCMD} | |
96340a01 | 256 | stop_lttng_tracing_ok |
8cfcd41c | 257 | |
fac26884 MD |
258 | # ensure "open" syscall is there. |
259 | validate_trace_exp "-e syscall_entry_open: -e compat_syscall_entry_open: -e syscall_exit_open: -e compat_syscall_exit_open:" $TRACE_PATH | |
260 | ||
261 | # ensure "close" syscall is there. | |
262 | validate_trace_exp "-e syscall_entry_close: -e compat_syscall_entry_close:" $TRACE_PATH | |
263 | validate_trace_exp "-e syscall_exit_close: -e compat_syscall_exit_close:" $TRACE_PATH | |
8cfcd41c MD |
264 | |
265 | # ensure "execve" syscall is there. | |
a39bd0ab MD |
266 | validate_trace_exp "-e syscall_entry_execve: -e compat_syscall_entry_execve:" $TRACE_PATH |
267 | validate_trace_exp "-e syscall_exit_execve: -e compat_syscall_exit_execve:" $TRACE_PATH | |
8cfcd41c | 268 | |
67b4c664 | 269 | destroy_lttng_session_ok $SESSION_NAME |
8cfcd41c MD |
270 | |
271 | rm -rf $TRACE_PATH | |
272 | } | |
273 | ||
274 | function test_syscall_enable_all_disable_all() | |
275 | { | |
276 | TRACE_PATH=$(mktemp -d) | |
277 | SESSION_NAME="kernel_syscall_enable_all_disable_all" | |
278 | ||
031f232e DG |
279 | diag "Syscall trace all events and disable all" |
280 | ||
bf6ae429 | 281 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
8cfcd41c MD |
282 | |
283 | # enable all system calls | |
284 | lttng_enable_kernel_syscall_ok $SESSION_NAME | |
285 | # disable all system calls | |
286 | lttng_disable_kernel_syscall_ok $SESSION_NAME | |
287 | ||
e563bbdb | 288 | start_lttng_tracing_ok |
8cfcd41c MD |
289 | # generates open, close, execve (at least) |
290 | eval ${TESTCMD} | |
96340a01 | 291 | stop_lttng_tracing_ok |
8cfcd41c MD |
292 | |
293 | # ensure nothing has been traced. | |
294 | validate_trace_empty $TRACE_PATH | |
295 | ||
67b4c664 | 296 | destroy_lttng_session_ok $SESSION_NAME |
8cfcd41c MD |
297 | |
298 | rm -rf $TRACE_PATH | |
299 | } | |
300 | ||
301 | function test_syscall_enable_all_disable_all_enable_all() | |
302 | { | |
303 | TRACE_PATH=$(mktemp -d) | |
304 | SESSION_NAME="kernel_syscall_enable_all_disable_all_enable_all" | |
305 | ||
031f232e DG |
306 | diag "Syscall trace all events and enable/disable all" |
307 | ||
bf6ae429 | 308 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
8cfcd41c MD |
309 | |
310 | # enable all system calls | |
311 | lttng_enable_kernel_syscall_ok $SESSION_NAME | |
312 | # disable all system calls | |
313 | lttng_disable_kernel_syscall_ok $SESSION_NAME | |
314 | # enable all system calls | |
315 | lttng_enable_kernel_syscall_ok $SESSION_NAME | |
316 | ||
e563bbdb | 317 | start_lttng_tracing_ok |
8cfcd41c MD |
318 | # generates open, close, execve (at least) |
319 | eval ${TESTCMD} | |
96340a01 | 320 | stop_lttng_tracing_ok |
8cfcd41c MD |
321 | |
322 | # ensure at least open and close are there. | |
a39bd0ab MD |
323 | validate_trace_exp "-e syscall_entry_open: -e compat_syscall_entry_open:" $TRACE_PATH |
324 | validate_trace_exp "-e syscall_exit_open: -e compat_syscall_exit_open:" $TRACE_PATH | |
325 | validate_trace_exp "-e syscall_entry_close: -e compat_syscall_entry_close:" $TRACE_PATH | |
326 | validate_trace_exp "-e syscall_exit_close: -e compat_syscall_exit_close:" $TRACE_PATH | |
8cfcd41c MD |
327 | # trace may contain other syscalls. |
328 | ||
67b4c664 | 329 | destroy_lttng_session_ok $SESSION_NAME |
8cfcd41c MD |
330 | |
331 | rm -rf $TRACE_PATH | |
332 | } | |
333 | ||
334 | function test_syscall_enable_all_disable_all_twice() | |
335 | { | |
336 | TRACE_PATH=$(mktemp -d) | |
337 | SESSION_NAME="kernel_syscall_enable_all_disable_all_twice" | |
338 | ||
031f232e DG |
339 | diag "Syscall trace all events and enable/disable all twice" |
340 | ||
bf6ae429 | 341 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
8cfcd41c MD |
342 | |
343 | # enable all system calls | |
344 | lttng_enable_kernel_syscall_ok $SESSION_NAME | |
345 | # disable all system calls | |
346 | lttng_disable_kernel_syscall_ok $SESSION_NAME | |
347 | # enable all system calls | |
348 | lttng_enable_kernel_syscall_ok $SESSION_NAME | |
349 | # disable all system calls | |
350 | lttng_disable_kernel_syscall_ok $SESSION_NAME | |
351 | ||
e563bbdb | 352 | start_lttng_tracing_ok |
8cfcd41c MD |
353 | # generates open, close, execve (at least) |
354 | eval ${TESTCMD} | |
96340a01 | 355 | stop_lttng_tracing_ok |
8cfcd41c MD |
356 | |
357 | # ensure nothing has been traced. | |
358 | validate_trace_empty $TRACE_PATH | |
359 | ||
67b4c664 | 360 | destroy_lttng_session_ok $SESSION_NAME |
8cfcd41c MD |
361 | |
362 | rm -rf $TRACE_PATH | |
363 | } | |
364 | ||
365 | function test_syscall_enable_one_disable_one() | |
366 | { | |
367 | TRACE_PATH=$(mktemp -d) | |
368 | SESSION_NAME="kernel_syscall_enable_one_disable_one" | |
369 | ||
031f232e DG |
370 | diag "Syscall trace one event and disable one" |
371 | ||
bf6ae429 | 372 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
8cfcd41c MD |
373 | |
374 | # enable open system call | |
375 | lttng_enable_kernel_syscall_ok $SESSION_NAME "open" | |
376 | # disable open system call | |
377 | lttng_disable_kernel_syscall_ok $SESSION_NAME "open" | |
378 | ||
e563bbdb | 379 | start_lttng_tracing_ok |
8cfcd41c MD |
380 | # generates open, close, execve (at least) |
381 | eval ${TESTCMD} | |
96340a01 | 382 | stop_lttng_tracing_ok |
8cfcd41c MD |
383 | |
384 | # ensure nothing has been traced. | |
385 | validate_trace_empty $TRACE_PATH | |
386 | ||
67b4c664 | 387 | destroy_lttng_session_ok $SESSION_NAME |
8cfcd41c MD |
388 | |
389 | rm -rf $TRACE_PATH | |
390 | } | |
391 | ||
392 | function test_syscall_enable_two_disable_two() | |
393 | { | |
394 | TRACE_PATH=$(mktemp -d) | |
395 | SESSION_NAME="kernel_syscall_enable_two_disable_two" | |
396 | ||
031f232e DG |
397 | diag "Syscall trace two events and disable two" |
398 | ||
bf6ae429 | 399 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
8cfcd41c MD |
400 | |
401 | # enable open and close system calls | |
402 | lttng_enable_kernel_syscall_ok $SESSION_NAME "open" | |
403 | lttng_enable_kernel_syscall_ok $SESSION_NAME "close" | |
404 | # disable open and close system calls | |
405 | lttng_disable_kernel_syscall_ok $SESSION_NAME "open" | |
406 | lttng_disable_kernel_syscall_ok $SESSION_NAME "close" | |
407 | ||
e563bbdb | 408 | start_lttng_tracing_ok |
8cfcd41c MD |
409 | # generates open, close, execve (at least) |
410 | eval ${TESTCMD} | |
96340a01 | 411 | stop_lttng_tracing_ok |
8cfcd41c MD |
412 | |
413 | # ensure nothing has been traced. | |
414 | validate_trace_empty $TRACE_PATH | |
415 | ||
67b4c664 | 416 | destroy_lttng_session_ok $SESSION_NAME |
8cfcd41c MD |
417 | |
418 | rm -rf $TRACE_PATH | |
419 | } | |
420 | ||
421 | function test_syscall_enable_two_disable_one() | |
422 | { | |
423 | TRACE_PATH=$(mktemp -d) | |
424 | SESSION_NAME="kernel_syscall_enable_two_disable_one" | |
425 | ||
031f232e DG |
426 | diag "Syscall trace two events and disable one" |
427 | ||
bf6ae429 | 428 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
8cfcd41c MD |
429 | |
430 | # enable open and close system calls | |
431 | lttng_enable_kernel_syscall_ok $SESSION_NAME "open" | |
432 | lttng_enable_kernel_syscall_ok $SESSION_NAME "close" | |
433 | # disable close system call | |
434 | lttng_disable_kernel_syscall_ok $SESSION_NAME "close" | |
435 | ||
e563bbdb | 436 | start_lttng_tracing_ok |
8cfcd41c MD |
437 | # generates open, close, execve (at least) |
438 | eval ${TESTCMD} | |
96340a01 | 439 | stop_lttng_tracing_ok |
8cfcd41c MD |
440 | |
441 | # ensure open is there. | |
a39bd0ab MD |
442 | validate_trace_exp "-e syscall_entry_open: -e compat_syscall_entry_open:" $TRACE_PATH |
443 | validate_trace_exp "-e syscall_exit_open: -e compat_syscall_exit_open:" $TRACE_PATH | |
8cfcd41c MD |
444 | |
445 | # ensure trace only contains those. | |
a39bd0ab | 446 | validate_trace_only_exp "-e syscall_entry_open: -e compat_syscall_entry_open: -e syscall_exit_open: -e compat_syscall_exit_open:" $TRACE_PATH |
8cfcd41c | 447 | |
67b4c664 | 448 | destroy_lttng_session_ok $SESSION_NAME |
8cfcd41c MD |
449 | |
450 | rm -rf $TRACE_PATH | |
451 | } | |
452 | ||
453 | function test_syscall_disable_twice() | |
454 | { | |
455 | TRACE_PATH=$(mktemp -d) | |
456 | SESSION_NAME="kernel_syscall_disable_twice" | |
457 | ||
031f232e DG |
458 | diag "Syscall trace one event and disable twice" |
459 | ||
bf6ae429 | 460 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
8cfcd41c MD |
461 | |
462 | lttng_enable_kernel_syscall_ok $SESSION_NAME "open" | |
463 | # First disable will succeed | |
464 | lttng_disable_kernel_syscall_ok $SESSION_NAME "open" | |
fac26884 MD |
465 | # Second disable succeeds too, due to enabler semantic. |
466 | lttng_disable_kernel_syscall_ok $SESSION_NAME "open" | |
8cfcd41c | 467 | |
67b4c664 | 468 | destroy_lttng_session_ok $SESSION_NAME |
8cfcd41c MD |
469 | |
470 | rm -rf $TRACE_PATH | |
471 | } | |
472 | ||
473 | function test_syscall_disable_all_twice() | |
474 | { | |
475 | TRACE_PATH=$(mktemp -d) | |
476 | SESSION_NAME="kernel_syscall_disable_all_twice" | |
477 | ||
031f232e DG |
478 | diag "Syscall trace all events and disable all twice" |
479 | ||
bf6ae429 | 480 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
8cfcd41c MD |
481 | |
482 | lttng_enable_kernel_syscall_ok $SESSION_NAME | |
483 | # First disable will succeed | |
484 | lttng_disable_kernel_syscall_ok $SESSION_NAME | |
fac26884 MD |
485 | # Second disable succeeds too, due to enabler semantic. |
486 | lttng_disable_kernel_syscall_ok $SESSION_NAME | |
8cfcd41c | 487 | |
67b4c664 | 488 | destroy_lttng_session_ok $SESSION_NAME |
8cfcd41c MD |
489 | |
490 | rm -rf $TRACE_PATH | |
491 | } | |
492 | ||
493 | ||
494 | function test_syscall_enable_unknown() | |
495 | { | |
496 | TRACE_PATH=$(mktemp -d) | |
497 | SESSION_NAME="kernel_syscall_enable_unknown" | |
498 | ||
031f232e DG |
499 | diag "Syscall enable an unknown event" |
500 | ||
bf6ae429 | 501 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
8cfcd41c | 502 | |
fac26884 MD |
503 | # Enabling a syscall that does not exist succeeds, due to enabler |
504 | # semantic. | |
505 | lttng_enable_kernel_syscall_ok $SESSION_NAME "thissyscallcannotexist" | |
8cfcd41c | 506 | |
67b4c664 | 507 | destroy_lttng_session_ok $SESSION_NAME |
8cfcd41c MD |
508 | |
509 | rm -rf $TRACE_PATH | |
510 | } | |
511 | ||
512 | function test_syscall_enable_all_enable_one() | |
513 | { | |
514 | TRACE_PATH=$(mktemp -d) | |
515 | SESSION_NAME="kernel_syscall_enable_all_enable_one" | |
516 | ||
031f232e DG |
517 | diag "Syscall enable all and enable one" |
518 | ||
bf6ae429 | 519 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
8cfcd41c MD |
520 | |
521 | lttng_enable_kernel_syscall_ok $SESSION_NAME | |
fac26884 MD |
522 | # Enabling an event already enabled succeeds, due to enabler semantic. |
523 | lttng_enable_kernel_syscall_ok $SESSION_NAME "open" | |
8cfcd41c | 524 | |
67b4c664 | 525 | destroy_lttng_session_ok $SESSION_NAME |
8cfcd41c MD |
526 | |
527 | rm -rf $TRACE_PATH | |
528 | } | |
529 | ||
530 | function test_syscall_disable_all_disable_one() | |
531 | { | |
532 | TRACE_PATH=$(mktemp -d) | |
533 | SESSION_NAME="kernel_syscall_enable_all_enable_one" | |
534 | ||
031f232e DG |
535 | diag "Syscall disable all and disable one" |
536 | ||
bf6ae429 | 537 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
8cfcd41c MD |
538 | |
539 | lttng_enable_kernel_syscall_ok $SESSION_NAME | |
540 | lttng_disable_kernel_syscall_ok $SESSION_NAME | |
541 | # Disabling an event already disabled fails. | |
542 | lttng_disable_kernel_syscall_fail $SESSION_NAME "open" | |
543 | ||
67b4c664 | 544 | destroy_lttng_session_ok $SESSION_NAME |
8cfcd41c MD |
545 | |
546 | rm -rf $TRACE_PATH | |
547 | } | |
548 | ||
d96f6315 MD |
549 | function test_syscall_enable_channel_disable_all() |
550 | { | |
551 | TRACE_PATH=$(mktemp -d) | |
552 | SESSION_NAME="kernel_syscall_enable_channel_disable_all" | |
553 | CHANNEL_NAME="channel" | |
554 | ||
031f232e DG |
555 | diag "Syscall enable channel and disable all" |
556 | ||
bf6ae429 | 557 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
d96f6315 MD |
558 | |
559 | lttng_enable_kernel_channel_ok $SESSION_NAME $CHANNEL_NAME | |
fac26884 MD |
560 | # sessiond semantic for "disable all" is to try to match all enalers |
561 | # it knowns about. Disable all succeeds if it finds no match. | |
562 | lttng_disable_kernel_syscall_ok $SESSION_NAME "-a" $CHANNEL_NAME | |
d96f6315 | 563 | |
67b4c664 | 564 | destroy_lttng_session_ok $SESSION_NAME |
d96f6315 MD |
565 | |
566 | rm -rf $TRACE_PATH | |
567 | } | |
568 | ||
569 | function test_syscall_enable_channel_disable_one() | |
570 | { | |
571 | TRACE_PATH=$(mktemp -d) | |
572 | SESSION_NAME="kernel_syscall_enable_channel_disable_all" | |
573 | CHANNEL_NAME="channel" | |
574 | ||
031f232e DG |
575 | diag "Syscall enable channel and disable one" |
576 | ||
bf6ae429 | 577 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
d96f6315 MD |
578 | |
579 | lttng_enable_kernel_channel_ok $SESSION_NAME $CHANNEL_NAME | |
580 | lttng_disable_kernel_syscall_fail $SESSION_NAME "open" $CHANNEL_NAME | |
581 | ||
67b4c664 | 582 | destroy_lttng_session_ok $SESSION_NAME |
d96f6315 MD |
583 | |
584 | rm -rf $TRACE_PATH | |
585 | } | |
586 | ||
8cfcd41c MD |
587 | # MUST set TESTDIR before calling those functions |
588 | plan_tests $NUM_TESTS | |
589 | ||
590 | print_test_banner "$TEST_DESC" | |
591 | ||
592 | if [ "$(id -u)" == "0" ]; then | |
593 | isroot=1 | |
594 | else | |
595 | isroot=0 | |
596 | fi | |
597 | ||
598 | skip $isroot "Root access is needed. Skipping all tests." $NUM_TESTS || | |
599 | { | |
600 | start_lttng_sessiond | |
601 | ||
02db71ba DG |
602 | test_syscall_event_list |
603 | test_syscall_simple_list | |
604 | test_syscall_simple_list_two | |
8cfcd41c MD |
605 | test_syscall_single |
606 | test_syscall_two | |
607 | test_syscall_all | |
608 | test_syscall_all_disable_one | |
609 | test_syscall_all_disable_two | |
610 | test_syscall_enable_all_disable_all | |
611 | test_syscall_enable_all_disable_all_enable_all | |
612 | test_syscall_enable_all_disable_all_twice | |
613 | test_syscall_enable_one_disable_one | |
614 | test_syscall_enable_two_disable_two | |
615 | test_syscall_enable_two_disable_one | |
616 | test_syscall_disable_twice | |
617 | test_syscall_disable_all_twice | |
618 | test_syscall_enable_unknown | |
619 | test_syscall_enable_all_enable_one | |
620 | test_syscall_disable_all_disable_one | |
d96f6315 MD |
621 | test_syscall_enable_channel_disable_all |
622 | test_syscall_enable_channel_disable_one | |
8cfcd41c MD |
623 | |
624 | stop_lttng_sessiond | |
625 | } |