3 # Copyright (C) 2013 Christian Babeux <christian.babeux@efficios.com>
5 # SPDX-License-Identifier: LGPL-2.1-only
7 TEST_DESC
="Tracefile count limits"
10 TESTDIR
=$CURDIR/..
/..
/..
12 TESTAPP_PATH
="$TESTDIR/utils/testapp"
13 TESTAPP_NAME
="gen-ust-events"
14 TESTAPP_BIN
="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
16 STATS_BIN
="$TESTDIR/utils/babelstats.pl"
20 PAGE_SIZE
=$
(getconf PAGE_SIZE
)
22 source $TESTDIR/utils
/utils.sh
24 if [ ! -x "$TESTAPP_BIN" ]; then
25 BAIL_OUT
"No UST events binary detected."
28 function enable_lttng_channel_count_limit
()
32 tracefile_count_limit
="$3"
34 test_name
="Enable channel $channel_name "
35 test_name
+="for session $sess_name: "
36 test_name
+="$tracefile_count_limit tracefiles"
38 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel \
39 -u $channel_name -s $sess_name \
40 -C $
(($PAGE_SIZE*3)) -W $tracefile_count_limit \
41 --overwrite >/dev
/null
2>&1
46 function enable_ust_lttng_event_per_channel
()
52 test_name
="Enable event $event_name "
53 test_name
+="for session $sess_name "
54 test_name
+="in channel $channel_name"
56 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" \
57 -s $sess_name -u -c $channel_name >/dev
/null
2>&1
62 function validate_min_max
69 echo $stats |
grep -q -E "$field $expected_min $expected_max"
73 function validate_file_count
77 expected_max_count
="$3"
79 count
=`find $path -name "$file_pattern" -type f \( ! -iname "*.idx" \) | wc -l`
81 if [ "$count" -gt "$expected_max_count" ]; then
82 fail
"Validate file count: $file_pattern"
83 diag
"File count: $count expected: $expected_max_count"
85 pass
"Validate file count: $file_pattern"
89 function test_tracefile_count_limit
()
92 trace_path
=$
(mktemp
-d)
93 session_name
=$
(randstring
16 0)
94 channel_name
="channel"
95 event_name
="tp:tptest"
97 expected_max
=$
(($num_iter - 1))
99 diag
"Test tracefile count limit : $count_limit tracefiles"
101 create_lttng_session_ok
$session_name $trace_path
103 enable_lttng_channel_count_limit \
104 $session_name $channel_name $count_limit
106 enable_ust_lttng_event_per_channel \
107 $session_name $event_name $channel_name
109 start_lttng_tracing_ok
$session_name
111 $TESTAPP_BIN -i $num_iter >/dev
/null
2>&1
113 stop_lttng_tracing_ok
$session_name
115 destroy_lttng_session_ok
$session_name
117 # Validate tracing dir
119 for cpuno
in $
(seq 0 $
(($NUM_CPUS - 1)))
121 validate_file_count \
122 $trace_path "${channel_name}_${cpuno}_*" $count_limit
125 # Validate tracing data
127 stats
=`babeltrace $trace_path | $STATS_BIN --tracepoint $event_name`
129 validate_min_max
"$stats" "intfield" "[0-9]+" "$expected_max"
130 ok $?
"Trace validation - intfield"
132 validate_min_max
"$stats" "netintfield" "[0-9]+" "$expected_max"
133 ok $?
"Trace validation - netintfield"
135 validate_min_max
"$stats" "longfield" "[0-9]+" "$expected_max"
136 ok $?
"Trace validation - longfield"
141 LIMITS
=("1" "2" "4" "8" "10" "16" "32" "64")
143 # The file count validation depends on the number of streams (1 per cpu)
144 TOTAL_TESTS
=$
(($NUM_TESTS + (${#LIMITS[@]} * $NUM_CPUS)))
146 plan_tests
$TOTAL_TESTS
148 print_test_banner
"$TEST_DESC"
152 for limit
in ${LIMITS[@]};
154 test_tracefile_count_limit
$limit