8222410: java/nio/file/attribute/BasicFileAttributeView/UnixSocketFile hangs when "nc" does not accept "-U"
authorshade
Mon, 15 Apr 2019 18:22:08 +0200
changeset 54533 9219624244a6
parent 54532 e9c62d960d64
child 54534 66f5241da404
8222410: java/nio/file/attribute/BasicFileAttributeView/UnixSocketFile hangs when "nc" does not accept "-U" Reviewed-by: alanb
test/jdk/java/nio/file/attribute/BasicFileAttributeView/UnixSocketFile.java
--- a/test/jdk/java/nio/file/attribute/BasicFileAttributeView/UnixSocketFile.java	Tue Apr 09 16:21:20 2019 +0100
+++ b/test/jdk/java/nio/file/attribute/BasicFileAttributeView/UnixSocketFile.java	Mon Apr 15 18:22:08 2019 +0200
@@ -61,6 +61,14 @@
             return;
         }
 
+        // Verify that 'nc' accepts '-U' for Unix domain sockets.
+        // Skip the test if it is not.
+        Process procHelp = Runtime.getRuntime().exec(CMD_BASE + " -h");
+        if (procHelp.waitFor() != 0) {
+            System.err.println("Netcat does not accept required options; skipping test.");
+            return;
+        }
+
         // Create a new sub-directory of the nominal test directory in which
         // 'nc' will create the socket file.
         String testSubDir = System.getProperty("test.dir", ".")