Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/gc/shenandoah/options/TestModeUnlock.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/*25* @test TestModeUnlock26* @summary Test that Shenandoah modes are unlocked properly27* @key gc28* @library /testlibrary29* @run driver TestModeUnlock30*/3132import com.oracle.java.testlibrary.*;3334public class TestModeUnlock {3536enum Mode {37PRODUCT,38DIAGNOSTIC,39EXPERIMENTAL,40}4142public static void main(String[] args) throws Exception {43testWith("-XX:ShenandoahGCMode=satb", Mode.PRODUCT);44testWith("-XX:ShenandoahGCMode=iu", Mode.EXPERIMENTAL);45testWith("-XX:ShenandoahGCMode=passive", Mode.DIAGNOSTIC);46}4748private static void testWith(String h, Mode mode) throws Exception {49if (false) { // When ShenandoahGC is experimental flag, this makes no sense to test50ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(51"-Xmx128m",52"-XX:-UnlockDiagnosticVMOptions",53"-XX:-UnlockExperimentalVMOptions",54"-XX:+UseShenandoahGC",55h,56"-version"57);58OutputAnalyzer output = new OutputAnalyzer(pb.start());59switch (mode) {60case PRODUCT:61output.shouldHaveExitValue(0);62break;63case DIAGNOSTIC:64case EXPERIMENTAL:65output.shouldHaveExitValue(1);66break;67}68}6970if (false) { // When ShenandoahGC is experimental flag, this makes no sense to test71ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(72"-Xmx128m",73"-XX:+UnlockDiagnosticVMOptions",74"-XX:-UnlockExperimentalVMOptions",75"-XX:+UseShenandoahGC",76h,77"-version"78);79OutputAnalyzer output = new OutputAnalyzer(pb.start());80switch (mode) {81case PRODUCT:82case DIAGNOSTIC:83output.shouldHaveExitValue(0);84break;85case EXPERIMENTAL:86output.shouldHaveExitValue(1);87break;88}89}9091{92ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(93"-Xmx128m",94"-XX:-UnlockDiagnosticVMOptions",95"-XX:+UnlockExperimentalVMOptions",96"-XX:+UseShenandoahGC",97h,98"-version"99);100OutputAnalyzer output = new OutputAnalyzer(pb.start());101switch (mode) {102case PRODUCT:103case EXPERIMENTAL:104output.shouldHaveExitValue(0);105break;106case DIAGNOSTIC:107output.shouldHaveExitValue(1);108break;109}110}111}112113}114115116