hotspot/test/runtime/SharedArchiveFile/DefaultUseWithClient.java
author mseledtsov
Mon, 10 Mar 2014 14:50:20 -0400
changeset 23442 be6bd2c1f2a8
parent 22892 1709e0e0b87c
child 29678 dd2f3932c21e
child 30123 7a8b6bd85e24
permissions -rw-r--r--
8026154: [TESTBUG] runtime/CDSCompressedKPtrs/XShareAuto.java failed due to exception Summary: Added statements in the tests to handle failures in sharing Reviewed-by: zgu, ctornqvi
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22517
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
     1
/*
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
     4
 *
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
     7
 * published by the Free Software Foundation.
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
     8
 *
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    13
 * accompanied this code).
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    14
 *
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    18
 *
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    21
 * questions.
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    22
 */
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    23
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    24
/*
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    25
 * @test DefaultUseWithClient
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    26
 * @summary Test default behavior of sharing with -client
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    27
 * @library /testlibrary
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    28
 * @run main DefaultUseWithClient
22892
1709e0e0b87c 8034898: [TESTBUG]: Zero failure project - tag all Runtime JTReg bugs that fail nightly
gtriantafill
parents: 22517
diff changeset
    29
 * @bug 8032224
22517
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    30
 */
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    31
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    32
import com.oracle.java.testlibrary.*;
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    33
import java.io.File;
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    34
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    35
public class DefaultUseWithClient {
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    36
    public static void main(String[] args) throws Exception {
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    37
        String fileName = "test.jsa";
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    38
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    39
        // On 32-bit windows CDS should be on by default in "-client" config
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    40
        // Skip this test on any other platform
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    41
        boolean is32BitWindows = (Platform.isWindows() && Platform.is32bit());
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    42
        if (!is32BitWindows) {
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    43
            System.out.println("Test only applicable on 32-bit Windows. Skipping");
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    44
            return;
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    45
        }
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    46
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    47
        // create the archive
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    48
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    49
           "-XX:+UnlockDiagnosticVMOptions",
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    50
           "-XX:SharedArchiveFile=./" + fileName,
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    51
           "-Xshare:dump");
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    52
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    53
        output.shouldHaveExitValue(0);
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    54
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    55
        pb = ProcessTools.createJavaProcessBuilder(
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    56
           "-XX:+UnlockDiagnosticVMOptions",
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    57
           "-XX:SharedArchiveFile=./" + fileName,
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    58
           "-client",
23442
be6bd2c1f2a8 8026154: [TESTBUG] runtime/CDSCompressedKPtrs/XShareAuto.java failed due to exception
mseledtsov
parents: 22892
diff changeset
    59
           "-XX:+PrintSharedSpaces",
22517
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    60
           "-version");
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    61
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    62
        output = new OutputAnalyzer(pb.start());
23442
be6bd2c1f2a8 8026154: [TESTBUG] runtime/CDSCompressedKPtrs/XShareAuto.java failed due to exception
mseledtsov
parents: 22892
diff changeset
    63
        try {
be6bd2c1f2a8 8026154: [TESTBUG] runtime/CDSCompressedKPtrs/XShareAuto.java failed due to exception
mseledtsov
parents: 22892
diff changeset
    64
            output.shouldContain("sharing");
be6bd2c1f2a8 8026154: [TESTBUG] runtime/CDSCompressedKPtrs/XShareAuto.java failed due to exception
mseledtsov
parents: 22892
diff changeset
    65
        } catch (RuntimeException e) {
be6bd2c1f2a8 8026154: [TESTBUG] runtime/CDSCompressedKPtrs/XShareAuto.java failed due to exception
mseledtsov
parents: 22892
diff changeset
    66
            // if sharing failed due to ASLR or similar reasons,
be6bd2c1f2a8 8026154: [TESTBUG] runtime/CDSCompressedKPtrs/XShareAuto.java failed due to exception
mseledtsov
parents: 22892
diff changeset
    67
            // check whether sharing was attempted at all (UseSharedSpaces)
be6bd2c1f2a8 8026154: [TESTBUG] runtime/CDSCompressedKPtrs/XShareAuto.java failed due to exception
mseledtsov
parents: 22892
diff changeset
    68
            output.shouldContain("UseSharedSpaces:");
be6bd2c1f2a8 8026154: [TESTBUG] runtime/CDSCompressedKPtrs/XShareAuto.java failed due to exception
mseledtsov
parents: 22892
diff changeset
    69
        }
22517
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    70
        output.shouldHaveExitValue(0);
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    71
   }
8de4bcd74cd5 8031151: Add basic CDS tests
mseledtsov
parents:
diff changeset
    72
}