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