mirror of
https://github.com/opencontainers/runc.git
synced 2025-09-27 03:46:19 +08:00

CentOS 7 is showing its age and we'd rather skip some tests on it than find out why they are flaky. Add internal/testutil package, and move the generalized version of SkipOnCentOS7 from libcontainer/cgroups/devices to there. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
31 lines
544 B
Go
31 lines
544 B
Go
package testutil
|
|
|
|
import (
|
|
"os/exec"
|
|
"strconv"
|
|
"sync"
|
|
"testing"
|
|
)
|
|
|
|
var (
|
|
centosVer string
|
|
centosVerOnce sync.Once
|
|
)
|
|
|
|
func centosVersion() string {
|
|
centosVerOnce.Do(func() {
|
|
ver, _ := exec.Command("rpm", "-q", "--qf", "%{version}", "centos-release").CombinedOutput()
|
|
centosVer = string(ver)
|
|
})
|
|
return centosVer
|
|
}
|
|
|
|
func SkipOnCentOS(t *testing.T, reason string, versions ...int) {
|
|
t.Helper()
|
|
for _, v := range versions {
|
|
if vstr := strconv.Itoa(v); centosVersion() == vstr {
|
|
t.Skip(reason + " on CentOS " + vstr)
|
|
}
|
|
}
|
|
}
|