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