All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iotests/testrunner: Flush after run_test()
@ 2022-05-06 13:42 Hanna Reitz
  2022-05-06 17:07 ` Eric Blake
  2022-05-12 10:25 ` Kevin Wolf
  0 siblings, 2 replies; 3+ messages in thread
From: Hanna Reitz @ 2022-05-06 13:42 UTC (permalink / raw)
  To: qemu-block
  Cc: qemu-devel, Hanna Reitz, Kevin Wolf, Thomas Huth,
	Vladimir Sementsov-Ogievskiy

When stdout is not a terminal, the buffer may not be flushed at each end
of line, so we should flush after each test is done.  This is especially
apparent when run by check-block, in two ways:

First, when running make check-block -jX with X > 1, progress indication
was missing, even though testrunner.py does theoretically print each
test's status once it has been run, even in multi-processing mode.
Flushing after each test restores this progress indication.

Second, sometimes make check-block failed altogether, with an error
message that "too few tests [were] run".  I presume that's because one
worker process in the job pool did not get to flush its stdout before
the main process exited, and so meson did not get to see that worker's
test results.  In any case, by flushing at the end of run_test(), the
problem has disappeared for me.

Signed-off-by: Hanna Reitz <hreitz@redhat.com>
---
 tests/qemu-iotests/testrunner.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/qemu-iotests/testrunner.py b/tests/qemu-iotests/testrunner.py
index aae70a8341..10d9e8ef27 100644
--- a/tests/qemu-iotests/testrunner.py
+++ b/tests/qemu-iotests/testrunner.py
@@ -378,6 +378,7 @@ def run_test(self, test: str,
             else:
                 print(res.casenotrun)
 
+        sys.stdout.flush()
         return res
 
     def run_tests(self, tests: List[str], jobs: int = 1) -> bool:
-- 
2.35.1



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

* Re: [PATCH] iotests/testrunner: Flush after run_test()
  2022-05-06 13:42 [PATCH] iotests/testrunner: Flush after run_test() Hanna Reitz
@ 2022-05-06 17:07 ` Eric Blake
  2022-05-12 10:25 ` Kevin Wolf
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Blake @ 2022-05-06 17:07 UTC (permalink / raw)
  To: Hanna Reitz
  Cc: qemu-block, qemu-devel, Kevin Wolf, Thomas Huth,
	Vladimir Sementsov-Ogievskiy

On Fri, May 06, 2022 at 03:42:15PM +0200, Hanna Reitz wrote:
> When stdout is not a terminal, the buffer may not be flushed at each end
> of line, so we should flush after each test is done.  This is especially
> apparent when run by check-block, in two ways:
> 
> First, when running make check-block -jX with X > 1, progress indication
> was missing, even though testrunner.py does theoretically print each
> test's status once it has been run, even in multi-processing mode.
> Flushing after each test restores this progress indication.
> 
> Second, sometimes make check-block failed altogether, with an error
> message that "too few tests [were] run".  I presume that's because one
> worker process in the job pool did not get to flush its stdout before
> the main process exited, and so meson did not get to see that worker's
> test results.  In any case, by flushing at the end of run_test(), the
> problem has disappeared for me.
> 
> Signed-off-by: Hanna Reitz <hreitz@redhat.com>
> ---
>  tests/qemu-iotests/testrunner.py | 1 +
>  1 file changed, 1 insertion(+)

Reviewed-by: Eric Blake <eblake@redhat.com>

> 
> diff --git a/tests/qemu-iotests/testrunner.py b/tests/qemu-iotests/testrunner.py
> index aae70a8341..10d9e8ef27 100644
> --- a/tests/qemu-iotests/testrunner.py
> +++ b/tests/qemu-iotests/testrunner.py
> @@ -378,6 +378,7 @@ def run_test(self, test: str,
>              else:
>                  print(res.casenotrun)
>  
> +        sys.stdout.flush()
>          return res
>  
>      def run_tests(self, tests: List[str], jobs: int = 1) -> bool:
> -- 
> 2.35.1
> 
> 

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org



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

* Re: [PATCH] iotests/testrunner: Flush after run_test()
  2022-05-06 13:42 [PATCH] iotests/testrunner: Flush after run_test() Hanna Reitz
  2022-05-06 17:07 ` Eric Blake
@ 2022-05-12 10:25 ` Kevin Wolf
  1 sibling, 0 replies; 3+ messages in thread
From: Kevin Wolf @ 2022-05-12 10:25 UTC (permalink / raw)
  To: Hanna Reitz
  Cc: qemu-block, qemu-devel, Thomas Huth, Vladimir Sementsov-Ogievskiy

Am 06.05.2022 um 15:42 hat Hanna Reitz geschrieben:
> When stdout is not a terminal, the buffer may not be flushed at each end
> of line, so we should flush after each test is done.  This is especially
> apparent when run by check-block, in two ways:
> 
> First, when running make check-block -jX with X > 1, progress indication
> was missing, even though testrunner.py does theoretically print each
> test's status once it has been run, even in multi-processing mode.
> Flushing after each test restores this progress indication.
> 
> Second, sometimes make check-block failed altogether, with an error
> message that "too few tests [were] run".  I presume that's because one
> worker process in the job pool did not get to flush its stdout before
> the main process exited, and so meson did not get to see that worker's
> test results.  In any case, by flushing at the end of run_test(), the
> problem has disappeared for me.
> 
> Signed-off-by: Hanna Reitz <hreitz@redhat.com>

Thanks, applied to the block branch.

Kevin



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

end of thread, other threads:[~2022-05-12 10:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-06 13:42 [PATCH] iotests/testrunner: Flush after run_test() Hanna Reitz
2022-05-06 17:07 ` Eric Blake
2022-05-12 10:25 ` Kevin Wolf

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.