Commit | Line | Data |
---|---|---|
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 | ||
18 | TEST_DESC="Tracefile size limits" | |
19 | ||
20 | CURDIR=$(dirname $0)/ | |
21 | TESTDIR=$CURDIR/../../.. | |
22 | ||
23 | NR_ITER=1000 | |
24 | ||
25 | TESTAPP_PATH="$TESTDIR/utils/testapp" | |
26 | TESTAPP_NAME="gen-ust-events" | |
27 | TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME" | |
28 | ||
d7ee608c | 29 | NUM_TESTS=42 |
34497a63 CB |
30 | |
31 | source $TESTDIR/utils/utils.sh | |
32 | ||
33 | if [ ! -x "$TESTAPP_BIN" ]; then | |
34 | BAIL_OUT "No UST events binary detected." | |
35 | fi | |
36 | ||
34497a63 CB |
37 | function 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 | ||
54 | function 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 | ||
70 | function 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 | ||
93 | function 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 | ||
103 | create_lttng_session $session_name $trace_path | |
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 | ||
111 | start_lttng_tracing $session_name | |
112 | ||
d7ee608c | 113 | $TESTAPP_BIN $NR_ITER >/dev/null 2>&1 |
34497a63 CB |
114 | |
115 | stop_lttng_tracing $session_name | |
116 | ||
117 | destroy_lttng_session $session_name | |
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 | ||
131 | plan_tests $NUM_TESTS | |
132 | ||
133 | print_test_banner "$TEST_DESC" | |
134 | ||
135 | start_lttng_sessiond | |
136 | ||
137 | LIMITS=("4096" "8192" "16384" "32768" "65536") | |
138 | ||
139 | for limit in ${LIMITS[@]}; | |
140 | do | |
141 | test_tracefile_size_limit $limit | |
142 | done | |
143 | ||
144 | stop_lttng_sessiond |