Path: blob/master/test/hotspot/jtreg/gc/shenandoah/options/TestWrongBarrierEnable.java
41153 views
/*1* Copyright (c) 2020, 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/* @test TestWrongBarrierEnable25* @summary Test that disabling wrong barriers fails early26* @requires vm.gc.Shenandoah27* @library /test/lib28* @run driver TestWrongBarrierEnable29*/3031import java.util.*;3233import jdk.test.lib.process.ProcessTools;34import jdk.test.lib.process.OutputAnalyzer;3536public class TestWrongBarrierEnable {3738public static void main(String[] args) throws Exception {39String[] concurrent = {40"ShenandoahIUBarrier",41};42String[] iu = {43"ShenandoahSATBBarrier",44};4546shouldFailAll("-XX:ShenandoahGCHeuristics=adaptive", concurrent);47shouldFailAll("-XX:ShenandoahGCHeuristics=static", concurrent);48shouldFailAll("-XX:ShenandoahGCHeuristics=compact", concurrent);49shouldFailAll("-XX:ShenandoahGCHeuristics=aggressive", concurrent);50shouldFailAll("-XX:ShenandoahGCMode=iu", iu);51shouldPassAll("-XX:ShenandoahGCMode=passive", concurrent);52shouldPassAll("-XX:ShenandoahGCMode=passive", iu);53}5455private static void shouldFailAll(String h, String[] barriers) throws Exception {56for (String b : barriers) {57ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(58"-Xmx128m",59"-XX:+UnlockDiagnosticVMOptions",60"-XX:+UnlockExperimentalVMOptions",61"-XX:+UseShenandoahGC",62h,63"-XX:+" + b,64"-version"65);66OutputAnalyzer output = new OutputAnalyzer(pb.start());67output.shouldNotHaveExitValue(0);68output.shouldContain("GC mode needs ");69output.shouldContain("to work correctly");70}71}7273private static void shouldPassAll(String h, String[] barriers) throws Exception {74for (String b : barriers) {75ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(76"-Xmx128m",77"-XX:+UnlockDiagnosticVMOptions",78"-XX:+UnlockExperimentalVMOptions",79"-XX:+UseShenandoahGC",80h,81"-XX:+" + b,82"-version"83);84OutputAnalyzer output = new OutputAnalyzer(pb.start());85output.shouldHaveExitValue(0);86}87}8889}909192