MCPcopy
hub / github.com/containerd/containerd / FuzzContainerdImport

Function FuzzContainerdImport

contrib/fuzz/containerd_import_fuzz_test.go:34–65  ·  view source on GitHub ↗
(f *testing.F)

Source from the content-addressed store, hash-verified

32}
33
34func 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}

Callers

nothing calls this directly

Calls 5

fuzzContextFunction · 0.85
DoMethod · 0.80
FatalMethod · 0.80
CloseMethod · 0.65
ImportMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…