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