annotate test/runtime/SharedArchiveFile/SharedArchiveFile.java @ 10270:f944ba972151

8014138: Add VM option to facilitate the writing of CDS tests Summary: Added the -XX:SharedArchiveFile option. Reviewed-by: coleenp, ccheung, acorn, dcubed, zgu
author hseigel
date Tue, 14 May 2013 09:17:52 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10270
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
1 /*
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
4 *
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
7 * published by the Free Software Foundation.
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
8 *
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
13 * accompanied this code).
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
14 *
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
18 *
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
21 * questions.
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
22 */
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
23
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
24 /*
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
25 * @test
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
26 * @bug 8014138
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
27 * @summary Testing new -XX:SharedArchiveFile=<file-name> option
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
28 * @library /testlibrary
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
29 */
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
30
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
31 import com.oracle.java.testlibrary.*;
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
32
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
33 public class SharedArchiveFile {
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
34 public static void main(String[] args) throws Exception {
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
35 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
36 "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./sample.jsa", "-Xshare:dump");
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
37 OutputAnalyzer output = new OutputAnalyzer(pb.start());
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
38 try {
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
39 output.shouldContain("Loading classes to share");
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
40 output.shouldHaveExitValue(0);
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
41
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
42 pb = ProcessTools.createJavaProcessBuilder(
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
43 "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./sample.jsa", "-Xshare:on", "-version");
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
44 output = new OutputAnalyzer(pb.start());
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
45 output.shouldContain("sharing");
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
46 output.shouldHaveExitValue(0);
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
47
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
48 } catch (RuntimeException e) {
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
49 output.shouldContain("Unable to use shared archive");
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
50 output.shouldHaveExitValue(1);
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
51 }
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
52 }
f944ba972151 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
53 }