diff options
| -rw-r--r-- | test/137-cfi/cfi.cc | 1 | ||||
| -rw-r--r-- | test/137-cfi/src/Main.java | 12 |
2 files changed, 7 insertions, 6 deletions
diff --git a/test/137-cfi/cfi.cc b/test/137-cfi/cfi.cc index 87656bcf0e..45251b8f7d 100644 --- a/test/137-cfi/cfi.cc +++ b/test/137-cfi/cfi.cc @@ -53,6 +53,7 @@ static void CauseSegfault() { extern "C" JNIEXPORT jboolean JNICALL Java_Main_sleep(JNIEnv*, jobject, jint, jboolean, jdouble) { // Keep pausing. + printf("Going to sleep\n"); for (;;) { pause(); } diff --git a/test/137-cfi/src/Main.java b/test/137-cfi/src/Main.java index 77553380c8..d60a4ebba8 100644 --- a/test/137-cfi/src/Main.java +++ b/test/137-cfi/src/Main.java @@ -16,10 +16,7 @@ import java.io.BufferedReader; import java.io.FileReader; -import java.io.InputStream; -import java.io.OutputStream; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; +import java.io.InputStreamReader; import java.util.Arrays; import java.util.Comparator; @@ -98,9 +95,12 @@ public class Main implements Comparator<Main> { throw new RuntimeException("Couldn't parse process"); } - // Wait a bit, so the forked process has time to run until its sleep phase. + // Wait until the forked process had time to run until its sleep phase. try { - Thread.sleep(5000); + InputStreamReader stdout = new InputStreamReader(p.getInputStream(), "UTF-8"); + BufferedReader lineReader = new BufferedReader(stdout); + while (!lineReader.readLine().contains("Going to sleep")) { + } } catch (Exception e) { throw new RuntimeException(e); } |