96 |
|
private static final boolean useSecurityManager = |
97 |
|
Boolean.getBoolean("jsr166.useSecurityManager"); |
98 |
|
|
99 |
+ |
protected static final boolean expensiveTests = |
100 |
+ |
Boolean.getBoolean("jsr166.expensiveTests"); |
101 |
+ |
|
102 |
+ |
/** |
103 |
+ |
* If true, report on stdout all "slow" tests, that is, ones that |
104 |
+ |
* take more than profileThreshold milliseconds to execute. |
105 |
+ |
*/ |
106 |
+ |
private static final boolean profileTests = |
107 |
+ |
Boolean.getBoolean("jsr166.profileTests"); |
108 |
+ |
|
109 |
+ |
/** |
110 |
+ |
* The number of milliseconds that tests are permitted for |
111 |
+ |
* execution without being reported, when profileTests is set. |
112 |
+ |
*/ |
113 |
+ |
private static final long profileThreshold = |
114 |
+ |
Long.getLong("jsr166.profileThreshold", 100); |
115 |
+ |
|
116 |
+ |
protected void runTest() throws Throwable { |
117 |
+ |
if (profileTests) |
118 |
+ |
runTestProfiled(); |
119 |
+ |
else |
120 |
+ |
super.runTest(); |
121 |
+ |
} |
122 |
+ |
|
123 |
+ |
protected void runTestProfiled() throws Throwable { |
124 |
+ |
long t0 = System.nanoTime(); |
125 |
+ |
try { |
126 |
+ |
super.runTest(); |
127 |
+ |
} finally { |
128 |
+ |
long elapsedMillis = |
129 |
+ |
(System.nanoTime() - t0) / (1000L * 1000L); |
130 |
+ |
if (elapsedMillis >= profileThreshold) |
131 |
+ |
System.out.printf("%n%s: %d%n", toString(), elapsedMillis); |
132 |
+ |
} |
133 |
+ |
} |
134 |
+ |
|
135 |
|
/** |
136 |
|
* Runs all JSR166 unit tests using junit.textui.TestRunner |
137 |
|
*/ |
832 |
|
} |
833 |
|
} |
834 |
|
|
835 |
+ |
public interface TrackedRunnable extends Runnable { |
836 |
+ |
boolean isDone(); |
837 |
+ |
} |
838 |
+ |
|
839 |
+ |
public static TrackedRunnable trackedRunnable(final long timeoutMillis) { |
840 |
+ |
return new TrackedRunnable() { |
841 |
+ |
private volatile boolean done = false; |
842 |
+ |
public boolean isDone() { return done; } |
843 |
+ |
public void run() { |
844 |
+ |
try { |
845 |
+ |
Thread.sleep(timeoutMillis); |
846 |
+ |
done = true; |
847 |
+ |
} catch (InterruptedException ok) {} |
848 |
+ |
} |
849 |
+ |
}; |
850 |
+ |
} |
851 |
+ |
|
852 |
|
public static class TrackedShortRunnable implements Runnable { |
853 |
|
public volatile boolean done = false; |
854 |
|
public void run() { |
855 |
|
try { |
856 |
+ |
Thread.sleep(SHORT_DELAY_MS); |
857 |
+ |
done = true; |
858 |
+ |
} catch (InterruptedException ok) {} |
859 |
+ |
} |
860 |
+ |
} |
861 |
+ |
|
862 |
+ |
public static class TrackedSmallRunnable implements Runnable { |
863 |
+ |
public volatile boolean done = false; |
864 |
+ |
public void run() { |
865 |
+ |
try { |
866 |
|
Thread.sleep(SMALL_DELAY_MS); |
867 |
|
done = true; |
868 |
|
} catch (InterruptedException ok) {} |