author | kbarrett |
Mon, 08 Jul 2019 17:24:21 -0400 | |
changeset 55610 | 47fdb5b0fa41 |
parent 53523 | 4c5184c56dc2 |
permissions | -rw-r--r-- |
35458 | 1 |
/* |
53523
4c5184c56dc2
8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. |
41705
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
4 |
* |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
7 |
* published by the Free Software Foundation. |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
8 |
* |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
13 |
* accompanied this code). |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
14 |
* |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
18 |
* |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
21 |
* questions. |
332239c052cc
8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents:
40631
diff
changeset
|
22 |
*/ |
35458 | 23 |
|
53523
4c5184c56dc2
8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents:
47216
diff
changeset
|
24 |
package gc.arguments; |
4c5184c56dc2
8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents:
47216
diff
changeset
|
25 |
|
35458 | 26 |
/* |
27 |
* @test TestNewSizeThreadIncrease |
|
28 |
* @key gc |
|
29 |
* @bug 8144527 |
|
30 |
* @summary Tests argument processing for NewSizeThreadIncrease |
|
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
39414
diff
changeset
|
31 |
* @library /test/lib |
55610
47fdb5b0fa41
8217170: gc/arguments/TestUseCompressedOopsErgo.java timed out
kbarrett
parents:
53523
diff
changeset
|
32 |
* @library / |
39414
4adf52148100
8160088: update hotspot tests depending on GC to use @requires vm.gc.X
dfazunen
parents:
36851
diff
changeset
|
33 |
* @requires vm.gc.Serial |
36851 | 34 |
* @modules java.base/jdk.internal.misc |
35458 | 35 |
* java.management |
53523
4c5184c56dc2
8214799: Add package declaration to each JTREG test case in the gc folder
lkorinth
parents:
47216
diff
changeset
|
36 |
* @run main gc.arguments.TestNewSizeThreadIncrease |
35458 | 37 |
*/ |
38 |
||
39 |
||
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
39414
diff
changeset
|
40 |
import jdk.test.lib.Platform; |
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
39414
diff
changeset
|
41 |
import jdk.test.lib.process.OutputAnalyzer; |
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
39414
diff
changeset
|
42 |
import jdk.test.lib.process.ProcessTools; |
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
39414
diff
changeset
|
43 |
|
35458 | 44 |
|
45 |
// Range of NewSizeThreadIncrease is 0 ~ max_uintx. |
|
46 |
// Total of 5 threads will be created (1 GCTest thread and 4 TestThread). |
|
47 |
public class TestNewSizeThreadIncrease { |
|
48 |
static final String VALID_VALUE = "2097152"; // 2MB |
|
49 |
||
50 |
// This value will make an overflow of 'thread count * NewSizeThreadIncrease' at DefNewGeneration::compute_new_size(). |
|
51 |
// = (max_uintx / 5) + 1, = (18446744073709551615 / 5) + 1 |
|
52 |
static String INVALID_VALUE_1 = "3689348814741910324"; |
|
53 |
||
54 |
// This string is contained when compute_new_size() expands or shrinks. |
|
55 |
static final String LOG_NEWSIZE_CHANGED = "New generation size "; |
|
56 |
||
57 |
public static void main(String[] args) throws Exception { |
|
58 |
if (Platform.is32bit()) { |
|
59 |
// (max_uintx / 5) + 1, 4294967295/5 + 1 |
|
60 |
INVALID_VALUE_1 = "858993460"; |
|
61 |
} |
|
62 |
||
63 |
// New size will be applied as NewSizeThreadIncrease is small enough to expand. |
|
64 |
runNewSizeThreadIncreaseTest(VALID_VALUE, true); |
|
65 |
||
66 |
// New size will be ignored as 'thread count * NewSizeThreadIncrease' overflows. |
|
67 |
runNewSizeThreadIncreaseTest(INVALID_VALUE_1, false); |
|
68 |
} |
|
69 |
||
70 |
static void runNewSizeThreadIncreaseTest(String expectedValue, boolean isNewsizeChanged) throws Exception { |
|
55610
47fdb5b0fa41
8217170: gc/arguments/TestUseCompressedOopsErgo.java timed out
kbarrett
parents:
53523
diff
changeset
|
71 |
ProcessBuilder pb = GCArguments.createJavaProcessBuilder("-XX:+UseSerialGC", |
47fdb5b0fa41
8217170: gc/arguments/TestUseCompressedOopsErgo.java timed out
kbarrett
parents:
53523
diff
changeset
|
72 |
"-Xms96M", |
47fdb5b0fa41
8217170: gc/arguments/TestUseCompressedOopsErgo.java timed out
kbarrett
parents:
53523
diff
changeset
|
73 |
"-Xmx128M", |
47fdb5b0fa41
8217170: gc/arguments/TestUseCompressedOopsErgo.java timed out
kbarrett
parents:
53523
diff
changeset
|
74 |
"-XX:NewRatio=2", |
47fdb5b0fa41
8217170: gc/arguments/TestUseCompressedOopsErgo.java timed out
kbarrett
parents:
53523
diff
changeset
|
75 |
"-Xlog:gc+heap+ergo=debug", |
47fdb5b0fa41
8217170: gc/arguments/TestUseCompressedOopsErgo.java timed out
kbarrett
parents:
53523
diff
changeset
|
76 |
"-XX:NewSizeThreadIncrease="+expectedValue, |
47fdb5b0fa41
8217170: gc/arguments/TestUseCompressedOopsErgo.java timed out
kbarrett
parents:
53523
diff
changeset
|
77 |
GCTest.class.getName()); |
35458 | 78 |
OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
79 |
||
80 |
output.shouldHaveExitValue(0); |
|
81 |
||
82 |
if (isNewsizeChanged) { |
|
83 |
output.shouldContain(LOG_NEWSIZE_CHANGED); |
|
84 |
} else { |
|
85 |
output.shouldNotContain(LOG_NEWSIZE_CHANGED); |
|
86 |
} |
|
87 |
} |
|
88 |
||
89 |
static class GCTest { |
|
90 |
||
91 |
static final int MAX_THREADS_COUNT = 4; |
|
92 |
static TestThread threads[] = new TestThread[MAX_THREADS_COUNT]; |
|
93 |
||
94 |
public static void main(String[] args) { |
|
95 |
||
96 |
System.out.println("Creating garbage"); |
|
97 |
||
98 |
for (int i=0; i<MAX_THREADS_COUNT; i++) { |
|
99 |
threads[i] = new TestThread(); |
|
100 |
threads[i].start(); |
|
101 |
} |
|
102 |
||
103 |
System.gc(); |
|
104 |
||
105 |
for (int i=0; i<MAX_THREADS_COUNT; i++) { |
|
106 |
threads[i].stopRunning(); |
|
107 |
} |
|
108 |
||
109 |
System.out.println("Done"); |
|
110 |
} |
|
111 |
||
112 |
private static class TestThread extends Thread { |
|
113 |
||
114 |
volatile boolean isRunning = true; |
|
115 |
||
116 |
public void run() { |
|
117 |
while (isRunning == true) { |
|
118 |
try { |
|
119 |
Thread.sleep(10); |
|
120 |
} catch (Throwable t) { |
|
121 |
} |
|
122 |
} |
|
123 |
} |
|
124 |
||
125 |
public void stopRunning() { |
|
126 |
isRunning = false; |
|
127 |
} |
|
128 |
} |
|
129 |
} |
|
130 |
} |