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" | |
22 | PID_RELAYD=0 | |
23 | SESSION_NAME="" | |
24 | ||
25 | TRACE_PATH=$(mktemp -d) | |
26 | ||
27 | NUM_TESTS=18 | |
28 | ||
29 | source $TESTDIR/utils/utils.sh | |
30 | ||
801236b0 JD |
31 | function lttng_create_session_uri |
32 | { | |
33 | # Create session with default path | |
34 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME -U net://localhost >/dev/null 2>&1 | |
35 | ||
36 | ok $? "Create session $SESSION_NAME" | |
37 | } | |
38 | ||
39 | function test_kernel_streaming () | |
40 | { | |
41 | diag "Test kernel streaming with metadata regeneration" | |
42 | lttng_create_session_uri | |
43 | lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME | |
44 | start_lttng_tracing_ok $SESSION_NAME | |
45 | echo -n "100" > /proc/lttng-test-filter-event | |
eded6438 | 46 | regenerate_metadata_ok $SESSION_NAME |
801236b0 JD |
47 | stop_lttng_tracing_ok $SESSION_NAME |
48 | # Validate test | |
49 | validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME* | |
50 | if [ $? -eq 0 ]; then | |
51 | # Only delete if successful | |
52 | rm -rf $TRACE_PATH | |
53 | else | |
54 | break | |
55 | fi | |
56 | destroy_lttng_session_ok $SESSION_NAME | |
57 | } | |
58 | ||
59 | function test_kernel_local () | |
60 | { | |
61 | diag "Test kernel local with metadata regeneration" | |
62 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH | |
63 | lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME | |
64 | start_lttng_tracing_ok $SESSION_NAME | |
65 | echo -n "100" > /proc/lttng-test-filter-event | |
eded6438 | 66 | regenerate_metadata_ok $SESSION_NAME |
801236b0 JD |
67 | stop_lttng_tracing_ok $SESSION_NAME |
68 | validate_trace $EVENT_NAME $TRACE_PATH | |
69 | if [ $? -eq 0 ]; then | |
70 | # Only delete if successful | |
71 | rm -rf $TRACE_PATH | |
72 | fi | |
73 | destroy_lttng_session_ok $SESSION_NAME | |
74 | } | |
75 | ||
76 | plan_tests $NUM_TESTS | |
77 | ||
78 | print_test_banner "$TEST_DESC" | |
79 | ||
80 | if [ "$(id -u)" == "0" ]; then | |
81 | isroot=1 | |
82 | else | |
83 | isroot=0 | |
84 | fi | |
85 | ||
86 | skip $isroot "Root access is needed. Skipping all kernel streaming tests." $NUM_TESTS || | |
87 | { | |
9c8a3964 JR |
88 | validate_lttng_modules_present |
89 | ||
801236b0 JD |
90 | start_lttng_relayd "-o $TRACE_PATH" |
91 | start_lttng_sessiond | |
92 | modprobe lttng-test | |
93 | ||
94 | tests=( test_kernel_streaming test_kernel_local ) | |
95 | ||
96 | for fct_test in ${tests[@]}; | |
97 | do | |
98 | SESSION_NAME=$(randstring 16 0) | |
99 | ${fct_test} | |
100 | done | |
101 | ||
102 | rmmod lttng-test | |
103 | stop_lttng_sessiond | |
104 | stop_lttng_relayd | |
105 | } |