properly strip path.rootfs from mountpoint labels (#1421)

Change-type: patch
Connects-to: #1418
Signed-off-by: dt-rush <nickp@balena.io>
This commit is contained in:
dt-rush 2019-07-19 14:51:17 +00:00 committed by Ben Kochie
commit 5d3e2ce2ef
7 changed files with 44 additions and 3 deletions

View file

@ -112,3 +112,30 @@ func TestMountsFallback(t *testing.T) {
}
}
}
func TestPathRootfs(t *testing.T) {
if _, err := kingpin.CommandLine.Parse([]string{"--path.procfs", "./fixtures_bindmount/proc", "--path.rootfs", "/host"}); err != nil {
t.Fatal(err)
}
expected := map[string]string{
// should modify these mountpoints (removes /host, see fixture proc file)
"/media/volume1": "",
"/media/volume2": "",
// should not modify these mountpoints
"/dev/shm": "",
"/run/lock": "",
"/sys/fs/cgroup": "",
}
filesystems, err := mountPointDetails()
if err != nil {
t.Log(err)
}
for _, fs := range filesystems {
if _, ok := expected[fs.mountPoint]; !ok {
t.Errorf("Got unexpected %s", fs.mountPoint)
}
}
}