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 -C $tracefile_size_limit >/dev
/null
2>&1
56 function enable_ust_lttng_event_per_channel
()
62 test_name
="Enable event $event_name "
63 test_name
+="for session $sess_name "
64 test_name
+="in channel $channel_name"
66 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-event
"$event_name" \
67 -s $sess_name -u -c $channel_name >/dev
/null
2>&1
72 function check_file_size
()
76 expected_max_size
="$3"
78 find $path -name "$file_pattern" -exec stat
-c '%n %s' {} \
; \
79 |
while read file_info
;
81 name
=$
(echo $file_info | cut
-f1 -d ' ')
82 size
=$
(echo $file_info | cut
-f2 -d ' ')
84 if [ "$size" -gt "$expected_max_size" ]; then
85 diag_msg
="file: $name size: $size"
86 diag_msg
+="expected maximum size: $expected_max_size"
92 ok $?
"File size validation"
95 function test_tracefile_size_limit
()
98 trace_path
=$
(mktemp
-d)
99 session_name
=$
(randstring
16 0)
100 channel_name
="channel"
101 event_name
="tp:tptest"
103 diag
"Test tracefile size limit : $size_limit bytes"
105 create_lttng_session_ok
$session_name $trace_path
107 enable_lttng_channel_size_limit \
108 $session_name $channel_name $size_limit
110 enable_ust_lttng_event_per_channel \
111 $session_name $event_name $channel_name
113 start_lttng_tracing_ok
$session_name
115 $TESTAPP_BIN $NR_ITER >/dev
/null
2>&1
117 stop_lttng_tracing_ok
$session_name
119 destroy_lttng_session_ok
$session_name
121 # Validate file size, each one shall be no larger than the
122 # specified size limit
124 check_file_size
$trace_path "${channel_name}_*" $size_limit
126 # Validate tracing data, we should at least have some events
128 validate_trace
$event_name $trace_path
133 function test_tracefile_size_limit_pagesize
()
135 # Set a size limit lower than the page_size
136 size_limit
="$(($PAGE_SIZE-2))"
137 trace_path
=$
(mktemp
-d)
138 session_name
=$
(randstring
16 0)
139 channel_name
="channel"
140 event_name
="tp:tptest"
142 diag
"Test tracefile size limit lower than PAGE_SIZE : $size_limit bytes"
144 create_lttng_session_ok
$session_name $trace_path
146 enable_lttng_channel_size_limit \
147 $session_name $channel_name $size_limit
149 enable_ust_lttng_event_per_channel \
150 $session_name $event_name $channel_name
152 start_lttng_tracing_ok
$session_name
154 $TESTAPP_BIN $NR_ITER >/dev
/null
2>&1
156 stop_lttng_tracing_ok
$session_name
158 destroy_lttng_session_ok
$session_name
160 # Validate file size, expect file size to be equal to the page size
162 check_file_size
$trace_path "${channel_name}_*" $PAGE_SIZE
164 # Validate tracing data, we should at least have some events
166 validate_trace
$event_name $trace_path
171 plan_tests
$NUM_TESTS
173 print_test_banner
"$TEST_DESC"
177 # Test with multiples of PAGE_SIZE
178 LIMITS
=("$(($PAGE_SIZE))"
183 "$(($PAGE_SIZE*32))")
185 for limit
in ${LIMITS[@]};
187 test_tracefile_size_limit
$limit
190 # Test with a value that is not a multiple of PAGE_SIZE
191 test_tracefile_size_limit
"$(($PAGE_SIZE+1024))"
193 # Test that a value lower than the PAGE_SIZE is rounded to it
194 test_tracefile_size_limit_pagesize