[PATCH v2] selftests/mm: run_vmtests.sh: fail if invoked from the wrong directory

Sun Jian posted 1 patch 4 weeks, 1 day ago
tools/testing/selftests/mm/run_vmtests.sh | 7 +++++++
1 file changed, 7 insertions(+)
[PATCH v2] selftests/mm: run_vmtests.sh: fail if invoked from the wrong directory
Posted by Sun Jian 4 weeks, 1 day ago
run_vmtests.sh assumes it is invoked from tools/testing/selftests/mm.
When run from another working directory, relative paths can lead to
confusing failures. Detect this case and abort with a clear message.

Signed-off-by: Sun Jian <sun.jian.kdev@gmail.com>
---
 tools/testing/selftests/mm/run_vmtests.sh | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh
index d9173f2312b7..b7025afb56fd 100755
--- a/tools/testing/selftests/mm/run_vmtests.sh
+++ b/tools/testing/selftests/mm/run_vmtests.sh
@@ -5,6 +5,13 @@
 # Kselftest framework requirement - SKIP code is 4.
 ksft_skip=4
 
+# Verify invocation from the script directory.
+SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
+if [ "$(pwd -P)" != "$SCRIPT_DIR" ]; then
+    echo "Please run this test from $SCRIPT_DIR" >&2
+    exit 1
+fi
+
 count_total=0
 count_pass=0
 count_fail=0
-- 
2.43.0
Re: [PATCH v2] selftests/mm: run_vmtests.sh: fail if invoked from the wrong directory
Posted by SeongJae Park 4 weeks ago
On Sat, 10 Jan 2026 01:28:33 +0800 Sun Jian <sun.jian.kdev@gmail.com> wrote:

> run_vmtests.sh assumes it is invoked from tools/testing/selftests/mm.
> When run from another working directory, relative paths can lead to
> confusing failures. Detect this case and abort with a clear message.
> 
> Signed-off-by: Sun Jian <sun.jian.kdev@gmail.com>

Reviewed-by: SeongJae Park <sj@kernel.org>


Thanks,
SJ

[...]