[PATCH] selftests/mm: skip split_huge_page_test without the split_huge_pages file

Sasha Levin posted 1 patch an hour ago
tools/testing/selftests/mm/split_huge_page_test.c | 3 +++
1 file changed, 3 insertions(+)
[PATCH] selftests/mm: skip split_huge_page_test without the split_huge_pages file
Posted by Sasha Levin an hour ago
Every case in split_huge_page_test goes through
/sys/kernel/debug/split_huge_pages. When that file does not exist,
because debugfs is not mounted or the kernel has no CONFIG_DEBUG_FS, the
first write bails out of the whole test and it is reported as a failure:

  Bail out! write_file(/sys/kernel/debug/split_huge_pages): No such file or directory

Skip the test in that case.

Fixes: fa6c02315f74 ("mm: huge_memory: a new debugfs interface for splitting THP tests")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
Found with KernelCI's NVIDIA lab, which runs the tests in a chroot
without debugfs. Tested on an AMD EPYC 9655P with KernelCI's x86_64
build of next-20261104: without debugfs the test now skips, and with
debugfs mounted it still passes all 62 cases.

 tools/testing/selftests/mm/split_huge_page_test.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/testing/selftests/mm/split_huge_page_test.c
index 33a2473327bb7..deabb7db06192 100644
--- a/tools/testing/selftests/mm/split_huge_page_test.c
+++ b/tools/testing/selftests/mm/split_huge_page_test.c
@@ -610,6 +610,9 @@ int main(int argc, char **argv)
 	if (!thp_is_enabled())
 		ksft_exit_skip("Transparent Hugepages not available\n");
 
+	if (access(SPLIT_DEBUGFS, W_OK))
+		ksft_exit_skip("%s: %s\n", SPLIT_DEBUGFS, strerror(errno));
+
 	if (argc > 1)
 		optional_xfs_path = argv[1];
 
-- 
2.53.0