run basic C++ tests under qemu emulator
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 0000000..425cc90
--- /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 0000000..70a0d7c
--- /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 0000000..26f95f3
--- /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