fuzz_test.go 671 B

123456789101112131415161718192021222324252627282930
  1. package oci
  2. import (
  3. "testing"
  4. fuzz "github.com/AdaLogics/go-fuzz-headers"
  5. specs "github.com/opencontainers/runtime-spec/specs-go"
  6. )
  7. func FuzzAppendDevicePermissionsFromCgroupRules(f *testing.F) {
  8. f.Fuzz(func(t *testing.T, data []byte) {
  9. ff := fuzz.NewConsumer(data)
  10. sp := make([]specs.LinuxDeviceCgroup, 0)
  11. noOfRecords, err := ff.GetInt()
  12. if err != nil {
  13. return
  14. }
  15. for i := 0; i < noOfRecords%40; i++ {
  16. s := specs.LinuxDeviceCgroup{}
  17. err := ff.GenerateStruct(&s)
  18. if err != nil {
  19. return
  20. }
  21. sp = append(sp, s)
  22. }
  23. rules := make([]string, 0)
  24. ff.CreateSlice(&rules)
  25. _, _ = AppendDevicePermissionsFromCgroupRules(sp, rules)
  26. })
  27. }