[LTP] [PATCH] madvise09: Make memory map output conditional and more informative

“Samir samir@linux.ibm.com
Wed Apr 1 07:41:46 CEST 2026


The memory map was being printed unconditionally for every test run,
creating verbose output even for successful tests. This change makes
the output conditional and adds useful context.

Changes:
- Only display memory map when there are issues (corrupted pages or
  no pages freed), eliminating verbose output for successful runs
- Add legend to memory map output explaining symbols:
  p=present, _=freed, ?=corrupted
- Enhance TPASS message to show freed page count (e.g., "126/128 freed")
- Improve TFAIL message to show count of corrupted pages

Before:
  TINFO: Memory map: p_________p_____________________...
  TPASS: Pages MADV_FREE were freed on low memory

After (successful run):
  TPASS: Pages MADV_FREE were freed on low memory (126/128 freed)

After (failure with issues):
  TINFO: Memory map: p_________p??___ (p=present, _=freed, ?=corrupted)
  TFAIL: Found 2 corrupted page(s)

This improves test output readability while preserving debugging
information when needed.

Signed-off-by: Samir <samir@linux.ibm.com>
---
 testcases/kernel/syscalls/madvise/madvise09.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/testcases/kernel/syscalls/madvise/madvise09.c b/testcases/kernel/syscalls/madvise/madvise09.c
index 1fad983fd..87fe096fb 100644
--- a/testcases/kernel/syscalls/madvise/madvise09.c
+++ b/testcases/kernel/syscalls/madvise/madvise09.c
@@ -219,15 +219,17 @@ static void child(void)
 	}
 	map[PAGES] = '\0';
 
-	tst_res(TINFO, "Memory map: %s", map);
+	/* Only show memory map if there are issues or for debugging */
+	if (corrupted || freed == 0)
+		tst_res(TINFO, "Memory map: %s (p=present, _=freed, ?=corrupted)", map);
 
 	if (freed)
-		tst_res(TPASS, "Pages MADV_FREE were freed on low memory");
+		tst_res(TPASS, "Pages MADV_FREE were freed on low memory (%u/%u freed)", freed, PAGES);
 	else
 		tst_res(TFAIL, "No MADV_FREE page was freed on low memory");
 
 	if (corrupted)
-		tst_res(TFAIL, "Found corrupted page");
+		tst_res(TFAIL, "Found %u corrupted page(s)", corrupted);
 	else
 		tst_res(TPASS, "All pages have expected content");
 
-- 
2.52.0



More information about the ltp mailing list