Commit | Line | Data |
---|---|---|
801236b0 JD |
1 | #!/bin/bash |
2 | # | |
3 | # Copyright (C) - 2015 Julien Desfossez <jdesfossez@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 | TEST_DESC="Streaming - User space tracing" | |
18 | ||
19 | CURDIR=$(dirname $0)/ | |
20 | TESTDIR=$CURDIR/../../.. | |
21 | NR_ITER=1 | |
22 | NR_USEC_WAIT=0 | |
23 | TESTAPP_PATH="$TESTDIR/utils/testapp" | |
24 | TESTAPP_NAME="gen-ust-events" | |
25 | TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME" | |
26 | SESSION_NAME="stream" | |
27 | EVENT_NAME="tp:tptest" | |
28 | PID_RELAYD=0 | |
29 | ||
30 | TRACE_PATH=$(mktemp -d) | |
31 | ||
32 | NUM_TESTS=33 | |
33 | ||
34 | source $TESTDIR/utils/utils.sh | |
35 | ||
36 | if [ ! -x "$TESTAPP_BIN" ]; then | |
37 | BAIL_OUT "No UST events binary detected." | |
38 | fi | |
39 | ||
40 | function lttng_create_session_uri | |
41 | { | |
42 | # Create session with default path | |
43 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME -U net://localhost >/dev/null 2>&1 | |
44 | ok $? "Create session with default path" | |
45 | } | |
46 | ||
47 | function lttng_create_session_uri_live | |
48 | { | |
49 | # Create session with default path | |
50 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME --live -U net://localhost >/dev/null 2>&1 | |
51 | ok $? "Create live session" | |
52 | } | |
53 | ||
54 | function enable_channel_per_pid() | |
55 | { | |
56 | sess_name=$1 | |
57 | channel_name=$2 | |
58 | ||
59 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel --buffers-pid -u $channel_name -s $sess_name >/dev/null 2>&1 | |
60 | ok $? "Enable channel $channel_name per PID for session $sess_name" | |
61 | } | |
62 | ||
63 | # MUST set TESTDIR before calling those functions | |
64 | ||
65 | function test_ust_streaming () | |
66 | { | |
67 | local file_sync_after_first=$(mktemp -u) | |
68 | local file_sync_before_last=$(mktemp -u) | |
69 | ||
70 | diag "Test UST streaming with metadata regeneration" | |
71 | lttng_create_session_uri | |
72 | enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME | |
73 | ||
e8526e3f JR |
74 | $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT \ |
75 | --sync-after-first-event ${file_sync_after_first} \ | |
76 | --sync-before-last-event ${file_sync_before_last} >/dev/null 2>&1 & | |
801236b0 JD |
77 | |
78 | start_lttng_tracing_ok $SESSION_NAME | |
79 | ||
80 | touch ${file_sync_before_last} | |
81 | ||
82 | # Wait for the applications started in background | |
83 | wait | |
eded6438 | 84 | regenerate_metadata_ok $SESSION_NAME |
801236b0 JD |
85 | |
86 | stop_lttng_tracing_ok $SESSION_NAME | |
87 | destroy_lttng_session_ok $SESSION_NAME | |
88 | # Validate test | |
89 | validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME* | |
90 | if [ $? -eq 0 ]; then | |
91 | # Only delete if successful | |
92 | rm -rf $TRACE_PATH | |
93 | fi | |
94 | rm -f ${file_sync_after_first} | |
95 | rm -f ${file_sync_before_last} | |
96 | } | |
97 | ||
98 | function test_ust_local () | |
99 | { | |
100 | local file_sync_after_first=$(mktemp -u) | |
101 | local file_sync_before_last=$(mktemp -u) | |
102 | ||
103 | diag "Test UST local with metadata regeneration" | |
104 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH | |
105 | enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME | |
106 | ||
e8526e3f JR |
107 | $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT \ |
108 | --sync-after-first-event ${file_sync_after_first} \ | |
109 | --sync-before-last-event ${file_sync_before_last} > /dev/null 2>&1 & | |
801236b0 JD |
110 | |
111 | start_lttng_tracing_ok $SESSION_NAME | |
112 | ||
113 | touch ${file_sync_before_last} | |
114 | ||
115 | # Wait for the applications started in background | |
116 | wait | |
eded6438 | 117 | regenerate_metadata_ok $SESSION_NAME |
801236b0 JD |
118 | |
119 | stop_lttng_tracing_ok $SESSION_NAME | |
120 | destroy_lttng_session_ok $SESSION_NAME | |
121 | # Validate test | |
122 | validate_trace $EVENT_NAME $TRACE_PATH | |
123 | if [ $? -eq 0 ]; then | |
124 | # Only delete if successful | |
125 | rm -rf $TRACE_PATH | |
126 | fi | |
127 | rm -f ${file_sync_after_first} | |
128 | rm -f ${file_sync_before_last} | |
129 | } | |
130 | ||
131 | function test_ust_pid () | |
132 | { | |
133 | local file_sync_after_first=$(mktemp -u) | |
134 | local file_sync_before_last=$(mktemp -u) | |
135 | ||
136 | diag "Test UST per-pid with metadata regeneration (expect failure)" | |
137 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH | |
138 | enable_channel_per_pid $SESSION_NAME "channel0" | |
139 | enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME "channel0" | |
140 | ||
e8526e3f JR |
141 | $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT \ |
142 | --sync-after-first-event ${file_sync_after_first} \ | |
143 | --sync-before-last-event ${file_sync_before_last} >/dev/null 2>&1 & | |
801236b0 JD |
144 | |
145 | start_lttng_tracing_ok $SESSION_NAME | |
146 | ||
147 | touch ${file_sync_before_last} | |
148 | ||
149 | # Wait for the applications started in background | |
150 | wait | |
eded6438 | 151 | regenerate_metadata_fail $SESSION_NAME |
801236b0 JD |
152 | |
153 | stop_lttng_tracing_ok $SESSION_NAME | |
154 | destroy_lttng_session_ok $SESSION_NAME | |
155 | # Validate test | |
156 | validate_trace $EVENT_NAME $TRACE_PATH | |
157 | if [ $? -eq 0 ]; then | |
158 | # Only delete if successful | |
159 | rm -rf $TRACE_PATH | |
160 | fi | |
161 | rm -f ${file_sync_after_first} | |
162 | rm -f ${file_sync_before_last} | |
163 | } | |
164 | ||
165 | function test_ust_live () | |
166 | { | |
167 | local file_sync_after_first=$(mktemp -u) | |
168 | local file_sync_before_last=$(mktemp -u) | |
169 | ||
170 | diag "Test UST live with metadata regeneration (expect failure)" | |
171 | lttng_create_session_uri_live $SESSION_NAME $TRACE_PATH | |
172 | enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME | |
173 | ||
e8526e3f JR |
174 | $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT \ |
175 | --sync-after-first-event ${file_sync_after_first} \ | |
176 | --sync-before-last-event ${file_sync_before_last} >/dev/null 2>&1 & | |
801236b0 JD |
177 | |
178 | start_lttng_tracing_ok $SESSION_NAME | |
179 | ||
180 | touch ${file_sync_before_last} | |
181 | ||
182 | # Wait for the applications started in background | |
183 | wait | |
eded6438 | 184 | regenerate_metadata_fail $SESSION_NAME |
801236b0 JD |
185 | |
186 | stop_lttng_tracing_ok $SESSION_NAME | |
187 | destroy_lttng_session_ok $SESSION_NAME | |
188 | # Validate test | |
189 | validate_trace $EVENT_NAME $TRACE_PATH | |
190 | if [ $? -eq 0 ]; then | |
191 | # Only delete if successful | |
192 | rm -rf $TRACE_PATH | |
193 | fi | |
194 | rm -f ${file_sync_after_first} | |
195 | rm -f ${file_sync_before_last} | |
196 | } | |
197 | ||
198 | plan_tests $NUM_TESTS | |
199 | ||
200 | print_test_banner "$TEST_DESC" | |
201 | ||
202 | start_lttng_relayd "-o $TRACE_PATH" | |
203 | start_lttng_sessiond | |
204 | ||
205 | tests=( test_ust_streaming test_ust_local test_ust_pid test_ust_live ) | |
206 | ||
207 | for fct_test in ${tests[@]}; | |
208 | do | |
209 | SESSION_NAME=$(randstring 16 0) | |
210 | ${fct_test} | |
211 | done | |
212 | ||
213 | stop_lttng_sessiond | |
214 | stop_lttng_relayd | |
215 | ||
216 | exit $out |