diff --git a/test/test_core.py b/test/test_core.py index d76f59bd8f249..4947402b91283 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -8587,32 +8587,19 @@ def test_memprof_requirements(self): # This test checks for the global variables required to run the memory # profiler. It would fail if these variables were made no longer global # or if their identifiers were changed. - create_file('main.c', ''' - int check_memprof_requirements(); - - int main() { - return check_memprof_requirements(); - } - ''') - create_file('lib.js', ''' - addToLibrary({ - check_memprof_requirements: () => { - if (typeof _emscripten_stack_get_base === 'function' && - typeof _emscripten_stack_get_end === 'function' && - typeof _emscripten_stack_get_current === 'function' && - typeof Module['___heap_base'] === 'number' && - Module['___heap_base'] > 0) { - out('able to run memprof'); - return 0; - } else { - out('missing the required variables to run memprof'); - return 1; - } + create_file('pre.js', ''' + Module = { + onRuntimeInitialized: () => { + assert(typeof _emscripten_stack_get_base === 'function'); + assert(typeof _emscripten_stack_get_end === 'function'); + assert(typeof _emscripten_stack_get_current === 'function'); + assert(typeof Module['___heap_base'] === 'number'); + assert(Module['___heap_base'] > 0); + out('able to run memprof'); } - }); + }; ''') - self.cflags += ['--memoryprofiler', '--js-library', 'lib.js'] - self.do_runf('main.c', 'able to run memprof') + self.do_runf('hello_world.c', 'able to run memprof', cflags=['--memoryprofiler', '--pre-js=pre.js']) @no_wasmfs('depends on MEMFS which WASMFS does not have') def test_fs_dict(self):