Move completed trace archive chunks to an "archives" sub-folder
[lttng-tools.git] / tests / regression / tools / rotation / test_kernel
CommitLineData
e7716c6a
JD
1#!/bin/bash
2#
3# Copyright (C) - 2017 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="Rotation - Kernel tracing"
18
19CURDIR=$(dirname $0)/
20TESTDIR=$CURDIR/../../..
21EVENT_NAME="lttng_test_filter_event"
e7716c6a
JD
22
23TRACE_PATH=$(mktemp -d)
24
36e66320 25NUM_TESTS=64
e7716c6a
JD
26
27source $TESTDIR/utils/utils.sh
28source $CURDIR/rotate_utils.sh
29
e7716c6a
JD
30function rotate_kernel_test ()
31{
32 local_path=$1
33
34 lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME
35 start_lttng_tracing_ok $SESSION_NAME
36
37 today=$(date +%Y%m%d)
38 # First chunk contains 10 events.
39 echo -n "10" > /proc/lttng-test-filter-event
40 rotate_session_ok $SESSION_NAME
41
42 # Second chunk contains 20 events.
43 echo -n "20" > /proc/lttng-test-filter-event
44 stop_lttng_tracing_ok $SESSION_NAME
45
46 # Third chunk contains no event (rotate after stop).
47 rotate_session_ok $SESSION_NAME
48
49 destroy_lttng_session_ok $SESSION_NAME
50
e7716c6a
JD
51 validate_test_chunks $local_path $today kernel kernel 0
52}
53
54function test_kernel_streaming ()
55{
56 diag "Test kernel streaming with session rotation"
f0d43d3d 57 create_lttng_session_uri $SESSION_NAME net://localhost
3b33e9e7 58 rotate_kernel_test "${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*/archives"
e7716c6a
JD
59}
60
61function test_kernel_local ()
62{
63 diag "Test kernel local with session rotation"
64 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
65
3b33e9e7 66 rotate_kernel_test "${TRACE_PATH}/archives"
e7716c6a
JD
67}
68
69function test_kernel_local_timer ()
70{
71 diag "Test kernel local with session rotation timer"
72 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
73 lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME
74 lttng_enable_rotation_timer_ok $SESSION_NAME 500ms
75 start_lttng_tracing_ok $SESSION_NAME
76
3b33e9e7 77 rotate_timer_test "${TRACE_PATH}/archives" 0
e7716c6a
JD
78}
79
80function test_kernel_streaming_timer ()
81{
82 diag "Test kernel remote with session rotation timer"
f0d43d3d 83 create_lttng_session_uri $SESSION_NAME net://localhost
e7716c6a
JD
84 lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME
85 lttng_enable_rotation_timer_ok $SESSION_NAME 500ms
86 start_lttng_tracing_ok $SESSION_NAME
87
3b33e9e7 88 rotate_timer_test "${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*/archives" 0
e7716c6a
JD
89}
90
91plan_tests $NUM_TESTS
92
93print_test_banner "$TEST_DESC"
94
95if [ "$(id -u)" == "0" ]; then
96 isroot=1
97else
98 isroot=0
99fi
100
101skip $isroot "Root access is needed. Skipping all kernel streaming tests." $NUM_TESTS ||
102{
9c8a3964
JR
103 validate_lttng_modules_present
104
e7716c6a
JD
105 start_lttng_relayd "-o $TRACE_PATH"
106 start_lttng_sessiond
107 modprobe lttng-test
108
109 tests=( test_kernel_streaming test_kernel_local test_kernel_local_timer test_kernel_streaming_timer)
110
111 for fct_test in ${tests[@]};
112 do
113 SESSION_NAME=$(randstring 16 0)
114 ${fct_test}
8f2d0517 115 clean_path $TRACE_PATH
e7716c6a
JD
116 done
117
118 rmmod lttng-test
119 stop_lttng_sessiond
120 stop_lttng_relayd
121}
9dc506ae
JR
122
123rm -rf $TRACE_PATH
This page took 0.028811 seconds and 4 git commands to generate.