196 |
|
// static volatile int currentRun = 0; |
197 |
|
static { |
198 |
|
Runnable checkForWedgedTest = new Runnable() { public void run() { |
199 |
< |
// avoid spurious reports with enormous runsPerTest |
200 |
< |
final int timeoutMinutes = Math.max(runsPerTest / 10, 1); |
199 |
> |
// Avoid spurious reports with enormous runsPerTest. |
200 |
> |
// A single test case run should never take more than 1 second. |
201 |
> |
// But let's cap it at the high end too ... |
202 |
> |
final int timeoutMinutes = |
203 |
> |
Math.min(15, Math.max(runsPerTest / 60, 1)); |
204 |
|
for (TestCase lastTestCase = currentTestCase;;) { |
205 |
|
try { MINUTES.sleep(timeoutMinutes); } |
206 |
|
catch (InterruptedException unexpected) { break; } |
211 |
|
// System.err.printf( |
212 |
|
// "Looks like we're stuck running test: %s (%d/%d)%n", |
213 |
|
// lastTestCase, currentRun, runsPerTest); |
214 |
< |
System.err.println("availableProcessors=" + |
215 |
< |
Runtime.getRuntime().availableProcessors()); |
216 |
< |
System.err.printf("cpu model = %s%n", cpuModel()); |
214 |
> |
// System.err.println("availableProcessors=" + |
215 |
> |
// Runtime.getRuntime().availableProcessors()); |
216 |
> |
// System.err.printf("cpu model = %s%n", cpuModel()); |
217 |
|
dumpTestThreads(); |
218 |
|
// one stack dump is probably enough; more would be spam |
219 |
|
break; |
225 |
|
thread.start(); |
226 |
|
} |
227 |
|
|
228 |
< |
public static String cpuModel() { |
229 |
< |
try { |
230 |
< |
Matcher matcher = Pattern.compile("model name\\s*: (.*)") |
231 |
< |
.matcher(new String( |
232 |
< |
Files.readAllBytes(Paths.get("/proc/cpuinfo")), "UTF-8")); |
233 |
< |
matcher.find(); |
234 |
< |
return matcher.group(1); |
235 |
< |
} catch (Exception ex) { return null; } |
236 |
< |
} |
228 |
> |
// public static String cpuModel() { |
229 |
> |
// try { |
230 |
> |
// Matcher matcher = Pattern.compile("model name\\s*: (.*)") |
231 |
> |
// .matcher(new String( |
232 |
> |
// Files.readAllBytes(Paths.get("/proc/cpuinfo")), "UTF-8")); |
233 |
> |
// matcher.find(); |
234 |
> |
// return matcher.group(1); |
235 |
> |
// } catch (Exception ex) { return null; } |
236 |
> |
// } |
237 |
|
|
238 |
|
public void runBare() throws Throwable { |
239 |
|
currentTestCase = this; |
1396 |
|
|
1397 |
|
public void await(CountDownLatch latch) { |
1398 |
|
try { |
1399 |
< |
assertTrue(latch.await(LONG_DELAY_MS, MILLISECONDS)); |
1399 |
> |
if (!latch.await(LONG_DELAY_MS, MILLISECONDS)) |
1400 |
> |
fail("timed out waiting for CountDownLatch for " |
1401 |
> |
+ (LONG_DELAY_MS/1000) + " sec"); |
1402 |
|
} catch (Throwable fail) { |
1403 |
|
threadUnexpectedException(fail); |
1404 |
|
} |
1406 |
|
|
1407 |
|
public void await(Semaphore semaphore) { |
1408 |
|
try { |
1409 |
< |
assertTrue(semaphore.tryAcquire(LONG_DELAY_MS, MILLISECONDS)); |
1409 |
> |
if (!semaphore.tryAcquire(LONG_DELAY_MS, MILLISECONDS)) |
1410 |
> |
fail("timed out waiting for Semaphore for " |
1411 |
> |
+ (LONG_DELAY_MS/1000) + " sec"); |
1412 |
|
} catch (Throwable fail) { |
1413 |
|
threadUnexpectedException(fail); |
1414 |
|
} |