Typo: 'toogle' -> 'toggle'
[lttng-tools.git] / tests / regression / tools / notification / test_notification_ust
1 #!/bin/bash
2 #
3 # Copyright (C) 2017 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
4 #
5 # SPDX-License-Identifier: LGPL-2.1-only
6
7 CURDIR=$(dirname $0)/
8 TESTDIR=$CURDIR/../../../
9
10 TMPDIR=$(mktemp -d)
11
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 TESTPOIT_ARGS="CONSUMER_PAUSE_PIPE_PATH=${TESTPOINT_PIPE_PATH} LTTNG_TESTPOINT_ENABLE=1"
16 TESTPOINT=$(readlink -f ${CURDIR}/.libs/libpause_consumer.so)
17
18
19 TESTAPP_PATH="$TESTDIR/utils/testapp"
20 TESTAPP_NAME="gen-ust-events"
21 TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
22 TESTAPP_STATE_PATH=$(mktemp -u "$TMPDIR/application_state.XXXXXXXXXX")
23
24 NR_ITER=1000
25 NR_USEC_WAIT=5
26
27 SESSION_NAME="my_session"
28 CHANNEL_NAME="my_channel"
29
30 TRACE_PATH=$(mktemp -d)
31 PAGE_SIZE=$(getconf PAGE_SIZE)
32
33 DIR=$(readlink -f $TESTDIR)
34
35
36 source $TESTDIR/utils/utils.sh
37
38 function ust_event_generator_toggle_state
39 {
40 ust_event_generator_suspended=$((ust_event_generator_suspended==0))
41
42 }
43 function ust_event_generator
44 {
45 state_file=$1
46 ust_event_generator_suspended=0
47 trap ust_event_generator_toggle_state SIGUSR1
48
49 while (true); do
50 if [[ $ust_event_generator_suspended -eq "1" ]]; then
51 touch $state_file
52 sleep 0.5
53 else
54 if [[ -f $state_file ]]; then
55 rm -rf $state_file 2> /dev/null
56 fi
57 taskset -c 0 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT > /dev/null 2>&1
58 fi
59 done
60 }
61
62 consumerd_pipe=()
63 file_sync_after_first_event=$(mktemp -u)
64 event_name="tp:tptest"
65
66 LTTNG_SESSIOND_ENV_VARS="LTTNG_TESTPOINT_ENABLE=1 CONSUMER_PAUSE_PIPE_PATH=${TESTPOINT_PIPE_PATH} LD_PRELOAD=${TESTPOINT}"
67 start_lttng_sessiond_notap
68
69 create_lttng_session_notap $SESSION_NAME $TRACE_PATH
70
71 enable_ust_lttng_channel_notap $SESSION_NAME $CHANNEL_NAME --subbuf-size=$PAGE_SIZE
72 enable_ust_lttng_event_notap $SESSION_NAME $event_name $CHANNEL_NAME
73
74 #This is needed since the testpoint create a pipe with the consumer type suffixed
75 for f in "$TESTPOINT_BASE_PATH"*; do
76 consumerd_pipe+=("$f")
77 done
78
79
80 ust_event_generator $TESTAPP_STATE_PATH &
81 APP_PID=$!
82
83 $CURDIR/notification LTTNG_DOMAIN_UST $SESSION_NAME $CHANNEL_NAME $APP_PID $TESTAPP_STATE_PATH ${consumerd_pipe[@]}
84
85 destroy_lttng_session_notap $SESSION_NAME
86 stop_lttng_sessiond_notap
87
88 # On ungraceful kill the app is cleaned up via the full_cleanup call
89 # Suppress kill message
90 kill -9 $APP_PID
91 wait $APP_PID 2> /dev/null
92
93 rm -rf $TMPDIR
94
95 # Just in case cleanup
96 rm -rf $TRACE_PATH
This page took 0.056307 seconds and 5 git commands to generate.