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 | function test_kernel_before_start () |
32 | { | |
d346ccad | 33 | diag "Test kernel streaming with event enable BEFORE start" |
f0d43d3d | 34 | create_lttng_session_uri $SESSION_NAME net://localhost |
f4e40ab6 | 35 | lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME |
e563bbdb | 36 | start_lttng_tracing_ok $SESSION_NAME |
f4e40ab6 DG |
37 | # Give a second |
38 | sleep 1 | |
96340a01 | 39 | stop_lttng_tracing_ok $SESSION_NAME |
67b4c664 | 40 | destroy_lttng_session_ok $SESSION_NAME |
f4e40ab6 DG |
41 | } |
42 | ||
173af62f DG |
43 | # Deactivated since this feature is not yet available where we can enable |
44 | # an event AFTERE tracing has started. | |
f4e40ab6 DG |
45 | function test_kernel_after_start () |
46 | { | |
d346ccad | 47 | diag "Test kernel streaming with event enable AFTER start" |
f0d43d3d | 48 | create_lttng_session_uri $SESSION_NAME net://localhost |
e563bbdb | 49 | start_lttng_tracing_ok $SESSION_NAME |
f4e40ab6 DG |
50 | lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME |
51 | # Give a second | |
52 | sleep 1 | |
96340a01 | 53 | stop_lttng_tracing_ok $SESSION_NAME |
67b4c664 | 54 | destroy_lttng_session_ok $SESSION_NAME |
f4e40ab6 DG |
55 | } |
56 | ||
d346ccad | 57 | plan_tests $NUM_TESTS |
f4e40ab6 | 58 | |
e3bef725 CB |
59 | print_test_banner "$TEST_DESC" |
60 | ||
d346ccad CB |
61 | if [ "$(id -u)" == "0" ]; then |
62 | isroot=1 | |
63 | else | |
64 | isroot=0 | |
65 | fi | |
f4e40ab6 | 66 | |
d346ccad CB |
67 | skip $isroot "Root access is needed. Skipping all kernel streaming tests." $NUM_TESTS || |
68 | { | |
9c8a3964 JR |
69 | validate_lttng_modules_present |
70 | ||
d346ccad | 71 | start_lttng_relayd "-o $TRACE_PATH" |
7972aab2 | 72 | start_lttng_sessiond |
d346ccad CB |
73 | |
74 | tests=( test_kernel_before_start ) | |
75 | ||
76 | for fct_test in ${tests[@]}; | |
77 | do | |
78 | SESSION_NAME=$(randstring 16 0) | |
79 | ${fct_test} | |
80 | ||
81 | # Validate test | |
82 | validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME* | |
83 | if [ $? -eq 0 ]; then | |
84 | # Only delete if successful | |
85 | rm -rf $TRACE_PATH | |
86 | else | |
87 | break | |
88 | fi | |
89 | done | |
f4e40ab6 | 90 | |
d346ccad CB |
91 | stop_lttng_sessiond |
92 | stop_lttng_relayd | |
93 | } |