reduce the number of iteration when test SharedMutexTest in ASAN mode
[folly.git] / folly / test / SharedMutexTest.cpp
index e5c3c24a02dfab55d072be483088b7bcf1010fee..f27ba1bcf21076c5609d844d1f5d7e5ef9ed345d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016 Facebook, Inc.
+ * Copyright 2017 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,7 +26,6 @@
 #include <folly/Benchmark.h>
 #include <folly/MPMCQueue.h>
 #include <folly/RWSpinLock.h>
-#include <folly/Random.h>
 #include <folly/portability/GFlags.h>
 #include <folly/portability/GTest.h>
 #include <folly/test/DeterministicSchedule.h>
@@ -99,7 +98,7 @@ void runBasicHoldersTest() {
     EXPECT_FALSE(lock.try_lock_shared(token));
 
     // move ownership to another write holder via assign operator
-    typename Lock::WriteHolder holder3;
+    typename Lock::WriteHolder holder3(nullptr);
     holder3 = std::move(holder2);
     EXPECT_FALSE(lock.try_lock());
     EXPECT_FALSE(lock.try_lock_shared(token));
@@ -1053,14 +1052,14 @@ TEST(SharedMutex, deterministic_lost_wakeup_write_prio) {
 }
 
 TEST(SharedMutex, mixed_mostly_write_read_prio) {
-  for (int pass = 0; pass < 5; ++pass) {
+  for (int pass = 0; pass < (folly::kIsSanitizeAddress ? 1 : 5); ++pass) {
     runMixed<atomic, SharedMutexReadPriority, TokenLocker>(
         50000, 300, 0.9, false);
   }
 }
 
 TEST(SharedMutex, mixed_mostly_write_write_prio) {
-  for (int pass = 0; pass < 5; ++pass) {
+  for (int pass = 0; pass < (folly::kIsSanitizeAddress ? 1 : 5); ++pass) {
     runMixed<atomic, SharedMutexWritePriority, TokenLocker>(
         50000, 300, 0.9, false);
   }
@@ -1230,7 +1229,7 @@ TEST(SharedMutex, remote_write_prio) {
 }
 
 TEST(SharedMutex, remote_read_prio) {
-  for (int pass = 0; pass < 100; ++pass) {
+  for (int pass = 0; pass < (folly::kIsSanitizeAddress ? 1 : 100); ++pass) {
     runRemoteUnlock<SharedMutexReadPriority, atomic>(100000, 0.1, 0.1, 5, 5);
   }
 }