diff options
Diffstat (limited to 'lib/Fuzzer/FuzzerIOPosix.cpp')
-rw-r--r-- | lib/Fuzzer/FuzzerIOPosix.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/Fuzzer/FuzzerIOPosix.cpp b/lib/Fuzzer/FuzzerIOPosix.cpp index 6d8edf6ff538..c5ebdbac467b 100644 --- a/lib/Fuzzer/FuzzerIOPosix.cpp +++ b/lib/Fuzzer/FuzzerIOPosix.cpp @@ -75,6 +75,18 @@ void RemoveFile(const std::string &Path) { unlink(Path.c_str()); } +void DiscardOutput(int Fd) { + FILE* Temp = fopen("/dev/null", "w"); + if (!Temp) + return; + dup2(fileno(Temp), Fd); + fclose(Temp); +} + +intptr_t GetHandleFromFd(int fd) { + return static_cast<intptr_t>(fd); +} + std::string DirName(const std::string &FileName) { char *Tmp = new char[FileName.size() + 1]; memcpy(Tmp, FileName.c_str(), FileName.size() + 1); @@ -89,6 +101,23 @@ std::string TmpDir() { return "/tmp"; } +bool IsInterestingCoverageFile(const std::string &FileName) { + if (FileName.find("compiler-rt/lib/") != std::string::npos) + return false; // sanitizer internal. + if (FileName.find("/usr/lib/") != std::string::npos) + return false; + if (FileName.find("/usr/include/") != std::string::npos) + return false; + if (FileName == "<null>") + return false; + return true; +} + + +void RawPrint(const char *Str) { + write(2, Str, strlen(Str)); +} + } // namespace fuzzer #endif // LIBFUZZER_POSIX |