.github/workflows: add a native Windows/arm64 test target (#471)
Add windows-11-arm to the test matrix so the Windows/arm64 ABI is exercised on real hardware (Go 1.25.x and 1.26.x). The runner has no C toolchain that targets Windows arm64 (its bundled gcc is an x86_64 mingw build and MSYS2 is omitted), so the tests that compile a C shared library are skipped on windows/arm64, as they already are on windows/386. The skip lives in buildSharedLib, so every test that builds a C library inherits it. The remaining tests still cover the Go callback and syscall paths on the platform. Also skip the Windows steps that do not apply to arm64: the MSYS2 setup, the Cgo variant of the 386 test, and the race detector, which Go does not support on windows/arm64. Closes #468 Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
- commit
- 5da538943ca77dfb42802ec46a21876c5874b8ee
- author
- Hajime Hoshi · · 2026-06-28 03:25 UTC
- committer
- GitHub · · 2026-06-28 03:25 UTC
- parent
- 80e859b
- signature
- GPG Unverified
B5690EEEBB952194The key is unknown
7 files · +36 -24
M .github/workflows/test.yml +8 -3
| @@ -9,7 +9,7 @@ jobs: | |||
| 9 | 9 | test: | |
| 10 | 10 | strategy: | |
| 11 | 11 | matrix: | |
| 12 | - | os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, windows-latest] | |
| 12 | + | os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, windows-latest, windows-11-arm] | |
| 13 | 13 | go: ['1.25.x', '1.26.x'] | |
| 14 | 14 | name: Test with Go ${{ matrix.go }} on ${{ matrix.os }} | |
| 15 | 15 | runs-on: ${{ matrix.os }} | |
| @@ -31,8 +31,8 @@ jobs: | |||
| 31 | 31 | with: | |
| 32 | 32 | go-version: ${{ matrix.go }} | |
| 33 | 33 | ||
| 34 | - | - name: Set up the prerequisites | |
| 35 | - | if: runner.os == 'Windows' | |
| 34 | + | - name: Set up Msys2 | |
| 35 | + | if: runner.os == 'Windows' && runner.arch != 'ARM64' | |
| 36 | 36 | uses: msys2/setup-msys2@v2 | |
| 37 | 37 | ||
| 38 | 38 | - name: go vet | |
| @@ -127,6 +127,10 @@ jobs: | |||
| 127 | 127 | if: runner.os == 'Windows' | |
| 128 | 128 | run: | | |
| 129 | 129 | env CGO_ENABLED=0 GOARCH=386 go test -shuffle=on -v -count=10 ./... | |
| 130 | + | ||
| 131 | + | - name: go test (Windows 386, Cgo) | |
| 132 | + | if: runner.os == 'Windows' && runner.arch != 'ARM64' | |
| 133 | + | run: | | |
| 130 | 134 | env CGO_ENABLED=1 GOARCH=386 go test -shuffle=on -v -count=10 ./... | |
| 131 | 135 | ||
| 132 | 136 | - name: go test (Linux 386) | |
| @@ -180,6 +184,7 @@ jobs: | |||
| 180 | 184 | env CGO_ENABLED=0 go test -race -shuffle=on -v -count=10 ./... | |
| 181 | 185 | ||
| 182 | 186 | - name: go test race (Cgo) | |
| 187 | + | if: ${{ !(runner.os == 'Windows' && runner.arch == 'ARM64') }} | |
| 183 | 188 | run: | | |
| 184 | 189 | env CGO_ENABLED=1 go test -race -shuffle=on -v -count=10 ./... | |
| 185 | 190 | ||
| @@ -9,7 +9,7 @@ jobs: | |||||
| 9 | test: | 9 | test: | ||
| 10 | strategy: | 10 | strategy: | ||
| 11 | matrix: | 11 | matrix: | ||
| 12 | - | os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, windows-latest] | 12 | + | os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, windows-latest, windows-11-arm] |
| 13 | go: ['1.25.x', '1.26.x'] | 13 | go: ['1.25.x', '1.26.x'] | ||
| 14 | name: Test with Go ${{ matrix.go }} on ${{ matrix.os }} | 14 | name: Test with Go ${{ matrix.go }} on ${{ matrix.os }} | ||
| 15 | runs-on: ${{ matrix.os }} | 15 | runs-on: ${{ matrix.os }} | ||
| @@ -31,8 +31,8 @@ jobs: | |||||
| 31 | with: | 31 | with: | ||
| 32 | go-version: ${{ matrix.go }} | 32 | go-version: ${{ matrix.go }} | ||
| 33 | 33 | ||||
| 34 | - | - name: Set up the prerequisites | 34 | + | - name: Set up Msys2 |
| 35 | - | if: runner.os == 'Windows' | 35 | + | if: runner.os == 'Windows' && runner.arch != 'ARM64' |
| 36 | uses: msys2/setup-msys2@v2 | 36 | uses: msys2/setup-msys2@v2 | ||
| 37 | 37 | ||||
| 38 | - name: go vet | 38 | - name: go vet | ||
| @@ -127,6 +127,10 @@ jobs: | |||||
| 127 | if: runner.os == 'Windows' | 127 | if: runner.os == 'Windows' | ||
| 128 | run: | | 128 | run: | | ||
| 129 | env CGO_ENABLED=0 GOARCH=386 go test -shuffle=on -v -count=10 ./... | 129 | env CGO_ENABLED=0 GOARCH=386 go test -shuffle=on -v -count=10 ./... | ||
| 130 | + | ||||
| 131 | + | - name: go test (Windows 386, Cgo) | |||
| 132 | + | if: runner.os == 'Windows' && runner.arch != 'ARM64' | |||
| 133 | + | run: | | |||
| 130 | env CGO_ENABLED=1 GOARCH=386 go test -shuffle=on -v -count=10 ./... | 134 | env CGO_ENABLED=1 GOARCH=386 go test -shuffle=on -v -count=10 ./... | ||
| 131 | 135 | ||||
| 132 | - name: go test (Linux 386) | 136 | - name: go test (Linux 386) | ||
| @@ -180,6 +184,7 @@ jobs: | |||||
| 180 | env CGO_ENABLED=0 go test -race -shuffle=on -v -count=10 ./... | 184 | env CGO_ENABLED=0 go test -race -shuffle=on -v -count=10 ./... | ||
| 181 | 185 | ||||
| 182 | - name: go test race (Cgo) | 186 | - name: go test race (Cgo) | ||
| 187 | + | if: ${{ !(runner.os == 'Windows' && runner.arch == 'ARM64') }} | |||
| 183 | run: | | 188 | run: | | ||
| 184 | env CGO_ENABLED=1 go test -race -shuffle=on -v -count=10 ./... | 189 | env CGO_ENABLED=1 go test -race -shuffle=on -v -count=10 ./... | ||
| 185 | 190 | ||||
M callback_test.go +7 -7
| @@ -22,7 +22,7 @@ func TestCallGoFromSharedLib(t *testing.T) { | |||
| 22 | 22 | libFileName := filepath.Join(t.TempDir(), "libcbtest.so") | |
| 23 | 23 | t.Logf("Build %v", libFileName) | |
| 24 | 24 | ||
| 25 | - | if err := buildSharedLib("CC", libFileName, filepath.Join("testdata", "libcbtest", "callback_test.c")); err != nil { | |
| 25 | + | if err := buildSharedLib(t, "CC", libFileName, filepath.Join("testdata", "libcbtest", "callback_test.c")); err != nil { | |
| 26 | 26 | t.Fatal(err) | |
| 27 | 27 | } | |
| 28 | 28 | defer os.Remove(libFileName) | |
| @@ -186,7 +186,7 @@ func TestCallbackInt32Packing(t *testing.T) { | |||
| 186 | 186 | } | |
| 187 | 187 | ||
| 188 | 188 | libFileName := filepath.Join(t.TempDir(), "libcbtest_packing.so") | |
| 189 | - | if err := buildSharedLib("CC", libFileName, filepath.Join("testdata", "libcbtest", "callback_packing_test.c")); err != nil { | |
| 189 | + | if err := buildSharedLib(t, "CC", libFileName, filepath.Join("testdata", "libcbtest", "callback_packing_test.c")); err != nil { | |
| 190 | 190 | t.Fatal(err) | |
| 191 | 191 | } | |
| 192 | 192 | defer os.Remove(libFileName) | |
| @@ -218,7 +218,7 @@ func TestCallbackMixedStackPacking(t *testing.T) { | |||
| 218 | 218 | } | |
| 219 | 219 | ||
| 220 | 220 | libFileName := filepath.Join(t.TempDir(), "libcbtest_packing.so") | |
| 221 | - | if err := buildSharedLib("CC", libFileName, filepath.Join("testdata", "libcbtest", "callback_packing_test.c")); err != nil { | |
| 221 | + | if err := buildSharedLib(t, "CC", libFileName, filepath.Join("testdata", "libcbtest", "callback_packing_test.c")); err != nil { | |
| 222 | 222 | t.Fatal(err) | |
| 223 | 223 | } | |
| 224 | 224 | defer os.Remove(libFileName) | |
| @@ -251,7 +251,7 @@ func TestCallbackSmallTypesPacking(t *testing.T) { | |||
| 251 | 251 | } | |
| 252 | 252 | ||
| 253 | 253 | libFileName := filepath.Join(t.TempDir(), "libcbtest_packing.so") | |
| 254 | - | if err := buildSharedLib("CC", libFileName, filepath.Join("testdata", "libcbtest", "callback_packing_test.c")); err != nil { | |
| 254 | + | if err := buildSharedLib(t, "CC", libFileName, filepath.Join("testdata", "libcbtest", "callback_packing_test.c")); err != nil { | |
| 255 | 255 | t.Fatal(err) | |
| 256 | 256 | } | |
| 257 | 257 | defer os.Remove(libFileName) | |
| @@ -319,7 +319,7 @@ func TestCallback10Int32Packing(t *testing.T) { | |||
| 319 | 319 | } | |
| 320 | 320 | ||
| 321 | 321 | libFileName := filepath.Join(t.TempDir(), "libcbtest_packing.so") | |
| 322 | - | if err := buildSharedLib("CC", libFileName, filepath.Join("testdata", "libcbtest", "callback_packing_test.c")); err != nil { | |
| 322 | + | if err := buildSharedLib(t, "CC", libFileName, filepath.Join("testdata", "libcbtest", "callback_packing_test.c")); err != nil { | |
| 323 | 323 | t.Fatal(err) | |
| 324 | 324 | } | |
| 325 | 325 | defer os.Remove(libFileName) | |
| @@ -350,7 +350,7 @@ func TestCallbackFloat64StackPacking(t *testing.T) { | |||
| 350 | 350 | } | |
| 351 | 351 | ||
| 352 | 352 | libFileName := filepath.Join(t.TempDir(), "libcbtest_packing.so") | |
| 353 | - | if err := buildSharedLib("CC", libFileName, filepath.Join("testdata", "libcbtest", "callback_packing_test.c")); err != nil { | |
| 353 | + | if err := buildSharedLib(t, "CC", libFileName, filepath.Join("testdata", "libcbtest", "callback_packing_test.c")); err != nil { | |
| 354 | 354 | t.Fatal(err) | |
| 355 | 355 | } | |
| 356 | 356 | defer os.Remove(libFileName) | |
| @@ -384,7 +384,7 @@ func TestCallbackFloat32StackPacking(t *testing.T) { | |||
| 384 | 384 | } | |
| 385 | 385 | ||
| 386 | 386 | libFileName := filepath.Join(t.TempDir(), "libcbtest_packing.so") | |
| 387 | - | if err := buildSharedLib("CC", libFileName, filepath.Join("testdata", "libcbtest", "callback_packing_test.c")); err != nil { | |
| 387 | + | if err := buildSharedLib(t, "CC", libFileName, filepath.Join("testdata", "libcbtest", "callback_packing_test.c")); err != nil { | |
| 388 | 388 | t.Fatal(err) | |
| 389 | 389 | } | |
| 390 | 390 | defer os.Remove(libFileName) | |
| @@ -22,7 +22,7 @@ func TestCallGoFromSharedLib(t *testing.T) { | |||||
| 22 | libFileName := filepath.Join(t.TempDir(), "libcbtest.so") | 22 | libFileName := filepath.Join(t.TempDir(), "libcbtest.so") | ||
| 23 | t.Logf("Build %v", libFileName) | 23 | t.Logf("Build %v", libFileName) | ||
| 24 | 24 | ||||
| 25 | - | if err := buildSharedLib("CC", libFileName, filepath.Join("testdata", "libcbtest", "callback_test.c")); err != nil { | 25 | + | if err := buildSharedLib(t, "CC", libFileName, filepath.Join("testdata", "libcbtest", "callback_test.c")); err != nil { |
| 26 | t.Fatal(err) | 26 | t.Fatal(err) | ||
| 27 | } | 27 | } | ||
| 28 | defer os.Remove(libFileName) | 28 | defer os.Remove(libFileName) | ||
| @@ -186,7 +186,7 @@ func TestCallbackInt32Packing(t *testing.T) { | |||||
| 186 | } | 186 | } | ||
| 187 | 187 | ||||
| 188 | libFileName := filepath.Join(t.TempDir(), "libcbtest_packing.so") | 188 | libFileName := filepath.Join(t.TempDir(), "libcbtest_packing.so") | ||
| 189 | - | if err := buildSharedLib("CC", libFileName, filepath.Join("testdata", "libcbtest", "callback_packing_test.c")); err != nil { | 189 | + | if err := buildSharedLib(t, "CC", libFileName, filepath.Join("testdata", "libcbtest", "callback_packing_test.c")); err != nil { |
| 190 | t.Fatal(err) | 190 | t.Fatal(err) | ||
| 191 | } | 191 | } | ||
| 192 | defer os.Remove(libFileName) | 192 | defer os.Remove(libFileName) | ||
| @@ -218,7 +218,7 @@ func TestCallbackMixedStackPacking(t *testing.T) { | |||||
| 218 | } | 218 | } | ||
| 219 | 219 | ||||
| 220 | libFileName := filepath.Join(t.TempDir(), "libcbtest_packing.so") | 220 | libFileName := filepath.Join(t.TempDir(), "libcbtest_packing.so") | ||
| 221 | - | if err := buildSharedLib("CC", libFileName, filepath.Join("testdata", "libcbtest", "callback_packing_test.c")); err != nil { | 221 | + | if err := buildSharedLib(t, "CC", libFileName, filepath.Join("testdata", "libcbtest", "callback_packing_test.c")); err != nil { |
| 222 | t.Fatal(err) | 222 | t.Fatal(err) | ||
| 223 | } | 223 | } | ||
| 224 | defer os.Remove(libFileName) | 224 | defer os.Remove(libFileName) | ||
| @@ -251,7 +251,7 @@ func TestCallbackSmallTypesPacking(t *testing.T) { | |||||
| 251 | } | 251 | } | ||
| 252 | 252 | ||||
| 253 | libFileName := filepath.Join(t.TempDir(), "libcbtest_packing.so") | 253 | libFileName := filepath.Join(t.TempDir(), "libcbtest_packing.so") | ||
| 254 | - | if err := buildSharedLib("CC", libFileName, filepath.Join("testdata", "libcbtest", "callback_packing_test.c")); err != nil { | 254 | + | if err := buildSharedLib(t, "CC", libFileName, filepath.Join("testdata", "libcbtest", "callback_packing_test.c")); err != nil { |
| 255 | t.Fatal(err) | 255 | t.Fatal(err) | ||
| 256 | } | 256 | } | ||
| 257 | defer os.Remove(libFileName) | 257 | defer os.Remove(libFileName) | ||
| @@ -319,7 +319,7 @@ func TestCallback10Int32Packing(t *testing.T) { | |||||
| 319 | } | 319 | } | ||
| 320 | 320 | ||||
| 321 | libFileName := filepath.Join(t.TempDir(), "libcbtest_packing.so") | 321 | libFileName := filepath.Join(t.TempDir(), "libcbtest_packing.so") | ||
| 322 | - | if err := buildSharedLib("CC", libFileName, filepath.Join("testdata", "libcbtest", "callback_packing_test.c")); err != nil { | 322 | + | if err := buildSharedLib(t, "CC", libFileName, filepath.Join("testdata", "libcbtest", "callback_packing_test.c")); err != nil { |
| 323 | t.Fatal(err) | 323 | t.Fatal(err) | ||
| 324 | } | 324 | } | ||
| 325 | defer os.Remove(libFileName) | 325 | defer os.Remove(libFileName) | ||
| @@ -350,7 +350,7 @@ func TestCallbackFloat64StackPacking(t *testing.T) { | |||||
| 350 | } | 350 | } | ||
| 351 | 351 | ||||
| 352 | libFileName := filepath.Join(t.TempDir(), "libcbtest_packing.so") | 352 | libFileName := filepath.Join(t.TempDir(), "libcbtest_packing.so") | ||
| 353 | - | if err := buildSharedLib("CC", libFileName, filepath.Join("testdata", "libcbtest", "callback_packing_test.c")); err != nil { | 353 | + | if err := buildSharedLib(t, "CC", libFileName, filepath.Join("testdata", "libcbtest", "callback_packing_test.c")); err != nil { |
| 354 | t.Fatal(err) | 354 | t.Fatal(err) | ||
| 355 | } | 355 | } | ||
| 356 | defer os.Remove(libFileName) | 356 | defer os.Remove(libFileName) | ||
| @@ -384,7 +384,7 @@ func TestCallbackFloat32StackPacking(t *testing.T) { | |||||
| 384 | } | 384 | } | ||
| 385 | 385 | ||||
| 386 | libFileName := filepath.Join(t.TempDir(), "libcbtest_packing.so") | 386 | libFileName := filepath.Join(t.TempDir(), "libcbtest_packing.so") | ||
| 387 | - | if err := buildSharedLib("CC", libFileName, filepath.Join("testdata", "libcbtest", "callback_packing_test.c")); err != nil { | 387 | + | if err := buildSharedLib(t, "CC", libFileName, filepath.Join("testdata", "libcbtest", "callback_packing_test.c")); err != nil { |
| 388 | t.Fatal(err) | 388 | t.Fatal(err) | ||
| 389 | } | 389 | } | ||
| 390 | defer os.Remove(libFileName) | 390 | defer os.Remove(libFileName) | ||
M dlfcn_test.go +1 -1
| @@ -24,7 +24,7 @@ func TestNestedDlopenCall(t *testing.T) { | |||
| 24 | 24 | libFileName := filepath.Join(t.TempDir(), "libdlnested.so") | |
| 25 | 25 | t.Logf("Build %v", libFileName) | |
| 26 | 26 | ||
| 27 | - | if err := buildSharedLib("CXX", libFileName, filepath.Join("testdata", "libdlnested", "nested_test.cpp")); err != nil { | |
| 27 | + | if err := buildSharedLib(t, "CXX", libFileName, filepath.Join("testdata", "libdlnested", "nested_test.cpp")); err != nil { | |
| 28 | 28 | t.Fatal(err) | |
| 29 | 29 | } | |
| 30 | 30 | defer os.Remove(libFileName) | |
| @@ -24,7 +24,7 @@ func TestNestedDlopenCall(t *testing.T) { | |||||
| 24 | libFileName := filepath.Join(t.TempDir(), "libdlnested.so") | 24 | libFileName := filepath.Join(t.TempDir(), "libdlnested.so") | ||
| 25 | t.Logf("Build %v", libFileName) | 25 | t.Logf("Build %v", libFileName) | ||
| 26 | 26 | ||||
| 27 | - | if err := buildSharedLib("CXX", libFileName, filepath.Join("testdata", "libdlnested", "nested_test.cpp")); err != nil { | 27 | + | if err := buildSharedLib(t, "CXX", libFileName, filepath.Join("testdata", "libdlnested", "nested_test.cpp")); err != nil { |
| 28 | t.Fatal(err) | 28 | t.Fatal(err) | ||
| 29 | } | 29 | } | ||
| 30 | defer os.Remove(libFileName) | 30 | defer os.Remove(libFileName) | ||
M func_test.go +16 -9
| @@ -178,13 +178,10 @@ func TestRegisterLibFunc_Bool(t *testing.T) { | |||
| 178 | 178 | } | |
| 179 | 179 | ||
| 180 | 180 | func TestABI(t *testing.T) { | |
| 181 | - | if runtime.GOOS == "windows" && runtime.GOARCH == "386" { | |
| 182 | - | t.Skip("need a 32bit gcc to run this test") // TODO: find 32bit gcc for test | |
| 183 | - | } | |
| 184 | 181 | libFileName := filepath.Join(t.TempDir(), "abitest.so") | |
| 185 | 182 | t.Logf("Build %v", libFileName) | |
| 186 | 183 | ||
| 187 | - | if err := buildSharedLib("CC", libFileName, filepath.Join("testdata", "abitest", "abi_test.c")); err != nil { | |
| 184 | + | if err := buildSharedLib(t, "CC", libFileName, filepath.Join("testdata", "abitest", "abi_test.c")); err != nil { | |
| 188 | 185 | t.Fatal(err) | |
| 189 | 186 | } | |
| 190 | 187 | ||
| @@ -242,11 +239,8 @@ func TestABI(t *testing.T) { | |||
| 242 | 239 | } | |
| 243 | 240 | ||
| 244 | 241 | func TestABI_ArgumentPassing(t *testing.T) { | |
| 245 | - | if runtime.GOOS == "windows" && runtime.GOARCH == "386" { | |
| 246 | - | t.Skip("need a 32bit gcc to run this test") // TODO: find 32bit gcc for test | |
| 247 | - | } | |
| 248 | 242 | libFileName := filepath.Join(t.TempDir(), "abitest.so") | |
| 249 | - | if err := buildSharedLib("CC", libFileName, filepath.Join("testdata", "abitest", "abi_test.c")); err != nil { | |
| 243 | + | if err := buildSharedLib(t, "CC", libFileName, filepath.Join("testdata", "abitest", "abi_test.c")); err != nil { | |
| 250 | 244 | t.Fatal(err) | |
| 251 | 245 | } | |
| 252 | 246 | lib, err := load.OpenLibrary(libFileName) | |
| @@ -603,7 +597,8 @@ func TestABI_TooManyArguments(t *testing.T) { | |||
| 603 | 597 | }) | |
| 604 | 598 | } | |
| 605 | 599 | ||
| 606 | - | func buildSharedLib(compilerEnv, libFile string, sources ...string) error { | |
| 600 | + | func buildSharedLib(tb testing.TB, compilerEnv, libFile string, sources ...string) error { | |
| 601 | + | tb.Helper() | |
| 607 | 602 | // When PUREGO_TEST_PREBUILT_LIBDIR is set, the shared library has been | |
| 608 | 603 | // cross-compiled ahead of time and placed in that directory under the | |
| 609 | 604 | // base name of libFile. This allows running the tests on a target that | |
| @@ -619,6 +614,18 @@ func buildSharedLib(compilerEnv, libFile string, sources ...string) error { | |||
| 619 | 614 | return nil | |
| 620 | 615 | } | |
| 621 | 616 | ||
| 617 | + | // Compiling the library needs a C toolchain targeting GOARCH. CI has none | |
| 618 | + | // for Windows on 386 or arm64, so skip those (the prebuilt path above | |
| 619 | + | // avoids the toolchain). | |
| 620 | + | if runtime.GOOS == "windows" { | |
| 621 | + | switch runtime.GOARCH { | |
| 622 | + | case "386": | |
| 623 | + | tb.Skip("need a 386 C toolchain to run this test") // TODO: find a 386 C toolchain for test | |
| 624 | + | case "arm64": | |
| 625 | + | tb.Skip("need an arm64 C toolchain to run this test") | |
| 626 | + | } | |
| 627 | + | } | |
| 628 | + | ||
| 622 | 629 | out, err := exec.Command("go", "env", compilerEnv).Output() | |
| 623 | 630 | if err != nil { | |
| 624 | 631 | return fmt.Errorf("go env %s error: %w", compilerEnv, err) | |
| @@ -178,13 +178,10 @@ func TestRegisterLibFunc_Bool(t *testing.T) { | |||||
| 178 | } | 178 | } | ||
| 179 | 179 | ||||
| 180 | func TestABI(t *testing.T) { | 180 | func TestABI(t *testing.T) { | ||
| 181 | - | if runtime.GOOS == "windows" && runtime.GOARCH == "386" { | |||
| 182 | - | t.Skip("need a 32bit gcc to run this test") // TODO: find 32bit gcc for test | |||
| 183 | - | } | |||
| 184 | libFileName := filepath.Join(t.TempDir(), "abitest.so") | 181 | libFileName := filepath.Join(t.TempDir(), "abitest.so") | ||
| 185 | t.Logf("Build %v", libFileName) | 182 | t.Logf("Build %v", libFileName) | ||
| 186 | 183 | ||||
| 187 | - | if err := buildSharedLib("CC", libFileName, filepath.Join("testdata", "abitest", "abi_test.c")); err != nil { | 184 | + | if err := buildSharedLib(t, "CC", libFileName, filepath.Join("testdata", "abitest", "abi_test.c")); err != nil { |
| 188 | t.Fatal(err) | 185 | t.Fatal(err) | ||
| 189 | } | 186 | } | ||
| 190 | 187 | ||||
| @@ -242,11 +239,8 @@ func TestABI(t *testing.T) { | |||||
| 242 | } | 239 | } | ||
| 243 | 240 | ||||
| 244 | func TestABI_ArgumentPassing(t *testing.T) { | 241 | func TestABI_ArgumentPassing(t *testing.T) { | ||
| 245 | - | if runtime.GOOS == "windows" && runtime.GOARCH == "386" { | |||
| 246 | - | t.Skip("need a 32bit gcc to run this test") // TODO: find 32bit gcc for test | |||
| 247 | - | } | |||
| 248 | libFileName := filepath.Join(t.TempDir(), "abitest.so") | 242 | libFileName := filepath.Join(t.TempDir(), "abitest.so") | ||
| 249 | - | if err := buildSharedLib("CC", libFileName, filepath.Join("testdata", "abitest", "abi_test.c")); err != nil { | 243 | + | if err := buildSharedLib(t, "CC", libFileName, filepath.Join("testdata", "abitest", "abi_test.c")); err != nil { |
| 250 | t.Fatal(err) | 244 | t.Fatal(err) | ||
| 251 | } | 245 | } | ||
| 252 | lib, err := load.OpenLibrary(libFileName) | 246 | lib, err := load.OpenLibrary(libFileName) | ||
| @@ -603,7 +597,8 @@ func TestABI_TooManyArguments(t *testing.T) { | |||||
| 603 | }) | 597 | }) | ||
| 604 | } | 598 | } | ||
| 605 | 599 | ||||
| 606 | - | func buildSharedLib(compilerEnv, libFile string, sources ...string) error { | 600 | + | func buildSharedLib(tb testing.TB, compilerEnv, libFile string, sources ...string) error { |
| 601 | + | tb.Helper() | |||
| 607 | // When PUREGO_TEST_PREBUILT_LIBDIR is set, the shared library has been | 602 | // When PUREGO_TEST_PREBUILT_LIBDIR is set, the shared library has been | ||
| 608 | // cross-compiled ahead of time and placed in that directory under the | 603 | // cross-compiled ahead of time and placed in that directory under the | ||
| 609 | // base name of libFile. This allows running the tests on a target that | 604 | // base name of libFile. This allows running the tests on a target that | ||
| @@ -619,6 +614,18 @@ func buildSharedLib(compilerEnv, libFile string, sources ...string) error { | |||||
| 619 | return nil | 614 | return nil | ||
| 620 | } | 615 | } | ||
| 621 | 616 | ||||
| 617 | + | // Compiling the library needs a C toolchain targeting GOARCH. CI has none | |||
| 618 | + | // for Windows on 386 or arm64, so skip those (the prebuilt path above | |||
| 619 | + | // avoids the toolchain). | |||
| 620 | + | if runtime.GOOS == "windows" { | |||
| 621 | + | switch runtime.GOARCH { | |||
| 622 | + | case "386": | |||
| 623 | + | tb.Skip("need a 386 C toolchain to run this test") // TODO: find a 386 C toolchain for test | |||
| 624 | + | case "arm64": | |||
| 625 | + | tb.Skip("need an arm64 C toolchain to run this test") | |||
| 626 | + | } | |||
| 627 | + | } | |||
| 628 | + | ||||
| 622 | out, err := exec.Command("go", "env", compilerEnv).Output() | 629 | out, err := exec.Command("go", "env", compilerEnv).Output() | ||
| 623 | if err != nil { | 630 | if err != nil { | ||
| 624 | return fmt.Errorf("go env %s error: %w", compilerEnv, err) | 631 | return fmt.Errorf("go env %s error: %w", compilerEnv, err) | ||
M struct_test.go +2 -2
| @@ -24,7 +24,7 @@ func TestRegisterFunc_structArgs(t *testing.T) { | |||
| 24 | 24 | libFileName := filepath.Join(t.TempDir(), "structtest.so") | |
| 25 | 25 | t.Logf("Build %v", libFileName) | |
| 26 | 26 | ||
| 27 | - | if err := buildSharedLib("CC", libFileName, filepath.Join("testdata", "structtest", "struct_test.c")); err != nil { | |
| 27 | + | if err := buildSharedLib(t, "CC", libFileName, filepath.Join("testdata", "structtest", "struct_test.c")); err != nil { | |
| 28 | 28 | t.Fatal(err) | |
| 29 | 29 | } | |
| 30 | 30 | defer os.Remove(libFileName) | |
| @@ -859,7 +859,7 @@ func TestRegisterFunc_structReturns(t *testing.T) { | |||
| 859 | 859 | libFileName := filepath.Join(t.TempDir(), "structreturntest.so") | |
| 860 | 860 | t.Logf("Build %v", libFileName) | |
| 861 | 861 | ||
| 862 | - | if err := buildSharedLib("CC", libFileName, filepath.Join("testdata", "structtest", "structreturn_test.c")); err != nil { | |
| 862 | + | if err := buildSharedLib(t, "CC", libFileName, filepath.Join("testdata", "structtest", "structreturn_test.c")); err != nil { | |
| 863 | 863 | t.Fatal(err) | |
| 864 | 864 | } | |
| 865 | 865 | defer os.Remove(libFileName) | |
| @@ -24,7 +24,7 @@ func TestRegisterFunc_structArgs(t *testing.T) { | |||||
| 24 | libFileName := filepath.Join(t.TempDir(), "structtest.so") | 24 | libFileName := filepath.Join(t.TempDir(), "structtest.so") | ||
| 25 | t.Logf("Build %v", libFileName) | 25 | t.Logf("Build %v", libFileName) | ||
| 26 | 26 | ||||
| 27 | - | if err := buildSharedLib("CC", libFileName, filepath.Join("testdata", "structtest", "struct_test.c")); err != nil { | 27 | + | if err := buildSharedLib(t, "CC", libFileName, filepath.Join("testdata", "structtest", "struct_test.c")); err != nil { |
| 28 | t.Fatal(err) | 28 | t.Fatal(err) | ||
| 29 | } | 29 | } | ||
| 30 | defer os.Remove(libFileName) | 30 | defer os.Remove(libFileName) | ||
| @@ -859,7 +859,7 @@ func TestRegisterFunc_structReturns(t *testing.T) { | |||||
| 859 | libFileName := filepath.Join(t.TempDir(), "structreturntest.so") | 859 | libFileName := filepath.Join(t.TempDir(), "structreturntest.so") | ||
| 860 | t.Logf("Build %v", libFileName) | 860 | t.Logf("Build %v", libFileName) | ||
| 861 | 861 | ||||
| 862 | - | if err := buildSharedLib("CC", libFileName, filepath.Join("testdata", "structtest", "structreturn_test.c")); err != nil { | 862 | + | if err := buildSharedLib(t, "CC", libFileName, filepath.Join("testdata", "structtest", "structreturn_test.c")); err != nil { |
| 863 | t.Fatal(err) | 863 | t.Fatal(err) | ||
| 864 | } | 864 | } | ||
| 865 | defer os.Remove(libFileName) | 865 | defer os.Remove(libFileName) | ||
M syscall_bench_test.go +1 -1
| @@ -37,7 +37,7 @@ func BenchmarkCallingMethods(b *testing.B) { | |||
| 37 | 37 | ||
| 38 | 38 | // Build C library for benchmarking | |
| 39 | 39 | libFileName := filepath.Join(b.TempDir(), "libbenchmark.so") | |
| 40 | - | if err := buildSharedLib("CC", libFileName, filepath.Join("testdata", "benchmarktest", "benchmark.c")); err != nil { | |
| 40 | + | if err := buildSharedLib(b, "CC", libFileName, filepath.Join("testdata", "benchmarktest", "benchmark.c")); err != nil { | |
| 41 | 41 | b.Fatalf("Failed to build C library: %v", err) | |
| 42 | 42 | } | |
| 43 | 43 | b.Cleanup(func() { | |
| @@ -37,7 +37,7 @@ func BenchmarkCallingMethods(b *testing.B) { | |||||
| 37 | 37 | ||||
| 38 | // Build C library for benchmarking | 38 | // Build C library for benchmarking | ||
| 39 | libFileName := filepath.Join(b.TempDir(), "libbenchmark.so") | 39 | libFileName := filepath.Join(b.TempDir(), "libbenchmark.so") | ||
| 40 | - | if err := buildSharedLib("CC", libFileName, filepath.Join("testdata", "benchmarktest", "benchmark.c")); err != nil { | 40 | + | if err := buildSharedLib(b, "CC", libFileName, filepath.Join("testdata", "benchmarktest", "benchmark.c")); err != nil { |
| 41 | b.Fatalf("Failed to build C library: %v", err) | 41 | b.Fatalf("Failed to build C library: %v", err) | ||
| 42 | } | 42 | } | ||
| 43 | b.Cleanup(func() { | 43 | b.Cleanup(func() { | ||
M syscall_linux_test.go +1 -1
| @@ -173,7 +173,7 @@ func compareStatus(filter, expect string) error { | |||
| 173 | 173 | func TestDlopenThenAllThreadsSyscall(t *testing.T) { | |
| 174 | 174 | // Step 1: Build and load a shared C library that calls back into Go. | |
| 175 | 175 | libFileName := filepath.Join(t.TempDir(), "libcbtest.so") | |
| 176 | - | if err := buildSharedLib("CC", libFileName, filepath.Join("testdata", "libcbtest", "callback_test.c")); err != nil { | |
| 176 | + | if err := buildSharedLib(t, "CC", libFileName, filepath.Join("testdata", "libcbtest", "callback_test.c")); err != nil { | |
| 177 | 177 | t.Fatal(err) | |
| 178 | 178 | } | |
| 179 | 179 | defer os.Remove(libFileName) | |
| @@ -173,7 +173,7 @@ func compareStatus(filter, expect string) error { | |||||
| 173 | func TestDlopenThenAllThreadsSyscall(t *testing.T) { | 173 | func TestDlopenThenAllThreadsSyscall(t *testing.T) { | ||
| 174 | // Step 1: Build and load a shared C library that calls back into Go. | 174 | // Step 1: Build and load a shared C library that calls back into Go. | ||
| 175 | libFileName := filepath.Join(t.TempDir(), "libcbtest.so") | 175 | libFileName := filepath.Join(t.TempDir(), "libcbtest.so") | ||
| 176 | - | if err := buildSharedLib("CC", libFileName, filepath.Join("testdata", "libcbtest", "callback_test.c")); err != nil { | 176 | + | if err := buildSharedLib(t, "CC", libFileName, filepath.Join("testdata", "libcbtest", "callback_test.c")); err != nil { |
| 177 | t.Fatal(err) | 177 | t.Fatal(err) | ||
| 178 | } | 178 | } | ||
| 179 | defer os.Remove(libFileName) | 179 | defer os.Remove(libFileName) | ||