Commit | Line | Data |
---|---|---|
801236b0 JD |
1 | #!/bin/bash |
2 | # | |
3 | # Copyright (C) - 2015 Julien Desfossez <jdesfossez@efficios.com> | |
4 | # | |
5 | # This library is free software; you can redistribute it and/or modify it under | |
6 | # the terms of the GNU Lesser General Public License as published by the Free | |
7 | # Software Foundation; version 2.1 of the License. | |
8 | # | |
9 | # This library is distributed in the hope that it will be useful, but WITHOUT | |
10 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
11 | # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | |
12 | # details. | |
13 | # | |
14 | # You should have received a copy of the GNU Lesser General Public License | |
15 | # along with this library; if not, write to the Free Software Foundation, Inc., | |
16 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
17 | TEST_DESC="Streaming - Kernel tracing" | |
18 | ||
19 | CURDIR=$(dirname $0)/ | |
20 | TESTDIR=$CURDIR/../../.. | |
21 | EVENT_NAME="lttng_test_filter_event" | |
801236b0 JD |
22 | SESSION_NAME="" |
23 | ||
24 | TRACE_PATH=$(mktemp -d) | |
25 | ||
e13c8ac0 | 26 | NUM_TESTS=24 |
801236b0 JD |
27 | |
28 | source $TESTDIR/utils/utils.sh | |
29 | ||
801236b0 JD |
30 | function test_kernel_streaming () |
31 | { | |
e13c8ac0 JR |
32 | local metadata_path |
33 | ||
801236b0 | 34 | diag "Test kernel streaming with metadata regeneration" |
f0d43d3d | 35 | create_lttng_session_uri $SESSION_NAME net://localhost |
801236b0 JD |
36 | lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME |
37 | start_lttng_tracing_ok $SESSION_NAME | |
38 | echo -n "100" > /proc/lttng-test-filter-event | |
e13c8ac0 JR |
39 | |
40 | # Baseline | |
41 | stop_lttng_tracing_ok $SESSION_NAME | |
42 | validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME* | |
43 | ||
44 | # Find the metadata file | |
45 | metadata_path=$(find "$TRACE_PATH/$HOSTNAME/$SESSION_NAME"* | grep metadata) | |
46 | ||
47 | # Empty the metadata file | |
48 | echo -n > "$metadata_path" | |
49 | ||
50 | start_lttng_tracing_ok $SESSION_NAME | |
eded6438 | 51 | regenerate_metadata_ok $SESSION_NAME |
801236b0 JD |
52 | stop_lttng_tracing_ok $SESSION_NAME |
53 | # Validate test | |
54 | validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME* | |
801236b0 | 55 | destroy_lttng_session_ok $SESSION_NAME |
e13c8ac0 | 56 | rm -rf "$TRACE_PATH" |
801236b0 JD |
57 | } |
58 | ||
59 | function test_kernel_local () | |
60 | { | |
e13c8ac0 JR |
61 | local metadata_path |
62 | ||
801236b0 JD |
63 | diag "Test kernel local with metadata regeneration" |
64 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH | |
65 | lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME | |
66 | start_lttng_tracing_ok $SESSION_NAME | |
e13c8ac0 JR |
67 | |
68 | # Baseline | |
801236b0 | 69 | echo -n "100" > /proc/lttng-test-filter-event |
e13c8ac0 JR |
70 | stop_lttng_tracing_ok $SESSION_NAME |
71 | validate_trace $EVENT_NAME "$TRACE_PATH" | |
72 | ||
73 | # Find the metadata file | |
74 | metadata_path=$(find "$TRACE_PATH"* | grep metadata) | |
75 | ||
76 | # Empty the metadata file | |
77 | echo -n > "$metadata_path" | |
78 | ||
79 | start_lttng_tracing_ok $SESSION_NAME | |
eded6438 | 80 | regenerate_metadata_ok $SESSION_NAME |
801236b0 | 81 | stop_lttng_tracing_ok $SESSION_NAME |
e13c8ac0 | 82 | |
801236b0 | 83 | validate_trace $EVENT_NAME $TRACE_PATH |
801236b0 | 84 | destroy_lttng_session_ok $SESSION_NAME |
e13c8ac0 JR |
85 | |
86 | rm -rf "$TRACE_PATH" | |
801236b0 JD |
87 | } |
88 | ||
89 | plan_tests $NUM_TESTS | |
90 | ||
91 | print_test_banner "$TEST_DESC" | |
92 | ||
93 | if [ "$(id -u)" == "0" ]; then | |
94 | isroot=1 | |
95 | else | |
96 | isroot=0 | |
97 | fi | |
98 | ||
99 | skip $isroot "Root access is needed. Skipping all kernel streaming tests." $NUM_TESTS || | |
100 | { | |
9c8a3964 JR |
101 | validate_lttng_modules_present |
102 | ||
801236b0 JD |
103 | start_lttng_relayd "-o $TRACE_PATH" |
104 | start_lttng_sessiond | |
105 | modprobe lttng-test | |
106 | ||
107 | tests=( test_kernel_streaming test_kernel_local ) | |
108 | ||
109 | for fct_test in ${tests[@]}; | |
110 | do | |
111 | SESSION_NAME=$(randstring 16 0) | |
112 | ${fct_test} | |
113 | done | |
114 | ||
962971d2 | 115 | modprobe --remove lttng-test |
801236b0 JD |
116 | stop_lttng_sessiond |
117 | stop_lttng_relayd | |
118 | } |