Improve ThreadedQuarantineTest heap memory measurements.
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>
Thu, 22 Dec 2016 21:16:04 +0000 (21:16 +0000)
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>
Thu, 22 Dec 2016 21:16:04 +0000 (21:16 +0000)
Summary:
Warm up ASAN caches in ThreadedQuarantineTest to get more predictable
incremental heap memory usage measurements.

Reviewers: eugenis

Patch by Alex Shlyapnikov.

Subscribers: aemerson, kubabrecka, llvm-commits

Differential Revision: https://reviews.llvm.org/D28061

llvm-svn: 290371

compiler-rt/lib/asan/tests/asan_noinst_test.cc

index 1ccaa76..65acb28 100644 (file)
@@ -170,6 +170,12 @@ void *ThreadedQuarantineTestWorker(void *unused) {
 // Check that the thread local allocators are flushed when threads are
 // destroyed.
 TEST(AddressSanitizer, ThreadedQuarantineTest) {
+  // Run the routine once to warm up ASAN internal structures to get more
+  // predictable incremental memory changes.
+  pthread_t t;
+  PTHREAD_CREATE(&t, NULL, ThreadedQuarantineTestWorker, 0);
+  PTHREAD_JOIN(t, 0);
+
   const int n_threads = 3000;
   size_t mmaped1 = __sanitizer_get_heap_size();
   for (int i = 0; i < n_threads; i++) {
@@ -178,7 +184,7 @@ TEST(AddressSanitizer, ThreadedQuarantineTest) {
     PTHREAD_JOIN(t, 0);
     size_t mmaped2 = __sanitizer_get_heap_size();
     // Figure out why this much memory is required.
-    EXPECT_LT(mmaped2 - mmaped1, 352U * (1 << 20));
+    EXPECT_LT(mmaped2 - mmaped1, 320U * (1 << 20));
   }
 }