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