f1b967505222e01bd2576546124b50d7953fd09e
[lttng-tools.git] / tests / regression / tools / regen-metadata / test_ust
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
29 TRACE_PATH=$(mktemp -d)
30
31 NUM_TESTS=33
32
33 source $TESTDIR/utils/utils.sh
34
35 if [ ! -x "$TESTAPP_BIN" ]; then
36 BAIL_OUT "No UST events binary detected."
37 fi
38
39 function enable_channel_per_pid()
40 {
41 sess_name=$1
42 channel_name=$2
43
44 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel --buffers-pid -u $channel_name -s $sess_name >/dev/null 2>&1
45 ok $? "Enable channel $channel_name per PID for session $sess_name"
46 }
47
48 # MUST set TESTDIR before calling those functions
49
50 function test_ust_streaming ()
51 {
52 local file_sync_after_first=$(mktemp -u)
53 local file_sync_before_last=$(mktemp -u)
54
55 diag "Test UST streaming with metadata regeneration"
56 create_lttng_session_uri $SESSION_NAME net://localhost
57 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
58
59 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} ${file_sync_before_last} /dev/null 2>&1 &
60
61 start_lttng_tracing_ok $SESSION_NAME
62
63 touch ${file_sync_before_last}
64
65 # Wait for the applications started in background
66 wait
67 regenerate_metadata_ok $SESSION_NAME
68
69 stop_lttng_tracing_ok $SESSION_NAME
70 destroy_lttng_session_ok $SESSION_NAME
71 # Validate test
72 validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME*
73 if [ $? -eq 0 ]; then
74 # Only delete if successful
75 rm -rf $TRACE_PATH
76 fi
77 rm -f ${file_sync_after_first}
78 rm -f ${file_sync_before_last}
79 }
80
81 function test_ust_local ()
82 {
83 local file_sync_after_first=$(mktemp -u)
84 local file_sync_before_last=$(mktemp -u)
85
86 diag "Test UST local with metadata regeneration"
87 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
88 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
89
90 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} ${file_sync_before_last} /dev/null 2>&1 &
91
92 start_lttng_tracing_ok $SESSION_NAME
93
94 touch ${file_sync_before_last}
95
96 # Wait for the applications started in background
97 wait
98 regenerate_metadata_ok $SESSION_NAME
99
100 stop_lttng_tracing_ok $SESSION_NAME
101 destroy_lttng_session_ok $SESSION_NAME
102 # Validate test
103 validate_trace $EVENT_NAME $TRACE_PATH
104 if [ $? -eq 0 ]; then
105 # Only delete if successful
106 rm -rf $TRACE_PATH
107 fi
108 rm -f ${file_sync_after_first}
109 rm -f ${file_sync_before_last}
110 }
111
112 function test_ust_pid ()
113 {
114 local file_sync_after_first=$(mktemp -u)
115 local file_sync_before_last=$(mktemp -u)
116
117 diag "Test UST per-pid with metadata regeneration (expect failure)"
118 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
119 enable_channel_per_pid $SESSION_NAME "channel0"
120 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME "channel0"
121
122 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} ${file_sync_before_last} /dev/null 2>&1 &
123
124 start_lttng_tracing_ok $SESSION_NAME
125
126 touch ${file_sync_before_last}
127
128 # Wait for the applications started in background
129 wait
130 regenerate_metadata_fail $SESSION_NAME
131
132 stop_lttng_tracing_ok $SESSION_NAME
133 destroy_lttng_session_ok $SESSION_NAME
134 # Validate test
135 validate_trace $EVENT_NAME $TRACE_PATH
136 if [ $? -eq 0 ]; then
137 # Only delete if successful
138 rm -rf $TRACE_PATH
139 fi
140 rm -f ${file_sync_after_first}
141 rm -f ${file_sync_before_last}
142 }
143
144 function test_ust_live ()
145 {
146 local file_sync_after_first=$(mktemp -u)
147 local file_sync_before_last=$(mktemp -u)
148
149 diag "Test UST live with metadata regeneration (expect failure)"
150 create_lttng_session_uri $SESSION_NAME net://localhost --live
151 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
152
153 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} ${file_sync_before_last} /dev/null 2>&1 &
154
155 start_lttng_tracing_ok $SESSION_NAME
156
157 touch ${file_sync_before_last}
158
159 # Wait for the applications started in background
160 wait
161 regenerate_metadata_fail $SESSION_NAME
162
163 stop_lttng_tracing_ok $SESSION_NAME
164 destroy_lttng_session_ok $SESSION_NAME
165 # Validate test
166 validate_trace $EVENT_NAME $TRACE_PATH
167 if [ $? -eq 0 ]; then
168 # Only delete if successful
169 rm -rf $TRACE_PATH
170 fi
171 rm -f ${file_sync_after_first}
172 rm -f ${file_sync_before_last}
173 }
174
175 plan_tests $NUM_TESTS
176
177 print_test_banner "$TEST_DESC"
178
179 start_lttng_relayd "-o $TRACE_PATH"
180 start_lttng_sessiond
181
182 tests=( test_ust_streaming test_ust_local test_ust_pid test_ust_live )
183
184 for fct_test in ${tests[@]};
185 do
186 SESSION_NAME=$(randstring 16 0)
187 ${fct_test}
188 done
189
190 stop_lttng_sessiond
191 stop_lttng_relayd
192
193 exit $out
This page took 0.049649 seconds and 4 git commands to generate.