Commit | Line | Data |
---|---|---|
c87d483b CB |
1 | #!/bin/bash |
2 | # | |
3 | # Copyright (C) - 2013 Christian Babeux <christian.babeux@efficios.com> | |
4 | # | |
5 | # This program is free software; you can redistribute it and/or modify it | |
6 | # under the terms of the GNU General Public License, version 2 only, as | |
7 | # published by the Free Software Foundation. | |
8 | # | |
9 | # This program is distributed in the hope that it will be useful, but WITHOUT | |
10 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
12 | # more details. | |
13 | # | |
14 | # You should have received a copy of the GNU General Public License along with | |
15 | # this program; if not, write to the Free Software Foundation, Inc., 51 | |
16 | # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
17 | ||
18 | TEST_DESC="Kernel tracer - Basic event" | |
19 | ||
20 | CURDIR=$(dirname $0)/ | |
21 | TESTDIR=$CURDIR/../.. | |
85ed2b26 | 22 | NUM_TESTS=20 |
c87d483b CB |
23 | |
24 | source $TESTDIR/utils/utils.sh | |
25 | ||
c87d483b CB |
26 | function test_event_basic() |
27 | { | |
28 | TRACE_PATH=$(mktemp -d) | |
29 | SESSION_NAME="kernel_event_basic" | |
30 | ||
bf6ae429 | 31 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
c87d483b CB |
32 | |
33 | lttng_enable_kernel_event $SESSION_NAME "sched_switch" | |
34 | lttng_enable_kernel_event $SESSION_NAME "sched_process_exit" | |
35 | lttng_enable_kernel_event $SESSION_NAME "sched_process_free" | |
36 | ||
e563bbdb | 37 | start_lttng_tracing_ok |
96340a01 | 38 | stop_lttng_tracing_ok |
c87d483b CB |
39 | |
40 | validate_trace "sched_switch" $TRACE_PATH | |
41 | validate_trace "sched_process_exit" $TRACE_PATH | |
42 | validate_trace "sched_process_free" $TRACE_PATH | |
43 | ||
67b4c664 | 44 | destroy_lttng_session_ok $SESSION_NAME |
c87d483b CB |
45 | |
46 | rm -rf $TRACE_PATH | |
47 | } | |
48 | ||
85ed2b26 JD |
49 | function test_enable_after_start() |
50 | { | |
51 | TRACE_PATH=$(mktemp -d) | |
52 | SESSION_NAME="kernel_enable_after_start" | |
53 | ||
bf6ae429 | 54 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
85ed2b26 JD |
55 | |
56 | lttng_enable_kernel_event $SESSION_NAME "sched_switch" | |
57 | ||
e563bbdb | 58 | start_lttng_tracing_ok |
85ed2b26 | 59 | lttng_enable_kernel_event $SESSION_NAME "sched_process_exit" |
96340a01 | 60 | stop_lttng_tracing_ok |
85ed2b26 JD |
61 | |
62 | validate_trace "sched_switch" $TRACE_PATH | |
63 | validate_trace "sched_process_exit" $TRACE_PATH | |
64 | ||
67b4c664 | 65 | destroy_lttng_session_ok $SESSION_NAME |
85ed2b26 JD |
66 | |
67 | rm -rf $TRACE_PATH | |
68 | } | |
69 | ||
c87d483b CB |
70 | # MUST set TESTDIR before calling those functions |
71 | plan_tests $NUM_TESTS | |
72 | ||
e3bef725 CB |
73 | print_test_banner "$TEST_DESC" |
74 | ||
c87d483b CB |
75 | if [ "$(id -u)" == "0" ]; then |
76 | isroot=1 | |
77 | else | |
78 | isroot=0 | |
79 | fi | |
80 | ||
81 | skip $isroot "Root access is needed. Skipping all tests." $NUM_TESTS || | |
82 | { | |
83 | start_lttng_sessiond | |
84 | ||
85 | test_event_basic | |
85ed2b26 | 86 | test_enable_after_start |
c87d483b CB |
87 | |
88 | stop_lttng_sessiond | |
89 | } |