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"
32 source $TESTDIR/utils
/utils.sh
34 if [ ! -x "$TESTAPP_BIN" ]; then
35 BAIL_OUT
"No UST events binary detected."
40 while [ -n "$(pidof $TESTAPP_NAME)" ]; do
43 pass
"Wait for applications to end"
46 function enable_lttng_channel_count_limit
()
50 tracefile_count_limit
="$3"
52 test_name
="Enable channel $channel_name "
53 test_name
+="for session $sess_name: "
54 test_name
+="$tracefile_count_limit tracefiles"
56 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel \
57 -u $channel_name -s $sess_name \
58 -C 4096 -W $tracefile_count_limit \
59 --overwrite >/dev
/null
2>&1
64 function enable_ust_lttng_event_per_channel
()
70 test_name
="Enable event $event_name "
71 test_name
+="for session $sess_name "
72 test_name
+="in channel $channel_name"
74 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" \
75 -s $sess_name -u -c $channel_name >/dev
/null
2>&1
80 function validate_min_max
87 echo $stats |
grep -q -E "$field $expected_min $expected_max"
91 function validate_file_count
95 expected_max_count
="$3"
97 count
=`find $path -name "$file_pattern" -type f | wc -l`
99 if [ "$count" -gt "$expected_max_count" ]; then
100 fail
"Validate file count: $file_pattern"
101 diag
"File count: $count expected: $expected_max_count"
103 pass
"Validate file count: $file_pattern"
107 function test_tracefile_count_limit
()
110 trace_path
=$
(mktemp
-d)
111 session_name
=$
(randstring
16 0)
112 channel_name
="channel"
113 event_name
="tp:tptest"
115 expected_max
=$
(($num_iter - 1))
117 diag
"Test tracefile count limit : $count_limit tracefiles"
119 create_lttng_session
$session_name $trace_path
121 enable_lttng_channel_count_limit \
122 $session_name $channel_name $count_limit
124 enable_ust_lttng_event_per_channel \
125 $session_name $event_name $channel_name
127 start_lttng_tracing
$session_name
129 $TESTAPP_BIN $num_iter >/dev
/null
2>&1 &
133 stop_lttng_tracing
$session_name
135 destroy_lttng_session
$session_name
137 # Validate tracing dir
139 for cpuno
in $
(seq 0 $
(($NUM_CPUS - 1)))
141 validate_file_count \
142 $trace_path "${channel_name}_${cpuno}_*" $count_limit
145 # Validate tracing data
147 stats
=`babeltrace $trace_path | $STATS_BIN --tracepoint $event_name`
149 validate_min_max
"$stats" "intfield" "[0-9]+" "$expected_max"
150 ok $?
"Trace validation - intfield"
152 validate_min_max
"$stats" "netintfield" "[0-9]+" "$expected_max"
153 ok $?
"Trace validation - netintfield"
155 validate_min_max
"$stats" "longfield" "[0-9]+" "$expected_max"
156 ok $?
"Trace validation - longfield"
161 LIMITS
=("1" "2" "4" "8" "10" "16" "32" "64")
163 # The file count validation depends on the number of streams (1 per cpu)
164 TOTAL_TESTS
=$
(($NUM_TESTS + (${#LIMITS[@]} * $NUM_CPUS)))
166 plan_tests
$TOTAL_TESTS
168 print_test_banner
"$TEST_DESC"
172 for limit
in ${LIMITS[@]};
174 test_tracefile_count_limit
$limit