Skip to content

Commit

Permalink
Add *BSD to CI. (#2338)
Browse files Browse the repository at this point in the history
Signed-off-by: Nuno Cruces <[email protected]>
  • Loading branch information
ncruces authored Nov 14, 2024
1 parent dc08732 commit c5e90c5
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 20 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,43 @@ jobs:
# This runs all tests compiled above in sequence. Note: This mounts /tmp to allow t.TempDir() in tests.
run: find . -name "*.test" | xargs -Itestbin docker run --platform linux/${{ matrix.arch }} -v $(pwd)/testbin:/test -v $(pwd)/wazerocli:/wazero -e WAZEROCLI=/wazero --tmpfs /tmp --rm -t wazero:test

test_bsd:
name: amd64, ${{ matrix.os.name }}
runs-on: ubuntu-22.04
strategy:
fail-fast: false # don't fail fast as sometimes failures are OS specific
matrix:
os:
- name: freebsd
version: "14.1"
- name: openbsd
version: "7.5"
- name: netbsd
version: "10.0"

steps:
- uses: actions/checkout@v3

- name: Build test binaries
run: |
go list -f '{{.Dir}}' ./... | egrep -v 'imports|sysfs' | xargs -Ipkg go test pkg -c -o pkg.test
go build -o wazerocli ./cmd/wazero
env:
GOOS: ${{ matrix.os.name }}

- name: Run built test binaries
uses: cross-platform-actions/[email protected]
env:
WAZEROCLI: ./wazerocli
with:
operating_system: ${{ matrix.os.name }}
version: ${{ matrix.os.version }}
shell: bash
sync_files: runner-to-vm
environment_variables: WAZEROCLI
# This runs all tests compiled above in sequence.
run: find . -name "*.test" | xargs -Itestbin nice testbin -test.short

# This ensures that internal/integration_test/fuzz is runnable, and is not intended to
# run full-length fuzzing while trying to find low-hanging frontend bugs.
fuzz:
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,11 @@ We currently test Linux (Ubuntu and scratch), MacOS and Windows as packaged by
* Interpreter
* Linux is tested on amd64 (native) as well arm64 and riscv64 via emulation.
* MacOS and Windows are only tested on amd64.
* FreeBSD, NetBSD and OpenBSD are only tested on amd64.
* Compiler
* Linux is tested on amd64 (native) as well arm64 via emulation.
* MacOS and Windows are only tested on amd64.
* FreeBSD is only tested on amd64.

wazero has no dependencies and doesn't require CGO. This means it can also be
embedded in an application that doesn't use an operating system. This is a main
Expand Down
19 changes: 0 additions & 19 deletions internal/sysfs/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1000,25 +1000,6 @@ func TestFileTruncate(t *testing.T) {
})
}

func TestFileUtimens(t *testing.T) {
switch runtime.GOOS {
case "linux", "darwin": // supported
case "freebsd": // TODO: support freebsd w/o CGO
case "windows":
default: // expect ENOSYS and callers need to fall back to Utimens
t.Skip("unsupported GOOS", runtime.GOOS)
}

testUtimens(t, true)

testEBADFIfFileClosed(t, func(f experimentalsys.File) experimentalsys.Errno {
return f.Utimens(experimentalsys.UTIME_OMIT, experimentalsys.UTIME_OMIT)
})
testEBADFIfDirClosed(t, func(d experimentalsys.File) experimentalsys.Errno {
return d.Utimens(experimentalsys.UTIME_OMIT, experimentalsys.UTIME_OMIT)
})
}

func TestNewStdioFile(t *testing.T) {
// simulate regular file attached to stdin
f, err := os.CreateTemp(t.TempDir(), "somefile")
Expand Down
12 changes: 12 additions & 0 deletions internal/sysfs/futimens_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"time"

"github.com/tetratelabs/wazero/experimental/sys"
experimentalsys "github.com/tetratelabs/wazero/experimental/sys"
"github.com/tetratelabs/wazero/internal/platform"
"github.com/tetratelabs/wazero/internal/testing/require"
)
Expand All @@ -22,6 +23,17 @@ func TestUtimens(t *testing.T) {
testUtimens(t, false)
}

func TestFileUtimens(t *testing.T) {
testUtimens(t, true)

testEBADFIfFileClosed(t, func(f experimentalsys.File) experimentalsys.Errno {
return f.Utimens(experimentalsys.UTIME_OMIT, experimentalsys.UTIME_OMIT)
})
testEBADFIfDirClosed(t, func(d experimentalsys.File) experimentalsys.Errno {
return d.Utimens(experimentalsys.UTIME_OMIT, experimentalsys.UTIME_OMIT)
})
}

func testUtimens(t *testing.T, futimes bool) {
// Note: This sets microsecond granularity because Windows doesn't support
// nanosecond.
Expand Down
2 changes: 1 addition & 1 deletion sys/stat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func Test_NewStat_t(t *testing.T) {
tc := tt
t.Run(tc.name, func(t *testing.T) {
st := sys.NewStat_t(tc.info)
if tc.expectDevIno && runtime.GOOS != "windows" {
if tc.expectDevIno && (runtime.GOOS == "linux" || runtime.GOOS == "darwin" || runtime.GOOS == "freebsd") {
require.NotEqual(t, uint64(0), st.Dev)
require.NotEqual(t, uint64(0), st.Ino)
} else {
Expand Down

0 comments on commit c5e90c5

Please sign in to comment.