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.109 by jsr166, Sun Jul 14 16:55:01 2013 UTC vs.
Revision 1.117 by jsr166, Mon Jun 9 18:17:37 2014 UTC

# Line 26 | Line 26 | import java.util.concurrent.atomic.Atomi
26   import java.util.concurrent.atomic.AtomicReference;
27   import static java.util.concurrent.TimeUnit.MILLISECONDS;
28   import static java.util.concurrent.TimeUnit.NANOSECONDS;
29 + import java.util.regex.Pattern;
30   import java.security.CodeSource;
31   import java.security.Permission;
32   import java.security.PermissionCollection;
# Line 134 | Line 135 | public class JSR166TestCase extends Test
135      private static final int runsPerTest =
136          Integer.getInteger("jsr166.runsPerTest", 1);
137  
138 +    /**
139 +     * A filter for tests to run, matching strings of the form
140 +     * methodName(className), e.g. "testInvokeAll5(ForkJoinPoolTest)"
141 +     * Usefully combined with jsr166.runsPerTest.
142 +     */
143 +    private static final Pattern methodFilter = methodFilter();
144 +
145 +    private static Pattern methodFilter() {
146 +        String regex = System.getProperty("jsr166.methodFilter");
147 +        return (regex == null) ? null : Pattern.compile(regex);
148 +    }
149 +
150      protected void runTest() throws Throwable {
151 <        for (int i = 0; i < runsPerTest; i++) {
152 <            if (profileTests)
153 <                runTestProfiled();
154 <            else
155 <                super.runTest();
151 >        if (methodFilter == null
152 >            || methodFilter.matcher(toString()).find()) {
153 >            for (int i = 0; i < runsPerTest; i++) {
154 >                if (profileTests)
155 >                    runTestProfiled();
156 >                else
157 >                    super.runTest();
158 >            }
159          }
160      }
161  
162      protected void runTestProfiled() throws Throwable {
163 +        // Warmup run, notably to trigger all needed classloading.
164 +        super.runTest();
165          long t0 = System.nanoTime();
166          try {
167              super.runTest();
168          } finally {
169 <            long elapsedMillis =
152 <                (System.nanoTime() - t0) / (1000L * 1000L);
169 >            long elapsedMillis = millisElapsedSince(t0);
170              if (elapsedMillis >= profileThreshold)
171                  System.out.printf("%n%s: %d%n", toString(), elapsedMillis);
172          }
# Line 205 | Line 222 | public class JSR166TestCase extends Test
222      }
223  
224      public static final double JAVA_CLASS_VERSION;
225 +    public static final String JAVA_SPECIFICATION_VERSION;
226      static {
227          try {
228              JAVA_CLASS_VERSION = java.security.AccessController.doPrivileged(
229                  new java.security.PrivilegedAction<Double>() {
230                  public Double run() {
231                      return Double.valueOf(System.getProperty("java.class.version"));}});
232 +            JAVA_SPECIFICATION_VERSION = java.security.AccessController.doPrivileged(
233 +                new java.security.PrivilegedAction<String>() {
234 +                public String run() {
235 +                    return System.getProperty("java.specification.version");}});
236          } catch (Throwable t) {
237              throw new Error(t);
238          }
# Line 219 | Line 241 | public class JSR166TestCase extends Test
241      public static boolean atLeastJava6() { return JAVA_CLASS_VERSION >= 50.0; }
242      public static boolean atLeastJava7() { return JAVA_CLASS_VERSION >= 51.0; }
243      public static boolean atLeastJava8() { return JAVA_CLASS_VERSION >= 52.0; }
244 +    public static boolean atLeastJava9() {
245 +        // As of 2014-05, java9 still uses 52.0 class file version
246 +        return JAVA_SPECIFICATION_VERSION.startsWith("1.9");
247 +    }
248  
249      /**
250       * Collects all JSR166 unit tests as one suite.
# Line 232 | Line 258 | public class JSR166TestCase extends Test
258              RecursiveTaskTest.suite(),
259              LinkedTransferQueueTest.suite(),
260              PhaserTest.suite(),
235            SplittableRandomTest.suite(),
261              ThreadLocalRandomTest.suite(),
262              AbstractExecutorServiceTest.suite(),
263              AbstractQueueTest.suite(),
# Line 295 | Line 320 | public class JSR166TestCase extends Test
320          // Java8+ test classes
321          if (atLeastJava8()) {
322              String[] java8TestClassNames = {
323 +                "Atomic8Test",
324                  "CompletableFutureTest",
325                  "ConcurrentHashMap8Test",
326                  "CountedCompleterTest",
327                  "DoubleAccumulatorTest",
328                  "DoubleAdderTest",
329                  "ForkJoinPool8Test",
330 +                "ForkJoinTask8Test",
331                  "LongAccumulatorTest",
332                  "LongAdderTest",
333 +                "SplittableRandomTest",
334                  "StampedLockTest",
335 +                "ThreadLocalRandom8Test",
336              };
337              addNamedTestClasses(suite, java8TestClassNames);
338          }
339  
340 +        // Java9+ test classes
341 +        if (atLeastJava9()) {
342 +            String[] java9TestClassNames = {
343 +                "ThreadPoolExecutor9Test",
344 +            };
345 +            addNamedTestClasses(suite, java9TestClassNames);
346 +        }
347 +
348          return suite;
349      }
350  
# Line 865 | Line 902 | public class JSR166TestCase extends Test
902       * startNanoTime, which must have been previously returned from a
903       * call to {@link System.nanoTime()}.
904       */
905 <    long millisElapsedSince(long startNanoTime) {
905 >    static long millisElapsedSince(long startNanoTime) {
906          return NANOSECONDS.toMillis(System.nanoTime() - startNanoTime);
907      }
908  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines