xref: /aosp_15_r20/external/protobuf/kokoro/linux/aarch64/test_python_aarch64.sh (revision 1b3f573f81763fcece89efc2b6a5209149e44ab8)
1#!/bin/bash
2
3set -e
4
5# go to the repo root
6cd $(dirname $0)/../../..
7
8if [[ -t 0 ]]; then
9  DOCKER_TTY_ARGS="-it"
10else
11  # The input device on kokoro is not a TTY, so -it does not work.
12  DOCKER_TTY_ARGS=
13fi
14
15# crosscompile python extension and the binary wheel under dockcross/manylinux2014-aarch64 image
16kokoro/linux/aarch64/dockcross_helpers/run_dockcross_manylinux2014_aarch64.sh kokoro/linux/aarch64/python_crosscompile_aarch64.sh
17
18# once crosscompilation is done, use an actual aarch64 docker image (with a real aarch64 python) to run all the tests under an emulator
19# * mount the protobuf root as /work to be able to access the crosscompiled files
20# * intentionally use a different image than manylinux2014 so that we don't build and test on the same linux distribution
21#   (manylinux_2_24 is debian-based while manylinux2014 is centos-based)
22# * to avoid running the process inside docker as root (which can pollute the workspace with files owned by root), we force
23#   running under current user's UID and GID. To be able to do that, we need to provide a home directory for the user
24#   otherwise the UID would be homeless under the docker container and pip install wouldn't work. For simplicity,
25#   we just run map the user's home to a throwaway temporary directory
26docker run $DOCKER_TTY_ARGS --rm --user "$(id -u):$(id -g)" -e "HOME=/home/fake-user" -v "$(mktemp -d):/home/fake-user" -v "$(pwd)":/work -w /work quay.io/pypa/manylinux_2_24_aarch64 kokoro/linux/aarch64/python_run_tests_with_qemu_aarch64.sh
27