7c4191a47909ae38bd16221fcb0341692972de22
[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 -t tmp.test_regen_metadata_kernel_trace_path.XXXXXX)
15
16 NUM_TESTS=32
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"* -name "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"* -name "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 function test_kernel_local_snapshot_after_regenerate_metadata ()
80 {
81 diag "Test kernel local snapshot after regenerate metadata"
82 create_lttng_session_ok $SESSION_NAME "$TRACE_PATH" --snapshot
83 lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME
84 start_lttng_tracing_ok $SESSION_NAME
85
86 echo -n "100" > /proc/lttng-test-filter-event
87
88 regenerate_metadata_ok $SESSION_NAME
89 lttng_snapshot_record $SESSION_NAME "$TRACE_PATH"
90 stop_lttng_tracing_ok $SESSION_NAME
91
92 validate_trace $EVENT_NAME "$TRACE_PATH"
93 destroy_lttng_session_ok $SESSION_NAME
94
95 rm -rf "$TRACE_PATH"
96 }
97
98 plan_tests $NUM_TESTS
99
100 print_test_banner "$TEST_DESC"
101
102 if [ "$(id -u)" == "0" ]; then
103 isroot=1
104 else
105 isroot=0
106 fi
107
108 skip $isroot "Root access is needed. Skipping all kernel streaming tests." $NUM_TESTS ||
109 {
110 validate_lttng_modules_present
111
112 start_lttng_relayd "-o $TRACE_PATH"
113 start_lttng_sessiond
114 modprobe lttng-test
115
116 tests=( test_kernel_streaming test_kernel_local
117 test_kernel_local_snapshot_after_regenerate_metadata )
118
119 for fct_test in ${tests[@]};
120 do
121 SESSION_NAME=$(randstring 16 0)
122 ${fct_test}
123 done
124
125 modprobe --remove lttng-test
126 stop_lttng_sessiond
127 stop_lttng_relayd
128 }
This page took 0.034641 seconds and 4 git commands to generate.