--- jsr166/src/test/tck/JSR166TestCase.java 2016/01/23 20:15:28 1.183 +++ jsr166/src/test/tck/JSR166TestCase.java 2016/02/22 19:36:59 1.185 @@ -9,6 +9,7 @@ /* * @test * @summary JSR-166 tck tests + * @modules java.management * @build * * @run junit/othervm/timeout=1000 -Djsr166.testImplementationDetails=true JSR166TestCase */ @@ -60,6 +61,7 @@ import java.util.concurrent.Semaphore; import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeoutException; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -182,11 +184,31 @@ public class JSR166TestCase extends Test private static final int suiteRuns = Integer.getInteger("jsr166.suiteRuns", 1); + private static float systemPropertyValue(String name, float defaultValue) { + String floatString = System.getProperty(name); + if (floatString == null) + return defaultValue; + try { + return Float.parseFloat(floatString); + } catch (NumberFormatException ex) { + throw new IllegalArgumentException( + String.format("Bad float value in system property %s=%s", + name, floatString)); + } + } + /** * The scaling factor to apply to standard delays used in tests. */ - private static final int delayFactor = - Integer.getInteger("jsr166.delay.factor", 1); + private static final float delayFactor = + systemPropertyValue("jsr166.delay.factor", 1.0f); + + /** + * The timeout factor as used in the jtreg test harness. + * See: http://openjdk.java.net/jtreg/tag-spec.html + */ + private static final float jtregTestTimeoutFactor + = systemPropertyValue("test.timeout.factor", 1.0f); public JSR166TestCase() { super(); } public JSR166TestCase(String name) { super(name); } @@ -562,10 +584,12 @@ public class JSR166TestCase extends Test /** * Returns the shortest timed delay. This can be scaled up for - * slow machines using the jsr166.delay.factor system property. + * slow machines using the jsr166.delay.factor system property, + * or via jtreg's -timeoutFactor: flag. + * http://openjdk.java.net/jtreg/command-help.html */ protected long getShortDelay() { - return 50 * delayFactor; + return (long) (50 * delayFactor * jtregTestTimeoutFactor); } /** @@ -878,6 +902,14 @@ public class JSR166TestCase extends Test }}; } + PoolCleaner cleaner(ExecutorService pool, AtomicBoolean flag) { + return new PoolCleanerWithReleaser(pool, releaser(flag)); + } + + Runnable releaser(final AtomicBoolean flag) { + return new Runnable() { public void run() { flag.set(true); }}; + } + /** * Waits out termination of a thread pool or fails doing so. */