Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions test/hello_world_loop.c

This file was deleted.

23 changes: 0 additions & 23 deletions test/hello_world_loop_malloc.c

This file was deleted.

84 changes: 0 additions & 84 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,90 +583,6 @@ def test_emcc_3(self, compiler, suffix):
os.chdir(last)
delete_file(path)

@is_slow_test
@with_both_compilers
def test_emcc_4(self, compiler):
# Optimization: emcc src.cpp -o something.js [-Ox]. -O0 is the same as not specifying any optimization setting
# link_param are used after compiling first
for params, opt_level, link_params, closure, has_malloc in [
(['-o', 'something.js'], 0, None, 0, 1),
(['-o', 'something.js', '-O0', '-g'], 0, None, 0, 0),
(['-o', 'something.js', '-O1'], 1, None, 0, 0),
(['-o', 'something.js', '-O1', '-g'], 1, None, 0, 0), # no closure since debug
(['-o', 'something.js', '-O2'], 2, None, 0, 1),
(['-o', 'something.js', '-O2', '-g'], 2, None, 0, 0),
(['-o', 'something.js', '-Os'], 2, None, 0, 1),
(['-o', 'something.js', '-O3'], 3, None, 0, 1),
# and, test compiling first
(['-c', '-o', 'something.o'], 0, [], 0, 0),
(['-c', '-o', 'something.o', '-O0'], 0, [], 0, 0),
(['-c', '-o', 'something.o', '-O1'], 1, ['-O1'], 0, 0),
(['-c', '-o', 'something.o', '-O2'], 2, ['-O2'], 0, 0),
(['-c', '-o', 'something.o', '-O3'], 3, ['-O3'], 0, 0),
(['-O1', '-c', '-o', 'something.o'], 1, [], 0, 0),
# non-wasm
(['-sWASM=0', '-o', 'something.js'], 0, None, 0, 1),
(['-sWASM=0', '-o', 'something.js', '-O0', '-g'], 0, None, 0, 0),
(['-sWASM=0', '-o', 'something.js', '-O1'], 1, None, 0, 0),
(['-sWASM=0', '-o', 'something.js', '-O1', '-g'], 1, None, 0, 0), # no closure since debug
(['-sWASM=0', '-o', 'something.js', '-O2'], 2, None, 0, 1),
(['-sWASM=0', '-o', 'something.js', '-O2', '-g'], 2, None, 0, 0),
(['-sWASM=0', '-o', 'something.js', '-Os'], 2, None, 0, 1),
(['-sWASM=0', '-o', 'something.js', '-O3'], 3, None, 0, 1),
# and, test compiling to bitcode first
(['-flto', '-c', '-o', 'something.o'], 0, [], 0, 0),
(['-flto', '-c', '-o', 'something.o', '-O0'], 0, [], 0, 0),
(['-flto', '-c', '-o', 'something.o', '-O1'], 1, ['-O1'], 0, 0),
(['-flto', '-c', '-o', 'something.o', '-O2'], 2, ['-O2'], 0, 0),
(['-flto', '-c', '-o', 'something.o', '-O3'], 3, ['-O3'], 0, 0),
(['-flto', '-O1', '-c', '-o', 'something.o'], 1, [], 0, 0),
]:
print(params, opt_level, link_params, closure, has_malloc)
self.clear()
keep_debug = '-g' in params
if has_malloc:
filename = test_file('hello_world_loop_malloc.c')
else:
filename = test_file('hello_world_loop.c')
args = [compiler, filename] + params
print('..', args)
output = self.run_process(args, stdout=PIPE, stderr=PIPE)
assert len(output.stdout) == 0, output.stdout
if link_params is not None:
self.assertExists('something.o', output.stderr)
obj_args = [compiler, 'something.o', '-o', 'something.js'] + link_params
print('....', obj_args)
output = self.run_process(obj_args, stdout=PIPE, stderr=PIPE)
self.assertExists('something.js', output.stderr)
self.assertContained('Hello, world!', self.run_js('something.js'))

# Verify optimization level etc. in the generated code
# XXX these are quite sensitive, and will need updating when code generation changes
generated = read_file('something.js')
main = self.get_func(generated, '_main') if 'function _main' in generated else generated
assert 'new Uint16Array' in generated and 'new Uint32Array' in generated, 'typed arrays 2 should be used by default'
assert 'SAFE_HEAP_LOAD' not in generated, 'safe heap should not be used by default'
assert 'SAFE_HEAP_STORE' not in generated, 'safe heap should not be used by default'
assert ': while(' not in main, 'when relooping we also js-optimize, so there should be no labelled whiles'
if closure:
if opt_level == 0:
assert '._main =' in generated, 'closure compiler should have been run'
elif opt_level >= 1:
assert '._main=' in generated, 'closure compiler should have been run (and output should be minified)'
else:
# closure has not been run, we can do some additional checks. TODO: figure out how to do these even with closure
assert '._main = ' not in generated, 'closure compiler should not have been run'
if keep_debug:
self.assertContainedIf("assert(typeof Module['STACK_SIZE'] == 'undefined'", generated, opt_level == 0)
if 'WASM=0' in params:
looks_unminified = ' = {}' in generated and ' = []' in generated
looks_minified = '={}' in generated and '=[]' and ';var' in generated
assert not (looks_minified and looks_unminified)
if opt_level == 0 or '-g' in params:
assert looks_unminified
elif opt_level >= 2:
assert looks_minified
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing I'm not sure if other tests cover is closure (that closure runs exactly when asked). Code size tests might indirectly, but I think those run without closure so that we can see function names?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The codesize tests absolutes do use closure. We sometimes build twice to get names I think but the core measurements are all about closure.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm.. I just noticed that closure is always 0 here... i.e. we are not actually ever testing if closure ran

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like even more evidence that this test is bittrotted/not doing much anymore.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!


def test_multiple_sources(self):
# Compiling two sources at a time should work.
cmd = [EMCC, '-c', test_file('twopart_main.cpp'), test_file('twopart_side.c')]
Expand Down
Loading