mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-12 09:46:25 +08:00
libct/cg/dev: add sync.Once to test case
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/opencontainers/runc/libcontainer/cgroups"
|
||||
@@ -117,11 +118,23 @@ func TestPodSkipDevicesUpdate(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
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 skipOnCentOS7(t *testing.T) {
|
||||
t.Helper()
|
||||
// https://github.com/opencontainers/runc/issues/3743
|
||||
centosVer, _ := exec.Command("rpm", "-q", "--qf", "%{version}", "centos-release").CombinedOutput()
|
||||
if string(centosVer) == "7" {
|
||||
if centosVersion() == "7" {
|
||||
t.Skip("Flaky on CentOS 7")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user