hotspot/test/gc/serial/HeapChangeLogging.java
author jprovino
Wed, 11 Nov 2015 23:47:42 +0000
changeset 33911 af2cff5bd523
parent 30764 fec48bf5a827
child 35061 be6025ebffea
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22204
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
     1
/*
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 27692
diff changeset
     2
 * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
22204
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
     4
 *
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
     7
 * published by the Free Software Foundation.
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
     8
 *
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    13
 * accompanied this code).
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    14
 *
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    18
 *
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    21
 * questions.
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    22
 */
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    23
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    24
/*
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    25
 * @test HeapChangeLogging.java
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    26
 * @bug 8027440
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    27
 * @library /testlibrary
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 27692
diff changeset
    28
 * @modules java.base/sun.misc
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 27692
diff changeset
    29
 *          java.management
22204
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    30
 * @build HeapChangeLogging
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    31
 * @summary Allocate to get a promotion failure and verify that that heap change logging is present.
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    32
 * @run main HeapChangeLogging
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    33
 */
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    34
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    35
import java.util.regex.Matcher;
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    36
import java.util.regex.Pattern;
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    37
30604
b8d532cb6420 8067013: Rename the com.oracle.java.testlibary package
ykantser
parents: 29678
diff changeset
    38
import jdk.test.lib.*;
22204
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    39
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    40
public class HeapChangeLogging {
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    41
  public static void main(String[] args) throws Exception {
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    42
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xmx128m", "-Xmn100m", "-XX:+UseSerialGC", "-XX:+PrintGC", "HeapFiller");
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    43
    OutputAnalyzer output = new OutputAnalyzer(pb.start());
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    44
    String stdout = output.getStdout();
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    45
    System.out.println(stdout);
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    46
    Matcher stdoutMatcher = Pattern.compile("\\[GC .Allocation Failure.*K->.*K\\(.*K\\), .* secs\\]", Pattern.MULTILINE).matcher(stdout);
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    47
    if (!stdoutMatcher.find()) {
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    48
      throw new RuntimeException("No proper GC log line found");
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    49
    }
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    50
    output.shouldHaveExitValue(0);
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    51
  }
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    52
}
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    53
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    54
class HeapFiller {
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    55
  public static Entry root;
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    56
  private static final int PAYLOAD_SIZE = 1000;
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    57
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    58
  public static void main(String[] args) {
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    59
    root = new Entry(PAYLOAD_SIZE, null);
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    60
    Entry current = root;
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    61
    try {
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    62
      while (true) {
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    63
        Entry newEntry = new Entry(PAYLOAD_SIZE, current);
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    64
        current = newEntry;
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    65
      }
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    66
    } catch (OutOfMemoryError e) {
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    67
      root = null;
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    68
    }
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    69
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    70
  }
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    71
}
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    72
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    73
class Entry {
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    74
  public Entry previous;
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    75
  public byte[] payload;
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    76
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    77
  Entry(int payloadSize, Entry previous) {
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    78
    payload = new byte[payloadSize];
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    79
    this.previous = previous;
eef85c68cec0 8027440: DefNew does not log heap change information when a promotion failure occurs
brutisso
parents:
diff changeset
    80
  }
27692
11c231c781dc 8062537: [TESTBUG] Conflicting GC combinations in hotspot tests
eistepan
parents: 22204
diff changeset
    81
}