forked from security/hakurei
sandbox/vfs: count mountinfo entries
Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user