system/tmpfiles: do not fail for smaller files
All checks were successful
Test / Create distribution (push) Successful in 34s
Test / Sandbox (push) Successful in 2m23s
Test / Hpkg (push) Successful in 4m9s
Test / Sandbox (race detector) (push) Successful in 4m31s
Test / Hakurei (race detector) (push) Successful in 5m15s
Test / Hakurei (push) Successful in 2m11s
Test / Flake checks (push) Successful in 1m27s
All checks were successful
Test / Create distribution (push) Successful in 34s
Test / Sandbox (push) Successful in 2m23s
Test / Hpkg (push) Successful in 4m9s
Test / Sandbox (race detector) (push) Successful in 4m31s
Test / Hakurei (race detector) (push) Successful in 5m15s
Test / Hakurei (push) Successful in 2m11s
Test / Flake checks (push) Successful in 1m27s
The limit is meant to be an upper bound. Handle EOF and print verbose message for it instead of failing. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"io"
|
||||
"io/fs"
|
||||
"os"
|
||||
"reflect"
|
||||
"slices"
|
||||
"testing"
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
"hakurei.app/container/stub"
|
||||
@@ -180,6 +183,34 @@ func checkOpMeta(t *testing.T, testCases []opMetaTestCase) {
|
||||
})
|
||||
}
|
||||
|
||||
type stubFi struct {
|
||||
size int64
|
||||
isDir bool
|
||||
}
|
||||
|
||||
func (stubFi) Name() string { panic("unreachable") }
|
||||
func (fi stubFi) Size() int64 { return fi.size }
|
||||
func (stubFi) Mode() fs.FileMode { panic("unreachable") }
|
||||
func (stubFi) ModTime() time.Time { panic("unreachable") }
|
||||
func (fi stubFi) IsDir() bool { return fi.isDir }
|
||||
func (stubFi) Sys() any { panic("unreachable") }
|
||||
|
||||
type readerOsFile struct {
|
||||
closed bool
|
||||
io.Reader
|
||||
}
|
||||
|
||||
func (*readerOsFile) Name() string { panic("unreachable") }
|
||||
func (*readerOsFile) Write([]byte) (int, error) { panic("unreachable") }
|
||||
func (*readerOsFile) Stat() (fs.FileInfo, error) { panic("unreachable") }
|
||||
func (r *readerOsFile) Close() error {
|
||||
if r.closed {
|
||||
return os.ErrClosed
|
||||
}
|
||||
r.closed = true
|
||||
return nil
|
||||
}
|
||||
|
||||
// InternalNew initialises [I] with a stub syscallDispatcher.
|
||||
func InternalNew(t *testing.T, want stub.Expect, uid int) (*I, *stub.Stub[syscallDispatcher]) {
|
||||
k := stub.New(t, func(s *stub.Stub[syscallDispatcher]) syscallDispatcher { return &kstub{s} }, want)
|
||||
@@ -192,6 +223,28 @@ type kstub struct{ *stub.Stub[syscallDispatcher] }
|
||||
|
||||
func (k *kstub) new(f func(k syscallDispatcher)) { k.Helper(); k.New(f) }
|
||||
|
||||
func (k *kstub) stat(name string) (fi os.FileInfo, err error) {
|
||||
k.Helper()
|
||||
expect := k.Expects("stat")
|
||||
err = expect.Error(
|
||||
stub.CheckArg(k.Stub, "name", name, 0))
|
||||
if err == nil {
|
||||
fi = expect.Ret.(os.FileInfo)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (k *kstub) open(name string) (f osFile, err error) {
|
||||
k.Helper()
|
||||
expect := k.Expects("open")
|
||||
err = expect.Error(
|
||||
stub.CheckArg(k.Stub, "name", name, 0))
|
||||
if err == nil {
|
||||
f = expect.Ret.(osFile)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (k *kstub) mkdir(name string, perm os.FileMode) error {
|
||||
k.Helper()
|
||||
return k.Expects("mkdir").Error(
|
||||
|
||||
Reference in New Issue
Block a user