summary refs log tree commit diff
path: root/kokoro
diff options
context:
space:
mode:
authorZach Reizner <zachr@google.com>2019-05-02 12:26:24 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-05-15 13:36:19 -0700
commit6868c0a72ffc556fcd9c48006b673f5774d0d35b (patch)
tree5dbf28cc77e65cc3a8acfa4b6bf165260fb7a167 /kokoro
parent050af40382a5619278fc08eef7dfbde5591abd76 (diff)
downloadcrosvm-6868c0a72ffc556fcd9c48006b673f5774d0d35b.tar
crosvm-6868c0a72ffc556fcd9c48006b673f5774d0d35b.tar.gz
crosvm-6868c0a72ffc556fcd9c48006b673f5774d0d35b.tar.bz2
crosvm-6868c0a72ffc556fcd9c48006b673f5774d0d35b.tar.lz
crosvm-6868c0a72ffc556fcd9c48006b673f5774d0d35b.tar.xz
crosvm-6868c0a72ffc556fcd9c48006b673f5774d0d35b.tar.zst
crosvm-6868c0a72ffc556fcd9c48006b673f5774d0d35b.zip
add docker supported builds and tests
BUG=None
TEST=docker/build_crosvm_base.sh
     docker/build_crosvm.sh
     docker/wrapped_smoke_test.sh
     docker/crosvm_wrapper.sh
     kokoro/kokoro_simulator.sh
     bin/smoke_test

Change-Id: I55a805ba6326c3c58973d1fe21172a5e3551c1e2
Reviewed-on: https://chromium-review.googlesource.com/1593723
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Diffstat (limited to 'kokoro')
-rw-r--r--kokoro/Dockerfile151
-rw-r--r--kokoro/README.md10
-rwxr-xr-xkokoro/build.sh8
-rwxr-xr-xkokoro/kokoro_simulator.sh2
-rw-r--r--kokoro/pkgconfig/libtpm2.pc5
5 files changed, 7 insertions, 169 deletions
diff --git a/kokoro/Dockerfile b/kokoro/Dockerfile
deleted file mode 100644
index b055181..0000000
--- a/kokoro/Dockerfile
+++ /dev/null
@@ -1,151 +0,0 @@
-# Copyright 2018 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.
-
-FROM debian:stretch
-LABEL description="Test crosvm using a command like the following: \
-docker run --privileged -v /dev/log:/dev/log -v <path to crosvm>:/platform/crosvm:ro <crosvm base image>"
-
-RUN apt-get update && apt-get install -y \
-    autoconf \
-    automake \
-    curl \
-    gcc \
-    g++ \
-    git \
-    libcap-dev \
-    libdbus-1-dev \
-    libdrm-dev \
-    libfdt-dev \
-    libegl1-mesa-dev \
-    libgl1-mesa-dev \
-    libgles1-mesa-dev \
-    libgles2-mesa-dev \
-    libssl1.0-dev \
-    libtool \
-    libusb-1.0-0-dev \
-    libwayland-dev \
-    make \
-    nasm \
-    ninja-build \
-    pkg-config \
-    protobuf-compiler \
-    python3
-
-ENV RUSTUP_HOME=/usr/local/rustup \
-    CARGO_HOME=/usr/local/cargo \
-    PATH=/usr/local/cargo/bin:$PATH \
-    RUST_VERSION=1.33.0 \
-    RUSTFLAGS='--cfg hermetic'
-
-# Debian usually has an old rust version in the repository. Instead of using that, we use rustup to
-# pull in a toolchain versions of our choosing.
-RUN curl -LO "https://static.rust-lang.org/rustup/archive/1.14.0/x86_64-unknown-linux-gnu/rustup-init" \
-    && echo "0077ff9c19f722e2be202698c037413099e1188c0c233c12a2297bf18e9ff6e7 *rustup-init" | sha256sum -c - \
-    && chmod +x rustup-init \
-    && ./rustup-init -y --no-modify-path --default-toolchain $RUST_VERSION \
-    && rustup component add rustfmt-preview \
-    && rm rustup-init \
-    && chmod -R a+w $RUSTUP_HOME $CARGO_HOME \
-    && rustup --version \
-    && cargo --version \
-    && rustc --version
-
-# Warms up the cargo registry cache for future cargo runs. Cargo will still update the cache using a
-# git pull, but it only needs to download files that were changed since this image was built.
-RUN cargo install thisiznotarealpackage -q || true
-
-# Used /scratch for building dependencies which are too new or don't exist on Debian stretch.
-WORKDIR /scratch
-
-# minijail does not exist in upstream linux distros.
-RUN git clone https://android.googlesource.com/platform/external/minijail \
-    && cd minijail \
-    && make -j24 \
-    && cp libminijail.so /usr/lib/x86_64-linux-gnu/
-
-# The gbm used by upstream linux distros is not compatible with crosvm, which must use Chrome OS's
-# minigbm.
-RUN dpkg --force-depends -r libgbm1
-RUN git clone https://chromium.googlesource.com/chromiumos/platform/minigbm \
-    && cd minigbm \
-    && sed 's/-Wall/-Wno-maybe-uninitialized/g' -i Makefile \
-    && make install -j24
-
-# New libepoxy requires newer meson than is in Debian stretch.
-RUN git clone https://github.com/mesonbuild/meson \
-    && cd meson \
-    && git checkout 0a5ff338012a00f32c3aa9d8773835accc3e4e5b \
-    && ln -s $PWD/meson.py /usr/bin/meson
-
-# New libepoxy has EGL_KHR_DEBUG entry points needed by crosvm.
-RUN git clone https://github.com/anholt/libepoxy.git \
-    && cd libepoxy \
-    && git checkout 707f50e680ab4f1861b1e54ca6e2907aaca56c12 \
-    && mkdir build \
-    && cd build \
-    && meson \
-    && ninja install
-
-# virglrenderer is under heavy development on master and we want the very latest.
-RUN git clone https://gitlab.freedesktop.org/virgl/virglrenderer.git \
-    && cd virglrenderer \
-    && ./autogen.sh \
-    && make install -j24
-
-# Install libtpm2 so that tpm2-sys/build.rs does not try to build it in place in
-# the read-only source directory.
-RUN git clone https://chromium.googlesource.com/chromiumos/third_party/tpm2 \
-    && cd tpm2 \
-    && git checkout 15260c8cd98eb10b4976d2161cd5cb9bc0c3adac \
-    && make -j24 \
-    && cp build/libtpm2.a /lib
-
-# Install librendernodehost
-RUN git clone https://chromium.googlesource.com/chromiumos/platform2 \
-    && cd platform2 \
-    && git checkout 226fc35730a430344a68c34d7fe7d613f758f417 \
-    && cd rendernodehost \
-    && gcc -c src.c -o src.o \
-    && ar rcs librendernodehost.a src.o \
-    && cp librendernodehost.a /lib
-
-# Set up sysroot from which system_api proto files are built.
-ENV SYSROOT=/sysroot
-RUN mkdir -p $SYSROOT/usr/include/chromeos/dbus/trunks \
-    && cp platform2/trunks/interface.proto \
-        $SYSROOT/usr/include/chromeos/dbus/trunks
-
-# Inform pkg-config where libraries we install are placed.
-COPY pkgconfig/* /usr/lib/pkgconfig
-
-# Reduces image size and prevents accidentally using /scratch files
-RUN rm -r /scratch /usr/bin/meson
-
-# The manual installation of shared objects requires an ld.so.cache refresh.
-RUN ldconfig
-
-# Pull down repositories that crosvm depends on to cros checkout-like locations.
-ENV CROS_ROOT=/
-ENV THIRD_PARTY_ROOT=$CROS_ROOT/third_party
-RUN mkdir -p $THIRD_PARTY_ROOT
-ENV PLATFORM_ROOT=$CROS_ROOT/platform
-RUN mkdir -p $PLATFORM_ROOT
-
-# Pull the cras library for audio access.
-RUN git clone https://chromium.googlesource.com/chromiumos/third_party/adhd $THIRD_PARTY_ROOT/adhd
-
-# The /build directory is used so that the bind mounted /platform/crosvm volume
-# does not get scribbled on.
-ENV CARGO_TARGET_DIR=/build
-RUN mkdir -p $CARGO_TARGET_DIR
-WORKDIR /platform/crosvm
-CMD rustup default "$(cat rust-toolchain)" && \
-    rustup component add rustfmt-preview && \
-    cargo --version && rustc --version && rustfmt --version && \
-    echo "Running cargo test" && \
-    cargo test --no-fail-fast --features plugin,default-no-sandbox,wl-dmabuf,gpu,tpm,gpu-forward \
-    --all --exclude aarch64 $TEST_FLAGS -- \
-    --test-threads=1 $TEST_RUNNER_FLAGS && \
-    echo "Running cargo fmt" && \
-    bin/fmt --check
diff --git a/kokoro/README.md b/kokoro/README.md
index 70cceb2..727b74a 100644
--- a/kokoro/README.md
+++ b/kokoro/README.md
@@ -3,7 +3,7 @@
 For presubmit testing, each change posted for Gerrit on the master branch of crosvm will be tried by
 Kokoro. The configuration is found in [`presubmit.cfg`](presubmit.cfg) and the build script is at
 [`build.sh`](build.sh). A Docker image called `crosvm-base` is used as the testing environment which
-is built with a [`Dockerfile`](Dockerfile).
+is built with a [`Dockerfile`](../docker/Dockerfile).
 
 [TOC]
 
@@ -12,17 +12,17 @@ is built with a [`Dockerfile`](Dockerfile).
 Assuming a Docker daemon is already running, build the `crosvm-base` image:
 
 ```shell
-docker build -t crosvm-base path/to/crosvm/kokoro
+path/to/crosvm/docker/build_crosvm_base.sh
 ```
 
 Here is how to use the image to test a crosvm repository located at `$CROSVM_SRC`:
 
 ```shell
-docker run --privileged -v /dev/log:/dev/log -v "${CROSVM_SRC}":/platform/crosvm:ro crosvm-base
+$CROSVM_SRC/docker/wrapped_smoke_test.sh
 ```
 
 > **WARNING**:
-> The `--privileged` is so that the container will have `/dev/kvm` access.
+> The `--privileged` flag is used in that script so that the container will have `/dev/kvm` access.
 
 ## How to update `crosvm-base`
 
@@ -32,7 +32,7 @@ If an update or new library is needed or any other adjustment is required, a new
 generated as follows:
 
 ```shell
-docker build -t crosvm-base path/to/crosvm/kokoro
+path/to/crosvm/docker/build_crosvm_base.sh
 docker save crosvm-base | xz -T 0 -z >crosvm-base.tar.xz
 ```
 
diff --git a/kokoro/build.sh b/kokoro/build.sh
index e78d9c7..96028ac 100755
--- a/kokoro/build.sh
+++ b/kokoro/build.sh
@@ -18,13 +18,7 @@ main() {
   if [[ "$(docker images -q ${base_image} 2> /dev/null)" == "" ]]; then
     docker load -i "${base_image_tarball}"
   fi
-  docker run \
-    --rm \
-    --privileged \
-    -e TEST_RUNNER_FLAGS='--format terse' \
-    -v /dev/log:/dev/log \
-    -v "${src_root}":/platform/crosvm:ro \
-    ${base_image}
+  "${src_root}"/docker/wrapped_smoke_test.sh
 
   return 0
 }
diff --git a/kokoro/kokoro_simulator.sh b/kokoro/kokoro_simulator.sh
index 5303c5c..08961de 100755
--- a/kokoro/kokoro_simulator.sh
+++ b/kokoro/kokoro_simulator.sh
@@ -16,7 +16,7 @@ main() {
   mkdir -p "${kokoro_simulator_root}"
   if [[ ! -e "${base_image_tarball}" ]]; then
     if [[ "$(docker images -q ${base_image} 2> /dev/null)" == "" ]]; then
-      docker build -t ${base_image} .
+      ../docker/build_crosvm_base.sh
     fi
     docker save ${base_image} | xz -T 0 -z >"${base_image_tarball}"
   fi
diff --git a/kokoro/pkgconfig/libtpm2.pc b/kokoro/pkgconfig/libtpm2.pc
deleted file mode 100644
index c9ff8f0..0000000
--- a/kokoro/pkgconfig/libtpm2.pc
+++ /dev/null
@@ -1,5 +0,0 @@
-Name: tpm2
-Description: TPM simulator extracted from the TCG TPM 2.0 library specification
-Version: 2.0.0
-Requires.private: libcrypto
-Libs: -L/lib -ltpm2