OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 the V8 project authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 #include "src/zone/accounting-allocator.h" | |
jochen (gone - plz use gerrit)
2016/10/20 10:29:34
empty line above this one
| |
5 #include "testing/gtest/include/gtest/gtest.h" | |
6 namespace v8 { | |
jochen (gone - plz use gerrit)
2016/10/20 10:29:34
empty line above this one
| |
7 namespace internal { | |
8 | |
9 class SegmentPoolTests { | |
10 public: | |
11 static void test_pool_size_constraints() { | |
12 size_t sizes[]{ | |
13 0, // Corner case | |
14 AccountingAllocator::kMaxPoolSizeLowMemoryDevice, | |
15 AccountingAllocator::kMaxPoolSizeMediumMemoryDevice, | |
16 AccountingAllocator::kMaxPoolSizeHighMemoryDevice, | |
17 AccountingAllocator::kMaxPoolSizeHugeMemoryDevice, | |
18 GB // Something really large | |
19 }; | |
20 | |
21 AccountingAllocator allocator; | |
22 for (size_t size : sizes) { | |
23 allocator.ConfigureSegmentPool(size); | |
24 size_t total_size = 0; | |
25 for (size_t power = 0; power < AccountingAllocator::kNumberBuckets; | |
26 ++power) { | |
27 total_size += | |
28 allocator.unused_segments_max_sizes_[power] * (size_t(1) << power); | |
29 } | |
30 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
| |
31 } | |
32 } | |
33 }; | |
34 | |
35 TEST(Zone, SegmentPoolConstraints) { | |
36 SegmentPoolTests::test_pool_size_constraints(); | |
jochen (gone - plz use gerrit)
2016/10/20 10:29:34
just inline the entire static method here
| |
37 } | |
38 | |
39 } // namespace internal | |
40 } // namespace v8 | |
OLD | NEW |