Path: blob/master/test/hotspot/jtreg/gc/shenandoah/options/TestHeuristicsUnlock.java
41153 views
/*1* Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324/*25* @test TestHeuristicsUnlock26* @summary Test that Shenandoah heuristics are unlocked properly27* @requires vm.gc.Shenandoah28* @library /test/lib29* @modules java.base/jdk.internal.misc30* java.management31* @run driver TestHeuristicsUnlock32*/3334import jdk.test.lib.process.ProcessTools;35import jdk.test.lib.process.OutputAnalyzer;3637public class TestHeuristicsUnlock {3839enum Mode {40PRODUCT,41DIAGNOSTIC,42EXPERIMENTAL,43}4445public static void main(String[] args) throws Exception {46testWith("-XX:ShenandoahGCHeuristics=adaptive", Mode.PRODUCT);47testWith("-XX:ShenandoahGCHeuristics=static", Mode.PRODUCT);48testWith("-XX:ShenandoahGCHeuristics=compact", Mode.PRODUCT);49testWith("-XX:ShenandoahGCHeuristics=aggressive", Mode.DIAGNOSTIC);50}5152private static void testWith(String h, Mode mode) throws Exception {53{54ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(55"-Xmx128m",56"-XX:-UnlockDiagnosticVMOptions",57"-XX:-UnlockExperimentalVMOptions",58"-XX:+UseShenandoahGC",59h,60"-version"61);62OutputAnalyzer output = new OutputAnalyzer(pb.start());63switch (mode) {64case PRODUCT:65output.shouldHaveExitValue(0);66break;67case DIAGNOSTIC:68case EXPERIMENTAL:69output.shouldNotHaveExitValue(0);70break;71}72}7374{75ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(76"-Xmx128m",77"-XX:+UnlockDiagnosticVMOptions",78"-XX:-UnlockExperimentalVMOptions",79"-XX:+UseShenandoahGC",80h,81"-version"82);83OutputAnalyzer output = new OutputAnalyzer(pb.start());84switch (mode) {85case PRODUCT:86case DIAGNOSTIC:87output.shouldHaveExitValue(0);88break;89case EXPERIMENTAL:90output.shouldNotHaveExitValue(0);91break;92}93}9495{96ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(97"-Xmx128m",98"-XX:-UnlockDiagnosticVMOptions",99"-XX:+UnlockExperimentalVMOptions",100"-XX:+UseShenandoahGC",101h,102"-version"103);104OutputAnalyzer output = new OutputAnalyzer(pb.start());105switch (mode) {106case PRODUCT:107case EXPERIMENTAL:108output.shouldHaveExitValue(0);109break;110case DIAGNOSTIC:111output.shouldNotHaveExitValue(0);112break;113}114}115}116117}118119120