--- old/test/TEST.groups 2015-01-20 17:14:15.573397030 +0300 +++ new/test/TEST.groups 2015-01-20 17:14:15.473396454 +0300 @@ -233,7 +233,9 @@ gc/metaspace/G1AddMetaspaceDependency.java \ gc/metaspace/TestMetaspacePerfCounters.java \ gc/startup_warnings/TestG1.java \ - gc/whitebox/TestConcMarkCycleWB.java + gc/whitebox/TestConcMarkCycleWB.java \ + gc/logging/TestPrintAdaptiveSizePolicyG1GCDisabled.java \ + gc/logging/TestPrintAdaptiveSizePolicyG1GCEnabled.java # All tests that explicitly set the serial GC # --- /dev/null 2015-01-17 02:57:05.640001672 +0300 +++ new/test/gc/logging/AbstractPrintGCTest.java 2015-01-20 17:14:15.783398237 +0300 @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.io.IOException; +import java.nio.charset.Charset; +import java.nio.file.Files; +import java.nio.file.Paths; + +/** + * This is a base class for any tests which are intended to test -XX:Print* + * options by parsing GC log output. It encapsulates reading GC's log + * output from the log file and provides that output to the tests. + * + * NOTE: It assumes that the log filename is determined from the test's class + * name by removing leading 'Test' and adding '.txt' suffix. For instance, + * the test class TestWhatever corresponds to the log filename Whatever.txt. + * + */ +public abstract class AbstractPrintGCTest { + + private final String logFileName; + + /** + * Constructs a test object. Binds the test's name with the GC's log + * filename. + */ + public AbstractPrintGCTest() { + String className = getClass().getName(); + if (!className.startsWith("Test")) { + throw new IllegalStateException( + "The test's class name shall starts with 'Test'"); + } + logFileName = getClass().getName().substring("Test".length()) + + ".txt"; + } + + /** + * Retrieves content of GC's log file. + */ + public final String getContent() { + try { + return new String(Files.readAllBytes(Paths.get(logFileName)), + Charset.defaultCharset()); + } catch (IOException e) { + throw new RuntimeException( + "Failed to retrieve content from the log file: " + + logFileName, e); + } + } + + /** + * The test code goes here. + */ + public abstract void runTest(); +} --- /dev/null 2015-01-17 02:57:05.640001672 +0300 +++ new/test/gc/logging/GCTask.java 2015-01-20 17:14:16.073399906 +0300 @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * This is a helper class that forces the garbage collecting process. It + * attempts to consume all memory available to the young generation by + * creating a lot of unreferenced objects. Sooner or later the garbage + * collector shall be invoked. + * + * For purposes of performance the task is implemented to be ran with + * a small memory size less or equal to 128 megabytes. This shall be + * excplicitly specified with -Xmx JVM's option. In case if this option + * is not specified it's not guaranteed that GC will be invoked. + * + * The class is intended to be used with -Xloggc option to provide diagnostics + * output which can be parsed by the real tests. + * + * The class is implemented as an alternative to the explicit call to + * System.gc(). The second has some drawbacks and should be avoided. + */ +public class GCTask { + + public static final int BLOCK_SIZE = 16 * 1024; // 16 kilobytes + public static final int MAX_ITERATIONS = 8192; // 16K * 8K = 128M + public static byte[] garbage; + + @SuppressWarnings("unused") + public void run() { + // ensure there's an object that will survive garbage collecting + byte[] survivor = new byte[BLOCK_SIZE]; + + // if -Xmx has not been specified we assume that we're working within + // 128 megabytes of memory + long iterCount = Math.min(Runtime.getRuntime().maxMemory() / BLOCK_SIZE, + MAX_ITERATIONS); + while (iterCount-- > 1) { + // make an object that will be eligible for garbage collecting + garbage = new byte[BLOCK_SIZE]; + } + } + + public static void main(String[] args) { + new GCTask().run(); + } + +} --- /dev/null 2015-01-17 02:57:05.640001672 +0300 +++ new/test/gc/logging/TestPrintAdaptiveSizePolicyG1GCDisabled.java 2015-01-20 17:14:16.363401572 +0300 @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import com.oracle.java.testlibrary.OutputAnalyzer; + +/* + * @test TestPrintAdaptiveSizePolicyG1GCDisabled + * @summary test checks -XX:-PrintAdaptiveSizePolicy produce no output for G1 GC + * @key gc + * @library /testlibrary + * @requires vm.gc == "G1" + * @run main/othervm -Xmx128M -Xloggc:PrintAdaptiveSizePolicyG1GCDisabled.txt -XX:-PrintAdaptiveSizePolicy GCTask + * @run main TestPrintAdaptiveSizePolicyG1GCDisabled + */ +public class TestPrintAdaptiveSizePolicyG1GCDisabled extends AbstractPrintGCTest { + + public void runTest() { + OutputAnalyzer analyzer = new OutputAnalyzer(getContent()); + analyzer.shouldNotContain("Error"); + analyzer.shouldNotContain("G1Ergonomics"); + } + + public static void main(String[] args) { + new TestPrintAdaptiveSizePolicyG1GCDisabled().runTest(); + } +} --- /dev/null 2015-01-17 02:57:05.640001672 +0300 +++ new/test/gc/logging/TestPrintAdaptiveSizePolicyG1GCEnabled.java 2015-01-20 17:14:16.643403184 +0300 @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import com.oracle.java.testlibrary.OutputAnalyzer; + +/* + * @test TestPrintAdaptiveSizePolicyG1GCEnabled + * @summary test checks -XX:+PrintAdaptiveSizePolicy produces some output for G1 GC + * @key gc + * @library /testlibrary + * @requires vm.gc == "G1" + * @run main/othervm -Xmx128M -Xloggc:PrintAdaptiveSizePolicyG1GCEnabled.txt -XX:+PrintAdaptiveSizePolicy GCTask + * @run main TestPrintAdaptiveSizePolicyG1GCEnabled + */ +public class TestPrintAdaptiveSizePolicyG1GCEnabled extends AbstractPrintGCTest { + + public void runTest() { + OutputAnalyzer analyzer = new OutputAnalyzer(getContent()); + analyzer.shouldNotContain("Error"); + analyzer.shouldContain("G1Ergonomics"); + } + + public static void main(String[] args) { + new TestPrintAdaptiveSizePolicyG1GCEnabled().runTest(); + } +} --- /dev/null 2015-01-17 02:57:05.640001672 +0300 +++ new/test/gc/logging/TestPrintAdaptiveSizePolicyParallelGCDisabled.java 2015-01-20 17:14:16.923404792 +0300 @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import com.oracle.java.testlibrary.OutputAnalyzer; + +/* + * @test TestPrintAdaptiveSizePolicyParallelGCDisabled + * @summary test checks -XX:-PrintAdaptiveSizePolicy produce no output for Parallel GC + * @key gc + * @library /testlibrary + * @requires vm.gc == "Parallel" + * @run main/othervm -Xmx128M -Xloggc:PrintAdaptiveSizePolicyParallelGCDisabled.txt -XX:-PrintAdaptiveSizePolicy GCTask + * @run main TestPrintAdaptiveSizePolicyParallelGCDisabled + */ +public class TestPrintAdaptiveSizePolicyParallelGCDisabled extends AbstractPrintGCTest { + + public void runTest() { + OutputAnalyzer analyzer = new OutputAnalyzer(getContent()); + analyzer.shouldNotContain("Error"); + analyzer.shouldNotContain("AdaptiveSizePolicy:"); + analyzer.shouldNotContain("AdaptiveSizeStart:"); + analyzer.shouldNotContain("AdaptiveSizeStop:"); + } + + public static void main(String[] args) { + new TestPrintAdaptiveSizePolicyParallelGCDisabled().runTest(); + } +} --- /dev/null 2015-01-17 02:57:05.640001672 +0300 +++ new/test/gc/logging/TestPrintAdaptiveSizePolicyParallelGCEnabled.java 2015-01-20 17:14:17.203406403 +0300 @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import com.oracle.java.testlibrary.OutputAnalyzer; + +/* + * @test TestPrintAdaptiveSizePolicyParallelGCEnabled + * @summary test checks -XX:+PrintAdaptiveSizePolicy produces some output for Parallel GC + * @key gc + * @library /testlibrary + * @requires vm.gc == "Parallel" + * @run main/othervm -Xmx128M -Xloggc:PrintAdaptiveSizePolicyParallelGCEnabled.txt -XX:+PrintAdaptiveSizePolicy GCTask + * @run main TestPrintAdaptiveSizePolicyParallelGCEnabled + */ +public class TestPrintAdaptiveSizePolicyParallelGCEnabled extends AbstractPrintGCTest { + + public void runTest() { + OutputAnalyzer analyzer = new OutputAnalyzer(getContent()); + analyzer.shouldNotContain("Error"); + analyzer.shouldContain("AdaptiveSizePolicy:"); + analyzer.shouldContain("AdaptiveSizeStart:"); + analyzer.shouldContain("AdaptiveSizeStop:"); + } + + public static void main(String[] args) { + new TestPrintAdaptiveSizePolicyParallelGCEnabled().runTest(); + } +} --- /dev/null 2015-01-17 02:57:05.640001672 +0300 +++ new/test/gc/logging/TestPrintGCApplicationConcurrentTimeDisabled.java 2015-01-20 17:14:17.493408071 +0300 @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import com.oracle.java.testlibrary.OutputAnalyzer; + +/* + * @test TestPrintGCApplicationConcurrentTimeDisabled + * @summary tests checks -XX:-PrintGCApplicationConcurrentTime produce no output + * @key gc + * @library /testlibrary + * @run main/othervm -Xmx128M -Xloggc:PrintGCApplicationConcurrentTimeDisabled.txt -XX:-PrintGCApplicationConcurrentTime GCTask + * @run main TestPrintGCApplicationConcurrentTimeDisabled + */ +public class TestPrintGCApplicationConcurrentTimeDisabled extends AbstractPrintGCTest { + + public void runTest() { + OutputAnalyzer analyzer = new OutputAnalyzer(getContent()); + analyzer.shouldNotContain("Error"); + analyzer.shouldNotContain("Application time:"); + } + + public static void main(String[] args) { + new TestPrintGCApplicationConcurrentTimeDisabled().runTest(); + } +} --- /dev/null 2015-01-17 02:57:05.640001672 +0300 +++ new/test/gc/logging/TestPrintGCApplicationConcurrentTimeEnabled.java 2015-01-20 17:14:17.773409680 +0300 @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import com.oracle.java.testlibrary.OutputAnalyzer; + +/* + * @test TestPrintGCApplicationConcurrentTimeEnabled + * @summary tests checks -XX:+PrintGCApplicationConcurrentTime prints an application's concurrent time + * @key gc + * @library /testlibrary + * @run main/othervm -Xmx128M -Xloggc:PrintGCApplicationConcurrentTimeEnabled.txt -XX:+PrintGCApplicationConcurrentTime GCTask + * @run main TestPrintGCApplicationConcurrentTimeEnabled + */ +public class TestPrintGCApplicationConcurrentTimeEnabled extends AbstractPrintGCTest { + + public void runTest() { + OutputAnalyzer analyzer = new OutputAnalyzer(getContent()); + analyzer.shouldNotContain("Error"); + analyzer.shouldContain("Application time:"); + } + + public static void main(String[] args) { + new TestPrintGCApplicationConcurrentTimeEnabled().runTest(); + } +} --- /dev/null 2015-01-17 02:57:05.640001672 +0300 +++ new/test/gc/logging/TestPrintGCApplicationStoppedTimeDisabled.java 2015-01-20 17:14:18.053411290 +0300 @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import com.oracle.java.testlibrary.OutputAnalyzer; + +/* + * @test TestPrintGCApplicationStoppedTimeDisabled + * @summary tests checks -XX:-PrintGCApplicationStoppedTime produce no output + * @key gc + * @library /testlibrary + * @run main/othervm -Xmx128M -Xloggc:PrintGCApplicationStoppedTimeDisabled.txt -XX:-PrintGCApplicationStoppedTime GCTask + * @run main TestPrintGCApplicationStoppedTimeDisabled + */ +public class TestPrintGCApplicationStoppedTimeDisabled extends AbstractPrintGCTest { + + public void runTest() { + OutputAnalyzer analyzer = new OutputAnalyzer(getContent()); + analyzer.shouldNotContain("Error"); + analyzer.shouldNotMatch("stopped: \\d+\\.\\d+\\s+seconds"); + } + + public static void main(String[] args) { + new TestPrintGCApplicationStoppedTimeDisabled().runTest(); + } +} --- /dev/null 2015-01-17 02:57:05.640001672 +0300 +++ new/test/gc/logging/TestPrintGCApplicationStoppedTimeEnabled.java 2015-01-20 17:14:18.333412901 +0300 @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import com.oracle.java.testlibrary.OutputAnalyzer; + +/* + * @test TestPrintGCApplicationStoppedTimeEnabled + * @summary tests checks -XX:+PrintGCApplicationStoppedTime prints application's stopped time + * @key gc + * @library /testlibrary + * @run main/othervm -Xmx128M -Xloggc:PrintGCApplicationStoppedTimeEnabled.txt -XX:+PrintGCApplicationStoppedTime GCTask + * @run main TestPrintGCApplicationStoppedTimeEnabled + */ +public class TestPrintGCApplicationStoppedTimeEnabled extends AbstractPrintGCTest { + + public void runTest() { + OutputAnalyzer analyzer = new OutputAnalyzer(getContent()); + analyzer.shouldNotContain("Error"); + analyzer.shouldMatch("stopped: \\d+\\.\\d+\\s+seconds"); + } + + public static void main(String[] args) { + new TestPrintGCApplicationStoppedTimeEnabled().runTest(); + } +} --- /dev/null 2015-01-17 02:57:05.640001672 +0300 +++ new/test/gc/logging/TestPrintGCDateStampsDisabled.java 2015-01-20 17:14:18.623414568 +0300 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import com.oracle.java.testlibrary.OutputAnalyzer; + +/* + * @test TestPrintGCDateStampsDisabled + * @summary test checks -XX:-PrintGCDateStamps suppresses date stamps printing + * @key gc + * @library /testlibrary + * @run main/othervm -Xmx128M -Xloggc:PrintGCDateStampsDisabled.txt -XX:+PrintGC -XX:-PrintGCTimeStamps -XX:-PrintGCDateStamps GCTask + * @run main TestPrintGCDateStampsDisabled + */ +public class TestPrintGCDateStampsDisabled extends AbstractPrintGCTest { + + public void runTest() { + OutputAnalyzer analyzer = new OutputAnalyzer(getContent()); + analyzer.shouldNotMatch("^\\d+"); + } + + public static void main(String[] args) { + new TestPrintGCDateStampsDisabled().runTest(); + } +} --- /dev/null 2015-01-17 02:57:05.640001672 +0300 +++ new/test/gc/logging/TestPrintGCDateStampsEnabled.java 2015-01-20 17:14:18.903416178 +0300 @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import com.oracle.java.testlibrary.Asserts; + +/* + * @test TestPrintGCDateStampsEnabled + * @summary test checks -XX:+PrintGCDateStamps enables date stamps printing + * @key gc + * @library /testlibrary + * @run main/othervm -Xmx128M -Xloggc:PrintGCDateStampsEnabled.txt -XX:+PrintGC -XX:+PrintGCDateStamps GCTask + * @run main TestPrintGCDateStampsEnabled + */ +public class TestPrintGCDateStampsEnabled extends AbstractPrintGCTest { + + public void runTest() { + String content = getContent(); + // match an every line containing '[GC' and capture everything before the first + // colon followed by space + Pattern pattern = Pattern.compile("^(.+?): +?.*\\[GC", Pattern.MULTILINE); + Matcher matcher = pattern.matcher(content); + LocalDate gcLastDateStamp = LocalDate.MIN; + while (matcher.find()) { + String match = matcher.group(1); + try { + LocalDate dateStamp = LocalDate.parse( + match, DateTimeFormatter.ofPattern( + "yyyy-MM-dd'T'HH:mm:ss.SSSxxxx")); + Asserts.assertGreaterThanOrEqual(dateStamp, gcLastDateStamp, + "GC datestamps are inconsistent"); + } catch (DateTimeParseException e) { + Asserts.assertFalse(true, "The text '" + match + "' is not a valid GC's DateStamp"); + } + } + } + + public static void main(String[] args) { + new TestPrintGCDateStampsEnabled().runTest(); + } +} --- /dev/null 2015-01-17 02:57:05.640001672 +0300 +++ new/test/gc/logging/TestPrintGCDetailsDisabled.java 2015-01-20 17:14:19.183417788 +0300 @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import com.oracle.java.testlibrary.OutputAnalyzer; + +/* + * @test TestPrintGCDetailsDisabled + * @summary test checks -XX:-PrintGCDetails produce no output + * @key gc + * @library /testlibrary + * @run main/othervm -Xmx128M -Xloggc:PrintGCDetailsDisabled.txt -XX:+PrintGC -XX:-PrintGCDetails GCTask + * @run main TestPrintGCDetailsDisabled + */ +public class TestPrintGCDetailsDisabled extends AbstractPrintGCTest { + + public void runTest() { + OutputAnalyzer analyzer = new OutputAnalyzer(getContent()); + analyzer.shouldNotContain("Error"); + analyzer.shouldNotMatch("\\bHeap\\b"); + analyzer.shouldNotMatch("\\bMetaspace\\b"); + } + + public static void main(String[] args) { + new TestPrintGCDetailsDisabled().runTest(); + } +} --- /dev/null 2015-01-17 02:57:05.640001672 +0300 +++ new/test/gc/logging/TestPrintGCDetailsEnabled.java 2015-01-20 17:14:19.463419398 +0300 @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import com.oracle.java.testlibrary.OutputAnalyzer; + +/* + * @test TestPrintGCDetailsEnabled + * @summary test checks -XX:+PrintGCDetails prints GC details + * @key gc + * @library /testlibrary + * @run main/othervm -Xmx128M -Xloggc:PrintGCDetailsEnabled.txt -XX:+PrintGC -XX:+PrintGCDetails GCTask + * @run main TestPrintGCDetailsEnabled + */ +public class TestPrintGCDetailsEnabled extends AbstractPrintGCTest { + + public void runTest() { + OutputAnalyzer analyzer = new OutputAnalyzer(getContent()); + analyzer.shouldNotContain("Error"); + analyzer.shouldMatch("\\bHeap\\b"); + analyzer.shouldMatch("\\bMetaspace\\b"); + } + + public static void main(String[] args) { + new TestPrintGCDetailsEnabled().runTest(); + } +} --- /dev/null 2015-01-17 02:57:05.640001672 +0300 +++ new/test/gc/logging/TestPrintGCDisabled.java 2015-01-20 17:14:19.743421009 +0300 @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import com.oracle.java.testlibrary.OutputAnalyzer; + +/* + * @test TestPrintGCDisabled + * @summary test checks -XX:-PrintGC supresses an output from GC + * @key gc + * @library /testlibrary + * @run main/othervm -Xmx128M -Xloggc:PrintGCDisabled.txt -XX:-PrintGC GCTask + * @run main TestPrintGCDisabled + */ +public class TestPrintGCDisabled extends AbstractPrintGCTest { + + public void runTest() { + OutputAnalyzer analyzer = new OutputAnalyzer(getContent()); + analyzer.shouldNotContain("Error"); + analyzer.shouldNotMatch("\\[Full GC|\\[GC"); + } + + public static void main(String[] args) { + new TestPrintGCDisabled().runTest(); + } +} --- /dev/null 2015-01-17 02:57:05.640001672 +0300 +++ new/test/gc/logging/TestPrintGCEnabled.java 2015-01-20 17:14:20.023422619 +0300 @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import com.oracle.java.testlibrary.OutputAnalyzer; + +/* + * @test TestPrintGCEnabled + * @summary test checks -XX:+PrintGC enables an output from GC + * @key gc + * @library /testlibrary + * @run main/othervm -Xmx128M -Xloggc:PrintGCEnabled.txt -XX:+PrintGC GCTask + * @run main TestPrintGCEnabled + */ +public class TestPrintGCEnabled extends AbstractPrintGCTest { + + public void runTest() { + OutputAnalyzer analyzer = new OutputAnalyzer(getContent()); + analyzer.shouldNotContain("Error"); + analyzer.shouldMatch("\\[Full GC|\\[GC"); + } + + public static void main(String[] args) { + new TestPrintGCEnabled().runTest(); + } +} --- /dev/null 2015-01-17 02:57:05.640001672 +0300 +++ new/test/gc/logging/TestPrintGCTimeStampsDisabled.java 2015-01-20 17:14:20.313424285 +0300 @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import com.oracle.java.testlibrary.OutputAnalyzer; + +/* + * @test TestPrintGCTimeStampsDisabled + * @summary test checks -XX:-PrintGCTimeStamps suppresses time stamps printing + * @key gc + * @library /testlibrary + * @run main/othervm -Xmx128M -Xloggc:PrintGCTimeStampsDisabled.txt -XX:+PrintGC -XX:-PrintGCTimeStamps GCTask + * @run main TestPrintGCTimeStampsDisabled + */ +public class TestPrintGCTimeStampsDisabled extends AbstractPrintGCTest { + + public void runTest() { + OutputAnalyzer analyzer = new OutputAnalyzer(getContent()); + analyzer.shouldNotContain("Error"); + analyzer.shouldNotMatch("^\\d+"); + } + + public static void main(String[] args) { + new TestPrintGCTimeStampsDisabled().runTest(); + } +} --- /dev/null 2015-01-17 02:57:05.640001672 +0300 +++ new/test/gc/logging/TestPrintGCTimeStampsEnabled.java 2015-01-20 17:14:20.593425896 +0300 @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import com.oracle.java.testlibrary.Asserts; + +/* + * @test TestPrintGCTimeStampsEnabled + * @summary test checks -XX:+PrintGCDateStamps enables date stamps printing + * @key gc + * @library /testlibrary + * @run main/othervm -Xmx128M -Xloggc:PrintGCTimeStampsEnabled.txt -XX:+PrintGC -XX:+PrintGCTimeStamps GCTask + * @run main TestPrintGCTimeStampsEnabled + */ +public class TestPrintGCTimeStampsEnabled extends AbstractPrintGCTest { + + public void runTest() { + String content = getContent(); + Pattern pattern = Pattern.compile("^(\\d+\\.\\d+):.*\\[GC", Pattern.MULTILINE); + Matcher matcher = pattern.matcher(content); + float gcLastRunTimestamp = 0.0f; + while (matcher.find()) { + String match = matcher.group(1); + float timestamp = Float.parseFloat(match); + Asserts.assertGreaterThanOrEqual(timestamp, gcLastRunTimestamp, + "GC timestamps are inconsistent"); + gcLastRunTimestamp = timestamp; + } + } + + public static void main(String[] args) { + new TestPrintGCTimeStampsEnabled().runTest(); + } +} --- /dev/null 2015-01-17 02:57:05.640001672 +0300 +++ new/test/gc/logging/TestPrintTenuringDistributionDisabled.java 2015-01-20 17:14:20.873427505 +0300 @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import com.oracle.java.testlibrary.OutputAnalyzer; + +/* + * @test TestPrintTenuringDistributionDisabled + * @summary test checks -XX:-PrintTenuringDistribution produces no output + * @key gc + * @library /testlibrary + * @run main/othervm -Xmx128M -Xloggc:PrintTenuringDistributionDisabled.txt -XX:-PrintTenuringDistribution GCTask + * @run main TestPrintTenuringDistributionDisabled + */ +public class TestPrintTenuringDistributionDisabled extends AbstractPrintGCTest { + + public void runTest() { + OutputAnalyzer analyzer = new OutputAnalyzer(getContent()); + analyzer.shouldNotContain("Error"); + analyzer.shouldNotContain("Desired survivor size"); + } + + public static void main(String[] args) { + new TestPrintTenuringDistributionDisabled().runTest(); + } +} --- /dev/null 2015-01-17 02:57:05.640001672 +0300 +++ new/test/gc/logging/TestPrintTenuringDistributionEnabled.java 2015-01-20 17:14:21.153429116 +0300 @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import com.oracle.java.testlibrary.OutputAnalyzer; + +/* + * @test TestPrintTenuringDistributionEnabled + * @summary test checks -XX:+PrintTenuringDistribution prints tenuring information + * @key gc + * @library /testlibrary + * @run main/othervm -Xmx128M -Xloggc:PrintTenuringDistributionEnabled.txt -XX:+PrintTenuringDistribution GCTask + * @run main TestPrintTenuringDistributionEnabled + */ +public class TestPrintTenuringDistributionEnabled extends AbstractPrintGCTest { + + public void runTest() { + OutputAnalyzer analyzer = new OutputAnalyzer(getContent()); + analyzer.shouldNotContain("Error"); + analyzer.shouldContain("Desired survivor size"); + } + + public static void main(String[] args) { + new TestPrintTenuringDistributionEnabled().runTest(); + } +}