crosvm/infra/recipes/build_linux.py
Dennis Kempin 767e094fb8 tools/run_tests: Use triples for arch
Updates run_tests to use cargo style target triples for specifying
build targets. A simple 'aarch64' or 'armhf' was nice while we just
had linux builds. We now are looking at windows and possibly
different toolchain options (e.g. msvc vs gnu), so our old system
was getting confusing and inconsistent.

We used to have some special handling for adding wrappers to test
runs for emulation (e.g. wine, qemu). That logic has been moved
into TestTarget which now contains not just where to run the test
but also how.

Supported are armhf/aarch64 qemu as well as wine64.

The CLI has been updated to match and now uses the build-target
argument instead of arch.

The following combinations have been tested (though not all
combinations actually pass all tests, which is a separate issue).

./tools/run_tests
./tools/run_tests --target=host --build-target=x86_64-unknown-linux-gnu
./tools/run_tests --target=host --build-target=armhf
./tools/run_tests --target=host --build-target=aarch64
./tools/run_tests --target=host --build-target=mingw64
./tools/run_tests --target=vm:aarch64
./tools/run_tests --target=vm:aarch64 --build-target=armhf

BUG=b:233914170
TEST=See above

Change-Id: Ic6dbb5b39788e2573714606d3bb0e7c712032d91
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3739240
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-07-01 19:16:59 +00:00

90 lines
2.7 KiB
Python

# Copyright 2022 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from recipe_engine.recipe_api import Property
from recipe_engine.post_process import DropExpectation, StatusFailure, Filter
from PB.recipes.crosvm.build_linux import BuildLinuxProperties
PYTHON_VERSION_COMPATIBILITY = "PY3"
DEPS = [
"crosvm",
"recipe_engine/buildbucket",
"recipe_engine/context",
"recipe_engine/properties",
"recipe_engine/step",
]
PROPERTIES = BuildLinuxProperties
def get_test_args(api, test_arch):
"Returns architecture specific arguments for ./tools/run_tests"
# TODO(denniskempin): Move this logic into ./tools/presubmit
if test_arch == "" or test_arch == "x86_64":
return ["--target=host"]
elif test_arch == "aarch64":
return ["--target=vm:aarch64"]
elif test_arch == "armhf":
return ["--target=vm:aarch64", "--build-target=armhf"]
else:
raise api.step.StepFailure("Unknown test_arch " + test_arch)
def RunSteps(api, properties):
with api.crosvm.build_context():
api.crosvm.step_in_container(
"Build crosvm tests",
[
"./tools/run_tests",
"--verbose",
"--build-only",
]
+ get_test_args(api, properties.test_arch),
)
api.crosvm.step_in_container(
"Run crosvm tests",
[
"./tools/run_tests",
"--verbose",
]
+ get_test_args(api, properties.test_arch),
)
def GenTests(api):
filter_steps = Filter("Build crosvm tests", "Run crosvm tests")
yield (
api.test(
"build_x86_64",
api.buildbucket.ci_build(project="crosvm/crosvm"),
)
+ api.properties(BuildLinuxProperties(test_arch="x86_64"))
+ api.post_process(filter_steps)
)
yield (
api.test(
"build_aarch64",
api.buildbucket.ci_build(project="crosvm/crosvm"),
)
+ api.properties(BuildLinuxProperties(test_arch="aarch64"))
+ api.post_process(filter_steps)
)
yield (
api.test(
"build_armhf",
api.buildbucket.ci_build(project="crosvm/crosvm"),
)
+ api.properties(BuildLinuxProperties(test_arch="armhf"))
+ api.post_process(filter_steps)
)
yield (
api.test(
"build_unknown",
api.buildbucket.ci_build(project="crosvm/crosvm"),
)
+ api.properties(BuildLinuxProperties(test_arch="foobar"))
+ api.post_process(StatusFailure)
+ api.post_process(DropExpectation)
)