]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/rocksdb/util/heap_test.cc
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / rocksdb / util / heap_test.cc
index 1f188e73b459f0a5613e56fcbece2a6c8688d5e0..bbb93324f5a74d01604f308e5c863c9939942180 100644 (file)
@@ -3,15 +3,16 @@
 //  COPYING file in the root directory) and Apache 2.0 License
 //  (found in the LICENSE.Apache file in the root directory).
 
+#include "util/heap.h"
+
 #include <gtest/gtest.h>
 
 #include <climits>
-
 #include <queue>
 #include <random>
 #include <utility>
 
-#include "util/heap.h"
+#include "port/stack_trace.h"
 
 #ifndef GFLAGS
 const int64_t FLAGS_iters = 100000;
@@ -30,8 +31,7 @@ namespace ROCKSDB_NAMESPACE {
 using HeapTestValue = uint64_t;
 using Params = std::tuple<size_t, HeapTestValue, int64_t>;
 
-class HeapTest : public ::testing::TestWithParam<Params> {
-};
+class HeapTest : public ::testing::TestWithParam<Params> {};
 
 TEST_P(HeapTest, Test) {
   // This test performs the same pseudorandom sequence of operations on a
@@ -53,15 +53,14 @@ TEST_P(HeapTest, Test) {
   std::mt19937 rng(static_cast<unsigned int>(RNG_SEED));
   std::uniform_int_distribution<HeapTestValue> value_dist(0, MAX_VALUE);
   int ndrains = 0;
-  bool draining = false;     // hit max size, draining until we empty the heap
+  bool draining = false;  // hit max size, draining until we empty the heap
   size_t size = 0;
   for (int64_t i = 0; i < FLAGS_iters; ++i) {
     if (size == 0) {
       draining = false;
     }
 
-    if (!draining &&
-        (size == 0 || std::bernoulli_distribution(0.4)(rng))) {
+    if (!draining && (size == 0 || std::bernoulli_distribution(0.4)(rng))) {
       // insert
       HeapTestValue val = value_dist(rng);
       heap.push(val);
@@ -103,34 +102,27 @@ TEST_P(HeapTest, Test) {
 }
 
 // Basic test, MAX_VALUE = 3*MAX_HEAP_SIZE (occasional duplicates)
-INSTANTIATE_TEST_CASE_P(
-  Basic, HeapTest,
-  ::testing::Values(Params(1000, 3000, 0x1b575cf05b708945))
-);
+INSTANTIATE_TEST_CASE_P(Basic, HeapTest,
+                        ::testing::Values(Params(1000, 3000,
+                                                 0x1b575cf05b708945)));
 // Mid-size heap with small values (many duplicates)
-INSTANTIATE_TEST_CASE_P(
-  SmallValues, HeapTest,
-  ::testing::Values(Params(100, 10, 0x5ae213f7bd5dccd0))
-);
+INSTANTIATE_TEST_CASE_P(SmallValues, HeapTest,
+                        ::testing::Values(Params(100, 10, 0x5ae213f7bd5dccd0)));
 // Small heap, large value range (no duplicates)
-INSTANTIATE_TEST_CASE_P(
-  SmallHeap, HeapTest,
-  ::testing::Values(Params(10, ULLONG_MAX, 0x3e1fa8f4d01707cf))
-);
+INSTANTIATE_TEST_CASE_P(SmallHeap, HeapTest,
+                        ::testing::Values(Params(10, ULLONG_MAX,
+                                                 0x3e1fa8f4d01707cf)));
 // Two-element heap
-INSTANTIATE_TEST_CASE_P(
-  TwoElementHeap, HeapTest,
-  ::testing::Values(Params(2, 5, 0x4b5e13ea988c6abc))
-);
+INSTANTIATE_TEST_CASE_P(TwoElementHeap, HeapTest,
+                        ::testing::Values(Params(2, 5, 0x4b5e13ea988c6abc)));
 // One-element heap
-INSTANTIATE_TEST_CASE_P(
-  OneElementHeap, HeapTest,
-  ::testing::Values(Params(1, 3, 0x176a1019ab0b612e))
-);
+INSTANTIATE_TEST_CASE_P(OneElementHeap, HeapTest,
+                        ::testing::Values(Params(1, 3, 0x176a1019ab0b612e)));
 
 }  // namespace ROCKSDB_NAMESPACE
 
 int main(int argc, char** argv) {
+  ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
   ::testing::InitGoogleTest(&argc, argv);
 #ifdef GFLAGS
   GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);