diff mbox series

unlink08: use TST_EXP_FAIL() and turn comment into docparse, reword

Message ID 20220715071216.15404-1-akumar@suse.de
State Superseded
Headers show
Series unlink08: use TST_EXP_FAIL() and turn comment into docparse, reword | expand

Commit Message

Avinesh Kumar July 15, 2022, 7:12 a.m. UTC
Signed-off-by: Avinesh Kumar <akumar@suse.de>
---
 testcases/kernel/syscalls/unlink/unlink08.c | 35 +++++++--------------
 1 file changed, 11 insertions(+), 24 deletions(-)

Comments

Petr Vorel Sept. 1, 2022, 6:53 a.m. UTC | #1
Hi Avinesh,

most of the tips for unlink07 apply here as well
https://lore.kernel.org/ltp/YxBWRndhRQRF69Cl@pevik/

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..d16607540 100644
--- a/testcases/kernel/syscalls/unlink/unlink08.c
+++ b/testcases/kernel/syscalls/unlink/unlink08.c
@@ -3,15 +3,14 @@ 
  * 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>
@@ -36,21 +35,9 @@  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)