Add new LTP tests related to fsmount family of syscalls
v3 cover Add new LTP tests related to fsmount family of syscalls
Hello,
Here is the third version of my work rebased over the latest changes pushed around fsmount work by Zorro. This is tested on both ARM and X86 platforms now and no more errors are seen with it.
V2->V3:
- Fix errors with xfs.
- Add macros to define test names.
- Continue with multiple iteration tests on failures, instead of returning early.
- Set value of is_mounted in open_tree patch.
- Rename tst_ismount() and make it return 1 on success.
- Fix various formatting issues.
- Add all reviewed/ack tags.
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 | 23 ++++ runtest/syscalls | 16 +++ testcases/kernel/syscalls/fsconfig/.gitignore | 2 + testcases/kernel/syscalls/fsconfig/Makefile | 6 + .../kernel/syscalls/fsconfig/fsconfig01.c | 104 +++++++++++++++ .../kernel/syscalls/fsconfig/fsconfig02.c | 98 ++++++++++++++ testcases/kernel/syscalls/fsmount/.gitignore | 1 + testcases/kernel/syscalls/fsmount/fsmount01.c | 121 +++++++++-------- testcases/kernel/syscalls/fsmount/fsmount02.c | 79 +++++++++++ testcases/kernel/syscalls/fsopen/.gitignore | 2 + testcases/kernel/syscalls/fsopen/Makefile | 6 + testcases/kernel/syscalls/fsopen/fsopen01.c | 83 ++++++++++++ testcases/kernel/syscalls/fsopen/fsopen02.c | 55 ++++++++ testcases/kernel/syscalls/fspick/.gitignore | 2 + testcases/kernel/syscalls/fspick/Makefile | 6 + testcases/kernel/syscalls/fspick/fspick01.c | 117 +++++++++++++++++ testcases/kernel/syscalls/fspick/fspick02.c | 105 +++++++++++++++ .../kernel/syscalls/move_mount/.gitignore | 2 + testcases/kernel/syscalls/move_mount/Makefile | 6 + .../kernel/syscalls/move_mount/move_mount01.c | 86 ++++++++++++ .../kernel/syscalls/move_mount/move_mount02.c | 95 ++++++++++++++ .../kernel/syscalls/open_tree/.gitignore | 2 + testcases/kernel/syscalls/open_tree/Makefile | 6 + .../kernel/syscalls/open_tree/open_tree01.c | 124 ++++++++++++++++++ .../kernel/syscalls/open_tree/open_tree02.c | 104 +++++++++++++++ 27 files changed, 1209 insertions(+), 59 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 v3 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 | 23 +++++++++++++++++ testcases/kernel/syscalls/fsmount/fsmount01.c | 25 +------------------ 3 files changed, 30 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_is_mounted (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 +23 -0
@@ -386,6 +386,29 @@ int tst_umount(const char *path)return -1 ; } +int tst_is_mounted (const char *path) +{ +char line[256 ]; +FILE *file; +int ret =0 ; + + file =SAFE_FOPEN (NULL ,"/proc/mounts" ,"r" ); + +while (fgets (line,sizeof (line), file)) { +if (strstr (line, path) !=NULL ) { + ret =1 ; +break ; + } + } + +SAFE_FCLOSE (NULL , file); + +if (!ret) +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_is_mounted (MNTPOINT )) {SAFE_UMOUNT (MNTPOINT ); is_mounted =0 ; - }else { -tst_res (TFAIL ,"device not mounted" ); } }
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
PATCH v4 1/10 tst_device: Add tst_is_mounted() helper
This patch moves the ismount() helper added to the fsmount syscall tests to the standard library and renames it to tst_is_mounted(). The helper can be used across different files now.
Minor modifications are also done to the helper.
---V3->V4:
- s/TWARN/TINFO
- Fix commit log.
include/tst_device.h | 6 +++++ lib/tst_device.c | 23 +++++++++++++++++ testcases/kernel/syscalls/fsmount/fsmount01.c | 25 +------------------ 3 files changed, 30 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_is_mounted (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 +23 -0
@@ -386,6 +386,29 @@ int tst_umount(const char *path)return -1 ; } +int tst_is_mounted (const char *path) +{ +char line[256 ]; +FILE *file; +int ret =0 ; + + file =SAFE_FOPEN (NULL ,"/proc/mounts" ,"r" ); + +while (fgets (line,sizeof (line), file)) { +if (strstr (line, path) !=NULL ) { + ret =1 ; +break ; + } + } + +SAFE_FCLOSE (NULL , file); + +if (!ret) +tst_resm (TINFO ,"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_is_mounted (MNTPOINT )) {SAFE_UMOUNT (MNTPOINT ); is_mounted =0 ; - }else { -tst_res (TFAIL ,"device not mounted" ); } }
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
PATCH v4 1/10 tst_device: Add tst_is_mounted() helper
Quoted 44 lines · Viresh Kumar
This patch moves the
ismount()helper added to the fsmount syscall tests to the standard library and renames it totst_is_mounted(). The helper can be used across different files now.Minor modifications are also done to the helper.
Acked-by Li Wang <[email protected]>Reviewed-by Petr Vorel <[email protected]>Signed-off-by Viresh Kumar <[email protected]>---
V3->V4:
- s/TWARN/TINFO
- Fix commit log.include/tst_device.h | 6 +++++ lib/tst_device.c | 23 +++++++++++++++++ testcases/kernel/syscalls/fsmount/fsmount01.c | 25 +------------------ 3 files changed, 30 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_is_mounted (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 +0
-0@@ -386,6 +386,29 @@ int tst_umount(const char *path)return -1 ; }
lib/tst_device.c int tst_umount(const char *path) · line 398
Quoted 10 lines
lib/tst_device.c +10
-0+int tst_is_mounted (const char *path) +{ +char line[256 ]; +FILE *file; +int ret =0 ; + + file =SAFE_FOPEN (NULL ,"/proc/mounts" ,"r" ); + +while (fgets (line,sizeof (line), file)) { +if (strstr (line, path) !=NULL ) {
This code moving is fine. But if we'd like to make this function to be common function, we'd better think more about that. I think the current code logic isn't so well.
For example, if path is "/mnt/test", and we get a line as "/mnt/test/mnt1 ..." or "/mnt/mnt/test", Then this function thinks "/mnt/test" is a mountpoint.
We can refer to util-linux/sys-utils/mountpoint.c a little, but it's complicated, or we can call mountpoint command directly?
Quoted 68 lines
lib/tst_device.c +13
-0+ ret =1 ; +break ; + } + } + +SAFE_FCLOSE (NULL , file); + +if (!ret) +tst_resm (TINFO ,"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_is_mounted (MNTPOINT )) {SAFE_UMOUNT (MNTPOINT ); is_mounted =0 ; - }else { -tst_res (TFAIL ,"device not mounted" ); } }Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
PATCH v4 1/10 tst_device: Add tst_is_mounted() helper
Hi
Quoted 60 lines · Viresh Kumar
Quoted 44 lines
This patch moves the
ismount()helper added to the fsmount syscall tests to the standard library and renames it totst_is_mounted(). The helper can be used across different files now.Minor modifications are also done to the helper.
Acked-by Li Wang <[email protected]>Reviewed-by Petr Vorel <[email protected]>Signed-off-by Viresh Kumar <[email protected]>---
V3->V4:
- s/TWARN/TINFO
- Fix commit log.include/tst_device.h | 6 +++++ lib/tst_device.c | 23 +++++++++++++++++ testcases/kernel/syscalls/fsmount/fsmount01.c | 25 +------------------ 3 files changed, 30 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_is_mounted (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 +0
-0@@ -386,6 +386,29 @@ int tst_umount(const char *path)return -1 ; }lib/tst_device.c int tst_umount(const char *path) · line 398
Quoted 10 lines
lib/tst_device.c +10
-0+int tst_is_mounted (const char *path) +{ +char line[256 ]; +FILE *file; +int ret =0 ; + + file =SAFE_FOPEN (NULL ,"/proc/mounts" ,"r" ); + +while (fgets (line,sizeof (line), file)) { +if (strstr (line, path) !=NULL ) {This code moving is fine. But if we'd like to make this function to be common function, we'd better think more about that. I think the current code logic isn't so well.
Quoted 6 lines
For example, if path is "
/mnt/test", and we get a line as "/mnt/test/mnt1..." or "/mnt/mnt/test", Then this function thinks "/mnt/test" is a mountpoint.We can refer to
util-linux/sys-utils/mountpoint.ca little, but it's complicated, or we can call mountpoint command directly?
I think we can use a fixed format to extract it like kernel code tools/lib/api/fs/fs.c
static bool fs__read_mounts(struct fs *fs)
{
bool found = false;
char type[100];
FILE *fp;
fp = fopen("/proc/mounts", "r");
if (fp == NULL)
return NULL;
while (!found &&
fscanf(fp, "%*s %" STR(PATH_MAX) "s %99s %*s %*d %*d\n",
fs->path, type) == 2) {
if (strcmp(type, fs->name) == 0)
found = true;
}
fclose(fp);
return fs->found = found;
}But this way maybe wrong if kernel updates mount info format in future.
Best Regards
Yang Xu
Quoted 70 lines
Quoted 68 lines
lib/tst_device.c +13
-0+ ret =1 ; +break ; + } + } + +SAFE_FCLOSE (NULL , file); + +if (!ret) +tst_resm (TINFO ,"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_is_mounted (MNTPOINT )) {SAFE_UMOUNT (MNTPOINT ); is_mounted =0 ; - }else { -tst_res (TFAIL ,"device not mounted" ); } }Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
PATCH v4 1/10 tst_device: Add tst_is_mounted() helper
In reply to Zorro LangQuoted 5 lines · Zorro Lang
For example, if path is "
/mnt/test", and we get a line as "/mnt/test/mnt1..." or "/mnt/mnt/test", Then this function thinks "/mnt/test" is a mountpoint.We can refer to
util-linux/sys-utils/mountpoint.ca little, but it's complicated, or we can call mountpoint command directly?
This is working fine for me, does this looks okay now ?
lib/tst_device.c +6 -16
@@ -388,25 +388,16 @@ int tst_umount(const char *path)int tst_is_mounted (const char *path) { -char line[256 ]; -FILE *file; -int ret =0 ; - - file =SAFE_FOPEN (NULL ,"/proc/mounts" ,"r" ); - -while (fgets (line,sizeof (line), file)) { -if (strstr (line, path) !=NULL ) { - ret =1 ; -break ; - } - } +char cmd[PATH_MAX ]; +int ret; -SAFE_FCLOSE (NULL , file); +snprintf (cmd,sizeof (cmd),"mountpoint -q %s" , path); + ret =tst_system (cmd); -if (!ret) +if (ret)tst_resm (TINFO ,"No device is mounted at %s" , path); -return ret; +return !ret; } --
viresh
PATCH v3 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 supported on kernel version < v5.2" ); + } +}#endif /* FSMOUNT_H__ */
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
PATCH v3 2/10 lapi/fsmount.h: Add fsopen_supported_by_kernel()
Quoted 14 lines · Viresh Kumar
Add a helper to check if the
fsmount()related syscalls are supported by the kernel or not.Reviewed-by Petr Vorel <[email protected]>Signed-off-by Viresh Kumar <[email protected]>--- include/lapi/fsmount.h | 9 +++++++++ 1 file changed, 9 insertions(+)include/lapi/fsmount.h +0
-0
include/lapi/fsmount.h enum fsconfig_command { · line 133
Quoted 4 lines
include/lapi/fsmount.h +1
-0@@ -130,5 +130,14 @@ enum fsconfig_command {#endif /* OPEN_TREE_CLONE */ +void fsopen_supported_by_kernel (void )
Looks good to me.
Quoted 13 lines
include/lapi/fsmount.h +8
-0+{ +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 supported on kernel version < v5.2" ); + } +}#endif /* FSMOUNT_H__ */ Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
PATCH v3 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 v3 3/10 lapi/fsmount.h: Include "lapi/fcntl.h"
Quoted 7 lines · Viresh Kumar
All 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.Acked-by Petr Vorel <[email protected]>Signed-off-by Viresh Kumar <[email protected]>---
Good to me
Quoted 37 lines
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 v3 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 | 83 +++++++++++++++++++++ testcases/kernel/syscalls/fsopen/fsopen02.c | 55 ++++++++++++++ 5 files changed, 149 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 +83 -0
83 lines not on this page · raw message
testcases/kernel/syscalls/fsopen/fsopen02.c new file +55 -0
55 lines not on this page · raw message
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
PATCH v3 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 | 104 ++++++++++++++++++ .../kernel/syscalls/fsconfig/fsconfig02.c | 98 +++++++++++++++++ 5 files changed, 213 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 +104 -0
104 lines not on this page · raw message
testcases/kernel/syscalls/fsconfig/fsconfig02.c new file +98 -0
98 lines not on this page · raw message
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
PATCH v3 5/10 syscalls/fsconfig: New tests
Hi,
Quoted 1 line
Add tests to check working of
fsconfig()syscall.
LGTM, minor comments below.
...
Quoted 10 lines
+++
b/testcases/kernel/syscalls/fsconfig/fsconfig01.ctestcases/kernel/syscalls/fsconfig/fsconfig01.c new file +8
-0@@ -0,0 +1,104 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2020 Viresh Kumar <[email protected]> +* +* Basic fsconfig() test which tries to configure and mount the filesystem as +* well. +*/ +#include "tst_test.h"
testcases/kernel/syscalls/fsconfig/fsconfig01.c line 18
Quoted 10 lines
testcases/kernel/syscalls/fsconfig/fsconfig01.c new file +10
-0+#include "lapi/fsmount.h" + +#define MNTPOINT "mntpoint" + +static void run (void ) +{ +int fd, fsmfd; + +TEST (fsopen (tst_device->fs_type,0 )); + fd =TST_RET ;
JustTEST(fd = fsopen(tst_device->fs_type, 0));
Quoted 10 lines
testcases/kernel/syscalls/fsconfig/fsconfig01.c new file +10
-0+ +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; + } +
testcases/kernel/syscalls/fsconfig/fsconfig01.c line 38
Quoted 10 lines
testcases/kernel/syscalls/fsconfig/fsconfig01.c new file +10
-0+TEST (fsconfig (fd,FSCONFIG_SET_STRING ,"source" , tst_device->dev,0 )); +if (TST_RET ==-1 ) { +tst_res (TFAIL |TERRNO ,"fsconfig() failed" ); + goto out; + } + +TEST (fsconfig (fd,FSCONFIG_SET_PATH ,"sync" , tst_device->dev,0 )); +if (TST_RET ==-1 ) { +if (TST_ERR ==EOPNOTSUPP ) { +tst_res (TINFO ,"fsconfig(): FSCONFIG_SET_PATH not supported" );
This should be TCONF. It'd be nice to have this check in functions in lapi/fsmount.h (just DRY). But don't want to block these tests just because DRY.
Quoted 73 lines
testcases/kernel/syscalls/fsconfig/fsconfig01.c new file +66
-0+ }else { +tst_res (TFAIL |TERRNO ,"fsconfig() failed" ); + goto out; + } + } + +TEST (fsconfig (fd,FSCONFIG_SET_PATH_EMPTY ,"sync" , tst_device->dev,0 )); +if (TST_RET ==-1 ) { +if (TST_ERR ==EOPNOTSUPP ) { +tst_res (TINFO ,"fsconfig(): FSCONFIG_SET_PATH_EMPTY not supported" ); + }else { +tst_res (TFAIL |TERRNO ,"fsconfig() failed" ); + goto out; + } + } + +TEST (fsconfig (fd,FSCONFIG_SET_FD ,"sync" ,NULL ,0 )); +if (TST_RET ==-1 ) { +if (TST_ERR ==EOPNOTSUPP ) { +tst_res (TINFO ,"fsconfig(): FSCONFIG_SET_FD not supported" ); + }else { +tst_res (TFAIL |TERRNO ,"fsconfig() failed" ); + goto out; + } + } + +TEST (fsconfig (fd,FSCONFIG_CMD_CREATE ,NULL ,NULL ,0 )); +if (TST_RET ==-1 ) { +tst_res (TFAIL |TERRNO ,"fsconfig() failed" ); + goto out; + } + +TEST (fsmount (fd,0 ,0 )); +if (TST_RET ==-1 ) { +tst_res (TBROK |TERRNO ,"fsmount() failed" ); + goto out; + } + + fsmfd =TST_RET ; +TEST (move_mount (fsmfd,"" ,AT_FDCWD ,MNTPOINT , +MOVE_MOUNT_F_EMPTY_PATH )); +SAFE_CLOSE (fsmfd); + +if (TST_RET ==-1 ) { +tst_res (TBROK |TERRNO ,"move_mount() failed" ); + goto out; + } + +if (tst_is_mounted (MNTPOINT )) +tst_res (TPASS ,"fsconfig() passed" ); + +SAFE_UMOUNT (MNTPOINT ); + +out: +SAFE_CLOSE (fd); +} + +static struct tst_test test = { + .test_all = run, + .setup = fsopen_supported_by_kernel, + .needs_root =1 , + .format_device =1 , + .mntpoint =MNTPOINT , + .all_filesystems =1 , + .dev_fs_flags =TST_FS_SKIP_FUSE , +};testcases/kernel/syscalls/fsconfig/fsconfig02.c new file +1
-0@@ -0,0 +1,98 @@ +// SPDX-License-Identifier: GPL-2.0-or-later
testcases/kernel/syscalls/fsconfig/fsconfig02.c line 11
Quoted 10 lines
testcases/kernel/syscalls/fsconfig/fsconfig02.c new file +10
-0+/* +* Copyright (c) 2020 Viresh Kumar <[email protected]> +* +* Basic fsconfig() failure tests. +*/ +#include "tst_test.h" +#include "lapi/fsmount.h" + +int fd =-1 , temp_fd =-1 , invalid_fd =-1 ; +int aux_0 =0 , aux_1 =1 , aux_fdcwd =AT_FDCWD , aux_minus1 =-1 ;
These 2 should be static (also fd could be default 0, but who cares :)).
Kind regards,
Petr
PATCH v3 5/10 syscalls/fsconfig: New tests
Quoted 10 lines · Petr Vorel
Quoted 10 lines
testcases/kernel/syscalls/fsconfig/fsconfig02.c new file +4
-0@@ -0,0 +1,98 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2020 Viresh Kumar <[email protected]> +*
Quoted 8 lines
testcases/kernel/syscalls/fsconfig/fsconfig02.c line 11
Quoted 7 lines
testcases/kernel/syscalls/fsconfig/fsconfig02.c new file +7
-0+* Basic fsconfig() failure tests. +*/ +#include "tst_test.h" +#include "lapi/fsmount.h" + +int fd =-1 , temp_fd =-1 , invalid_fd =-1 ; +int aux_0 =0 , aux_1 =1 , aux_fdcwd =AT_FDCWD , aux_minus1 =-1 ;These 2 should be static (also fd could be default 0, but who cares :)).
No, fd was intentionally set to -1 here. If we return early due to tst_brk() from fsopen_supported_by_kernel(), then we need to handle that case in cleanup().
Signature · 1 line
viresh
PATCH v3 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 | 101 +++++++++++------- 1 file changed, 65 insertions(+), 36 deletions(-)
testcases/kernel/syscalls/fsmount/fsmount01.c +65 -36
@@ -3,67 +3,96 @@* 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. +* 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 void cleanup (void ) -{ -if (is_mounted) -SAFE_UMOUNT (MNTPOINT ); -} +#define TCASE_ENTRY (_flags, _attrs) {.name = "Flag " #_flags ", Attr " #_attrs, .flags = _flags, .attrs = _attrs} + +static struct tcase { +char *name; +unsigned int flags; +unsigned int attrs; +} tcases[] = { +TCASE_ENTRY (0 ,MOUNT_ATTR_RDONLY ), +TCASE_ENTRY (0 ,MOUNT_ATTR_NOSUID ), +TCASE_ENTRY (0 ,MOUNT_ATTR_NODEV ), +TCASE_ENTRY (0 ,MOUNT_ATTR_NOEXEC ), +TCASE_ENTRY (0 ,MOUNT_ATTR_RELATIME ), +TCASE_ENTRY (0 ,MOUNT_ATTR_NOATIME ), +TCASE_ENTRY (0 ,MOUNT_ATTR_STRICTATIME ), +TCASE_ENTRY (0 ,MOUNT_ATTR_NODIRATIME ), +TCASE_ENTRY (FSMOUNT_CLOEXEC ,MOUNT_ATTR_RDONLY ), +TCASE_ENTRY (FSMOUNT_CLOEXEC ,MOUNT_ATTR_NOSUID ), +TCASE_ENTRY (FSMOUNT_CLOEXEC ,MOUNT_ATTR_NODEV ), +TCASE_ENTRY (FSMOUNT_CLOEXEC ,MOUNT_ATTR_NOEXEC ), +TCASE_ENTRY (FSMOUNT_CLOEXEC ,MOUNT_ATTR_RELATIME ), +TCASE_ENTRY (FSMOUNT_CLOEXEC ,MOUNT_ATTR_NOATIME ), +TCASE_ENTRY (FSMOUNT_CLOEXEC ,MOUNT_ATTR_STRICTATIME ), +TCASE_ENTRY (FSMOUNT_CLOEXEC ,MOUNT_ATTR_NODIRATIME ), +}; -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_res (TBROK |TTERRNO ,"fsopen() on %s failed" , + tst_device->fs_type); +return ; + } 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 ) -tst_brk (TBROK |TTERRNO , +if (TST_RET <0 ) { +SAFE_CLOSE (sfd); +tst_res (TBROK |TTERRNO ,"fsconfig() failed to set source to %s" , tst_device->dev); -tst_res (TPASS ,"fsconfig() set source to %s" , tst_device->dev); - +return ; + }TEST (fsconfig (sfd,FSCONFIG_CMD_CREATE ,NULL ,NULL ,0 )); -if (TST_RET <0 ) -tst_brk (TBROK |TTERRNO ,"fsconfig() created superblock" ); -tst_res (TPASS ,"fsconfig() created superblock" ); +if (TST_RET <0 ) { +SAFE_CLOSE (sfd); +tst_res (TBROK |TTERRNO ,"fsconfig() created superblock" ); +return ; + } -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->attrs));SAFE_CLOSE (sfd); +if (TST_RET <0 ) { +tst_res (TFAIL |TTERRNO , +"fsmount() failed to create a mount object" ); +return ; + } + 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_is_mounted (MNTPOINT )) { -SAFE_UMOUNT (MNTPOINT ); - is_mounted =0 ; +if (TST_RET <0 ) { +tst_res (TBROK |TTERRNO , +"move_mount() failed to attach to the mount point" ); +return ; } + +if (tst_is_mounted (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 = fsopen_supported_by_kernel, .needs_root =1 , .mntpoint =MNTPOINT , .format_device =1 ,
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
PATCH v3 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 | 79 +++++++++++++++++++ 3 files changed, 81 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 +79 -0
79 lines not on this page · raw message
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
PATCH v3 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 | 86 +++++++++++++++++ .../kernel/syscalls/move_mount/move_mount02.c | 95 +++++++++++++++++++ 5 files changed, 192 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 +86 -0
86 lines not on this page · raw message
testcases/kernel/syscalls/move_mount/move_mount02.c new file +95 -0
95 lines not on this page · raw message
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
PATCH v3 8/10 syscalls/move_mount: New tests
Hi,
Review
Quoted 2 lines
(quoted diff) +2
-0+ TEST(fsopen(tst_device->fs_type, 0)); + fd = TST_RET;
Again:TEST(fd = fsopen(tst_device->fs_type, 0));
testcases/kernel/syscalls/move_mount/move_mount01.c line 42
Quoted 10 lines
testcases/kernel/syscalls/move_mount/move_mount01.c new file +10
-0+ +if (fd ==-1 ) { +tst_res (TBROK |TERRNO ,"fsopen() failed" ); +return ; + } + +TEST (fsconfig (fd,FSCONFIG_SET_STRING ,"source" , tst_device->dev,0 )); +if (TST_RET ==-1 ) { +SAFE_CLOSE (fd); +tst_res (TBROK |TERRNO ,"fsconfig() failed" );
These should be TFAIL otherwise it 1) breaks all tests 2) does not report any result:
move_mount02.c:37: BROK: fsopen() failed: SUCCESS (0) tst_test.c:1051: BROK: Test 0 haven't reported results!
I'll send diff with these small fixes and if anybody complains, we could merge whole patchset.
Kind regards,
Petr
PATCH v3 8/10 syscalls/move_mount: New tests
Quoted 9 lines · Petr Vorel
testcases/kernel/syscalls/move_mount/move_mount01.c line 42
Quoted 4 lines
testcases/kernel/syscalls/move_mount/move_mount01.c new file +4
-0+TEST (fsconfig (fd,FSCONFIG_SET_STRING ,"source" , tst_device->dev,0 )); +if (TST_RET ==-1 ) { +SAFE_CLOSE (fd); +tst_res (TBROK |TERRNO ,"fsconfig() failed" );These should be TFAIL otherwise it 1) breaks all tests 2) does not report any result:
move_mount02.c:37: BROK:
fsopen()failed: SUCCESS (0) tst_test.c:1051: BROK: Test 0 haven't reported results!
I am a bit confused about TBROK and TFAIL to be honest. The test writing guideline says this:
| 'TFAIL' | Test has failed. | 'TBROK' | Something has failed in test preparation phase.
And so in my code I have been using TFAIL only for the failures for the actual syscalls that we are testing, like move_mount here. And I have been using TBROK for pretty much everything else.
Would be good if you and Cyril can explain what's the correct usage model for these is.
Signature · 1 line
viresh
PATCH v3 8/10 syscalls/move_mount: New tests
Hi
Quoted 14 lines · Petr Vorel
Quoted 9 lines
testcases/kernel/syscalls/move_mount/move_mount01.c line 42
Quoted 4 lines
testcases/kernel/syscalls/move_mount/move_mount01.c new file +4
-0+TEST (fsconfig (fd,FSCONFIG_SET_STRING ,"source" , tst_device->dev,0 )); +if (TST_RET ==-1 ) { +SAFE_CLOSE (fd); +tst_res (TBROK |TERRNO ,"fsconfig() failed" );These should be TFAIL otherwise it 1) breaks all tests 2) does not report any result:
move_mount02.c:37: BROK:
fsopen()failed: SUCCESS (0) tst_test.c:1051: BROK: Test 0 haven't reported results!I am a bit confused about TBROK and TFAIL to be honest. The test writing guideline says this:
Quoted 6 lines
| 'TFAIL' | Test has failed. | 'TBROK' | Something has failed in test preparation phase.And so in my code I have been using TFAIL only for the failures for the actual syscalls that we are testing, like
move_mounthere. And I have been using TBROK for pretty much everything else
If using TBROK, it will terminate the program. So how can test the remaining test?
Like move_mount02.c, if test "invalid-from-fd"and fsconfig failed, it will exit. So how do you test "invalid-from-path"?
Also, using return after TBROK is meaningless.
Best Regards
Yang Xu
Quoted 4 lines
Would be good if you and Cyril can explain what's the correct usage model for these is.
PATCH v3 8/10 syscalls/move_mount: New tests
Quoted 6 lines · Yang Xu
If using TBROK, it will terminate the program. So how can test the remaining test?
Likemove_mount02.c, if test "invalid-from-fd"and fsconfig failed, it will exit. So how do you test "invalid-from-path"?Also, using return after TBROK is meaningless.
I think one of us has surely misunderstood it all :)
What my understanding says is that if you use tst_brk(), then it breaks the test and returns early. TBROK or TFAIL, both can be used in tst_brk() or tst_ret() and they only imply what has failed, the test or some preparatory thing.
Signature · 1 line
viresh
PATCH v3 8/10 syscalls/move_mount: New tests
In reply to Viresh KumarHi Viresh,
Quoted 14 lines · Petr Vorel
Quoted 9 lines
testcases/kernel/syscalls/move_mount/move_mount01.c line 42
Quoted 4 lines
testcases/kernel/syscalls/move_mount/move_mount01.c new file +4
-0+TEST (fsconfig (fd,FSCONFIG_SET_STRING ,"source" , tst_device->dev,0 )); +if (TST_RET ==-1 ) { +SAFE_CLOSE (fd); +tst_res (TBROK |TERRNO ,"fsconfig() failed" );These should be TFAIL otherwise it 1) breaks all tests 2) does not report any result:
move_mount02.c:37: BROK:
fsopen()failed: SUCCESS (0) tst_test.c:1051: BROK: Test 0 haven't reported results!I am a bit confused about TBROK and TFAIL to be honest. The test writing guideline says this:
Quoted 6 lines
| 'TFAIL' | Test has failed. | 'TBROK' | Something has failed in test preparation phase.And so in my code I have been using TFAIL only for the failures for the actual syscalls that we are testing, like
move_mounthere. And I have been using TBROK for pretty much everything else.
Your idea is correct, but IMHO it's not good to skip all the tests, which is done due
tst_test.c:1051: BROK: Test 0 haven't reported results!
if you use tst_res(TBROK ...).
You can use tst_brk(TBROK) to avoid no reported results, but that's obviously exit the test either.
tst_brk(TBROK) is used for setup, where you create some resource, which is then reused by all test runs, but this preparation fails.
NOTE: There are some tests which are using tst_res(TBROK). At least some of them are wrong. IMHO in testcases/kernel/syscalls/request_key/request_key04.c
TST_ERR = saved_errno;
if (TST_ERR == EACCES) {
tst_res(TPASS, "request_key() failed with EACCES as expected");
} else {
tst_res(TBROK | TTERRNO,
"request_key() failed with unexpected error code");
}IMHO it should be
TST_ERR = saved_errno;
if (TST_ERR == EACCES) {
tst_res(TPASS, "request_key() failed with EACCES as expected");
} else {
tst_res(TFAIL | TTERRNO,
"request_key() failed with unexpected error code");
}Otherwise if it fails at unexpected error code, you get:
request_key04.c:68: BROK: request_key() failed with unexpected error code: EACCES (13) tst_test.c:1036: BROK: Test haven't reported results!
Thus I'd try to avoid TBROK with tst_res().
Quoted 2 lines
Would be good if you and Cyril can explain what's the correct usage model for these is.
Kind regards,
Petr
PATCH v3 8/10 syscalls/move_mount: New tests
Quoted 4 lines · Petr Vorel
Your idea is correct, but IMHO it's not good to skip all the tests, which is done due
tst_test.c:1051: BROK: Test 0 haven't reported results!
if you usetst_res(TBROK ...).
I don't think that is the case. tst_res(TBROK, ...) shouldn't (and isn't for me) result in skipping of tests.
Quoted 2 lines
tst_brk(TBROK)is used for setup, where you create some resource, which is then reused by all test runs, but this preparation fails.
Right, but in my case I can't put all setup stuff in setup() callback and some of the setup bits stay in run() callback as well.
Signature · 1 line
viresh
PATCH v3 8/10 syscalls/move_mount: New tests
Hi Viresh,
Quoted 8 lines · Petr Vorel
Quoted 4 lines
Your idea is correct, but IMHO it's not good to skip all the tests, which is done due
tst_test.c:1051: BROK: Test 0 haven't reported results!
if you usetst_res(TBROK ...).I don't think that is the case.
tst_res(TBROK, ...)shouldn't (and isn't for me) result in skipping of tests.
Correct, tst_res() itself doesn't exit the test. But the fact it uses TBROK without reporting any result previously leads to tst_brk from the library:
tst_test.c:1036: BROK: Test haven't reported results!
tst_brk(TBROK, "Test %i haven't reported results!", i);
That's why I consider tst_res(TBROK problematic.
This is a separate discussion, see the patch I sent today
https://patchwork.ozlabs.org/patch/1244781/
Kind regards,
Petr
Quoted 5 lines
Quoted 2 lines
tst_brk(TBROK)is used for setup, where you create some resource, which is then reused by all test runs, but this preparation fails.Right, but in my case I can't put all setup stuff in
setup()callback and some of the setup bits stay inrun()callback as well.
Sure. But as a result of it I'd personally use tst_res(TFAIL). But maybe I'm wrong and others will correct me.
Kind regards,
Petr
PATCH v3 8/10 syscalls/move_mount: New tests
Quoted 8 lines · Petr Vorel
Hi Viresh,
Quoted 5 lines · Petr Vorel
Quoted 4 lines
Your idea is correct, but IMHO it's not good to skip all the tests, which is done due
tst_test.c:1051: BROK: Test 0 haven't reported results!
if you usetst_res(TBROK ...).
Quoted 6 lines
Quoted 2 lines
I don't think that is the case.
tst_res(TBROK, ...)shouldn't (and isn't for me) result in skipping of tests.Correct,
tst_res()itself doesn't exit the test. But the fact it uses TBROK without reporting any result previously leads totst_brkfrom the library:tst_test.c:1036: BROK: Test haven't reported results!
Ahh, I missed this part then.
Quoted 4 lines
Quoted 2 lines
Right, but in my case I can't put all setup stuff in
setup()callback and some of the setup bits stay inrun()callback as well.Sure. But as a result of it I'd personally use
tst_res(TFAIL). But maybe I'm wrong and others will correct me.
FWIW, I am the least educated guy here in terms of LTP stuff :)
I just want to make sure I don't need to do it again and so wanted to better understand TBROK vs TFAIL thing.
So the conclusion is that in the run() callback we should always use TFAIL ?
Signature · 1 line
viresh
PATCH v3 8/10 syscalls/move_mount: New tests
Hi Viresh,
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
I don't think that is the case.
tst_res(TBROK, ...)shouldn't (and isn't for me) result in skipping of tests.Correct,
tst_res()itself doesn't exit the test. But the fact it uses TBROK without reporting any result previously leads totst_brkfrom the library:tst_test.c:1036: BROK: Test haven't reported results!
Quoted 8 lines
Ahh, I missed this part then.
Quoted 4 lines
Quoted 2 lines
Right, but in my case I can't put all setup stuff in
setup()callback and some of the setup bits stay inrun()callback as well.Sure. But as a result of it I'd personally use
tst_res(TFAIL). But maybe I'm wrong and others will correct me.FWIW, I am the least educated guy here in terms of LTP stuff :)
You're doing well :).
Quoted 2 lines
I just want to make sure I don't need to do it again and so wanted to better understand TBROK vs TFAIL thing.
+1.
Quoted 2 lines
So the conclusion is that in the
run()callback we should always use TFAIL ?
I'd wait on the outcome of the discussion here
https://patchwork.ozlabs.org/patch/1244781/
Kind regards,
Petr
PATCH v3 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 | 117 ++++++++++++++++++++ testcases/kernel/syscalls/fspick/fspick02.c | 105 ++++++++++++++++++ 5 files changed, 233 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 +117 -0
117 lines not on this page · raw message
testcases/kernel/syscalls/fspick/fspick02.c new file +105 -0
105 lines not on this page · raw message
Signature · 1 line
2.21.0.rc0.269.g1a574e7a288b
PATCH v3 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 | 124 ++++++++++++++++++ .../kernel/syscalls/open_tree/open_tree02.c | 104 +++++++++++++++ 5 files changed, 239 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 +124 -0
124 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 v3 10/10 syscalls/open_tree: New tests
Hi,
Quoted 1 line
+++
b/testcases/kernel/syscalls/open_tree/open_tree01.c
...
testcases/kernel/syscalls/open_tree/open_tree01.c line 37
Quoted 5 lines
testcases/kernel/syscalls/open_tree/open_tree01.c new file +5
-0+static void cleanup (void ) +{ +if (dir_created) +SAFE_RMDIR (OT_MNTPOINT ); +}
BTW: This might not be needed (whole tmp directory gets deleted after test exits by the library).
Kind regards,
Petr
v3 cover Add new LTP tests related to fsmount family of syscalls
In reply to Viresh KumarHi Viresh,
These new tests look good, only a few comments/questions below:
Patch 1/10:
1. The git summary should be updated too (someone who push patch can help do that:).
2. Maybe better to replace the TWARN by TINFO? Since tst_is_mounted() as a general function to check if mount success, sometimes we just need the return status then do next work(I tend to leave the waring or break operate to LTP users:).
Patch 5/10, 9/10:
May I ask why we use "sync" as the key value in fsconfig()? I ask this because it can get rid of the errors we found in XFS test before.
Patch 9/10, 10/10:
I guess that'd be better if we put the 'ismounted = 1' at the behind of tst_is_mounted(), do you feel the code sequence looks strange which we set 'ismounted' to 1 then do mount checking?
Ack for the whole patchset v3 (+ follow some modification for above comments):
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20200225/515a0f53/attachment.htm>
v3 cover Add new LTP tests related to fsmount family of syscalls
Hi,
Quoted 3 lines
Patch 5/10, 9/10:
May I ask why we use "sync" as the key value infsconfig()? I ask this because it can get rid of the errors we found in XFS test before.
I guess "sync" is valid option (see FILESYSTEM-INDEPENDENT MOUNT OPTIONS in mount(8)), but "foo" obviously not.
Quoted 4 lines
Patch 9/10, 10/10:
I guess that'd be better if we put the 'ismounted = 1' at the behind oftst_is_mounted(), do you feel the code sequence looks strange which we set 'ismounted' to 1 then do mount checking?
+1.
Kind regards,
Petr
v3 cover Add new LTP tests related to fsmount family of syscalls
In reply to Li WangQuoted 11 lines · Li Wang
Hi Viresh,
These new tests look good, only a few comments/questions below:
Patch 1/10:
1. The git summary should be updated too (someone who push patch can help do that:).
2. Maybe better to replace the TWARN by TINFO? Sincetst_is_mounted()as a general function to check if mount success, sometimes we just need the return status then do next work(I tend to leave the waring or break operate to LTP users:).
Done and sent an update as well.
Quoted 3 lines
Patch 5/10, 9/10:
May I ask why we use "sync" as the key value infsconfig()? I ask this because it can get rid of the errors we found in XFS test before.
I wasn't able to test it earlier during V2 on my ARM platform and so just added "foo" there.
This time, I tried running it on my x86 machine and so was able to run xfs tests and so I figured out what needs to be passed by looking out the Linux source.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/fs_context.c#n41
The first two arrays have the valid options that can be passed.
Quoted 4 lines
Patch 9/10, 10/10:
I guess that'd be better if we put the 'ismounted = 1' at the behind oftst_is_mounted(), do you feel the code sequence looks strange which we set 'ismounted' to 1 then do mount checking?
I understand the weirdness you are talking about, but I think the code does what the right thing to do at this point is.
The question is, what are we supposed to do when move_mount() passes, but we aren't able to see the mount in /proc/mounts ? I think, we should call umount() anyway as move_mount() passed. And that's why I have kept the ismounted = 1, line before the tst_is_mounted() call.
Quoted 3 lines
Ack for the whole patchset v3 (+ follow some modification for above comments):
Acked-by Li Wang <[email protected]>
Thanks for your reviews Li.
Signature · 1 line
viresh
v3 cover Add new LTP tests related to fsmount family of syscalls
In reply to Viresh KumarHi,
I addressed some of my concerns here (+ add fspick.h to remove a bit of the duplicity):
https://github.com/pevik/ltp/tree/Viresh_Kumar/fsmount.v3.fixes
LGTM, but I'd like to have more look.
I'd also appreciate somebody else to have look.
Kind regards,
Petr
tst_device.c +1 -1
@@ -404,7 +404,7 @@ int tst_is_mounted(const char *path)SAFE_FCLOSE (NULL , file);if (!ret) -tst_resm (TWARN ,"No device is mounted at %s" , path); +tst_resm (TINFO ,"No device is mounted at %s" , path);return ret; }
kernel/syscalls/fsconfig/fsconfig02.c +3 -5
@@ -7,8 +7,8 @@#include "tst_test.h" #include "lapi/fsmount.h" -int fd =-1 , temp_fd =-1 , invalid_fd =-1 ; -int aux_0 =0 , aux_1 =1 , aux_fdcwd =AT_FDCWD , aux_minus1 =-1 ; +static int fd =-1 , temp_fd =-1 , invalid_fd =-1 ; +static int aux_0 =0 , aux_1 =1 , aux_fdcwd =AT_FDCWD , aux_minus1 =-1 ; static struct tcase { char *name;
@@ -51,9 +51,7 @@ static void setup(void) {fsopen_supported_by_kernel (); -TEST (fsopen (tst_device->fs_type,0 )); - fd =TST_RET ; - +TEST (fd =fsopen (tst_device->fs_type,0 ));if (fd ==-1 )tst_brk (TBROK |TERRNO ,"fsopen() failed" );
kernel/syscalls/fsmount/fsmount01.c +2 -3
@@ -41,13 +41,12 @@ 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 ==-1 ) { +TEST (sfd =fsopen (tst_device->fs_type,FSOPEN_CLOEXEC )); +if (sfd ==-1 ) {tst_res (TBROK |TTERRNO ,"fsopen() on %s failed" , tst_device->fs_type);return ; } - sfd =TST_RET ;TEST (fsconfig (sfd,FSCONFIG_SET_STRING ,"source" , tst_device->dev,0 ));if (TST_RET <0 ) {
kernel/syscalls/fsmount/fsmount02.c +1 -3
@@ -33,9 +33,7 @@ static void setup(void) {fsopen_supported_by_kernel (); -TEST (fsopen (tst_device->fs_type,0 )); - fd =TST_RET ; - +TEST (fd =fsopen (tst_device->fs_type,0 ));if (fd ==-1 )tst_brk (TBROK |TERRNO ,"fsopen() failed" );
kernel/syscalls/fsopen/fsopen01.c +1 -3
@@ -25,9 +25,7 @@ static void run(unsigned int n)struct tcase *tc = &tcases[n];int fd, fsmfd; -TEST (fsopen (tst_device->fs_type, tc->flags)); - fd =TST_RET ; - +TEST (fd =fsopen (tst_device->fs_type, tc->flags));if (fd ==-1 ) {tst_res (TFAIL |TERRNO ,"fsopen() failed" );return ;
kernel/syscalls/fspick/fspick.h new file +60 -0
60 lines not on this page · raw message
kernel/syscalls/fspick/fspick01.c +1 -54
67 lines not on this page · raw message
kernel/syscalls/fspick/fspick02.c +1 -55
68 lines not on this page · raw message
kernel/syscalls/move_mount/move_mount01.c +5 -7
@@ -28,25 +28,23 @@ static void run(unsigned int n)struct tcase *tc = &tcases[n];int fsmfd, fd; -TEST (fsopen (tst_device->fs_type,0 )); - fd =TST_RET ; - +TEST (fd =fsopen (tst_device->fs_type,0 ));if (fd ==-1 ) { -tst_res (TBROK |TERRNO ,"fsopen() failed" ); +tst_res (TFAIL |TERRNO ,"fsopen() failed" );return ; }TEST (fsconfig (fd,FSCONFIG_SET_STRING ,"source" , tst_device->dev,0 ));if (TST_RET ==-1 ) {SAFE_CLOSE (fd); -tst_res (TBROK |TERRNO ,"fsconfig() failed" ); +tst_res (TFAIL |TERRNO ,"fsconfig() failed" );return ; }TEST (fsconfig (fd,FSCONFIG_CMD_CREATE ,NULL ,NULL ,0 ));if (TST_RET ==-1 ) {SAFE_CLOSE (fd); -tst_res (TBROK |TERRNO ,"fsconfig() failed" ); +tst_res (TFAIL |TERRNO ,"fsconfig() failed" );return ; }
@@ -54,7 +52,7 @@ static void run(unsigned int n)SAFE_CLOSE (fd);if (TST_RET ==-1 ) { -tst_res (TBROK |TERRNO ,"fsmount() failed" ); +tst_res (TFAIL |TERRNO ,"fsmount() failed" );return ; }
kernel/syscalls/move_mount/move_mount02.c +5 -7
@@ -32,25 +32,23 @@ static void run(unsigned int n)struct tcase *tc = &tcases[n];int fd; -TEST (fsopen (tst_device->fs_type,0 )); - fd =TST_RET ; - +TEST (fd =fsopen (tst_device->fs_type,0 ));if (fd ==-1 ) { -tst_res (TBROK |TERRNO ,"fsopen() failed" ); +tst_res (TFAIL |TERRNO ,"fsopen() failed" );return ; }TEST (fsconfig (fd,FSCONFIG_SET_STRING ,"source" , tst_device->dev,0 ));if (TST_RET ==-1 ) {SAFE_CLOSE (fd); -tst_res (TBROK |TERRNO ,"fsconfig() failed" ); +tst_res (TFAIL |TERRNO ,"fsconfig() failed" );return ; }TEST (fsconfig (fd,FSCONFIG_CMD_CREATE ,NULL ,NULL ,0 ));if (TST_RET ==-1 ) {SAFE_CLOSE (fd); -tst_res (TBROK |TERRNO ,"fsconfig() failed" ); +tst_res (TFAIL |TERRNO ,"fsconfig() failed" );return ; }
@@ -58,7 +56,7 @@ static void run(unsigned int n)SAFE_CLOSE (fd);if (TST_RET ==-1 ) { -tst_res (TBROK |TERRNO ,"fsmount() failed" ); +tst_res (TFAIL |TERRNO ,"fsmount() failed" );return ; }
kernel/syscalls/open_tree/open_tree01.c +3 -5
@@ -52,18 +52,18 @@ static void run(unsigned int n)TEST (fsconfig (fd,FSCONFIG_SET_STRING ,"source" , tst_device->dev,0 ));if (TST_RET ==-1 ) {SAFE_CLOSE (fd); -tst_res (TBROK |TERRNO ,"fsconfig failed" ); +tst_res (TBROK |TERRNO ,"fsconfig() failed" );return ; }TEST (fsconfig (fd,FSCONFIG_CMD_CREATE ,NULL ,NULL ,0 ));if (TST_RET ==-1 ) {SAFE_CLOSE (fd); -tst_res (TBROK |TERRNO ,"fsconfig failed" ); +tst_res (TBROK |TERRNO ,"fsconfig() failed" );return ; } -TEST (fsmount (fd,0 ,0 )); +TEST (fsmfd =fsmount (fd,0 ,0 ));SAFE_CLOSE (fd);if (TST_RET ==-1 ) {
@@ -71,8 +71,6 @@ static void run(unsigned int n)return ; } - fsmfd =TST_RET ; -TEST (move_mount (fsmfd,"" ,AT_FDCWD ,MNTPOINT ,MOVE_MOUNT_F_EMPTY_PATH ));SAFE_CLOSE (fsmfd);
kernel/syscalls/open_tree/open_tree02.c +3 -4
@@ -44,22 +44,21 @@ static void setup(void)TEST (fsconfig (fd,FSCONFIG_SET_STRING ,"source" , tst_device->dev,0 ));if (TST_RET ==-1 ) {SAFE_CLOSE (fd); -tst_brk (TBROK |TERRNO ,"fsconfig failed" ); +tst_brk (TBROK |TERRNO ,"fsconfig() failed" ); }TEST (fsconfig (fd,FSCONFIG_CMD_CREATE ,NULL ,NULL ,0 ));if (TST_RET ==-1 ) {SAFE_CLOSE (fd); -tst_brk (TBROK |TERRNO ,"fsconfig failed" ); +tst_brk (TBROK |TERRNO ,"fsconfig() failed" ); } -TEST (fsmount (fd,0 ,0 )); +TEST (fsmfd =fsmount (fd,0 ,0 ));SAFE_CLOSE (fd);if (TST_RET ==-1 )tst_brk (TBROK |TERRNO ,"fsmount() failed" ); - fsmfd =TST_RET ;TEST (move_mount (fsmfd,"" ,AT_FDCWD ,MNTPOINT ,MOVE_MOUNT_F_EMPTY_PATH ));SAFE_CLOSE (fsmfd);