Fix: force _lttng python binding to be linked with g++
[lttng-tools.git] / tests / regression / tools / rotation / test_ust_kernel
CommitLineData
6f7eb8e1
JG
1#!/bin/bash
2#
3# Copyright (C) 2022 Jérémie Galarneau <jeremie.galarneau@efficios.com>
4#
5# SPDX-License-Identifier: LGPL-2.1-only
6
7TEST_DESC="Rotation - Kernel tracing"
8
9CURDIR=$(dirname $0)/
10TESTDIR=$CURDIR/../../..
11NR_USEC_WAIT=0
12TESTAPP_PATH="$TESTDIR/utils/testapp"
13TESTAPP_NAME="gen-ust-events"
14TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
15SESSION_NAME="stream"
16UST_EVENT_NAME="tp:tptest"
17KERNEL_EVENT_NAME="lttng_test_filter_event"
18
8d5a3312 19TRACE_PATH=$(mktemp -d -t tmp.rotation_ust_kernel_tracing.XXXXXX)
6f7eb8e1
JG
20
21NUM_TESTS=64
22
23source $TESTDIR/utils/utils.sh
24source $CURDIR/rotate_utils.sh
25
26function rotate_ust_kernel_test ()
27{
28 local local_path=$1
29 local today
30 local expected_domains
31
32 expected_domains=("ust" "kernel")
33
34 enable_ust_lttng_event_ok $SESSION_NAME $UST_EVENT_NAME
35 lttng_enable_kernel_event $SESSION_NAME $KERNEL_EVENT_NAME
36
37 start_lttng_tracing_ok $SESSION_NAME
38
39 today=$(date +%Y%m%d)
40
41 # First chunk contains 10 events of each domain.
42 echo -n "10" > /proc/lttng-test-filter-event
43 $TESTAPP_BIN -i 10 -w $NR_USEC_WAIT > /dev/null 2>&1
44 rotate_session_ok $SESSION_NAME
45
46 # Second chunk contains 20 events of each domain.
47 echo -n "20" > /proc/lttng-test-filter-event
48 $TESTAPP_BIN -i 20 -w $NR_USEC_WAIT > /dev/null 2>&1
49 stop_lttng_tracing_ok $SESSION_NAME
50
51 # Third chunk contains no event (rotate after stop).
52 rotate_session_ok $SESSION_NAME
53
54 destroy_lttng_session_ok $SESSION_NAME
55
56 diag "Validate kernel domain chunks"
57 EVENT_NAME=$KERNEL_EVENT_NAME
58 validate_test_chunks $local_path $today kernel "${expected_domains[@]}"
59
60 diag "Validate user space domain chunks"
61 EVENT_NAME=$UST_EVENT_NAME
62 validate_test_chunks $local_path $today "ust/uid/*/*/" "${expected_domains[@]}"
63}
64
65function test_ust_kernel_streaming ()
66{
67 diag "Test combined UST + kernel streaming with session rotation"
68 create_lttng_session_uri $SESSION_NAME net://localhost
69 rotate_ust_kernel_test "${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*/archives" "ust/uid/*/*/"
70}
71
72function test_ust_kernel_local ()
73{
74 diag "Test combined UST + kernel local with session rotation"
75 create_lttng_session_ok $SESSION_NAME "$TRACE_PATH"
76 rotate_ust_kernel_test "${TRACE_PATH}/archives" "ust/uid/*/*/"
77}
78
79if [ ! -x "$TESTAPP_BIN" ]; then
80 BAIL_OUT "No UST events binary detected."
81fi
82
83plan_tests $NUM_TESTS
84
85print_test_banner "$TEST_DESC"
86bail_out_if_no_babeltrace
87
88if [ "$(id -u)" == "0" ]; then
89 isroot=1
90else
91 isroot=0
92fi
93
94skip $isroot "Root access is needed. Skipping all tests." $NUM_TESTS ||
95{
96 validate_lttng_modules_present
97
98 start_lttng_relayd "-o $TRACE_PATH"
99 start_lttng_sessiond
100 modprobe lttng-test
101
102 tests=( test_ust_kernel_streaming test_ust_kernel_local )
103
104 for fct_test in "${tests[@]}";
105 do
106 SESSION_NAME=$(randstring 16 0)
107 ${fct_test}
108 clean_path "$TRACE_PATH"
109 done
110
111 modprobe --remove lttng-test
112 stop_lttng_sessiond
113 stop_lttng_relayd
114}
115
116rm -rf "$TRACE_PATH"
This page took 0.040428 seconds and 4 git commands to generate.