[LTP] [PATCH v1] ksm: Fix sysfs path concatenation in ksm_test.h

Wei Gao wegao@suse.com
Mon Jun 8 09:44:15 CEST 2026


The check() function in ksm_test.h was concatenating PATH_MM_KSM and
the relative path (e.g. "run") directly without a directory separator:

    snprintf(fullpath, BUFSIZ, PATH_MM_KSM "%s", path);

This resulted in invalid paths like "/sys/kernel/mm/ksmrun", causing
the tests to fail with TBROK (Failed to open FILE '/sys/kernel/mm/ksmrun').

Fix this by adding the missing slash between PATH_MM_KSM and the subpath.

Fixes: 40a366b53adc ("lib: Introduce tst_path_defs.h to consolidate system paths")
Signed-off-by: Wei Gao <wegao@suse.com>
---
 testcases/kernel/mem/ksm/ksm_test.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/testcases/kernel/mem/ksm/ksm_test.h b/testcases/kernel/mem/ksm/ksm_test.h
index d04aa8e2b..d3f61edfb 100644
--- a/testcases/kernel/mem/ksm/ksm_test.h
+++ b/testcases/kernel/mem/ksm/ksm_test.h
@@ -13,7 +13,7 @@ static inline void check(char *path, long int value)
 	char fullpath[BUFSIZ];
 	long actual_val;
 
-	snprintf(fullpath, BUFSIZ, PATH_MM_KSM "%s", path);
+	snprintf(fullpath, BUFSIZ, PATH_MM_KSM "/%s", path);
 	SAFE_FILE_SCANF(fullpath, "%ld", &actual_val);
 
 	if (actual_val != value)
-- 
2.54.0



More information about the ltp mailing list