public inbox for dtrace@lists.linux.dev
 help / color / mirror / Atom feed
From: Kris Van Hees <kris.van.hees@oracle.com>
To: eugene.loh@oracle.com
Cc: dtrace@lists.linux.dev, dtrace-devel@oss.oracle.com
Subject: Re: [PATCH 4/4] test: Skip D return() action if kernel not configured right
Date: Mon, 6 Oct 2025 18:14:50 -0400	[thread overview]
Message-ID: <aOQ/WnsdkXAClL87@oracle.com> (raw)
In-Reply-To: <20251006215726.8893-4-eugene.loh@oracle.com>

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

On Mon, Oct 06, 2025 at 05:57:26PM -0400, eugene.loh@oracle.com wrote:
> From: Eugene Loh <eugene.loh@oracle.com>
> 
> Most of the err.* tests can still be run, since they test other
> failure modes.
> 
> Signed-off-by: Eugene Loh <eugene.loh@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
> 

  reply	other threads:[~2025-10-06 22:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-06 21:57 [PATCH 1/4] test: Turn char[16] into string to ignore garbage bytes eugene.loh
2025-10-06 21:57 ` [PATCH 2/4] test: Use syscall in case of no execveat() wrapper eugene.loh
2025-10-07 15:38   ` [DTrace-devel] " Kris Van Hees
2025-10-07 17:44     ` Eugene Loh
2025-10-06 21:57 ` [PATCH 3/4] test: Supply XFAIL for tests that use vtimestamp eugene.loh
2025-10-07 15:41   ` [DTrace-devel] " Kris Van Hees
2025-10-07 22:54     ` Eugene Loh
2025-10-06 21:57 ` [PATCH 4/4] test: Skip D return() action if kernel not configured right eugene.loh
2025-10-06 22:14   ` Kris Van Hees [this message]
2025-10-07 15:37 ` [PATCH 1/4] test: Turn char[16] into string to ignore garbage bytes Kris Van Hees

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aOQ/WnsdkXAClL87@oracle.com \
    --to=kris.van.hees@oracle.com \
    --cc=dtrace-devel@oss.oracle.com \
    --cc=dtrace@lists.linux.dev \
    --cc=eugene.loh@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox