8c31d488e373557912fa85674a0199ac73f99ecd
[lttng-tools.git] / tests / regression / tools / regen-metadata / test_kernel
1 #!/bin/bash
2 #
3 # Copyright (C) 2015 Julien Desfossez <jdesfossez@efficios.com>
4 #
5 # SPDX-License-Identifier: LGPL-2.1-only
6
7 TEST_DESC="Streaming - Kernel tracing"
8
9 CURDIR=$(dirname $0)/
10 TESTDIR=$CURDIR/../../..
11 EVENT_NAME="lttng_test_filter_event"
12 SESSION_NAME=""
13
14 TRACE_PATH=$(mktemp -d)
15
16 NUM_TESTS=24
17
18 source $TESTDIR/utils/utils.sh
19
20 function test_kernel_streaming ()
21 {
22 local metadata_path
23
24 diag "Test kernel streaming with metadata regeneration"
25 create_lttng_session_uri $SESSION_NAME net://localhost
26 lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME
27 start_lttng_tracing_ok $SESSION_NAME
28 echo -n "100" > /proc/lttng-test-filter-event
29
30 # Baseline
31 stop_lttng_tracing_ok $SESSION_NAME
32 validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME*
33
34 # Find the metadata file
35 metadata_path=$(find "$TRACE_PATH/$HOSTNAME/$SESSION_NAME"* | grep metadata)
36
37 # Empty the metadata file
38 echo -n > "$metadata_path"
39
40 start_lttng_tracing_ok $SESSION_NAME
41 regenerate_metadata_ok $SESSION_NAME
42 stop_lttng_tracing_ok $SESSION_NAME
43 # Validate test
44 validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME*
45 destroy_lttng_session_ok $SESSION_NAME
46 rm -rf "$TRACE_PATH"
47 }
48
49 function test_kernel_local ()
50 {
51 local metadata_path
52
53 diag "Test kernel local with metadata regeneration"
54 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
55 lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME
56 start_lttng_tracing_ok $SESSION_NAME
57
58 # Baseline
59 echo -n "100" > /proc/lttng-test-filter-event
60 stop_lttng_tracing_ok $SESSION_NAME
61 validate_trace $EVENT_NAME "$TRACE_PATH"
62
63 # Find the metadata file
64 metadata_path=$(find "$TRACE_PATH"* | grep metadata)
65
66 # Empty the metadata file
67 echo -n > "$metadata_path"
68
69 start_lttng_tracing_ok $SESSION_NAME
70 regenerate_metadata_ok $SESSION_NAME
71 stop_lttng_tracing_ok $SESSION_NAME
72
73 validate_trace $EVENT_NAME $TRACE_PATH
74 destroy_lttng_session_ok $SESSION_NAME
75
76 rm -rf "$TRACE_PATH"
77 }
78
79 plan_tests $NUM_TESTS
80
81 print_test_banner "$TEST_DESC"
82
83 if [ "$(id -u)" == "0" ]; then
84 isroot=1
85 else
86 isroot=0
87 fi
88
89 skip $isroot "Root access is needed. Skipping all kernel streaming tests." $NUM_TESTS ||
90 {
91 validate_lttng_modules_present
92
93 start_lttng_relayd "-o $TRACE_PATH"
94 start_lttng_sessiond
95 modprobe lttng-test
96
97 tests=( test_kernel_streaming test_kernel_local )
98
99 for fct_test in ${tests[@]};
100 do
101 SESSION_NAME=$(randstring 16 0)
102 ${fct_test}
103 done
104
105 modprobe --remove lttng-test
106 stop_lttng_sessiond
107 stop_lttng_relayd
108 }
This page took 0.032404 seconds and 4 git commands to generate.