mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-24 04:09:48 +00:00
dev_container: Pass through NEXTEST_PROFILE
This allows postsubmit to run with the postsubmit nextest profile to fail flaky tests. BUG=b:300669562 TEST=export NEXTEST_PROFILE=postsubmit; dev_container run_tests Change-Id: I4ac9c351e63243cb1c66fabfb755949530768917 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5121290 Reviewed-by: Zihan Chen <zihanchen@google.com> Commit-Queue: Dennis Kempin <denniskempin@google.com>
This commit is contained in:
parent
15058f7b55
commit
a82d43ef87
3 changed files with 18 additions and 6 deletions
|
@ -9,3 +9,6 @@ retries = 2
|
|||
[profile.postsubmit]
|
||||
# Do not retry tests in postsubmit to detect flaky tests.
|
||||
retries = 0
|
||||
|
||||
[profile.presubmit]
|
||||
# Use default settings for presubmit
|
||||
|
|
|
@ -72,8 +72,6 @@ COMMON_ARGS = [
|
|||
"--device /dev/kvm" if Path("/dev/kvm").is_char_device() else None,
|
||||
# Enable terminal colors
|
||||
f"--env TERM={os.environ.get('TERM', 'xterm-256color')}",
|
||||
# Pass through NEXTEST_PROFILE for use by run_tests.
|
||||
f"--env NEXTEST_PROFILE",
|
||||
]
|
||||
|
||||
DOCKER_ARGS = [
|
||||
|
@ -88,6 +86,11 @@ PODMAN_ARGS = [
|
|||
"--pids-limit=4096" if os.name == "posix" else None,
|
||||
]
|
||||
|
||||
# Environment variables to pass through to the container if they are specified.
|
||||
ENV_PASSTHROUGH = [
|
||||
"NEXTEST_PROFILE",
|
||||
]
|
||||
|
||||
|
||||
def machine_is_running(docker: cmd):
|
||||
machine_state = docker("machine info").stdout()
|
||||
|
@ -273,6 +276,14 @@ def main(argv: List[str]):
|
|||
else:
|
||||
docker_args.append(DEV_IMAGE_NAME + ":" + DEV_IMAGE_VERSION)
|
||||
|
||||
# Add environment variables to command line
|
||||
exec_args: List[str] = []
|
||||
for key in ENV_PASSTHROUGH:
|
||||
value = os.environ.get(key)
|
||||
if value is not None:
|
||||
exec_args.append("--env")
|
||||
exec_args.append(f"{key}={quoted(value)}")
|
||||
|
||||
if args.self_test:
|
||||
TestDevContainer.docker = docker
|
||||
suite = unittest.defaultTestLoader.loadTestsFromTestCase(TestDevContainer)
|
||||
|
@ -307,14 +318,14 @@ def main(argv: List[str]):
|
|||
if args.hermetic:
|
||||
# cmd is passed to entrypoint
|
||||
quoted_cmd = list(map(quoted, command))
|
||||
docker(f"run --rm", *tty_args, *docker_args, *quoted_cmd).fg()
|
||||
docker(f"run --rm", *tty_args, *docker_args, *exec_args, *quoted_cmd).fg()
|
||||
else:
|
||||
# cmd is executed directly
|
||||
cid = ensure_container_is_alive(docker, docker_args, args.cros)
|
||||
if not command:
|
||||
command = ("/bin/bash",)
|
||||
quoted_cmd = list(map(quoted, command))
|
||||
docker("exec", *tty_args, cid, *quoted_cmd).fg()
|
||||
docker("exec", *tty_args, *exec_args, cid, *quoted_cmd).fg()
|
||||
|
||||
|
||||
class TestDevContainer(unittest.TestCase):
|
||||
|
|
|
@ -163,7 +163,6 @@ def get_vm_arch(triple: Triple):
|
|||
"--features",
|
||||
help=f"List of comma separated features to be passed to cargo. Defaults to `all-$platform`",
|
||||
)
|
||||
@argh.arg("--profile", help="Select nextest profile.")
|
||||
@argh.arg("--no-parallel", help="Do not parallelize integration tests. Slower but more stable.")
|
||||
@argh.arg("--repetitions", help="Repeat all tests, useful for checking test stability.")
|
||||
def main(
|
||||
|
@ -177,7 +176,6 @@ def main(
|
|||
no_strip: bool = False,
|
||||
run_root_tests: bool = False,
|
||||
features: Optional[str] = None,
|
||||
profile: Optional[str] = None,
|
||||
no_parallel: bool = False,
|
||||
repetitions: int = 1,
|
||||
):
|
||||
|
|
Loading…
Reference in a new issue