aoqi@0: /* aoqi@0: * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: */ aoqi@0: aoqi@0: /* aoqi@0: * @test TestSummarizeRSetStatsThreads aoqi@0: * @bug 8025441 aoqi@0: * @summary Ensure that various values of worker threads/concurrent aoqi@0: * refinement threads do not crash the VM. aoqi@0: * @key gc aoqi@0: * @library /testlibrary aoqi@0: */ aoqi@0: aoqi@0: import java.util.regex.Matcher; aoqi@0: import java.util.regex.Pattern; aoqi@0: aoqi@0: import com.oracle.java.testlibrary.ProcessTools; aoqi@0: import com.oracle.java.testlibrary.OutputAnalyzer; aoqi@0: aoqi@0: public class TestSummarizeRSetStatsThreads { aoqi@0: aoqi@0: private static void runTest(int refinementThreads, int workerThreads) throws Exception { aoqi@0: ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC", aoqi@0: "-XX:+UnlockDiagnosticVMOptions", aoqi@0: "-XX:+G1SummarizeRSetStats", aoqi@0: "-XX:G1ConcRefinementThreads=" + refinementThreads, aoqi@0: "-XX:ParallelGCThreads=" + workerThreads, aoqi@0: "-version"); aoqi@0: aoqi@0: OutputAnalyzer output = new OutputAnalyzer(pb.start()); aoqi@0: aoqi@0: // check output to contain the string "Concurrent RS threads times (s)" followed by aoqi@0: // the correct number of values in the next line. aoqi@0: aoqi@0: // a zero in refinement thread numbers indicates that the value in ParallelGCThreads should be used. aoqi@0: // Additionally use at least one thread. aoqi@0: int expectedNumRefinementThreads = refinementThreads == 0 ? workerThreads : refinementThreads; aoqi@0: expectedNumRefinementThreads = Math.max(1, expectedNumRefinementThreads); aoqi@0: // create the pattern made up of n copies of a floating point number pattern aoqi@0: String numberPattern = String.format("%0" + expectedNumRefinementThreads + "d", 0) aoqi@0: .replace("0", "\\s+\\d+\\.\\d+"); aoqi@0: String pattern = "Concurrent RS threads times \\(s\\)$" + numberPattern + "$"; aoqi@0: Matcher m = Pattern.compile(pattern, Pattern.MULTILINE).matcher(output.getStdout()); aoqi@0: aoqi@0: if (!m.find()) { aoqi@0: throw new Exception("Could not find correct output for concurrent RS threads times in stdout," + aoqi@0: " should match the pattern \"" + pattern + "\", but stdout is \n" + output.getStdout()); aoqi@0: } aoqi@0: output.shouldHaveExitValue(0); aoqi@0: } aoqi@0: aoqi@0: public static void main(String[] args) throws Exception { aoqi@0: if (!TestSummarizeRSetStatsTools.testingG1GC()) { aoqi@0: return; aoqi@0: } aoqi@0: // different valid combinations of number of refinement and gc worker threads aoqi@0: runTest(0, 0); aoqi@0: runTest(0, 5); aoqi@0: runTest(5, 0); aoqi@0: runTest(10, 10); aoqi@0: runTest(1, 2); aoqi@0: runTest(4, 3); aoqi@0: } aoqi@0: }