test/runtime/SharedArchiveFile/DefaultUseWithClient.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 DefaultUseWithClient
mseledtsov@7202 26 * @summary Test default behavior of sharing with -client
mseledtsov@7202 27 * @library /testlibrary
mseledtsov@7202 28 * @run main DefaultUseWithClient
mseledtsov@7202 29 * @bug 8032224
mseledtsov@7202 30 */
mseledtsov@7202 31
mseledtsov@7202 32 import com.oracle.java.testlibrary.*;
mseledtsov@7202 33 import java.io.File;
mseledtsov@7202 34
mseledtsov@7202 35 public class DefaultUseWithClient {
mseledtsov@7202 36 public static void main(String[] args) throws Exception {
mseledtsov@7202 37 String fileName = "test.jsa";
mseledtsov@7202 38
mseledtsov@7202 39 // On 32-bit windows CDS should be on by default in "-client" config
mseledtsov@7202 40 // Skip this test on any other platform
mseledtsov@7202 41 boolean is32BitWindows = (Platform.isWindows() && Platform.is32bit());
mseledtsov@7202 42 if (!is32BitWindows) {
mseledtsov@7202 43 System.out.println("Test only applicable on 32-bit Windows. Skipping");
mseledtsov@7202 44 return;
mseledtsov@7202 45 }
mseledtsov@7202 46
mseledtsov@7202 47 // create the archive
mseledtsov@7202 48 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
mseledtsov@7202 49 "-XX:+UnlockDiagnosticVMOptions",
mseledtsov@7202 50 "-XX:SharedArchiveFile=./" + fileName,
mseledtsov@7202 51 "-Xshare:dump");
mseledtsov@7202 52 OutputAnalyzer output = new OutputAnalyzer(pb.start());
mseledtsov@7202 53 output.shouldHaveExitValue(0);
mseledtsov@7202 54
mseledtsov@7202 55 pb = ProcessTools.createJavaProcessBuilder(
mseledtsov@7202 56 "-XX:+UnlockDiagnosticVMOptions",
mseledtsov@7202 57 "-XX:SharedArchiveFile=./" + fileName,
mseledtsov@7202 58 "-client",
mseledtsov@7202 59 "-XX:+PrintSharedSpaces",
mseledtsov@7202 60 "-version");
mseledtsov@7202 61
mseledtsov@7202 62 output = new OutputAnalyzer(pb.start());
mseledtsov@7202 63 try {
mseledtsov@7202 64 output.shouldContain("sharing");
mseledtsov@7202 65 } catch (RuntimeException e) {
mseledtsov@7202 66 // if sharing failed due to ASLR or similar reasons,
mseledtsov@7202 67 // check whether sharing was attempted at all (UseSharedSpaces)
mseledtsov@7202 68 output.shouldContain("UseSharedSpaces:");
mseledtsov@7202 69 }
mseledtsov@7202 70 output.shouldHaveExitValue(0);
mseledtsov@7202 71 }
mseledtsov@7202 72 }

mercurial