diff options
author | Alon Zakai <alonzakai@gmail.com> | 2014-02-26 17:58:26 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2014-02-26 17:58:26 -0800 |
commit | 2a43c14b8458f4e5c4e7ee5b8e28d52be5f472bb (patch) | |
tree | d29810ab00f0974d419d5b8a2a6c1c423a12d9ab | |
parent | 024adc2a7a7fe07b4c7436eed072646734e741f5 (diff) |
more warnings on source versions not matching, plus testing
-rw-r--r-- | tests/test_sanity.py | 46 | ||||
-rw-r--r-- | tools/shared.py | 4 |
2 files changed, 45 insertions, 5 deletions
diff --git a/tests/test_sanity.py b/tests/test_sanity.py index f78ff1c5..3d3da523 100644 --- a/tests/test_sanity.py +++ b/tests/test_sanity.py @@ -214,20 +214,56 @@ class sanity(RunnerCore): # Fake incorrect llc output, no mention of js backend restore() f = open(CONFIG_FILE, 'a') - f.write('LLVM_ROOT = "' + path_from_root('tests', 'fake') + '"') + f.write('LLVM_ROOT = "' + path_from_root('tests', 'fake', 'bin') + '"') f.close() + #print '1', open(CONFIG_FILE).read() - if not os.path.exists(path_from_root('tests', 'fake')): - os.makedirs(path_from_root('tests', 'fake')) + try_delete(path_from_root('tests', 'fake')) + os.makedirs(path_from_root('tests', 'fake', 'bin')) - f = open(path_from_root('tests', 'fake', 'llc'), 'w') + f = open(path_from_root('tests', 'fake', 'bin', 'llc'), 'w') f.write('#!/bin/sh\n') f.write('echo "llc fake output\nRegistered Targets:\nno j-s backend for you!"') f.close() - os.chmod(path_from_root('tests', 'fake', 'llc'), stat.S_IREAD | stat.S_IWRITE | stat.S_IEXEC) + os.chmod(path_from_root('tests', 'fake', 'bin', 'llc'), stat.S_IREAD | stat.S_IWRITE | stat.S_IEXEC) output = self.check_working(EMCC, WARNING) output = self.check_working(EMCC, WARNING2) + # fake some more + for fake in ['llvm-link', 'clang', 'clang++', 'llvm-ar', 'opt', 'llvm-as', 'llvm-dis', 'llvm-nm', 'lli']: + open(path_from_root('tests', 'fake', 'bin', fake), 'w').write('.') + try_delete(SANITY_FILE) + output = self.check_working(EMCC, WARNING) + # make sure sanity checks notice there is no source dir with version # + open(path_from_root('tests', 'fake', 'bin', 'llc'), 'w').write('#!/bin/sh\necho "Registered Targets: there IZ a js backend: JavaScript (asm.js, emscripten) backend"') + open(path_from_root('tests', 'fake', 'bin', 'clang++'), 'w').write('#!/bin/sh\necho "clang version %s (blah blah)" >&2\necho "..." >&2\n' % '.'.join(map(str, EXPECTED_LLVM_VERSION))) + os.chmod(path_from_root('tests', 'fake', 'bin', 'llc'), stat.S_IREAD | stat.S_IWRITE | stat.S_IEXEC) + os.chmod(path_from_root('tests', 'fake', 'bin', 'clang++'), stat.S_IREAD | stat.S_IWRITE | stat.S_IEXEC) + try_delete(SANITY_FILE) + output = self.check_working(EMCC, 'did not see a source tree above LLVM_DIR, could not verify version numbers match') + + VERSION_WARNING = 'Emscripten, llvm and clang versions do not match, this is dangerous' + + # add version number + open(path_from_root('tests', 'fake', 'emscripten-version.txt'), 'w').write('waka') + try_delete(SANITY_FILE) + output = self.check_working(EMCC, VERSION_WARNING) + + os.makedirs(path_from_root('tests', 'fake', 'tools', 'clang')) + + open(path_from_root('tests', 'fake', 'tools', 'clang', 'emscripten-version.txt'), 'w').write(EMSCRIPTEN_VERSION) + try_delete(SANITY_FILE) + output = self.check_working(EMCC, VERSION_WARNING) + + open(path_from_root('tests', 'fake', 'emscripten-version.txt'), 'w').write(EMSCRIPTEN_VERSION) + try_delete(SANITY_FILE) + output = self.check_working(EMCC) + assert VERSION_WARNING not in output + + open(path_from_root('tests', 'fake', 'tools', 'clang', 'emscripten-version.txt'), 'w').write('waka') + try_delete(SANITY_FILE) + output = self.check_working(EMCC, VERSION_WARNING) + restore() self.check_working([EMCC, 'tests/hello_world.cpp', '-s', 'INIT_HEAP=1'], '''Compiler settings are incompatible with fastcomp. You can fall back to the older compiler core, although that is not recommended, see https://github.com/kripken/emscripten/wiki/LLVM-Backend''') diff --git a/tools/shared.py b/tools/shared.py index f2f90398..ac6319bf 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -307,9 +307,11 @@ def check_fastcomp(): return False # look for a source tree under the llvm binary directory. if there is one, look for emscripten-version.txt files + seen = False d = os.path.dirname(LLVM_COMPILER) while d != os.path.dirname(d): if os.path.exists(os.path.join(d, 'emscripten-version.txt')): + seen = True llvm_version = open(os.path.join(d, 'emscripten-version.txt')).read().strip() if os.path.exists(os.path.join(d, 'tools', 'clang', 'emscripten-version.txt')): clang_version = open(os.path.join(d, 'tools', 'clang', 'emscripten-version.txt')).read().strip() @@ -320,6 +322,8 @@ def check_fastcomp(): logging.error('Make sure to use the same branch in each repo, and to be up-to-date on each. See https://github.com/kripken/emscripten/wiki/LLVM-Backend') break d = os.path.dirname(d) + if not seen: + logging.warning('did not see a source tree above LLVM_DIR, could not verify version numbers match') return True except Exception, e: logging.warning('could not check fastcomp: %s' % str(e)) |