1*795d594fSAndroid Build Coastguard Worker /*
2*795d594fSAndroid Build Coastguard Worker * Copyright (C) 2011 The Android Open Source Project
3*795d594fSAndroid Build Coastguard Worker *
4*795d594fSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License");
5*795d594fSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License.
6*795d594fSAndroid Build Coastguard Worker * You may obtain a copy of the License at
7*795d594fSAndroid Build Coastguard Worker *
8*795d594fSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0
9*795d594fSAndroid Build Coastguard Worker *
10*795d594fSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software
11*795d594fSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS,
12*795d594fSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*795d594fSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and
14*795d594fSAndroid Build Coastguard Worker * limitations under the License.
15*795d594fSAndroid Build Coastguard Worker */
16*795d594fSAndroid Build Coastguard Worker
17*795d594fSAndroid Build Coastguard Worker #include <algorithm>
18*795d594fSAndroid Build Coastguard Worker
19*795d594fSAndroid Build Coastguard Worker #include "base/metrics/metrics.h"
20*795d594fSAndroid Build Coastguard Worker #include "class_linker-inl.h"
21*795d594fSAndroid Build Coastguard Worker #include "common_runtime_test.h"
22*795d594fSAndroid Build Coastguard Worker #include "gc/accounting/card_table-inl.h"
23*795d594fSAndroid Build Coastguard Worker #include "gc/accounting/space_bitmap-inl.h"
24*795d594fSAndroid Build Coastguard Worker #include "handle_scope-inl.h"
25*795d594fSAndroid Build Coastguard Worker #include "mirror/class-inl.h"
26*795d594fSAndroid Build Coastguard Worker #include "mirror/object-inl.h"
27*795d594fSAndroid Build Coastguard Worker #include "mirror/object_array-alloc-inl.h"
28*795d594fSAndroid Build Coastguard Worker #include "mirror/object_array-inl.h"
29*795d594fSAndroid Build Coastguard Worker #include "scoped_thread_state_change-inl.h"
30*795d594fSAndroid Build Coastguard Worker
31*795d594fSAndroid Build Coastguard Worker namespace art HIDDEN {
32*795d594fSAndroid Build Coastguard Worker namespace gc {
33*795d594fSAndroid Build Coastguard Worker
34*795d594fSAndroid Build Coastguard Worker class HeapTest : public CommonRuntimeTest {
35*795d594fSAndroid Build Coastguard Worker public:
HeapTest()36*795d594fSAndroid Build Coastguard Worker HeapTest() {
37*795d594fSAndroid Build Coastguard Worker use_boot_image_ = true; // Make the Runtime creation cheaper.
38*795d594fSAndroid Build Coastguard Worker }
39*795d594fSAndroid Build Coastguard Worker
SetUp()40*795d594fSAndroid Build Coastguard Worker void SetUp() override {
41*795d594fSAndroid Build Coastguard Worker MemMap::Init();
42*795d594fSAndroid Build Coastguard Worker std::string error_msg;
43*795d594fSAndroid Build Coastguard Worker // Reserve the preferred address to force the heap to use another one for testing.
44*795d594fSAndroid Build Coastguard Worker reserved_ = MemMap::MapAnonymous("ReserveMap",
45*795d594fSAndroid Build Coastguard Worker gc::Heap::kPreferredAllocSpaceBegin,
46*795d594fSAndroid Build Coastguard Worker 16 * KB,
47*795d594fSAndroid Build Coastguard Worker PROT_READ,
48*795d594fSAndroid Build Coastguard Worker /*low_4gb=*/ true,
49*795d594fSAndroid Build Coastguard Worker /*reuse=*/ false,
50*795d594fSAndroid Build Coastguard Worker /*reservation=*/ nullptr,
51*795d594fSAndroid Build Coastguard Worker &error_msg);
52*795d594fSAndroid Build Coastguard Worker // There is no guarantee that reserved_ will be valid (due to ASLR). See b/175018342.
53*795d594fSAndroid Build Coastguard Worker CommonRuntimeTest::SetUp();
54*795d594fSAndroid Build Coastguard Worker }
55*795d594fSAndroid Build Coastguard Worker
56*795d594fSAndroid Build Coastguard Worker private:
57*795d594fSAndroid Build Coastguard Worker MemMap reserved_;
58*795d594fSAndroid Build Coastguard Worker };
59*795d594fSAndroid Build Coastguard Worker
TEST_F(HeapTest,ClearGrowthLimit)60*795d594fSAndroid Build Coastguard Worker TEST_F(HeapTest, ClearGrowthLimit) {
61*795d594fSAndroid Build Coastguard Worker Heap* heap = Runtime::Current()->GetHeap();
62*795d594fSAndroid Build Coastguard Worker int64_t max_memory_before = heap->GetMaxMemory();
63*795d594fSAndroid Build Coastguard Worker int64_t total_memory_before = heap->GetTotalMemory();
64*795d594fSAndroid Build Coastguard Worker heap->ClearGrowthLimit();
65*795d594fSAndroid Build Coastguard Worker int64_t max_memory_after = heap->GetMaxMemory();
66*795d594fSAndroid Build Coastguard Worker int64_t total_memory_after = heap->GetTotalMemory();
67*795d594fSAndroid Build Coastguard Worker EXPECT_GE(max_memory_after, max_memory_before);
68*795d594fSAndroid Build Coastguard Worker EXPECT_GE(total_memory_after, total_memory_before);
69*795d594fSAndroid Build Coastguard Worker }
70*795d594fSAndroid Build Coastguard Worker
TEST_F(HeapTest,GarbageCollectClassLinkerInit)71*795d594fSAndroid Build Coastguard Worker TEST_F(HeapTest, GarbageCollectClassLinkerInit) {
72*795d594fSAndroid Build Coastguard Worker {
73*795d594fSAndroid Build Coastguard Worker ScopedObjectAccess soa(Thread::Current());
74*795d594fSAndroid Build Coastguard Worker // garbage is created during ClassLinker::Init
75*795d594fSAndroid Build Coastguard Worker
76*795d594fSAndroid Build Coastguard Worker StackHandleScope<1> hs(soa.Self());
77*795d594fSAndroid Build Coastguard Worker Handle<mirror::Class> c(
78*795d594fSAndroid Build Coastguard Worker hs.NewHandle(class_linker_->FindSystemClass(soa.Self(), "[Ljava/lang/Object;")));
79*795d594fSAndroid Build Coastguard Worker for (size_t i = 0; i < 1024; ++i) {
80*795d594fSAndroid Build Coastguard Worker StackHandleScope<1> hs2(soa.Self());
81*795d594fSAndroid Build Coastguard Worker Handle<mirror::ObjectArray<mirror::Object>> array(hs2.NewHandle(
82*795d594fSAndroid Build Coastguard Worker mirror::ObjectArray<mirror::Object>::Alloc(soa.Self(), c.Get(), 2048)));
83*795d594fSAndroid Build Coastguard Worker for (size_t j = 0; j < 2048; ++j) {
84*795d594fSAndroid Build Coastguard Worker ObjPtr<mirror::String> string =
85*795d594fSAndroid Build Coastguard Worker mirror::String::AllocFromModifiedUtf8(soa.Self(), "hello, world!");
86*795d594fSAndroid Build Coastguard Worker // handle scope operator -> deferences the handle scope before running the method.
87*795d594fSAndroid Build Coastguard Worker array->Set<false>(j, string);
88*795d594fSAndroid Build Coastguard Worker }
89*795d594fSAndroid Build Coastguard Worker }
90*795d594fSAndroid Build Coastguard Worker }
91*795d594fSAndroid Build Coastguard Worker Runtime::Current()->GetHeap()->CollectGarbage(/* clear_soft_references= */ false);
92*795d594fSAndroid Build Coastguard Worker }
93*795d594fSAndroid Build Coastguard Worker
TEST_F(HeapTest,HeapBitmapCapacityTest)94*795d594fSAndroid Build Coastguard Worker TEST_F(HeapTest, HeapBitmapCapacityTest) {
95*795d594fSAndroid Build Coastguard Worker uint8_t* heap_begin = reinterpret_cast<uint8_t*>(0x1000);
96*795d594fSAndroid Build Coastguard Worker const size_t heap_capacity = kObjectAlignment * (sizeof(intptr_t) * 8 + 1);
97*795d594fSAndroid Build Coastguard Worker accounting::ContinuousSpaceBitmap bitmap(
98*795d594fSAndroid Build Coastguard Worker accounting::ContinuousSpaceBitmap::Create("test bitmap", heap_begin, heap_capacity));
99*795d594fSAndroid Build Coastguard Worker mirror::Object* fake_end_of_heap_object =
100*795d594fSAndroid Build Coastguard Worker reinterpret_cast<mirror::Object*>(&heap_begin[heap_capacity - kObjectAlignment]);
101*795d594fSAndroid Build Coastguard Worker bitmap.Set(fake_end_of_heap_object);
102*795d594fSAndroid Build Coastguard Worker }
103*795d594fSAndroid Build Coastguard Worker
TEST_F(HeapTest,DumpGCPerformanceOnShutdown)104*795d594fSAndroid Build Coastguard Worker TEST_F(HeapTest, DumpGCPerformanceOnShutdown) {
105*795d594fSAndroid Build Coastguard Worker Runtime::Current()->GetHeap()->CollectGarbage(/* clear_soft_references= */ false);
106*795d594fSAndroid Build Coastguard Worker Runtime::Current()->SetDumpGCPerformanceOnShutdown(true);
107*795d594fSAndroid Build Coastguard Worker }
108*795d594fSAndroid Build Coastguard Worker
AnyIsFalse(bool x,bool y)109*795d594fSAndroid Build Coastguard Worker bool AnyIsFalse(bool x, bool y) { return !x || !y; }
110*795d594fSAndroid Build Coastguard Worker
TEST_F(HeapTest,GCMetrics)111*795d594fSAndroid Build Coastguard Worker TEST_F(HeapTest, GCMetrics) {
112*795d594fSAndroid Build Coastguard Worker // Allocate a few string objects (to be collected), then trigger garbage
113*795d594fSAndroid Build Coastguard Worker // collection, and check that GC metrics are updated (where applicable).
114*795d594fSAndroid Build Coastguard Worker Heap* heap = Runtime::Current()->GetHeap();
115*795d594fSAndroid Build Coastguard Worker {
116*795d594fSAndroid Build Coastguard Worker constexpr const size_t kNumObj = 128;
117*795d594fSAndroid Build Coastguard Worker ScopedObjectAccess soa(Thread::Current());
118*795d594fSAndroid Build Coastguard Worker StackHandleScope<kNumObj> hs(soa.Self());
119*795d594fSAndroid Build Coastguard Worker for (size_t i = 0u; i < kNumObj; ++i) {
120*795d594fSAndroid Build Coastguard Worker Handle<mirror::String> string [[maybe_unused]] (
121*795d594fSAndroid Build Coastguard Worker hs.NewHandle(mirror::String::AllocFromModifiedUtf8(soa.Self(), "test")));
122*795d594fSAndroid Build Coastguard Worker }
123*795d594fSAndroid Build Coastguard Worker // Do one GC while the temporary objects are reachable, forcing the GC to scan something.
124*795d594fSAndroid Build Coastguard Worker // The subsequent GC at line 127 may not scan anything but will certainly free some bytes.
125*795d594fSAndroid Build Coastguard Worker // Together the two GCs ensure success of the test.
126*795d594fSAndroid Build Coastguard Worker heap->CollectGarbage(/* clear_soft_references= */ false);
127*795d594fSAndroid Build Coastguard Worker }
128*795d594fSAndroid Build Coastguard Worker heap->CollectGarbage(/* clear_soft_references= */ false);
129*795d594fSAndroid Build Coastguard Worker
130*795d594fSAndroid Build Coastguard Worker // ART Metrics.
131*795d594fSAndroid Build Coastguard Worker metrics::ArtMetrics* metrics = Runtime::Current()->GetMetrics();
132*795d594fSAndroid Build Coastguard Worker // ART full-heap GC metrics.
133*795d594fSAndroid Build Coastguard Worker metrics::MetricsBase<int64_t>* full_gc_collection_time = metrics->FullGcCollectionTime();
134*795d594fSAndroid Build Coastguard Worker metrics::MetricsBase<uint64_t>* full_gc_count = metrics->FullGcCount();
135*795d594fSAndroid Build Coastguard Worker metrics::MetricsBase<uint64_t>* full_gc_count_delta = metrics->FullGcCountDelta();
136*795d594fSAndroid Build Coastguard Worker metrics::MetricsBase<int64_t>* full_gc_throughput = metrics->FullGcThroughput();
137*795d594fSAndroid Build Coastguard Worker metrics::MetricsBase<int64_t>* full_gc_tracing_throughput = metrics->FullGcTracingThroughput();
138*795d594fSAndroid Build Coastguard Worker metrics::MetricsBase<uint64_t>* full_gc_throughput_avg = metrics->FullGcThroughputAvg();
139*795d594fSAndroid Build Coastguard Worker metrics::MetricsBase<uint64_t>* full_gc_tracing_throughput_avg =
140*795d594fSAndroid Build Coastguard Worker metrics->FullGcTracingThroughputAvg();
141*795d594fSAndroid Build Coastguard Worker metrics::MetricsBase<uint64_t>* full_gc_scanned_bytes = metrics->FullGcScannedBytes();
142*795d594fSAndroid Build Coastguard Worker metrics::MetricsBase<uint64_t>* full_gc_scanned_bytes_delta = metrics->FullGcScannedBytesDelta();
143*795d594fSAndroid Build Coastguard Worker metrics::MetricsBase<uint64_t>* full_gc_freed_bytes = metrics->FullGcFreedBytes();
144*795d594fSAndroid Build Coastguard Worker metrics::MetricsBase<uint64_t>* full_gc_freed_bytes_delta = metrics->FullGcFreedBytesDelta();
145*795d594fSAndroid Build Coastguard Worker metrics::MetricsBase<uint64_t>* full_gc_duration = metrics->FullGcDuration();
146*795d594fSAndroid Build Coastguard Worker metrics::MetricsBase<uint64_t>* full_gc_duration_delta = metrics->FullGcDurationDelta();
147*795d594fSAndroid Build Coastguard Worker // ART young-generation GC metrics.
148*795d594fSAndroid Build Coastguard Worker metrics::MetricsBase<int64_t>* young_gc_collection_time = metrics->YoungGcCollectionTime();
149*795d594fSAndroid Build Coastguard Worker metrics::MetricsBase<uint64_t>* young_gc_count = metrics->YoungGcCount();
150*795d594fSAndroid Build Coastguard Worker metrics::MetricsBase<uint64_t>* young_gc_count_delta = metrics->YoungGcCountDelta();
151*795d594fSAndroid Build Coastguard Worker metrics::MetricsBase<int64_t>* young_gc_throughput = metrics->YoungGcThroughput();
152*795d594fSAndroid Build Coastguard Worker metrics::MetricsBase<int64_t>* young_gc_tracing_throughput = metrics->YoungGcTracingThroughput();
153*795d594fSAndroid Build Coastguard Worker metrics::MetricsBase<uint64_t>* young_gc_throughput_avg = metrics->YoungGcThroughputAvg();
154*795d594fSAndroid Build Coastguard Worker metrics::MetricsBase<uint64_t>* young_gc_tracing_throughput_avg =
155*795d594fSAndroid Build Coastguard Worker metrics->YoungGcTracingThroughputAvg();
156*795d594fSAndroid Build Coastguard Worker metrics::MetricsBase<uint64_t>* young_gc_scanned_bytes = metrics->YoungGcScannedBytes();
157*795d594fSAndroid Build Coastguard Worker metrics::MetricsBase<uint64_t>* young_gc_scanned_bytes_delta =
158*795d594fSAndroid Build Coastguard Worker metrics->YoungGcScannedBytesDelta();
159*795d594fSAndroid Build Coastguard Worker metrics::MetricsBase<uint64_t>* young_gc_freed_bytes = metrics->YoungGcFreedBytes();
160*795d594fSAndroid Build Coastguard Worker metrics::MetricsBase<uint64_t>* young_gc_freed_bytes_delta = metrics->YoungGcFreedBytesDelta();
161*795d594fSAndroid Build Coastguard Worker metrics::MetricsBase<uint64_t>* young_gc_duration = metrics->YoungGcDuration();
162*795d594fSAndroid Build Coastguard Worker metrics::MetricsBase<uint64_t>* young_gc_duration_delta = metrics->YoungGcDurationDelta();
163*795d594fSAndroid Build Coastguard Worker
164*795d594fSAndroid Build Coastguard Worker CollectorType fg_collector_type = heap->GetForegroundCollectorType();
165*795d594fSAndroid Build Coastguard Worker if (fg_collector_type == kCollectorTypeCC || fg_collector_type == kCollectorTypeCMC) {
166*795d594fSAndroid Build Coastguard Worker // Only the Concurrent Copying and Concurrent Mark-Compact collectors enable
167*795d594fSAndroid Build Coastguard Worker // GC metrics at the moment.
168*795d594fSAndroid Build Coastguard Worker if (heap->GetUseGenerationalCC()) {
169*795d594fSAndroid Build Coastguard Worker // Check that full-heap and/or young-generation GC metrics are non-null
170*795d594fSAndroid Build Coastguard Worker // after trigerring the collection.
171*795d594fSAndroid Build Coastguard Worker EXPECT_PRED2(
172*795d594fSAndroid Build Coastguard Worker AnyIsFalse, full_gc_collection_time->IsNull(), young_gc_collection_time->IsNull());
173*795d594fSAndroid Build Coastguard Worker EXPECT_PRED2(AnyIsFalse, full_gc_count->IsNull(), young_gc_count->IsNull());
174*795d594fSAndroid Build Coastguard Worker EXPECT_PRED2(AnyIsFalse, full_gc_count_delta->IsNull(), young_gc_count_delta->IsNull());
175*795d594fSAndroid Build Coastguard Worker EXPECT_PRED2(AnyIsFalse, full_gc_throughput->IsNull(), young_gc_throughput->IsNull());
176*795d594fSAndroid Build Coastguard Worker EXPECT_PRED2(
177*795d594fSAndroid Build Coastguard Worker AnyIsFalse, full_gc_tracing_throughput->IsNull(), young_gc_tracing_throughput->IsNull());
178*795d594fSAndroid Build Coastguard Worker EXPECT_PRED2(AnyIsFalse, full_gc_throughput_avg->IsNull(), young_gc_throughput_avg->IsNull());
179*795d594fSAndroid Build Coastguard Worker EXPECT_PRED2(AnyIsFalse,
180*795d594fSAndroid Build Coastguard Worker full_gc_tracing_throughput_avg->IsNull(),
181*795d594fSAndroid Build Coastguard Worker young_gc_tracing_throughput_avg->IsNull());
182*795d594fSAndroid Build Coastguard Worker EXPECT_PRED2(AnyIsFalse, full_gc_scanned_bytes->IsNull(), young_gc_scanned_bytes->IsNull());
183*795d594fSAndroid Build Coastguard Worker EXPECT_PRED2(AnyIsFalse,
184*795d594fSAndroid Build Coastguard Worker full_gc_scanned_bytes_delta->IsNull(),
185*795d594fSAndroid Build Coastguard Worker young_gc_scanned_bytes_delta->IsNull());
186*795d594fSAndroid Build Coastguard Worker EXPECT_PRED2(AnyIsFalse, full_gc_freed_bytes->IsNull(), young_gc_freed_bytes->IsNull());
187*795d594fSAndroid Build Coastguard Worker EXPECT_PRED2(
188*795d594fSAndroid Build Coastguard Worker AnyIsFalse, full_gc_freed_bytes_delta->IsNull(), young_gc_freed_bytes_delta->IsNull());
189*795d594fSAndroid Build Coastguard Worker // We have observed that sometimes the GC duration (both for full-heap and
190*795d594fSAndroid Build Coastguard Worker // young-generation collections) is null (b/271112044). Temporarily
191*795d594fSAndroid Build Coastguard Worker // suspend the following checks while we investigate.
192*795d594fSAndroid Build Coastguard Worker //
193*795d594fSAndroid Build Coastguard Worker // TODO(b/271112044): Investigate and adjust these expectations and/or the
194*795d594fSAndroid Build Coastguard Worker // corresponding metric logic.
195*795d594fSAndroid Build Coastguard Worker #if 0
196*795d594fSAndroid Build Coastguard Worker EXPECT_PRED2(AnyIsFalse, full_gc_duration->IsNull(), young_gc_duration->IsNull());
197*795d594fSAndroid Build Coastguard Worker EXPECT_PRED2(AnyIsFalse, full_gc_duration_delta->IsNull(), young_gc_duration_delta->IsNull());
198*795d594fSAndroid Build Coastguard Worker #endif
199*795d594fSAndroid Build Coastguard Worker } else {
200*795d594fSAndroid Build Coastguard Worker // Check that only full-heap GC metrics are non-null after trigerring the collection.
201*795d594fSAndroid Build Coastguard Worker EXPECT_FALSE(full_gc_collection_time->IsNull());
202*795d594fSAndroid Build Coastguard Worker EXPECT_FALSE(full_gc_count->IsNull());
203*795d594fSAndroid Build Coastguard Worker EXPECT_FALSE(full_gc_count_delta->IsNull());
204*795d594fSAndroid Build Coastguard Worker EXPECT_FALSE(full_gc_throughput->IsNull());
205*795d594fSAndroid Build Coastguard Worker EXPECT_FALSE(full_gc_tracing_throughput->IsNull());
206*795d594fSAndroid Build Coastguard Worker EXPECT_FALSE(full_gc_throughput_avg->IsNull());
207*795d594fSAndroid Build Coastguard Worker EXPECT_FALSE(full_gc_tracing_throughput_avg->IsNull());
208*795d594fSAndroid Build Coastguard Worker EXPECT_FALSE(full_gc_scanned_bytes->IsNull());
209*795d594fSAndroid Build Coastguard Worker EXPECT_FALSE(full_gc_scanned_bytes_delta->IsNull());
210*795d594fSAndroid Build Coastguard Worker EXPECT_FALSE(full_gc_freed_bytes->IsNull());
211*795d594fSAndroid Build Coastguard Worker EXPECT_FALSE(full_gc_freed_bytes_delta->IsNull());
212*795d594fSAndroid Build Coastguard Worker EXPECT_FALSE(full_gc_duration->IsNull());
213*795d594fSAndroid Build Coastguard Worker EXPECT_FALSE(full_gc_duration_delta->IsNull());
214*795d594fSAndroid Build Coastguard Worker
215*795d594fSAndroid Build Coastguard Worker EXPECT_TRUE(young_gc_collection_time->IsNull());
216*795d594fSAndroid Build Coastguard Worker EXPECT_TRUE(young_gc_count->IsNull());
217*795d594fSAndroid Build Coastguard Worker EXPECT_TRUE(young_gc_count_delta->IsNull());
218*795d594fSAndroid Build Coastguard Worker EXPECT_TRUE(young_gc_throughput->IsNull());
219*795d594fSAndroid Build Coastguard Worker EXPECT_TRUE(young_gc_tracing_throughput->IsNull());
220*795d594fSAndroid Build Coastguard Worker EXPECT_TRUE(young_gc_throughput_avg->IsNull());
221*795d594fSAndroid Build Coastguard Worker EXPECT_TRUE(young_gc_tracing_throughput_avg->IsNull());
222*795d594fSAndroid Build Coastguard Worker EXPECT_TRUE(young_gc_scanned_bytes->IsNull());
223*795d594fSAndroid Build Coastguard Worker EXPECT_TRUE(young_gc_scanned_bytes_delta->IsNull());
224*795d594fSAndroid Build Coastguard Worker EXPECT_TRUE(young_gc_freed_bytes->IsNull());
225*795d594fSAndroid Build Coastguard Worker EXPECT_TRUE(young_gc_freed_bytes_delta->IsNull());
226*795d594fSAndroid Build Coastguard Worker EXPECT_TRUE(young_gc_duration->IsNull());
227*795d594fSAndroid Build Coastguard Worker EXPECT_TRUE(young_gc_duration_delta->IsNull());
228*795d594fSAndroid Build Coastguard Worker }
229*795d594fSAndroid Build Coastguard Worker } else {
230*795d594fSAndroid Build Coastguard Worker // Check that all metrics are null after trigerring the collection.
231*795d594fSAndroid Build Coastguard Worker EXPECT_TRUE(full_gc_collection_time->IsNull());
232*795d594fSAndroid Build Coastguard Worker EXPECT_TRUE(full_gc_count->IsNull());
233*795d594fSAndroid Build Coastguard Worker EXPECT_TRUE(full_gc_count_delta->IsNull());
234*795d594fSAndroid Build Coastguard Worker EXPECT_TRUE(full_gc_throughput->IsNull());
235*795d594fSAndroid Build Coastguard Worker EXPECT_TRUE(full_gc_tracing_throughput->IsNull());
236*795d594fSAndroid Build Coastguard Worker EXPECT_TRUE(full_gc_throughput_avg->IsNull());
237*795d594fSAndroid Build Coastguard Worker EXPECT_TRUE(full_gc_tracing_throughput_avg->IsNull());
238*795d594fSAndroid Build Coastguard Worker EXPECT_TRUE(full_gc_scanned_bytes->IsNull());
239*795d594fSAndroid Build Coastguard Worker EXPECT_TRUE(full_gc_scanned_bytes_delta->IsNull());
240*795d594fSAndroid Build Coastguard Worker EXPECT_TRUE(full_gc_freed_bytes->IsNull());
241*795d594fSAndroid Build Coastguard Worker EXPECT_TRUE(full_gc_freed_bytes_delta->IsNull());
242*795d594fSAndroid Build Coastguard Worker EXPECT_TRUE(full_gc_duration->IsNull());
243*795d594fSAndroid Build Coastguard Worker EXPECT_TRUE(full_gc_duration_delta->IsNull());
244*795d594fSAndroid Build Coastguard Worker
245*795d594fSAndroid Build Coastguard Worker EXPECT_TRUE(young_gc_collection_time->IsNull());
246*795d594fSAndroid Build Coastguard Worker EXPECT_TRUE(young_gc_count->IsNull());
247*795d594fSAndroid Build Coastguard Worker EXPECT_TRUE(young_gc_count_delta->IsNull());
248*795d594fSAndroid Build Coastguard Worker EXPECT_TRUE(young_gc_throughput->IsNull());
249*795d594fSAndroid Build Coastguard Worker EXPECT_TRUE(young_gc_tracing_throughput->IsNull());
250*795d594fSAndroid Build Coastguard Worker EXPECT_TRUE(young_gc_throughput_avg->IsNull());
251*795d594fSAndroid Build Coastguard Worker EXPECT_TRUE(young_gc_tracing_throughput_avg->IsNull());
252*795d594fSAndroid Build Coastguard Worker EXPECT_TRUE(young_gc_scanned_bytes->IsNull());
253*795d594fSAndroid Build Coastguard Worker EXPECT_TRUE(young_gc_scanned_bytes_delta->IsNull());
254*795d594fSAndroid Build Coastguard Worker EXPECT_TRUE(young_gc_freed_bytes->IsNull());
255*795d594fSAndroid Build Coastguard Worker EXPECT_TRUE(young_gc_freed_bytes_delta->IsNull());
256*795d594fSAndroid Build Coastguard Worker EXPECT_TRUE(young_gc_duration->IsNull());
257*795d594fSAndroid Build Coastguard Worker EXPECT_TRUE(young_gc_duration_delta->IsNull());
258*795d594fSAndroid Build Coastguard Worker }
259*795d594fSAndroid Build Coastguard Worker }
260*795d594fSAndroid Build Coastguard Worker
261*795d594fSAndroid Build Coastguard Worker class ZygoteHeapTest : public CommonRuntimeTest {
262*795d594fSAndroid Build Coastguard Worker public:
ZygoteHeapTest()263*795d594fSAndroid Build Coastguard Worker ZygoteHeapTest() {
264*795d594fSAndroid Build Coastguard Worker use_boot_image_ = true; // Make the Runtime creation cheaper.
265*795d594fSAndroid Build Coastguard Worker }
266*795d594fSAndroid Build Coastguard Worker
SetUpRuntimeOptions(RuntimeOptions * options)267*795d594fSAndroid Build Coastguard Worker void SetUpRuntimeOptions(RuntimeOptions* options) override {
268*795d594fSAndroid Build Coastguard Worker CommonRuntimeTest::SetUpRuntimeOptions(options);
269*795d594fSAndroid Build Coastguard Worker options->push_back(std::make_pair("-Xzygote", nullptr));
270*795d594fSAndroid Build Coastguard Worker }
271*795d594fSAndroid Build Coastguard Worker };
272*795d594fSAndroid Build Coastguard Worker
TEST_F(ZygoteHeapTest,PreZygoteFork)273*795d594fSAndroid Build Coastguard Worker TEST_F(ZygoteHeapTest, PreZygoteFork) {
274*795d594fSAndroid Build Coastguard Worker // Exercise Heap::PreZygoteFork() to check it does not crash.
275*795d594fSAndroid Build Coastguard Worker Runtime::Current()->GetHeap()->PreZygoteFork();
276*795d594fSAndroid Build Coastguard Worker }
277*795d594fSAndroid Build Coastguard Worker
278*795d594fSAndroid Build Coastguard Worker } // namespace gc
279*795d594fSAndroid Build Coastguard Worker } // namespace art
280