Mercurial > hg > truffle
annotate test/runtime/SharedArchiveFile/CdsWriteError.java @ 14533:e5235120893c
split BciBlockMapping liveness calculation into fast and slow path
author | Lukas Stadler <lukas.stadler@oracle.com> |
---|---|
date | Fri, 14 Mar 2014 10:21:46 +0100 |
parents | 4510a3502166 |
children |
rev | line source |
---|---|
14275 | 1 /* |
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 */ | |
23 | |
24 /* | |
14476
4510a3502166
8034898: [TESTBUG]: Zero failure project - tag all Runtime JTReg bugs that fail nightly
gtriantafill
parents:
14275
diff
changeset
|
25 * @ignore 8032222 |
14275 | 26 * @test CdsWriteError |
27 * @summary Test how VM handles situation when it is impossible to write the | |
28 * CDS archive. VM is expected to exit gracefully and display the | |
29 * correct reason for the error. | |
30 * @library /testlibrary | |
31 * @run main CdsWriteError | |
14476
4510a3502166
8034898: [TESTBUG]: Zero failure project - tag all Runtime JTReg bugs that fail nightly
gtriantafill
parents:
14275
diff
changeset
|
32 * @bug 8032222 |
14275 | 33 */ |
34 | |
35 import com.oracle.java.testlibrary.*; | |
36 import java.io.File; | |
37 | |
38 public class CdsWriteError { | |
39 public static void main(String[] args) throws Exception { | |
40 | |
41 if (Platform.isWindows()) { | |
42 System.out.println("This test is ignored on Windows. This test " + | |
43 "manipulates folder writable attribute, which is known to be " + | |
44 "often ignored by Windows"); | |
45 | |
46 return; | |
47 } | |
48 | |
49 String folderName = "tmp"; | |
50 String fileName = folderName + File.separator + "empty.jsa"; | |
51 | |
52 // create an empty archive file and make it read only | |
53 File folder = new File(folderName); | |
54 if (!folder.mkdir()) | |
55 throw new RuntimeException("Error when creating a tmp folder"); | |
56 | |
57 File cdsFile = new File(fileName); | |
58 if (!cdsFile.createNewFile()) | |
59 throw new RuntimeException("Error when creating an empty CDS file"); | |
60 if (!cdsFile.setWritable(false)) | |
61 throw new RuntimeException("Error: could not set writable attribute on cds file"); | |
62 if (!folder.setWritable(false)) | |
63 throw new RuntimeException("Error: could not set writable attribute on the cds folder"); | |
64 | |
65 try { | |
66 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( | |
67 "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./" + fileName, "-Xshare:dump"); | |
68 | |
69 OutputAnalyzer output = new OutputAnalyzer(pb.start()); | |
70 output.shouldContain("Unable to create shared archive file"); | |
71 output.shouldHaveExitValue(1); | |
72 } finally { | |
73 // doing this, just in case, to make sure that files can be deleted by the harness | |
74 // on any subsequent run | |
75 folder.setWritable(true); | |
76 cdsFile.setWritable(true); | |
77 } | |
78 } | |
79 } | |
80 |