ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/JSR166TestCase.java
(Generate patch)

Comparing jsr166/src/test/tck/JSR166TestCase.java (file contents):
Revision 1.184 by jsr166, Wed Feb 10 00:05:20 2016 UTC vs.
Revision 1.185 by jsr166, Mon Feb 22 19:36:59 2016 UTC

# Line 61 | Line 61 | import java.util.concurrent.Semaphore;
61   import java.util.concurrent.ThreadFactory;
62   import java.util.concurrent.ThreadPoolExecutor;
63   import java.util.concurrent.TimeoutException;
64 + import java.util.concurrent.atomic.AtomicBoolean;
65   import java.util.concurrent.atomic.AtomicReference;
66   import java.util.regex.Matcher;
67   import java.util.regex.Pattern;
# Line 183 | Line 184 | public class JSR166TestCase extends Test
184      private static final int suiteRuns =
185          Integer.getInteger("jsr166.suiteRuns", 1);
186  
187 +    private static float systemPropertyValue(String name, float defaultValue) {
188 +        String floatString = System.getProperty(name);
189 +        if (floatString == null)
190 +            return defaultValue;
191 +        try {
192 +            return Float.parseFloat(floatString);
193 +        } catch (NumberFormatException ex) {
194 +            throw new IllegalArgumentException(
195 +                String.format("Bad float value in system property %s=%s",
196 +                              name, floatString));
197 +        }
198 +    }
199 +
200      /**
201       * The scaling factor to apply to standard delays used in tests.
202       */
203 <    private static final int delayFactor =
204 <        Integer.getInteger("jsr166.delay.factor", 1);
203 >    private static final float delayFactor =
204 >        systemPropertyValue("jsr166.delay.factor", 1.0f);
205 >    
206 >    /**
207 >     * The timeout factor as used in the jtreg test harness.
208 >     * See: http://openjdk.java.net/jtreg/tag-spec.html
209 >     */
210 >    private static final float jtregTestTimeoutFactor
211 >        = systemPropertyValue("test.timeout.factor", 1.0f);
212  
213      public JSR166TestCase() { super(); }
214      public JSR166TestCase(String name) { super(name); }
# Line 563 | Line 584 | public class JSR166TestCase extends Test
584  
585      /**
586       * Returns the shortest timed delay. This can be scaled up for
587 <     * slow machines using the jsr166.delay.factor system property.
587 >     * slow machines using the jsr166.delay.factor system property,
588 >     * or via jtreg's -timeoutFactor:<val> flag.
589 >     * http://openjdk.java.net/jtreg/command-help.html
590       */
591      protected long getShortDelay() {
592 <        return 50 * delayFactor;
592 >        return (long) (50 * delayFactor * jtregTestTimeoutFactor);
593      }
594  
595      /**
# Line 879 | Line 902 | public class JSR166TestCase extends Test
902          }};
903      }
904  
905 +    PoolCleaner cleaner(ExecutorService pool, AtomicBoolean flag) {
906 +        return new PoolCleanerWithReleaser(pool, releaser(flag));
907 +    }
908 +
909 +    Runnable releaser(final AtomicBoolean flag) {
910 +        return new Runnable() { public void run() { flag.set(true); }};
911 +    }
912 +
913      /**
914       * Waits out termination of a thread pool or fails doing so.
915       */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines