提交 23b7eafe 编写于 作者: S smarks

7187882: TEST_BUG: java/rmi/activation/checkusage/CheckUsage.java fails intermittently

Summary: Tighten up JavaVM test library API, and adjust tests to match.
Reviewed-by: mchung, dmocek
上级 58b3960e
########################################################################### ###########################################################################
# #
# Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2009, 2013, 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
...@@ -238,9 +238,6 @@ java/nio/channels/AsynchronousChannelGroup/Unbounded.java windows-amd64 ...@@ -238,9 +238,6 @@ java/nio/channels/AsynchronousChannelGroup/Unbounded.java windows-amd64
# 7146541 # 7146541
java/rmi/transport/rapidExportUnexport/RapidExportUnexport.java linux-all java/rmi/transport/rapidExportUnexport/RapidExportUnexport.java linux-all
# 7187882
java/rmi/activation/checkusage/CheckUsage.java generic-all
# 7190106 # 7190106
java/rmi/reliability/benchmark/runRmiBench.sh generic-all java/rmi/reliability/benchmark/runRmiBench.sh generic-all
......
/* /*
* Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2013, 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
...@@ -168,7 +168,7 @@ public class ShutdownGracefully ...@@ -168,7 +168,7 @@ public class ShutdownGracefully
registering = null; registering = null;
// Need to make sure that rmid goes away by itself // Need to make sure that rmid goes away by itself
Process rmidProcess = rmid.getVM(); JavaVM rmidProcess = rmid;
if (rmidProcess != null) { if (rmidProcess != null) {
try { try {
Runnable waitThread = Runnable waitThread =
...@@ -205,9 +205,9 @@ public class ShutdownGracefully ...@@ -205,9 +205,9 @@ public class ShutdownGracefully
* class that waits for rmid to exit * class that waits for rmid to exit
*/ */
private static class ShutdownDetectThread implements Runnable { private static class ShutdownDetectThread implements Runnable {
private Process rmidProcess = null; private JavaVM rmidProcess = null;
ShutdownDetectThread(Process rmidProcess) { ShutdownDetectThread(JavaVM rmidProcess) {
this.rmidProcess = rmidProcess; this.rmidProcess = rmidProcess;
} }
public void run() { public void run() {
......
/* /*
* Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2013, 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
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
/* @test /* @test
* @bug 4259564 * @bug 4259564
* @summary RMID's usage message is incomplete and inconsistent with other tools
* *
* @library ../../testlibrary * @library ../../testlibrary
* @build TestLibrary JavaVM * @build TestLibrary JavaVM
...@@ -37,23 +38,16 @@ import java.io.ByteArrayOutputStream; ...@@ -37,23 +38,16 @@ import java.io.ByteArrayOutputStream;
*/ */
public class CheckUsage { public class CheckUsage {
public static void main(String[] args) { public static void main(String[] args) {
System.err.println("\nregression test for 4259564\n");
JavaVM rmidVM = null;
try { try {
// make sure the registry exits with a proper usage statement
ByteArrayOutputStream berr = new ByteArrayOutputStream(); ByteArrayOutputStream berr = new ByteArrayOutputStream();
// run a VM to start the registry // create rmid with incorrect command line args
rmidVM = new JavaVM("sun.rmi.server.Activation", "", "foo", JavaVM rmidVM = new JavaVM("sun.rmi.server.Activation", "", "foo",
System.out, berr); System.out, berr);
System.err.println("starting rmid"); System.err.println("starting rmid");
rmidVM.start();
// wait for registry exit // run the subprocess and wait for it to exit
int rmidVMExitStatus = rmidVM.getVM().waitFor(); int rmidVMExitStatus = rmidVM.execute();
System.err.println("rmid exited with status: " + System.err.println("rmid exited with status: " +
rmidVMExitStatus); rmidVMExitStatus);
...@@ -66,12 +60,8 @@ public class CheckUsage { ...@@ -66,12 +60,8 @@ public class CheckUsage {
} else { } else {
System.err.println("test passed"); System.err.println("test passed");
} }
} catch (Exception e) { } catch (Exception e) {
TestLibrary.bomb(e); TestLibrary.bomb(e);
} finally {
rmidVM.destroy();
rmidVM = null;
} }
} }
} }
/* /*
* Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2013, 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
...@@ -76,8 +76,7 @@ public class AltSecurityManager implements Runnable { ...@@ -76,8 +76,7 @@ public class AltSecurityManager implements Runnable {
} }
System.err.println("starting " + utilityToStart); System.err.println("starting " + utilityToStart);
vm.start(); vm.execute();
vm.getVM().waitFor();
} catch (Exception e) { } catch (Exception e) {
TestLibrary.bomb(e); TestLibrary.bomb(e);
......
/* /*
* Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2013, 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
...@@ -35,34 +35,21 @@ import java.io.ByteArrayOutputStream; ...@@ -35,34 +35,21 @@ import java.io.ByteArrayOutputStream;
/** /**
* Make sure that the rmiregistry prints out a correct usage statement * Make sure that the rmiregistry prints out a correct usage statement
* when run with an incorrect command line; test written to conform to * when run with an incorrect command line.
* new tighter bug fix/regression test guidelines.
*/ */
public class CheckUsage { public class CheckUsage {
public static void main(String[] args) { public static void main(String[] args) {
System.err.println("\nregression test for 4151966\n");
JavaVM registryVM = null;
try { try {
// make sure the registry exits with a proper usage statement
ByteArrayOutputStream berr = new ByteArrayOutputStream(); ByteArrayOutputStream berr = new ByteArrayOutputStream();
// run a VM to start the registry // run a VM to start the registry
registryVM = new JavaVM("sun.rmi.registry.RegistryImpl", JavaVM registryVM = new JavaVM("sun.rmi.registry.RegistryImpl",
"", "foo", "", "foo",
System.out, berr); System.out, berr);
System.err.println("starting registry"); System.err.println("starting registry");
registryVM.start();
// wait for registry exit
System.err.println(" registry exited with status: " + System.err.println(" registry exited with status: " +
registryVM.getVM().waitFor()); registryVM.execute());
try {
Thread.sleep(7000);
} catch (InterruptedException ie) {
}
String usage = new String(berr.toByteArray()); String usage = new String(berr.toByteArray());
...@@ -75,9 +62,6 @@ public class CheckUsage { ...@@ -75,9 +62,6 @@ public class CheckUsage {
} }
} catch (Exception e) { } catch (Exception e) {
TestLibrary.bomb(e); TestLibrary.bomb(e);
} finally {
registryVM.destroy();
registryVM = null;
} }
} }
} }
/* /*
* Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2013, 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
...@@ -122,8 +122,7 @@ public class Reexport { ...@@ -122,8 +122,7 @@ public class Reexport {
try { try {
JavaVM jvm = new JavaVM("RegistryRunner", "", Integer.toString(p)); JavaVM jvm = new JavaVM("RegistryRunner", "", Integer.toString(p));
jvm.start(); jvm.start();
Reexport.subreg = jvm.getVM(); Reexport.subreg = jvm;
} catch (IOException e) { } catch (IOException e) {
// one of these is summarily dropped, can't remember which one // one of these is summarily dropped, can't remember which one
System.out.println ("Test setup failed - cannot run rmiregistry"); System.out.println ("Test setup failed - cannot run rmiregistry");
...@@ -135,7 +134,8 @@ public class Reexport { ...@@ -135,7 +134,8 @@ public class Reexport {
} catch (Exception whatever) { } catch (Exception whatever) {
} }
} }
private static Process subreg = null;
private static JavaVM subreg = null;
public static void killRegistry(int port) { public static void killRegistry(int port) {
if (Reexport.subreg != null) { if (Reexport.subreg != null) {
......
/* /*
* Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2013, 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
...@@ -41,6 +41,8 @@ public class JavaVM { ...@@ -41,6 +41,8 @@ public class JavaVM {
private OutputStream outputStream = System.out; private OutputStream outputStream = System.out;
private OutputStream errorStream = System.err; private OutputStream errorStream = System.err;
private String policyFileName = null; private String policyFileName = null;
private StreamPipe outPipe;
private StreamPipe errPipe;
private static void mesg(Object mesg) { private static void mesg(Object mesg) {
System.err.println("JAVAVM: " + mesg.toString()); System.err.println("JAVAVM: " + mesg.toString());
...@@ -145,13 +147,12 @@ public class JavaVM { ...@@ -145,13 +147,12 @@ public class JavaVM {
} }
mesg("command = " + Arrays.asList(javaCommand).toString()); mesg("command = " + Arrays.asList(javaCommand).toString());
System.err.println("");
vm = Runtime.getRuntime().exec(javaCommand); vm = Runtime.getRuntime().exec(javaCommand);
/* output from the execed process may optionally be captured. */ /* output from the execed process may optionally be captured. */
StreamPipe.plugTogether(vm.getInputStream(), this.outputStream); outPipe = StreamPipe.plugTogether(vm.getInputStream(), this.outputStream);
StreamPipe.plugTogether(vm.getErrorStream(), this.errorStream); errPipe = StreamPipe.plugTogether(vm.getErrorStream(), this.errorStream);
} }
public void destroy() { public void destroy() {
...@@ -161,7 +162,25 @@ public class JavaVM { ...@@ -161,7 +162,25 @@ public class JavaVM {
vm = null; vm = null;
} }
protected Process getVM() { /**
return vm; * Waits for the subprocess to exit, joins the pipe threads to ensure that
* all output is collected, and returns its exit status.
*/
public int waitFor() throws InterruptedException {
if (vm == null)
throw new IllegalStateException("can't wait for JavaVM that hasn't started");
int status = vm.waitFor();
outPipe.join();
errPipe.join();
return status;
}
/**
* Starts the subprocess, waits for it to exit, and returns its exit status.
*/
public int execute() throws IOException, InterruptedException {
start();
return waitFor();
} }
} }
/* /*
* Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2013, 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
...@@ -202,8 +202,6 @@ public class RMID extends JavaVM { ...@@ -202,8 +202,6 @@ public class RMID extends JavaVM {
public void start(long waitTime) throws IOException { public void start(long waitTime) throws IOException {
if (getVM() != null) return;
// if rmid is already running, then the test will fail with // if rmid is already running, then the test will fail with
// a well recognized exception (port already in use...). // a well recognized exception (port already in use...).
......
/* /*
* Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2013, 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
...@@ -114,6 +114,7 @@ public class CheckFQDN extends UnicastRemoteObject ...@@ -114,6 +114,7 @@ public class CheckFQDN extends UnicastRemoteObject
equal = "="; equal = "=";
} }
// create a client to tell checkFQDN what its rmi name is.
JavaVM jvm = new JavaVM("CheckFQDNClient", JavaVM jvm = new JavaVM("CheckFQDNClient",
propOption + property + propOption + property +
equal + equal +
...@@ -125,10 +126,7 @@ public class CheckFQDN extends UnicastRemoteObject ...@@ -125,10 +126,7 @@ public class CheckFQDN extends UnicastRemoteObject
propertyBeingTested=property; propertyBeingTested=property;
propertyBeingTestedValue=propertyValue; propertyBeingTestedValue=propertyValue;
// create a client to tell checkFQDN what its rmi name is. */ if (jvm.execute() != 0) {
jvm.start();
if (jvm.getVM().waitFor() != 0 ) {
TestLibrary.bomb("Test failed, error in client."); TestLibrary.bomb("Test failed, error in client.");
} }
......
/* /*
* Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2013, 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
...@@ -102,9 +102,8 @@ public class CheckLeaseLeak extends UnicastRemoteObject implements LeaseLeak { ...@@ -102,9 +102,8 @@ public class CheckLeaseLeak extends UnicastRemoteObject implements LeaseLeak {
" -Drmi.registry.port=" + " -Drmi.registry.port=" +
registryPort, registryPort,
""); "");
jvm.start();
if (jvm.getVM().waitFor() == 1 ) { if (jvm.execute() != 0) {
TestLibrary.bomb("Client process failed"); TestLibrary.bomb("Client process failed");
} }
} }
......
/* /*
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2002, 2013, 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
...@@ -48,8 +48,7 @@ public class Test4504153 { ...@@ -48,8 +48,7 @@ public class Test4504153 {
ByteArrayOutputStream err = new ByteArrayOutputStream(); ByteArrayOutputStream err = new ByteArrayOutputStream();
JavaVM vm = new JavaVM(StartRegistry.class.getName(), JavaVM vm = new JavaVM(StartRegistry.class.getName(),
"-Dsun.rmi.transport.logLevel=v", "", out, err); "-Dsun.rmi.transport.logLevel=v", "", out, err);
vm.start(); vm.execute();
vm.getVM().waitFor();
String errString = err.toString(); String errString = err.toString();
......
/* /*
* Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2006, 2013, 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
...@@ -65,8 +65,7 @@ public class NoConsoleOutput { ...@@ -65,8 +65,7 @@ public class NoConsoleOutput {
JavaVM vm = new JavaVM(DoRMIStuff.class.getName(), JavaVM vm = new JavaVM(DoRMIStuff.class.getName(),
"-Djava.util.logging.config.file=" + loggingPropertiesFile, "-Djava.util.logging.config.file=" + loggingPropertiesFile,
"", out, err); "", out, err);
vm.start(); vm.execute();
vm.getVM().waitFor();
/* /*
* Verify that the subprocess had no System.out or System.err * Verify that the subprocess had no System.out or System.err
......
/* /*
* Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2013, 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
...@@ -104,7 +104,7 @@ public class DeadCachedConnection { ...@@ -104,7 +104,7 @@ public class DeadCachedConnection {
JavaVM jvm = JavaVM jvm =
new JavaVM("sun.rmi.registry.RegistryImpl", "", Integer.toString(p)); new JavaVM("sun.rmi.registry.RegistryImpl", "", Integer.toString(p));
jvm.start(); jvm.start();
DeadCachedConnection.subreg = jvm.getVM(); DeadCachedConnection.subreg = jvm;
} catch (IOException e) { } catch (IOException e) {
// one of these is summarily dropped, can't remember which one // one of these is summarily dropped, can't remember which one
...@@ -117,7 +117,7 @@ public class DeadCachedConnection { ...@@ -117,7 +117,7 @@ public class DeadCachedConnection {
} catch (Exception whatever) { } catch (Exception whatever) {
} }
} }
private static Process subreg = null; private static JavaVM subreg = null;
public static void killRegistry() { public static void killRegistry() {
if (DeadCachedConnection.subreg != null) { if (DeadCachedConnection.subreg != null) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册