3 # Copyright (C) 2017 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
5 # SPDX-License-Identifier: LGPL-2.1-only
7 CURDIR
=$
(dirname "$0")/
8 TESTDIR
=$CURDIR/..
/..
/..
/
12 #This is needed since the testpoint create a pipe with the consumerd type suffixed
13 TESTPOINT_BASE_PATH
=$
(readlink
-f "$TMPDIR/lttng.t_p_n")
14 TESTPOINT_PIPE_PATH
=$
(mktemp
-u "${TESTPOINT_BASE_PATH}.XXXXXX")
15 TESTPOINT
=$
(readlink
-f "${CURDIR}/.libs/libpause_consumer.so")
16 TESTAPP_STATE_PATH
=$
(mktemp
-u "$TMPDIR/application_state.XXXXXXXXXX")
19 SESSION_NAME
="my_session"
20 CHANNEL_NAME
="my_channel"
24 # shellcheck source=../../../utils/utils.sh
25 source "$TESTDIR/utils/utils.sh"
27 function kernel_event_generator_toggle_state
29 kernel_event_generator_suspended
=$
((kernel_event_generator_suspended
==0))
32 function generate_filter_events
34 /bin
/echo -n "10" > /proc
/lttng-test-filter-event
2> /dev
/null
37 function kernel_event_generator
41 kernel_event_generator_suspended
=0
42 trap kernel_event_generator_toggle_state SIGUSR1
45 if [[ $kernel_event_generator_suspended -eq "1" ]]; then
49 if [[ -f $state_file ]]; then
50 rm $state_file 2> /dev
/null
57 function test_buffer_usage_notification
59 local event_name
="lttng_test_filter_event"
62 local consumerd_pipe
=()
64 trace_path
=$
(mktemp
-d)
65 page_size
=$
(getconf PAGE_SIZE
)
67 create_lttng_session_notap
$SESSION_NAME "$trace_path"
69 lttng_enable_kernel_channel_notap
$SESSION_NAME $CHANNEL_NAME \
70 --subbuf-size="$page_size"
71 enable_kernel_lttng_event_notap
$SESSION_NAME $event_name $CHANNEL_NAME
73 kernel_event_generator generate_filter_events
"$TESTAPP_STATE_PATH" &
76 # This is needed since the testpoint create a pipe with the consumer
78 for f
in "$TESTPOINT_BASE_PATH"*; do
79 consumerd_pipe
+=("$f")
82 "$CURDIR/notification" 2 LTTNG_DOMAIN_KERNEL
$SESSION_NAME $CHANNEL_NAME \
83 $APP_PID $TESTAPP_STATE_PATH ${consumerd_pipe[@]}
85 destroy_lttng_session_notap
$SESSION_NAME
88 wait $APP_PID 2> /dev
/null
91 if [ "$(id -u)" == "0" ]; then
93 validate_lttng_modules_present
98 # Used on sessiond launch.
99 LTTNG_SESSIOND_ENV_VARS
="LTTNG_TESTPOINT_ENABLE=1 \
100 CONSUMER_PAUSE_PIPE_PATH=${TESTPOINT_PIPE_PATH} \
101 LD_PRELOAD=${TESTPOINT}"
102 start_lttng_sessiond_notap
104 test_buffer_usage_notification
106 stop_lttng_sessiond_notap
109 rm -rf "${consumerd_pipe[@]}" 2> /dev
/null
111 # Kernel tests are skipped.
112 plan_tests
$NUM_TESTS
113 skip
0 "Root access is needed. Skipping all kernel notification tests." $NUM_TESTS