-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scafolding for cuttlefish e2e testing with bazel
includes testing aosp-main phone x86_64
- Loading branch information
Showing
4 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
load("boot_tests.bzl", "launch_cvd_boot_test") | ||
|
||
launch_cvd_boot_test( | ||
name="aosp_main_x64_phone", | ||
branch="aosp-main", | ||
target="aosp_cf_x86_64_phone-trunk_staging-userdebug" | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
############################################################################### | ||
# Bazel now uses Bzlmod by default to manage external dependencies. | ||
# Please consider migrating your external dependencies from WORKSPACE to MODULE.bazel. | ||
# | ||
# For more details, please check https://github.com/bazelbuild/bazel/issues/18958 | ||
############################################################################### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
def launch_cvd_boot_test(name, branch, target): | ||
native.sh_test( | ||
name = name, | ||
size = "medium", | ||
srcs = ["launch_cvd_boot_test.sh"], | ||
args = ["-b", branch, "-t", target], | ||
tags = [ | ||
"exclusive", | ||
"external", | ||
"no-sandbox", | ||
], | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/bin/bash | ||
|
||
set -e -x | ||
|
||
BRANCH="" | ||
TARGET="" | ||
|
||
while getopts "b:t:" opt; do | ||
case "${opt}" in | ||
b) | ||
BRANCH="${OPTARG}" | ||
;; | ||
t) | ||
TARGET="${OPTARG}" | ||
;; | ||
*) | ||
echo "Unknown flag: -${opt}" >&2 | ||
echo "Usage: $0 -b BRANCH -t TARGET" | ||
exit 1 | ||
esac | ||
done | ||
|
||
if [[ "${BRANCH}" == "" ]]; then | ||
echo "Missing required -b argument" | ||
fi | ||
|
||
if [[ "${TARGET}" == "" ]]; then | ||
echo "Missing required -t argument" | ||
fi | ||
|
||
workdir="$(mktemp -d -t cvd_boot_test.XXXXXX)" | ||
|
||
function collect_logs_and_cleanup() { | ||
# Don't immediately exit on failure anymore | ||
set +e | ||
if [[ -n "${TEST_UNDECLARED_OUTPUTS_DIR}" ]] && [[ -d "${TEST_UNDECLARED_OUTPUTS_DIR}" ]]; then | ||
cp "${workdir}"/*.log "${TEST_UNDECLARED_OUTPUTS_DIR}" | ||
cp "${workdir}"/cuttlefish_runtime/*.log "${TEST_UNDECLARED_OUTPUTS_DIR}" | ||
cp "${workdir}"/cuttlefish_runtime/logcat "${TEST_UNDECLARED_OUTPUTS_DIR}" | ||
cp "${workdir}"/cuttlefish_runtime/cuttlefish_config.json "${TEST_UNDECLARED_OUTPUTS_DIR}" | ||
fi | ||
rm -rf "${workdir}" | ||
# Be nice, dont' leave a server or devices behind. | ||
cvd reset -y | ||
} | ||
|
||
# Regardless of whether and when a failure occurs logs must collected | ||
trap collect_logs_and_cleanup EXIT | ||
|
||
# Make sure the server isn't running. Bazel tries to sandbox tests, but the cvd | ||
# client can still connect to the server outside the sandbox and cause issues. | ||
cvd reset -y | ||
|
||
cvd fetch --default_build="${BRANCH}/${TARGET}" --target_directory="${workdir}" | ||
|
||
( | ||
cd "${workdir}" | ||
HOME=$(pwd) bin/launch_cvd --daemon --report_anonymous_usage_stats=y | ||
HOME=$(pwd) bin/stop_cvd | ||
) |