Skip to content

Commit 216ebc7

Browse files
authored
Merge pull request #594 from kinvolk/alban/593-tapError-count
runtimetest: count correctly TAP tests
2 parents 4492c1d + c9b4d66 commit 216ebc7

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed

cmd/runtimetest/main.go

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ var (
6969
)
7070

7171
type validation struct {
72-
test func(*rspec.Spec) error
72+
test func(*rspec.Spec, *tap.T) error
7373
description string
7474
}
7575

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

94-
func validatePosixUser(spec *rspec.Spec) error {
94+
func validatePosixUser(spec *rspec.Spec, t *tap.T) error {
9595
if spec.Process == nil {
9696
return nil
9797
}
@@ -124,7 +124,7 @@ func validatePosixUser(spec *rspec.Spec) error {
124124
return nil
125125
}
126126

127-
func validateProcess(spec *rspec.Spec) error {
127+
func validateProcess(spec *rspec.Spec, t *tap.T) error {
128128
if spec.Process == nil {
129129
return nil
130130
}
@@ -152,7 +152,7 @@ func validateProcess(spec *rspec.Spec) error {
152152
return nil
153153
}
154154

155-
func validateLinuxProcess(spec *rspec.Spec) error {
155+
func validateLinuxProcess(spec *rspec.Spec, t *tap.T) error {
156156
if spec.Process == nil {
157157
return nil
158158
}
@@ -186,7 +186,7 @@ func validateLinuxProcess(spec *rspec.Spec) error {
186186
return nil
187187
}
188188

189-
func validateCapabilities(spec *rspec.Spec) error {
189+
func validateCapabilities(spec *rspec.Spec, t *tap.T) error {
190190
if spec.Process == nil || spec.Process.Capabilities == nil {
191191
return nil
192192
}
@@ -251,7 +251,7 @@ func validateCapabilities(spec *rspec.Spec) error {
251251
return nil
252252
}
253253

254-
func validateHostname(spec *rspec.Spec) error {
254+
func validateHostname(spec *rspec.Spec, t *tap.T) error {
255255
hostname, err := os.Hostname()
256256
if err != nil {
257257
return err
@@ -262,7 +262,7 @@ func validateHostname(spec *rspec.Spec) error {
262262
return nil
263263
}
264264

265-
func validateRlimits(spec *rspec.Spec) error {
265+
func validateRlimits(spec *rspec.Spec, t *tap.T) error {
266266
if spec.Process == nil {
267267
return nil
268268
}
@@ -288,7 +288,7 @@ func validateRlimits(spec *rspec.Spec) error {
288288
return nil
289289
}
290290

291-
func validateSysctls(spec *rspec.Spec) error {
291+
func validateSysctls(spec *rspec.Spec, t *tap.T) error {
292292
if spec.Linux == nil {
293293
return nil
294294
}
@@ -318,7 +318,7 @@ func testWriteAccess(path string) error {
318318
return nil
319319
}
320320

321-
func validateRootFS(spec *rspec.Spec) error {
321+
func validateRootFS(spec *rspec.Spec, t *tap.T) error {
322322
if spec.Root == nil {
323323
return nil
324324
}
@@ -333,7 +333,7 @@ func validateRootFS(spec *rspec.Spec) error {
333333
return nil
334334
}
335335

336-
func validateRootfsPropagation(spec *rspec.Spec) error {
336+
func validateRootfsPropagation(spec *rspec.Spec, t *tap.T) error {
337337
if spec.Linux == nil || spec.Linux.RootfsPropagation == "" {
338338
return nil
339339
}
@@ -398,7 +398,7 @@ func validateRootfsPropagation(spec *rspec.Spec) error {
398398
return nil
399399
}
400400

401-
func validateDefaultFS(spec *rspec.Spec) error {
401+
func validateDefaultFS(spec *rspec.Spec, t *tap.T) error {
402402
mountInfos, err := mount.GetMounts()
403403
if err != nil {
404404
specerror.NewError(specerror.DefaultFilesystems, err, spec.Version)
@@ -418,7 +418,7 @@ func validateDefaultFS(spec *rspec.Spec) error {
418418
return nil
419419
}
420420

421-
func validateLinuxDevices(spec *rspec.Spec) error {
421+
func validateLinuxDevices(spec *rspec.Spec, t *tap.T) error {
422422
if spec.Linux == nil {
423423
return nil
424424
}
@@ -475,7 +475,7 @@ func validateLinuxDevices(spec *rspec.Spec) error {
475475
return nil
476476
}
477477

478-
func validateDefaultSymlinks(spec *rspec.Spec) error {
478+
func validateDefaultSymlinks(spec *rspec.Spec, t *tap.T) error {
479479
for symlink, dest := range defaultSymlinks {
480480
fi, err := os.Lstat(symlink)
481481
if err != nil {
@@ -501,7 +501,7 @@ func validateDefaultSymlinks(spec *rspec.Spec) error {
501501
return nil
502502
}
503503

504-
func validateDefaultDevices(spec *rspec.Spec) error {
504+
func validateDefaultDevices(spec *rspec.Spec, t *tap.T) error {
505505
if spec.Process != nil && spec.Process.Terminal {
506506
defaultDevices = append(defaultDevices, "/dev/console")
507507
}
@@ -526,7 +526,7 @@ func validateDefaultDevices(spec *rspec.Spec) error {
526526
return nil
527527
}
528528

529-
func validateMaskedPaths(spec *rspec.Spec) error {
529+
func validateMaskedPaths(spec *rspec.Spec, t *tap.T) error {
530530
if spec.Linux == nil {
531531
return nil
532532
}
@@ -545,11 +545,10 @@ func validateMaskedPaths(spec *rspec.Spec) error {
545545
return nil
546546
}
547547

548-
func validateSeccomp(spec *rspec.Spec) error {
548+
func validateSeccomp(spec *rspec.Spec, t *tap.T) error {
549549
if spec.Linux == nil || spec.Linux.Seccomp == nil {
550550
return nil
551551
}
552-
t := tap.New()
553552
for _, sys := range spec.Linux.Seccomp.Syscalls {
554553
if sys.Action == "SCMP_ACT_ERRNO" {
555554
for _, name := range sys.Names {
@@ -569,7 +568,7 @@ func validateSeccomp(spec *rspec.Spec) error {
569568
return nil
570569
}
571570

572-
func validateROPaths(spec *rspec.Spec) error {
571+
func validateROPaths(spec *rspec.Spec, t *tap.T) error {
573572
if spec.Linux == nil {
574573
return nil
575574
}
@@ -583,7 +582,7 @@ func validateROPaths(spec *rspec.Spec) error {
583582
return nil
584583
}
585584

586-
func validateOOMScoreAdj(spec *rspec.Spec) error {
585+
func validateOOMScoreAdj(spec *rspec.Spec, t *tap.T) error {
587586
if spec.Process != nil && spec.Process.OOMScoreAdj != nil {
588587
expected := *spec.Process.OOMScoreAdj
589588
f, err := os.Open("/proc/self/oom_score_adj")
@@ -674,14 +673,14 @@ func validateIDMappings(mappings []rspec.LinuxIDMapping, path string, property s
674673
return nil
675674
}
676675

677-
func validateUIDMappings(spec *rspec.Spec) error {
676+
func validateUIDMappings(spec *rspec.Spec, t *tap.T) error {
678677
if spec.Linux == nil {
679678
return nil
680679
}
681680
return validateIDMappings(spec.Linux.UIDMappings, "/proc/self/uid_map", "linux.uidMappings")
682681
}
683682

684-
func validateGIDMappings(spec *rspec.Spec) error {
683+
func validateGIDMappings(spec *rspec.Spec, t *tap.T) error {
685684
if spec.Linux == nil {
686685
return nil
687686
}
@@ -710,7 +709,7 @@ func mountMatch(configMount rspec.Mount, sysMount *mount.Info) error {
710709
return nil
711710
}
712711

713-
func validatePosixMounts(spec *rspec.Spec) error {
712+
func validatePosixMounts(spec *rspec.Spec, t *tap.T) error {
714713
mountInfos, err := mount.GetMounts()
715714
if err != nil {
716715
return err
@@ -904,7 +903,7 @@ func run(context *cli.Context) error {
904903
}
905904

906905
for _, v := range validations {
907-
err := v.test(spec)
906+
err := v.test(spec, t)
908907
if err == nil {
909908
t.Pass(v.description)
910909
} else {

0 commit comments

Comments
 (0)