Skip to contentSkip to conversation

Add chdir05 test

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

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add chdir05 test

From: Andrea Cervesato <[email protected]>

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

---
 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
runtest/syscalls +1 -1
index 6e2407879..68460de0b 100644
@@ -61,8 +61,8 @@ capset04 capset04
 cacheflush01 cacheflush01
 
 chdir01 chdir01
-chdir01A symlink01 -T chdir01
 chdir04 chdir04
+chdir05 chdir05
 
 chmod01 chmod01
 chmod01A symlink01 -T chmod01
testcases/kernel/syscalls/chdir/.gitignore +1 -0
index 1b15eb6b9..96dc538f1 100644
@@ -1,2 +1,3 @@
 /chdir01
 /chdir04
+/chdir05
testcases/kernel/syscalls/chdir/chdir05.c new file +58 -0

58 lines not on this page · raw message

Signature · 5 lines
2.35.3


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

Hi!

Quoted 18 lines
testcases/kernel/syscalls/chdir/chdir05.c new file +18 -0
+/*\
+ * [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);
+}

testcases/kernel/syscalls/chdir/chdir05.c line 36

Quoted 10 lines
testcases/kernel/syscalls/chdir/chdir05.c new file +10 -0
+
+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.

testcases/kernel/syscalls/chdir/chdir05.c line 46

Quoted 9 lines
testcases/kernel/syscalls/chdir/chdir05.c new file +9 -0
+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

Quoted 17 lines
testcases/kernel/syscalls/chdir/chdir05.c new file +11 -0
+static void run(void)
+{
+	test_chdir();
+	test_chdir_no_path();
+	test_chdir_loop();
+}
+
+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
Signature · 5 lines
Cyril Hrubis
[email protected]

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

Hi!

this patch can be ignored due to code duplication.

Andrea

Quoted 60 lines · Cyril Hrubis

Hi!

Quoted 18 lines
testcases/kernel/syscalls/chdir/chdir05.c new file +18 -0
+/*\
+ * [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);
+}

testcases/kernel/syscalls/chdir/chdir05.c line 36

Quoted 10 lines
testcases/kernel/syscalls/chdir/chdir05.c new file +10 -0
+
+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.

testcases/kernel/syscalls/chdir/chdir05.c line 46

Quoted 9 lines
testcases/kernel/syscalls/chdir/chdir05.c new file +9 -0
+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

Quoted 17 lines
testcases/kernel/syscalls/chdir/chdir05.c new file +11 -0
+static void run(void)
+{
+	test_chdir();
+	test_chdir_no_path();
+	test_chdir_loop();
+}
+
+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
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp