diff --git a/snapshot/testsuite/helpers_linux.go b/snapshot/testsuite/helpers_linux.go new file mode 100644 index 000000000..1f8fb2824 --- /dev/null +++ b/snapshot/testsuite/helpers_linux.go @@ -0,0 +1,5 @@ +package testsuite + +import "golang.org/x/sys/unix" + +const umountflags int = unix.MNT_DETACH diff --git a/snapshot/testsuite/helpers_other.go b/snapshot/testsuite/helpers_other.go new file mode 100644 index 000000000..1df729c52 --- /dev/null +++ b/snapshot/testsuite/helpers_other.go @@ -0,0 +1,5 @@ +// +build !linux + +package testsuite + +const umountflags int = 0 diff --git a/snapshot/testsuite/testsuite_unix.go b/snapshot/testsuite/testsuite_unix.go index 14dc85864..6a02eda9d 100644 --- a/snapshot/testsuite/testsuite_unix.go +++ b/snapshot/testsuite/testsuite_unix.go @@ -2,13 +2,7 @@ package testsuite -import ( - "syscall" - - "golang.org/x/sys/unix" -) - -const umountflags int = unix.MNT_DETACH +import "syscall" func clearMask() func() { oldumask := syscall.Umask(0) diff --git a/snapshot/testsuite/testsuite_windows.go b/snapshot/testsuite/testsuite_windows.go index c48cca3e6..c3cc8c22b 100644 --- a/snapshot/testsuite/testsuite_windows.go +++ b/snapshot/testsuite/testsuite_windows.go @@ -1,7 +1,5 @@ package testsuite -const umountflags int = 0 - func clearMask() func() { return func() {} } diff --git a/testutil/helpers_unix.go b/testutil/helpers_unix.go index fd207449e..e8f983404 100644 --- a/testutil/helpers_unix.go +++ b/testutil/helpers_unix.go @@ -9,13 +9,12 @@ import ( "github.com/containerd/containerd/mount" "github.com/stretchr/testify/assert" - "golang.org/x/sys/unix" ) // Unmount unmounts a given mountPoint and sets t.Error if it fails func Unmount(t *testing.T, mountPoint string) { t.Log("unmount", mountPoint) - if err := mount.UnmountAll(mountPoint, unix.MNT_DETACH); err != nil { + if err := mount.UnmountAll(mountPoint, umountflags); err != nil { t.Error("Could not umount", mountPoint, err) } } diff --git a/testutil/mount_linux.go b/testutil/mount_linux.go new file mode 100644 index 000000000..1c1164215 --- /dev/null +++ b/testutil/mount_linux.go @@ -0,0 +1,5 @@ +package testutil + +import "golang.org/x/sys/unix" + +const umountflags int = unix.MNT_DETACH diff --git a/testutil/mount_other.go b/testutil/mount_other.go new file mode 100644 index 000000000..da3cb9e79 --- /dev/null +++ b/testutil/mount_other.go @@ -0,0 +1,5 @@ +// +build !linux + +package testutil + +const umountflags int = 0