changeset 10846:fad7b54324e0

8039953: [TESTBUG] Timeout java/lang/invoke/MethodHandles/CatchExceptionTest.java Reviewed-by: vlivanov, psandoz
author kshefov
date Thu, 18 Jun 2015 15:40:15 +0300
parents 573bb970a604
children bd0eaab40c8b
files test/java/lang/invoke/MethodHandles/CatchExceptionTest.java
diffstat 1 files changed, 17 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/test/java/lang/invoke/MethodHandles/CatchExceptionTest.java	Tue Jun 16 13:13:05 2015 +0200
+++ b/test/java/lang/invoke/MethodHandles/CatchExceptionTest.java	Thu Jun 18 15:40:15 2015 +0300
@@ -24,6 +24,8 @@
 
 import com.oracle.testlibrary.jsr292.Helper;
 import jdk.testlibrary.Asserts;
+import jdk.testlibrary.TimeLimitedRunner;
+import jdk.testlibrary.Utils;
 
 import java.lang.invoke.MethodHandle;
 import java.lang.invoke.MethodHandles;
@@ -33,6 +35,7 @@
 import java.util.function.BiFunction;
 import java.util.function.Function;
 import java.util.function.Supplier;
+import java.util.concurrent.TimeUnit;
 
 /* @test
  * @library /lib/testlibrary/jsr292 /lib/testlibrary/
@@ -94,14 +97,23 @@
     }
 
     public static void main(String[] args) throws Throwable {
+        TestFactory factory = new TestFactory();
+        long timeout = Helper.IS_THOROUGH ? 0L : Utils.adjustTimeout(Utils.DEFAULT_TEST_TIMEOUT);
+        // substract vm init time and reserve time for vm exit
+        timeout *= 0.9;
+        TimeLimitedRunner runner = new TimeLimitedRunner(timeout, 2.0d,
+                () -> {
+                    CatchExceptionTest test = factory.nextTest();
+                    if (test != null) {
+                        test.runTest();
+                        return true;
+                    }
+                    return false;
+                });
         for (CatchExceptionTest test : TestFactory.MANDATORY_TEST_CASES) {
             test.runTest();
         }
-        TestFactory factory = new TestFactory();
-        CatchExceptionTest test;
-        while ((test = factory.nextTest()) != null ) {
-            test.runTest();
-        }
+        runner.call();
     }
 
     private List<Class<?>> getThrowerParams(boolean isVararg, int argsCount) {