github.com/kardianos/nomad@v0.1.3-0.20151022182107-b13df73ee850/client/testutil/driver_compatible.go (about)

     1  package testutil
     2  
     3  import (
     4  	"os/exec"
     5  	"runtime"
     6  	"syscall"
     7  	"testing"
     8  )
     9  
    10  func ExecCompatible(t *testing.T) {
    11  	if runtime.GOOS != "windows" && syscall.Geteuid() != 0 {
    12  		t.Skip("Must be root on non-windows environments to run test")
    13  	}
    14  }
    15  
    16  func QemuCompatible(t *testing.T) {
    17  	if runtime.GOOS != "windows" && syscall.Geteuid() != 0 {
    18  		t.Skip("Must be root on non-windows environments to run test")
    19  	}
    20  }
    21  
    22  func RktCompatible(t *testing.T) {
    23  	if runtime.GOOS == "windows" || syscall.Geteuid() != 0 {
    24  		t.Skip("Must be root on non-windows environments to run test")
    25  	}
    26  	// else see if rkt exists
    27  	_, err := exec.Command("rkt", "version").CombinedOutput()
    28  	if err != nil {
    29  		t.Skip("Must have rkt installed for rkt specific tests to run")
    30  	}
    31  }
    32  
    33  func MountCompatible(t *testing.T) {
    34  	if runtime.GOOS == "windows" {
    35  		t.Skip("Windows does not support mount")
    36  	}
    37  
    38  	if syscall.Geteuid() != 0 {
    39  		t.Skip("Must be root to run test")
    40  	}
    41  }