Linux Test Project
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: Kushal Chand <kushalkataria5@gmail.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2] fstat_02: Increase test coverage by creating hard link to file and validate using fstat
Date: Thu, 10 Feb 2022 16:36:14 +0100	[thread overview]
Message-ID: <YgUw7scGZwUcK22E@yuki> (raw)
In-Reply-To: <20220210105101.38337-1-kushalkataria5@gmail.com>

Hi!
The subject should be shorter and more to the point, something as:

"fstat02: Validate st_nlink as well"

> Implements: #517

The code looks good now, but it's not complete solution to #517, there
are still many fields of the structure that are not checked and a few
more patches would be required to complete it.

For instance the st_blocks should be more or less equal size/512

And we should check the atime/mtime/ctime as well, but maybe it would be
easier if we do that in a separate test.

> This patch creates a hard link for a file during setup and checks if number of hardlinks
> match with the expected number.

This is missing Signed-off-by: line see:

https://www.kernel.org/doc/html/v4.17/process/submitting-patches.html#sign-your-work-the-developer-s-certificate-of-origin

> ---
>  testcases/kernel/syscalls/fstat/fstat02.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/testcases/kernel/syscalls/fstat/fstat02.c b/testcases/kernel/syscalls/fstat/fstat02.c
> index c0229de44..2f9632edf 100644
> --- a/testcases/kernel/syscalls/fstat/fstat02.c
> +++ b/testcases/kernel/syscalls/fstat/fstat02.c
> @@ -17,8 +17,10 @@
>  #include "tst_safe_macros.h"
>  
>  #define TESTFILE        "test_file"
> +#define LINK_TESTFILE   "link_test_file"
>  #define FILE_SIZE       1024
>  #define FILE_MODE	0644
> +#define NLINK	        2
>  
>  static struct stat stat_buf;
>  static uid_t user_id;
> @@ -61,6 +63,12 @@ static void run(void)
>  		fail++;
>  	}
>  
> +	if (stat_buf.st_nlink != NLINK) {
> +		tst_res(TFAIL, "stat_buf.st_nlink = %li expected %i",
> +			(long)stat_buf.st_nlink, NLINK);
> +		fail++;
> +	}
> +
>  	if (fail)
>  		return;
>  
> @@ -78,6 +86,8 @@ static void setup(void)
>  
>  	if (tst_fill_file(TESTFILE, 'a', FILE_SIZE, 1))
>  		tst_brk(TBROK, "Could not fill Testfile!");
> +
> +	SAFE_LINK(TESTFILE, LINK_TESTFILE);
>  }
>  
>  static void cleanup(void)
> -- 
> 2.25.1
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz

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

  reply	other threads:[~2022-02-10 15:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-10 10:51 [LTP] [PATCH v2] fstat_02: Increase test coverage by creating hard link to file and validate using fstat Kushal Chand
2022-02-10 15:36 ` Cyril Hrubis [this message]
2022-02-23 10:20   ` Kushal Chand
2022-02-23 12:43     ` Cyril Hrubis

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=YgUw7scGZwUcK22E@yuki \
    --to=chrubis@suse.cz \
    --cc=kushalkataria5@gmail.com \
    --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