Skip to content

Commit 7645977

Browse files
authored
Fix parallel race condition in tests emrun.test_emrun and emrun.test_emrun_pthreads (#26790)
Fix parallel race condition in tests emrun.test_emrun and emrun.test_emrun_pthreads, which would not be able to run simultaneously, since they attempted to launch emrun server on the same port. Each parallel process needs its own server port, but different individual test cases do not.
1 parent bd45df6 commit 7645977

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

test/test_browser.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5765,8 +5765,14 @@ def test_emrun(self):
57655765
# delete it. Therefore switch away from that directory before launching.
57665766
os.chdir(path_from_root())
57675767

5768+
# emrun tests may run in parallel processes, so each test case should use a unique port number
5769+
# to avoid port address already in use errors.
5770+
port = '6939'
5771+
if '-pthread' in self.cflags:
5772+
port = '6940'
5773+
57685774
args_base = [EMRUN, '--timeout', '30', '--safe_firefox_profile',
5769-
'--kill-exit', '--port', '6939', '--verbose',
5775+
'--kill-exit', '--port', port, '--verbose',
57705776
'--log-stdout', self.in_dir('stdout.txt'),
57715777
'--log-stderr', self.in_dir('stderr.txt')]
57725778

@@ -5791,9 +5797,9 @@ def test_emrun(self):
57915797
for args in [
57925798
[],
57935799
['--port', '0'],
5794-
['--private_browsing', '--port', '6941'],
5795-
['--dump_out_directory', 'other dir/multiple', '--port', '6942'],
5796-
['--dump_out_directory=foo_bar', '--port', '6942'],
5800+
['--private_browsing'],
5801+
['--dump_out_directory', 'other dir/multiple'],
5802+
['--dump_out_directory=foo_bar'],
57975803
]:
57985804
args = args_base + args + [self.in_dir('test_emrun.html'), '--', '1', '2', '--3', 'escaped space', 'with_underscore']
57995805
print(shlex.join(args))

0 commit comments

Comments
 (0)