Skip to contentSkip to conversation

app/test: flush stdout after forking

PATCH Applied John Levon 3 participants 4 messages Jul 26, 2021 – Jul 31, 2021

lore
Share & tools
lore

John Levon

author
#0 lore raw

PATCH 1/1 app/test: flush stdout after forking

meson test was not capturing the intended output from the child process; force a flush to ensure it reaches the test log.

---
 app/test/process.h | 1 +
 1 file changed, 1 insertion(+)
app/test/process.h +1 -0
index a09a088477..0ed91a939e 100644
@@ -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)
Signature · 1 line
2.25.1
Acked-by on v1 1/1
#1 lore raw
Quoted 13 lines · John Levon

meson test was not capturing the intended output from the child process; force a flush to ensure it reaches the test log.

---
 app/test/process.h | 1 +
 1 file changed, 1 insertion(+)
app/test/process.h +0 -0
index a09a088477..0ed91a939e 100644

app/test/process.h process_dup(const char *const argv[], int numargs, const char *env_value) · line 114

Quoted 5 lines
app/test/process.h +1 -0
@@ -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.

author
#2 lore raw
Quoted 9 lines · Bruce Richardson
Quoted 8 lines · John Levon

meson test was not capturing the intended output from the child process; force a flush to ensure it reaches the test log.

---
 app/test/process.h | 1 +
 1 file changed, 1 insertion(+)
Quoted 12 lines

app/test/process.h process_dup(const char *const argv[], int numargs, const char *env_value) · line 114

Quoted 10 lines
app/test/process.h +1 -0
index a09a088477..0ed91a939e 100644
@@ -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