< prev index next >

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

Print this page

        

*** 23,33 **** --- 23,36 ---- package optionsvalidation; import com.sun.tools.attach.VirtualMachine; import com.sun.tools.attach.AttachOperationFailedException; import java.util.ArrayList; + import java.util.Arrays; + import java.util.HashSet; import java.util.List; + import java.util.Set; import jdk.test.lib.DynamicVMOption; import jdk.test.lib.OutputAnalyzer; import jdk.test.lib.ProcessTools; import jdk.test.lib.dcmd.CommandExecutor; import jdk.test.lib.dcmd.JMXExecutor;
*** 62,80 **** --- 65,88 ---- /** * Test valid max range value and additional big values */ protected boolean testMaxRange; + private Set<Integer> allowedExitCodes; + /** * Prepend string which added before testing option to the command line */ private final List<String> prepend; private final StringBuilder prependString; protected JVMOption() { this.prepend = new ArrayList<>(); prependString = new StringBuilder(); + allowedExitCodes = new HashSet<>(); + allowedExitCodes.add(0); + allowedExitCodes.add(1); withRange = false; testMinRange = true; testMaxRange = true; }
*** 159,168 **** --- 167,180 ---- */ public final void excludeTestMaxRange() { testMaxRange = false; } + public final void setAllowedExitCodes(Integer... allowedExitCodes) { + this.allowedExitCodes.addAll(Arrays.asList(allowedExitCodes)); + } + /** * Set new minimum option value * * @param min new minimum value */
*** 382,398 **** /* 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; --- 394,410 ---- /* 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 (!allowedExitCodes.contains(exitCode)) { failedMessage(name, fullOptionString, valid, "JVM exited with unexpected error code = " + exitCode); printOutputContent(out); result = false; ! } else if ((exitCode != 0) && (out.getOutput().isEmpty() == true)) { ! failedMessage(name, fullOptionString, valid, "JVM exited with error(exitcode == " + exitCode + ! + "), 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;
< prev index next >