mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-05 10:10:41 +00:00
21ec73fc4c
The test runner can now repeat tests in two ways: - Via --repeat to run tests multiple times and fail if any one of them fails. Which will help us find flakes in post-submit. - Via --retry, which will retry a test if it has failed. Which makes pre-submit tests more resilient to flakes. Both can be configured by builder configs to adjust as needed. Also slighly changes the repeat behavior to repeat tests in batches, so we do not run the same test multiple times simultaneously, which can cause some of them to fail. It's also easier to read the results. BUG=b:238232551 TEST=added a random flake into some tests and used --repeat and --retry Change-Id: I78e0ff0751da40a99a56080d9baf207307c9e93a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3751835 Tested-by: Dennis Kempin <denniskempin@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
105 lines
3.2 KiB
Python
105 lines
3.2 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, properties):
|
|
"Returns architecture specific arguments for ./tools/run_tests"
|
|
# TODO(denniskempin): Move this logic into ./tools/presubmit
|
|
test_arch = properties.test_arch
|
|
args = []
|
|
if test_arch == "" or test_arch == "x86_64":
|
|
args += ["--target=host"]
|
|
elif test_arch == "aarch64":
|
|
args += ["--target=vm:aarch64"]
|
|
elif test_arch == "armhf":
|
|
args += ["--target=vm:aarch64", "--build-target=armhf"]
|
|
else:
|
|
raise api.step.StepFailure("Unknown test_arch " + test_arch)
|
|
if properties.crosvm_direct:
|
|
args += ["--crosvm-direct"]
|
|
return args
|
|
|
|
|
|
def RunSteps(api, properties):
|
|
with api.crosvm.container_build_context():
|
|
api.crosvm.step_in_container(
|
|
"Build crosvm tests",
|
|
[
|
|
"./tools/run_tests",
|
|
"--verbose",
|
|
"--build-only",
|
|
]
|
|
+ get_test_args(api, properties),
|
|
)
|
|
api.crosvm.step_in_container(
|
|
"Run crosvm tests",
|
|
[
|
|
"./tools/run_tests",
|
|
"--verbose",
|
|
"--retry=" + str(properties.retry_tests or 0),
|
|
"--repeat=" + str(properties.repeat_tests or 1),
|
|
]
|
|
+ get_test_args(api, properties),
|
|
)
|
|
|
|
|
|
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_x86_64_direct",
|
|
api.buildbucket.ci_build(project="crosvm/crosvm"),
|
|
)
|
|
+ api.properties(BuildLinuxProperties(test_arch="x86_64", crosvm_direct=True))
|
|
+ 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)
|
|
)
|