.github/workflows: add tests for Linux arm64 (#167)
- commit
- 6aa09b68c630e17af36c79122618372971b1e63d
- author
- Hajime Hoshi · · 2023-09-23 12:31 UTC
- committer
- GitHub · · 2023-09-23 12:31 UTC
- parent
- 092d3a9
- signature
- GPG Unverified
4AEE18F83AFDEB23The key is unknown
2 files · +24 -2
M .github/workflows/test.yml +23 -1
| @@ -1,6 +1,10 @@ | |||
| 1 | 1 | name: Test | |
| 2 | 2 | ||
| 3 | - | on: [push, pull_request] | |
| 3 | + | on: | |
| 4 | + | pull_request: | |
| 5 | + | push: | |
| 6 | + | branches: | |
| 7 | + | - main | |
| 4 | 8 | ||
| 5 | 9 | jobs: | |
| 6 | 10 | test: | |
| @@ -28,6 +32,12 @@ jobs: | |||
| 28 | 32 | with: | |
| 29 | 33 | go-version: ${{ matrix.go }} | |
| 30 | 34 | ||
| 35 | + | - name: Set up the prerequisites | |
| 36 | + | if: runner.os == 'Linux' | |
| 37 | + | run: | | |
| 38 | + | sudo apt-get update | |
| 39 | + | sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu qemu-user | |
| 40 | + | ||
| 31 | 41 | - name: go vet | |
| 32 | 42 | if: runner.os != 'Windows' && runner.os != 'macOS' | |
| 33 | 43 | run: | | |
| @@ -82,6 +92,18 @@ jobs: | |||
| 82 | 92 | env CGO_ENABLED=0 go test -shuffle=on -v -count=10 ./... | |
| 83 | 93 | env CGO_ENABLED=1 go test -shuffle=on -v -count=10 ./... | |
| 84 | 94 | ||
| 95 | + | - name: go test (Linux arm64) | |
| 96 | + | if: runner.os == 'Linux' | |
| 97 | + | run: | | |
| 98 | + | go env -w CC=aarch64-linux-gnu-gcc | |
| 99 | + | go env -w CXX=aarch64-linux-gnu-g++ | |
| 100 | + | env GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go test -c -o=purego-test-nocgo . | |
| 101 | + | env QEMU_LD_PREFIX=/usr/aarch64-linux-gnu qemu-aarch64 ./purego-test-nocgo -test.shuffle=on -test.v -test.count=10 | |
| 102 | + | env GOOS=linux GOARCH=arm64 CGO_ENABLED=1 go test -c -o=purego-test-cgo . | |
| 103 | + | env QEMU_LD_PREFIX=/usr/aarch64-linux-gnu qemu-aarch64 ./purego-test-cgo -test.shuffle=on -test.v -test.count=10 | |
| 104 | + | go env -u CC | |
| 105 | + | go env -u CXX | |
| 106 | + | ||
| 85 | 107 | # TODO: add Windows 386 tests | |
| 86 | 108 | ||
| 87 | 109 | - name: go test race | |
| @@ -1,6 +1,10 @@ | |||||
| 1 | name: Test | 1 | name: Test | ||
| 2 | 2 | ||||
| 3 | - | on: [push, pull_request] | 3 | + | on: |
| 4 | + | pull_request: | |||
| 5 | + | push: | |||
| 6 | + | branches: | |||
| 7 | + | - main | |||
| 4 | 8 | ||||
| 5 | jobs: | 9 | jobs: | ||
| 6 | test: | 10 | test: | ||
| @@ -28,6 +32,12 @@ jobs: | |||||
| 28 | with: | 32 | with: | ||
| 29 | go-version: ${{ matrix.go }} | 33 | go-version: ${{ matrix.go }} | ||
| 30 | 34 | ||||
| 35 | + | - name: Set up the prerequisites | |||
| 36 | + | if: runner.os == 'Linux' | |||
| 37 | + | run: | | |||
| 38 | + | sudo apt-get update | |||
| 39 | + | sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu qemu-user | |||
| 40 | + | ||||
| 31 | - name: go vet | 41 | - name: go vet | ||
| 32 | if: runner.os != 'Windows' && runner.os != 'macOS' | 42 | if: runner.os != 'Windows' && runner.os != 'macOS' | ||
| 33 | run: | | 43 | run: | | ||
| @@ -82,6 +92,18 @@ jobs: | |||||
| 82 | env CGO_ENABLED=0 go test -shuffle=on -v -count=10 ./... | 92 | env CGO_ENABLED=0 go test -shuffle=on -v -count=10 ./... | ||
| 83 | env CGO_ENABLED=1 go test -shuffle=on -v -count=10 ./... | 93 | env CGO_ENABLED=1 go test -shuffle=on -v -count=10 ./... | ||
| 84 | 94 | ||||
| 95 | + | - name: go test (Linux arm64) | |||
| 96 | + | if: runner.os == 'Linux' | |||
| 97 | + | run: | | |||
| 98 | + | go env -w CC=aarch64-linux-gnu-gcc | |||
| 99 | + | go env -w CXX=aarch64-linux-gnu-g++ | |||
| 100 | + | env GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go test -c -o=purego-test-nocgo . | |||
| 101 | + | env QEMU_LD_PREFIX=/usr/aarch64-linux-gnu qemu-aarch64 ./purego-test-nocgo -test.shuffle=on -test.v -test.count=10 | |||
| 102 | + | env GOOS=linux GOARCH=arm64 CGO_ENABLED=1 go test -c -o=purego-test-cgo . | |||
| 103 | + | env QEMU_LD_PREFIX=/usr/aarch64-linux-gnu qemu-aarch64 ./purego-test-cgo -test.shuffle=on -test.v -test.count=10 | |||
| 104 | + | go env -u CC | |||
| 105 | + | go env -u CXX | |||
| 106 | + | ||||
| 85 | # TODO: add Windows 386 tests | 107 | # TODO: add Windows 386 tests | ||
| 86 | 108 | ||||
| 87 | - name: go test race | 109 | - name: go test race | ||
M callback_test.go +1 -1
| @@ -14,7 +14,7 @@ import ( | |||
| 14 | 14 | "github.com/ebitengine/purego" | |
| 15 | 15 | ) | |
| 16 | 16 | ||
| 17 | - | // TestCallGoFromSharedLib is a test that checks for stack corruption on darwin/arm64 | |
| 17 | + | // TestCallGoFromSharedLib is a test that checks for stack corruption on arm64 | |
| 18 | 18 | // when C calls Go code from a non-Go thread in a dynamically loaded share library. | |
| 19 | 19 | func TestCallGoFromSharedLib(t *testing.T) { | |
| 20 | 20 | libFileName := filepath.Join(t.TempDir(), "libcbtest.so") | |
| @@ -14,7 +14,7 @@ import ( | |||||
| 14 | "github.com/ebitengine/purego" | 14 | "github.com/ebitengine/purego" | ||
| 15 | ) | 15 | ) | ||
| 16 | 16 | ||||
| 17 | - | // TestCallGoFromSharedLib is a test that checks for stack corruption on darwin/arm64 | 17 | + | // TestCallGoFromSharedLib is a test that checks for stack corruption on arm64 |
| 18 | // when C calls Go code from a non-Go thread in a dynamically loaded share library. | 18 | // when C calls Go code from a non-Go thread in a dynamically loaded share library. | ||
| 19 | func TestCallGoFromSharedLib(t *testing.T) { | 19 | func TestCallGoFromSharedLib(t *testing.T) { | ||
| 20 | libFileName := filepath.Join(t.TempDir(), "libcbtest.so") | 20 | libFileName := filepath.Join(t.TempDir(), "libcbtest.so") | ||