Fix: create lttng run dir regardless of user privilege
[lttng-tools.git] / tests / regression / tools / notification / test_notification
1 #!/bin/bash
2 #
3 # Copyright (C) - 2017 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
4 #
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.
8 #
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
12 # details.
13 #
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
17
18 CURDIR=$(dirname $0)/
19 TESTDIR=$CURDIR/../../../
20
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)
26
27 TESTAPP_PATH="$TESTDIR/utils/testapp"
28 TESTAPP_NAME="gen-ust-events"
29 TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
30
31 NR_ITER=-1
32 NR_USEC_WAIT=5
33
34 SESSION_NAME="my_session"
35 CHANNEL_NAME="my_ust_channel"
36 EVENT_NAME="tp:tptest"
37
38 TRACE_PATH=$(mktemp -d)
39 PAGE_SIZE=$(getconf PAGE_SIZE)
40
41 DIR=$(readlink -f $TESTDIR)
42
43 source $TESTDIR/utils/utils.sh
44
45 consumerd_pipe=()
46
47 file_sync_after_first_event=$(mktemp -u)
48
49 LTTNG_SESSIOND_ENV_VARS="LTTNG_TESTPOINT_ENABLE=1 CONSUMER_PAUSE_PIPE_PATH=${TESTPOINT_PIPE_PATH} LD_PRELOAD=${TESTPOINT}"
50 start_lttng_sessiond_notap
51
52 create_lttng_session_notap $SESSION_NAME $TRACE_PATH
53
54 enable_ust_lttng_channel_notap $SESSION_NAME $CHANNEL_NAME --subbuf-size=$PAGE_SIZE
55 enable_ust_lttng_event_notap $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
56
57 #This is needed since the testpoint create a pipe with the consumer type suffixed
58 for f in "$TESTPOINT_BASE_PATH"*; do
59 consumerd_pipe+=("$f")
60 done
61
62
63 # Start app in infinite loop
64 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT $file_sync_after_first_event &
65 APP_PID=$!
66 # Pin to CPU zero to force specific sub buffer usage
67 taskset -p -c 0 $APP_PID > /dev/null 2>&1
68
69 while [ ! -f "${file_sync_after_first_event}" ]; do
70 sleep 0.5
71 done
72 rm ${file_sync_after_first_event}
73
74 # The actual test suite
75 # TODO: Add support for kernel domain
76 $CURDIR/notification $SESSION_NAME $CHANNEL_NAME LTTNG_DOMAIN_UST ${consumerd_pipe[@]}
77
78 stop_lttng_sessiond_notap
79
80 # On ungraceful kill the app is cleaned up via the full_cleanup call
81 # Suppress kill message
82 kill -9 $APP_PID
83 wait $APP_PID 2> /dev/null
84
85 # Just in case cleanup
86 rm -rf $TRACE_PATH
87 rm ${consumerd_pipe[@]} 2> /dev/null
This page took 0.031392 seconds and 4 git commands to generate.