[LTP] [PATCH 3/3] Add ioctl_ficlone03 test
Andrea Cervesato
andrea.cervesato@suse.com
Fri May 31 09:53:10 CEST 2024
Hi,
On 5/30/24 12:52, Cyril Hrubis wrote:
> Hi!
>> inotify_init1_01 inotify_init1_01
>> inotify_init1_02 inotify_init1_02
>> diff --git a/testcases/kernel/syscalls/ioctl/.gitignore b/testcases/kernel/syscalls/ioctl/.gitignore
>> index 3d25fdfb2..d0b470714 100644
>> --- a/testcases/kernel/syscalls/ioctl/.gitignore
>> +++ b/testcases/kernel/syscalls/ioctl/.gitignore
>> @@ -24,3 +24,4 @@
>> /ioctl_sg01
>> /ioctl_ficlone01
>> /ioctl_ficlone02
>> +/ioctl_ficlone03
>> diff --git a/testcases/kernel/syscalls/ioctl/ioctl_ficlone03.c b/testcases/kernel/syscalls/ioctl/ioctl_ficlone03.c
>> new file mode 100644
>> index 000000000..c6f9806a3
>> --- /dev/null
>> +++ b/testcases/kernel/syscalls/ioctl/ioctl_ficlone03.c
>> @@ -0,0 +1,96 @@
>> +// SPDX-License-Identifier: GPL-2.0-or-later
>> +/*
>> + * Copyright (C) 2024 Andrea Cervesato andrea.cervesato@suse.com
>> + */
>> +
>> +/*\
>> + * [Description]
>> + *
>> + * This test verifies that ioctl() FICLONE feature correctly raises exceptions
>> + * when it's supposed to.
>> + */
>> +
>> +#include "tst_test.h"
>> +#include "lapi/fs.h"
>> +
>> +#define MNTPOINT "mnt"
>> +
>> +static int invalid_fd = -1;
>> +static int rw_file = -1;
>> +static int ro_file = -1;
>> +static int wo_file = -1;
>> +static int dir_fd = -1;
>> +static int immut_fd = -1;
>> +static int mnt_file = -1;
>> +
>> +static struct tcase {
>> + int *src_fd;
>> + int *dst_fd;
>> + int errno_exp;
>> + char *msg;
>> +} tcases[] = {
>> + {&invalid_fd, &rw_file, EBADF, "invalid source"},
>> + {&rw_file, &invalid_fd, EBADF, "invalid destination"},
> Can we move these invalid_fd tests into a separate test and use tst_fd
> to loop over all kinds of invalid input and output file descriptors?
>
I don't know if it's worth to loop over all possible cases. Each one of
them has a specific test case.
Also, invalid_fd test cases would look so simple that it makes more
sense to keep it here.
Andrea
More information about the ltp
mailing list