[LTP] [PATCH 5/8] setxattr03: add setxattrat variant
Andrea Cervesato
andrea.cervesato@suse.de
Mon Jan 27 15:08:23 CET 2025
From: Andrea Cervesato <andrea.cervesato@suse.com>
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
testcases/kernel/syscalls/setxattr/setxattr03.c | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/testcases/kernel/syscalls/setxattr/setxattr03.c b/testcases/kernel/syscalls/setxattr/setxattr03.c
index 52cec078877580ab17385dfaaad77ec0ed7ec563..92f12c31c7858fade8fd535923bde7c887484b7c 100644
--- a/testcases/kernel/syscalls/setxattr/setxattr03.c
+++ b/testcases/kernel/syscalls/setxattr/setxattr03.c
@@ -32,6 +32,8 @@
#include "lapi/fs.h"
#include "tst_test.h"
+#include "lapi/syscalls.h"
+#include "lapi/xattr.h"
#if defined HAVE_SYS_XATTR_H
#define XATTR_TEST_KEY "user.testkey"
@@ -78,11 +80,24 @@ static struct test_case tc[] = {
static int immu_fd;
static int append_fd;
+static int tmpdir_fd = -1;
static void verify_setxattr(unsigned int i)
{
- TEST(setxattr(tc[i].fname, tc[i].key, tc[i].value, tc[i].size,
- tc[i].flags));
+ if (tst_variant) {
+ struct xattr_args args = {
+ .value = tc[i].value,
+ .size = tc[i].size,
+ .flags = tc[i].flags,
+ };
+
+ TEST(tst_syscall(__NR_setxattrat,
+ tmpdir_fd, tc[i].fname, AT_SYMLINK_NOFOLLOW,
+ tc[i].key, &args, sizeof(args)));
+ } else {
+ TEST(setxattr(tc[i].fname, tc[i].key, tc[i].value, tc[i].size,
+ tc[i].flags));
+ }
if (!TST_RET) {
tst_res(TFAIL, "%s succeeded unexpectedly", tc[i].desc);
@@ -145,10 +160,15 @@ static void setup(void)
if (set_append_on(append_fd))
tst_brk(TBROK | TERRNO, "Set %s append-only failed",
APPEND_FILE);
+
+ tmpdir_fd = SAFE_OPEN(tst_tmpdir_path(), O_DIRECTORY);
}
static void cleanup(void)
{
+ if (tmpdir_fd != -1)
+ SAFE_CLOSE(tmpdir_fd);
+
if ((immu_fd > 0) && set_immutable_off(immu_fd))
tst_res(TWARN | TERRNO, "Unset %s immutable failed",
IMMU_FILE);
@@ -169,6 +189,7 @@ static struct tst_test test = {
.cleanup = cleanup,
.test = verify_setxattr,
.tcnt = ARRAY_SIZE(tc),
+ .test_variants = 2,
.needs_tmpdir = 1,
.needs_root = 1,
};
--
2.43.0
More information about the ltp
mailing list