Commit | Line | Data |
---|---|---|
801236b0 JD |
1 | #!/bin/bash |
2 | # | |
9d16b343 | 3 | # Copyright (C) 2015 Julien Desfossez <jdesfossez@efficios.com> |
801236b0 | 4 | # |
9d16b343 MJ |
5 | # SPDX-License-Identifier: LGPL-2.1-only |
6 | ||
801236b0 JD |
7 | TEST_DESC="Streaming - Kernel tracing" |
8 | ||
9 | CURDIR=$(dirname $0)/ | |
10 | TESTDIR=$CURDIR/../../.. | |
11 | EVENT_NAME="lttng_test_filter_event" | |
801236b0 JD |
12 | SESSION_NAME="" |
13 | ||
14 | TRACE_PATH=$(mktemp -d) | |
15 | ||
dbbc5b0a | 16 | NUM_TESTS=24 |
801236b0 JD |
17 | |
18 | source $TESTDIR/utils/utils.sh | |
19 | ||
801236b0 JD |
20 | function test_kernel_streaming () |
21 | { | |
dbbc5b0a JR |
22 | local metadata_path |
23 | ||
801236b0 | 24 | diag "Test kernel streaming with metadata regeneration" |
f0d43d3d | 25 | create_lttng_session_uri $SESSION_NAME net://localhost |
801236b0 JD |
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 | |
dbbc5b0a JR |
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 | |
eded6438 | 41 | regenerate_metadata_ok $SESSION_NAME |
801236b0 JD |
42 | stop_lttng_tracing_ok $SESSION_NAME |
43 | # Validate test | |
44 | validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME* | |
801236b0 | 45 | destroy_lttng_session_ok $SESSION_NAME |
dbbc5b0a | 46 | rm -rf "$TRACE_PATH" |
801236b0 JD |
47 | } |
48 | ||
49 | function test_kernel_local () | |
50 | { | |
dbbc5b0a JR |
51 | local metadata_path |
52 | ||
801236b0 JD |
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 | |
dbbc5b0a JR |
57 | |
58 | # Baseline | |
801236b0 | 59 | echo -n "100" > /proc/lttng-test-filter-event |
dbbc5b0a JR |
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 | |
eded6438 | 70 | regenerate_metadata_ok $SESSION_NAME |
801236b0 | 71 | stop_lttng_tracing_ok $SESSION_NAME |
dbbc5b0a | 72 | |
801236b0 | 73 | validate_trace $EVENT_NAME $TRACE_PATH |
801236b0 | 74 | destroy_lttng_session_ok $SESSION_NAME |
dbbc5b0a JR |
75 | |
76 | rm -rf "$TRACE_PATH" | |
801236b0 JD |
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 | { | |
9c8a3964 JR |
91 | validate_lttng_modules_present |
92 | ||
801236b0 JD |
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 | ||
d0e263e7 | 105 | modprobe --remove lttng-test |
801236b0 JD |
106 | stop_lttng_sessiond |
107 | stop_lttng_relayd | |
108 | } |