# HG changeset patch # User kzhaldyb # Date 1539102278 25200 # Tue Oct 09 09:24:38 2018 -0700 # Node ID 73805e89a304bd92709b5a0ead8c09f045db8531 # Parent 50dc6dd40e6a1186c5ae61b9ad62fda5fb1c8b84 8157728: Covert GCTimer_test to GTest Reviewed-by: duke diff --git a/src/hotspot/share/gc/shared/gcTimer.cpp b/src/hotspot/share/gc/shared/gcTimer.cpp --- a/src/hotspot/share/gc/shared/gcTimer.cpp +++ b/src/hotspot/share/gc/shared/gcTimer.cpp @@ -184,212 +184,3 @@ } -/////////////// Unit tests /////////////// - -#ifndef PRODUCT - -class TimePartitionPhasesIteratorTest { - public: - static void all() { - one_pause(); - two_pauses(); - one_sub_pause_phase(); - many_sub_pause_phases(); - many_sub_pause_phases2(); - max_nested_pause_phases(); - one_concurrent(); - } - - static void validate_gc_phase(GCPhase* phase, int level, const char* name, const Ticks& start, const Ticks& end) { - assert(phase->level() == level, "Incorrect level"); - assert(strcmp(phase->name(), name) == 0, "Incorrect name"); - assert(phase->start() == start, "Incorrect start"); - assert(phase->end() == end, "Incorrect end"); - } - - static void one_pause() { - TimePartitions time_partitions; - time_partitions.report_gc_phase_start("PausePhase", 2); - time_partitions.report_gc_phase_end(8); - - TimePartitionPhasesIterator iter(&time_partitions); - - validate_gc_phase(iter.next(), 0, "PausePhase", 2, 8); - assert(time_partitions.sum_of_pauses() == Ticks(8) - Ticks(2), "Incorrect"); - assert(time_partitions.longest_pause() == Ticks(8) - Ticks(2), "Incorrect"); - - assert(!iter.has_next(), "Too many elements"); - } - - static void two_pauses() { - TimePartitions time_partitions; - time_partitions.report_gc_phase_start("PausePhase1", 2); - time_partitions.report_gc_phase_end(3); - time_partitions.report_gc_phase_start("PausePhase2", 4); - time_partitions.report_gc_phase_end(6); - - TimePartitionPhasesIterator iter(&time_partitions); - - validate_gc_phase(iter.next(), 0, "PausePhase1", 2, 3); - validate_gc_phase(iter.next(), 0, "PausePhase2", 4, 6); - - assert(time_partitions.sum_of_pauses() == Ticks(3) - Ticks(0), "Incorrect"); - assert(time_partitions.longest_pause() == Ticks(2) - Ticks(0), "Incorrect"); - - assert(!iter.has_next(), "Too many elements"); - } - - static void one_sub_pause_phase() { - TimePartitions time_partitions; - time_partitions.report_gc_phase_start("PausePhase", 2); - time_partitions.report_gc_phase_start("SubPhase", 3); - time_partitions.report_gc_phase_end(4); - time_partitions.report_gc_phase_end(5); - - TimePartitionPhasesIterator iter(&time_partitions); - - validate_gc_phase(iter.next(), 0, "PausePhase", 2, 5); - validate_gc_phase(iter.next(), 1, "SubPhase", 3, 4); - - assert(time_partitions.sum_of_pauses() == Ticks(3) - Ticks(0), "Incorrect"); - assert(time_partitions.longest_pause() == Ticks(3) - Ticks(0), "Incorrect"); - - assert(!iter.has_next(), "Too many elements"); - } - - static void max_nested_pause_phases() { - TimePartitions time_partitions; - time_partitions.report_gc_phase_start("PausePhase", 2); - time_partitions.report_gc_phase_start("SubPhase1", 3); - time_partitions.report_gc_phase_start("SubPhase2", 4); - time_partitions.report_gc_phase_start("SubPhase3", 5); - time_partitions.report_gc_phase_end(6); - time_partitions.report_gc_phase_end(7); - time_partitions.report_gc_phase_end(8); - time_partitions.report_gc_phase_end(9); - - TimePartitionPhasesIterator iter(&time_partitions); - - validate_gc_phase(iter.next(), 0, "PausePhase", 2, 9); - validate_gc_phase(iter.next(), 1, "SubPhase1", 3, 8); - validate_gc_phase(iter.next(), 2, "SubPhase2", 4, 7); - validate_gc_phase(iter.next(), 3, "SubPhase3", 5, 6); - - assert(time_partitions.sum_of_pauses() == Ticks(7) - Ticks(0), "Incorrect"); - assert(time_partitions.longest_pause() == Ticks(7) - Ticks(0), "Incorrect"); - - assert(!iter.has_next(), "Too many elements"); - } - - static void many_sub_pause_phases() { - TimePartitions time_partitions; - time_partitions.report_gc_phase_start("PausePhase", 2); - - time_partitions.report_gc_phase_start("SubPhase1", 3); - time_partitions.report_gc_phase_end(4); - time_partitions.report_gc_phase_start("SubPhase2", 5); - time_partitions.report_gc_phase_end(6); - time_partitions.report_gc_phase_start("SubPhase3", 7); - time_partitions.report_gc_phase_end(8); - time_partitions.report_gc_phase_start("SubPhase4", 9); - time_partitions.report_gc_phase_end(10); - - time_partitions.report_gc_phase_end(11); - - TimePartitionPhasesIterator iter(&time_partitions); - - validate_gc_phase(iter.next(), 0, "PausePhase", 2, 11); - validate_gc_phase(iter.next(), 1, "SubPhase1", 3, 4); - validate_gc_phase(iter.next(), 1, "SubPhase2", 5, 6); - validate_gc_phase(iter.next(), 1, "SubPhase3", 7, 8); - validate_gc_phase(iter.next(), 1, "SubPhase4", 9, 10); - - assert(time_partitions.sum_of_pauses() == Ticks(9) - Ticks(0), "Incorrect"); - assert(time_partitions.longest_pause() == Ticks(9) - Ticks(0), "Incorrect"); - - assert(!iter.has_next(), "Too many elements"); - } - - static void many_sub_pause_phases2() { - TimePartitions time_partitions; - time_partitions.report_gc_phase_start("PausePhase", 2); - - time_partitions.report_gc_phase_start("SubPhase1", 3); - time_partitions.report_gc_phase_start("SubPhase11", 4); - time_partitions.report_gc_phase_end(5); - time_partitions.report_gc_phase_start("SubPhase12", 6); - time_partitions.report_gc_phase_end(7); - time_partitions.report_gc_phase_end(8); - time_partitions.report_gc_phase_start("SubPhase2", 9); - time_partitions.report_gc_phase_start("SubPhase21", 10); - time_partitions.report_gc_phase_end(11); - time_partitions.report_gc_phase_start("SubPhase22", 12); - time_partitions.report_gc_phase_end(13); - time_partitions.report_gc_phase_end(14); - time_partitions.report_gc_phase_start("SubPhase3", 15); - time_partitions.report_gc_phase_end(16); - - time_partitions.report_gc_phase_end(17); - - TimePartitionPhasesIterator iter(&time_partitions); - - validate_gc_phase(iter.next(), 0, "PausePhase", 2, 17); - validate_gc_phase(iter.next(), 1, "SubPhase1", 3, 8); - validate_gc_phase(iter.next(), 2, "SubPhase11", 4, 5); - validate_gc_phase(iter.next(), 2, "SubPhase12", 6, 7); - validate_gc_phase(iter.next(), 1, "SubPhase2", 9, 14); - validate_gc_phase(iter.next(), 2, "SubPhase21", 10, 11); - validate_gc_phase(iter.next(), 2, "SubPhase22", 12, 13); - validate_gc_phase(iter.next(), 1, "SubPhase3", 15, 16); - - assert(time_partitions.sum_of_pauses() == Ticks(15) - Ticks(0), "Incorrect"); - assert(time_partitions.longest_pause() == Ticks(15) - Ticks(0), "Incorrect"); - - assert(!iter.has_next(), "Too many elements"); - } - - static void one_concurrent() { - TimePartitions time_partitions; - time_partitions.report_gc_phase_start("ConcurrentPhase", 2, GCPhase::ConcurrentPhaseType); - time_partitions.report_gc_phase_end(8, GCPhase::ConcurrentPhaseType); - - TimePartitionPhasesIterator iter(&time_partitions); - - validate_gc_phase(iter.next(), 0, "ConcurrentPhase", 2, 8); - // ConcurrentPhaseType should not affect to both 'sum_of_pauses()' and 'longest_pause()'. - assert(time_partitions.sum_of_pauses() == Tickspan(), "Incorrect"); - assert(time_partitions.longest_pause() == Tickspan(), "Incorrect"); - - assert(!iter.has_next(), "Too many elements"); - } -}; - -class GCTimerTest { -public: - static void all() { - gc_start(); - gc_end(); - } - - static void gc_start() { - GCTimer gc_timer; - gc_timer.register_gc_start(1); - - assert(gc_timer.gc_start() == Ticks(1), "Incorrect"); - } - - static void gc_end() { - GCTimer gc_timer; - gc_timer.register_gc_start(1); - gc_timer.register_gc_end(2); - - assert(gc_timer.gc_end() == Ticks(2), "Incorrect"); - } -}; - -void GCTimer_test() { - GCTimerTest::all(); - TimePartitionPhasesIteratorTest::all(); -} - -#endif diff --git a/src/hotspot/share/gc/shared/gcTimer.hpp b/src/hotspot/share/gc/shared/gcTimer.hpp --- a/src/hotspot/share/gc/shared/gcTimer.hpp +++ b/src/hotspot/share/gc/shared/gcTimer.hpp @@ -129,7 +129,6 @@ }; class GCTimer : public ResourceObj { - NOT_PRODUCT(friend class GCTimerTest;) protected: Ticks _gc_start; Ticks _gc_end; diff --git a/src/hotspot/share/utilities/internalVMTests.cpp b/src/hotspot/share/utilities/internalVMTests.cpp --- a/src/hotspot/share/utilities/internalVMTests.cpp +++ b/src/hotspot/share/utilities/internalVMTests.cpp @@ -46,7 +46,6 @@ run_unit_test(TestReserveMemorySpecial_test); run_unit_test(TestVirtualSpace_test); run_unit_test(TestMetaspaceUtils_test); - run_unit_test(GCTimer_test); // These tests require the "C" locale to correctly parse decimal values const char* orig_locale = setlocale(LC_NUMERIC, NULL); setlocale(LC_NUMERIC, "C"); diff --git a/src/hotspot/share/utilities/ticks.hpp b/src/hotspot/share/utilities/ticks.hpp --- a/src/hotspot/share/utilities/ticks.hpp +++ b/src/hotspot/share/utilities/ticks.hpp @@ -233,7 +233,7 @@ TimeInstant(jlong ticks) : Rep(ticks) {} friend class GranularTimer; friend class ObjectSample; - // GC VM tests + // GC unit tests friend class TimePartitionPhasesIteratorTest; friend class GCTimerTest; }; diff --git a/test/hotspot/gtest/gc/shared/test_gcTimer.cpp b/test/hotspot/gtest/gc/shared/test_gcTimer.cpp new file mode 100644 --- /dev/null +++ b/test/hotspot/gtest/gc/shared/test_gcTimer.cpp @@ -0,0 +1,238 @@ +/* + * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +#include "precompiled.hpp" +#include "gc/shared/gcTimer.hpp" +#include "utilities/ticks.hpp" +#include "unittest.hpp" + +class GCTimerTest { + public: + static void register_gc_start(GCTimer* const timer, jlong ticks) { + timer->register_gc_start(ticks); + } + static void register_gc_end(GCTimer* const timer, jlong ticks) { + timer->register_gc_end(ticks); + } +}; + +TEST(GCTimer, start) { + GCTimer gc_timer; + GCTimerTest::register_gc_start(&gc_timer, 1); + + EXPECT_EQ(1, gc_timer.gc_start().value()); +} + +TEST(GCTimer, end) { + GCTimer gc_timer; + + GCTimerTest::register_gc_start(&gc_timer, 1); + GCTimerTest::register_gc_end(&gc_timer, 2); + + ASSERT_EQ(2, gc_timer.gc_end().value()); +} + +class TimePartitionPhasesIteratorTest { + public: + + static void validate_gc_phase(GCPhase* phase, int level, const char* name, const jlong& start, const jlong& end) { + EXPECT_EQ(level, phase->level()); + EXPECT_STREQ(name, phase->name()); + EXPECT_EQ(start, phase->start().value()); + EXPECT_EQ(end, phase->end().value()); + } + + static void validate_pauses(const TimePartitions& time_partitions, const Tickspan& expected_sum_of_pauses, const Tickspan& expected_longest_pause) { + EXPECT_EQ(expected_sum_of_pauses, time_partitions.sum_of_pauses()); + EXPECT_EQ(expected_longest_pause, time_partitions.longest_pause()); + } + static void validate_pauses(const TimePartitions& time_partitions, const Tickspan& expected_pause) { + TimePartitionPhasesIteratorTest::validate_pauses(time_partitions, expected_pause, expected_pause); + } + static void validate_pauses(const TimePartitions& time_partitions, jlong end, jlong start) { + TimePartitionPhasesIteratorTest::validate_pauses(time_partitions, Ticks(end) - Ticks(start)); + } + static void validate_pauses(const TimePartitions& time_partitions, jlong all_end, jlong all_start, jlong longest_end, jlong longest_start) { + TimePartitionPhasesIteratorTest::validate_pauses(time_partitions, Ticks(all_end) - Ticks(all_start), Ticks(longest_end) - Ticks(longest_start)); + } + + static void report_gc_phase_start(TimePartitions* const partitions, const char* name, jlong ticks, GCPhase::PhaseType type=GCPhase::PausePhaseType) { + partitions->report_gc_phase_start(name, Ticks(ticks), type); + } + + static void report_gc_phase_end(TimePartitions* const partitions, jlong ticks, GCPhase::PhaseType type=GCPhase::PausePhaseType) { + partitions->report_gc_phase_end(Ticks(ticks), type); + } +}; + +TEST(TimePartitionPhasesIterator, one_pause) { + TimePartitions time_partitions; + TimePartitionPhasesIteratorTest::report_gc_phase_start(&time_partitions, "PausePhase", 2); + TimePartitionPhasesIteratorTest::report_gc_phase_end(&time_partitions, 8); + + TimePartitionPhasesIterator iter(&time_partitions); + + EXPECT_NO_FATAL_FAILURE(TimePartitionPhasesIteratorTest::validate_gc_phase(iter.next(), 0, "PausePhase", 2, 8)); + + EXPECT_NO_FATAL_FAILURE(TimePartitionPhasesIteratorTest::validate_pauses(time_partitions, 8, 2)); + + EXPECT_FALSE(iter.has_next()) << "Too many elements"; +} + +TEST(TimePartitionPhasesIterator, two_pauses) { + TimePartitions time_partitions; + TimePartitionPhasesIteratorTest::report_gc_phase_start(&time_partitions, "PausePhase1", 2); + TimePartitionPhasesIteratorTest::report_gc_phase_end(&time_partitions, 3); + TimePartitionPhasesIteratorTest::report_gc_phase_start(&time_partitions, "PausePhase2", 4); + TimePartitionPhasesIteratorTest::report_gc_phase_end(&time_partitions, 6); + + TimePartitionPhasesIterator iter(&time_partitions); + + EXPECT_NO_FATAL_FAILURE(TimePartitionPhasesIteratorTest::validate_gc_phase(iter.next(), 0, "PausePhase1", 2, 3)); + EXPECT_NO_FATAL_FAILURE(TimePartitionPhasesIteratorTest::validate_gc_phase(iter.next(), 0, "PausePhase2", 4, 6)); + + EXPECT_NO_FATAL_FAILURE(TimePartitionPhasesIteratorTest::validate_pauses(time_partitions, 3, 0, 2, 0)); + + EXPECT_FALSE(iter.has_next()) << "Too many elements"; +} + +TEST(TimePartitionPhasesIterator, one_sub_pause_phase) { + TimePartitions time_partitions; + TimePartitionPhasesIteratorTest::report_gc_phase_start(&time_partitions, "PausePhase", 2); + TimePartitionPhasesIteratorTest::report_gc_phase_start(&time_partitions, "SubPhase", 3); + TimePartitionPhasesIteratorTest::report_gc_phase_end(&time_partitions, 4); + TimePartitionPhasesIteratorTest::report_gc_phase_end(&time_partitions, 5); + + TimePartitionPhasesIterator iter(&time_partitions); + + EXPECT_NO_FATAL_FAILURE(TimePartitionPhasesIteratorTest::validate_gc_phase(iter.next(), 0, "PausePhase", 2, 5)); + EXPECT_NO_FATAL_FAILURE(TimePartitionPhasesIteratorTest::validate_gc_phase(iter.next(), 1, "SubPhase", 3, 4)); + + EXPECT_NO_FATAL_FAILURE(TimePartitionPhasesIteratorTest::validate_pauses(time_partitions, 3, 0)); + + EXPECT_FALSE(iter.has_next()) << "Too many elements"; +} + +TEST(TimePartitionPhasesIterator, max_nested_pause_phases) { + TimePartitions time_partitions; + TimePartitionPhasesIteratorTest::report_gc_phase_start(&time_partitions, "PausePhase", 2); + TimePartitionPhasesIteratorTest::report_gc_phase_start(&time_partitions, "SubPhase1", 3); + TimePartitionPhasesIteratorTest::report_gc_phase_start(&time_partitions, "SubPhase2", 4); + TimePartitionPhasesIteratorTest::report_gc_phase_start(&time_partitions, "SubPhase3", 5); + TimePartitionPhasesIteratorTest::report_gc_phase_end(&time_partitions, 6); + TimePartitionPhasesIteratorTest::report_gc_phase_end(&time_partitions, 7); + TimePartitionPhasesIteratorTest::report_gc_phase_end(&time_partitions, 8); + TimePartitionPhasesIteratorTest::report_gc_phase_end(&time_partitions, 9); + + TimePartitionPhasesIterator iter(&time_partitions); + + EXPECT_NO_FATAL_FAILURE(TimePartitionPhasesIteratorTest::validate_gc_phase(iter.next(), 0, "PausePhase", 2, 9)); + EXPECT_NO_FATAL_FAILURE(TimePartitionPhasesIteratorTest::validate_gc_phase(iter.next(), 1, "SubPhase1", 3, 8)); + EXPECT_NO_FATAL_FAILURE(TimePartitionPhasesIteratorTest::validate_gc_phase(iter.next(), 2, "SubPhase2", 4, 7)); + EXPECT_NO_FATAL_FAILURE(TimePartitionPhasesIteratorTest::validate_gc_phase(iter.next(), 3, "SubPhase3", 5, 6)); + + EXPECT_NO_FATAL_FAILURE(TimePartitionPhasesIteratorTest::validate_pauses(time_partitions, 7, 0)); + + EXPECT_FALSE(iter.has_next()) << "Too many elements"; +} + +TEST(TimePartitionPhasesIterator, many_sub_pause_phases) { + TimePartitions time_partitions; + TimePartitionPhasesIteratorTest::report_gc_phase_start(&time_partitions, "PausePhase", 2); + + TimePartitionPhasesIteratorTest::report_gc_phase_start(&time_partitions, "SubPhase1", 3); + TimePartitionPhasesIteratorTest::report_gc_phase_end(&time_partitions, 4); + TimePartitionPhasesIteratorTest::report_gc_phase_start(&time_partitions, "SubPhase2", 5); + TimePartitionPhasesIteratorTest::report_gc_phase_end(&time_partitions, 6); + TimePartitionPhasesIteratorTest::report_gc_phase_start(&time_partitions, "SubPhase3", 7); + TimePartitionPhasesIteratorTest::report_gc_phase_end(&time_partitions, 8); + TimePartitionPhasesIteratorTest::report_gc_phase_start(&time_partitions, "SubPhase4", 9); + TimePartitionPhasesIteratorTest::report_gc_phase_end(&time_partitions, 10); + + TimePartitionPhasesIteratorTest::report_gc_phase_end(&time_partitions, 11); + + TimePartitionPhasesIterator iter(&time_partitions); + + EXPECT_NO_FATAL_FAILURE(TimePartitionPhasesIteratorTest::validate_gc_phase(iter.next(), 0, "PausePhase", 2, 11)); + EXPECT_NO_FATAL_FAILURE(TimePartitionPhasesIteratorTest::validate_gc_phase(iter.next(), 1, "SubPhase1", 3, 4)); + EXPECT_NO_FATAL_FAILURE(TimePartitionPhasesIteratorTest::validate_gc_phase(iter.next(), 1, "SubPhase2", 5, 6)); + EXPECT_NO_FATAL_FAILURE(TimePartitionPhasesIteratorTest::validate_gc_phase(iter.next(), 1, "SubPhase3", 7, 8)); + EXPECT_NO_FATAL_FAILURE(TimePartitionPhasesIteratorTest::validate_gc_phase(iter.next(), 1, "SubPhase4", 9, 10)); + + EXPECT_NO_FATAL_FAILURE(TimePartitionPhasesIteratorTest::validate_pauses(time_partitions, 9, 0)); + + EXPECT_FALSE(iter.has_next()) << "Too many elements"; +} + +TEST(TimePartitionPhasesIterator, many_sub_pause_phases2) { + TimePartitions time_partitions; + TimePartitionPhasesIteratorTest::report_gc_phase_start(&time_partitions, "PausePhase", 2); + + TimePartitionPhasesIteratorTest::report_gc_phase_start(&time_partitions, "SubPhase1", 3); + TimePartitionPhasesIteratorTest::report_gc_phase_start(&time_partitions, "SubPhase11", 4); + TimePartitionPhasesIteratorTest::report_gc_phase_end(&time_partitions, 5); + TimePartitionPhasesIteratorTest::report_gc_phase_start(&time_partitions, "SubPhase12", 6); + TimePartitionPhasesIteratorTest::report_gc_phase_end(&time_partitions, 7); + TimePartitionPhasesIteratorTest::report_gc_phase_end(&time_partitions, 8); + + TimePartitionPhasesIteratorTest::report_gc_phase_start(&time_partitions, "SubPhase2", 9); + TimePartitionPhasesIteratorTest::report_gc_phase_start(&time_partitions, "SubPhase21", 10); + TimePartitionPhasesIteratorTest::report_gc_phase_end(&time_partitions, 11); + TimePartitionPhasesIteratorTest::report_gc_phase_start(&time_partitions, "SubPhase22", 12); + TimePartitionPhasesIteratorTest::report_gc_phase_end(&time_partitions, 13); + TimePartitionPhasesIteratorTest::report_gc_phase_end(&time_partitions, 14); + + TimePartitionPhasesIteratorTest::report_gc_phase_start(&time_partitions, "SubPhase3", 15); + TimePartitionPhasesIteratorTest::report_gc_phase_end(&time_partitions, 16); + + TimePartitionPhasesIteratorTest::report_gc_phase_end(&time_partitions, 17); + + TimePartitionPhasesIterator iter(&time_partitions); + + EXPECT_NO_FATAL_FAILURE(TimePartitionPhasesIteratorTest::validate_gc_phase(iter.next(), 0, "PausePhase", 2, 17)); + EXPECT_NO_FATAL_FAILURE(TimePartitionPhasesIteratorTest::validate_gc_phase(iter.next(), 1, "SubPhase1", 3, 8)); + EXPECT_NO_FATAL_FAILURE(TimePartitionPhasesIteratorTest::validate_gc_phase(iter.next(), 2, "SubPhase11", 4, 5)); + EXPECT_NO_FATAL_FAILURE(TimePartitionPhasesIteratorTest::validate_gc_phase(iter.next(), 2, "SubPhase12", 6, 7)); + EXPECT_NO_FATAL_FAILURE(TimePartitionPhasesIteratorTest::validate_gc_phase(iter.next(), 1, "SubPhase2", 9, 14)); + EXPECT_NO_FATAL_FAILURE(TimePartitionPhasesIteratorTest::validate_gc_phase(iter.next(), 2, "SubPhase21", 10, 11)); + EXPECT_NO_FATAL_FAILURE(TimePartitionPhasesIteratorTest::validate_gc_phase(iter.next(), 2, "SubPhase22", 12, 13)); + EXPECT_NO_FATAL_FAILURE(TimePartitionPhasesIteratorTest::validate_gc_phase(iter.next(), 1, "SubPhase3", 15, 16)); + + EXPECT_NO_FATAL_FAILURE(TimePartitionPhasesIteratorTest::validate_pauses(time_partitions, 15, 0)); + + EXPECT_FALSE(iter.has_next()) << "Too many elements"; +} + +TEST(TimePartitionPhasesIterator, one_concurrent) { + TimePartitions time_partitions; + TimePartitionPhasesIteratorTest::report_gc_phase_start(&time_partitions, "ConcurrentPhase", 2, GCPhase::ConcurrentPhaseType); + TimePartitionPhasesIteratorTest::report_gc_phase_end(&time_partitions, 8, GCPhase::ConcurrentPhaseType); + + TimePartitionPhasesIterator iter(&time_partitions); + + EXPECT_NO_FATAL_FAILURE(TimePartitionPhasesIteratorTest::validate_gc_phase(iter.next(), 0, "ConcurrentPhase", 2, 8)); + // ConcurrentPhaseType should not affect to both 'sum_of_pauses()' and 'longest_pause()'. + EXPECT_NO_FATAL_FAILURE(TimePartitionPhasesIteratorTest::validate_pauses(time_partitions, Tickspan())); + + EXPECT_FALSE(iter.has_next()) << "Too many elements"; +}