-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This test verifies that ioctl() FICLONE/FICLONERANGE feature raises the right error according with bad file descriptors. Reviewed-by: Cyril Hrubis <[email protected]> Reviewed-by: Petr Vorel <[email protected]> Signed-off-by: Andrea Cervesato <[email protected]>
- Loading branch information
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,5 +25,6 @@ | |
/ioctl_ficlone01 | ||
/ioctl_ficlone02 | ||
/ioctl_ficlone03 | ||
/ioctl_ficlone04 | ||
/ioctl_ficlonerange01 | ||
/ioctl_ficlonerange02 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
/* | ||
* Copyright (C) 2024 Andrea Cervesato <[email protected]> | ||
*/ | ||
|
||
/*\ | ||
* [Description] | ||
* | ||
* This test verifies that ioctl() FICLONE/FICLONERANGE feature raises the right | ||
* error according with bad file descriptors. | ||
*/ | ||
|
||
#include "tst_test.h" | ||
#include "lapi/ficlone.h" | ||
|
||
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(TINFO, "Skipping file: SUCCESS"); | ||
return; | ||
} | ||
|
||
int exp_errnos[] = { | ||
EOPNOTSUPP, | ||
EPERM, | ||
EISDIR, | ||
EBADF, | ||
EINVAL, | ||
EXDEV, | ||
}; | ||
|
||
TST_EXP_FAIL2_ARR(ioctl(fd_dst->fd, FICLONE, fd_src->fd), | ||
exp_errnos, ARRAY_SIZE(exp_errnos), | ||
"ioctl(%s, FICLONE, %s)", | ||
tst_fd_desc(fd_src), | ||
tst_fd_desc(fd_dst)); | ||
} | ||
|
||
static void run(void) | ||
{ | ||
TST_FD_FOREACH(fd_src) { | ||
TST_FD_FOREACH(fd_dst) | ||
test_bad_fd(&fd_src, &fd_dst); | ||
} | ||
} | ||
|
||
static struct tst_test test = { | ||
.test_all = run, | ||
.min_kver = "4.5", | ||
.needs_root = 1, | ||
.needs_tmpdir = 1, | ||
}; |