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