mirror of
https://github.com/containers/podman.git
synced 2025-09-25 15:55:32 +08:00
Merge pull request #4031 from QazerLab/master
Skip spec_test for rootless envs without cgroup v2.
This commit is contained in:
@ -4,6 +4,8 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/containers/libpod/pkg/cgroups"
|
||||||
|
"github.com/containers/libpod/pkg/rootless"
|
||||||
"github.com/containers/libpod/pkg/sysinfo"
|
"github.com/containers/libpod/pkg/sysinfo"
|
||||||
"github.com/containers/storage"
|
"github.com/containers/storage"
|
||||||
"github.com/containers/storage/pkg/idtools"
|
"github.com/containers/storage/pkg/idtools"
|
||||||
@ -26,14 +28,30 @@ func makeTestCreateConfig() *CreateConfig {
|
|||||||
return cc
|
return cc
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestPIDsLimit verifies the given pid-limit is correctly defined in the spec
|
func doCommonSkipChecks(t *testing.T) {
|
||||||
func TestPIDsLimit(t *testing.T) {
|
|
||||||
// The default configuration of podman enables seccomp, which is not available on non-Linux systems.
|
// The default configuration of podman enables seccomp, which is not available on non-Linux systems.
|
||||||
// Thus, any tests that use the default seccomp setting would fail.
|
// Thus, any tests that use the default seccomp setting would fail.
|
||||||
// Skip the tests on non-Linux platforms rather than explicitly disable seccomp in the test and possibly affect the test result.
|
// Skip the tests on non-Linux platforms rather than explicitly disable seccomp in the test and possibly affect the test result.
|
||||||
if runtime.GOOS != "linux" {
|
if runtime.GOOS != "linux" {
|
||||||
t.Skip("seccomp, which is enabled by default, is only supported on Linux")
|
t.Skip("seccomp, which is enabled by default, is only supported on Linux")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if rootless.IsRootless() {
|
||||||
|
isCgroupV2, err := cgroups.IsCgroup2UnifiedMode()
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("unexpected error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !isCgroupV2 {
|
||||||
|
t.Skip("cgroups v1 cannot be used when rootless")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestPIDsLimit verifies the given pid-limit is correctly defined in the spec
|
||||||
|
func TestPIDsLimit(t *testing.T) {
|
||||||
|
doCommonSkipChecks(t)
|
||||||
|
|
||||||
if !sysInfo.PidsLimit {
|
if !sysInfo.PidsLimit {
|
||||||
t.Skip("running test not supported by the host system")
|
t.Skip("running test not supported by the host system")
|
||||||
}
|
}
|
||||||
@ -50,12 +68,8 @@ func TestPIDsLimit(t *testing.T) {
|
|||||||
// TestBLKIOWeightDevice verifies the given blkio weight is correctly set in the
|
// TestBLKIOWeightDevice verifies the given blkio weight is correctly set in the
|
||||||
// spec.
|
// spec.
|
||||||
func TestBLKIOWeightDevice(t *testing.T) {
|
func TestBLKIOWeightDevice(t *testing.T) {
|
||||||
// The default configuration of podman enables seccomp, which is not available on non-Linux systems.
|
doCommonSkipChecks(t)
|
||||||
// Thus, any tests that use the default seccomp setting would fail.
|
|
||||||
// Skip the tests on non-Linux platforms rather than explicitly disable seccomp in the test and possibly affect the test result.
|
|
||||||
if runtime.GOOS != "linux" {
|
|
||||||
t.Skip("seccomp, which is enabled by default, is only supported on Linux")
|
|
||||||
}
|
|
||||||
if !sysInfo.BlkioWeightDevice {
|
if !sysInfo.BlkioWeightDevice {
|
||||||
t.Skip("running test not supported by the host system")
|
t.Skip("running test not supported by the host system")
|
||||||
}
|
}
|
||||||
@ -75,12 +89,8 @@ func TestBLKIOWeightDevice(t *testing.T) {
|
|||||||
// TestMemorySwap verifies that the given swap memory limit is correctly set in
|
// TestMemorySwap verifies that the given swap memory limit is correctly set in
|
||||||
// the spec.
|
// the spec.
|
||||||
func TestMemorySwap(t *testing.T) {
|
func TestMemorySwap(t *testing.T) {
|
||||||
// The default configuration of podman enables seccomp, which is not available on non-Linux systems.
|
doCommonSkipChecks(t)
|
||||||
// Thus, any tests that use the default seccomp setting would fail.
|
|
||||||
// Skip the tests on non-Linux platforms rather than explicitly disable seccomp in the test and possibly affect the test result.
|
|
||||||
if runtime.GOOS != "linux" {
|
|
||||||
t.Skip("seccomp, which is enabled by default, is only supported on Linux")
|
|
||||||
}
|
|
||||||
if !sysInfo.SwapLimit {
|
if !sysInfo.SwapLimit {
|
||||||
t.Skip("running test not supported by the host system")
|
t.Skip("running test not supported by the host system")
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user