From b3d497f6a50cd0c24b4e3a08e7338f8622dc9d60 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 8 Mar 2021 11:04:43 +0100 Subject: [PATCH 1/2] run basic C++ tests under qemu emulator --- ...compile_and_run_tests_with_qemu_aarch64.sh | 21 ++++++++++++ .../run_dockcross_linux_aarch64.sh | 33 +++++++++++++++++++ kokoro/linux/aarch64/test_cpp_aarch64.sh | 14 ++++++++ 3 files changed, 68 insertions(+) create mode 100755 kokoro/linux/aarch64/cpp_crosscompile_and_run_tests_with_qemu_aarch64.sh create mode 100755 kokoro/linux/aarch64/dockcross_helpers/run_dockcross_linux_aarch64.sh create mode 100755 kokoro/linux/aarch64/test_cpp_aarch64.sh diff --git a/kokoro/linux/aarch64/cpp_crosscompile_and_run_tests_with_qemu_aarch64.sh b/kokoro/linux/aarch64/cpp_crosscompile_and_run_tests_with_qemu_aarch64.sh new file mode 100755 index 0000000000..425cc90b75 --- /dev/null +++ b/kokoro/linux/aarch64/cpp_crosscompile_and_run_tests_with_qemu_aarch64.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# +# Builds protobuf C++ with aarch64 crosscompiler and runs a basic set of tests under an emulator. +# NOTE: This script is expected to run under the dockcross/linux-arm64 docker image. + +set -ex + +mkdir -p cmake/crossbuild_aarch64 +cd cmake/crossbuild_aarch64 + +# the build commands are expected to run under dockcross docker image +# where the CC, CXX and other toolchain variables already point to the crosscompiler +cmake .. +make -j8 + +# check that the resulting test binary is indeed an aarch64 ELF +(file ./tests | grep -q "ELF 64-bit LSB executable, ARM aarch64") || (echo "Test binary in not an aarch64 binary"; exit 1) + +# run the basic set of C++ tests under QEMU +# there are other tests we could run (e.g. ./lite-test), but this is sufficient as a smoketest +qemu-aarch64 ./tests diff --git a/kokoro/linux/aarch64/dockcross_helpers/run_dockcross_linux_aarch64.sh b/kokoro/linux/aarch64/dockcross_helpers/run_dockcross_linux_aarch64.sh new file mode 100755 index 0000000000..70a0d7c327 --- /dev/null +++ b/kokoro/linux/aarch64/dockcross_helpers/run_dockcross_linux_aarch64.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +set -e + +# go to the repo root +cd $(dirname $0)/../../../.. + +if [[ -t 0 ]]; then + DOCKER_TTY_ARGS="-it" +else + # The input device on kokoro is not a TTY, so -it does not work. + DOCKER_TTY_ARGS= +fi + +# running dockcross image without any arguments generates a wrapper +# scripts that can be used to run commands under the dockcross image +# easily. +# See https://github.com/dockcross/dockcross#usage for details +docker run $DOCKER_TTY_ARGS --rm dockcross/linux-arm64 >dockcross-linux-arm64.sh +chmod +x dockcross-linux-arm64.sh + +# the wrapper script has CRLF line endings and bash doesn't like that +# so we change CRLF line endings into LF. +sed -i 's/\r//g' dockcross-linux-arm64.sh + +# The dockcross wrapper script runs arbitrary commands under the selected dockcross +# image with the following properties which make its use very convenient: +# * the current working directory is mounted under /work so the container can easily +# access the current workspace +# * the processes in the container run under the same UID and GID as the host process so unlike +# vanilla "docker run" invocations, the workspace doesn't get polluted with files +# owned by root. +./dockcross-linux-arm64.sh "$@" diff --git a/kokoro/linux/aarch64/test_cpp_aarch64.sh b/kokoro/linux/aarch64/test_cpp_aarch64.sh new file mode 100755 index 0000000000..26f95f323c --- /dev/null +++ b/kokoro/linux/aarch64/test_cpp_aarch64.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# +# Crosscompiles protobuf C++ under dockcross docker image and runs the tests under an emulator. + +set -e + +# go to the repo root +cd $(dirname $0)/../../.. + +# Initialize any submodules. +git submodule update --init --recursive + +# run the C++ build and test script under dockcross/linux-arm64 image +kokoro/linux/aarch64/dockcross_helpers/run_dockcross_linux_aarch64.sh kokoro/linux/aarch64/cpp_crosscompile_and_run_tests_with_qemu_aarch64.sh From 64d0b2940d24536013204bad040918da4542e2c1 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 13 Apr 2021 12:44:56 +0200 Subject: [PATCH 2/2] add C++ aarch64 kokoro configuration --- kokoro/linux/cpp_aarch64/build.sh | 11 +++++++++++ kokoro/linux/cpp_aarch64/continuous.cfg | 5 +++++ kokoro/linux/cpp_aarch64/presubmit.cfg | 5 +++++ 3 files changed, 21 insertions(+) create mode 100755 kokoro/linux/cpp_aarch64/build.sh create mode 100644 kokoro/linux/cpp_aarch64/continuous.cfg create mode 100644 kokoro/linux/cpp_aarch64/presubmit.cfg diff --git a/kokoro/linux/cpp_aarch64/build.sh b/kokoro/linux/cpp_aarch64/build.sh new file mode 100755 index 0000000000..a43ab1c71e --- /dev/null +++ b/kokoro/linux/cpp_aarch64/build.sh @@ -0,0 +1,11 @@ +#!/bin/bash +# +# This is the top-level script we give to Kokoro as the entry point for +# running the "continuous" and "presubmit" jobs. + +set -ex + +# Change to repo root +cd $(dirname $0)/../../.. + +kokoro/linux/aarch64/test_cpp_aarch64.sh diff --git a/kokoro/linux/cpp_aarch64/continuous.cfg b/kokoro/linux/cpp_aarch64/continuous.cfg new file mode 100644 index 0000000000..0f1be4a224 --- /dev/null +++ b/kokoro/linux/cpp_aarch64/continuous.cfg @@ -0,0 +1,5 @@ +# Config file for running tests in Kokoro + +# Location of the build script in repository +build_file: "protobuf/kokoro/linux/cpp_aarch64/build.sh" +timeout_mins: 120 diff --git a/kokoro/linux/cpp_aarch64/presubmit.cfg b/kokoro/linux/cpp_aarch64/presubmit.cfg new file mode 100644 index 0000000000..0f1be4a224 --- /dev/null +++ b/kokoro/linux/cpp_aarch64/presubmit.cfg @@ -0,0 +1,5 @@ +# Config file for running tests in Kokoro + +# Location of the build script in repository +build_file: "protobuf/kokoro/linux/cpp_aarch64/build.sh" +timeout_mins: 120