hotspot/test/runtime/SharedArchiveFile/SharedArchiveFile.java
author ykantser
Mon, 04 May 2015 16:30:07 +0200
changeset 30604 b8d532cb6420
parent 30146 a5809dde4617
child 36851 03e2f4d0a421
permissions -rw-r--r--
8067013: Rename the com.oracle.java.testlibary package Reviewed-by: dholmes, gtriantafill, sla Contributed-by: alexander.kulyakhtin@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
17375
e9554fd82263 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
     1
/*
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 17375
diff changeset
     2
 * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
17375
e9554fd82263 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.
e9554fd82263 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
     4
 *
e9554fd82263 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
e9554fd82263 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
e9554fd82263 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
     7
 * published by the Free Software Foundation.
e9554fd82263 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
     8
 *
e9554fd82263 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
e9554fd82263 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
e9554fd82263 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
e9554fd82263 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
e9554fd82263 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
    13
 * accompanied this code).
e9554fd82263 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
    14
 *
e9554fd82263 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
e9554fd82263 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,
e9554fd82263 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.
e9554fd82263 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
    18
 *
e9554fd82263 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
e9554fd82263 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
e9554fd82263 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
    21
 * questions.
e9554fd82263 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
    22
 */
e9554fd82263 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
    23
e9554fd82263 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
    24
/*
e9554fd82263 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
    25
 * @test
e9554fd82263 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
    26
 * @bug 8014138
e9554fd82263 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
    27
 * @summary Testing new -XX:SharedArchiveFile=<file-name> option
e9554fd82263 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
    28
 * @library /testlibrary
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 17375
diff changeset
    29
 * @modules java.base/sun.misc
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 17375
diff changeset
    30
 *          java.management
17375
e9554fd82263 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
    31
 */
e9554fd82263 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
    32
30604
b8d532cb6420 8067013: Rename the com.oracle.java.testlibary package
ykantser
parents: 30146
diff changeset
    33
import jdk.test.lib.*;
17375
e9554fd82263 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
    34
e9554fd82263 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
    35
public class SharedArchiveFile {
e9554fd82263 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
    36
  public static void main(String[] args) throws Exception {
e9554fd82263 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
    37
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
30123
7a8b6bd85e24 8075438: [TESTBUG] Hotspot JTREG tests should use unique CDS archive names
ctornqvi
parents: 17375
diff changeset
    38
        "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./SharedArchiveFile.jsa", "-Xshare:dump");
17375
e9554fd82263 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
    39
    OutputAnalyzer output = new OutputAnalyzer(pb.start());
e9554fd82263 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
    40
    try {
e9554fd82263 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
    41
      output.shouldContain("Loading classes to share");
e9554fd82263 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
    42
      output.shouldHaveExitValue(0);
e9554fd82263 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
    43
e9554fd82263 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
    44
      pb = ProcessTools.createJavaProcessBuilder(
30123
7a8b6bd85e24 8075438: [TESTBUG] Hotspot JTREG tests should use unique CDS archive names
ctornqvi
parents: 17375
diff changeset
    45
        "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./SharedArchiveFile.jsa", "-Xshare:on", "-version");
17375
e9554fd82263 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
    46
      output = new OutputAnalyzer(pb.start());
e9554fd82263 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
    47
      output.shouldContain("sharing");
e9554fd82263 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
    48
      output.shouldHaveExitValue(0);
e9554fd82263 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
    49
e9554fd82263 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
    50
    } catch (RuntimeException e) {
e9554fd82263 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
    51
      output.shouldContain("Unable to use shared archive");
e9554fd82263 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
    52
      output.shouldHaveExitValue(1);
e9554fd82263 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
    53
    }
e9554fd82263 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
    54
  }
e9554fd82263 8014138: Add VM option to facilitate the writing of CDS tests
hseigel
parents:
diff changeset
    55
}