author | dfazunen |
Fri, 24 Jun 2016 19:52:31 +0400 | |
changeset 39414 | 4adf52148100 |
parent 38008 | 58732890050d |
child 40631 | ed82623d7831 |
permissions | -rw-r--r-- |
32179
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
1 |
/* |
36508 | 2 |
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. |
32179
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
4 |
* |
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
8 |
* |
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
13 |
* accompanied this code). |
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
14 |
* |
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
18 |
* |
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
21 |
* questions. |
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
22 |
*/ |
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
23 |
|
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
24 |
/* |
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
25 |
* @test |
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
26 |
* @summary Check to make sure that shared strings in the bootstrap CDS archive |
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
27 |
* are actually shared |
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
28 |
* Feature support: G1GC only, compressed oops/kptrs, 64-bit os, not on windows |
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
29 |
* @requires (sun.arch.data.model != "32") & (os.family != "windows") |
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
30 |
* @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true) |
39414
4adf52148100
8160088: update hotspot tests depending on GC to use @requires vm.gc.X
dfazunen
parents:
38008
diff
changeset
|
31 |
* @requires vm.gc.G1 |
33730
30e064828045
8140189: [TESTBUG] Get rid of "@library /../../test/lib" in jtreg tests
cjplummer
parents:
32615
diff
changeset
|
32 |
* @library /testlibrary /test/lib |
36851 | 33 |
* @modules java.base/jdk.internal.misc |
32179
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
34 |
* java.management |
37263
08dec586ed5c
8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents:
36508
diff
changeset
|
35 |
* @build SharedStringsWb SharedStrings ClassFileInstaller sun.hotspot.WhiteBox |
08dec586ed5c
8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents:
36508
diff
changeset
|
36 |
* @run main ClassFileInstaller -jar whitebox.jar sun.hotspot.WhiteBox |
32179
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
37 |
* @run main SharedStrings |
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
38 |
*/ |
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
39 |
import jdk.test.lib.*; |
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
40 |
|
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
41 |
public class SharedStrings { |
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
42 |
public static void main(String[] args) throws Exception { |
38008
58732890050d
8154457: runtime/SharedArchiveFile/SharedStrings Shared string table stats missing
jiangli
parents:
37297
diff
changeset
|
43 |
boolean test_runtime = true; |
32179
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
44 |
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( |
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
45 |
"-XX:+UnlockDiagnosticVMOptions", |
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
46 |
"-XX:SharedArchiveFile=./SharedStrings.jsa", |
38008
58732890050d
8154457: runtime/SharedArchiveFile/SharedStrings Shared string table stats missing
jiangli
parents:
37297
diff
changeset
|
47 |
"-XX:+UseG1GC", |
58732890050d
8154457: runtime/SharedArchiveFile/SharedStrings Shared string table stats missing
jiangli
parents:
37297
diff
changeset
|
48 |
"-XX:+UseCompressedOops", |
32179
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
49 |
"-XX:+PrintSharedSpaces", |
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
50 |
// Needed for bootclasspath match, for CDS to work with WhiteBox API |
37263
08dec586ed5c
8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents:
36508
diff
changeset
|
51 |
"-Xbootclasspath/a:" + ClassFileInstaller.getJarPath("whitebox.jar"), |
32179
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
52 |
"-Xshare:dump"); |
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
53 |
|
38008
58732890050d
8154457: runtime/SharedArchiveFile/SharedStrings Shared string table stats missing
jiangli
parents:
37297
diff
changeset
|
54 |
OutputAnalyzer dumpOutput = new OutputAnalyzer(pb.start()); |
58732890050d
8154457: runtime/SharedArchiveFile/SharedStrings Shared string table stats missing
jiangli
parents:
37297
diff
changeset
|
55 |
try { |
58732890050d
8154457: runtime/SharedArchiveFile/SharedStrings Shared string table stats missing
jiangli
parents:
37297
diff
changeset
|
56 |
dumpOutput.shouldContain("Loading classes to share"); |
58732890050d
8154457: runtime/SharedArchiveFile/SharedStrings Shared string table stats missing
jiangli
parents:
37297
diff
changeset
|
57 |
dumpOutput.shouldContain("Shared string table stats"); |
58732890050d
8154457: runtime/SharedArchiveFile/SharedStrings Shared string table stats missing
jiangli
parents:
37297
diff
changeset
|
58 |
dumpOutput.shouldHaveExitValue(0); |
58732890050d
8154457: runtime/SharedArchiveFile/SharedStrings Shared string table stats missing
jiangli
parents:
37297
diff
changeset
|
59 |
} catch (RuntimeException e) { |
58732890050d
8154457: runtime/SharedArchiveFile/SharedStrings Shared string table stats missing
jiangli
parents:
37297
diff
changeset
|
60 |
if (dumpOutput.getOutput().indexOf("Shared strings are excluded") != -1 || |
58732890050d
8154457: runtime/SharedArchiveFile/SharedStrings Shared string table stats missing
jiangli
parents:
37297
diff
changeset
|
61 |
dumpOutput.getOutput().indexOf("Cannot dump shared archive") != -1) { |
58732890050d
8154457: runtime/SharedArchiveFile/SharedStrings Shared string table stats missing
jiangli
parents:
37297
diff
changeset
|
62 |
test_runtime = false; |
58732890050d
8154457: runtime/SharedArchiveFile/SharedStrings Shared string table stats missing
jiangli
parents:
37297
diff
changeset
|
63 |
} else { |
58732890050d
8154457: runtime/SharedArchiveFile/SharedStrings Shared string table stats missing
jiangli
parents:
37297
diff
changeset
|
64 |
throw new RuntimeException("Unexpected failure"); |
58732890050d
8154457: runtime/SharedArchiveFile/SharedStrings Shared string table stats missing
jiangli
parents:
37297
diff
changeset
|
65 |
} |
58732890050d
8154457: runtime/SharedArchiveFile/SharedStrings Shared string table stats missing
jiangli
parents:
37297
diff
changeset
|
66 |
} |
32179
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
67 |
|
38008
58732890050d
8154457: runtime/SharedArchiveFile/SharedStrings Shared string table stats missing
jiangli
parents:
37297
diff
changeset
|
68 |
if (test_runtime) { |
58732890050d
8154457: runtime/SharedArchiveFile/SharedStrings Shared string table stats missing
jiangli
parents:
37297
diff
changeset
|
69 |
pb = ProcessTools.createJavaProcessBuilder( |
58732890050d
8154457: runtime/SharedArchiveFile/SharedStrings Shared string table stats missing
jiangli
parents:
37297
diff
changeset
|
70 |
"-XX:+UnlockDiagnosticVMOptions", |
58732890050d
8154457: runtime/SharedArchiveFile/SharedStrings Shared string table stats missing
jiangli
parents:
37297
diff
changeset
|
71 |
"-XX:SharedArchiveFile=./SharedStrings.jsa", |
58732890050d
8154457: runtime/SharedArchiveFile/SharedStrings Shared string table stats missing
jiangli
parents:
37297
diff
changeset
|
72 |
// these are required modes for shared strings |
58732890050d
8154457: runtime/SharedArchiveFile/SharedStrings Shared string table stats missing
jiangli
parents:
37297
diff
changeset
|
73 |
"-XX:+UseCompressedOops", "-XX:+UseG1GC", |
58732890050d
8154457: runtime/SharedArchiveFile/SharedStrings Shared string table stats missing
jiangli
parents:
37297
diff
changeset
|
74 |
// needed for access to white box test API |
58732890050d
8154457: runtime/SharedArchiveFile/SharedStrings Shared string table stats missing
jiangli
parents:
37297
diff
changeset
|
75 |
"-Xbootclasspath/a:" + ClassFileInstaller.getJarPath("whitebox.jar"), |
58732890050d
8154457: runtime/SharedArchiveFile/SharedStrings Shared string table stats missing
jiangli
parents:
37297
diff
changeset
|
76 |
"-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", |
58732890050d
8154457: runtime/SharedArchiveFile/SharedStrings Shared string table stats missing
jiangli
parents:
37297
diff
changeset
|
77 |
"-Xshare:on", "-showversion", "SharedStringsWb"); |
32179
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
78 |
|
38008
58732890050d
8154457: runtime/SharedArchiveFile/SharedStrings Shared string table stats missing
jiangli
parents:
37297
diff
changeset
|
79 |
OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
32179
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
80 |
|
38008
58732890050d
8154457: runtime/SharedArchiveFile/SharedStrings Shared string table stats missing
jiangli
parents:
37297
diff
changeset
|
81 |
try { |
58732890050d
8154457: runtime/SharedArchiveFile/SharedStrings Shared string table stats missing
jiangli
parents:
37297
diff
changeset
|
82 |
output.shouldContain("sharing"); |
58732890050d
8154457: runtime/SharedArchiveFile/SharedStrings Shared string table stats missing
jiangli
parents:
37297
diff
changeset
|
83 |
output.shouldHaveExitValue(0); |
58732890050d
8154457: runtime/SharedArchiveFile/SharedStrings Shared string table stats missing
jiangli
parents:
37297
diff
changeset
|
84 |
} catch (RuntimeException e) { |
58732890050d
8154457: runtime/SharedArchiveFile/SharedStrings Shared string table stats missing
jiangli
parents:
37297
diff
changeset
|
85 |
output.shouldContain("Unable to use shared archive"); |
58732890050d
8154457: runtime/SharedArchiveFile/SharedStrings Shared string table stats missing
jiangli
parents:
37297
diff
changeset
|
86 |
output.shouldHaveExitValue(1); |
58732890050d
8154457: runtime/SharedArchiveFile/SharedStrings Shared string table stats missing
jiangli
parents:
37297
diff
changeset
|
87 |
} |
32179
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
88 |
} |
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
89 |
} |
246b2ef581b2
8132214: [TESTBUG] Create basic shared strings test for CDS archive
mseledtsov
parents:
diff
changeset
|
90 |
} |