diff mbox series

[v2] unlink08: use TST_EXP_FAIL(), turn comment into docparse and reword, copyright update

Message ID 20220902063341.21705-1-akumar@suse.de
State Accepted
Headers show
Series [v2] unlink08: use TST_EXP_FAIL(), turn comment into docparse and reword, copyright update | expand

Commit Message

Avinesh Kumar Sept. 2, 2022, 6:33 a.m. UTC
Signed-off-by: Avinesh Kumar <akumar@suse.de>
---
 testcases/kernel/syscalls/unlink/unlink08.c | 37 ++++++---------------
 1 file changed, 10 insertions(+), 27 deletions(-)

Comments

Petr Vorel Sept. 5, 2022, 2:45 p.m. UTC | #1
Hi Avinesh,

I merged with following diff:

* kept relevant headers (It might be a good practise to keep *relevant headers -
library can be rewritten and headers removed, the build would fail).
* fixed docparse formatting (blank line before list is needed

Thanks!

Kind regards,
Petr
Petr Vorel Sept. 5, 2022, 3:01 p.m. UTC | #2
Hi Avinesh,

FYI I also make subject shorter (it should be ~50 characters, the rest should go
to the blank separated log body.

Kind regards,
Petr
diff mbox series

Patch

diff --git a/testcases/kernel/syscalls/unlink/unlink08.c b/testcases/kernel/syscalls/unlink/unlink08.c
index f3ce46ad8..f75ba06e0 100644
--- a/testcases/kernel/syscalls/unlink/unlink08.c
+++ b/testcases/kernel/syscalls/unlink/unlink08.c
@@ -1,22 +1,20 @@ 
 // SPDX-License-Identifier: GPL-2.0-or-later
 /*
+ * Copyright (c) Linux Test Project, 2002-2022
  * Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
  */
 
-/*
- * Description:
- * The testcase checks the various errnos of the unlink(2).
- * 1) unlink() returns EACCES when deleting file in unwritable directory
- *    as an unprivileged user.
- * 2) unlink() returns EACCES when deleting file in "unsearchable directory
- *    as an unprivileged user.
- * 3) unlink() returns EISDIR when deleting directory for root
- * 4) unlink() returns EISDIR when deleting directory for regular user
+/*\
+ * [Description]
+ *
+ * Verify that unlink(2) fails with
+ * - EACCES when no write access to the directory containing pathname
+ * - EACCES when one of the directories in pathname did not allow search
+ * - EISDIR when deleting directory as root user
+ * - EISDIR when deleting directory as non-root user
  */
 
-#include <errno.h>
 #include <stdlib.h>
-#include <sys/types.h>
 #include <pwd.h>
 #include "tst_test.h"
 
@@ -36,21 +34,7 @@  static struct test_case_t {
 
 static void verify_unlink(struct test_case_t *tc)
 {
-	TEST(unlink(tc->name));
-	if (TST_RET != -1) {
-		tst_res(TFAIL, "unlink(<%s>) succeeded unexpectedly",
-			tc->desc);
-		return;
-	}
-
-	if (TST_ERR == tc->exp_errno) {
-		tst_res(TPASS | TTERRNO, "unlink(<%s>) failed as expected",
-			tc->desc);
-	} else {
-		tst_res(TFAIL | TTERRNO,
-			"unlink(<%s>) failed, expected errno: %s",
-			tc->desc, tst_strerrno(tc->exp_errno));
-	}
+	TST_EXP_FAIL(unlink(tc->name), tc->exp_errno, "%s", tc->desc);
 }
 
 static void do_unlink(unsigned int n)
@@ -65,7 +49,6 @@  static void do_unlink(unsigned int n)
 			verify_unlink(cases);
 			exit(0);
 		}
-
 		SAFE_WAITPID(pid, NULL, 0);
 	} else {
 		verify_unlink(cases);