diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-02-27 13:35:34 -0500 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-02-27 13:35:34 -0500 |
commit | 4aad802450a801823849081fff44f63dbc88349e (patch) | |
tree | 325ec4bb377abdff9db5917438747867b65d86cf | |
parent | 013dbae927627b7ca88d15a23ac4a649b99df0d2 (diff) |
test for EMCC_OPTIMIZE_NORMALLY
-rwxr-xr-x | tests/runner.py | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/runner.py b/tests/runner.py index 9cf40543..e9accf2b 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -9659,6 +9659,62 @@ seeked= file. code = open('a.out.js').read() assert 'SAFE_HEAP' in code, 'valid -s option had an effect' + def test_optimize_normally(self): + assert not os.environ.get('EMCC_OPTIMIZE_NORMALLY') + assert not os.environ.get('EMCC_DEBUG') + + try: + os.environ['EMCC_OPTIMIZE_NORMALLY'] = '1' + os.environ['EMCC_DEBUG'] = '1' + + open(self.in_dir('main.cpp'), 'w').write(r''' + extern "C" { + void something(); + } + + int main() { + something(); + return 0; + } + ''') + open(self.in_dir('supp.cpp'), 'w').write(r''' + #include <stdio.h> + + extern "C" { + void something() { + printf("yello\n"); + } + } + ''') + out, err = Popen([PYTHON, EMCC, self.in_dir('main.cpp'), '-O2', '-o', 'main.o'], stdout=PIPE, stderr=PIPE).communicate() + assert "emcc: LLVM opts: ['-disable-inlining', '-O3']" in err + assert ' with -O3 since EMCC_OPTIMIZE_NORMALLY defined' in err + + out, err = Popen([PYTHON, EMCC, self.in_dir('supp.cpp'), '-O2', '-o', 'supp.o'], stdout=PIPE, stderr=PIPE).communicate() + assert "emcc: LLVM opts: ['-disable-inlining', '-O3']" in err + assert ' with -O3 since EMCC_OPTIMIZE_NORMALLY defined' in err + + out, err = Popen([PYTHON, EMCC, self.in_dir('main.o'), self.in_dir('supp.o'), '-O2', '-o', 'both.o'], stdout=PIPE, stderr=PIPE).communicate() + assert "emcc: LLVM opts: ['-disable-inlining', '-O3']" not in err + assert ' with -O3 since EMCC_OPTIMIZE_NORMALLY defined' not in err + assert 'despite EMCC_OPTIMIZE_NORMALLY since not source code' in err, err + + out, err = Popen([PYTHON, EMCC, self.in_dir('main.cpp'), self.in_dir('supp.cpp'), '-O2', '-o', 'both2.o'], stdout=PIPE, stderr=PIPE).communicate() + assert "emcc: LLVM opts: ['-disable-inlining', '-O3']" in err + assert ' with -O3 since EMCC_OPTIMIZE_NORMALLY defined' in err + + for last in ['both.o', 'both2.o']: + out, err = Popen([PYTHON, EMCC, self.in_dir('both.o'), '-O2', '-o', last + '.js'], stdout=PIPE, stderr=PIPE).communicate() + assert "emcc: LLVM opts: ['-disable-inlining', '-O3']" not in err + assert ' with -O3 since EMCC_OPTIMIZE_NORMALLY defined' not in err + output = run_js(last + '.js') + assert 'yello' in output, 'code works' + assert open('both.o.js').read() == open('both2.o.js').read() + + finally: + del os.environ['EMCC_OPTIMIZE_NORMALLY'] + del os.environ['EMCC_DEBUG'] + def test_conftest_s_flag_passing(self): open(os.path.join(self.get_dir(), 'conftest.c'), 'w').write(r''' int main() { |