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