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