test/runtime/SharedArchiveFile/SharedBaseAddress.java

Fri, 19 Sep 2014 11:12:39 -0400

author
mseledtsov
date
Fri, 19 Sep 2014 11:12:39 -0400
changeset 7202
9c8439756c05
permissions
-rw-r--r--

8052313: Backport CDS tests from JDK-9 to jdk8_u40
Summary: Copied CDS tests from jdk-9 to jdk8u40
Reviewed-by: ccheung, dholmes

mseledtsov@7202 1 /*
mseledtsov@7202 2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
mseledtsov@7202 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
mseledtsov@7202 4 *
mseledtsov@7202 5 * This code is free software; you can redistribute it and/or modify it
mseledtsov@7202 6 * under the terms of the GNU General Public License version 2 only, as
mseledtsov@7202 7 * published by the Free Software Foundation.
mseledtsov@7202 8 *
mseledtsov@7202 9 * This code is distributed in the hope that it will be useful, but WITHOUT
mseledtsov@7202 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
mseledtsov@7202 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
mseledtsov@7202 12 * version 2 for more details (a copy is included in the LICENSE file that
mseledtsov@7202 13 * accompanied this code).
mseledtsov@7202 14 *
mseledtsov@7202 15 * You should have received a copy of the GNU General Public License version
mseledtsov@7202 16 * 2 along with this work; if not, write to the Free Software Foundation,
mseledtsov@7202 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
mseledtsov@7202 18 *
mseledtsov@7202 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
mseledtsov@7202 20 * or visit www.oracle.com if you need additional information or have any
mseledtsov@7202 21 * questions.
mseledtsov@7202 22 */
mseledtsov@7202 23
mseledtsov@7202 24 /*
mseledtsov@7202 25 * @test SharedBaseAddress
mseledtsov@7202 26 * @summary Test variety of values for SharedBaseAddress, making sure
mseledtsov@7202 27 * VM handles normal values as well as edge values w/o a crash.
mseledtsov@7202 28 * @library /testlibrary
mseledtsov@7202 29 * @run main SharedBaseAddress
mseledtsov@7202 30 */
mseledtsov@7202 31
mseledtsov@7202 32 import com.oracle.java.testlibrary.*;
mseledtsov@7202 33
mseledtsov@7202 34 public class SharedBaseAddress {
mseledtsov@7202 35
mseledtsov@7202 36 // shared base address test table
mseledtsov@7202 37 private static final String[] testTable = {
mseledtsov@7202 38 "1g", "8g", "64g","512g", "4t",
mseledtsov@7202 39 "32t", "128t", "0",
mseledtsov@7202 40 "1", "64k", "64M"
mseledtsov@7202 41 };
mseledtsov@7202 42
mseledtsov@7202 43 public static void main(String[] args) throws Exception {
mseledtsov@7202 44 // Known issue on Solaris-Sparc
mseledtsov@7202 45 // @ignore JDK-8044600
mseledtsov@7202 46 if (Platform.isSolaris() && Platform.isSparc())
mseledtsov@7202 47 return;
mseledtsov@7202 48
mseledtsov@7202 49 for (String testEntry : testTable) {
mseledtsov@7202 50 System.out.println("sharedBaseAddress = " + testEntry);
mseledtsov@7202 51
mseledtsov@7202 52 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
mseledtsov@7202 53 "-XX:+UnlockDiagnosticVMOptions",
mseledtsov@7202 54 "-XX:SharedArchiveFile=test.jsa",
mseledtsov@7202 55 "-XX:SharedBaseAddress=" + testEntry,
mseledtsov@7202 56 "-Xshare:dump");
mseledtsov@7202 57
mseledtsov@7202 58 OutputAnalyzer output = new OutputAnalyzer(pb.start());
mseledtsov@7202 59
mseledtsov@7202 60 output.shouldContain("Loading classes to share");
mseledtsov@7202 61
mseledtsov@7202 62 try {
mseledtsov@7202 63 pb = ProcessTools.createJavaProcessBuilder(
mseledtsov@7202 64 "-XX:+UnlockDiagnosticVMOptions",
mseledtsov@7202 65 "-XX:SharedArchiveFile=test.jsa",
mseledtsov@7202 66 "-Xshare:on",
mseledtsov@7202 67 "-version");
mseledtsov@7202 68 output = new OutputAnalyzer(pb.start());
mseledtsov@7202 69 output.shouldContain("sharing");
mseledtsov@7202 70 output.shouldHaveExitValue(0);
mseledtsov@7202 71 } catch (RuntimeException e) {
mseledtsov@7202 72 output.shouldContain("Unable to use shared archive");
mseledtsov@7202 73 output.shouldHaveExitValue(1);
mseledtsov@7202 74 }
mseledtsov@7202 75 }
mseledtsov@7202 76 }
mseledtsov@7202 77 }

mercurial