hotspot/test/gc/TestVerifySilently.java
author pchelko
Wed, 23 Apr 2014 17:56:05 +0400
changeset 24529 c580bcb3aabc
parent 22760 8469dee00b80
child 29678 dd2f3932c21e
permissions -rw-r--r--
8027148: SystemFlavorMap.getNativesForFlavor returns list of native formats in incorrect order Reviewed-by: anthony, serb
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
/*
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
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
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    29
 */
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    30
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    31
import com.oracle.java.testlibrary.OutputAnalyzer;
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    32
import com.oracle.java.testlibrary.ProcessTools;
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    33
import java.util.ArrayList;
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    34
import java.util.Collections;
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    35
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    36
class RunSystemGC {
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    37
  public static void main(String args[]) throws Exception {
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    38
    System.gc();
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    39
  }
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    40
}
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
public class TestVerifySilently {
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    44
  private static String[] getTestJavaOpts() {
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    45
    String testVmOptsStr = System.getProperty("test.java.opts");
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    46
    if (!testVmOptsStr.isEmpty()) {
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    47
      return testVmOptsStr.split(" ");
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    48
    } else {
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    49
      return new String[] {};
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    50
    }
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    51
  }
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
  private static OutputAnalyzer runTest(boolean verifySilently) throws Exception {
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    54
    ArrayList<String> vmOpts = new ArrayList();
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    55
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    56
    Collections.addAll(vmOpts, getTestJavaOpts());
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    57
    Collections.addAll(vmOpts, new String[] {"-XX:+UnlockDiagnosticVMOptions",
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    58
                                             "-XX:+VerifyDuringStartup",
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    59
                                             "-XX:+VerifyBeforeGC",
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    60
                                             "-XX:+VerifyAfterGC",
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    61
                                             "-XX:" + (verifySilently ? "+":"-") + "VerifySilently",
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    62
                                             RunSystemGC.class.getName()});
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    63
    ProcessBuilder pb =
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    64
      ProcessTools.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()]));
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    65
    OutputAnalyzer output = new OutputAnalyzer(pb.start());
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    66
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    67
    System.out.println("Output:\n" + output.getOutput());
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    68
    return output;
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    69
  }
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    70
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
  public static void main(String args[]) throws Exception {
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
    OutputAnalyzer output;
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
    output = runTest(false);
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    77
    output.shouldContain("[Verifying");
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    78
    output.shouldHaveExitValue(0);
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    79
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    80
    output = runTest(true);
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    81
    output.shouldNotContain("[Verifying");
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    82
    output.shouldHaveExitValue(0);
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    83
  }
8469dee00b80 8032771: The flag VerifySilently misses a test case
tschatzl
parents:
diff changeset
    84
}