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.169 by jsr166, Thu Oct 8 21:50:26 2015 UTC vs.
Revision 1.172 by jsr166, Fri Oct 9 01:26:36 2015 UTC

# Line 20 | Line 20 | import java.lang.management.ThreadMXBean
20   import java.lang.reflect.Constructor;
21   import java.lang.reflect.Method;
22   import java.lang.reflect.Modifier;
23 + import java.nio.file.Files;
24 + import java.nio.file.Paths;
25   import java.security.CodeSource;
26   import java.security.Permission;
27   import java.security.PermissionCollection;
# Line 52 | Line 54 | import java.util.concurrent.ThreadFactor
54   import java.util.concurrent.ThreadPoolExecutor;
55   import java.util.concurrent.TimeoutException;
56   import java.util.concurrent.atomic.AtomicReference;
57 + import java.util.regex.Matcher;
58   import java.util.regex.Pattern;
59  
60   import junit.framework.AssertionFailedError;
# Line 188 | Line 191 | public class JSR166TestCase extends Test
191          return (regex == null) ? null : Pattern.compile(regex);
192      }
193  
194 +    // Instrumentation to debug very rare, but very annoying hung test runs.
195      static volatile TestCase currentTestCase;
196 +    static volatile int currentRun = 0;
197      static {
198          Runnable checkForWedgedTest = new Runnable() { public void run() {
199              // avoid spurious reports with enormous runsPerTest
# Line 197 | Line 202 | public class JSR166TestCase extends Test
202                  try { MINUTES.sleep(timeoutMinutes); }
203                  catch (InterruptedException unexpected) { break; }
204                  if (lastTestCase == currentTestCase) {
205 <                    System.err.println
206 <                        ("Looks like we're stuck running test: "
207 <                         + lastTestCase);
205 >                    System.err.printf(
206 >                        "Looks like we're stuck running test: %s (%d/%d)%n",
207 >                        lastTestCase, currentRun, runsPerTest);
208                      System.err.println("availableProcessors=" +
209                          Runtime.getRuntime().availableProcessors());
210 +                    System.err.printf("cpu model = %s%n", cpuModel());
211                      dumpTestThreads();
212                      // one stack dump is probably enough; more would be spam
213                      break;
# Line 213 | Line 219 | public class JSR166TestCase extends Test
219          thread.start();
220      }
221  
222 +    public static String cpuModel() {
223 +        try {
224 +            Matcher matcher = Pattern.compile("model name\\s*: (.*)")
225 +                .matcher(new String(
226 +                     Files.readAllBytes(Paths.get("/proc/cpuinfo")), "UTF-8"));
227 +            matcher.find();
228 +            return matcher.group(1);
229 +        } catch (Exception ex) { return null; }
230 +    }
231 +
232      public void runBare() throws Throwable {
233          currentTestCase = this;
234          if (methodFilter == null
# Line 222 | Line 238 | public class JSR166TestCase extends Test
238  
239      protected void runTest() throws Throwable {
240          for (int i = 0; i < runsPerTest; i++) {
241 +            currentRun = i;
242              if (profileTests)
243                  runTestProfiled();
244              else

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines