Files
runc/internal/testutil/testutil.go
Kir Kolyshkin a2f7c6add8 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>
2023-10-30 16:54:17 -07:00

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)
}
}
}