mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
internal/testutil: create, add SkipOnCentOS
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>
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user