Commit | Line | Data |
---|---|---|
f4e40ab6 DG |
1 | #!/bin/bash |
2 | # | |
3 | # Copyright (C) - 2012 David Goulet <dgoulet@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 | |
c38b5107 | 17 | TEST_DESC="Streaming - Kernel tracing" |
f4e40ab6 DG |
18 | |
19 | CURDIR=$(dirname $0)/ | |
9ac429ef | 20 | TESTDIR=$CURDIR/../../.. |
f4e40ab6 DG |
21 | EVENT_NAME="sched_switch" |
22 | PID_RELAYD=0 | |
23 | SESSION_NAME="" | |
24 | ||
173af62f DG |
25 | TRACE_PATH=$(mktemp -d) |
26 | ||
7972aab2 | 27 | NUM_TESTS=10 |
d346ccad | 28 | |
9ac429ef | 29 | source $TESTDIR/utils/utils.sh |
f4e40ab6 | 30 | |
f4e40ab6 DG |
31 | # LTTng kernel modules check |
32 | out=`ls /lib/modules/$(uname -r)/extra | grep lttng` | |
33 | if [ -z "$out" ]; then | |
d346ccad | 34 | BAIL_OUT "LTTng modules not detected." |
f4e40ab6 DG |
35 | fi |
36 | ||
785d2d0d | 37 | function lttng_create_session_uri |
f4e40ab6 | 38 | { |
f4e40ab6 | 39 | # Create session with default path |
785d2d0d | 40 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME -U net://localhost >/dev/null 2>&1 |
d346ccad CB |
41 | |
42 | ok $? "Create session $SESSION_NAME" | |
f4e40ab6 DG |
43 | } |
44 | ||
45 | function test_kernel_before_start () | |
46 | { | |
d346ccad | 47 | diag "Test kernel streaming with event enable BEFORE start" |
785d2d0d | 48 | lttng_create_session_uri |
f4e40ab6 | 49 | lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME |
fb3268e3 | 50 | start_lttng_tracing $SESSION_NAME |
f4e40ab6 DG |
51 | # Give a second |
52 | sleep 1 | |
fb3268e3 | 53 | stop_lttng_tracing $SESSION_NAME |
f4e40ab6 DG |
54 | destroy_lttng_session $SESSION_NAME |
55 | } | |
56 | ||
173af62f DG |
57 | # Deactivated since this feature is not yet available where we can enable |
58 | # an event AFTERE tracing has started. | |
f4e40ab6 DG |
59 | function test_kernel_after_start () |
60 | { | |
d346ccad | 61 | diag "Test kernel streaming with event enable AFTER start" |
785d2d0d | 62 | lttng_create_session_uri |
fb3268e3 | 63 | start_lttng_tracing $SESSION_NAME |
f4e40ab6 DG |
64 | lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME |
65 | # Give a second | |
66 | sleep 1 | |
fb3268e3 | 67 | stop_lttng_tracing $SESSION_NAME |
f4e40ab6 DG |
68 | destroy_lttng_session $SESSION_NAME |
69 | } | |
70 | ||
d346ccad | 71 | plan_tests $NUM_TESTS |
f4e40ab6 | 72 | |
e3bef725 CB |
73 | print_test_banner "$TEST_DESC" |
74 | ||
d346ccad CB |
75 | if [ "$(id -u)" == "0" ]; then |
76 | isroot=1 | |
77 | else | |
78 | isroot=0 | |
79 | fi | |
f4e40ab6 | 80 | |
d346ccad CB |
81 | skip $isroot "Root access is needed. Skipping all kernel streaming tests." $NUM_TESTS || |
82 | { | |
d346ccad | 83 | start_lttng_relayd "-o $TRACE_PATH" |
7972aab2 | 84 | start_lttng_sessiond |
d346ccad CB |
85 | |
86 | tests=( test_kernel_before_start ) | |
87 | ||
88 | for fct_test in ${tests[@]}; | |
89 | do | |
90 | SESSION_NAME=$(randstring 16 0) | |
91 | ${fct_test} | |
92 | ||
93 | # Validate test | |
94 | validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME* | |
95 | if [ $? -eq 0 ]; then | |
96 | # Only delete if successful | |
97 | rm -rf $TRACE_PATH | |
98 | else | |
99 | break | |
100 | fi | |
101 | done | |
f4e40ab6 | 102 | |
d346ccad CB |
103 | stop_lttng_sessiond |
104 | stop_lttng_relayd | |
105 | } |