Tests: consolidate session creation with a uri parameter in utils.sh
[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"
22PID_RELAYD=0
23SESSION_NAME=""
24
25TRACE_PATH=$(mktemp -d)
26
27NUM_TESTS=68
28
29source $TESTDIR/utils/utils.sh
30source $CURDIR/rotate_utils.sh
31
e7716c6a
JD
32function rotate_kernel_test ()
33{
34 local_path=$1
35
36 lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME
37 start_lttng_tracing_ok $SESSION_NAME
38
39 today=$(date +%Y%m%d)
40 # First chunk contains 10 events.
41 echo -n "10" > /proc/lttng-test-filter-event
42 rotate_session_ok $SESSION_NAME
43
44 # Second chunk contains 20 events.
45 echo -n "20" > /proc/lttng-test-filter-event
46 stop_lttng_tracing_ok $SESSION_NAME
47
48 # Third chunk contains no event (rotate after stop).
49 rotate_session_ok $SESSION_NAME
50
51 destroy_lttng_session_ok $SESSION_NAME
52
53 # The tests on the chunk folder rely on the date staying the same during
54 # the duration of the test, if this fail we will now why the other checks
55 # fail afterwards. There is a short window of time where an automated test
56 # could fail because of that.
57 now=$(date +%Y%m%d)
58 test $today = $now
59 ok $? "Date did not change during the test"
60
61 validate_test_chunks $local_path $today kernel kernel 0
62}
63
64function test_kernel_streaming ()
65{
66 diag "Test kernel streaming with session rotation"
f0d43d3d 67 create_lttng_session_uri $SESSION_NAME net://localhost
e7716c6a 68 rotate_kernel_test "${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
9dc506ae 69 clean_path $TRACE_PATH
e7716c6a
JD
70}
71
72function test_kernel_local ()
73{
74 diag "Test kernel local with session rotation"
75 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
76
77 rotate_kernel_test "${TRACE_PATH}"
78}
79
80function test_kernel_local_timer ()
81{
82 diag "Test kernel local with session rotation timer"
83 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
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
88 rotate_timer_test "${TRACE_PATH}" 0
89}
90
91function test_kernel_streaming_timer ()
92{
93 diag "Test kernel remote with session rotation timer"
f0d43d3d 94 create_lttng_session_uri $SESSION_NAME net://localhost
e7716c6a
JD
95 lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME
96 lttng_enable_rotation_timer_ok $SESSION_NAME 500ms
97 start_lttng_tracing_ok $SESSION_NAME
98
99 rotate_timer_test "${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" 0
9dc506ae 100 clean_path $TRACE_PATH
e7716c6a
JD
101}
102
103plan_tests $NUM_TESTS
104
105print_test_banner "$TEST_DESC"
106
107if [ "$(id -u)" == "0" ]; then
108 isroot=1
109else
110 isroot=0
111fi
112
113skip $isroot "Root access is needed. Skipping all kernel streaming tests." $NUM_TESTS ||
114{
9c8a3964
JR
115 validate_lttng_modules_present
116
e7716c6a
JD
117 start_lttng_relayd "-o $TRACE_PATH"
118 start_lttng_sessiond
119 modprobe lttng-test
120
121 tests=( test_kernel_streaming test_kernel_local test_kernel_local_timer test_kernel_streaming_timer)
122
123 for fct_test in ${tests[@]};
124 do
125 SESSION_NAME=$(randstring 16 0)
126 ${fct_test}
127 done
128
129 rmmod lttng-test
130 stop_lttng_sessiond
131 stop_lttng_relayd
132}
9dc506ae
JR
133
134rm -rf $TRACE_PATH
This page took 0.02765 seconds and 4 git commands to generate.