diff mbox series

[2/2] tst_test: Don't print hints if failed to acquire

Message ID 20240527202858.350200-2-pvorel@suse.cz
State Superseded
Headers show
Series [1/2] tst_device: Print info about acquiring device | expand

Commit Message

Petr Vorel May 27, 2024, 8:28 p.m. UTC
It does not make much sense to print hints when it failed to acquire the
device. It can be misleading.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 lib/tst_test.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Cyril Hrubis May 29, 2024, 5:51 p.m. UTC | #1
Hi!
This is a great catch but I do not think that it should be limited to
the device init. We should distable the hints during the whole library
setup and only enable them once we actually start running the test.

I guess that we need:

diff --git a/lib/tst_test.c b/lib/tst_test.c
index 190e8da2a..47d0ecf7d 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -61,6 +61,7 @@ static int mntpoint_mounted;
 static int ovl_mounted;
 static struct timespec tst_start_time; /* valid only for test pid */
 static int tdebug;
+static int show_failure_hints;

 struct results {
        int passed;
@@ -883,7 +884,8 @@ static void do_exit(int ret)

                if (results->broken) {
                        ret |= TBROK;
-                       print_failure_hints();
+                       if (show_failure_hints)
+                               print_failure_hints();
                }

                fprintf(stderr, "\nSummary:\n");
@@ -1740,6 +1742,8 @@ void tst_run_tcases(int argc, char *argv[], struct tst_test *self)
        if (tst_test->test_variants)
                test_variants = tst_test->test_variants;

+       show_failure_hints = 1;
+
        for (tst_variant = 0; tst_variant < test_variants; tst_variant++) {
                if (tst_test->all_filesystems)
                        ret |= run_tcases_per_fs();
Petr Vorel May 30, 2024, 2:49 p.m. UTC | #2
Hi Cyril,

> Hi!
> This is a great catch but I do not think that it should be limited to
> the device init. We should distable the hints during the whole library
> setup and only enable them once we actually start running the test.

+1. I suspected that, but did not have enough time to explore. Thanks for
raising this.

> I guess that we need:

I'll try to test it, hopefully next week. Or feel free to send your patch
and just put me in some tag (e.g.  Co-developed-by:, but not that important).

Kind regards,
Petr
diff mbox series

Patch

diff --git a/lib/tst_test.c b/lib/tst_test.c
index 8c212c983..834acda0e 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -88,6 +88,9 @@  int TST_ERR;
 int TST_PASS;
 long TST_RET;
 
+static struct tst_device tdev;
+struct tst_device *tst_device;
+
 static void do_cleanup(void);
 static void do_exit(int ret) __attribute__ ((noreturn));
 
@@ -883,7 +886,9 @@  static void do_exit(int ret)
 
 		if (results->broken) {
 			ret |= TBROK;
-			print_failure_hints();
+
+			if (!(tst_test->needs_device && !tdev.dev))
+				print_failure_hints();
 		}
 
 		fprintf(stderr, "\nSummary:\n");
@@ -965,9 +970,6 @@  static const char *get_tid(char *argv[])
 	return argv[0];
 }
 
-static struct tst_device tdev;
-struct tst_device *tst_device;
-
 static void assert_test_fn(void)
 {
 	int cnt = 0;