diff options
-rwxr-xr-x | tests/runner.py | 40 | ||||
-rw-r--r-- | tools/shared.py | 19 |
2 files changed, 58 insertions, 1 deletions
diff --git a/tests/runner.py b/tests/runner.py index bf971996..7085f5f9 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -15,7 +15,7 @@ will use 4 processes. To install nose do something like ''' from subprocess import Popen, PIPE, STDOUT -import os, unittest, tempfile, shutil, time, inspect, sys, math, glob, tempfile, re, difflib, webbrowser, hashlib, threading, platform, BaseHTTPServer, multiprocessing, functools +import os, unittest, tempfile, shutil, time, inspect, sys, math, glob, tempfile, re, difflib, webbrowser, hashlib, threading, platform, BaseHTTPServer, multiprocessing, functools, stat if len(sys.argv) == 1: @@ -8455,6 +8455,44 @@ elif 'sanity' in str(sys.argv): output = self.check_working([EMCC, '-O2', 'tests/hello_world.cpp'], '') assert os.path.exists('a.out.js') + def test_llvm(self): + LLVM_WARNING = 'warning: LLVM version appears incorrect' + + restore() + + # Clang should report the version number we expect, and emcc should not warn + assert ('clang version ' + '.'.join(map(str, EXPECTED_LLVM_VERSION))) in Popen([CLANG, '-v'], stderr=PIPE).communicate()[1] + output = self.check_working(EMCC) + assert LLVM_WARNING not in output, output + + # Fake a different llvm version + restore() + f = open(CONFIG_FILE, 'a') + f.write('LLVM_ROOT = "' + path_from_root('tests', 'fake') + '"') + f.close() + + if not os.path.exists(path_from_root('tests', 'fake')): + os.makedirs(path_from_root('tests', 'fake')) + + try: + os.environ['EM_IGNORE_SANITY'] = '1' + for x in range(-2, 3): + for y in range(-2, 3): + f = open(path_from_root('tests', 'fake', 'clang'), 'w') + f.write('#!/bin/sh\n') + f.write('echo "clang version %d.%d" 1>&2\n' % (EXPECTED_LLVM_VERSION[0] + x, EXPECTED_LLVM_VERSION[1] + y)) + f.close() + shutil.copyfile(path_from_root('tests', 'fake', 'clang'), path_from_root('tests', 'fake', 'clang++')) + os.chmod(path_from_root('tests', 'fake', 'clang'), stat.S_IREAD | stat.S_IWRITE | stat.S_IEXEC) + os.chmod(path_from_root('tests', 'fake', 'clang++'), stat.S_IREAD | stat.S_IWRITE | stat.S_IEXEC) + if x != 0 or y != 0: + output = self.check_working(EMCC, LLVM_WARNING) + else: + output = self.check_working(EMCC) + assert LLVM_WARNING not in output, output + finally: + del os.environ['EM_IGNORE_SANITY'] + def test_emcc(self): SANITY_MESSAGE = 'Emscripten: Running sanity checks' SANITY_FAIL_MESSAGE = 'sanity check failed to run' diff --git a/tools/shared.py b/tools/shared.py index c09db358..4ab54273 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -43,12 +43,31 @@ except Exception, e: print >> sys.stderr, 'Error in evaluating %s (at %s): %s, text: %s' % (EM_CONFIG, CONFIG_FILE, str(e), config_text) sys.exit(1) +# Expectations + +EXPECTED_LLVM_VERSION = (3,1) + +def check_llvm_version(): + try: + expected = 'clang version ' + '.'.join(map(str, EXPECTED_LLVM_VERSION)) + actual = Popen([CLANG, '-v'], stderr=PIPE).communicate()[1].split('\n')[0][0:len(expected)] + if expected != actual: + print >> sys.stderr, 'warning: LLVM version appears incorrect (seeing "%s", expected "%s")' % (actual, expected) + except Exception, e: + print >> sys.stderr, 'warning: Could not verify LLVM version: %s' % str(e) + # Check that basic stuff we need (a JS engine to compile, Node.js, and Clang and LLVM) # exists. # The test runner always does this check (through |force|). emcc does this less frequently, # only when ${EM_CONFIG}_sanity does not exist or is older than EM_CONFIG (so, # we re-check sanity when the settings are changed) def check_sanity(force=False): + check_llvm_version() # just a warning, not a fatal check - do it even if EM_IGNORE_SANITY is on + + if os.environ.get('EM_IGNORE_SANITY'): + print >> sys.stderr, 'EM_IGNORE_SANITY set, ignoring sanity checks' + return + try: if not force: if not CONFIG_FILE: |