Add readlink04 test
PATCH 1/1 Add readlink04 test
From: Andrea Cervesato <[email protected]>
This test has been extracted from symlink01 and it verifies that readlink() is working correctly on symlink() generated files.
--- runtest/syscalls | 2 +- testcases/kernel/syscalls/readlink/.gitignore | 1 + .../kernel/syscalls/readlink/readlink04.c | 57 +++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 testcases/kernel/syscalls/readlink/readlink04.c
runtest/syscalls +1 -1
@@ -1125,9 +1125,9 @@ readahead02 readahead02 readdir01 readdir01 readdir21 readdir21 -readlink01A symlink01 -T readlink01 readlink01 readlink01 readlink03 readlink03 +readlink04 readlink04 #readlinkat test cases readlinkat01 readlinkat01
testcases/kernel/syscalls/readlink/.gitignore +1 -0
@@ -1,2 +1,3 @@ /readlink01 /readlink03 +/readlink04
testcases/kernel/syscalls/readlink/readlink04.c new file +57 -0
57 lines not on this page · raw message
Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 63 lines · Andrea Cervesato
From: Andrea Cervesato <[email protected]>
This test has been extracted from symlink01 and it verifies that
readlink()is working correctly onsymlink()generated files.Signed-off-by Andrea Cervesato <[email protected]>--- runtest/syscalls | 2 +- testcases/kernel/syscalls/readlink/.gitignore | 1 + .../kernel/syscalls/readlink/readlink04.c | 57 +++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 testcases/kernel/syscalls/readlink/readlink04.cruntest/syscalls +1
-1@@ -1125,9 +1125,9 @@ readahead02 readahead02 readdir01 readdir01 readdir21 readdir21 -readlink01A symlink01 -T readlink01 readlink01 readlink01 readlink03 readlink03 +readlink04 readlink04 #readlinkat test cases readlinkat01 readlinkat01testcases/kernel/syscalls/readlink/.gitignore +1
-0@@ -1,2 +1,3 @@ /readlink01 /readlink03 +/readlink04testcases/kernel/syscalls/readlink/readlink04.c new file +21
-0@@ -0,0 +1,57 @@ +// 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 <[email protected]> +*/ + +/*\ +* [Description] +* +* This test verifies that readlink() is working correctly on symlink() +* generated files. +*/ + +#include "tst_test.h" + +static void test_readlink (void ) +{ +char *symname ="my_symlink0" ; +
testcases/kernel/syscalls/readlink/readlink04.c line 31
Quoted 10 lines
testcases/kernel/syscalls/readlink/readlink04.c new file +10
-0+SAFE_SYMLINK (tst_get_tmpdir (), symname); + +char path[PATH_MAX ]; +struct stat path_link; + +SAFE_READLINK (symname, path,PATH_MAX ); +TST_EXP_PASS (lstat (path, &path_link)); + +SAFE_UNLINK (symname); +}
Isn't this already tested in readlink01?
And actually the readlink01 is doing this better by comparing the string returned from readlink() against the one we passed to the sysmlink() syscall previously. The lastat() check is indirectly asserting that we got right value as well, however simple memcmp() is better.
Quoted 4 lines
testcases/kernel/syscalls/readlink/readlink04.c new file +4
-0+static void test_readlink_no_path (void ) +{ +char *symname ="my_symlink1" ; +
testcases/kernel/syscalls/readlink/readlink04.c line 46
Quoted 10 lines
testcases/kernel/syscalls/readlink/readlink04.c new file +10
-0+SAFE_SYMLINK ("bc+eFhi!k" , symname); + +char path[PATH_MAX ]; +struct stat path_link; + +SAFE_READLINK (symname, path,PATH_MAX ); +TST_EXP_FAIL (lstat (path, &path_link),ENOENT ); + +SAFE_UNLINK (symname); +}
Maybe it would be easier to add this to symlink01 as well?
In reality it probably does not make much difference if we readlink a symlink to an existing or non-existing file though...
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Quoted 76 lines · Cyril Hrubis
Quoted 63 lines · Andrea Cervesato
From: Andrea Cervesato <[email protected]>
This test has been extracted from symlink01 and it verifies that
readlink()is working correctly onsymlink()generated files.Signed-off-by Andrea Cervesato <[email protected]>--- runtest/syscalls | 2 +- testcases/kernel/syscalls/readlink/.gitignore | 1 + .../kernel/syscalls/readlink/readlink04.c | 57 +++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-)create mode 100644
testcases/kernel/syscalls/readlink/readlink04.cruntest/syscalls +1
-1@@ -1125,9 +1125,9 @@ readahead02 readahead02 readdir01 readdir01 readdir21 readdir21 -readlink01A symlink01 -T readlink01 readlink01 readlink01 readlink03 readlink03 +readlink04 readlink04 #readlinkat test cases readlinkat01 readlinkat01testcases/kernel/syscalls/readlink/.gitignore +1
-0@@ -1,2 +1,3 @@ /readlink01 /readlink03 +/readlink04testcases/kernel/syscalls/readlink/readlink04.c new file +21
-0@@ -0,0 +1,57 @@ +// 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 <[email protected]> +*/ + +/*\ +* [Description] +* +* This test verifies that readlink() is working correctly on symlink() +* generated files. +*/ + +#include "tst_test.h" + +static void test_readlink (void ) +{ +char *symname ="my_symlink0" ; +testcases/kernel/syscalls/readlink/readlink04.c line 31
Quoted 10 lines
testcases/kernel/syscalls/readlink/readlink04.c new file +10
-0+SAFE_SYMLINK (tst_get_tmpdir (), symname); + +char path[PATH_MAX ]; +struct stat path_link; + +SAFE_READLINK (symname, path,PATH_MAX ); +TST_EXP_PASS (lstat (path, &path_link)); + +SAFE_UNLINK (symname); +}Isn't this already tested in readlink01?
Quoted 5 lines
And actually the readlink01 is doing this better by comparing the string returned from
readlink()against the one we passed to thesysmlink()syscall previously. Thelastat()check is indirectly asserting that we got right value as well, however simplememcmp()is better.
I agree, please ignore this test. I think we can just skip it
Quoted 16 lines
Quoted 4 lines
testcases/kernel/syscalls/readlink/readlink04.c new file +4
-0+static void test_readlink_no_path (void ) +{ +char *symname ="my_symlink1" ; +testcases/kernel/syscalls/readlink/readlink04.c line 46
Quoted 10 lines
testcases/kernel/syscalls/readlink/readlink04.c new file +10
-0+SAFE_SYMLINK ("bc+eFhi!k" , symname); + +char path[PATH_MAX ]; +struct stat path_link; + +SAFE_READLINK (symname, path,PATH_MAX ); +TST_EXP_FAIL (lstat (path, &path_link),ENOENT ); + +SAFE_UNLINK (symname); +}Maybe it would be easier to add this to symlink01 as well?
Quoted 3 lines
In reality it probably does not make much difference if we readlink a symlink to an existing or non-existing file though...
Andrea
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi,
taking in consideration the comments, I think we can just forget about it. This test doesn't add anything and we can skip this patch.
Andrea
Quoted 100 lines · Cyril Hrubis
Quoted 63 lines · Andrea Cervesato
From: Andrea Cervesato <[email protected]>
This test has been extracted from symlink01 and it verifies that
readlink()is working correctly onsymlink()generated files.Signed-off-by Andrea Cervesato <[email protected]>--- runtest/syscalls | 2 +- testcases/kernel/syscalls/readlink/.gitignore | 1 + .../kernel/syscalls/readlink/readlink04.c | 57 +++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-)create mode 100644
testcases/kernel/syscalls/readlink/readlink04.cruntest/syscalls +1
-1@@ -1125,9 +1125,9 @@ readahead02 readahead02 readdir01 readdir01 readdir21 readdir21 -readlink01A symlink01 -T readlink01 readlink01 readlink01 readlink03 readlink03 +readlink04 readlink04 #readlinkat test cases readlinkat01 readlinkat01testcases/kernel/syscalls/readlink/.gitignore +1
-0@@ -1,2 +1,3 @@ /readlink01 /readlink03 +/readlink04testcases/kernel/syscalls/readlink/readlink04.c new file +21
-0@@ -0,0 +1,57 @@ +// 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 <[email protected]> +*/ + +/*\ +* [Description] +* +* This test verifies that readlink() is working correctly on symlink() +* generated files. +*/ + +#include "tst_test.h" + +static void test_readlink (void ) +{ +char *symname ="my_symlink0" ; +testcases/kernel/syscalls/readlink/readlink04.c line 31
Quoted 10 lines
testcases/kernel/syscalls/readlink/readlink04.c new file +10
-0+SAFE_SYMLINK (tst_get_tmpdir (), symname); + +char path[PATH_MAX ]; +struct stat path_link; + +SAFE_READLINK (symname, path,PATH_MAX ); +TST_EXP_PASS (lstat (path, &path_link)); + +SAFE_UNLINK (symname); +}Isn't this already tested in readlink01?
And actually the readlink01 is doing this better by comparing the string returned from
readlink()against the one we passed to thesysmlink()syscall previously. Thelastat()check is indirectly asserting that we got right value as well, however simplememcmp()is better.Quoted 4 lines
testcases/kernel/syscalls/readlink/readlink04.c new file +4
-0+static void test_readlink_no_path (void ) +{ +char *symname ="my_symlink1" ; +testcases/kernel/syscalls/readlink/readlink04.c line 46
Quoted 10 lines
testcases/kernel/syscalls/readlink/readlink04.c new file +10
-0+SAFE_SYMLINK ("bc+eFhi!k" , symname); + +char path[PATH_MAX ]; +struct stat path_link; + +SAFE_READLINK (symname, path,PATH_MAX ); +TST_EXP_FAIL (lstat (path, &path_link),ENOENT ); + +SAFE_UNLINK (symname); +}Maybe it would be easier to add this to symlink01 as well?
In reality it probably does not make much difference if we readlink a symlink to an existing or non-existing file though...
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp