[PATCH] D21817: [compiler-rt] Fix Sanitizer-common Unittests on win64

Etienne Bergeron via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 28 15:21:39 PDT 2016


etienneb created this revision.
etienneb added a reviewer: rnk.
etienneb added subscribers: llvm-commits, wang0109, chrisha.
Herald added a subscriber: kubabrecka.

This patch is fixing unittests that are broken on windows (64-bits).

Tested on Win32/Win64 (Ninja and MSVC).
Tested on Linux 32-bit/64-bit clang.

```
C:\src\llvm\build64\projects\compiler-rt>lib\sanitizer_common\tests\Release\Sanitizer-x86_64-Test.exe
[==========] Running 101 tests from 12 test cases.
[----------] Global test environment set-up.
[----------] 51 tests from SanitizerCommon
[ RUN      ] SanitizerCommon.DefaultSizeClassMap
[       OK ] SanitizerCommon.DefaultSizeClassMap (1 ms)
[ RUN      ] SanitizerCommon.CompactSizeClassMap
[       OK ] SanitizerCommon.CompactSizeClassMap (1 ms)
[ RUN      ] SanitizerCommon.InternalSizeClassMap
[       OK ] SanitizerCommon.InternalSizeClassMap (1 ms)
[ RUN      ] SanitizerCommon.SizeClassAllocator32Compact
[       OK ] SanitizerCommon.SizeClassAllocator32Compact (828 ms)
[ RUN      ] SanitizerCommon.SizeClassAllocator32CompactMetadataStress
[       OK ] SanitizerCommon.SizeClassAllocator32CompactMetadataStress (914 ms)
[ RUN      ] SanitizerCommon.SizeClassAllocator32MapUnmapCallback

[...]

[----------] 4 tests from Symbolizer
[ RUN      ] Symbolizer.ExtractToken
[       OK ] Symbolizer.ExtractToken (0 ms)
[ RUN      ] Symbolizer.ExtractInt
[       OK ] Symbolizer.ExtractInt (0 ms)
[ RUN      ] Symbolizer.ExtractUptr
[       OK ] Symbolizer.ExtractUptr (0 ms)
[ RUN      ] Symbolizer.ExtractTokenUpToDelimiter
[       OK ] Symbolizer.ExtractTokenUpToDelimiter (0 ms)
[----------] 4 tests from Symbolizer (24 ms total)

[----------] Global test environment tear-down
[==========] 101 tests from 12 test cases ran. (5090 ms total)
[  PASSED  ] 101 tests.
```

http://reviews.llvm.org/D21817

Files:
  lib/sanitizer_common/sanitizer_platform.h
  lib/sanitizer_common/tests/sanitizer_printf_test.cc
  lib/sanitizer_common/tests/sanitizer_test_main.cc

Index: lib/sanitizer_common/tests/sanitizer_test_main.cc
===================================================================
--- lib/sanitizer_common/tests/sanitizer_test_main.cc
+++ lib/sanitizer_common/tests/sanitizer_test_main.cc
@@ -13,6 +13,10 @@
 #include "gtest/gtest.h"
 #include "sanitizer_common/sanitizer_flags.h"
 
+#ifdef _MSC_VER
+#pragma comment(linker, "/STACK:16777216")
+#endif
+
 const char *argv0;
 
 int main(int argc, char **argv) {
Index: lib/sanitizer_common/tests/sanitizer_printf_test.cc
===================================================================
--- lib/sanitizer_common/tests/sanitizer_printf_test.cc
+++ lib/sanitizer_common/tests/sanitizer_printf_test.cc
@@ -23,9 +23,9 @@
   char buf[1024];
   uptr len = internal_snprintf(buf, sizeof(buf),
       "a%db%zdc%ue%zuf%xh%zxq%pe%sr",
-      (int)-1, (long)-2, // NOLINT
-      (unsigned)-4, (unsigned long)5, // NOLINT
-      (unsigned)10, (unsigned long)11, // NOLINT
+      (int)-1, (sptr)-2, // NOLINT
+      (unsigned)-4, (sptr)5, // NOLINT
+      (unsigned)10, (sptr)11, // NOLINT
       (void*)0x123, "_string_");
   EXPECT_EQ(len, strlen(buf));
 
Index: lib/sanitizer_common/sanitizer_platform.h
===================================================================
--- lib/sanitizer_common/sanitizer_platform.h
+++ lib/sanitizer_common/sanitizer_platform.h
@@ -168,7 +168,7 @@
 // For such platforms build this code with -DSANITIZER_CAN_USE_ALLOCATOR64=0 or
 // change the definition of SANITIZER_CAN_USE_ALLOCATOR64 here.
 #ifndef SANITIZER_CAN_USE_ALLOCATOR64
-# if defined(__mips64) || defined(__aarch64__)
+# if defined(__mips64) || defined(__aarch64__) || defined(_WIN32)
 #  define SANITIZER_CAN_USE_ALLOCATOR64 0
 # else
 #  define SANITIZER_CAN_USE_ALLOCATOR64 (SANITIZER_WORDSIZE == 64)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21817.62140.patch
Type: text/x-patch
Size: 1788 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160628/1890fb20/attachment-0001.bin>


More information about the llvm-commits mailing list