From a0e901777e9e9798f50e2682975ff639ab26ef59 Mon Sep 17 00:00:00 2001 From: Lorenz Bauer Date: Wed, 6 Dec 2023 16:08:08 +0000 Subject: [PATCH 1/2] CI: run tests on arm64 Use the actuated runners provided by the CNCF to run the testsuite on arm64. These runners do not support nested KVM and therefore we can't run the VM tests there. Signed-off-by: Lorenz Bauer --- .github/workflows/ci.yml | 41 +++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 27fffb3c2..1df6a1f78 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,3 +1,4 @@ +name: ci on: push: branches: [ "main" ] @@ -69,13 +70,6 @@ jobs: go build -v ./... go test -c -o /dev/null ./... >/dev/null - - name: Cross build arm64 - env: - GOARCH: arm64 - run: | - go build -v ./... - go test -c -o /dev/null ./... >/dev/null - build-docs: name: Build Documentation runs-on: ubuntu-22.04 @@ -139,6 +133,39 @@ jobs: name: Test Results (previous stable Go) path: junit.xml + test-on-arm64: + name: Run tests on arm64 + runs-on: actuated-arm64-2cpu-8gb + needs: build-and-lint + timeout-minutes: 10 + steps: + - uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '${{ env.prev_go_version }}' + + - run: go install gotest.tools/gotestsum@v1.8.1 + + - name: Test + run: gotestsum --ignore-non-json-output-lines --junitfile junit.xml -- -exec sudo -short -count 1 -json ./... + + - name: Benchmark + run: go test -exec sudo -short -run '^$' -bench . -benchtime=1x ./... + + - name: Upload Test Results + if: always() + uses: actions/upload-artifact@v3 + with: + name: Test Results (arm64) + path: junit.xml + + - name: Show dmesg + if: failure() + run: | + sudo dmesg + vm-test: name: Run tests on pre-built kernel runs-on: ubuntu-latest-4cores-16gb From 7dd3794cd960576d38dcbd3ad9e76aaab7152f93 Mon Sep 17 00:00:00 2001 From: Lorenz Bauer Date: Wed, 6 Dec 2023 14:05:44 +0000 Subject: [PATCH 2/2] link: fix TestExecutableLazyLoadSymbols on arm64 Creating a uprobe on arm64 validates that the address is a multiple of AARCH64_INSN_SIZE aka 4. The tests currently uses 123 which isn't divisible by 4 and hence we get EINVAL on arm64. Fix this by using an address that is divisible by 4. Signed-off-by: Lorenz Bauer --- link/uprobe_test.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/link/uprobe_test.go b/link/uprobe_test.go index 1616bde7f..501420bee 100644 --- a/link/uprobe_test.go +++ b/link/uprobe_test.go @@ -71,15 +71,17 @@ func TestExecutableLazyLoadSymbols(t *testing.T) { ex, err := OpenExecutable("/bin/bash") qt.Assert(t, qt.IsNil(err)) // Addresses must be empty, will be lazy loaded. - qt.Assert(t, qt.DeepEquals(ex.addresses, map[string]uint64{})) + qt.Assert(t, qt.HasLen(ex.addresses, 0)) prog := mustLoadProgram(t, ebpf.Kprobe, 0, "") - up, err := ex.Uprobe(bashSym, prog, &UprobeOptions{Address: 123}) + // Address must be a multiple of 4 on arm64, see + // https://elixir.bootlin.com/linux/v6.6.4/source/arch/arm64/kernel/probes/uprobes.c#L42 + up, err := ex.Uprobe(bashSym, prog, &UprobeOptions{Address: 124}) qt.Assert(t, qt.IsNil(err)) up.Close() // Addresses must still be empty as Address has been provided via options. - qt.Assert(t, qt.DeepEquals(ex.addresses, map[string]uint64{})) + qt.Assert(t, qt.HasLen(ex.addresses, 0)) up, err = ex.Uprobe(bashSym, prog, nil) qt.Assert(t, qt.IsNil(err))