diff options
Diffstat (limited to 'compiler-rt/lib/sanitizer_common/tests')
7 files changed, 40 insertions, 19 deletions
diff --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cc b/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cc index ee977682bf1..abde2088998 100644 --- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cc +++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cc @@ -17,11 +17,11 @@ #include "sanitizer_common/sanitizer_flags.h" #include "sanitizer_test_utils.h" +#include "sanitizer_pthread_wrappers.h" #include "gtest/gtest.h" #include <stdlib.h> -#include <pthread.h> #include <algorithm> #include <vector> #include <set> @@ -553,8 +553,8 @@ TEST(SanitizerCommon, AllocatorLeakTest) { uptr total_used_memory = 0; for (int i = 0; i < 100; i++) { pthread_t t; - EXPECT_EQ(0, pthread_create(&t, 0, AllocatorLeakTestWorker, &a)); - EXPECT_EQ(0, pthread_join(t, 0)); + PTHREAD_CREATE(&t, 0, AllocatorLeakTestWorker, &a); + PTHREAD_JOIN(t, 0); if (i == 0) total_used_memory = a.TotalMemoryUsed(); EXPECT_EQ(a.TotalMemoryUsed(), total_used_memory); @@ -595,8 +595,8 @@ TEST(Allocator, AllocatorCacheDeallocNewThread) { params->allocator = &allocator; params->class_id = class_id; pthread_t t; - EXPECT_EQ(0, pthread_create(&t, 0, DeallocNewThreadWorker, params)); - EXPECT_EQ(0, pthread_join(t, 0)); + PTHREAD_CREATE(&t, 0, DeallocNewThreadWorker, params); + PTHREAD_JOIN(t, 0); } #endif @@ -843,10 +843,10 @@ TEST(SanitizerCommon, ThreadedTwoLevelByteMap) { p[i].m = &m; p[i].shard = i; p[i].num_shards = kNumThreads; - EXPECT_EQ(0, pthread_create(&t[i], 0, TwoLevelByteMapUserThread, &p[i])); + PTHREAD_CREATE(&t[i], 0, TwoLevelByteMapUserThread, &p[i]); } for (int i = 0; i < kNumThreads; i++) { - EXPECT_EQ(0, pthread_join(t[i], 0)); + PTHREAD_JOIN(t[i], 0); } EXPECT_EQ((uptr)TestMapUnmapCallback::map_count, m.size1()); EXPECT_EQ((uptr)TestMapUnmapCallback::unmap_count, 0UL); diff --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_common_test.cc b/compiler-rt/lib/sanitizer_common/tests/sanitizer_common_test.cc index 3150d565d77..8dcecaf978c 100644 --- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_common_test.cc +++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_common_test.cc @@ -15,6 +15,9 @@ #include "sanitizer_common/sanitizer_flags.h" #include "sanitizer_common/sanitizer_libc.h" #include "sanitizer_common/sanitizer_platform.h" + +#include "sanitizer_pthread_wrappers.h" + #include "gtest/gtest.h" namespace __sanitizer { @@ -159,8 +162,8 @@ TEST(SanitizerCommon, ThreadStackTlsMain) { TEST(SanitizerCommon, ThreadStackTlsWorker) { InitTlsSize(); pthread_t t; - pthread_create(&t, 0, WorkerThread, 0); - pthread_join(t, 0); + PTHREAD_CREATE(&t, 0, WorkerThread, 0); + PTHREAD_JOIN(t, 0); } bool UptrLess(uptr a, uptr b) { diff --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_format_interceptor_test.cc b/compiler-rt/lib/sanitizer_common/tests/sanitizer_format_interceptor_test.cc index 4cfb95ddb86..13918aff100 100644 --- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_format_interceptor_test.cc +++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_format_interceptor_test.cc @@ -10,6 +10,7 @@ // Tests for *scanf interceptors implementation in sanitizer_common. // //===----------------------------------------------------------------------===// +#include <algorithm> #include <vector> #include "interception/interception.h" diff --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_mutex_test.cc b/compiler-rt/lib/sanitizer_common/tests/sanitizer_mutex_test.cc index 06f742b4179..d14e7c2fba2 100644 --- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_mutex_test.cc +++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_mutex_test.cc @@ -12,6 +12,9 @@ //===----------------------------------------------------------------------===// #include "sanitizer_common/sanitizer_mutex.h" #include "sanitizer_common/sanitizer_common.h" + +#include "sanitizer_pthread_wrappers.h" + #include "gtest/gtest.h" #include <string.h> @@ -103,9 +106,9 @@ TEST(SanitizerCommon, SpinMutex) { TestData<SpinMutex> data(&mtx); pthread_t threads[kThreads]; for (int i = 0; i < kThreads; i++) - pthread_create(&threads[i], 0, lock_thread<SpinMutex>, &data); + PTHREAD_CREATE(&threads[i], 0, lock_thread<SpinMutex>, &data); for (int i = 0; i < kThreads; i++) - pthread_join(threads[i], 0); + PTHREAD_JOIN(threads[i], 0); } TEST(SanitizerCommon, SpinMutexTry) { @@ -114,9 +117,9 @@ TEST(SanitizerCommon, SpinMutexTry) { TestData<SpinMutex> data(&mtx); pthread_t threads[kThreads]; for (int i = 0; i < kThreads; i++) - pthread_create(&threads[i], 0, try_thread<SpinMutex>, &data); + PTHREAD_CREATE(&threads[i], 0, try_thread<SpinMutex>, &data); for (int i = 0; i < kThreads; i++) - pthread_join(threads[i], 0); + PTHREAD_JOIN(threads[i], 0); } TEST(SanitizerCommon, BlockingMutex) { @@ -125,9 +128,9 @@ TEST(SanitizerCommon, BlockingMutex) { TestData<BlockingMutex> data(mtx); pthread_t threads[kThreads]; for (int i = 0; i < kThreads; i++) - pthread_create(&threads[i], 0, lock_thread<BlockingMutex>, &data); + PTHREAD_CREATE(&threads[i], 0, lock_thread<BlockingMutex>, &data); for (int i = 0; i < kThreads; i++) - pthread_join(threads[i], 0); + PTHREAD_JOIN(threads[i], 0); check_locked(mtx); } diff --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_printf_test.cc b/compiler-rt/lib/sanitizer_common/tests/sanitizer_printf_test.cc index c33af3db1c4..d0b46ac94ff 100644 --- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_printf_test.cc +++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_printf_test.cc @@ -103,6 +103,11 @@ TEST(Printf, OverflowPtr) { EXPECT_EQ(buf[9], 0); } +#if defined(_WIN32) +// Oh well, MSVS headers don't define snprintf. +# define snprintf _snprintf +#endif + template<typename T> static void TestAgainstLibc(const char *fmt, T arg1, T arg2) { char buf[1024]; @@ -115,11 +120,14 @@ static void TestAgainstLibc(const char *fmt, T arg1, T arg2) { TEST(Printf, MinMax) { TestAgainstLibc<int>("%d-%d", INT_MIN, INT_MAX); // NOLINT - TestAgainstLibc<long>("%zd-%zd", LONG_MIN, LONG_MAX); // NOLINT TestAgainstLibc<unsigned>("%u-%u", 0, UINT_MAX); // NOLINT - TestAgainstLibc<unsigned long>("%zu-%zu", 0, ULONG_MAX); // NOLINT TestAgainstLibc<unsigned>("%x-%x", 0, UINT_MAX); // NOLINT +#if !defined(_WIN32) + // %z* format doesn't seem to be supported by MSVS. + TestAgainstLibc<long>("%zd-%zd", LONG_MIN, LONG_MAX); // NOLINT + TestAgainstLibc<unsigned long>("%zu-%zu", 0, ULONG_MAX); // NOLINT TestAgainstLibc<unsigned long>("%zx-%zx", 0, ULONG_MAX); // NOLINT +#endif } TEST(Printf, Padding) { diff --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_procmaps_test.cc b/compiler-rt/lib/sanitizer_common/tests/sanitizer_procmaps_test.cc index 335a84ed97d..495b726dcc4 100644 --- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_procmaps_test.cc +++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_procmaps_test.cc @@ -10,6 +10,8 @@ // This file is a part of ThreadSanitizer/AddressSanitizer runtime. // //===----------------------------------------------------------------------===// +#if !defined(_WIN32) // There are no /proc/maps on Windows. + #include "sanitizer_common/sanitizer_procmaps.h" #include "gtest/gtest.h" @@ -52,3 +54,4 @@ TEST(MemoryMappingLayout, DumpListOfModules) { } } // namespace __sanitizer +#endif // !defined(_WIN32) diff --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_thread_registry_test.cc b/compiler-rt/lib/sanitizer_common/tests/sanitizer_thread_registry_test.cc index 69b6e13e721..b6a60d5e7b9 100644 --- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_thread_registry_test.cc +++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_thread_registry_test.cc @@ -11,6 +11,9 @@ // //===----------------------------------------------------------------------===// #include "sanitizer_common/sanitizer_thread_registry.h" + +#include "sanitizer_pthread_wrappers.h" + #include "gtest/gtest.h" #include <vector> @@ -203,10 +206,10 @@ static void ThreadedTestRegistry(ThreadRegistry *registry) { for (int i = 0; i < kNumShards; i++) { args[i].registry = registry; args[i].shard = i + 1; - pthread_create(&threads[i], 0, RunThread, &args[i]); + PTHREAD_CREATE(&threads[i], 0, RunThread, &args[i]); } for (int i = 0; i < kNumShards; i++) { - pthread_join(threads[i], 0); + PTHREAD_JOIN(threads[i], 0); } // Check that each thread created/started/joined correct amount // of "threads" in thread_registry. |

