< prev index next >

test/runtime/CommandLine/OptionsValidation/common/optionsvalidation/JVMOption.java

Print this page

        

*** 27,36 **** --- 27,37 ---- import com.sun.tools.attach.AttachOperationFailedException; import java.util.ArrayList; import java.util.List; import jdk.test.lib.DynamicVMOption; import jdk.test.lib.OutputAnalyzer; + import jdk.test.lib.Platform; import jdk.test.lib.ProcessTools; import jdk.test.lib.dcmd.CommandExecutor; import jdk.test.lib.dcmd.JMXExecutor; import sun.tools.attach.HotSpotVirtualMachine;
*** 42,51 **** --- 43,54 ---- /** * Executor for JCMD */ private final static CommandExecutor executor = new JMXExecutor(); + private final static boolean isClient = Platform.isClient(); + /** * Name of the tested parameter */ protected String name;
*** 75,96 **** */ static JVMOption createVMOption(String type, String name) { JVMOption parameter; switch (type) { case "intx": case "size_t": case "uintx": case "uint64_t": parameter = new IntJVMOption(name, type); break; case "double": parameter = new DoubleJVMOption(name); break; default: ! throw new Error("Expected only \"intx\", \"size_t\", \"uintx\", \"uint64_t\"," ! + " or \"double\" option types! Got " + type + " type!"); } return parameter; } --- 78,102 ---- */ static JVMOption createVMOption(String type, String name) { JVMOption parameter; switch (type) { + case "int": case "intx": case "size_t": + case "uint": case "uintx": case "uint64_t": parameter = new IntJVMOption(name, type); break; case "double": parameter = new DoubleJVMOption(name); break; default: ! throw new Error("Expected only \"int\", \"intx\", \"size_t\", " ! + "\"uint\", \"uintx\", \"uint64_t\", or \"double\" " ! + "option types! Got " + type + " type!"); } return parameter; }
*** 329,380 **** * @param valid indicates whether the JVM should fail or not * @return true - if test passed * @throws Exception if java process can not be started */ private boolean runJavaWithParam(String optionValue, boolean valid) throws Exception { ! int returnCode; boolean result = true; String value = optionValue.substring(optionValue.lastIndexOf("=") + 1); String fullOptionString = prependString.toString() + optionValue; List<String> runJava = new ArrayList<>(); OutputAnalyzer out; runJava.addAll(prepend); runJava.add(optionValue); runJava.add(JVMOptionsUtils.class.getName()); ! out = new OutputAnalyzer(ProcessTools.createJavaProcessBuilder(true, runJava.toArray(new String[0])).start()); ! returnCode = out.getExitValue(); if (out.getOutput().contains("A fatal error has been detected by the Java Runtime Environment")) { /* Always consider "fatal error" in output as fail */ ! failedMessage(name, fullOptionString, valid, "JVM output reports a fatal error. JVM exited with code " + returnCode + "!"); printOutputContent(out); result = false; } else if (valid == true) { ! if ((returnCode != 0) && (returnCode != 1)) { ! failedMessage(name, fullOptionString, valid, "JVM exited with unexpected error code = " + returnCode); printOutputContent(out); result = false; ! } else if ((returnCode == 1) && (out.getOutput().isEmpty() == true)) { failedMessage(name, fullOptionString, valid, "JVM exited with error(exitcode == 1)" + ", but with empty stdout and stderr. Description of error is needed!"); result = false; } else if (out.getOutput().contains("is outside the allowed range")) { failedMessage(name, fullOptionString, valid, "JVM output contains \"is outside the allowed range\""); printOutputContent(out); result = false; } } else { // valid == false ! if (returnCode == 0) { failedMessage(name, fullOptionString, valid, "JVM successfully exit"); result = false; ! } else if (returnCode != 1) { failedMessage(name, fullOptionString, valid, "JVM exited with code " ! + returnCode + " which not equal to 1"); result = false; } else if (!out.getOutput().contains(getErrorMessageCommandLine(value))) { failedMessage(name, fullOptionString, valid, "JVM output does not contain " + "expected output \"" + getErrorMessageCommandLine(value) + "\""); printOutputContent(out); --- 335,390 ---- * @param valid indicates whether the JVM should fail or not * @return true - if test passed * @throws Exception if java process can not be started */ private boolean runJavaWithParam(String optionValue, boolean valid) throws Exception { ! int exitCode; boolean result = true; String value = optionValue.substring(optionValue.lastIndexOf("=") + 1); String fullOptionString = prependString.toString() + optionValue; List<String> runJava = new ArrayList<>(); OutputAnalyzer out; + if (isClient) { + runJava.add("-client"); + } + runJava.addAll(prepend); runJava.add(optionValue); runJava.add(JVMOptionsUtils.class.getName()); ! out = new OutputAnalyzer(ProcessTools.createJavaProcessBuilder(runJava.toArray(new String[0])).start()); ! exitCode = out.getExitValue(); if (out.getOutput().contains("A fatal error has been detected by the Java Runtime Environment")) { /* Always consider "fatal error" in output as fail */ ! failedMessage(name, fullOptionString, valid, "JVM output reports a fatal error. JVM exited with code " + exitCode + "!"); printOutputContent(out); result = false; } else if (valid == true) { ! if ((exitCode != 0) && (exitCode != 1)) { ! failedMessage(name, fullOptionString, valid, "JVM exited with unexpected error code = " + exitCode); printOutputContent(out); result = false; ! } else if ((exitCode == 1) && (out.getOutput().isEmpty() == true)) { failedMessage(name, fullOptionString, valid, "JVM exited with error(exitcode == 1)" + ", but with empty stdout and stderr. Description of error is needed!"); result = false; } else if (out.getOutput().contains("is outside the allowed range")) { failedMessage(name, fullOptionString, valid, "JVM output contains \"is outside the allowed range\""); printOutputContent(out); result = false; } } else { // valid == false ! if (exitCode == 0) { failedMessage(name, fullOptionString, valid, "JVM successfully exit"); result = false; ! } else if (exitCode != 1) { failedMessage(name, fullOptionString, valid, "JVM exited with code " ! + exitCode + " which not equal to 1"); result = false; } else if (!out.getOutput().contains(getErrorMessageCommandLine(value))) { failedMessage(name, fullOptionString, valid, "JVM output does not contain " + "expected output \"" + getErrorMessageCommandLine(value) + "\""); printOutputContent(out);
< prev index next >