Skip to content

Commit 4794350

Browse files
authored
Merge pull request #591 from q384566678/process-error
Implement PosixProcRlimitsTypeGenError and LinuxProcCapError
2 parents 34d0d59 + ac12f97 commit 4794350

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"os"
6+
"runtime"
7+
8+
rspecs "github.com/opencontainers/runtime-spec/specs-go"
9+
"github.com/opencontainers/runtime-tools/specerror"
10+
"github.com/opencontainers/runtime-tools/validation/util"
11+
)
12+
13+
func main() {
14+
if "linux" != runtime.GOOS {
15+
util.Skip("linux-specific process.capabilities test", map[string]string{"OS": runtime.GOOS})
16+
os.Exit(0)
17+
}
18+
19+
g := util.GetDefaultGenerator()
20+
g.AddProcessCapabilityBounding("CAP_TEST")
21+
err := util.RuntimeInsideValidate(g, nil)
22+
if err == nil {
23+
util.Fatal(specerror.NewError(specerror.LinuxProcCapError, fmt.Errorf("Any value which cannot be mapped to a relevant kernel interface MUST cause an error"), rspecs.Version))
24+
}
25+
}

validation/process_rlimits_fail.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
6+
rspecs "github.com/opencontainers/runtime-spec/specs-go"
7+
"github.com/opencontainers/runtime-tools/specerror"
8+
"github.com/opencontainers/runtime-tools/validation/util"
9+
)
10+
11+
func main() {
12+
g := util.GetDefaultGenerator()
13+
g.AddProcessRlimits("RLIMIT_TEST", 1024, 1024)
14+
err := util.RuntimeInsideValidate(g, nil)
15+
if err == nil {
16+
util.Fatal(specerror.NewError(specerror.PosixProcRlimitsTypeGenError, fmt.Errorf("The runtime MUST generate an error for any values which cannot be mapped to a relevant kernel interface"), rspecs.Version))
17+
}
18+
}

0 commit comments

Comments
 (0)