|
9 | 9 | from runner import RunnerCore, path_from_root, get_zlib_library, get_bullet_library
|
10 | 10 | import tools.line_endings
|
11 | 11 |
|
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 |
| - |
21 | 12 | class temp_directory(object):
|
22 | 13 | def __enter__(self):
|
23 | 14 | self.directory = tempfile.mkdtemp(prefix='emsripten_temp_', dir=TEMP_DIR)
|
@@ -366,12 +357,13 @@ def test_emcc_multiprocess_cache_access(self):
|
366 | 357 | tasks = []
|
367 | 358 | num_times_libc_was_built = 0
|
368 | 359 | 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) |
371 | 361 | tasks += [p]
|
372 | 362 | 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 |
375 | 367 | assert os.path.exists(cache_dir_name), 'The cache directory %s must exist after the build' % cache_dir_name
|
376 | 368 | assert os.path.exists(os.path.join(cache_dir_name, 'asmjs', 'libc.bc')), 'The cache directory must contain a built libc'
|
377 | 369 | 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