hotspot/test/gc/TestVerifySilently.java
author alanb
Tue, 03 May 2016 09:11:31 +0100
changeset 37827 09fa0c82a5f7
parent 36851 03e2f4d0a421
child 38084 21c37af5ba7e
permissions -rw-r--r--
8154956: Module system implementation refresh (4/2016) Reviewed-by: alanb, mchung, chegar, redestad Contributed-by: alan.bateman@oracle.com, erik.joelsson@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22760
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
     1
/*
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 22760
diff changeset
     2
 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
22760
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
     4
 *
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
     7
 * published by the Free Software Foundation.
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
     8
 *
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    13
 * accompanied this code).
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    14
 *
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    18
 *
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    21
 * questions.
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    22
 */
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    23
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    24
/* @test TestVerifySilently.java
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    25
 * @key gc
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    26
 * @bug 8032771
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    27
 * @summary Test silent verification.
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    28
 * @library /testlibrary
36851
03e2f4d0a421 8153737: Unsupported Module
chegar
parents: 35061
diff changeset
    29
 * @modules java.base/jdk.internal.misc
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 22760
diff changeset
    30
 *          java.management
22760
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    31
 */
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    32
30604
b8d532cb6420 8067013: Rename the com.oracle.java.testlibary package
ykantser
parents: 29678
diff changeset
    33
import jdk.test.lib.OutputAnalyzer;
b8d532cb6420 8067013: Rename the com.oracle.java.testlibary package
ykantser
parents: 29678
diff changeset
    34
import jdk.test.lib.ProcessTools;
22760
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    35
import java.util.ArrayList;
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    36
import java.util.Collections;
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    37
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    38
class RunSystemGC {
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    39
  public static void main(String args[]) throws Exception {
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    40
    System.gc();
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    41
  }
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    42
}
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    43
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    44
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    45
public class TestVerifySilently {
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    46
  private static String[] getTestJavaOpts() {
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    47
    String testVmOptsStr = System.getProperty("test.java.opts");
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    48
    if (!testVmOptsStr.isEmpty()) {
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    49
      return testVmOptsStr.split(" ");
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    50
    } else {
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    51
      return new String[] {};
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    52
    }
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    53
  }
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    54
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    55
  private static OutputAnalyzer runTest(boolean verifySilently) throws Exception {
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    56
    ArrayList<String> vmOpts = new ArrayList();
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    57
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    58
    Collections.addAll(vmOpts, getTestJavaOpts());
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    59
    Collections.addAll(vmOpts, new String[] {"-XX:+UnlockDiagnosticVMOptions",
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    60
                                             "-XX:+VerifyDuringStartup",
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    61
                                             "-XX:+VerifyBeforeGC",
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    62
                                             "-XX:+VerifyAfterGC",
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 30604
diff changeset
    63
                                             (verifySilently ? "-Xlog:gc":"-Xlog:gc+verify=debug"),
22760
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    64
                                             RunSystemGC.class.getName()});
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    65
    ProcessBuilder pb =
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    66
      ProcessTools.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()]));
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    67
    OutputAnalyzer output = new OutputAnalyzer(pb.start());
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    68
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    69
    System.out.println("Output:\n" + output.getOutput());
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    70
    return output;
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    71
  }
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    72
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    73
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    74
  public static void main(String args[]) throws Exception {
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    75
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    76
    OutputAnalyzer output;
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    77
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    78
    output = runTest(false);
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 30604
diff changeset
    79
    output.shouldContain("Verifying");
22760
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    80
    output.shouldHaveExitValue(0);
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    81
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    82
    output = runTest(true);
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 30604
diff changeset
    83
    output.shouldNotContain("Verifying");
22760
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    84
    output.shouldHaveExitValue(0);
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    85
  }
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    86
}