Enable support for installcheck.
[lttng-tools.git] / tests / regression / tools / snapshots / test_ust
CommitLineData
ebaaaf5e
JD
1#!/bin/bash
2#
3# Copyright (C) - 2013 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
17TEST_DESC="Snapshots - UST tracing"
18
19CURDIR=$(dirname $0)/
20TESTDIR=$CURDIR/../../..
21EVENT_NAME="tp:tptest"
ebaaaf5e
JD
22PID_RELAYD=0
23SESSION_NAME=""
24CHANNEL_NAME="snapchan"
25TESTAPP_PATH="$TESTDIR/utils/testapp"
26TESTAPP_NAME="gen-ust-events"
27TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
28NR_ITER=2000000
29NR_USEC_WAIT=100
30
31TRACE_PATH=$(mktemp -d)
32
a54047ec 33NUM_TESTS=2053
ebaaaf5e
JD
34
35source $TESTDIR/utils/utils.sh
36
37if [ ! -x "$TESTAPP_BIN" ]; then
38 BAIL_OUT "No UST events binary detected."
39fi
40
41function test_ust_local_snapshot ()
42{
43 diag "Test local UST snapshots"
44 create_lttng_session_no_output $SESSION_NAME
45 enable_lttng_mmap_overwrite_ust_channel $SESSION_NAME $CHANNEL_NAME
46 enable_ust_lttng_event $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
47 start_lttng_tracing $SESSION_NAME
48 lttng_snapshot_add_output $SESSION_NAME $TRACE_PATH
49 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
50 ok $? "Start application to trace"
51 lttng_snapshot_record $SESSION_NAME
52 stop_lttng_tracing $SESSION_NAME
53 destroy_lttng_session $SESSION_NAME
54
55 # Validate test
56 validate_trace $EVENT_NAME $TRACE_PATH/
57 if [ $? -eq 0 ]; then
58 # Only delete if successful
59 rm -rf $TRACE_PATH
60 else
61 break
62 fi
63 diag "Killing $TESTAPP_NAME"
64 PID_APP=`pidof $TESTAPP_NAME`
65 kill $PID_APP >/dev/null 2>&1
66}
67
a54047ec
JD
68function test_ust_local_snapshot_large_metadata ()
69{
70 LM_EVENT="tp:tptest1,tp:tptest2,tp:tptest3,tp:tptest4,tp:tptest5"
71 LM_PATH="$TESTDIR/utils/testapp"
72 LM_NAME="gen-ust-nevents"
73 LM_BIN="$LM_PATH/$LM_NAME/$LM_NAME"
74
75 diag "Test local UST snapshots with > 4kB metadata"
76 create_lttng_session_no_output $SESSION_NAME
77 enable_lttng_mmap_overwrite_ust_channel $SESSION_NAME $CHANNEL_NAME
78 enable_ust_lttng_event $SESSION_NAME $LM_EVENT $CHANNEL_NAME
79 start_lttng_tracing $SESSION_NAME
80 lttng_snapshot_add_output $SESSION_NAME $TRACE_PATH
81 $LM_BIN 1 1
82 ok $? "Start application to trace"
83 lttng_snapshot_record $SESSION_NAME
84 stop_lttng_tracing $SESSION_NAME
85 destroy_lttng_session $SESSION_NAME
86
87 # Validate test
88 validate_trace $LM_EVENT $TRACE_PATH/
89 if [ $? -eq 0 ]; then
90 # Only delete if successful
91 rm -rf $TRACE_PATH
92 else
93 break
94 fi
95}
96
5f4c2d80
JD
97function enable_channel_per_uid_mmap_overwrite()
98{
99 sess_name=$1
100 channel_name=$2
101
102 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel --buffers-uid -u $channel_name -s $sess_name --output mmap --overwrite >/dev/null 2>&1
103 ok $? "Enable channel $channel_name per UID for session $sess_name"
104}
105
106function test_ust_per_uid_local_snapshot ()
107{
108 diag "Test local UST snapshots"
109 create_lttng_session_no_output $SESSION_NAME
110 enable_channel_per_uid_mmap_overwrite $SESSION_NAME $CHANNEL_NAME
111 enable_ust_lttng_event $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
112 start_lttng_tracing $SESSION_NAME
113 lttng_snapshot_add_output $SESSION_NAME $TRACE_PATH
114 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
115 ok $? "Start application to trace"
116 lttng_snapshot_record $SESSION_NAME
117 stop_lttng_tracing $SESSION_NAME
118 destroy_lttng_session $SESSION_NAME
119
120 # Validate test
121 validate_trace $EVENT_NAME $TRACE_PATH/
122 if [ $? -eq 0 ]; then
123 # Only delete if successful
124 rm -rf $TRACE_PATH
125 else
126 break
127 fi
128 diag "Killing $TESTAPP_NAME"
129 PID_APP=`pidof $TESTAPP_NAME`
130 kill $PID_APP >/dev/null 2>&1
131}
132
4f03c06d
JD
133function test_ust_per_uid_local_snapshot_post_mortem ()
134{
135 diag "Test local UST snapshots post-mortem"
136 create_lttng_session_no_output $SESSION_NAME
137 enable_channel_per_uid_mmap_overwrite $SESSION_NAME $CHANNEL_NAME
138 enable_ust_lttng_event $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
139 start_lttng_tracing $SESSION_NAME
140 lttng_snapshot_add_output $SESSION_NAME $TRACE_PATH
141 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
142 ok $? "Start application to trace"
143 diag "Killing $TESTAPP_NAME"
144 PID_APP=`pidof $TESTAPP_NAME`
145 kill $PID_APP >/dev/null 2>&1
146 lttng_snapshot_record $SESSION_NAME
147 stop_lttng_tracing $SESSION_NAME
148 destroy_lttng_session $SESSION_NAME
149
150 # Validate test
151 validate_trace $EVENT_NAME $TRACE_PATH/
152 if [ $? -eq 0 ]; then
153 # Only delete if successful
154 rm -rf $TRACE_PATH
155 else
156 break
157 fi
158}
159
ebaaaf5e
JD
160function test_ust_1000_local_snapshots ()
161{
162 NB_SNAP=1000
163
164 diag "Test $NB_SNAP local UST snapshots"
165 create_lttng_session_no_output $SESSION_NAME
166 enable_lttng_mmap_overwrite_ust_channel $SESSION_NAME $CHANNEL_NAME
167 enable_ust_lttng_event $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
168 start_lttng_tracing $SESSION_NAME
169 lttng_snapshot_add_output $SESSION_NAME $TRACE_PATH
170 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
171 for i in $(seq 1 $NB_SNAP); do
172 diag "Snapshot $i/$NB_SNAP"
173 rm -rf $TRACE_PATH/snapshot/* 2>/dev/null
174 lttng_snapshot_record $SESSION_NAME
175 # Validate test
176 validate_trace $EVENT_NAME $TRACE_PATH/
177 if [ $? -eq 0 ]; then
178 # Only delete if successful
179 rm -rf $TRACE_PATH
180 else
181 break
182 fi
183 done
184 stop_lttng_tracing $SESSION_NAME
185 destroy_lttng_session $SESSION_NAME
186 diag "Killing $TESTAPP_NAME"
187 PID_APP=`pidof $TESTAPP_NAME`
7f12ef5d 188 kill $PID_APP >/dev/null 2>&1
ebaaaf5e
JD
189}
190
191plan_tests $NUM_TESTS
192
193print_test_banner "$TEST_DESC"
194
195if [ "$(id -u)" == "0" ]; then
196 isroot=1
197else
198 isroot=0
199fi
200
201start_lttng_sessiond
202
4f03c06d
JD
203tests=( test_ust_local_snapshot \
204 test_ust_per_uid_local_snapshot \
205 test_ust_per_uid_local_snapshot_post_mortem \
a54047ec 206 test_ust_local_snapshot_large_metadata \
4f03c06d 207 test_ust_1000_local_snapshots )
ebaaaf5e
JD
208
209for fct_test in ${tests[@]};
210do
211 SESSION_NAME=$(randstring 16 0)
212 ${fct_test}
213
214done
215
216stop_lttng_sessiond
This page took 0.044152 seconds and 5 git commands to generate.