[LTP] [PATCH 2/2] syscalls/stat*: Add nlink member check
Yang Xu
xuyang2018.jy@fujitsu.com
Fri Nov 19 09:28:42 CET 2021
Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
---
mount_id member check will add in the next week.
[1]https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=fa2fcf4
[2]https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/commit/?id=728009a47497b6
testcases/kernel/syscalls/stat/stat01.c | 8 +++++++-
testcases/kernel/syscalls/statx/statx01.c | 6 ++++++
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/testcases/kernel/syscalls/stat/stat01.c b/testcases/kernel/syscalls/stat/stat01.c
index 14f1036d5..0f5c1dcc2 100644
--- a/testcases/kernel/syscalls/stat/stat01.c
+++ b/testcases/kernel/syscalls/stat/stat01.c
@@ -71,11 +71,17 @@ static void verify_stat(unsigned int n)
fail++;
}
+ if (stat_buf.st_nlink != 1) {
+ tst_res(TFAIL, "stat_buf.st_nlink = %lu expected 1",
+ stat_buf.st_nlink);
+ fail++;
+ }
+
if (!fail)
tst_res(TPASS, "stat(%s)", tc->pathname);
}
-void setup(void)
+static void setup(void)
{
unsigned int i;
diff --git a/testcases/kernel/syscalls/statx/statx01.c b/testcases/kernel/syscalls/statx/statx01.c
index 1289366b9..63d97b8c7 100644
--- a/testcases/kernel/syscalls/statx/statx01.c
+++ b/testcases/kernel/syscalls/statx/statx01.c
@@ -16,6 +16,7 @@
* 3) mode
* 4) blocks
* 5) size
+ * 6) nlink
*
* A file is created and metadata values are set with
* predefined values.
@@ -99,6 +100,11 @@ static void test_normal_file(void)
tst_res(TFAIL, "stx_blocks(%"PRIu64") is invalid",
(uint64_t)buff.stx_blocks);
+ if (buff.stx_nlink == 1)
+ tst_res(TPASS, "stx_nlink(1) is correct");
+ else
+ tst_res(TFAIL, "stx_nlink(%u) is different from expected(1)",
+ buff.stx_nlink);
}
static void test_device_file(void)
--
2.23.0
More information about the ltp
mailing list