* [LTP] [PATCH v2 1/7] Add fallback definitions for lapi/fs.h
2024-07-23 7:15 [LTP] [PATCH v2 0/7] Add ioctl_ficlone testing suite Andrea Cervesato
@ 2024-07-23 7:15 ` Andrea Cervesato
2024-07-24 11:52 ` Cyril Hrubis
2024-07-24 16:29 ` Cyril Hrubis
2024-07-23 7:15 ` [LTP] [PATCH v2 2/7] Add ioctl_ficlone01 test Andrea Cervesato
` (5 subsequent siblings)
6 siblings, 2 replies; 26+ messages in thread
From: Andrea Cervesato @ 2024-07-23 7:15 UTC (permalink / raw)
To: ltp
From: Andrea Cervesato <andrea.cervesato@suse.com>
This patch adds "struct file_clone_range" and FICLONERANGE fallback
definitions.
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
configure.ac | 1 +
include/lapi/fs.h | 17 +++++++++++++++++
2 files changed, 18 insertions(+)
diff --git a/configure.ac b/configure.ac
index 1f8796c87..4d466f052 100644
--- a/configure.ac
+++ b/configure.ac
@@ -177,6 +177,7 @@ AC_CHECK_TYPES([struct acct_v3],,,[#include <sys/acct.h>])
AC_CHECK_TYPES([struct af_alg_iv, struct sockaddr_alg],,,[# include <linux/if_alg.h>])
AC_CHECK_TYPES([struct fanotify_event_info_fid, struct fanotify_event_info_error,
struct fanotify_event_info_header, struct fanotify_event_info_pidfd],,,[#include <sys/fanotify.h>])
+AC_CHECK_TYPES([struct file_clone_range],,,[#include <linux/fs.h>])
AC_CHECK_TYPES([struct file_dedupe_range],,,[#include <linux/fs.h>])
AC_CHECK_TYPES([struct file_handle],,,[
diff --git a/include/lapi/fs.h b/include/lapi/fs.h
index 635979b02..0e8d646d8 100644
--- a/include/lapi/fs.h
+++ b/include/lapi/fs.h
@@ -20,6 +20,15 @@
#include <limits.h>
#include "lapi/abisize.h"
+#ifndef HAVE_FILE_CLONE_RANGE
+struct file_clone_range {
+ int64_t src_fd;
+ uint64_t src_offset;
+ uint64_t src_length;
+ uint64_t dest_offset;
+};
+#endif
+
#ifndef FS_IOC_GETFLAGS
# define FS_IOC_GETFLAGS _IOR('f', 1, long)
#endif
@@ -48,6 +57,14 @@
# define FS_VERITY_FL 0x00100000 /* Verity protected inode */
#endif
+#ifndef FICLONE
+# define FICLONE _IOW(0x94, 9, int)
+#endif
+
+#ifndef FICLONERANGE
+# define FICLONERANGE _IOW(0x94, 13, struct file_clone_range)
+#endif
+
/*
* Helper function to get MAX_LFS_FILESIZE.
* Missing PAGE_SHIFT on some libc prevents defining MAX_LFS_FILESIZE.
--
2.43.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 26+ messages in thread* Re: [LTP] [PATCH v2 1/7] Add fallback definitions for lapi/fs.h
2024-07-23 7:15 ` [LTP] [PATCH v2 1/7] Add fallback definitions for lapi/fs.h Andrea Cervesato
@ 2024-07-24 11:52 ` Cyril Hrubis
2024-07-24 16:29 ` Cyril Hrubis
1 sibling, 0 replies; 26+ messages in thread
From: Cyril Hrubis @ 2024-07-24 11:52 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: ltp
Hi!
> #include <limits.h>
I've added #include <stdint.h> here to make sure that the *int*_t are
defined and pushed, thanks.
> #include "lapi/abisize.h"
>
> +#ifndef HAVE_FILE_CLONE_RANGE
> +struct file_clone_range {
> + int64_t src_fd;
> + uint64_t src_offset;
> + uint64_t src_length;
> + uint64_t dest_offset;
> +};
> +#endif
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 26+ messages in thread* Re: [LTP] [PATCH v2 1/7] Add fallback definitions for lapi/fs.h
2024-07-23 7:15 ` [LTP] [PATCH v2 1/7] Add fallback definitions for lapi/fs.h Andrea Cervesato
2024-07-24 11:52 ` Cyril Hrubis
@ 2024-07-24 16:29 ` Cyril Hrubis
2024-07-25 7:11 ` Li Wang
1 sibling, 1 reply; 26+ messages in thread
From: Cyril Hrubis @ 2024-07-24 16:29 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: ltp
Hi!
> diff --git a/configure.ac b/configure.ac
> index 1f8796c87..4d466f052 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -177,6 +177,7 @@ AC_CHECK_TYPES([struct acct_v3],,,[#include <sys/acct.h>])
> AC_CHECK_TYPES([struct af_alg_iv, struct sockaddr_alg],,,[# include <linux/if_alg.h>])
> AC_CHECK_TYPES([struct fanotify_event_info_fid, struct fanotify_event_info_error,
> struct fanotify_event_info_header, struct fanotify_event_info_pidfd],,,[#include <sys/fanotify.h>])
> +AC_CHECK_TYPES([struct file_clone_range],,,[#include <linux/fs.h>])
> AC_CHECK_TYPES([struct file_dedupe_range],,,[#include <linux/fs.h>])
>
> AC_CHECK_TYPES([struct file_handle],,,[
> diff --git a/include/lapi/fs.h b/include/lapi/fs.h
> index 635979b02..0e8d646d8 100644
> --- a/include/lapi/fs.h
> +++ b/include/lapi/fs.h
> @@ -20,6 +20,15 @@
> #include <limits.h>
> #include "lapi/abisize.h"
>
> +#ifndef HAVE_FILE_CLONE_RANGE
> +struct file_clone_range {
> + int64_t src_fd;
> + uint64_t src_offset;
> + uint64_t src_length;
> + uint64_t dest_offset;
> +};
> +#endif
Sigh, this is still horribly broken even when I fixed the macro to
HAVE_STRUCT_FILE_CLONE_RANGE that is because:
commit b857f8723f30a4b9554bf6b0ff8fa52fd07e8b60
Author: Li Wang <liwang@redhat.com>
Date: Fri Aug 5 14:34:01 2022 +0800
lapi/fsmount: resolve conflict in different header files
However the CI seems to work fine if I remove the HAVE_MOUNT_SETATTR
check with:
#define LAPI_FS_H__
#include "config.h"
-#ifndef HAVE_MOUNT_SETATTR
-# ifdef HAVE_LINUX_FS_H
-# include <linux/fs.h>
-# endif
+
+#ifdef HAVE_LINUX_FS_H
+# include <linux/fs.h>
#endif
#include <sys/user.h>
@Li do we still need that ifdef or can we get rid of it?
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 26+ messages in thread* Re: [LTP] [PATCH v2 1/7] Add fallback definitions for lapi/fs.h
2024-07-24 16:29 ` Cyril Hrubis
@ 2024-07-25 7:11 ` Li Wang
2024-07-25 9:18 ` Cyril Hrubis
2024-07-25 12:55 ` Petr Vorel
0 siblings, 2 replies; 26+ messages in thread
From: Li Wang @ 2024-07-25 7:11 UTC (permalink / raw)
To: Cyril Hrubis, Petr Vorel; +Cc: ltp
On Thu, Jul 25, 2024 at 12:29 AM Cyril Hrubis <chrubis@suse.cz> wrote:
> Hi!
> > diff --git a/configure.ac b/configure.ac
> > index 1f8796c87..4d466f052 100644
> > --- a/configure.ac
> > +++ b/configure.ac
> > @@ -177,6 +177,7 @@ AC_CHECK_TYPES([struct acct_v3],,,[#include
> <sys/acct.h>])
> > AC_CHECK_TYPES([struct af_alg_iv, struct sockaddr_alg],,,[# include
> <linux/if_alg.h>])
> > AC_CHECK_TYPES([struct fanotify_event_info_fid, struct
> fanotify_event_info_error,
> > struct fanotify_event_info_header, struct
> fanotify_event_info_pidfd],,,[#include <sys/fanotify.h>])
> > +AC_CHECK_TYPES([struct file_clone_range],,,[#include <linux/fs.h>])
> > AC_CHECK_TYPES([struct file_dedupe_range],,,[#include <linux/fs.h>])
> >
> > AC_CHECK_TYPES([struct file_handle],,,[
> > diff --git a/include/lapi/fs.h b/include/lapi/fs.h
> > index 635979b02..0e8d646d8 100644
> > --- a/include/lapi/fs.h
> > +++ b/include/lapi/fs.h
> > @@ -20,6 +20,15 @@
> > #include <limits.h>
> > #include "lapi/abisize.h"
> >
> > +#ifndef HAVE_FILE_CLONE_RANGE
> > +struct file_clone_range {
> > + int64_t src_fd;
> > + uint64_t src_offset;
> > + uint64_t src_length;
> > + uint64_t dest_offset;
> > +};
> > +#endif
>
> Sigh, this is still horribly broken even when I fixed the macro to
> HAVE_STRUCT_FILE_CLONE_RANGE that is because:
>
> commit b857f8723f30a4b9554bf6b0ff8fa52fd07e8b60
> Author: Li Wang <liwang@redhat.com>
> Date: Fri Aug 5 14:34:01 2022 +0800
>
> lapi/fsmount: resolve conflict in different header files
>
>
> However the CI seems to work fine if I remove the HAVE_MOUNT_SETATTR
> check with:
>
> #define LAPI_FS_H__
>
> #include "config.h"
> -#ifndef HAVE_MOUNT_SETATTR
> -# ifdef HAVE_LINUX_FS_H
> -# include <linux/fs.h>
> -# endif
> +
> +#ifdef HAVE_LINUX_FS_H
> +# include <linux/fs.h>
> #endif
>
> #include <sys/user.h>
>
>
> @Li do we still need that ifdef or can we get rid of it?
>
Theoretically, we can remove it because that problem is addressed in
Glibc-2.37 by:
https://github.com/kraj/glibc/commit/774058d72942249f71d74e7f2b639f77184160a6
It is essentially a glibc bug we don't need to fix that in LTP.
We ever discussed in
https://lists.linux.it/pipermail/ltp/2023-March/033138.html
However, if we want LTP could be built with all the middle glibc versions
(2.22 < glibc < 2.36)
this might be thinking over. Because we announce support the minimal
glibc-version is 2.22.
--
Regards,
Li Wang
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 26+ messages in thread* Re: [LTP] [PATCH v2 1/7] Add fallback definitions for lapi/fs.h
2024-07-25 7:11 ` Li Wang
@ 2024-07-25 9:18 ` Cyril Hrubis
2024-07-25 12:55 ` Petr Vorel
1 sibling, 0 replies; 26+ messages in thread
From: Cyril Hrubis @ 2024-07-25 9:18 UTC (permalink / raw)
To: Li Wang; +Cc: ltp
Hi!
> Theoretically, we can remove it because that problem is addressed in
> Glibc-2.37 by:
>
>
> https://github.com/kraj/glibc/commit/774058d72942249f71d74e7f2b639f77184160a6
>
> It is essentially a glibc bug we don't need to fix that in LTP.
>
> We ever discussed in
> https://lists.linux.it/pipermail/ltp/2023-March/033138.html
>
> However, if we want LTP could be built with all the middle glibc versions
> (2.22 < glibc < 2.36)
> this might be thinking over. Because we announce support the minimal
> glibc-version is 2.22.
That does sound like we will need the workaround for quite some time.
Or maybe give up on including linux/fs.h and stick to the libc headers.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [LTP] [PATCH v2 1/7] Add fallback definitions for lapi/fs.h
2024-07-25 7:11 ` Li Wang
2024-07-25 9:18 ` Cyril Hrubis
@ 2024-07-25 12:55 ` Petr Vorel
2024-07-25 15:17 ` Cyril Hrubis
1 sibling, 1 reply; 26+ messages in thread
From: Petr Vorel @ 2024-07-25 12:55 UTC (permalink / raw)
To: Li Wang; +Cc: ltp
Hi all,
...
> > #include "config.h"
> > -#ifndef HAVE_MOUNT_SETATTR
> > -# ifdef HAVE_LINUX_FS_H
> > -# include <linux/fs.h>
> > -# endif
> > +
> > +#ifdef HAVE_LINUX_FS_H
> > +# include <linux/fs.h>
> > #endif
> > #include <sys/user.h>
> > @Li do we still need that ifdef or can we get rid of it?
> Theoretically, we can remove it because that problem is addressed in
> Glibc-2.37 by:
> https://github.com/kraj/glibc/commit/774058d72942249f71d74e7f2b639f77184160a6
> It is essentially a glibc bug we don't need to fix that in LTP.
> We ever discussed in
> https://lists.linux.it/pipermail/ltp/2023-March/033138.html
> However, if we want LTP could be built with all the middle glibc versions
> (2.22 < glibc < 2.36)
> this might be thinking over. Because we announce support the minimal
> glibc-version is 2.22.
Hm, it makes sense to keep it. But nobody will remember once we raise the
support.
Also, removing HAVE_LINUX_FS_H [1] works in the CI [2], including distros with
glibc 2.36 (minimal build [3] or all cross-compile builds, e.g. [4]).
I wonder how realistic is that somebody is still affected by this issue.
Kind regards,
Petr
[1] https://github.com/linux-test-project/ltp/commit/4bc155448559bc2ff75381c0e04662d585677bc4
[2] https://github.com/pevik/ltp/actions/runs/10093238273
[3] https://github.com/pevik/ltp/actions/runs/10093238273/job/27908521308
[4] https://github.com/pevik/ltp/actions/runs/10093238273/job/27908520925
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [LTP] [PATCH v2 1/7] Add fallback definitions for lapi/fs.h
2024-07-25 12:55 ` Petr Vorel
@ 2024-07-25 15:17 ` Cyril Hrubis
2024-07-26 12:03 ` Li Wang
0 siblings, 1 reply; 26+ messages in thread
From: Cyril Hrubis @ 2024-07-25 15:17 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
Hi!
> > However, if we want LTP could be built with all the middle glibc versions
> > (2.22 < glibc < 2.36)
> > this might be thinking over. Because we announce support the minimal
> > glibc-version is 2.22.
>
> Hm, it makes sense to keep it. But nobody will remember once we raise the
> support.
Maybe we should at least add a comment glibc-2.22 workaround or
something that could be found with grep.
> Also, removing HAVE_LINUX_FS_H [1] works in the CI [2], including distros with
> glibc 2.36 (minimal build [3] or all cross-compile builds, e.g. [4]).
>
> I wonder how realistic is that somebody is still affected by this issue.
That's a good question but I'm afraid the only way to find out is to
remove the workaround and wait for people complain that the next LTP
release is broken...
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [LTP] [PATCH v2 1/7] Add fallback definitions for lapi/fs.h
2024-07-25 15:17 ` Cyril Hrubis
@ 2024-07-26 12:03 ` Li Wang
0 siblings, 0 replies; 26+ messages in thread
From: Li Wang @ 2024-07-26 12:03 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: ltp
On Thu, Jul 25, 2024 at 11:17 PM Cyril Hrubis <chrubis@suse.cz> wrote:
> Hi!
> > > However, if we want LTP could be built with all the middle glibc
> versions
> > > (2.22 < glibc < 2.36)
> > > this might be thinking over. Because we announce support the minimal
> > > glibc-version is 2.22.
> >
> > Hm, it makes sense to keep it. But nobody will remember once we raise the
> > support.
>
> Maybe we should at least add a comment glibc-2.22 workaround or
> something that could be found with grep.
>
Sounds good.
> > Also, removing HAVE_LINUX_FS_H [1] works in the CI [2], including
> distros with
> > glibc 2.36 (minimal build [3] or all cross-compile builds, e.g. [4]).
> >
> > I wonder how realistic is that somebody is still affected by this issue.
>
> That's a good question but I'm afraid the only way to find out is to
> remove the workaround and wait for people complain that the next LTP
> release is broken...
>
I remember the broken was found by our CI automation tests
on Fedora-rawhide at that moment. That is a tentative version
and fixed imitatively by my patch, so yes, we can remove that
to see if it impacts other users.
--
Regards,
Li Wang
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 26+ messages in thread
* [LTP] [PATCH v2 2/7] Add ioctl_ficlone01 test
2024-07-23 7:15 [LTP] [PATCH v2 0/7] Add ioctl_ficlone testing suite Andrea Cervesato
2024-07-23 7:15 ` [LTP] [PATCH v2 1/7] Add fallback definitions for lapi/fs.h Andrea Cervesato
@ 2024-07-23 7:15 ` Andrea Cervesato
2024-07-23 7:15 ` [LTP] [PATCH v2 3/7] Add ioctl_ficlone02 test Andrea Cervesato
` (4 subsequent siblings)
6 siblings, 0 replies; 26+ messages in thread
From: Andrea Cervesato @ 2024-07-23 7:15 UTC (permalink / raw)
To: ltp
From: Andrea Cervesato <andrea.cervesato@suse.com>
This test verifies that ioctl() FICLONE feature clones file content
from one file to an another.
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
runtest/syscalls | 2 +
testcases/kernel/syscalls/ioctl/.gitignore | 1 +
testcases/kernel/syscalls/ioctl/ioctl_ficlone01.c | 122 ++++++++++++++++++++++
3 files changed, 125 insertions(+)
diff --git a/runtest/syscalls b/runtest/syscalls
index 27eb9a86b..f05386ba2 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -592,6 +592,8 @@ ioctl_ns07 ioctl_ns07
ioctl_sg01 ioctl_sg01
+ioctl_ficlone01 ioctl_ficlone01
+
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 5fff7a61d..5404aa93f 100644
--- a/testcases/kernel/syscalls/ioctl/.gitignore
+++ b/testcases/kernel/syscalls/ioctl/.gitignore
@@ -22,3 +22,4 @@
/ioctl_ns06
/ioctl_ns07
/ioctl_sg01
+/ioctl_ficlone01
diff --git a/testcases/kernel/syscalls/ioctl/ioctl_ficlone01.c b/testcases/kernel/syscalls/ioctl/ioctl_ficlone01.c
new file mode 100644
index 000000000..bb3dc8c6c
--- /dev/null
+++ b/testcases/kernel/syscalls/ioctl/ioctl_ficlone01.c
@@ -0,0 +1,122 @@
+// 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 clones file content from
+ * one file to an another.
+ *
+ * [Algorithm]
+ *
+ * - populate source file
+ * - clone source content inside destination file
+ * - verify that source content has been cloned inside destination file
+ * - write a single byte inside destination file
+ * - verify that source content didn't change while destination did
+ */
+
+#include "tst_test.h"
+#include "lapi/fs.h"
+
+#define MNTPOINT "mnt"
+#define SRCPATH MNTPOINT "/file0"
+#define DSTPATH MNTPOINT "/file1"
+
+#define FILEDATA "qwerty"
+#define FILESIZE sizeof(FILEDATA)
+
+static int src_fd = -1;
+static int dst_fd = -1;
+
+static void run(void)
+{
+ char buff[FILESIZE];
+ struct stat src_stat;
+ struct stat dst_stat;
+
+ src_fd = SAFE_OPEN(SRCPATH, O_CREAT | O_RDWR, 0640);
+ dst_fd = SAFE_OPEN(DSTPATH, O_CREAT | O_RDWR, 0640);
+
+ tst_res(TINFO, "Writing data inside src file");
+
+ SAFE_WRITE(1, src_fd, FILEDATA, FILESIZE);
+ SAFE_FSYNC(src_fd);
+
+ TST_EXP_PASS(ioctl(dst_fd, FICLONE, src_fd));
+ if (TST_RET == -1)
+ return;
+
+ SAFE_FSYNC(dst_fd);
+
+ tst_res(TINFO, "Verifing that data is cloned between files");
+
+ SAFE_FSTAT(src_fd, &src_stat);
+ SAFE_FSTAT(dst_fd, &dst_stat);
+
+ TST_EXP_EXPR(src_stat.st_ino != dst_stat.st_ino,
+ "inode is different. %lu != %lu",
+ src_stat.st_ino,
+ dst_stat.st_ino);
+
+ TST_EXP_EQ_LI(src_stat.st_size, dst_stat.st_size);
+
+ SAFE_READ(0, dst_fd, buff, FILESIZE);
+
+ TST_EXP_EXPR(!strncmp(buff, FILEDATA, FILESIZE),
+ "dst file has the src file content (\"%s\" - %ld bytes)",
+ buff,
+ FILESIZE);
+
+ tst_res(TINFO, "Writing a byte inside dst file");
+
+ SAFE_LSEEK(dst_fd, 0, SEEK_SET);
+ SAFE_WRITE(SAFE_WRITE_ALL, dst_fd, "+", 1);
+ SAFE_FSYNC(dst_fd);
+
+ tst_res(TINFO, "Verifing that src file content didn't change");
+
+ SAFE_FSTAT(src_fd, &src_stat);
+ SAFE_FSTAT(dst_fd, &dst_stat);
+
+ TST_EXP_EQ_LI(dst_stat.st_size, src_stat.st_size);
+
+ SAFE_READ(0, src_fd, buff, FILESIZE);
+
+ TST_EXP_EXPR(!strncmp(buff, FILEDATA, FILESIZE),
+ "src file content didn't change");
+
+ SAFE_CLOSE(src_fd);
+ SAFE_CLOSE(dst_fd);
+
+ SAFE_UNLINK(SRCPATH);
+ SAFE_UNLINK(DSTPATH);
+}
+
+static void cleanup(void)
+{
+ if (src_fd != -1)
+ SAFE_CLOSE(src_fd);
+
+ if (dst_fd != -1)
+ SAFE_CLOSE(dst_fd);
+}
+
+static struct tst_test test = {
+ .test_all = run,
+ .cleanup = cleanup,
+ .min_kver = "4.5",
+ .needs_root = 1,
+ .mount_device = 1,
+ .mntpoint = MNTPOINT,
+ .filesystems = (struct tst_fs []) {
+ {.type = "btrfs"},
+ {
+ .type = "xfs",
+ .mkfs_opts = (const char *const []) {"-m", "reflink=1", NULL},
+ },
+ {}
+ }
+};
--
2.43.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 26+ messages in thread* [LTP] [PATCH v2 3/7] Add ioctl_ficlone02 test
2024-07-23 7:15 [LTP] [PATCH v2 0/7] Add ioctl_ficlone testing suite Andrea Cervesato
2024-07-23 7:15 ` [LTP] [PATCH v2 1/7] Add fallback definitions for lapi/fs.h Andrea Cervesato
2024-07-23 7:15 ` [LTP] [PATCH v2 2/7] Add ioctl_ficlone01 test Andrea Cervesato
@ 2024-07-23 7:15 ` Andrea Cervesato
2024-07-29 11:53 ` Petr Vorel
2024-07-23 7:15 ` [LTP] [PATCH v2 4/7] Add ioctl_ficlone03 test Andrea Cervesato
` (3 subsequent siblings)
6 siblings, 1 reply; 26+ messages in thread
From: Andrea Cervesato @ 2024-07-23 7:15 UTC (permalink / raw)
To: ltp
From: Andrea Cervesato <andrea.cervesato@suse.com>
This test verifies that ioctl() FICLONE/FICLONERANGE feature
correctly raises EOPNOTSUPP when unsupported filesystem is used.
In particular, filesystems which don't support copy-on-write.
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
runtest/syscalls | 1 +
testcases/kernel/syscalls/ioctl/.gitignore | 1 +
testcases/kernel/syscalls/ioctl/ioctl_ficlone02.c | 70 +++++++++++++++++++++++
3 files changed, 72 insertions(+)
diff --git a/runtest/syscalls b/runtest/syscalls
index f05386ba2..48fe85c97 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -593,6 +593,7 @@ ioctl_ns07 ioctl_ns07
ioctl_sg01 ioctl_sg01
ioctl_ficlone01 ioctl_ficlone01
+ioctl_ficlone02 ioctl_ficlone02
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 5404aa93f..3d25fdfb2 100644
--- a/testcases/kernel/syscalls/ioctl/.gitignore
+++ b/testcases/kernel/syscalls/ioctl/.gitignore
@@ -23,3 +23,4 @@
/ioctl_ns07
/ioctl_sg01
/ioctl_ficlone01
+/ioctl_ficlone02
diff --git a/testcases/kernel/syscalls/ioctl/ioctl_ficlone02.c b/testcases/kernel/syscalls/ioctl/ioctl_ficlone02.c
new file mode 100644
index 000000000..f6d492026
--- /dev/null
+++ b/testcases/kernel/syscalls/ioctl/ioctl_ficlone02.c
@@ -0,0 +1,70 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2024 Andrea Cervesato andrea.cervesato@suse.com
+ */
+
+/*\
+ * [Description]
+ *
+ * This test verifies that ioctl() FICLONE/FICLONERANGE feature correctly raises
+ * EOPNOTSUPP when an unsupported filesystem is used. In particular, filesystems
+ * which don't support copy-on-write.
+ */
+
+#include "tst_test.h"
+#include "lapi/fs.h"
+
+#define MNTPOINT "mnt"
+#define SRCPATH MNTPOINT "/file0"
+#define DSTPATH MNTPOINT "/file1"
+
+static struct file_clone_range *clone_range;
+
+static void run(void)
+{
+ int src_fd;
+ int dst_fd;
+
+ src_fd = SAFE_OPEN(SRCPATH, O_CREAT | O_RDWR, 0640);
+ dst_fd = SAFE_OPEN(DSTPATH, O_CREAT | O_RDWR, 0640);
+
+ clone_range->src_fd = src_fd;
+
+ TST_EXP_FAIL(ioctl(dst_fd, FICLONE, src_fd), EOPNOTSUPP);
+ TST_EXP_FAIL(ioctl(dst_fd, FICLONERANGE, clone_range), EOPNOTSUPP);
+
+ SAFE_CLOSE(src_fd);
+ SAFE_CLOSE(dst_fd);
+}
+
+static void setup(void)
+{
+ struct stat sb;
+
+ SAFE_STAT(MNTPOINT, &sb);
+
+ clone_range->src_offset = 0;
+ clone_range->src_length = sb.st_blksize;
+ clone_range->dest_offset = 0;
+}
+
+static struct tst_test test = {
+ .test_all = run,
+ .setup = setup,
+ .min_kver = "4.5",
+ .needs_root = 1,
+ .mount_device = 1,
+ .mntpoint = MNTPOINT,
+ .all_filesystems = 1,
+ .skip_filesystems = (const char *[]) {
+ "btrfs",
+ "overlayfs",
+ "nfs",
+ "xfs",
+ NULL,
+ },
+ .bufs = (struct tst_buffers []) {
+ {&clone_range, .size = sizeof(struct file_clone_range)},
+ {},
+ }
+};
--
2.43.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 26+ messages in thread* Re: [LTP] [PATCH v2 3/7] Add ioctl_ficlone02 test
2024-07-23 7:15 ` [LTP] [PATCH v2 3/7] Add ioctl_ficlone02 test Andrea Cervesato
@ 2024-07-29 11:53 ` Petr Vorel
2024-07-29 12:03 ` Cyril Hrubis
0 siblings, 1 reply; 26+ messages in thread
From: Petr Vorel @ 2024-07-29 11:53 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: linux-bcachefs, Kent Overstreet, ltp
Hi all,
> This test verifies that ioctl() FICLONE/FICLONERANGE feature
> correctly raises EOPNOTSUPP when unsupported filesystem is used.
> In particular, filesystems which don't support copy-on-write.
This test, merged as [1] fails on bcachefs:
$ cd testcases/kernel/syscalls/ioctl/
# # LTP_SINGLE_FS_TYPE=bcachefs ./ioctl_ficlone02
tst_buffers.c:57: TINFO: Test is using guarded buffers
tst_tmpdir.c:316: TINFO: Using /tmp/LTP_iocu1xhKp as tmpdir (tmpfs filesystem)
tst_device.c:96: TINFO: Found free device 0 '/dev/loop0'
tst_test.c:1806: TINFO: LTP version: 20240524-131-gdfb293ee0
tst_test.c:1650: TINFO: Timeout per run is 0h 00m 30s
tst_supported_fs_types.c:161: TINFO: WARNING: testing only bcachefs
tst_supported_fs_types.c:97: TINFO: Kernel supports bcachefs
tst_supported_fs_types.c:62: TINFO: mkfs.bcachefs does exist
tst_test.c:1746: TINFO: === Testing on bcachefs ===
tst_test.c:1111: TINFO: Formatting /dev/loop0 with bcachefs opts='' extra opts=''
tst_test.c:1123: TINFO: Mounting /dev/loop0 to /tmp/LTP_iocu1xhKp/mnt fstyp=bcachefs flags=0
ioctl_ficlone02.c:33: TFAIL: ioctl(dst_fd, FICLONE, src_fd) succeeded
ioctl_ficlone02.c:34: TFAIL: ioctl(dst_fd, FICLONERANGE, clone_range) expected EOPNOTSUPP: EINVAL (22)
I tested only kernel 6.10 and 6.9, fails on both. Maybe it's just a different
errno set...
Kind regards,
Petr
[1] https://github.com/linux-test-project/ltp/commit/d70bfb185c9aa52aeab9b9893055eec7fc969a4f
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [LTP] [PATCH v2 3/7] Add ioctl_ficlone02 test
2024-07-29 11:53 ` Petr Vorel
@ 2024-07-29 12:03 ` Cyril Hrubis
2024-07-29 21:29 ` Petr Vorel
0 siblings, 1 reply; 26+ messages in thread
From: Cyril Hrubis @ 2024-07-29 12:03 UTC (permalink / raw)
To: Petr Vorel; +Cc: linux-bcachefs, Kent Overstreet, ltp
Hi!
> This test, merged as [1] fails on bcachefs:
>
> $ cd testcases/kernel/syscalls/ioctl/
> # # LTP_SINGLE_FS_TYPE=bcachefs ./ioctl_ficlone02
> tst_buffers.c:57: TINFO: Test is using guarded buffers
> tst_tmpdir.c:316: TINFO: Using /tmp/LTP_iocu1xhKp as tmpdir (tmpfs filesystem)
> tst_device.c:96: TINFO: Found free device 0 '/dev/loop0'
> tst_test.c:1806: TINFO: LTP version: 20240524-131-gdfb293ee0
> tst_test.c:1650: TINFO: Timeout per run is 0h 00m 30s
> tst_supported_fs_types.c:161: TINFO: WARNING: testing only bcachefs
> tst_supported_fs_types.c:97: TINFO: Kernel supports bcachefs
> tst_supported_fs_types.c:62: TINFO: mkfs.bcachefs does exist
> tst_test.c:1746: TINFO: === Testing on bcachefs ===
> tst_test.c:1111: TINFO: Formatting /dev/loop0 with bcachefs opts='' extra opts=''
> tst_test.c:1123: TINFO: Mounting /dev/loop0 to /tmp/LTP_iocu1xhKp/mnt fstyp=bcachefs flags=0
> ioctl_ficlone02.c:33: TFAIL: ioctl(dst_fd, FICLONE, src_fd) succeeded
> ioctl_ficlone02.c:34: TFAIL: ioctl(dst_fd, FICLONERANGE, clone_range) expected EOPNOTSUPP: EINVAL (22)
This looks that FIOCLONE is supported on bcachefs and bcachefs should be
skipped in this test as well. And I suppose that we should enable
bcachefs in the rest of the FICLONE tests too.
BTW, the EINVAL in the second subtest is caused by the fact that we
attempt to clone a range that does not exist, this can be fixed by:
diff --git a/testcases/kernel/syscalls/ioctl/ioctl_ficlone02.c b/testcases/kernel/syscalls/ioctl/ioctl_ficlone02.c
index be3b01c29..17452a1a3 100644
--- a/testcases/kernel/syscalls/ioctl/ioctl_ficlone02.c
+++ b/testcases/kernel/syscalls/ioctl/ioctl_ficlone02.c
@@ -43,6 +43,8 @@ static void setup(void)
SAFE_STAT(MNTPOINT, &sb);
+ tst_fill_file(SRCPATH, 0x00, sb.st_blksize, 1);
+
clone_range->src_offset = 0;
clone_range->src_length = sb.st_blksize;
clone_range->dest_offset = 0;
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 26+ messages in thread* Re: [LTP] [PATCH v2 3/7] Add ioctl_ficlone02 test
2024-07-29 12:03 ` Cyril Hrubis
@ 2024-07-29 21:29 ` Petr Vorel
0 siblings, 0 replies; 26+ messages in thread
From: Petr Vorel @ 2024-07-29 21:29 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: linux-bcachefs, Kent Overstreet, ltp
Hi Cyril, all,
> Hi!
> > This test, merged as [1] fails on bcachefs:
> > $ cd testcases/kernel/syscalls/ioctl/
> > # # LTP_SINGLE_FS_TYPE=bcachefs ./ioctl_ficlone02
> > tst_buffers.c:57: TINFO: Test is using guarded buffers
> > tst_tmpdir.c:316: TINFO: Using /tmp/LTP_iocu1xhKp as tmpdir (tmpfs filesystem)
> > tst_device.c:96: TINFO: Found free device 0 '/dev/loop0'
> > tst_test.c:1806: TINFO: LTP version: 20240524-131-gdfb293ee0
> > tst_test.c:1650: TINFO: Timeout per run is 0h 00m 30s
> > tst_supported_fs_types.c:161: TINFO: WARNING: testing only bcachefs
> > tst_supported_fs_types.c:97: TINFO: Kernel supports bcachefs
> > tst_supported_fs_types.c:62: TINFO: mkfs.bcachefs does exist
> > tst_test.c:1746: TINFO: === Testing on bcachefs ===
> > tst_test.c:1111: TINFO: Formatting /dev/loop0 with bcachefs opts='' extra opts=''
> > tst_test.c:1123: TINFO: Mounting /dev/loop0 to /tmp/LTP_iocu1xhKp/mnt fstyp=bcachefs flags=0
> > ioctl_ficlone02.c:33: TFAIL: ioctl(dst_fd, FICLONE, src_fd) succeeded
> > ioctl_ficlone02.c:34: TFAIL: ioctl(dst_fd, FICLONERANGE, clone_range) expected EOPNOTSUPP: EINVAL (22)
> This looks that FIOCLONE is supported on bcachefs and bcachefs should be
> skipped in this test as well. And I suppose that we should enable
> bcachefs in the rest of the FICLONE tests too.
Thanks! (I should have read the test description).
I dared to enable it + skip on ioctl_ficlone02.c and merge with your SBT
https://github.com/linux-test-project/ltp/commit/b3d9561793657239548269378d02f65580917e7c
> BTW, the EINVAL in the second subtest is caused by the fact that we
> attempt to clone a range that does not exist, this can be fixed by:
> diff --git a/testcases/kernel/syscalls/ioctl/ioctl_ficlone02.c b/testcases/kernel/syscalls/ioctl/ioctl_ficlone02.c
> index be3b01c29..17452a1a3 100644
> --- a/testcases/kernel/syscalls/ioctl/ioctl_ficlone02.c
> +++ b/testcases/kernel/syscalls/ioctl/ioctl_ficlone02.c
> @@ -43,6 +43,8 @@ static void setup(void)
> SAFE_STAT(MNTPOINT, &sb);
> + tst_fill_file(SRCPATH, 0x00, sb.st_blksize, 1);
> +
> clone_range->src_offset = 0;
> clone_range->src_length = sb.st_blksize;
> clone_range->dest_offset = 0;
Thanks, again! This is less confusing. I again dared to merge with your SBT:
https://github.com/linux-test-project/ltp/commit/9c6390812831f5c36e531be5a25bd8d7862e79fb
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 26+ messages in thread
* [LTP] [PATCH v2 4/7] Add ioctl_ficlone03 test
2024-07-23 7:15 [LTP] [PATCH v2 0/7] Add ioctl_ficlone testing suite Andrea Cervesato
` (2 preceding siblings ...)
2024-07-23 7:15 ` [LTP] [PATCH v2 3/7] Add ioctl_ficlone02 test Andrea Cervesato
@ 2024-07-23 7:15 ` Andrea Cervesato
2024-07-24 12:20 ` Cyril Hrubis
2024-07-23 7:15 ` [LTP] [PATCH v2 5/7] Add ioctl_ficlonerange01 test Andrea Cervesato
` (2 subsequent siblings)
6 siblings, 1 reply; 26+ messages in thread
From: Andrea Cervesato @ 2024-07-23 7:15 UTC (permalink / raw)
To: ltp
From: Andrea Cervesato <andrea.cervesato@suse.com>
This test verifies that ioctl() FICLONE/FICLONERANGE feature correctly
raises exceptions when it's supposed to.
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
runtest/syscalls | 1 +
testcases/kernel/syscalls/ioctl/.gitignore | 1 +
testcases/kernel/syscalls/ioctl/ioctl_ficlone03.c | 124 ++++++++++++++++++++++
3 files changed, 126 insertions(+)
diff --git a/runtest/syscalls b/runtest/syscalls
index 48fe85c97..5aef2b97e 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -594,6 +594,7 @@ ioctl_sg01 ioctl_sg01
ioctl_ficlone01 ioctl_ficlone01
ioctl_ficlone02 ioctl_ficlone02
+ioctl_ficlone03 ioctl_ficlone03
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..be069836a
--- /dev/null
+++ b/testcases/kernel/syscalls/ioctl/ioctl_ficlone03.c
@@ -0,0 +1,124 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2024 Andrea Cervesato andrea.cervesato@suse.com
+ */
+
+/*\
+ * [Description]
+ *
+ * This test verifies that ioctl() FICLONE/FICLONERANGE feature correctly raises
+ * exceptions when it's supposed to.
+ */
+
+#include "tst_test.h"
+#include "lapi/fs.h"
+
+#define MNTPOINT "mnt"
+
+static struct file_clone_range *clone_range;
+
+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"},
+ {&rw_file, &ro_file, EBADF, "read-only destination"},
+ {&wo_file, &rw_file, EBADF, "write-only source"},
+ {&rw_file, &dir_fd, EISDIR, "source is a directory"},
+ {&dir_fd, &rw_file, EISDIR, "destination is a directory"},
+ {&rw_file, &immut_fd, EPERM, "destination is immutable"},
+ {&rw_file, &mnt_file, EXDEV, "destination is on a different mount"},
+ {&mnt_file, &rw_file, EXDEV, "source is on a different mount"},
+};
+
+static void run(unsigned int n)
+{
+ struct tcase *tc = &tcases[n];
+
+ TST_EXP_FAIL(ioctl(*tc->dst_fd, FICLONE, *tc->src_fd),
+ tc->errno_exp,
+ "%s", tc->msg);
+
+ clone_range->src_fd = *tc->src_fd;
+
+ TST_EXP_FAIL(ioctl(*tc->dst_fd, FICLONERANGE, clone_range),
+ tc->errno_exp,
+ "%s", tc->msg);
+}
+
+static void setup(void)
+{
+ int attr;
+ struct stat sb;
+
+ rw_file = SAFE_OPEN("ok_only", O_CREAT | O_RDWR, 0640);
+ ro_file = SAFE_OPEN("rd_only", O_CREAT | O_RDONLY, 0640);
+ wo_file = SAFE_OPEN("rw_only", O_CREAT | O_WRONLY, 0640);
+
+ if (access("mydir", F_OK) == -1)
+ SAFE_MKDIR("mydir", 0640);
+
+ dir_fd = SAFE_OPEN("mydir", O_DIRECTORY, 0640);
+
+ attr = FS_IMMUTABLE_FL;
+ immut_fd = SAFE_OPEN("immutable", O_CREAT | O_RDWR, 0640);
+ SAFE_IOCTL(immut_fd, FS_IOC_SETFLAGS, &attr);
+
+ mnt_file = SAFE_OPEN(MNTPOINT"/file", O_CREAT | O_RDWR, 0640);
+
+ SAFE_STAT(MNTPOINT, &sb);
+
+ clone_range->src_offset = 0;
+ clone_range->src_length = sb.st_blksize;
+ clone_range->dest_offset = 0;
+}
+
+static void cleanup(void)
+{
+ int attr;
+
+ SAFE_IOCTL(immut_fd, FS_IOC_GETFLAGS, &attr);
+ attr &= ~FS_IMMUTABLE_FL;
+ SAFE_IOCTL(immut_fd, FS_IOC_SETFLAGS, &attr);
+ SAFE_CLOSE(immut_fd);
+
+ SAFE_CLOSE(rw_file);
+ SAFE_CLOSE(ro_file);
+ SAFE_CLOSE(wo_file);
+ SAFE_CLOSE(dir_fd);
+ SAFE_CLOSE(mnt_file);
+}
+
+static struct tst_test test = {
+ .test = run,
+ .tcnt = ARRAY_SIZE(tcases),
+ .setup = setup,
+ .cleanup = cleanup,
+ .min_kver = "4.5",
+ .needs_root = 1,
+ .mount_device = 1,
+ .mntpoint = MNTPOINT,
+ .filesystems = (struct tst_fs []) {
+ {.type = "btrfs"},
+ {
+ .type = "xfs",
+ .mkfs_opts = (const char *const []) {"-m", "reflink=1", NULL},
+ },
+ {}
+ },
+ .bufs = (struct tst_buffers []) {
+ {&clone_range, .size = sizeof(struct file_clone_range)},
+ {},
+ }
+};
--
2.43.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 26+ messages in thread* Re: [LTP] [PATCH v2 4/7] Add ioctl_ficlone03 test
2024-07-23 7:15 ` [LTP] [PATCH v2 4/7] Add ioctl_ficlone03 test Andrea Cervesato
@ 2024-07-24 12:20 ` Cyril Hrubis
0 siblings, 0 replies; 26+ messages in thread
From: Cyril Hrubis @ 2024-07-24 12:20 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: ltp
Hi!
Pushed with a small fix, thanks.
The immutable file has to be on the MNTPOINT as well as th source for
the immutable file, otherwise we get EOPNOTSUPP instead of EPERM since
the check for supported filesystems kicks in first:
diff --git a/testcases/kernel/syscalls/ioctl/ioctl_ficlone03.c b/testcases/kernel/syscalls/ioctl/ioctl_ficlone03.c
index be069836a..406b64cca 100644
--- a/testcases/kernel/syscalls/ioctl/ioctl_ficlone03.c
+++ b/testcases/kernel/syscalls/ioctl/ioctl_ficlone03.c
@@ -37,7 +37,7 @@ static struct tcase {
{&wo_file, &rw_file, EBADF, "write-only source"},
{&rw_file, &dir_fd, EISDIR, "source is a directory"},
{&dir_fd, &rw_file, EISDIR, "destination is a directory"},
- {&rw_file, &immut_fd, EPERM, "destination is immutable"},
+ {&mnt_file, &immut_fd, EPERM, "destination is immutable"},
{&rw_file, &mnt_file, EXDEV, "destination is on a different mount"},
{&mnt_file, &rw_file, EXDEV, "source is on a different mount"},
};
@@ -72,7 +72,7 @@ static void setup(void)
dir_fd = SAFE_OPEN("mydir", O_DIRECTORY, 0640);
attr = FS_IMMUTABLE_FL;
- immut_fd = SAFE_OPEN("immutable", O_CREAT | O_RDWR, 0640);
+ immut_fd = SAFE_OPEN(MNTPOINT"/immutable", O_CREAT | O_RDWR, 0640);
SAFE_IOCTL(immut_fd, FS_IOC_SETFLAGS, &attr);
mnt_file = SAFE_OPEN(MNTPOINT"/file", O_CREAT | O_RDWR, 0640);
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [LTP] [PATCH v2 5/7] Add ioctl_ficlonerange01 test
2024-07-23 7:15 [LTP] [PATCH v2 0/7] Add ioctl_ficlone testing suite Andrea Cervesato
` (3 preceding siblings ...)
2024-07-23 7:15 ` [LTP] [PATCH v2 4/7] Add ioctl_ficlone03 test Andrea Cervesato
@ 2024-07-23 7:15 ` Andrea Cervesato
2024-07-24 15:24 ` Cyril Hrubis
2024-07-23 7:15 ` [LTP] [PATCH v2 6/7] Add ioctl_ficlonerange02 test Andrea Cervesato
2024-07-23 7:15 ` [LTP] [PATCH v2 7/7] Add ioctl_ficlone04 test Andrea Cervesato
6 siblings, 1 reply; 26+ messages in thread
From: Andrea Cervesato @ 2024-07-23 7:15 UTC (permalink / raw)
To: ltp
From: Andrea Cervesato <andrea.cervesato@suse.com>
This test verifies that ioctl() FICLONERANGE feature clones file
content from one file to an another.
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
runtest/syscalls | 1 +
testcases/kernel/syscalls/ioctl/.gitignore | 1 +
.../kernel/syscalls/ioctl/ioctl_ficlonerange01.c | 162 +++++++++++++++++++++
3 files changed, 164 insertions(+)
diff --git a/runtest/syscalls b/runtest/syscalls
index 5aef2b97e..1f050c5f5 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -595,6 +595,7 @@ ioctl_sg01 ioctl_sg01
ioctl_ficlone01 ioctl_ficlone01
ioctl_ficlone02 ioctl_ficlone02
ioctl_ficlone03 ioctl_ficlone03
+ioctl_ficlonerange01 ioctl_ficlonerange01
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 d0b470714..08c015928 100644
--- a/testcases/kernel/syscalls/ioctl/.gitignore
+++ b/testcases/kernel/syscalls/ioctl/.gitignore
@@ -25,3 +25,4 @@
/ioctl_ficlone01
/ioctl_ficlone02
/ioctl_ficlone03
+/ioctl_ficlonerange01
diff --git a/testcases/kernel/syscalls/ioctl/ioctl_ficlonerange01.c b/testcases/kernel/syscalls/ioctl/ioctl_ficlonerange01.c
new file mode 100644
index 000000000..122b7656f
--- /dev/null
+++ b/testcases/kernel/syscalls/ioctl/ioctl_ficlonerange01.c
@@ -0,0 +1,162 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2024 Andrea Cervesato andrea.cervesato@suse.com
+ */
+
+/*\
+ * [Description]
+ *
+ * This test verifies that ioctl() FICLONERANGE feature clones file content from
+ * one file to an another.
+ *
+ * [Algorithm]
+ *
+ * - populate source file
+ * - clone a portion of source content inside destination file
+ * - verify that source content portion has been cloned inside destination file
+ * - write a single byte inside destination file
+ * - verify that source content didn't change while destination did
+ */
+
+#include "tst_test.h"
+#include "lapi/fs.h"
+
+#define MNTPOINT "mnt"
+#define SRCPATH MNTPOINT "/file0"
+#define DSTPATH MNTPOINT "/file1"
+#define CHUNKS 64
+
+static struct file_clone_range *clone_range;
+static int filesize;
+static int offset;
+static int leftsize;
+static int src_fd = -1;
+static int dst_fd = -1;
+static char *data;
+static char *buff;
+
+static void run(void)
+{
+ struct stat src_stat;
+ struct stat dst_stat;
+
+ for (int i = 0; i < filesize; i++)
+ data[i] = 'a' + (rand() % 21);
+
+ src_fd = SAFE_OPEN(SRCPATH, O_CREAT | O_RDWR, 0640);
+ dst_fd = SAFE_OPEN(DSTPATH, O_CREAT | O_RDWR, 0640);
+
+ tst_res(TINFO, "Writing data inside src file");
+
+ SAFE_WRITE(SAFE_WRITE_ALL, src_fd, data, filesize);
+ SAFE_FSYNC(src_fd);
+
+ clone_range->src_fd = src_fd;
+ TST_EXP_PASS(ioctl(dst_fd, FICLONERANGE, clone_range));
+ if (TST_RET == -1)
+ return;
+
+ SAFE_FSYNC(dst_fd);
+
+ tst_res(TINFO, "Verifing that data is cloned between files");
+
+ SAFE_FSTAT(src_fd, &src_stat);
+ SAFE_FSTAT(dst_fd, &dst_stat);
+
+ TST_EXP_EXPR(src_stat.st_ino != dst_stat.st_ino,
+ "inode is different. %lu != %lu",
+ src_stat.st_ino,
+ dst_stat.st_ino);
+
+ TST_EXP_EQ_LI(src_stat.st_size, filesize);
+ TST_EXP_EQ_LI(dst_stat.st_size, leftsize);
+
+ SAFE_READ(0, dst_fd, buff, leftsize);
+
+ TST_EXP_EXPR(!strncmp(buff, data + offset, leftsize),
+ "dst file has been cloned (%d bytes)",
+ leftsize);
+
+ tst_res(TINFO, "Writing a byte inside dst file");
+
+ SAFE_LSEEK(dst_fd, 0, SEEK_SET);
+ SAFE_WRITE(SAFE_WRITE_ALL, dst_fd, "!", 1);
+ SAFE_FSYNC(dst_fd);
+
+ tst_res(TINFO, "Verifing that src file content didn't change");
+
+ SAFE_FSTAT(src_fd, &src_stat);
+ SAFE_FSTAT(dst_fd, &dst_stat);
+
+ TST_EXP_EQ_LI(src_stat.st_size, filesize);
+ TST_EXP_EQ_LI(dst_stat.st_size, leftsize);
+
+ SAFE_LSEEK(src_fd, 0, SEEK_SET);
+ SAFE_READ(0, src_fd, buff, filesize);
+
+ TST_EXP_EXPR(!strncmp(buff, data, filesize),
+ "src file content didn't change");
+
+ SAFE_CLOSE(src_fd);
+ SAFE_CLOSE(dst_fd);
+
+ SAFE_UNLINK(SRCPATH);
+ SAFE_UNLINK(DSTPATH);
+}
+
+static void setup(void)
+{
+ struct stat sb;
+
+ SAFE_STAT(MNTPOINT, &sb);
+
+ filesize = sb.st_blksize * CHUNKS;
+ offset = filesize / 4;
+ leftsize = filesize - offset;
+
+ clone_range->src_offset = offset;
+ clone_range->src_length = leftsize;
+ clone_range->dest_offset = 0;
+
+ data = (char *)SAFE_MALLOC(filesize);
+ buff = (char *)SAFE_MALLOC(filesize);
+
+ srand(time(NULL));
+}
+
+static void cleanup(void)
+{
+ if (buff)
+ free(buff);
+
+ if (data)
+ free(data);
+
+ if (src_fd != -1)
+ SAFE_CLOSE(src_fd);
+
+ if (dst_fd != -1)
+ SAFE_CLOSE(dst_fd);
+}
+
+static struct tst_test test = {
+ .test_all = run,
+ .setup = setup,
+ .cleanup = cleanup,
+ .min_kver = "4.5",
+ .needs_root = 1,
+ .mount_device = 1,
+ .mntpoint = MNTPOINT,
+ .filesystems = (struct tst_fs []) {
+ {.type = "btrfs"},
+ {
+ .type = "xfs",
+ .mkfs_opts = (const char *const []) {"-m", "reflink=1", NULL},
+ },
+ {}
+ },
+ .bufs = (struct tst_buffers []) {
+ {&clone_range, .size = sizeof(struct file_clone_range)},
+ {},
+ }
+};
--
2.43.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 26+ messages in thread* [LTP] [PATCH v2 6/7] Add ioctl_ficlonerange02 test
2024-07-23 7:15 [LTP] [PATCH v2 0/7] Add ioctl_ficlone testing suite Andrea Cervesato
` (4 preceding siblings ...)
2024-07-23 7:15 ` [LTP] [PATCH v2 5/7] Add ioctl_ficlonerange01 test Andrea Cervesato
@ 2024-07-23 7:15 ` Andrea Cervesato
2024-07-24 15:37 ` Cyril Hrubis
2024-07-23 7:15 ` [LTP] [PATCH v2 7/7] Add ioctl_ficlone04 test Andrea Cervesato
6 siblings, 1 reply; 26+ messages in thread
From: Andrea Cervesato @ 2024-07-23 7:15 UTC (permalink / raw)
To: ltp
From: Andrea Cervesato <andrea.cervesato@suse.com>
This test verifies that ioctl() FICLONERANGE feature correctly raises
EINVAL when:
- filesystem does not support overlapping reflink ranges in the same file
- filesystem does not support reflinking on bad blocks alignment
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
runtest/syscalls | 1 +
testcases/kernel/syscalls/ioctl/.gitignore | 1 +
.../kernel/syscalls/ioctl/ioctl_ficlonerange02.c | 97 ++++++++++++++++++++++
3 files changed, 99 insertions(+)
diff --git a/runtest/syscalls b/runtest/syscalls
index 1f050c5f5..4a73852e8 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -596,6 +596,7 @@ ioctl_ficlone01 ioctl_ficlone01
ioctl_ficlone02 ioctl_ficlone02
ioctl_ficlone03 ioctl_ficlone03
ioctl_ficlonerange01 ioctl_ficlonerange01
+ioctl_ficlonerange02 ioctl_ficlonerange02
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 08c015928..9f995b1ad 100644
--- a/testcases/kernel/syscalls/ioctl/.gitignore
+++ b/testcases/kernel/syscalls/ioctl/.gitignore
@@ -26,3 +26,4 @@
/ioctl_ficlone02
/ioctl_ficlone03
/ioctl_ficlonerange01
+/ioctl_ficlonerange02
diff --git a/testcases/kernel/syscalls/ioctl/ioctl_ficlonerange02.c b/testcases/kernel/syscalls/ioctl/ioctl_ficlonerange02.c
new file mode 100644
index 000000000..24666ebcc
--- /dev/null
+++ b/testcases/kernel/syscalls/ioctl/ioctl_ficlonerange02.c
@@ -0,0 +1,97 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2024 Andrea Cervesato andrea.cervesato@suse.com
+ */
+
+/*\
+ * [Description]
+ *
+ * This test verifies that ioctl() FICLONERANGE feature correctly raises
+ * EINVAL when:
+ * - filesystem does not support overlapping reflink ranges in the same file
+ * - filesystem does not support reflinking on bad blocks alignment
+ */
+
+#include "tst_test.h"
+#include "lapi/fs.h"
+
+#define MNTPOINT "mnt"
+#define SRCPATH MNTPOINT "/file0"
+#define DSTPATH MNTPOINT "/file1"
+#define CHUNKS 10
+
+static struct file_clone_range *clone_range;
+static int filesize;
+static int alignment;
+static char *data;
+
+static void run(void)
+{
+ int src_fd;
+ int dst_fd;
+
+ src_fd = SAFE_OPEN(SRCPATH, O_CREAT | O_RDWR, 0640);
+ SAFE_WRITE(SAFE_WRITE_ALL, src_fd, data, filesize);
+ SAFE_FSYNC(src_fd);
+
+ dst_fd = SAFE_OPEN(DSTPATH, O_CREAT | O_RDWR, 0640);
+
+ clone_range->src_fd = dst_fd;
+ clone_range->src_offset = 0;
+ clone_range->src_length = filesize;
+ clone_range->dest_offset = 0;
+
+ TST_EXP_FAIL(ioctl(dst_fd, FICLONERANGE, clone_range), EINVAL,
+ "overlapping reflink ranges in the same file");
+
+ clone_range->src_fd = src_fd;
+ clone_range->src_offset = 0;
+ clone_range->src_length = alignment - 1;
+ clone_range->dest_offset = 0;
+
+ TST_EXP_FAIL(ioctl(dst_fd, FICLONERANGE, clone_range), EINVAL,
+ "bad blocks alignment");
+
+ SAFE_CLOSE(src_fd);
+ SAFE_CLOSE(dst_fd);
+}
+
+static void setup(void)
+{
+ struct stat sb;
+
+ SAFE_STAT(MNTPOINT, &sb);
+
+ alignment = sb.st_blksize;
+ filesize = alignment * CHUNKS;
+
+ data = (char *)SAFE_MALLOC(filesize);
+}
+
+static void cleanup(void)
+{
+ if (data)
+ free(data);
+}
+
+static struct tst_test test = {
+ .test_all = run,
+ .setup = setup,
+ .cleanup = cleanup,
+ .min_kver = "4.5",
+ .needs_root = 1,
+ .mount_device = 1,
+ .mntpoint = MNTPOINT,
+ .filesystems = (struct tst_fs []) {
+ {.type = "btrfs"},
+ {
+ .type = "xfs",
+ .mkfs_opts = (const char *const []) {"-m", "reflink=1", NULL},
+ },
+ {}
+ },
+ .bufs = (struct tst_buffers []) {
+ {&clone_range, .size = sizeof(struct file_clone_range)},
+ {},
+ }
+};
--
2.43.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 26+ messages in thread* [LTP] [PATCH v2 7/7] Add ioctl_ficlone04 test
2024-07-23 7:15 [LTP] [PATCH v2 0/7] Add ioctl_ficlone testing suite Andrea Cervesato
` (5 preceding siblings ...)
2024-07-23 7:15 ` [LTP] [PATCH v2 6/7] Add ioctl_ficlonerange02 test Andrea Cervesato
@ 2024-07-23 7:15 ` Andrea Cervesato
2024-07-24 15:42 ` Cyril Hrubis
6 siblings, 1 reply; 26+ messages in thread
From: Andrea Cervesato @ 2024-07-23 7:15 UTC (permalink / raw)
To: ltp
From: Andrea Cervesato <andrea.cervesato@suse.com>
This test verifies that ioctl() FICLONE/FICLONERANGE feature raises
the right error according with bad file descriptors.
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
testcases/kernel/syscalls/ioctl/.gitignore | 1 +
testcases/kernel/syscalls/ioctl/ioctl_ficlone04.c | 108 ++++++++++++++++++++++
2 files changed, 109 insertions(+)
diff --git a/testcases/kernel/syscalls/ioctl/.gitignore b/testcases/kernel/syscalls/ioctl/.gitignore
index 9f995b1ad..1f099ff95 100644
--- a/testcases/kernel/syscalls/ioctl/.gitignore
+++ b/testcases/kernel/syscalls/ioctl/.gitignore
@@ -25,5 +25,6 @@
/ioctl_ficlone01
/ioctl_ficlone02
/ioctl_ficlone03
+/ioctl_ficlone04
/ioctl_ficlonerange01
/ioctl_ficlonerange02
diff --git a/testcases/kernel/syscalls/ioctl/ioctl_ficlone04.c b/testcases/kernel/syscalls/ioctl/ioctl_ficlone04.c
new file mode 100644
index 000000000..6be0b8d41
--- /dev/null
+++ b/testcases/kernel/syscalls/ioctl/ioctl_ficlone04.c
@@ -0,0 +1,108 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2024 Andrea Cervesato andrea.cervesato@suse.com
+ */
+
+/*\
+ * [Description]
+ *
+ * This test verifies that ioctl() FICLONE/FICLONERANGE feature raises the right
+ * error according with bad file descriptors.
+ */
+
+#include "tst_test.h"
+#include "lapi/fs.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(TCONF, "Skipping file: SUCCESS");
+ return;
+ }
+
+ switch (fd_src->type) {
+ case TST_FD_DEV_ZERO:
+ case TST_FD_PROC_MAPS:
+ case TST_FD_PIPE_READ:
+ case TST_FD_PIPE_WRITE:
+ case TST_FD_UNIX_SOCK:
+ case TST_FD_INET_SOCK:
+ case TST_FD_EPOLL:
+ case TST_FD_EVENTFD:
+ case TST_FD_SIGNALFD:
+ case TST_FD_TIMERFD:
+ case TST_FD_PIDFD:
+ case TST_FD_FANOTIFY:
+ case TST_FD_INOTIFY:
+ case TST_FD_USERFAULTFD:
+ case TST_FD_PERF_EVENT:
+ case TST_FD_IO_URING:
+ case TST_FD_BPF_MAP:
+ case TST_FD_FSOPEN:
+ case TST_FD_FSPICK:
+ case TST_FD_OPEN_TREE:
+ case TST_FD_MEMFD:
+ case TST_FD_MEMFD_SECRET:
+ return;
+ default:
+ break;
+ }
+
+ int exp_errnos[2];
+
+ switch (fd_src->type) {
+ case TST_FD_FILE:
+ exp_errnos[0] = 0;
+ break;
+ case TST_FD_DIR:
+ exp_errnos[0] = EISDIR;
+ break;
+ case TST_FD_PATH:
+ case TST_FD_OPEN_TREE:
+ exp_errnos[0] = EBADF;
+ break;
+ case TST_FD_DEV_ZERO:
+ exp_errnos[0] = EXDEV;
+ break;
+ default:
+ exp_errnos[0] = EINVAL;
+ break;
+ }
+
+ switch (fd_dst->type) {
+ case TST_FD_FILE:
+ exp_errnos[1] = 0;
+ break;
+ case TST_FD_DIR:
+ exp_errnos[1] = EISDIR;
+ break;
+ case TST_FD_PATH:
+ case TST_FD_OPEN_TREE:
+ exp_errnos[1] = EBADF;
+ break;
+ default:
+ exp_errnos[1] = EXDEV;
+ break;
+ }
+
+ 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,
+};
--
2.43.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 26+ messages in thread* Re: [LTP] [PATCH v2 7/7] Add ioctl_ficlone04 test
2024-07-23 7:15 ` [LTP] [PATCH v2 7/7] Add ioctl_ficlone04 test Andrea Cervesato
@ 2024-07-24 15:42 ` Cyril Hrubis
2024-07-24 19:36 ` Andrea Cervesato via ltp
0 siblings, 1 reply; 26+ messages in thread
From: Cyril Hrubis @ 2024-07-24 15:42 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: ltp
Hi!
> + switch (fd_src->type) {
> + case TST_FD_DEV_ZERO:
> + case TST_FD_PROC_MAPS:
> + case TST_FD_PIPE_READ:
> + case TST_FD_PIPE_WRITE:
> + case TST_FD_UNIX_SOCK:
> + case TST_FD_INET_SOCK:
> + case TST_FD_EPOLL:
> + case TST_FD_EVENTFD:
> + case TST_FD_SIGNALFD:
> + case TST_FD_TIMERFD:
> + case TST_FD_PIDFD:
> + case TST_FD_FANOTIFY:
> + case TST_FD_INOTIFY:
> + case TST_FD_USERFAULTFD:
> + case TST_FD_PERF_EVENT:
> + case TST_FD_IO_URING:
> + case TST_FD_BPF_MAP:
> + case TST_FD_FSOPEN:
> + case TST_FD_FSPICK:
> + case TST_FD_OPEN_TREE:
> + case TST_FD_MEMFD:
> + case TST_FD_MEMFD_SECRET:
> + return;
> + default:
> + break;
> + }
Why do we skip all these cases?
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 26+ messages in thread* Re: [LTP] [PATCH v2 7/7] Add ioctl_ficlone04 test
2024-07-24 15:42 ` Cyril Hrubis
@ 2024-07-24 19:36 ` Andrea Cervesato via ltp
2024-07-24 20:06 ` Cyril Hrubis
0 siblings, 1 reply; 26+ messages in thread
From: Andrea Cervesato via ltp @ 2024-07-24 19:36 UTC (permalink / raw)
To: Cyril Hrubis, Andrea Cervesato; +Cc: ltp
On 7/24/24 17:42, Cyril Hrubis wrote:
> Hi!
>> + switch (fd_src->type) {
>> + case TST_FD_DEV_ZERO:
>> + case TST_FD_PROC_MAPS:
>> + case TST_FD_PIPE_READ:
>> + case TST_FD_PIPE_WRITE:
>> + case TST_FD_UNIX_SOCK:
>> + case TST_FD_INET_SOCK:
>> + case TST_FD_EPOLL:
>> + case TST_FD_EVENTFD:
>> + case TST_FD_SIGNALFD:
>> + case TST_FD_TIMERFD:
>> + case TST_FD_PIDFD:
>> + case TST_FD_FANOTIFY:
>> + case TST_FD_INOTIFY:
>> + case TST_FD_USERFAULTFD:
>> + case TST_FD_PERF_EVENT:
>> + case TST_FD_IO_URING:
>> + case TST_FD_BPF_MAP:
>> + case TST_FD_FSOPEN:
>> + case TST_FD_FSPICK:
>> + case TST_FD_OPEN_TREE:
>> + case TST_FD_MEMFD:
>> + case TST_FD_MEMFD_SECRET:
>> + return;
>> + default:
>> + break;
>> + }
> Why do we skip all these cases?
>
I can't understand what's the best way to test all the combinations. As
you can see there are many flags, which means the amount of permutations
is big.
Most of those flags are handled (indeed) in the wrong way, since most of
their permutations return EXDEV. The point is that the syscall has many
error codes, so it's complex to write a code that covers all possible
results.
My idea would be to have an array of errors to give to
TST_EXP_FAIL2_ARR() and to avoid any statement around fd_src/fd_dst,
because the amount of if/switch-case might explode with the number of
permutations.
Andrea
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 26+ messages in thread* Re: [LTP] [PATCH v2 7/7] Add ioctl_ficlone04 test
2024-07-24 19:36 ` Andrea Cervesato via ltp
@ 2024-07-24 20:06 ` Cyril Hrubis
2024-07-25 7:16 ` Andrea Cervesato via ltp
0 siblings, 1 reply; 26+ messages in thread
From: Cyril Hrubis @ 2024-07-24 20:06 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: ltp
Hi!
> I can't understand what's the best way to test all the combinations. As
> you can see there are many flags, which means the amount of permutations
> is big.
> Most of those flags are handled (indeed) in the wrong way, since most of
> their permutations return EXDEV. The point is that the syscall has many
> error codes, so it's complex to write a code that covers all possible
> results.
>
> My idea would be to have an array of errors to give to
> TST_EXP_FAIL2_ARR() and to avoid any statement around fd_src/fd_dst,
> because the amount of if/switch-case might explode with the number of
> permutations.
The purpose of the tst_fd iterator is mainly to hammer syscalls with
different kinds of file descriptors and trigger code paths in the kernel
that are not excercies under normal circumstances. So it's fine to have
a single array with a few sensible errno codes and pass that in all the
cases.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [LTP] [PATCH v2 7/7] Add ioctl_ficlone04 test
2024-07-24 20:06 ` Cyril Hrubis
@ 2024-07-25 7:16 ` Andrea Cervesato via ltp
0 siblings, 0 replies; 26+ messages in thread
From: Andrea Cervesato via ltp @ 2024-07-25 7:16 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: ltp
Hi!
On 7/24/24 22:06, Cyril Hrubis wrote:
> Hi!
>> I can't understand what's the best way to test all the combinations. As
>> you can see there are many flags, which means the amount of permutations
>> is big.
>> Most of those flags are handled (indeed) in the wrong way, since most of
>> their permutations return EXDEV. The point is that the syscall has many
>> error codes, so it's complex to write a code that covers all possible
>> results.
>>
>> My idea would be to have an array of errors to give to
>> TST_EXP_FAIL2_ARR() and to avoid any statement around fd_src/fd_dst,
>> because the amount of if/switch-case might explode with the number of
>> permutations.
> The purpose of the tst_fd iterator is mainly to hammer syscalls with
> different kinds of file descriptors and trigger code paths in the kernel
> that are not excercies under normal circumstances. So it's fine to have
> a single array with a few sensible errno codes and pass that in all the
> cases.
>
Sent v4 that does exactly this.
Andrea
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 26+ messages in thread