aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/internal/sandbox/assert.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-10-03 17:49:27 +0900
committerOphestra <cat@gensokyo.uk>2026-10-03 18:15:20 +0900
commitaa41002e8078a3ab00896cbd403e573c6dd817c2 (patch)
tree9ebcf82d99ff95a97a8661ffdaf86dd20c9213bf /test/internal/sandbox/assert.go
parent4697e493fe59a2e61b5e8e8a9d0ae4b8e338e378 (diff)
test/internal/mountinfo: move from sandbox
This also improves its API. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'test/internal/sandbox/assert.go')
-rw-r--r--test/internal/sandbox/assert.go25
1 files changed, 15 insertions, 10 deletions
diff --git a/test/internal/sandbox/assert.go b/test/internal/sandbox/assert.go
index e6fe926b..2125419b 100644
--- a/test/internal/sandbox/assert.go
+++ b/test/internal/sandbox/assert.go
@@ -19,6 +19,8 @@ import (
"os"
"path/filepath"
"syscall"
+
+ "hakurei.app/test/internal/mountinfo"
)
var (
@@ -31,10 +33,10 @@ func printf(format string, v ...any) { printfFunc(format, v...) }
func fatalf(format string, v ...any) { fatalfFunc(format, v...) }
type TestCase struct {
- Env []string `json:"env"`
- FS *FS `json:"fs"`
- Mount []*MountinfoEntry `json:"mount"`
- Seccomp bool `json:"seccomp"`
+ Env []string `json:"env"`
+ FS *FS `json:"fs"`
+ Mount []*mountinfo.Entry `json:"mount"`
+ Seccomp bool `json:"seccomp"`
TrySocket string `json:"try_socket,omitempty"`
SocketAbstract bool `json:"socket_abstract,omitempty"`
@@ -120,15 +122,18 @@ func (t *T) MustCheck(want *TestCase) {
var fail bool
m := mustParseMountinfo(t.MountsPath)
i := 0
- for ent := range m.Entries() {
+ var ent mountinfo.Entry
+ for m.Next() {
+ m.Copy(&ent)
+
if i == len(want.Mount) {
fatalf("got more than %d entries", i)
}
if !ent.EqualWithIgnore(want.Mount[i], "//ignore") {
fail = true
- printf("[FAIL] %s", ent)
+ printf("[FAIL] %s", &ent)
} else {
- printf("[ OK ] %s", ent)
+ printf("[ OK ] %s", &ent)
}
i++
@@ -262,9 +267,9 @@ func mustDecode(wantFilePath string, v any) {
}
}
-func mustParseMountinfo(name string) *Mountinfo {
- m := NewMountinfo(name)
- if err := m.Parse(); err != nil {
+func mustParseMountinfo(name string) *mountinfo.Iter {
+ m, err := mountinfo.Open(name)
+ if err != nil {
fatalf("%v", err)
panic("unreachable")
}