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