3 # Copyright (C) - 2013 Christian Babeux <christian.babeux@efficios.com>
5 # This library is free software; you can redistribute it and/or modify it under
6 # the terms of the GNU Lesser General Public License as published by the Free
7 # Software Foundation; version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful, but WITHOUT
10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14 # You should have received a copy of the GNU Lesser General Public License
15 # along with this library; if not, write to the Free Software Foundation, Inc.,
16 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 TEST_DESC
="Tracefile count limits"
21 TESTDIR
=$CURDIR/..
/..
/..
23 TESTAPP_PATH
="$TESTDIR/utils/testapp"
24 TESTAPP_NAME
="gen-ust-events"
25 TESTAPP_BIN
="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
27 STATS_BIN
="$TESTDIR/utils/babelstats.pl"
31 PAGE_SIZE
=$
(getconf PAGE_SIZE
)
33 source $TESTDIR/utils
/utils.sh
35 if [ ! -x "$TESTAPP_BIN" ]; then
36 BAIL_OUT
"No UST events binary detected."
39 function enable_lttng_channel_count_limit
()
43 tracefile_count_limit
="$3"
45 test_name
="Enable channel $channel_name "
46 test_name
+="for session $sess_name: "
47 test_name
+="$tracefile_count_limit tracefiles"
49 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel \
50 -u $channel_name -s $sess_name \
51 -C $
(($PAGE_SIZE*3)) -W $tracefile_count_limit \
52 --overwrite >/dev
/null
2>&1
57 function enable_ust_lttng_event_per_channel
()
63 test_name
="Enable event $event_name "
64 test_name
+="for session $sess_name "
65 test_name
+="in channel $channel_name"
67 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" \
68 -s $sess_name -u -c $channel_name >/dev
/null
2>&1
73 function validate_min_max
80 echo $stats |
grep -q -E "$field $expected_min $expected_max"
84 function validate_file_count
88 expected_max_count
="$3"
90 count
=`find $path -name "$file_pattern" -type f \( ! -iname "*.idx" \) | wc -l`
92 if [ "$count" -gt "$expected_max_count" ]; then
93 fail
"Validate file count: $file_pattern"
94 diag
"File count: $count expected: $expected_max_count"
96 pass
"Validate file count: $file_pattern"
100 function test_tracefile_count_limit
()
103 trace_path
=$
(mktemp
-d)
104 session_name
=$
(randstring
16 0)
105 channel_name
="channel"
106 event_name
="tp:tptest"
108 expected_max
=$
(($num_iter - 1))
110 diag
"Test tracefile count limit : $count_limit tracefiles"
112 create_lttng_session_ok
$session_name $trace_path
114 enable_lttng_channel_count_limit \
115 $session_name $channel_name $count_limit
117 enable_ust_lttng_event_per_channel \
118 $session_name $event_name $channel_name
120 start_lttng_tracing_ok
$session_name
122 $TESTAPP_BIN -i $num_iter >/dev
/null
2>&1
124 stop_lttng_tracing_ok
$session_name
126 destroy_lttng_session_ok
$session_name
128 # Validate tracing dir
130 for cpuno
in $
(seq 0 $
(($NUM_CPUS - 1)))
132 validate_file_count \
133 $trace_path "${channel_name}_${cpuno}_*" $count_limit
136 # Validate tracing data
138 stats
=`babeltrace $trace_path | $STATS_BIN --tracepoint $event_name`
140 validate_min_max
"$stats" "intfield" "[0-9]+" "$expected_max"
141 ok $?
"Trace validation - intfield"
143 validate_min_max
"$stats" "netintfield" "[0-9]+" "$expected_max"
144 ok $?
"Trace validation - netintfield"
146 validate_min_max
"$stats" "longfield" "[0-9]+" "$expected_max"
147 ok $?
"Trace validation - longfield"
152 LIMITS
=("1" "2" "4" "8" "10" "16" "32" "64")
154 # The file count validation depends on the number of streams (1 per cpu)
155 TOTAL_TESTS
=$
(($NUM_TESTS + (${#LIMITS[@]} * $NUM_CPUS)))
157 plan_tests
$TOTAL_TESTS
159 print_test_banner
"$TEST_DESC"
163 for limit
in ${LIMITS[@]};
165 test_tracefile_count_limit
$limit