116 |
|
Boolean.getBoolean("jsr166.expensiveTests"); |
117 |
|
|
118 |
|
/** |
119 |
+ |
* If true, also run tests that are not part of the official tck |
120 |
+ |
* because they test unspecified implementation details. |
121 |
+ |
*/ |
122 |
+ |
protected static final boolean testImplementationDetails = |
123 |
+ |
Boolean.getBoolean("jsr166.testImplementationDetails"); |
124 |
+ |
|
125 |
+ |
/** |
126 |
|
* If true, report on stdout all "slow" tests, that is, ones that |
127 |
|
* take more than profileThreshold milliseconds to execute. |
128 |
|
*/ |
167 |
|
} |
168 |
|
|
169 |
|
protected void runTestProfiled() throws Throwable { |
170 |
+ |
// Warmup run, notably to trigger all needed classloading. |
171 |
+ |
super.runTest(); |
172 |
|
long t0 = System.nanoTime(); |
173 |
|
try { |
174 |
|
super.runTest(); |
175 |
|
} finally { |
176 |
< |
long elapsedMillis = |
168 |
< |
(System.nanoTime() - t0) / (1000L * 1000L); |
176 |
> |
long elapsedMillis = millisElapsedSince(t0); |
177 |
|
if (elapsedMillis >= profileThreshold) |
178 |
|
System.out.printf("%n%s: %d%n", toString(), elapsedMillis); |
179 |
|
} |
229 |
|
} |
230 |
|
|
231 |
|
public static final double JAVA_CLASS_VERSION; |
232 |
+ |
public static final String JAVA_SPECIFICATION_VERSION; |
233 |
|
static { |
234 |
|
try { |
235 |
|
JAVA_CLASS_VERSION = java.security.AccessController.doPrivileged( |
236 |
|
new java.security.PrivilegedAction<Double>() { |
237 |
|
public Double run() { |
238 |
|
return Double.valueOf(System.getProperty("java.class.version"));}}); |
239 |
+ |
JAVA_SPECIFICATION_VERSION = java.security.AccessController.doPrivileged( |
240 |
+ |
new java.security.PrivilegedAction<String>() { |
241 |
+ |
public String run() { |
242 |
+ |
return System.getProperty("java.specification.version");}}); |
243 |
|
} catch (Throwable t) { |
244 |
|
throw new Error(t); |
245 |
|
} |
248 |
|
public static boolean atLeastJava6() { return JAVA_CLASS_VERSION >= 50.0; } |
249 |
|
public static boolean atLeastJava7() { return JAVA_CLASS_VERSION >= 51.0; } |
250 |
|
public static boolean atLeastJava8() { return JAVA_CLASS_VERSION >= 52.0; } |
251 |
+ |
public static boolean atLeastJava9() { |
252 |
+ |
// As of 2014-05, java9 still uses 52.0 class file version |
253 |
+ |
return JAVA_SPECIFICATION_VERSION.startsWith("1.9"); |
254 |
+ |
} |
255 |
|
|
256 |
|
/** |
257 |
|
* Collects all JSR166 unit tests as one suite. |
344 |
|
addNamedTestClasses(suite, java8TestClassNames); |
345 |
|
} |
346 |
|
|
347 |
+ |
// Java9+ test classes |
348 |
+ |
if (atLeastJava9()) { |
349 |
+ |
String[] java9TestClassNames = { |
350 |
+ |
"ThreadPoolExecutor9Test", |
351 |
+ |
}; |
352 |
+ |
addNamedTestClasses(suite, java9TestClassNames); |
353 |
+ |
} |
354 |
+ |
|
355 |
|
return suite; |
356 |
|
} |
357 |
|
|
909 |
|
* startNanoTime, which must have been previously returned from a |
910 |
|
* call to {@link System.nanoTime()}. |
911 |
|
*/ |
912 |
< |
long millisElapsedSince(long startNanoTime) { |
912 |
> |
static long millisElapsedSince(long startNanoTime) { |
913 |
|
return NANOSECONDS.toMillis(System.nanoTime() - startNanoTime); |
914 |
|
} |
915 |
|
|