Index: test/unittests/zone/segmentpool-tests.cc |
diff --git a/test/unittests/zone/segmentpool-tests.cc b/test/unittests/zone/segmentpool-tests.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d48be3bbdeb73cf37cbd30c1b604e862b9baa621 |
--- /dev/null |
+++ b/test/unittests/zone/segmentpool-tests.cc |
@@ -0,0 +1,40 @@ |
+// Copyright 2016 the V8 project authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+#include "src/zone/accounting-allocator.h" |
jochen (gone - plz use gerrit)
2016/10/20 10:29:34
empty line above this one
|
+#include "testing/gtest/include/gtest/gtest.h" |
+namespace v8 { |
jochen (gone - plz use gerrit)
2016/10/20 10:29:34
empty line above this one
|
+namespace internal { |
+ |
+class SegmentPoolTests { |
+ public: |
+ static void test_pool_size_constraints() { |
+ size_t sizes[]{ |
+ 0, // Corner case |
+ AccountingAllocator::kMaxPoolSizeLowMemoryDevice, |
+ AccountingAllocator::kMaxPoolSizeMediumMemoryDevice, |
+ AccountingAllocator::kMaxPoolSizeHighMemoryDevice, |
+ AccountingAllocator::kMaxPoolSizeHugeMemoryDevice, |
+ GB // Something really large |
+ }; |
+ |
+ AccountingAllocator allocator; |
+ for (size_t size : sizes) { |
+ allocator.ConfigureSegmentPool(size); |
+ size_t total_size = 0; |
+ for (size_t power = 0; power < AccountingAllocator::kNumberBuckets; |
+ ++power) { |
+ total_size += |
+ allocator.unused_segments_max_sizes_[power] * (size_t(1) << power); |
+ } |
+ CHECK_LE(total_size, size); |
jochen (gone - plz use gerrit)
2016/10/20 10:29:34
use EXPECT_LE - there's no reason to crash
|
+ } |
+ } |
+}; |
+ |
+TEST(Zone, SegmentPoolConstraints) { |
+ SegmentPoolTests::test_pool_size_constraints(); |
jochen (gone - plz use gerrit)
2016/10/20 10:29:34
just inline the entire static method here
|
+} |
+ |
+} // namespace internal |
+} // namespace v8 |