sandbox: verify outcome via mountinfo
All checks were successful
Test / Create distribution (push) Successful in 26s
Test / Fortify (push) Successful in 2m39s
Test / Fpkg (push) Successful in 3m29s
Test / Data race detector (push) Successful in 4m17s
Test / Flake checks (push) Successful in 1m6s

This contains much more information than /proc/mounts and allows for more fields to be checked. This also removes the dependency on the test package.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2025-03-23 22:17:36 +09:00
parent 806ce18c0a
commit e8809125d4
2 changed files with 109 additions and 31 deletions

View File

@@ -6,6 +6,7 @@ import (
"fmt"
"io"
"iter"
"slices"
"strconv"
"strings"
"syscall"
@@ -236,3 +237,22 @@ func parseMountInfoLine(s string, ent *MountInfoEntry) error {
return nil
}
func (e *MountInfoEntry) EqualWithIgnore(want *MountInfoEntry) bool {
return (e.ID == want.ID || want.ID == -1) &&
(e.Parent == want.Parent || want.Parent == -1) &&
(e.Devno == want.Devno || (want.Devno[0] == -1 && want.Devno[1] == -1)) &&
(e.Root == want.Root || want.Root == "\x00") &&
(e.Target == want.Target || want.Target == "\x00") &&
(e.VfsOptstr == want.VfsOptstr || want.VfsOptstr == "\x00") &&
(slices.Equal(e.OptFields, want.OptFields) || (len(want.OptFields) == 1 && want.OptFields[0] == "\x00")) &&
(e.FsType == want.FsType || want.FsType == "\x00") &&
(e.Source == want.Source || want.Source == "\x00") &&
(e.FsOptstr == want.FsOptstr || want.FsOptstr == "\x00")
}
func (e *MountInfoEntry) String() string {
return fmt.Sprintf("%d %d %d:%d %s %s %s %s %s %s %s",
e.ID, e.Parent, e.Devno[0], e.Devno[1], e.Root, e.Target, e.VfsOptstr,
strings.Join(append(e.OptFields, "-"), " "), e.FsType, e.Source, e.FsOptstr)
}