On Wed, 2026-07-22 at 15:34 +0200, Gabriele Monaco wrote: > I tried to refactor it to follow more standard selftest building, > avoiding to maintain things ourselves. The only drawback is that you'd > have to move the tlob_*.c files to selftests/verification , then we can > still use RV_BINDIR but support it only via Makefile and > run_tlob_tests.sh (so let's drop defining it in all tests and save > inconvenience if things ever change).
I made a mistake in the Makefile (OUTPUT isn't populated before lib.mk), please find the fixed version attached. And really, stop skipping the test result if there is a mistake in the build system, that should be LOUD. I removed all exit_unsupported for you (as I already mentioned, you can use chrt:program taskset:program for those instead, all other things are real errors). >From 088d371276d4bdb67d23941e178a351b6afa309a Mon Sep 17 00:00:00 2001 From: Gabriele Monaco <[email protected]> Date: Wed, 22 Jul 2026 15:29:21 +0200 Subject: [PATCH] selftests/verification: Simplify tlob tests Squash this with the other patch should you accept it! Drop nested Makefile in favour of lib.mk and simplify run_tlob_tests --- .../testing/selftests/verification/.gitignore | 4 +- tools/testing/selftests/verification/Makefile | 18 +---- .../verification/test.d/tlob/Makefile | 28 ------- .../test.d/tlob/run_tlob_tests.sh | 79 +------------------ .../verification/test.d/tlob/uprobe_bind.tc | 5 -- .../test.d/tlob/uprobe_detail_running.tc | 5 -- .../test.d/tlob/uprobe_detail_sleeping.tc | 5 -- .../test.d/tlob/uprobe_detail_waiting.tc | 10 +-- .../verification/test.d/tlob/uprobe_multi.tc | 1 - .../test.d/tlob/uprobe_violation.tc | 1 - .../verification/{test.d/tlob => }/tlob_sym.c | 0 .../{test.d/tlob => }/tlob_target.c | 0 12 files changed, 9 insertions(+), 147 deletions(-) delete mode 100644 tools/testing/selftests/verification/test.d/tlob/Makefile rename tools/testing/selftests/verification/{test.d/tlob => }/tlob_sym.c (100%) rename tools/testing/selftests/verification/{test.d/tlob => }/tlob_target.c (100%) diff --git a/tools/testing/selftests/verification/.gitignore b/tools/testing/selftests/verification/.gitignore index cbbd03ee16c7..d2f231f1bacb 100644 --- a/tools/testing/selftests/verification/.gitignore +++ b/tools/testing/selftests/verification/.gitignore @@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0-only logs -test.d/tlob/tlob_sym -test.d/tlob/tlob_target +tlob_sym +tlob_target diff --git a/tools/testing/selftests/verification/Makefile b/tools/testing/selftests/verification/Makefile index 0b32bdfdb8db..aa17478076b1 100644 --- a/tools/testing/selftests/verification/Makefile +++ b/tools/testing/selftests/verification/Makefile @@ -4,22 +4,8 @@ TEST_PROGS := verificationtest-ktap TEST_FILES := test.d settings EXTRA_CLEAN := $(OUTPUT)/logs/* -# Subdirectories that provide binaries used by the test runner. -# Each entry must contain a Makefile that accepts OUTDIR= and -# deposits its binaries there. -BUILD_SUBDIRS := test.d/tlob +TEST_GEN_FILES := tlob_sym tlob_target include ../lib.mk -all: $(patsubst %,_build_%,$(BUILD_SUBDIRS)) - -clean: $(patsubst %,_clean_%,$(BUILD_SUBDIRS)) - -.PHONY: $(patsubst %,_build_%,$(BUILD_SUBDIRS)) \ - $(patsubst %,_clean_%,$(BUILD_SUBDIRS)) - -$(patsubst %,_build_%,$(BUILD_SUBDIRS)): _build_%: - $(MAKE) -C $* OUTDIR="$(OUTPUT)" TOOLS_INCLUDES="$(TOOLS_INCLUDES)" - -$(patsubst %,_clean_%,$(BUILD_SUBDIRS)): _clean_%: - $(MAKE) -C $* OUTDIR="$(OUTPUT)" clean +export RV_BINDIR := $(OUTPUT) diff --git a/tools/testing/selftests/verification/test.d/tlob/Makefile b/tools/testing/selftests/verification/test.d/tlob/Makefile deleted file mode 100644 index 05a2d2599c4e..000000000000 --- a/tools/testing/selftests/verification/test.d/tlob/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -# Builds tlob selftest helper binaries in the directory of this Makefile. -# -# Invoked by ../../Makefile via BUILD_SUBDIRS; outputs tlob_sym and -# tlob_target alongside the .tc scripts so they are self-contained. - -CFLAGS += $(TOOLS_INCLUDES) - -# For standalone execution via vng -FTRACETEST := ../../../ftrace/ftracetest -LOGDIR ?= ../../logs - -.PHONY: all -all: tlob_sym tlob_target - -tlob_sym: tlob_sym.c - $(CC) $(CFLAGS) -o $@ $< - -tlob_target: tlob_target.c - $(CC) $(CFLAGS) -o $@ $< - -.PHONY: run_tests -run_tests: all - @./run_tlob_tests.sh - -.PHONY: clean -clean: - $(RM) tlob_sym tlob_target diff --git a/tools/testing/selftests/verification/test.d/tlob/run_tlob_tests.sh b/tools/testing/selftests/verification/test.d/tlob/run_tlob_tests.sh index cd949756e713..6bedb1813891 100755 --- a/tools/testing/selftests/verification/test.d/tlob/run_tlob_tests.sh +++ b/tools/testing/selftests/verification/test.d/tlob/run_tlob_tests.sh @@ -2,89 +2,18 @@ # SPDX-License-Identifier: GPL-2.0 # # Standalone runner for tlob selftests -# Usage: ./run_tlob_tests.sh [options] -# -# Options: -# -v, --verbose Verbose output -# -k, --keep Keep test logs -# -l, --logdir DIR Log directory (default: ../../logs) -# -h, --help Show this help set -e SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" FTRACETEST="$SCRIPT_DIR/../../../ftrace/ftracetest" -LOGDIR="$SCRIPT_DIR/../../logs" -VERBOSE="" -KEEP="" -EXTRA_ARGS="" - -# Parse arguments -while [[ $# -gt 0 ]]; do - case $1 in - -v|--verbose) - VERBOSE="-v" - shift - ;; - -k|--keep) - KEEP="-k" - shift - ;; - -l|--logdir) - LOGDIR="$2" - shift 2 - ;; - -h|--help) - echo "Usage: $0 [options]" - echo "" - echo "Options:" - echo " -v, --verbose Verbose output" - echo " -k, --keep Keep test logs" - echo " -l, --logdir DIR Log directory (default: ../../logs)" - echo " -h, --help Show this help" - echo "" - echo "Examples:" - echo " $0 # Run all tlob tests" - echo " $0 -v # Run with verbose output" - echo " $0 -v -l /tmp/tlob-logs # Custom log directory" - echo "" - echo "With vng:" - echo " vng -v --rwdir $LOGDIR -- $0" - exit 0 - ;; - *) - EXTRA_ARGS="$EXTRA_ARGS $1" - shift - ;; - esac -done # Build test helpers echo "Building tlob test helpers..." -make -C "$SCRIPT_DIR" all - -# Check ftracetest exists -if [ ! -x "$FTRACETEST" ]; then - echo "Error: $FTRACETEST not found or not executable" - echo "Make sure you're running from the correct directory" - exit 1 -fi - -# Create log directory -mkdir -p "$LOGDIR" - -# Run tests -echo "Running tlob selftests..." -echo "Log directory: $LOGDIR" -echo "" +make -C "$SCRIPT_DIR/../.." all # Export RV_BINDIR so test scripts can find tlob_target and tlob_sym -export RV_BINDIR="$SCRIPT_DIR" - -# Pass the test directory, not individual .tc files -# ftracetest will discover all .tc files in the directory -"$FTRACETEST" -K $VERBOSE $KEEP --rv --logdir "$LOGDIR" \ - "$SCRIPT_DIR" $EXTRA_ARGS +export RV_BINDIR="$(realpath "$SCRIPT_DIR/../..")" -echo "" -echo "Tests completed. Logs saved to: $LOGDIR" +# Run ftracetest, forwarding all options and passing the test directory +exec "$FTRACETEST" -K --rv "$SCRIPT_DIR" "$@" diff --git a/tools/testing/selftests/verification/test.d/tlob/uprobe_bind.tc b/tools/testing/selftests/verification/test.d/tlob/uprobe_bind.tc index 4a1c18c7485a..efa4ae47ce72 100644 --- a/tools/testing/selftests/verification/test.d/tlob/uprobe_bind.tc +++ b/tools/testing/selftests/verification/test.d/tlob/uprobe_bind.tc @@ -3,17 +3,12 @@ # description: Test tlob monitor uprobe binding (visible in monitor file, removable, duplicate rejected) # requires: tlob:monitor -RV_BINDIR="${RV_BINDIR:-$(realpath "$(dirname "${1:-$0}")")}" UPROBE_TARGET="${RV_BINDIR}/tlob_target" TLOB_SYM="${RV_BINDIR}/tlob_sym" -[ -x "$UPROBE_TARGET" ] || exit_unsupported -[ -x "$TLOB_SYM" ] || exit_unsupported TLOB_MONITOR=monitors/tlob/monitor busy_offset=$("$TLOB_SYM" sym_offset "$UPROBE_TARGET" tlob_busy_work 2>/dev/null) stop_offset=$("$TLOB_SYM" sym_offset "$UPROBE_TARGET" tlob_busy_work_done 2>/dev/null) -[ -n "$busy_offset" ] || exit_unsupported -[ -n "$stop_offset" ] || exit_unsupported "$UPROBE_TARGET" 30000 & busy_pid=$! diff --git a/tools/testing/selftests/verification/test.d/tlob/uprobe_detail_running.tc b/tools/testing/selftests/verification/test.d/tlob/uprobe_detail_running.tc index afca157b5ea4..ef53b1b70104 100644 --- a/tools/testing/selftests/verification/test.d/tlob/uprobe_detail_running.tc +++ b/tools/testing/selftests/verification/test.d/tlob/uprobe_detail_running.tc @@ -3,17 +3,12 @@ # description: Test tlob monitor detail running (running_ns dominates when task busy-spins between probes) # requires: tlob:monitor -RV_BINDIR="${RV_BINDIR:-$(realpath "$(dirname "${1:-$0}")")}" UPROBE_TARGET="${RV_BINDIR}/tlob_target" TLOB_SYM="${RV_BINDIR}/tlob_sym" -[ -x "$UPROBE_TARGET" ] || exit_unsupported -[ -x "$TLOB_SYM" ] || exit_unsupported TLOB_MONITOR=monitors/tlob/monitor start_offset=$("$TLOB_SYM" sym_offset "$UPROBE_TARGET" tlob_busy_work 2>/dev/null) stop_offset=$("$TLOB_SYM" sym_offset "$UPROBE_TARGET" tlob_busy_work_done 2>/dev/null) -[ -n "$start_offset" ] || exit_unsupported -[ -n "$stop_offset" ] || exit_unsupported "$UPROBE_TARGET" 5000 & busy_pid=$! diff --git a/tools/testing/selftests/verification/test.d/tlob/uprobe_detail_sleeping.tc b/tools/testing/selftests/verification/test.d/tlob/uprobe_detail_sleeping.tc index 0a6470b4cadb..f97e18059e15 100644 --- a/tools/testing/selftests/verification/test.d/tlob/uprobe_detail_sleeping.tc +++ b/tools/testing/selftests/verification/test.d/tlob/uprobe_detail_sleeping.tc @@ -3,17 +3,12 @@ # description: Test tlob monitor detail sleeping (sleeping_ns dominates when task blocks between probes) # requires: tlob:monitor -RV_BINDIR="${RV_BINDIR:-$(realpath "$(dirname "${1:-$0}")")}" UPROBE_TARGET="${RV_BINDIR}/tlob_target" TLOB_SYM="${RV_BINDIR}/tlob_sym" -[ -x "$UPROBE_TARGET" ] || exit_unsupported -[ -x "$TLOB_SYM" ] || exit_unsupported TLOB_MONITOR=monitors/tlob/monitor start_offset=$("$TLOB_SYM" sym_offset "$UPROBE_TARGET" tlob_sleep_work 2>/dev/null) stop_offset=$("$TLOB_SYM" sym_offset "$UPROBE_TARGET" tlob_sleep_work_done 2>/dev/null) -[ -n "$start_offset" ] || exit_unsupported -[ -n "$stop_offset" ] || exit_unsupported "$UPROBE_TARGET" 5000 sleep & busy_pid=$! diff --git a/tools/testing/selftests/verification/test.d/tlob/uprobe_detail_waiting.tc b/tools/testing/selftests/verification/test.d/tlob/uprobe_detail_waiting.tc index ef22fce700fc..0a5c41e57617 100644 --- a/tools/testing/selftests/verification/test.d/tlob/uprobe_detail_waiting.tc +++ b/tools/testing/selftests/verification/test.d/tlob/uprobe_detail_waiting.tc @@ -1,22 +1,14 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0-or-later # description: Test tlob monitor detail waiting (waiting_ns dominates when task is preempted between probes) -# requires: tlob:monitor +# requires: tlob:monitor chrt:program taskset:program -RV_BINDIR="${RV_BINDIR:-$(realpath "$(dirname "${1:-$0}")")}" UPROBE_TARGET="${RV_BINDIR}/tlob_target" TLOB_SYM="${RV_BINDIR}/tlob_sym" -[ -x "$UPROBE_TARGET" ] || exit_unsupported -[ -x "$TLOB_SYM" ] || exit_unsupported TLOB_MONITOR=monitors/tlob/monitor -command -v chrt > /dev/null || exit_unsupported -command -v taskset > /dev/null || exit_unsupported - start_offset=$("$TLOB_SYM" sym_offset "$UPROBE_TARGET" tlob_preempt_work 2>/dev/null) stop_offset=$("$TLOB_SYM" sym_offset "$UPROBE_TARGET" tlob_preempt_work_done 2>/dev/null) -[ -n "$start_offset" ] || exit_unsupported -[ -n "$stop_offset" ] || exit_unsupported cpu=0 diff --git a/tools/testing/selftests/verification/test.d/tlob/uprobe_multi.tc b/tools/testing/selftests/verification/test.d/tlob/uprobe_multi.tc index a798f3e9b3fa..3c606b354ad2 100644 --- a/tools/testing/selftests/verification/test.d/tlob/uprobe_multi.tc +++ b/tools/testing/selftests/verification/test.d/tlob/uprobe_multi.tc @@ -3,7 +3,6 @@ # description: Test tlob monitor multiple uprobe bindings (different offsets fire independently) # requires: tlob:monitor -RV_BINDIR="${RV_BINDIR:-$(realpath "$(dirname "${1:-$0}")")}" UPROBE_TARGET="${RV_BINDIR}/tlob_target" TLOB_SYM="${RV_BINDIR}/tlob_sym" [ -x "$UPROBE_TARGET" ] || exit_unsupported diff --git a/tools/testing/selftests/verification/test.d/tlob/uprobe_violation.tc b/tools/testing/selftests/verification/test.d/tlob/uprobe_violation.tc index 8a94bd679b88..ff8b736932ca 100644 --- a/tools/testing/selftests/verification/test.d/tlob/uprobe_violation.tc +++ b/tools/testing/selftests/verification/test.d/tlob/uprobe_violation.tc @@ -3,7 +3,6 @@ # description: Test tlob monitor budget violation (error_env_tlob and detail_env_tlob fire with correct fields) # requires: tlob:monitor -RV_BINDIR="${RV_BINDIR:-$(realpath "$(dirname "${1:-$0}")")}" UPROBE_TARGET="${RV_BINDIR}/tlob_target" TLOB_SYM="${RV_BINDIR}/tlob_sym" [ -x "$UPROBE_TARGET" ] || exit_unsupported diff --git a/tools/testing/selftests/verification/test.d/tlob/tlob_sym.c b/tools/testing/selftests/verification/tlob_sym.c similarity index 100% rename from tools/testing/selftests/verification/test.d/tlob/tlob_sym.c rename to tools/testing/selftests/verification/tlob_sym.c diff --git a/tools/testing/selftests/verification/test.d/tlob/tlob_target.c b/tools/testing/selftests/verification/tlob_target.c similarity index 100% rename from tools/testing/selftests/verification/test.d/tlob/tlob_target.c rename to tools/testing/selftests/verification/tlob_target.c -- 2.55.0
