diff mbox series

syscalls/mmap08: Use macro TST_EXP_FAIL_PTR_VOID()

Message ID 20240429194821.9112-1-akumar@suse.de
State Accepted
Headers show
Series syscalls/mmap08: Use macro TST_EXP_FAIL_PTR_VOID() | expand

Commit Message

Avinesh Kumar April 29, 2024, 7:48 p.m. UTC
Signed-off-by: Avinesh Kumar <akumar@suse.de>
---
 testcases/kernel/syscalls/mmap/mmap08.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

Comments

Petr Vorel May 7, 2024, 4:53 p.m. UTC | #1
Hi Avinesh,

> Signed-off-by: Avinesh Kumar <akumar@suse.de>
> ---
>  testcases/kernel/syscalls/mmap/mmap08.c | 11 +----------
>  1 file changed, 1 insertion(+), 10 deletions(-)

> diff --git a/testcases/kernel/syscalls/mmap/mmap08.c b/testcases/kernel/syscalls/mmap/mmap08.c
> index 5c9fd782c..befd73e14 100644
> --- a/testcases/kernel/syscalls/mmap/mmap08.c
> +++ b/testcases/kernel/syscalls/mmap/mmap08.c
> @@ -27,16 +27,7 @@ static void setup(void)

>  static void run(void)
>  {
> -	TESTPTR(mmap(NULL, page_sz, PROT_WRITE, MAP_FILE | MAP_SHARED, fd, 0));
> -
> -	if (TST_RET_PTR != MAP_FAILED) {
> -		tst_res(TFAIL, "mmap() passed unexpectedly");
> -		SAFE_MUNMAP(TST_RET_PTR, page_sz);
> -	} else if (TST_ERR == EBADF) {
> -		tst_res(TPASS, "mmap() failed with EBADF");
> -	} else {
> -		tst_res(TFAIL | TERRNO, "mmap() failed with an invalid errno");
> -	}
> +	TST_EXP_FAIL_PTR_VOID(mmap(NULL, page_sz, PROT_WRITE, MAP_FILE | MAP_SHARED, fd, 0), EBADF);

Don't we need to add:
	if (TST_RET_PTR != MAP_FAILED) {
		SAFE_MUNMAP(TST_RET_PTR, page_sz);

Also, while at it, could you please change docs: "verify that" => "Verify that" ?

Kind regards,
Petr

>  }

>  static void cleanup(void)
diff mbox series

Patch

diff --git a/testcases/kernel/syscalls/mmap/mmap08.c b/testcases/kernel/syscalls/mmap/mmap08.c
index 5c9fd782c..befd73e14 100644
--- a/testcases/kernel/syscalls/mmap/mmap08.c
+++ b/testcases/kernel/syscalls/mmap/mmap08.c
@@ -27,16 +27,7 @@  static void setup(void)
 
 static void run(void)
 {
-	TESTPTR(mmap(NULL, page_sz, PROT_WRITE, MAP_FILE | MAP_SHARED, fd, 0));
-
-	if (TST_RET_PTR != MAP_FAILED) {
-		tst_res(TFAIL, "mmap() passed unexpectedly");
-		SAFE_MUNMAP(TST_RET_PTR, page_sz);
-	} else if (TST_ERR == EBADF) {
-		tst_res(TPASS, "mmap() failed with EBADF");
-	} else {
-		tst_res(TFAIL | TERRNO, "mmap() failed with an invalid errno");
-	}
+	TST_EXP_FAIL_PTR_VOID(mmap(NULL, page_sz, PROT_WRITE, MAP_FILE | MAP_SHARED, fd, 0), EBADF);
 }
 
 static void cleanup(void)