b193dfb888f441b48f3a92736eb1684e3ef385a4
[lttng-tools.git] / tests / regression / kernel / test_syscall
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 # SPDX-License-Identifier: GPL-2.0-only
7 #
8
9 TEST_DESC="Kernel tracer - System calls"
10
11 CURDIR=$(dirname $0)/
12 TESTDIR=$CURDIR/../..
13 NUM_TESTS=214
14
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"
18
19 source $TESTDIR/utils/utils.sh
20
21 function trace_testapp()
22 {
23 local start_file_sync=$(mktemp --tmpdir -u -t "tmp.${FUNCNAME[0]}_sync_start.XXXXXX")
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
29 ./"$TESTCMD" "$start_file_sync" "/proc/cpuinfo" "/proc/cmdline" &
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
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 {
75 local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
76 SESSION_NAME="kernel_syscall_simple_list"
77 local EVENT_NAME="close"
78
79 diag "Syscall simple listing"
80
81 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
82
83 lttng_enable_kernel_syscall_ok $SESSION_NAME $EVENT_NAME
84
85 validate_list $SESSION_NAME $EVENT_NAME
86
87 trace_testapp
88
89 # ensure all events are in the trace.
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
96 destroy_lttng_session_ok $SESSION_NAME
97
98 rm -rf $TRACE_PATH
99 }
100
101 function test_syscall_simple_list_two()
102 {
103 local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
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
110 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
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
118 trace_testapp
119
120 # ensure all events are in the trace.
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
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
130 destroy_lttng_session_ok $SESSION_NAME
131
132 rm -rf $TRACE_PATH
133 }
134
135 function test_syscall_single()
136 {
137 local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
138 SESSION_NAME="kernel_syscall_single"
139
140 diag "Syscall trace single"
141
142 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
143
144 lttng_enable_kernel_syscall_ok $SESSION_NAME "openat"
145
146 trace_testapp
147
148 # ensure all events are in the trace.
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
151
152 # ensure trace only contains those.
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
154
155 destroy_lttng_session_ok $SESSION_NAME
156
157 rm -rf $TRACE_PATH
158 }
159
160 function test_syscall_two()
161 {
162 local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
163 SESSION_NAME="kernel_syscall_two"
164
165 diag "Syscall trace two events"
166
167 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
168
169 lttng_enable_kernel_syscall_ok $SESSION_NAME "openat"
170 lttng_enable_kernel_syscall_ok $SESSION_NAME "close"
171
172 trace_testapp
173
174 # ensure all events are in the trace.
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
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
179
180 # ensure trace only contains those.
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
182
183 destroy_lttng_session_ok $SESSION_NAME
184
185 rm -rf $TRACE_PATH
186 }
187
188 function test_syscall_all()
189 {
190 local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
191 SESSION_NAME="kernel_syscall_all"
192
193 diag "Syscall trace all events"
194
195 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
196
197 # enable all syscalls
198 lttng_enable_kernel_syscall_ok $SESSION_NAME
199
200 trace_testapp
201
202 # ensure at least open and close are there.
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
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
207 # trace may contain other syscalls.
208
209 destroy_lttng_session_ok $SESSION_NAME
210
211 rm -rf $TRACE_PATH
212 }
213
214 function test_syscall_all_disable_one()
215 {
216 local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
217 SESSION_NAME="kernel_syscall_all_disable_one"
218
219 diag "Syscall trace all events and disable one"
220
221 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
222
223 # enable all syscalls
224 lttng_enable_kernel_syscall_ok $SESSION_NAME
225 # try to disable open system call: fails because enabler semantic of
226 # "all syscalls" is not "the open" system call.
227 lttng_disable_kernel_syscall_fail $SESSION_NAME "openat"
228
229 trace_testapp
230
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
233
234 # ensure "close" syscall is there.
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
237
238 destroy_lttng_session_ok $SESSION_NAME
239
240 rm -rf $TRACE_PATH
241 }
242
243 function test_syscall_all_disable_two()
244 {
245 local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
246 SESSION_NAME="kernel_syscall_all_disable_two"
247
248 diag "Syscall trace all events and disable two"
249
250 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
251
252 # enable all syscalls
253 lttng_enable_kernel_syscall_ok $SESSION_NAME
254 # try to disable open and close system calls: fails because enabler
255 # semantic of "all syscalls" is not "the open" system call.
256 lttng_disable_kernel_syscall_fail $SESSION_NAME "openat"
257 lttng_disable_kernel_syscall_fail $SESSION_NAME "close"
258
259 trace_testapp
260
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
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
267
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
271
272 destroy_lttng_session_ok $SESSION_NAME
273
274 rm -rf $TRACE_PATH
275 }
276
277 function test_syscall_enable_all_disable_all()
278 {
279 local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
280 SESSION_NAME="kernel_syscall_enable_all_disable_all"
281
282 diag "Syscall trace all events and disable all"
283
284 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
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
291 trace_testapp
292
293 # ensure nothing has been traced.
294 validate_trace_empty $TRACE_PATH
295
296 destroy_lttng_session_ok $SESSION_NAME
297
298 rm -rf $TRACE_PATH
299 }
300
301 function test_syscall_enable_all_disable_all_enable_all()
302 {
303 local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
304 SESSION_NAME="kernel_syscall_enable_all_disable_all_enable_all"
305
306 diag "Syscall trace all events and enable/disable all"
307
308 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
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
317 trace_testapp
318
319 # ensure at least open and close are there.
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
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
324 # trace may contain other syscalls.
325
326 destroy_lttng_session_ok $SESSION_NAME
327
328 rm -rf $TRACE_PATH
329 }
330
331 function test_syscall_enable_all_enable_one_disable_all()
332 {
333 local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
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 {
362 local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
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 {
391 local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
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
421 function test_syscall_enable_all_disable_all_twice()
422 {
423 local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
424 SESSION_NAME="kernel_syscall_enable_all_disable_all_twice"
425
426 diag "Syscall trace all events and enable/disable all twice"
427
428 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
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
439 trace_testapp
440
441 # ensure nothing has been traced.
442 validate_trace_empty $TRACE_PATH
443
444 destroy_lttng_session_ok $SESSION_NAME
445
446 rm -rf $TRACE_PATH
447 }
448
449 function test_syscall_enable_one_disable_one()
450 {
451 local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
452 SESSION_NAME="kernel_syscall_enable_one_disable_one"
453
454 diag "Syscall trace one event and disable one"
455
456 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
457
458 # enable open system call
459 lttng_enable_kernel_syscall_ok $SESSION_NAME "openat"
460 # disable open system call
461 lttng_disable_kernel_syscall_ok $SESSION_NAME "openat"
462
463 trace_testapp
464
465 # ensure nothing has been traced.
466 validate_trace_empty $TRACE_PATH
467
468 destroy_lttng_session_ok $SESSION_NAME
469
470 rm -rf $TRACE_PATH
471 }
472
473 function test_syscall_enable_two_disable_two()
474 {
475 local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
476 SESSION_NAME="kernel_syscall_enable_two_disable_two"
477
478 diag "Syscall trace two events and disable two"
479
480 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
481
482 # enable open and close system calls
483 lttng_enable_kernel_syscall_ok $SESSION_NAME "openat"
484 lttng_enable_kernel_syscall_ok $SESSION_NAME "close"
485 # disable open and close system calls
486 lttng_disable_kernel_syscall_ok $SESSION_NAME "openat"
487 lttng_disable_kernel_syscall_ok $SESSION_NAME "close"
488
489 trace_testapp
490
491 # ensure nothing has been traced.
492 validate_trace_empty $TRACE_PATH
493
494 destroy_lttng_session_ok $SESSION_NAME
495
496 rm -rf $TRACE_PATH
497 }
498
499 function test_syscall_enable_two_disable_one()
500 {
501 local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
502 SESSION_NAME="kernel_syscall_enable_two_disable_one"
503
504 diag "Syscall trace two events and disable one"
505
506 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
507
508 # enable open and close system calls
509 lttng_enable_kernel_syscall_ok $SESSION_NAME "openat"
510 lttng_enable_kernel_syscall_ok $SESSION_NAME "close"
511 # disable close system call
512 lttng_disable_kernel_syscall_ok $SESSION_NAME "close"
513
514 trace_testapp
515
516 # ensure open is there.
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
519
520 # ensure trace only contains those.
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
522
523 destroy_lttng_session_ok $SESSION_NAME
524
525 rm -rf $TRACE_PATH
526 }
527
528 function test_syscall_disable_twice()
529 {
530 local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
531 SESSION_NAME="kernel_syscall_disable_twice"
532
533 diag "Syscall trace one event and disable twice"
534
535 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
536
537 lttng_enable_kernel_syscall_ok $SESSION_NAME "openat"
538 # First disable will succeed
539 lttng_disable_kernel_syscall_ok $SESSION_NAME "openat"
540 # Second disable succeeds too, due to enabler semantic.
541 lttng_disable_kernel_syscall_ok $SESSION_NAME "openat"
542
543 destroy_lttng_session_ok $SESSION_NAME
544
545 rm -rf $TRACE_PATH
546 }
547
548 function test_syscall_disable_all_twice()
549 {
550 local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
551 SESSION_NAME="kernel_syscall_disable_all_twice"
552
553 diag "Syscall trace all events and disable all twice"
554
555 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
556
557 lttng_enable_kernel_syscall_ok $SESSION_NAME
558 # First disable will succeed
559 lttng_disable_kernel_syscall_ok $SESSION_NAME
560 # Second disable succeeds too, due to enabler semantic.
561 lttng_disable_kernel_syscall_ok $SESSION_NAME
562
563 destroy_lttng_session_ok $SESSION_NAME
564
565 rm -rf $TRACE_PATH
566 }
567
568
569 function test_syscall_enable_unknown()
570 {
571 local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
572 SESSION_NAME="kernel_syscall_enable_unknown"
573
574 diag "Syscall enable an unknown event"
575
576 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
577
578 # Enabling a syscall that does not exist succeeds, due to enabler
579 # semantic.
580 lttng_enable_kernel_syscall_ok $SESSION_NAME "thissyscallcannotexist"
581
582 destroy_lttng_session_ok $SESSION_NAME
583
584 rm -rf $TRACE_PATH
585 }
586
587 function test_syscall_enable_all_enable_one()
588 {
589 local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
590 SESSION_NAME="kernel_syscall_enable_all_enable_one"
591
592 diag "Syscall enable all and enable one"
593
594 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
595
596 lttng_enable_kernel_syscall_ok $SESSION_NAME
597 # Enabling an event already enabled succeeds, due to enabler semantic.
598 lttng_enable_kernel_syscall_ok $SESSION_NAME "openat"
599
600 destroy_lttng_session_ok $SESSION_NAME
601
602 rm -rf $TRACE_PATH
603 }
604
605 function test_syscall_disable_all_disable_one()
606 {
607 local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
608 SESSION_NAME="kernel_syscall_enable_all_enable_one"
609
610 diag "Syscall disable all and disable one"
611
612 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
613
614 lttng_enable_kernel_syscall_ok $SESSION_NAME
615 lttng_disable_kernel_syscall_ok $SESSION_NAME
616 # Disabling an event already disabled fails.
617 lttng_disable_kernel_syscall_fail $SESSION_NAME "openat"
618
619 destroy_lttng_session_ok $SESSION_NAME
620
621 rm -rf $TRACE_PATH
622 }
623
624 function test_syscall_enable_channel_disable_all()
625 {
626 local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
627 SESSION_NAME="kernel_syscall_enable_channel_disable_all"
628 CHANNEL_NAME="channel"
629
630 diag "Syscall enable channel and disable all"
631
632 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
633
634 lttng_enable_kernel_channel_ok $SESSION_NAME $CHANNEL_NAME
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
638
639 destroy_lttng_session_ok $SESSION_NAME
640
641 rm -rf $TRACE_PATH
642 }
643
644 function test_syscall_enable_channel_disable_one()
645 {
646 local TRACE_PATH=$(mktemp --tmpdir -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
647 SESSION_NAME="kernel_syscall_enable_channel_disable_all"
648 CHANNEL_NAME="channel"
649
650 diag "Syscall enable channel and disable one"
651
652 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
653
654 lttng_enable_kernel_channel_ok $SESSION_NAME $CHANNEL_NAME
655 lttng_disable_kernel_syscall_fail $SESSION_NAME "openat" $CHANNEL_NAME
656
657 destroy_lttng_session_ok $SESSION_NAME
658
659 rm -rf $TRACE_PATH
660 }
661
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
677 test_syscall_event_list
678 test_syscall_simple_list
679 test_syscall_simple_list_two
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
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
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
699 test_syscall_enable_channel_disable_all
700 test_syscall_enable_channel_disable_one
701
702 stop_lttng_sessiond
703 }
This page took 0.045969 seconds and 4 git commands to generate.