summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Fuzzer/test
diff options
context:
space:
mode:
authorMarcos Pividori <mpividori@google.com>2016-12-16 17:35:13 +0000
committerMarcos Pividori <mpividori@google.com>2016-12-16 17:35:13 +0000
commit6a7e4c2e202629c9d60719d7ee0fea4b9eb52c93 (patch)
tree4ab64329ec709b80f3efb12090daf49e57decc18 /llvm/lib/Fuzzer/test
parent6c293673303a1bdc8f3c86f544ff6936fbaa28b8 (diff)
downloadbcm5719-llvm-6a7e4c2e202629c9d60719d7ee0fea4b9eb52c93.tar.gz
bcm5719-llvm-6a7e4c2e202629c9d60719d7ee0fea4b9eb52c93.zip
[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 llvm-svn: 289964
Diffstat (limited to 'llvm/lib/Fuzzer/test')
-rw-r--r--llvm/lib/Fuzzer/test/OutOfMemoryTest.cpp3
-rw-r--r--llvm/lib/Fuzzer/test/StrstrTest.cpp6
2 files changed, 8 insertions, 1 deletions
diff --git a/llvm/lib/Fuzzer/test/OutOfMemoryTest.cpp b/llvm/lib/Fuzzer/test/OutOfMemoryTest.cpp
index e5c9f0a038f..18949c7c8c9 100644
--- a/llvm/lib/Fuzzer/test/OutOfMemoryTest.cpp
+++ b/llvm/lib/Fuzzer/test/OutOfMemoryTest.cpp
@@ -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(const uint8_t *Data, size_t Size) {
char *p = new char[kSize];
memset(p, 0, kSize);
SinkPtr = p;
- sleep(1);
+ std::this_thread::sleep_for(std::chrono::seconds(1));
}
}
}
diff --git a/llvm/lib/Fuzzer/test/StrstrTest.cpp b/llvm/lib/Fuzzer/test/StrstrTest.cpp
index dd839530940..f021e75ec0f 100644
--- a/llvm/lib/Fuzzer/test/StrstrTest.cpp
+++ b/llvm/lib/Fuzzer/test/StrstrTest.cpp
@@ -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);
OpenPOWER on IntegriCloud