hotspot/test/gc/TestVerifySilently.java
author lana
Fri, 18 Sep 2015 10:46:55 -0700
changeset 32691 6b39cec6c115
parent 30604 b8d532cb6420
child 35061 be6025ebffea
permissions -rw-r--r--
Added tag jdk9-b82 for changeset a86fb74acc8d
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
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 22760
diff changeset
    29
 * @modules java.base/sun.misc
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",
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    63
                                             "-XX:" + (verifySilently ? "+":"-") + "VerifySilently",
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);
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    79
    output.shouldContain("[Verifying");
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);
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    83
    output.shouldNotContain("[Verifying");
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
}