def ExecuteLLVMTorture(name, runner, indir, fails, extension, outdir='', wasmjs='', extra_files=None, warn_only=False): extra_files = [] if extra_files is None else extra_files buildbot.Step('Execute LLVM Torture with %s' % name) if not indir: print 'Step skipped: no input' buildbot.Fail(True) return None assert os.path.isfile(runner), 'Cannot find runner at %s' % runner files = os.path.join(indir, '*.%s' % extension) unexpected_result_count = execute_files.run(runner=runner, files=files, fails=fails, out=outdir, wasmjs=wasmjs, extra_files=extra_files) if 0 != unexpected_result_count: buildbot.Fail(warn_only) return outdir
def Musl(): buildbot.Step('musl') Mkdir(MUSL_OUT_DIR) path = os.environ['PATH'] try: # Build musl directly to wasm object files in an ar library proc.check_call([ os.path.join(MUSL_SRC_DIR, 'libc.py'), '--clang_dir', HOST_BIN, '--out', os.path.join(MUSL_OUT_DIR, 'libc.a'), '--musl', MUSL_SRC_DIR ]) CopyLibraryToSysroot(SYSROOT_DIR, os.path.join(MUSL_OUT_DIR, 'libc.a')) CopyLibraryToSysroot(SYSROOT_DIR, os.path.join(MUSL_OUT_DIR, 'crt1.o')) CopyLibraryToSysroot( SYSROOT_DIR, os.path.join(MUSL_SRC_DIR, 'arch', 'wasm32', 'libc.imports')) CopyTree(os.path.join(MUSL_SRC_DIR, 'include'), os.path.join(SYSROOT_DIR, 'include')) CopyTree(os.path.join(MUSL_SRC_DIR, 'arch', 'generic'), os.path.join(SYSROOT_DIR, 'include')) CopyTree(os.path.join(MUSL_SRC_DIR, 'arch', 'wasm32'), os.path.join(SYSROOT_DIR, 'include')) CopyTree(os.path.join(MUSL_OUT_DIR, 'obj', 'include'), os.path.join(SYSROOT_DIR, 'include')) except proc.CalledProcessError: # Note the failure but allow the build to continue. buildbot.Fail() finally: os.environ['PATH'] = path
def ExecuteEmscriptenTestSuite(name, outdir): buildbot.Step('Execute emscripten testsuite (emwasm)') Mkdir(EMSCRIPTEN_TEST_OUT_DIR) try: proc.check_call( [sys.executable, os.path.join(INSTALL_BIN, 'emscripten', 'tests', 'runner.py'), 'binaryen2', '--em-config', EMSCRIPTEN_CONFIG_WASM], cwd=outdir) except proc.CalledProcessError: buildbot.Fail(True)
def LinkLLVMTorture(name, linker, fails, indir, outdir, extension, opt, args=None): buildbot.Step('Link LLVM Torture (%s, %s)' % (name, opt)) assert os.path.isfile(linker), 'Cannot find linker at %s' % linker Remove(outdir) Mkdir(outdir) input_pattern = os.path.join(indir, '*.' + extension) unexpected_result_count = link_assembly_files.run( linker=linker, files=input_pattern, fails=fails, attributes=[opt], out=outdir, args=args) if 0 != unexpected_result_count: buildbot.Fail()
def LinkLLVMTorture(name, linker, fails): buildbot.Step('Link LLVM Torture with %s' % name) assert os.path.isfile(linker), 'Cannot find linker at %s' % linker assembly_files = os.path.join(TORTURE_S_OUT_DIR, '*.s') out = os.path.join(WORK_DIR, 'torture-%s' % name) Remove(out) Mkdir(out) unexpected_result_count = link_assembly_files.run( linker=linker, files=assembly_files, fails=fails, out=out) Archive('torture-%s' % name, Tar(out)) if 0 != unexpected_result_count: buildbot.Fail() return out
def Summary(repos): buildbot.Step('Summary') info = {'repositories': repos} info_file = os.path.join(HOST_DIR, 'buildinfo.json') print 'Failed steps: %s.' % buildbot.Failed() for step in buildbot.FailedList(): print ' %s' % step print 'Warned steps: %s.' % buildbot.Warned() for step in buildbot.WarnedList(): print ' %s' % step if buildbot.Failed(): buildbot.Fail()
def AssembleLLVMTorture(name, assembler, indir, fails): buildbot.Step('Assemble LLVM Torture with %s' % name) assert os.path.isfile(assembler), 'Cannot find assembler at %s' % assembler files = os.path.join(indir, '*.wast') out = os.path.join(WORK_DIR, 'torture-%s' % name) Remove(out) Mkdir(out) unexpected_result_count = assemble_files.run(assembler=assembler, files=files, fails=fails, out=out) Archive('torture-%s' % name, Tar(out)) if 0 != unexpected_result_count: buildbot.Fail() return out
def Emscripten(use_asm=True): buildbot.Step('emscripten') # Remove cached library builds (e.g. libc, libc++) to force them to be # rebuilt in the step below. Remove(os.path.expanduser(os.path.join('~', '.emscripten_cache'))) emscripten_dir = os.path.join(INSTALL_DIR, 'bin', 'emscripten') Remove(emscripten_dir) shutil.copytree( EMSCRIPTEN_SRC_DIR, emscripten_dir, symlinks=True, # Ignore the big git blob so it doesn't get archived. ignore=shutil.ignore_patterns('.git')) def WriteEmscriptenConfig(infile, outfile): with open(infile) as config: text = config.read().replace('{{WASM_INSTALL}}', INSTALL_DIR) with open(outfile, 'w') as config: config.write(text) WriteEmscriptenConfig(os.path.join(SCRIPT_DIR, 'emscripten_config'), EMSCRIPTEN_CONFIG_ASMJS) WriteEmscriptenConfig( os.path.join(SCRIPT_DIR, 'emscripten_config_vanilla'), EMSCRIPTEN_CONFIG_WASM) try: # Build a C++ file with each active emscripten config. This causes system # libs to be built and cached (so we don't have that happen when building # tests in parallel). Do it with full debug output. # This depends on binaryen already being built and installed into the # archive/install dir. os.environ['EMCC_DEBUG'] = '2' configs = [EMSCRIPTEN_CONFIG_WASM ] + ([EMSCRIPTEN_CONFIG_ASMJS] if use_asm else []) for config in configs: os.environ['EM_CONFIG'] = config proc.check_call([ os.path.join(emscripten_dir, 'em++'), os.path.join(EMSCRIPTEN_SRC_DIR, 'tests', 'hello_libcxx.cpp'), '-O2', '-s', 'BINARYEN=1', '-s', 'BINARYEN_METHOD="native-wasm"' ]) except proc.CalledProcessError: # Note the failure but allow the build to continue. buildbot.Fail() finally: del os.environ['EMCC_DEBUG']
def CompileLLVMTorture(outdir, opt): name = 'Compile LLVM Torture (%s)' % (opt) buildbot.Step(name) c = Executable(os.path.join(HOST_BIN, 'clang')) cxx = Executable(os.path.join(HOST_BIN, 'clang++')) Remove(outdir) Mkdir(outdir) unexpected_result_count = compile_torture_tests.run( c=c, cxx=cxx, testsuite=GCC_TEST_DIR, sysroot_dir=SYSROOT_DIR, fails=LLVM_KNOWN_TORTURE_FAILURES, out=outdir, config='wasm-o', opt=opt) if 0 != unexpected_result_count: buildbot.Fail()
def CompileLLVMTorture(): name = 'Compile LLVM Torture' buildbot.Step(name) c = os.path.join(INSTALL_BIN, 'clang') cxx = os.path.join(INSTALL_BIN, 'clang++') Remove(TORTURE_S_OUT_DIR) Mkdir(TORTURE_S_OUT_DIR) unexpected_result_count = compile_torture_tests.run( c=c, cxx=cxx, testsuite=GCC_TEST_DIR, sysroot_dir=INSTALL_SYSROOT, fails=LLVM_KNOWN_TORTURE_FAILURES, out=TORTURE_S_OUT_DIR) Archive('torture-c', Tar(GCC_TEST_DIR)) Archive('torture-s', Tar(TORTURE_S_OUT_DIR)) if 0 != unexpected_result_count: buildbot.Fail()
def main(): start = time.time() try: ret = run() print 'Completed in {}s'.format(time.time() - start) return ret except: traceback.print_exc() # If an except is raised during one of the steps we still need to # print the @@@STEP_FAILURE@@@ annotation otherwise the annotator # makes the failed stap as green: # TODO(sbc): Remove this if the annotator is fixed: http://crbug.com/647357 if buildbot.current_step: buildbot.Fail() return 1
def CompileLLVMTortureBinaryen(name, em_config, outdir, fails): buildbot.Step(name) os.environ['EM_CONFIG'] = em_config c = os.path.join(INSTALL_DIR, 'bin', 'emscripten', 'emcc') cxx = os.path.join(INSTALL_DIR, 'bin', 'emscripten', 'em++') Remove(outdir) Mkdir(outdir) unexpected_result_count = compile_torture_tests.run( c=c, cxx=cxx, testsuite=GCC_TEST_DIR, sysroot_dir=INSTALL_SYSROOT, fails=fails, out=outdir, config='binaryen-interpret') Archive('torture-' + em_config, Tar(outdir)) if 0 != unexpected_result_count: buildbot.Fail() return outdir
def Summary(repos): buildbot.Step('Summary') info = {'repositories': repos} info['build'] = BUILDBOT_BUILDNUMBER info['scheduler'] = SCHEDULER info_json = json.dumps(info) print info print 'Failed steps: %s.' % buildbot.Failed() with open('latest', 'w+') as f: f.write(info_json) buildbot.Link('latest', cloud.Upload('latest', 'git/latest')) if buildbot.Failed(): buildbot.Fail() else: with open('lkgr', 'w+') as f: f.write(info_json) buildbot.Link('lkgr', cloud.Upload('lkgr', 'git/lkgr'))
def Musl(): buildbot.Step('musl') Mkdir(MUSL_OUT_DIR) try: proc.check_call([ os.path.join(MUSL_SRC_DIR, 'libc.py'), '--clang_dir', INSTALL_BIN, '--binaryen_dir', INSTALL_BIN, '--sexpr_wasm', os.path.join(INSTALL_BIN, 'sexpr-wasm'), '--musl', MUSL_SRC_DIR ], cwd=MUSL_OUT_DIR) for f in ['musl.wast', 'musl.wasm']: CopyLibraryToArchive(os.path.join(MUSL_OUT_DIR, f)) CopyLibraryToArchive( os.path.join(MUSL_SRC_DIR, 'arch', 'wasm32', 'wasm.js')) CopyTree(os.path.join(MUSL_SRC_DIR, 'include'), os.path.join(INSTALL_SYSROOT, 'include')) CopyTree(os.path.join(MUSL_SRC_DIR, 'arch', 'wasm32'), os.path.join(INSTALL_SYSROOT, 'include')) except proc.CalledProcessError: buildbot.Fail()
def run(): #Clobber() try: BuildRepos() except Exception: # If any exception reaches here, do not attempt to run the tests; just # log the error for buildbot and exit print "Exception thrown in build step." traceback.print_exc() buildbot.Fail() Summary({}) return 1 for t in AllTests(): t.Test() # Keep the summary step last: it'll be marked as red if the return code is # non-zero. Individual steps are marked as red with buildbot.Fail(). Summary({}) return buildbot.Failed()
def Summary(repos): buildbot.Step('Summary') info = {'repositories': repos} info['build'] = BUILDBOT_BUILDNUMBER info['scheduler'] = SCHEDULER info_json = json.dumps(info, indent=2) print info_json print 'Failed steps: %s.' % buildbot.Failed() for step in buildbot.FailedList(): print ' %s' % step latest_file = os.path.join(WORK_DIR, 'latest') with open(latest_file, 'w+') as f: f.write(info_json) buildbot.Link('latest', cloud.Upload(latest_file, 'git/latest')) if buildbot.Failed(): buildbot.Fail() else: lkgr_file = os.path.join(WORK_DIR, 'lkgr') with open(lkgr_file, 'w+') as f: f.write(info_json) buildbot.Link('lkgr', cloud.Upload(lkgr_file, 'git/lkgr'))
def Emscripten(use_asm=True): buildbot.Step('emscripten') # Remove cached library builds (e.g. libc, libc++) to force them to be # rebuilt in the step below. Remove(os.path.expanduser(os.path.join('~', '.emscripten_cache'))) em_config = os.path.join(INSTALL_DIR, 'emscripten_config') emscripten_dir = os.path.join(INSTALL_DIR, 'bin', 'emscripten') Remove(emscripten_dir) shutil.copytree( EMSCRIPTEN_SRC_DIR, emscripten_dir, symlinks=True, # Ignore the big git blob so it doesn't get archived. ignore=shutil.ignore_patterns('.git')) shutil.copy2(os.path.join(SCRIPT_DIR, 'emscripten_config_vanilla'), em_config + '_vanilla') shutil.copy2(os.path.join(SCRIPT_DIR, 'emscripten_config'), em_config) try: # Build a C++ file with each active emscripten config. This causes system # libs to be built and cached (so we don't have that happen when building # tests in parallel). Do it with full debug output. # This depends on binaryen already being built and installed into the # archive/install dir. os.environ['EMCC_DEBUG'] = '2' configs = [em_config + '_vanilla'] + ([em_config] if use_asm else []) for config in configs: os.environ['EM_CONFIG'] = config proc.check_call([ os.path.join(emscripten_dir, 'em++'), os.path.join(EMSCRIPTEN_SRC_DIR, 'tests', 'hello_libcxx.cpp'), '-O2', '-s', 'BINARYEN=1', '-s', 'BINARYEN_METHOD="native-wasm"' ]) except proc.CalledProcessError: # Don't make it fatal yet. buildbot.Fail(True) finally: del os.environ['EMCC_DEBUG']
def main(): import time start = time.time() options = ParseArgs() sync_include = options.sync_include if options.sync else [] sync_filter = Filter(sync_include, options.sync_exclude) build_include = options.build_include if options.build else [] build_filter = Filter(build_include, options.build_exclude) test_include = options.test_include if options.test else [] test_filter = Filter(test_include, options.test_exclude) try: ret = run(sync_filter, build_filter, test_filter, options) print 'Completed in {}s'.format(time.time() - start) return ret except: traceback.print_exc() # If an except is raised during one of the steps we still need to # print the @@@STEP_FAILURE@@@ annotation otherwise the annotator # makes the failed stap as green: # TODO(sbc): Remove this if the annotator is fixed: http://crbug.com/647357 if buildbot.current_step: buildbot.Fail() return 1
def run(sync_filter, build_filter, test_filter, options): Clobber() Chdir(SCRIPT_DIR) Mkdir(WORK_DIR) SyncRepos(sync_filter, options.sync_lkgr) repos = None if sync_filter.Check(''): repos = GetRepoInfo() if build_filter.All(): Remove(INSTALL_DIR) Mkdir(INSTALL_DIR) Mkdir(INSTALL_BIN) Mkdir(INSTALL_LIB) # Add prebuilt cmake to PATH so any subprocesses use a consistent cmake. os.environ['PATH'] = (os.path.join(PREBUILT_CMAKE_DIR, 'bin') + os.pathsep + os.environ['PATH']) try: BuildRepos(build_filter, test_filter.Check('asm')) except Exception as e: # If any exception reaches here, do not attempt to run the tests; just # log the error for buildbot and exit print "Exception thrown: {}".format(e) buildbot.Fail() Summary(repos) return 1 if test_filter.Check('bare'): CompileLLVMTorture() s2wasm_out = LinkLLVMTorture( name='s2wasm', linker=os.path.join(INSTALL_BIN, '0xb', 's2wasm'), fails=S2WASM_KNOWN_TORTURE_FAILURES) sexpr_wasm_out = AssembleLLVMTorture( name='s2wasm-sexpr-wasm', assembler=os.path.join(INSTALL_BIN, 'sexpr-wasm'), indir=s2wasm_out, fails=SEXPR_S2WASM_KNOWN_TORTURE_FAILURES) ExecuteLLVMTorture( name='wasm-shell', runner=os.path.join(INSTALL_BIN, '0xb', 'wasm-shell'), indir=s2wasm_out, fails=BINARYEN_SHELL_KNOWN_TORTURE_FAILURES, extension='wast', warn_only=True) # TODO wasm-shell is flaky when running tests. ExecuteLLVMTorture( name='spec', runner=os.path.join(INSTALL_BIN, 'wasm.opt'), indir=s2wasm_out, fails=SPEC_KNOWN_TORTURE_FAILURES, extension='wast') ExecuteLLVMTorture( name='d8', runner=os.path.join(INSTALL_BIN, 'd8'), indir=sexpr_wasm_out, fails=V8_KNOWN_TORTURE_FAILURES, extension='wasm', warn_only=True, wasmjs=os.path.join(INSTALL_LIB, 'wasm.js')) ExecuteLLVMTorture( name='d8-musl', runner=os.path.join(INSTALL_BIN, 'd8'), indir=sexpr_wasm_out, fails=V8_MUSL_KNOWN_TORTURE_FAILURES, extension='wasm', warn_only=True, wasmjs=os.path.join(INSTALL_LIB, 'wasm.js'), extra_files=[os.path.join(INSTALL_LIB, 'musl.wasm')]) if test_filter.Check('asm'): asm2wasm_out = CompileLLVMTortureBinaryen( 'Compile LLVM Torture (asm2wasm)', os.path.join(INSTALL_DIR, 'emscripten_config'), ASM2WASM_TORTURE_OUT_DIR, ASM2WASM_KNOWN_TORTURE_COMPILE_FAILURES) ExecuteLLVMTorture( name='asm2wasm', runner=os.path.join(INSTALL_BIN, 'd8'), indir=asm2wasm_out, fails=ASM2WASM_KNOWN_TORTURE_FAILURES, extension='c.js', outdir=asm2wasm_out) # emscripten's wasm.js expects all files in cwd. if test_filter.Check('emwasm'): emscripten_wasm_out = CompileLLVMTortureBinaryen( 'Compile LLVM Torture (emscripten+wasm backend)', os.path.join(INSTALL_DIR, 'emscripten_config_vanilla'), EMSCRIPTENWASM_TORTURE_OUT_DIR, EMSCRIPTENWASM_KNOWN_TORTURE_COMPILE_FAILURES) ExecuteLLVMTorture( name='emscripten-wasm', runner=os.path.join(INSTALL_BIN, 'd8'), indir=emscripten_wasm_out, fails=EMSCRIPTENWASM_KNOWN_TORTURE_FAILURES, extension='c.js', outdir=emscripten_wasm_out) if test_filter.Check('emtest'): ExecuteEmscriptenTestSuite( 'Emscripten test suite (wasm backend)', outdir=EMSCRIPTEN_TEST_OUT_DIR) # Keep the summary step last: it'll be marked as red if the return code is # non-zero. Individual steps are marked as red with buildbot.Fail(). Summary(repos) return buildbot.Failed()