hotspot/test/runtime/SharedArchiveFile/PrintSharedArchiveAndExit.java
author iklam
Thu, 04 Dec 2014 15:20:09 -0800
changeset 28017 84009002b566
child 29678 dd2f3932c21e
child 30123 7a8b6bd85e24
permissions -rw-r--r--
8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid Summary: in FileMapInfo::fail_continue do not set UseSharedSpaces = false Reviewed-by: dholmes, ccheung
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
/*
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
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
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    29
 */
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    30
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    31
import com.oracle.java.testlibrary.*;
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
public class PrintSharedArchiveAndExit {
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    34
  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
    35
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    36
        "-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
    37
    OutputAnalyzer output = new OutputAnalyzer(pb.start());
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    38
    try {
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    39
      output.shouldContain("Loading classes to share");
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    40
      output.shouldHaveExitValue(0);
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    41
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    42
      // (1) With a valid archive
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    43
      pb = ProcessTools.createJavaProcessBuilder(
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    44
          "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./sample.jsa",
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    45
          "-XX:+PrintSharedArchiveAndExit", "-version");
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    46
      output = new OutputAnalyzer(pb.start());
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    47
      output.shouldContain("archive is valid");
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    48
      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
    49
      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
    50
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    51
      pb = ProcessTools.createJavaProcessBuilder(
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    52
          "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./sample.jsa",
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    53
          "-XX:+PrintSharedArchiveAndExit");
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    54
      output = new OutputAnalyzer(pb.start());
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    55
      output.shouldContain("archive is valid");
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    56
      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
    57
      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
    58
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    59
      // (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
    60
      pb = ProcessTools.createJavaProcessBuilder(
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    61
          "-Xbootclasspath/p:foo.jar",
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    62
          "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./sample.jsa",
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    63
          "-XX:+PrintSharedArchiveAndExit", "-version");
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    64
      output = new OutputAnalyzer(pb.start());
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    65
      output.shouldContain("archive is invalid");
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    66
      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
    67
      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
    68
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    69
      pb = ProcessTools.createJavaProcessBuilder(
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    70
          "-Xbootclasspath/p:foo.jar",
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    71
          "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./sample.jsa",
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    72
          "-XX:+PrintSharedArchiveAndExit");
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    73
      output = new OutputAnalyzer(pb.start());
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    74
      output.shouldContain("archive is invalid");
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    75
      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
    76
      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
    77
    } catch (RuntimeException e) {
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    78
      e.printStackTrace();
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    79
      output.shouldContain("Unable to use shared archive");
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    80
      output.shouldHaveExitValue(1);
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    81
    }
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    82
  }
84009002b566 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
    83
}