diff mbox series

[v1] Add rmdir04 test

Message ID 20240119085622.10743-1-andrea.cervesato@suse.de
State Rejected
Headers show
Series [v1] Add rmdir04 test | expand

Commit Message

Andrea Cervesato Jan. 19, 2024, 8:56 a.m. UTC
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

Comments

Cyril Hrubis Feb. 2, 2024, 5:14 p.m. UTC | #1
Hi!
> +#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 Cervesato Feb. 19, 2024, 3:57 p.m. UTC | #2
Hi,
please don't consider this patch anymore.

On 2/2/24 18:14, Cyril Hrubis wrote:
> Hi!
>> +#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
diff mbox series

Patch

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,
+};