Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/gc/shenandoah/options/TestWrongBarrierDisable.java
32285 views
/*1* Copyright (c) 2018, Red Hat, Inc. All rights reserved.2*3* This code is free software; you can redistribute it and/or modify it4* under the terms of the GNU General Public License version 2 only, as5* published by the Free Software Foundation.6*7* This code is distributed in the hope that it will be useful, but WITHOUT8* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or9* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License10* version 2 for more details (a copy is included in the LICENSE file that11* accompanied this code).12*13* You should have received a copy of the GNU General Public License version14* 2 along with this work; if not, write to the Free Software Foundation,15* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.16*17* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA18* or visit www.oracle.com if you need additional information or have any19* questions.20*21*/2223/* @test TestWrongBarrierDisable24* @summary Test that disabling wrong barriers fails early25* @key gc26* @library /testlibrary27* @run main/othervm TestWrongBarrierDisable28*/2930import java.util.*;3132import com.oracle.java.testlibrary.*;3334public class TestWrongBarrierDisable {3536public static void main(String[] args) throws Exception {37String[] concurrent = {38"ShenandoahLoadRefBarrier",39"ShenandoahSATBBarrier",40"ShenandoahCASBarrier",41"ShenandoahCloneBarrier",42};43String[] iu = {44"ShenandoahLoadRefBarrier",45"ShenandoahStoreValEnqueueBarrier",46"ShenandoahCASBarrier",47"ShenandoahCloneBarrier",48};4950shouldFailAll("-XX:ShenandoahGCHeuristics=adaptive", concurrent);51shouldFailAll("-XX:ShenandoahGCHeuristics=static", concurrent);52shouldFailAll("-XX:ShenandoahGCHeuristics=compact", concurrent);53shouldFailAll("-XX:ShenandoahGCHeuristics=aggressive", concurrent);54shouldFailAll("-XX:ShenandoahGCMode=iu", iu);55shouldPassAll("-XX:ShenandoahGCMode=passive", concurrent);56shouldPassAll("-XX:ShenandoahGCMode=passive", iu);57}5859private static void shouldFailAll(String h, String[] barriers) throws Exception {60for (String b : barriers) {61ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(62"-Xmx128m",63"-XX:+UnlockDiagnosticVMOptions",64"-XX:+UnlockExperimentalVMOptions",65"-XX:+UseShenandoahGC",66h,67"-XX:-" + b,68"-version"69);70OutputAnalyzer output = new OutputAnalyzer(pb.start());71output.shouldHaveExitValue(1);72output.shouldContain("GC mode needs ");73output.shouldContain("to work correctly");74}75}7677private static void shouldPassAll(String h, String[] barriers) throws Exception {78for (String b : barriers) {79ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(80"-Xmx128m",81"-XX:+UnlockDiagnosticVMOptions",82"-XX:+UnlockExperimentalVMOptions",83"-XX:+UseShenandoahGC",84h,85"-XX:-" + b,86"-version"87);88OutputAnalyzer output = new OutputAnalyzer(pb.start());89output.shouldHaveExitValue(0);90}91}9293}949596