mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-09 03:57:24 +00:00
Changes how unit tests are executed. Instead of running all tests on a selected target (i.e. host or a VM), we will select a platform to test and run_tests will use a separate target for unit tests than for integration tests. e.g. instead of running all tests in the aarch64 vm: ./tools/run_tests --target=vm:aarch64 We can now run ./tools/run_tests --platform=aarch64 to run unit tests via user-space emulation on the host, and only integration tests on the VM. This will eventually apply to x86 testing as well, so tests can be run in an unprivileged environment (e.g. podman). A new TestOption has been added to mark unit tests that have system interactions that require them to be run like integration tests in a VM. These should be fixed. You can also use --unit-tests and --integration-tests to run just one type of tests. Running unit tests only takes a few seconds on most platforms since we can use user-space emulation. BUG=b:247139912 TEST=./tools/run_tests ./tools/run_tests -p aarch64 ./tools/run_tests -p mingw64 ./tools/run_tests -p armhf Change-Id: Icd0c502623f1889906d199e752b3eccb7de76dc0 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3902688 Reviewed-by: Zihan Chen <zihanchen@google.com> Commit-Queue: Dennis Kempin <denniskempin@google.com>
122 lines
2.8 KiB
Bash
Executable file
122 lines
2.8 KiB
Bash
Executable file
#!/bin/bash
|
|
# Copyright 2021 The ChromiumOS Authors
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
# found in the LICENSE file.
|
|
set -e
|
|
|
|
cd "$(dirname $0)/.."
|
|
|
|
HELP="This will run presubmit checks for crosvm.
|
|
|
|
To run all checks just run
|
|
|
|
$ ./tools/presubmit
|
|
|
|
The checks can be run in parallel for faster execution:
|
|
|
|
$ ./tools/presubmit --tmux
|
|
|
|
This will open a tmux session to run all presubmit builds in parallel. It will
|
|
create a nested tmux session if you are already using it.
|
|
|
|
All tests are executed in the local development environment. If your host is not
|
|
set up for aarch64 builds, it will use './tools/dev_container' to build run
|
|
those.
|
|
|
|
There are three levels of presubmit tests that can be run:
|
|
|
|
$ ./tools/presubmit --quick
|
|
$ ./tools/presubmit
|
|
$ ./tools/presubmit --all
|
|
|
|
The quick mode will only cover x86 and does not require a dev_container. The
|
|
default mode will add aarch64 tests, and the all mode will test everything that
|
|
is also tested on Kokoro.
|
|
"
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
case "$1" in
|
|
-q | --quick)
|
|
QUICK=true
|
|
shift
|
|
;;
|
|
-a | --all)
|
|
ALL=true
|
|
shift
|
|
;;
|
|
--tmux)
|
|
RUN_IN_TMUX=true
|
|
shift
|
|
;;
|
|
-h | --help)
|
|
echo "$HELP"
|
|
exit 0
|
|
shift
|
|
;;
|
|
*)
|
|
echo "unknown argument $1"
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
run_commands_in_tmux() {
|
|
local tmux_commands=(
|
|
set-option -g default-shell /bin/bash \;
|
|
new-session "$1; read -p 'Press enter to close.'" \;
|
|
)
|
|
for cmd in "${@:2}"; do
|
|
tmux_commands+=(
|
|
split-window -h "$cmd; read -p 'Press enter to close.'" \;
|
|
)
|
|
done
|
|
tmux_commands+=(
|
|
select-layout even-horizontal \;
|
|
)
|
|
TMUX="" tmux "${tmux_commands[@]}"
|
|
}
|
|
|
|
run_commands() {
|
|
for cmd in "$@"; do
|
|
echo "$ ${cmd}"
|
|
bash -c "$cmd"
|
|
echo
|
|
done
|
|
}
|
|
|
|
aarch64_wrapper() {
|
|
if ! (rustup target list --installed | grep -q aarch64 &&
|
|
dpkg --print-foreign-architectures | grep -q arm64); then
|
|
echo "./tools/dev_container"
|
|
fi
|
|
}
|
|
|
|
commands=(
|
|
"./tools/health-check"
|
|
)
|
|
|
|
if [ "$ALL" == true ]; then
|
|
commands+=(
|
|
"./tools/run_tests"
|
|
"./tools/run_tests --target=mingw64"
|
|
"$(aarch64_wrapper) ./tools/run_tests --platform=aarch64"
|
|
"$(aarch64_wrapper) ./tools/run_tests --platform=armhf"
|
|
"cargo build --verbose --no-default-features"
|
|
)
|
|
elif [ "$QUICK" != true ]; then
|
|
commands+=(
|
|
"./tools/run_tests"
|
|
"$(aarch64_wrapper) ./tools/run_tests --platform=aarch64 --unit-tests"
|
|
"./tools/run_tests --target=mingw64 --unit-tests"
|
|
)
|
|
else
|
|
commands+=(
|
|
"./tools/run_tests --unit-tests"
|
|
)
|
|
fi
|
|
|
|
if [ "$RUN_IN_TMUX" = true ]; then
|
|
run_commands_in_tmux "${commands[@]}"
|
|
else
|
|
run_commands "${commands[@]}"
|
|
fi
|