Path: blob/master/test/hotspot/jtreg/gc/shenandoah/options/TestModeUnlock.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/*25* @test TestModeUnlock26* @summary Test that Shenandoah modes are unlocked properly27* @requires vm.gc.Shenandoah28* @library /test/lib29* @modules java.base/jdk.internal.misc30* java.management31* @run driver TestModeUnlock32*/3334import jdk.test.lib.process.ProcessTools;35import jdk.test.lib.process.OutputAnalyzer;3637public class TestModeUnlock {3839enum Mode {40PRODUCT,41DIAGNOSTIC,42EXPERIMENTAL,43}4445public static void main(String[] args) throws Exception {46testWith("-XX:ShenandoahGCMode=satb", Mode.PRODUCT);47testWith("-XX:ShenandoahGCMode=iu", Mode.EXPERIMENTAL);48testWith("-XX:ShenandoahGCMode=passive", Mode.DIAGNOSTIC);49}5051private static void testWith(String h, Mode mode) throws Exception {52{53ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(54"-Xmx128m",55"-XX:-UnlockDiagnosticVMOptions",56"-XX:-UnlockExperimentalVMOptions",57"-XX:+UseShenandoahGC",58h,59"-version"60);61OutputAnalyzer output = new OutputAnalyzer(pb.start());62switch (mode) {63case PRODUCT:64output.shouldHaveExitValue(0);65break;66case DIAGNOSTIC:67case EXPERIMENTAL:68output.shouldNotHaveExitValue(0);69break;70}71}7273{74ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(75"-Xmx128m",76"-XX:+UnlockDiagnosticVMOptions",77"-XX:-UnlockExperimentalVMOptions",78"-XX:+UseShenandoahGC",79h,80"-version"81);82OutputAnalyzer output = new OutputAnalyzer(pb.start());83switch (mode) {84case PRODUCT:85case DIAGNOSTIC:86output.shouldHaveExitValue(0);87break;88case EXPERIMENTAL:89output.shouldNotHaveExitValue(0);90break;91}92}9394{95ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(96"-Xmx128m",97"-XX:-UnlockDiagnosticVMOptions",98"-XX:+UnlockExperimentalVMOptions",99"-XX:+UseShenandoahGC",100h,101"-version"102);103OutputAnalyzer output = new OutputAnalyzer(pb.start());104switch (mode) {105case PRODUCT:106case EXPERIMENTAL:107output.shouldHaveExitValue(0);108break;109case DIAGNOSTIC:110output.shouldNotHaveExitValue(0);111break;112}113}114}115116}117118119