@@ -15,6 +15,7 @@ import (
1515
1616 "github.com/Sirupsen/logrus"
1717 "github.com/hashicorp/go-multierror"
18+ "github.com/mndrix/tap-go"
1819 rspec "github.com/opencontainers/runtime-spec/specs-go"
1920 "github.com/opencontainers/runtime-tools/cmd/runtimetest/mount"
2021 "github.com/syndtr/gocapability/capability"
5354 }
5455)
5556
56- type validation func (* rspec.Spec ) error
57+ type validation struct {
58+ test func (* rspec.Spec ) error
59+ description string
60+ }
5761
5862func loadSpecConfig () (spec * rspec.Spec , err error ) {
5963 cf , err := os .Open (specConfig )
@@ -588,41 +592,97 @@ func validate(context *cli.Context) error {
588592 }
589593
590594 defaultValidations := []validation {
591- validateRootFS ,
592- validateHostname ,
593- validateMountsExist ,
595+ {
596+ test : validateRootFS ,
597+ description : "root filesystem" ,
598+ },
599+ {
600+ test : validateHostname ,
601+ description : "hostname" ,
602+ },
603+ {
604+ test : validateMountsExist ,
605+ description : "mounts" ,
606+ },
594607 }
595608
596609 linuxValidations := []validation {
597- validateCapabilities ,
598- validateDefaultSymlinks ,
599- validateDefaultFS ,
600- validateDefaultDevices ,
601- validateLinuxDevices ,
602- validateLinuxProcess ,
603- validateMaskedPaths ,
604- validateOOMScoreAdj ,
605- validateROPaths ,
606- validateRlimits ,
607- validateSysctls ,
608- validateUIDMappings ,
609- validateGIDMappings ,
610+ {
611+ test : validateCapabilities ,
612+ description : "capabilities" ,
613+ },
614+ {
615+ test : validateDefaultSymlinks ,
616+ description : "default symlinks" ,
617+ },
618+ {
619+ test : validateDefaultFS ,
620+ description : "default file system" ,
621+ },
622+ {
623+ test : validateDefaultDevices ,
624+ description : "default devices" ,
625+ },
626+ {
627+ test : validateLinuxDevices ,
628+ description : "linux devices" ,
629+ },
630+ {
631+ test : validateLinuxProcess ,
632+ description : "linux process" ,
633+ },
634+ {
635+ test : validateMaskedPaths ,
636+ description : "masked paths" ,
637+ },
638+ {
639+ test : validateOOMScoreAdj ,
640+ description : "oom score adj" ,
641+ },
642+ {
643+ test : validateROPaths ,
644+ description : "read only paths" ,
645+ },
646+ {
647+ test : validateRlimits ,
648+ description : "rlimits" ,
649+ },
650+ {
651+ test : validateSysctls ,
652+ description : "sysctls" ,
653+ },
654+ {
655+ test : validateUIDMappings ,
656+ description : "uid mappings" ,
657+ },
658+ {
659+ test : validateGIDMappings ,
660+ description : "gid mappings" ,
661+ },
610662 }
611663
664+ t := tap .New ()
665+ t .Header (0 )
666+
612667 var validationErrors error
613668 for _ , v := range defaultValidations {
614- if err := v (spec ); err != nil {
669+ err := v .test (spec )
670+ t .Ok (err == nil , v .description )
671+ if err != nil {
615672 validationErrors = multierror .Append (validationErrors , err )
616673 }
617674 }
618675
619676 if spec .Platform .OS == "linux" {
620677 for _ , v := range linuxValidations {
621- if err := v (spec ); err != nil {
678+ err := v .test (spec )
679+ t .Ok (err == nil , v .description )
680+ if err != nil {
622681 validationErrors = multierror .Append (validationErrors , err )
623682 }
624683 }
625684 }
685+ t .AutoPlan ()
626686
627687 return validationErrors
628688}
0 commit comments