2021-10-15 01:56:44 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# Copyright 2021 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.
|
|
|
|
set -e
|
|
|
|
|
|
|
|
cd "$(dirname $0)/.."
|
|
|
|
|
2021-11-18 23:15:15 +00:00
|
|
|
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.
|
2021-10-15 01:56:44 +00:00
|
|
|
|
2021-11-18 23:15:15 +00:00
|
|
|
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.
|
2021-10-15 01:56:44 +00:00
|
|
|
|
2022-02-08 23:20:53 +00:00
|
|
|
There are three levels of presubmit tests that can be run:
|
2021-10-15 01:56:44 +00:00
|
|
|
|
2021-11-18 23:15:15 +00:00
|
|
|
$ ./tools/presubmit --quick
|
2022-02-08 23:20:53 +00:00
|
|
|
$ ./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.
|
2021-11-18 23:15:15 +00:00
|
|
|
"
|
2021-10-15 01:56:44 +00:00
|
|
|
|
2021-11-18 23:15:15 +00:00
|
|
|
while [[ $# -gt 0 ]]; do
|
|
|
|
case "$1" in
|
|
|
|
-q | --quick)
|
|
|
|
QUICK=true
|
|
|
|
shift
|
|
|
|
;;
|
2022-02-08 23:20:53 +00:00
|
|
|
-a | --all)
|
|
|
|
ALL=true
|
|
|
|
shift
|
|
|
|
;;
|
2021-11-18 23:15:15 +00:00
|
|
|
--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+=(
|
2022-02-08 23:20:53 +00:00
|
|
|
split-window -h "$cmd; read -p 'Press enter to close.'" \;
|
2021-11-18 23:15:15 +00:00
|
|
|
)
|
|
|
|
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=(
|
2022-03-22 20:04:31 +00:00
|
|
|
"./tools/health-check"
|
2021-11-18 23:15:15 +00:00
|
|
|
"./tools/run_tests --target=host"
|
|
|
|
)
|
|
|
|
|
2022-02-08 23:20:53 +00:00
|
|
|
if [ "$ALL" == true ]; then
|
2021-11-18 23:15:15 +00:00
|
|
|
commands+=(
|
|
|
|
"$(aarch64_wrapper) ./tools/run_tests --target=vm:aarch64"
|
2022-06-30 00:56:04 +00:00
|
|
|
"$(aarch64_wrapper) ./tools/run_tests --target=vm:aarch64 --build-target=armhf"
|
|
|
|
"./tools/run_tests --target=host --build-target=mingw64 --build-only"
|
2022-02-08 23:20:53 +00:00
|
|
|
"cargo build --verbose --no-default-features"
|
|
|
|
)
|
|
|
|
elif [ "$QUICK" != true ]; then
|
|
|
|
commands+=(
|
|
|
|
# Test via user-space emulation for faster, but less complete results.
|
2022-06-30 00:56:04 +00:00
|
|
|
"$(aarch64_wrapper) ./tools/run_tests --target=host --build-target=aarch64"
|
|
|
|
"./tools/run_tests --target=host --build-target=mingw64 --build-only"
|
2021-11-18 23:15:15 +00:00
|
|
|
)
|
2021-10-15 01:56:44 +00:00
|
|
|
fi
|
|
|
|
|
2021-11-18 23:15:15 +00:00
|
|
|
if [ "$RUN_IN_TMUX" = true ]; then
|
|
|
|
run_commands_in_tmux "${commands[@]}"
|
|
|
|
else
|
|
|
|
run_commands "${commands[@]}"
|
|
|
|
fi
|