crosvm/tools/impl/test_config.py
Dennis Kempin 18724772c2 Add test runner ./tools/run_tests
The new runner makes use of the simplified crosvm build and greatly
improves execution speed by gathering test binaries from cargo output
and executes them directly in parallel.

This allows all of our tests to execute in ~5 seconds when run locally.

The new test runner also makes use of the new testvm tools to make it
easy to switch between testing on the host, in a VM or via SSH on a
remote device.

See ./tools/run_tests --help for usage instructions.

To allow more iterative testing with the same test targets, this CL
includes a set_test_target script to write env vars that instruct cargo
to build for the target arch and run on the test target.

Note: The test runner can build for armhf, but we need build file fixed
to allow armhf to build successfully.

BUG=b:199951064
TEST=Inside ./tools/dev_container:
./tools/run_tests --target=host
./tools/run_tests --target=vm:aarch64
./tools/run_tests --aarch=armhf --build-only
./tools/set_test_target vm:aarch64 && source .envrc
cargo test

Change-Id: I60291fa726fb2298f62d1f032e55ed6e7ab1c4ac
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3221779
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-15 22:12:03 +00:00

45 lines
1.7 KiB
Python
Executable file

import enum
class TestOption(enum.Enum):
# Build and run tests on aarch64 or arm32 only
BUILD_ARM_ONLY = "build_arm_only"
# Build and run tests on x86_64 only
BUILD_X86_ONLY = "build_x86_only"
# Do not build nor run tests
DO_NOT_BUILD = "do_not_build"
# Build but do not run tests
DO_NOT_RUN = "do_not_run"
# Build for all platforms, but only run on arm
RUN_ARM_ONLY = "run_arm_only"
# Build for all platforms, but only run on x86
RUN_X86_ONLY = "run_x86_only"
# Run tests single-threaded
SINGLE_THREADED = "single_threaded"
# Configuration to restrict how and where tests of a certain crate can
# be build and run.
#
# Please add a bug number when restricting a tests.
CRATE_OPTIONS: dict[str, list[TestOption]] = {
"aarch64": [TestOption.BUILD_ARM_ONLY],
"enumn": [TestOption.RUN_X86_ONLY], # b/203100960
"cros_async": [TestOption.DO_NOT_BUILD], # b/202293468
"crosvm_plugin": [TestOption.BUILD_X86_ONLY],
"devices": [TestOption.SINGLE_THREADED],
"disk": [TestOption.RUN_X86_ONLY], # b/202294155
"fuzz": [TestOption.DO_NOT_BUILD], # b/194499769
"hypervisor": [TestOption.RUN_X86_ONLY], # b/181672912
"integration_tests": [
TestOption.SINGLE_THREADED,
TestOption.RUN_X86_ONLY, # b/180196508
],
"io_uring": [TestOption.DO_NOT_BUILD], # b/202294403
"kvm": [TestOption.RUN_X86_ONLY], # b/181674144
"libcras_stub": [TestOption.DO_NOT_BUILD], # empty stub crate
"libvda": [TestOption.DO_NOT_BUILD], # b/202293971
"system_api_stub": [TestOption.DO_NOT_BUILD], # empty stub crate
"x86_64": [TestOption.BUILD_X86_ONLY],
"sys_util": [TestOption.SINGLE_THREADED],
}