changeset 53810:59a6aaef42a7

8257884: Re-enable sun/security/ssl/SSLSocketImpl/SSLSocketLeak.java as automatic test Reviewed-by: xuelei
author clanger
date Tue, 29 Dec 2020 18:59:59 +0000
parents 0fdf7159d5c2
children 78378ca3cf3b
files test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketLeak.java
diffstat 1 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketLeak.java	Tue Dec 29 18:49:16 2020 +0000
+++ b/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketLeak.java	Tue Dec 29 18:59:59 2020 +0000
@@ -26,21 +26,26 @@
 import javax.net.SocketFactory;
 import javax.net.ssl.SSLSocketFactory;
 
+import jdk.test.lib.Platform;
 import jdk.test.lib.util.FileUtils;
 
 /*
  * @test
- * @bug 8256818 8257670
+ * @bug 8256818 8257670 8257884
  * @summary Test that creating and closing SSL Sockets without bind/connect
  *          will not leave leaking socket file descriptors
  * @library /test/lib
- * @run main/manual SSLSocketLeak
+ * @run main/othervm SSLSocketLeak
  */
 // Note: this test is not reliable, run it manually.
 public class SSLSocketLeak {
 
+    // number of sockets to open/close
     private static final int NUM_TEST_SOCK = 500;
 
+    // percentage of accepted growth of open handles
+    private static final int OPEN_HANDLE_GROWTH_THRESHOLD = Platform.isWindows() ? 25 : 10;
+
     public static void main(String[] args) throws IOException {
         long fds_start = FileUtils.getProcessHandleCount();
         System.out.println("FDs at the beginning: " + fds_start);
@@ -53,7 +58,7 @@
         long fds_end = FileUtils.getProcessHandleCount();
         System.out.println("FDs in the end: " + fds_end);
 
-        if ((fds_end - fds_start) > (NUM_TEST_SOCK / 10)) {
+        if ((fds_end - fds_start) > (NUM_TEST_SOCK / OPEN_HANDLE_GROWTH_THRESHOLD)) {
             throw new RuntimeException("Too many open file descriptors. Looks leaky.");
         }
     }