Test: jul/log4j: use -a instead of '*' to disable all events
[lttng-tools.git] / tests / regression / tools / tracefile-limits / test_tracefile_size
CommitLineData
34497a63
CB
1#!/bin/bash
2#
3# Copyright (C) - 2013 Christian Babeux <christian.babeux@efficios.com>
4#
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.
8#
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
12# details.
13#
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
17
18TEST_DESC="Tracefile size limits"
19
20CURDIR=$(dirname $0)/
21TESTDIR=$CURDIR/../../..
22
23NR_ITER=1000
24
25TESTAPP_PATH="$TESTDIR/utils/testapp"
26TESTAPP_NAME="gen-ust-events"
27TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
28
d7ee608c 29NUM_TESTS=42
34497a63
CB
30
31source $TESTDIR/utils/utils.sh
32
33if [ ! -x "$TESTAPP_BIN" ]; then
34 BAIL_OUT "No UST events binary detected."
35fi
36
34497a63
CB
37function enable_lttng_channel_size_limit ()
38{
39 sess_name="$1"
40 channel_name="$2"
41 tracefile_size_limit="$3"
42
43 test_name="Enable channel $channel_name "
44 test_name+="for session $sess_name: "
45 test_name+="$tracefile_size_limit bytes tracefile limit"
46
47 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel \
c1b8e6f8 48 -u $channel_name -s $sess_name --buffers-pid \
34497a63
CB
49 -C $tracefile_size_limit >/dev/null 2>&1
50
51 ok $? "$test_name"
52}
53
54function enable_ust_lttng_event_per_channel ()
55{
56 sess_name="$1"
57 event_name="$2"
58 channel_name="$3"
59
60 test_name="Enable event $event_name "
61 test_name+="for session $sess_name "
62 test_name+="in channel $channel_name"
63
64 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" \
65 -s $sess_name -u -c $channel_name >/dev/null 2>&1
66
67 ok $? "$test_name"
68}
69
70function check_file_size ()
71{
72 path="$1"
73 file_pattern="$2"
74 expected_max_size="$3"
75
76 find $path -name "$file_pattern" -exec stat -c '%n %s' {} \; \
77 | while read file_info;
78 do
79 name=$(echo $file_info | cut -f1 -d ' ')
80 size=$(echo $file_info | cut -f2 -d ' ')
81
82 if [ "$size" -gt "$expected_max_size" ]; then
83 diag_msg="file: $name size: $size"
84 diag_msg+="expected maximum size: $expected_max_size"
85 diag "$diag_msg"
86 exit 1
87 fi
88 done
89
90 ok $? "File size validation"
91}
92
93function test_tracefile_size_limit ()
94{
95 size_limit="$1"
96 trace_path=$(mktemp -d)
97 session_name=$(randstring 16 0)
98 channel_name="channel"
99 event_name="tp:tptest"
100
101 diag "Test tracefile size limit : $size_limit bytes"
102
bf6ae429 103 create_lttng_session_ok $session_name $trace_path
34497a63
CB
104
105 enable_lttng_channel_size_limit \
106 $session_name $channel_name $size_limit
107
108 enable_ust_lttng_event_per_channel \
109 $session_name $event_name $channel_name
110
e563bbdb 111 start_lttng_tracing_ok $session_name
34497a63 112
d7ee608c 113 $TESTAPP_BIN $NR_ITER >/dev/null 2>&1
34497a63 114
96340a01 115 stop_lttng_tracing_ok $session_name
34497a63 116
67b4c664 117 destroy_lttng_session_ok $session_name
34497a63
CB
118
119 # Validate file size, each one shall be no larger than the
120 # specified size limit
121
122 check_file_size $trace_path "${channel_name}_*" $size_limit
123
124 # Validate tracing data, we should at least have some events
125
126 validate_trace $event_name $trace_path
127
128 rm -rf $trace_path
129}
130
131plan_tests $NUM_TESTS
132
133print_test_banner "$TEST_DESC"
134
135start_lttng_sessiond
136
137LIMITS=("4096" "8192" "16384" "32768" "65536")
138
139for limit in ${LIMITS[@]};
140do
141 test_tracefile_size_limit $limit
142done
143
144stop_lttng_sessiond
This page took 0.057786 seconds and 5 git commands to generate.