aboutsummaryrefslogtreecommitdiff
path: root/tests/runner.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/runner.py')
-rwxr-xr-xtests/runner.py110
1 files changed, 78 insertions, 32 deletions
diff --git a/tests/runner.py b/tests/runner.py
index da37583d..ce38f0a2 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -185,7 +185,7 @@ process(sys.argv[1])
''')
transform.close()
transform_args = ['--js-transform', "python %s" % transform_filename]
- Building.emcc(filename + '.o.ll', Settings.serialize() + self.emcc_args + transform_args, filename + '.o.js')
+ Building.emcc(filename + '.o.ll', Settings.serialize() + self.emcc_args + transform_args + Building.COMPILER_TEST_OPTS, filename + '.o.js')
run_post(post2)
# Build JavaScript code from source code
@@ -306,14 +306,14 @@ process(sys.argv[1])
os.makedirs(ret)
return ret
- def get_library(self, name, generated_libs, configure=['sh', './configure'], configure_args=[], make=['make'], make_args=['-j', '2'], cache=True, env_init={}):
+ def get_library(self, name, generated_libs, configure=['sh', './configure'], configure_args=[], make=['make'], make_args=['-j', '2'], cache=True, env_init={}, cache_name_extra=''):
build_dir = self.get_build_dir()
output_dir = self.get_dir()
- cache_name = name + '|' + Building.COMPILER
+ cache_name = name + cache_name_extra
if self.library_cache is not None:
if cache and self.library_cache.get(cache_name):
- print >> sys.stderr, '<load build from cache> ',
+ print >> sys.stderr, '<load %s from cache> ' % cache_name,
generated_libs = []
for basename, contents in self.library_cache[cache_name]:
bc_file = os.path.join(build_dir, basename)
@@ -323,14 +323,14 @@ process(sys.argv[1])
generated_libs.append(bc_file)
return generated_libs
- print >> sys.stderr, '<building and saving into cache> ',
+ print >> sys.stderr, '<building and saving %s into cache> ' % cache_name,
return Building.build_library(name, build_dir, output_dir, generated_libs, configure, configure_args, make, make_args, self.library_cache, cache_name,
copy_project=True, env_init=env_init)
def clear(self):
for name in os.listdir(self.get_dir()):
- try_delete(name)
+ try_delete(os.path.join(self.get_dir(), name))
emcc_debug = os.environ.get('EMCC_DEBUG')
if emcc_debug:
for name in os.listdir(EMSCRIPTEN_TEMP_DIR):
@@ -1123,16 +1123,22 @@ c5,de,15,8a
self.do_run(open(path_from_root('tests', 'cube2md5.cpp')).read(), open(path_from_root('tests', 'cube2md5.ok')).read())
def test_cube2hash(self):
- # A good test of i64 math
- if Settings.USE_TYPED_ARRAYS != 2: return self.skip('requires ta2 C-style memory aliasing')
- self.do_run('', 'Usage: hashstring <seed>',
- libraries=self.get_library('cube2hash', ['cube2hash.bc'], configure=None),
- includes=[path_from_root('tests', 'cube2hash')])
-
- for text, output in [('fleefl', '892BDB6FD3F62E863D63DA55851700FDE3ACF30204798CE9'),
- ('fleefl2', 'AA2CC5F96FC9D540CA24FDAF1F71E2942753DB83E8A81B61'),
- ('64bitisslow', '64D8470573635EC354FEE7B7F87C566FCAF1EFB491041670')]:
- self.do_run('', 'hash value: ' + output, [text], no_build=True)
+ try:
+ old_chunk_size = os.environ.get('EMSCRIPT_MAX_CHUNK_SIZE') or ''
+ os.environ['EMSCRIPT_MAX_CHUNK_SIZE'] = '1' # test splitting out each function to a chunk in emscripten.py (21 functions here)
+
+ # A good test of i64 math
+ if Settings.USE_TYPED_ARRAYS != 2: return self.skip('requires ta2 C-style memory aliasing')
+ self.do_run('', 'Usage: hashstring <seed>',
+ libraries=self.get_library('cube2hash', ['cube2hash.bc'], configure=None),
+ includes=[path_from_root('tests', 'cube2hash')])
+
+ for text, output in [('fleefl', '892BDB6FD3F62E863D63DA55851700FDE3ACF30204798CE9'),
+ ('fleefl2', 'AA2CC5F96FC9D540CA24FDAF1F71E2942753DB83E8A81B61'),
+ ('64bitisslow', '64D8470573635EC354FEE7B7F87C566FCAF1EFB491041670')]:
+ self.do_run('', 'hash value: ' + output, [text], no_build=True)
+ finally:
+ os.environ['EMSCRIPT_MAX_CHUNK_SIZE'] = old_chunk_size
def test_unaligned(self):
if Settings.QUANTUM_SIZE == 1: return self.skip('No meaning to unaligned addresses in q1')
@@ -2785,7 +2791,7 @@ def process(filename):
'''
# Fail without memory growth
- self.do_run(src, 'Cannot enlarge memory arrays. Adjust TOTAL_MEMORY (currently 10485760) or compile with ALLOW_MEMORY_GROWTH')
+ self.do_run(src, 'Cannot enlarge memory arrays.')
fail = open('src.cpp.o.js').read()
# Win with it
@@ -5748,8 +5754,8 @@ void*:16
def get_freetype(self):
Settings.INIT_STACK = 1 # TODO: Investigate why this is necessary
-
- return self.get_library('freetype', os.path.join('objs', '.libs', 'libfreetype.a'))
+ return self.get_library('freetype',
+ os.path.join('objs', '.libs', 'libfreetype.a'))
def test_freetype(self):
if Settings.QUANTUM_SIZE == 1: return self.skip('TODO: Figure out and try to fix')
@@ -6002,17 +6008,23 @@ def process(filename):
do_test()
- # some test coverage for EMCC_DEBUG
+ # some test coverage for EMCC_DEBUG 1 and 2
if self.emcc_args and '-O2' in self.emcc_args and 'EMCC_DEBUG' not in os.environ:
shutil.copyfile('src.c.o.js', 'release.js')
try:
os.environ['EMCC_DEBUG'] = '1'
+ print '2'
do_test()
+ shutil.copyfile('src.c.o.js', 'debug1.js')
+ os.environ['EMCC_DEBUG'] = '2'
+ print '3'
+ do_test()
+ shutil.copyfile('src.c.o.js', 'debug2.js')
finally:
del os.environ['EMCC_DEBUG']
- shutil.copyfile('src.c.o.js', 'debug.js')
- self.assertIdentical(open('release.js').read().replace('\n\n', '\n').replace('\n\n', '\n'), open('debug.js').read().replace('\n\n', '\n').replace('\n\n', '\n')) # EMCC_DEBUG=1 mode must not generate different code!
- print >> sys.stderr, 'debug check passed too'
+ for debug in [1,2]:
+ self.assertIdentical(open('release.js').read().replace('\n\n', '\n').replace('\n\n', '\n'), open('debug%d.js' % debug).read().replace('\n\n', '\n').replace('\n\n', '\n')) # EMCC_DEBUG=1 mode must not generate different code!
+ print >> sys.stderr, 'debug check %d passed too' % debug
else:
print >> sys.stderr, 'not doing debug check'
@@ -6713,6 +6725,8 @@ def process(filename):
assert 'Too many corrections' in str(e), str(e)
def test_debug(self):
+ if '-g' not in Building.COMPILER_TEST_OPTS: Building.COMPILER_TEST_OPTS.append('-g')
+
src = '''
#include <stdio.h>
#include <assert.h>
@@ -6743,6 +6757,7 @@ def process(filename):
assert 'Assertion failed' in str(e), str(e)
def test_linespecific(self):
+ if '-g' not in Building.COMPILER_TEST_OPTS: Building.COMPILER_TEST_OPTS.append('-g')
if self.emcc_args: self.emcc_args += ['--llvm-opts', '0'] # llvm full opts make the expected failures here not happen
Settings.CHECK_SIGNS = 0
@@ -6899,6 +6914,7 @@ def process(filename):
Settings.CORRECT_SIGNS = 0
def test_pgo(self):
+ if '-g' not in Building.COMPILER_TEST_OPTS: Building.COMPILER_TEST_OPTS.append('-g')
Settings.PGO = Settings.CHECK_OVERFLOWS = Settings.CORRECT_OVERFLOWS = Settings.CHECK_SIGNS = Settings.CORRECT_SIGNS = 1
src = '''
@@ -6927,6 +6943,7 @@ def process(filename):
assert 'UnSign|src.cpp:13 : 6 hits, %17 failures' in output, 'no indication of Sign corrections: ' + output
return output
+ print >>sys.stderr, '1'
self.do_run(src, '*186854335,63*\n', output_nicerizer=check)
Settings.PGO = Settings.CHECK_OVERFLOWS = Settings.CORRECT_OVERFLOWS = Settings.CHECK_SIGNS = Settings.CORRECT_SIGNS = 0
@@ -6940,10 +6957,12 @@ def process(filename):
Settings.CORRECT_OVERFLOWS = 2
Settings.CORRECT_OVERFLOWS_LINES = pgo_data['overflows_lines']
+ print >>sys.stderr, '2'
self.do_run(src, '*186854335,63*\n')
# Sanity check: Without PGO, we will fail
+ print >>sys.stderr, '3'
try:
self.do_run(src, '*186854335,63*\n')
except:
@@ -7101,6 +7120,8 @@ class %s(T):
if self.emcc_args is not None:
Settings.load(self.emcc_args)
Building.LLVM_OPTS = 0
+ if '-O2' in self.emcc_args:
+ Building.COMPILER_TEST_OPTS = [] # remove -g in -O2 tests, for more coverage
return
llvm_opts = %d # 1 is yes, 2 is yes and unsafe
@@ -8099,6 +8120,11 @@ fixture: interfaces
--test: test can call interface methods that return nothing''', output)
def test_llvm_nativizer(self):
+ try:
+ Popen(['as', '--version'], stdout=PIPE, stderr=PIPE).communicate()
+ except:
+ return self.skip('no gnu as, cannot run nativizer')
+
# avoid impure_ptr problems etc.
shutil.copyfile(path_from_root('tests', 'files.cpp'), os.path.join(self.get_dir(), 'files.cpp'))
open(os.path.join(self.get_dir(), 'somefile.binary'), 'w').write('''waka waka############################''')
@@ -8123,20 +8149,24 @@ fscanfed: 10 - hello
self.assertIdentical('texte\n', output[1])
def test_emconfig(self):
- output = Popen(['python', EMCONFIG, 'LLVM_ROOT'], stdout=PIPE, stderr=PIPE).communicate()[0]
- assert output == LLVM_ROOT + "\n"
- invalid = 'Usage: em-config VAR_NAME\n'
+ output = Popen(['python', EMCONFIG, 'LLVM_ROOT'], stdout=PIPE, stderr=PIPE).communicate()[0].strip()
+ try:
+ assert output == LLVM_ROOT
+ except:
+ print >> sys.stderr, 'Assertion failed: python %s LLVM_ROOT returned "%s" instead of expected "%s"!' % (EMCONFIG, output, LLVM_ROOT)
+ raise
+ invalid = 'Usage: em-config VAR_NAME'
# Don't accept variables that do not exist
- output = Popen(['python', EMCONFIG, 'VAR_WHICH_DOES_NOT_EXIST'], stdout=PIPE, stderr=PIPE).communicate()[0]
+ output = Popen(['python', EMCONFIG, 'VAR_WHICH_DOES_NOT_EXIST'], stdout=PIPE, stderr=PIPE).communicate()[0].strip()
assert output == invalid
# Don't accept no arguments
- output = Popen(['python', EMCONFIG], stdout=PIPE, stderr=PIPE).communicate()[0]
+ output = Popen(['python', EMCONFIG], stdout=PIPE, stderr=PIPE).communicate()[0].strip()
assert output == invalid
# Don't accept more than one variable
- output = Popen(['python', EMCONFIG, 'LLVM_ROOT', 'EMCC'], stdout=PIPE, stderr=PIPE).communicate()[0]
+ output = Popen(['python', EMCONFIG, 'LLVM_ROOT', 'EMCC'], stdout=PIPE, stderr=PIPE).communicate()[0].strip()
assert output == invalid
# Don't accept arbitrary python code
- output = Popen(['python', EMCONFIG, 'sys.argv[1]'], stdout=PIPE, stderr=PIPE).communicate()[0]
+ output = Popen(['python', EMCONFIG, 'sys.argv[1]'], stdout=PIPE, stderr=PIPE).communicate()[0].strip()
assert output == invalid
def test_link_s(self):
@@ -10047,14 +10077,25 @@ fi
try_delete('a.out.js')
basebc_name = os.path.join(TEMP_DIR, 'emscripten_temp', 'emcc-0-basebc.bc')
- dcebc_name = os.path.join(TEMP_DIR, 'emscripten_temp', 'emcc-1-dce.bc')
+ dcebc_name1 = os.path.join(TEMP_DIR, 'emscripten_temp', 'emcc-1-linktime.bc')
+ dcebc_name2 = os.path.join(TEMP_DIR, 'emscripten_temp', 'emcc-2-linktime.bc')
+ ll_name1 = os.path.join(TEMP_DIR, 'emscripten_temp', 'emcc-2-ll.ll')
+ ll_name2 = os.path.join(TEMP_DIR, 'emscripten_temp', 'emcc-3-ll.ll')
+
+ self.working_dir = os.path.join(TEMP_DIR, 'emscripten_temp')
# Building a file that *does* need dlmalloc *should* trigger cache generation, but only the first time
for filename, libname in [('hello_malloc.cpp', 'dlmalloc'), ('hello_libcxx.cpp', 'libcxx')]:
for i in range(3):
+ print filename, libname, i
+ self.clear()
+ dcebc_name = dcebc_name1 if i == 0 else dcebc_name2
+ ll_name = ll_name1 if i == 0 else ll_name2
try_delete(basebc_name) # we might need to check this file later
try_delete(dcebc_name) # we might need to check this file later
- output = self.do([EMCC, path_from_root('tests', filename)])
+ try_delete(ll_name) # we might need to check this file later
+ output = self.do([EMCC, '-O' + str(i), '--closure', '0', '-s', 'RELOOP=0', '--llvm-lto', '0', path_from_root('tests', filename)])
+ #print output
assert INCLUDING_MESSAGE.replace('X', libname) in output
if libname == 'dlmalloc':
assert INCLUDING_MESSAGE.replace('X', 'libcxx') not in output # we don't need libcxx in this code
@@ -10069,6 +10110,11 @@ fi
assert os.stat(os.path.join(EMCC_CACHE, libname + '.bc')).st_size > 2000000, 'libc++ is big'
assert os.stat(basebc_name).st_size > 2000000, 'libc++ is indeed big'
assert os.stat(dcebc_name).st_size < 1500000, 'Dead code elimination must remove most of libc++'
+ # should only have metadata in -O0, not 1 and 2
+ ll = open(ll_name).read()
+ if (ll.count('\n!') < 10) == (i == 0): # a few lines are left even in -O1 and -O2
+ print i, 'll metadata should be removed in -O1 and O2 by default', ll[-300:]
+ assert False
finally:
if emcc_debug:
os.environ['EMCC_DEBUG'] = emcc_debug