diff options
author | 2023-03-03 12:41:31 +0000 | |
---|---|---|
committer | 2023-03-06 13:36:06 +0000 | |
commit | 92181e6b4622d456b9266eed43bf97ef6bd83784 (patch) | |
tree | 545467f91bed8bdcf47fe14c0d4a7c316b92fd9d | |
parent | 03a88039cea89e3be80421a0f1f9c77b04571ef7 (diff) |
Improve and simplify error reporting in test `HeapTest.GCMetrics`.
Test: ART_USE_READ_BARRIER=true ART_USE_GENERATIONAL_CC=true \
m test-art-host-gtest-art_runtime_tests
Bug: 271112044
Bug: 270391874
Change-Id: I1230b9979eb9bbaade3336f2e2dd1271aab4e4fc
-rw-r--r-- | libartbase/base/metrics/metrics.h | 4 | ||||
-rw-r--r-- | runtime/gc/heap_test.cc | 36 |
2 files changed, 19 insertions, 21 deletions
diff --git a/libartbase/base/metrics/metrics.h b/libartbase/base/metrics/metrics.h index 512ce34417..40db63d282 100644 --- a/libartbase/base/metrics/metrics.h +++ b/libartbase/base/metrics/metrics.h @@ -113,8 +113,6 @@ class MetricsBase; namespace gc { class HeapTest_GCMetrics_Test; -template <typename T> -bool AnyIsNonNull(const metrics::MetricsBase<T>* x, const metrics::MetricsBase<T>* y); } // namespace gc namespace metrics { @@ -305,8 +303,6 @@ class MetricsBase { virtual bool IsNull() const = 0; ART_FRIEND_TEST(gc::HeapTest, GCMetrics); - template <typename T> - friend bool gc::AnyIsNonNull(const MetricsBase<T>* x, const MetricsBase<T>* y); }; template <DatumId counter_type, typename T = uint64_t> diff --git a/runtime/gc/heap_test.cc b/runtime/gc/heap_test.cc index 874189c380..5e64ae2192 100644 --- a/runtime/gc/heap_test.cc +++ b/runtime/gc/heap_test.cc @@ -106,10 +106,7 @@ TEST_F(HeapTest, DumpGCPerformanceOnShutdown) { Runtime::Current()->SetDumpGCPerformanceOnShutdown(true); } -template <typename T> -bool AnyIsNonNull(const metrics::MetricsBase<T>* x, const metrics::MetricsBase<T>* y) { - return !x->IsNull() || !y->IsNull(); -} +bool AnyIsFalse(bool x, bool y) { return !x || !y; } TEST_F(HeapTest, GCMetrics) { // Allocate a few string objects (to be collected), then trigger garbage @@ -167,19 +164,24 @@ TEST_F(HeapTest, GCMetrics) { if (heap->GetUseGenerationalCC()) { // Check that full-heap and/or young-generation GC metrics are non-null // after trigerring the collection. - EXPECT_PRED2(AnyIsNonNull<int64_t>, full_gc_collection_time, young_gc_collection_time); - EXPECT_PRED2(AnyIsNonNull<uint64_t>, full_gc_count, young_gc_count); - EXPECT_PRED2(AnyIsNonNull<uint64_t>, full_gc_count_delta, young_gc_count_delta); - EXPECT_PRED2(AnyIsNonNull<int64_t>, full_gc_throughput, young_gc_throughput); - EXPECT_PRED2(AnyIsNonNull<int64_t>, full_gc_tracing_throughput, young_gc_tracing_throughput); - EXPECT_PRED2(AnyIsNonNull<uint64_t>, full_gc_throughput_avg, young_gc_throughput_avg); EXPECT_PRED2( - AnyIsNonNull<uint64_t>, full_gc_tracing_throughput_avg, young_gc_tracing_throughput_avg); - EXPECT_PRED2(AnyIsNonNull<uint64_t>, full_gc_scanned_bytes, young_gc_scanned_bytes); + AnyIsFalse, full_gc_collection_time->IsNull(), young_gc_collection_time->IsNull()); + EXPECT_PRED2(AnyIsFalse, full_gc_count->IsNull(), young_gc_count->IsNull()); + EXPECT_PRED2(AnyIsFalse, full_gc_count_delta->IsNull(), young_gc_count_delta->IsNull()); + EXPECT_PRED2(AnyIsFalse, full_gc_throughput->IsNull(), young_gc_throughput->IsNull()); + EXPECT_PRED2( + AnyIsFalse, full_gc_tracing_throughput->IsNull(), young_gc_tracing_throughput->IsNull()); + EXPECT_PRED2(AnyIsFalse, full_gc_throughput_avg->IsNull(), young_gc_throughput_avg->IsNull()); + EXPECT_PRED2(AnyIsFalse, + full_gc_tracing_throughput_avg->IsNull(), + young_gc_tracing_throughput_avg->IsNull()); + EXPECT_PRED2(AnyIsFalse, full_gc_scanned_bytes->IsNull(), young_gc_scanned_bytes->IsNull()); + EXPECT_PRED2(AnyIsFalse, + full_gc_scanned_bytes_delta->IsNull(), + young_gc_scanned_bytes_delta->IsNull()); + EXPECT_PRED2(AnyIsFalse, full_gc_freed_bytes->IsNull(), young_gc_freed_bytes->IsNull()); EXPECT_PRED2( - AnyIsNonNull<uint64_t>, full_gc_scanned_bytes_delta, young_gc_scanned_bytes_delta); - EXPECT_PRED2(AnyIsNonNull<uint64_t>, full_gc_freed_bytes, young_gc_freed_bytes); - EXPECT_PRED2(AnyIsNonNull<uint64_t>, full_gc_freed_bytes_delta, young_gc_freed_bytes_delta); + AnyIsFalse, full_gc_freed_bytes_delta->IsNull(), young_gc_freed_bytes_delta->IsNull()); // We have observed that sometimes the GC duration (both for full-heap and // young-generation collections) is null (b/271112044). Temporarily // suspend the following checks while we investigate. @@ -187,8 +189,8 @@ TEST_F(HeapTest, GCMetrics) { // TODO(b/271112044): Investigate and adjust these expectations and/or the // corresponding metric logic. #if 0 - EXPECT_PRED2(AnyIsNonNull<uint64_t>, full_gc_duration, young_gc_duration); - EXPECT_PRED2(AnyIsNonNull<uint64_t>, full_gc_duration_delta, young_gc_duration_delta); + EXPECT_PRED2(AnyIsFalse, full_gc_duration->IsNull(), young_gc_duration->IsNull()); + EXPECT_PRED2(AnyIsFalse, full_gc_duration_delta->IsNull(), young_gc_duration_delta->IsNull()); #endif } else { // Check that only full-heap GC metrics are non-null after trigerring the collection. |