8143097: java/net/ipv6tests/UdpTest.java fails intermittently with "checkTime failed: got 1998 expected 4000"
authoramlu
Thu, 03 Nov 2016 15:40:55 +0800
changeset 41887 61839a1a7e62
parent 41886 52cfb8c08257
child 41888 dc533ef5583a
8143097: java/net/ipv6tests/UdpTest.java fails intermittently with "checkTime failed: got 1998 expected 4000" Reviewed-by: chegar
jdk/test/java/net/ipv6tests/Tests.java
jdk/test/java/net/ipv6tests/UdpTest.java
--- a/jdk/test/java/net/ipv6tests/Tests.java	Wed Nov 02 18:44:59 2016 -0700
+++ b/jdk/test/java/net/ipv6tests/Tests.java	Thu Nov 03 15:40:55 2016 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, 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
@@ -139,11 +139,17 @@
 
     /* check the time got is within 50% of the time expected */
     public static void checkTime (long got, long expected) {
-        dprintln ("checkTime: got " + got + " expected " + expected);
-        long upper = expected + (expected / 2);
-        long lower = expected - (expected / 2);
+        checkTime(got, expected, expected);
+    }
+
+    /* check the time got is between start and end, given 50% tolerance */
+    public static void checkTime(long got, long start, long end) {
+        dprintln("checkTime: got = " + got + " start = " + start + " end = " + end);
+        long upper = end + (end / 2);
+        long lower = start - (start / 2);
         if (got > upper || got < lower) {
-            throw new RuntimeException ("checkTime failed: got " + got + " expected " + expected);
+            throw new RuntimeException("checkTime failed: got " + got
+                    + ", expected between " + start + " and " + end);
         }
     }
 
--- a/jdk/test/java/net/ipv6tests/UdpTest.java	Wed Nov 02 18:44:59 2016 -0700
+++ b/jdk/test/java/net/ipv6tests/UdpTest.java	Thu Nov 03 15:40:55 2016 +0800
@@ -24,7 +24,6 @@
 /*
  * @test
  * @bug 4868820
- * @key intermittent
  * @summary IPv6 support for Windows XP and 2003 server
  */
 
@@ -159,7 +158,7 @@
         });
         t1 = System.currentTimeMillis();
         s1.receive (new DatagramPacket (new byte [128], 128));
-        checkTime (System.currentTimeMillis() - t1, 4000);
+        checkTime (System.currentTimeMillis() - t1, 2000, 10000);
         s1.close ();
         s2.close ();
         System.out.println ("Test2: OK");