Skip to content

Commit 9d55a69

Browse files
committed
8258483: [TESTBUG] gtest CollectorPolicy.young_scaled_initial_ergo_vm fails if heap is too small
Reviewed-by: sgehwolf Backport-of: d08b5bd9f5f740d75c1acfbd644ce1c822e03833
1 parent bfc3beb commit 9d55a69

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

test/hotspot/gtest/gc/shared/test_collectorPolicy.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class TestGenCollectorPolicy {
7878
FLAG_SET_ERGO(size_t, InitialHeapSize, 100 * M);
7979
FLAG_SET_ERGO(size_t, OldSize, 4 * M);
8080
FLAG_SET_ERGO(size_t, NewSize, 1 * M);
81-
FLAG_SET_ERGO(size_t, MaxNewSize, 80 * M);
81+
FLAG_SET_ERGO(size_t, MaxNewSize, 40 * M);
8282
Arguments::set_min_heap_size(40 * M);
8383

8484
ASSERT_NO_FATAL_FAILURE(setter1->execute());
@@ -227,10 +227,16 @@ TEST_VM(CollectorPolicy, young_min_ergo) {
227227
TestGenCollectorPolicy::TestWrapper::test(&setter, &checker);
228228
}
229229

230+
// Tests require at least 128M of MaxHeap
231+
// otherwise ergonomic is different and generation sizes might be changed.
232+
230233
// If NewSize has been ergonomically set, the collector policy
231234
// should use it for min but calculate the initial young size
232235
// using NewRatio.
233236
TEST_VM(CollectorPolicy, young_scaled_initial_ergo) {
237+
if (MaxHeapSize < 128 * M) {
238+
return;
239+
}
234240
TestGenCollectorPolicy::SetNewSizeErgo setter(20 * M);
235241
TestGenCollectorPolicy::CheckScaledYoungInitial checker;
236242

@@ -243,6 +249,9 @@ TEST_VM(CollectorPolicy, young_scaled_initial_ergo) {
243249
// the rest of the VM lifetime. This is an irreversible change and
244250
// could impact other tests so we use TEST_OTHER_VM
245251
TEST_OTHER_VM(CollectorPolicy, young_cmd) {
252+
if (MaxHeapSize < 128 * M) {
253+
return;
254+
}
246255
// If NewSize is set on the command line, it should be used
247256
// for both min and initial young size if less than min heap.
248257
TestGenCollectorPolicy::SetNewSizeCmd setter(20 * M);
@@ -255,8 +264,8 @@ TEST_OTHER_VM(CollectorPolicy, young_cmd) {
255264

256265
// If NewSize is set on command line, but is larger than the min
257266
// heap size, it should only be used for initial young size.
258-
TestGenCollectorPolicy::SetNewSizeCmd setter_large(80 * M);
259-
TestGenCollectorPolicy::CheckYoungInitial checker_large(80 * M);
267+
TestGenCollectorPolicy::SetNewSizeCmd setter_large(40 * M);
268+
TestGenCollectorPolicy::CheckYoungInitial checker_large(40 * M);
260269
TestGenCollectorPolicy::TestWrapper::test(&setter_large, &checker_large);
261270
}
262271

0 commit comments

Comments
 (0)