Commit | Line | Data |
---|---|---|
1b368955 JD |
1 | #!/bin/bash |
2 | # | |
3 | # Copyright (C) - 2013 Julien Desfossez <julien.desfossez@efficios.com> | |
4 | # David Goulet <dgoulet@efficios.com> | |
5 | # | |
6 | # This library is free software; you can redistribute it and/or modify it under | |
7 | # the terms of the GNU Lesser General Public License as published by the Free | |
8 | # Software Foundation; version 2.1 of the License. | |
9 | # | |
10 | # This library is distributed in the hope that it will be useful, but WITHOUT | |
11 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
12 | # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | |
13 | # details. | |
14 | # | |
15 | # You should have received a copy of the GNU Lesser General Public License | |
16 | # along with this library; if not, write to the Free Software Foundation, Inc., | |
17 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
18 | ||
19 | TEST_DESC="Live - Kernel space tracing" | |
20 | ||
21 | CURDIR=$(dirname $0)/ | |
22 | TESTDIR=$CURDIR/../../../ | |
23 | SESSIOND_BIN="lttng-sessiond" | |
24 | RELAYD_BIN="lttng-relayd" | |
25 | LTTNG_BIN="lttng" | |
26 | DELAY_USEC=2000000 | |
27 | ||
28 | SESSION_NAME="live" | |
29 | EVENT_NAME="sched_switch" | |
30 | ||
31 | TRACE_PATH=$(mktemp -d) | |
32 | ||
33 | DIR=$(readlink -f $TESTDIR) | |
34 | ||
35 | NUM_TESTS=10 | |
36 | ||
37 | source $TESTDIR/utils/utils.sh | |
38 | ||
39 | # MUST set TESTDIR before calling those functions | |
40 | plan_tests $NUM_TESTS | |
41 | ||
42 | print_test_banner "$TEST_DESC" | |
43 | ||
44 | function setup_live_tracing() | |
45 | { | |
46 | # Create session with default path | |
47 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME --live $DELAY_USEC \ | |
48 | -U net://localhost >/dev/null 2>&1 | |
49 | ok $? "Create session in live mode with delay $DELAY_USEC" | |
50 | ||
51 | lttng_enable_kernel_event $SESSION_NAME $EVENT_NAME | |
52 | start_lttng_tracing $SESSION_NAME | |
53 | } | |
54 | ||
55 | function clean_live_tracing() | |
56 | { | |
57 | stop_lttng_tracing $SESSION_NAME | |
58 | destroy_lttng_session $SESSION_NAME | |
59 | } | |
60 | ||
61 | # Need root access for kernel tracing. | |
62 | if [ "$(id -u)" == "0" ]; then | |
63 | isroot=1 | |
64 | else | |
65 | isroot=0 | |
66 | fi | |
67 | ||
68 | skip $isroot "Root access is needed. Skipping all tests." $NUM_TESTS || | |
69 | { | |
70 | start_lttng_sessiond | |
71 | start_lttng_relayd "-o $TRACE_PATH" | |
72 | ||
73 | setup_live_tracing | |
74 | ||
75 | # Just hit some events | |
76 | sleep 2 | |
77 | ||
78 | clean_live_tracing | |
79 | ||
80 | validate_trace $EVENT_NAME $TRACE_PATH | |
81 | rm -rf $TRACE_PATH | |
82 | ||
83 | stop_lttng_relayd | |
84 | stop_lttng_sessiond | |
85 | } |