diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-03-21 12:14:33 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-03-21 12:14:33 +0900 |
| commit | 5098b12e4a0843a7f63a90ad6099cba66bc353a8 (patch) | |
| tree | 7eed6b15201f367e518a8db42b3fe77b452c08b1 /sandbox/vfs/mountinfo_test.go | |
| parent | 9ddf5794dd6eb5222fc1cccceb7d27c7cbd9c785 (diff) | |
sandbox/vfs: count mountinfo entries
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'sandbox/vfs/mountinfo_test.go')
| -rw-r--r-- | sandbox/vfs/mountinfo_test.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/sandbox/vfs/mountinfo_test.go b/sandbox/vfs/mountinfo_test.go index 8d1c2e46..93738a45 100644 --- a/sandbox/vfs/mountinfo_test.go +++ b/sandbox/vfs/mountinfo_test.go @@ -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) { |
