2015-09-23 00:10:03 +00:00
|
|
|
package testutil
|
|
|
|
|
|
|
|
import (
|
2015-10-07 22:24:16 +00:00
|
|
|
"os/exec"
|
2015-09-23 00:10:03 +00:00
|
|
|
"runtime"
|
|
|
|
"syscall"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func ExecCompatible(t *testing.T) {
|
2015-10-29 00:22:04 +00:00
|
|
|
if runtime.GOOS != "linux" || syscall.Geteuid() != 0 {
|
|
|
|
t.Skip("Test only available running as root on linux")
|
2015-09-23 00:10:03 +00:00
|
|
|
}
|
|
|
|
}
|
2015-09-23 04:56:29 +00:00
|
|
|
|
2015-09-25 23:49:14 +00:00
|
|
|
func QemuCompatible(t *testing.T) {
|
2015-10-26 19:24:37 +00:00
|
|
|
if runtime.GOOS == "windows" {
|
2015-10-23 07:27:59 +00:00
|
|
|
t.Skip("Must be on non-windows environments to run test")
|
|
|
|
}
|
|
|
|
// else see if qemu exists
|
|
|
|
_, err := exec.Command("qemu-system-x86_64", "-version").CombinedOutput()
|
|
|
|
if err != nil {
|
|
|
|
t.Skip("Must have Qemu installed for Qemu specific tests to run")
|
2015-09-25 23:49:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-02 21:19:53 +00:00
|
|
|
func RktCompatible(t *testing.T) {
|
2015-10-07 22:24:16 +00:00
|
|
|
if runtime.GOOS == "windows" || syscall.Geteuid() != 0 {
|
|
|
|
t.Skip("Must be root on non-windows environments to run test")
|
|
|
|
}
|
|
|
|
// else see if rkt exists
|
|
|
|
_, err := exec.Command("rkt", "version").CombinedOutput()
|
|
|
|
if err != nil {
|
|
|
|
t.Skip("Must have rkt installed for rkt specific tests to run")
|
|
|
|
}
|
2015-09-29 22:33:25 +00:00
|
|
|
}
|
|
|
|
|
2015-09-23 04:56:29 +00:00
|
|
|
func MountCompatible(t *testing.T) {
|
|
|
|
if runtime.GOOS == "windows" {
|
|
|
|
t.Skip("Windows does not support mount")
|
|
|
|
}
|
|
|
|
|
|
|
|
if syscall.Geteuid() != 0 {
|
|
|
|
t.Skip("Must be root to run test")
|
|
|
|
}
|
|
|
|
}
|