# SPDX-License-Identifier: GPL-2.0-only
-EXTRA_DIST = test_event_basic test_all_events test_syscall \
- test_clock_override test_rotation_destroy_flush \
- test_select_poll_epoll test_lttng_logger \
- test_userspace_probe test_callstack \
- test_syscall validate_select_poll_epoll.py \
- test_ns_contexts test_ns_contexts_change
+EXTRA_DIST = test_all_events test_syscall \
+ test_callstack \
+ test_clock_override \
+ test_event_basic \
+ test_kernel_function \
+ test_lttng_logger \
+ test_ns_contexts \
+ test_ns_contexts_change
+ test_rotation_destroy_flush \
+ test_select_poll_epoll \
+ test_syscall \
+ test_userspace_probe \
+ validate_select_poll_epoll.py
noinst_PROGRAMS = select_poll_epoll
select_poll_epoll_SOURCES = select_poll_epoll.c
--- /dev/null
+#!/bin/bash
+#
+# Copyright (C) 2021 Francis Deslauriers <francis.deslauriers@efficios.com>
+#
+# SPDX-License-Identifier: GPL-2.0-only
+#
+
+TEST_DESC="Kernel tracer - function event"
+
+CURDIR=$(dirname $0)/
+TESTDIR=$CURDIR/../..
+NUM_TESTS=6
+
+source $TESTDIR/utils/utils.sh
+
+function test_kernel_function_basic()
+{
+ local TRACE_PATH=$(mktemp -d)
+ local SESSION_NAME="kernel_function_basic"
+ local EVENT_NAME="my_event_name"
+ local TARGET_SYMBOL="lttng_test_filter_event_write"
+
+ create_lttng_session_ok $SESSION_NAME $TRACE_PATH
+
+ lttng_enable_kernel_function_event_ok $SESSION_NAME "$TARGET_SYMBOL" "$EVENT_NAME"
+
+ start_lttng_tracing_ok
+
+ echo 1 > /proc/lttng-test-filter-event
+
+ stop_lttng_tracing_ok
+
+ validate_trace "${EVENT_NAME}_entry" $TRACE_PATH
+ validate_trace "${EVENT_NAME}_return" $TRACE_PATH
+
+ destroy_lttng_session_ok $SESSION_NAME
+
+ rm -rf $TRACE_PATH
+}
+
+# MUST set TESTDIR before calling those functions
+plan_tests $NUM_TESTS
+
+print_test_banner "$TEST_DESC"
+
+if [ "$(id -u)" == "0" ]; then
+ isroot=1
+else
+ isroot=0
+fi
+
+skip $isroot "Root access is needed. Skipping all tests." $NUM_TESTS ||
+{
+ start_lttng_sessiond_notap
+ validate_lttng_modules_present
+ modprobe lttng-test
+
+ test_kernel_function_basic
+
+ modprobe --remove lttng-test
+ stop_lttng_sessiond_notap
+}
lttng_disable_kernel_syscall 1 "$@"
}
+function lttng_enable_kernel_function_event ()
+{
+ local expected_to_fail="$1"
+ local sess_name="$2"
+ local target="$3"
+ local event_name="$4"
+
+ "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" enable-event --kernel --function="$target" "$event_name" -s "$sess_name" > "$OUTPUT_DEST" 2> "$ERROR_OUTPUT_DEST"
+ ret=$?
+ if [[ $expected_to_fail -eq "1" ]]; then
+ test $ret -ne "0"
+ ok $? "Enable kernel function event for session $sess_name failed as expected"
+ else
+ ok $ret "Enable kernel function event for session $sess_name"
+ fi
+}
+
+function lttng_enable_kernel_function_event_ok ()
+{
+ lttng_enable_kernel_function_event 0 "$@"
+}
+
function lttng_enable_kernel_userspace_probe_event ()
{
local expected_to_fail="$1"