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)
| 87 | // take 25 seconds when running through OSS-fuzz. |
| 88 | // Should an iteration exceed that, then the fuzzer stops. |
| 89 | func 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 | |
| 123 | func tearDown() error { |
| 124 | if err := ctrd.Stop(); err != nil { |
no test coverage detected
searching dependent graphs…