1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
|
#!/bin/bash
#
# SPDX-FileCopyrightText: 2013 Christian Babeux <christian.babeux@efficios.com>
#
# SPDX-License-Identifier: LGPL-2.1-only
TEST_DESC="Tracefile size limits"
CURDIR=$(dirname $0)/
TESTDIR=$CURDIR/../../..
NR_ITER=1000
PAGE_SIZE=$(getconf PAGE_SIZE)
TESTAPP_PATH="$TESTDIR/utils/testapp"
TESTAPP_NAME="gen-ust-events"
TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
NUM_TESTS=74
source $TESTDIR/utils/utils.sh
if [ ! -x "$TESTAPP_BIN" ]; then
BAIL_OUT "No UST events binary detected."
fi
function enable_lttng_channel_size_limit ()
{
sess_name="$1"
channel_name="$2"
tracefile_size_limit="$3"
test_name="Enable channel $channel_name "
test_name+="for session $sess_name: "
test_name+="$tracefile_size_limit bytes tracefile limit"
$TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel \
-u $channel_name -s $sess_name --buffer-ownership=process \
--subbuf-size=$PAGE_SIZE \
-C $tracefile_size_limit >/dev/null 2>&1
ok $? "$test_name"
}
function enable_ust_lttng_event_per_channel ()
{
sess_name="$1"
event_name="$2"
channel_name="$3"
test_name="Enable event $event_name "
test_name+="for session $sess_name "
test_name+="in channel $channel_name"
$TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" \
-s $sess_name -u -c $channel_name >/dev/null 2>&1
ok $? "$test_name"
}
function check_file_size ()
{
path="$1"
file_pattern="$2"
expected_max_size="$3"
find $path -name "$file_pattern" -exec stat -c '%n %s' {} \; \
| while read file_info;
do
name=$(echo $file_info | cut -f1 -d ' ')
size=$(echo $file_info | cut -f2 -d ' ')
if [ "$size" -gt "$expected_max_size" ]; then
diag_msg="file: $name size: $size"
diag_msg+="expected maximum size: $expected_max_size"
diag "$diag_msg"
exit 1
fi
done
ok $? "File size validation"
}
function test_tracefile_size_limit ()
{
local size_limit="$1"
local trace_path=$(mktemp -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
local session_name=$(randstring 16 0)
local channel_name="channel"
local event_name="tp:tptest"
diag "Test tracefile size limit : $size_limit bytes"
create_lttng_session_ok $session_name $trace_path
enable_lttng_channel_size_limit \
$session_name $channel_name $size_limit
enable_ust_lttng_event_per_channel \
$session_name $event_name $channel_name
start_lttng_tracing_ok $session_name
$TESTAPP_BIN -i $NR_ITER >/dev/null 2>&1
stop_lttng_tracing_ok $session_name
destroy_lttng_session_ok $session_name
# Validate file size, each one shall be no larger than the
# specified size limit
check_file_size $trace_path "${channel_name}_*" $size_limit
# Validate tracing data, we should at least have some events
validate_trace_path_ust_pid "$trace_path" "" "gen-ust-events"
validate_trace $event_name $trace_path
rm -rf $trace_path
}
function test_tracefile_size_limit_pagesize ()
{
# Set a size limit lower than the page_size
local size_limit="$(($PAGE_SIZE-2))"
local trace_path=$(mktemp -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
local session_name=$(randstring 16 0)
local channel_name="channel"
local event_name="tp:tptest"
diag "Test tracefile size limit lower than PAGE_SIZE : $size_limit bytes"
create_lttng_session_ok $session_name $trace_path
enable_lttng_channel_size_limit \
$session_name $channel_name $size_limit
enable_ust_lttng_event_per_channel \
$session_name $event_name $channel_name
start_lttng_tracing_ok $session_name
$TESTAPP_BIN -i $NR_ITER >/dev/null 2>&1
stop_lttng_tracing_ok $session_name
destroy_lttng_session_ok $session_name
# Validate file size, expect file size to be equal to the page size
check_file_size $trace_path "${channel_name}_*" $PAGE_SIZE
# Validate tracing data, we should at least have some events
validate_trace_path_ust_pid "$trace_path" "" "gen-ust-events"
validate_trace $event_name $trace_path
rm -rf $trace_path
}
plan_tests $NUM_TESTS
print_test_banner "$TEST_DESC"
bail_out_if_no_babeltrace
start_lttng_sessiond
# Test with multiples of PAGE_SIZE
LIMITS=("$(($PAGE_SIZE))"
"$(($PAGE_SIZE*2))"
"$(($PAGE_SIZE*4))"
"$(($PAGE_SIZE*8))"
"$(($PAGE_SIZE*16))"
"$(($PAGE_SIZE*32))")
for limit in ${LIMITS[@]};
do
test_tracefile_size_limit $limit
done
# Test with a value that is not a multiple of PAGE_SIZE
test_tracefile_size_limit "$(($PAGE_SIZE+1024))"
# Test that a value lower than the PAGE_SIZE is rounded to it
test_tracefile_size_limit_pagesize
stop_lttng_sessiond
|