MCPcopy
hub / github.com/containerd/containerd / initInSteps

Function initInSteps

integration/client/container_fuzz_test.go:89–121  ·  view source on GitHub ↗

initInSteps() performs initialization in several steps The reason for spreading the initialization out in multiple steps is that each fuzz iteration can maximum take 25 seconds when running through OSS-fuzz. Should an iteration exceed that, then the fuzzer stops.

(t *testing.T)

Source from the content-addressed store, hash-verified

87// take 25 seconds when running through OSS-fuzz.
88// Should an iteration exceed that, then the fuzzer stops.
89func initInSteps(t *testing.T) bool {
90 // Download binaries
91 if !haveDownloadedbinaries {
92 if err := downloadFile(downloadPath, downloadLink); err != nil {
93 t.Fatalf("failed to download containerd: %v", err)
94 }
95 haveDownloadedbinaries = true
96 return true
97 }
98 // Extract binaries
99 if !haveExtractedBinaries {
100
101 if err := os.MkdirAll(downloadBinDir, 0777); err != nil {
102 return true
103 }
104 cmd := exec.Command("tar", "xvf", downloadPath, "-C", downloadBinDir)
105
106 if err := cmd.Run(); err != nil {
107 return true
108 }
109 haveExtractedBinaries = true
110 return true
111 }
112 // Add binaries to $PATH:
113 if !haveChangedDownloadPATH {
114 oldPathEnv := os.Getenv("PATH")
115 newPathEnv := fmt.Sprintf("%s:%s", filepath.Join(downloadBinDir, "bin"), oldPathEnv)
116 t.Setenv("PATH", newPathEnv)
117 haveChangedDownloadPATH = true
118 return true
119 }
120 return false
121}
122
123func tearDown() error {
124 if err := ctrd.Stop(); err != nil {

Callers 1

Calls 3

downloadFileFunction · 0.85
MkdirAllMethod · 0.65
RunMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…