On Tue, 2026-05-12 at 02:24 +0800, [email protected] wrote:
> From: Wen Yang <[email protected]>
> 
> verificationtest-ktap used a CWD-relative path (../ftrace/ftracetest)
> and a relative argument (../verification) for --rv.  This works when
> the shell changes into the verification directory first, but breaks
> when the script is invoked directly - e.g. by the kselftest runner or
> vng - because the working directory is the kernel source root, not the
> script's own directory.
> 
> Fix this by computing the script's directory from $0 with cd/dirname/pwd
> and using absolute paths for both the ftracetest invocation and the --rv
> argument.  Also export the directory to PATH so that check_requires in
> the ftracetest framework can locate helper binaries.
> 
> Signed-off-by: Wen Yang <[email protected]>

Just out of curiosity, how do you run the selftests?
Are you calling the script directly just to run /some/ of them?

The officially supported way is through make [1]:

  make -C tools/testing/selftests TARGETS=verification run_tests

(though I find it faster to omit TARGETS and just do make -C
tools/testing/selftests/verification).

Calling with make should set up all paths as needed.

> ---
>  tools/testing/selftests/verification/verificationtest-ktap | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/verification/verificationtest-ktap
> b/tools/testing/selftests/verification/verificationtest-ktap
> index 18f7fe324e2f..456b8578a307 100755
> --- a/tools/testing/selftests/verification/verificationtest-ktap
> +++ b/tools/testing/selftests/verification/verificationtest-ktap
> @@ -5,4 +5,6 @@
>  #
>  # Copyright (C) Arm Ltd., 2023
>  
> -../ftrace/ftracetest -K -v --rv ../verification
> +dir=$(cd "$(dirname "$0")" && pwd)
> +export PATH="$dir:$PATH"

Then if you really really need to call it directly, do you need to override
PATH?

And isn't it clearer to do:

  dir=$(realpath "$(dirname "$0")")

Thanks,
Gabriele

[1] - https://www.kernel.org/doc/html/latest/dev-tools/kselftest.html

> +"$dir/../ftrace/ftracetest" -K -v --rv "$dir"


Reply via email to