sandbox/vfs: count mountinfo entries

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2025-03-21 12:14:33 +09:00
parent 9ddf5794dd
commit 5098b12e4a
2 changed files with 25 additions and 13 deletions

View File

@@ -120,7 +120,7 @@ id 20 0:53 / /mnt/test rw,relatime shared:212 - tmpfs rw
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
got, err := vfs.ParseMountInfo(strings.NewReader(tc.sample))
got, n, err := vfs.ParseMountInfo(strings.NewReader(tc.sample))
if !errors.Is(err, tc.wantErr) {
if tc.wantError == "" {
t.Errorf("ParseMountInfo: error = %v, wantErr %v",
@@ -131,6 +131,14 @@ id 20 0:53 / /mnt/test rw,relatime shared:212 - tmpfs rw
}
}
wantCount := len(tc.want)
if tc.wantErr != nil || tc.wantError != "" {
wantCount = -1
}
if n != wantCount {
t.Errorf("ParseMountInfo: got %d entries, want %d", n, wantCount)
}
i := 0
for cur := got; cur != nil; cur = cur.Next {
if i == len(tc.want) {