From de6ab1bedab4597614050fed2bc23ff4d883a7e9 Mon Sep 17 00:00:00 2001 From: Eric Engestrom Date: Tue, 29 Apr 2025 17:48:51 +0200 Subject: [PATCH] intel/compiler tests: rewrite subprocess handling in run-test.py `subprocess.Popen()` returns immediately, and the subprocess might not have finished by the time `stdout` is read on the next line, spuriously failing the tests. `subprocess.check_output()` makes sure the output is available before returning, solving this issue; it additionally raises an error if the subprocess failed, giving a better error than a failed diff later in the script. cc: mesa-stable Part-of: --- src/intel/compiler/elk/tests/run-test.py | 6 ++---- src/intel/compiler/tests/run-test.py | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/intel/compiler/elk/tests/run-test.py b/src/intel/compiler/elk/tests/run-test.py index f90356138cd..1b85726e0d5 100755 --- a/src/intel/compiler/elk/tests/run-test.py +++ b/src/intel/compiler/elk/tests/run-test.py @@ -48,10 +48,8 @@ for asm_file in args.gen_folder.glob('*.asm'): '--gen', args.gen_name, asm_file ] - with subprocess.Popen(command, - stdout=subprocess.PIPE, - stderr=subprocess.DEVNULL) as cmd: - lines_after = [line.decode('ascii') for line in cmd.stdout.readlines()] + stdout = subprocess.check_output(command, timeout=1).decode() + lines_after = stdout.splitlines(keepends=True) except OSError as e: if e.errno == errno.ENOEXEC: print('Skipping due to inability to run host binaries.', diff --git a/src/intel/compiler/tests/run-test.py b/src/intel/compiler/tests/run-test.py index 6178a120496..5cf0d1506b6 100755 --- a/src/intel/compiler/tests/run-test.py +++ b/src/intel/compiler/tests/run-test.py @@ -48,10 +48,8 @@ for asm_file in args.gen_folder.glob('*.asm'): '--gen', args.gen_name, asm_file ] - with subprocess.Popen(command, - stdout=subprocess.PIPE, - stderr=subprocess.DEVNULL) as cmd: - lines_after = [line.decode('ascii') for line in cmd.stdout.readlines()] + stdout = subprocess.check_output(command, timeout=1).decode() + lines_after = stdout.splitlines(keepends=True) except OSError as e: if e.errno == errno.ENOEXEC: print('Skipping due to inability to run host binaries.',