Path: blob/master/test/hotspot/jtreg/gc/shenandoah/options/TestExplicitGC.java
41153 views
/*1* Copyright (c) 2017, 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/*25* @test TestExplicitGC26* @summary Test that Shenandoah reacts to explicit GC flags appropriately27* @requires vm.gc.Shenandoah28* @library /test/lib29* @modules java.base/jdk.internal.misc30* java.management31* @run driver TestExplicitGC32*/3334import jdk.test.lib.process.ProcessTools;35import jdk.test.lib.process.OutputAnalyzer;3637public class TestExplicitGC {3839enum Mode {40PRODUCT,41DIAGNOSTIC,42EXPERIMENTAL,43}4445public static void main(String[] args) throws Exception {46if (args.length > 0) {47System.out.println("Calling System.gc()");48System.gc();49return;50}5152String[] full = new String[] {53"Pause Full"54};5556String[] concNormal = new String[] {57"Pause Init Mark",58"Pause Final Mark",59};6061{62ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(63"-Xmx128m",64"-XX:+UnlockExperimentalVMOptions",65"-XX:+UseShenandoahGC",66"-Xlog:gc",67TestExplicitGC.class.getName(),68"test");69OutputAnalyzer output = new OutputAnalyzer(pb.start());70for (String p : full) {71output.shouldNotContain(p);72}73for (String p : concNormal) {74output.shouldContain(p);75}76}7778{79ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(80"-Xmx128m",81"-XX:+UnlockExperimentalVMOptions",82"-XX:+UseShenandoahGC",83"-Xlog:gc",84"-XX:+DisableExplicitGC",85TestExplicitGC.class.getName(),86"test");87OutputAnalyzer output = new OutputAnalyzer(pb.start());88for (String p : full) {89output.shouldNotContain(p);90}91for (String p : concNormal) {92output.shouldNotContain(p);93}94}9596{97ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(98"-Xmx128m",99"-XX:+UnlockExperimentalVMOptions",100"-XX:+UseShenandoahGC",101"-Xlog:gc",102"-XX:+ExplicitGCInvokesConcurrent",103TestExplicitGC.class.getName(),104"test");105OutputAnalyzer output = new OutputAnalyzer(pb.start());106for (String p : full) {107output.shouldNotContain(p);108}109for (String p : concNormal) {110output.shouldContain(p);111}112}113114{115ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(116"-Xmx128m",117"-XX:+UnlockExperimentalVMOptions",118"-XX:+UseShenandoahGC",119"-Xlog:gc",120"-XX:-ExplicitGCInvokesConcurrent",121TestExplicitGC.class.getName(),122"test");123OutputAnalyzer output = new OutputAnalyzer(pb.start());124for (String p : full) {125output.shouldContain(p);126}127for (String p : concNormal) {128output.shouldNotContain(p);129}130}131132{133ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(134"-Xmx128m",135"-XX:+UnlockExperimentalVMOptions",136"-XX:+UseShenandoahGC",137"-Xlog:gc",138"-XX:+ExplicitGCInvokesConcurrent",139"-XX:ShenandoahGCMode=iu",140TestExplicitGC.class.getName(),141"test");142OutputAnalyzer output = new OutputAnalyzer(pb.start());143for (String p : full) {144output.shouldNotContain(p);145}146for (String p : concNormal) {147output.shouldContain(p);148}149}150}151}152153154