Move detach flags to platform specific

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
Derek McGowan 2017-08-22 17:20:25 -07:00
parent f74cea71dd
commit 96a75ab1ab
No known key found for this signature in database
GPG Key ID: F58C5D0A4405ACDB
7 changed files with 22 additions and 11 deletions

View File

@ -0,0 +1,5 @@
package testsuite
import "golang.org/x/sys/unix"
const umountflags int = unix.MNT_DETACH

View File

@ -0,0 +1,5 @@
// +build !linux
package testsuite
const umountflags int = 0

View File

@ -2,13 +2,7 @@
package testsuite package testsuite
import ( import "syscall"
"syscall"
"golang.org/x/sys/unix"
)
const umountflags int = unix.MNT_DETACH
func clearMask() func() { func clearMask() func() {
oldumask := syscall.Umask(0) oldumask := syscall.Umask(0)

View File

@ -1,7 +1,5 @@
package testsuite package testsuite
const umountflags int = 0
func clearMask() func() { func clearMask() func() {
return func() {} return func() {}
} }

View File

@ -9,13 +9,12 @@ import (
"github.com/containerd/containerd/mount" "github.com/containerd/containerd/mount"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"golang.org/x/sys/unix"
) )
// Unmount unmounts a given mountPoint and sets t.Error if it fails // Unmount unmounts a given mountPoint and sets t.Error if it fails
func Unmount(t *testing.T, mountPoint string) { func Unmount(t *testing.T, mountPoint string) {
t.Log("unmount", mountPoint) 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) t.Error("Could not umount", mountPoint, err)
} }
} }

5
testutil/mount_linux.go Normal file
View File

@ -0,0 +1,5 @@
package testutil
import "golang.org/x/sys/unix"
const umountflags int = unix.MNT_DETACH

5
testutil/mount_other.go Normal file
View File

@ -0,0 +1,5 @@
// +build !linux
package testutil
const umountflags int = 0