Skip to content

Commit e8d9f75

Browse files
authored
Merge branch 'master' into syq-fix
2 parents ac9d13f + f56d9c1 commit e8d9f75

7 files changed

Lines changed: 106 additions & 51 deletions

File tree

test/hotspot/jtreg/vmTestbase/ExecDriver.java

Lines changed: 53 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -21,16 +21,16 @@
2121
* questions.
2222
*/
2323

24-
import jdk.test.lib.Platform;
25-
import jdk.test.lib.Utils;
26-
2724
import java.io.File;
2825
import java.io.IOException;
2926
import java.io.InputStream;
3027
import java.io.OutputStream;
3128
import java.nio.file.Path;
3229
import java.nio.file.Paths;
30+
import java.util.ArrayList;
3331
import java.util.Arrays;
32+
import java.util.Collections;
33+
import java.util.List;
3434

3535
/**
3636
* Starts a new process to execute a command.
@@ -48,6 +48,10 @@
4848
* {@code --java}, i.e. 0 or 95 means pass.
4949
*/
5050
public class ExecDriver {
51+
// copied from jdk.test.lib.Utils.TEST_CLASS_PATH
52+
private static final String TEST_CLASS_PATH = System.getProperty("test.class.path", ".");
53+
// copied from jdk.test.lib.Utils.TEST_CLASS_PATH
54+
private static final String TEST_JDK = System.getProperty("test.jdk");
5155
public static void main(String[] args) throws IOException, InterruptedException {
5256
boolean java = false;
5357
boolean launcher = false;
@@ -68,7 +72,7 @@ public static void main(String[] args) throws IOException, InterruptedException
6872
}
6973
args[0] = javaBin();
7074
args[1] = "-cp";
71-
args[2] = Utils.TEST_CLASS_PATH;
75+
args[2] = TEST_CLASS_PATH;
7276
System.arraycopy(oldArgs, 1, args, count, oldArgs.length - 1);
7377
java = true;
7478
break;
@@ -84,7 +88,7 @@ public static void main(String[] args) throws IOException, InterruptedException
8488
// adding 'test.vm.opts' and 'test.java.opts'
8589
if (java) {
8690
String[] oldArgs = args;
87-
String[] testJavaOpts = Utils.getTestJavaOpts();
91+
String[] testJavaOpts = getTestJavaOpts();
8892
if (testJavaOpts.length > 0) {
8993
args = new String[args.length + testJavaOpts.length];
9094
// bin/java goes before options
@@ -101,10 +105,11 @@ public static void main(String[] args) throws IOException, InterruptedException
101105
ProcessBuilder pb = new ProcessBuilder(args);
102106
// adding jvm.so to library path
103107
if (launcher) {
104-
Path dir = Paths.get(Utils.TEST_JDK);
108+
Path dir = Paths.get(TEST_JDK);
105109
String value;
106-
String name = Platform.sharedLibraryPathVariableName();
107-
if (Platform.isWindows()) {
110+
String name = sharedLibraryPathVariableName();
111+
// if (jdk.test.lib.Platform.isWindows()) {
112+
if (System.getProperty("os.name").toLowerCase().startsWith("win")) {
108113
value = dir.resolve("bin")
109114
.resolve(variant())
110115
.toAbsolutePath()
@@ -125,7 +130,7 @@ public static void main(String[] args) throws IOException, InterruptedException
125130
.merge(name, value, (x, y) -> y + File.pathSeparator + x));
126131
System.out.println(" with CLASSPATH = " +
127132
pb.environment()
128-
.put("CLASSPATH", Utils.TEST_CLASS_PATH));
133+
.put("CLASSPATH", TEST_CLASS_PATH));
129134
}
130135
Process p = pb.start();
131136
// inheritIO does not work as expected for @run driver
@@ -138,19 +143,52 @@ public static void main(String[] args) throws IOException, InterruptedException
138143
}
139144
}
140145

146+
// copied from jdk.test.lib.Platform::sharedLibraryPathVariableName
147+
private static String sharedLibraryPathVariableName() {
148+
String osName = System.getProperty("os.name").toLowerCase();
149+
if (osName.startsWith("win")) {
150+
return "PATH";
151+
} else if (osName.startsWith("mac")) {
152+
return "DYLD_LIBRARY_PATH";
153+
} else if (osName.startsWith("aix")) {
154+
return "LIBPATH";
155+
} else {
156+
return "LD_LIBRARY_PATH";
157+
}
158+
}
159+
160+
// copied from jdk.test.lib.Utils::getTestJavaOpts()
161+
private static String[] getTestJavaOpts() {
162+
List<String> opts = new ArrayList<String>();
163+
{
164+
String v = System.getProperty("test.vm.opts", "").trim();
165+
if (!v.isEmpty()) {
166+
Collections.addAll(opts, v.split("\\s+"));
167+
}
168+
}
169+
{
170+
String v = System.getProperty("test.java.opts", "").trim();
171+
if (!v.isEmpty()) {
172+
Collections.addAll(opts, v.split("\\s+"));
173+
}
174+
}
175+
return opts.toArray(new String[0]);
176+
}
177+
178+
// copied jdk.test.lib.Platform::variant
141179
private static String variant() {
142-
if (Platform.isServer()) {
180+
String vmName = System.getProperty("java.vm.name");
181+
if (vmName.endsWith(" Server VM")) {
143182
return "server";
144-
} else if (Platform.isClient()) {
183+
} else if (vmName.endsWith(" Client VM")) {
145184
return "client";
146-
} else if (Platform.isMinimal()) {
185+
} else if (vmName.endsWith(" Minimal VM")) {
147186
return "minimal";
148187
} else {
149188
throw new Error("TESTBUG: unsuppported vm variant");
150189
}
151190
}
152191

153-
154192
private static void copy(InputStream is, OutputStream os) {
155193
byte[] buffer = new byte[1024];
156194
int n;
@@ -165,7 +203,7 @@ private static void copy(InputStream is, OutputStream os) {
165203
}
166204

167205
private static String javaBin() {
168-
return Paths.get(Utils.TEST_JDK)
206+
return Paths.get(TEST_JDK)
169207
.resolve("bin")
170208
.resolve("java")
171209
.toAbsolutePath()

test/hotspot/jtreg/vmTestbase/nsk/share/gc/NonbranchyTree.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
2727
import java.util.*;
2828

2929
import nsk.share.test.ExecutionController;
30+
import nsk.share.test.LocalRandom;
3031

3132
/**
3233
* <tt>NonbranchyTree</tt> defines a tree structure. Each node of the tree
@@ -38,7 +39,6 @@ public class NonbranchyTree {
3839
/** Minimal size of each node (in bytes) */
3940
public final static int MIN_NODE_SIZE = 20;
4041
private Node root;
41-
private Random random;
4242
private int numberOfNodes;
4343
private float branchiness;
4444
private int size;
@@ -61,21 +61,16 @@ public class NonbranchyTree {
6161
*
6262
*/
6363
public NonbranchyTree(int numberOfNodes, float branchiness, int size) {
64-
this(numberOfNodes, branchiness, size, new Random(System.currentTimeMillis()), null);
64+
this(numberOfNodes, branchiness, size, null);
6565
initTree();
6666
}
6767

6868
public NonbranchyTree(int numberOfNodes, float branchiness, int size, ExecutionController controller) {
69-
this(numberOfNodes, branchiness, size, new Random(System.currentTimeMillis()), controller);
70-
initTree();
71-
}
72-
73-
private NonbranchyTree(int numberOfNodes, float branchiness, int size, Random random, ExecutionController controller) {
7469
this.numberOfNodes = numberOfNodes;
7570
this.branchiness = branchiness;
7671
this.size = size;
77-
this.random = random;
7872
this.controller = controller;
73+
initTree();
7974
}
8075

8176
private void initTree() {
@@ -94,6 +89,8 @@ private void initTree() {
9489
throw new IllegalArgumentException("Illegal size of nodes: "
9590
+ size + ", must be at least 1.");
9691
}
92+
// ensure that LocalRandom is loaded and has enough memory
93+
LocalRandom.nextBoolean();
9794
root = createTree(numberOfNodes, size);
9895
}
9996

@@ -119,7 +116,7 @@ private Node createTree(int numberOfNodes, int size) {
119116
// Create a few nodes
120117
if (makeRightNode()) {
121118
// The node will have two sons
122-
int leftNodes = 1 + random.nextInt(numberOfNodes - 2);
119+
int leftNodes = 1 + LocalRandom.nextInt(numberOfNodes - 2);
123120
int rightNodes = numberOfNodes - 1 - leftNodes;
124121

125122
node.left = createTree(leftNodes, size);
@@ -142,7 +139,7 @@ private Node createTree(int numberOfNodes, int size) {
142139

143140
// Define the "branchiness" of the tree
144141
private boolean makeRightNode() {
145-
return (random.nextFloat() < branchiness);
142+
return (LocalRandom.nextFloat() < branchiness);
146143
}
147144

148145
/**

test/hotspot/jtreg/vmTestbase/nsk/share/jdi/SerialExecutionDebugger.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
2727
import nsk.share.jpda.AbstractDebuggeeTest;
2828
import java.io.*;
2929
import java.util.*;
30+
import jdk.test.lib.Utils;
3031

3132
/*
3233
* This class serial executes several JDI tests based on nsk.share.jdi.TestDebuggerType2 in single VM
@@ -192,7 +193,7 @@ else if (arguments[i].equalsIgnoreCase("iterations") && (i < (arguments.length -
192193
if (testWorkDir == null)
193194
throw new TestBug("Debugger requires -testWorkDir parameter");
194195

195-
Collections.shuffle(result);
196+
Collections.shuffle(result, Utils.getRandomInstance());
196197

197198
// save resulted tests sequence in file (to simplify reproducing)
198199
try {

test/hotspot/jtreg/vmTestbase/nsk/share/runner/RunParams.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -26,13 +26,13 @@
2626
import nsk.share.log.Log;
2727
import nsk.share.test.StressOptions;
2828
import java.io.PrintStream;
29+
import jdk.test.lib.Utils;
2930

3031
public class RunParams {
3132
private StressOptions stressOptions;
3233
private long sleepTime = 500;
3334
private long iterations = 0;
3435
private int numberOfThreads;
35-
private long seed = System.currentTimeMillis();
3636
private boolean runGCThread = false;
3737
private boolean runFinThread = false;
3838
private boolean runMemDiagThread = false;
@@ -126,11 +126,9 @@ public final void setNumberOfThreads(int numberOfThreads) {
126126
}
127127

128128
public final long getSeed() {
129-
return seed;
130-
}
131-
132-
public final void setSeed(long seed) {
133-
this.seed = seed;
129+
// ensure that seed got printed out
130+
Utils.getRandomInstance();
131+
return Utils.SEED;
134132
}
135133

136134
public final boolean isRunGCThread() {
@@ -212,8 +210,6 @@ else if (args[i].equals("-Df1"))
212210
runFinDiagThread = true;
213211
else if (args[i].equals("-Df"))
214212
runFinDiagThread = true;
215-
else if (args[i].equals("-s"))
216-
seed = Long.parseLong(args[++i]);
217213
else if (args[i].equals("-t"))
218214
numberOfThreads = Integer.parseInt(args[++i]);
219215
else if (args[i].equals("-it"))
@@ -233,7 +229,6 @@ public void printConfig(PrintStream out) {
233229
out.println("Sleep time: " + sleepTime);
234230
out.println("Iterations: " + iterations);
235231
out.println("Number of threads: " + numberOfThreads);
236-
out.println("Seed: " + seed);
237232
out.println("Run GC thread: " + runGCThread);
238233
out.println("Run mem diag thread: " + runMemDiagThread);
239234
out.println("Run forever: " + runForever);
@@ -244,7 +239,6 @@ public void logConfig(Log log) {
244239
log.debug("Sleep time: " + sleepTime);
245240
log.debug("Iterations: " + iterations);
246241
log.debug("Number of threads: " + numberOfThreads);
247-
log.debug("Seed: " + seed);
248242
log.debug("Run GC thread: " + runGCThread);
249243
log.debug("Run mem diag thread: " + runMemDiagThread);
250244
log.debug("Run forever: " + runForever);

0 commit comments

Comments
 (0)