crosvm/integration_tests/guest_under_test/upload_prebuilts.sh
Dennis Kempin 0797a55462 Framework for extended integration tests
This CL expands the existing boot.rs test to not just boot a kernel
but also provide a debian-based rootfs and a special init binary
that is used to communicate between test code and the guest VM.

The delegate binary listens for commands on /dev/ttyS1 and returns
the stdout of the executed command.
This allows the test code to setup pipes for the serial device to
issue commands in the client and receive the command output, which
provides a good foundation for tests of basic functionality without
the need to pass test binary code into the guest.

The integration tests will pull a prebuilt kernel and rootfs image
from cloud storage unless local files are specified via ENV variables.

The integration_tests/guest_under_test directory contains the files
needed to build and upload those prebuilts.

BUG=b:172926609
TEST=This is a test.

Cq-Depend: chromium:2551073
Change-Id: Iffb88a146a13d1b6ed7250df1b487bd87a5599d0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2536831
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Dennis Kempin <denniskempin@google.com>
2021-01-20 17:48:10 +00:00

45 lines
1.4 KiB
Bash
Executable file

#!/bin/bash
# Copyright 2020 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.
# Builds and uploads prebuilts to cloud storage.
#
# Note: Only Googlers with access to the crosvm-testing cloud storage bin can
# upload prebuilts.
#
# See README.md for how to uprev the prebuilt version.
set -e
cd "${0%/*}"
readonly PREBUILT_VERSION="$(cat ./PREBUILT_VERSION)"
# Cloud storage files
readonly GS_BUCKET="gs://chromeos-localmirror/distfiles"
readonly GS_PREFIX="${GS_BUCKET}/crosvm-testing"
readonly REMOTE_BZIMAGE="${GS_PREFIX}-bzimage-$(arch)-${PREBUILT_VERSION}"
readonly REMOTE_ROOTFS="${GS_PREFIX}-rootfs-$(arch)-${PREBUILT_VERSION}"
# Local files
CARGO_TARGET=$(cargo metadata --no-deps --format-version 1 |
jq -r ".target_directory")
LOCAL_BZIMAGE=${CARGO_TARGET}/guest_under_test/bzImage
LOCAL_ROOTFS=${CARGO_TARGET}/guest_under_test/rootfs
function prebuilts_exist_error() {
echo "Prebuilts of version ${PREBUILT_VERSION} already exist. See README.md"
exit 1
}
echo "Checking if prebuilts already exist."
gsutil stat "${REMOTE_BZIMAGE}" && prebuilts_exist_error
gsutil stat "${REMOTE_ROOTFS}" && prebuilts_exist_error
echo "Building rootfs and kernel."
make "${LOCAL_BZIMAGE}" "${LOCAL_ROOTFS}"
echo "Uploading files."
gsutil cp -n -a public-read "${LOCAL_BZIMAGE}" "${REMOTE_BZIMAGE}"
gsutil cp -n -a public-read "${LOCAL_ROOTFS}" "${REMOTE_ROOTFS}"