From: Richard Palethorpe <rpalethorpe@suse.de>
To: Avinesh Kumar <akumar@suse.de>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] stat01: cleanup, use TST_EXP macros
Date: Tue, 11 Oct 2022 12:36:20 +0100 [thread overview]
Message-ID: <875ygq7fm0.fsf@suse.de> (raw)
In-Reply-To: <20220816074449.30861-1-akumar@suse.de>
Hello,
Merged!
Avinesh Kumar <akumar@suse.de> writes:
> - update copyright
> - turn comment into docparse format
> - remove redundant headers
> - make check fixes: static vars
> - use TST_EXP_* macros
>
> Signed-off-by: Avinesh Kumar <akumar@suse.de>
> ---
> testcases/kernel/syscalls/stat/stat01.c | 60 ++++++-------------------
> 1 file changed, 14 insertions(+), 46 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/stat/stat01.c b/testcases/kernel/syscalls/stat/stat01.c
> index 0f5c1dcc2..e0dbfbf2f 100644
> --- a/testcases/kernel/syscalls/stat/stat01.c
> +++ b/testcases/kernel/syscalls/stat/stat01.c
> @@ -2,16 +2,17 @@
> /* Copyright (c) International Business Machines Corp., 2001
> * 07/2001 John George
> * -Ported
> + * Copyright (c) Linux Test Project, 2002-2022
> + */
> +
> +/*\
> + * [Description]
> *
> * Verify that, stat(2) succeeds to get the status of a file and fills the
> * stat structure elements regardless of whether process has or doesn't
> * have read access to the file.
> */
>
> -#include <sys/types.h>
> -#include <fcntl.h>
> -#include <sys/stat.h>
> -#include <errno.h>
> #include <pwd.h>
> #include "tst_test.h"
>
> @@ -22,9 +23,9 @@
> #define NEW_MODE 0222
> #define MASK 0777
>
> -uid_t user_id;
> -gid_t group_id;
> -struct passwd *ltpuser;
> +static uid_t user_id;
> +static gid_t group_id;
> +static struct passwd *ltpuser;
>
> static struct tcase{
> char *pathname;
> @@ -38,47 +39,14 @@ static void verify_stat(unsigned int n)
> {
> struct tcase *tc = TC + n;
> struct stat stat_buf;
> - int fail = 0;
> -
> - TEST(stat(tc->pathname, &stat_buf));
> -
> - if (TST_RET == -1) {
> - tst_res(TFAIL | TTERRNO, "stat(%s) failed", tc->pathname);
> - return;
> - }
> -
> - if (stat_buf.st_uid != user_id) {
> - tst_res(TFAIL, "stat_buf.st_uid = %i expected %i",
> - stat_buf.st_uid, user_id);
> - fail++;
> - }
>
> - if (stat_buf.st_gid != group_id) {
> - tst_res(TFAIL, "stat_buf.st_gid = %i expected %i",
> - stat_buf.st_gid, group_id);
> - fail++;
> - }
> -
> - if (stat_buf.st_size != FILE_SIZE) {
> - tst_res(TFAIL, "stat_buf.st_size = %li expected %i",
> - (long)stat_buf.st_size, FILE_SIZE);
> - fail++;
> - }
> -
> - if ((stat_buf.st_mode & MASK) != tc->mode) {
> - tst_res(TFAIL, "stat_buf.st_mode = %o expected %o",
> - (stat_buf.st_mode & MASK), tc->mode);
> - fail++;
> - }
> -
> - if (stat_buf.st_nlink != 1) {
> - tst_res(TFAIL, "stat_buf.st_nlink = %lu expected 1",
> - stat_buf.st_nlink);
> - fail++;
> - }
> + TST_EXP_PASS(stat(tc->pathname, &stat_buf));
>
> - if (!fail)
> - tst_res(TPASS, "stat(%s)", tc->pathname);
> + TST_EXP_EQ_LU(stat_buf.st_uid, user_id);
> + TST_EXP_EQ_LU(stat_buf.st_gid, group_id);
> + TST_EXP_EQ_LI(stat_buf.st_size, FILE_SIZE);
> + TST_EXP_EQ_LU(stat_buf.st_mode & MASK, tc->mode);
> + TST_EXP_EQ_LU(stat_buf.st_nlink, 1);
> }
>
> static void setup(void)
> --
> 2.37.1
--
Thank you,
Richard.
--
Mailing list info: https://lists.linux.it/listinfo/ltp
prev parent reply other threads:[~2022-10-11 11:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-16 7:44 [LTP] [PATCH] stat01: cleanup, use TST_EXP macros Avinesh Kumar
2022-10-11 11:36 ` Richard Palethorpe [this message]
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=875ygq7fm0.fsf@suse.de \
--to=rpalethorpe@suse.de \
--cc=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.