diff options
Diffstat (limited to 'tests/runner.py')
-rw-r--r-- | tests/runner.py | 67 |
1 files changed, 43 insertions, 24 deletions
diff --git a/tests/runner.py b/tests/runner.py index a2ca7305..d5489dd6 100644 --- a/tests/runner.py +++ b/tests/runner.py @@ -4878,6 +4878,11 @@ TT = %s del T # T is just a shape for the specific subclasses, we don't test it itself class other(RunnerCore): + def test_reminder(self): + raise Exception('''Fix emmaken.py and emconfiguren.py, they should work but mention they are deprecated + Test emconfigure + configure in test_zlib looks broken''') + def test_emcc(self): def clear(): for name in os.listdir(self.get_dir()): @@ -4916,27 +4921,31 @@ Options that are modified or new in %s include: # emcc src.cpp -c and emcc src.cpp -o src.[o|bc] ==> should give a .bc file for args in [['-c'], ['-o', 'src.o'], ['-o', 'src.bc']]: - target = args[1] if len(args) == 2 else 'hello_world.bc' + target = args[1] if len(args) == 2 else 'hello_world.o' clear() output = Popen([compiler, path_from_root('tests', 'hello_world' + suffix)] + args, stdout=PIPE, stderr=PIPE).communicate() assert len(output[0]) == 0, output[0] - assert os.path.exists(target), 'Expected %s to exist since args are %s : %s' % (target, str(args), output) + assert os.path.exists(target), 'Expected %s to exist since args are %s : %s' % (target, str(args), '\n'.join(output)) self.assertContained('hello, world!', self.run_llvm_interpreter([target])) # Optimization: emcc src.cpp -o something.js [-Ox]. -O0 is the same as not specifying any optimization setting - for params, opt_level, bc_params in [ # bc params are used after compiling to bitcode - (['-o', 'something.js'], 0, None), - (['-o', 'something.js', '-O0'], 0, None), - (['-o', 'something.js', '-O1'], 1, None), - (['-o', 'something.js', '-O2'], 2, None), - (['-o', 'something.js', '-O3'], 3, None), + for params, opt_level, bc_params, closure in [ # bc params are used after compiling to bitcode + (['-o', 'something.js'], 0, None, 0), + (['-o', 'something.js', '-O0'], 0, None, 0), + (['-o', 'something.js', '-O1'], 1, None, 0), + (['-o', 'something.js', '-O1', '--closure', '1'], 1, None, 1), + (['-o', 'something.js', '-O2'], 2, None, 1), + (['-o', 'something.js', '-O2', '--closure', '0'], 2, None, 0), + (['-o', 'something.js', '-O3'], 3, None, 1), + (['-o', 'something.js', '-O3', '--closure', '0'], 3, None, 0), # and, test compiling to bitcode first - (['-o', 'something.bc'], 0, []), - (['-o', 'something.bc'], 0, ['-O0']), - (['-o', 'something.bc'], 1, ['-O1']), - (['-o', 'something.bc'], 2, ['-O2']), - (['-o', 'something.bc'], 3, ['-O3']), + (['-o', 'something.bc'], 0, [], 0), + (['-o', 'something.bc'], 0, ['-O0'], 0), + (['-o', 'something.bc'], 1, ['-O1'], 0), + (['-o', 'something.bc'], 2, ['-O2'], 1), + (['-o', 'something.bc'], 3, ['-O3'], 1), ]: + #print params, opt_level, bc_params, closure clear() output = Popen([compiler, path_from_root('tests', 'hello_world_loop.cpp')] + params, stdout=PIPE, stderr=PIPE).communicate() @@ -4952,16 +4961,17 @@ Options that are modified or new in %s include: # Verify optimization level etc. in the generated code # XXX these are quite sensitive, and will need updating when code generation changes generated = open('something.js').read() # TODO: parse out the _main function itself, not support code, if the tests below need that some day - assert ('(__label__)' in generated) == (opt_level <= 1), 'relooping should be in opt >= 2' - assert ('assert(STACKTOP < STACK_MAX)' in generated) == (opt_level == 0), 'assertions should be in opt == 0' - assert ('|0)/2)|0)' in generated or '| 0) / 2 | 0)' in generated) == (opt_level <= 2), 'corrections should be in opt <= 2' assert 'new Uint16Array' in generated and 'new Uint32Array' in generated, 'typed arrays 2 should be used by default' assert 'SAFE_HEAP' not in generated, 'safe heap should not be used by default' assert ': while(' not in generated, 'when relooping we also js-optimize, so there should be no labelled whiles' - if opt_level >= 3: + if closure: assert 'Module._main = ' in generated, 'closure compiler should have been run' else: # closure has not been run, we can do some additional checks. TODO: figure out how to do these even with closure + assert 'Module._main = ' not in generated, 'closure compiler should not have been run' + # XXX find a way to test this: assert ('& 255' in generated or '&255' in generated) == (opt_level <= 2), 'corrections should be in opt <= 2' + assert ('(__label__)' in generated) == (opt_level <= 1), 'relooping should be in opt >= 2' + assert ('assert(STACKTOP < STACK_MAX)' in generated) == (opt_level == 0), 'assertions should be in opt == 0' assert 'var $i;' in generated, 'micro opts should always be on' if opt_level >= 1: assert 'HEAP8[HEAP32[' in generated, 'eliminator should create compound expressions, and fewer one-time vars' assert ('_puts(' in generated) == (opt_level >= 1), 'with opt >= 1, llvm opts are run and they should optimize printf to puts' @@ -5002,25 +5012,36 @@ Options that are modified or new in %s include: assert 'fatal error' in output[1], output[1] continue - assert os.path.exists('twopart_main.bc'), '\n'.join(output) - assert os.path.exists('twopart_side.bc'), '\n'.join(output) + assert os.path.exists('twopart_main.o'), '\n'.join(output) + assert os.path.exists('twopart_side.o'), '\n'.join(output) assert not os.path.exists(target), 'We should only have created bitcode here: ' + '\n'.join(output) # Compiling one of them alone is expected to fail - output = Popen([compiler, 'twopart_main.bc'] + args, stdout=PIPE, stderr=PIPE).communicate() + output = Popen([compiler, 'twopart_main.o'] + args, stdout=PIPE, stderr=PIPE).communicate() assert os.path.exists(target), '\n'.join(output) #print '\n'.join(output) self.assertContained('is not a function', run_js(target, stderr=STDOUT)) try_delete(target) # Combining those bc files into js should work - output = Popen([compiler, 'twopart_main.bc', 'twopart_side.bc'] + args, stdout=PIPE, stderr=PIPE).communicate() + output = Popen([compiler, 'twopart_main.o', 'twopart_side.o'] + args, stdout=PIPE, stderr=PIPE).communicate() assert os.path.exists(target), '\n'.join(output) self.assertContained('side got: hello from main, over', run_js(target)) + # Combining bc files into another bc should also work + try_delete(target) + assert not os.path.exists(target) + output = Popen([compiler, 'twopart_main.o', 'twopart_side.o', '-o', 'combined.bc'] + args, stdout=PIPE, stderr=PIPE).communicate() + assert os.path.exists('combined.bc'), '\n'.join(output) + self.assertContained('side got: hello from main, over', self.run_llvm_interpreter(['combined.bc'])) + + # TODO: compile .ll inputs to emcc into .bc + # TODO: dlmalloc in emcc (just pass the arg to emscripten.py) # TODO: test normal project linking, static and dynamic: get_library should not need to be told what to link! # TODO: when ready, switch tools/shared building to use emcc over emmaken # TODO: when this is done, more test runner to test these (i.e., test all -Ox thoroughly) + # TODO: emscripten tutorial with emcc + # TODO: deprecate llvm optimizations etc. in emscripten.py. # Finally, do some web browser tests def run_browser(html_file, message): @@ -5069,7 +5090,7 @@ Options that are modified or new in %s include: def test_js_optimizer(self): input = open(path_from_root('tools', 'test-js-optimizer.js')).read() expected = open(path_from_root('tools', 'test-js-optimizer-output.js')).read() - output = Popen([NODE_JS, JS_OPTIMIZER, 'unGlobalize', 'removeAssignsToUndefined', 'simplifyExpressions', 'loopOptimizer'], + output = Popen([NODE_JS, JS_OPTIMIZER, 'unGlobalize', 'removeAssignsToUndefined', 'simplifyExpressionsPre', 'simplifyExpressionsPost', 'loopOptimizer'], stdin=PIPE, stdout=PIPE).communicate(input)[0] self.assertIdentical(expected, output.replace('\n\n', '\n')) @@ -5110,8 +5131,6 @@ else: print 'Benchmarking JS engine:', JS_ENGINE Building.COMPILER_TEST_OPTS = [] - # TODO: Use other js optimizer options, like remove assigns to undefined (seems to slow us down more than speed us up) - POST_OPTIMIZATIONS = [['js-optimizer', 'loopOptimizer'], 'eliminator', 'closure', ['js-optimizer', 'simplifyExpressions']] TEST_REPS = 10 TOTAL_TESTS = 7 |