Tests: add kernel test into the `make check` test suite.
[lttng-tools.git] / tests / regression / kernel / test_kernel_function
1 #!/bin/bash
2 #
3 # Copyright (C) 2021 Francis Deslauriers <francis.deslauriers@efficios.com>
4 #
5 # SPDX-License-Identifier: GPL-2.0-only
6 #
7
8 TEST_DESC="Kernel tracer - function event"
9
10 CURDIR=$(dirname $0)/
11 TESTDIR=$CURDIR/../..
12 NUM_TESTS=7
13
14 source $TESTDIR/utils/utils.sh
15
16 function test_kernel_function_basic()
17 {
18 local TRACE_PATH=$(mktemp --tmpdir -d "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
19 local SESSION_NAME="kernel_function_basic"
20 local EVENT_NAME="my_event_name"
21 local TARGET_SYMBOL="lttng_test_filter_event_write"
22
23 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
24
25 lttng_enable_kernel_function_event_ok $SESSION_NAME "$TARGET_SYMBOL" "$EVENT_NAME"
26
27 start_lttng_tracing_ok
28
29 echo 1 > /proc/lttng-test-filter-event
30
31 stop_lttng_tracing_ok
32
33 validate_trace "${EVENT_NAME}_entry" $TRACE_PATH
34 validate_trace "${EVENT_NAME}_exit" $TRACE_PATH
35
36 destroy_lttng_session_ok $SESSION_NAME
37
38 rm -rf $TRACE_PATH
39 }
40
41 # MUST set TESTDIR before calling those functions
42 plan_tests $NUM_TESTS
43
44 print_test_banner "$TEST_DESC"
45
46 if [ "$(id -u)" == "0" ]; then
47 isroot=1
48 else
49 isroot=0
50 fi
51
52 skip $isroot "Root access is needed. Skipping all tests." $NUM_TESTS ||
53 {
54 start_lttng_sessiond_notap
55 validate_lttng_modules_present
56 modprobe lttng-test
57
58 test_kernel_function_basic
59
60 modprobe --remove lttng-test
61 stop_lttng_sessiond_notap
62 }
This page took 0.030643 seconds and 4 git commands to generate.