parser.add_option('--testsuite-all', dest='testsuite_all',
action='store_true', default=False,
help='Run all testsuite steps (requires <arch> argument)')
+ parser.add_option('--llvm-buildpath', dest='llvm_buildpath',
+ help='Path to the LLVM build directory')
+ parser.add_option('-v', '--verbose', action='store_true',
+ default=False, dest='verbose',
+ help=('[--testsuite-report/regression option] ' +
+ 'Print compilation/run logs of failing tests in'
+ 'testsuite report and print all regression output'))
# The following options are specific to parse_llvm_test_report.
parser.add_option('-x', '--exclude', action='append', dest='excludes',
default=[],
default=False, dest='check_excludes',
help=('[--testsuite-report option] ' +
'Report tests which unexpectedly pass'))
- parser.add_option('-v', '--verbose', action='store_true',
- default=False, dest='verbose',
- help=('[--testsuite-report option] ' +
- 'Print compilation/run logs of failing tests'))
parser.add_option('-p', '--build-path', dest='buildpath',
help=('[--testsuite-report option] ' +
'Path to test-suite build directory'))
"""
return config['frontend_attr'] + '_' + config['backend_attr']
-def SetupEnvironment():
+def SetupEnvironment(options):
"""Create an environment.
This is based on the current system, various defaults, and various
environment variables.
+ Args:
+ options: The result of OptionParser.parse_args()
Returns:
A dict with various string->string mappings.
"""
env = {}
pwd = os.getcwd()
- if not pwd.endswith('/native_client'):
+ if not pwd.endswith(os.sep + 'native_client'):
Fatal("ERROR: must be run in native_client/ directory!\n" +
" (Current directory is " + pwd + ")")
# Simulate what's needed from common-tools.sh.
# We need PNACL_BUILDBOT, BUILD_PLATFORM, and HOST_ARCH.
+ # TODO(dschuff): This should come from toolchain_build or the upcoming common
+ # python infrastructure.
env['PNACL_BUILDBOT'] = os.environ.get('PNACL_BUILDBOT', 'false')
if sys.platform == 'linux2':
env['BUILD_PLATFORM'] = 'linux'
env['BUILD_ARCH'] = os.environ.get('BUILD_ARCH', os.uname()[4])
env['HOST_ARCH'] = os.environ.get('HOST_ARCH', env['BUILD_ARCH'])
+ env['HOST_TRIPLE'] = 'x86_64_linux'
elif sys.platform == 'cygwin':
env['BUILD_PLATFORM'] = 'win'
env['HOST_ARCH'] = os.environ.get('HOST_ARCH', 'x86_32')
+ env['HOST_TRIPLE'] = 'i686_pc_cygwin'
elif sys.platform == 'darwin':
env['BUILD_PLATFORM'] = 'mac'
env['HOST_ARCH'] = os.environ.get('HOST_ARCH', 'x86_64')
+ env['HOST_TRIPLE'] = 'x86_64_apple_darwin'
+ elif sys.platform == 'win32':
+ env['BUILD_PLATFORM'] = 'win'
+ env['HOST_ARCH'] = os.environ.get('HOST_ARCH', 'x86_64')
+ env['HOST_TRIPLE'] = 'i686_w64_mingw32'
+ # TODO(dschuff) unify this with toolchain_build_pnacl
+ msys_path = os.environ.get(
+ 'MSYS',
+ os.path.join(os.getcwd(), 'mingw32', 'msys', 'bin'))
+ os.environ['PATH'] = os.pathsep.join([os.environ['PATH'], msys_path])
else:
Fatal("Unknown system " + sys.platform)
if env['HOST_ARCH'] in ['i386', 'i686']:
env['HOST_ARCH'] = 'x86_32'
+
# Set up the rest of the environment.
env['NACL_ROOT'] = pwd
env['LLVM_TESTSUITE_SRC'] = (
- '{NACL_ROOT}/pnacl/git/llvm-test-suite'.format(**env))
+ '{NACL_ROOT}/toolchain_build/src/llvm-test-suite'.format(**env))
env['LLVM_TESTSUITE_BUILD'] = (
'{NACL_ROOT}/pnacl/build/llvm-test-suite'.format(**env))
env['TC_SRC_LLVM'] = (
- '{NACL_ROOT}/pnacl/git/llvm'.format(**env))
- env['TC_BUILD_LLVM'] = (
- '{NACL_ROOT}/pnacl/build/llvm_{HOST_ARCH}'.format(**env))
+ '{NACL_ROOT}/toolchain_build/src/llvm'.format(**env))
+ env['TC_BUILD_LLVM'] = options.llvm_buildpath or (
+ '{NACL_ROOT}/toolchain_build/out/llvm_{HOST_TRIPLE}_work'.format(**env))
env['TC_BUILD_LIBCXX'] = (
- ('{NACL_ROOT}/pnacl/build/' +
- 'c++-stdlib-newlib-portable-libc++/pnacl-target').format(**env))
+ ('{NACL_ROOT}/toolchain_build/out/' +
+ 'libcxx_portable_work/').format(**env))
env['PNACL_CONCURRENCY'] = os.environ.get('PNACL_CONCURRENCY', '8')
# The toolchain used may not be the one downloaded, but one that is freshly
# built into a different directory,
# Overriding the default here will Not affect the sel_ldr
# and IRT used to run the tests (they are controlled by run.py)
- env['PNACL_TOOLCHAIN_LABEL'] = (
- os.environ.get('PNACL_TOOLCHAIN_LABEL',
- 'pnacl_{BUILD_PLATFORM}_x86'.format(**env)))
+ env['PNACL_TOOLCHAIN_DIR'] = (
+ os.environ.get('PNACL_TOOLCHAIN_DIR',
+ '{BUILD_PLATFORM}_x86/pnacl_newlib'.format(**env)))
env['PNACL_BIN'] = (
- '{NACL_ROOT}/toolchain/{PNACL_TOOLCHAIN_LABEL}/bin'.format(**env))
+ '{NACL_ROOT}/toolchain/{PNACL_TOOLCHAIN_DIR}/bin'.format(**env))
env['PNACL_SDK_DIR'] = (
- '{NACL_ROOT}/toolchain/{PNACL_TOOLCHAIN_LABEL}/sdk/lib'
+ '{NACL_ROOT}/toolchain/{PNACL_TOOLCHAIN_DIR}/sdk/lib'
.format(**env))
env['PNACL_SCRIPTS'] = '{NACL_ROOT}/pnacl/scripts'.format(**env)
env['LLVM_REGRESSION_KNOWN_FAILURES'] = (
return env
+def IsEmptyOrNonexistent(testdir):
+ # TODO(dschuff): Because this script is run directly from the buildbot
+ # script and not as part of a toolchain_build rule, we do not know
+ # whether the llvm target was actually built (in which case the working
+ # directory is still there) or whether it was just retrieved from cache
+ # (in which case it was clobbered, since the bots run with --clobber).
+ # So we have to just exit rather than fail here.
+ return not os.path.exists(testdir) or len(os.listdir(testdir)) == 0
+
+
def RunLitTest(testdir, testarg, lit_failures, env, options):
"""Run LLVM lit tests, and check failures against known failures.
0 always
"""
with remember_cwd():
+ if IsEmptyOrNonexistent(testdir):
+ print 'Working directory %s is empty. Not running tests' % testdir
+ if env['PNACL_BUILDBOT'] != 'false':
+ print '@@@STEP_TEXT (skipped)@@@'
+ return 0
os.chdir(testdir)
sub_env = os.environ.copy()
maker = 'ninja' if os.path.isfile('./build.ninja') else 'make'
cmd = [maker, testarg, '-v' if maker == 'ninja' else 'VERBOSE=1']
+ print 'Running lit test:', ' '.join(cmd)
make_pipe = subprocess.Popen(cmd, env=sub_env, stdout=subprocess.PIPE)
lines = []
# output). The readline avoids buffering when reading from a
# pipe in Python 2, which may be complicit in the problem.
for line in iter(make_pipe.stdout.readline, ''):
- if env['PNACL_BUILDBOT'] != 'false':
+ if env['PNACL_BUILDBOT'] != 'false' or options.verbose:
# The buildbots need to be fully verbose and print all output.
print str(datetime.datetime.now()) + ' ' + line,
lines.append(line)
return parse_llvm_test_report.Report(parse_options, filename=report_file)
+def RunTestsuiteSteps(env, config, options):
+ result = 0
+ if IsEmptyOrNonexistent(env['TC_BUILD_LLVM']):
+ print ('LLVM build directory %s is empty. Skipping testsuite' %
+ env['TC_BUILD_LLVM'])
+ if env['PNACL_BUILDBOT'] != 'false':
+ print '@@@STEP_TEXT (skipped)@@@'
+ return result
+ if options.testsuite_all or options.testsuite_prereq:
+ result = result or TestsuitePrereq(env, options)
+ if options.testsuite_all or options.testsuite_clean:
+ result = result or TestsuiteClean(env)
+ if options.testsuite_all or options.testsuite_configure:
+ result = result or TestsuiteConfigure(env)
+ if options.testsuite_all or options.testsuite_run:
+ result = result or TestsuiteRun(env, config, options)
+ if options.testsuite_all or options.testsuite_report:
+ result = result or TestsuiteReport(env, config, options)
+ return result
+
+
def main(argv):
- env = SetupEnvironment()
options, args = ParseCommandLine(argv[1:])
if len(args):
Fatal("Unknown arguments: " + ', '.join(args))
config = ParseConfig(options)
+ env = SetupEnvironment(options)
result = 0
# Run each specified test in sequence, and return on the first failure.
if options.run_llvm_regression:
result = result or RunLitTest(env['TC_BUILD_LIBCXX'], 'check-libcxx',
'LIBCXX_KNOWN_FAILURES',
env, options)
- if options.testsuite_all or options.testsuite_prereq:
- result = result or TestsuitePrereq(env, options)
- if options.testsuite_all or options.testsuite_clean:
- result = result or TestsuiteClean(env)
- if options.testsuite_all or options.testsuite_configure:
- result = result or TestsuiteConfigure(env)
- if options.testsuite_all or options.testsuite_run:
- result = result or TestsuiteRun(env, config, options)
- if options.testsuite_all or options.testsuite_report:
- result = result or TestsuiteReport(env, config, options)
+
+ result = result or RunTestsuiteSteps(env, config, options)
return result
if __name__ == '__main__':