shell: nfs: $TST_ALL_FILESYSTEMS (.all_filesystems)
Subsystems (3)
v3 cover shell: nfs: $TST_ALL_FILESYSTEMS (.all_filesystems)
Hi,
changes v2->v3:
* add $TST_SKIP_FILESYSTEMS implementation
* various fixes for tst_test.sh + tests
- tst_test.sh: Fix tst_mkfs() for tmpfs
Diff to v2:
shell-test-api.txt +4 -0
@@ -200,6 +200,8 @@ simply by setting right '$TST_FOO'. |============================================================================= | 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,
@@ -230,6 +232,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.
tst_fs.h +10 -0
@@ -182,6 +182,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. *
newlib_tests/shell/tst_mount_device.sh +6 -1
@@ -5,7 +5,7 @@ TST_MOUNT_DEVICE=1 TST_FS_TYPE=ext4 TST_TESTFUNC=test -TST_CNT=2 +TST_CNT=3 test1() {
@@ -17,5 +17,10 @@ test2() EXPECT_PASS "grep '$TST_MNTPOINT $TST_FS_TYPE' /proc/mounts" } +test3() +{ + tst_brk TCONF "quit early to test early tst_umount" +} + . tst_test.sh tst_run
newlib_tests/shell/tst_mount_device_tmpfs.sh new file +15 -0
@@ -0,0 +1,15 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022 Petr Vorel <[email protected]> + +TST_MOUNT_DEVICE=1 +TST_FS_TYPE=tmpfs +TST_TESTFUNC=test + +test() +{ + EXPECT_PASS "cd $TST_MNTPOINT" +} + +. tst_test.sh +tst_run
newlib_tests/shell/tst_skip_filesystems.sh new file +34 -0
@@ -0,0 +1,34 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022 Petr Vorel <[email protected]> + +TST_MOUNT_DEVICE=1 +TST_FS_TYPE=ext4 +TST_TESTFUNC=test +TST_SKIP_FILESYSTEMS="btrfs,ext2,ext3,xfs,vfat,exfat,ntfs,tmpfs" +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
newlib_tests/shell/tst_skip_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_MOUNT_DEVICE=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
tst_supported_fs_types.c +18 -0
@@ -134,6 +134,24 @@ 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)) { +tst_brk (TCONF ,"%s is not supported by the test" , + fs_type); + } + +return ret; +} +const char **tst_get_supported_fs_types (const char *const *skiplist) {unsigned int i, j =0 ;
lib/tst_supported_fs.c +44 -12
86 lines not on this page · raw message
lib/tst_test.sh +30 -12
131 lines not on this page · raw message
misc/lvm/generate_lvm_runfile.sh +1 -1
@@ -16,7 +16,7 @@ generate_runfile() trap 'tst_brk TBROK "Cannot create LVM runfile"' ERR 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
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"
network/nfs/nfs_stress/nfs_lib.sh +4 -1
@@ -8,6 +8,7 @@ VERSION=${VERSION:=3} NFILES=${NFILES:=1000} SOCKET_TYPE="${SOCKET_TYPE:-udp}" NFS_TYPE=${NFS_TYPE:=nfs} +TST_SKIP_FILESYSTEMS="ntfs,vfat" nfs_usage() {
@@ -205,7 +206,9 @@ nfs_cleanup() n=$(( n + 1 )) done - systemctl restart nfs-server + restart_daemon nfs-server + tst_sleep 500ms } +. daemonlib.sh . tst_net.sh
Petr Vorel (10):
tst_test.sh: Fix tst_mkfs() for tmpfs
tst_device: Add clear command
tst_test.sh: Allow $ ; after whitelisted variable tst_mount_device.sh: Cover early tst_umount call
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: Add $TST_ALL_FILESYSTEMS
shell: Add test for TST_ALL_FILESYSTEMS=1
nfs: Use TST_ALL_FILESYSTEMS=1
doc/shell-test-api.txt | 5 + include/tst_fs.h | 10 ++ lib/newlib_tests/shell/tst_all_filesystems.sh | 27 ++++ lib/newlib_tests/shell/tst_mount_device.sh | 7 +- .../shell/tst_mount_device_tmpfs.sh | 15 +++ .../shell/tst_skip_filesystems.sh | 34 +++++ .../shell/tst_skip_filesystems_skip.sh | 16 +++ lib/tst_supported_fs_types.c | 18 +++ testcases/lib/tst_device.c | 20 ++- testcases/lib/tst_supported_fs.c | 56 ++++++-- testcases/lib/tst_test.sh | 126 ++++++++++++------ testcases/misc/lvm/generate_lvm_runfile.sh | 2 +- testcases/misc/lvm/prepare_lvm.sh | 2 +- testcases/network/nfs/nfs_stress/nfs_lib.sh | 28 ++-- 14 files changed, 299 insertions(+), 67 deletions(-) create mode 100755 lib/newlib_tests/shell/tst_all_filesystems.sh create mode 100755 lib/newlib_tests/shell/tst_mount_device_tmpfs.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.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v3 1/10 tst_test.sh: Fix tst_mkfs() for tmpfs
+ add test for it.
This has been broken since ever, but get more problematic when $TST_FORMAT_DEVICE got introduced.
---
New in v3
lib/newlib_tests/shell/tst_mount_device_tmpfs.sh | 15 +++++++++++++++ testcases/lib/tst_test.sh | 5 +++++ 2 files changed, 20 insertions(+) create mode 100755 lib/newlib_tests/shell/tst_mount_device_tmpfs.sh
lib/newlib_tests/shell/tst_mount_device_tmpfs.sh new file +15 -0
@@ -0,0 +1,15 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022 Petr Vorel <[email protected]> + +TST_MOUNT_DEVICE=1 +TST_FS_TYPE=tmpfs +TST_TESTFUNC=test + +test() +{ + EXPECT_PASS "cd $TST_MNTPOINT" +} + +. tst_test.sh +tst_run
testcases/lib/tst_test.sh +5 -0
@@ -351,6 +351,11 @@ tst_mkfs() opts="$@" + if [ "$fs_type" = tmpfs ]; then + tst_res TINFO "Skipping mkfs for TMPFS filesystem" + return + fi + if [ -z "$opts" ]; then if [ "$TST_NEEDS_DEVICE" != 1 ]; then tst_brk "Using default parameters in tst_mkfs requires TST_NEEDS_DEVICE=1"
Signature · 5 lines
2.37.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v3 01/10] tst_test.sh: Fix tst_mkfs() for tmpfs
Hello,
No response and seems reasonable, please merge!
Quoted 56 lines · Petr Vorel
+ add test for it.
This has been broken since ever, but get more problematic when $TST_FORMAT_DEVICE got introduced.
Fixes 7783ac3a0 ("lib/tst_test.sh: Add new shell library")Fixes 95734791c ("tst_test.sh: Add $TST_FORMAT_DEVICE and related vars")Signed-off-by Petr Vorel <[email protected]>---
New in v3lib/newlib_tests/shell/tst_mount_device_tmpfs.sh | 15 +++++++++++++++ testcases/lib/tst_test.sh | 5 +++++ 2 files changed, 20 insertions(+) create mode 100755 lib/newlib_tests/shell/tst_mount_device_tmpfs.shlib/newlib_tests/shell/tst_mount_device_tmpfs.sh new file +15
-0@@ -0,0 +1,15 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022 Petr Vorel <[email protected]> + +TST_MOUNT_DEVICE=1 +TST_FS_TYPE=tmpfs +TST_TESTFUNC=test + +test() +{ + EXPECT_PASS "cd $TST_MNTPOINT" +} + +. tst_test.sh +tst_runtestcases/lib/tst_test.sh +5
-0@@ -351,6 +351,11 @@ tst_mkfs() opts="$@" + if [ "$fs_type" = tmpfs ]; then + tst_res TINFO "Skipping mkfs for TMPFS filesystem" + return + fi + if [ -z "$opts" ]; then if [ "$TST_NEEDS_DEVICE" != 1 ]; then tst_brk "Using default parameters in tst_mkfs requires TST_NEEDS_DEVICE=1"Signature · 1 line
2.37.1
Signature · 5 lines
Thank you, Richard. -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v3 01/10] tst_test.sh: Fix tst_mkfs() for tmpfs
Hi Richie,
Quoted 5 lines
Hello,
No response and seems reasonable, please merge!
Thanks a lot for your review! I suppose you mean your ack for whole patchset.
If yes, I'll merge all but the last RFC commit which needs more work (i.e. TST_ALL_FILESYSTEMS infrastructure although nothing uses it yet).
Merging would help me not having to rebase this work after finishing and get merged "Track minimal size per filesystem" [1] (originally I thought that one would go first, but TST_ALL_FILESYSTEMS infrastructure is ready now).
I also plan to convert df01.sh and mkfs01.sh to TST_ALL_FILESYSTEMS.
Kind regards,
Petr
[1] https://patchwork.ozlabs.org/project/ltp/list/?series=315621
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v3 01/10] tst_test.sh: Fix tst_mkfs() for tmpfs
Hi,
Quoted 16 lines · Petr Vorel
Hi Richie,
Quoted 5 lines
Hello,
No response and seems reasonable, please merge!
Thanks a lot for your review! I suppose you mean your ack for whole patchset.
If yes, I'll merge all but the last RFC commit which needs more work (i.e.
TST_ALL_FILESYSTEMSinfrastructure although nothing uses it yet).Merging would help me not having to rebase this work after finishing and get merged "Track minimal size per filesystem" [1] (originally I thought that one would go first, but
TST_ALL_FILESYSTEMSinfrastructure is ready now).
Quoted 6 lines
I also plan to convert
df01.shandmkfs01.shtoTST_ALL_FILESYSTEMS.Kind regards,
Petr[1] https://patchwork.ozlabs.org/project/ltp/list/?series=315621
OK, I have acked everything that didn't already have a review tag. It would help to include some test conversions in the patch set, but I trust you will follow up with df01.sh and mkfs01.sh ;-)
Signature · 5 lines
Thank you, Richard. -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v3 01/10] tst_test.sh: Fix tst_mkfs() for tmpfs
Quoted 20 lines
Quoted 17 lines · Petr Vorel
Hi Richie,
Quoted 5 lines
Hello,
No response and seems reasonable, please merge!
Thanks a lot for your review! I suppose you mean your ack for whole patchset.
If yes, I'll merge all but the last RFC commit which needs more work (i.e.
TST_ALL_FILESYSTEMSinfrastructure although nothing uses it yet).Merging would help me not having to rebase this work after finishing and get merged "Track minimal size per filesystem" [1] (originally I thought that one would go first, but
TST_ALL_FILESYSTEMSinfrastructure is ready now).I also plan to convert
df01.shandmkfs01.shtoTST_ALL_FILESYSTEMS.
Quoted 8 lines
Quoted 4 lines
Kind regards,
Petr[1] https://patchwork.ozlabs.org/project/ltp/list/?series=315621
OK, I have acked everything that didn't already have a review tag. It would help to include some test conversions in the patch set, but I trust you will follow up with
df01.shandmkfs01.sh;-)
Thanks! As I found that there is tiny issue in TST_ALL_FILESYSTEMS implementation (there should be equivalent of tst_device->fs_type) I've merged patches up to "[v3,04/10] tst_mount_device.sh: Cover early tst_umount call" and send v4 with fixed this version and converted at least one of df01.sh and mkfs01.sh. Then I base "Track minimal size per filesystem" patchset on this work (suppose this patchet will be quickly re-reviewed).
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v3 2/10 tst_device: Add clear command
In reply to Petr Vorelclearing block device will be needed for TST_ALL_FILESYSTEMS implementation in shell API. Now we clear device during acquire, but we will reuse this device for each tested filesystem, thus we need a separate command for it.
--- testcases/lib/tst_device.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
testcases/lib/tst_device.c +18 -2
@@ -18,8 +18,10 @@ static struct tst_test test = {static void print_help (void ) { -fprintf (stderr,"\nUsage: tst_device acquire [size [filename]]\n" ); -fprintf (stderr," or: tst_device release /path/to/device\n\n" ); +fprintf (stderr,"\nUsage:\n" ); +fprintf (stderr,"tst_device acquire [size [filename]]\n" ); +fprintf (stderr,"tst_device release /path/to/device\n" ); +fprintf (stderr,"tst_device clear /path/to/device\n\n" ); }static int acquire_device (int argc,char *argv[])
@@ -72,6 +74,17 @@ static int release_device(int argc, char *argv[])return tst_detach_device (argv[2 ]); } +static int clear_device (int argc,char *argv[]) +{ +if (argc !=3 ) +return 1 ; + +if (tst_clear_device (argv[2 ])) +return 1 ; + +return 0 ; +} +int main (int argc,char *argv[]) {/*
@@ -94,6 +107,9 @@ int main(int argc, char *argv[]) }else if (!strcmp (argv[1 ],"release" )) {if (release_device (argc, argv)) goto help; + }else if (!strcmp (argv[1 ],"clear" )) { +if (clear_device (argc, argv)) + goto help; }else {fprintf (stderr,"ERROR: Invalid COMMAND '%s'\n" , argv[1 ]); goto help;
Signature · 5 lines
2.37.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v3 3/10 tst_test.sh: Allow $ ; after whitelisted variable
In reply to Petr VorelVariable followed by other variable was not whitelisted:
e.g.:
$TST_FS_TYPE$pattern
TWARN: Reserved variable TST_FS_TYPE$ used!
for i in $SKIP_FILESYSTEMS; do
TWARN: Reserved variable TST_SKIP_FILESYSTEMS used!
Also use the same patter for second grep for detection of _tst_* functions variables.
---
New in v3
testcases/lib/tst_test.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
testcases/lib/tst_test.sh +3 -2
@@ -625,9 +625,10 @@ tst_run() local _tst_data local _tst_max local _tst_name + local _tst_pattern='[='\''"} \t\/:`$\;].*' if [ -n "$TST_TEST_PATH" ]; then - for _tst_i in $(grep '^[^#]*\bTST_' "$TST_TEST_PATH" | sed 's/.*TST_//; s/[='\''"} \t\/:`].*//'); do + for _tst_i in $(grep '^[^#]*\bTST_' "$TST_TEST_PATH" | sed "s/.*TST_//; s/$_tst_pattern//"); do case "$_tst_i" in DISABLE_APPARMOR|DISABLE_SELINUX);; SETUP|CLEANUP|TESTFUNC|ID|CNT|MIN_KVER);;
@@ -647,7 +648,7 @@ tst_run() esac done - for _tst_i in $(grep '^[^#]*\b_tst_' "$TST_TEST_PATH" | sed 's/.*_tst_//; s/[="} \t\/:`].*//'); do + for _tst_i in $(grep '^[^#]*\b_tst_' "$TST_TEST_PATH" | sed "s/.*_tst_//; s/$_tst_pattern//"); do tst_res TWARN "Private variable or function _tst_$_tst_i used!" done fi
Signature · 5 lines
2.37.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v3 03/10] tst_test.sh: Allow $ ; after whitelisted variable
Hi,
Quoted 45 lines · Petr Vorel
Variable followed by other variable was not whitelisted:
e.g.:
$TST_FS_TYPE$pattern
TWARN: Reserved variable TST_FS_TYPE$ used!for i in $SKIP_FILESYSTEMS; do
TWARN: Reserved variableTST_SKIP_FILESYSTEMSused!Also use the same patter for second grep for detection of _tst_* functions variables.
Signed-off-by Petr Vorel <[email protected]>---
New in v3testcases/lib/tst_test.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)testcases/lib/tst_test.sh +3
-2@@ -625,9 +625,10 @@ tst_run() local _tst_data local _tst_max local _tst_name + local _tst_pattern='[='\''"} \t\/:`$\;].*' if [ -n "$TST_TEST_PATH" ]; then - for _tst_i in $(grep '^[^#]*\bTST_' "$TST_TEST_PATH" | sed 's/.*TST_//; s/[='\''"} \t\/:`].*//'); do + for _tst_i in $(grep '^[^#]*\bTST_' "$TST_TEST_PATH" | sed "s/.*TST_//; s/$_tst_pattern//"); do case "$_tst_i" in DISABLE_APPARMOR|DISABLE_SELINUX);; SETUP|CLEANUP|TESTFUNC|ID|CNT|MIN_KVER);;@@ -647,7 +648,7 @@ tst_run() esac done - for _tst_i in $(grep '^[^#]*\b_tst_' "$TST_TEST_PATH" | sed 's/.*_tst_//; s/[="} \t\/:`].*//'); do + for _tst_i in $(grep '^[^#]*\b_tst_' "$TST_TEST_PATH" | sed "s/.*_tst_//; s/$_tst_pattern//"); do tst_res TWARN "Private variable or function _tst_$_tst_i used!" done fiSignature · 1 line
2.37.1
Signature · 5 lines
Thank you, Richard. -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v3 4/10 tst_mount_device.sh: Cover early tst_umount call
In reply to Petr VorelCaused by tst_brk in tests with TST_MOUNT_DEVICE=1.
---
New in v3
lib/newlib_tests/shell/tst_mount_device.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
lib/newlib_tests/shell/tst_mount_device.sh +6 -1
@@ -5,7 +5,7 @@ TST_MOUNT_DEVICE=1 TST_FS_TYPE=ext4 TST_TESTFUNC=test -TST_CNT=2 +TST_CNT=3 test1() {
@@ -17,5 +17,10 @@ test2() EXPECT_PASS "grep '$TST_MNTPOINT $TST_FS_TYPE' /proc/mounts" } +test3() +{ + tst_brk TCONF "quit early to test early tst_umount" +} + . tst_test.sh tst_run
Signature · 5 lines
2.37.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v3 04/10] tst_mount_device.sh: Cover early tst_umount call
Quoted 35 lines · Petr Vorel
Caused by
tst_brkin tests with TST_MOUNT_DEVICE=1.Signed-off-by Petr Vorel <[email protected]>---
New in v3lib/newlib_tests/shell/tst_mount_device.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)lib/newlib_tests/shell/tst_mount_device.sh +6
-1@@ -5,7 +5,7 @@ TST_MOUNT_DEVICE=1 TST_FS_TYPE=ext4 TST_TESTFUNC=test -TST_CNT=2 +TST_CNT=3 test1() {@@ -17,5 +17,10 @@ test2() EXPECT_PASS "grep '$TST_MNTPOINT $TST_FS_TYPE' /proc/mounts" } +test3() +{ + tst_brk TCONF "quit early to test early tst_umount" +} + . tst_test.sh tst_runSignature · 1 line
2.37.1
Signature · 5 lines
Thank you, Richard. -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v3 5/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), but allow to use zram01.sh with tmpfs as it works with it.
---
New in v3
testcases/lib/tst_supported_fs.c | 56 +++++++++++++++++----- testcases/misc/lvm/generate_lvm_runfile.sh | 2 +- testcases/misc/lvm/prepare_lvm.sh | 2 +- 3 files changed, 46 insertions(+), 14 deletions(-)
testcases/lib/tst_supported_fs.c +44 -12
@@ -5,42 +5,74 @@*/ #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 ); }int main (int argc,char *argv[]) { -const char *skiplist[] = {"tmpfs" ,NULL };const char *const *filesystems; -int i; +int i, ret, cnt =1 ; +char **skiplist =NULL ; +char *fs; -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 '?' : +return 1 ; + +case 'h' : +usage (); +return 0 ; + +case 's' : + fs = optarg; +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 1 ; + } + + fs = optarg; +for (i =0 ; i < cnt; i++) + skiplist[i] =strtok_r (fs,TST_TO_STR (SKIP_DELIMITER ), &fs); +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 ]) -return !tst_fs_is_supported (argv[1 ]); +if (optind < argc) +return !tst_fs_is_supported (argv[optind]); - filesystems =tst_get_supported_fs_types (skiplist); + filesystems =tst_get_supported_fs_types ((const char *const *)skiplist);for (i =0 ; filesystems[i]; i++)printf ("%s\n" , filesystems[i]);
testcases/misc/lvm/generate_lvm_runfile.sh +1 -1
@@ -16,7 +16,7 @@ generate_runfile() trap 'tst_brk TBROK "Cannot create LVM runfile"' ERR 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.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v3 05/10] tst_supported_fs: Implement skip list
Hi,
Quoted 132 lines · Petr Vorel
as it will be needed for $ALL_FILESYSTEMS shell implementation in the next commit. Pass tmpfs to LVM scripts (as it was required there), but allow to use
zram01.shwith tmpfs as it works with it.Signed-off-by Petr Vorel <[email protected]>---
New in v3testcases/lib/tst_supported_fs.c | 56 +++++++++++++++++----- testcases/misc/lvm/generate_lvm_runfile.sh | 2 +- testcases/misc/lvm/prepare_lvm.sh | 2 +- 3 files changed, 46 insertions(+), 14 deletions(-)testcases/lib/tst_supported_fs.c +44
-12@@ -5,42 +5,74 @@*/ #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 ); }int main (int argc,char *argv[]) { -const char *skiplist[] = {"tmpfs" ,NULL };const char *const *filesystems; -int i; +int i, ret, cnt =1 ; +char **skiplist =NULL ; +char *fs; -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 '?' : +return 1 ; + +case 'h' : +usage (); +return 0 ; + +case 's' : + fs = optarg; +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 1 ; + } + + fs = optarg; +for (i =0 ; i < cnt; i++) + skiplist[i] =strtok_r (fs,TST_TO_STR (SKIP_DELIMITER ), &fs); +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 ]) -return !tst_fs_is_supported (argv[1 ]); +if (optind < argc) +return !tst_fs_is_supported (argv[optind]); - filesystems =tst_get_supported_fs_types (skiplist); + filesystems =tst_get_supported_fs_types ((const char *const *)skiplist);for (i =0 ; filesystems[i]; i++)printf ("%s\n" , filesystems[i]);testcases/misc/lvm/generate_lvm_runfile.sh +1
-1@@ -16,7 +16,7 @@ generate_runfile() trap 'tst_brk TBROK "Cannot create LVM runfile"' ERR 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; dotestcases/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 · 1 line
2.37.1
Signature · 5 lines
Thank you, Richard. -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v3 6/10 tst_supported_fs: Support skip list when query single fs
In reply to Petr Vorel---
New in v3
include/tst_fs.h | 10 ++++++++++ lib/tst_supported_fs_types.c | 18 ++++++++++++++++++ testcases/lib/tst_supported_fs.c | 2 +- 3 files changed, 29 insertions(+), 1 deletion(-)
include/tst_fs.h +10 -0
@@ -182,6 +182,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 +18 -0
@@ -134,6 +134,24 @@ 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)) { +tst_brk (TCONF ,"%s is not supported by the test" , + fs_type); + } + +return ret; +} +const char **tst_get_supported_fs_types (const char *const *skiplist) {unsigned int i, j =0 ;
testcases/lib/tst_supported_fs.c +1 -1
@@ -70,7 +70,7 @@ int main(int argc, char *argv[]) }if (optind < argc) -return !tst_fs_is_supported (argv[optind]); +return !tst_fs_is_supported_skiplist (argv[optind], (const char *const *)skiplist); filesystems =tst_get_supported_fs_types ((const char *const *)skiplist);for (i =0 ; filesystems[i]; i++)
Signature · 5 lines
2.37.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v3 06/10] tst_supported_fs: Support skip list when query single fs
Hi,
Quoted 74 lines · Petr Vorel
Signed-off-by Petr Vorel <[email protected]>---
New in v3include/tst_fs.h | 10 ++++++++++ lib/tst_supported_fs_types.c | 18 ++++++++++++++++++ testcases/lib/tst_supported_fs.c | 2 +- 3 files changed, 29 insertions(+), 1 deletion(-)include/tst_fs.h +10
-0@@ -182,6 +182,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 +18
-0@@ -134,6 +134,24 @@ 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)) { +tst_brk (TCONF ,"%s is not supported by the test" , + fs_type); + } + +return ret; +} +const char **tst_get_supported_fs_types (const char *const *skiplist) {unsigned int i, j =0 ;testcases/lib/tst_supported_fs.c +1
-1@@ -70,7 +70,7 @@ int main(int argc, char *argv[]) }if (optind < argc) -return !tst_fs_is_supported (argv[optind]); +return !tst_fs_is_supported_skiplist (argv[optind], (const char *const *)skiplist); filesystems =tst_get_supported_fs_types ((const char *const *)skiplist);for (i =0 ; filesystems[i]; i++)Signature · 1 line
2.37.1
Signature · 5 lines
Thank you, Richard. -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v3 7/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)
---
New in v3
doc/shell-test-api.txt | 1 + .../shell/tst_skip_filesystems.sh | 34 +++++++++++++++++++ .../shell/tst_skip_filesystems_skip.sh | 16 +++++++++ testcases/lib/tst_test.sh | 6 ++++ 4 files changed, 57 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 +1 -0
@@ -229,6 +229,7 @@ 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_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 +34 -0
@@ -0,0 +1,34 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022 Petr Vorel <[email protected]> + +TST_MOUNT_DEVICE=1 +TST_FS_TYPE=ext4 +TST_TESTFUNC=test +TST_SKIP_FILESYSTEMS="btrfs,ext2,ext3,xfs,vfat,exfat,ntfs,tmpfs" +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 +16 -0
@@ -0,0 +1,16 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022 Petr Vorel <[email protected]> + +TST_MOUNT_DEVICE=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
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.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v3 07/10] shell: Add $TST_SKIP_FILESYSTEMS + tests
Quoted 124 lines · Petr Vorel
C API struct
tst_testskip_filesystemsmember equivalent.Now only running on single filesystem (will be improved in the next commit)
Signed-off-by Petr Vorel <[email protected]>---
New in v3doc/shell-test-api.txt | 1 + .../shell/tst_skip_filesystems.sh | 34 +++++++++++++++++++ .../shell/tst_skip_filesystems_skip.sh | 16 +++++++++ testcases/lib/tst_test.sh | 6 ++++ 4 files changed, 57 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 +1
-0@@ -229,6 +229,7 @@ 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_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 +34
-0@@ -0,0 +1,34 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022 Petr Vorel <[email protected]> + +TST_MOUNT_DEVICE=1 +TST_FS_TYPE=ext4 +TST_TESTFUNC=test +TST_SKIP_FILESYSTEMS="btrfs,ext2,ext3,xfs,vfat,exfat,ntfs,tmpfs" +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 +16
-0@@ -0,0 +1,16 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022 Petr Vorel <[email protected]> + +TST_MOUNT_DEVICE=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_runtestcases/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=1Signature · 1 line
2.37.1
Signature · 5 lines
Thank you, Richard. -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v3 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 v2->v3:
* Fixed various functional problems
* Added $TST_SKIP_FILESYSTEMS support
doc/shell-test-api.txt | 6 +- testcases/lib/tst_test.sh | 118 +++++++++++++++++++++++++------------- 2 files changed, 82 insertions(+), 42 deletions(-)
doc/shell-test-api.txt +5 -1
@@ -199,6 +199,9 @@ 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,
@@ -229,7 +232,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_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.
testcases/lib/tst_test.sh +77 -41
188 lines not on this page · raw message
Signature · 5 lines
2.37.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v3 08/10] tst_test.sh: Add $TST_ALL_FILESYSTEMS
Hi,
Quoted 243 lines · 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.
Reviewed-by Li Wang <[email protected]>Signed-off-by Petr Vorel <[email protected]>---
Changesv2->v3:
* Fixed various functional problems
* Added $TST_SKIP_FILESYSTEMS supportdoc/shell-test-api.txt | 6 +- testcases/lib/tst_test.sh | 118 +++++++++++++++++++++++++------------- 2 files changed, 82 insertions(+), 42 deletions(-)doc/shell-test-api.txt +5
-1@@ -199,6 +199,9 @@ 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,@@ -229,7 +232,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_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.testcases/lib/tst_test.sh +77
-41@@ -33,17 +33,7 @@ _tst_do_exit() local ret=0 TST_DO_EXIT=1 - if [ -n "$TST_DO_CLEANUP" -a -n "$TST_CLEANUP" -a -z "$TST_NO_CLEANUP" ]; then - if command -v $TST_CLEANUP >/dev/null 2>/dev/null; then - $TST_CLEANUP - else - tst_res TWARN "TST_CLEANUP=$TST_CLEANUP declared, but function not defined (or cmd not found)" - fi - fi - - if [ "$TST_MOUNT_FLAG" = 1 ]; then - tst_umount - fi + [ "$TST_MOUNT_FLAG" = 1 ] && tst_umount if [ "$TST_NEEDS_DEVICE" = 1 -a "$TST_DEVICE_FLAG" = 1 ]; then if ! tst_device release "$TST_DEVICE"; then@@ -479,6 +469,7 @@ LTPROOT Prefix for installed LTP (default: /opt/ltp) LTP_COLORIZE_OUTPUT Force colorized output behaviour (y/1 always, n/0: never) LTP_DEV Path to the block device to be used (for .needs_device) LTP_DEV_FS_TYPE Filesystem used for testing (default: ext2) +LTP_SINGLE_FS_TYPE Testing only - specifies filesystem instead all supported (for TST_ALL_FILESYSTEMS=1) LTP_TIMEOUT_MUL Timeout multiplier (must be a number >=1, ceiled to int) TMPDIR Base directory for template directory (for .needs_tmpdir, default: /tmp) EOF@@ -619,10 +610,33 @@ _tst_init_checkpoints() export LTP_IPC_PATH } +_prepare_device() +{ + if [ "$TST_FORMAT_DEVICE" = 1 ]; then + tst_device clear "$TST_DEVICE" + tst_mkfs $TST_FS_TYPE $TST_DEV_FS_OPTS $TST_DEVICE $TST_DEV_EXTRA_OPTS + fi + + if [ "$TST_MOUNT_DEVICE" = 1 ]; then + tst_mount + TST_MOUNT_FLAG=1 + fi +} + +_tst_run_tcases_per_fs() +{ + for _tst_fs in $(tst_supported_fs -s "$TST_SKIP_FILESYSTEMS"); do + tst_res TINFO "=== Testing on $_tst_fs ===" + TST_FS_TYPE="$_tst_fs" + _tst_run_iterations + done +} + tst_run() { local _tst_i local _tst_data + local _tst_fs local _tst_max local _tst_name local _tst_pattern='[='\''"} \t\/:`$\;].*'@@ -631,7 +645,7 @@ tst_run() if [ -n "$TST_TEST_PATH" ]; then for _tst_i in $(grep '^[^#]*\bTST_' "$TST_TEST_PATH" | sed "s/.*TST_//; s/$_tst_pattern//"); do case "$_tst_i" in - DISABLE_APPARMOR|DISABLE_SELINUX);; + ALL_FILESYSTEMS|DISABLE_APPARMOR|DISABLE_SELINUX);; SETUP|CLEANUP|TESTFUNC|ID|CNT|MIN_KVER);; OPTS|USAGE|PARSE_ARGS|POS_ARGS);; NEEDS_ROOT|NEEDS_TMPDIR|TMPDIR|NEEDS_DEVICE|DEVICE);;@@ -677,16 +691,29 @@ 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 + [ -n "$TST_NEEDS_MODULE" ] && tst_require_module "$TST_NEEDS_MODULE" + [ "$TST_ALL_FILESYSTEMS" = 1 ] && TST_MOUNT_DEVICE=1 [ "$TST_MOUNT_DEVICE" = 1 ] && TST_FORMAT_DEVICE=1 [ "$TST_FORMAT_DEVICE" = 1 ] && TST_NEEDS_DEVICE=1 [ "$TST_NEEDS_DEVICE" = 1 ] && TST_NEEDS_TMPDIR=1 + if [ "$TST_ALL_FILESYSTEMS" != 1 ]; then + tst_supported_fs -s "$TST_SKIP_FILESYSTEMS" $TST_FS_TYPE + ret=$? + [ $ret -ne 0 ] && return $ret + fi + + if [ "$TST_NEEDS_DEVICE" = 1 ]; then + TST_DEVICE=$(tst_device acquire) + + if [ ! -b "$TST_DEVICE" -o $? -ne 0 ]; then + unset TST_DEVICE + tst_brk TBROK "Failed to acquire device" + fi + TST_DEVICE_FLAG=1 + fi + if [ "$TST_NEEDS_TMPDIR" = 1 ]; then if [ -z "$TMPDIR" ]; then export TMPDIR="/tmp"@@ -697,35 +724,32 @@ tst_run() chmod 777 "$TST_TMPDIR" TST_STARTWD=$(pwd) - cd "$TST_TMPDIR" fi - TST_MNTPOINT="${TST_MNTPOINT:-$PWD/mntpoint}" - if [ "$TST_NEEDS_DEVICE" = 1 ]; then - - TST_DEVICE=$(tst_device acquire) + [ -n "$TST_NEEDS_CHECKPOINTS" ] && _tst_init_checkpoints - if [ ! -b "$TST_DEVICE" -o $? -ne 0 ]; then - unset TST_DEVICE - tst_brk TBROK "Failed to acquire device" - fi + TST_MNTPOINT="${TST_MNTPOINT:-$PWD/mntpoint}" - TST_DEVICE_FLAG=1 + if [ "$TST_ALL_FILESYSTEMS" = 1 ]; then + _tst_run_tcases_per_fs + else + _tst_run_iterations fi - [ -n "$TST_NEEDS_MODULE" ] && tst_require_module "$TST_NEEDS_MODULE" + _tst_do_exit +} - if [ "$TST_FORMAT_DEVICE" = 1 ]; then - tst_mkfs $TST_FS_TYPE $TST_DEV_FS_OPTS $TST_DEVICE $TST_DEV_EXTRA_OPTS - fi +_tst_run_iterations() +{ + local _tst_i=$TST_ITERATIONS + local _tst_j - if [ "$TST_MOUNT_DEVICE" = 1 ]; then - tst_mount - TST_MOUNT_FLAG=1 - fi + [ "$TST_NEEDS_TMPDIR" = 1 ] && cd "$TST_TMPDIR" - [ -n "$TST_NEEDS_CHECKPOINTS" ] && _tst_init_checkpoints + _prepare_device + + _tst_setup_timer if [ -n "$TST_SETUP" ]; then if command -v $TST_SETUP >/dev/null 2>/dev/null; then@@ -737,20 +761,32 @@ tst_run() fi #TODO check that test reports some results for each test function call - while [ $TST_ITERATIONS -gt 0 ]; do + while [ $_tst_i -gt 0 ]; do if [ -n "$TST_TEST_DATA" ]; then tst_require_cmds cut tr wc _tst_max=$(( $(echo $TST_TEST_DATA | tr -cd "$TST_TEST_DATA_IFS" | wc -c) +1)) - for _tst_i in $(seq $_tst_max); do - _tst_data="$(echo "$TST_TEST_DATA" | cut -d"$TST_TEST_DATA_IFS" -f$_tst_i)" + for _tst_j in $(seq $_tst_max); do + _tst_data="$(echo "$TST_TEST_DATA" | cut -d"$TST_TEST_DATA_IFS" -f$_tst_j)" _tst_run_tests "$_tst_data" done else _tst_run_tests fi - TST_ITERATIONS=$((TST_ITERATIONS-1)) + _tst_i=$((_tst_i-1)) done - _tst_do_exit + + if [ -n "$TST_DO_CLEANUP" -a -n "$TST_CLEANUP" -a -z "$TST_NO_CLEANUP" ]; then + if command -v $TST_CLEANUP >/dev/null 2>/dev/null; then + $TST_CLEANUP + else + tst_res TWARN "TST_CLEANUP=$TST_CLEANUP declared, but function not defined (or cmd not found)" + fi + fi + + if [ "$TST_MOUNT_FLAG" = 1 ]; then + tst_umount + TST_MOUNT_FLAG= + fi } _tst_run_tests()Signature · 1 line
2.37.1
Signature · 5 lines
Thank you, Richard. -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v3 9/10 shell: Add test 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
--- lib/newlib_tests/shell/tst_all_filesystems.sh | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 lib/newlib_tests/shell/tst_all_filesystems.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_TESTFUNC=test +TST_CNT=2 + +test1() +{ + tst_res TPASS "device using filesystem" +} + +test2() +{ + local pattern + + + if [ "$TST_FS_TYPE" = "exfat" -o "$TST_FS_TYPE" = "ntfs" ]; then + pattern="|fuseblk" + fi + + EXPECT_PASS "grep -E '$TST_MNTPOINT ($TST_FS_TYPE${pattern})' /proc/mounts" +} + +. tst_test.sh +tst_run
Signature · 5 lines
2.37.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v3 09/10] shell: Add test for TST_ALL_FILESYSTEMS=1
Hi,
Quoted 49 lines · Petr Vorel
Unfortunately GitHub Actions don't have loop devices, thus cannot be run in CI:
tst_format_device1 TINFO: timeout per run is 0h 5m 0s /__w/ltp/ltp/lib/tst_device.c:139: TINFO: No free devices foundReviewed-by Cyril Hrubis <[email protected]>Reviewed-by Li Wang <[email protected]>Signed-off-by Petr Vorel <[email protected]>--- lib/newlib_tests/shell/tst_all_filesystems.sh | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 lib/newlib_tests/shell/tst_all_filesystems.shlib/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_TESTFUNC=test +TST_CNT=2 + +test1() +{ + tst_res TPASS "device using filesystem" +} + +test2() +{ + local pattern + + + if [ "$TST_FS_TYPE" = "exfat" -o "$TST_FS_TYPE" = "ntfs" ]; then + pattern="|fuseblk" + fi + + EXPECT_PASS "grep -E '$TST_MNTPOINT ($TST_FS_TYPE${pattern})' /proc/mounts" +} + +. tst_test.sh +tst_runSignature · 1 line
2.37.1
Signature · 5 lines
Thank you, Richard. -- Mailing list info: https://lists.linux.it/listinfo/ltp
RFC PATCH v3 10/10 nfs: Use TST_ALL_FILESYSTEMS=1
In reply to Petr Vorel---
Changes v2->v3:
* restart_daemon nfs-server + tst_sleep 500ms
But still sometimes last test TCONF due server not being ready (restart is not reliable) :(
* Skip NTFS and vfat (NTFS is problematic, vfat IMHO does not make sense to test).
testcases/network/nfs/nfs_stress/nfs_lib.sh | 28 +++++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-)
testcases/network/nfs/nfs_stress/nfs_lib.sh +17 -11
@@ -8,6 +8,7 @@ VERSION=${VERSION:=3} NFILES=${NFILES:=1000} SOCKET_TYPE="${SOCKET_TYPE:-udp}" NFS_TYPE=${NFS_TYPE:=nfs} +TST_SKIP_FILESYSTEMS="ntfs,vfat" nfs_usage() {
@@ -28,7 +29,7 @@ NFS_PARSE_ARGS_CALLER="$TST_PARSE_ARGS" TST_OPTS="v:t:$TST_OPTS" TST_PARSE_ARGS=nfs_parse_args TST_USAGE=nfs_usage -TST_NEEDS_TMPDIR=1 +TST_ALL_FILESYSTEMS=1 TST_NEEDS_ROOT=1 TST_NEEDS_CMDS="$TST_NEEDS_CMDS mount exportfs mount.nfs" TST_SETUP="${TST_SETUP:-nfs_setup}"
@@ -63,7 +64,7 @@ nfs_get_remote_path() done v=${1:-$v} - echo "$TST_TMPDIR/$v/$type" + echo "$TST_MNTPOINT/$v/$type" } nfs_server_udp_enabled()
@@ -162,8 +163,8 @@ nfs_setup() tst_brk TCONF "UDP support disabled on NFS server" fi - local_dir="$TST_TMPDIR/$i/$n" - remote_dir="$TST_TMPDIR/$i/$type" + local_dir="$TST_MNTPOINT/$i/$n" + remote_dir="$TST_MNTPOINT/$i/$type" mkdir -p $local_dir nfs_setup_server $(($$ + n))
@@ -174,7 +175,7 @@ nfs_setup() done if [ "$n" -eq 1 ]; then - cd ${VERSION}/0 + cd $TST_MNTPOINT/$VERSION/0 fi }
@@ -190,19 +191,24 @@ nfs_cleanup() local n=0 for i in $VERSION; do - local_dir="$TST_TMPDIR/$i/$n" - grep -q "$local_dir" /proc/mounts && umount $local_dir + type=$(get_socket_type $n) + remote_dir="$TST_MNTPOINT/$i/$type" + tst_rhost_run -c "test -d $remote_dir && exportfs -u *:$remote_dir" + tst_rhost_run -c "test -d $remote_dir && rm -rf $remote_dir" n=$(( n + 1 )) done n=0 for i in $VERSION; do - type=$(get_socket_type $n) - remote_dir="$TST_TMPDIR/$i/$type" - tst_rhost_run -c "test -d $remote_dir && exportfs -u *:$remote_dir" - tst_rhost_run -c "test -d $remote_dir && rm -rf $remote_dir" + local_dir="$TST_MNTPOINT/$i/$n" + + grep -q "$local_dir" /proc/mounts && umount $local_dir n=$(( n + 1 )) done + + restart_daemon nfs-server + tst_sleep 500ms } +. daemonlib.sh . tst_net.sh
Signature · 1 line
2.37.1
Hello,
If there are no objections then let's merge.
Quoted 510 lines · Petr Vorel
Hi,
changes
v2->v3:
* add $TST_SKIP_FILESYSTEMS implementation
* various fixes fortst_test.sh+ tests
-tst_test.sh: Fixtst_mkfs()for tmpfsDiff to v2:
shell-test-api.txt +4
-0@@ -200,6 +200,8 @@ simply by setting right '$TST_FOO'. |============================================================================= | 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,@@ -230,6 +232,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.tst_fs.h +10
-0@@ -182,6 +182,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. * newlib_tests/shell/tst_mount_device.sh +6
-1@@ -5,7 +5,7 @@ TST_MOUNT_DEVICE=1 TST_FS_TYPE=ext4 TST_TESTFUNC=test -TST_CNT=2 +TST_CNT=3 test1() {@@ -17,5 +17,10 @@ test2() EXPECT_PASS "grep '$TST_MNTPOINT $TST_FS_TYPE' /proc/mounts" } +test3() +{ + tst_brk TCONF "quit early to test early tst_umount" +} + . tst_test.sh tst_runnewlib_tests/shell/tst_mount_device_tmpfs.sh new file +15
-0@@ -0,0 +1,15 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022 Petr Vorel <[email protected]> + +TST_MOUNT_DEVICE=1 +TST_FS_TYPE=tmpfs +TST_TESTFUNC=test + +test() +{ + EXPECT_PASS "cd $TST_MNTPOINT" +} + +. tst_test.sh +tst_runnewlib_tests/shell/tst_skip_filesystems.sh new file +34
-0@@ -0,0 +1,34 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022 Petr Vorel <[email protected]> + +TST_MOUNT_DEVICE=1 +TST_FS_TYPE=ext4 +TST_TESTFUNC=test +TST_SKIP_FILESYSTEMS="btrfs,ext2,ext3,xfs,vfat,exfat,ntfs,tmpfs" +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_runnewlib_tests/shell/tst_skip_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_MOUNT_DEVICE=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_runtst_supported_fs_types.c +18
-0@@ -134,6 +134,24 @@ 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)) { +tst_brk (TCONF ,"%s is not supported by the test" , + fs_type); + } + +return ret; +} +const char **tst_get_supported_fs_types (const char *const *skiplist) {unsigned int i, j =0 ;lib/tst_supported_fs.c +44
-12@@ -5,42 +5,74 @@*/ #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 ); }int main (int argc,char *argv[]) { -const char *skiplist[] = {"tmpfs" ,NULL };const char *const *filesystems; -int i; +int i, ret, cnt =1 ; +char **skiplist =NULL ; +char *fs; -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 '?' : +return 1 ; + +case 'h' : +usage (); +return 0 ; + +case 's' : + fs = optarg; +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 1 ; + } + + fs = optarg; +for (i =0 ; i < cnt; i++) + skiplist[i] =strtok_r (fs,TST_TO_STR (SKIP_DELIMITER ), &fs); +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 ]) -return !tst_fs_is_supported (argv[1 ]); +if (optind < argc) +return !tst_fs_is_supported_skiplist (argv[optind], (const char *const *)skiplist); - filesystems =tst_get_supported_fs_types (skiplist); + filesystems =tst_get_supported_fs_types ((const char *const *)skiplist);for (i =0 ; filesystems[i]; i++)printf ("%s\n" , filesystems[i]);lib/tst_test.sh +30
-12@@ -28,12 +28,13 @@ fi trap "tst_brk TBROK 'test interrupted'" INT trap "unset _tst_setup_timer_pid; tst_brk TBROK 'test terminated'" TERM -# FIXME: debug called more times => check things moved out of it _tst_do_exit() { local ret=0 TST_DO_EXIT=1 + [ "$TST_MOUNT_FLAG" = 1 ] && tst_umount + if [ "$TST_NEEDS_DEVICE" = 1 -a "$TST_DEVICE_FLAG" = 1 ]; then if ! tst_device release "$TST_DEVICE"; then tst_res TWARN "Failed to release device '$TST_DEVICE'"@@ -50,6 +51,8 @@ _tst_do_exit() rm $LTP_IPC_PATH fi + _tst_cleanup_timer + if [ $TST_FAIL -gt 0 ]; then ret=$((ret|1)) fi@@ -338,6 +341,11 @@ tst_mkfs() opts="$@" + if [ "$fs_type" = tmpfs ]; then + tst_res TINFO "Skipping mkfs for TMPFS filesystem" + return + fi + if [ -z "$opts" ]; then if [ "$TST_NEEDS_DEVICE" != 1 ]; then tst_brk "Using default parameters in tst_mkfs requires TST_NEEDS_DEVICE=1"@@ -461,6 +469,7 @@ LTPROOT Prefix for installed LTP (default: /opt/ltp) LTP_COLORIZE_OUTPUT Force colorized output behaviour (y/1 always, n/0: never) LTP_DEV Path to the block device to be used (for .needs_device) LTP_DEV_FS_TYPE Filesystem used for testing (default: ext2) +LTP_SINGLE_FS_TYPE Testing only - specifies filesystem instead all supported (for TST_ALL_FILESYSTEMS=1) LTP_TIMEOUT_MUL Timeout multiplier (must be a number >=1, ceiled to int) TMPDIR Base directory for template directory (for .needs_tmpdir, default: /tmp) EOF@@ -616,10 +625,9 @@ _prepare_device() _tst_run_tcases_per_fs() { - for _tst_fs in $(tst_supported_fs); do - tst_res TINFO "Testing on $_tst_fs" + for _tst_fs in $(tst_supported_fs -s "$TST_SKIP_FILESYSTEMS"); do + tst_res TINFO "=== Testing on $_tst_fs ===" TST_FS_TYPE="$_tst_fs" - _prepare_device _tst_run_iterations done }@@ -631,9 +639,11 @@ tst_run() local _tst_fs 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/[='\''"} \t\/:`].*//'); do + for _tst_i in $(grep '^[^#]*\bTST_' "$TST_TEST_PATH" | sed "s/.*TST_//; s/$_tst_pattern//"); do case "$_tst_i" in ALL_FILESYSTEMS|DISABLE_APPARMOR|DISABLE_SELINUX);; SETUP|CLEANUP|TESTFUNC|ID|CNT|MIN_KVER);;@@ -649,11 +659,12 @@ 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 - for _tst_i in $(grep '^[^#]*\b_tst_' "$TST_TEST_PATH" | sed 's/.*_tst_//; s/[="} \t\/:`].*//'); do + for _tst_i in $(grep '^[^#]*\b_tst_' "$TST_TEST_PATH" | sed "s/.*_tst_//; s/$_tst_pattern//"); do tst_res TWARN "Private variable or function _tst_$_tst_i used!" done fi@@ -687,6 +698,12 @@ tst_run() [ "$TST_FORMAT_DEVICE" = 1 ] && TST_NEEDS_DEVICE=1 [ "$TST_NEEDS_DEVICE" = 1 ] && TST_NEEDS_TMPDIR=1 + if [ "$TST_ALL_FILESYSTEMS" != 1 ]; then + tst_supported_fs -s "$TST_SKIP_FILESYSTEMS" $TST_FS_TYPE + ret=$? + [ $ret -ne 0 ] && return $ret + fi + if [ "$TST_NEEDS_DEVICE" = 1 ]; then TST_DEVICE=$(tst_device acquire)@@ -713,9 +730,8 @@ tst_run() [ -n "$TST_NEEDS_CHECKPOINTS" ] && _tst_init_checkpoints TST_MNTPOINT="${TST_MNTPOINT:-$PWD/mntpoint}" - [ -z "$TST_ALL_FILESYSTEMS" ] && _prepare_device - if [ -n "$TST_ALL_FILESYSTEMS" ]; then + if [ "$TST_ALL_FILESYSTEMS" = 1 ]; then _tst_run_tcases_per_fs else _tst_run_iterations@@ -727,9 +743,12 @@ tst_run() _tst_run_iterations() { local _tst_i=$TST_ITERATIONS + local _tst_j [ "$TST_NEEDS_TMPDIR" = 1 ] && cd "$TST_TMPDIR" + _prepare_device + _tst_setup_timer if [ -n "$TST_SETUP" ]; then@@ -746,8 +765,8 @@ _tst_run_iterations() if [ -n "$TST_TEST_DATA" ]; then tst_require_cmds cut tr wc _tst_max=$(( $(echo $TST_TEST_DATA | tr -cd "$TST_TEST_DATA_IFS" | wc -c) +1)) - for _tst_i in $(seq $_tst_max); do - _tst_data="$(echo "$TST_TEST_DATA" | cut -d"$TST_TEST_DATA_IFS" -f$_tst_i)" + for _tst_j in $(seq $_tst_max); do + _tst_data="$(echo "$TST_TEST_DATA" | cut -d"$TST_TEST_DATA_IFS" -f$_tst_j)" _tst_run_tests "$_tst_data" done else@@ -766,9 +785,8 @@ _tst_run_iterations() if [ "$TST_MOUNT_FLAG" = 1 ]; then tst_umount + TST_MOUNT_FLAG= fi - - _tst_cleanup_timer } _tst_run_tests()misc/lvm/generate_lvm_runfile.sh +1
-1@@ -16,7 +16,7 @@ generate_runfile() trap 'tst_brk TBROK "Cannot create LVM runfile"' ERR 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; domisc/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"network/nfs/nfs_stress/nfs_lib.sh +4
-1@@ -8,6 +8,7 @@ VERSION=${VERSION:=3} NFILES=${NFILES:=1000} SOCKET_TYPE="${SOCKET_TYPE:-udp}" NFS_TYPE=${NFS_TYPE:=nfs} +TST_SKIP_FILESYSTEMS="ntfs,vfat" nfs_usage() {@@ -205,7 +206,9 @@ nfs_cleanup() n=$(( n + 1 )) done - systemctl restart nfs-server + restart_daemon nfs-server + tst_sleep 500ms } +. daemonlib.sh . tst_net.shPetr Vorel (10):
tst_test.sh: Fixtst_mkfs()for tmpfs
tst_device: Add clear command
tst_test.sh: Allow $ ; after whitelisted variabletst_mount_device.sh: Cover earlytst_umountcall
tst_supported_fs: Implement skip list
tst_supported_fs: Support skip list when query single fs
shell: Add $TST_SKIP_FILESYSTEMS + teststst_test.sh: Add $TST_ALL_FILESYSTEMS
shell: Add test for TST_ALL_FILESYSTEMS=1
nfs: Use TST_ALL_FILESYSTEMS=1doc/shell-test-api.txt | 5 + include/tst_fs.h | 10 ++ lib/newlib_tests/shell/tst_all_filesystems.sh | 27 ++++ lib/newlib_tests/shell/tst_mount_device.sh | 7 +- .../shell/tst_mount_device_tmpfs.sh | 15 +++ .../shell/tst_skip_filesystems.sh | 34 +++++ .../shell/tst_skip_filesystems_skip.sh | 16 +++ lib/tst_supported_fs_types.c | 18 +++ testcases/lib/tst_device.c | 20 ++- testcases/lib/tst_supported_fs.c | 56 ++++++-- testcases/lib/tst_test.sh | 126 ++++++++++++------ testcases/misc/lvm/generate_lvm_runfile.sh | 2 +- testcases/misc/lvm/prepare_lvm.sh | 2 +- testcases/network/nfs/nfs_stress/nfs_lib.sh | 28 ++-- 14 files changed, 299 insertions(+), 67 deletions(-) create mode 100755 lib/newlib_tests/shell/tst_all_filesystems.sh create mode 100755 lib/newlib_tests/shell/tst_mount_device_tmpfs.sh create mode 100755 lib/newlib_tests/shell/tst_skip_filesystems.sh create mode 100755 lib/newlib_tests/shell/tst_skip_filesystems_skip.shSignature · 1 line
2.37.1
Signature · 5 lines
Thank you, Richard. -- Mailing list info: https://lists.linux.it/listinfo/ltp