[llvm] r289964 - [libFuzzer] Update tests to use more general functions instead of posix specific.

Marcos Pividori via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 16 09:35:13 PST 2016


Author: mpividori
Date: Fri Dec 16 11:35:13 2016
New Revision: 289964

URL: http://llvm.org/viewvc/llvm-project?rev=289964&view=rev
Log:
[libFuzzer] Update tests to use more general functions instead of posix specific.

Replace sleep() posix function by a more portable sleep_for() function
from std. Also, ignore memmem() and strcasestr() on Windows.

Differential Revision: https://reviews.llvm.org/D27729

Modified:
    llvm/trunk/lib/Fuzzer/test/OutOfMemoryTest.cpp
    llvm/trunk/lib/Fuzzer/test/StrstrTest.cpp

Modified: llvm/trunk/lib/Fuzzer/test/OutOfMemoryTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/test/OutOfMemoryTest.cpp?rev=289964&r1=289963&r2=289964&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/test/OutOfMemoryTest.cpp (original)
+++ llvm/trunk/lib/Fuzzer/test/OutOfMemoryTest.cpp Fri Dec 16 11:35:13 2016
@@ -8,6 +8,7 @@
 #include <cstddef>
 #include <cstring>
 #include <iostream>
+#include <thread>
 #include <unistd.h>
 
 static volatile char *SinkPtr;
@@ -21,7 +22,7 @@ extern "C" int LLVMFuzzerTestOneInput(co
           char *p = new char[kSize];
           memset(p, 0, kSize);
           SinkPtr = p;
-          sleep(1);
+          std::this_thread::sleep_for(std::chrono::seconds(1));
         }
       }
     }

Modified: llvm/trunk/lib/Fuzzer/test/StrstrTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/test/StrstrTest.cpp?rev=289964&r1=289963&r2=289964&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/test/StrstrTest.cpp (original)
+++ llvm/trunk/lib/Fuzzer/test/StrstrTest.cpp Fri Dec 16 11:35:13 2016
@@ -8,6 +8,12 @@
 #include <cstdio>
 #include <cstdlib>
 
+// Windows does not have strcasestr and memmem, so we are not testing them.
+#ifdef _WIN32
+#define strcasestr strstr
+#define memmem(a, b, c, d) true
+#endif
+
 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
   if (Size < 4) return 0;
   std::string s(reinterpret_cast<const char*>(Data), Size);




More information about the llvm-commits mailing list