From f45fd2f61688410ad2385481993929a805ab67f3 Mon Sep 17 00:00:00 2001 From: Kees Cook Date: Sat, 18 Sep 2021 09:06:12 -0700 Subject: [PATCH] Flush output buffers proactively In the CI logs, QEMU output shows up before the rest of check_log.py output. This is likely due to IO buffering, so explicitly flush buffers in the helper routines and before spawning QEMU. Signed-off-by: Kees Cook --- check_logs.py | 6 ++++++ utils.py | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/check_logs.py b/check_logs.py index 7e68a846..d4197bb6 100755 --- a/check_logs.py +++ b/check_logs.py @@ -132,6 +132,12 @@ def run_boot(build): boot_qemu += ["-t", "20m"] else: boot_qemu += ["-t", "10m"] + + # Before spawning a process with potentially different IO buffering, + # flush the existing buffers so output is ordered correctly. + sys.stdout.flush() + sys.stderr.flush() + try: subprocess.run(boot_qemu, check=True) except subprocess.CalledProcessError as e: diff --git a/utils.py b/utils.py index 420f6160..c0020391 100644 --- a/utils.py +++ b/utils.py @@ -126,10 +126,12 @@ def get_build(): def print_red(msg): print("\033[91m%s\033[0m" % msg, file=sys.stderr) + sys.stderr.flush() def print_yellow(msg): - print("\033[93m%s\033[0m" % msg) + print("\033[93m%s\033[0m" % msg, file=sys.stdout) + sys.stdout.flush() def patch_series_flag(tree):