Tests: add kernel test into the `make check` test suite.
[lttng-tools.git] / tests / regression / kernel / test_event_basic
1 #!/bin/bash
2 #
3 # Copyright (C) 2013 Christian Babeux <christian.babeux@efficios.com>
4 #
5 # SPDX-License-Identifier: GPL-2.0-only
6 #
7
8 TEST_DESC="Kernel tracer - Basic event"
9
10 CURDIR=$(dirname $0)/
11 TESTDIR=$CURDIR/../..
12 NUM_TESTS=21
13
14 TESTCMD="/bin/true"
15
16 source $TESTDIR/utils/utils.sh
17
18 function test_event_basic()
19 {
20 TRACE_PATH=$(mktemp --tmpdir -d "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
21 SESSION_NAME="kernel_event_basic"
22
23 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
24
25 lttng_enable_kernel_event $SESSION_NAME "sched_switch"
26 lttng_enable_kernel_event $SESSION_NAME "sched_process_exit"
27 lttng_enable_kernel_event $SESSION_NAME "sched_process_fork"
28
29 start_lttng_tracing_ok
30
31 # Running a process and waiting for its completion forces the triggering of
32 # fork, sched_switch and exit events
33 eval ${TESTCMD}
34 stop_lttng_tracing_ok
35
36 validate_trace_path_kernel "$TRACE_PATH" ""
37 validate_trace "sched_switch" $TRACE_PATH
38 validate_trace "sched_process_exit" $TRACE_PATH
39 validate_trace "sched_process_fork" $TRACE_PATH
40
41 destroy_lttng_session_ok $SESSION_NAME
42
43 rm -rf $TRACE_PATH
44 }
45
46 function test_enable_after_start()
47 {
48 TRACE_PATH=$(mktemp --tmpdir -d "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
49 SESSION_NAME="kernel_enable_after_start"
50
51 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
52
53 lttng_enable_kernel_event $SESSION_NAME "sched_switch"
54
55 start_lttng_tracing_ok
56 lttng_enable_kernel_event $SESSION_NAME "sched_process_exit"
57
58 # Running a process and waiting for its completion forces the triggering of
59 # sched_switch and exit events
60 eval ${TESTCMD}
61 stop_lttng_tracing_ok
62
63 validate_trace "sched_switch" $TRACE_PATH
64 validate_trace "sched_process_exit" $TRACE_PATH
65
66 destroy_lttng_session_ok $SESSION_NAME
67
68 rm -rf $TRACE_PATH
69 }
70
71 # MUST set TESTDIR before calling those functions
72 plan_tests $NUM_TESTS
73
74 print_test_banner "$TEST_DESC"
75
76 if [ "$(id -u)" == "0" ]; then
77 isroot=1
78 else
79 isroot=0
80 fi
81
82 skip $isroot "Root access is needed. Skipping all tests." $NUM_TESTS ||
83 {
84 validate_lttng_modules_present
85 start_lttng_sessiond
86
87 test_event_basic
88 test_enable_after_start
89
90 stop_lttng_sessiond
91 }
This page took 0.06035 seconds and 4 git commands to generate.