snapshot: Fix leaked mounts and temp directories

Signed-off-by: Samuel Karp <skarp@amazon.com>
This commit is contained in:
Samuel Karp
2017-01-12 01:08:00 +00:00
parent e2eb06dd3d
commit 2c36c387de
4 changed files with 36 additions and 24 deletions

24
snapshot/common_test.go Normal file
View File

@@ -0,0 +1,24 @@
package snapshot
import (
"os/exec"
"testing"
"github.com/docker/containerd"
)
func unmountAll(t *testing.T, mounts []containerd.Mount) {
for _, mount := range mounts {
unmount(t, mount.Target)
}
}
func unmount(t *testing.T, mountPoint string) {
t.Log("unmount", mountPoint)
umount := exec.Command("umount", mountPoint)
err := umount.Run()
if err != nil {
t.Error("Could not umount", mountPoint, err)
}
}