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