Skip to content

Commit b574248

Browse files
TBBlegabriel-samfira
authored andcommitted
Unify testutil.Unmount on Windows and Unix
Signed-off-by: Paul "TBBle" Hampson <[email protected]>
1 parent b9a8aad commit b574248

4 files changed

Lines changed: 12 additions & 14 deletions

File tree

pkg/testutil/helpers.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ import (
2323
"path/filepath"
2424
"strconv"
2525
"testing"
26+
27+
"github.com/containerd/containerd/mount"
28+
"github.com/stretchr/testify/assert"
2629
)
2730

2831
var rootEnabled bool
@@ -79,3 +82,10 @@ func DumpDirOnFailure(t *testing.T, root string) {
7982
DumpDir(t, root)
8083
}
8184
}
85+
86+
// Unmount unmounts a given mountPoint and sets t.Error if it fails
87+
func Unmount(t testing.TB, mountPoint string) {
88+
t.Log("unmount", mountPoint)
89+
err := mount.UnmountAll(mountPoint, umountflags)
90+
assert.NoError(t, err)
91+
}

pkg/testutil/helpers_unix.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,9 @@ import (
2323
"os"
2424
"testing"
2525

26-
"github.com/containerd/containerd/mount"
2726
"github.com/stretchr/testify/assert"
2827
)
2928

30-
// Unmount unmounts a given mountPoint and sets t.Error if it fails
31-
func Unmount(t testing.TB, mountPoint string) {
32-
t.Log("unmount", mountPoint)
33-
err := mount.UnmountAll(mountPoint, umountflags)
34-
assert.NoError(t, err)
35-
}
36-
3729
// RequiresRoot skips tests that require root, unless the test.root flag has
3830
// been set
3931
func RequiresRoot(t testing.TB) {

pkg/testutil/helpers_windows.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,3 @@ func RequiresRoot(t testing.TB) {
2525
// RequiresRootM is similar to RequiresRoot but intended to be called from *testing.M.
2626
func RequiresRootM() {
2727
}
28-
29-
// Unmount unmounts a given mountPoint and sets t.Error if it fails
30-
// Does nothing on Windows
31-
func Unmount(t *testing.T, mountPoint string) {
32-
}

pkg/testutil/mount_other.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
//go:build !linux && !windows
1+
//go:build !linux
2+
// +build !linux
23

34
/*
45
Copyright The containerd Authors.

0 commit comments

Comments
 (0)