Cleanup: Use pkg-config to detect liburcu
[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=20
13
14 TESTCMD="/bin/true"
15
16 source $TESTDIR/utils/utils.sh
17
18 function test_event_basic()
19 {
20 TRACE_PATH=$(mktemp -d)
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 "sched_switch" $TRACE_PATH
37 validate_trace "sched_process_exit" $TRACE_PATH
38 validate_trace "sched_process_fork" $TRACE_PATH
39
40 destroy_lttng_session_ok $SESSION_NAME
41
42 rm -rf $TRACE_PATH
43 }
44
45 function test_enable_after_start()
46 {
47 TRACE_PATH=$(mktemp -d)
48 SESSION_NAME="kernel_enable_after_start"
49
50 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
51
52 lttng_enable_kernel_event $SESSION_NAME "sched_switch"
53
54 start_lttng_tracing_ok
55 lttng_enable_kernel_event $SESSION_NAME "sched_process_exit"
56
57 # Running a process and waiting for its completion forces the triggering of
58 # sched_switch and exit events
59 eval ${TESTCMD}
60 stop_lttng_tracing_ok
61
62 validate_trace "sched_switch" $TRACE_PATH
63 validate_trace "sched_process_exit" $TRACE_PATH
64
65 destroy_lttng_session_ok $SESSION_NAME
66
67 rm -rf $TRACE_PATH
68 }
69
70 # MUST set TESTDIR before calling those functions
71 plan_tests $NUM_TESTS
72
73 print_test_banner "$TEST_DESC"
74
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
86 test_enable_after_start
87
88 stop_lttng_sessiond
89 }
This page took 0.039813 seconds and 4 git commands to generate.