Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/gc/shenandoah/options/TestWrongBarrierEnable.java
32285 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* @key gc27* @library /testlibrary28* @run main/othervm TestWrongBarrierEnable29*/3031import java.util.*;3233import com.oracle.java.testlibrary.*;3435public class TestWrongBarrierEnable {3637public static void main(String[] args) throws Exception {38String[] concurrent = {39"ShenandoahStoreValEnqueueBarrier",40};41String[] iu = {42"ShenandoahSATBBarrier",43};4445shouldFailAll("-XX:ShenandoahGCHeuristics=adaptive", concurrent);46shouldFailAll("-XX:ShenandoahGCHeuristics=static", concurrent);47shouldFailAll("-XX:ShenandoahGCHeuristics=compact", concurrent);48shouldFailAll("-XX:ShenandoahGCHeuristics=aggressive", concurrent);49shouldFailAll("-XX:ShenandoahGCMode=iu", iu);50shouldPassAll("-XX:ShenandoahGCMode=passive", concurrent);51shouldPassAll("-XX:ShenandoahGCMode=passive", iu);52}5354private static void shouldFailAll(String h, String[] barriers) throws Exception {55for (String b : barriers) {56ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(57"-Xmx128m",58"-XX:+UnlockDiagnosticVMOptions",59"-XX:+UnlockExperimentalVMOptions",60"-XX:+UseShenandoahGC",61h,62"-XX:+" + b,63"-version"64);65OutputAnalyzer output = new OutputAnalyzer(pb.start());66output.shouldHaveExitValue(1);67output.shouldContain("GC mode needs ");68output.shouldContain("to work correctly");69}70}7172private static void shouldPassAll(String h, String[] barriers) throws Exception {73for (String b : barriers) {74ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(75"-Xmx128m",76"-XX:+UnlockDiagnosticVMOptions",77"-XX:+UnlockExperimentalVMOptions",78"-XX:+UseShenandoahGC",79h,80"-XX:+" + b,81"-version"82);83OutputAnalyzer output = new OutputAnalyzer(pb.start());84output.shouldHaveExitValue(0);85}86}8788}899091