Skip to content

Commit

Permalink
Testing for s390x
Browse files Browse the repository at this point in the history
  • Loading branch information
justsmth committed Mar 1, 2024
1 parent 856952e commit 853b015
Show file tree
Hide file tree
Showing 8 changed files with 137 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/cross-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,20 @@ jobs:
- uses: actions/checkout@v4
- name: PPC64LE Build/Test
run: tests/ci/run_cross_tests.sh ppc64le powerpc64le-unknown-linux-gnu "-DCMAKE_BUILD_TYPE=Release" "-DCMAKE_BUILD_TYPE=Release -DFIPS=1 -DBUILD_SHARED_LIBS=1"
s390x-non-fips-build-test:
runs-on: ubuntu-latest
steps:
- name: Install qemu
run: |
sudo apt-get update
sudo apt-get -y install qemu-user qemu-user-binfmt
- uses: actions/checkout@v4
- name: s390x Build/Test
# The flag below is set to avoid the following error with GCC 11.4.0:
#
# /home/runner/work/aws-lc/aws-lc/crypto/pem/pem_lib.c:705:11: error: 'strncmp' of strings of length 1 and 9 and bound of 9 evaluates to nonzero [-Werror=string-compare]
# 705 | if (strncmp(buf, "-----END ", 9) == 0) {
# | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
env:
CFLAGS: "-Wno-string-compare"
run: tests/ci/run_cross_tests.sh s390x s390x-ibm-linux-gnu "-DCMAKE_BUILD_TYPE=Release"
2 changes: 2 additions & 0 deletions tests/ci/run_cross_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ set(ENABLE_EXPERIMENTAL_BIG_ENDIAN_SUPPORT true)
set(CMAKE_GENERATOR Ninja)
EOF

cat ${TARGET_CPU}.cmake

export QEMU_LD_PREFIX="${SCRATCH_FOLDER}/${TARGET_PLATFORM}/${TARGET_PLATFORM}/sysroot"
export LD_LIBRARY_PATH="${SCRATCH_FOLDER}/${TARGET_PLATFORM}/${TARGET_PLATFORM}/sysroot/lib"

Expand Down
1 change: 1 addition & 0 deletions tests/docker_images/linux-ppc/ubuntu-x-tools/ppc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ set(CMAKE_CXX_COMPILER /powerpc-unknown-linux-gnu/bin/powerpc-unknown-linux-gnu-
# Specify the sysroot for the target system
set(CMAKE_SYSROOT /powerpc-unknown-linux-gnu/powerpc-unknown-linux-gnu/sysroot)
set(CMAKE_GENERATOR Ninja)
set(ENABLE_EXPERIMENTAL_BIG_ENDIAN_SUPPORT true)
1 change: 1 addition & 0 deletions tests/docker_images/linux-ppc64/ubuntu-x-tools/ppc64.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ set(CMAKE_CXX_COMPILER /powerpc64-unknown-linux-gnu/bin/powerpc64-unknown-linux-
# Specify the sysroot for the target system
set(CMAKE_SYSROOT /powerpc64-unknown-linux-gnu/powerpc64-unknown-linux-gnu/sysroot/)
set(CMAKE_GENERATOR Ninja)
set(ENABLE_EXPERIMENTAL_BIG_ENDIAN_SUPPORT true)
41 changes: 41 additions & 0 deletions tests/docker_images/linux-s390x/build_images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0 OR ISC

set -ex

# Note:
# After host reboot, qemu registration may need to be performed.
# `docker run --rm --privileged multiarch/qemu-user-static --reset -p yes`

# On Linux, you can see which architectures that qemu is registered for by looking
# under `/proc/sys/fs/binfmt_misc`.

# If needed, you can clear these entries using the following command:
# `sudo find /proc/sys/fs/binfmt_misc -type f -name 'qemu-*' -exec sh -c 'echo -1 > {}' \;`

# Log Docker hub limit https://docs.docker.com/docker-hub/download-rate-limit/#how-can-i-check-my-current-rate
TOKEN=$(curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token)
curl --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest

SCRIPT_DIR=$(dirname "$(readlink -f "${0}")")

docker run --rm --privileged multiarch/qemu-user-static --reset -p yes

ARCH_NAME=s390x

X_TOOLS_FILE=${ARCH_NAME}-x-tools
if [ ! -f "./ubuntu-x-tools/${X_TOOLS_FILE}.tar.xz" ]; then
wget "https://aws-libcrypto.s3.us-west-2.amazonaws.com/cross-compile-toolchains/host-x86_64-pc-linux-gnu/${X_TOOLS_FILE}.tar.xz"
mv ${X_TOOLS_FILE}.tar.xz ./ubuntu-x-tools/
fi

BUILDER_NAME=${ARCH_NAME}-builder
if ! docker buildx inspect ${BUILDER_NAME}; then
docker buildx create --name ${BUILDER_NAME} --use
fi

docker buildx build -t ubuntu-${ARCH_NAME}:test "${SCRIPT_DIR}"/ubuntu-test --load
docker buildx build -t ubuntu-${ARCH_NAME}:x-tools "${SCRIPT_DIR}"/ubuntu-x-tools --load

docker buildx rm ${BUILDER_NAME}
23 changes: 23 additions & 0 deletions tests/docker_images/linux-s390x/ubuntu-test/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0 OR ISC

FROM --platform=$BUILDPLATFORM s390x/ubuntu

SHELL ["/bin/bash", "-c"]

# Note: valgind was not available on this platform
RUN apt-get update && apt-get install -y \
git gcc g++ cmake golang gdb gdbserver \
libclang-dev clang \
build-essential \
ssh \
rsync \
tar \
python3 \
&& apt-get clean

EXPOSE 7777

ENV GOCACHE=/tmp

CMD ["/bin/bash"]
40 changes: 40 additions & 0 deletions tests/docker_images/linux-s390x/ubuntu-x-tools/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0 OR ISC

FROM ubuntu:22.04

RUN apt-get update && apt-get install -y \
git cmake golang gdb gdbserver valgrind \
libclang1 \
build-essential \
ssh \
rsync \
tar \
python3 \
xz-utils \
ninja-build

RUN apt-get install -y \
qemu-system-s390x \
qemu-user \
qemu-user-binfmt

RUN apt-get clean

COPY s390x-x-tools.tar.xz /
RUN tar Jxvf s390x-x-tools.tar.xz -C / && rm /s390x-x-tools.tar.xz
COPY s390x.cmake /

EXPOSE 1234

ENV GOCACHE=/tmp \
CMAKE_TOOLCHAIN_FILE=/s390x.cmake \
CMAKE_SYSTEM_NAME=Linux \
CMAKE_SYSTEM_PROCESSOR=s390x \
PATH="${PATH}:/s390x-ibm-linux-gnu/bin/" \
CMAKE_C_COMPILER=/s390x-ibm-linux-gnu/bin/s390x-ibm-linux-gnu-gcc \
CMAKE_CXX_COMPILER=/s390x-ibm-linux-gnu/bin/s390x-ibm-linux-gnu-g++ \
CMAKE_SYSROOT=/s390x-ibm-linux-gnu/s390x-ibm-linux-gnu/sysroot \
CMAKE_GENERATOR=Ninja

CMD ["/bin/bash"]
12 changes: 12 additions & 0 deletions tests/docker_images/linux-s390x/ubuntu-x-tools/s390x.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Specify the target system
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR s390x)

# Specify the cross-compiler
set(CMAKE_C_COMPILER /s390x-ibm-linux-gnu/bin/s390x-ibm-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER /s390x-ibm-linux-gnu/bin/s390x-ibm-linux-gnu-g++)

# Specify the sysroot for the target system
set(CMAKE_SYSROOT /s390x-ibm-linux-gnu/s390x-ibm-linux-gnu/sysroot)
set(CMAKE_GENERATOR Ninja)
set(ENABLE_EXPERIMENTAL_BIG_ENDIAN_SUPPORT true)

0 comments on commit 853b015

Please sign in to comment.