Path: blob/master/test/hotspot/jtreg/gc/shenandoah/options/TestWrongBarrierDisable.java
41153 views
/*1* Copyright (c) 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/* @test TestWrongBarrierDisable25* @summary Test that disabling wrong barriers fails early26* @requires vm.gc.Shenandoah27* @library /test/lib28* @run driver TestWrongBarrierDisable29*/3031import java.util.*;3233import jdk.test.lib.process.ProcessTools;34import jdk.test.lib.process.OutputAnalyzer;3536public class TestWrongBarrierDisable {3738public static void main(String[] args) throws Exception {39String[] concurrent = {40"ShenandoahLoadRefBarrier",41"ShenandoahSATBBarrier",42"ShenandoahCASBarrier",43"ShenandoahCloneBarrier",44"ShenandoahNMethodBarrier",45"ShenandoahStackWatermarkBarrier",46};47String[] iu = {48"ShenandoahLoadRefBarrier",49"ShenandoahIUBarrier",50"ShenandoahCASBarrier",51"ShenandoahCloneBarrier",52"ShenandoahNMethodBarrier",53"ShenandoahStackWatermarkBarrier",54};5556shouldFailAll("-XX:ShenandoahGCHeuristics=adaptive", concurrent);57shouldFailAll("-XX:ShenandoahGCHeuristics=static", concurrent);58shouldFailAll("-XX:ShenandoahGCHeuristics=compact", concurrent);59shouldFailAll("-XX:ShenandoahGCHeuristics=aggressive", concurrent);60shouldFailAll("-XX:ShenandoahGCMode=iu", iu);61shouldPassAll("-XX:ShenandoahGCMode=passive", concurrent);62shouldPassAll("-XX:ShenandoahGCMode=passive", iu);63}6465private static void shouldFailAll(String h, String[] barriers) throws Exception {66for (String b : barriers) {67ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(68"-Xmx128m",69"-XX:+UnlockDiagnosticVMOptions",70"-XX:+UnlockExperimentalVMOptions",71"-XX:+UseShenandoahGC",72h,73"-XX:-" + b,74"-version"75);76OutputAnalyzer output = new OutputAnalyzer(pb.start());77output.shouldNotHaveExitValue(0);78output.shouldContain("GC mode needs ");79output.shouldContain("to work correctly");80}81}8283private static void shouldPassAll(String h, String[] barriers) throws Exception {84for (String b : barriers) {85ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(86"-Xmx128m",87"-XX:+UnlockDiagnosticVMOptions",88"-XX:+UnlockExperimentalVMOptions",89"-XX:+UseShenandoahGC",90h,91"-XX:-" + b,92"-version"93);94OutputAnalyzer output = new OutputAnalyzer(pb.start());95output.shouldHaveExitValue(0);96}97}9899}100101102