All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [RFC PATCH 1/1] tst_test.sh: Fix filesystem support detection
@ 2022-09-21 10:26 Petr Vorel
  2022-09-22  4:32 ` Li Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Petr Vorel @ 2022-09-21 10:26 UTC (permalink / raw)
  To: ltp

Filesystem detection of locally used filesystem was broken on tests
which did not use TST_ALL_FILESYSTEMS as it 1) expected used filesystem
is $TST_FS_TYPE 2) this variable was not yet set.

Also this check makes sense only if test defines TST_SKIP_FILESYSTEMS
(to align with the condition in do_test_setup() in C API).

Move filesystem check after (optional) cd "$TST_TMPDIR" (TMPDIR can have
different filesystem).

Not printing extra TINFO "$_tst_fs is supported by the test" (which is
printed in C API) when test is supported, because there is already
similar TINFO from testcases/lib/tst_supported_fs.c:
tst_supported_fs.c:104: TINFO: btrfs is not skipped

Fixes: 1f6bd6e66 ("tst_test.sh: Add $TST_ALL_FILESYSTEMS")

Reported-by: Martin Doucha <mdoucha@suse.cz>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
First, sorry for introducing a regression.

I don't like df and tail dependency. Also df output is stable (even on
busybox), but I'd prefer to use code from do_test_setup() in lib/tst_test.c:

	long fs_type = tst_fs_type(".");
	const char *fs_name = tst_fs_type_name(fs_type);

Instead adding yet another binary, I wonder if we could add extra getopt
parameter to ask for current filesystem.

i.e. to replace:
-tst_supported_fs -s skip_list fs_type
+tst_supported_fs -s skip_list -d DIR

Because 'tst_supported_fs -s skip_list fs_type' mode is used only in
tst_test.sh.

Whole help would be:

$ ./testcases/lib/tst_supported_fs -h
* all filesystems
tst_supported_fs [-s skip_list]
   print the list of supported filesystems
   if fs_type is supported and not in skip_list (optional),
   print list of supported filesystems and return 0
   if fs_type isn't supported or in skip_list, return 1

* single filesystem
tst_supported_fs fs_type
   if fs_type is supported, return 0 otherwise return 1

-tst_supported_fs -s skip_list fs_type
+tst_supported_fs -s skip_list -d DIR
   if fs_type is in skip_list, return 1 otherwise return 0

fs_type - a specified filesystem type
skip_list - filesystems to skip, delimiter: ','

 testcases/lib/tst_test.sh | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index 229317713..1691846ae 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -703,12 +703,6 @@ tst_run()
 	[ "$TST_FORMAT_DEVICE" = 1 -o "$TST_ALL_FILESYSTEMS" = 1 ] && TST_NEEDS_DEVICE=1
 	[ "$TST_NEEDS_DEVICE" = 1 ] && TST_NEEDS_TMPDIR=1
 
-	if [ "$TST_ALL_FILESYSTEMS" != 1 ]; then
-		if ! tst_supported_fs -s "$TST_SKIP_FILESYSTEMS" $TST_FS_TYPE > /dev/null; then
-			tst_brk TCONF "$TST_FS_TYPE is skipped by the test"
-		fi
-	fi
-
 	if [ "$TST_NEEDS_DEVICE" = 1 ]; then
 		TST_DEVICE=$(tst_device acquire)
 
@@ -736,6 +730,15 @@ tst_run()
 		cd "$TST_TMPDIR"
 	fi
 
+	if [ "$TST_ALL_FILESYSTEMS" != 1 -a "$TST_SKIP_FILESYSTEMS" ]; then
+		tst_require_cmds df tail
+		_tst_fs="$(df -T . | tail -1 | awk '{print $2}')"
+		[ "$_tst_fs" ] || tst_brk TBROK "failed to detect filesystem for $PWD"
+		if ! tst_supported_fs -s "$TST_SKIP_FILESYSTEMS" $_tst_fs > /dev/null; then
+			tst_brk TCONF "$_tst_fs is not supported by the test"
+		fi
+	fi
+
 	[ -n "$TST_NEEDS_CHECKPOINTS" ] && _tst_init_checkpoints
 
 	TST_MNTPOINT="${TST_MNTPOINT:-$PWD/mntpoint}"
-- 
2.37.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [LTP] [RFC PATCH 1/1] tst_test.sh: Fix filesystem support detection
  2022-09-21 10:26 [LTP] [RFC PATCH 1/1] tst_test.sh: Fix filesystem support detection Petr Vorel
@ 2022-09-22  4:32 ` Li Wang
  2022-09-22  7:07   ` Petr Vorel
  0 siblings, 1 reply; 3+ messages in thread
From: Li Wang @ 2022-09-22  4:32 UTC (permalink / raw)
  To: Petr Vorel; +Cc: LTP List


[-- Attachment #1.1: Type: text/plain, Size: 1643 bytes --]

On Wed, Sep 21, 2022 at 6:27 PM Petr Vorel <pvorel@suse.cz> wrote:

> Filesystem detection of locally used filesystem was broken on tests
> which did not use TST_ALL_FILESYSTEMS as it 1) expected used filesystem
> is $TST_FS_TYPE 2) this variable was not yet set.
>
> Also this check makes sense only if test defines TST_SKIP_FILESYSTEMS
> (to align with the condition in do_test_setup() in C API).
>
> Move filesystem check after (optional) cd "$TST_TMPDIR" (TMPDIR can have
> different filesystem).
>
> Not printing extra TINFO "$_tst_fs is supported by the test" (which is
> printed in C API) when test is supported, because there is already
> similar TINFO from testcases/lib/tst_supported_fs.c:
> tst_supported_fs.c:104: TINFO: btrfs is not skipped
>
> Fixes: 1f6bd6e66 ("tst_test.sh: Add $TST_ALL_FILESYSTEMS")
>
> Reported-by: Martin Doucha <mdoucha@suse.cz>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> First, sorry for introducing a regression.
>
> I don't like df and tail dependency. Also df output is stable (even on
> busybox), but I'd prefer to use code from do_test_setup() in
> lib/tst_test.c:
>
>         long fs_type = tst_fs_type(".");
>         const char *fs_name = tst_fs_type_name(fs_type);
>
> Instead adding yet another binary, I wonder if we could add extra getopt
> parameter to ask for current filesystem.
>
> i.e. to replace:
> -tst_supported_fs -s skip_list fs_type
> +tst_supported_fs -s skip_list -d DIR
>

+1, and Martin already sent out the achievement patch,
you can rebase this patch on that.

And I'd like to vote for merging your both patches for
adding to the new release.


-- 
Regards,
Li Wang

[-- Attachment #1.2: Type: text/html, Size: 2671 bytes --]

[-- Attachment #2: Type: text/plain, Size: 60 bytes --]


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [LTP] [RFC PATCH 1/1] tst_test.sh: Fix filesystem support detection
  2022-09-22  4:32 ` Li Wang
@ 2022-09-22  7:07   ` Petr Vorel
  0 siblings, 0 replies; 3+ messages in thread
From: Petr Vorel @ 2022-09-22  7:07 UTC (permalink / raw)
  To: Li Wang; +Cc: LTP List

Hi Li, all,

...
> > Instead adding yet another binary, I wonder if we could add extra getopt
> > parameter to ask for current filesystem.

> > i.e. to replace:
> > -tst_supported_fs -s skip_list fs_type
> > +tst_supported_fs -s skip_list -d DIR


> +1, and Martin already sent out the achievement patch,
> you can rebase this patch on that.
Yep, I'm planning to do.

> And I'd like to vote for merging your both patches for
> adding to the new release.
+1

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-09-22  7:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-21 10:26 [LTP] [RFC PATCH 1/1] tst_test.sh: Fix filesystem support detection Petr Vorel
2022-09-22  4:32 ` Li Wang
2022-09-22  7:07   ` Petr Vorel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.