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 | 23 | |
e9826a9d FD |
24 | TESTCMD="/bin/true" |
25 | ||
c87d483b CB |
26 | source $TESTDIR/utils/utils.sh |
27 | ||
c87d483b CB |
28 | function test_event_basic() |
29 | { | |
30 | TRACE_PATH=$(mktemp -d) | |
31 | SESSION_NAME="kernel_event_basic" | |
32 | ||
bf6ae429 | 33 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
c87d483b CB |
34 | |
35 | lttng_enable_kernel_event $SESSION_NAME "sched_switch" | |
36 | lttng_enable_kernel_event $SESSION_NAME "sched_process_exit" | |
e9826a9d | 37 | lttng_enable_kernel_event $SESSION_NAME "sched_process_fork" |
c87d483b | 38 | |
e563bbdb | 39 | start_lttng_tracing_ok |
e9826a9d FD |
40 | |
41 | # Running a process and waiting for its completion forces the triggering of | |
42 | # fork, sched_switch and exit events | |
43 | eval ${TESTCMD} | |
96340a01 | 44 | stop_lttng_tracing_ok |
c87d483b CB |
45 | |
46 | validate_trace "sched_switch" $TRACE_PATH | |
47 | validate_trace "sched_process_exit" $TRACE_PATH | |
e9826a9d | 48 | validate_trace "sched_process_fork" $TRACE_PATH |
c87d483b | 49 | |
67b4c664 | 50 | destroy_lttng_session_ok $SESSION_NAME |
c87d483b CB |
51 | |
52 | rm -rf $TRACE_PATH | |
53 | } | |
54 | ||
85ed2b26 JD |
55 | function test_enable_after_start() |
56 | { | |
57 | TRACE_PATH=$(mktemp -d) | |
58 | SESSION_NAME="kernel_enable_after_start" | |
59 | ||
bf6ae429 | 60 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
85ed2b26 JD |
61 | |
62 | lttng_enable_kernel_event $SESSION_NAME "sched_switch" | |
63 | ||
e563bbdb | 64 | start_lttng_tracing_ok |
85ed2b26 | 65 | lttng_enable_kernel_event $SESSION_NAME "sched_process_exit" |
e9826a9d FD |
66 | |
67 | # Running a process and waiting for its completion forces the triggering of | |
68 | # sched_switch and exit events | |
69 | eval ${TESTCMD} | |
96340a01 | 70 | stop_lttng_tracing_ok |
85ed2b26 JD |
71 | |
72 | validate_trace "sched_switch" $TRACE_PATH | |
73 | validate_trace "sched_process_exit" $TRACE_PATH | |
74 | ||
67b4c664 | 75 | destroy_lttng_session_ok $SESSION_NAME |
85ed2b26 JD |
76 | |
77 | rm -rf $TRACE_PATH | |
78 | } | |
79 | ||
c87d483b CB |
80 | # MUST set TESTDIR before calling those functions |
81 | plan_tests $NUM_TESTS | |
82 | ||
e3bef725 CB |
83 | print_test_banner "$TEST_DESC" |
84 | ||
c87d483b CB |
85 | if [ "$(id -u)" == "0" ]; then |
86 | isroot=1 | |
87 | else | |
88 | isroot=0 | |
89 | fi | |
90 | ||
91 | skip $isroot "Root access is needed. Skipping all tests." $NUM_TESTS || | |
92 | { | |
93 | start_lttng_sessiond | |
94 | ||
95 | test_event_basic | |
85ed2b26 | 96 | test_enable_after_start |
c87d483b CB |
97 | |
98 | stop_lttng_sessiond | |
99 | } |