mirror of
https://gitea.com/gitea/runner.git
synced 2026-11-18 05:43:42 +00:00
The runner did not build on illumos, Solaris, NetBSD and OpenBSD: `internal/pkg/disk` called `unix.Statfs`, which `golang.org/x/sys/unix` lacks on illumos, Solaris and NetBSD (they have `statvfs(2)`) and exposes with `F_`-prefixed fields on OpenBSD. Each now has an implementation matching its syscall. FreeBSD and DragonFly report a negative available-block count once root writes into the reserved blocks. It wrapped to ~16 EiB free, so the disk health check and cache eviction saw plenty of space exactly when the disk was full. A shared helper clamps it to zero and absorbs the per-platform integer types. CI only built for the host, which let this and https://gitea.com/gitea/runner/pulls/1098 through. `make cross-check` vets code and tests on one target per distinct set of platform files, plus linux/arm for its 32-bit syscall fields, and runs as its own job in parallel to the others. It also surfaced docker-only tests lacking the docker build tag, which are fixed too. Assisted-by: Claude Code:claude-opus-5-5 Co-authored-by: rosekanari <[email protected]>
65 lines
1.9 KiB
Go
65 lines
1.9 KiB
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
//go:build !(WITHOUT_DOCKER || !(linux || darwin || windows || netbsd || freebsd))
|
|
|
|
package container
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestCreateFlagsFromOptions(t *testing.T) {
|
|
for _, tc := range []struct {
|
|
options string
|
|
platform string
|
|
pull string
|
|
}{
|
|
{"", "", pullPolicyMissing},
|
|
{"-v /a:/b --platform=linux/arm64 --pull always", "linux/arm64", pullPolicyAlways},
|
|
{"--platform linux/arm/v7 --pull never", "linux/arm/v7", pullPolicyNever},
|
|
{`--platform "linux/amd64`, "", pullPolicyMissing}, // malformed, defaults kept
|
|
} {
|
|
t.Run(tc.options, func(t *testing.T) {
|
|
cf := createFlagsFromOptions(tc.options)
|
|
assert.Equal(t, tc.platform, cf.platform)
|
|
assert.Equal(t, tc.pull, cf.pull)
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestCreateFlagsValidate(t *testing.T) {
|
|
for _, tc := range []struct {
|
|
options string
|
|
wantErr string
|
|
}{
|
|
{"--quiet --disable-content-trust --name mine", ""},
|
|
{"--pull sometimes", `invalid --pull option "sometimes"`},
|
|
{"--use-api-socket", "--use-api-socket is not supported"},
|
|
} {
|
|
t.Run(tc.options, func(t *testing.T) {
|
|
err := createFlagsFromOptions(tc.options).validate()
|
|
if tc.wantErr == "" {
|
|
require.NoError(t, err)
|
|
return
|
|
}
|
|
require.ErrorContains(t, err, tc.wantErr)
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestNewContainerAppliesCreateFlags(t *testing.T) {
|
|
input := &NewContainerInput{Platform: "linux/amd64", RunnerOptions: "--pull never", WorkflowOptions: "--platform linux/arm64"}
|
|
cr, ok := NewContainer(input).(*containerReference)
|
|
require.True(t, ok)
|
|
assert.Equal(t, "linux/arm64", input.Platform)
|
|
assert.Equal(t, pullPolicyNever, cr.pullPolicy)
|
|
|
|
kept := &NewContainerInput{Platform: "linux/amd64", RunnerOptions: "--privileged"}
|
|
NewContainer(kept)
|
|
assert.Equal(t, "linux/amd64", kept.Platform)
|
|
}
|