Skip to content

[tests] Improve dylink_testf. NFC #14992

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/core/pthread/test_pthread_dylink.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
success
File renamed without changes.
File renamed without changes.
21 changes: 9 additions & 12 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3523,7 +3523,7 @@ def dylink_test(self, main, side, expected=None, header=None, force_c=False,

return self.dylink_testf(main, side, expected, force_c, main_module=main_module, **kwargs)

def dylink_testf(self, main, side, expected=None, force_c=False, main_emcc_args=[],
def dylink_testf(self, main, side=None, expected=None, force_c=False, main_emcc_args=[],
main_module=2,
so_name='liblib.so',
need_reverse=True, **kwargs):
Expand All @@ -3532,8 +3532,10 @@ def dylink_testf(self, main, side, expected=None, force_c=False, main_emcc_args=
old_args = self.emcc_args.copy()
if not expected:
outfile = shared.unsuffixed(main) + '.out'
if os.path.exists(outfile):
expected = read_file(outfile)
expected = read_file(outfile)
if not side:
side, ext = os.path.splitext(main)
side += '_side' + ext

# side settings
self.clear_setting('MAIN_MODULE')
Expand Down Expand Up @@ -4579,9 +4581,7 @@ def test_dylink_argv_argc(self):
def test_dylink_weak(self):
# Verify that weakly defined symbols can be defined in both side module and main
# module but that only one gets used at runtime.
main = test_file('core/test_dylink_weak_main.c')
side = test_file('core/test_dylink_weak_side.c')
self.dylink_testf(main, side, force_c=True, need_reverse=False)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

force_c=True was deleted in the RHS.. Is this intended?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, force_c is only needed when the filename is not specified. In this case it doesn't do anything.

self.dylink_testf(test_file('core/test_dylink_weak.c'), need_reverse=False)

@node_pthreads
@needs_dylink
Expand All @@ -4593,7 +4593,7 @@ def test_dylink_tls(self):
# TODO(sbc): Add tests that depend on importing/exported TLS symbols
# once we figure out how to do that.
self.emcc_args.append('-Wno-experimental')
self.dylink_testf(test_file('core/test_dylink_tls.c'), test_file('core/test_dylink_tls_side.c'),
self.dylink_testf(test_file('core/test_dylink_tls.c'),
need_reverse=False)

def test_random(self):
Expand Down Expand Up @@ -8405,15 +8405,13 @@ def test_pthread_dylink(self):
self.set_setting('LLD_REPORT_UNDEFINED')
self.set_setting('PTHREAD_POOL_SIZE', 2)
main = test_file('core/pthread/test_pthread_dylink.c')
side = test_file('core/pthread/test_pthread_dylink_side.c')

# test with a long .so name, as a regression test for
# https://github.com/emscripten-core/emscripten/issues/14833
# where we had a bug with long names + TextDecoder + pthreads + dylink
very_long_name = 'very_very_very_very_very_very_very_very_very_long.so'

self.dylink_testf(main, side, "success",
so_name=very_long_name,
self.dylink_testf(main, so_name=very_long_name,
need_reverse=False)

@needs_dylink
Expand All @@ -8424,8 +8422,7 @@ def test_pthread_dylink_tls(self):
self.set_setting('USE_PTHREADS')
self.set_setting('PTHREAD_POOL_SIZE=1')
main = test_file('core/pthread/test_pthread_dylink_tls.c')
side = test_file('core/pthread/test_pthread_dylink_tls_side.c')
self.dylink_testf(main, side, need_reverse=False)
self.dylink_testf(main, need_reverse=False)

@needs_dylink
@node_pthreads
Expand Down