shell: df01.sh: $TST_ALL_FILESYSTEMS (.all_filesystems)
v5 cover shell: df01.sh: $TST_ALL_FILESYSTEMS (.all_filesystems)
Hi,
changes v4->v5:
* tst_fs_is_supported_skiplist() returns TST_FS_UNSUPPORTED, errors handled in testcases/lib/tst_supported_fs.c (Cyril)
* testcases/lib/tst_supported_fs.c: put parsing code to separate function parse_skiplist() (Cyril)
* testcases/lib/tst_supported_fs.c: Print usage on getopts error (Cyril)
* print TCONF when filesystem is not supported
* tst_test.sh: fix quiting test when no filesystem supported
* zram01.sh: use -f tmpfs in tst_supported_fs call
* new test lib/newlib_tests/shell/tst_all_filesystems_skip.sh
* add fuse to lib/newlib_tests/shell/tst_skip_filesystems.sh
new commits:
* tst_supported_fs: Print TCONF if no filesystem supported
Petr Vorel (10):
shell: Print mount command in tst_mount()
shell API/tests: Require root for format/mount tests
tst_supported_fs: Print TCONF if no filesystem supported
tst_supported_fs: Implement skip list
tst_supported_fs: Support skip list when query single fs
shell: Add $TST_SKIP_FILESYSTEMS + tests tst_test.sh: Introduce TST_FS_TYPE_FUSE tst_test.sh: Add $TST_ALL_FILESYSTEMS
shell: Add tests for TST_ALL_FILESYSTEMS=1 df01.sh: Convert to TST_ALL_FILESYSTEMS=1
doc/shell-test-api.txt | 13 +- include/tst_fs.h | 10 ++ lib/newlib_tests/shell/tst_all_filesystems.sh | 27 +++ .../shell/tst_all_filesystems_skip.sh | 16 ++ lib/newlib_tests/shell/tst_format_device.sh | 1 + lib/newlib_tests/shell/tst_mount_device.sh | 1 + .../shell/tst_mount_device_tmpfs.sh | 1 + .../shell/tst_skip_filesystems.sh | 35 ++++ .../shell/tst_skip_filesystems_skip.sh | 17 ++ lib/tst_supported_fs_types.c | 17 ++ runtest/commands | 8 +- runtest/smoketest | 2 +- testcases/commands/df/df01.sh | 32 +--- .../kernel/device-drivers/zram/zram01.sh | 3 +- testcases/lib/tst_supported_fs.c | 74 +++++++-- testcases/lib/tst_test.sh | 155 +++++++++++++----- testcases/misc/lvm/generate_lvm_runfile.sh | 2 +- testcases/misc/lvm/prepare_lvm.sh | 2 +- 18 files changed, 326 insertions(+), 90 deletions(-) create mode 100755 lib/newlib_tests/shell/tst_all_filesystems.sh create mode 100755 lib/newlib_tests/shell/tst_all_filesystems_skip.sh create mode 100755 lib/newlib_tests/shell/tst_skip_filesystems.sh create mode 100755 lib/newlib_tests/shell/tst_skip_filesystems_skip.sh
Signature · 5 lines
2.37.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v5 1/10 shell: Print mount command in tst_mount()
---
The same as in v4
testcases/lib/tst_test.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
testcases/lib/tst_test.sh +3 -1
@@ -293,9 +293,11 @@ tst_mount() mnt_opt="-t $TST_FS_TYPE" mnt_err=" $TST_FS_TYPE type" fi + local cmd="mount $mnt_opt $TST_DEVICE $TST_MNTPOINT $TST_MNT_PARAMS" ROD_SILENT mkdir -p $TST_MNTPOINT - mount $mnt_opt $TST_DEVICE $TST_MNTPOINT $TST_MNT_PARAMS + tst_res TINFO "Mounting device: $cmd" + $cmd local ret=$? if [ $ret -eq 32 ]; then
Signature · 5 lines
2.37.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v5 01/10] shell: Print mount command in tst_mount()
Hi!
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v5 2/10 shell API/tests: Require root for format/mount tests
In reply to Petr Voreli.e. for TST_{FORMAT,MOUNT}_DEVICE=1.
Although the warning is quite obvious:
tst_device.c:101: TINFO: Not allowed to open /dev/loop-control. Are you root?: EACCES (13) tst_device.c:140: TINFO: No free devices found
TBROK: Failed to acquire device
It's safer to expect root to get valid result.
---
The same as in v4
lib/newlib_tests/shell/tst_format_device.sh | 1 + lib/newlib_tests/shell/tst_mount_device.sh | 1 + lib/newlib_tests/shell/tst_mount_device_tmpfs.sh | 1 + 3 files changed, 3 insertions(+)
lib/newlib_tests/shell/tst_format_device.sh +1 -0
@@ -3,6 +3,7 @@ # Copyright (c) 2022 Petr Vorel <[email protected]> TST_FORMAT_DEVICE=1 +TST_NEEDS_ROOT=1 TST_TESTFUNC=test TST_CNT=2 TST_DEV_FS_OPTS="-b 1024"
lib/newlib_tests/shell/tst_mount_device.sh +1 -0
@@ -3,6 +3,7 @@ # Copyright (c) 2022 Petr Vorel <[email protected]> TST_MOUNT_DEVICE=1 +TST_NEEDS_ROOT=1 TST_FS_TYPE=ext4 TST_TESTFUNC=test TST_CNT=3
lib/newlib_tests/shell/tst_mount_device_tmpfs.sh +1 -0
@@ -3,6 +3,7 @@ # Copyright (c) 2022 Petr Vorel <[email protected]> TST_MOUNT_DEVICE=1 +TST_NEEDS_ROOT=1 TST_FS_TYPE=tmpfs TST_TESTFUNC=test
Signature · 5 lines
2.37.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v5 02/10] shell API/tests: Require root for format/mount tests
Hi!
Quoted 6 lines
Although the warning is quite obvious:
tst_device.c:101: TINFO: Not allowed to open/dev/loop-control. Are you root?: EACCES (13) tst_device.c:140: TINFO: No free devices found
TBROK: Failed to acquire deviceIt's safer to expect root to get valid result.
Another option would actually be to make the TST_NEED_DEVICE flag imply TST_NEEDS_ROOT flag, but I do not think that we have that for the C library either.
Either way this is fine as well:
Quoted 49 lines
Reviewed-by Li Wang <[email protected]>Signed-off-by Petr Vorel <[email protected]>---
The same as in v4lib/newlib_tests/shell/tst_format_device.sh | 1 + lib/newlib_tests/shell/tst_mount_device.sh | 1 + lib/newlib_tests/shell/tst_mount_device_tmpfs.sh | 1 + 3 files changed, 3 insertions(+)lib/newlib_tests/shell/tst_format_device.sh +1
-0@@ -3,6 +3,7 @@ # Copyright (c) 2022 Petr Vorel <[email protected]> TST_FORMAT_DEVICE=1 +TST_NEEDS_ROOT=1 TST_TESTFUNC=test TST_CNT=2 TST_DEV_FS_OPTS="-b 1024"lib/newlib_tests/shell/tst_mount_device.sh +1
-0@@ -3,6 +3,7 @@ # Copyright (c) 2022 Petr Vorel <[email protected]> TST_MOUNT_DEVICE=1 +TST_NEEDS_ROOT=1 TST_FS_TYPE=ext4 TST_TESTFUNC=test TST_CNT=3lib/newlib_tests/shell/tst_mount_device_tmpfs.sh +1
-0@@ -3,6 +3,7 @@ # Copyright (c) 2022 Petr Vorel <[email protected]> TST_MOUNT_DEVICE=1 +TST_NEEDS_ROOT=1 TST_FS_TYPE=tmpfs TST_TESTFUNC=testSignature · 1 line
2.37.3
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v5 02/10] shell API/tests: Require root for format/mount tests
Quoted 11 lines
Hi!
Quoted 6 lines
Although the warning is quite obvious:
tst_device.c:101: TINFO: Not allowed to open/dev/loop-control. Are you root?: EACCES (13) tst_device.c:140: TINFO: No free devices found
TBROK: Failed to acquire deviceIt's safer to expect root to get valid result.
Another option would actually be to make the
TST_NEED_DEVICEflag implyTST_NEEDS_ROOTflag, but I do not think that we have that for the C library either.
No, it does not imply in C API either. Yes, that would make sense for both API. But I'd keep it as it is now and I'll do this change after the release, Because I have other small fixes on API I'd like to post before the release.
BTW I always wondered why it was not done from the start, I thought there is a reason for that (i.e. some special user with approved permissions).
Quoted 3 lines
Either way this is fine as well:
Reviwed-by Cyril Hrubis <[email protected]>
Thanks!
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v5 02/10] shell API/tests: Require root for format/mount tests
Hi!
Quoted 10 lines
Quoted 10 lines
Quoted 6 lines
Although the warning is quite obvious:
tst_device.c:101: TINFO: Not allowed to open/dev/loop-control. Are you root?: EACCES (13) tst_device.c:140: TINFO: No free devices found
TBROK: Failed to acquire deviceIt's safer to expect root to get valid result.
Another option would actually be to make the
TST_NEED_DEVICEflag implyTST_NEEDS_ROOTflag, but I do not think that we have that for the C library either.
Quoted 6 lines
No, it does not imply in C API either. Yes, that would make sense for both API. But I'd keep it as it is now and I'll do this change after the release, Because I have other small fixes on API I'd like to post before the release.
BTW I always wondered why it was not done from the start, I thought there is a reason for that (i.e. some special user with approved permissions).
Well technically you can be added into whatever group is set to /dev/loop-control e.g. disk group and then you can create devices without a need to be a root.
So the most correct solution would be checking if we can access /dev/loop-control if tst_test.needs_device is set and if not we would imply needs_root. However this would need to be rethinked properly so that we do not end up creating something complex and not really required.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v5 02/10] shell API/tests: Require root for format/mount tests
Quoted 22 lines
Hi!
Quoted 10 lines
Quoted 10 lines
Quoted 6 lines
Although the warning is quite obvious:
tst_device.c:101: TINFO: Not allowed to open/dev/loop-control. Are you root?: EACCES (13) tst_device.c:140: TINFO: No free devices found
TBROK: Failed to acquire deviceIt's safer to expect root to get valid result.
Another option would actually be to make the
TST_NEED_DEVICEflag implyTST_NEEDS_ROOTflag, but I do not think that we have that for the C library either.Quoted 6 lines
No, it does not imply in C API either. Yes, that would make sense for both API. But I'd keep it as it is now and I'll do this change after the release, Because I have other small fixes on API I'd like to post before the release.
BTW I always wondered why it was not done from the start, I thought there is a reason for that (i.e. some special user with approved permissions).
Well technically you can be added into whatever group is set to
/dev/loop-controle.g. disk group and then you can create devices without a need to be a root.
Quoted 5 lines
So the most correct solution would be checking if we can access
/dev/loop-controlif tst_test.needs_device is set and if not we would implyneeds_root. However this would need to be rethinked properly so that we do not end up creating something complex and not really required.
Agree. I wonder if anybody tests with this setup.
I guess people just test with root (which is the reason why some tests have to switch to nobody).
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v5 02/10] shell API/tests: Require root for format/mount tests
In reply to Petr VorelHi all,
merged this and previous commit.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v5 3/10 tst_supported_fs: Print TCONF if no filesystem supported
In reply to Petr VorelAlthough this is unlikely, it can happen.
This means 32 (TCONF) instead of 0 exit code when searching for all filesystems and 32 instead of 1 when searching for a particular filesystem.
---
New in v5
NOTE:
Although this will later leads to duplicating message (see below) it's IMHO better because LVM scripts and zram01.sh use this helper directly.
Tests added in later commits which demonstrates TCONF:
# ./tst_skip_filesystems_skip.sh tst_supported_fs_types.c:90: TINFO: Kernel supports ext4 tst_supported_fs_types.c:52: TINFO: mkfs.ext4 does exist tst_supported_fs.c:88: TCONF: ext4 is skipped or not supported tst_skip_filesystems_skip 1 TCONF: ext4 is not supported
Summary:
passed 0 failed 0 broken 0 skipped 1
warnings 0
# ./tst_all_filesystems_skip.sh tst_device.c:89: TINFO: Found free device 0 '/dev/loop0' tst_supported_fs_types.c:173: TINFO: Skipping ext2 as requested by the test tst_supported_fs_types.c:173: TINFO: Skipping ext3 as requested by the test tst_supported_fs_types.c:173: TINFO: Skipping ext4 as requested by the test tst_supported_fs_types.c:173: TINFO: Skipping xfs as requested by the test tst_supported_fs_types.c:173: TINFO: Skipping btrfs as requested by the test tst_supported_fs_types.c:173: TINFO: Skipping vfat as requested by the test tst_supported_fs_types.c:173: TINFO: Skipping exfat as requested by the test tst_supported_fs_types.c:173: TINFO: Skipping ntfs as requested by the test tst_supported_fs_types.c:173: TINFO: Skipping tmpfs as requested by the test tst_supported_fs.c:96: TCONF: There are no supported filesystems or all skipped tst_all_filesystems_skip 1 TCONF: There are no supported filesystems or all skipped
Summary:
passed 0 failed 0 broken 0 skipped 1
warnings 0
testcases/lib/tst_supported_fs.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
testcases/lib/tst_supported_fs.c +13 -3
@@ -24,7 +24,7 @@ int main(int argc, char *argv[]) {const char *skiplist[] = {"tmpfs" ,NULL };const char *const *filesystems; -int i; +int i, ret;if (argc >2 ) {fprintf (stderr,"Can't specify multiple fs_type\n" );
@@ -37,10 +37,20 @@ int main(int argc, char *argv[])return 0 ; } -if (argv[1 ]) -return !tst_fs_is_supported (argv[1 ]); +if (argv[1 ]) { + ret =tst_fs_is_supported (argv[1 ]); + +if (ret ==TST_FS_UNSUPPORTED ) +tst_brk (TCONF ,"%s is not supported" , argv[optind]); + +return !ret; + } filesystems =tst_get_supported_fs_types (skiplist); + +if (!filesystems[0 ]) +tst_brk (TCONF ,"There are no supported filesystems" ); +for (i =0 ; filesystems[i]; i++)printf ("%s\n" , filesystems[i]);
Signature · 5 lines
2.37.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v5 03/10] tst_supported_fs: Print TCONF if no filesystem supported
Hi!
Quoted 9 lines
Although this is unlikely, it can happen.
This means 32 (TCONF) instead of 0 exit code when searching for all filesystems and 32 instead of 1 when searching for a particular filesystem.Signed-off-by Petr Vorel <[email protected]>---
New in v5
Quoted 6 lines
NOTE:
Although this will later leads to duplicating message (see below) it's IMHO better because LVM scripts and
zram01.shuse this helper directly.Tests added in later commits which demonstrates TCONF:
Shouldn't we rather than this add tst_res(TCONF, "...") messages to the lib/tst_supported_fs_types.c so that we get consistent messages between C and shell?
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v5 03/10] tst_supported_fs: Print TCONF if no filesystem supported
Quoted 12 lines
Hi!
Quoted 10 lines
Although this is unlikely, it can happen.
This means 32 (TCONF) instead of 0 exit code when searching for all filesystems and 32 instead of 1 when searching for a particular filesystem.Signed-off-by Petr Vorel <[email protected]>---
New in v5NOTE:
Quoted 8 lines
Quoted 4 lines
Although this will later leads to duplicating message (see below) it's IMHO better because LVM scripts and
zram01.shuse this helper directly.Tests added in later commits which demonstrates TCONF:
Shouldn't we rather than this add
tst_res(TCONF, "...")messages to thelib/tst_supported_fs_types.cso that we get consistent messages between C and shell?
Well, in v4 I add TCONF in tst_fs_is_supported_skiplist() (lib/tst_supported_fs_types.c), but you asked for TST_FS_UNSUPPORTED [1].
This function is used only in testcases/lib/tst_supported_fs.c, i.e. in shell. C API handles skip list in do_test_setup() (lib/tst_test.c). I don't like this inconsistency either, but not sure now how to put common code to lib/tst_supported_fs_types.c (new function).
There is also inconsistency in "There are no supported filesystems" (run_tcases_per_fs in lib/tst_test.c) and "There are no supported filesystems or all skipped" in testcases/lib/tst_supported_fs.c. I'm not sure if it's worth to add function tst_loop_per_fs (or macro in kernel style TST_FOR_EACH_FS()), so that check and TCONF would be on single place.
Kind regards,
Petr
[1] https://lore.kernel.org/ltp/YxsKz9j1mVHIhcfw@yuki/
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v5 03/10] tst_supported_fs: Print TCONF if no filesystem supported
Hi!
Quoted 6 lines
Quoted 3 lines
Shouldn't we rather than this add
tst_res(TCONF, "...")messages to thelib/tst_supported_fs_types.cso that we get consistent messages between C and shell?Well, in v4 I add TCONF in
tst_fs_is_supported_skiplist()(lib/tst_supported_fs_types.c), but you asked forTST_FS_UNSUPPORTED[1].
I guess that we misunderstand each other. I'm fine with the library printing messages, what I didn't like was the tst_brk() which made the whole program execution flow obscured.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v5 03/10] tst_supported_fs: Print TCONF if no filesystem supported
Quoted 11 lines
Hi!
Quoted 6 lines
Quoted 3 lines
Shouldn't we rather than this add
tst_res(TCONF, "...")messages to thelib/tst_supported_fs_types.cso that we get consistent messages between C and shell?Well, in v4 I add TCONF in
tst_fs_is_supported_skiplist()(lib/tst_supported_fs_types.c), but you asked forTST_FS_UNSUPPORTED[1].I guess that we misunderstand each other. I'm fine with the library printing messages, what I didn't like was the
tst_brk()which made the whole program execution flow obscured.
OK, instead of this from v4:
Review
Quoted 3 lines
(quoted diff) +3
-0+ if (tst_fs_in_skiplist(fs_type, skiplist)) { + tst_brk(TCONF, "%s is not supported by the test", + fs_type);
I'll add in v6:
Review
Quoted 5 lines
(quoted diff) +5
-0+ if (tst_fs_in_skiplist(fs_type, skiplist)) { + tst_res(TCONF, "%s is not supported by the test", + fs_type); + return TST_FS_UNSUPPORTED; + }
I'll add tst_res(TINFO, "%s is supported by the test", fs_name); from do_test_setup() tst_fs_is_supported_skiplist() and call tst_fs_is_supported_skiplist() in do_test_setup().
But not sure if there can be a cleanup of duplicity of:
if (!filesystems[0])
tst_brk(TCONF, "There are no supported filesystems")
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v5 03/10] tst_supported_fs: Print TCONF if no filesystem supported
Quoted 28 lines
Quoted 11 lines
Hi!
Quoted 6 lines
Quoted 3 lines
Shouldn't we rather than this add
tst_res(TCONF, "...")messages to thelib/tst_supported_fs_types.cso that we get consistent messages between C and shell?Well, in v4 I add TCONF in
tst_fs_is_supported_skiplist()(lib/tst_supported_fs_types.c), but you asked forTST_FS_UNSUPPORTED[1].I guess that we misunderstand each other. I'm fine with the library printing messages, what I didn't like was the
tst_brk()which made the whole program execution flow obscured.OK, instead of this from v4:
Review
Quoted 3 lines
(quoted diff) +3
-0+ if (tst_fs_in_skiplist(fs_type, skiplist)) { + tst_brk(TCONF, "%s is not supported by the test", + fs_type);I'll add in v6:
Review
Quoted 5 lines
(quoted diff) +5
-0+ if (tst_fs_in_skiplist(fs_type, skiplist)) { + tst_res(TCONF, "%s is not supported by the test", + fs_type); + return TST_FS_UNSUPPORTED; + }I'll add
tst_res(TINFO, "%s is supported by the test", fs_name); fromdo_test_setup()tst_fs_is_supported_skiplist()and calltst_fs_is_supported_skiplist()indo_test_setup().
Quoted 3 lines
But not sure if there can be a cleanup of duplicity of:
if (!filesystems[0])
tst_brk(TCONF, "There are no supported filesystems")
In order to unify the API I suggest to move the check above to tst_get_supported_fs_types() in lib/tst_supported_fs_types.c. This function is used only on lib/tst_test.c (and will be now in testcases/lib/tst_supported_fs.c) and uses static array fs_types. I see no point to add wrapper which would contain this check just to keep tst_get_supported_fs_types() without tst_brk().
@Cyril WDYT?
Kind regards,
Petr
Quoted 2 lines
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v5 4/10 tst_supported_fs: Implement skip list
In reply to Petr Vorelas it will be needed for $ALL_FILESYSTEMS shell implementation in the next commit. Pass tmpfs to LVM scripts (as it was required there).
---
changes v4->v5:
* testcases/lib/tst_supported_fs.c: put parsing code to separate function parse_skiplist() (Cyril)
testcases/lib/tst_supported_fs.c | 65 ++++++++++++++++++---- testcases/misc/lvm/generate_lvm_runfile.sh | 2 +- testcases/misc/lvm/prepare_lvm.sh | 2 +- 3 files changed, 56 insertions(+), 13 deletions(-)
testcases/lib/tst_supported_fs.c +54 -11
@@ -5,40 +5,83 @@*/ #include <stdio.h> +#include <stdlib.h> #include <string.h> +#define SKIP_DELIMITER ',' +#define TST_NO_DEFAULT_MAIN #include "tst_test.h" #include "tst_fs.h" static void usage (void ) { -fprintf (stderr,"Usage: tst_supported_fs [fs_type]\n" ); +fprintf (stderr,"Usage: tst_supported_fs [-s skip_list] [fs_type]\n" );fprintf (stderr," If fs_type is supported, return 0\n" );fprintf (stderr," If fs_type isn't supported, return 1\n" );fprintf (stderr," If fs_type isn't specified, print the list of supported filesystems\n" );fprintf (stderr," fs_type - a specified filesystem type\n" ); +fprintf (stderr," skip_list - filesystems to skip, delimiter: '%c'\n" , +SKIP_DELIMITER ); +} + +static char **parse_skiplist (char *fs) +{ +char **skiplist =NULL ; +int i, cnt =1 ; + +for (i =0 ; fs[i]; i++) { +if (optarg[i] ==SKIP_DELIMITER ) + cnt++; + } + + skiplist =malloc (++cnt *sizeof (char *)); +if (!skiplist) { +fprintf (stderr,"malloc() failed\n" ); +return NULL ; + } + +for (i =0 ; i < cnt; i++) + skiplist[i] =strtok_r (fs,TST_TO_STR (SKIP_DELIMITER ), &fs); + +return skiplist; }int main (int argc,char *argv[]) { -const char *skiplist[] = {"tmpfs" ,NULL };const char *const *filesystems;int i, ret; +char **skiplist =NULL ; -if (argc >2 ) { -fprintf (stderr,"Can't specify multiple fs_type\n" ); -usage (); -return 2 ; +while ((ret =getopt (argc, argv,"hs:" ))) { +if (ret <0 ) +break ; + +switch (ret) { +case '?' : +usage (); +return 1 ; + +case 'h' : +usage (); +return 0 ; + +case 's' : + skiplist =parse_skiplist (optarg); +if (!skiplist) +return 1 ; +break ; + } } -if (argv[1 ] && !strcmp (argv[1 ],"-h" )) { +if (argc - optind >1 ) { +fprintf (stderr,"Can't specify multiple fs_type\n" );usage (); -return 0 ; +return 2 ; } -if (argv[1 ]) { - ret =tst_fs_is_supported (argv[1 ]); +if (optind < argc) { + ret =tst_fs_is_supported (argv[optind]);if (ret ==TST_FS_UNSUPPORTED )tst_brk (TCONF ,"%s is not supported" , argv[optind]);
@@ -46,7 +89,7 @@ int main(int argc, char *argv[])return !ret; } - filesystems =tst_get_supported_fs_types (skiplist); + filesystems =tst_get_supported_fs_types ((const char *const *)skiplist);if (!filesystems[0 ])tst_brk (TCONF ,"There are no supported filesystems" );
testcases/misc/lvm/generate_lvm_runfile.sh +1 -1
@@ -17,7 +17,7 @@ generate_runfile() trap '[ $? -eq 0 ] || tst_brk TBROK "Cannot create LVM runfile"' EXIT INFILE="$LTPROOT/testcases/data/lvm/runfile.tpl" OUTFILE="$LTPROOT/runtest/lvm.local" - FS_LIST=`tst_supported_fs` + FS_LIST=$(tst_supported_fs -s tmpfs) echo -n "" >"$OUTFILE" for fsname in $FS_LIST; do
testcases/misc/lvm/prepare_lvm.sh +1 -1
@@ -70,7 +70,7 @@ prepare_mounts() prepare_lvm() { - FS_LIST=`tst_supported_fs | sort -u` + FS_LIST=$(tst_supported_fs -s tmpfs | sort -u) ROD mkdir -p "$LVM_TMPDIR" ROD mkdir -p "$LVM_IMGDIR" chmod 777 "$LVM_TMPDIR"
Signature · 5 lines
2.37.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v5 04/10] tst_supported_fs: Implement skip list
Hi!
testcases/lib/tst_supported_fs.c line 30
Quoted 3 lines
testcases/lib/tst_supported_fs.c +3
-0+static char **parse_skiplist (char *fs) +{ +char **skiplist =NULL ;
There is no point in initializing variables that are not read before they are assigned.
Other than that:
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v5 04/10] tst_supported_fs: Implement skip list
Quoted 7 lines
Hi!
testcases/lib/tst_supported_fs.c line 30
Quoted 3 lines
testcases/lib/tst_supported_fs.c +3
-0+static char **parse_skiplist (char *fs) +{ +char **skiplist =NULL ;There is no point in initializing variables that are not read before they are assigned.
Good catch, thanks!
I'll fix it in next version or before pushing.
Kind regards,
Petr
Quoted 3 lines
Other than that:
Reviewed-by Cyril Hrubis <[email protected]>
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v5 5/10 tst_supported_fs: Support skip list when query single fs
In reply to Petr VorelAnd use this feature in zram01.sh
---
changes v4->v5:
* tst_fs_is_supported_skiplist() returns TST_FS_UNSUPPORTED, errors handled in testcases/lib/tst_supported_fs.c (Cyril)
* testcases/lib/tst_supported_fs.c: put parsing code to separate function parse_skiplist() (Cyril)
* testcases/lib/tst_supported_fs.c: Print usage on getopts error (Cyril)
* zram01.sh: use -f tmpfs in tst_supported_fs call
include/tst_fs.h | 10 ++++++++++ lib/tst_supported_fs_types.c | 16 ++++++++++++++++ testcases/kernel/device-drivers/zram/zram01.sh | 3 +-- testcases/lib/tst_supported_fs.c | 7 ++++--- 4 files changed, 31 insertions(+), 5 deletions(-)
include/tst_fs.h +10 -0
@@ -183,6 +183,16 @@ enum tst_fs_impl {*/ enum tst_fs_impl tst_fs_is_supported (const char *fs_type); +/* +* Check filesystem support (@see tst_fs_is_supported()), but consider also +* filesystems to skip. +* +* @fs_type A filesystem name to check the support for. +* @skiplist A NULL terminated array of filesystems to skip. +*/ +enum tst_fs_impl tst_fs_is_supported_skiplist (const char *fs_type,const char + *const *skiplist); +/* * Returns NULL-terminated array of kernel-supported filesystems. *
lib/tst_supported_fs_types.c +16 -0
@@ -134,6 +134,22 @@ enum tst_fs_impl tst_fs_is_supported(const char *fs_type)return TST_FS_UNSUPPORTED ; } +enum tst_fs_impl tst_fs_is_supported_skiplist (const char *fs_type,const char + *const *skiplist) +{ +int ret; + + ret =tst_fs_is_supported (fs_type); + +if (!ret) +return ret; + +if (tst_fs_in_skiplist (fs_type, skiplist)) +return TST_FS_UNSUPPORTED ; + +return ret; +} +const char **tst_get_supported_fs_types (const char *const *skiplist) {unsigned int i, j =0 ;
testcases/kernel/device-drivers/zram/zram01.sh +1 -2
@@ -38,8 +38,7 @@ initialize_vars() local fs limit size stream=-1 dev_num=0 - for fs in $(tst_supported_fs); do - [ "$fs" = "tmpfs" ] && continue + for fs in $(tst_supported_fs -s tmpfs); do size="26214400" limit="25M" if [ "$fs" = "btrfs" ]; then
testcases/lib/tst_supported_fs.c +4 -3
@@ -81,10 +81,11 @@ int main(int argc, char *argv[]) }if (optind < argc) { - ret =tst_fs_is_supported (argv[optind]); + ret =tst_fs_is_supported_skiplist (argv[optind], + (const char *const *)skiplist);if (ret ==TST_FS_UNSUPPORTED ) -tst_brk (TCONF ,"%s is not supported" , argv[optind]); +tst_brk (TCONF ,"%s is skipped or not supported" , argv[optind]);return !ret; }
@@ -92,7 +93,7 @@ int main(int argc, char *argv[]) filesystems =tst_get_supported_fs_types ((const char *const *)skiplist);if (!filesystems[0 ]) -tst_brk (TCONF ,"There are no supported filesystems" ); +tst_brk (TCONF ,"There are no supported filesystems or all skipped" );for (i =0 ; filesystems[i]; i++)printf ("%s\n" , filesystems[i]);
Signature · 5 lines
2.37.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v5 05/10] tst_supported_fs: Support skip list when query single fs
Hi all,
thread for v4 [1] [2] should have been for v5.
Therefore repeat here there will be diff below:
FYI if anybody wants to test v5 with this fix, it's in my fork in branch shell/all_filesystems.v5.fixes [3]
Kind regards,
Petr
[1] https://lore.kernel.org/ltp/[email protected]/
[2] https://lore.kernel.org/ltp/Yx7GPOsudkoRn5Nd@pevik/
[3] https://github.com/pevik/ltp/commits/shell/all_filesystems.v5.fixes
tst_supported_fs_types.c +1 -8
@@ -138,17 +138,10 @@ enum tst_fs_impl tst_fs_is_supported(const char *fs_type)enum tst_fs_impl tst_fs_is_supported_skiplist (const char *fs_type,const char *const *skiplist) { -int ret; - - ret =tst_fs_is_supported (fs_type); - -if (!ret) -return ret; -if (tst_fs_in_skiplist (fs_type, skiplist))return TST_FS_UNSUPPORTED ; -return ret; +return tst_fs_is_supported (fs_type); }const char **tst_get_supported_fs_types (const char *const *skiplist)
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v5 05/10] tst_supported_fs: Support skip list when query single fs
In reply to Petr VorelHi!
Shouldn't this one go before the addition of the functionality to the wrapper used by shell?
Other than that:
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v5 05/10] tst_supported_fs: Support skip list when query single fs
Quoted 2 lines
Hi!
Shouldn't this one go before the addition of the functionality to the wrapper used by shell?
Do you mean to put this ("tst_supported_fs: Support skip list when query single fs") before the previous ("tst_supported_fs: Implement skip list")?
Originally I had these 2 commits in squashed in single commit. But it was quite big, thus I implemented skip list just for all filesystems and then for particular filesystem.
Maybe "tst_supported_fs: Implement skip list" should be "tst_supported_fs:
Implement skip list for all fs".
Or did you mean something else?
Kind regards,
Petr
Quoted 3 lines
Other than that:
Reviewed-by Cyril Hrubis <[email protected]>
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v5 05/10] tst_supported_fs: Support skip list when query single fs
Hi!
Quoted 3 lines
Quoted 1 line
Shouldn't this one go before the addition of the functionality to the wrapper used by shell?
Do you mean to put this ("
tst_supported_fs: Support skip list when query single fs") before the previous ("tst_supported_fs: Implement skip list")?
Yes, as far as I can tell this commit implement function that is called from the previous patch.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v5 05/10] tst_supported_fs: Support skip list when query single fs
Quoted 7 lines
Hi!
Quoted 3 lines
Quoted 1 line
Shouldn't this one go before the addition of the functionality to the wrapper used by shell?
Do you mean to put this ("
tst_supported_fs: Support skip list when query single fs") before the previous ("tst_supported_fs: Implement skip list")?Yes, as far as I can tell this commit implement function that is called from the previous patch.
I'm really slow on this. Which function do you mean please?
"[v5,05/10] tst_supported_fs: Support skip list when query single fs" implements just tst_fs_is_supported_skiplist() which is not used in "[v5,04/10]tst_supported_fs: Implement skip list".
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v5 05/10] tst_supported_fs: Support skip list when query single fs
Hi!
Quoted 7 lines
Quoted 2 lines
Yes, as far as I can tell this commit implement function that is called from the previous patch.
I'm really slow on this. Which function do you mean please?
"[v5,05/10]
tst_supported_fs: Support skip list when query single fs" implements justtst_fs_is_supported_skiplist()which is not used in "[v5,04/10]tst_supported_fs: Implement skip list".
My bad, I confused the tst_fs_is_suppored() andtst_fs_is_supported_skiplist() yesterday.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v5 05/10] tst_supported_fs: Support skip list when query single fs
In reply to Petr VorelHi,
there are 2 errors, 2) needs more thinking.
Quoted 1 line
And use this feature in
zram01.sh
1) zram01.sh check in "all_filesystem" mode, thus it should not be changed here, but in the separate commit.
Quoted 18 lines
include/tst_fs.h +10
-0+/* +* Check filesystem support (@see tst_fs_is_supported()), but consider also +* filesystems to skip. +* +* @fs_type A filesystem name to check the support for. +* @skiplist A NULL terminated array of filesystems to skip. +*/ +enum tst_fs_impl tst_fs_is_supported_skiplist (const char *fs_type,const char + *const *skiplist); +/* * Returns NULL-terminated array of kernel-supported filesystems. * lib/tst_supported_fs_types.c +0
-0
lib/tst_supported_fs_types.c enum tst_fs_impl tst_fs_is_supported(const char *fs_type) · line 142
Quoted 9 lines
lib/tst_supported_fs_types.c +6
-0@@ -134,6 +134,22 @@ enum tst_fs_impl tst_fs_is_supported(const char *fs_type)return TST_FS_UNSUPPORTED ; } +enum tst_fs_impl tst_fs_is_supported_skiplist (const char *fs_type,const char + *const *skiplist) +{ +int ret; + + ret =tst_fs_is_supported (fs_type);
2) while this function might be useful in the future, now it's not what is needed... Because for single filesystem does not need check for mkfs.foo.
lib/tst_supported_fs_types.c enum tst_fs_impl tst_fs_is_supported(const char *fs_type) · line 151
Quoted 9 lines
lib/tst_supported_fs_types.c +9
-0+ +if (!ret) +return ret; + +if (tst_fs_in_skiplist (fs_type, skiplist)) +return TST_FS_UNSUPPORTED ; + +return ret; +}
There should be new function with code moved from do_test_setup():
void tst_fs_is_current_fs_supported(const char *fs_name, const char *const *skiplist)
{
if (tst_fs_in_skiplist(fs_name, skiplist))
tst_brk(TCONF, "%s is not supported by the test", fs_name);
tst_res(TINFO, "%s is supported by the test", fs_name);
}I know you want tst_res(TCONF) in the library, that means I'd have to call tst_vbrk_(), right? Because we have message already printed. Maybe different function prefix could help.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v5 6/10 shell: Add $TST_SKIP_FILESYSTEMS + tests
In reply to Petr VorelC API struct tst_test skip_filesystems member equivalent.
Now only running on single filesystem (will be improved in the next commit)
---
changes v4->v5:
* add fuse to lib/newlib_tests/shell/tst_skip_filesystems.sh
doc/shell-test-api.txt | 2 ++ .../shell/tst_skip_filesystems.sh | 35 +++++++++++++++++++ .../shell/tst_skip_filesystems_skip.sh | 17 +++++++++ lib/tst_supported_fs_types.c | 1 + testcases/lib/tst_test.sh | 6 ++++ 5 files changed, 61 insertions(+) create mode 100755 lib/newlib_tests/shell/tst_skip_filesystems.sh create mode 100755 lib/newlib_tests/shell/tst_skip_filesystems_skip.sh
doc/shell-test-api.txt +2 -0
@@ -229,6 +229,8 @@ simply by setting right '$TST_FOO'. | 'TST_NEEDS_KCONFIGS' | Checks kernel kconfigs support for the test (see below). | 'TST_NEEDS_KCONFIGS_IFS' | Used for splitting '$TST_NEEDS_KCONFIGS' variable, default value is comma, it only supports single character. +| 'TST_SKIP_FILESYSTEMS' | Comma separated list of filesystems on which test will be skipped + (tst_test.skip_filesystems equivalent). | 'TST_TIMEOUT' | Maximum timeout set for the test in sec. Must be int >= 1, or -1 (special value to disable timeout), default is 300. Variable is meant be set in tests, not by user.
lib/newlib_tests/shell/tst_skip_filesystems.sh new file +35 -0
@@ -0,0 +1,35 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022 Petr Vorel <[email protected]> + +TST_MOUNT_DEVICE=1 +TST_NEEDS_ROOT=1 +TST_FS_TYPE=ext4 +TST_TESTFUNC=test +TST_SKIP_FILESYSTEMS="btrfs,exfat,ext2,ext3,fuse,ntfs,vfat,tmpfs,xfs" +TST_CNT=3 + +test1() +{ + EXPECT_PASS "cd $TST_MNTPOINT" +} + +test2() +{ + EXPECT_PASS "grep '$TST_MNTPOINT $TST_FS_TYPE' /proc/mounts" +} + +test3() +{ + local fs fs_skip + + fs=$(grep "$TST_MNTPOINT $TST_FS_TYPE" /proc/mounts | cut -d ' ' -f3) + EXPECT_PASS "[ '$fs' = '$TST_FS_TYPE' ]" + + for fs_skip in $TST_SKIP_FILESYSTEMS; do + EXPECT_FAIL "[ $fs = $fs_skip ]" + done +} + +. tst_test.sh +tst_run
lib/newlib_tests/shell/tst_skip_filesystems_skip.sh new file +17 -0
@@ -0,0 +1,17 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022 Petr Vorel <[email protected]> + +TST_MOUNT_DEVICE=1 +TST_NEEDS_ROOT=1 +TST_FS_TYPE=ext4 +TST_TESTFUNC=test +TST_SKIP_FILESYSTEMS="ext4" + +test() +{ + tst_res TFAIL "test should be skipped with TCONF" +} + +. tst_test.sh +tst_run
lib/tst_supported_fs_types.c +1 -0
@@ -14,6 +14,7 @@#include "tst_test.h" #include "tst_fs.h" +/* NOTE: new filesystem should be also added to tst_skip_filesystems.sh */ static const char *const fs_type_whitelist[] = {"ext2" ,"ext3" ,
testcases/lib/tst_test.sh +6 -0
@@ -626,6 +626,7 @@ tst_run() local _tst_max local _tst_name local _tst_pattern='[='\''"} \t\/:`$\;].*' + local ret if [ -n "$TST_TEST_PATH" ]; then for _tst_i in $(grep '^[^#]*\bTST_' "$TST_TEST_PATH" | sed "s/.*TST_//; s/$_tst_pattern//"); do
@@ -644,6 +645,7 @@ tst_run() CHECKPOINT_WAIT|CHECKPOINT_WAKE);; CHECKPOINT_WAKE2|CHECKPOINT_WAKE_AND_WAIT);; DEV_EXTRA_OPTS|DEV_FS_OPTS|FORMAT_DEVICE|MOUNT_DEVICE);; + SKIP_FILESYSTEMS);; *) tst_res TWARN "Reserved variable TST_$_tst_i used!";; esac done
@@ -675,6 +677,10 @@ tst_run() tst_brk TCONF "test requires kernel $TST_MIN_KVER+" fi + tst_supported_fs -s "$TST_SKIP_FILESYSTEMS" $TST_FS_TYPE + ret=$? + [ $ret -ne 0 ] && return $ret + _tst_setup_timer [ "$TST_MOUNT_DEVICE" = 1 ] && TST_FORMAT_DEVICE=1
Signature · 5 lines
2.37.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v5 06/10] shell: Add $TST_SKIP_FILESYSTEMS + tests
Hi!
Quoted 131 lines
C API struct
tst_testskip_filesystemsmember equivalent.Now only running on single filesystem (will be improved in the next commit)
Reviewed-by Li Wang <[email protected]>Signed-off-by Petr Vorel <[email protected]>---
changesv4->v5:
* add fuse tolib/newlib_tests/shell/tst_skip_filesystems.shdoc/shell-test-api.txt | 2 ++ .../shell/tst_skip_filesystems.sh | 35 +++++++++++++++++++ .../shell/tst_skip_filesystems_skip.sh | 17 +++++++++ lib/tst_supported_fs_types.c | 1 + testcases/lib/tst_test.sh | 6 ++++ 5 files changed, 61 insertions(+) create mode 100755 lib/newlib_tests/shell/tst_skip_filesystems.sh create mode 100755 lib/newlib_tests/shell/tst_skip_filesystems_skip.shdoc/shell-test-api.txt +2
-0@@ -229,6 +229,8 @@ simply by setting right '$TST_FOO'. | 'TST_NEEDS_KCONFIGS' | Checks kernel kconfigs support for the test (see below). | 'TST_NEEDS_KCONFIGS_IFS' | Used for splitting '$TST_NEEDS_KCONFIGS' variable, default value is comma, it only supports single character. +| 'TST_SKIP_FILESYSTEMS' | Comma separated list of filesystems on which test will be skipped + (tst_test.skip_filesystems equivalent). | 'TST_TIMEOUT' | Maximum timeout set for the test in sec. Must be int >= 1, or -1 (special value to disable timeout), default is 300. Variable is meant be set in tests, not by user.lib/newlib_tests/shell/tst_skip_filesystems.sh new file +35
-0@@ -0,0 +1,35 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022 Petr Vorel <[email protected]> + +TST_MOUNT_DEVICE=1 +TST_NEEDS_ROOT=1 +TST_FS_TYPE=ext4 +TST_TESTFUNC=test +TST_SKIP_FILESYSTEMS="btrfs,exfat,ext2,ext3,fuse,ntfs,vfat,tmpfs,xfs" +TST_CNT=3 + +test1() +{ + EXPECT_PASS "cd $TST_MNTPOINT" +} + +test2() +{ + EXPECT_PASS "grep '$TST_MNTPOINT $TST_FS_TYPE' /proc/mounts" +} + +test3() +{ + local fs fs_skip + + fs=$(grep "$TST_MNTPOINT $TST_FS_TYPE" /proc/mounts | cut -d ' ' -f3) + EXPECT_PASS "[ '$fs' = '$TST_FS_TYPE' ]" + + for fs_skip in $TST_SKIP_FILESYSTEMS; do + EXPECT_FAIL "[ $fs = $fs_skip ]" + done +} + +. tst_test.sh +tst_runlib/newlib_tests/shell/tst_skip_filesystems_skip.sh new file +17
-0@@ -0,0 +1,17 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022 Petr Vorel <[email protected]> + +TST_MOUNT_DEVICE=1 +TST_NEEDS_ROOT=1 +TST_FS_TYPE=ext4 +TST_TESTFUNC=test +TST_SKIP_FILESYSTEMS="ext4" + +test() +{ + tst_res TFAIL "test should be skipped with TCONF" +} + +. tst_test.sh +tst_runlib/tst_supported_fs_types.c +1
-0@@ -14,6 +14,7 @@#include "tst_test.h" #include "tst_fs.h" +/* NOTE: new filesystem should be also added to tst_skip_filesystems.sh */ static const char *const fs_type_whitelist[] = {"ext2" ,"ext3" ,testcases/lib/tst_test.sh +2
-0@@ -626,6 +626,7 @@ tst_run() local _tst_max local _tst_name local _tst_pattern='[='\''"} \t\/:`$\;].*' + local ret if [ -n "$TST_TEST_PATH" ]; then for _tst_i in $(grep '^[^#]*\bTST_' "$TST_TEST_PATH" | sed "s/.*TST_//; s/$_tst_pattern//"); do@@ -644,6 +645,7 @@ tst_run() CHECKPOINT_WAIT|CHECKPOINT_WAKE);; CHECKPOINT_WAKE2|CHECKPOINT_WAKE_AND_WAIT);; DEV_EXTRA_OPTS|DEV_FS_OPTS|FORMAT_DEVICE|MOUNT_DEVICE);; + SKIP_FILESYSTEMS);; *) tst_res TWARN "Reserved variable TST_$_tst_i used!";; esac done
testcases/lib/tst_test.sh tst_run() · line 682
Quoted 6 lines
testcases/lib/tst_test.sh +3
-0@@ -675,6 +677,10 @@ tst_run() tst_brk TCONF "test requires kernel $TST_MIN_KVER+" fi + tst_supported_fs -s "$TST_SKIP_FILESYSTEMS" $TST_FS_TYPE + ret=$? + [ $ret -ne 0 ] && return $ret
So we actually depend here on the tst_supported_fs return value. So at least we have to do return TCONF in the helper binary even if ve move the messages into the library.
Quoted 6 lines
testcases/lib/tst_test.sh +0
-0_tst_setup_timer [ "$TST_MOUNT_DEVICE" = 1 ] && TST_FORMAT_DEVICE=1Signature · 1 line
2.37.3
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v5 06/10] shell: Add $TST_SKIP_FILESYSTEMS + tests
...
Quoted 21 lines
Quoted 20 lines
+++
b/testcases/lib/tst_test.shtestcases/lib/tst_test.sh +2
-0@@ -626,6 +626,7 @@ tst_run() local _tst_max local _tst_name local _tst_pattern='[='\''"} \t\/:`$\;].*' + local ret if [ -n "$TST_TEST_PATH" ]; then for _tst_i in $(grep '^[^#]*\bTST_' "$TST_TEST_PATH" | sed "s/.*TST_//; s/$_tst_pattern//"); do@@ -644,6 +645,7 @@ tst_run() CHECKPOINT_WAIT|CHECKPOINT_WAKE);; CHECKPOINT_WAKE2|CHECKPOINT_WAKE_AND_WAIT);; DEV_EXTRA_OPTS|DEV_FS_OPTS|FORMAT_DEVICE|MOUNT_DEVICE);; + SKIP_FILESYSTEMS);; *) tst_res TWARN "Reserved variable TST_$_tst_i used!";; esac done@@ -675,6 +677,10 @@ tst_run() tst_brk TCONF "test requires kernel $TST_MIN_KVER+" fi
Quoted 7 lines
testcases/lib/tst_test.sh tst_run() · line 682
Quoted 3 lines
testcases/lib/tst_test.sh +3
-0+ tst_supported_fs -s "$TST_SKIP_FILESYSTEMS" $TST_FS_TYPE + ret=$? + [ $ret -ne 0 ] && return $retSo we actually depend here on the
tst_supported_fsreturn value. So at least we have to do return TCONF in the helper binary even if ve move the messages into the library.
Yes. This is the equivalent of code in do_test_setup() (i.e. handling skipped filesystems when testing single filesystem - *not* doing all filesystems loop).
Again, have C API function for looping filesystems and for single filesystem would help avoiding duplicity, but not sure how to keep things simple and readable. I'll try to think about it, but hints are welcome :).
Kind regards,
Petr
Quoted 5 lines
Quoted 5 lines
testcases/lib/tst_test.sh +0
-0_tst_setup_timer [ "$TST_MOUNT_DEVICE" = 1 ] && TST_FORMAT_DEVICE=1Signature · 1 line
2.37.3
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v5 7/10 tst_test.sh: Introduce TST_FS_TYPE_FUSE
In reply to Petr VorelUseful if tests need to grep on mount output (there is fuseblk instead of expected filesystem).
--- doc/shell-test-api.txt | 2 ++ testcases/lib/tst_test.sh | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-)
doc/shell-test-api.txt +2 -0
@@ -210,6 +210,8 @@ simply by setting right '$TST_FOO'. | 'TST_DEVICE' | Block device name for 'tst_mount' and 'tst_mkfs', see https://github.com/linux-test-project/ltp/wiki/Shell-Test-API#formatting-device-with-a-filesystem[Formatting device with a filesystem]. | 'TST_FS_TYPE' | Override the default filesystem to be used. +| 'TST_FS_TYPE_FUSE' | 1 if mounted 'TST_FS_TYPE' filesystem on + 'TST_DEVICE' device is FUSE. | 'TST_MNTPOINT' | Holds path to mountpoint used in 'tst_mount', see https://github.com/linux-test-project/ltp/wiki/Shell-Test-API#formatting-device-with-a-filesystem[Formatting device with a filesystem]. | 'TST_MNT_PARAMS' | Extra mount params for 'tst_mount', see
testcases/lib/tst_test.sh +13 -1
@@ -307,6 +307,18 @@ tst_mount() if [ $ret -ne 0 ]; then tst_brk TBROK "Failed to mount device${mnt_err}: mount exit = $ret" fi + + mnt_real="$(grep -E "$TST_MNTPOINT ($TST_FS_TYPE|fuseblk)" /proc/mounts | awk 'NR==1{print $3}')" + case $mnt_real in + '') tst_brk TBROK 'Failed to found filesystem type in /proc/mounts';; + 'fuseblk') TST_FS_TYPE_FUSE=1;; + *) + if [ "$mnt_real" != "$TST_FS_TYPE" ]; then + tst_brk TBROK "$mnt_real: unsupported type in /proc/mounts" + fi + TST_FS_TYPE_FUSE= + ;; + esac } tst_umount()
@@ -636,7 +648,7 @@ tst_run() OPTS|USAGE|PARSE_ARGS|POS_ARGS);; NEEDS_ROOT|NEEDS_TMPDIR|TMPDIR|NEEDS_DEVICE|DEVICE);; NEEDS_CMDS|NEEDS_MODULE|MODPATH|DATAROOT);; - NEEDS_DRIVERS|FS_TYPE|MNTPOINT|MNT_PARAMS);; + NEEDS_DRIVERS|FS_TYPE|FS_TYPE_FUSE|MNTPOINT|MNT_PARAMS);; NEEDS_KCONFIGS|NEEDS_KCONFIGS_IFS);; IPV6|IPV6_FLAG|IPVER|TEST_DATA|TEST_DATA_IFS);; RETRY_FUNC|RETRY_FN_EXP_BACKOFF|TIMEOUT);;
Signature · 5 lines
2.37.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v5 07/10] tst_test.sh: Introduce TST_FS_TYPE_FUSE
Hi!
Quoted 7 lines
testcases/lib/tst_test.sh +3
-0@@ -307,6 +307,18 @@ tst_mount() if [ $ret -ne 0 ]; then tst_brk TBROK "Failed to mount device${mnt_err}: mount exit = $ret" fi + + mnt_real="$(grep -E "$TST_MNTPOINT ($TST_FS_TYPE|fuseblk)" /proc/mounts | awk 'NR==1{print $3}')" + case $mnt_real in
testcases/lib/tst_test.sh tst_mount() · line 322
Quoted 10 lines
testcases/lib/tst_test.sh +9
-0+ '') tst_brk TBROK 'Failed to found filesystem type in /proc/mounts';; + 'fuseblk') TST_FS_TYPE_FUSE=1;; + *) + if [ "$mnt_real" != "$TST_FS_TYPE" ]; then + tst_brk TBROK "$mnt_real: unsupported type in /proc/mounts" + fi + TST_FS_TYPE_FUSE= + ;; + esac }
I just wonder if this is worth being added to the test library just for a single test. Or do you expect this to be usable in more than df01.sh?
Also maybe it would be a better as a function so that the code does not run unconditionally on each tst_mount() call?
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v5 07/10] tst_test.sh: Introduce TST_FS_TYPE_FUSE
Quoted 13 lines
Hi!
Quoted 12 lines
testcases/lib/tst_test.sh +8
-0@@ -307,6 +307,18 @@ tst_mount() if [ $ret -ne 0 ]; then tst_brk TBROK "Failed to mount device${mnt_err}: mount exit = $ret" fi + + mnt_real="$(grep -E "$TST_MNTPOINT ($TST_FS_TYPE|fuseblk)" /proc/mounts | awk 'NR==1{print $3}')" + case $mnt_real in + '') tst_brk TBROK 'Failed to found filesystem type in /proc/mounts';; + 'fuseblk') TST_FS_TYPE_FUSE=1;; + *) + if [ "$mnt_real" != "$TST_FS_TYPE" ]; then + tst_brk TBROK "$mnt_real: unsupported type in /proc/mounts"
Quoted 8 lines
testcases/lib/tst_test.sh tst_mount() · line 322
Quoted 5 lines
testcases/lib/tst_test.sh +4
-0+ fi + TST_FS_TYPE_FUSE= + ;; + esac }I just wonder if this is worth being added to the test library just for a single test. Or do you expect this to be usable in more than
df01.sh?
Well, the inspiration was the C API, which also allows to skip fuse. But sure, I can handle it just in df01.sh, just let me know the result.
Quoted 2 lines
Also maybe it would be a better as a function so that the code does not run unconditionally on each
tst_mount()call?
Do you mean e.g. tst_is_fuse() and df01.sh would call it?
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v5 07/10] tst_test.sh: Introduce TST_FS_TYPE_FUSE
Hi!
Quoted 3 lines
Quoted 2 lines
Also maybe it would be a better as a function so that the code does not run unconditionally on each
tst_mount()call?Do you mean e.g.
tst_is_fuse()anddf01.shwould call it?
Yes that looks slightly cleaner than adding another variable.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v5 07/10] tst_test.sh: Introduce TST_FS_TYPE_FUSE
Quoted 6 lines
Hi!
Quoted 3 lines
Quoted 2 lines
Also maybe it would be a better as a function so that the code does not run unconditionally on each
tst_mount()call?Do you mean e.g.
tst_is_fuse()anddf01.shwould call it?Yes that looks slightly cleaner than adding another variable.
OK, I'll fix it in v7. I put it into tst_test.sh, but if you prefer to have this function just in df01.sh (called as is_fuse) until anything else needs it that would work for me as well.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v5 07/10] tst_test.sh: Introduce TST_FS_TYPE_FUSE
In reply to Cyril HrubisQuoted 6 lines
Hi!
Quoted 3 lines
Quoted 2 lines
Also maybe it would be a better as a function so that the code does not run unconditionally on each
tst_mount()call?Do you mean e.g.
tst_is_fuse()anddf01.shwould call it?Yes that looks slightly cleaner than adding another variable.
In the end I add custom code to df01.sh, that's really better until some other test needs to detects fuse.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v5 8/10 tst_test.sh: Add $TST_ALL_FILESYSTEMS
In reply to Petr Vorel$TST_ALL_FILESYSTEMS is shell API equivalent of .all_filesystems from C API.
Improve also $TST_SKIP_FILESYSTEMS to behave like .skip_filesystems.
---
changes v4->v5:
* tst_test.sh: fix quiting test when no filesystem supported
doc/shell-test-api.txt | 9 ++- testcases/lib/tst_test.sh | 139 +++++++++++++++++++++++++------------- 2 files changed, 101 insertions(+), 47 deletions(-)
doc/shell-test-api.txt +8 -1
@@ -199,6 +199,10 @@ simply by setting right '$TST_FOO'. [options="header"] |============================================================================= | Variable name | Action done +| 'TST_ALL_FILESYSTEMS' | Testing on all available filesystems + ('tst_test.all_filesystems' equivalent). + When 'TST_SKIP_FILESYSTEMS' any listed filesystem is not + included in the resulting list of supported filesystems. | 'TST_DEV_EXTRA_OPTS' | Pass extra 'mkfs' options _after_ device name, to 'tst_mkfs', use with 'TST_FORMAT_DEVICE=1'. | 'TST_DEV_FS_OPTS' | Pass 'mkfs' options _before_ the device name,
@@ -209,7 +213,10 @@ simply by setting right '$TST_FOO'. Implies 'TST_NEEDS_DEVICE=1' (no need to set it). | 'TST_DEVICE' | Block device name for 'tst_mount' and 'tst_mkfs', see https://github.com/linux-test-project/ltp/wiki/Shell-Test-API#formatting-device-with-a-filesystem[Formatting device with a filesystem]. -| 'TST_FS_TYPE' | Override the default filesystem to be used. +| 'TST_FS_TYPE' | Override the default filesystem to be used. Also + contains currently used filesystem during looping + filesystems in 'TST_ALL_FILESYSTEMS=1' + ('tst_device->fs_type' equivalent). | 'TST_FS_TYPE_FUSE' | 1 if mounted 'TST_FS_TYPE' filesystem on 'TST_DEVICE' device is FUSE. | 'TST_MNTPOINT' | Holds path to mountpoint used in 'tst_mount', see
testcases/lib/tst_test.sh +93 -46
221 lines not on this page · raw message
Signature · 5 lines
2.37.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v5 9/10 shell: Add tests for TST_ALL_FILESYSTEMS=1
In reply to Petr VorelUnfortunately GitHub Actions don't have loop devices, thus cannot be run in CI:
tst_format_device 1 TINFO: timeout per run is 0h 5m 0s /__w/ltp/ltp/lib/tst_device.c:139: TINFO: No free devices found
---
changes v4->v5:
* new test lib/newlib_tests/shell/tst_all_filesystems_skip.sh
lib/newlib_tests/shell/tst_all_filesystems.sh | 27 +++++++++++++++++++ .../shell/tst_all_filesystems_skip.sh | 16 +++++++++++ lib/tst_supported_fs_types.c | 2 +- 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100755 lib/newlib_tests/shell/tst_all_filesystems.sh create mode 100755 lib/newlib_tests/shell/tst_all_filesystems_skip.sh
lib/newlib_tests/shell/tst_all_filesystems.sh new file +27 -0
@@ -0,0 +1,27 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022 Petr Vorel <[email protected]> + +TST_ALL_FILESYSTEMS=1 +TST_NEEDS_ROOT=1 +TST_TESTFUNC=test +TST_CNT=2 + +test1() +{ + tst_res TPASS "device using filesystem" +} + +test2() +{ + local pattern="$TST_FS_TYPE" + + if [ "$TST_FS_TYPE_FUSE" = 1 ]; then + pattern="fuseblk" + fi + + EXPECT_PASS "grep -E '$TST_MNTPOINT ($pattern)' /proc/mounts" +} + +. tst_test.sh +tst_run
lib/newlib_tests/shell/tst_all_filesystems_skip.sh new file +16 -0
@@ -0,0 +1,16 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022 Petr Vorel <[email protected]> + +TST_ALL_FILESYSTEMS=1 +TST_NEEDS_ROOT=1 +TST_TESTFUNC=test +TST_SKIP_FILESYSTEMS="btrfs,exfat,ext2,ext3,ext4,fuse,ntfs,vfat,tmpfs,xfs" + +test1() +{ + tst_res TFAIL "test should be skipped with TCONF" +} + +. tst_test.sh +tst_run
lib/tst_supported_fs_types.c +1 -1
@@ -14,7 +14,7 @@#include "tst_test.h" #include "tst_fs.h" -/* NOTE: new filesystem should be also added to tst_skip_filesystems.sh */ +/* NOTE: new filesystem should be also added to tst_*skip*.sh */ static const char *const fs_type_whitelist[] = {"ext2" ,"ext3" ,
Signature · 5 lines
2.37.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v5 10/10 df01.sh: Convert to TST_ALL_FILESYSTEMS=1
In reply to Petr Vorel---
The same as in v4
runtest/commands | 8 +------- runtest/smoketest | 2 +- testcases/commands/df/df01.sh | 32 +++++++++----------------------- 3 files changed, 11 insertions(+), 31 deletions(-)
runtest/commands +1 -7
@@ -14,13 +14,7 @@ ln01_sh ln_tests.sh mkdir01_sh mkdir_tests.sh mv01_sh mv_tests.sh du01_sh du01.sh -df01_ext2_sh df01.sh -f ext2 -df01_ext3_sh df01.sh -f ext3 -df01_ext4_sh df01.sh -f ext4 -df01_xfs_sh df01.sh -f xfs -df01_vfat_sh df01.sh -f vfat -df01_exfat_sh df01.sh -f exfat -df01_ntfs_sh df01.sh -f ntfs +df01_sh df01.sh mkfs01_sh mkfs01.sh mkfs01_ext2_sh mkfs01.sh -f ext2 mkfs01_ext3_sh mkfs01.sh -f ext3
runtest/smoketest +1 -1
@@ -12,7 +12,7 @@ stat04 symlink01 -T stat04 utime01A symlink01 -T utime01 rename01A symlink01 -T rename01 splice02 splice02 -s 20 -df01_ext4_sh df01.sh -f ext4 +df01_sh df01.sh shell_test01 echo "SUCCESS" | shell_pipe01.sh ping602 ping02.sh -6 macsec02 macsec02.sh
testcases/commands/df/df01.sh +9 -23
@@ -6,35 +6,19 @@ # # Test df command with some basic options. +TST_ALL_FILESYSTEMS=1 TST_CNT=12 TST_SETUP=setup TST_TESTFUNC=test -TST_OPTS="f:" -TST_USAGE=usage -TST_PARSE_ARGS=parse_args TST_NEEDS_ROOT=1 -TST_MOUNT_DEVICE=1 - -usage() -{ - cat << EOF -usage: $0 [-f <ext2|ext3|ext4|vfat|...>] - -OPTIONS --f Specify the type of filesystem to be built. If not - specified, the default filesystem type (currently ext2) - is used. -EOF -} - -parse_args() -{ - TST_FS_TYPE="$2" -} setup() { - DF_FS_TYPE=$(mount | grep "$TST_DEVICE" | awk 'NR==1{print $5}') + DF_FS_TYPE="$TST_FS_TYPE" + + if [ "$TST_FS_TYPE_FUSE" = 1 ]; then + DF_FS_TYPE="fuseblk" + fi } df_test()
@@ -180,7 +164,9 @@ test11() test12() { - local cmd="df -x $DF_FS_TYPE -P" + local fs="$DF_FS_TYPE" + + local cmd="df -x $fs -P" df_verify $cmd if [ $? -ne 0 ]; then
Signature · 5 lines
2.37.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp