diff mbox series

[v1] Add chdir05 test

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

Commit Message

Andrea Cervesato Jan. 19, 2024, 8:59 a.m. UTC
From: Andrea Cervesato <andrea.cervesato@suse.com>

This test has been extracted from symlink01 and it verifies that
chdir() is working correctly on symlink() generated files.

Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
 runtest/syscalls                           |  2 +-
 testcases/kernel/syscalls/chdir/.gitignore |  1 +
 testcases/kernel/syscalls/chdir/chdir05.c  | 58 ++++++++++++++++++++++
 3 files changed, 60 insertions(+), 1 deletion(-)
 create mode 100644 testcases/kernel/syscalls/chdir/chdir05.c

Comments

Cyril Hrubis Feb. 2, 2024, 5:17 p.m. UTC | #1
Hi!
> +/*\
> + * [Description]
> + *
> + * This test verifies that chdir() is working correctly on symlink()
> + * generated files.
> + */
> +
> +#include "tst_test.h"
> +
> +static void test_chdir(void)
> +{
> +	char *symname = "my_symlink0";
> +
> +	SAFE_SYMLINK(tst_get_tmpdir(), symname);
> +	TST_EXP_PASS(chdir(symname));
> +
> +	SAFE_UNLINK(symname);
> +}
> +
> +static void test_chdir_no_path(void)
> +{
> +	char *symname = "my_symlink1";
> +
> +	SAFE_SYMLINK("bc+eFhi!k", symname);
> +	TST_EXP_FAIL(chdir(symname), ENOENT);
> +
> +	SAFE_UNLINK(symname);
> +}

This two should go to chdir01.c and possibly chdir01 should be split
into positive cases and negative cases when you are at it.

> +static void test_chdir_loop(void)
> +{
> +	char *symname = "my_symlink2";
> +
> +	TST_EXP_PASS(symlink(symname, symname));
> +	TST_EXP_FAIL(chdir(symname), ELOOP);
> +
> +	SAFE_UNLINK(symname);
> +}

This is already in chdir01.c

> +static void run(void)
> +{
> +	test_chdir();
> +	test_chdir_no_path();
> +	test_chdir_loop();
> +}
> +
> +static struct tst_test test = {
> +	.test_all = run,
> +	.needs_tmpdir = 1,
> +};
> -- 
> 2.35.3
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp
Andrea Cervesato Feb. 20, 2024, 12:20 p.m. UTC | #2
Hi!

this patch can be ignored due to code duplication.

Andrea

On 2/2/24 18:17, Cyril Hrubis wrote:
> Hi!
>> +/*\
>> + * [Description]
>> + *
>> + * This test verifies that chdir() is working correctly on symlink()
>> + * generated files.
>> + */
>> +
>> +#include "tst_test.h"
>> +
>> +static void test_chdir(void)
>> +{
>> +	char *symname = "my_symlink0";
>> +
>> +	SAFE_SYMLINK(tst_get_tmpdir(), symname);
>> +	TST_EXP_PASS(chdir(symname));
>> +
>> +	SAFE_UNLINK(symname);
>> +}
>> +
>> +static void test_chdir_no_path(void)
>> +{
>> +	char *symname = "my_symlink1";
>> +
>> +	SAFE_SYMLINK("bc+eFhi!k", symname);
>> +	TST_EXP_FAIL(chdir(symname), ENOENT);
>> +
>> +	SAFE_UNLINK(symname);
>> +}
> This two should go to chdir01.c and possibly chdir01 should be split
> into positive cases and negative cases when you are at it.
>
>> +static void test_chdir_loop(void)
>> +{
>> +	char *symname = "my_symlink2";
>> +
>> +	TST_EXP_PASS(symlink(symname, symname));
>> +	TST_EXP_FAIL(chdir(symname), ELOOP);
>> +
>> +	SAFE_UNLINK(symname);
>> +}
> This is already in chdir01.c
>
>> +static void run(void)
>> +{
>> +	test_chdir();
>> +	test_chdir_no_path();
>> +	test_chdir_loop();
>> +}
>> +
>> +static struct tst_test test = {
>> +	.test_all = run,
>> +	.needs_tmpdir = 1,
>> +};
>> -- 
>> 2.35.3
>>
>>
>> -- 
>> Mailing list info: https://lists.linux.it/listinfo/ltp
diff mbox series

Patch

diff --git a/runtest/syscalls b/runtest/syscalls
index 6e2407879..68460de0b 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -61,8 +61,8 @@  capset04 capset04
 cacheflush01 cacheflush01
 
 chdir01 chdir01
-chdir01A symlink01 -T chdir01
 chdir04 chdir04
+chdir05 chdir05
 
 chmod01 chmod01
 chmod01A symlink01 -T chmod01
diff --git a/testcases/kernel/syscalls/chdir/.gitignore b/testcases/kernel/syscalls/chdir/.gitignore
index 1b15eb6b9..96dc538f1 100644
--- a/testcases/kernel/syscalls/chdir/.gitignore
+++ b/testcases/kernel/syscalls/chdir/.gitignore
@@ -1,2 +1,3 @@ 
 /chdir01
 /chdir04
+/chdir05
diff --git a/testcases/kernel/syscalls/chdir/chdir05.c b/testcases/kernel/syscalls/chdir/chdir05.c
new file mode 100644
index 000000000..d9fa94a13
--- /dev/null
+++ b/testcases/kernel/syscalls/chdir/chdir05.c
@@ -0,0 +1,58 @@ 
+// 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 chdir() is working correctly on symlink()
+ * generated files.
+ */
+
+#include "tst_test.h"
+
+static void test_chdir(void)
+{
+	char *symname = "my_symlink0";
+
+	SAFE_SYMLINK(tst_get_tmpdir(), symname);
+	TST_EXP_PASS(chdir(symname));
+
+	SAFE_UNLINK(symname);
+}
+
+static void test_chdir_no_path(void)
+{
+	char *symname = "my_symlink1";
+
+	SAFE_SYMLINK("bc+eFhi!k", symname);
+	TST_EXP_FAIL(chdir(symname), ENOENT);
+
+	SAFE_UNLINK(symname);
+}
+
+static void test_chdir_loop(void)
+{
+	char *symname = "my_symlink2";
+
+	TST_EXP_PASS(symlink(symname, symname));
+	TST_EXP_FAIL(chdir(symname), ELOOP);
+
+	SAFE_UNLINK(symname);
+}
+
+static void run(void)
+{
+	test_chdir();
+	test_chdir_no_path();
+	test_chdir_loop();
+}
+
+static struct tst_test test = {
+	.test_all = run,
+	.needs_tmpdir = 1,
+};