115 |
|
protected static final boolean expensiveTests = |
116 |
|
Boolean.getBoolean("jsr166.expensiveTests"); |
117 |
|
|
118 |
+ |
protected static final boolean testImplementationDetails = |
119 |
+ |
Boolean.getBoolean("jsr166.testImplementationDetails"); |
120 |
+ |
|
121 |
|
/** |
122 |
|
* If true, report on stdout all "slow" tests, that is, ones that |
123 |
|
* take more than profileThreshold milliseconds to execute. |
163 |
|
} |
164 |
|
|
165 |
|
protected void runTestProfiled() throws Throwable { |
166 |
+ |
// Warmup run, notably to trigger all needed classloading. |
167 |
+ |
super.runTest(); |
168 |
|
long t0 = System.nanoTime(); |
169 |
|
try { |
170 |
|
super.runTest(); |
171 |
|
} finally { |
172 |
< |
long elapsedMillis = |
168 |
< |
(System.nanoTime() - t0) / (1000L * 1000L); |
172 |
> |
long elapsedMillis = millisElapsedSince(t0); |
173 |
|
if (elapsedMillis >= profileThreshold) |
174 |
|
System.out.printf("%n%s: %d%n", toString(), elapsedMillis); |
175 |
|
} |
225 |
|
} |
226 |
|
|
227 |
|
public static final double JAVA_CLASS_VERSION; |
228 |
+ |
public static final String JAVA_SPECIFICATION_VERSION; |
229 |
|
static { |
230 |
|
try { |
231 |
|
JAVA_CLASS_VERSION = java.security.AccessController.doPrivileged( |
232 |
|
new java.security.PrivilegedAction<Double>() { |
233 |
|
public Double run() { |
234 |
|
return Double.valueOf(System.getProperty("java.class.version"));}}); |
235 |
+ |
JAVA_SPECIFICATION_VERSION = java.security.AccessController.doPrivileged( |
236 |
+ |
new java.security.PrivilegedAction<String>() { |
237 |
+ |
public String run() { |
238 |
+ |
return System.getProperty("java.specification.version");}}); |
239 |
|
} catch (Throwable t) { |
240 |
|
throw new Error(t); |
241 |
|
} |
244 |
|
public static boolean atLeastJava6() { return JAVA_CLASS_VERSION >= 50.0; } |
245 |
|
public static boolean atLeastJava7() { return JAVA_CLASS_VERSION >= 51.0; } |
246 |
|
public static boolean atLeastJava8() { return JAVA_CLASS_VERSION >= 52.0; } |
247 |
+ |
public static boolean atLeastJava9() { |
248 |
+ |
// As of 2014-05, java9 still uses 52.0 class file version |
249 |
+ |
return JAVA_SPECIFICATION_VERSION.startsWith("1.9"); |
250 |
+ |
} |
251 |
|
|
252 |
|
/** |
253 |
|
* Collects all JSR166 unit tests as one suite. |
340 |
|
addNamedTestClasses(suite, java8TestClassNames); |
341 |
|
} |
342 |
|
|
343 |
+ |
// Java9+ test classes |
344 |
+ |
if (atLeastJava9()) { |
345 |
+ |
String[] java9TestClassNames = { |
346 |
+ |
"ThreadPoolExecutor9Test", |
347 |
+ |
}; |
348 |
+ |
addNamedTestClasses(suite, java9TestClassNames); |
349 |
+ |
} |
350 |
+ |
|
351 |
|
return suite; |
352 |
|
} |
353 |
|
|
905 |
|
* startNanoTime, which must have been previously returned from a |
906 |
|
* call to {@link System.nanoTime()}. |
907 |
|
*/ |
908 |
< |
long millisElapsedSince(long startNanoTime) { |
908 |
> |
static long millisElapsedSince(long startNanoTime) { |
909 |
|
return NANOSECONDS.toMillis(System.nanoTime() - startNanoTime); |
910 |
|
} |
911 |
|
|