Commit | Line | Data |
---|---|---|
8cfcd41c MD |
1 | #!/bin/bash |
2 | # | |
9d16b343 MJ |
3 | # Copyright (C) 2013 Christian Babeux <christian.babeux@efficios.com> |
4 | # Copyright (C) 2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
8cfcd41c | 5 | # |
9d16b343 | 6 | # SPDX-License-Identifier: GPL-2.0-only |
8cfcd41c | 7 | # |
8cfcd41c MD |
8 | |
9 | TEST_DESC="Kernel tracer - System calls" | |
10 | ||
11 | CURDIR=$(dirname $0)/ | |
12 | TESTDIR=$CURDIR/../.. | |
0ee507ec | 13 | NUM_TESTS=214 |
8cfcd41c | 14 | |
c8e51d15 FD |
15 | # `gen-syscall-event` starts and waits for the creation a file passed by |
16 | # arguments to start executing 3 syscalls (open,read,close) and returning. | |
17 | TESTCMD="$TESTDIR/utils/testapp/gen-syscall-events/gen-syscall-events" | |
8cfcd41c MD |
18 | |
19 | source $TESTDIR/utils/utils.sh | |
20 | ||
c8e51d15 FD |
21 | function trace_testapp() |
22 | { | |
33e55711 | 23 | local start_file_sync=$(mktemp --tmpdir -u -t "tmp.${FUNCNAME[0]}_sync_start.XXXXXX") |
c8e51d15 FD |
24 | |
25 | # Clear all entries from the resource tracker | |
26 | lttng_untrack_kernel_all_ok | |
27 | ||
28 | # Launch the testapp and save its Process ID | |
ca342eaf | 29 | ./"$TESTCMD" "$start_file_sync" "/proc/cpuinfo" "/proc/cmdline" & |
c8e51d15 FD |
30 | PID=$! |
31 | ||
32 | # Set LTTng to track this PID and start the tracing | |
33 | lttng_track_pid_ok $PID | |
34 | ||
35 | start_lttng_tracing_ok | |
36 | ||
37 | # Create start file to launch the execution of the workload by the | |
38 | # test app | |
39 | touch "$start_file_sync" | |
40 | ||
41 | wait $PID | |
42 | ||
43 | stop_lttng_tracing_ok | |
44 | ||
45 | # Clean up the synchronization file | |
46 | rm -f "$start_file_sync" | |
47 | } | |
48 | ||
02db71ba DG |
49 | function validate_list() |
50 | { | |
51 | local session_name=$1 | |
52 | local event_name=$2 | |
53 | local opt=$3 | |
54 | ||
55 | out=$($TESTDIR/../src/bin/lttng/$LTTNG_BIN list $session_name $opt | grep $event_name) | |
56 | if [ -z "$out" ]; then | |
57 | fail "Validate syscall listing" | |
58 | diag "$event_name not found when listing $session_name (opt $opt)" | |
59 | else | |
60 | pass "Validate syscall listing. Found $event_name." | |
61 | fi | |
62 | } | |
63 | ||
64 | function test_syscall_event_list() | |
65 | { | |
66 | local EVENT_NAME="getpid" | |
67 | ||
68 | diag "Syscall event listing" | |
69 | ||
70 | validate_list "" $EVENT_NAME "-k --syscall" | |
71 | } | |
72 | ||
73 | function test_syscall_simple_list() | |
74 | { | |
33e55711 | 75 | local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX") |
02db71ba DG |
76 | SESSION_NAME="kernel_syscall_simple_list" |
77 | local EVENT_NAME="close" | |
78 | ||
79 | diag "Syscall simple listing" | |
80 | ||
bf6ae429 | 81 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
02db71ba DG |
82 | |
83 | lttng_enable_kernel_syscall_ok $SESSION_NAME $EVENT_NAME | |
84 | ||
85 | validate_list $SESSION_NAME $EVENT_NAME | |
86 | ||
c8e51d15 | 87 | trace_testapp |
02db71ba | 88 | |
c8e51d15 | 89 | # ensure all events are in the trace. |
02db71ba DG |
90 | validate_trace_exp "-e syscall_entry_$EVENT_NAME: -e compat_syscall_entry_$EVENT_NAME:" $TRACE_PATH |
91 | validate_trace_exp "-e syscall_exit_$EVENT_NAME: -e compat_syscall_exit_$EVENT_NAME:" $TRACE_PATH | |
92 | ||
93 | # ensure trace only contains those. | |
94 | 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 | |
95 | ||
67b4c664 | 96 | destroy_lttng_session_ok $SESSION_NAME |
02db71ba DG |
97 | |
98 | rm -rf $TRACE_PATH | |
99 | } | |
100 | ||
101 | function test_syscall_simple_list_two() | |
102 | { | |
33e55711 | 103 | local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX") |
02db71ba DG |
104 | SESSION_NAME="kernel_syscall_simple_list_two" |
105 | local EVENT_NAME="close" | |
106 | local EVENT_NAME2="read" | |
107 | ||
108 | diag "Syscall simple listing" | |
109 | ||
bf6ae429 | 110 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
02db71ba DG |
111 | |
112 | lttng_enable_kernel_syscall_ok $SESSION_NAME $EVENT_NAME | |
113 | lttng_enable_kernel_syscall_ok $SESSION_NAME $EVENT_NAME2 | |
114 | ||
115 | validate_list $SESSION_NAME $EVENT_NAME | |
116 | validate_list $SESSION_NAME $EVENT_NAME2 | |
117 | ||
c8e51d15 | 118 | trace_testapp |
02db71ba | 119 | |
c8e51d15 | 120 | # ensure all events are in the trace. |
02db71ba DG |
121 | validate_trace_exp "-e syscall_entry_$EVENT_NAME: -e compat_syscall_entry_$EVENT_NAME:" $TRACE_PATH |
122 | validate_trace_exp "-e syscall_exit_$EVENT_NAME: -e compat_syscall_exit_$EVENT_NAME:" $TRACE_PATH | |
123 | ||
02db71ba DG |
124 | validate_trace_exp "-e syscall_entry_$EVENT_NAME2: -e compat_syscall_entry_$EVENT_NAME2:" $TRACE_PATH |
125 | validate_trace_exp "-e syscall_exit_$EVENT_NAME2: -e compat_syscall_exit_$EVENT_NAME2:" $TRACE_PATH | |
126 | ||
127 | # ensure trace only contains those. | |
128 | 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 | |
129 | ||
67b4c664 | 130 | destroy_lttng_session_ok $SESSION_NAME |
02db71ba DG |
131 | |
132 | rm -rf $TRACE_PATH | |
133 | } | |
134 | ||
8cfcd41c MD |
135 | function test_syscall_single() |
136 | { | |
33e55711 | 137 | local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX") |
8cfcd41c MD |
138 | SESSION_NAME="kernel_syscall_single" |
139 | ||
031f232e DG |
140 | diag "Syscall trace single" |
141 | ||
bf6ae429 | 142 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
8cfcd41c | 143 | |
8192bd8f | 144 | lttng_enable_kernel_syscall_ok $SESSION_NAME "openat" |
8cfcd41c | 145 | |
c8e51d15 | 146 | trace_testapp |
8cfcd41c | 147 | |
c8e51d15 | 148 | # ensure all events are in the trace. |
8192bd8f FD |
149 | validate_trace_exp "-e syscall_entry_openat: -e compat_syscall_entry_openat:" $TRACE_PATH |
150 | validate_trace_exp "-e syscall_exit_openat: -e compat_syscall_exit_openat:" $TRACE_PATH | |
8cfcd41c MD |
151 | |
152 | # ensure trace only contains those. | |
8192bd8f | 153 | validate_trace_only_exp "-e syscall_entry_openat: -e compat_syscall_entry_openat: -e syscall_exit_openat: -e compat_syscall_exit_openat:" $TRACE_PATH |
8cfcd41c | 154 | |
67b4c664 | 155 | destroy_lttng_session_ok $SESSION_NAME |
8cfcd41c MD |
156 | |
157 | rm -rf $TRACE_PATH | |
158 | } | |
159 | ||
160 | function test_syscall_two() | |
161 | { | |
33e55711 | 162 | local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX") |
8cfcd41c MD |
163 | SESSION_NAME="kernel_syscall_two" |
164 | ||
031f232e DG |
165 | diag "Syscall trace two events" |
166 | ||
bf6ae429 | 167 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
8cfcd41c | 168 | |
8192bd8f | 169 | lttng_enable_kernel_syscall_ok $SESSION_NAME "openat" |
8cfcd41c MD |
170 | lttng_enable_kernel_syscall_ok $SESSION_NAME "close" |
171 | ||
c8e51d15 | 172 | trace_testapp |
8cfcd41c | 173 | |
c8e51d15 | 174 | # ensure all events are in the trace. |
8192bd8f FD |
175 | validate_trace_exp "-e syscall_entry_openat: -e compat_syscall_entry_openat:" $TRACE_PATH |
176 | validate_trace_exp "-e syscall_exit_openat: -e compat_syscall_exit_openat:" $TRACE_PATH | |
a39bd0ab MD |
177 | validate_trace_exp "-e syscall_entry_close: -e compat_syscall_entry_close:" $TRACE_PATH |
178 | validate_trace_exp "-e syscall_exit_close: -e compat_syscall_exit_close:" $TRACE_PATH | |
8cfcd41c MD |
179 | |
180 | # ensure trace only contains those. | |
8192bd8f | 181 | validate_trace_only_exp "-e syscall_entry_openat: -e compat_syscall_entry_openat: -e syscall_exit_openat: -e compat_syscall_exit_openat: -e syscall_entry_close: -e compat_syscall_entry_close: -e syscall_exit_close: -e compat_syscall_exit_close:" $TRACE_PATH |
8cfcd41c | 182 | |
67b4c664 | 183 | destroy_lttng_session_ok $SESSION_NAME |
8cfcd41c MD |
184 | |
185 | rm -rf $TRACE_PATH | |
186 | } | |
187 | ||
188 | function test_syscall_all() | |
189 | { | |
33e55711 | 190 | local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX") |
8cfcd41c MD |
191 | SESSION_NAME="kernel_syscall_all" |
192 | ||
031f232e DG |
193 | diag "Syscall trace all events" |
194 | ||
bf6ae429 | 195 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
8cfcd41c MD |
196 | |
197 | # enable all syscalls | |
198 | lttng_enable_kernel_syscall_ok $SESSION_NAME | |
199 | ||
c8e51d15 | 200 | trace_testapp |
8cfcd41c MD |
201 | |
202 | # ensure at least open and close are there. | |
8192bd8f FD |
203 | validate_trace_exp "-e syscall_entry_openat: -e compat_syscall_entry_openat:" $TRACE_PATH |
204 | validate_trace_exp "-e syscall_exit_openat: -e compat_syscall_exit_openat:" $TRACE_PATH | |
a39bd0ab MD |
205 | validate_trace_exp "-e syscall_entry_close: -e compat_syscall_entry_close:" $TRACE_PATH |
206 | validate_trace_exp "-e syscall_exit_close: -e compat_syscall_exit_close:" $TRACE_PATH | |
8cfcd41c MD |
207 | # trace may contain other syscalls. |
208 | ||
67b4c664 | 209 | destroy_lttng_session_ok $SESSION_NAME |
8cfcd41c MD |
210 | |
211 | rm -rf $TRACE_PATH | |
212 | } | |
213 | ||
214 | function test_syscall_all_disable_one() | |
215 | { | |
33e55711 | 216 | local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX") |
8cfcd41c MD |
217 | SESSION_NAME="kernel_syscall_all_disable_one" |
218 | ||
031f232e DG |
219 | diag "Syscall trace all events and disable one" |
220 | ||
bf6ae429 | 221 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
8cfcd41c MD |
222 | |
223 | # enable all syscalls | |
224 | lttng_enable_kernel_syscall_ok $SESSION_NAME | |
fac26884 MD |
225 | # try to disable open system call: fails because enabler semantic of |
226 | # "all syscalls" is not "the open" system call. | |
8192bd8f | 227 | lttng_disable_kernel_syscall_fail $SESSION_NAME "openat" |
8cfcd41c | 228 | |
c8e51d15 | 229 | trace_testapp |
8cfcd41c | 230 | |
8192bd8f FD |
231 | # ensure "openat" syscall is there. |
232 | validate_trace_exp "-e syscall_entry_openat: -e compat_syscall_entry_openat: -e syscall_exit_openat: -e compat_syscall_exit_openat:" $TRACE_PATH | |
8cfcd41c MD |
233 | |
234 | # ensure "close" syscall is there. | |
a39bd0ab MD |
235 | validate_trace_exp "-e syscall_entry_close: -e compat_syscall_entry_close:" $TRACE_PATH |
236 | validate_trace_exp "-e syscall_exit_close: -e compat_syscall_exit_close:" $TRACE_PATH | |
8cfcd41c | 237 | |
67b4c664 | 238 | destroy_lttng_session_ok $SESSION_NAME |
8cfcd41c MD |
239 | |
240 | rm -rf $TRACE_PATH | |
241 | } | |
242 | ||
243 | function test_syscall_all_disable_two() | |
244 | { | |
33e55711 | 245 | local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX") |
8cfcd41c MD |
246 | SESSION_NAME="kernel_syscall_all_disable_two" |
247 | ||
031f232e DG |
248 | diag "Syscall trace all events and disable two" |
249 | ||
bf6ae429 | 250 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
8cfcd41c MD |
251 | |
252 | # enable all syscalls | |
253 | lttng_enable_kernel_syscall_ok $SESSION_NAME | |
fac26884 MD |
254 | # try to disable open and close system calls: fails because enabler |
255 | # semantic of "all syscalls" is not "the open" system call. | |
8192bd8f | 256 | lttng_disable_kernel_syscall_fail $SESSION_NAME "openat" |
fac26884 | 257 | lttng_disable_kernel_syscall_fail $SESSION_NAME "close" |
8cfcd41c | 258 | |
c8e51d15 | 259 | trace_testapp |
8cfcd41c | 260 | |
8192bd8f FD |
261 | # ensure "openat" syscall is there. |
262 | validate_trace_exp "-e syscall_entry_openat: -e compat_syscall_entry_openat: -e syscall_exit_openat: -e compat_syscall_exit_openat:" $TRACE_PATH | |
fac26884 MD |
263 | |
264 | # ensure "close" syscall is there. | |
265 | validate_trace_exp "-e syscall_entry_close: -e compat_syscall_entry_close:" $TRACE_PATH | |
266 | validate_trace_exp "-e syscall_exit_close: -e compat_syscall_exit_close:" $TRACE_PATH | |
8cfcd41c | 267 | |
c8e51d15 FD |
268 | # ensure "read" syscall is there. |
269 | validate_trace_exp "-e syscall_entry_read: -e compat_syscall_entry_read:" $TRACE_PATH | |
270 | validate_trace_exp "-e syscall_exit_read: -e compat_syscall_exit_read:" $TRACE_PATH | |
8cfcd41c | 271 | |
67b4c664 | 272 | destroy_lttng_session_ok $SESSION_NAME |
8cfcd41c MD |
273 | |
274 | rm -rf $TRACE_PATH | |
275 | } | |
276 | ||
277 | function test_syscall_enable_all_disable_all() | |
278 | { | |
33e55711 | 279 | local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX") |
8cfcd41c MD |
280 | SESSION_NAME="kernel_syscall_enable_all_disable_all" |
281 | ||
031f232e DG |
282 | diag "Syscall trace all events and disable all" |
283 | ||
bf6ae429 | 284 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
8cfcd41c MD |
285 | |
286 | # enable all system calls | |
287 | lttng_enable_kernel_syscall_ok $SESSION_NAME | |
288 | # disable all system calls | |
289 | lttng_disable_kernel_syscall_ok $SESSION_NAME | |
290 | ||
c8e51d15 | 291 | trace_testapp |
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 | { | |
33e55711 | 303 | local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX") |
8cfcd41c MD |
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 | ||
c8e51d15 | 317 | trace_testapp |
8cfcd41c MD |
318 | |
319 | # ensure at least open and close are there. | |
8192bd8f FD |
320 | validate_trace_exp "-e syscall_entry_openat: -e compat_syscall_entry_openat:" $TRACE_PATH |
321 | validate_trace_exp "-e syscall_exit_openat: -e compat_syscall_exit_openat:" $TRACE_PATH | |
a39bd0ab MD |
322 | validate_trace_exp "-e syscall_entry_close: -e compat_syscall_entry_close:" $TRACE_PATH |
323 | validate_trace_exp "-e syscall_exit_close: -e compat_syscall_exit_close:" $TRACE_PATH | |
8cfcd41c MD |
324 | # trace may contain other syscalls. |
325 | ||
67b4c664 | 326 | destroy_lttng_session_ok $SESSION_NAME |
8cfcd41c MD |
327 | |
328 | rm -rf $TRACE_PATH | |
329 | } | |
330 | ||
0ee507ec MJ |
331 | function test_syscall_enable_all_enable_one_disable_all() |
332 | { | |
33e55711 | 333 | local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX") |
0ee507ec MJ |
334 | SESSION_NAME="kernel_syscall_enable_all_enable_one_disable_all" |
335 | ||
336 | diag "Syscall trace all events, enable one and disable all" | |
337 | ||
338 | create_lttng_session_ok $SESSION_NAME "$TRACE_PATH" | |
339 | ||
340 | # enable all syscalls | |
341 | lttng_enable_kernel_syscall_ok $SESSION_NAME | |
342 | ||
343 | # enable one specific syscall, "openat" | |
344 | lttng_enable_kernel_syscall_ok $SESSION_NAME openat | |
345 | ||
346 | # disable all syscalls | |
347 | lttng_disable_kernel_syscall_ok $SESSION_NAME | |
348 | ||
349 | trace_testapp | |
350 | ||
351 | # The trace shouldn't contain any syscalls, disable-all should disable | |
352 | # even individually specified syscalls | |
353 | trace_match_only openat 0 "$TRACE_PATH" | |
354 | ||
355 | destroy_lttng_session_ok $SESSION_NAME | |
356 | ||
357 | rm -rf "$TRACE_PATH" | |
358 | } | |
359 | ||
360 | function test_syscall_enable_one_enable_all_disable_one() | |
361 | { | |
33e55711 | 362 | local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX") |
0ee507ec MJ |
363 | SESSION_NAME="kernel_syscall_enable_one_enable_all_disable_one" |
364 | ||
365 | diag "Syscall trace all events and enable/disable one" | |
366 | ||
367 | create_lttng_session_ok $SESSION_NAME "$TRACE_PATH" | |
368 | ||
369 | # enable one specific syscall, "openat" | |
370 | lttng_enable_kernel_syscall_ok $SESSION_NAME openat | |
371 | ||
372 | # enable all syscalls | |
373 | lttng_enable_kernel_syscall_ok $SESSION_NAME | |
374 | ||
375 | # disable one specific syscall, "openat" | |
376 | lttng_disable_kernel_syscall_ok $SESSION_NAME openat | |
377 | ||
378 | trace_testapp | |
379 | ||
380 | # The trace should contain all syscalls, including 'openat' because | |
381 | # enable-all overrides individually disabled syscalls. | |
382 | validate_trace openat "$TRACE_PATH" | |
383 | ||
384 | destroy_lttng_session_ok $SESSION_NAME | |
385 | ||
386 | rm -rf "$TRACE_PATH" | |
387 | } | |
388 | ||
389 | function test_syscall_enable_one_enable_all_disable_all_disable_one() | |
390 | { | |
33e55711 | 391 | local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX") |
0ee507ec MJ |
392 | SESSION_NAME="kernel_syscall_enable_one_enable_all_disable_all_disable_one" |
393 | ||
394 | diag "Syscall trace all events and enable/disable one" | |
395 | ||
396 | create_lttng_session_ok $SESSION_NAME "$TRACE_PATH" | |
397 | ||
398 | # enable one specific syscall, "openat" | |
399 | lttng_enable_kernel_syscall_ok $SESSION_NAME openat | |
400 | ||
401 | # enable all syscalls | |
402 | lttng_enable_kernel_syscall_ok $SESSION_NAME | |
403 | ||
404 | # disable all syscalls | |
405 | lttng_disable_kernel_syscall_ok $SESSION_NAME | |
406 | ||
407 | # disable one specific syscall, "openat" | |
408 | lttng_disable_kernel_syscall_ok $SESSION_NAME openat | |
409 | ||
410 | trace_testapp | |
411 | ||
412 | # The trace shouldn't contain any syscalls, disable-all should disable | |
413 | # even individually specified syscalls | |
414 | trace_match_only openat 0 "$TRACE_PATH" | |
415 | ||
416 | destroy_lttng_session_ok $SESSION_NAME | |
417 | ||
418 | rm -rf "$TRACE_PATH" | |
419 | } | |
420 | ||
8cfcd41c MD |
421 | function test_syscall_enable_all_disable_all_twice() |
422 | { | |
33e55711 | 423 | local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX") |
8cfcd41c MD |
424 | SESSION_NAME="kernel_syscall_enable_all_disable_all_twice" |
425 | ||
031f232e DG |
426 | diag "Syscall trace all events and enable/disable all twice" |
427 | ||
bf6ae429 | 428 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
8cfcd41c MD |
429 | |
430 | # enable all system calls | |
431 | lttng_enable_kernel_syscall_ok $SESSION_NAME | |
432 | # disable all system calls | |
433 | lttng_disable_kernel_syscall_ok $SESSION_NAME | |
434 | # enable all system calls | |
435 | lttng_enable_kernel_syscall_ok $SESSION_NAME | |
436 | # disable all system calls | |
437 | lttng_disable_kernel_syscall_ok $SESSION_NAME | |
438 | ||
c8e51d15 | 439 | trace_testapp |
8cfcd41c MD |
440 | |
441 | # ensure nothing has been traced. | |
442 | validate_trace_empty $TRACE_PATH | |
443 | ||
67b4c664 | 444 | destroy_lttng_session_ok $SESSION_NAME |
8cfcd41c MD |
445 | |
446 | rm -rf $TRACE_PATH | |
447 | } | |
448 | ||
449 | function test_syscall_enable_one_disable_one() | |
450 | { | |
33e55711 | 451 | local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX") |
8cfcd41c MD |
452 | SESSION_NAME="kernel_syscall_enable_one_disable_one" |
453 | ||
031f232e DG |
454 | diag "Syscall trace one event and disable one" |
455 | ||
bf6ae429 | 456 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
8cfcd41c MD |
457 | |
458 | # enable open system call | |
8192bd8f | 459 | lttng_enable_kernel_syscall_ok $SESSION_NAME "openat" |
8cfcd41c | 460 | # disable open system call |
8192bd8f | 461 | lttng_disable_kernel_syscall_ok $SESSION_NAME "openat" |
8cfcd41c | 462 | |
c8e51d15 | 463 | trace_testapp |
8cfcd41c MD |
464 | |
465 | # ensure nothing has been traced. | |
466 | validate_trace_empty $TRACE_PATH | |
467 | ||
67b4c664 | 468 | destroy_lttng_session_ok $SESSION_NAME |
8cfcd41c MD |
469 | |
470 | rm -rf $TRACE_PATH | |
471 | } | |
472 | ||
473 | function test_syscall_enable_two_disable_two() | |
474 | { | |
33e55711 | 475 | local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX") |
8cfcd41c MD |
476 | SESSION_NAME="kernel_syscall_enable_two_disable_two" |
477 | ||
031f232e DG |
478 | diag "Syscall trace two events and disable two" |
479 | ||
bf6ae429 | 480 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
8cfcd41c MD |
481 | |
482 | # enable open and close system calls | |
8192bd8f | 483 | lttng_enable_kernel_syscall_ok $SESSION_NAME "openat" |
8cfcd41c MD |
484 | lttng_enable_kernel_syscall_ok $SESSION_NAME "close" |
485 | # disable open and close system calls | |
8192bd8f | 486 | lttng_disable_kernel_syscall_ok $SESSION_NAME "openat" |
8cfcd41c MD |
487 | lttng_disable_kernel_syscall_ok $SESSION_NAME "close" |
488 | ||
c8e51d15 | 489 | trace_testapp |
8cfcd41c MD |
490 | |
491 | # ensure nothing has been traced. | |
492 | validate_trace_empty $TRACE_PATH | |
493 | ||
67b4c664 | 494 | destroy_lttng_session_ok $SESSION_NAME |
8cfcd41c MD |
495 | |
496 | rm -rf $TRACE_PATH | |
497 | } | |
498 | ||
499 | function test_syscall_enable_two_disable_one() | |
500 | { | |
33e55711 | 501 | local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX") |
8cfcd41c MD |
502 | SESSION_NAME="kernel_syscall_enable_two_disable_one" |
503 | ||
031f232e DG |
504 | diag "Syscall trace two events and disable one" |
505 | ||
bf6ae429 | 506 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
8cfcd41c MD |
507 | |
508 | # enable open and close system calls | |
8192bd8f | 509 | lttng_enable_kernel_syscall_ok $SESSION_NAME "openat" |
8cfcd41c MD |
510 | lttng_enable_kernel_syscall_ok $SESSION_NAME "close" |
511 | # disable close system call | |
512 | lttng_disable_kernel_syscall_ok $SESSION_NAME "close" | |
513 | ||
c8e51d15 | 514 | trace_testapp |
8cfcd41c MD |
515 | |
516 | # ensure open is there. | |
8192bd8f FD |
517 | validate_trace_exp "-e syscall_entry_openat: -e compat_syscall_entry_openat:" $TRACE_PATH |
518 | validate_trace_exp "-e syscall_exit_openat: -e compat_syscall_exit_openat:" $TRACE_PATH | |
8cfcd41c MD |
519 | |
520 | # ensure trace only contains those. | |
8192bd8f | 521 | validate_trace_only_exp "-e syscall_entry_openat: -e compat_syscall_entry_openat: -e syscall_exit_openat: -e compat_syscall_exit_openat:" $TRACE_PATH |
8cfcd41c | 522 | |
67b4c664 | 523 | destroy_lttng_session_ok $SESSION_NAME |
8cfcd41c MD |
524 | |
525 | rm -rf $TRACE_PATH | |
526 | } | |
527 | ||
528 | function test_syscall_disable_twice() | |
529 | { | |
33e55711 | 530 | local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX") |
8cfcd41c MD |
531 | SESSION_NAME="kernel_syscall_disable_twice" |
532 | ||
031f232e DG |
533 | diag "Syscall trace one event and disable twice" |
534 | ||
bf6ae429 | 535 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
8cfcd41c | 536 | |
8192bd8f | 537 | lttng_enable_kernel_syscall_ok $SESSION_NAME "openat" |
8cfcd41c | 538 | # First disable will succeed |
8192bd8f | 539 | lttng_disable_kernel_syscall_ok $SESSION_NAME "openat" |
fac26884 | 540 | # Second disable succeeds too, due to enabler semantic. |
8192bd8f | 541 | lttng_disable_kernel_syscall_ok $SESSION_NAME "openat" |
8cfcd41c | 542 | |
67b4c664 | 543 | destroy_lttng_session_ok $SESSION_NAME |
8cfcd41c MD |
544 | |
545 | rm -rf $TRACE_PATH | |
546 | } | |
547 | ||
548 | function test_syscall_disable_all_twice() | |
549 | { | |
33e55711 | 550 | local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX") |
8cfcd41c MD |
551 | SESSION_NAME="kernel_syscall_disable_all_twice" |
552 | ||
031f232e DG |
553 | diag "Syscall trace all events and disable all twice" |
554 | ||
bf6ae429 | 555 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
8cfcd41c MD |
556 | |
557 | lttng_enable_kernel_syscall_ok $SESSION_NAME | |
558 | # First disable will succeed | |
559 | lttng_disable_kernel_syscall_ok $SESSION_NAME | |
fac26884 MD |
560 | # Second disable succeeds too, due to enabler semantic. |
561 | lttng_disable_kernel_syscall_ok $SESSION_NAME | |
8cfcd41c | 562 | |
67b4c664 | 563 | destroy_lttng_session_ok $SESSION_NAME |
8cfcd41c MD |
564 | |
565 | rm -rf $TRACE_PATH | |
566 | } | |
567 | ||
568 | ||
569 | function test_syscall_enable_unknown() | |
570 | { | |
33e55711 | 571 | local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX") |
8cfcd41c MD |
572 | SESSION_NAME="kernel_syscall_enable_unknown" |
573 | ||
031f232e DG |
574 | diag "Syscall enable an unknown event" |
575 | ||
bf6ae429 | 576 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
8cfcd41c | 577 | |
fac26884 MD |
578 | # Enabling a syscall that does not exist succeeds, due to enabler |
579 | # semantic. | |
580 | lttng_enable_kernel_syscall_ok $SESSION_NAME "thissyscallcannotexist" | |
8cfcd41c | 581 | |
67b4c664 | 582 | destroy_lttng_session_ok $SESSION_NAME |
8cfcd41c MD |
583 | |
584 | rm -rf $TRACE_PATH | |
585 | } | |
586 | ||
587 | function test_syscall_enable_all_enable_one() | |
588 | { | |
33e55711 | 589 | local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX") |
8cfcd41c MD |
590 | SESSION_NAME="kernel_syscall_enable_all_enable_one" |
591 | ||
031f232e DG |
592 | diag "Syscall enable all and enable one" |
593 | ||
bf6ae429 | 594 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
8cfcd41c MD |
595 | |
596 | lttng_enable_kernel_syscall_ok $SESSION_NAME | |
fac26884 | 597 | # Enabling an event already enabled succeeds, due to enabler semantic. |
8192bd8f | 598 | lttng_enable_kernel_syscall_ok $SESSION_NAME "openat" |
8cfcd41c | 599 | |
67b4c664 | 600 | destroy_lttng_session_ok $SESSION_NAME |
8cfcd41c MD |
601 | |
602 | rm -rf $TRACE_PATH | |
603 | } | |
604 | ||
605 | function test_syscall_disable_all_disable_one() | |
606 | { | |
33e55711 | 607 | local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX") |
8cfcd41c MD |
608 | SESSION_NAME="kernel_syscall_enable_all_enable_one" |
609 | ||
031f232e DG |
610 | diag "Syscall disable all and disable one" |
611 | ||
bf6ae429 | 612 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
8cfcd41c MD |
613 | |
614 | lttng_enable_kernel_syscall_ok $SESSION_NAME | |
615 | lttng_disable_kernel_syscall_ok $SESSION_NAME | |
616 | # Disabling an event already disabled fails. | |
8192bd8f | 617 | lttng_disable_kernel_syscall_fail $SESSION_NAME "openat" |
8cfcd41c | 618 | |
67b4c664 | 619 | destroy_lttng_session_ok $SESSION_NAME |
8cfcd41c MD |
620 | |
621 | rm -rf $TRACE_PATH | |
622 | } | |
623 | ||
d96f6315 MD |
624 | function test_syscall_enable_channel_disable_all() |
625 | { | |
33e55711 | 626 | local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX") |
d96f6315 MD |
627 | SESSION_NAME="kernel_syscall_enable_channel_disable_all" |
628 | CHANNEL_NAME="channel" | |
629 | ||
031f232e DG |
630 | diag "Syscall enable channel and disable all" |
631 | ||
bf6ae429 | 632 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
d96f6315 MD |
633 | |
634 | lttng_enable_kernel_channel_ok $SESSION_NAME $CHANNEL_NAME | |
fac26884 MD |
635 | # sessiond semantic for "disable all" is to try to match all enalers |
636 | # it knowns about. Disable all succeeds if it finds no match. | |
637 | lttng_disable_kernel_syscall_ok $SESSION_NAME "-a" $CHANNEL_NAME | |
d96f6315 | 638 | |
67b4c664 | 639 | destroy_lttng_session_ok $SESSION_NAME |
d96f6315 MD |
640 | |
641 | rm -rf $TRACE_PATH | |
642 | } | |
643 | ||
644 | function test_syscall_enable_channel_disable_one() | |
645 | { | |
33e55711 | 646 | local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX") |
d96f6315 MD |
647 | SESSION_NAME="kernel_syscall_enable_channel_disable_all" |
648 | CHANNEL_NAME="channel" | |
649 | ||
031f232e DG |
650 | diag "Syscall enable channel and disable one" |
651 | ||
bf6ae429 | 652 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
d96f6315 MD |
653 | |
654 | lttng_enable_kernel_channel_ok $SESSION_NAME $CHANNEL_NAME | |
8192bd8f | 655 | lttng_disable_kernel_syscall_fail $SESSION_NAME "openat" $CHANNEL_NAME |
d96f6315 | 656 | |
67b4c664 | 657 | destroy_lttng_session_ok $SESSION_NAME |
d96f6315 MD |
658 | |
659 | rm -rf $TRACE_PATH | |
660 | } | |
661 | ||
8cfcd41c MD |
662 | # MUST set TESTDIR before calling those functions |
663 | plan_tests $NUM_TESTS | |
664 | ||
665 | print_test_banner "$TEST_DESC" | |
666 | ||
667 | if [ "$(id -u)" == "0" ]; then | |
668 | isroot=1 | |
669 | else | |
670 | isroot=0 | |
671 | fi | |
672 | ||
673 | skip $isroot "Root access is needed. Skipping all tests." $NUM_TESTS || | |
674 | { | |
675 | start_lttng_sessiond | |
676 | ||
02db71ba DG |
677 | test_syscall_event_list |
678 | test_syscall_simple_list | |
679 | test_syscall_simple_list_two | |
8cfcd41c MD |
680 | test_syscall_single |
681 | test_syscall_two | |
682 | test_syscall_all | |
683 | test_syscall_all_disable_one | |
684 | test_syscall_all_disable_two | |
685 | test_syscall_enable_all_disable_all | |
686 | test_syscall_enable_all_disable_all_enable_all | |
687 | test_syscall_enable_all_disable_all_twice | |
0ee507ec MJ |
688 | test_syscall_enable_all_enable_one_disable_all |
689 | test_syscall_enable_one_enable_all_disable_one | |
690 | test_syscall_enable_one_enable_all_disable_all_disable_one | |
8cfcd41c MD |
691 | test_syscall_enable_one_disable_one |
692 | test_syscall_enable_two_disable_two | |
693 | test_syscall_enable_two_disable_one | |
694 | test_syscall_disable_twice | |
695 | test_syscall_disable_all_twice | |
696 | test_syscall_enable_unknown | |
697 | test_syscall_enable_all_enable_one | |
698 | test_syscall_disable_all_disable_one | |
d96f6315 MD |
699 | test_syscall_enable_channel_disable_all |
700 | test_syscall_enable_channel_disable_one | |
8cfcd41c MD |
701 | |
702 | stop_lttng_sessiond | |
703 | } |