From: Avinesh Kumar <akumar@suse.de>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] stat03: cleanup, use TST_EXP_FAIL macro
Date: Tue, 16 Aug 2022 13:14:49 +0530 [thread overview]
Message-ID: <20220816074449.30861-2-akumar@suse.de> (raw)
- update copyright
- turn comment into docparse format
- remove redundant headers
- make check fix: change to static
- use TST_EXP_FAIL with expected errno code
Signed-off-by: Avinesh Kumar <akumar@suse.de>
---
testcases/kernel/syscalls/stat/stat03.c | 25 +++++++------------------
1 file changed, 7 insertions(+), 18 deletions(-)
diff --git a/testcases/kernel/syscalls/stat/stat03.c b/testcases/kernel/syscalls/stat/stat03.c
index 20d4c772f..369e6d79f 100644
--- a/testcases/kernel/syscalls/stat/stat03.c
+++ b/testcases/kernel/syscalls/stat/stat03.c
@@ -2,15 +2,16 @@
/* Copyright (c) International Business Machines Corp., 2001
* 07/2001 John George
* -Ported
+ * Copyright (c) Linux Test Project, 2002-2022
+ */
+
+/*\
+ * [Description]
*
* check stat() with various error conditions that should produce
* EACCES, EFAULT, ENAMETOOLONG, ENOENT, ENOTDIR, ELOOP
*/
-#include <fcntl.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
#include <pwd.h>
#include "tst_test.h"
@@ -23,7 +24,7 @@
#define MODE_RW 0666
#define DIR_MODE 0755
-struct passwd *ltpuser;
+static struct passwd *ltpuser;
static char long_dir[PATH_MAX + 2] = {[0 ... PATH_MAX + 1] = 'a'};
static char loop_dir[PATH_MAX] = ".";
@@ -45,19 +46,7 @@ static void verify_stat(unsigned int n)
struct tcase *tc = TC + n;
struct stat stat_buf;
- TEST(stat(tc->pathname, &stat_buf));
- if (TST_RET != -1) {
- tst_res(TFAIL, "stat() succeeded unexpectedly");
- return;
- }
-
- if (TST_ERR == tc->exp_errno) {
- tst_res(TPASS | TTERRNO, "stat() failed as expected");
- } else {
- tst_res(TFAIL | TTERRNO,
- "stat() failed unexpectedly; expected: %d - %s",
- tc->exp_errno, tst_strerrno(tc->exp_errno));
- }
+ TST_EXP_FAIL(stat(tc->pathname, &stat_buf), tc->exp_errno);
}
static void setup(void)
--
2.37.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next reply other threads:[~2022-08-16 7:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-16 7:44 Avinesh Kumar [this message]
2022-10-11 12:38 ` [LTP] [PATCH] stat03: cleanup, use TST_EXP_FAIL macro Richard Palethorpe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220816074449.30861-2-akumar@suse.de \
--to=akumar@suse.de \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox