提交 fcfa0249 编写于 作者: T tyan

7190106: java/rmi/reliability/benchmark fails intermittently because of use of fixed port

Reviewed-by: smarks, mduigou
上级 fbff9c3e
...@@ -205,9 +205,6 @@ java/nio/file/WatchService/LotsOfEvents.java solaris-all ...@@ -205,9 +205,6 @@ java/nio/file/WatchService/LotsOfEvents.java solaris-all
# 7146541 # 7146541
java/rmi/transport/rapidExportUnexport/RapidExportUnexport.java linux-all java/rmi/transport/rapidExportUnexport/RapidExportUnexport.java linux-all
# 7190106
java/rmi/reliability/benchmark/runRmiBench.sh generic-all
# 7191877 # 7191877
java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak.java generic-all java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak.java generic-all
......
/* /*
* Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 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
...@@ -21,8 +21,27 @@ ...@@ -21,8 +21,27 @@
* questions. * questions.
*/ */
/* /**
* * @test
* @summary The RMI benchmark test. This java class is used to run the test
* under JTREG.
* @library ../../../../testlibrary ../../
* @build TestLibrary bench.BenchInfo bench.HtmlReporter bench.Util
* bench.Benchmark bench.Reporter bench.XmlReporter bench.ConfigFormatException
* bench.Harness bench.TextReporter bench.rmi.BenchServer
* bench.rmi.DoubleArrayCalls bench.rmi.LongCalls bench.rmi.ShortCalls
* bench.rmi.BenchServerImpl bench.rmi.DoubleCalls bench.rmi.Main
* bench.rmi.SmallObjTreeCalls bench.rmi.BooleanArrayCalls
* bench.rmi.ExceptionCalls bench.rmi.NullCalls bench.rmi.BooleanCalls
* bench.rmi.ExportObjs bench.rmi.ObjArrayCalls bench.rmi.ByteArrayCalls
* bench.rmi.FloatArrayCalls bench.rmi.ObjTreeCalls bench.rmi.ByteCalls
* bench.rmi.FloatCalls bench.rmi.ProxyArrayCalls bench.rmi.CharArrayCalls
* bench.rmi.IntArrayCalls bench.rmi.RemoteObjArrayCalls bench.rmi.CharCalls
* bench.rmi.IntCalls bench.rmi.ClassLoading bench.rmi.LongArrayCalls
* bench.rmi.ShortArrayCalls
* bench.rmi.altroot.Node
* @run main/othervm/policy=policy.all/timeout=1800 bench.rmi.Main -server -c config
* @author Mike Warres, Nigel Daley
*/ */
package bench.rmi; package bench.rmi;
...@@ -33,21 +52,27 @@ import bench.HtmlReporter; ...@@ -33,21 +52,27 @@ import bench.HtmlReporter;
import bench.Reporter; import bench.Reporter;
import bench.TextReporter; import bench.TextReporter;
import bench.XmlReporter; import bench.XmlReporter;
import static bench.rmi.Main.OutputFormat.*;
import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.InputStream; import java.io.InputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.PrintStream; import java.io.PrintStream;
import java.rmi.AlreadyBoundException;
import java.rmi.NotBoundException;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import java.rmi.RMISecurityManager;
import java.rmi.registry.LocateRegistry; import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry; import java.rmi.registry.Registry;
import java.rmi.server.RemoteObject; import java.rmi.server.RemoteObject;
import java.util.ArrayList;
import java.util.List;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
/* /**
* RMI/Serialization benchmark tests. * RMI/Serialization benchmark tests.
*/ */
public class Main { public class Main {
...@@ -66,19 +91,20 @@ public class Main { ...@@ -66,19 +91,20 @@ public class Main {
/** /**
* Cleanup both client and server side in between each benchmark. * Cleanup both client and server side in between each benchmark.
*/ */
@Override
protected void cleanup() { protected void cleanup() {
System.gc(); System.gc();
if (Main.runmode == CLIENT) { if (Main.runmode == CLIENT) {
try { try {
Main.server.gc(); Main.server.gc();
} catch (Exception e) { } catch (RemoteException e) {
System.err.println("Warning: server gc failed: " + e); System.err.println("Warning: server gc failed: " + e);
} }
} }
} }
} }
static final String CONFFILE = "/bench/rmi/config"; static final String CONFFILE = "config";
static final String VERSION = "1.3"; static final String VERSION = "1.3";
static final String REGNAME = "server"; static final String REGNAME = "server";
...@@ -86,9 +112,32 @@ public class Main { ...@@ -86,9 +112,32 @@ public class Main {
static final int CLIENT = 1; static final int CLIENT = 1;
static final int SERVER = 2; static final int SERVER = 2;
static final int TEXT = 0; static enum OutputFormat {
static final int HTML = 1;
static final int XML = 2; TEXT {
@Override
Reporter getReport(String title) {
return new TextReporter(repstr, title);
}
},
HTML {
@Override
Reporter getReport(String title) {
return new HtmlReporter(repstr, title);
}
},
XML {
@Override
Reporter getReport(String title) {
return new XmlReporter(repstr, title);
}
};
abstract Reporter getReport(String title);
};
static final String TEST_SRC_PATH = System.getProperty("test.src") + File.separator;
static boolean verbose; static boolean verbose;
static boolean list; static boolean list;
...@@ -96,9 +145,11 @@ public class Main { ...@@ -96,9 +145,11 @@ public class Main {
static int testDurationSeconds; static int testDurationSeconds;
static volatile boolean exitRequested; static volatile boolean exitRequested;
static Timer timer; static Timer timer;
static int format = TEXT; static OutputFormat format = TEXT;
static int runmode; static int runmode;
static String confFile;
static InputStream confstr; static InputStream confstr;
static String repFile;
static OutputStream repstr; static OutputStream repstr;
static String host; static String host;
static int port; static int port;
...@@ -109,6 +160,8 @@ public class Main { ...@@ -109,6 +160,8 @@ public class Main {
/** /**
* Returns reference to benchmark server. * Returns reference to benchmark server.
*
* @return a benchmark server
*/ */
public static BenchServer getBenchServer() { public static BenchServer getBenchServer() {
return server; return server;
...@@ -126,44 +179,29 @@ public class Main { ...@@ -126,44 +179,29 @@ public class Main {
p.println(" -l list configuration file"); p.println(" -l list configuration file");
p.println(" -t <num hours> repeat benchmarks for specified number of hours"); p.println(" -t <num hours> repeat benchmarks for specified number of hours");
p.println(" -o <file> specify output file"); p.println(" -o <file> specify output file");
p.println(" -c <file> specify (non-default) " + p.println(" -c <file> specify (non-default) "
"configuration file"); + "configuration file");
p.println(" -html format output as html " + p.println(" -html format output as html "
"(default is text)"); + "(default is text)");
p.println(" -xml format output as xml"); p.println(" -xml format output as xml");
p.println(" -client <host:port> run benchmark client using server " + p.println(" -server run benchmark server ");
"on specified host/port"); p.println(" -client <host:port> run benchmark client using server "
p.println(" -server <port> run benchmark server on given port"); + "on specified host/port");
} }
/** /**
* Print error message and exit. * Throw RuntimeException that wrap message.
*
* @param mesg a message will be wrapped in the RuntimeException.
*/ */
static void die(String mesg) { static void die(String mesg) {
System.err.println(mesg); throw new RuntimeException(mesg);
System.exit(1);
}
/**
* Stop server and exit.
*/
public static void exit() {
switch (runmode) {
case CLIENT:
if (server != null) {
try {
server.terminate(0);
} catch (RemoteException re) {
// ignore
}
}
default:
System.exit(0);
}
} }
/** /**
* Benchmark mainline. * Benchmark mainline.
*
* @param args
*/ */
public static void main(String[] args) { public static void main(String[] args) {
setupSecurity(); setupSecurity();
...@@ -173,21 +211,78 @@ public class Main { ...@@ -173,21 +211,78 @@ public class Main {
listConfig(); listConfig();
} else { } else {
setupServer(); setupServer();
if (runmode != SERVER) { switch (runmode) {
setupHarness(); case SAMEVM:
setupReporter(); case CLIENT:
if (exitOnTimer) { setupHarness();
setupTimer(testDurationSeconds); setupReporter();
while (true) { if (exitOnTimer) {
setupTimer(testDurationSeconds);
do {
runBenchmarks();
} while (!exitRequested);
} else {
runBenchmarks(); runBenchmarks();
if (exitRequested) { }
exit(); break;
case SERVER:
//Setup for client mode, server will fork client process
//after its initiation.
List<String> clientProcessStr = new ArrayList<>();
clientProcessStr.add(System.getProperty("test.jdk") +
File.separator + "bin" + File.separator + "java");
String classpath = System.getProperty("java.class.path");
if (classpath != null) {
clientProcessStr.add("-cp");
clientProcessStr.add(classpath);
}
clientProcessStr.add("-Djava.security.policy=" + TEST_SRC_PATH + "policy.all");
clientProcessStr.add("-Dtest.src=" + TEST_SRC_PATH);
clientProcessStr.add("bench.rmi.Main"); //Client mode
if (verbose) {
clientProcessStr.add("-v");
}
if (list) {
clientProcessStr.add("-l");
}
clientProcessStr.add("-client");
clientProcessStr.add("localhost:" + port);
if (exitOnTimer) {
clientProcessStr.add("-t");
clientProcessStr.add(String.valueOf(testDurationSeconds / 3600));
}
if (repFile != null) {
clientProcessStr.add("-o");
clientProcessStr.add(repFile);
}
if (confFile != null) {
clientProcessStr.add("-c");
clientProcessStr.add(confFile);
}
switch (format) {
case HTML:
clientProcessStr.add("-html");
break;
case XML:
clientProcessStr.add("-xml");
break;
}
try {
Process client = new ProcessBuilder(clientProcessStr).
inheritIO().start();
client.waitFor();
int exitValue = client.exitValue();
if (0 != exitValue) {
die("Error: error happened in client process, exitValue = " + exitValue);
} }
} catch (IOException ex) {
die("Error: Unable start client process, ex=" + ex.getMessage());
} catch (InterruptedException ex) {
die("Error: Error happening to client process, ex=" + ex.getMessage());
} }
} else { break;
runBenchmarks();
exit();
}
} }
} }
} }
...@@ -197,78 +292,107 @@ public class Main { ...@@ -197,78 +292,107 @@ public class Main {
*/ */
static void parseArgs(String[] args) { static void parseArgs(String[] args) {
for (int i = 0; i < args.length; i++) { for (int i = 0; i < args.length; i++) {
if (args[i].equals("-h")) { switch (args[i]) {
usage(); case "-h":
System.exit(0); usage();
} else if (args[i].equals("-v")) { System.exit(0);
verbose = true; break;
} else if (args[i].equals("-l")) { case "-v":
list = true; verbose = true;
} else if (args[i].equals("-t")) { break;
if (++i >= args.length) case "-l":
die("Error: no timeout value specified"); list = true;
try { break;
exitOnTimer = true; case "-t":
testDurationSeconds = Integer.parseInt(args[i]) * 3600; if (++i >= args.length) {
} catch (Exception e) { die("Error: no timeout value specified");
die("Error: unable to determine timeout value"); }
} try {
} else if (args[i].equals("-o")) { exitOnTimer = true;
if (++i >= args.length) testDurationSeconds = Integer.parseInt(args[i]) * 3600;
die("Error: no output file specified"); } catch (NumberFormatException e) {
try { die("Error: unable to determine timeout value");
repstr = new FileOutputStream(args[i]); }
} catch (IOException e) { break;
die("Error: unable to open \"" + args[i] + "\""); case "-o":
} if (++i >= args.length) {
} else if (args[i].equals("-c")) { die("Error: no output file specified");
if (++i >= args.length) }
die("Error: no config file specified"); try {
try { repFile = args[i];
confstr = new FileInputStream(args[i]); repstr = new FileOutputStream(repFile);
} catch (IOException e) { } catch (FileNotFoundException e) {
die("Error: unable to open \"" + args[i] + "\""); die("Error: unable to open \"" + args[i] + "\"");
} }
} else if (args[i].equals("-html")) { break;
if (format != TEXT) case "-c":
die("Error: conflicting formats"); if (++i >= args.length) {
format = HTML; die("Error: no config file specified");
} else if (args[i].equals("-xml")) { }
if (format != TEXT) confFile = args[i];
die("Error: conflicting formats"); String confFullPath = TEST_SRC_PATH + confFile;
format = XML; try {
} else if (args[i].equals("-client")) { confstr = new FileInputStream(confFullPath);
if (runmode == CLIENT) } catch (FileNotFoundException e) {
die("Error: multiple -client options"); die("Error: unable to open \"" + confFullPath + "\"");
if (runmode == SERVER) }
die("Error: -client and -server options conflict"); break;
if (++i >= args.length) case "-html":
die("Error: -client missing host/port"); if (format != TEXT) {
try { die("Error: conflicting formats");
int sepi = args[i].indexOf(':'); }
host = args[i].substring(0, sepi); format = HTML;
port = Integer.parseInt(args[i].substring(sepi + 1)); break;
} catch (Exception e) { case "-xml":
die("Error: illegal host/port specified for -client"); if (format != TEXT) {
} die("Error: conflicting formats");
runmode = CLIENT; }
} else if (args[i].equals("-server")) { format = XML;
if (runmode == CLIENT) break;
die("Error: -client and -server options conflict"); case "-client":
if (runmode == SERVER) if (runmode == CLIENT) {
die("Error: multiple -server options"); die("Error: multiple -client options");
if (++i >= args.length) }
die("Error: -server missing port"); if (runmode == SERVER) {
try { die("Error: -client and -server options conflict");
port = Integer.parseInt(args[i]); }
} catch (Exception e) { if (++i >= args.length) {
die("Error: illegal port specified for -server"); die("Error: -client missing host/port");
} }
runmode = SERVER; try {
} else { String[] hostAndPort = args[i].split(":");
System.err.println("Illegal option: \"" + args[i] + "\""); if (hostAndPort.length != 2) {
usage(); die("Error: Invalid format host/port:" + args[i]);
System.exit(1); }
host = hostAndPort[0];
port = Integer.parseInt(hostAndPort[1]);
} catch (NumberFormatException e) {
die("Error: illegal host/port specified for -client");
}
runmode = CLIENT;
break;
case "-server":
if (runmode == CLIENT) {
die("Error: -client and -server options conflict");
}
if (runmode == SERVER) {
die("Error: multiple -server options");
}
try {
//This is the hack code because named package class has
//difficulty in accessing unamed package class. This
//should be removed ater JDK-8003358 is finished.
port = (int) Class.forName("TestLibrary")
.getMethod("getUnusedRandomPort")
.invoke(null);
} catch (ReflectiveOperationException ex) {
die("Error: can't get a free port " + ex);
}
runmode = SERVER;
break;
default:
usage();
die("Illegal option: \"" + args[i] + "\"");
} }
} }
} }
...@@ -277,27 +401,31 @@ public class Main { ...@@ -277,27 +401,31 @@ public class Main {
* Set up security manager and policy, if not set already. * Set up security manager and policy, if not set already.
*/ */
static void setupSecurity() { static void setupSecurity() {
if (System.getSecurityManager() != null) if (System.getSecurityManager() != null) {
return; return;
}
/* As of 1.4, it is too late to set the security policy /* As of 1.4, it is too late to set the security policy
* file at this point so these line have been commented out. * file at this point so these line have been commented out.
*/ */
//System.setProperty("java.security.policy", //System.setProperty("java.security.policy",
// Main.class.getResource("/bench/rmi/policy.all").toString()); // Main.class.getResource("/bench/rmi/policy.all").toString());
System.setSecurityManager(new RMISecurityManager()); System.setSecurityManager(new SecurityManager());
} }
/** /**
* Set up configuration file and report streams, if not set already. * Set up configuration file and report streams, if not set already.
*/ */
static void setupStreams() { static void setupStreams() {
if (repstr == null) if (repstr == null) {
repstr = System.out; repstr = System.out;
if (confstr == null) }
confstr = (new Main()).getClass().getResourceAsStream(CONFFILE); if (confstr == null) {
if (confstr == null) confstr = Main.class.getResourceAsStream(TEST_SRC_PATH + CONFFILE);
}
if (confstr == null) {
die("Error: unable to find default config file"); die("Error: unable to find default config file");
}
} }
/** /**
...@@ -323,7 +451,7 @@ public class Main { ...@@ -323,7 +451,7 @@ public class Main {
try { try {
serverImpl = new BenchServerImpl(); serverImpl = new BenchServerImpl();
server = (BenchServer) RemoteObject.toStub(serverImpl); server = (BenchServer) RemoteObject.toStub(serverImpl);
} catch (Exception e) { } catch (RemoteException e) {
die("Error: failed to create local server: " + e); die("Error: failed to create local server: " + e);
} }
if (verbose) if (verbose)
...@@ -334,7 +462,7 @@ public class Main { ...@@ -334,7 +462,7 @@ public class Main {
try { try {
Registry reg = LocateRegistry.getRegistry(host, port); Registry reg = LocateRegistry.getRegistry(host, port);
server = (BenchServer) reg.lookup(REGNAME); server = (BenchServer) reg.lookup(REGNAME);
} catch (Exception e) { } catch (NotBoundException | RemoteException e) {
die("Error: failed to connect to server: " + e); die("Error: failed to connect to server: " + e);
} }
if (server == null) { if (server == null) {
...@@ -351,7 +479,7 @@ public class Main { ...@@ -351,7 +479,7 @@ public class Main {
Registry reg = LocateRegistry.createRegistry(port); Registry reg = LocateRegistry.createRegistry(port);
serverImpl = new BenchServerImpl(); serverImpl = new BenchServerImpl();
reg.bind(REGNAME, serverImpl); reg.bind(REGNAME, serverImpl);
} catch (Exception e) { } catch (AlreadyBoundException | RemoteException e) {
die("Error: failed to initialize server: " + e); die("Error: failed to initialize server: " + e);
} }
if (verbose) { if (verbose) {
...@@ -368,18 +496,19 @@ public class Main { ...@@ -368,18 +496,19 @@ public class Main {
/** /**
* Set up the timer to end the test. * Set up the timer to end the test.
* *
* @param delay the amount of delay, in seconds, before requesting * @param delay the amount of delay, in seconds, before requesting the
* the process exit * process exit
*/ */
static void setupTimer(int delay) { static void setupTimer(int delay) {
timer = new Timer(true); timer = new Timer(true);
timer.schedule( timer.schedule(
new TimerTask() { new TimerTask() {
public void run() { @Override
exitRequested = true; public void run() {
} exitRequested = true;
}, }
delay * 1000); },
delay * 1000);
} }
/** /**
...@@ -404,23 +533,7 @@ public class Main { ...@@ -404,23 +533,7 @@ public class Main {
* Setup benchmark reporter. * Setup benchmark reporter.
*/ */
static void setupReporter() { static void setupReporter() {
String title = "RMI Benchmark, v" + VERSION; reporter = format.getReport("RMI Benchmark, v" + VERSION);
switch (format) {
case TEXT:
reporter = new TextReporter(repstr, title);
break;
case HTML:
reporter = new HtmlReporter(repstr, title);
break;
case XML:
reporter = new XmlReporter(repstr, title);
break;
default:
die("Error: unrecognized format type");
}
} }
/** /**
......
/* /*
* 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
...@@ -22,7 +22,29 @@ ...@@ -22,7 +22,29 @@
*/ */
/* /*
* * @test
* @summary The Serialization benchmark test. This java class is used to run the
* test under JTREG.
* @library ../../
* @build bench.BenchInfo bench.HtmlReporter bench.Util bench.Benchmark
* @build bench.Reporter bench.XmlReporter bench.ConfigFormatException
* @build bench.Harness bench.TextReporter
* @build bench.serial.BooleanArrays bench.serial.Booleans
* @build bench.serial.ByteArrays bench.serial.Bytes bench.serial.CharArrays
* @build bench.serial.Chars bench.serial.ClassDesc bench.serial.Cons
* @build bench.serial.CustomDefaultObjTrees bench.serial.CustomObjTrees
* @build bench.serial.DoubleArrays bench.serial.Doubles
* @build bench.serial.ExternObjTrees bench.serial.FloatArrays
* @build bench.serial.Floats bench.serial.GetPutFieldTrees
* @build bench.serial.IntArrays bench.serial.Ints bench.serial.LongArrays
* @build bench.serial.Longs bench.serial.Main bench.serial.ObjArrays
* @build bench.serial.ObjTrees bench.serial.ProxyArrays
* @build bench.serial.ProxyClassDesc bench.serial.RepeatObjs
* @build bench.serial.ReplaceTrees bench.serial.ShortArrays
* @build bench.serial.Shorts bench.serial.SmallObjTrees
* @build bench.serial.StreamBuffer bench.serial.Strings
* @run main/othervm/timeout=1800 bench.serial.Main -c jtreg-config
* @author Mike Warres, Nigel Daley
*/ */
package bench.serial; package bench.serial;
...@@ -33,7 +55,9 @@ import bench.HtmlReporter; ...@@ -33,7 +55,9 @@ import bench.HtmlReporter;
import bench.Reporter; import bench.Reporter;
import bench.TextReporter; import bench.TextReporter;
import bench.XmlReporter; import bench.XmlReporter;
import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.InputStream; import java.io.InputStream;
import java.io.IOException; import java.io.IOException;
...@@ -47,8 +71,9 @@ import java.util.TimerTask; ...@@ -47,8 +71,9 @@ import java.util.TimerTask;
*/ */
public class Main { public class Main {
static final String CONFFILE = "/bench/serial/config"; static final String CONFFILE = "config";
static final String VERSION = "1.3"; static final String VERSION = "1.3";
static final String TEST_SRC_PATH = System.getProperty("test.src") + File.separator;
static final int TEXT = 0; static final int TEXT = 0;
static final int HTML = 1; static final int HTML = 1;
...@@ -84,15 +109,18 @@ public class Main { ...@@ -84,15 +109,18 @@ public class Main {
} }
/** /**
* Print error message and exit. * Throw RuntimeException that wrap message.
*
* @param mesg a message will be wrapped in the RuntimeException.
*/ */
static void die(String mesg) { static void die(String mesg) {
System.err.println(mesg); throw new RuntimeException(mesg);
System.exit(1);
} }
/** /**
* Mainline parses command line, then hands off to benchmark harness. * Mainline parses command line, then hands off to benchmark harness.
*
* @param args
*/ */
public static void main(String[] args) { public static void main(String[] args) {
parseArgs(args); parseArgs(args);
...@@ -104,15 +132,11 @@ public class Main { ...@@ -104,15 +132,11 @@ public class Main {
setupReporter(); setupReporter();
if (exitOnTimer) { if (exitOnTimer) {
setupTimer(testDurationSeconds); setupTimer(testDurationSeconds);
while (true) { do {
runBenchmarks(); runBenchmarks();
if (exitRequested) { } while (!exitRequested);
System.exit(0);
}
}
} else { } else {
runBenchmarks(); runBenchmarks();
System.exit(0);
} }
} }
} }
...@@ -122,50 +146,59 @@ public class Main { ...@@ -122,50 +146,59 @@ public class Main {
*/ */
static void parseArgs(String[] args) { static void parseArgs(String[] args) {
for (int i = 0; i < args.length; i++) { for (int i = 0; i < args.length; i++) {
if (args[i].equals("-h")) { switch (args[i]) {
usage(); case "-h":
System.exit(0); usage();
} else if (args[i].equals("-v")) { System.exit(0);
verbose = true; break;
} else if (args[i].equals("-l")) { case "-v":
list = true; verbose = true;
} else if (args[i].equals("-t")) { break;
if (++i >= args.length) case "-l":
die("Error: no timeout value specified"); list = true;
try { break;
exitOnTimer = true; case "-t":
testDurationSeconds = Integer.parseInt(args[i]) * 3600; if (++i >= args.length)
} catch (Exception e) { die("Error: no timeout value specified");
die("Error: unable to determine timeout value"); try {
} exitOnTimer = true;
} else if (args[i].equals("-o")) { testDurationSeconds = Integer.parseInt(args[i]) * 3600;
if (++i >= args.length) } catch (NumberFormatException e) {
die("Error: no output file specified"); die("Error: unable to determine timeout value");
try { }
repstr = new FileOutputStream(args[i]); break;
} catch (IOException e) { case "-o":
die("Error: unable to open \"" + args[i] + "\""); if (++i >= args.length)
} die("Error: no output file specified");
} else if (args[i].equals("-c")) { try {
if (++i >= args.length) repstr = new FileOutputStream(args[i]);
die("Error: no config file specified"); } catch (FileNotFoundException e) {
try { die("Error: unable to open \"" + args[i] + "\"");
confstr = new FileInputStream(args[i]); }
} catch (IOException e) { break;
die("Error: unable to open \"" + args[i] + "\""); case "-c":
} if (++i >= args.length)
} else if (args[i].equals("-html")) { die("Error: no config file specified");
if (format != TEXT) String confFileName = TEST_SRC_PATH + args[i];
die("Error: conflicting formats"); try {
format = HTML; confstr = new FileInputStream(confFileName);
} else if (args[i].equals("-xml")) { } catch (FileNotFoundException e) {
if (format != TEXT) die("Error: unable to open \"" + confFileName + "\"");
die("Error: conflicting formats"); }
format = XML; break;
} else { case "-html":
System.err.println("Illegal option: \"" + args[i] + "\""); if (format != TEXT)
usage(); die("Error: conflicting formats");
System.exit(1); format = HTML;
break;
case "-xml":
if (format != TEXT)
die("Error: conflicting formats");
format = XML;
break;
default:
usage();
die("Illegal option: \"" + args[i] + "\"");
} }
} }
} }
...@@ -177,7 +210,7 @@ public class Main { ...@@ -177,7 +210,7 @@ public class Main {
if (repstr == null) if (repstr == null)
repstr = System.out; repstr = System.out;
if (confstr == null) if (confstr == null)
confstr = (new Main()).getClass().getResourceAsStream(CONFFILE); confstr = Main.class.getResourceAsStream(TEST_SRC_PATH + CONFFILE);
if (confstr == null) if (confstr == null)
die("Error: unable to find default config file"); die("Error: unable to find default config file");
} }
...@@ -206,6 +239,7 @@ public class Main { ...@@ -206,6 +239,7 @@ public class Main {
timer = new Timer(true); timer = new Timer(true);
timer.schedule( timer.schedule(
new TimerTask() { new TimerTask() {
@Override
public void run() { public void run() {
exitRequested = true; exitRequested = true;
} }
......
#
# Copyright (c) 2005, 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
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
# @test
#
# @summary The RMI benchmark test. This script is only
# used to run the test under JTREG.
#
# @build bench.BenchInfo bench.HtmlReporter bench.Util bench.Benchmark
# bench.Reporter bench.XmlReporter bench.ConfigFormatException
# bench.Harness bench.TextReporter bench.rmi.BenchServer
# bench.rmi.DoubleArrayCalls bench.rmi.LongCalls bench.rmi.ShortCalls
# bench.rmi.BenchServerImpl bench.rmi.DoubleCalls
# bench.rmi.Main bench.rmi.SmallObjTreeCalls
# bench.rmi.BooleanArrayCalls bench.rmi.ExceptionCalls
# bench.rmi.NullCalls bench.rmi.BooleanCalls bench.rmi.ExportObjs
# bench.rmi.ObjArrayCalls bench.rmi.ByteArrayCalls
# bench.rmi.FloatArrayCalls bench.rmi.ObjTreeCalls
# bench.rmi.ByteCalls bench.rmi.FloatCalls bench.rmi.ProxyArrayCalls
# bench.rmi.CharArrayCalls bench.rmi.IntArrayCalls
# bench.rmi.RemoteObjArrayCalls bench.rmi.CharCalls bench.rmi.IntCalls
# bench.rmi.ClassLoading bench.rmi.LongArrayCalls
# bench.rmi.ShortArrayCalls bench.rmi.altroot.Node
#
# @run shell/timeout=1800 runRmiBench.sh
#
# @author Mike Warres, Nigel Daley
echo "Starting RMI benchmark server "
$TESTJAVA/bin/java \
-server \
-cp $TESTCLASSES \
-Djava.security.policy=$TESTSRC/bench/rmi/policy.all \
bench.rmi.Main \
-server 2007 \
-c $TESTSRC/bench/rmi/config &
sleep 10
echo "Starting RMI benchmark client "
$TESTJAVA/bin/java \
-client \
-cp $TESTCLASSES \
-Djava.security.policy=$TESTSRC/bench/rmi/policy.all \
bench.rmi.Main \
-client localhost:2007 \
-c $TESTSRC/bench/rmi/config
#
# Copyright (c) 2005, 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
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
# @test
#
# @summary The Serialization benchmark test. This script is only
# used to run the test under JTREG.
#
# @build bench.BenchInfo bench.HtmlReporter bench.Util bench.Benchmark
# @build bench.Reporter bench.XmlReporter bench.ConfigFormatException
# @build bench.Harness bench.TextReporter
# @build bench.serial.BooleanArrays bench.serial.Booleans
# @build bench.serial.ByteArrays bench.serial.Bytes bench.serial.CharArrays
# @build bench.serial.Chars bench.serial.ClassDesc bench.serial.Cons
# @build bench.serial.CustomDefaultObjTrees bench.serial.CustomObjTrees
# @build bench.serial.DoubleArrays bench.serial.Doubles
# @build bench.serial.ExternObjTrees bench.serial.FloatArrays
# @build bench.serial.Floats bench.serial.GetPutFieldTrees
# @build bench.serial.IntArrays bench.serial.Ints bench.serial.LongArrays
# @build bench.serial.Longs bench.serial.Main bench.serial.ObjArrays
# @build bench.serial.ObjTrees bench.serial.ProxyArrays
# @build bench.serial.ProxyClassDesc bench.serial.RepeatObjs
# @build bench.serial.ReplaceTrees bench.serial.ShortArrays
# @build bench.serial.Shorts bench.serial.SmallObjTrees
# @build bench.serial.StreamBuffer bench.serial.Strings
#
# @run shell/timeout=1800 runSerialBench.sh
#
# @author Mike Warres, Nigel Daley
echo "Starting serialization benchmark "
$TESTJAVA/bin/java \
${TESTVMOPTS} \
-cp $TESTCLASSES \
bench.serial.Main \
-c $TESTSRC/bench/serial/jtreg-config &
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册