Gen-ust-events: use options instead of arguments
[lttng-tools.git] / tests / regression / ust / rotation-destroy-flush / test_rotation_destroy_flush
CommitLineData
ced06804
MD
1#!/bin/bash
2#
3# Copyright (C) - 2015 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
4# Copyright (C) - 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5#
6# This library is free software; you can redistribute it and/or modify it under
7# the terms of the GNU Lesser General Public License as published by the Free
8# Software Foundation; version 2.1 of the License.
9#
10# This library is distributed in the hope that it will be useful, but WITHOUT
11# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13# details.
14#
15# You should have received a copy of the GNU Lesser General Public License
16# along with this library; if not, write to the Free Software Foundation, Inc.,
17# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18TEST_DESC="UST - Rotation destroy flush"
19
20CURDIR=$(dirname $0)/
21TESTDIR=$CURDIR/../../..
22SESSION_NAME="rotation_destroy_flush"
23
24TESTAPP_PATH="$TESTDIR/utils/testapp"
25TESTAPP_NAME="gen-ust-events"
26TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
27NUM_EVENT=1000000
28EVENT_NAME="tp:tptest"
29CHANNEL_NAME="testchan"
30PAGE_SIZE=$(getconf PAGE_SIZE)
31SIZE_LIMIT=$PAGE_SIZE
32
33NR_ITER=10
34NUM_TESTS=$((15*$NR_ITER))
35
36# Ensure the daemons invoke abort on error.
37export LTTNG_ABORT_ON_ERROR=1
38
39source $TESTDIR/utils/utils.sh
40
41# MUST set TESTDIR before calling those functions
42function run_app()
43{
a4c30524 44 $TESTAPP_BIN -i $NUM_EVENT
ced06804
MD
45 ok $? "Application done"
46}
47
48function signal_cleanup()
49{
50 diag "*** Exiting ***"
51 stop_lttng_sessiond
52 exit 1
53}
54
55function enable_ust_lttng_channel_size_limit ()
56{
57 sess_name="$1"
58 channel_name="$2"
59 tracefile_size_limit="$3"
60
61 test_name="Enable channel $channel_name "
62 test_name+="for session $sess_name: "
63 test_name+="$tracefile_size_limit bytes tracefile limit"
64
65 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel \
66 -u $channel_name -s $sess_name --buffers-pid \
67 -C $tracefile_size_limit >/dev/null 2>&1
68
69 ok $? "$test_name"
70}
71
72function enable_ust_lttng_event_per_channel ()
73{
74 sess_name="$1"
75 event_name="$2"
76 channel_name="$3"
77
78 test_name="Enable event $event_name "
79 test_name+="for session $sess_name "
80 test_name+="in channel $channel_name"
81
82 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" \
83 -s $sess_name -u -c $channel_name >/dev/null 2>&1
84
85 ok $? "$test_name"
86}
87
88function test_rotation_destroy_flush_single()
89{
90 start_lttng_sessiond
91
92 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
93 enable_ust_lttng_channel_size_limit \
94 $SESSION_NAME $CHANNEL_NAME $SIZE_LIMIT
95 enable_ust_lttng_event_per_channel \
96 $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
97 start_lttng_tracing_ok $SESSION_NAME
98 run_app
99 # stop and destroy
100 stop_lttng_tracing_ok $SESSION_NAME
101 destroy_lttng_session_ok $SESSION_NAME
102
103 rm -rf $TRACE_PATH
104
105 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
106 enable_ust_lttng_channel_size_limit \
107 $SESSION_NAME $CHANNEL_NAME $SIZE_LIMIT
108 enable_ust_lttng_event_per_channel \
109 $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
110 start_lttng_tracing_ok $SESSION_NAME
111 run_app
112 # destroy only
113 destroy_lttng_session_ok $SESSION_NAME
114
115 rm -rf $TRACE_PATH
116
117 stop_lttng_sessiond
118}
119
120function test_rotation_destroy_flush()
121{
122 for a in $(seq 1 ${NR_ITER}); do
123 diag "Iteration ${a}/${NR_ITER}"
124 test_rotation_destroy_flush_single
125 done
126}
127
128
129plan_tests $NUM_TESTS
130
131print_test_banner "$TEST_DESC"
132
133TESTS=(
134 "test_rotation_destroy_flush"
135)
136
137TEST_COUNT=${#TESTS[@]}
138i=0
139
140while [ "$i" -lt "$TEST_COUNT" ]; do
141
142 trap signal_cleanup SIGTERM SIGINT
143
144 TRACE_PATH=$(mktemp -d)
145
146 # Execute test
147 ${TESTS[$i]}
148
149 let "i++"
150done
This page took 0.054009 seconds and 5 git commands to generate.