Commit | Line | Data |
---|---|---|
854382b8 JR |
1 | #!/bin/bash |
2 | # | |
4942c256 | 3 | # Copyright (C) 2017 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com> |
854382b8 | 4 | # |
9d16b343 | 5 | # SPDX-License-Identifier: LGPL-2.1-only |
854382b8 | 6 | |
069fc1c5 | 7 | CURDIR=$(dirname "$0")/ |
854382b8 JR |
8 | TESTDIR=$CURDIR/../../../ |
9 | ||
8d5a3312 MJ |
10 | TEST_TMPDIR=$(mktemp -d -t tmp.test_notif_kernel_buffer_usage_dir.XXXXXX) |
11 | ||
12 | # Set TMPDIR for further call to mktemp | |
13 | export TMPDIR="$TEST_TMPDIR" | |
345ed219 | 14 | |
854382b8 | 15 | #This is needed since the testpoint create a pipe with the consumerd type suffixed |
33e55711 | 16 | TESTPOINT_BASE_PATH=$(readlink -f "$TEST_TMPDIR/lttng.t_p_n") |
8d5a3312 | 17 | TESTPOINT_PIPE_PATH=$(mktemp -u -t "lttng.t_p_n.XXXXXX") |
069fc1c5 | 18 | TESTPOINT=$(readlink -f "${CURDIR}/.libs/libpause_consumer.so") |
8d5a3312 | 19 | TESTAPP_STATE_PATH=$(mktemp -u -t "application_state.XXXXXXXXXX") |
854382b8 | 20 | |
854382b8 JR |
21 | |
22 | SESSION_NAME="my_session" | |
23 | CHANNEL_NAME="my_channel" | |
24 | ||
0e8f2e45 | 25 | NUM_TESTS=99 |
854382b8 | 26 | |
069fc1c5 FD |
27 | # shellcheck source=../../../utils/utils.sh |
28 | source "$TESTDIR/utils/utils.sh" | |
25cb2044 JR |
29 | # shellcheck source=./util_event_generator.sh |
30 | source "$CURDIR/util_event_generator.sh" | |
854382b8 | 31 | |
069fc1c5 | 32 | function test_buffer_usage_notification |
854382b8 | 33 | { |
854382b8 | 34 | local event_name="lttng_test_filter_event" |
069fc1c5 FD |
35 | local trace_path |
36 | local page_size | |
37 | local consumerd_pipe=() | |
854382b8 | 38 | |
8d5a3312 | 39 | trace_path=$(mktemp -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXXX") |
069fc1c5 | 40 | page_size=$(getconf PAGE_SIZE) |
854382b8 | 41 | |
069fc1c5 | 42 | create_lttng_session_notap $SESSION_NAME "$trace_path" |
854382b8 | 43 | |
069fc1c5 FD |
44 | lttng_enable_kernel_channel_notap $SESSION_NAME $CHANNEL_NAME \ |
45 | --subbuf-size="$page_size" | |
854382b8 JR |
46 | enable_kernel_lttng_event_notap $SESSION_NAME $event_name $CHANNEL_NAME |
47 | ||
069fc1c5 FD |
48 | kernel_event_generator generate_filter_events "$TESTAPP_STATE_PATH" & |
49 | APP_PID=$! | |
50 | ||
51 | # This is needed since the testpoint create a pipe with the consumer | |
52 | # type suffixed. | |
854382b8 JR |
53 | for f in "$TESTPOINT_BASE_PATH"*; do |
54 | consumerd_pipe+=("$f") | |
55 | done | |
56 | ||
a740a242 FD |
57 | "$CURDIR/notification" 2 LTTNG_DOMAIN_KERNEL $APP_PID "$TESTAPP_STATE_PATH" \ |
58 | $SESSION_NAME $CHANNEL_NAME "${consumerd_pipe[@]}" | |
854382b8 JR |
59 | |
60 | destroy_lttng_session_notap $SESSION_NAME | |
854382b8 | 61 | |
25cb2044 | 62 | kill -SIGUSR2 $APP_PID |
854382b8 | 63 | wait $APP_PID 2> /dev/null |
854382b8 JR |
64 | } |
65 | ||
66 | if [ "$(id -u)" == "0" ]; then | |
069fc1c5 | 67 | |
5da3fc85 | 68 | validate_lttng_modules_present |
069fc1c5 FD |
69 | |
70 | ||
71 | modprobe lttng-test | |
72 | ||
73 | # Used on sessiond launch. | |
74 | LTTNG_SESSIOND_ENV_VARS="LTTNG_TESTPOINT_ENABLE=1 \ | |
75 | CONSUMER_PAUSE_PIPE_PATH=${TESTPOINT_PIPE_PATH} \ | |
76 | LD_PRELOAD=${TESTPOINT}" | |
77 | start_lttng_sessiond_notap | |
78 | ||
79 | test_buffer_usage_notification | |
80 | ||
81 | stop_lttng_sessiond_notap | |
82 | rmmod lttng-test | |
83 | ||
84 | rm -rf "${consumerd_pipe[@]}" 2> /dev/null | |
854382b8 JR |
85 | else |
86 | # Kernel tests are skipped. | |
87 | plan_tests $NUM_TESTS | |
88 | skip 0 "Root access is needed. Skipping all kernel notification tests." $NUM_TESTS | |
89 | fi | |
90 | ||
33e55711 | 91 | rm -rf "$TEST_TMPDIR" |