Skip to contentSkip to conversation

syscalls/mmap06: use macro TST_EXP_FAIL_PTR_VOID()

PATCH In review Avinesh Kumar 2 participants 3 messages Apr 29, 2024 – May 13, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 syscalls/mmap06: use macro TST_EXP_FAIL_PTR_VOID()

---
 testcases/kernel/syscalls/mmap/mmap06.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)
testcases/kernel/syscalls/mmap/mmap06.c +1 -10
index 615743fa7..02c186a3a 100644
@@ -56,16 +56,7 @@ static void run(unsigned int i)
 {
 	struct tcase *tc = &tcases[i];
 
-	TESTPTR(mmap(NULL, tc->length, tc->prot, tc->flags, fd, 0));
-
-	if (TST_RET_PTR != MAP_FAILED) {
-		tst_res(TFAIL, "mmap() was successful unexpectedly");
-		SAFE_MUNMAP(TST_RET_PTR, MMAPSIZE);
-	} else if (TST_ERR == tc->exp_errno) {
-		tst_res(TPASS | TERRNO, "mmap() failed with");
-	} else {
-		tst_res(TFAIL | TERRNO, "mmap() failed unexpectedly");
-	}
+	TST_EXP_FAIL_PTR_VOID(mmap(NULL, tc->length, tc->prot, tc->flags, fd, 0), tc->exp_errno);
 }
 
 static void cleanup(void)
Signature · 5 lines
2.44.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Hi Avinesh,

...

testcases/kernel/syscalls/mmap/mmap06.c static void run(unsigned int i) · line 59

Quoted 11 lines
testcases/kernel/syscalls/mmap/mmap06.c +1 -10
-	TESTPTR(mmap(NULL, tc->length, tc->prot, tc->flags, fd, 0));
-
-	if (TST_RET_PTR != MAP_FAILED) {
-		tst_res(TFAIL, "mmap() was successful unexpectedly");
-		SAFE_MUNMAP(TST_RET_PTR, MMAPSIZE);
-	} else if (TST_ERR == tc->exp_errno) {
-		tst_res(TPASS | TERRNO, "mmap() failed with");
-	} else {
-		tst_res(TFAIL | TERRNO, "mmap() failed unexpectedly");
-	}
+	TST_EXP_FAIL_PTR_VOID(mmap(NULL, tc->length, tc->prot, tc->flags, fd, 0), tc->exp_errno);

Also here should IMHO be:

	if (TST_RET_PTR != MAP_FAILED) {
		SAFE_MUNMAP(TST_RET_PTR, page_sz);

Kind regards,
Petr

Quoted 3 lines

}

static void cleanup(void)

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw

PATCH v2 1/1 syscalls/mmap06: use macro TST_EXP_FAIL_PTR_VOID()

---
 testcases/kernel/syscalls/mmap/mmap06.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
testcases/kernel/syscalls/mmap/mmap06.c +2 -7
index 615743fa7..c825abf9e 100644
@@ -56,15 +56,10 @@ static void run(unsigned int i)
 {
 	struct tcase *tc = &tcases[i];
 
-	TESTPTR(mmap(NULL, tc->length, tc->prot, tc->flags, fd, 0));
+	TST_EXP_FAIL_PTR_VOID(mmap(NULL, tc->length, tc->prot, tc->flags, fd, 0), tc->exp_errno);
 
 	if (TST_RET_PTR != MAP_FAILED) {
-		tst_res(TFAIL, "mmap() was successful unexpectedly");
-		SAFE_MUNMAP(TST_RET_PTR, MMAPSIZE);
-	} else if (TST_ERR == tc->exp_errno) {
-		tst_res(TPASS | TERRNO, "mmap() failed with");
-	} else {
-		tst_res(TFAIL | TERRNO, "mmap() failed unexpectedly");
+		SAFE_MUNMAP(TST_RET_PTR, page_sz);
 	}
 }
 
Signature · 5 lines
2.44.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp