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