Skip to content

Commit f8d3cf7

Browse files
committed
[MODULARIZE=instance] Enable more core tests
Split out from #24288 See #24060
1 parent 1b0e585 commit f8d3cf7

File tree

2 files changed

+43
-34
lines changed

2 files changed

+43
-34
lines changed

.circleci/config.yml

+7
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,13 @@ jobs:
804804
esm_integration.test_fs_js_api*
805805
instance.test_hello_world
806806
instance.test_dylink_basics
807+
instance.test_cube2hash*
808+
instance.test_exceptions_3*
809+
instance.test_memorygrowth
810+
instance.test_stat
811+
instance.test_iostream_and_determinism
812+
instance.test_fannkuch
813+
instance.test_fasta
807814
esm_integration.test_inlinejs3
808815
esm_integration.test_embind_val_basics
809816
"

test/test_core.py

+36-34
Original file line numberDiff line numberDiff line change
@@ -592,11 +592,12 @@ def test_cube2hash(self):
592592
self.do_run('// empty file', 'Usage: hashstring <seed>',
593593
libraries=self.get_library('third_party/cube2hash', ['libcube2hash.a'], configure=None),
594594
includes=[test_file('third_party/cube2hash')], assert_returncode=NON_ZERO)
595+
js_out = self.output_name('src')
595596

596597
for text, output in [('fleefl', '892BDB6FD3F62E863D63DA55851700FDE3ACF30204798CE9'),
597598
('fleefl2', 'AA2CC5F96FC9D540CA24FDAF1F71E2942753DB83E8A81B61'),
598599
('64bitisslow', '64D8470573635EC354FEE7B7F87C566FCAF1EFB491041670')]:
599-
self.do_run('src.js', 'hash value: ' + output, args=[text], no_build=True)
600+
self.do_run(js_out, 'hash value: ' + output, args=[text], no_build=True)
600601

601602
@only_wasm2js('tests 64-bit alignment of structs')
602603
def test_align64(self):
@@ -1163,46 +1164,48 @@ def test_exceptions_3(self):
11631164
}
11641165
'''
11651166

1167+
js_out = self.output_name('src')
11661168
print('0')
11671169
self.do_run(src, 'Caught C string: a c string\nDone.', args=['0'])
11681170
print('1')
1169-
self.do_run('src.js', 'Caught exception: std::exception\nDone.', args=['1'], no_build=True)
1171+
self.do_run(js_out, 'Caught exception: std::exception\nDone.', args=['1'], no_build=True)
11701172
print('2')
1171-
self.do_run('src.js', 'Caught exception: Hello\nDone.', args=['2'], no_build=True)
1173+
self.do_run(js_out, 'Caught exception: Hello\nDone.', args=['2'], no_build=True)
11721174

11731175
def test_exceptions_allowed(self):
11741176
self.set_setting('EXCEPTION_CATCHING_ALLOWED', ["_Z12somefunctionv"])
11751177
# otherwise it is inlined and not identified
11761178
self.set_setting('INLINING_LIMIT')
11771179

11781180
self.do_core_test('test_exceptions_allowed.cpp')
1179-
size = os.path.getsize('test_exceptions_allowed.js')
1181+
js_out = self.output_name('test_exceptions_allowed')
1182+
size = os.path.getsize(js_out)
11801183
if self.is_wasm():
11811184
size += os.path.getsize('test_exceptions_allowed.wasm')
1182-
shutil.copy('test_exceptions_allowed.js', 'orig.js')
1185+
shutil.copy(js_out, 'orig.js')
11831186

11841187
# check that an empty allow list works properly (as in, same as exceptions disabled)
11851188

11861189
self.set_setting('EXCEPTION_CATCHING_ALLOWED', [])
11871190
self.do_run_in_out_file_test('core/test_exceptions_allowed.cpp', out_suffix='_empty', assert_returncode=NON_ZERO)
1188-
empty_size = os.path.getsize('test_exceptions_allowed.js')
1191+
empty_size = os.path.getsize(js_out)
11891192
if self.is_wasm():
11901193
empty_size += os.path.getsize('test_exceptions_allowed.wasm')
1191-
shutil.copy('test_exceptions_allowed.js', 'empty.js')
1194+
shutil.copy(js_out, 'empty.js')
11921195

11931196
self.set_setting('EXCEPTION_CATCHING_ALLOWED', ['fake'])
11941197
self.do_run_in_out_file_test('core/test_exceptions_allowed.cpp', out_suffix='_empty', assert_returncode=NON_ZERO)
1195-
fake_size = os.path.getsize('test_exceptions_allowed.js')
1198+
fake_size = os.path.getsize(js_out)
11961199
if self.is_wasm():
11971200
fake_size += os.path.getsize('test_exceptions_allowed.wasm')
1198-
shutil.copy('test_exceptions_allowed.js', 'fake.js')
1201+
shutil.copy(js_out, 'fake.js')
11991202

12001203
self.clear_setting('EXCEPTION_CATCHING_ALLOWED')
12011204
self.do_run_in_out_file_test('core/test_exceptions_allowed.cpp', out_suffix='_empty', assert_returncode=NON_ZERO)
1202-
disabled_size = os.path.getsize('test_exceptions_allowed.js')
1205+
disabled_size = os.path.getsize(js_out)
12031206
if self.is_wasm():
12041207
disabled_size += os.path.getsize('test_exceptions_allowed.wasm')
1205-
shutil.copy('test_exceptions_allowed.js', 'disabled.js')
1208+
shutil.copy(js_out, 'disabled.js')
12061209

12071210
print('size: %d' % size)
12081211
print('empty_size: %d' % empty_size)
@@ -1965,8 +1968,8 @@ def test_em_js(self, args, force_c):
19651968
if '-pthread' in args:
19661969
self.setup_node_pthreads()
19671970

1968-
self.do_core_test('test_em_js.cpp', force_c=force_c)
1969-
self.assertContained("no args returning int", read_file('test_em_js.js'))
1971+
err = self.do_core_test('test_em_js.cpp', force_c=force_c)
1972+
self.assertContained('no args returning int', read_file(self.output_name('test_em_js')))
19701973

19711974
@no_wasm2js('test depends on WASM_BIGINT which is not compatible with wasm2js')
19721975
def test_em_js_i64(self):
@@ -2013,12 +2016,12 @@ def test_memorygrowth(self):
20132016

20142017
# Fail without memory growth
20152018
self.do_runf(src, 'OOM', assert_returncode=NON_ZERO)
2016-
fail = read_file('test_memorygrowth.js')
2019+
fail = read_file(self.output_name('test_memorygrowth'))
20172020

20182021
# Win with it
20192022
self.set_setting('ALLOW_MEMORY_GROWTH')
20202023
self.do_runf(src, '*pre: hello,4.955*\n*hello,4.955*\n*hello,4.955*')
2021-
win = read_file('test_memorygrowth.js')
2024+
win = read_file(self.output_name('test_memorygrowth'))
20222025

20232026
if '-O2' in self.emcc_args and self.is_wasm2js():
20242027
# Make sure ALLOW_MEMORY_GROWTH generates different code (should be less optimized)
@@ -2046,12 +2049,12 @@ def test_memorygrowth_2(self):
20462049

20472050
# Fail without memory growth
20482051
self.do_runf(src, 'OOM', assert_returncode=NON_ZERO)
2049-
fail = read_file('test_memorygrowth_2.js')
2052+
fail = read_file(self.output_name('test_memorygrowth_2'))
20502053

20512054
# Win with it
20522055
self.set_setting('ALLOW_MEMORY_GROWTH')
20532056
self.do_runf(src, '*pre: hello,4.955*\n*hello,4.955*\n*hello,4.955*')
2054-
win = read_file('test_memorygrowth_2.js')
2057+
win = read_file(self.output_name('test_memorygrowth_2'))
20552058

20562059
if '-O2' in self.emcc_args and self.is_wasm2js():
20572060
# Make sure ALLOW_MEMORY_GROWTH generates different code (should be less optimized)
@@ -2110,7 +2113,7 @@ def test_memorygrowth_3_force_fail_reallocBuffer(self):
21102113
self.set_setting('ALLOW_MEMORY_GROWTH')
21112114
# Force memory growth to fail at runtime
21122115
self.add_pre_run('growMemory = (size) => false;')
2113-
self.do_core_test('test_memorygrowth_3.c')
2116+
self.do_core_test('test_memorygrowth_3.c', emcc_args=['-sINCOMING_MODULE_JS_API=preRun'])
21142117

21152118
@parameterized({
21162119
'nogrow': ([],),
@@ -5561,7 +5564,7 @@ def test_readdir_unlink(self):
55615564
def test_stat(self):
55625565
self.set_setting("FORCE_FILESYSTEM")
55635566
self.do_runf('stat/test_stat.c', 'success')
5564-
self.verify_in_strict_mode('test_stat.js')
5567+
self.verify_in_strict_mode(self.output_name('test_stat'))
55655568

55665569
def test_statx(self):
55675570
self.set_setting("FORCE_FILESYSTEM")
@@ -6154,6 +6157,7 @@ def test_iostream_and_determinism(self):
61546157
return 0;
61556158
}
61566159
''')
6160+
js_out = self.output_name('src')
61576161

61586162
num = 5
61596163
for i in range(num):
@@ -6165,8 +6169,8 @@ def test_iostream_and_determinism(self):
61656169

61666170
# Verify that this build is identical to the previous one
61676171
if os.path.exists('src.js.previous'):
6168-
self.assertBinaryEqual('src.js', 'src.js.previous')
6169-
shutil.copy2('src.js', 'src.js.previous')
6172+
self.assertBinaryEqual(js_out, 'src.js.previous')
6173+
shutil.copy2(js_out, 'src.js.previous')
61706174

61716175
# Same but for the wasm file.
61726176
if self.is_wasm():
@@ -6269,10 +6273,10 @@ def test_constglobalunion(self):
62696273

62706274
def test_fannkuch(self):
62716275
results = [(1, 0), (2, 1), (3, 2), (4, 4), (5, 7), (6, 10), (7, 16), (8, 22)]
6272-
self.build('third_party/fannkuch.c')
6276+
js_out = self.build('third_party/fannkuch.c')
62736277
for i, j in results:
62746278
print(i, j)
6275-
self.do_run('fannkuch.js', 'Pfannkuchen(%d) = %d.' % (i, j), args=[str(i)], no_build=True)
6279+
self.do_run(js_out, 'Pfannkuchen(%d) = %d.' % (i, j), args=[str(i)], no_build=True)
62766280

62776281
def test_raytrace(self):
62786282
# TODO: Should we remove this test?
@@ -6295,9 +6299,9 @@ def test_fasta(self, float_type):
62956299

62966300
src = orig_src.replace('double', float_type)
62976301
create_file('fasta.cpp', src)
6298-
self.build('fasta.cpp')
6302+
js_out = self.build('fasta.cpp')
62996303
for arg, output in results:
6300-
self.do_run('fasta.js', output, args=[arg], no_build=True)
6304+
self.do_run(js_out, output, args=[arg], no_build=True)
63016305

63026306
@needs_non_trapping_float_to_int
63036307
def test_fasta_nontrapping(self):
@@ -7677,7 +7681,7 @@ def test_source_map(self):
76777681
'''
76787682
create_file('src.cpp', src)
76797683

7680-
out_filename = 'a.out.js'
7684+
out_filename = self.output_name('a.out')
76817685
wasm_filename = 'a.out.wasm'
76827686
no_maps_filename = 'no-maps.out.js'
76837687

@@ -7761,13 +7765,11 @@ def test_embind_dylink_visibility_hidden(self):
77617765
def test_dwarf(self):
77627766
self.emcc_args.append('-g')
77637767

7764-
js_filename = 'a.out.js'
7765-
wasm_filename = 'a.out.wasm'
77667768
shutil.copy(test_file('core/test_dwarf.c'), '.')
77677769

7768-
self.emcc('test_dwarf.c', output_filename=js_filename)
7770+
self.emcc('test_dwarf.c')
77697771

7770-
out = self.run_process([shared.LLVM_DWARFDUMP, wasm_filename, '-all'], stdout=PIPE).stdout
7772+
out = self.run_process([shared.LLVM_DWARFDUMP, 'a.out.wasm', '-all'], stdout=PIPE).stdout
77717773

77727774
# parse the sections
77737775
sections = {}
@@ -7837,7 +7839,7 @@ def get_dwarf_addr(line, col):
78377839

78387840
# Get the wat, printing with -g which has binary offsets
78397841
wat = self.run_process([os.path.join(building.get_binaryen_bin(), 'wasm-opt'),
7840-
wasm_filename, '-g', '--print', '-all'], stdout=PIPE).stdout
7842+
'a.out.wasm', '-g', '--print', '-all'], stdout=PIPE).stdout
78417843

78427844
# We expect to see a pattern like this in optimized builds (there isn't
78437845
# much that can change with such calls to JS (they can't be reordered or
@@ -8577,7 +8579,7 @@ def test_environment(self):
85778579

85788580
def test(assert_returncode=0):
85798581
self.do_core_test('test_hello_world.c', assert_returncode=assert_returncode)
8580-
js = read_file('test_hello_world.js')
8582+
js = read_file(self.output_name('test_hello_world'))
85818583
assert ('require(' in js) == ('node' in self.get_setting('ENVIRONMENT')), 'we should have require() calls only if node js specified'
85828584

85838585
for engine in config.JS_ENGINES:
@@ -8613,8 +8615,8 @@ def test_postrun_exception(self):
86138615
# verify that an exception thrown in postRun() will not trigger the
86148616
# compilation failed handler, and will be printed to stderr.
86158617
self.add_post_run('ThisFunctionDoesNotExist()')
8616-
self.build('core/test_hello_world.c')
8617-
output = self.run_js('test_hello_world.js', assert_returncode=NON_ZERO)
8618+
out_js = self.build('core/test_hello_world.c')
8619+
output = self.run_js(out_js, assert_returncode=NON_ZERO)
86188620
self.assertStartswith(output, 'hello, world!')
86198621
self.assertContained('ThisFunctionDoesNotExist is not defined', output)
86208622

0 commit comments

Comments
 (0)