Skip to contentSkip to conversation

Add rmdir04 test

PATCH In review Andrea Cervesato 3 participants 3 messages Jan 19, 2024 – Feb 19, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add rmdir04 test

From: Andrea Cervesato <[email protected]>

This test has been extracted from symlink01 test and it verifies rmdir() syscall functionalities on symlink generated file.

---
 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
runtest/syscalls +1 -1
index 6e2407879..2c82a7f98 100644
@@ -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
testcases/kernel/syscalls/rmdir/.gitignore +1 -0
index 1a1e18066..c68c174dc 100644
@@ -1,3 +1,4 @@
 /rmdir01
 /rmdir02
 /rmdir03
+/rmdir04
testcases/kernel/syscalls/rmdir/rmdir04.c new file +30 -0
new file mode 100644
index 000000000..4c8f11d50
@@ -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 [email protected]
+ */
+
+/*\
+ * [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,
+};
Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Hi!

testcases/kernel/syscalls/rmdir/rmdir04.c line 25

Quoted 11 lines
testcases/kernel/syscalls/rmdir/rmdir04.c new file +11 -0
+#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);
+}

Here as well, easily added to rmdir02 along with a few more different ENOTDIR cases.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw

Hi,
please don't consider this patch anymore.

Quoted 15 lines · Cyril Hrubis

Hi!

testcases/kernel/syscalls/rmdir/rmdir04.c line 25

Quoted 11 lines
testcases/kernel/syscalls/rmdir/rmdir04.c new file +11 -0
+#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);
+}

Here as well, easily added to rmdir02 along with a few more different ENOTDIR cases.

Andrea

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp