Skip to content

Commit 2847623

Browse files
committed
mountinfo: add unit-test for fully-filled fields in filter
Signed-off-by: Aleksa Sarai <[email protected]>
1 parent 41fc4b7 commit 2847623

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

mountinfo/mountinfo_linux_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,33 @@ func TestParseFedoraMountinfoFields(t *testing.T) {
477477
}
478478
}
479479

480+
func TestParseFedoraMountinfoFilterFields(t *testing.T) {
481+
r := bytes.NewBuffer([]byte(fedoraMountinfo))
482+
_, err := GetMountsFromReader(r, func(info *Info) (skip bool, stop bool) {
483+
mi := Info{
484+
ID: 15,
485+
Parent: 35,
486+
Major: 0,
487+
Minor: 3,
488+
Root: "/",
489+
Mountpoint: "/proc",
490+
Options: "rw,nosuid,nodev,noexec,relatime",
491+
Optional: "shared:5",
492+
FSType: "proc",
493+
Source: "proc",
494+
VFSOptions: "rw",
495+
}
496+
if *info != mi {
497+
t.Fatalf("expected %#v, got %#v", mi, *info)
498+
}
499+
// Only match the first entry as in TestParseFedoraMountinfoFields.
500+
return false, true
501+
})
502+
if err != nil {
503+
t.Fatal(err)
504+
}
505+
}
506+
480507
func TestParseMountinfoWithSpaces(t *testing.T) {
481508
r := bytes.NewBuffer([]byte(mountInfoWithSpaces))
482509
infos, err := GetMountsFromReader(r, nil)

0 commit comments

Comments
 (0)