Add ioctl_ficlone04 test
PATCH v3 1/1 Add ioctl_ficlone04 test
From: Andrea Cervesato <[email protected]>
This test verifies that ioctl() FICLONE/FICLONERANGE feature raises the right error according with bad file descriptors.
---
This testing suite is testing ioctl() FICLONE and FICLONERANGE functionalities. In particular, file clone and error codes.
---
Changes in v3:
- ioctl_ficlone04: use a generic array for expected errors
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- add fallback definitions
- algorithm steps using '-'
- avoid assigning -1 to file descriptors after close()
- use SAFE_UNLINK() instead of remove()
- enable both xfs and btrs for all tests
- Link to v1: https://lore.kernel.org/r/[email protected]
--- testcases/kernel/syscalls/ioctl/.gitignore | 1 + testcases/kernel/syscalls/ioctl/ioctl_ficlone04.c | 55 +++++++++++++++++++++++ 2 files changed, 56 insertions(+)
testcases/kernel/syscalls/ioctl/.gitignore +1 -0
@@ -25,5 +25,6 @@ /ioctl_ficlone01 /ioctl_ficlone02 /ioctl_ficlone03 +/ioctl_ficlone04 /ioctl_ficlonerange01 /ioctl_ficlonerange02
testcases/kernel/syscalls/ioctl/ioctl_ficlone04.c new file +55 -0
55 lines not on this page · raw message
---
base-commit: c68112b0774bf4f13bfb7b121ecc6671d15d133e
change-id: 20240529-ioctl_ficlone-95c603f71d53
Best regards,
Signature · 5 lines
Andrea Cervesato <[email protected]> -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 6 lines · Andrea Cervesato
From: Andrea Cervesato <[email protected]>
This test verifies that
ioctl()FICLONE/FICLONERANGE feature raises the right error according with bad file descriptors.Signed-off-by Andrea Cervesato <[email protected]>
...
Quoted 8 lines
testcases/kernel/syscalls/ioctl/ioctl_ficlone04.c new file +8
-0+static void test_bad_fd (struct tst_fd *fd_src,struct tst_fd *fd_dst) +{ +if (fd_src->type ==TST_FD_FILE && fd_src->type == fd_dst->type) { +tst_res (TCONF ,"Skipping file: SUCCESS" ); +return ; + } + +if (fd_src->type ==TST_FD_MEMFD && fd_src->type == fd_dst->type) {
testcases/kernel/syscalls/ioctl/ioctl_ficlone04.c line 33
Quoted 10 lines
testcases/kernel/syscalls/ioctl/ioctl_ficlone04.c new file +10
-0+tst_res (TCONF ,"Skipping memory: EOPNOTSUPP" ); +return ; + } + +int exp_errnos[] = { +EISDIR , +EBADF , +EINVAL , +EXDEV , + };
Two comments here: Sometimes security modules forbid operations on unexpected file types and you get EPERM in that case so I'd add it to the list of allowed error codes. Also the test for EOPNOTSUPP looks a bit fragile to me. Currently TST_FD_MEMFD is the only fd type where we'd get as far as checking whether the fs actually supports reflink but that could change in the future. So I'd not special-case MEMFD and instead add EOPNOTSUPP as another allowed error code. Otherwise the test looks good to me.
Honza
Signature · 5 lines
Jan Kara <[email protected]> SUSE Labs, CR -- Mailing list info: https://lists.linux.it/listinfo/ltp