annotate test/runtime/SharedArchiveFile/ArchiveDoesNotExist.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 9c8439756c05
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
20488
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
1 /*
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
4 *
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
7 * published by the Free Software Foundation.
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
8 *
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
13 * accompanied this code).
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
14 *
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
18 *
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
21 * questions.
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
22 */
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
23
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
24 /*
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
25 * @test ArchiveDoesNotExist
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
26 * @summary Test how VM handles "file does not exist" situation while
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
27 * attempting to use CDS archive. JVM should exit gracefully
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
28 * when sharing mode is ON, and continue w/o sharing if sharing
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
29 * mode is AUTO.
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
30 * @library /testlibrary
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
31 * @run main ArchiveDoesNotExist
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
32 */
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
33
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
34 import com.oracle.java.testlibrary.*;
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
35 import java.io.File;
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
36
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
37 public class ArchiveDoesNotExist {
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
38 public static void main(String[] args) throws Exception {
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
39 String fileName = "test.jsa";
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
40
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
41 File cdsFile = new File(fileName);
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
42 if (cdsFile.exists())
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
43 throw new RuntimeException("Test error: cds file already exists");
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
44
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
45 // Sharing: on
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
46 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
47 "-XX:+UnlockDiagnosticVMOptions",
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
48 "-XX:SharedArchiveFile=./" + fileName,
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
49 "-Xshare:on",
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
50 "-version");
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
51
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
52 OutputAnalyzer output = new OutputAnalyzer(pb.start());
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
53 output.shouldContain("Specified shared archive not found");
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
54 output.shouldHaveExitValue(1);
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
55
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
56 // Sharing: auto
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
57 pb = ProcessTools.createJavaProcessBuilder(
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
58 "-XX:+UnlockDiagnosticVMOptions",
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
59 "-XX:SharedArchiveFile=./" + fileName,
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
60 "-Xshare:auto",
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
61 "-version");
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
62
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
63 output = new OutputAnalyzer(pb.start());
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
64 output.shouldMatch("(java|openjdk) version");
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
65 output.shouldNotContain("sharing");
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
66 output.shouldHaveExitValue(0);
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
67 }
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
68 }