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