MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / test_Module_dynamicLibraries

Method test_Module_dynamicLibraries

test/test_core.py:9413–9462  ·  view source on GitHub ↗
(self, args)

Source from the content-addressed store, hash-verified

9411 'pthreads': (['-sPROXY_TO_PTHREAD', '-sEXIT_RUNTIME', '-pthread', '-Wno-experimental'],),
9412 })
9413 def test_Module_dynamicLibraries(self, args):
9414 # test that Module.dynamicLibraries works with pthreads
9415 self.cflags += args
9416 self.cflags += ['--pre-js', 'pre.js', '-sINCOMING_MODULE_JS_API=dynamicLibraries']
9417 self.cflags += ['--js-library', 'lib.js']
9418 # This test is for setting dynamicLibraries at runtime, so we don't
9419 # want emscripten loading `libside.so` automatically (which it would
9420 # do without this setting)
9421 self.set_setting('NO_AUTOLOAD_DYLIBS')
9422
9423 create_file('pre.js', '''
9424 if (typeof ENVIRONMENT_IS_PTHREAD == 'undefined' || !ENVIRONMENT_IS_PTHREAD) {
9425 // Load libside.so on the main thread, this would be equivalent to
9426 // defining it outside the module (e.g. in MODULARIZE mode).
9427 Module['dynamicLibraries'] = ['libside.so'];
9428 }
9429 ''')
9430
9431 create_file('lib.js', '''
9432 addToLibrary({
9433 mainCallback: () => {
9434#if PTHREADS
9435 err('sharedModules: ' + Object.keys(sharedModules));
9436 assert('libside.so' in sharedModules);
9437 assert(sharedModules['libside.so'] instanceof WebAssembly.Module);
9438#endif
9439 },
9440 })
9441 ''')
9442
9443 if args:
9444 self.require_pthreads()
9445
9446 self.dylink_test(
9447 r'''
9448 void mainCallback();
9449
9450 #include <stdio.h>
9451 int side();
9452 int main() {
9453 mainCallback();
9454 printf("result is %d\n", side());
9455 return 0;
9456 }
9457 ''&#x27;,
9458 r''&#x27;
9459 int side() { return 42; }
9460 ''&#x27;,
9461 'result is 42',
9462 force_c=True)
9463
9464 # Tests the emscripten_get_exported_function() API.
9465 @also_with_minimal_runtime

Callers

nothing calls this directly

Calls 4

dylink_testMethod · 0.95
create_fileFunction · 0.90
set_settingMethod · 0.80
require_pthreadsMethod · 0.80

Tested by

no test coverage detected