hotspot/test/gc/logging/TestDeprecatedPrintFlags.java
author erikj
Thu, 14 Apr 2016 15:13:42 +0200
changeset 37299 db3b0d4c3bda
parent 36851 03e2f4d0a421
child 40631 ed82623d7831
permissions -rw-r--r--
8149777: Enable enhanced failure handler for "make test" Reviewed-by: ihse
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35872
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
     1
/*
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
     4
 *
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
     7
 * published by the Free Software Foundation.
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
     8
 *
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    13
 * accompanied this code).
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    14
 *
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    18
 *
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    21
 * questions.
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    22
 */
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    23
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    24
/*
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    25
 * @test TestDeprecatedPrintFlags
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    26
 * @bug 8145180
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    27
 * @summary Verify PrintGC, PrintGCDetails and -Xloggc
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    28
 * @key gc
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    29
 * @library /testlibrary
36851
03e2f4d0a421 8153737: Unsupported Module
chegar
parents: 35908
diff changeset
    30
 * @modules java.base/jdk.internal.misc
35872
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    31
 *          java.management
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    32
 */
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    33
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    34
import jdk.test.lib.*;
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    35
import java.io.File;
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    36
import java.nio.file.Files;
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    37
import java.nio.file.Paths;
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    38
import java.util.List;
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    39
import java.util.stream.Collectors;
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    40
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    41
public class TestDeprecatedPrintFlags {
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    42
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    43
    public static void testPrintGC() throws Exception {
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    44
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+PrintGC", "DoGC");
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    45
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    46
        output.shouldContain("-XX:+PrintGC is deprecated. Will use -Xlog:gc instead.");
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    47
        output.shouldNotContain("PrintGCDetails");
35908
cb12f847b199 8148733: G1: Add log message to print the heap region size
brutisso
parents: 35872
diff changeset
    48
        output.stdoutShouldMatch("\\[info.*\\]\\[gc *\\]");
35872
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    49
        output.stdoutShouldNotMatch("\\[info.*\\]\\[gc\\,");
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    50
        output.shouldHaveExitValue(0);
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    51
    }
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    52
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    53
    public static void testPrintGCDetails() throws Exception {
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    54
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+PrintGCDetails", "DoGC");
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    55
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    56
        output.shouldContain("-XX:+PrintGCDetails is deprecated. Will use -Xlog:gc* instead.");
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    57
        output.shouldNotContain("PrintGC is deprecated");
35908
cb12f847b199 8148733: G1: Add log message to print the heap region size
brutisso
parents: 35872
diff changeset
    58
        output.stdoutShouldMatch("\\[info.*\\]\\[gc *\\]");
35872
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    59
        output.stdoutShouldMatch("\\[info.*\\]\\[gc\\,");
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    60
        output.shouldHaveExitValue(0);
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    61
    }
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    62
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    63
    public static void testXloggc() throws Exception {
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    64
        String fileName = "gc-test.log";
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    65
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xloggc:" + fileName, "DoGC");
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    66
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    67
        output.shouldContain("-Xloggc is deprecated. Will use -Xlog:gc:gc-test.log instead.");
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    68
        output.shouldNotContain("PrintGCDetails");
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    69
        output.shouldNotContain("PrintGC");
35908
cb12f847b199 8148733: G1: Add log message to print the heap region size
brutisso
parents: 35872
diff changeset
    70
        output.stdoutShouldNotMatch("\\[info.*\\]\\[gc *\\]");
35872
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    71
        output.stdoutShouldNotMatch("\\[info.*\\]\\[gc\\,");
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    72
        output.shouldHaveExitValue(0);
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    73
        String lines = Files.lines(Paths.get(fileName)).collect(Collectors.joining());
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    74
        System.out.println("lines: " + lines);
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    75
        OutputAnalyzer outputLog = new OutputAnalyzer(lines, "");
35908
cb12f847b199 8148733: G1: Add log message to print the heap region size
brutisso
parents: 35872
diff changeset
    76
        outputLog.stdoutShouldMatch("\\[info.*\\]\\[gc *\\]");
35872
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    77
        outputLog.stdoutShouldNotMatch("\\[info.*\\]\\[gc\\,");
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    78
    }
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    79
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    80
    public static void testXloggcWithPrintGCDetails() throws Exception {
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    81
        String fileName = "gc-test.log";
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    82
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+PrintGCDetails", "-Xloggc:" + fileName, "DoGC");
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    83
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    84
        output.shouldContain("-XX:+PrintGCDetails is deprecated. Will use -Xlog:gc* instead.");
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    85
        output.shouldContain("-Xloggc is deprecated. Will use -Xlog:gc:gc-test.log instead.");
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    86
        output.shouldNotContain("PrintGC is deprecated");
35908
cb12f847b199 8148733: G1: Add log message to print the heap region size
brutisso
parents: 35872
diff changeset
    87
        output.stdoutShouldNotMatch("\\[info.*\\]\\[gc *\\]");
35872
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    88
        output.stdoutShouldNotMatch("\\[info.*\\]\\[gc\\,");
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    89
        output.shouldHaveExitValue(0);
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    90
        String lines = Files.lines(Paths.get(fileName)).collect(Collectors.joining());
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    91
        OutputAnalyzer outputLog = new OutputAnalyzer(lines, "");
35908
cb12f847b199 8148733: G1: Add log message to print the heap region size
brutisso
parents: 35872
diff changeset
    92
        outputLog.stdoutShouldMatch("\\[info.*\\]\\[gc *\\]");
35872
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    93
        outputLog.stdoutShouldMatch("\\[info.*\\]\\[gc\\,");
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    94
    }
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    95
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    96
    public static void main(String[] args) throws Exception {
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    97
        testPrintGC();
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    98
        testPrintGCDetails();
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
    99
        testXloggc();
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
   100
        testXloggcWithPrintGCDetails();
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
   101
    }
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
   102
}
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
   103
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
   104
class DoGC {
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
   105
    public static void main(String[] args) {
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
   106
        System.gc();
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
   107
    }
7fb1e4de83ff 8145180: Add back PrintGC, PrintGCDetails and -Xloggc
brutisso
parents:
diff changeset
   108
}