diff mbox series

[5/5] Add fchmodat2_03 test

Message ID 20240521-fchmodat2-v1-5-191b4a986202@suse.com
State New
Headers show
Series Add fchmodat2 testing suite | expand

Commit Message

Andrea Cervesato May 21, 2024, 6:15 a.m. UTC
From: Andrea Cervesato <andrea.cervesato@suse.com>

This test verifies that fchmodat2() syscall is properly working with
AT_EMPTY_PATH.

Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
 runtest/syscalls                                   |  1 +
 testcases/kernel/syscalls/fchmodat2/.gitignore     |  1 +
 testcases/kernel/syscalls/fchmodat2/fchmodat2_03.c | 46 ++++++++++++++++++++++
 3 files changed, 48 insertions(+)
diff mbox series

Patch

diff --git a/runtest/syscalls b/runtest/syscalls
index c3712da36..51b1ad535 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -266,6 +266,7 @@  fchmodat02 fchmodat02
 
 fchmodat2_01 fchmodat2_01
 fchmodat2_02 fchmodat2_02
+fchmodat2_03 fchmodat2_03
 
 fchown01 fchown01
 fchown01_16 fchown01_16
diff --git a/testcases/kernel/syscalls/fchmodat2/.gitignore b/testcases/kernel/syscalls/fchmodat2/.gitignore
index 9f713198c..c46387095 100644
--- a/testcases/kernel/syscalls/fchmodat2/.gitignore
+++ b/testcases/kernel/syscalls/fchmodat2/.gitignore
@@ -1,2 +1,3 @@ 
 fchmodat2_01
 fchmodat2_02
+fchmodat2_03
diff --git a/testcases/kernel/syscalls/fchmodat2/fchmodat2_03.c b/testcases/kernel/syscalls/fchmodat2/fchmodat2_03.c
new file mode 100644
index 000000000..a912b95c8
--- /dev/null
+++ b/testcases/kernel/syscalls/fchmodat2/fchmodat2_03.c
@@ -0,0 +1,46 @@ 
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2024 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
+ */
+
+/*\
+ * [Description]
+ *
+ * This test verifies that fchmodat2() syscall is properly working with
+ * AT_EMPTY_PATH.
+ */
+
+#include "fchmodat2.h"
+#include "lapi/fcntl.h"
+
+#define MNTPOINT "mntpoint"
+#define DNAME MNTPOINT "/mydir"
+
+static void run(void)
+{
+	int fd;
+	struct stat st;
+
+	SAFE_MKDIR(DNAME, 0640);
+	fd = SAFE_OPEN(DNAME, O_PATH | O_DIRECTORY, 0640);
+
+	TST_EXP_PASS(fchmodat2(fd, "", 0777, AT_EMPTY_PATH));
+
+	SAFE_FSTAT(fd, &st);
+	TST_EXP_EQ_LI(st.st_mode, S_IFDIR | 0777);
+
+	SAFE_CLOSE(fd);
+	SAFE_RMDIR(DNAME);
+}
+
+static struct tst_test test = {
+	.test_all = run,
+	.min_kver = "6.6",
+	.mntpoint = MNTPOINT,
+	.format_device = 1,
+	.all_filesystems = 1,
+	.skip_filesystems = (const char *const []) {
+		"fuse",
+		NULL
+	},
+};