Skip to content

Commit 6d2798e

Browse files
saschanazkripken
authored andcommitted
Check process failure in test_emcc_multiprocess_cache_access (#5891)
* use subprocess.Popen + check return code * show return code
1 parent b67c3d6 commit 6d2798e

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

tests/test_other.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,6 @@
99
from runner import RunnerCore, path_from_root, get_zlib_library, get_bullet_library
1010
import tools.line_endings
1111

12-
# Runs an emcc task (used from another process in test test_emcc_multiprocess_cache_access, needs to be at top level for it to be pickleable).
13-
def multiprocess_task(c_file, cache_dir_name):
14-
output = run_process([PYTHON, EMCC, c_file, '--cache', cache_dir_name], stderr=subprocess.STDOUT, stdout=PIPE).stdout
15-
if len(output.strip()) > 0:
16-
print('------')
17-
print(output)
18-
print('------')
19-
sys.exit(1 if 'generating system library: libc.bc' in output else 0)
20-
2112
class temp_directory(object):
2213
def __enter__(self):
2314
self.directory = tempfile.mkdtemp(prefix='emsripten_temp_', dir=TEMP_DIR)
@@ -366,12 +357,13 @@ def test_emcc_multiprocess_cache_access(self):
366357
tasks = []
367358
num_times_libc_was_built = 0
368359
for i in range(3):
369-
p = multiprocessing.Process(target=multiprocess_task, args=(c_file,cache_dir_name,))
370-
p.start()
360+
p = subprocess.Popen([PYTHON, EMCC, c_file, '--cache', cache_dir_name], stderr=subprocess.STDOUT, stdout=PIPE, universal_newlines=True)
371361
tasks += [p]
372362
for p in tasks:
373-
p.join()
374-
num_times_libc_was_built += p.exitcode
363+
stdout, stderr = p.communicate()
364+
assert not p.returncode, 'A child process failed with return code %s: %s' % (p.returncode, stderr)
365+
if 'generating system library: libc.bc' in stdout:
366+
num_times_libc_was_built += 1
375367
assert os.path.exists(cache_dir_name), 'The cache directory %s must exist after the build' % cache_dir_name
376368
assert os.path.exists(os.path.join(cache_dir_name, 'asmjs', 'libc.bc')), 'The cache directory must contain a built libc'
377369
assert num_times_libc_was_built == 1, 'Exactly one child process should have triggered libc build! (instead %d processes did)' % num_times_libc_was_built

0 commit comments

Comments
 (0)