Commit | Line | Data |
---|---|---|
069fc1c5 FD |
1 | #!/bin/bash |
2 | # | |
3 | # Copyright (C) 2017 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com> | |
4 | # | |
5 | # SPDX-License-Identifier: LGPL-2.1-only | |
6 | ||
7 | CURDIR=$(dirname "$0")/ | |
8 | TESTDIR=$CURDIR/../../../ | |
9 | ||
8d5a3312 MJ |
10 | TEST_TMPDIR=$(mktemp -d -t tmp.test_notif_ust_buffer_usage_dir.XXXXXX) |
11 | ||
12 | # Set TMPDIR for further call to mktemp | |
13 | export TMPDIR="$TEST_TMPDIR" | |
069fc1c5 | 14 | |
33e55711 | 15 | set -x |
069fc1c5 | 16 | #This is needed since the testpoint create a pipe with the consumerd type suffixed |
33e55711 | 17 | TESTPOINT_BASE_PATH=$(readlink -f "$TEST_TMPDIR/lttng.t_p_n") |
8d5a3312 | 18 | TESTPOINT_PIPE_PATH=$(mktemp -u -t "lttng.t_p_n.XXXXXX") |
069fc1c5 FD |
19 | TESTPOINT=$(readlink -f "${CURDIR}/.libs/libpause_consumer.so") |
20 | ||
21 | TESTAPP_PATH="$TESTDIR/utils/testapp" | |
22 | ||
23 | GEN_UST_EVENTS_TESTAPP_NAME="gen-ust-events" | |
24 | GEN_UST_EVENTS_TESTAPP_BIN="$TESTAPP_PATH/$GEN_UST_EVENTS_TESTAPP_NAME/$GEN_UST_EVENTS_TESTAPP_NAME" | |
25 | ||
8d5a3312 | 26 | TESTAPP_STATE_PATH=$(mktemp -u -t "application_state.XXXXXXXXXX") |
069fc1c5 FD |
27 | |
28 | SESSION_NAME="my_session" | |
29 | CHANNEL_NAME="my_channel" | |
30 | ||
8d5a3312 | 31 | TRACE_PATH=$(mktemp -d -t "trace_path.XXXXXX") |
069fc1c5 | 32 | PAGE_SIZE=$(getconf PAGE_SIZE) |
33e55711 | 33 | set +x |
069fc1c5 FD |
34 | |
35 | # shellcheck source=../../../utils/utils.sh | |
36 | source "$TESTDIR/utils/utils.sh" | |
25cb2044 JR |
37 | # shellcheck source=./util_event_generator.sh |
38 | source "$CURDIR/util_event_generator.sh" | |
069fc1c5 FD |
39 | |
40 | function test_buffer_usage_notification | |
41 | { | |
42 | consumerd_pipe=() | |
43 | event_name="tp:tptest" | |
44 | ||
45 | create_lttng_session_notap $SESSION_NAME "$TRACE_PATH" | |
46 | ||
47 | enable_ust_lttng_channel_notap $SESSION_NAME $CHANNEL_NAME --subbuf-size="$PAGE_SIZE" | |
48 | enable_ust_lttng_event_notap $SESSION_NAME $event_name $CHANNEL_NAME | |
49 | ||
50 | # This is needed since the testpoint create a pipe with the consumer type suffixed | |
51 | for f in "$TESTPOINT_BASE_PATH"*; do | |
52 | consumerd_pipe+=("$f") | |
53 | done | |
54 | ||
25cb2044 | 55 | ust_event_generator "$GEN_UST_EVENTS_TESTAPP_BIN" "$TESTAPP_STATE_PATH" & |
069fc1c5 FD |
56 | APP_PID=$! |
57 | ||
a740a242 FD |
58 | "$CURDIR/notification" 2 LTTNG_DOMAIN_UST $APP_PID "$TESTAPP_STATE_PATH" \ |
59 | $SESSION_NAME $CHANNEL_NAME "${consumerd_pipe[@]}" | |
069fc1c5 FD |
60 | |
61 | destroy_lttng_session_notap $SESSION_NAME | |
62 | ||
63 | # On ungraceful kill the app is cleaned up via the full_cleanup call | |
64 | # Suppress kill message | |
25cb2044 | 65 | kill -SIGUSR2 $APP_PID |
069fc1c5 FD |
66 | wait $APP_PID 2> /dev/null |
67 | ||
68 | # Just in case cleanup | |
69 | rm -rf "$TRACE_PATH" | |
70 | } | |
71 | ||
72 | LTTNG_SESSIOND_ENV_VARS="LTTNG_TESTPOINT_ENABLE=1 CONSUMER_PAUSE_PIPE_PATH=${TESTPOINT_PIPE_PATH} LD_PRELOAD=${TESTPOINT}" | |
73 | start_lttng_sessiond_notap | |
74 | ||
75 | test_buffer_usage_notification | |
76 | ||
77 | stop_lttng_sessiond_notap | |
78 | ||
33e55711 | 79 | rm -rf "$TEST_TMPDIR" |