v0.11.1 15800b5

test.yml RawHistoryFolder

1name: Test
2
3on: [push, pull_request]
4
5env:
6  QEMU_MAJOR_VERSION: "10"
7
8jobs:
9  test:
10    strategy:
11      matrix:
12        os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, windows-latest, windows-11-arm]
13        go: ['1.25.x', '1.26.x', '1.27.x']
14    name: Test with Go ${{ matrix.go }} on ${{ matrix.os }}
15    runs-on: ${{ matrix.os }}
16    defaults:
17      run:
18        shell: bash
19    steps:
20      - name: Git
21        run: |
22          # See actions/checkout#135
23          git config --global core.autocrlf false
24          git config --global core.eol lf
25
26      - name: Checkout
27        uses: actions/checkout@v5
28
29      - name: Setup Go
30        uses: actions/setup-go@v6
31        with:
32          go-version: ${{ matrix.go }}
33
34      - name: Set up Msys2
35        if: runner.os == 'Windows' && runner.arch != 'ARM64'
36        uses: msys2/setup-msys2@v2
37
38      - name: go vet
39        run: |
40          env CGO_ENABLED=0 go vet -v ./...
41
42      - name: gofmt
43        run: test -z "$(gofmt -s -l .)"
44
45      - name: go build
46        run: |
47          go build -v ./...
48          # Compile without optimization to check potential stack overflow.
49          # The option '-gcflags=all=-N -l' is often used at Visual Studio Code.
50          # See also https://go.googlesource.com/vscode-go/+/HEAD/docs/debugging.md#launch and the issue hajimehoshi/ebiten#2120.
51          go build "-gcflags=all=-N -l" -v ./...
52
53          # Check cross-compiling Windows binaries.
54          env GOOS=windows GOARCH=386 go build -v ./...
55          env GOOS=windows GOARCH=amd64 go build -v ./...
56          env GOOS=windows GOARCH=arm64 go build -v ./...
57
58          # Check cross-compiling macOS binaries.
59          env GOOS=darwin GOARCH=amd64 go build -v ./...
60          env GOOS=darwin GOARCH=arm64 go build -v ./...
61
62          # Check cross-compiling Linux binaries.
63          env GOOS=linux GOARCH=amd64 go build -v ./...
64          env GOOS=linux GOARCH=arm64 go build -v ./...
65
66          # Check cross-compiling FreeBSD binaries.
67          # gcflags -std is necessary to make fakecgo the Cgo for
68          # FreeBSD to add the symbols that libc.so depends on.
69          env GOOS=freebsd GOARCH=amd64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./...
70          env GOOS=freebsd GOARCH=arm64 go build -gcflags="github.com/ebitengine/purego/internal/fakecgo=-std" -v ./...          
71          
72          # Check cross-compiling NetBSD binaries.
73          env GOOS=netbsd GOARCH=amd64 go build -v ./...
74          env GOOS=netbsd GOARCH=arm64 go build -v ./...
75
76      - name: go build (Linux minor architectures)
77        # Test them only on the latest Go to reduce CI time.
78        if: startsWith(matrix.go, '1.27.')
79        run: |
80          # Check cross-compiling Linux binaries for minor architectures.
81          env GOOS=linux GOARCH=loong64 go build -v ./...
82          env GOOS=linux GOARCH=ppc64le go build -v ./...
83          env GOOS=linux GOARCH=riscv64 go build -v ./...
84          env GOOS=linux GOARCH=s390x go build -v ./...
85
86      - name: go build (Linux mips, Cgo)
87        # mips builds only via the Cgo fallback (CGO_ENABLED=1). See #460.
88        if: runner.os == 'Linux'
89        run: |
90          sudo apt-get update
91          sudo apt-get install -y gcc-mips-linux-gnu
92          env GOOS=linux GOARCH=mips CGO_ENABLED=1 CC=mips-linux-gnu-gcc go build -v ./...
93
94      - name: go build (plugin)
95        if: runner.os == 'Linux' || runner.os == 'macOS'
96        run:
97          # Make sure that plugin buildmode works since we save the R15 register (#254)
98          go build -buildmode=plugin ./examples/libc
99
100      - name: go mod vendor
101        if: runner.os != 'Linux'
102        run: |
103          mkdir /tmp/vendoring
104          cd /tmp/vendoring
105          go mod init foo
106          echo 'package main' > main.go
107          echo 'import (' >> main.go
108          echo '  _ "github.com/ebitengine/purego"' >> main.go
109          echo ')' >> main.go
110          echo 'func main() {}' >> main.go
111          go mod edit -replace github.com/ebitengine/purego=$GITHUB_WORKSPACE
112          go mod tidy
113          go mod vendor
114          go build -v .
115
116      - name: go test
117        run: |
118          env CGO_ENABLED=0 go test -shuffle=on -v -count=10 ./...
119          env CGO_ENABLED=1 go test -shuffle=on -v -count=10 ./...
120          # Compile without optimization to check potential stack overflow.
121          # The option '-gcflags=all=-N -l' is often used at Visual Studio Code.
122          # See also https://go.googlesource.com/vscode-go/+/HEAD/docs/debugging.md#launch.
123          env CGO_ENABLED=0 go test "-gcflags=all=-N -l" -v ./...
124          env CGO_ENABLED=1 go test "-gcflags=all=-N -l" -v ./...
125
126      - name: go test (Windows 386)
127        if: runner.os == 'Windows'
128        run: |
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: |
134          env CGO_ENABLED=1 GOARCH=386 go test -shuffle=on -v -count=10 ./...
135
136      - name: go test (Linux 386)
137        if: ${{ runner.os == 'Linux' && runner.arch != 'ARM64' }}
138        run: |
139          sudo apt-get update
140          sudo apt-get install gcc-multilib
141          sudo apt-get install g++-multilib
142          env CGO_ENABLED=0 GOARCH=386 go test -shuffle=on -v -count=10 ./...
143          env CGO_ENABLED=1 GOARCH=386 go test -shuffle=on -v -count=10 ./...
144      
145      - name: go test (Linux arm)
146        if: ${{ runner.os == 'Linux' && runner.arch == 'ARM64' }}
147        run: |
148          sudo apt-get update
149          sudo apt-get install -y \
150            gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf libc6-armhf-cross \
151            gcc-arm-linux-gnueabi g++-arm-linux-gnueabi libc6-armel-cross
152
153          # Install the latest QEMU 10.x package from Debian. Ubuntu 24.04 ships QEMU 8.2
154          # which has a bug where inter-thread signal delivery (tgkill) hangs,
155          # causing TestSetuidEtc to deadlock.
156          arch=$(dpkg --print-architecture)
157          qemu_user_deb=$(
158            curl -fsSL https://ftp.debian.org/debian/pool/main/q/qemu/ |
159              grep -Eo "qemu-user_${QEMU_MAJOR_VERSION}\.[0-9.]+\+ds-[0-9]+([+~][A-Za-z0-9.+:~-]+)*_${arch}\.deb" |
160              sort -V |
161              tail -n 1
162          )
163          if [ -z "${qemu_user_deb}" ]; then
164            echo "missing qemu-user ${QEMU_MAJOR_VERSION}.x package for ${arch}" >&2
165            exit 1
166          fi
167          wget -q "https://ftp.debian.org/debian/pool/main/q/qemu/${qemu_user_deb}" -O /tmp/qemu-user.deb
168          sudo dpkg --force-depends -i /tmp/qemu-user.deb
169          sudo apt-get -f install -y
170
171          # Create symlink for the dynamic linker that QEMU expects
172          sudo ln -sf /usr/arm-linux-gnueabihf/lib/ld-linux-armhf.so.3 /lib/ld-linux.so.3
173          go env -w CC=arm-linux-gnueabihf-gcc
174          go env -w CXX=arm-linux-gnueabihf-g++
175          env GOOS=linux GOARCH=arm CGO_ENABLED=0 go test -c -o=purego-test-nocgo .
176          env QEMU_LD_PREFIX=/usr/arm-linux-gnueabihf qemu-arm ./purego-test-nocgo -test.shuffle=on -test.v -test.count=10
177          env GOOS=linux GOARCH=arm CGO_ENABLED=1 go test -c -o=purego-test-cgo .
178          env QEMU_LD_PREFIX=/usr/arm-linux-gnueabihf qemu-arm ./purego-test-cgo -test.shuffle=on -test.v -test.count=10
179          go env -u CC
180          go env -u CXX
181
182          # Repeat the same for ARMv5 target (soft-float)
183          sudo ln -sf /usr/arm-linux-gnueabi/lib/ld-linux.so.3 /lib/ld-linux.so.3
184          go env -w CC=arm-linux-gnueabi-gcc
185          go env -w CXX=arm-linux-gnueabi-g++
186          env GOOS=linux GOARCH=arm GOARM=5 CGO_ENABLED=0 go test -c -o=purego-test-nocgo .
187          env QEMU_LD_PREFIX=/usr/arm-linux-gnueabi qemu-arm ./purego-test-nocgo -test.shuffle=on -test.v -test.count=10
188          env GOOS=linux GOARCH=arm GOARM=5 CGO_ENABLED=1 go test -c -o=purego-test-cgo .
189          env QEMU_LD_PREFIX=/usr/arm-linux-gnueabi qemu-arm ./purego-test-cgo -test.shuffle=on -test.v -test.count=10
190          go env -u CC
191          go env -u CXX
192
193      - name: go test race (no Cgo)
194        if: runner.os == 'macOS'
195        run: |
196          # -race usually requires Cgo, but macOS is an exception. See https://go.dev/doc/articles/race_detector#Requirements
197          env CGO_ENABLED=0 go test -race -shuffle=on -v -count=10 ./...
198
199      - name: go test race (Cgo)
200        if: ${{ !(runner.os == 'Windows' && runner.arch == 'ARM64') }}
201        run: |
202          env CGO_ENABLED=1 go test -race -shuffle=on -v -count=10 ./...
203
204  minor-arches:
205    strategy:
206      matrix:
207        go: ['1.25.x', '1.26.x', '1.27.x']
208    name: Test with Go ${{ matrix.go }} on Linux minor architectures
209    runs-on: ubuntu-latest
210    defaults:
211      run:
212        shell: bash
213    steps:
214      - name: Checkout
215        uses: actions/checkout@v5
216
217      - name: Setup Go
218        uses: actions/setup-go@v6
219        with:
220          go-version: ${{ matrix.go }}
221
222      - name: Set up the prerequisites
223        run: |
224          sudo apt-get update
225          sudo apt-get install -y \
226            gcc-14-loongarch64-linux-gnu g++-14-loongarch64-linux-gnu \
227            gcc-powerpc64le-linux-gnu g++-powerpc64le-linux-gnu \
228            gcc-riscv64-linux-gnu g++-riscv64-linux-gnu \
229            gcc-s390x-linux-gnu g++-s390x-linux-gnu
230
231          # Install the latest QEMU 10.x package from Debian. Ubuntu 24.04 ships QEMU 8.2
232          # which has a bug where inter-thread signal delivery (tgkill) hangs,
233          # causing TestSetuidEtc to deadlock.
234          arch=$(dpkg --print-architecture)
235          qemu_user_deb=$(
236            curl -fsSL https://ftp.debian.org/debian/pool/main/q/qemu/ |
237              grep -Eo "qemu-user_${QEMU_MAJOR_VERSION}\.[0-9.]+\+ds-[0-9]+([+~][A-Za-z0-9.+:~-]+)*_${arch}\.deb" |
238              sort -V |
239              tail -n 1
240          )
241          if [ -z "${qemu_user_deb}" ]; then
242            echo "missing qemu-user ${QEMU_MAJOR_VERSION}.x package for ${arch}" >&2
243            exit 1
244          fi
245          wget -q "https://ftp.debian.org/debian/pool/main/q/qemu/${qemu_user_deb}" -O /tmp/qemu-user.deb
246          sudo dpkg --force-depends -i /tmp/qemu-user.deb
247          sudo apt-get -f install -y
248
249          # Verify that the expected QEMU binaries are installed and usable.
250          qemu-loongarch64 --version
251          qemu-ppc64le --version
252          qemu-riscv64 --version
253          qemu-s390x --version
254
255      - name: go test (Linux loong64)
256        run: |
257          go env -w CC=loongarch64-linux-gnu-gcc-14
258          go env -w CXX=loongarch64-linux-gnu-g++-14
259          env GOOS=linux GOARCH=loong64 CGO_ENABLED=0 go test -c -o=purego-test-nocgo .
260          env QEMU_LD_PREFIX=/usr/loongarch64-linux-gnu qemu-loongarch64 ./purego-test-nocgo -test.shuffle=on -test.v -test.count=10
261          env GOOS=linux GOARCH=loong64 CGO_ENABLED=1 go test -c -o=purego-test-cgo .
262          env QEMU_LD_PREFIX=/usr/loongarch64-linux-gnu qemu-loongarch64 ./purego-test-cgo -test.shuffle=on -test.v -test.count=10
263          go env -u CC
264          go env -u CXX
265
266      - name: go test (Linux ppc64le)
267        run: |
268          go env -w CC=powerpc64le-linux-gnu-gcc
269          go env -w CXX=powerpc64le-linux-gnu-g++
270          env GOOS=linux GOARCH=ppc64le CGO_ENABLED=0 go test -c -o=purego-test-nocgo .
271          env QEMU_LD_PREFIX=/usr/powerpc64le-linux-gnu qemu-ppc64le ./purego-test-nocgo -test.shuffle=on -test.v -test.count=10
272          env GOOS=linux GOARCH=ppc64le CGO_ENABLED=1 go test -c -o=purego-test-cgo .
273          env QEMU_LD_PREFIX=/usr/powerpc64le-linux-gnu qemu-ppc64le ./purego-test-cgo -test.shuffle=on -test.v -test.count=10
274          go env -u CC
275          go env -u CXX
276
277      - name: go test (Linux riscv64)
278        run: |
279          go env -w CC=riscv64-linux-gnu-gcc
280          go env -w CXX=riscv64-linux-gnu-g++
281          # Create symlink for the dynamic linker that QEMU expects
282          sudo ln -sf /usr/riscv64-linux-gnu/lib/ld-linux-riscv64-lp64d.so.1 /lib/ld.so.1
283          env GOOS=linux GOARCH=riscv64 CGO_ENABLED=0 go test -c -o=purego-test-nocgo .
284          env QEMU_LD_PREFIX=/usr/riscv64-linux-gnu qemu-riscv64 ./purego-test-nocgo -test.shuffle=on -test.v -test.count=10
285          env GOOS=linux GOARCH=riscv64 CGO_ENABLED=1 go test -c -o=purego-test-cgo .
286          env QEMU_LD_PREFIX=/usr/riscv64-linux-gnu qemu-riscv64 ./purego-test-cgo -test.shuffle=on -test.v -test.count=10
287          go env -u CC
288          go env -u CXX
289
290      - name: go test (Linux s390x)
291        run: |
292          go env -w CC=s390x-linux-gnu-gcc
293          go env -w CXX=s390x-linux-gnu-g++
294          # CGO_ENABLED=0 is only supported on Go 1.27+ for s390x.
295          if [[ "${{ matrix.go }}" != 1.25.* && "${{ matrix.go }}" != 1.26.* ]]; then
296            env GOOS=linux GOARCH=s390x CGO_ENABLED=0 go test -c -o=purego-test-nocgo .
297            env QEMU_LD_PREFIX=/usr/s390x-linux-gnu qemu-s390x ./purego-test-nocgo -test.shuffle=on -test.v -test.count=10
298          fi
299          env GOOS=linux GOARCH=s390x CGO_ENABLED=1 go test -c -o=purego-test-cgo .
300          env QEMU_LD_PREFIX=/usr/s390x-linux-gnu qemu-s390x ./purego-test-cgo -test.shuffle=on -test.v -test.count=10
301          go env -u CC
302          go env -u CXX
303
304  bsd:
305    strategy:
306      matrix:
307        os: ['FreeBSD', 'NetBSD']
308        go: ['1.25.8', '1.26.1']
309    name: Test with Go ${{ matrix.go }} on ${{ matrix.os }}
310    runs-on: ubuntu-22.04
311    defaults:
312      run:
313        shell: bash
314    steps:
315      - uses: actions/checkout@v5
316      - name: Run in FreeBSD
317        if: matrix.os == 'FreeBSD'
318        uses: vmactions/freebsd-vm@v1
319        with:
320          usesh: true
321          prepare: |
322            fetch https://go.dev/dl/go${{matrix.go}}.freebsd-amd64.tar.gz
323            rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.freebsd-amd64.tar.gz
324            chmod +x $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh
325          run: $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh
326      - name: Run in NetBSD
327        if: matrix.os == 'NetBSD'
328        uses: vmactions/netbsd-vm@v1
329        with:
330          usesh: true
331          prepare: |
332            ftp https://go.dev/dl/go${{matrix.go}}.netbsd-amd64.tar.gz
333            mkdir /usr/local
334            rm -fr /usr/local/go && tar -C /usr/local -xf go${{matrix.go}}.netbsd-amd64.tar.gz
335            chmod +x $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh
336          run: $GITHUB_WORKSPACE/.github/scripts/bsd_tests.sh
337
338  # Android is tested on amd64 only. The emulator requires the system image
339  # architecture to match the host, and GitHub's arm64 hosted runners do not
340  # provide a usable KVM device, so there is no hosted hardware-accelerated path
341  # to an Android arm64 emulator. The arm64 struct ABI is already covered by the
342  # linux/arm64 `test` job, and Android's Bionic/cgo integration by this job.
343  android:
344    strategy:
345      fail-fast: false
346      matrix:
347        go: ['1.25.x', '1.26.x', '1.27.x']
348    name: Test with Go ${{ matrix.go }} on Android amd64
349    runs-on: ubuntu-latest
350    defaults:
351      run:
352        shell: bash
353    steps:
354      - uses: actions/checkout@v5
355
356      - name: Setup Go
357        uses: actions/setup-go@v6
358        with:
359          go-version: ${{ matrix.go }}
360
361      # The tests compile their C libraries at run time via `go env CC`, but the
362      # emulator has no C toolchain. Every library the tests load must therefore be
363      # cross-compiled here and loaded as a prebuilt library at run time instead.
364      - name: Cross-compile the test binary and C libraries
365        run: |
366          set -eux
367          NDK="$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin"
368          CC="$NDK/x86_64-linux-android21-clang"
369          mkdir -p prebuilt
370          # Build every library the tests load. Keep this in sync with the
371          # buildSharedLib callers in the tests; a missing entry surfaces as a
372          # "prebuilt lib ... no such file" failure on the emulator.
373          "$CC" -shared -Wall -Werror -fPIC -o prebuilt/structtest.so testdata/structtest/struct_test.c
374          "$CC" -shared -Wall -Werror -fPIC -o prebuilt/structreturntest.so testdata/structtest/structreturn_test.c
375          "$CC" -shared -Wall -Werror -fPIC -o prebuilt/libcbtest.so testdata/libcbtest/callback_test.c
376          "$CC" -shared -Wall -Werror -fPIC -o prebuilt/abitest.so testdata/abitest/abi_test.c
377          env GOOS=android GOARCH=amd64 CGO_ENABLED=1 CC="$CC" go test -c -o purego.test .
378
379      - name: Enable KVM
380        run: |
381          echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
382          sudo udevadm control --reload-rules
383          sudo udevadm trigger --name-match=kvm
384
385      - name: Run the test suite on the Android emulator
386        uses: reactivecircus/android-emulator-runner@v2
387        with:
388          api-level: 34
389          arch: x86_64
390          target: google_apis
391          emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim
392          script: |
393            set -eux
394            adb push purego.test /data/local/tmp/purego.test
395            adb push prebuilt /data/local/tmp/prebuilt
396            adb shell "chmod 755 /data/local/tmp/purego.test"
397            # TestSetuidEtc needs root and glibc (not Bionic) semantics; TestNestedDlopenCall
398            # needs the C++ runtime present on the device. Both are covered by the Linux
399            # runners, so skip them here rather than special-casing the emulator.
400            adb shell "cd /data/local/tmp && TMPDIR=/data/local/tmp PUREGO_TEST_PREBUILT_LIBDIR=/data/local/tmp/prebuilt ./purego.test -test.v -test.skip 'TestSetuidEtc|TestNestedDlopenCall'" | tee result.txt
401            grep -q '^PASS' result.txt
402            ! grep -q '^FAIL' result.txt
403
404  # TODO: Add an iOS job that runs the test suite on the iOS Simulator.
405  # iOS has no emulator runner equivalent: on a macOS runner the test binary must
406  # be wrapped into a .app and launched via `xcrun simctl` (or x/mobile's
407  # go_ios_exec), with the C libraries cross-compiled against the iphonesimulator
408  # SDK and loaded through PUREGO_TEST_PREBUILT_LIBDIR (as the android job does).
409  # Deprioritized because the iOS arm64 ABI matches macOS arm64, which the `test`
410  # job already runs.

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 102

↑↓ moveenter openesc close