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 PAGE_SIZE
=$
(getconf PAGE_SIZE
)
27 TESTAPP_PATH
="$TESTDIR/utils/testapp"
28 TESTAPP_NAME
="gen-ust-events"
29 TESTAPP_BIN
="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
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_size_limit
()
43 tracefile_size_limit
="$3"
45 test_name
="Enable channel $channel_name "
46 test_name
+="for session $sess_name: "
47 test_name
+="$tracefile_size_limit bytes tracefile limit"
49 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel \
50 -u $channel_name -s $sess_name --buffers-pid \
51 --subbuf-size=$PAGE_SIZE \
52 -C $tracefile_size_limit >/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 check_file_size
()
77 expected_max_size
="$3"
79 find $path -name "$file_pattern" -exec stat
-c '%n %s' {} \
; \
80 |
while read file_info
;
82 name
=$
(echo $file_info | cut
-f1 -d ' ')
83 size
=$
(echo $file_info | cut
-f2 -d ' ')
85 if [ "$size" -gt "$expected_max_size" ]; then
86 diag_msg
="file: $name size: $size"
87 diag_msg
+="expected maximum size: $expected_max_size"
93 ok $?
"File size validation"
96 function test_tracefile_size_limit
()
99 trace_path
=$
(mktemp
-d)
100 session_name
=$
(randstring
16 0)
101 channel_name
="channel"
102 event_name
="tp:tptest"
104 diag
"Test tracefile size limit : $size_limit bytes"
106 create_lttng_session_ok
$session_name $trace_path
108 enable_lttng_channel_size_limit \
109 $session_name $channel_name $size_limit
111 enable_ust_lttng_event_per_channel \
112 $session_name $event_name $channel_name
114 start_lttng_tracing_ok
$session_name
116 $TESTAPP_BIN -i $NR_ITER >/dev
/null
2>&1
118 stop_lttng_tracing_ok
$session_name
120 destroy_lttng_session_ok
$session_name
122 # Validate file size, each one shall be no larger than the
123 # specified size limit
125 check_file_size
$trace_path "${channel_name}_*" $size_limit
127 # Validate tracing data, we should at least have some events
129 validate_trace
$event_name $trace_path
134 function test_tracefile_size_limit_pagesize
()
136 # Set a size limit lower than the page_size
137 size_limit
="$(($PAGE_SIZE-2))"
138 trace_path
=$
(mktemp
-d)
139 session_name
=$
(randstring
16 0)
140 channel_name
="channel"
141 event_name
="tp:tptest"
143 diag
"Test tracefile size limit lower than PAGE_SIZE : $size_limit bytes"
145 create_lttng_session_ok
$session_name $trace_path
147 enable_lttng_channel_size_limit \
148 $session_name $channel_name $size_limit
150 enable_ust_lttng_event_per_channel \
151 $session_name $event_name $channel_name
153 start_lttng_tracing_ok
$session_name
155 $TESTAPP_BIN -i $NR_ITER >/dev
/null
2>&1
157 stop_lttng_tracing_ok
$session_name
159 destroy_lttng_session_ok
$session_name
161 # Validate file size, expect file size to be equal to the page size
163 check_file_size
$trace_path "${channel_name}_*" $PAGE_SIZE
165 # Validate tracing data, we should at least have some events
167 validate_trace
$event_name $trace_path
172 plan_tests
$NUM_TESTS
174 print_test_banner
"$TEST_DESC"
178 # Test with multiples of PAGE_SIZE
179 LIMITS
=("$(($PAGE_SIZE))"
184 "$(($PAGE_SIZE*32))")
186 for limit
in ${LIMITS[@]};
188 test_tracefile_size_limit
$limit
191 # Test with a value that is not a multiple of PAGE_SIZE
192 test_tracefile_size_limit
"$(($PAGE_SIZE+1024))"
194 # Test that a value lower than the PAGE_SIZE is rounded to it
195 test_tracefile_size_limit_pagesize