Skip to content

Commit 0e18f6a

Browse files
committed
[MODULARIZE=instance] Enable more core tests
Split out from emscripten-core#24288 See emscripten-core#24060
1 parent 8e3d62c commit 0e18f6a

File tree

2 files changed

+45
-41
lines changed

2 files changed

+45
-41
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

+38-41
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")
@@ -6157,6 +6160,7 @@ def test_iostream_and_determinism(self):
61576160
return 0;
61586161
}
61596162
''')
6163+
js_out = self.output_name('src')
61606164

61616165
num = 5
61626166
for i in range(num):
@@ -6168,8 +6172,8 @@ def test_iostream_and_determinism(self):
61686172

61696173
# Verify that this build is identical to the previous one
61706174
if os.path.exists('src.js.previous'):
6171-
self.assertBinaryEqual('src.js', 'src.js.previous')
6172-
shutil.copy2('src.js', 'src.js.previous')
6175+
self.assertBinaryEqual(js_out, 'src.js.previous')
6176+
shutil.copy2(js_out, 'src.js.previous')
61736177

61746178
# Same but for the wasm file.
61756179
if self.is_wasm():
@@ -6272,10 +6276,10 @@ def test_constglobalunion(self):
62726276

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

62806284
def test_raytrace(self):
62816285
# TODO: Should we remove this test?
@@ -6298,9 +6302,9 @@ def test_fasta(self, float_type):
62986302

62996303
src = orig_src.replace('double', float_type)
63006304
create_file('fasta.cpp', src)
6301-
self.build('fasta.cpp')
6305+
js_out = self.build('fasta.cpp')
63026306
for arg, output in results:
6303-
self.do_run('fasta.js', output, args=[arg], no_build=True)
6307+
self.do_run(js_out, output, args=[arg], no_build=True)
63046308

63056309
@needs_non_trapping_float_to_int
63066310
def test_fasta_nontrapping(self):
@@ -7658,17 +7662,12 @@ def test_embind_sync_if_pthread_delayed(self):
76587662
### Tests for tools
76597663

76607664
@no_wasm2js('TODO: source maps in wasm2js')
7661-
@parameterized({
7662-
'': ([],),
7663-
'minimal_runtime': (['-sMINIMAL_RUNTIME'],),
7664-
})
7665+
@also_with_minimal_runtime
76657666
@requires_node
7666-
def test_source_map(self, args):
7667+
def test_source_map(self):
76677668
if '-g' not in self.emcc_args:
76687669
self.emcc_args.append('-g')
76697670

7670-
self.emcc_args += args
7671-
76727671
src = '''
76737672
#include <stdio.h>
76747673
#include <assert.h>
@@ -7685,7 +7684,7 @@ def test_source_map(self, args):
76857684
'''
76867685
create_file('src.cpp', src)
76877686

7688-
out_filename = 'a.out.js'
7687+
out_filename = self.output_name('a.out')
76897688
wasm_filename = 'a.out.wasm'
76907689
no_maps_filename = 'no-maps.out.js'
76917690

@@ -7769,13 +7768,11 @@ def test_embind_dylink_visibility_hidden(self):
77697768
def test_dwarf(self):
77707769
self.emcc_args.append('-g')
77717770

7772-
js_filename = 'a.out.js'
7773-
wasm_filename = 'a.out.wasm'
77747771
shutil.copy(test_file('core/test_dwarf.c'), '.')
77757772

7776-
self.emcc('test_dwarf.c', output_filename=js_filename)
7773+
self.emcc('test_dwarf.c')
77777774

7778-
out = self.run_process([shared.LLVM_DWARFDUMP, wasm_filename, '-all'], stdout=PIPE).stdout
7775+
out = self.run_process([shared.LLVM_DWARFDUMP, 'a.out.wasm', '-all'], stdout=PIPE).stdout
77797776

77807777
# parse the sections
77817778
sections = {}
@@ -7845,7 +7842,7 @@ def get_dwarf_addr(line, col):
78457842

78467843
# Get the wat, printing with -g which has binary offsets
78477844
wat = self.run_process([os.path.join(building.get_binaryen_bin(), 'wasm-opt'),
7848-
wasm_filename, '-g', '--print', '-all'], stdout=PIPE).stdout
7845+
'a.out.wasm', '-g', '--print', '-all'], stdout=PIPE).stdout
78497846

78507847
# We expect to see a pattern like this in optimized builds (there isn't
78517848
# much that can change with such calls to JS (they can't be reordered or
@@ -8589,7 +8586,7 @@ def test_environment(self):
85898586

85908587
def test(assert_returncode=0):
85918588
self.do_core_test('test_hello_world.c', assert_returncode=assert_returncode)
8592-
js = read_file('test_hello_world.js')
8589+
js = read_file(self.output_name('test_hello_world'))
85938590
assert ('require(' in js) == ('node' in self.get_setting('ENVIRONMENT')), 'we should have require() calls only if node js specified'
85948591

85958592
for engine in config.JS_ENGINES:
@@ -8625,8 +8622,8 @@ def test_postrun_exception(self):
86258622
# verify that an exception thrown in postRun() will not trigger the
86268623
# compilation failed handler, and will be printed to stderr.
86278624
self.add_post_run('ThisFunctionDoesNotExist()')
8628-
self.build('core/test_hello_world.c')
8629-
output = self.run_js('test_hello_world.js', assert_returncode=NON_ZERO)
8625+
out_js = self.build('core/test_hello_world.c')
8626+
output = self.run_js(out_js, assert_returncode=NON_ZERO)
86308627
self.assertStartswith(output, 'hello, world!')
86318628
self.assertContained('ThisFunctionDoesNotExist is not defined', output)
86328629

0 commit comments

Comments
 (0)