From 24a226169dfc4fae3049fd6e9d27bd36c92dac90 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Thu, 3 Mar 2022 01:29:26 +0000 Subject: [PATCH] Run some win64 tests with wine as part of presubmit docker container size increases to ~4.7-8 Gb TEST=./dev_container --hermetic ./tools/presubmit BUG=none Change-Id: I49dc03182f6ac5c29e0174618cc3864e073a2eb8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3499264 Reviewed-by: Dennis Kempin Tested-by: kokoro Commit-Queue: Anton Romanov Auto-Submit: Anton Romanov --- .cargo/config.toml | 3 + Cargo.toml | 1 + ci/kokoro/windows/crosvm_build.bat | 2 +- tools/clippy | 2 +- tools/impl/dev_container/Dockerfile | 5 + tools/impl/dev_container/version | 2 +- tools/impl/test_config.py | 221 ++++++++++++++-------------- tools/impl/test_runner.py | 11 +- tools/impl/test_target.py | 9 +- tools/install-aarch64-deps | 1 - tools/install-armhf-deps | 1 - tools/install-deps | 6 +- tools/presubmit | 2 + 13 files changed, 146 insertions(+), 120 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 026186029e..98133d579c 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -42,3 +42,6 @@ rustflags = [ [target.armv7-unknown-linux-gnueabihf] linker = "arm-linux-gnueabihf-gcc" + +[target.x86_64-pc-windows-gnu] +runner = "wine64" diff --git a/Cargo.toml b/Cargo.toml index f5a1ca2186..955ddcbf7c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -116,6 +116,7 @@ all-linux = [ "virgl_renderer", "x", ] +win64 = [] audio = ["devices/audio"] audio_cras = ["devices/audio_cras"] chromeos = ["base/chromeos", "audio_cras", "devices/chromeos"] diff --git a/ci/kokoro/windows/crosvm_build.bat b/ci/kokoro/windows/crosvm_build.bat index 70c56b23d0..942e477d2b 100644 --- a/ci/kokoro/windows/crosvm_build.bat +++ b/ci/kokoro/windows/crosvm_build.bat @@ -48,7 +48,7 @@ py .\tools\clippy if %ERRORLEVEL% neq 0 ( exit /b %ERRORLEVEL% ) echo [%TIME%] Calling crosvm\build_test.py -py ./tools\impl/test_runner.py --arch x86_64 -v +py ./tools\impl/test_runner.py --arch win64 -v if %ERRORLEVEL% neq 0 ( exit /b %ERRORLEVEL% ) exit /b %ERRORLEVEL% diff --git a/tools/clippy b/tools/clippy index b9ce02ce23..d3ae380f62 100755 --- a/tools/clippy +++ b/tools/clippy @@ -25,7 +25,7 @@ if os.name == "posix": FEATURES: str = "--features=all-linux" elif os.name == "nt": - EXCLUDED_CRATES: list[str] = list(get_workspace_excludes("x86_64")) + EXCLUDED_CRATES: list[str] = list(get_workspace_excludes("win64")) EXCLUDED_CRATES_ARGS: list[str] = [f"--exclude={crate}" for crate in EXCLUDED_CRATES] FEATURES: str = "" diff --git a/tools/impl/dev_container/Dockerfile b/tools/impl/dev_container/Dockerfile index 3e2beae607..215cf04e8f 100644 --- a/tools/impl/dev_container/Dockerfile +++ b/tools/impl/dev_container/Dockerfile @@ -25,8 +25,13 @@ RUN apt-get update \ # Delete build artifacts from 'cargo install' to save space in layer. && rm -rf /scratch/cargo_target/* +# Prepare wine64 +RUN ln -sf /usr/bin/wine64-stable /usr/bin/wine64 \ + && wine64 wineboot + # Install cross-compilation dependencies. COPY tools/install-aarch64-deps tools/install-armhf-deps /tools/ + RUN apt-get update \ && /tools/install-aarch64-deps \ && /tools/install-armhf-deps \ diff --git a/tools/impl/dev_container/version b/tools/impl/dev_container/version index 5aed675d3a..fa0363b794 100644 --- a/tools/impl/dev_container/version +++ b/tools/impl/dev_container/version @@ -1 +1 @@ -r0007 +r0008 diff --git a/tools/impl/test_config.py b/tools/impl/test_config.py index 84874cad2f..b85107db0c 100755 --- a/tools/impl/test_config.py +++ b/tools/impl/test_config.py @@ -12,6 +12,7 @@ class TestOption(enum.Enum): DO_NOT_BUILD_AARCH64 = "do_not_build_aarch64" DO_NOT_BUILD_ARMHF = "do_not_build_armhf" DO_NOT_BUILD_X86_64 = "do_not_build_x86_64" + DO_NOT_BUILD_WIN64 = "do_not_build_win64" # Build tests, but do not run for all, or just some platforms. DO_NOT_RUN = "do_not_run" @@ -32,119 +33,119 @@ class TestOption(enum.Enum): # This test needs longer than usual to run. LARGE = "large" - # 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. -if os.name == "posix": - CRATE_OPTIONS: dict[str, list[TestOption]] = { - "base": [TestOption.SINGLE_THREADED, TestOption.LARGE], - "cros_async": [TestOption.LARGE], - "crosvm_plugin": [TestOption.DO_NOT_BUILD_AARCH64, TestOption.DO_NOT_BUILD_ARMHF], - "crosvm": [TestOption.SINGLE_THREADED], - "devices": [ - TestOption.SINGLE_THREADED, - TestOption.LARGE, - TestOption.DO_NOT_RUN_ON_FOREIGN_KERNEL, - ], - "disk": [TestOption.DO_NOT_RUN_AARCH64, TestOption.DO_NOT_RUN_ARMHF], # b/202294155 - "crosvm-fuzz": [TestOption.DO_NOT_BUILD], # b/194499769 - "fuzz": [TestOption.DO_NOT_BUILD], - "hypervisor": [ - TestOption.DO_NOT_RUN_AARCH64, - TestOption.DO_NOT_RUN_ON_FOREIGN_KERNEL, - ], # b/181672912 - "integration_tests": [ # b/180196508 - TestOption.SINGLE_THREADED, - TestOption.LARGE, - TestOption.DO_NOT_RUN_AARCH64, - TestOption.DO_NOT_RUN_ON_FOREIGN_KERNEL, - ], - "io_uring": [TestOption.DO_NOT_RUN], # b/202294403 - "kvm_sys": [TestOption.DO_NOT_RUN_ON_FOREIGN_KERNEL], - "kvm": [ - TestOption.DO_NOT_RUN_AARCH64, - TestOption.DO_NOT_RUN_ON_FOREIGN_KERNEL, - ], # b/181674144 - "libvda": [TestOption.DO_NOT_BUILD], # b/202293971 - "sys_util": [TestOption.SINGLE_THREADED], - "sys_util_core": [TestOption.SINGLE_THREADED], - "rutabaga_gfx": [TestOption.DO_NOT_BUILD_ARMHF], # b/210015864 - "vhost": [TestOption.DO_NOT_RUN_ON_FOREIGN_KERNEL], - "vm_control": [TestOption.DO_NOT_BUILD_ARMHF], # b/210015864 - "libcrosvm_control": [TestOption.DO_NOT_BUILD_ARMHF], # b/210015864 - } - BUILD_FEATURES: dict[str, str] = { - "x86_64": "linux-x86_64", - "aarch64": "linux-aarch64", - "armhf": "linux-armhf", - } -elif os.name == "nt": - CRATE_OPTIONS: dict[str, list[TestOption]] = { - "aarch64": [TestOption.DO_NOT_BUILD], - "acpi_tables": [TestOption.DO_NOT_BUILD], - "arch": [TestOption.DO_NOT_BUILD], - "audio_streams": [TestOption.DO_NOT_BUILD], - "balloon_control": [], - "base": [TestOption.SINGLE_THREADED, TestOption.LARGE], - "bit_field_derive": [TestOption.DO_NOT_BUILD], - "bit_field": [TestOption.DO_NOT_BUILD], - "cros_async": [TestOption.DO_NOT_BUILD], - "cros_asyncv2": [TestOption.DO_NOT_BUILD], - "cros-fuzz": [TestOption.DO_NOT_BUILD], - "crosvm_control": [TestOption.DO_NOT_BUILD], - "crosvm_plugin": [TestOption.DO_NOT_BUILD], - "crosvm-fuzz": [TestOption.DO_NOT_BUILD], - "crosvm": [TestOption.DO_NOT_BUILD], - "devices": [TestOption.DO_NOT_BUILD], - "disk": [TestOption.DO_NOT_BUILD], - "ffi": [TestOption.DO_NOT_BUILD], - "fuse": [TestOption.DO_NOT_BUILD], - "fuzz": [TestOption.DO_NOT_BUILD], - "gpu_display": [TestOption.DO_NOT_BUILD], - "hypervisor": [TestOption.DO_NOT_BUILD], - "integration_tests": [TestOption.DO_NOT_BUILD], - "io_uring": [TestOption.DO_NOT_BUILD], - "kernel_cmdline": [TestOption.DO_NOT_BUILD], - "kernel_loader": [TestOption.DO_NOT_BUILD], - "kvm_sys": [TestOption.DO_NOT_BUILD], - "kvm": [TestOption.DO_NOT_BUILD], - "libcras_stub": [TestOption.DO_NOT_BUILD], - "libvda": [TestOption.DO_NOT_BUILD], - "linux_input_sys": [TestOption.DO_NOT_BUILD], - "minijail-sys": [TestOption.DO_NOT_BUILD], - "minijail": [TestOption.DO_NOT_BUILD], - "net_sys": [TestOption.DO_NOT_BUILD], - "net_util": [TestOption.DO_NOT_BUILD], - "p9": [TestOption.DO_NOT_BUILD], - "poll_token_derive": [], - "power_monitor": [TestOption.DO_NOT_BUILD], - "protos": [TestOption.DO_NOT_BUILD], - "qcow_utils": [TestOption.DO_NOT_BUILD], - "resources": [TestOption.DO_NOT_BUILD], - "rutabaga_gfx": [TestOption.DO_NOT_BUILD], - "rutabaga_gralloc": [TestOption.DO_NOT_BUILD], - "sync": [TestOption.DO_NOT_BUILD], - "sys_util": [TestOption.DO_NOT_BUILD], - "sys_util_core": [], - "system_api_stub": [TestOption.DO_NOT_BUILD], - "tpm2-sys": [TestOption.DO_NOT_BUILD], - "tpm2": [TestOption.DO_NOT_BUILD], - "usb_sys": [TestOption.DO_NOT_BUILD], - "usb_util": [TestOption.DO_NOT_BUILD], - "vfio_sys": [TestOption.DO_NOT_BUILD], - "vhost": [TestOption.DO_NOT_BUILD], - "virtio_sys": [TestOption.DO_NOT_BUILD], - "vm_control": [TestOption.DO_NOT_BUILD], - "vm_memory": [TestOption.DO_NOT_BUILD], - "wire_format_derive": [TestOption.DO_NOT_BUILD], - "x86_64": [TestOption.DO_NOT_BUILD], - } +# This is just too big to keep in main list for now +WIN64_DISABLED_CRATES = [ + "aarch64", + "acpi_tables", + "arch", + "assertions", + "audio_streams", + "bit_field_derive", + "bit_field", + "cros_async", + "cros_asyncv2", + "cros-fuzz", + "crosvm_control", + "crosvm_plugin", + "crosvm-fuzz", + "crosvm", + "data_model", + "devices", + "disk", + "ffi", + "fuse", + "fuzz", + "gpu_display", + "hypervisor", + "integration_tests", + "io_uring", + "kernel_cmdline", + "kernel_loader", + "kvm_sys", + "kvm", + "libcras_stub", + "libvda", + "linux_input_sys", + "minijail-sys", + "minijail", + "net_sys", + "net_util", + "p9", + "power_monitor", + "protos", + "qcow_utils", + "resources", + "rutabaga_gfx", + "rutabaga_gralloc", + "sync", + "sys_util", + "system_api_stub", + "tpm2-sys", + "tpm2", + "usb_sys", + "usb_util", + "vfio_sys", + "vhost", + "virtio_sys", + "vm_control", + "vm_memory", + "vmm_vhost", + "wire_format_derive", + "x86_64", + ] - BUILD_FEATURES: dict[str, str] = { - "x86_64": "", - } -else: - raise Exception(f"Unsupported build target: {os.name}") +CRATE_OPTIONS: dict[str, list[TestOption]] = { + "base": [TestOption.SINGLE_THREADED, TestOption.LARGE], + "cros_async": [TestOption.LARGE], + "crosvm": [TestOption.SINGLE_THREADED], + "crosvm_plugin": [ + TestOption.DO_NOT_BUILD_AARCH64, + TestOption.DO_NOT_BUILD_ARMHF, + ], + "crosvm-fuzz": [TestOption.DO_NOT_BUILD], # b/194499769 + "devices": [ + TestOption.SINGLE_THREADED, + TestOption.LARGE, + TestOption.DO_NOT_RUN_ON_FOREIGN_KERNEL, + ], + "disk": [TestOption.DO_NOT_RUN_AARCH64, TestOption.DO_NOT_RUN_ARMHF], # b/202294155 + "fuzz": [TestOption.DO_NOT_BUILD], + "hypervisor": [ + TestOption.DO_NOT_RUN_AARCH64, + TestOption.DO_NOT_RUN_ON_FOREIGN_KERNEL, + ], # b/181672912 + "integration_tests": [ # b/180196508 + TestOption.SINGLE_THREADED, + TestOption.LARGE, + TestOption.DO_NOT_RUN_AARCH64, + TestOption.DO_NOT_RUN_ON_FOREIGN_KERNEL, + ], + "io_uring": [TestOption.DO_NOT_RUN], # b/202294403 + "kvm_sys": [TestOption.DO_NOT_RUN_ON_FOREIGN_KERNEL], + "kvm": [ + TestOption.DO_NOT_RUN_AARCH64, + TestOption.DO_NOT_RUN_ON_FOREIGN_KERNEL, + ], # b/181674144 + "libcrosvm_control": [TestOption.DO_NOT_BUILD_ARMHF], # b/210015864 + "libvda": [TestOption.DO_NOT_BUILD], # b/202293971 + "rutabaga_gfx": [TestOption.DO_NOT_BUILD_ARMHF], # b/210015864 + "sys_util": [TestOption.SINGLE_THREADED], + "sys_util_core": [TestOption.SINGLE_THREADED], + "vhost": [TestOption.DO_NOT_RUN_ON_FOREIGN_KERNEL], + "vm_control": [TestOption.DO_NOT_BUILD_ARMHF], # b/210015864 +} + +for name in WIN64_DISABLED_CRATES: + CRATE_OPTIONS[name] = CRATE_OPTIONS.get(name, []) + [TestOption.DO_NOT_BUILD_WIN64] + +BUILD_FEATURES: dict[str, str] = { + "x86_64": "linux-x86_64", + "aarch64": "linux-aarch64", + "armhf": "linux-armhf", + "win64": "win64", +} diff --git a/tools/impl/test_runner.py b/tools/impl/test_runner.py index 8a5831d9be..6cadf54ee2 100644 --- a/tools/impl/test_runner.py +++ b/tools/impl/test_runner.py @@ -110,6 +110,8 @@ def get_workspace_excludes(target_arch: Arch): yield crate elif TestOption.DO_NOT_BUILD_ARMHF in options and target_arch == "armhf": yield crate + elif TestOption.DO_NOT_BUILD_WIN64 in options and target_arch == "win64": + yield crate def should_run_executable(executable: Executable, target_arch: Arch): @@ -282,6 +284,13 @@ def execute_test(target: TestTarget, executable: Executable): if TestOption.SINGLE_THREADED in options: args += ["--test-threads=1"] + binary_path = executable.binary_path + + if executable.arch == "win64" and executable.kind != "proc-macro" and os.name != "nt": + args.insert(0, binary_path) + binary_path = "wine64" + + # proc-macros and their tests are executed on the host. if executable.kind == "proc-macro": target = TestTarget("host") @@ -292,7 +301,7 @@ def execute_test(target: TestTarget, executable: Executable): # Pipe stdout/err to be printed in the main process if needed. test_process = test_target.exec_file_on_target( target, - executable.binary_path, + binary_path, args=args, timeout=get_test_timeout(target, executable), stdout=subprocess.PIPE, diff --git a/tools/impl/test_target.py b/tools/impl/test_target.py index f01d86723f..e6098c1765 100755 --- a/tools/impl/test_target.py +++ b/tools/impl/test_target.py @@ -44,7 +44,7 @@ TESTVM_DIR = SCRIPT_DIR.parent.joinpath("testvm") TARGET_DIR = testvm.cargo_target_dir().joinpath("crosvm_tools") ENVRC_PATH = SCRIPT_DIR.parent.parent.joinpath(".envrc") -Arch = Literal["x86_64", "aarch64", "armhf"] +Arch = Literal["x86_64", "aarch64", "armhf", "win64"] # Enviroment variables needed for building with cargo BUILD_ENV = { @@ -182,10 +182,15 @@ def get_cargo_build_target(arch: Arch): if os.name == "posix": if arch == "armhf": return "armv7-unknown-linux-gnueabihf" + elif arch == "win64": + return "x86_64-pc-windows-gnu" else: return f"{arch}-unknown-linux-gnu" elif os.name == "nt": - return f"{arch}-pc-windows-msvc" + if arch == "win64": + return f"x86_64-pc-windows-msvc" + else: + return f"{arch}-pc-windows-msvc" else: raise Exception(f"Unsupported build target: {os.name}") diff --git a/tools/install-aarch64-deps b/tools/install-aarch64-deps index a97eee6bcf..7627482c94 100755 --- a/tools/install-aarch64-deps +++ b/tools/install-aarch64-deps @@ -5,7 +5,6 @@ set -ex sudo apt-get install --yes --no-install-recommends \ - g++-aarch64-linux-gnu \ gcc-aarch64-linux-gnu \ ipxe-qemu \ libc-dev:arm64 \ diff --git a/tools/install-armhf-deps b/tools/install-armhf-deps index 4758a5a15e..250fab1d92 100755 --- a/tools/install-armhf-deps +++ b/tools/install-armhf-deps @@ -5,7 +5,6 @@ set -ex sudo apt-get install --yes --no-install-recommends \ - g++-arm-linux-gnueabihf \ gcc-arm-linux-gnueabihf \ libc-dev:armhf \ libcap-dev:armhf \ diff --git a/tools/install-deps b/tools/install-deps index 5045e7497d..23aa211a2a 100755 --- a/tools/install-deps +++ b/tools/install-deps @@ -7,12 +7,10 @@ set -ex sudo apt-get update sudo apt-get install --yes --no-install-recommends \ ca-certificates \ - clang \ cloud-image-utils \ curl \ dpkg-dev \ expect \ - g++ \ gcc \ git \ jq \ @@ -37,6 +35,8 @@ sudo apt-get install --yes --no-install-recommends \ qemu-system-x86 \ rsync \ screen \ + wine64 \ + gcc-mingw-w64-x86-64-win32 \ wayland-protocols # Install meson for rutabaga_gfx @@ -51,6 +51,8 @@ pip3 install argh rustup component add clippy rustup component add rustfmt +rustup target add x86_64-pc-windows-gnu + # The bindgen tool is required to build a crosvm dependency. cargo install bindgen diff --git a/tools/presubmit b/tools/presubmit index 458d656282..91ab4a4db9 100755 --- a/tools/presubmit +++ b/tools/presubmit @@ -100,12 +100,14 @@ if [ "$ALL" == true ]; then commands+=( "$(aarch64_wrapper) ./tools/run_tests --target=vm:aarch64" "$(aarch64_wrapper) ./tools/run_tests --target=vm:aarch64 --arch=armhf" + "./tools/run_tests --target=host --arch=win64 --build-only" "cargo build --verbose --no-default-features" ) elif [ "$QUICK" != true ]; then commands+=( # Test via user-space emulation for faster, but less complete results. "$(aarch64_wrapper) ./tools/run_tests --target=host --arch=aarch64" + "./tools/run_tests --target=host --arch=win64 --build-only" ) fi