Skip to content

Commit eebd4e6

Browse files
committed
Add new requirements (HyperV, RootfulOrCGroupV2)
Signed-off-by: apostasie <[email protected]>
1 parent 07cb00b commit eebd4e6

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed

pkg/testutil/nerdtest/requirements.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,20 @@ var CGroup = &test.Requirement{
171171
},
172172
}
173173

174+
var RootfulOrCGroupV2 = &test.Requirement{
175+
Check: func(data test.Data, helpers test.Helpers) (ret bool, mess string) {
176+
isRootLess := getTarget() == targetNerdctl && rootlessutil.IsRootless()
177+
if isRootLess {
178+
stdout := helpers.Capture("info", "--format", "{{ json . }}")
179+
var dinf dockercompat.Info
180+
err := json.Unmarshal([]byte(stdout), &dinf)
181+
assert.NilError(helpers.T(), err, "failed to parse docker info")
182+
return dinf.CgroupVersion == "2", "we are rootless, and cgroup version is not 2"
183+
}
184+
return true, ""
185+
},
186+
}
187+
174188
// Soci requires that the soci snapshotter is enabled
175189
var Soci = &test.Requirement{
176190
Check: func(data test.Data, helpers test.Helpers) (ret bool, mess string) {
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//go:build !windows
2+
3+
/*
4+
Copyright The containerd Authors.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
*/
18+
19+
package nerdtest
20+
21+
import (
22+
"github.com/containerd/nerdctl/v2/pkg/testutil/test"
23+
)
24+
25+
var HyperV = &test.Requirement{
26+
Check: func(data test.Data, helpers test.Helpers) (ret bool, mess string) {
27+
return false, "HyperV is a windows-only feature"
28+
},
29+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
Copyright The containerd Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package nerdtest
18+
19+
import (
20+
"github.com/containerd/nerdctl/v2/pkg/testutil"
21+
"github.com/containerd/nerdctl/v2/pkg/testutil/test"
22+
)
23+
24+
var HyperV = &test.Requirement{
25+
Check: func(data test.Data, helpers test.Helpers) (ret bool, mess string) {
26+
return testutil.HyperVSupported(), "HyperV is not enabled, skipping test"
27+
},
28+
}

0 commit comments

Comments
 (0)