[LTP] [PATCH v1] Add rmdir04 test
Andrea Cervesato
andrea.cervesato@suse.de
Fri Jan 19 09:56:22 CET 2024
From: Andrea Cervesato <andrea.cervesato@suse.com>
This test has been extracted from symlink01 test and it verifies
rmdir() syscall functionalities on symlink generated file.
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
runtest/syscalls | 2 +-
testcases/kernel/syscalls/rmdir/.gitignore | 1 +
testcases/kernel/syscalls/rmdir/rmdir04.c | 30 ++++++++++++++++++++++
3 files changed, 32 insertions(+), 1 deletion(-)
create mode 100644 testcases/kernel/syscalls/rmdir/rmdir04.c
diff --git a/runtest/syscalls b/runtest/syscalls
index 6e2407879..2c82a7f98 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -1187,7 +1187,7 @@ request_key05 request_key05
rmdir01 rmdir01
rmdir02 rmdir02
rmdir03 rmdir03
-rmdir03A symlink01 -T rmdir03
+rmdir04 rmdir04
rt_sigaction01 rt_sigaction01
rt_sigaction02 rt_sigaction02
diff --git a/testcases/kernel/syscalls/rmdir/.gitignore b/testcases/kernel/syscalls/rmdir/.gitignore
index 1a1e18066..c68c174dc 100644
--- a/testcases/kernel/syscalls/rmdir/.gitignore
+++ b/testcases/kernel/syscalls/rmdir/.gitignore
@@ -1,3 +1,4 @@
/rmdir01
/rmdir02
/rmdir03
+/rmdir04
diff --git a/testcases/kernel/syscalls/rmdir/rmdir04.c b/testcases/kernel/syscalls/rmdir/rmdir04.c
new file mode 100644
index 000000000..4c8f11d50
--- /dev/null
+++ b/testcases/kernel/syscalls/rmdir/rmdir04.c
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
+ * Author: David Fenner
+ * Copilot: Jon Hendrickson
+ * Copyright (C) 2024 Andrea Cervesato andrea.cervesato@suse.com
+ */
+
+/*\
+ * [Description]
+ *
+ * This test verifies that rmdir() can't overwrite symlink() generated files.
+ */
+
+#include "tst_test.h"
+
+static void run(void)
+{
+ char *symname = "my_symlink0";
+
+ SAFE_SYMLINK(tst_get_tmpdir(), symname);
+ TST_EXP_FAIL(rmdir(symname), ENOTDIR);
+
+ SAFE_UNLINK(symname);
+}
+
+static struct tst_test test = {
+ .test_all = run,
+ .needs_tmpdir = 1,
+};
--
2.35.3
More information about the ltp
mailing list