Skip to content

Commit f388f6f

Browse files
authored
Prefer mb/gb when specifying memory settings. NFC. (#12965)
This didn't used to be supported by set_settings but it is since #9243.
1 parent 5b642f2 commit f388f6f

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

tests/runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ def _test_dylink_dso_needed(self, do_run):
929929
self.clear_setting('RUNTIME_LINKED_LIBS')
930930

931931
# XXX in wasm each lib load currently takes 5MB; default INITIAL_MEMORY=16MB is thus not enough
932-
self.set_setting('INITIAL_MEMORY', 32 * 1024 * 1024)
932+
self.set_setting('INITIAL_MEMORY', '32mb')
933933

934934
so = '.wasm' if self.is_wasm() else '.js'
935935

tests/test_core.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2933,7 +2933,7 @@ def test_dlfcn_varargs(self):
29332933
@needs_dlfcn
29342934
def test_dlfcn_alignment_and_zeroing(self):
29352935
self.prep_dlfcn_lib()
2936-
self.set_setting('INITIAL_MEMORY', 16 * 1024 * 1024)
2936+
self.set_setting('INITIAL_MEMORY', '16mb')
29372937
create_test_file('liblib.cpp', r'''
29382938
extern "C" {
29392939
int prezero = 0;
@@ -2948,7 +2948,7 @@ def test_dlfcn_alignment_and_zeroing(self):
29482948
self.emcc_args += ['--embed-file', curr]
29492949

29502950
self.prep_dlfcn_main()
2951-
self.set_setting('INITIAL_MEMORY', 128 * 1024 * 1024)
2951+
self.set_setting('INITIAL_MEMORY', '128mb')
29522952
src = r'''
29532953
#include <stdio.h>
29542954
#include <stdlib.h>
@@ -3277,7 +3277,7 @@ def test_dlfcn_funcs(self):
32773277
@needs_dlfcn
32783278
def test_dlfcn_mallocs(self):
32793279
# will be exhausted without functional malloc/free
3280-
self.set_setting('INITIAL_MEMORY', 64 * 1024 * 1024)
3280+
self.set_setting('INITIAL_MEMORY', '64mb')
32813281

32823282
self.prep_dlfcn_lib()
32833283
create_test_file('liblib.c', r'''
@@ -3464,7 +3464,7 @@ def indir(name):
34643464
self.emcc_args += ['--embed-file', '.@/']
34653465

34663466
# XXX in wasm each lib load currently takes 5MB; default INITIAL_MEMORY=16MB is thus not enough
3467-
self.set_setting('INITIAL_MEMORY', 32 * 1024 * 1024)
3467+
self.set_setting('INITIAL_MEMORY', '32mb')
34683468

34693469
src = r'''
34703470
#include <dlfcn.h>
@@ -4285,7 +4285,7 @@ def test_dylink_raii_exceptions(self):
42854285
@needs_dlfcn
42864286
@disabled('https://github.com/emscripten-core/emscripten/issues/12815')
42874287
def test_dylink_hyper_dupe(self):
4288-
self.set_setting('INITIAL_MEMORY', 64 * 1024 * 1024)
4288+
self.set_setting('INITIAL_MEMORY', '64mb')
42894289
if not self.has_changed_setting('ASSERTIONS'):
42904290
self.set_setting('ASSERTIONS', 2)
42914291

@@ -5583,7 +5583,7 @@ def test_whets(self):
55835583
def test_dlmalloc_inline(self):
55845584
self.banned_js_engines = [config.NODE_JS] # slower, and fail on 64-bit
55855585
# needed with typed arrays
5586-
self.set_setting('INITIAL_MEMORY', 128 * 1024 * 1024)
5586+
self.set_setting('INITIAL_MEMORY', '128mb')
55875587

55885588
src = open(path_from_root('system', 'lib', 'dlmalloc.c')).read() + '\n\n\n' + open(path_from_root('tests', 'dlmalloc_test.c')).read()
55895589
self.do_run(src, '*1,0*', args=['200', '1'], force_c=True)
@@ -5593,7 +5593,7 @@ def test_dlmalloc_inline(self):
55935593
def test_dlmalloc(self):
55945594
self.banned_js_engines = [config.NODE_JS] # slower, and fail on 64-bit
55955595
# needed with typed arrays
5596-
self.set_setting('INITIAL_MEMORY', 128 * 1024 * 1024)
5596+
self.set_setting('INITIAL_MEMORY', '128mb')
55975597

55985598
# Linked version
55995599
self.do_runf(path_from_root('tests', 'dlmalloc_test.c'), '*1,0*', args=['200', '1'])
@@ -5671,7 +5671,7 @@ def test_fakestat(self):
56715671
def test_mmap(self):
56725672
# ASan needs more memory, but that is set up separately
56735673
if '-fsanitize=address' not in self.emcc_args:
5674-
self.set_setting('INITIAL_MEMORY', 128 * 1024 * 1024)
5674+
self.set_setting('INITIAL_MEMORY', '128mb')
56755675

56765676
# needs to flush stdio streams
56775677
self.set_setting('EXIT_RUNTIME', 1)
@@ -7900,7 +7900,7 @@ def test_template_class_deduction(self):
79007900
def test_asan_no_error(self, name):
79017901
self.emcc_args.append('-fsanitize=address')
79027902
self.emcc_args.append('-sALLOW_MEMORY_GROWTH=1')
7903-
self.emcc_args.append('-sINITIAL_MEMORY=314572800')
7903+
self.emcc_args.append('-sINITIAL_MEMORY=300mb')
79047904
self.do_runf(path_from_root('tests', 'core', name), '', assert_returncode=NON_ZERO)
79057905

79067906
# note: these tests have things like -fno-builtin-memset in order to avoid
@@ -7970,7 +7970,7 @@ def test_asan(self, name, expected_output, cflags=None):
79707970

79717971
self.emcc_args.append('-fsanitize=address')
79727972
self.emcc_args.append('-sALLOW_MEMORY_GROWTH=1')
7973-
self.emcc_args.append('-sINITIAL_MEMORY=314572800')
7973+
self.emcc_args.append('-sINITIAL_MEMORY=300mb')
79747974
if cflags:
79757975
self.emcc_args += cflags
79767976
self.do_runf(path_from_root('tests', 'core', name),
@@ -7982,15 +7982,15 @@ def test_asan(self, name, expected_output, cflags=None):
79827982
def test_asan_js_stack_op(self):
79837983
self.emcc_args.append('-fsanitize=address')
79847984
self.emcc_args.append('-sALLOW_MEMORY_GROWTH=1')
7985-
self.emcc_args.append('-sINITIAL_MEMORY=314572800')
7985+
self.emcc_args.append('-sINITIAL_MEMORY=300mb')
79867986
self.do_runf(path_from_root('tests', 'core', 'test_asan_js_stack_op.c'),
79877987
expected_output='Hello, World!')
79887988

79897989
@no_safe_heap('asan does not work with SAFE_HEAP')
79907990
@no_wasm2js('TODO: ASAN in wasm2js')
79917991
def test_asan_api(self):
79927992
self.emcc_args.append('-fsanitize=address')
7993-
self.set_setting('INITIAL_MEMORY', 314572800)
7993+
self.set_setting('INITIAL_MEMORY', '300mb')
79947994
self.do_run_in_out_file_test('tests', 'core', 'test_asan_api.c')
79957995

79967996
@no_safe_heap('asan does not work with SAFE_HEAP')
@@ -8001,7 +8001,7 @@ def test_asan_modularized_with_closure(self):
80018001
self.emcc_args.append('-sUSE_CLOSURE_COMPILER=1')
80028002
self.emcc_args.append('-fsanitize=address')
80038003
self.emcc_args.append('-sALLOW_MEMORY_GROWTH=1')
8004-
self.emcc_args.append('-sINITIAL_MEMORY=314572800')
8004+
self.emcc_args.append('-sINITIAL_MEMORY=300mb')
80058005

80068006
def post(filename):
80078007
with open(filename, 'a') as f:
@@ -8307,9 +8307,9 @@ def setUp(self):
83078307
strict = make_run('strict', emcc_args=[], settings={'STRICT': 1})
83088308

83098309
lsan = make_run('lsan', emcc_args=['-fsanitize=leak', '-O2'], settings={'ALLOW_MEMORY_GROWTH': 1})
8310-
asan = make_run('asan', emcc_args=['-fsanitize=address', '-O2'], settings={'ALLOW_MEMORY_GROWTH': 1, 'INITIAL_MEMORY': 314572800})
8310+
asan = make_run('asan', emcc_args=['-fsanitize=address', '-O2'], settings={'ALLOW_MEMORY_GROWTH': 1, 'INITIAL_MEMORY': '300mb'})
83118311
asani = make_run('asani', emcc_args=['-fsanitize=address', '-O2', '--pre-js', os.path.join(os.path.dirname(__file__), 'asan-no-leak.js')],
8312-
settings={'ALLOW_MEMORY_GROWTH': 1, 'INITIAL_MEMORY': 314572800})
8312+
settings={'ALLOW_MEMORY_GROWTH': 1, 'INITIAL_MEMORY': '300mb'})
83138313

83148314
# Experimental modes (not tested by CI)
83158315
lld = make_run('lld', emcc_args=[], settings={'LLD_REPORT_UNDEFINED': 1})

0 commit comments

Comments
 (0)