diff mbox series

[v2] syscalls/mmap08: Use macro TST_EXP_FAIL_PTR_VOID()

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

Commit Message

Avinesh Kumar May 13, 2024, 1:08 p.m. UTC
Signed-off-by: Avinesh Kumar <akumar@suse.de>
---
 testcases/kernel/syscalls/mmap/mmap08.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

Comments

Petr Vorel May 13, 2024, 1:18 p.m. UTC | #1
Hi Avinesh,

...
>  static void run(void)
>  {
> -	TESTPTR(mmap(NULL, page_sz, PROT_WRITE, MAP_FILE | MAP_SHARED, fd, 0));
> +	TST_EXP_FAIL_PTR_VOID(mmap(NULL, page_sz, PROT_WRITE, MAP_FILE | MAP_SHARED, fd, 0), EBADF);

> -	if (TST_RET_PTR != MAP_FAILED) {
> -		tst_res(TFAIL, "mmap() passed unexpectedly");
> +	if(TST_RET_PTR != MAP_FAILED) {
Whitespace was broken (missing space after "if") + brackets were not needed any
more. I fixed it and merged together with mmap06 patch.

Thank you!

Kind regards,
Petr
diff mbox series

Patch

diff --git a/testcases/kernel/syscalls/mmap/mmap08.c b/testcases/kernel/syscalls/mmap/mmap08.c
index 5c9fd782c..f023446f5 100644
--- a/testcases/kernel/syscalls/mmap/mmap08.c
+++ b/testcases/kernel/syscalls/mmap/mmap08.c
@@ -8,7 +8,7 @@ 
 /*\
  * [Description]
  *
- * verify that, mmap() calls fails with errno EBADF when a file mapping
+ * Verify that, mmap() calls fails with errno EBADF when a file mapping
  * is requested but the fd is not a valid file descriptor.
  */
 
@@ -27,15 +27,10 @@  static void setup(void)
 
 static void run(void)
 {
-	TESTPTR(mmap(NULL, page_sz, PROT_WRITE, MAP_FILE | MAP_SHARED, fd, 0));
+	TST_EXP_FAIL_PTR_VOID(mmap(NULL, page_sz, PROT_WRITE, MAP_FILE | MAP_SHARED, fd, 0), EBADF);
 
-	if (TST_RET_PTR != MAP_FAILED) {
-		tst_res(TFAIL, "mmap() passed unexpectedly");
+	if(TST_RET_PTR != MAP_FAILED) {
 		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");
 	}
 }