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 size limits"
21 TESTDIR
=$CURDIR/..
/..
/..
25 TESTAPP_PATH
="$TESTDIR/utils/testapp"
26 TESTAPP_NAME
="gen-ust-events"
27 TESTAPP_BIN
="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
31 source $TESTDIR/utils
/utils.sh
33 if [ ! -x "$TESTAPP_BIN" ]; then
34 BAIL_OUT
"No UST events binary detected."
39 while [ -n "$(pidof $TESTAPP_NAME)" ]; do
42 pass
"Wait for applications to end"
45 function enable_lttng_channel_size_limit
()
49 tracefile_size_limit
="$3"
51 test_name
="Enable channel $channel_name "
52 test_name
+="for session $sess_name: "
53 test_name
+="$tracefile_size_limit bytes tracefile limit"
55 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel \
56 -u $channel_name -s $sess_name --buffers-pid \
57 -C $tracefile_size_limit >/dev
/null
2>&1
62 function enable_ust_lttng_event_per_channel
()
68 test_name
="Enable event $event_name "
69 test_name
+="for session $sess_name "
70 test_name
+="in channel $channel_name"
72 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" \
73 -s $sess_name -u -c $channel_name >/dev
/null
2>&1
78 function check_file_size
()
82 expected_max_size
="$3"
84 find $path -name "$file_pattern" -exec stat
-c '%n %s' {} \
; \
85 |
while read file_info
;
87 name
=$
(echo $file_info | cut
-f1 -d ' ')
88 size
=$
(echo $file_info | cut
-f2 -d ' ')
90 if [ "$size" -gt "$expected_max_size" ]; then
91 diag_msg
="file: $name size: $size"
92 diag_msg
+="expected maximum size: $expected_max_size"
98 ok $?
"File size validation"
101 function test_tracefile_size_limit
()
104 trace_path
=$
(mktemp
-d)
105 session_name
=$
(randstring
16 0)
106 channel_name
="channel"
107 event_name
="tp:tptest"
109 diag
"Test tracefile size limit : $size_limit bytes"
111 create_lttng_session
$session_name $trace_path
113 enable_lttng_channel_size_limit \
114 $session_name $channel_name $size_limit
116 enable_ust_lttng_event_per_channel \
117 $session_name $event_name $channel_name
119 start_lttng_tracing
$session_name
121 $TESTAPP_BIN $NR_ITER >/dev
/null
2>&1 &
125 stop_lttng_tracing
$session_name
127 destroy_lttng_session
$session_name
129 # Validate file size, each one shall be no larger than the
130 # specified size limit
132 check_file_size
$trace_path "${channel_name}_*" $size_limit
134 # Validate tracing data, we should at least have some events
136 validate_trace
$event_name $trace_path
141 plan_tests
$NUM_TESTS
143 print_test_banner
"$TEST_DESC"
147 LIMITS
=("4096" "8192" "16384" "32768" "65536")
149 for limit
in ${LIMITS[@]};
151 test_tracefile_size_limit
$limit