Skip to content

Commit

Permalink
Run ARM64 tests in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
athre0z committed Jul 3, 2024
1 parent a2ca004 commit a871e2f
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 21 deletions.
37 changes: 34 additions & 3 deletions .github/workflows/env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,42 @@ runs:
steps:
- name: Install dependencies
shell: bash
run: sudo apt-get install -y llvm clang dwz cmake curl unzip
- name: Set up Go ${{matrix.go}}
run: |
# Ubuntu has ARM64 packages in an entirely different repo, so we can't just
# `dpkg --add-architecture arm64` here: we have to add a custom sources.list first.
sudo tee /etc/apt/sources.list.d/ubuntu.sources <<EOF > /dev/null
#
# AMD64
#
Types: deb
URIs: http://azure.archive.ubuntu.com/ubuntu/
Suites: noble noble-updates noble-backports
Components: main universe restricted multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
Architectures: amd64
#
# ARM64
#
Types: deb
URIs: http://azure.ports.ubuntu.com/ubuntu-ports/
Suites: noble noble-updates noble-backports
Components: main universe restricted multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
Architectures: arm64
EOF
sudo dpkg --add-architecture arm64
sudo apt-get update -y
sudo apt-get install -y llvm clang dwz curl unzip gcc-aarch64-linux-gnu \
libc6-arm64-cross qemu-user-binfmt libc6:arm64
- name: Set up Go ${{ matrix.go }}
uses: actions/setup-go@v5
with:
go-version: ${{matrix.go}}
go-version: ${{ matrix.go }}
check-latest: true
cache-dependency-path: go.sum
id: go
31 changes: 26 additions & 5 deletions .github/workflows/unit-test-on-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,20 @@ jobs:
max-parallel: 2
matrix:
go: ["stable"]
toolchain:
- { goarch: amd64, cc: gcc }
- { goarch: arm64, cc: aarch64-linux-gnu-gcc }
steps:
- name: Clone code
uses: actions/checkout@v4
- name: Set up environment
uses: ./.github/workflows/env
- name: Build
run: |
echo $PATH
export GOARCH=${{ matrix.toolchain.goarch }}
export CC=${{ matrix.toolchain.cc }}
export OBJCOPY=llvm-objcopy # works cross-arch
export CGO_ENABLED=1
make test
- name: Tests
run: |
Expand All @@ -51,18 +57,28 @@ jobs:
name: Build integration test binaries
runs-on: ubuntu-24.04
timeout-minutes: 10
strategy:
matrix:
toolchain:
- { goarch: amd64, cc: gcc }
- { goarch: arm64, cc: aarch64-linux-gnu-gcc }
steps:
- name: Clone code
uses: actions/checkout@v4
- name: Set up environment
uses: ./.github/workflows/env
- name: Prepare integration test binaries for qemu tests
run: |
export GOARCH=${{ matrix.toolchain.goarch }}
export CC=${{ matrix.toolchain.cc }}
export OBJCOPY=llvm-objcopy # works cross-arch
export CGO_ENABLED=1
make integration-test-binaries
- name: Upload integration test binaries
uses: actions/upload-artifact@v4
with:
name: integration-test-binaries
name: integration-test-binaries-${{ matrix.toolchain.goarch }}
path: support/*.test

integration-tests:
Expand All @@ -71,6 +87,9 @@ jobs:
needs: build-integration-test-binaries
strategy:
matrix:
toolchain:
- { arch: x86, goarch: amd64, cc: gcc }
- { arch: aarch64, goarch: arm64, cc: aarch64-linux-gnu-gcc }
kernel-version:
- "4.19.314"
- "5.4.276"
Expand All @@ -87,19 +106,21 @@ jobs:
uses: ./.github/workflows/env
- name: Install dependencies
run: |
sudo apt-get -y install qemu-system-x86
sudo apt-get -y install qemu-system-${{ matrix.toolchain.arch }}
go install github.com/florianl/[email protected]
sudo mv ~/go/bin/bluebox /usr/local/bin/.
- name: Fetch integration test binaries
uses: actions/download-artifact@v4
with: { name: integration-test-binaries }
with: { name: integration-test-binaries-${{ matrix.toolchain.goarch }} }
- name: Fetch precompiled kernels
run: |
install -d ci-kernels
echo "FROM ghcr.io/cilium/ci-kernels:${{ matrix.kernel-version }}" \
| docker buildx build --quiet --pull --output="ci-kernels" -
| docker buildx build --platform linux/${{ matrix.toolchain.goarch }} \
--quiet --pull --output="ci-kernels" -
mv ci-kernels/boot/ ci-kernels/${{ matrix.kernel-version }}/
- name: Test on kernel ${{ matrix.kernel-version }}
run: |
chmod a+rx *.test
export QEMU_ARCH=${{ matrix.toolchain.arch}}
support/run-tests.sh ${{ matrix.kernel-version }}
17 changes: 10 additions & 7 deletions libpf/pfelf/testdata/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
.PHONY: all

CC ?= cc
OBJCOPY ?= objcopy

BINARIES=fixed-address \
go-binary \
kernel-image \
Expand All @@ -15,18 +18,18 @@ clean:
rm -f $(BINARIES)

with-debug-syms: test.c
gcc $< -g -o $@
$(CC) $< -g -o $@

without-debug-syms: test.c
gcc $< -s -o $@
$(CC) $< -s -o $@

separate-debug-file: with-debug-syms
objcopy --only-keep-debug $< $@
$(OBJCOPY) --only-keep-debug $< $@

fixed-address: fixed-address.c fixed-address.ld
# The following command will likely print a warning (about a missing -T option), which should be ignored.
# Removing the warning would require passing a fully-fledged linker script to bypass gcc's default.
gcc $^ -o $@
$(CC) $^ -o $@

# Write an ELF notes file with a build ID
the_notorious_build_id:
Expand All @@ -36,12 +39,12 @@ the_notorious_build_id:
bash -c "echo -en 'somedata\x04\x00\x00\x00\x14\x00\x00\x00\x03\x00\x00\x00GNU\x00_notorious_build_id_\x00somedata' > $@"

kernel-image: test.c
gcc $< -s -o $@ -DLINUX_VERSION="\"Linux version 1.2.3\\n\""
$(CC) $< -s -o $@ -DLINUX_VERSION="\"Linux version 1.2.3\\n\""

ubuntu-kernel-image: test.c
gcc $< -s -o $@ -DLINUX_VERSION="\"Linux version 1.2.3 (Ubuntu 4.5.6)\\n\""
$(CC) $< -s -o $@ -DLINUX_VERSION="\"Linux version 1.2.3 (Ubuntu 4.5.6)\\n\""

# A fake go binary (with a .gopclntab section)
go-binary: without-debug-syms
objcopy --add-section .gopclntab=/dev/null $< $@
$(OBJCOPY) --add-section .gopclntab=/dev/null $< $@

4 changes: 2 additions & 2 deletions reporter/testdata/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.PHONY: all

CC=gcc
CFLAGS=-Wl,--build-id
CC ?= cc
CFLAGS = -Wl,--build-id

all: test

Expand Down
5 changes: 3 additions & 2 deletions support/run-tests.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/usr/bin/env bash
# Test the current package under a different kernel.
# Requires qemu-system-x86_64 and bluebox to be installed.
# Requires qemu-system-$QEMU_ARCH and bluebox to be installed.

set -eu
set -o pipefail

qemu_arch="${QEMU_ARCH:-x86_64}"
color_green=$'\033[32m'
color_red=$'\033[31m'
color_default=$'\033[39m'
Expand Down Expand Up @@ -48,7 +49,7 @@ fi
bluebox "${bb_args[@]}" || (echo "failed to generate initramfs"; exit 1)

echo Testing on "${kernel_version}"
$sudo qemu-system-x86_64 ${additionalQemuArgs} \
$sudo qemu-system-${qemu_arch} ${additionalQemuArgs} \
-nographic \
-append "console=ttyS0" \
-monitor none \
Expand Down
6 changes: 4 additions & 2 deletions tools/fake-apm-agent/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.PHONY: clean all

CC ?= cc

ARCH=$(shell uname -m)
LIB_NAME=elastic-jvmti-linux-$(ARCH).so

Expand All @@ -12,10 +14,10 @@ endif
all: fake-apm-agent $(LIB_NAME)

$(LIB_NAME): fake-apm-agent-lib.c
cc $< -g -shared -fPIC -mtls-dialect=$(TLS_DIALECT) -ftls-model=global-dynamic -o $@
$(CC) $< -g -shared -fPIC -mtls-dialect=$(TLS_DIALECT) -ftls-model=global-dynamic -o $@

fake-apm-agent: fake-apm-agent.c
cc $< -g -DLIB_NAME='"$(LIB_NAME)"' -o $@
$(CC) $< -g -DLIB_NAME='"$(LIB_NAME)"' -o $@

clean:
rm elastic-jvmti-linux-$(ARCH).so
Expand Down

0 comments on commit a871e2f

Please sign in to comment.