OSDN Git Service

Add 20s timeout to 570-checker-osr.
authorVladimir Marko <vmarko@google.com>
Thu, 7 Apr 2016 09:12:31 +0000 (10:12 +0100)
committerVladimir Marko <vmarko@google.com>
Thu, 7 Apr 2016 09:53:12 +0000 (10:53 +0100)
It's better to report a timeout than to hang indefinitely.

Change-Id: Ibfa8059c8b44220c7a55801b020094fc342c8047

test/570-checker-osr/src/Main.java

index 1142d49..6514334 100644 (file)
 
 public class Main {
   public static void main(String[] args) {
-    new SubMain();
     System.loadLibrary(args[0]);
+    Thread testThread = new Thread() {
+      public void run() {
+        performTest();
+      }
+    };
+    testThread.start();
+    try {
+      testThread.join(20 * 1000);  // 20s timeout.
+    } catch (InterruptedException ie) {
+      System.out.println("Interrupted.");
+      System.exit(1);
+    }
+    Thread.State state = testThread.getState();
+    if (state != Thread.State.TERMINATED) {
+      System.out.println("Test timed out, current state: " + state);
+      System.exit(1);
+    }
+  }
+
+  public static void performTest() {
+    new SubMain();
     if ($noinline$returnInt() != 53) {
       throw new Error("Unexpected return value");
     }