syscalls: chdir02: Add test for valid buffer lenghts
PATCH 1/1 syscalls: chdir02: Add test for valid buffer lenghts
This test tests all buffer lenghts shorter than PATH_MAX and expect the chdir() syscall to succeed.
Suggested-by Al Viro <[email protected]>
Signed-off-by Cyril Hrubis <[email protected]>
--- 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
runtest/syscalls +1 -0
@@ -68,6 +68,7 @@ cachestat03 cachestat03 cachestat04 cachestat04 chdir01 chdir01 +chdir02 chdir02 chdir04 chdir04 chmod01 chmod01
testcases/kernel/syscalls/chdir/.gitignore +1 -0
@@ -1,2 +1,3 @@ /chdir01 +/chdir02 /chdir04
testcases/kernel/syscalls/chdir/chdir02.c new file +38 -0
@@ -0,0 +1,38 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (C) 2026 Cyril Hrubis <[email protected]> +*/ + +/*\ +* 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 }, + {} + } +};
Signature · 5 lines
2.52.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Cyril,
Quoted 2 lines
This test tests all buffer lenghts shorter than
PATH_MAXand expect thechdir()syscall to succeed.
Reviewed-by Petr Vorel <[email protected]>
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
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
A few typos below.
Quoted 1 line · Cyril Hrubis
This test tests all buffer lenghts shorter than
PATH_MAXand expect the
^ lengths
testcases/kernel/syscalls/chdir/chdir02.c line 29
Quoted 2 lines
testcases/kernel/syscalls/chdir/chdir02.c new file +2
-0+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 <[email protected]>
Signature · 7 lines
Andrea Cervesato SUSE QE Automation Engineer Linux [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Quoted 1 line
The rest LGTM. Feel free to merge.
Typos fixed and patch pushed, thanks.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp