Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 22 additions & 23 deletions cmd/runtimetest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ var (
)

type validation struct {
test func(*rspec.Spec) error
test func(*rspec.Spec, *tap.T) error
description string
}

Expand All @@ -91,7 +91,7 @@ func loadSpecConfig(path string) (spec *rspec.Spec, err error) {
return spec, nil
}

func validatePosixUser(spec *rspec.Spec) error {
func validatePosixUser(spec *rspec.Spec, t *tap.T) error {
if spec.Process == nil {
return nil
}
Expand Down Expand Up @@ -124,7 +124,7 @@ func validatePosixUser(spec *rspec.Spec) error {
return nil
}

func validateProcess(spec *rspec.Spec) error {
func validateProcess(spec *rspec.Spec, t *tap.T) error {
if spec.Process == nil {
return nil
}
Expand Down Expand Up @@ -152,7 +152,7 @@ func validateProcess(spec *rspec.Spec) error {
return nil
}

func validateLinuxProcess(spec *rspec.Spec) error {
func validateLinuxProcess(spec *rspec.Spec, t *tap.T) error {
if spec.Process == nil {
return nil
}
Expand Down Expand Up @@ -186,7 +186,7 @@ func validateLinuxProcess(spec *rspec.Spec) error {
return nil
}

func validateCapabilities(spec *rspec.Spec) error {
func validateCapabilities(spec *rspec.Spec, t *tap.T) error {
if spec.Process == nil || spec.Process.Capabilities == nil {
return nil
}
Expand Down Expand Up @@ -251,7 +251,7 @@ func validateCapabilities(spec *rspec.Spec) error {
return nil
}

func validateHostname(spec *rspec.Spec) error {
func validateHostname(spec *rspec.Spec, t *tap.T) error {
hostname, err := os.Hostname()
if err != nil {
return err
Expand All @@ -262,7 +262,7 @@ func validateHostname(spec *rspec.Spec) error {
return nil
}

func validateRlimits(spec *rspec.Spec) error {
func validateRlimits(spec *rspec.Spec, t *tap.T) error {
if spec.Process == nil {
return nil
}
Expand All @@ -288,7 +288,7 @@ func validateRlimits(spec *rspec.Spec) error {
return nil
}

func validateSysctls(spec *rspec.Spec) error {
func validateSysctls(spec *rspec.Spec, t *tap.T) error {
if spec.Linux == nil {
return nil
}
Expand Down Expand Up @@ -318,7 +318,7 @@ func testWriteAccess(path string) error {
return nil
}

func validateRootFS(spec *rspec.Spec) error {
func validateRootFS(spec *rspec.Spec, t *tap.T) error {
if spec.Root == nil {
return nil
}
Expand All @@ -338,7 +338,7 @@ func validateRootFS(spec *rspec.Spec) error {
return nil
}

func validateRootfsPropagation(spec *rspec.Spec) error {
func validateRootfsPropagation(spec *rspec.Spec, t *tap.T) error {
if spec.Linux == nil || spec.Linux.RootfsPropagation == "" {
return nil
}
Expand Down Expand Up @@ -403,7 +403,7 @@ func validateRootfsPropagation(spec *rspec.Spec) error {
return nil
}

func validateDefaultFS(spec *rspec.Spec) error {
func validateDefaultFS(spec *rspec.Spec, t *tap.T) error {
mountInfos, err := mount.GetMounts()
if err != nil {
specerror.NewError(specerror.DefaultFilesystems, err, spec.Version)
Expand All @@ -423,7 +423,7 @@ func validateDefaultFS(spec *rspec.Spec) error {
return nil
}

func validateLinuxDevices(spec *rspec.Spec) error {
func validateLinuxDevices(spec *rspec.Spec, t *tap.T) error {
if spec.Linux == nil {
return nil
}
Expand Down Expand Up @@ -480,7 +480,7 @@ func validateLinuxDevices(spec *rspec.Spec) error {
return nil
}

func validateDefaultSymlinks(spec *rspec.Spec) error {
func validateDefaultSymlinks(spec *rspec.Spec, t *tap.T) error {
for symlink, dest := range defaultSymlinks {
fi, err := os.Lstat(symlink)
if err != nil {
Expand All @@ -506,7 +506,7 @@ func validateDefaultSymlinks(spec *rspec.Spec) error {
return nil
}

func validateDefaultDevices(spec *rspec.Spec) error {
func validateDefaultDevices(spec *rspec.Spec, t *tap.T) error {
if spec.Process != nil && spec.Process.Terminal {
defaultDevices = append(defaultDevices, "/dev/console")
}
Expand All @@ -531,7 +531,7 @@ func validateDefaultDevices(spec *rspec.Spec) error {
return nil
}

func validateMaskedPaths(spec *rspec.Spec) error {
func validateMaskedPaths(spec *rspec.Spec, t *tap.T) error {
if spec.Linux == nil {
return nil
}
Expand All @@ -550,11 +550,10 @@ func validateMaskedPaths(spec *rspec.Spec) error {
return nil
}

func validateSeccomp(spec *rspec.Spec) error {
func validateSeccomp(spec *rspec.Spec, t *tap.T) error {
if spec.Linux == nil || spec.Linux.Seccomp == nil {
return nil
}
t := tap.New()
for _, sys := range spec.Linux.Seccomp.Syscalls {
if sys.Action == "SCMP_ACT_ERRNO" {
for _, name := range sys.Names {
Expand All @@ -574,7 +573,7 @@ func validateSeccomp(spec *rspec.Spec) error {
return nil
}

func validateROPaths(spec *rspec.Spec) error {
func validateROPaths(spec *rspec.Spec, t *tap.T) error {
if spec.Linux == nil {
return nil
}
Expand All @@ -588,7 +587,7 @@ func validateROPaths(spec *rspec.Spec) error {
return nil
}

func validateOOMScoreAdj(spec *rspec.Spec) error {
func validateOOMScoreAdj(spec *rspec.Spec, t *tap.T) error {
if spec.Process != nil && spec.Process.OOMScoreAdj != nil {
expected := *spec.Process.OOMScoreAdj
f, err := os.Open("/proc/self/oom_score_adj")
Expand Down Expand Up @@ -679,14 +678,14 @@ func validateIDMappings(mappings []rspec.LinuxIDMapping, path string, property s
return nil
}

func validateUIDMappings(spec *rspec.Spec) error {
func validateUIDMappings(spec *rspec.Spec, t *tap.T) error {
if spec.Linux == nil {
return nil
}
return validateIDMappings(spec.Linux.UIDMappings, "/proc/self/uid_map", "linux.uidMappings")
}

func validateGIDMappings(spec *rspec.Spec) error {
func validateGIDMappings(spec *rspec.Spec, t *tap.T) error {
if spec.Linux == nil {
return nil
}
Expand Down Expand Up @@ -715,7 +714,7 @@ func mountMatch(configMount rspec.Mount, sysMount *mount.Info) error {
return nil
}

func validatePosixMounts(spec *rspec.Spec) error {
func validatePosixMounts(spec *rspec.Spec, t *tap.T) error {
mountInfos, err := mount.GetMounts()
if err != nil {
return err
Expand Down Expand Up @@ -909,7 +908,7 @@ func run(context *cli.Context) error {
}

for _, v := range validations {
err := v.test(spec)
err := v.test(spec, t)
if err == nil {
t.Pass(v.description)
} else {
Expand Down