| # Copyright 2019 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| """Recipe for building and running LLVM test-suite.""" |
| |
| from recipe_engine.config import ConfigGroup, Enum, Single |
| from recipe_engine.recipe_api import Property |
| |
| DEPS = [ |
| "fuchsia/cipd_platform", |
| "fuchsia/git", |
| "fuchsia/status_check", |
| "recipe_engine/buildbucket", |
| "recipe_engine/cipd", |
| "recipe_engine/context", |
| "recipe_engine/file", |
| "recipe_engine/isolated", |
| "recipe_engine/json", |
| "recipe_engine/path", |
| "recipe_engine/platform", |
| "recipe_engine/properties", |
| "recipe_engine/python", |
| "recipe_engine/step", |
| ] |
| |
| PROPERTIES = { |
| "repository": Property( |
| kind=str, |
| help="Git repository URL", |
| default="https://fuchsia.googlesource.com/third_party/llvm-test-suite", |
| ), |
| "platform": Property(kind=str, help="CIPD platform for the target", default=None), |
| "clang_toolchain": Property( |
| kind=ConfigGroup(type=Enum("cipd", "isolated"), instance=Single(str)), |
| help="clang toolchain used to build the test-suite", |
| default={}, |
| ), |
| } |
| |
| |
| def RunSteps(api, repository, platform, clang_toolchain): |
| target_platform = platform or api.cipd_platform.name |
| |
| with api.step.nest("cipd_packages"), api.context(infra_steps=True): |
| cipd_dir = api.path["start_dir"].join("cipd") |
| pkgs = api.cipd.EnsureFile() |
| pkgs.add_package("infra/cmake/${platform}", "version:3.9.2") |
| pkgs.add_package("infra/ninja/${platform}", "version:1.8.2") |
| pkgs.add_package("fuchsia/third_party/clang/${platform}", "integration") |
| pkgs.add_package( |
| "fuchsia/sysroot/" + target_platform, "latest", target_platform |
| ) |
| api.cipd.ensure(cipd_dir, pkgs) |
| |
| # Get the toolchain. |
| with api.step.nest("toolchain"), api.context(infra_steps=True): |
| clang_instance = clang_toolchain["instance"] |
| clang_dir = api.path.mkdtemp("clang") |
| |
| if clang_toolchain["type"] == "cipd": |
| pkgs = api.cipd.EnsureFile() |
| pkgs.add_package("fuchsia/third_party/clang/${platform}", clang_instance) |
| api.cipd.ensure(clang_dir, pkgs) |
| elif clang_toolchain["type"] == "isolated": |
| api.isolated.download( |
| "download", isolated_hash=clang_instance, output_dir=clang_dir |
| ) |
| else: # pragma: no cover |
| assert False, "unsupported clang_toolchain package type" |
| |
| # Get sources for test-suite. |
| with api.step.nest("git"), api.context(infra_steps=True): |
| test_suite_dir = api.path["start_dir"].join("llvm-test-suite") |
| revision = api.git.checkout_from_build_input(test_suite_dir, repository) |
| |
| build_dir = api.path["start_dir"].join("test-suite-build") |
| api.file.ensure_directory("create test-suite-build dir", build_dir) |
| |
| with api.step.nest("test-suite"), api.context(cwd=build_dir): |
| api.step( |
| "configure", |
| [ |
| cipd_dir.join("bin", "cmake"), |
| "-GNinja", |
| "-DCMAKE_MAKE_PROGRAM=%s" % cipd_dir.join("ninja"), |
| "-DCMAKE_C_COMPILER=%s" % clang_dir.join("bin", "clang"), |
| "-DCMAKE_CXX_COMPILER=%s" % clang_dir.join("bin", "clang++"), |
| "-DCMAKE_EXE_LINKER_FLAGS=-ldl -lpthread", |
| "-DCMAKE_SHARED_LINKER_FLAGS=-ldl -lpthread", |
| "-DCMAKE_SYSROOT=%s" % cipd_dir.join(target_platform), |
| "-DTEST_SUITE_CXX_ABI=libc++", |
| "-C", |
| test_suite_dir.join("cmake", "caches", "O3.cmake"), |
| test_suite_dir, |
| ], |
| ) |
| api.step("build", [cipd_dir.join("ninja")]) |
| api.python( |
| "test", |
| script=api.resource("llvm-lit.py"), |
| args=[ |
| "-o", |
| api.json.output(leak_to=build_dir.join("results.json")), |
| build_dir, |
| ], |
| ) |
| |
| # TODO(fxbug.dev/3137): upload results.json to catapult |
| |
| |
| def GenTests(api): |
| yield ( |
| api.status_check.test("cipd") |
| + api.buildbucket.ci_build( |
| project="fuchsia", |
| bucket="ci", |
| git_repo="https://fuchsia.googlesource.com/third_party/llvm-test-suite", |
| revision="a" * 40, |
| ) |
| + api.platform.name("linux") |
| + api.properties( |
| clang_toolchain={ |
| "type": "cipd", |
| "instance": api.cipd.make_resolved_version(None), |
| } |
| ) |
| ) |
| yield ( |
| api.status_check.test("isolate") |
| + api.buildbucket.ci_build( |
| project="fuchsia", |
| bucket="ci", |
| git_repo="https://fuchsia.googlesource.com/third_party/llvm-test-suite", |
| revision="a" * 40, |
| ) |
| + api.platform.name("linux") |
| + api.properties(clang_toolchain={"type": "isolated", "instance": "abc123",}) |
| ) |