[LTP] [PATCH] madvise11: Allow test to skip if MADV_SOFT_OFFLINE is not supported

Edward Liaw edliaw@google.com
Fri Nov 3 00:00:53 CET 2023


madvise11 will exit with TFAIL if CONFIG_MEMORY_FAILURE is not
configured.  Skip the TFAIL if EINVAL is returned by madvise.

Signed-off-by: Edward Liaw <edliaw@google.com>
---
 testcases/kernel/syscalls/madvise/madvise11.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/testcases/kernel/syscalls/madvise/madvise11.c b/testcases/kernel/syscalls/madvise/madvise11.c
index 3cde85ef5..0793319d2 100644
--- a/testcases/kernel/syscalls/madvise/madvise11.c
+++ b/testcases/kernel/syscalls/madvise/madvise11.c
@@ -162,7 +162,7 @@ static void *alloc_mem(void *threadnum)
 	err = allocate_offline(tnum);
 	tst_res(TINFO,
 		"Thread [%d] returned %d, %s.", tnum, err, (err ? "failed" : "succeeded"));
-	return (void *)(uintptr_t) (err ? -1 : 0);
+	return (void *)(uintptr_t) err;
 }
 
 static void stress_alloc_offl(void)
@@ -188,8 +188,9 @@ static void stress_alloc_offl(void)
 
 		SAFE_PTHREAD_JOIN(thread_ids[thread_index], &status);
 		if ((intptr_t)status != 0) {
-			tst_res(TFAIL, "thread [%d] - exited with errors",
-				thread_index);
+			if ((intptr_t)status != EINVAL)
+				tst_res(TFAIL, "thread [%d] - exited with errors",
+					thread_index);
 			thread_failure++;
 		}
 	}
-- 
2.42.0.869.gea05f2083d-goog



More information about the ltp mailing list