Skip to content

Commit

Permalink
Merge pull request moby#36505 from kolyshkin/pkg-mount-tests
Browse files Browse the repository at this point in the history
pkg/mount unit tests: skip some test under non-root
  • Loading branch information
AkihiroSuda committed Mar 8, 2018
2 parents bc7424b + 4aae776 commit 4a1d35c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
8 changes: 8 additions & 0 deletions pkg/mount/mount_unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ func TestMountOptionsParsing(t *testing.T) {
}

func TestMounted(t *testing.T) {
if os.Getuid() != 0 {
t.Skip("root required")
}

tmp := path.Join(os.TempDir(), "mount-tests")
if err := os.MkdirAll(tmp, 0777); err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -76,6 +80,10 @@ func TestMounted(t *testing.T) {
}

func TestMountReadonly(t *testing.T) {
if os.Getuid() != 0 {
t.Skip("root required")
}

tmp := path.Join(os.TempDir(), "mount-tests")
if err := os.MkdirAll(tmp, 0777); err != nil {
t.Fatal(err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/mount/mounter_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

func TestMount(t *testing.T) {
if os.Getuid() != 0 {
t.Skip("not root tests would fail")
t.Skip("root required")
}

source, err := ioutil.TempDir("", "mount-test-source-")
Expand Down
16 changes: 16 additions & 0 deletions pkg/mount/sharedsubtree_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ import (

// nothing is propagated in or out
func TestSubtreePrivate(t *testing.T) {
if os.Getuid() != 0 {
t.Skip("root required")
}

tmp := path.Join(os.TempDir(), "mount-tests")
if err := os.MkdirAll(tmp, 0777); err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -110,6 +114,10 @@ func TestSubtreePrivate(t *testing.T) {
// Testing that when a target is a shared mount,
// then child mounts propagate to the source
func TestSubtreeShared(t *testing.T) {
if os.Getuid() != 0 {
t.Skip("root required")
}

tmp := path.Join(os.TempDir(), "mount-tests")
if err := os.MkdirAll(tmp, 0777); err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -178,6 +186,10 @@ func TestSubtreeShared(t *testing.T) {
// testing that mounts to a shared source show up in the slave target,
// and that mounts into a slave target do _not_ show up in the shared source
func TestSubtreeSharedSlave(t *testing.T) {
if os.Getuid() != 0 {
t.Skip("root required")
}

tmp := path.Join(os.TempDir(), "mount-tests")
if err := os.MkdirAll(tmp, 0777); err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -282,6 +294,10 @@ func TestSubtreeSharedSlave(t *testing.T) {
}

func TestSubtreeUnbindable(t *testing.T) {
if os.Getuid() != 0 {
t.Skip("root required")
}

tmp := path.Join(os.TempDir(), "mount-tests")
if err := os.MkdirAll(tmp, 0777); err != nil {
t.Fatal(err)
Expand Down

0 comments on commit 4a1d35c

Please sign in to comment.