3 # Copyright (C) - 2017 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
5 # This library is free software; you can redistribute it and/or modify it under
6 # the terms of the GNU Lesser General Public License as published by the Free
7 # Software Foundation; version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful, but WITHOUT
10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14 # You should have received a copy of the GNU Lesser General Public License
15 # along with this library; if not, write to the Free Software Foundation, Inc.,
16 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 TESTDIR
=$CURDIR/..
/..
/..
/
21 #This is needed since the testpoint create a pipe with the consumerd type suffixed
22 TESTPOINT_BASE_PATH
=$
(readlink
-f "$CURDIR/lttng.t_p_n")
23 TESTPOINT_PIPE_PATH
=$
(mktemp
-u "${TESTPOINT_BASE_PATH}.XXXXXX")
24 TESTPOIT_ARGS
="CONSUMER_PAUSE_PIPE_PATH=${TESTPOINT_PIPE_PATH} LTTNG_TESTPOINT_ENABLE=1"
25 TESTPOINT
=$
(readlink
-f ${CURDIR}/.libs
/libpause_consumer.so
)
28 TESTAPP_PATH
="$TESTDIR/utils/testapp"
29 TESTAPP_NAME
="gen-ust-events"
30 TESTAPP_BIN
="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
31 TESTAPP_STATE_PATH
=$
(mktemp
-u "$CURDIR/application_state.XXXXXXXXXX")
36 SESSION_NAME
="my_session"
37 CHANNEL_NAME
="my_channel"
39 TRACE_PATH
=$
(mktemp
-d)
40 PAGE_SIZE
=$
(getconf PAGE_SIZE
)
42 DIR
=$
(readlink
-f $TESTDIR)
45 source $TESTDIR/utils
/utils.sh
47 function kernel_event_generator_toogle_state
49 kernel_event_generator_suspended
=$
((kernel_event_generator_suspended
==0))
52 function kernel_event_generator
55 kernel_event_generator_suspended
=0
56 trap kernel_event_generator_toogle_state SIGUSR1
57 trap "exit" SIGTERM SIGINT EXIT
59 if [[ $kernel_event_generator_suspended -eq "1" ]]; then
63 if [[ -f $state_file ]]; then
64 rm $state_file 2> /dev
/null
66 echo -n "1000" > /proc
/lttng-test-filter-event
2> /dev
/null
73 local consumerd_pipe
=()
74 local event_name
="lttng_test_filter_event"
78 LTTNG_SESSIOND_ENV_VARS
="LTTNG_TESTPOINT_ENABLE=1 CONSUMER_PAUSE_PIPE_PATH=${TESTPOINT_PIPE_PATH} LD_PRELOAD=${TESTPOINT}"
79 start_lttng_sessiond_notap
81 create_lttng_session_notap
$SESSION_NAME $TRACE_PATH
83 lttng_enable_kernel_channel_notap
$SESSION_NAME $CHANNEL_NAME --subbuf-size=$PAGE_SIZE
84 enable_kernel_lttng_event_notap
$SESSION_NAME $event_name $CHANNEL_NAME
86 #This is needed since the testpoint create a pipe with the consumer type suffixed
87 for f
in "$TESTPOINT_BASE_PATH"*; do
88 consumerd_pipe
+=("$f")
91 kernel_event_generator
$TESTAPP_STATE_PATH &
94 $CURDIR/notification LTTNG_DOMAIN_KERNEL
$SESSION_NAME $CHANNEL_NAME $APP_PID $TESTAPP_STATE_PATH ${consumerd_pipe[@]}
96 destroy_lttng_session_notap
$SESSION_NAME
97 stop_lttng_sessiond_notap
100 wait $APP_PID 2> /dev
/null
105 rm ${consumerd_pipe[@]} 2> /dev
/null
108 if [ "$(id -u)" == "0" ]; then
111 # Kernel tests are skipped.
112 plan_tests
$NUM_TESTS
113 skip
0 "Root access is needed. Skipping all kernel notification tests." $NUM_TESTS
116 # Just in case cleanup