| #!/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. |
| |
| # cos/run_vmtests.sh --board=[anthos-amd64-vsphere] |
| # |
| # This script builds and runs VMTests for a given board. |
| |
| SCRIPT_ROOT=$(dirname $(readlink -f "$0")) |
| SCRIPT_ROOT=${SCRIPT_ROOT%cos} |
| . "${SCRIPT_ROOT}/build_library/build_common.sh" || exit 1 |
| |
| # Script must be run inside the chroot. |
| restart_in_chroot_if_needed "$@" |
| |
| DEFINE_string board "${DEFAULT_BOARD}" \ |
| "The board to build an image for." |
| DEFINE_string image_type "test" \ |
| "Image type to process, base, test or dev." |
| DEFINE_string image_dir "" "Path to the folder to store netboot images." |
| |
| # Parse command line. |
| FLAGS "$@" || exit 1 |
| eval set -- "${FLAGS_ARGV}" |
| |
| . "${SCRIPT_ROOT}/build_library/build_common.sh" || exit 1 |
| . "${BUILD_LIBRARY_DIR}/board_options.sh" || exit 1 |
| |
| switch_to_strict_mode |
| |
| set -x |
| # build_packages artifact output. |
| SYSROOT="${GCLIENT_ROOT}/chroot/build/${FLAGS_board}" |
| # build_image artifact output. |
| |
| IMAGE_DIR="${CHROOT_TRUNK_DIR}"/src/build/images/"${FLAGS_board}"/latest |
| if [ -n "${FLAGS_image_dir}" ]; then |
| IMAGE_DIR=${FLAGS_image_dir} |
| fi |
| |
| BOARD_ARCH=$(portageq-${FLAGS_board} envvar ARCH) |
| if [[ ${BOARD_ARCH} == "amd64" ]]; then |
| BOARD_ARCH="x86_64" |
| elif [[ ${BOARD_ARCH} == "arm64" ]]; then |
| BOARD_ARCH="aarch64" |
| else |
| echo "Unsupported ${BOARD_ARCH}" |
| exit 1 |
| fi |
| |
| cros_run_vm_test --board ${BOARD} \ |
| --image-path ${IMAGE_DIR}/chromiumos_${FLAGS_image_type}_image.bin \ |
| --private-key ${IMAGE_DIR}/id_rsa \ |
| --test_that-args=--model=ad_hoc_model \ |
| --copy-on-write \ |
| --start-vm \ |
| --qemu-arch ${BOARD_ARCH} \ |
| --autotest 'suite:smoke' |