From cbd0e89d7573937218a06e64e60e4237a947dcd5 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 11 Mar 2026 17:21:09 -0700 Subject: [PATCH] Remove `test_emcc_4`. NFC This is a rather sprawling and unfocused test that has a huge loop inside. This single test take over 30 seconds to run. It seems to test for a lot of different things, including stuff from the old compile-to-JS days. I'm pretty sure all this stuff is covered in a more logical fashion elsewhere. It also has a very useless name. --- test/hello_world_loop.c | 23 ---------- test/hello_world_loop_malloc.c | 23 ---------- test/test_other.py | 84 ---------------------------------- 3 files changed, 130 deletions(-) delete mode 100644 test/hello_world_loop.c delete mode 100644 test/hello_world_loop_malloc.c diff --git a/test/hello_world_loop.c b/test/hello_world_loop.c deleted file mode 100644 index 0bef2935e3c9d..0000000000000 --- a/test/hello_world_loop.c +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2011 The Emscripten Authors. All rights reserved. -// Emscripten is available under two separate licenses, the MIT license and the -// University of Illinois/NCSA Open Source License. Both these licenses can be -// found in the LICENSE file. - -#include -#include -#include - -void dump(char *s) { - printf("%s\n", s); -} - -int main() { - char *original = (char*)"H e l l o , w o r l d ! "; - char copy[strlen(original)]; - for (int i = 0; i < strlen(original); i += 2) { - copy[i/2] = original[i]; - } - copy[strlen(copy)+1] = (long)&original; // force original to be on the stack - dump(copy); - return 0; -} diff --git a/test/hello_world_loop_malloc.c b/test/hello_world_loop_malloc.c deleted file mode 100644 index ba63b91a7d4a4..0000000000000 --- a/test/hello_world_loop_malloc.c +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2011 The Emscripten Authors. All rights reserved. -// Emscripten is available under two separate licenses, the MIT license and the -// University of Illinois/NCSA Open Source License. Both these licenses can be -// found in the LICENSE file. - -#include -#include -#include - -void dump(char *s) { - printf("%s\n", s); -} - -int main() { - char *original = (char*)"H e l l o , w o r l d ! "; - char *copy = (char*)malloc(strlen(original)); - for (int i = 0; i < strlen(original); i += 2) { - copy[i/2] = original[i]; - } - copy[strlen(copy)+1] = (long)&original; // force original to be on the stack - dump(copy); - return 0; -} diff --git a/test/test_other.py b/test/test_other.py index 10ae5286e9dda..971eea354e4bd 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -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 - 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')]