virtcontainers/tests: Disable selected tests for uid != 0

Skip a number of virtcontainers tests if not running as `root.`

Fixes #70.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
This commit is contained in:
James O. D. Hunt
2018-03-19 19:59:12 +00:00
parent ce37ac146d
commit bfd497fdf9
3 changed files with 36 additions and 0 deletions

View File

@@ -279,6 +279,10 @@ func testGenerateCCProxySockDir() (string, error) {
}
func TestCreatePodHyperstartAgentSuccessful(t *testing.T) {
if os.Geteuid() != 0 {
t.Skip(testDisabledAsNonRoot)
}
cleanUp()
config := newTestPodConfigHyperstartAgent()
@@ -308,6 +312,10 @@ func TestCreatePodHyperstartAgentSuccessful(t *testing.T) {
}
func TestCreatePodKataAgentSuccessful(t *testing.T) {
if os.Geteuid() != 0 {
t.Skip(testDisabledAsNonRoot)
}
cleanUp()
config := newTestPodConfigKataAgent()
@@ -383,6 +391,10 @@ func TestDeletePodNoopAgentSuccessful(t *testing.T) {
}
func TestDeletePodHyperstartAgentSuccessful(t *testing.T) {
if os.Geteuid() != 0 {
t.Skip(testDisabledAsNonRoot)
}
cleanUp()
config := newTestPodConfigHyperstartAgent()
@@ -422,6 +434,10 @@ func TestDeletePodHyperstartAgentSuccessful(t *testing.T) {
}
func TestDeletePodKataAgentSuccessful(t *testing.T) {
if os.Geteuid() != 0 {
t.Skip(testDisabledAsNonRoot)
}
cleanUp()
config := newTestPodConfigKataAgent()
@@ -527,6 +543,10 @@ func TestStartPodHyperstartAgentSuccessful(t *testing.T) {
}
func TestStartPodKataAgentSuccessful(t *testing.T) {
if os.Geteuid() != 0 {
t.Skip(testDisabledAsNonRoot)
}
cleanUp()
config := newTestPodConfigKataAgent()
@@ -685,6 +705,10 @@ func TestStopPodHyperstartAgentSuccessful(t *testing.T) {
}
func TestStopPodKataAgentSuccessful(t *testing.T) {
if os.Geteuid() != 0 {
t.Skip(testDisabledAsNonRoot)
}
cleanUp()
config := newTestPodConfigKataAgent()
@@ -791,6 +815,10 @@ func TestRunPodHyperstartAgentSuccessful(t *testing.T) {
}
func TestRunPodKataAgentSuccessful(t *testing.T) {
if os.Geteuid() != 0 {
t.Skip(testDisabledAsNonRoot)
}
cleanUp()
config := newTestPodConfigKataAgent()

View File

@@ -193,6 +193,10 @@ func cleanupFakeRootfsSetup(testRawFile, loopDev, mntDir string) {
}
func TestContainerAddDriveDir(t *testing.T) {
if os.Geteuid() != 0 {
t.Skip(testDisabledAsNonRoot)
}
testRawFile, loopDev, fakeRootfs, err := testSetupFakeRootfs(t)
defer cleanupFakeRootfsSetup(testRawFile, loopDev, fakeRootfs)

View File

@@ -309,6 +309,10 @@ func TestCreateVirtualNetworkEndpointInvalidArgs(t *testing.T) {
}
func TestIsPhysicalIface(t *testing.T) {
if os.Geteuid() != 0 {
t.Skip(testDisabledAsNonRoot)
}
testNetIface := "testIface0"
testMTU := 1500
testMACAddr := "00:00:00:00:00:01"