<div dir="ltr">Most of these #ifdef's will go away as we make these test use lit infrastructure.<div><br></div><div>Suggestions on breaking down other stuff are welcome.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">

2014-05-12 20:20 GMT+04:00 Kostya Serebryany <span dir="ltr"><<a href="mailto:kcc@google.com" target="_blank">kcc@google.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div dir="ltr">This is really horrible. <div>I'd prefer to split the file instead of putting so many ifdefs </div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, May 12, 2014 at 7:04 PM, Timur Iskhodzhanov <span dir="ltr"><<a href="mailto:timurrrr@google.com" target="_blank">timurrrr@google.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: timurrrr<br>
Date: Mon May 12 10:04:25 2014<br>
New Revision: 208573<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=208573&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=208573&view=rev</a><br>
Log:<br>
[ASan tests] Exclude/simplify a bunch of tests to make them build on Windows<br>
<br>
(This also requires D3720, D3725 and a few more small changes to land)<br>
<br>
Modified:<br>
    compiler-rt/trunk/lib/asan/tests/asan_test.cc<br>
<br>
Modified: compiler-rt/trunk/lib/asan/tests/asan_test.cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/asan_test.cc?rev=208573&r1=208572&r2=208573&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/asan_test.cc?rev=208573&r1=208572&r2=208573&view=diff</a><br>



==============================================================================<br>
--- compiler-rt/trunk/lib/asan/tests/asan_test.cc (original)<br>
+++ compiler-rt/trunk/lib/asan/tests/asan_test.cc Mon May 12 10:04:25 2014<br>
@@ -138,6 +138,8 @@ TEST(AddressSanitizer, PvallocTest) {<br>
 }<br>
 #endif  // SANITIZER_TEST_HAS_PVALLOC<br>
<br>
+#if !defined(_WIN32)<br>
+// FIXME: Use an equivalent of pthread_setspecific on Windows.<br>
 void *TSDWorker(void *test_key) {<br>
   if (test_key) {<br>
     pthread_setspecific(*(pthread_key_t*)test_key, (void*)0xfeedface);<br>
@@ -167,6 +169,7 @@ TEST(AddressSanitizer, DISABLED_TSDTest)<br>
   PTHREAD_JOIN(th, NULL);<br>
   pthread_key_delete(test_key);<br>
 }<br>
+#endif<br>
<br>
 TEST(AddressSanitizer, UAF_char) {<br>
   const char *uaf_string = "AddressSanitizer:.*heap-use-after-free";<br>
@@ -421,12 +424,14 @@ void WrongFree() {<br>
   free(x + 1);<br>
 }<br>
<br>
+#if !defined(_WIN32)  // FIXME: This should be a lit test.<br>
 TEST(AddressSanitizer, WrongFreeTest) {<br>
   EXPECT_DEATH(WrongFree(), ASAN_PCRE_DOTALL<br>
                "ERROR: AddressSanitizer: attempting free.*not malloc"<br>
                ".*is located 4 bytes inside of 400-byte region"<br>
                ".*allocated by thread");<br>
 }<br>
+#endif<br>
<br>
 void DoubleFree() {<br>
   int *x = (int*)malloc(100 * sizeof(int));<br>
@@ -437,6 +442,7 @@ void DoubleFree() {<br>
   abort();<br>
 }<br>
<br>
+#if !defined(_WIN32)  // FIXME: This should be a lit test.<br>
 TEST(AddressSanitizer, DoubleFreeTest) {<br>
   EXPECT_DEATH(DoubleFree(), ASAN_PCRE_DOTALL<br>
                "ERROR: AddressSanitizer: attempting double-free"<br>
@@ -444,6 +450,7 @@ TEST(AddressSanitizer, DoubleFreeTest) {<br>
                ".*freed by thread T0 here"<br>
                ".*previously allocated by thread T0 here");<br>
 }<br>
+#endif<br>
<br>
 template<int kSize><br>
 NOINLINE void SizedStackTest() {<br>
@@ -628,7 +635,8 @@ TEST(AddressSanitizer, SigLongJmpTest) {<br>
 }<br>
 #endif<br>
<br>
-#ifdef __EXCEPTIONS<br>
+// FIXME: Why does clang-cl define __EXCEPTIONS?<br>
+#if defined(__EXCEPTIONS) && !defined(_WIN32)<br>
 NOINLINE void ThrowFunc() {<br>
   // create three red zones for these two stack objects.<br>
   int a;<br>
@@ -695,12 +703,19 @@ TEST(AddressSanitizer, Store128Test) {<br>
 }<br>
 #endif<br>
<br>
+// FIXME: All tests that use this function should be turned into lit tests.<br>
 string RightOOBErrorMessage(int oob_distance, bool is_write) {<br>
   assert(oob_distance >= 0);<br>
   char expected_str[100];<br>
   sprintf(expected_str, ASAN_PCRE_DOTALL<br>
-          "buffer-overflow.*%s.*located %d bytes to the right",<br>
-          is_write ? "WRITE" : "READ", oob_distance);<br>
+#if !GTEST_USES_SIMPLE_RE<br>
+          "buffer-overflow.*%s.*"<br>
+#endif<br>
+          "located %d bytes to the right",<br>
+#if !GTEST_USES_SIMPLE_RE<br>
+          is_write ? "WRITE" : "READ",<br>
+#endif<br>
+          oob_distance);<br>
   return string(expected_str);<br>
 }<br>
<br>
@@ -712,11 +727,19 @@ string RightOOBReadMessage(int oob_dista<br>
   return RightOOBErrorMessage(oob_distance, /*is_write*/false);<br>
 }<br>
<br>
+// FIXME: All tests that use this function should be turned into lit tests.<br>
 string LeftOOBErrorMessage(int oob_distance, bool is_write) {<br>
   assert(oob_distance > 0);<br>
   char expected_str[100];<br>
-  sprintf(expected_str, ASAN_PCRE_DOTALL "%s.*located %d bytes to the left",<br>
-          is_write ? "WRITE" : "READ", oob_distance);<br>
+  sprintf(expected_str,<br>
+#if !GTEST_USES_SIMPLE_RE<br>
+          ASAN_PCRE_DOTALL "%s.*"<br>
+#endif<br>
+          "located %d bytes to the left",<br>
+#if !GTEST_USES_SIMPLE_RE<br>
+          is_write ? "WRITE" : "READ",<br>
+#endif<br>
+          oob_distance);<br>
   return string(expected_str);<br>
 }<br>
<br>
@@ -870,6 +893,7 @@ void ThreadedTestSpawn() {<br>
   PTHREAD_JOIN(t, 0);<br>
 }<br>
<br>
+#if !defined(_WIN32)  // FIXME: This should be a lit test.<br>
 TEST(AddressSanitizer, ThreadedTest) {<br>
   EXPECT_DEATH(ThreadedTestSpawn(),<br>
                ASAN_PCRE_DOTALL<br>
@@ -877,6 +901,7 @@ TEST(AddressSanitizer, ThreadedTest) {<br>
                ".*Thread T.*created"<br>
                ".*Thread T.*created");<br>
 }<br>
+#endif<br>
<br>
 void *ThreadedTestFunc(void *unused) {<br>
   // Check if prctl(PR_SET_NAME) is supported. Return if not.<br>
@@ -1071,7 +1096,8 @@ TEST(AddressSanitizer, PthreadExitTest)<br>
   }<br>
 }<br>
<br>
-#ifdef __EXCEPTIONS<br>
+// FIXME: Why does clang-cl define __EXCEPTIONS?<br>
+#if defined(__EXCEPTIONS) && !defined(_WIN32)<br>
 NOINLINE static void StackReuseAndException() {<br>
   int large_stack[1000];<br>
   Ident(large_stack);<br>
@@ -1089,12 +1115,14 @@ TEST(AddressSanitizer, DISABLED_StressSt<br>
 }<br>
 #endif<br>
<br>
+#if !defined(_WIN32)<br>
 TEST(AddressSanitizer, MlockTest) {<br>
   EXPECT_EQ(0, mlockall(MCL_CURRENT));<br>
   EXPECT_EQ(0, mlock((void*)0x12345, 0x5678));<br>
   EXPECT_EQ(0, munlockall());<br>
   EXPECT_EQ(0, munlock((void*)0x987, 0x654));<br>
 }<br>
+#endif<br>
<br>
 struct LargeStruct {<br>
   int foo[100];<br>
@@ -1118,10 +1146,15 @@ TEST(AddressSanitizer, AttributeNoSaniti<br>
   Ident(NoSanitizeAddress)();<br>
 }<br>
<br>
-// It doesn't work on Android, as calls to new/delete go through malloc/free.<br>
-// Neither it does on OS X, see<br>
-// <a href="https://code.google.com/p/address-sanitizer/issues/detail?id=131.-#if" target="_blank">https://code.google.com/p/address-sanitizer/issues/detail?id=131.<br>
-#if</a> !defined(ANDROID) && !defined(__ANDROID__) && !defined(__APPLE__)<br>
+// The new/delete/etc mismatch checks don't work on Android,<br>
+//   as calls to new/delete go through malloc/free.<br>
+// OS X support is tracked here:<br>
+//   <a href="https://code.google.com/p/address-sanitizer/issues/detail?id=131" target="_blank">https://code.google.com/p/address-sanitizer/issues/detail?id=131</a><br>
+// Windows support is tracked here:<br>
+//   <a href="https://code.google.com/p/address-sanitizer/issues/detail?id=309+#if" target="_blank">https://code.google.com/p/address-sanitizer/issues/detail?id=309<br>
+#if</a> !defined(ANDROID) && !defined(__ANDROID__) && \<br>
+    !defined(__APPLE__) && \<br>
+    !defined(_WIN32)<br>
 static string MismatchStr(const string &str) {<br>
   return string("AddressSanitizer: alloc-dealloc-mismatch \\(") + str;<br>
 }<br>
@@ -1236,6 +1269,7 @@ TEST(AddressSanitizer, LongDoubleNegativ<br>
   memcpy(Ident(&c), Ident(&b), sizeof(long double));<br>
 }<br>
<br>
+#if !defined(_WIN32)<br>
 TEST(AddressSanitizer, pthread_getschedparam) {<br>
   int policy;<br>
   struct sched_param param;<br>
@@ -1248,3 +1282,4 @@ TEST(AddressSanitizer, pthread_getschedp<br>
   int res = pthread_getschedparam(pthread_self(), &policy, &param);<br>
   ASSERT_EQ(0, res);<br>
 }<br>
+#endif<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>