Path: blob/master/test/hotspot/jtreg/gc/TestVerifySilently.java
40930 views
/*1* Copyright (c) 2014, 2020, Oracle and/or its affiliates. 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*/2223package gc;2425/* @test TestVerifySilently.java26* @bug 803277127* @summary Test silent verification.28* @requires vm.gc != "Z"29* @library /test/lib30* @modules java.base/jdk.internal.misc31* @run main gc.TestVerifySilently32*/3334import jdk.test.lib.process.ProcessTools;35import jdk.test.lib.process.OutputAnalyzer;36import java.util.ArrayList;37import java.util.Collections;38import jdk.test.lib.Utils;3940class TestVerifySilentlyRunSystemGC {41public static void main(String args[]) throws Exception {42System.gc();43}44}454647public class TestVerifySilently {4849private static OutputAnalyzer runTest(boolean verifySilently) throws Exception {50ArrayList<String> vmOpts = new ArrayList<>();5152Collections.addAll(vmOpts, Utils.getFilteredTestJavaOpts("-Xlog.*"));53Collections.addAll(vmOpts, new String[] {"-XX:+UnlockDiagnosticVMOptions",54"-XX:+VerifyDuringStartup",55"-XX:+VerifyBeforeGC",56"-XX:+VerifyAfterGC",57(verifySilently ? "-Xlog:gc":"-Xlog:gc+verify=debug"),58TestVerifySilentlyRunSystemGC.class.getName()});59ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(vmOpts);60OutputAnalyzer output = new OutputAnalyzer(pb.start());6162System.out.println("Output:\n" + output.getOutput());63return output;64}656667public static void main(String args[]) throws Exception {6869OutputAnalyzer output;7071output = runTest(false);72output.shouldContain("Verifying");73output.shouldHaveExitValue(0);7475output = runTest(true);76output.shouldNotContain("Verifying");77output.shouldHaveExitValue(0);78}79}808182