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