Fix: keep metadata channel attr in UST session
[lttng-tools.git] / tests / regression / tools / snapshots / test_ust_streaming
CommitLineData
ebaaaf5e
JD
1#!/bin/bash
2#
3# Copyright (C) - 2013 David Goulet <dgoulet@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
17TEST_DESC="Streaming - Snapshot UST tracing"
18
19CURDIR=$(dirname $0)/
20TESTDIR=$CURDIR/../../..
21EVENT_NAME="tp:tptest"
22PID_RELAYD=0
23SESSION_NAME=""
24CHANNEL_NAME="chan1"
25BIN_NAME="gen-nevents"
26TESTAPP_PATH="$TESTDIR/utils/testapp"
27TESTAPP_NAME="gen-ust-events"
28TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
29NR_ITER=2000000
30NR_USEC_WAIT=100
31
32TRACE_PATH=$(mktemp -d)
33
847b88a9 34NUM_TESTS=49
ebaaaf5e
JD
35
36source $TESTDIR/utils/utils.sh
37
38if [ ! -x "$TESTAPP_BIN" ]; then
39 BAIL_OUT "No UST events binary detected."
40fi
41
42function snapshot_add_output ()
43{
44 local sess_name=$1
45 local trace_path=$2
46 local name=$3
47 local extra_opt=""
48
49 if [ ! -z $name ]; then
50 extra_opt="-n $name"
51 fi
52
53 $TESTDIR/../src/bin/lttng/$LTTNG_BIN snapshot add-output -s $sess_name $extra_opt $trace_path >/dev/null 2>&1
54 ok $? "Added snapshot output $trace_path"
55}
56
57# Test a snapshot using a default name for the output destination.
58function test_ust_default_name_with_del()
59{
60 diag "Test UST snapshot streaming with default name with delete output"
61 create_lttng_session_no_output $SESSION_NAME
62 enable_lttng_mmap_overwrite_ust_channel $SESSION_NAME $CHANNEL_NAME
63 enable_ust_lttng_event $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
64 start_lttng_tracing $SESSION_NAME
65 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
66 ok $? "Start application to trace"
67 snapshot_add_output $SESSION_NAME "net://localhost"
68 lttng_snapshot_record $SESSION_NAME
69
70 # Validate test
71 echo $TRACE_PATH/$HOSTNAME/snapshot-1
72 validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/snapshot-1*
73 if [ $? -ne 0 ]; then
74 return $?
75 fi
76
77 lttng_snapshot_del_output $SESSION_NAME 1
78 snapshot_add_output $SESSION_NAME "net://localhost"
79 lttng_snapshot_record $SESSION_NAME
80
81 # Validate test with the next ID since a del output was done prior.
82 validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/snapshot-2*
83 if [ $? -ne 0 ]; then
84 return $?
85 fi
86
87 stop_lttng_tracing $SESSION_NAME
88 destroy_lttng_session $SESSION_NAME
89
90 diag "Killing $TESTAPP_NAME"
91 PID_APP=`pidof $TESTAPP_NAME`
92 kill $PID_APP >/dev/null 2>&1
93
94 return 0
95}
96
97# Test a snapshot using a default name for the output destination.
98function test_ust_default_name()
99{
100 diag "Test UST snapshot streaming with default name"
101 create_lttng_session_no_output $SESSION_NAME
102 enable_lttng_mmap_overwrite_ust_channel $SESSION_NAME $CHANNEL_NAME
103 enable_ust_lttng_event $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
104 start_lttng_tracing $SESSION_NAME
105 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
106 ok $? "Start application to trace"
107 snapshot_add_output $SESSION_NAME "net://localhost"
108 lttng_snapshot_record $SESSION_NAME
109 stop_lttng_tracing $SESSION_NAME
110 destroy_lttng_session $SESSION_NAME
111 # Validate test
112 validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/snapshot-1*
113 out=$?
114
115 diag "Killing $TESTAPP_NAME"
116 PID_APP=`pidof $TESTAPP_NAME`
117 kill $PID_APP >/dev/null 2>&1
118
119 return $out
120}
121
847b88a9
CB
122function test_ust_default_name_custom_uri()
123{
124 diag "Test UST snapshot streaming with default name with custom URL"
125 create_lttng_session_no_output $SESSION_NAME
126 enable_lttng_mmap_overwrite_ust_channel $SESSION_NAME $CHANNEL_NAME
127 enable_ust_lttng_event $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
128 start_lttng_tracing $SESSION_NAME
129 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
130 ok $? "Start application to trace"
131 snapshot_add_output $SESSION_NAME "-C tcp://localhost:5342 -D tcp://localhost:5343"
132 lttng_snapshot_record $SESSION_NAME
133 stop_lttng_tracing $SESSION_NAME
134 destroy_lttng_session $SESSION_NAME
135 # Validate test
136 validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/snapshot-1*
137 out=$?
138
139 diag "Killing $TESTAPP_NAME"
140 PID_APP=`pidof $TESTAPP_NAME`
141 kill $PID_APP >/dev/null 2>&1
142
143 return $out
144}
145
ebaaaf5e
JD
146# Test a snapshot using a custom name for the output destination.
147function test_ust_custom_name()
148{
149 local out
150 local name="asnapshotname"
151
152 diag "Test UST snapshot streaming with custom name"
153 create_lttng_session_no_output $SESSION_NAME
154 enable_lttng_mmap_overwrite_ust_channel $SESSION_NAME $CHANNEL_NAME
155 enable_ust_lttng_event $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
156 start_lttng_tracing $SESSION_NAME
157 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
158 ok $? "Start application to trace"
159 snapshot_add_output $SESSION_NAME "net://localhost" $name
160 lttng_snapshot_record $SESSION_NAME
161 stop_lttng_tracing $SESSION_NAME
162 destroy_lttng_session $SESSION_NAME
163
164 if ls $TRACE_PATH/$HOSTNAME/$name* &> /dev/null; then
165 ok 0 "Custom name snapshot exists"
166 # Validate test
167 validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$name-*
168 out=$?
169 else
170 fail "No custom name snapshot found"
171 out=1
172 fi
173
174 diag "Killing $TESTAPP_NAME"
175 PID_APP=`pidof $TESTAPP_NAME`
176 kill $PID_APP >/dev/null 2>&1
177
178 return $out
179}
180
181plan_tests $NUM_TESTS
182
183print_test_banner "$TEST_DESC"
184
185if [ "$(id -u)" == "0" ]; then
186 isroot=1
187else
188 isroot=0
189fi
190
191start_lttng_relayd "-o $TRACE_PATH"
192start_lttng_sessiond
193
847b88a9 194tests=( test_ust_default_name_with_del test_ust_default_name test_ust_custom_name test_ust_default_name_custom_uri )
ebaaaf5e
JD
195
196for fct_test in ${tests[@]};
197do
198 SESSION_NAME=$(randstring 16 0)
199 ${fct_test}
200 if [ $? -eq 0 ]; then
201 # Only delete if successful
202 rm -rf $TRACE_PATH
203 else
204 break
205 fi
206done
207
208stop_lttng_sessiond
209stop_lttng_relayd
This page took 0.035763 seconds and 5 git commands to generate.