annotate test/runtime/SharedArchiveFile/PrintSharedArchiveAndExit.java @ 20700:0558eb13dcf3

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
author iklam
date Thu, 04 Dec 2014 15:20:09 -0800
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
20700
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
1 /*
0558eb13dcf3 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.
0558eb13dcf3 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.
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
4 *
0558eb13dcf3 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
0558eb13dcf3 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
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
7 * published by the Free Software Foundation.
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
8 *
0558eb13dcf3 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
0558eb13dcf3 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
0558eb13dcf3 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
0558eb13dcf3 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
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
13 * accompanied this code).
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
14 *
0558eb13dcf3 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
0558eb13dcf3 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,
0558eb13dcf3 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.
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
18 *
0558eb13dcf3 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
0558eb13dcf3 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
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
21 * questions.
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
22 */
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
23
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
24 /*
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
25 * @test
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
26 * @bug 8066670
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
27 * @summary Testing -XX:+PrintSharedArchiveAndExit option
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
28 * @library /testlibrary
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
29 */
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
30
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
31 import com.oracle.java.testlibrary.*;
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
32
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
33 public class PrintSharedArchiveAndExit {
0558eb13dcf3 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 {
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
35 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
0558eb13dcf3 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");
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
37 OutputAnalyzer output = new OutputAnalyzer(pb.start());
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
38 try {
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
39 output.shouldContain("Loading classes to share");
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
40 output.shouldHaveExitValue(0);
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
41
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
42 // (1) With a valid archive
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
43 pb = ProcessTools.createJavaProcessBuilder(
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
44 "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./sample.jsa",
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
45 "-XX:+PrintSharedArchiveAndExit", "-version");
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
46 output = new OutputAnalyzer(pb.start());
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
47 output.shouldContain("archive is valid");
0558eb13dcf3 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
0558eb13dcf3 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.
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
50
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
51 pb = ProcessTools.createJavaProcessBuilder(
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
52 "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./sample.jsa",
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
53 "-XX:+PrintSharedArchiveAndExit");
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
54 output = new OutputAnalyzer(pb.start());
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
55 output.shouldContain("archive is valid");
0558eb13dcf3 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
0558eb13dcf3 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.
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
58
0558eb13dcf3 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)
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
60 pb = ProcessTools.createJavaProcessBuilder(
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
61 "-Xbootclasspath/p:foo.jar",
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
62 "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./sample.jsa",
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
63 "-XX:+PrintSharedArchiveAndExit", "-version");
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
64 output = new OutputAnalyzer(pb.start());
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
65 output.shouldContain("archive is invalid");
0558eb13dcf3 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
0558eb13dcf3 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.
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
68
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
69 pb = ProcessTools.createJavaProcessBuilder(
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
70 "-Xbootclasspath/p:foo.jar",
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
71 "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./sample.jsa",
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
72 "-XX:+PrintSharedArchiveAndExit");
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
73 output = new OutputAnalyzer(pb.start());
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
74 output.shouldContain("archive is invalid");
0558eb13dcf3 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
0558eb13dcf3 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.
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
77 } catch (RuntimeException e) {
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
78 e.printStackTrace();
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
79 output.shouldContain("Unable to use shared archive");
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
80 output.shouldHaveExitValue(1);
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
81 }
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
82 }
0558eb13dcf3 8066670: PrintSharedArchiveAndExit does not exit the VM when the archive is invalid
iklam
parents:
diff changeset
83 }