Add 20s timeout to 570-checker-osr.
It's better to report a timeout than to hang indefinitely.
Change-Id: Ibfa8059c8b44220c7a55801b020094fc342c8047
diff --git a/test/570-checker-osr/src/Main.java b/test/570-checker-osr/src/Main.java
index 1142d49..6514334 100644
--- a/test/570-checker-osr/src/Main.java
+++ b/test/570-checker-osr/src/Main.java
@@ -16,8 +16,28 @@
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");
}