All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH v3] fstat_02: Increase test coverage by creating hard link to file and validate using fstat
@ 2022-02-10 11:18 Kushal Chand
  2022-02-10 15:47 ` Cyril Hrubis
  0 siblings, 1 reply; 2+ messages in thread
From: Kushal Chand @ 2022-02-10 11:18 UTC (permalink / raw)
  To: ltp; +Cc: Kushal Chand

Please ignore patch v2, I think that is wrong.

Fix format specfiers and cast to correct type when printing.
Implements: #517
---
 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..8084cd4c2 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 = %i expected %i",
+			(int)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

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

* Re: [LTP] [PATCH v3] fstat_02: Increase test coverage by creating hard link to file and validate using fstat
  2022-02-10 11:18 [LTP] [PATCH v3] fstat_02: Increase test coverage by creating hard link to file and validate using fstat Kushal Chand
@ 2022-02-10 15:47 ` Cyril Hrubis
  0 siblings, 0 replies; 2+ messages in thread
From: Cyril Hrubis @ 2022-02-10 15:47 UTC (permalink / raw)
  To: Kushal Chand; +Cc: ltp

Hi!
> Please ignore patch v2, I think that is wrong.
> 
> Fix format specfiers and cast to correct type when printing.

Well either it's %li and cast to (long) or %i and cast to (int) both
will work fine in this case.

However the points stated in v2 still apply to this patch as well.

> Implements: #517
> ---
>  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..8084cd4c2 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 = %i expected %i",
> +			(int)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

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

end of thread, other threads:[~2022-02-10 15:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-10 11:18 [LTP] [PATCH v3] fstat_02: Increase test coverage by creating hard link to file and validate using fstat Kushal Chand
2022-02-10 15:47 ` Cyril Hrubis

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.