(f *testing.F)
| 32 | } |
| 33 | |
| 34 | func FuzzContainerdImport(f *testing.F) { |
| 35 | if os.Getuid() != 0 { |
| 36 | f.Skip("skipping fuzz test that requires root") |
| 37 | } |
| 38 | |
| 39 | f.Fuzz(func(t *testing.T, data []byte) { |
| 40 | initDaemon.Do(startDaemon) |
| 41 | |
| 42 | client, err := containerd.New(defaultAddress) |
| 43 | if err != nil { |
| 44 | t.Fatal(err) |
| 45 | } |
| 46 | defer client.Close() |
| 47 | |
| 48 | f := fuzz.NewConsumer(data) |
| 49 | |
| 50 | noOfImports, err := f.GetInt() |
| 51 | if err != nil { |
| 52 | return |
| 53 | } |
| 54 | maxImports := 20 |
| 55 | ctx, cancel := fuzzContext() |
| 56 | defer cancel() |
| 57 | for i := 0; i < noOfImports%maxImports; i++ { |
| 58 | tarBytes, err := f.GetBytes() |
| 59 | if err != nil { |
| 60 | return |
| 61 | } |
| 62 | _, _ = client.Import(ctx, bytes.NewReader(tarBytes)) |
| 63 | } |
| 64 | }) |
| 65 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…