Add new LTP tests related to fsmount family of syscalls
v2 cover Add new LTP tests related to fsmount family of syscalls
Hello,
Here is the second version of my work rebased over the latest changes pushed around fsmount work by Zorro.
V1->V2:
- Lots of changes, really :)
- Rebased over Zorro's work with fsmount.
- The success tests are modified to test all possible flags, attributes as well.
- Create tst_ismount() and fsopen_supported_by_kernel() helpers.
- Verify if mount is successful or not using tst_ismount().
- Remove min_kver and instead check if older kernels have patches backported or not.
- Test on multiple filesystems.
- Better handling of failures during setup/run callbacks.
- One of the patches around fsmount.h is already merged, dropped it now.
- Other minor cleanups.
Viresh Kumar (10):
tst_device: Add tst_ismount() helper lapi/fsmount.h: Add fsopen_supported_by_kernel() lapi/fsmount.h: Include "lapi/fcntl.h" syscalls/fsopen: New tests syscalls/fsconfig: New tests syscalls/fsmount: Improve fsmount01 test syscalls/fsmount: Add failure tests syscalls/move_mount: New tests syscalls/fspick: New tests syscalls/open_tree: New tests
include/lapi/fsmount.h | 11 +- include/tst_device.h | 6 + lib/tst_device.c | 25 ++++ runtest/syscalls | 16 +++ testcases/kernel/syscalls/fsconfig/.gitignore | 2 + testcases/kernel/syscalls/fsconfig/Makefile | 6 + .../kernel/syscalls/fsconfig/fsconfig01.c | 110 +++++++++++++++++ .../kernel/syscalls/fsconfig/fsconfig02.c | 100 +++++++++++++++ testcases/kernel/syscalls/fsmount/.gitignore | 1 + testcases/kernel/syscalls/fsmount/fsmount01.c | 114 ++++++++--------- testcases/kernel/syscalls/fsmount/fsmount02.c | 81 ++++++++++++ testcases/kernel/syscalls/fsopen/.gitignore | 2 + testcases/kernel/syscalls/fsopen/Makefile | 6 + testcases/kernel/syscalls/fsopen/fsopen01.c | 85 +++++++++++++ testcases/kernel/syscalls/fsopen/fsopen02.c | 57 +++++++++ testcases/kernel/syscalls/fspick/.gitignore | 2 + testcases/kernel/syscalls/fspick/Makefile | 6 + testcases/kernel/syscalls/fspick/fspick01.c | 112 +++++++++++++++++ testcases/kernel/syscalls/fspick/fspick02.c | 107 ++++++++++++++++ .../kernel/syscalls/move_mount/.gitignore | 2 + testcases/kernel/syscalls/move_mount/Makefile | 6 + .../kernel/syscalls/move_mount/move_mount01.c | 82 +++++++++++++ .../kernel/syscalls/move_mount/move_mount02.c | 93 ++++++++++++++ .../kernel/syscalls/open_tree/.gitignore | 2 + testcases/kernel/syscalls/open_tree/Makefile | 6 + .../kernel/syscalls/open_tree/open_tree01.c | 115 ++++++++++++++++++ .../kernel/syscalls/open_tree/open_tree02.c | 104 ++++++++++++++++ 27 files changed, 1203 insertions(+), 56 deletions(-) create mode 100644 testcases/kernel/syscalls/fsconfig/.gitignore create mode 100644 testcases/kernel/syscalls/fsconfig/Makefile create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig01.c create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig02.c create mode 100644 testcases/kernel/syscalls/fsmount/fsmount02.c create mode 100644 testcases/kernel/syscalls/fsopen/.gitignore create mode 100644 testcases/kernel/syscalls/fsopen/Makefile create mode 100644 testcases/kernel/syscalls/fsopen/fsopen01.c create mode 100644 testcases/kernel/syscalls/fsopen/fsopen02.c create mode 100644 testcases/kernel/syscalls/fspick/.gitignore create mode 100644 testcases/kernel/syscalls/fspick/Makefile create mode 100644 testcases/kernel/syscalls/fspick/fspick01.c create mode 100644 testcases/kernel/syscalls/fspick/fspick02.c create mode 100644 testcases/kernel/syscalls/move_mount/.gitignore create mode 100644 testcases/kernel/syscalls/move_mount/Makefile create mode 100644 testcases/kernel/syscalls/move_mount/move_mount01.c create mode 100644 testcases/kernel/syscalls/move_mount/move_mount02.c create mode 100644 testcases/kernel/syscalls/open_tree/.gitignore create mode 100644 testcases/kernel/syscalls/open_tree/Makefile create mode 100644 testcases/kernel/syscalls/open_tree/open_tree01.c create mode 100644 testcases/kernel/syscalls/open_tree/open_tree02.c
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
PATCH v2 1/10 tst_device: Add tst_ismount() helper
This patch moves the ismount() helper added to the fsmount syscall tests to the standard library and renames it to tst_ismount(). The helper can be used across different files now.
Minor modifications are also done to the helper.
--- include/tst_device.h | 6 +++++ lib/tst_device.c | 25 +++++++++++++++++++ testcases/kernel/syscalls/fsmount/fsmount01.c | 25 +------------------ 3 files changed, 32 insertions(+), 24 deletions(-)
include/tst_device.h +6 -0
@@ -36,6 +36,12 @@ extern struct tst_device *tst_device;*/ int tst_umount (const char *path); +/* +* Verifies if an earlier mount is successful or not. +* @path: Mount path to verify +*/ +int tst_ismount (const char *path); +/* * Clears a first few blocks of the device. This is needed when device has * already been formatted with a filesystems, subset of mkfs.foo utils aborts
lib/tst_device.c +25 -0
@@ -386,6 +386,31 @@ int tst_umount(const char *path)return -1 ; } +int tst_ismount (const char *path) +{ +char line[256 ]; +FILE *file; +int ret =-1 ; + + file =SAFE_FOPEN (NULL ,"/proc/mounts" ,"r" ); + +while (fgets (line,sizeof (line), file)) { +if (strstr (line, path) !=NULL ) { + ret =0 ; +break ; + } + } + +SAFE_FCLOSE (NULL , file); + +if (ret) { + errno =ENOENT ; +tst_resm (TWARN ,"No device is mounted at %s" , path); + } + +return ret; +} +int find_stat_file (const char *dev,char *path,size_t path_len) {const char *devname =strrchr (dev,'/' ) +1 ;
testcases/kernel/syscalls/fsmount/fsmount01.c +1 -24
@@ -12,30 +12,10 @@#include "tst_test.h" #include "lapi/fcntl.h" #include "lapi/fsmount.h" -#include "tst_safe_stdio.h" -#define LINELENGTH 256#define MNTPOINT "newmount_point"static int sfd, mfd, is_mounted; -static int ismount (char *mntpoint) -{ -int ret =0 ; -FILE *file; -char line[LINELENGTH ]; - - file =SAFE_FOPEN ("/proc/mounts" ,"r" ); - -while (fgets (line,sizeof (line), file)) { -if (strstr (line, mntpoint) !=NULL ) { - ret =1 ; -break ; - } - } -SAFE_FCLOSE (file); -return ret; -} -static void cleanup (void ) {if (is_mounted)
@@ -76,12 +56,9 @@ static void test_fsmount(void)tst_res (TPASS ,"move_mount() attached to the mount point" );SAFE_CLOSE (mfd); -if (ismount (MNTPOINT )) { -tst_res (TPASS ,"device mounted" ); +if (!tst_ismount (MNTPOINT )) {SAFE_UMOUNT (MNTPOINT ); is_mounted =0 ; - }else { -tst_res (TFAIL ,"device not mounted" ); } }
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
PATCH v2 1/10 tst_device: Add tst_ismount() helper
Quoted 8 lines · Viresh Kumar
This patch moves the
ismount()helper added to the fsmount syscall tests to the standard library and renames it totst_ismount(). The helper can be used across different files now.Minor modifications are also done to the helper.
Signed-off-by Viresh Kumar <[email protected]>
include/tst_device.h extern struct tst_device *tst_device; · line 43
Quoted 7 lines
---
include/tst_device.h +5
-0+/* +* Verifies if an earlier mount is successful or not. +* @path: Mount path to verify +*/ +int tst_ismount (const char *path);
I have slightly thought to rename it as 'tst_is_mounted(const char *path)', but it also depends on other reviewer's opinion, I have no strong insist here.
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20200220/88c19774/attachment.htm>
PATCH v2 1/10 tst_device: Add tst_ismount() helper
Quoted 3 lines · Li Wang
I have slightly thought to rename it as '
tst_is_mounted(const char *path)', but it also depends on other reviewer's opinion, I have no strong insist here.
I didn't apply much brain and just used the name you suggested last :)
Sure, we can name it anything we like. I also thought about tst_verify_mount() though :)
Signature · 1 line
viresh
PATCH v2 1/10 tst_device: Add tst_ismount() helper
In reply to Viresh Kumarlib/tst_device.c int tst_umount(const char *path) · line 393
Quoted 5 lines
lib/tst_device.c +5
-0+int tst_ismount (const char *path) +{ +char line[256 ]; +FILE *file; +int ret =-1 ;
+
Quoted 8 lines
lib/tst_device.c +7
-0+ file =SAFE_FOPEN (NULL ,"/proc/mounts" ,"r" ); + +while (fgets (line,sizeof (line), file)) { +if (strstr (line, path) !=NULL ) { + ret =0 ; +break ; + }
lib/tst_device.c int tst_umount(const char *path) · line 411
Quoted 10 lines
lib/tst_device.c +10
-0+ } + +SAFE_FCLOSE (NULL , file); + +if (ret) { + errno =ENOENT ; +tst_resm (TWARN ,"No device is mounted at %s" , path); + } + +return ret;
Sorry, I think the return value should be '1' if it has been mounted already.
e.g
These codes will make people confused about whether it's mounted successfully or not.
if (tst_ismount(MNTPOINT))
tst_brk(TBROK | TERRNO, "device not mounted");
+}
Quoted 1 line
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20200220/98197515/attachment.htm>
PATCH v2 1/10 tst_device: Add tst_ismount() helper
Quoted 29 lines · Li Wang
lib/tst_device.c int tst_umount(const char *path) · line 393
Quoted 5 lines
lib/tst_device.c +5
-0+int tst_ismount (const char *path) +{ +char line[256 ]; +FILE *file; +int ret =-1 ;+
Quoted 8 lines
lib/tst_device.c +7
-0+ file =SAFE_FOPEN (NULL ,"/proc/mounts" ,"r" ); + +while (fgets (line,sizeof (line), file)) { +if (strstr (line, path) !=NULL ) { + ret =0 ; +break ; + }lib/tst_device.c int tst_umount(const char *path) · line 411
Quoted 10 lines
lib/tst_device.c +10
-0+ } + +SAFE_FCLOSE (NULL , file); + +if (ret) { + errno =ENOENT ; +tst_resm (TWARN ,"No device is mounted at %s" , path); + } + +return ret;Sorry, I think the return value should be '1' if it has been mounted already.
Quoted 6 lines
e.g
These codes will make people confused about whether it's mounted successfully or not.if (
tst_ismount(MNTPOINT))tst_brk(TBROK | TERRNO, "device not mounted");
I kept the return 0 on success thing here as well, but maybe yeah, it should return 1 on success here.
Signature · 1 line
viresh
PATCH v2 1/10 tst_device: Add tst_ismount() helper
Hi,
...
Quoted 7 lines
Quoted 6 lines
Sorry, I think the return value should be '1' if it has been mounted already.
e.g
These codes will make people confused about whether it's mounted successfully or not.
Quoted 5 lines
Quoted 2 lines
if (
tst_ismount(MNTPOINT))tst_brk(TBROK | TERRNO, "device not mounted");I kept the return 0 on success thing here as well, but maybe yeah, it should return 1 on success here.
Most of the functions returns 1 or -1 on failure. But here it's this approach really confusing, because the name and purpose. So I'd also be for 0 on failure and 1 on success.
Kind regards,
Petr
PATCH v2 2/10 lapi/fsmount.h: Add fsopen_supported_by_kernel()
In reply to Viresh KumarAdd a helper to check if the fsmount() related syscalls are supported by the kernel or not.
--- include/lapi/fsmount.h | 9 +++++++++ 1 file changed, 9 insertions(+)
include/lapi/fsmount.h +9 -0
@@ -130,5 +130,14 @@ enum fsconfig_command {#endif /* OPEN_TREE_CLONE */ +void fsopen_supported_by_kernel (void ) +{ +if ((tst_kvercmp (5 ,2 ,0 )) <0 ) { +/* Check if the syscall is backported on an older kernel */ +TEST (syscall (__NR_fsopen,NULL ,0 )); +if (TST_RET ==-1 &&TST_ERR ==ENOSYS ) +tst_brk (TCONF ,"Test not supporter on kernel version < v5.2" ); + } +}#endif /* FSMOUNT_H__ */
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
PATCH v2 2/10 lapi/fsmount.h: Add fsopen_supported_by_kernel()
Hi Viresh,
...
Quoted 1 line
+++
b/include/lapi/fsmount.h
...
include/lapi/fsmount.h enum fsconfig_command { · line 139
Quoted 7 lines
include/lapi/fsmount.h +7
-0+void fsopen_supported_by_kernel (void ) +{ +if ((tst_kvercmp (5 ,2 ,0 )) <0 ) { +/* Check if the syscall is backported on an older kernel */ +TEST (syscall (__NR_fsopen,NULL ,0 )); +if (TST_RET ==-1 &&TST_ERR ==ENOSYS ) +tst_brk (TCONF ,"Test not supporter on kernel version < v5.2" );
typo supporter => supported.
Kind regards,
Petr
PATCH v2 3/10 lapi/fsmount.h: Include "lapi/fcntl.h"
In reply to Viresh KumarAll the files that include (and that will include it in future) are most probably going to need the definitions from "lapi/fcntl.h", include it directly instead of <fcntl.h>, which will break it for old RHL distros.
--- include/lapi/fsmount.h | 2 +- testcases/kernel/syscalls/fsmount/fsmount01.c | 1 - 2 files changed, 1 insertion(+), 2 deletions(-)
include/lapi/fsmount.h +1 -1
@@ -7,12 +7,12 @@#ifndef FSMOUNT_H__ #define FSMOUNT_H__ -#include <fcntl.h> #include <sys/mount.h> #include <sys/syscall.h> #include <sys/types.h> #include "config.h" +#include "lapi/fcntl.h" #include "lapi/syscalls.h" #ifndef HAVE_FSOPEN
testcases/kernel/syscalls/fsmount/fsmount01.c +0 -1
@@ -10,7 +10,6 @@#include <sys/mount.h> #include "tst_test.h" -#include "lapi/fcntl.h" #include "lapi/fsmount.h" #define MNTPOINT "newmount_point"
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
PATCH v2 4/10 syscalls/fsopen: New tests
In reply to Viresh KumarAdd tests to check working of fsopen() syscall.
--- runtest/syscalls | 3 + testcases/kernel/syscalls/fsopen/.gitignore | 2 + testcases/kernel/syscalls/fsopen/Makefile | 6 ++ testcases/kernel/syscalls/fsopen/fsopen01.c | 85 +++++++++++++++++++++ testcases/kernel/syscalls/fsopen/fsopen02.c | 57 ++++++++++++++ 5 files changed, 153 insertions(+) create mode 100644 testcases/kernel/syscalls/fsopen/.gitignore create mode 100644 testcases/kernel/syscalls/fsopen/Makefile create mode 100644 testcases/kernel/syscalls/fsopen/fsopen01.c create mode 100644 testcases/kernel/syscalls/fsopen/fsopen02.c
runtest/syscalls +3 -0
@@ -343,6 +343,9 @@ fremovexattr02 fremovexattr02 fsmount01 fsmount01 +fsopen01 fsopen01 +fsopen02 fsopen02 + fstat02 fstat02 fstat02_64 fstat02_64 fstat03 fstat03
testcases/kernel/syscalls/fsopen/.gitignore new file +2 -0
@@ -0,0 +1,2 @@ +/fsopen01 +/fsopen02
testcases/kernel/syscalls/fsopen/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk +include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/fsopen/fsopen01.c new file +85 -0
85 lines not on this page · raw message
testcases/kernel/syscalls/fsopen/fsopen02.c new file +57 -0
57 lines not on this page · raw message
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
PATCH v2 4/10 syscalls/fsopen: New tests
Quoted 15 lines · Viresh Kumar
...
testcases/kernel/syscalls/fsopen/fsopen01.c new file +6
-0@@ -0,0 +1,85 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2020 Viresh Kumar <[email protected]> +* +* Description: +* Basic fsopen() test which tries to configure and mount the filesystem as
+ * well.
+ */testcases/kernel/syscalls/fsopen/fsopen01.c new file +1
-0+#include "tst_test.h"
testcases/kernel/syscalls/fsopen/fsopen01.c line 19
Quoted 10 lines
testcases/kernel/syscalls/fsopen/fsopen01.c new file +10
-0+#include "lapi/fsmount.h" + +#define MNTPOINT "mntpoint" + +static struct tcase { +char *name; +unsigned int flags; +} tcases[] = { + {"Flag 0" ,0 }, + {"Flag FSOPEN_CLOEXEC" ,FSOPEN_CLOEXEC },
Maybe better to remove the 'Flag' keywords from here and add it to the print sentence.
testcases/kernel/syscalls/fsopen/fsopen01.c line 68
Quoted 7 lines
testcases/kernel/syscalls/fsopen/fsopen01.c new file +5
-0+static void run (unsigned int n) +{ + +if (!tst_ismount (MNTPOINT )) +tst_res (TPASS ,"%s: fsopen() passed" , tc->name);
tst_res(TPASS, "Flag %s: fsopen() passed", tc->name);
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20200220/b99343b4/attachment.htm>
PATCH v2 4/10 syscalls/fsopen: New tests
Hi,
Quoted 10 lines
testcases/kernel/syscalls/fsopen/fsopen01.c line 19
Quoted 6 lines
testcases/kernel/syscalls/fsopen/fsopen01.c new file +6
-0+static struct tcase { +char *name; +unsigned int flags; +} tcases[] = { + {"Flag 0" ,0 }, + {"Flag FSOPEN_CLOEXEC" ,FSOPEN_CLOEXEC },Maybe better to remove the 'Flag' keywords from here and add it to the print sentence.
+1. BTW if you remove bogus text, you can use macro to not repeat the flag, see testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep01.c #define TYPE_NAME(x) .ttype = x, .desc = #x
(just a suggestion, nothing really important)
Quoted 9 lines
testcases/kernel/syscalls/fsopen/fsopen01.c line 68
Quoted 6 lines
testcases/kernel/syscalls/fsopen/fsopen01.c new file +5
-0+static void run (unsigned int n) +{ + +if (!tst_ismount (MNTPOINT )) +tst_res (TPASS ,"%s: fsopen() passed" , tc->name);
tst_res(TPASS, "Flag %s: fsopen() passed", tc->name);
Kind regards,
Petr
PATCH v2 4/10 syscalls/fsopen: New tests
In reply to Viresh KumarHi Viresh,
...
testcases/kernel/syscalls/fsopen/fsopen01.c line 20
Quoted 7 lines
testcases/kernel/syscalls/fsopen/fsopen01.c new file +7
-0+static struct tcase { +char *name; +unsigned int flags; +} tcases[] = { + {"Flag 0" ,0 }, + {"Flag FSOPEN_CLOEXEC" ,FSOPEN_CLOEXEC }, +};
Note about removing text from flags apply also for this test.
testcases/kernel/syscalls/fsopen/fsopen01.c line 25
Quoted 4 lines
testcases/kernel/syscalls/fsopen/fsopen01.c new file +4
-0+static void setup (void ) +{ +fsopen_supported_by_kernel (); +}
How about removing this and use as setup function directly fsopen_supported_by_kernel()?
.setup = fsopen_supported_by_kernel,
Other than that it's OK.
However I have problem on fsopen01 and fsmount02.
mkfs.vfat: Partitions or virtual mappings on device '/dev/loop0', not making filesystem (use -I to override)
tst_mkfs.c:100: BROK: tst_test.c:830: mkfs.vfat failed with 1
.dev_fs_flags = TST_FS_SKIP_FUSE helps with exfat and ntfs, but this also fails on vfat.
This is tested on system with CONFIG_VFAT_FS=m and CONFIG_FAT_FS=m, vfat and fat
are loaded by mkfs.vfat. IMHO we need something like TST_FS_SKIP_EXFAT | TST_FS_SKIP_FAT | TST_FS_SKIP_NTFS | TST_FS_SKIP_FUSE i.e. explicitly say what FS is not wanted no matter whether it's fuse or not.
Or maybe just TST_FS_SKIP_FAT | TST_FS_SKIP_FUSE would be enough.
NOTE: flags TST_FS_SKIP_EXFAT, TST_FS_SKIP_FAT, TST_FS_SKIP_NTFS do not exists yet.
...
testcases/kernel/syscalls/fsopen/fsopen02.c line 5
Quoted 11 lines
testcases/kernel/syscalls/fsopen/fsopen02.c new file +5
-0@@ -0,0 +1,57 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2020 Viresh Kumar <[email protected]> +* +* Description:
Nit: I'd avoid "Description:".
Quoted 2 lines
testcases/kernel/syscalls/fsopen/fsopen02.c new file +2
-0+* Basic fsopen() failure tests. +*/
...
testcases/kernel/syscalls/fsopen/fsopen02.c line 40
Quoted 10 lines
testcases/kernel/syscalls/fsopen/fsopen02.c new file +10
-0+static void run (unsigned int n) +{ +struct tcase *tc = &tcases[n]; + +TEST (fsopen (*tc->fs, tc->flags)); + +if (TST_RET !=-1 ) { +SAFE_CLOSE (TST_RET ); +tst_brk (TFAIL ,"%s: fsopen() succeeded unexpectedly (index: %d)" , + tc->name, n);
This also need tst_res() and return, or second test get skipped if first fails. See http://lists.linux.it/pipermail/ltp/2020-February/015505.html
testcases/kernel/syscalls/fsopen/fsopen02.c line 45
Quoted 5 lines
testcases/kernel/syscalls/fsopen/fsopen02.c new file +5
-0+ } + +if (tc->exp_errno !=TST_ERR ) { +tst_brk (TFAIL |TTERRNO ,"%s: fsopen() should fail with %s" , + tc->name,tst_strerrno (tc->exp_errno));
And here too.
testcases/kernel/syscalls/fsopen/fsopen02.c
Quoted 1 line
testcases/kernel/syscalls/fsopen/fsopen02.c new file +1
-0+ }
Kind regards,
Petr
PATCH v2 4/10 syscalls/fsopen: New tests
Quoted 8 lines · Petr Vorel
However I have problem on fsopen01 and fsmount02.
mkfs.vfat: Partitions or virtual mappings on device '/dev/loop0', not making filesystem (use -I to override)
tst_mkfs.c:100: BROK: tst_test.c:830: mkfs.vfat failed with 1.dev_fs_flags =
TST_FS_SKIP_FUSEhelps with exfat and ntfs, but this also fails on vfat.
Quoted 7 lines
This is tested on system with
CONFIG_VFAT_FS=mandCONFIG_FAT_FS=m, vfat and fat
are loaded by mkfs.vfat. IMHO we need something likeTST_FS_SKIP_EXFAT|TST_FS_SKIP_FAT|TST_FS_SKIP_NTFS|TST_FS_SKIP_FUSEi.e. explicitly say what FS is not wanted no matter whether it's fuse or not.Or maybe just
TST_FS_SKIP_FAT|TST_FS_SKIP_FUSEwould be enough.NOTE: flags
TST_FS_SKIP_EXFAT,TST_FS_SKIP_FAT,TST_FS_SKIP_NTFSdo not exists yet.
I am not sure what should be done here.
@Cyril ?
Signature · 1 line
viresh
PATCH v2 4/10 syscalls/fsopen: New tests
Hi Viresh
Quoted 13 lines · Petr Vorel
Quoted 12 lines
However I have problem on fsopen01 and fsmount02.
mkfs.vfat: Partitions or virtual mappings on device '/dev/loop0', not making filesystem (use -I to override)
tst_mkfs.c:100: BROK: tst_test.c:830: mkfs.vfat failed with 1.dev_fs_flags =
TST_FS_SKIP_FUSEhelps with exfat and ntfs, but this also fails on vfat.This is tested on system with
CONFIG_VFAT_FS=mandCONFIG_FAT_FS=m, vfat and fat
are loaded by mkfs.vfat. IMHO we need something likeTST_FS_SKIP_EXFAT|TST_FS_SKIP_FAT|TST_FS_SKIP_NTFS|TST_FS_SKIP_FUSEi.e. explicitly say what FS is not wanted no matter whether it's fuse or not.
Quoted 5 lines
Quoted 3 lines
Or maybe just
TST_FS_SKIP_FAT|TST_FS_SKIP_FUSEwould be enough.NOTE: flags
TST_FS_SKIP_EXFAT,TST_FS_SKIP_FAT,TST_FS_SKIP_NTFSdo not exists yet.I am not sure what should be done here.
I guess petr may want to let you add TST_FS_SKIP_FAT flag like adding TST_FS_SKIP_FUSE flag in commit dbe56e52bc50("ib: Add flags to tst_get_supported_fs_types()").
Best Regards
Yang Xu
Quoted 3 lines
@Cyril ?
PATCH v2 4/10 syscalls/fsopen: New tests
Hi,
Quoted 13 lines
Quoted 12 lines · Petr Vorel
Quoted 11 lines
However I have problem on fsopen01 and fsmount02.
mkfs.vfat: Partitions or virtual mappings on device '/dev/loop0', not making filesystem (use -I to override)
tst_mkfs.c:100: BROK: tst_test.c:830: mkfs.vfat failed with 1.dev_fs_flags =
TST_FS_SKIP_FUSEhelps with exfat and ntfs, but this also fails on vfat.This is tested on system with
CONFIG_VFAT_FS=mandCONFIG_FAT_FS=m, vfat and fat
are loaded by mkfs.vfat. IMHO we need something likeTST_FS_SKIP_EXFAT|TST_FS_SKIP_FAT|TST_FS_SKIP_NTFS|TST_FS_SKIP_FUSEi.e. explicitly say what FS is not wanted no matter whether it's fuse or not.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Or maybe just
TST_FS_SKIP_FAT|TST_FS_SKIP_FUSEwould be enough.NOTE: flags
TST_FS_SKIP_EXFAT,TST_FS_SKIP_FAT,TST_FS_SKIP_NTFSdo not exists yet.I am not sure what should be done here.
I guess petr may want to let you add
TST_FS_SKIP_FATflag like addingTST_FS_SKIP_FUSEflag in commitdbe56e52bc50("ib: Add flags to tst_get_supported_fs_types()").
Yes, that's what I meant.
This was meant as a question whether there is simpler solution than this (it's easy to implement it, but I might have overlook something - it might be fixed even without it).
Quoted 4 lines
Best Regards
Yang XuQuoted 1 line
@Cyril ?
PATCH v2 4/10 syscalls/fsopen: New tests
In reply to Viresh KumarHi!
Quoted 3 lines
I am not sure what should be done here.
@Cyril ?
Hmm, we should fix library to be able to format the device properly, looks like some kind of bug though:
https://github.com/dosfstools/dosfstools/issues/40
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v2 4/10 syscalls/fsopen: New tests
Hi,
Quoted 6 lines
Quoted 1 line
@Cyril ?
Hmm, we should fix library to be able to format the device properly, looks like some kind of bug though:
I'm not able to reproduce the problems on fsopen01 and fsmount02. Using different tmp directory via TMPDIR fixed that, but it started to work even without it and even reboot didn't bring back the failure. On different host (different distro) it worked all the time. I wonder what was wrong.
Kind regards,
Petr
PATCH v2 4/10 syscalls/fsopen: New tests
Hi!
Quoted 9 lines
Quoted 4 lines
Hmm, we should fix library to be able to format the device properly, looks like some kind of bug though:
I'm not able to reproduce the problems on fsopen01 and fsmount02. Using different tmp directory via TMPDIR fixed that, but it started to work even without it and even reboot didn't bring back the failure. On different host (different distro) it worked all the time. I wonder what was wrong.
Hmm, that sounds really strange, I doubt that there is something that would create partitions on a loop device on a background, so it really smells like a bug.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v2 4/10 syscalls/fsopen: New tests
Hi,
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
Hmm, we should fix library to be able to format the device properly, looks like some kind of bug though:
Quoted 8 lines
Quoted 4 lines
I'm not able to reproduce the problems on fsopen01 and fsmount02. Using different tmp directory via TMPDIR fixed that, but it started to work even without it and even reboot didn't bring back the failure. On different host (different distro) it worked all the time. I wonder what was wrong.
Hmm, that sounds really strange, I doubt that there is something that would create partitions on a loop device on a background, so it really smells like a bug.
I haven't found any hint in dmesg. I tested in on a machine, which sometimes has problems with disc I/O (occasionally it's slow). So maybe it was hw related.
Kind regards,
Petr
PATCH v2 5/10 syscalls/fsconfig: New tests
In reply to Viresh KumarAdd tests to check working of fsconfig() syscall.
--- runtest/syscalls | 3 + testcases/kernel/syscalls/fsconfig/.gitignore | 2 + testcases/kernel/syscalls/fsconfig/Makefile | 6 + .../kernel/syscalls/fsconfig/fsconfig01.c | 110 ++++++++++++++++++ .../kernel/syscalls/fsconfig/fsconfig02.c | 100 ++++++++++++++++ 5 files changed, 221 insertions(+) create mode 100644 testcases/kernel/syscalls/fsconfig/.gitignore create mode 100644 testcases/kernel/syscalls/fsconfig/Makefile create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig01.c create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig02.c
runtest/syscalls +3 -0
@@ -341,6 +341,9 @@ fpathconf01 fpathconf01 fremovexattr01 fremovexattr01 fremovexattr02 fremovexattr02 +fsconfig01 fsconfig01 +fsconfig02 fsconfig02 + fsmount01 fsmount01 fsopen01 fsopen01
testcases/kernel/syscalls/fsconfig/.gitignore new file +2 -0
@@ -0,0 +1,2 @@ +/fsconfig01 +/fsconfig02
testcases/kernel/syscalls/fsconfig/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk +include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/fsconfig/fsconfig01.c new file +110 -0
110 lines not on this page · raw message
testcases/kernel/syscalls/fsconfig/fsconfig02.c new file +100 -0
100 lines not on this page · raw message
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
PATCH v2 5/10 syscalls/fsconfig: New tests
Quoted 107 lines · Viresh Kumar
Add tests to check working of
fsconfig()syscall.Signed-off-by Viresh Kumar <[email protected]>--- runtest/syscalls | 3 + testcases/kernel/syscalls/fsconfig/.gitignore | 2 + testcases/kernel/syscalls/fsconfig/Makefile | 6 + .../kernel/syscalls/fsconfig/fsconfig01.c | 110 ++++++++++++++++++ .../kernel/syscalls/fsconfig/fsconfig02.c | 100 ++++++++++++++++ 5 files changed, 221 insertions(+) create mode 100644 testcases/kernel/syscalls/fsconfig/.gitignore create mode 100644 testcases/kernel/syscalls/fsconfig/Makefile create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig01.c create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig02.cruntest/syscalls +3
-0@@ -341,6 +341,9 @@ fpathconf01 fpathconf01 fremovexattr01 fremovexattr01 fremovexattr02 fremovexattr02 +fsconfig01 fsconfig01 +fsconfig02 fsconfig02 + fsmount01 fsmount01 fsopen01 fsopen01testcases/kernel/syscalls/fsconfig/.gitignore new file +2
-0@@ -0,0 +1,2 @@ +/fsconfig01 +/fsconfig02testcases/kernel/syscalls/fsconfig/Makefile new file +6
-0@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk +include $(top_srcdir)/include/mk/generic_leaf_target.mktestcases/kernel/syscalls/fsconfig/fsconfig01.c new file +6
-0@@ -0,0 +1,110 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2020 Viresh Kumar <[email protected]> +* +* Description: +* Basic fsconfig() test which tries to configure and mount the filesystem as
+ * well.
+ */testcases/kernel/syscalls/fsconfig/fsconfig01.c new file +27
-0+#include "tst_test.h" +#include "lapi/fsmount.h" + +#define MNTPOINT "mntpoint" + +static void setup (void ) +{ +fsopen_supported_by_kernel (); +} + +static void run (void ) +{ +int fd, fsmfd; + +TEST (fsopen (tst_device->fs_type,0 )); + fd =TST_RET ; + +if (fd ==-1 ) +tst_brk (TBROK |TERRNO ,"fsopen() failed" ); + +TEST (fsconfig (fd,FSCONFIG_SET_FLAG ,"rw" ,NULL ,0 )); +if (TST_RET ==-1 ) { +tst_res (TFAIL |TERRNO ,"fsconfig() failed" ); + goto out; + } + + TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", tst_device->dev,0));
testcases/kernel/syscalls/fsconfig/fsconfig01.c new file +6
-0+if (TST_RET ==-1 ) { +tst_res (TFAIL |TERRNO ,"fsconfig() failed" ); + goto out; + } + + TEST(fsconfig(fd, FSCONFIG_SET_PATH, "foo", tst_device->dev,
AT_FDCWD));testcases/kernel/syscalls/fsconfig/fsconfig01.c new file +3
-0+if (TST_RET ==-1 ) { +if (TST_ERR ==EOPNOTSUPP ) { + tst_res(TINFO, "fsconfig(): FSCONFIG_SET_PATH notsupported");
testcases/kernel/syscalls/fsconfig/fsconfig01.c
Quoted 2 lines
testcases/kernel/syscalls/fsconfig/fsconfig01.c new file +2
-0+ }else { +tst_res (TFAIL |TERRNO ,"fsconfig() failed" );
The test reports an EINVAL error when testing fsconfig() with 'FSCONFIG_SET_PATH' on XFS. I'm now trying to look close to this issue.
kernel: 5.6.0-rc2+ x86_64
tst_test.c:1278: INFO: Testing on xfs
tst_mkfs.c:90: INFO: Formatting /dev/loop0 with xfs opts='' extra opts='' tst_test.c:1217: INFO: Timeout per run is 0h 05m 00s fsconfig01.c:46: FAIL: fsconfig() failed: EINVAL (22)
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20200220/a2e38d20/attachment-0001.htm>
PATCH v2 5/10 syscalls/fsconfig: New tests
Quoted 6 lines · Li Wang
Quoted 6 lines
+ TEST(fsconfig(fd,
FSCONFIG_SET_PATH, "foo",tst_device->dev,AT_FDCWD));testcases/kernel/syscalls/fsconfig/fsconfig01.c new file +3
-0+if (TST_RET ==-1 ) { +if (TST_ERR ==EOPNOTSUPP ) { + tst_res(TINFO, "fsconfig(): FSCONFIG_SET_PATH notsupported");
On my ARM setup, I always hit this path for few of the syscalls :(
Quoted 7 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+ } else { + tst_res(TFAIL | TERRNO, "fsconfig() failed");The test reports an EINVAL error when testing
fsconfig()with 'FSCONFIG_SET_PATH' on XFS. I'm now trying to look close to this issue.
Quoted 6 lines
kernel: 5.6.0-rc2+
x86_64tst_test.c:1278: INFO: Testing on xfs
tst_mkfs.c:90: INFO: Formatting/dev/loop0with xfs opts='' extra opts='' tst_test.c:1217: INFO: Timeout per run is 0h 05m 00s fsconfig01.c:46: FAIL:fsconfig()failed: EINVAL (22)
Both "foo" and tst_device->dev may be wrong here unfortunately. Same for few other commands like: _PATH, _PATH_EMPTY, _FD..
Signature · 1 line
viresh
PATCH v2 5/10 syscalls/fsconfig: New tests
Quoted 20 lines · Viresh Kumar
Quoted 5 lines · Li Wang
testcases/kernel/syscalls/fsconfig/fsconfig01.c
Quoted 5 lines
+ TEST(fsconfig(fd,
FSCONFIG_SET_PATH, "foo",tst_device->dev,AT_FDCWD));testcases/kernel/syscalls/fsconfig/fsconfig01.c new file +3
-0+if (TST_RET ==-1 ) { +if (TST_ERR ==EOPNOTSUPP ) { + tst_res(TINFO, "fsconfig(): FSCONFIG_SET_PATHnot
Quoted 1 line
Quoted 1 line
supported");
On my ARM setup, I always hit this path for few of the syscalls :(
Quoted 9 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+ } else { + tst_res(TFAIL | TERRNO, "fsconfig() failed");The test reports an EINVAL error when testing
fsconfig()with 'FSCONFIG_SET_PATH' on XFS. I'm now trying to look close to this issue.kernel: 5.6.0-rc2+
x86_64
Quoted 8 lines
Quoted 4 lines
tst_test.c:1278: INFO: Testing on xfs
tst_mkfs.c:90: INFO: Formatting/dev/loop0with xfs opts='' extra opts='' tst_test.c:1217: INFO: Timeout per run is 0h 05m 00s fsconfig01.c:46: FAIL:fsconfig()failed: EINVAL (22)Both "foo" and
tst_device->devmay be wrong here unfortunately. Same for few other commands like:_PATH,_PATH_EMPTY,_FD..
If the parameter '_key' is replaced by 'ro' or 'rw', then the test always gets passed, the same behavior occurred in fspick01 too.
I'm not sure if the usage is correct for fsconfig(), it'd be great if FS guys could give advice.
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20200220/d12ad1c0/attachment.htm>
PATCH v2 5/10 syscalls/fsconfig: New tests
In reply to Li WangHi Li,
Quoted 4 lines
The test reports an EINVAL error when testing
fsconfig()with 'FSCONFIG_SET_PATH' on XFS. I'm now trying to look close to this issue.kernel: 5.6.0-rc2+
x86_64
Confirmed, with this XFS config:
CONFIG_XFS_FS=y
# CONFIG_XFS_QUOTA is not set
# CONFIG_XFS_POSIX_ACL is not set
# CONFIG_XFS_RT is not set
# CONFIG_XFS_ONLINE_SCRUB is not set
# CONFIG_XFS_WARN is not set
# CONFIG_XFS_DEBUG is not set
# CONFIG_VXFS_FS is not set
I'll have a look on it on Monday.
Kind regards,
Petr
Quoted 4 lines
tst_test.c:1278: INFO: Testing on xfs
tst_mkfs.c:90: INFO: Formatting/dev/loop0with xfs opts='' extra opts='' tst_test.c:1217: INFO: Timeout per run is 0h 05m 00s fsconfig01.c:46: FAIL:fsconfig()failed: EINVAL (22)
PATCH v2 6/10 syscalls/fsmount: Improve fsmount01 test
In reply to Viresh KumarThis patch updates the fsmount01.c file to make it look similar to all other fsmount related syscall tests and here is the list of all changes:
- Test all fsmount flags and mount attributes
- Remove extra PASS messages as all we want to test here is fsmount() and not other syscalls.
- On the same lines, print TFAIL for fsmount() syscall and TBROK for other calls.
- close sfd on failures
- Make the file look similar to other fsmount related tests
- General cleanup
--- testcases/kernel/syscalls/fsmount/fsmount01.c | 92 ++++++++++++------- 1 file changed, 60 insertions(+), 32 deletions(-)
testcases/kernel/syscalls/fsmount/fsmount01.c +60 -32
@@ -3,67 +3,95 @@* Copyright (C) 2020 Red Hat, Inc. All rights reserved. * Author: Zorro Lang <[email protected]> * -* Use new mount API from v5.2 (fsopen(), fsconfig(), fsmount(), move_mount()) -* to mount a filesystem without any specified mount options. +* Description: +* Basic fsmount() test. */ -#include <sys/mount.h> -#include "tst_test.h" #include "lapi/fsmount.h" -#define MNTPOINT "newmount_point" -static int sfd, mfd, is_mounted; +#define MNTPOINT "mntpoint" + +static struct tcase { +char *name; +unsigned int flags; +unsigned int mount_attrs; +} tcases[] = { + {"Flag 0, attr RDONLY" ,0 ,MOUNT_ATTR_RDONLY }, + {"Flag 0, attr NOSUID" ,0 ,MOUNT_ATTR_NOSUID }, + {"Flag 0, attr NODEV" ,0 ,MOUNT_ATTR_NODEV }, + {"Flag 0, attr NOEXEC" ,0 ,MOUNT_ATTR_NOEXEC }, + {"Flag 0, attr RELATIME" ,0 ,MOUNT_ATTR_RELATIME }, + {"Flag 0, attr NOATIME" ,0 ,MOUNT_ATTR_NOATIME }, + {"Flag 0, attr STRICTATIME" ,0 ,MOUNT_ATTR_STRICTATIME }, + {"Flag 0, attr NODIRATIME" ,0 ,MOUNT_ATTR_NODIRATIME }, + {"Flag CLOEXEC, attr RDONLY" ,FSMOUNT_CLOEXEC ,MOUNT_ATTR_RDONLY }, + {"Flag CLOEXEC, attr NOSUID" ,FSMOUNT_CLOEXEC ,MOUNT_ATTR_NOSUID }, + {"Flag CLOEXEC, attr NODEV" ,FSMOUNT_CLOEXEC ,MOUNT_ATTR_NODEV }, + {"Flag CLOEXEC, attr NOEXEC" ,FSMOUNT_CLOEXEC ,MOUNT_ATTR_NOEXEC }, + {"Flag CLOEXEC, attr RELATIME" ,FSMOUNT_CLOEXEC ,MOUNT_ATTR_RELATIME }, + {"Flag CLOEXEC, attr NOATIME" ,FSMOUNT_CLOEXEC ,MOUNT_ATTR_NOATIME }, + {"Flag CLOEXEC, attr STRICTATIME" ,FSMOUNT_CLOEXEC ,MOUNT_ATTR_STRICTATIME }, + {"Flag CLOEXEC, attr NODIRATIME" ,FSMOUNT_CLOEXEC ,MOUNT_ATTR_NODIRATIME }, +}; -static void cleanup (void ) +static void setup (void ) { -if (is_mounted) -SAFE_UMOUNT (MNTPOINT ); +fsopen_supported_by_kernel (); } -static void test_fsmount (void ) +static void run (unsigned int n) { +struct tcase *tc = &tcases[n]; +int sfd, mfd; +TEST (fsopen (tst_device->fs_type,FSOPEN_CLOEXEC )); -if (TST_RET <0 ) -tst_brk (TBROK |TTERRNO ,"fsopen() on %s failed" , tst_device->fs_type); +if (TST_RET ==-1 ) { +tst_brk (TBROK |TTERRNO ,"fsopen() on %s failed" , + tst_device->fs_type); + } sfd =TST_RET ; -tst_res (TPASS ,"fsopen() on %s" , tst_device->fs_type);TEST (fsconfig (sfd,FSCONFIG_SET_STRING ,"source" , tst_device->dev,0 )); -if (TST_RET <0 ) +if (TST_RET <0 ) { +SAFE_CLOSE (sfd);tst_brk (TBROK |TTERRNO ,"fsconfig() failed to set source to %s" , tst_device->dev); -tst_res (TPASS ,"fsconfig() set source to %s" , tst_device->dev); - + }TEST (fsconfig (sfd,FSCONFIG_CMD_CREATE ,NULL ,NULL ,0 )); -if (TST_RET <0 ) +if (TST_RET <0 ) { +SAFE_CLOSE (sfd);tst_brk (TBROK |TTERRNO ,"fsconfig() created superblock" ); -tst_res (TPASS ,"fsconfig() created superblock" ); + } -TEST (fsmount (sfd,FSMOUNT_CLOEXEC ,0 )); -if (TST_RET <0 ) -tst_brk (TBROK |TTERRNO ,"fsmount() failed to create a mount object" ); - mfd =TST_RET ; -tst_res (TPASS ,"fsmount() created a mount object" ); +TEST (fsmount (sfd, tc->flags, tc->mount_attrs));SAFE_CLOSE (sfd); +if (TST_RET <0 ) { +tst_brk (TFAIL |TTERRNO , +"fsmount() failed to create a mount object" ); + } + mfd =TST_RET ; +TEST (move_mount (mfd,"" ,AT_FDCWD ,MNTPOINT ,MOVE_MOUNT_F_EMPTY_PATH )); -if (TST_RET <0 ) -tst_brk (TBROK |TTERRNO ,"move_mount() failed to attach to the mount point" ); - is_mounted =1 ; -tst_res (TPASS ,"move_mount() attached to the mount point" );SAFE_CLOSE (mfd); -if (!tst_ismount (MNTPOINT )) { -SAFE_UMOUNT (MNTPOINT ); - is_mounted =0 ; +if (TST_RET <0 ) { +tst_brk (TBROK |TTERRNO , +"move_mount() failed to attach to the mount point" ); } + +if (!tst_ismount (MNTPOINT )) +tst_res (TPASS ,"%s: fsmount() passed" , tc->name); + +SAFE_UMOUNT (MNTPOINT ); }static struct tst_test test = { - .test_all = test_fsmount, - .cleanup = cleanup, + .tcnt =ARRAY_SIZE (tcases), + .test = run, + .setup = setup, .needs_root =1 , .mntpoint =MNTPOINT , .format_device =1 ,
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
PATCH v2 6/10 syscalls/fsmount: Improve fsmount01 test
Quoted 59 lines · Viresh Kumar
This patch updates the
fsmount01.cfile to make it look similar to all other fsmount related syscall tests and here is the list of all changes:- Test all fsmount flags and mount attributes
- Remove extra PASS messages as all we want to test here isfsmount()and not other syscalls.
- On the same lines, print TFAIL forfsmount()syscall and TBROK for other calls.
- close sfd on failures
- Make the file look similar to other fsmount related tests
- General cleanupSigned-off-by Viresh Kumar <[email protected]>--- testcases/kernel/syscalls/fsmount/fsmount01.c | 92 ++++++++++++------- 1 file changed, 60 insertions(+), 32 deletions(-)testcases/kernel/syscalls/fsmount/fsmount01.c +21
-6@@ -3,67 +3,95 @@* Copyright (C) 2020 Red Hat, Inc. All rights reserved. * Author: Zorro Lang <[email protected]> * -* Use new mount API from v5.2 (fsopen(), fsconfig(), fsmount(), move_mount()) -* to mount a filesystem without any specified mount options. +* Description: +* Basic fsmount() test. */ -#include <sys/mount.h> -#include "tst_test.h" #include "lapi/fsmount.h" -#define MNTPOINT "newmount_point" -static int sfd, mfd, is_mounted; +#define MNTPOINT "mntpoint" + +static struct tcase { +char *name; +unsigned int flags; +unsigned int mount_attrs; +} tcases[] = { + {"Flag 0, attr RDONLY" ,0 ,MOUNT_ATTR_RDONLY }, + {"Flag 0, attr NOSUID" ,0 ,MOUNT_ATTR_NOSUID }, + {"Flag 0, attr NODEV" ,0 ,MOUNT_ATTR_NODEV }, + {"Flag 0, attr NOEXEC" ,0 ,MOUNT_ATTR_NOEXEC }, + {"Flag 0, attr RELATIME" ,0 ,MOUNT_ATTR_RELATIME }, + {"Flag 0, attr NOATIME" ,0 ,MOUNT_ATTR_NOATIME }, + {"Flag 0, attr STRICTATIME" ,0 ,MOUNT_ATTR_STRICTATIME }, + {"Flag 0, attr NODIRATIME" ,0 ,MOUNT_ATTR_NODIRATIME }, + {"Flag CLOEXEC, attr RDONLY" ,FSMOUNT_CLOEXEC ,MOUNT_ATTR_RDONLY }, + {"Flag CLOEXEC, attr NOSUID" ,FSMOUNT_CLOEXEC ,MOUNT_ATTR_NOSUID }, + {"Flag CLOEXEC, attr NODEV" ,FSMOUNT_CLOEXEC ,MOUNT_ATTR_NODEV }, + {"Flag CLOEXEC, attr NOEXEC" ,FSMOUNT_CLOEXEC ,MOUNT_ATTR_NOEXEC },
testcases/kernel/syscalls/fsmount/fsmount01.c line 42
Quoted 10 lines
testcases/kernel/syscalls/fsmount/fsmount01.c +5
-0+ {"Flag CLOEXEC, attr RELATIME" ,FSMOUNT_CLOEXEC , MOUNT_ATTR_RELATIME}, + {"Flag CLOEXEC, attr NOATIME", FSMOUNT_CLOEXEC, MOUNT_ATTR_NOATIME}, + {"Flag CLOEXEC, attr STRICTATIME", FSMOUNT_CLOEXEC, MOUNT_ATTR_STRICTATIME}, + {"Flag CLOEXEC, attr NODIRATIME", FSMOUNT_CLOEXEC, MOUNT_ATTR_NODIRATIME}, +};
Again, if you move the 'Flag & attr' to print info, this patch looks pretty good to me.
testcases/kernel/syscalls/fsmount/fsmount01.c line 90
Quoted 3 lines
testcases/kernel/syscalls/fsmount/fsmount01.c +2
-0+if (!tst_ismount (MNTPOINT )) +tst_res (TPASS ,"%s: fsmount() passed" , tc->name);
What about:
tst_res(TPASS, "'Flag & mount_attr: %s': fsmount() passed",
tc->name);
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20200220/2c5c3798/attachment.htm>
PATCH v2 6/10 syscalls/fsmount: Improve fsmount01 test
In reply to Viresh KumarHi,
Quoted 12 lines
testcases/kernel/syscalls/fsmount/fsmount01.c +12
-0+static struct tcase { +char *name; +unsigned int flags; +unsigned int mount_attrs; +} tcases[] = { + {"Flag 0, attr RDONLY" ,0 ,MOUNT_ATTR_RDONLY }, + {"Flag 0, attr NOSUID" ,0 ,MOUNT_ATTR_NOSUID }, + {"Flag 0, attr NODEV" ,0 ,MOUNT_ATTR_NODEV }, + {"Flag 0, attr NOEXEC" ,0 ,MOUNT_ATTR_NOEXEC }, + {"Flag 0, attr RELATIME" ,0 ,MOUNT_ATTR_RELATIME }, + {"Flag 0, attr NOATIME" ,0 ,MOUNT_ATTR_NOATIME }, + {"Flag 0, attr STRICTATIME" ,0 ,MOUNT_ATTR_STRICTATIME },
testcases/kernel/syscalls/fsmount/fsmount01.c line 36
Quoted 10 lines
testcases/kernel/syscalls/fsmount/fsmount01.c +10
-0+ {"Flag 0, attr NODIRATIME", 0, MOUNT_ATTR_NODIRATIME}, + {"Flag CLOEXEC, attr RDONLY", FSMOUNT_CLOEXEC, MOUNT_ATTR_RDONLY}, + {"Flag CLOEXEC, attr NOSUID", FSMOUNT_CLOEXEC, MOUNT_ATTR_NOSUID}, + {"Flag CLOEXEC, attr NODEV", FSMOUNT_CLOEXEC, MOUNT_ATTR_NODEV}, + {"Flag CLOEXEC, attr NOEXEC", FSMOUNT_CLOEXEC, MOUNT_ATTR_NOEXEC}, + {"Flag CLOEXEC, attr RELATIME", FSMOUNT_CLOEXEC, MOUNT_ATTR_RELATIME}, + {"Flag CLOEXEC, attr NOATIME", FSMOUNT_CLOEXEC, MOUNT_ATTR_NOATIME}, + {"Flag CLOEXEC, attr STRICTATIME", FSMOUNT_CLOEXEC, MOUNT_ATTR_STRICTATIME}, + {"Flag CLOEXEC, attr NODIRATIME", FSMOUNT_CLOEXEC, MOUNT_ATTR_NODIRATIME}, +};
I'd use desc field
#define DESC(x, y) .flags = x, .mount_attrs = y, .desc = #x ", " #y
+static struct tcase {
+ char *desc;
+ unsigned int flags;
+ unsigned int mount_attrs;
+} tcases[] = {
+ {DESC(0, MOUNT_ATTR_RDONLY)},
+ {DESC(0, MOUNT_ATTR_NOSUID)},
(avoid copy paste).
testcases/kernel/syscalls/fsmount/fsmount01.c line 40
Quoted 5 lines
testcases/kernel/syscalls/fsmount/fsmount01.c +2
-2+static void setup (void ) { -if (is_mounted) -SAFE_UMOUNT (MNTPOINT ); +fsopen_supported_by_kernel ();
again, just .setup = fsopen_supported_by_kernel;
Quoted 4 lines
}
testcases/kernel/syscalls/fsmount/fsmount01.c +1
-1-static void test_fsmount (void ) +static void run (unsigned int n)
testcases/kernel/syscalls/fsmount/fsmount01.c line 51
Quoted 10 lines
testcases/kernel/syscalls/fsmount/fsmount01.c +6
-2{ +struct tcase *tc = &tcases[n]; +int sfd, mfd; +TEST (fsopen (tst_device->fs_type,FSOPEN_CLOEXEC )); -if (TST_RET <0 ) -tst_brk (TBROK |TTERRNO ,"fsopen() on %s failed" , tst_device->fs_type); +if (TST_RET ==-1 ) { +tst_brk (TBROK |TTERRNO ,"fsopen() on %s failed" , + tst_device->fs_type);
Again, tst_brk(TBROK) shouldn't be on tcnt = ARRAY_SIZE(tcases),
it skips all following tests after failure (sometimes needed but IMHO not here).
Quoted 9 lines
testcases/kernel/syscalls/fsmount/fsmount01.c +3
-2+ } sfd =TST_RET ; -tst_res (TPASS ,"fsopen() on %s" , tst_device->fs_type);TEST (fsconfig (sfd,FSCONFIG_SET_STRING ,"source" , tst_device->dev,0 )); -if (TST_RET <0 ) +if (TST_RET <0 ) { +SAFE_CLOSE (sfd); tst_brk(TBROK | TTERRNO,
testcases/kernel/syscalls/fsmount/fsmount01.c line 65
Quoted 10 lines
testcases/kernel/syscalls/fsmount/fsmount01.c +3
-3"fsconfig() failed to set source to %s", tst_device->dev); -tst_res (TPASS ,"fsconfig() set source to %s" , tst_device->dev); - + }TEST (fsconfig (sfd,FSCONFIG_CMD_CREATE ,NULL ,NULL ,0 )); -if (TST_RET <0 ) +if (TST_RET <0 ) { +SAFE_CLOSE (sfd);tst_brk (TBROK |TTERRNO ,"fsconfig() created superblock" );
As you added more runs of the test (changed .test_all to .test && run = ARRAY_SIZE(tcases)), you need to change all tst_brk() to tst_res() + return.
I also merged tst_brk(TBROK), I guess TFAIL would be better.
Other than that it looks ok.
I also wonder if it'd be worth to implement in fsmount.h some macros to reduce code duplicity. e.g. one of similar patterns (just flag is different):
TEST(fsopen(tst_device->fs_type, FLAG));
fd = TST_RET;
if (fd == -1)
tst_brk(TBROK | TERRNO, "fsopen() failed");
But that's not important.
Kind regards,
Petr
PATCH v2 7/10 syscalls/fsmount: Add failure tests
In reply to Viresh KumarThis adds fsmount02.c tests to verify all the errors returned on failures.
--- runtest/syscalls | 1 + testcases/kernel/syscalls/fsmount/.gitignore | 1 + testcases/kernel/syscalls/fsmount/fsmount02.c | 81 +++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 testcases/kernel/syscalls/fsmount/fsmount02.c
runtest/syscalls +1 -0
@@ -345,6 +345,7 @@ fsconfig01 fsconfig01 fsconfig02 fsconfig02 fsmount01 fsmount01 +fsmount02 fsmount02 fsopen01 fsopen01 fsopen02 fsopen02
testcases/kernel/syscalls/fsmount/.gitignore +1 -0
@@ -1 +1,2 @@ /fsmount01 +/fsmount02
testcases/kernel/syscalls/fsmount/fsmount02.c new file +81 -0
81 lines not on this page · raw message
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
PATCH v2 8/10 syscalls/move_mount: New tests
In reply to Viresh KumarAdd tests to check working of move_mount() syscall.
--- runtest/syscalls | 3 + .../kernel/syscalls/move_mount/.gitignore | 2 + testcases/kernel/syscalls/move_mount/Makefile | 6 ++ .../kernel/syscalls/move_mount/move_mount01.c | 82 ++++++++++++++++ .../kernel/syscalls/move_mount/move_mount02.c | 93 +++++++++++++++++++ 5 files changed, 186 insertions(+) create mode 100644 testcases/kernel/syscalls/move_mount/.gitignore create mode 100644 testcases/kernel/syscalls/move_mount/Makefile create mode 100644 testcases/kernel/syscalls/move_mount/move_mount01.c create mode 100644 testcases/kernel/syscalls/move_mount/move_mount02.c
runtest/syscalls +3 -0
@@ -731,6 +731,9 @@ mount04 mount04 mount05 mount05 mount06 mount06 +move_mount01 move_mount01 +move_mount02 move_mount02 + move_pages01 move_pages01 move_pages02 move_pages02 move_pages03 move_pages03
testcases/kernel/syscalls/move_mount/.gitignore new file +2 -0
@@ -0,0 +1,2 @@ +/move_mount01 +/move_mount02
testcases/kernel/syscalls/move_mount/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk +include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/move_mount/move_mount01.c new file +82 -0
82 lines not on this page · raw message
testcases/kernel/syscalls/move_mount/move_mount02.c new file +93 -0
93 lines not on this page · raw message
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
PATCH v2 9/10 syscalls/fspick: New tests
In reply to Viresh KumarAdd tests to check working of fspick() syscall.
--- runtest/syscalls | 3 + testcases/kernel/syscalls/fspick/.gitignore | 2 + testcases/kernel/syscalls/fspick/Makefile | 6 ++ testcases/kernel/syscalls/fspick/fspick01.c | 112 ++++++++++++++++++++ testcases/kernel/syscalls/fspick/fspick02.c | 107 +++++++++++++++++++ 5 files changed, 230 insertions(+) create mode 100644 testcases/kernel/syscalls/fspick/.gitignore create mode 100644 testcases/kernel/syscalls/fspick/Makefile create mode 100644 testcases/kernel/syscalls/fspick/fspick01.c create mode 100644 testcases/kernel/syscalls/fspick/fspick02.c
runtest/syscalls +3 -0
@@ -350,6 +350,9 @@ fsmount02 fsmount02 fsopen01 fsopen01 fsopen02 fsopen02 +fspick01 fspick01 +fspick02 fspick02 + fstat02 fstat02 fstat02_64 fstat02_64 fstat03 fstat03
testcases/kernel/syscalls/fspick/.gitignore new file +2 -0
@@ -0,0 +1,2 @@ +/fspick01 +/fspick02
testcases/kernel/syscalls/fspick/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk +include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/fspick/fspick01.c new file +112 -0
112 lines not on this page · raw message
testcases/kernel/syscalls/fspick/fspick02.c new file +107 -0
107 lines not on this page · raw message
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
PATCH v2 9/10 syscalls/fspick: New tests
Quoted 19 lines · Viresh Kumar
...
testcases/kernel/syscalls/fspick/fspick01.c new file +13
-0+ +static void run (unsigned int n) +{ +struct tcase *tc = &tcases[n]; +int fspick_fd; + +TEST (fspick (AT_FDCWD ,MNTPOINT , tc->flags)); +if (TST_RET ==-1 ) +tst_brk (TFAIL |TERRNO ,"fspick() failed" ); + + fspick_fd =TST_RET ; + + TEST(fsconfig(fspick_fd, FSCONFIG_SET_STRING, "user_xattr","false", 0));
testcases/kernel/syscalls/fspick/fspick01.c line 89
Quoted 3 lines
testcases/kernel/syscalls/fspick/fspick01.c new file +3
-0+if (TST_RET ==-1 ) { +SAFE_CLOSE (fspick_fd); +tst_brk (TBROK |TERRNO ,"fsconfig() failed" );
Test kernel: 5.6.0-rc2+ x86_64
tst_test.c:1278: INFO: Testing on xfs
tst_mkfs.c:90: INFO: Formatting /dev/loop3 with xfs opts='' extra opts='' tst_test.c:1217: INFO: Timeout per run is 0h 05m 00s fspick01.c:90: BROK: fsconfig() failed: EINVAL (22)
Quoted 12 lines
testcases/kernel/syscalls/fspick/fspick01.c new file +11
-0+ } + +TEST (fsconfig (fspick_fd,FSCONFIG_SET_FLAG ,"ro" ,NULL ,0 )); +if (TST_RET ==-1 ) { +SAFE_CLOSE (fspick_fd); +tst_brk (TBROK |TERRNO ,"fsconfig() failed" ); + } + +SAFE_CLOSE (fspick_fd); +tst_res (TPASS ,"%s: fspick() passed" , tc->name); +}
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20200220/82abd210/attachment.htm>
PATCH v2 10/10 syscalls/open_tree: New tests
In reply to Viresh KumarAdd tests to check working of open_tree() syscall.
--- runtest/syscalls | 3 + .../kernel/syscalls/open_tree/.gitignore | 2 + testcases/kernel/syscalls/open_tree/Makefile | 6 + .../kernel/syscalls/open_tree/open_tree01.c | 115 ++++++++++++++++++ .../kernel/syscalls/open_tree/open_tree02.c | 104 ++++++++++++++++ 5 files changed, 230 insertions(+) create mode 100644 testcases/kernel/syscalls/open_tree/.gitignore create mode 100644 testcases/kernel/syscalls/open_tree/Makefile create mode 100644 testcases/kernel/syscalls/open_tree/open_tree01.c create mode 100644 testcases/kernel/syscalls/open_tree/open_tree02.c
runtest/syscalls +3 -0
@@ -844,6 +844,9 @@ openat01 openat01 openat02 openat02 openat03 openat03 +open_tree01 open_tree01 +open_tree02 open_tree02 + mincore01 mincore01 mincore02 mincore02
testcases/kernel/syscalls/open_tree/.gitignore new file +2 -0
@@ -0,0 +1,2 @@ +/open_tree01 +/open_tree02
testcases/kernel/syscalls/open_tree/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk +include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/open_tree/open_tree01.c new file +115 -0
115 lines not on this page · raw message
testcases/kernel/syscalls/open_tree/open_tree02.c new file +104 -0
104 lines not on this page · raw message
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
PATCH v2 10/10 syscalls/open_tree: New tests
testcases/kernel/syscalls/open_tree/open_tree01.c line 20
Quoted 11 lines · Viresh Kumar
...
+++b/testcases/kernel/syscalls/open_tree/open_tree01.c
...testcases/kernel/syscalls/open_tree/open_tree01.c new file +7
-0+static struct tcase { +char *name; +unsigned int flags; +} tcases[] = { + {"Flag OPEN_TREE_CLONE" ,OPEN_TREE_CLONE }, + {"Flag OPEN_TREE_CLOEXEC" ,OPEN_TREE_CLONE |OPEN_TREE_CLOEXEC }, +};
==> remove Flag
+++ b/testcases/kernel/syscalls/open_tree/open_tree02.c
testcases/kernel/syscalls/open_tree/open_tree01.c line 75
Quoted 13 lines
testcases/kernel/syscalls/open_tree/open_tree01.c new file +10
-0@@ -0,0 +1,104 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + + fsmfd =TST_RET ; +TEST (move_mount (fsmfd,"" ,AT_FDCWD ,MNTPOINT , +MOVE_MOUNT_F_EMPTY_PATH )); +SAFE_CLOSE (fsmfd); + +if (TST_RET ==-1 ) +tst_brk (TBROK |TERRNO ,"move_mount() failed" ); +
+ ismounted = 1;
We need to set 'ismounted' variable to 1 here, otherwise, the test will break at the second loop.
------Error log------
tst_test.c:1278: INFO: Testing on ext3
tst_mkfs.c:90: INFO: Formatting /dev/loop2 with ext3 opts='' extra opts='' mke2fs 1.44.6 (5-Mar-2019)/dev/loop2 is mounted; will not make a filesystem here! tst_mkfs.c:101: BROK: tst_test.c:831: mkfs.ext3 failed with 1 tst_device.c:222: WARN: ioctl(/dev/loop2, LOOP_CLR_FD, 0) no ENXIO for too long
tst_tmpdir.c:330: WARN: tst_rmdir: rmobj(/tmp/SHZbDJ) failed:
unlink(/tmp/SHZbDJ/mntpoint) failed; errno=21: EISDIR
Summary:
passed 3 failed 0 skipped 0
warnings 0
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20200220/dd859363/attachment.htm>
PATCH v2 10/10 syscalls/open_tree: New tests
Quoted 33 lines · Li Wang
testcases/kernel/syscalls/open_tree/open_tree01.c line 20
Quoted 11 lines · Viresh Kumar
...
+++b/testcases/kernel/syscalls/open_tree/open_tree01.c
...testcases/kernel/syscalls/open_tree/open_tree01.c new file +7
-0+static struct tcase { +char *name; +unsigned int flags; +} tcases[] = { + {"Flag OPEN_TREE_CLONE" ,OPEN_TREE_CLONE }, + {"Flag OPEN_TREE_CLOEXEC" ,OPEN_TREE_CLONE |OPEN_TREE_CLOEXEC }, +};==> remove Flag
+++
b/testcases/kernel/syscalls/open_tree/open_tree02.ctestcases/kernel/syscalls/open_tree/open_tree01.c line 75
Quoted 13 lines
testcases/kernel/syscalls/open_tree/open_tree01.c new file +10
-0@@ -0,0 +1,104 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + + fsmfd =TST_RET ; +TEST (move_mount (fsmfd,"" ,AT_FDCWD ,MNTPOINT , +MOVE_MOUNT_F_EMPTY_PATH )); +SAFE_CLOSE (fsmfd); + +if (TST_RET ==-1 ) +tst_brk (TBROK |TERRNO ,"move_mount() failed" ); ++ ismounted = 1;
Quoted 2 lines
We need to set 'ismounted' variable to 1 here, otherwise, the test will break at the second loop.
Last minute change went untested it seems. Sorry about that.
Signature · 1 line
viresh