github.com/rawahars/moby@v24.0.4+incompatible/oci/fuzz_test.go (about)

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