8170704: java/rmi/activation/Activatable/* tests fails intermittently with "output improperly annotated"

Reviewed-by: dfuchs, rriggs
This commit is contained in:
Hamlin Li 2016-12-06 17:53:22 -08:00
parent 9877170d02
commit 1dad4ab65f

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -49,6 +49,7 @@ import java.util.StringTokenizer;
public class CheckAnnotations public class CheckAnnotations
extends Activatable implements MyRMI, Runnable extends Activatable implements MyRMI, Runnable
{ {
private static final double TIME_FACTOR = TestLibrary.getTimeoutFactor();
private static Object dummy = new Object(); private static Object dummy = new Object();
private static MyRMI myRMI = null; private static MyRMI myRMI = null;
@ -111,9 +112,7 @@ public class CheckAnnotations
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
// object activated in annotation check via method call // object activated in annotation check via method call
if(!checkAnnotations(i-1)) { checkAnnotations(i-1);
TestLibrary.bomb("Test failed: output improperly annotated.");
}
/* /*
* Clean up object too. * Clean up object too.
@ -143,24 +142,27 @@ public class CheckAnnotations
* check to make sure that the output from a spawned vm is * check to make sure that the output from a spawned vm is
* formatted/annotated properly. * formatted/annotated properly.
*/ */
public static boolean checkAnnotations(int iteration) public static void checkAnnotations(int iteration)
throws IOException throws IOException
{ {
try { try {
Thread.sleep(5000); Thread.sleep((long)(5000 * TIME_FACTOR));
} catch(Exception e) { } catch(Exception e) {
System.err.println(e.getMessage()); System.err.println(e.getMessage());
} }
final String FAIL_MSG = "Test failed: output improperly annotated.";
final String OUT = "outABC";
final String ERR = "errXYZ";
/** /**
* cause the spawned vm to generate output that will * cause the spawned vm to generate output that will
* be checked for proper annotation. printOut is * be checked for proper annotation. printOut is
* actually being called on an activated implementation. * actually being called on an activated implementation.
*/ */
myRMI.printOut("out" + iteration); myRMI.printOut(OUT + iteration);
myRMI.printErr("err" + iteration); myRMI.printErr(ERR + iteration);
myRMI.printOut("out" + iteration); myRMI.printOut(OUT + iteration);
myRMI.printErr("err" + iteration); myRMI.printErr(ERR + iteration);
/* we have to wait for output to filter down /* we have to wait for output to filter down
* from children so we can read it before we * from children so we can read it before we
@ -174,7 +176,7 @@ public class CheckAnnotations
// have to give output from rmid time to trickle down to // have to give output from rmid time to trickle down to
// this process // this process
try { try {
Thread.sleep(4000); Thread.sleep((long)(4000 * TIME_FACTOR));
} catch(InterruptedException e) { } catch(InterruptedException e) {
} }
@ -222,27 +224,24 @@ public class CheckAnnotations
if ((execErr == null)||(errTmp == null)|| if ((execErr == null)||(errTmp == null)||
(destErr == null)) { (destErr == null)) {
return false; TestLibrary.bomb(FAIL_MSG);
} }
if ((execOut == null)||(outTmp == null)|| if ((execOut == null)||(outTmp == null)||
(destOut == null)) { (destOut == null)) {
return false; TestLibrary.bomb(FAIL_MSG);
} }
// just make sure that last two strings are what we expect. // just make sure that last two strings are what we expect.
if (execOut.equals("ExecGroup-" + iteration) if (!execOut.equals("ExecGroup-" + iteration)
&& (new String(destOut.substring(0,4)).equals("out" + || !(new String(destOut.substring(0,OUT.length()+1)).equals(OUT +
iteration)) iteration))
&& (execErr.equals("ExecGroup-"+iteration)) || !(execErr.equals("ExecGroup-"+iteration))
&& (new String(destErr.substring(0,4)).equals("err" + || !(new String(destErr.substring(0,ERR.length()+1)).equals(ERR +
iteration)) ) { iteration)) ) {
return true; TestLibrary.bomb(FAIL_MSG);
} else {
return false;
} }
} }
return true;
} }
// implementation of MyRMI, make this object activatable. // implementation of MyRMI, make this object activatable.