< prev index next > test/hotspot/jtreg/gc/shenandoah/TestPeriodicGC.java
Print this page
/*
* Copyright (c) 2017, 2020, Red Hat, Inc. All rights reserved.
+ * Copyright Amazon.com Inc. 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.
cmds[args.length] = TestPeriodicGC.class.getName();
cmds[args.length + 1] = "test";
OutputAnalyzer output = ProcessTools.executeLimitedTestJava(cmds);
output.shouldHaveExitValue(0);
! if (periodic && !output.getOutput().contains("Trigger: Time since last GC")) {
! throw new AssertionError(msg + ": Should have periodic GC in logs");
}
! if (!periodic && output.getOutput().contains("Trigger: Time since last GC")) {
! throw new AssertionError(msg + ": Should not have periodic GC in logs");
}
}
public static void main(String[] args) throws Exception {
if (args.length > 0 && args[0].equals("test")) {
cmds[args.length] = TestPeriodicGC.class.getName();
cmds[args.length + 1] = "test";
OutputAnalyzer output = ProcessTools.executeLimitedTestJava(cmds);
output.shouldHaveExitValue(0);
! if (periodic) {
! output.shouldContain("Trigger (GLOBAL): Time since last GC");
}
! if (!periodic) {
! output.shouldNotContain("Trigger (GLOBAL): Time since last GC");
+ }
+ }
+
+ public static void testGenerational(boolean periodic, String... args) throws Exception {
+ String[] cmds = Arrays.copyOf(args, args.length + 2);
+ cmds[args.length] = TestPeriodicGC.class.getName();
+ cmds[args.length + 1] = "test";
+ ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(cmds);
+
+ OutputAnalyzer output = new OutputAnalyzer(pb.start());
+ output.shouldHaveExitValue(0);
+ if (periodic) {
+ output.shouldContain("Trigger (YOUNG): Time since last GC");
+ output.shouldContain("Trigger (OLD): Time since last GC");
+ } else {
+ output.shouldNotContain("Trigger (YOUNG): Time since last GC");
+ output.shouldNotContain("Trigger (OLD): Time since last GC");
}
}
public static void main(String[] args) throws Exception {
if (args.length > 0 && args[0].equals("test")) {
"-XX:+UnlockExperimentalVMOptions",
"-XX:+UseShenandoahGC",
"-XX:ShenandoahGCMode=passive",
"-XX:ShenandoahGuaranteedGCInterval=1000"
);
+
+ testGenerational(true,
+ "-Xlog:gc",
+ "-XX:+UnlockDiagnosticVMOptions",
+ "-XX:+UnlockExperimentalVMOptions",
+ "-XX:+UseShenandoahGC",
+ "-XX:ShenandoahGCMode=generational",
+ "-XX:ShenandoahGuaranteedYoungGCInterval=1000",
+ "-XX:ShenandoahGuaranteedOldGCInterval=1500"
+ );
+
+ testGenerational(false,
+ "-Xlog:gc",
+ "-XX:+UnlockDiagnosticVMOptions",
+ "-XX:+UnlockExperimentalVMOptions",
+ "-XX:+UseShenandoahGC",
+ "-XX:ShenandoahGCMode=generational",
+ "-XX:ShenandoahGuaranteedYoungGCInterval=0",
+ "-XX:ShenandoahGuaranteedOldGCInterval=0"
+ );
}
}
< prev index next >