184 |
|
private static final int suiteRuns = |
185 |
|
Integer.getInteger("jsr166.suiteRuns", 1); |
186 |
|
|
187 |
< |
private static float systemPropertyValue(String name, float defaultValue) { |
187 |
> |
/** |
188 |
> |
* Returns the value of the system property, or NaN if not defined. |
189 |
> |
*/ |
190 |
> |
private static float systemPropertyValue(String name) { |
191 |
|
String floatString = System.getProperty(name); |
192 |
|
if (floatString == null) |
193 |
< |
return defaultValue; |
193 |
> |
return Float.NaN; |
194 |
|
try { |
195 |
|
return Float.parseFloat(floatString); |
196 |
|
} catch (NumberFormatException ex) { |
202 |
|
|
203 |
|
/** |
204 |
|
* The scaling factor to apply to standard delays used in tests. |
205 |
< |
*/ |
206 |
< |
private static final float delayFactor = |
207 |
< |
systemPropertyValue("jsr166.delay.factor", 1.0f); |
208 |
< |
|
209 |
< |
/** |
210 |
< |
* The timeout factor as used in the jtreg test harness. |
211 |
< |
* See: http://openjdk.java.net/jtreg/tag-spec.html |
212 |
< |
*/ |
213 |
< |
private static final float jtregTestTimeoutFactor |
214 |
< |
= systemPropertyValue("test.timeout.factor", 1.0f); |
205 |
> |
* May be initialized from any of: |
206 |
> |
* - the "jsr166.delay.factor" system property |
207 |
> |
* - the "test.timeout.factor" system property (as used by jtreg) |
208 |
> |
* See: http://openjdk.java.net/jtreg/tag-spec.html |
209 |
> |
* - hard-coded fuzz factor when using a known slowpoke VM |
210 |
> |
*/ |
211 |
> |
private static final float delayFactor = delayFactor(); |
212 |
> |
|
213 |
> |
private static float delayFactor() { |
214 |
> |
float x; |
215 |
> |
if (!Float.isNaN(x = systemPropertyValue("jsr166.delay.factor"))) |
216 |
> |
return x; |
217 |
> |
if (!Float.isNaN(x = systemPropertyValue("test.timeout.factor"))) |
218 |
> |
return x; |
219 |
> |
String prop = System.getProperty("java.vm.version"); |
220 |
> |
if (prop != null && prop.matches(".*debug.*")) |
221 |
> |
return 4.0f; // How much slower is fastdebug than product?! |
222 |
> |
return 1.0f; |
223 |
> |
} |
224 |
|
|
225 |
|
public JSR166TestCase() { super(); } |
226 |
|
public JSR166TestCase(String name) { super(name); } |
511 |
|
"StampedLockTest", |
512 |
|
"SubmissionPublisherTest", |
513 |
|
"ThreadLocalRandom8Test", |
514 |
+ |
"TimeUnit8Test", |
515 |
|
}; |
516 |
|
addNamedTestClasses(suite, java8TestClassNames); |
517 |
|
} |
598 |
|
/** |
599 |
|
* Returns the shortest timed delay. This can be scaled up for |
600 |
|
* slow machines using the jsr166.delay.factor system property, |
601 |
< |
* or via jtreg's -timeoutFactor:<val> flag. |
601 |
> |
* or via jtreg's -timeoutFactor: flag. |
602 |
|
* http://openjdk.java.net/jtreg/command-help.html |
603 |
|
*/ |
604 |
|
protected long getShortDelay() { |
605 |
< |
return (long) (50 * delayFactor * jtregTestTimeoutFactor); |
605 |
> |
return (long) (50 * delayFactor); |
606 |
|
} |
607 |
|
|
608 |
|
/** |
1479 |
|
return new LatchAwaiter(latch); |
1480 |
|
} |
1481 |
|
|
1482 |
< |
public void await(CountDownLatch latch) { |
1482 |
> |
public void await(CountDownLatch latch, long timeoutMillis) { |
1483 |
|
try { |
1484 |
< |
if (!latch.await(LONG_DELAY_MS, MILLISECONDS)) |
1484 |
> |
if (!latch.await(timeoutMillis, MILLISECONDS)) |
1485 |
|
fail("timed out waiting for CountDownLatch for " |
1486 |
< |
+ (LONG_DELAY_MS/1000) + " sec"); |
1486 |
> |
+ (timeoutMillis/1000) + " sec"); |
1487 |
|
} catch (Throwable fail) { |
1488 |
|
threadUnexpectedException(fail); |
1489 |
|
} |
1490 |
|
} |
1491 |
|
|
1492 |
+ |
public void await(CountDownLatch latch) { |
1493 |
+ |
await(latch, LONG_DELAY_MS); |
1494 |
+ |
} |
1495 |
+ |
|
1496 |
|
public void await(Semaphore semaphore) { |
1497 |
|
try { |
1498 |
|
if (!semaphore.tryAcquire(LONG_DELAY_MS, MILLISECONDS)) |
1833 |
|
} catch (NoSuchElementException success) {} |
1834 |
|
assertFalse(it.hasNext()); |
1835 |
|
} |
1836 |
+ |
|
1837 |
+ |
public <T> Callable<T> callableThrowing(final Exception ex) { |
1838 |
+ |
return new Callable<T>() { public T call() throws Exception { throw ex; }}; |
1839 |
+ |
} |
1840 |
+ |
|
1841 |
+ |
public Runnable runnableThrowing(final RuntimeException ex) { |
1842 |
+ |
return new Runnable() { public void run() { throw ex; }}; |
1843 |
+ |
} |
1844 |
|
} |