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."
37 function enable_lttng_channel_size_limit
()
41 tracefile_size_limit
="$3"
43 test_name
="Enable channel $channel_name "
44 test_name
+="for session $sess_name: "
45 test_name
+="$tracefile_size_limit bytes tracefile limit"
47 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel \
48 -u $channel_name -s $sess_name --buffers-pid \
49 -C $tracefile_size_limit >/dev
/null
2>&1
54 function enable_ust_lttng_event_per_channel
()
60 test_name
="Enable event $event_name "
61 test_name
+="for session $sess_name "
62 test_name
+="in channel $channel_name"
64 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" \
65 -s $sess_name -u -c $channel_name >/dev
/null
2>&1
70 function check_file_size
()
74 expected_max_size
="$3"
76 find $path -name "$file_pattern" -exec stat
-c '%n %s' {} \
; \
77 |
while read file_info
;
79 name
=$
(echo $file_info | cut
-f1 -d ' ')
80 size
=$
(echo $file_info | cut
-f2 -d ' ')
82 if [ "$size" -gt "$expected_max_size" ]; then
83 diag_msg
="file: $name size: $size"
84 diag_msg
+="expected maximum size: $expected_max_size"
90 ok $?
"File size validation"
93 function test_tracefile_size_limit
()
96 trace_path
=$
(mktemp
-d)
97 session_name
=$
(randstring
16 0)
98 channel_name
="channel"
99 event_name
="tp:tptest"
101 diag
"Test tracefile size limit : $size_limit bytes"
103 create_lttng_session
$session_name $trace_path
105 enable_lttng_channel_size_limit \
106 $session_name $channel_name $size_limit
108 enable_ust_lttng_event_per_channel \
109 $session_name $event_name $channel_name
111 start_lttng_tracing
$session_name
113 $TESTAPP_BIN $NR_ITER >/dev
/null
2>&1
115 stop_lttng_tracing
$session_name
117 destroy_lttng_session
$session_name
119 # Validate file size, each one shall be no larger than the
120 # specified size limit
122 check_file_size
$trace_path "${channel_name}_*" $size_limit
124 # Validate tracing data, we should at least have some events
126 validate_trace
$event_name $trace_path
131 plan_tests
$NUM_TESTS
133 print_test_banner
"$TEST_DESC"
137 LIMITS
=("4096" "8192" "16384" "32768" "65536")
139 for limit
in ${LIMITS[@]};
141 test_tracefile_size_limit
$limit