changeset 11074:780460a01e2f

8066835: TEST_BUG: javax/management/remote/mandatory/connection/RMIConnector_NPETest.java fails Reviewed-by: lancea
author smarks
date Mon, 08 Dec 2014 14:32:31 -0800
parents 1a98ccf0b017
children 04cda88bbfde
files test/java/rmi/testlibrary/JavaVM.java test/java/rmi/testlibrary/RMID.java test/javax/management/remote/mandatory/connection/RMIConnector_NPETest.java
diffstat 3 files changed, 20 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/test/java/rmi/testlibrary/JavaVM.java	Mon Dec 08 11:54:17 2014 -0800
+++ b/test/java/rmi/testlibrary/JavaVM.java	Mon Dec 08 14:32:31 2014 -0800
@@ -194,7 +194,7 @@
             throws InterruptedException, TimeoutException {
         if (vm == null)
             throw new IllegalStateException("can't wait for JavaVM that isn't running");
-        long deadline = System.currentTimeMillis() + timeout;
+        long deadline = computeDeadline(System.currentTimeMillis(), timeout);
 
         while (true) {
             try {
@@ -218,4 +218,21 @@
         start();
         return waitFor();
     }
+
+    /**
+     * Computes a deadline from a timestamp and a timeout value.
+     * Maximum timeout (before multipliers are applied) is one hour.
+     */
+    public static long computeDeadline(long timestamp, long timeout) {
+        final long MAX_TIMEOUT_MS = 3_600_000L;
+
+        if (timeout < 0L || timeout > MAX_TIMEOUT_MS) {
+            throw new IllegalArgumentException("timeout " + timeout + "ms out of range");
+        }
+
+        // TODO apply test.timeout.factor (and possibly jcov.sleep.multiplier)
+        // here instead of upstream
+
+        return timestamp + timeout;
+    }
 }
--- a/test/java/rmi/testlibrary/RMID.java	Mon Dec 08 11:54:17 2014 -0800
+++ b/test/java/rmi/testlibrary/RMID.java	Mon Dec 08 14:32:31 2014 -0800
@@ -257,7 +257,7 @@
         waitTime = waitTime * slopFactor;
 
         long startTime = System.currentTimeMillis();
-        long deadline = startTime + waitTime;
+        long deadline = computeDeadline(startTime, waitTime);
 
         while (true) {
             try {
--- a/test/javax/management/remote/mandatory/connection/RMIConnector_NPETest.java	Mon Dec 08 11:54:17 2014 -0800
+++ b/test/javax/management/remote/mandatory/connection/RMIConnector_NPETest.java	Mon Dec 08 14:32:31 2014 -0800
@@ -38,7 +38,7 @@
 public class RMIConnector_NPETest {
     public static void main(String argv[]) throws Exception {
         RMID rmid = RMID.createRMID();
-        rmid.start(Long.MAX_VALUE);
+        rmid.start();
         int rmidPort = rmid.getPort();
         Exception failureCause = null;
         RMIConnector agent = null;