ltp.lists.linux.it archive mirror
 help / color / mirror / Atom feed
* [LTP] [PATCH] stat03: cleanup, use TST_EXP_FAIL macro
@ 2022-08-16  7:44 Avinesh Kumar
  2022-10-11 12:38 ` Richard Palethorpe
  0 siblings, 1 reply; 2+ messages in thread
From: Avinesh Kumar @ 2022-08-16  7:44 UTC (permalink / raw)
  To: ltp

- 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

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

* Re: [LTP] [PATCH] stat03: cleanup, use TST_EXP_FAIL macro
  2022-08-16  7:44 [LTP] [PATCH] stat03: cleanup, use TST_EXP_FAIL macro Avinesh Kumar
@ 2022-10-11 12:38 ` Richard Palethorpe
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Palethorpe @ 2022-10-11 12:38 UTC (permalink / raw)
  To: Avinesh Kumar; +Cc: ltp

Hello,

Merged!

-- 
Thank you,
Richard.

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

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

end of thread, other threads:[~2022-10-11 12:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-16  7:44 [LTP] [PATCH] stat03: cleanup, use TST_EXP_FAIL macro Avinesh Kumar
2022-10-11 12:38 ` Richard Palethorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).