8005618: TEST_BUG: java/lang/ProcessBuilder/Basic.java failing intermittently
authorrobm
Tue, 15 Jan 2013 19:58:22 +0000
changeset 15265 507fd9b4b485
parent 15264 3baf7f9d320d
child 15266 379788c73130
8005618: TEST_BUG: java/lang/ProcessBuilder/Basic.java failing intermittently Reviewed-by: alanb, martin, dholmes
jdk/test/java/lang/ProcessBuilder/Basic.java
--- a/jdk/test/java/lang/ProcessBuilder/Basic.java	Tue Jan 15 11:44:20 2013 +0000
+++ b/jdk/test/java/lang/ProcessBuilder/Basic.java	Tue Jan 15 19:58:22 2013 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -2218,7 +2218,7 @@
             start = System.nanoTime();
             p.waitFor(1000, TimeUnit.MILLISECONDS);
             end = System.nanoTime();
-            if ((end - start) > 100000000)
+            if ((end - start) > 900000000)
                 fail("Test failed: waitFor took too long on a dead process.");
         } catch (Throwable t) { unexpected(t); }
 
@@ -2231,11 +2231,13 @@
             childArgs.add("sleep");
             final Process p = new ProcessBuilder(childArgs).start();
             final long start = System.nanoTime();
+            final CountDownLatch latch = new CountDownLatch(1);
 
             final Thread thread = new Thread() {
                 public void run() {
                     try {
                         try {
+                            latch.countDown();
                             p.waitFor(10000, TimeUnit.MILLISECONDS);
                         } catch (InterruptedException e) {
                             return;
@@ -2244,6 +2246,7 @@
                     } catch (Throwable t) { unexpected(t); }}};
 
             thread.start();
+            latch.await();
             Thread.sleep(1000);
             thread.interrupt();
             p.destroy();