This makes `go test .` to pass if run as non-root user, skipping
those tests that require superuser privileges (for `mount`).
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
| ... | ... |
@@ -25,6 +25,10 @@ func TestMountOptionsParsing(t *testing.T) {
|
| 25 | 25 |
} |
| 26 | 26 |
|
| 27 | 27 |
func TestMounted(t *testing.T) {
|
| 28 |
+ if os.Getuid() != 0 {
|
|
| 29 |
+ t.Skip("root required")
|
|
| 30 |
+ } |
|
| 31 |
+ |
|
| 28 | 32 |
tmp := path.Join(os.TempDir(), "mount-tests") |
| 29 | 33 |
if err := os.MkdirAll(tmp, 0777); err != nil {
|
| 30 | 34 |
t.Fatal(err) |
| ... | ... |
@@ -76,6 +80,10 @@ func TestMounted(t *testing.T) {
|
| 76 | 76 |
} |
| 77 | 77 |
|
| 78 | 78 |
func TestMountReadonly(t *testing.T) {
|
| 79 |
+ if os.Getuid() != 0 {
|
|
| 80 |
+ t.Skip("root required")
|
|
| 81 |
+ } |
|
| 82 |
+ |
|
| 79 | 83 |
tmp := path.Join(os.TempDir(), "mount-tests") |
| 80 | 84 |
if err := os.MkdirAll(tmp, 0777); err != nil {
|
| 81 | 85 |
t.Fatal(err) |
| ... | ... |
@@ -12,6 +12,10 @@ import ( |
| 12 | 12 |
|
| 13 | 13 |
// nothing is propagated in or out |
| 14 | 14 |
func TestSubtreePrivate(t *testing.T) {
|
| 15 |
+ if os.Getuid() != 0 {
|
|
| 16 |
+ t.Skip("root required")
|
|
| 17 |
+ } |
|
| 18 |
+ |
|
| 15 | 19 |
tmp := path.Join(os.TempDir(), "mount-tests") |
| 16 | 20 |
if err := os.MkdirAll(tmp, 0777); err != nil {
|
| 17 | 21 |
t.Fatal(err) |
| ... | ... |
@@ -110,6 +114,10 @@ func TestSubtreePrivate(t *testing.T) {
|
| 110 | 110 |
// Testing that when a target is a shared mount, |
| 111 | 111 |
// then child mounts propagate to the source |
| 112 | 112 |
func TestSubtreeShared(t *testing.T) {
|
| 113 |
+ if os.Getuid() != 0 {
|
|
| 114 |
+ t.Skip("root required")
|
|
| 115 |
+ } |
|
| 116 |
+ |
|
| 113 | 117 |
tmp := path.Join(os.TempDir(), "mount-tests") |
| 114 | 118 |
if err := os.MkdirAll(tmp, 0777); err != nil {
|
| 115 | 119 |
t.Fatal(err) |
| ... | ... |
@@ -178,6 +186,10 @@ func TestSubtreeShared(t *testing.T) {
|
| 178 | 178 |
// testing that mounts to a shared source show up in the slave target, |
| 179 | 179 |
// and that mounts into a slave target do _not_ show up in the shared source |
| 180 | 180 |
func TestSubtreeSharedSlave(t *testing.T) {
|
| 181 |
+ if os.Getuid() != 0 {
|
|
| 182 |
+ t.Skip("root required")
|
|
| 183 |
+ } |
|
| 184 |
+ |
|
| 181 | 185 |
tmp := path.Join(os.TempDir(), "mount-tests") |
| 182 | 186 |
if err := os.MkdirAll(tmp, 0777); err != nil {
|
| 183 | 187 |
t.Fatal(err) |
| ... | ... |
@@ -282,6 +294,10 @@ func TestSubtreeSharedSlave(t *testing.T) {
|
| 282 | 282 |
} |
| 283 | 283 |
|
| 284 | 284 |
func TestSubtreeUnbindable(t *testing.T) {
|
| 285 |
+ if os.Getuid() != 0 {
|
|
| 286 |
+ t.Skip("root required")
|
|
| 287 |
+ } |
|
| 288 |
+ |
|
| 285 | 289 |
tmp := path.Join(os.TempDir(), "mount-tests") |
| 286 | 290 |
if err := os.MkdirAll(tmp, 0777); err != nil {
|
| 287 | 291 |
t.Fatal(err) |