[DTrace-devel] [PATCH 4/4] test: Skip D return() action if kernel not configured right

Kris Van Hees kris.van.hees at oracle.com
Mon Oct 6 22:14:50 UTC 2025


Why not just check /sys/kernel/debug/error_injection/list?

On Mon, Oct 06, 2025 at 05:57:26PM -0400, eugene.loh at oracle.com wrote:
> From: Eugene Loh <eugene.loh at oracle.com>
> 
> Most of the err.* tests can still be run, since they test other
> failure modes.
> 
> Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
> ---
>  .../unittest/actions/return/err.destructive.x |  1 +
>  .../unittest/actions/return/tst.destructive.x | 67 +++++++++++++++++++
>  .../return/tst.override-getpid-entry.x        |  1 +
>  .../return/tst.override-getpid-return.x       |  1 +
>  4 files changed, 70 insertions(+)
>  create mode 120000 test/unittest/actions/return/err.destructive.x
>  create mode 100755 test/unittest/actions/return/tst.destructive.x
>  create mode 120000 test/unittest/actions/return/tst.override-getpid-entry.x
>  create mode 120000 test/unittest/actions/return/tst.override-getpid-return.x
> 
> diff --git a/test/unittest/actions/return/err.destructive.x b/test/unittest/actions/return/err.destructive.x
> new file mode 120000
> index 000000000..2cb5b1159
> --- /dev/null
> +++ b/test/unittest/actions/return/err.destructive.x
> @@ -0,0 +1 @@
> +tst.destructive.s
> \ No newline at end of file
> diff --git a/test/unittest/actions/return/tst.destructive.x b/test/unittest/actions/return/tst.destructive.x
> new file mode 100755
> index 000000000..d54bbb2fa
> --- /dev/null
> +++ b/test/unittest/actions/return/tst.destructive.x
> @@ -0,0 +1,67 @@
> +#!/bin/bash
> +#
> +# Oracle Linux DTrace.
> +# Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
> +# Licensed under the Universal Permissive License v 1.0 as shown at
> +# http://oss.oracle.com/licenses/upl.
> +
> +# For us to use the return() action, the kernel needs to be configured
> +# properly.  In /usr/include/linux/bpf.h, we see that bpf_override_return()
> +# needs both CONFIG_BPF_KPROBE_OVERRIDE and CONFIG_FUNCTION_ERROR_INJECTION.
> +
> +# To check kernel configuration parameters, check
> +# https://docs.rockylinux.org/10/gemstones/core/view_kernel_conf/
> +
> +# Look for a file with kernel configuration parameters.
> +
> +file=""
> +for x in \
> +    /boot/config-$(uname -r) \
> +    /lib/modules/$(uname -r)/config \
> +    /lib/modules/$(uname -r)/build/.config \
> +    /usr/src/kernels/$(uname -r)/.config \
> +; do
> +	if [ -e $x ]; then
> +		file=$x
> +	fi
> +done
> +
> +# If such a file is found, look for the necessary parameters.
> +
> +if [ $file != "" ]; then
> +	if ! grep -q CONFIG_BPF_KPROBE_OVERRIDE=y      $file; then
> +		echo need CONFIG_BPF_KPROBE_OVERRIDE=y for D return action, not found in $file
> +		exit 2
> +	fi
> +	if ! grep -q CONFIG_FUNCTION_ERROR_INJECTION=y $file; then
> +		echo need CONFIG_FUNCTION_ERROR_INJECTION=y for D return action, not found in $file
> +		exit 2
> +	fi
> +
> +	exit 0
> +fi
> +
> +# Some distributions, like Gentoo and Arch, use the configs kernel module to provide
> +# /proc/config.gz by default instead.
> +
> +if [ -e /proc/config.gz ]; then
> +	echo try gentoo
> +   #    zcat /proc/config.gz | grep -i <keyword>
> +   #    zgrep <keyword> /proc/config.gz
> +	if ! zgrep -q CONFIG_BPF_KPROBE_OVERRIDE=y           /proc/config.gz; then
> +		echo need CONFIG_BPF_KPROBE_OVERRIDE=y for D return action
> +		exit 2
> +	fi
> +	if ! zgrep -q grep CONFIG_FUNCTION_ERROR_INJECTION=y /proc/config.gz; then
> +		echo need CONFIG_FUNCTION_ERROR_INJECTION=y for D return action
> +		exit 2
> +	fi
> +
> +	exit 0
> +fi
> +
> +
> +# We cannot figure out the kernel configuration parameters.
> +# Go ahead, run the test, and hope for the best.
> +
> +exit 0
> diff --git a/test/unittest/actions/return/tst.override-getpid-entry.x b/test/unittest/actions/return/tst.override-getpid-entry.x
> new file mode 120000
> index 000000000..36e160027
> --- /dev/null
> +++ b/test/unittest/actions/return/tst.override-getpid-entry.x
> @@ -0,0 +1 @@
> +tst.destructive.x
> \ No newline at end of file
> diff --git a/test/unittest/actions/return/tst.override-getpid-return.x b/test/unittest/actions/return/tst.override-getpid-return.x
> new file mode 120000
> index 000000000..36e160027
> --- /dev/null
> +++ b/test/unittest/actions/return/tst.override-getpid-return.x
> @@ -0,0 +1 @@
> +tst.destructive.x
> \ No newline at end of file
> -- 
> 2.47.3
> 



More information about the DTrace-devel mailing list