[compiler-rt] r208692 - [Sanitizer tests] Fix most of the build problems on Windows
Timur Iskhodzhanov
timurrrr at google.com
Tue May 13 05:02:53 PDT 2014
Author: timurrrr
Date: Tue May 13 07:02:53 2014
New Revision: 208692
URL: http://llvm.org/viewvc/llvm-project?rev=208692&view=rev
Log:
[Sanitizer tests] Fix most of the build problems on Windows
E.g. use the pthread helpers introduced in r208674
Modified:
compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator_test.cc
compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_common_test.cc
compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_format_interceptor_test.cc
compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_mutex_test.cc
compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_printf_test.cc
compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_procmaps_test.cc
compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_thread_registry_test.cc
Modified: compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator_test.cc?rev=208692&r1=208691&r2=208692&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator_test.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator_test.cc Tue May 13 07:02:53 2014
@@ -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, AllocatorCacheDeallocNew
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, ThreadedTwoLevelBy
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);
Modified: compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_common_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_common_test.cc?rev=208692&r1=208691&r2=208692&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_common_test.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_common_test.cc Tue May 13 07:02:53 2014
@@ -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) {
Modified: compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_format_interceptor_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_format_interceptor_test.cc?rev=208692&r1=208691&r2=208692&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_format_interceptor_test.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_format_interceptor_test.cc Tue May 13 07:02:53 2014
@@ -10,6 +10,7 @@
// Tests for *scanf interceptors implementation in sanitizer_common.
//
//===----------------------------------------------------------------------===//
+#include <algorithm>
#include <vector>
#include "interception/interception.h"
Modified: compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_mutex_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_mutex_test.cc?rev=208692&r1=208691&r2=208692&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_mutex_test.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_mutex_test.cc Tue May 13 07:02:53 2014
@@ -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);
}
Modified: compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_printf_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_printf_test.cc?rev=208692&r1=208691&r2=208692&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_printf_test.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_printf_test.cc Tue May 13 07:02:53 2014
@@ -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 *
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) {
Modified: compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_procmaps_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_procmaps_test.cc?rev=208692&r1=208691&r2=208692&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_procmaps_test.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_procmaps_test.cc Tue May 13 07:02:53 2014
@@ -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, DumpListOfModu
}
} // namespace __sanitizer
+#endif // !defined(_WIN32)
Modified: compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_thread_registry_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_thread_registry_test.cc?rev=208692&r1=208691&r2=208692&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_thread_registry_test.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_thread_registry_test.cc Tue May 13 07:02:53 2014
@@ -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(ThreadR
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.
More information about the llvm-commits
mailing list