| 1 |
#!/bin/bash |
| 2 |
# |
| 3 |
# SPDX-FileCopyrightText: 2015 Jonathan Rajotte <[email protected]> |
| 4 |
# SPDX-FileCopyrightText: 2016 Mathieu Desnoyers <[email protected]> |
| 5 |
# SPDX-FileCopyrightText: 2025 Michael Jeanson <[email protected]> |
| 6 |
# |
| 7 |
# SPDX-License-Identifier: LGPL-2.1-only |
| 8 |
|
| 9 |
TEST_DESC="UST - Rotation destroy flush" |
| 10 |
|
| 11 |
CURDIR=$(dirname "$0")/ |
| 12 |
TESTDIR=$CURDIR/../../.. |
| 13 |
|
| 14 |
TESTAPP_PATH="$TESTDIR/utils/testapp" |
| 15 |
TESTAPP_NAME="gen-ust-events" |
| 16 |
TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME" |
| 17 |
|
| 18 |
NUM_EVENT=1000000 |
| 19 |
EVENT_NAME="tp:tptest" |
| 20 |
|
| 21 |
TEST_RUNS=10 |
| 22 |
NUM_TESTS=$((19 * TEST_RUNS)) |
| 23 |
|
| 24 |
# shellcheck source-path=SCRIPTDIR/../../.. |
| 25 |
source "$TESTDIR/utils/utils.sh" |
| 26 |
|
| 27 |
# Ensure the daemons invoke abort on error. |
| 28 |
check_skip_kernel_test || export LTTNG_ABORT_ON_ERROR=1 |
| 29 |
|
| 30 |
# MUST set TESTDIR before calling those functions |
| 31 |
|
| 32 |
function test_rotation_destroy_flush_single() |
| 33 |
{ |
| 34 |
local session_name="rotation_destroy_flush" |
| 35 |
local channel_name="page_size_chan" |
| 36 |
local trace_path |
| 37 |
local file_testapp_output |
| 38 |
|
| 39 |
trace_path=$(mktemp -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX") |
| 40 |
file_testapp_output=$(mktemp -u -t "tmp.${FUNCNAME[0]}_testapp_output.XXXXXX") |
| 41 |
|
| 42 |
start_lttng_sessiond |
| 43 |
|
| 44 |
create_lttng_session_ok $session_name "$trace_path" |
| 45 |
enable_ust_lttng_channel_ok $session_name $channel_name --buffer-ownership=process --tracefile-size="$(getconf PAGE_SIZE)" |
| 46 |
enable_ust_lttng_event_ok $session_name $EVENT_NAME $channel_name |
| 47 |
start_lttng_tracing_ok $session_name |
| 48 |
|
| 49 |
run_testapp_ok "$file_testapp_output" "$TESTAPP_BIN" -i $NUM_EVENT |
| 50 |
|
| 51 |
# stop and destroy |
| 52 |
stop_lttng_tracing_ok $session_name |
| 53 |
destroy_lttng_session_ok $session_name |
| 54 |
|
| 55 |
validate_trace_count_range_incl_min_excl_max "$EVENT_NAME" "${trace_path}" 1 $NUM_EVENT |
| 56 |
|
| 57 |
rm -rf "$trace_path" |
| 58 |
trace_path=$(mktemp -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX") |
| 59 |
|
| 60 |
create_lttng_session_ok $session_name "$trace_path" |
| 61 |
enable_ust_lttng_channel_ok $session_name $channel_name --buffer-ownership=process --tracefile-size="$(getconf PAGE_SIZE)" |
| 62 |
enable_ust_lttng_event_ok $session_name $EVENT_NAME $channel_name |
| 63 |
start_lttng_tracing_ok $session_name |
| 64 |
|
| 65 |
run_testapp_ok "$file_testapp_output" "$TESTAPP_BIN" -i $NUM_EVENT |
| 66 |
|
| 67 |
# destroy only |
| 68 |
destroy_lttng_session_ok $session_name |
| 69 |
stop_lttng_sessiond |
| 70 |
|
| 71 |
validate_trace_count_range_incl_min_excl_max "$EVENT_NAME" "${trace_path}" 1 $NUM_EVENT |
| 72 |
|
| 73 |
rm -rf "$trace_path" |
| 74 |
rm -f "$file_testapp_output" |
| 75 |
} |
| 76 |
|
| 77 |
function test_rotation_destroy_flush() |
| 78 |
{ |
| 79 |
for a in $(seq 1 ${TEST_RUNS}); do |
| 80 |
diag "Test run ${a}/${TEST_RUNS}" |
| 81 |
test_rotation_destroy_flush_single |
| 82 |
done |
| 83 |
} |
| 84 |
|
| 85 |
plan_tests $NUM_TESTS |
| 86 |
|
| 87 |
print_test_banner "$TEST_DESC" |
| 88 |
|
| 89 |
test_rotation_destroy_flush |