public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] syscalls: chdir02: Add test for valid buffer lenghts
@ 2026-01-22 15:05 Cyril Hrubis
  2026-01-23  9:17 ` Petr Vorel
  2026-02-17 14:12 ` Andrea Cervesato via ltp
  0 siblings, 2 replies; 4+ messages in thread
From: Cyril Hrubis @ 2026-01-22 15:05 UTC (permalink / raw)
  To: ltp; +Cc: Al Viro

This test tests all buffer lenghts shorter than PATH_MAX and expect the
chdir() syscall to succeed.

Suggested-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 runtest/syscalls                           |  1 +
 testcases/kernel/syscalls/chdir/.gitignore |  1 +
 testcases/kernel/syscalls/chdir/chdir02.c  | 38 ++++++++++++++++++++++
 3 files changed, 40 insertions(+)
 create mode 100644 testcases/kernel/syscalls/chdir/chdir02.c

diff --git a/runtest/syscalls b/runtest/syscalls
index 05bb3ceb1..2f629e4e4 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -68,6 +68,7 @@ cachestat03 cachestat03
 cachestat04 cachestat04
 
 chdir01 chdir01
+chdir02 chdir02
 chdir04 chdir04
 
 chmod01 chmod01
diff --git a/testcases/kernel/syscalls/chdir/.gitignore b/testcases/kernel/syscalls/chdir/.gitignore
index 1b15eb6b9..3475c5e54 100644
--- a/testcases/kernel/syscalls/chdir/.gitignore
+++ b/testcases/kernel/syscalls/chdir/.gitignore
@@ -1,2 +1,3 @@
 /chdir01
+/chdir02
 /chdir04
diff --git a/testcases/kernel/syscalls/chdir/chdir02.c b/testcases/kernel/syscalls/chdir/chdir02.c
new file mode 100644
index 000000000..fc1f80136
--- /dev/null
+++ b/testcases/kernel/syscalls/chdir/chdir02.c
@@ -0,0 +1,38 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2026 Cyril Hrubis <chrubis@suse.cz>
+ */
+
+/*\
+ * Tests that all paths shorter than PATH_MAX work fine.
+ */
+
+#include "tst_test.h"
+
+static char *path;
+
+static void verify_chdir(void)
+{
+	int i, fails = 0;
+
+	memset(path, 0, PATH_MAX);
+
+	for (i = 1; i < PATH_MAX; i++) {
+		memset(path, '/', i);
+
+		TST_EXP_PASS_SILENT(chdir(path), "chdir('/' * %i)", i);
+
+		fails += !TST_PASS;
+	}
+
+	if (!fails)
+		tst_res(TPASS, "Path lenghts <1,%i> worked correctly", PATH_MAX);
+}
+
+static struct tst_test test = {
+	.test_all = verify_chdir,
+	.bufs = (struct tst_buffers []) {
+		{&path, .size = PATH_MAX},
+		{}
+	}
+};
-- 
2.52.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [LTP] [PATCH] syscalls: chdir02: Add test for valid buffer lenghts
  2026-01-22 15:05 [LTP] [PATCH] syscalls: chdir02: Add test for valid buffer lenghts Cyril Hrubis
@ 2026-01-23  9:17 ` Petr Vorel
  2026-02-17 14:12 ` Andrea Cervesato via ltp
  1 sibling, 0 replies; 4+ messages in thread
From: Petr Vorel @ 2026-01-23  9:17 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: ltp

Hi Cyril,

> This test tests all buffer lenghts shorter than PATH_MAX and expect the
> chdir() syscall to succeed.

Reviewed-by: Petr Vorel <pvorel@suse.cz>

Thanks for quickly implementing this test. IMHO it should be merged before the
release.

nit: I'd slightly prefer not to reuse the name of previously deleted test,
but no big deal.

Kind regards,
Petr

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [LTP] [PATCH] syscalls: chdir02: Add test for valid buffer lenghts
  2026-01-22 15:05 [LTP] [PATCH] syscalls: chdir02: Add test for valid buffer lenghts Cyril Hrubis
  2026-01-23  9:17 ` Petr Vorel
@ 2026-02-17 14:12 ` Andrea Cervesato via ltp
  2026-02-17 15:19   ` Cyril Hrubis
  1 sibling, 1 reply; 4+ messages in thread
From: Andrea Cervesato via ltp @ 2026-02-17 14:12 UTC (permalink / raw)
  To: Cyril Hrubis, ltp; +Cc: Al Viro

Hi!

A few typos below.

On Thu Jan 22, 2026 at 4:05 PM CET, Cyril Hrubis wrote:
> This test tests all buffer lenghts shorter than PATH_MAX and expect the
                               ^
			      lengths

> +	if (!fails)
> +		tst_res(TPASS, "Path lenghts <1,%i> worked correctly", PATH_MAX);
                                       ^
				       lengths
The rest LGTM. Feel free to merge.

Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com>

-- 
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [LTP] [PATCH] syscalls: chdir02: Add test for valid buffer lenghts
  2026-02-17 14:12 ` Andrea Cervesato via ltp
@ 2026-02-17 15:19   ` Cyril Hrubis
  0 siblings, 0 replies; 4+ messages in thread
From: Cyril Hrubis @ 2026-02-17 15:19 UTC (permalink / raw)
  To: Andrea Cervesato; +Cc: Al Viro, ltp

Hi!
> The rest LGTM. Feel free to merge.

Typos fixed and patch pushed, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-02-17 15:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-22 15:05 [LTP] [PATCH] syscalls: chdir02: Add test for valid buffer lenghts Cyril Hrubis
2026-01-23  9:17 ` Petr Vorel
2026-02-17 14:12 ` Andrea Cervesato via ltp
2026-02-17 15:19   ` Cyril Hrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox