[compiler-rt] 3afd1b2 - [sanitizer] Deflake test

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Wed May 24 16:48:43 PDT 2023


Author: Vitaly Buka
Date: 2023-05-24T16:48:23-07:00
New Revision: 3afd1b2c357fb5353084a736d885af60115d6acb

URL: https://github.com/llvm/llvm-project/commit/3afd1b2c357fb5353084a736d885af60115d6acb
DIFF: https://github.com/llvm/llvm-project/commit/3afd1b2c357fb5353084a736d885af60115d6acb.diff

LOG: [sanitizer] Deflake test

Added: 
    

Modified: 
    compiler-rt/test/sanitizer_common/TestCases/Linux/release_to_os_test.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/test/sanitizer_common/TestCases/Linux/release_to_os_test.cpp b/compiler-rt/test/sanitizer_common/TestCases/Linux/release_to_os_test.cpp
index 83af7d3e611e0..4c177ee00c671 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/Linux/release_to_os_test.cpp
+++ b/compiler-rt/test/sanitizer_common/TestCases/Linux/release_to_os_test.cpp
@@ -2,10 +2,10 @@
 // RUN: env %tool_options=allocator_release_to_os_interval_ms=-1 %run %t
 
 // Not needed, no allocator.
-// XFAIL: ubsan
+// UNSUPPORTED: ubsan
 
-// FIXME: Implement
-// XFAIL: lsan, msan, tsan, hwasan-aliasing
+// FIXME: This mode uses 32bit allocator without purge.
+// UNSUPPORTED: hwasan-aliasing
 
 #include <algorithm>
 #include <assert.h>
@@ -50,7 +50,7 @@ size_t current_rss() {
   return rss;
 }
 
-void MallocReleaseStress() {
+size_t MallocReleaseStress() {
   const size_t kNumChunks = 10000;
   const size_t kAllocSize = 100;
   const size_t kNumIter = 100;
@@ -73,18 +73,19 @@ void MallocReleaseStress() {
   fprintf(stderr, "before delete: %zu\n", current_rss());
   for (auto p : chunks)
     delete[] p;
+  return kNumChunks * kAllocSize * sizeof(uintptr_t);
 }
 
 int main(int argc, char **argv) {
   // 32bit asan allocator is unsupported.
-  if (sizeof(void *) < 8 && __has_feature(address_sanitizer))
+  if (sizeof(void *) < 8)
     return 0;
   auto a = current_rss();
-  MallocReleaseStress();
+  auto total = MallocReleaseStress() >> 10;
   auto b = current_rss();
   __sanitizer_purge_allocator();
   auto c = current_rss();
-  fprintf(stderr, "a:%zu b:%zu c:%zu\n", a, b, c);
-  assert(a * 2 < b);
-  assert(c * 2 < b);
+  fprintf(stderr, "a:%zu b:%zu c:%zu total:%zu\n", a, b, c, total);
+  assert(a + total / 8 < b);
+  assert(c + total / 8 < b);
 }


        


More information about the llvm-commits mailing list