Skip to content

Commit 53ecc30

Browse files
authored
Simplify test_memprof_requirements. NFC (#25573)
No need to a JS library file here, or a custom source file.
1 parent bb11bae commit 53ecc30

File tree

1 file changed

+11
-24
lines changed

1 file changed

+11
-24
lines changed

test/test_core.py

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8587,32 +8587,19 @@ def test_memprof_requirements(self):
85878587
# This test checks for the global variables required to run the memory
85888588
# profiler. It would fail if these variables were made no longer global
85898589
# or if their identifiers were changed.
8590-
create_file('main.c', '''
8591-
int check_memprof_requirements();
8592-
8593-
int main() {
8594-
return check_memprof_requirements();
8595-
}
8596-
''')
8597-
create_file('lib.js', '''
8598-
addToLibrary({
8599-
check_memprof_requirements: () => {
8600-
if (typeof _emscripten_stack_get_base === 'function' &&
8601-
typeof _emscripten_stack_get_end === 'function' &&
8602-
typeof _emscripten_stack_get_current === 'function' &&
8603-
typeof Module['___heap_base'] === 'number' &&
8604-
Module['___heap_base'] > 0) {
8605-
out('able to run memprof');
8606-
return 0;
8607-
} else {
8608-
out('missing the required variables to run memprof');
8609-
return 1;
8610-
}
8590+
create_file('pre.js', '''
8591+
Module = {
8592+
onRuntimeInitialized: () => {
8593+
assert(typeof _emscripten_stack_get_base === 'function');
8594+
assert(typeof _emscripten_stack_get_end === 'function');
8595+
assert(typeof _emscripten_stack_get_current === 'function');
8596+
assert(typeof Module['___heap_base'] === 'number');
8597+
assert(Module['___heap_base'] > 0);
8598+
out('able to run memprof');
86118599
}
8612-
});
8600+
};
86138601
''')
8614-
self.cflags += ['--memoryprofiler', '--js-library', 'lib.js']
8615-
self.do_runf('main.c', 'able to run memprof')
8602+
self.do_runf('hello_world.c', 'able to run memprof', cflags=['--memoryprofiler', '--pre-js=pre.js'])
86168603

86178604
@no_wasmfs('depends on MEMFS which WASMFS does not have')
86188605
def test_fs_dict(self):

0 commit comments

Comments
 (0)