SoW-2020-0002: Trace Hit Counters: trigger error reporting integration
[lttng-tools.git] / tests / regression / tools / notification / test_notification_kernel_buffer_usage
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
10 TMPDIR=$(mktemp -d)
11
12 #This is needed since the testpoint create a pipe with the consumerd type suffixed
13 TESTPOINT_BASE_PATH=$(readlink -f "$TMPDIR/lttng.t_p_n")
14 TESTPOINT_PIPE_PATH=$(mktemp -u "${TESTPOINT_BASE_PATH}.XXXXXX")
15 TESTPOINT=$(readlink -f "${CURDIR}/.libs/libpause_consumer.so")
16 TESTAPP_STATE_PATH=$(mktemp -u "$TMPDIR/application_state.XXXXXXXXXX")
17
18
19 SESSION_NAME="my_session"
20 CHANNEL_NAME="my_channel"
21
22 NUM_TESTS=104
23
24 # shellcheck source=../../../utils/utils.sh
25 source "$TESTDIR/utils/utils.sh"
26 # shellcheck source=./util_event_generator.sh
27 source "$CURDIR/util_event_generator.sh"
28
29 function test_buffer_usage_notification
30 {
31 local event_name="lttng_test_filter_event"
32 local trace_path
33 local page_size
34 local consumerd_pipe=()
35
36 trace_path=$(mktemp -d)
37 page_size=$(getconf PAGE_SIZE)
38
39 create_lttng_session_notap $SESSION_NAME "$trace_path"
40
41 lttng_enable_kernel_channel_notap $SESSION_NAME $CHANNEL_NAME \
42 --subbuf-size="$page_size"
43 enable_kernel_lttng_event_notap $SESSION_NAME $event_name $CHANNEL_NAME
44
45 kernel_event_generator generate_filter_events "$TESTAPP_STATE_PATH" &
46 APP_PID=$!
47
48 # This is needed since the testpoint create a pipe with the consumer
49 # type suffixed.
50 for f in "$TESTPOINT_BASE_PATH"*; do
51 consumerd_pipe+=("$f")
52 done
53
54 "$CURDIR/notification" 2 LTTNG_DOMAIN_KERNEL $APP_PID "$TESTAPP_STATE_PATH" \
55 $SESSION_NAME $CHANNEL_NAME "${consumerd_pipe[@]}"
56
57 destroy_lttng_session_notap $SESSION_NAME
58
59 kill -SIGUSR2 $APP_PID
60 wait $APP_PID 2> /dev/null
61 }
62
63 if [ "$(id -u)" == "0" ]; then
64
65 validate_lttng_modules_present
66
67
68 modprobe lttng-test
69
70 # Used on sessiond launch.
71 LTTNG_SESSIOND_ENV_VARS="LTTNG_TESTPOINT_ENABLE=1 \
72 CONSUMER_PAUSE_PIPE_PATH=${TESTPOINT_PIPE_PATH} \
73 LD_PRELOAD=${TESTPOINT}"
74 start_lttng_sessiond_notap
75
76 test_buffer_usage_notification
77
78 stop_lttng_sessiond_notap
79 rmmod lttng-test
80
81 rm -rf "${consumerd_pipe[@]}" 2> /dev/null
82 else
83 # Kernel tests are skipped.
84 plan_tests $NUM_TESTS
85 skip 0 "Root access is needed. Skipping all kernel notification tests." $NUM_TESTS
86 fi
87
88 rm -rf "$TMPDIR"
This page took 0.045617 seconds and 5 git commands to generate.