app/test: flush stdout after forking

Message ID 20210726121627.2324730-1-john.levon@nutanix.com (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers
Series app/test: flush stdout after forking |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/github-robot success github build: passed
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS

Commit Message

John Levon July 26, 2021, 12:16 p.m. UTC
  meson test was not capturing the intended output from the child
process; force a flush to ensure it reaches the test log.

Signed-off-by: John Levon <john.levon@nutanix.com>
---
 app/test/process.h | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Bruce Richardson July 26, 2021, 12:27 p.m. UTC | #1
On Mon, Jul 26, 2021 at 01:16:27PM +0100, John Levon wrote:
> meson test was not capturing the intended output from the child
> process; force a flush to ensure it reaches the test log.
> 
> Signed-off-by: John Levon <john.levon@nutanix.com>
> ---
>  app/test/process.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/app/test/process.h b/app/test/process.h
> index a09a088477..0ed91a939e 100644
> --- a/app/test/process.h
> +++ b/app/test/process.h
> @@ -110,6 +110,7 @@ process_dup(const char *const argv[], int numargs, const char *env_value)
>  		for (i = 0; i < num; i++)
>  			printf("'%s' ", argv_cpy[i]);
>  		printf("\n");
> +		fflush(stdout);
>  
I thought that "\n" normally flushes in most cases, but if explicit flush
is necessary for some cases, let's add it.

Acked-by: Bruce Richardson <bruce.richardson@intel.com>
  
John Levon July 26, 2021, 12:33 p.m. UTC | #2
On Mon, Jul 26, 2021 at 01:27:48PM +0100, Bruce Richardson wrote:

> On Mon, Jul 26, 2021 at 01:16:27PM +0100, John Levon wrote:
> > meson test was not capturing the intended output from the child
> > process; force a flush to ensure it reaches the test log.
> > 
> > Signed-off-by: John Levon <john.levon@nutanix.com>
> > ---
> >  app/test/process.h | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/app/test/process.h b/app/test/process.h
> > index a09a088477..0ed91a939e 100644
> > --- a/app/test/process.h
> > +++ b/app/test/process.h
> > @@ -110,6 +110,7 @@ process_dup(const char *const argv[], int numargs, const char *env_value)
> >  		for (i = 0; i < num; i++)
> >  			printf("'%s' ", argv_cpy[i]);
> >  		printf("\n");
> > +		fflush(stdout);
> >  
> I thought that "\n" normally flushes in most cases, but if explicit flush
> is necessary for some cases, let's add it.

stdout is only line-buffered if it's to a tty, but regardless, meson test
appears to wrap all output into tmp files. I didn't dig into exactly what's
going on with meson (or why the fork() matters), but certainly you don't get
this output *at all* under meson test (even with -v), but you do running
dpdk_test directly.

Furthermore, looks like others have found the same thing as there are several
other direct fflush()es.

regards
john
  
Thomas Monjalon July 31, 2021, 5:44 p.m. UTC | #3
26/07/2021 14:27, Bruce Richardson:
> On Mon, Jul 26, 2021 at 01:16:27PM +0100, John Levon wrote:
> > meson test was not capturing the intended output from the child
> > process; force a flush to ensure it reaches the test log.
> > 
> > Signed-off-by: John Levon <john.levon@nutanix.com>
> 
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>

Applied, thanks.
  

Patch

diff --git a/app/test/process.h b/app/test/process.h
index a09a088477..0ed91a939e 100644
--- a/app/test/process.h
+++ b/app/test/process.h
@@ -110,6 +110,7 @@  process_dup(const char *const argv[], int numargs, const char *env_value)
 		for (i = 0; i < num; i++)
 			printf("'%s' ", argv_cpy[i]);
 		printf("\n");
+		fflush(stdout);
 
 		/* set the environment variable */
 		if (setenv(RECURSIVE_ENV_VAR, env_value, 1) != 0)