aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShaopeng Tan <[email protected]>2023-04-13 16:22:56 +0900
committerShuah Khan <[email protected]>2023-04-13 11:34:12 -0600
commita080b6e74b241dbc7e13dd378d6f6fc884579196 (patch)
treeb572b6b6ab420e132cc9f0d4d957398f312de376
parent1e359b6a9422a2bdef14798d539e9d5783bdd5c1 (diff)
selftests/resctrl: Flush stdout file buffer before executing fork()
When a process has buffered output, a child process created by fork() will also copy buffered output. When using kselftest framework, the output (resctrl test result message) will be printed multiple times. Add fflush() to flush out the buffered output before executing fork(). Reviewed-by: Shuah Khan <[email protected]> Reviewed-by: Reinette Chatre <[email protected]> Signed-off-by: Shaopeng Tan <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
-rw-r--r--tools/testing/selftests/resctrl/cat_test.c1
-rw-r--r--tools/testing/selftests/resctrl/resctrl_val.c1
-rw-r--r--tools/testing/selftests/resctrl/resctrlfs.c1
3 files changed, 3 insertions, 0 deletions
diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c
index 08070d4fa735..38c10a8c1814 100644
--- a/tools/testing/selftests/resctrl/cat_test.c
+++ b/tools/testing/selftests/resctrl/cat_test.c
@@ -167,6 +167,7 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type)
return errno;
}
+ fflush(stdout);
bm_pid = fork();
/* Set param values for child thread which will be allocated bitmask
diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c
index 00864242d76c..e632657995c7 100644
--- a/tools/testing/selftests/resctrl/resctrl_val.c
+++ b/tools/testing/selftests/resctrl/resctrl_val.c
@@ -629,6 +629,7 @@ int resctrl_val(char **benchmark_cmd, struct resctrl_val_param *param)
* Fork to start benchmark, save child's pid so that it can be killed
* when needed
*/
+ fflush(stdout);
bm_pid = fork();
if (bm_pid == -1) {
perror("# Unable to fork");
diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c
index b31b1d9e41d1..fb00245dee92 100644
--- a/tools/testing/selftests/resctrl/resctrlfs.c
+++ b/tools/testing/selftests/resctrl/resctrlfs.c
@@ -678,6 +678,7 @@ int filter_dmesg(void)
perror("pipe");
return ret;
}
+ fflush(stdout);
pid = fork();
if (pid == 0) {
close(pipefds[0]);