Add test application with large metadata
[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"
22BIN_NAME="gen-nevents"
23PID_RELAYD=0
24SESSION_NAME=""
25CHANNEL_NAME="snapchan"
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
4f03c06d 34NUM_TESTS=2039
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 test_ust_local_snapshot ()
43{
44 diag "Test local UST snapshots"
45 create_lttng_session_no_output $SESSION_NAME
46 enable_lttng_mmap_overwrite_ust_channel $SESSION_NAME $CHANNEL_NAME
47 enable_ust_lttng_event $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
48 start_lttng_tracing $SESSION_NAME
49 lttng_snapshot_add_output $SESSION_NAME $TRACE_PATH
50 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
51 ok $? "Start application to trace"
52 lttng_snapshot_record $SESSION_NAME
53 stop_lttng_tracing $SESSION_NAME
54 destroy_lttng_session $SESSION_NAME
55
56 # Validate test
57 validate_trace $EVENT_NAME $TRACE_PATH/
58 if [ $? -eq 0 ]; then
59 # Only delete if successful
60 rm -rf $TRACE_PATH
61 else
62 break
63 fi
64 diag "Killing $TESTAPP_NAME"
65 PID_APP=`pidof $TESTAPP_NAME`
66 kill $PID_APP >/dev/null 2>&1
67}
68
5f4c2d80
JD
69function enable_channel_per_uid_mmap_overwrite()
70{
71 sess_name=$1
72 channel_name=$2
73
74 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel --buffers-uid -u $channel_name -s $sess_name --output mmap --overwrite >/dev/null 2>&1
75 ok $? "Enable channel $channel_name per UID for session $sess_name"
76}
77
78function test_ust_per_uid_local_snapshot ()
79{
80 diag "Test local UST snapshots"
81 create_lttng_session_no_output $SESSION_NAME
82 enable_channel_per_uid_mmap_overwrite $SESSION_NAME $CHANNEL_NAME
83 enable_ust_lttng_event $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
84 start_lttng_tracing $SESSION_NAME
85 lttng_snapshot_add_output $SESSION_NAME $TRACE_PATH
86 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
87 ok $? "Start application to trace"
88 lttng_snapshot_record $SESSION_NAME
89 stop_lttng_tracing $SESSION_NAME
90 destroy_lttng_session $SESSION_NAME
91
92 # Validate test
93 validate_trace $EVENT_NAME $TRACE_PATH/
94 if [ $? -eq 0 ]; then
95 # Only delete if successful
96 rm -rf $TRACE_PATH
97 else
98 break
99 fi
100 diag "Killing $TESTAPP_NAME"
101 PID_APP=`pidof $TESTAPP_NAME`
102 kill $PID_APP >/dev/null 2>&1
103}
104
4f03c06d
JD
105function test_ust_per_uid_local_snapshot_post_mortem ()
106{
107 diag "Test local UST snapshots post-mortem"
108 create_lttng_session_no_output $SESSION_NAME
109 enable_channel_per_uid_mmap_overwrite $SESSION_NAME $CHANNEL_NAME
110 enable_ust_lttng_event $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
111 start_lttng_tracing $SESSION_NAME
112 lttng_snapshot_add_output $SESSION_NAME $TRACE_PATH
113 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
114 ok $? "Start application to trace"
115 diag "Killing $TESTAPP_NAME"
116 PID_APP=`pidof $TESTAPP_NAME`
117 kill $PID_APP >/dev/null 2>&1
118 lttng_snapshot_record $SESSION_NAME
119 stop_lttng_tracing $SESSION_NAME
120 destroy_lttng_session $SESSION_NAME
121
122 # Validate test
123 validate_trace $EVENT_NAME $TRACE_PATH/
124 if [ $? -eq 0 ]; then
125 # Only delete if successful
126 rm -rf $TRACE_PATH
127 else
128 break
129 fi
130}
131
ebaaaf5e
JD
132function test_ust_1000_local_snapshots ()
133{
134 NB_SNAP=1000
135
136 diag "Test $NB_SNAP local UST snapshots"
137 create_lttng_session_no_output $SESSION_NAME
138 enable_lttng_mmap_overwrite_ust_channel $SESSION_NAME $CHANNEL_NAME
139 enable_ust_lttng_event $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
140 start_lttng_tracing $SESSION_NAME
141 lttng_snapshot_add_output $SESSION_NAME $TRACE_PATH
142 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT &
143 for i in $(seq 1 $NB_SNAP); do
144 diag "Snapshot $i/$NB_SNAP"
145 rm -rf $TRACE_PATH/snapshot/* 2>/dev/null
146 lttng_snapshot_record $SESSION_NAME
147 # Validate test
148 validate_trace $EVENT_NAME $TRACE_PATH/
149 if [ $? -eq 0 ]; then
150 # Only delete if successful
151 rm -rf $TRACE_PATH
152 else
153 break
154 fi
155 done
156 stop_lttng_tracing $SESSION_NAME
157 destroy_lttng_session $SESSION_NAME
158 diag "Killing $TESTAPP_NAME"
159 PID_APP=`pidof $TESTAPP_NAME`
160# kill $PID_APP >/dev/null 2>&1
161}
162
163plan_tests $NUM_TESTS
164
165print_test_banner "$TEST_DESC"
166
167if [ "$(id -u)" == "0" ]; then
168 isroot=1
169else
170 isroot=0
171fi
172
173start_lttng_sessiond
174
4f03c06d
JD
175tests=( test_ust_local_snapshot \
176 test_ust_per_uid_local_snapshot \
177 test_ust_per_uid_local_snapshot_post_mortem \
178 test_ust_1000_local_snapshots )
ebaaaf5e
JD
179
180for fct_test in ${tests[@]};
181do
182 SESSION_NAME=$(randstring 16 0)
183 ${fct_test}
184
185done
186
187stop_lttng_sessiond
This page took 0.031723 seconds and 5 git commands to generate.