8232135: Add diagnostic output to test java/util/ProcessBuilder/Basic.java
authorrriggs
Fri, 11 Oct 2019 13:14:33 -0400
changeset 58566 afbb7ec84228
parent 58565 baa5969ecf34
child 58568 6c1f645bd601
8232135: Add diagnostic output to test java/util/ProcessBuilder/Basic.java Reviewed-by: lancea
test/jdk/java/lang/ProcessBuilder/Basic.java
--- a/test/jdk/java/lang/ProcessBuilder/Basic.java	Fri Oct 11 13:11:56 2019 -0400
+++ b/test/jdk/java/lang/ProcessBuilder/Basic.java	Fri Oct 11 13:14:33 2019 -0400
@@ -2111,6 +2111,19 @@
                                 case 2: r = s.read(bytes); break;
                                 default: throw new Error();
                             }
+                            if (r >= 0) {
+                                // The child sent unexpected output; print it to diagnose
+                                System.out.println("Unexpected child output:");
+                                if ((action & 0x2) == 0) {
+                                    System.out.write(r);    // Single character
+
+                                } else {
+                                    System.out.write(bytes, 0, r);
+                                }
+                                for (int c = s.read(); c >= 0; c = s.read())
+                                    System.out.write(c);
+                                System.out.println("\nEND Child output.");
+                            }
                             equal(-1, r);
                         } catch (IOException ioe) {
                             if (!ioe.getMessage().equals("Stream closed")) {