Tests: fix shellcheck warning
[lttng-tools.git] / tests / regression / tools / base-path / test_ust
CommitLineData
2a166864
MD
1#!/bin/bash
2#
3# Copyright (C) - 2019 Mathieu Desnoyers <mathieu.desnoyers@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 Base Path Override - User space tracing"
18
3c3c7935 19CURDIR=$(dirname "$0")/
2a166864 20TESTDIR=$CURDIR/../../..
2a166864
MD
21TESTAPP_PATH="$TESTDIR/utils/testapp"
22TESTAPP_NAME="gen-ust-events"
23TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
24EVENT_NAME="tp:tptest"
25
26TRACE_PATH=$(mktemp -d)
27
ac29b2c7 28NUM_TESTS=37
2a166864 29
3c3c7935 30source "$TESTDIR/utils/utils.sh"
2a166864
MD
31
32if [ ! -x "$TESTAPP_BIN" ]; then
33 BAIL_OUT "No UST events binary detected."
34fi
35
36function ust_app_stream_base_path ()
37{
3c3c7935 38 local session_name="ust_app_stream_base_path"
2a166864
MD
39 local base_path="my/custom/path1"
40
41 diag "Test base path override for trace streaming"
42 create_lttng_session_uri $session_name net://localhost/$base_path
43 enable_ust_lttng_event_ok $session_name $EVENT_NAME
44
45 start_lttng_tracing_ok $session_name
46
47 $TESTAPP_BIN > /dev/null 2>&1
48
49 stop_lttng_tracing_ok $session_name
50 destroy_lttng_session_ok $session_name
51
52 # validate test
3c3c7935 53 if validate_trace $EVENT_NAME "$TRACE_PATH/$HOSTNAME/$base_path"; then
2a166864 54 # only delete if successful
3c3c7935 55 rm -rf "$TRACE_PATH"
2a166864
MD
56 fi
57}
58
59function ust_app_snapshot_create_base_path ()
60{
3c3c7935 61 local session_name="ust_app_snapshot_create_base_path"
2a166864
MD
62 local base_path="my/custom/path2"
63
64 diag "Test base path override for remote trace snapshot (URI on create)"
65 create_lttng_session_uri $session_name net://localhost/$base_path \
66 --snapshot
67 enable_ust_lttng_event_ok $session_name $EVENT_NAME
68
69 start_lttng_tracing_ok $session_name
70
71 $TESTAPP_BIN > /dev/null 2>&1
72
73 stop_lttng_tracing_ok $session_name
74
75 lttng_snapshot_record $session_name
76
77 destroy_lttng_session_ok $session_name
78
79 # validate test
3c3c7935 80 if validate_trace $EVENT_NAME "$TRACE_PATH/$HOSTNAME/$base_path"; then
2a166864 81 # only delete if successful
3c3c7935 82 rm -rf "$TRACE_PATH"
2a166864
MD
83 fi
84}
85
86function ust_app_snapshot_base_path ()
87{
3c3c7935 88 local session_name="ust_app_snapshot_base_path"
2a166864
MD
89 local base_path="my/custom/path3"
90
91 diag "Test base path override for remote trace snapshot (URI on snapshot)"
92 create_lttng_session_no_output $session_name --snapshot
93 enable_ust_lttng_event_ok $session_name $EVENT_NAME
94
95 start_lttng_tracing_ok $session_name
96
97 $TESTAPP_BIN > /dev/null 2>&1
98
99 stop_lttng_tracing_ok $session_name
100
101 lttng_snapshot_record $session_name net://localhost/$base_path
102
103 destroy_lttng_session_ok $session_name
104
105 # validate test
3c3c7935 106 if validate_trace $EVENT_NAME "$TRACE_PATH/$HOSTNAME/$base_path"; then
2a166864 107 # only delete if successful
3c3c7935 108 rm -rf "$TRACE_PATH"
2a166864
MD
109 fi
110}
111
112function ust_app_snapshot_add_output_base_path ()
113{
3c3c7935 114 local session_name="ust_app_snapshot_add_output_base_path"
ac29b2c7 115 local base_path="my/custom/path4"
2a166864
MD
116
117 diag "Test base path override for remote trace snapshot (URI on add-output)"
118 create_lttng_session_no_output $session_name --snapshot
119 enable_ust_lttng_event_ok $session_name $EVENT_NAME
120
121 start_lttng_tracing_ok $session_name
122
123 $TESTAPP_BIN > /dev/null 2>&1
124
125 stop_lttng_tracing_ok $session_name
126
127 lttng_snapshot_add_output_ok $session_name net://localhost/$base_path
128 lttng_snapshot_record $session_name
129
130 destroy_lttng_session_ok $session_name
131
132 # validate test
3c3c7935 133 if validate_trace $EVENT_NAME "$TRACE_PATH/$HOSTNAME/$base_path"; then
2a166864 134 # only delete if successful
3c3c7935 135 rm -rf "$TRACE_PATH"
2a166864
MD
136 fi
137}
138
ac29b2c7
JR
139function ust_app_stream_base_path_via_load ()
140{
141 local session_name="load-stream-extra-path"
142 local base_path="my/custom/path5"
143
144 diag "Test base path override for trace streaming using lttng load"
145 lttng_load_ok "-i $CURDIR/$session_name.lttng"
146 start_lttng_tracing_ok $session_name
147
148 $TESTAPP_BIN > /dev/null 2>&1
149
150 stop_lttng_tracing_ok $session_name
151 destroy_lttng_session_ok $session_name
152
153 # validate test
154 if validate_trace $EVENT_NAME "$TRACE_PATH/$HOSTNAME/$base_path"; then
155 # only delete if successful
156 rm -rf "$TRACE_PATH"
157 fi
158}
159
2a166864
MD
160plan_tests $NUM_TESTS
161
162print_test_banner "$TEST_DESC"
163
164start_lttng_relayd "-o $TRACE_PATH"
165start_lttng_sessiond
166
167tests=( ust_app_stream_base_path
168 ust_app_snapshot_create_base_path
169 ust_app_snapshot_base_path
ac29b2c7
JR
170 ust_app_snapshot_add_output_base_path
171 ust_app_stream_base_path_via_load
172)
3c3c7935 173for fct_test in "${tests[@]}";
2a166864
MD
174do
175 ${fct_test}
176done
177
178stop_lttng_sessiond
179stop_lttng_relayd
This page took 0.047091 seconds and 4 git commands to generate.