* [LTP] [PATCH v1] Add chdir05 test
@ 2024-01-19 8:59 Andrea Cervesato
2024-02-02 17:17 ` Cyril Hrubis
0 siblings, 1 reply; 3+ messages in thread
From: Andrea Cervesato @ 2024-01-19 8:59 UTC (permalink / raw)
To: ltp
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
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,
+};
--
2.35.3
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH v1] Add chdir05 test
2024-01-19 8:59 [LTP] [PATCH v1] Add chdir05 test Andrea Cervesato
@ 2024-02-02 17:17 ` Cyril Hrubis
2024-02-20 12:20 ` Andrea Cervesato via ltp
0 siblings, 1 reply; 3+ messages in thread
From: Cyril Hrubis @ 2024-02-02 17:17 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: ltp
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
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH v1] Add chdir05 test
2024-02-02 17:17 ` Cyril Hrubis
@ 2024-02-20 12:20 ` Andrea Cervesato via ltp
0 siblings, 0 replies; 3+ messages in thread
From: Andrea Cervesato via ltp @ 2024-02-20 12:20 UTC (permalink / raw)
To: Cyril Hrubis, Andrea Cervesato; +Cc: ltp
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
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-02-20 12:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-19 8:59 [LTP] [PATCH v1] Add chdir05 test Andrea Cervesato
2024-02-02 17:17 ` Cyril Hrubis
2024-02-20 12:20 ` Andrea Cervesato via ltp
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox