Linux Test Project
 help / color / mirror / Atom feed
* [LTP] [PATCH v2] unlink07: use TST_EXP_FAIL(), docparse format, copyright update  and remove redundant headers
@ 2022-09-02  6:23 Avinesh Kumar
  2022-09-05 14:49 ` Petr Vorel
  0 siblings, 1 reply; 2+ messages in thread
From: Avinesh Kumar @ 2022-09-02  6:23 UTC (permalink / raw)
  To: ltp

Signed-off-by: Avinesh Kumar <akumar@suse.de>
---
 testcases/kernel/syscalls/unlink/unlink07.c | 43 +++++++--------------
 1 file changed, 14 insertions(+), 29 deletions(-)

diff --git a/testcases/kernel/syscalls/unlink/unlink07.c b/testcases/kernel/syscalls/unlink/unlink07.c
index 869bd5f51..9c9ed0132 100644
--- a/testcases/kernel/syscalls/unlink/unlink07.c
+++ b/testcases/kernel/syscalls/unlink/unlink07.c
@@ -1,23 +1,22 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) Linux Test Project, 2002-2022
  */
 
-/*
- * Description:
- * The testcase checks the various errnos of the unlink(2).
- * 1) unlink() returns ENOENT if file doesn't exist.
- * 2) unlink() returns ENOENT if path is empty.
- * 3) unlink() returns ENOENT if path contains a non-existent file.
- * 4) unlink() returns EFAULT if address is invalid.
- * 5) unlink() returns ENOTDIR if path contains a regular file.
- * 6) unlink() returns ENAMETOOLONG if path contains a regular file.
+/*\
+ * [Description]
+ *
+ * Verify that unlink() fails with
+ * - ENOENT when file does not exist
+ * - ENOENT when pathname is empty
+ * - ENOENT when a component in pathname does not exist
+ * - EFAULT when pathname points outside the accessible address space
+ * - ENOTDIR when a component used as a directory in pathname is not,
+ * in fact, a directory
+ * - ENAMETOOLONG when pathname is too long
  */
 
-#include <errno.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/param.h>	/* for PATH_MAX */
 #include "tst_test.h"
 
 static char longpathname[PATH_MAX + 2];
@@ -39,26 +38,12 @@ static void verify_unlink(unsigned int n)
 {
 	struct test_case_t *tc = &tcases[n];
 
-	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 setup(void)
 {
-	unsigned int n;
+	size_t n;
 
 	SAFE_TOUCH("file", 0777, NULL);
 
-- 
2.37.1


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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [LTP] [PATCH v2] unlink07: use TST_EXP_FAIL(), docparse format, copyright update  and remove redundant headers
  2022-09-02  6:23 [LTP] [PATCH v2] unlink07: use TST_EXP_FAIL(), docparse format, copyright update and remove redundant headers Avinesh Kumar
@ 2022-09-05 14:49 ` Petr Vorel
  0 siblings, 0 replies; 2+ messages in thread
From: Petr Vorel @ 2022-09-05 14:49 UTC (permalink / raw)
  To: Avinesh Kumar; +Cc: ltp

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!

...
> +++ b/testcases/kernel/syscalls/unlink/unlink07.c
> @@ -1,23 +1,22 @@
>  // SPDX-License-Identifier: GPL-2.0-or-later
>  /*
>   * Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
> + * Copyright (c) Linux Test Project, 2002-2022
>   */

> -/*
> - * Description:
> - * The testcase checks the various errnos of the unlink(2).
> - * 1) unlink() returns ENOENT if file doesn't exist.
> - * 2) unlink() returns ENOENT if path is empty.
> - * 3) unlink() returns ENOENT if path contains a non-existent file.
> - * 4) unlink() returns EFAULT if address is invalid.
> - * 5) unlink() returns ENOTDIR if path contains a regular file.
> - * 6) unlink() returns ENAMETOOLONG if path contains a regular file.
> +/*\
> + * [Description]
> + *
> + * Verify that unlink() fails with
blank line is needed here.
> + * - ENOENT when file does not exist
> + * - ENOENT when pathname is empty
> + * - ENOENT when a component in pathname does not exist
> + * - EFAULT when pathname points outside the accessible address space
> + * - ENOTDIR when a component used as a directory in pathname is not,
> + * in fact, a directory
> + * - ENAMETOOLONG when pathname is too long
>   */

Kind regards,
Petr

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-09-05 14:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-02  6:23 [LTP] [PATCH v2] unlink07: use TST_EXP_FAIL(), docparse format, copyright update and remove redundant headers Avinesh Kumar
2022-09-05 14:49 ` Petr Vorel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox