-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
157 additions
and
4 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,109 @@ | ||
#!/bin/bash | ||
|
||
set -e -x | ||
|
||
function install_debuild_dependencies() { | ||
echo "Installing debuild dependencies" | ||
sudo apt-get update | ||
sudo DEBIAN_FRONTEND=noninteractive apt-get -y \ | ||
-o Dpkg::Options::="--force-confold" \ | ||
-o Dpkg::Options::="--force-confdef" \ | ||
upgrade | ||
sudo apt-get install -y devscripts config-package-dev debhelper-compat equivs | ||
} | ||
|
||
function install_bazel() { | ||
# From https://bazel.build/install/ubuntu | ||
echo "Installing bazel" | ||
sudo apt install apt-transport-https curl gnupg -y | ||
curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor >bazel-archive-keyring.gpg | ||
sudo mv bazel-archive-keyring.gpg /usr/share/keyrings | ||
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/bazel-archive-keyring.gpg] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list | ||
# bazel needs the zip command to gather test outputs but doesn't depend on it | ||
sudo apt-get update && sudo apt-get install -y bazel zip unzip | ||
} | ||
|
||
function build_and_install_pkgs() { | ||
local pkgdir="$1" | ||
shift | ||
pushd "${pkgdir}" | ||
echo "Installing dependencies for: $@" | ||
sudo mk-build-deps -i -t 'apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y' | ||
echo "Building packages: $@" | ||
debuild -i -uc -us -b | ||
for pkg in "$@"; do | ||
echo "Installing package: ${pkg}" | ||
sudo apt-get install -y ../"${pkg}"_*_*64.deb | ||
done | ||
popd | ||
} | ||
|
||
function check_service_started() { | ||
local service="$1" | ||
echo "Checking service ${service} status" | ||
systemctl is-active "${service}" | ||
} | ||
|
||
function load_kernel_modules() { | ||
echo "Loading kernel modules" | ||
sudo modprobe "$@" | ||
} | ||
|
||
function grant_device_access() { | ||
for d in "$@"; do | ||
ls -l /dev/"${d}" | ||
sudo chmod a+rw /dev/"${d}" | ||
done | ||
} | ||
|
||
function create_test_user() { | ||
local username=$1 | ||
local groups="kvm,cvdnetwork" | ||
if [[ "$2" != "" ]]; then | ||
groups="${groups},$2" | ||
fi | ||
echo "Creating user: ${username}" | ||
sudo useradd -G "${groups}" -m "${username}" | ||
sudo chmod a+rx "/home/${username}" | ||
} | ||
|
||
|
||
REPO_DIR="$(realpath "$(dirname "$0")/..")" | ||
TEST_USER="" | ||
EXTRA_GROUPS="" | ||
while getopts "d:u:g:" opt; do | ||
case "${opt}" in | ||
u) | ||
TEST_USER="${OPTARG}" | ||
;; | ||
g) | ||
EXTRA_GROUPS="${OPTARG}" | ||
;; | ||
*) | ||
echo "Invalid option: -${opt}" | ||
echo "Usage: $0 [-u TEST_USER [-g EXTRA_GROUPS]]" | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
if [[ "${REPO_DIR}" == "" ]] || ! [[ -d "${REPO_DIR}" ]]; then | ||
echo "Invalid repo directory: ${REPO_DIR}" | ||
exit 1 | ||
fi | ||
|
||
install_debuild_dependencies | ||
|
||
install_bazel | ||
|
||
build_and_install_pkgs "${REPO_DIR}/base" cuttlefish-base | ||
check_service_started cuttlefish-host-resources | ||
load_kernel_modules kvm vhost-vsock vhost-net | ||
grant_device_access vhost-vsock vhost-net kvm | ||
|
||
build_and_install_pkgs "${REPO_DIR}/frontend" cuttlefish-user | ||
check_service_started cuttlefish-operator | ||
|
||
if [[ "${TEST_USER}" != "" ]]; then | ||
create_test_user "${TEST_USER}" "${EXTRA_GROUPS}" | ||
fi |
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 |
---|---|---|
@@ -1,8 +1,10 @@ | ||
build_file: "android-cuttlefish/.kokoro/public_test.sh" | ||
build_file: "android-cuttlefish/.kokoro/presubmit.sh" | ||
|
||
action { | ||
define_artifacts { | ||
regex: "**/*sponge_log.xml" # Actually a glob, not a regex | ||
regex: "**/*sponge_log.log" | ||
regex: "*/*sponge_log.xml" # Actually a glob, not a regex | ||
regex: "*/*sponge_log.log" | ||
regex: "*/device_logs/*" | ||
regex: "github/android-cuttlefish/*.deb" | ||
} | ||
} |
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,11 @@ | ||
#!/bin/bash | ||
|
||
set -e -x | ||
|
||
TOOL_DIR="$(realpath "$(dirname "$0")")" | ||
|
||
# Add test user to the kokoro group so it has access to the source dir | ||
"${TOOL_DIR}/prepare_host.sh" -u testrunner -g kokoro | ||
|
||
# Run as different user without sudo privileges | ||
sudo -u testrunner "${TOOL_DIR}/runtests.sh" ... |
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
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,31 @@ | ||
#!/bin/bash | ||
|
||
set -x -e | ||
|
||
REPO_DIR="$(realpath "$(dirname "$0")/..")" | ||
OUTPUT_DIR="$(pwd)" | ||
|
||
function gather_test_results() { | ||
# Don't immediately exit on error anymore | ||
set +e | ||
for d in ./bazel-testlogs/*; do | ||
dir="${OUTPUT_DIR}/$(basename "$d")" | ||
mkdir -p "${dir}" | ||
cp "${d}/test.log" "${dir}/sponge_log.log" | ||
cp "${d}/test.xml" "${dir}/sponge_log.xml" | ||
if [[ -f "${d}/test.outputs/outputs.zip" ]]; then | ||
mkdir -p "${dir}" | ||
unzip "${d}/test.outputs/outputs.zip" -d "${dir}/device_logs" | ||
fi | ||
# Make sure everyone has access to the output files | ||
chmod -R a+rw "${dir}" | ||
done | ||
} | ||
|
||
cd "${REPO_DIR}/e2etests" | ||
|
||
# Gather test results regardless of status, but still return the exit code from | ||
# those tests | ||
trap gather_test_results EXIT | ||
bazel test "$@" | ||
|