hotspot/test/runtime/SharedArchiveFile/PrintSharedArchiveAndExit.java
author ykantser
Thu, 26 Mar 2015 16:36:56 +0100
changeset 29678 dd2f3932c21e
parent 28017 84009002b566
child 30146 a5809dde4617
permissions -rw-r--r--
8075586: Add @modules as needed to the open hotspot tests Reviewed-by: sla, ctornqvi, lfoltan, mchung, alanb Contributed-by: alexander.kulyakhtin@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28017
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
     1
/*
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 28017
diff changeset
     2
 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
28017
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
     4
 *
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
     7
 * published by the Free Software Foundation.
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
     8
 *
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    13
 * accompanied this code).
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    14
 *
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    18
 *
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    21
 * questions.
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    22
 */
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    23
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    24
/*
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    25
 * @test
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    26
 * @bug 8066670
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    27
 * @summary Testing -XX:+PrintSharedArchiveAndExit option
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    28
 * @library /testlibrary
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 28017
diff changeset
    29
 * @modules java.base/sun.misc
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 28017
diff changeset
    30
 *          java.management
28017
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    31
 */
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    32
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    33
import com.oracle.java.testlibrary.*;
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    34
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    35
public class PrintSharedArchiveAndExit {
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    36
  public static void main(String[] args) throws Exception {
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    37
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    38
        "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./sample.jsa", "-Xshare:dump");
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    39
    OutputAnalyzer output = new OutputAnalyzer(pb.start());
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    40
    try {
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    41
      output.shouldContain("Loading classes to share");
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    42
      output.shouldHaveExitValue(0);
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    43
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    44
      // (1) With a valid archive
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    45
      pb = ProcessTools.createJavaProcessBuilder(
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    46
          "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./sample.jsa",
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    47
          "-XX:+PrintSharedArchiveAndExit", "-version");
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    48
      output = new OutputAnalyzer(pb.start());
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    49
      output.shouldContain("archive is valid");
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    50
      output.shouldNotContain("java version");     // Should not print JVM version
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    51
      output.shouldHaveExitValue(0);               // Should report success in error code.
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    52
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    53
      pb = ProcessTools.createJavaProcessBuilder(
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    54
          "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./sample.jsa",
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    55
          "-XX:+PrintSharedArchiveAndExit");
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    56
      output = new OutputAnalyzer(pb.start());
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    57
      output.shouldContain("archive is valid");
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    58
      output.shouldNotContain("Usage:");           // Should not print JVM help message
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    59
      output.shouldHaveExitValue(0);               // Should report success in error code.
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    60
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    61
      // (2) With an invalid archive (boot class path has been prepended)
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    62
      pb = ProcessTools.createJavaProcessBuilder(
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    63
          "-Xbootclasspath/p:foo.jar",
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    64
          "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./sample.jsa",
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    65
          "-XX:+PrintSharedArchiveAndExit", "-version");
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    66
      output = new OutputAnalyzer(pb.start());
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    67
      output.shouldContain("archive is invalid");
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    68
      output.shouldNotContain("java version");     // Should not print JVM version
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    69
      output.shouldHaveExitValue(1);               // Should report failure in error code.
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    70
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    71
      pb = ProcessTools.createJavaProcessBuilder(
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    72
          "-Xbootclasspath/p:foo.jar",
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    73
          "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./sample.jsa",
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    74
          "-XX:+PrintSharedArchiveAndExit");
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    75
      output = new OutputAnalyzer(pb.start());
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    76
      output.shouldContain("archive is invalid");
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    77
      output.shouldNotContain("Usage:");           // Should not print JVM help message
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    78
      output.shouldHaveExitValue(1);               // Should report failure in error code.
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    79
    } catch (RuntimeException e) {
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    80
      e.printStackTrace();
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    81
      output.shouldContain("Unable to use shared archive");
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    82
      output.shouldHaveExitValue(1);
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    83
    }
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    84
  }
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    85
}