mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 02:54:35 +02:00
8194831: [TESTBUG] Test runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java misleading error message
Only show the actual GC used in the error message. Show exit status in hex as well as decimal. Reviewed-by: dholmes
This commit is contained in:
parent
7c6a67a268
commit
c43b98c1ff
1 changed files with 17 additions and 8 deletions
|
@ -373,11 +373,12 @@ public abstract class JVMOption {
|
||||||
* @throws Exception if java process can not be started
|
* @throws Exception if java process can not be started
|
||||||
*/
|
*/
|
||||||
private boolean runJavaWithParam(String optionValue, boolean valid) throws Exception {
|
private boolean runJavaWithParam(String optionValue, boolean valid) throws Exception {
|
||||||
int exitCode;
|
int exitCode = 0;
|
||||||
boolean result = true;
|
boolean result = true;
|
||||||
String errorMessage = null;
|
String errorMessage = null;
|
||||||
|
String explicitGC = null;
|
||||||
List<String> runJava = new ArrayList<>();
|
List<String> runJava = new ArrayList<>();
|
||||||
OutputAnalyzer out;
|
OutputAnalyzer out = null;
|
||||||
|
|
||||||
if (VMType != null) {
|
if (VMType != null) {
|
||||||
runJava.add(VMType);
|
runJava.add(VMType);
|
||||||
|
@ -388,7 +389,11 @@ public abstract class JVMOption {
|
||||||
prepend.contains("-XX:+UseSerialGC") ||
|
prepend.contains("-XX:+UseSerialGC") ||
|
||||||
prepend.contains("-XX:+UseParallelGC") ||
|
prepend.contains("-XX:+UseParallelGC") ||
|
||||||
prepend.contains("-XX:+UseG1GC"))) {
|
prepend.contains("-XX:+UseG1GC"))) {
|
||||||
runJava.add(GCType);
|
explicitGC = GCType;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (explicitGC != null) {
|
||||||
|
runJava.add(explicitGC);
|
||||||
}
|
}
|
||||||
|
|
||||||
runJava.addAll(prepend);
|
runJava.addAll(prepend);
|
||||||
|
@ -398,15 +403,19 @@ public abstract class JVMOption {
|
||||||
out = new OutputAnalyzer(ProcessTools.createJavaProcessBuilder(runJava.toArray(new String[0])).start());
|
out = new OutputAnalyzer(ProcessTools.createJavaProcessBuilder(runJava.toArray(new String[0])).start());
|
||||||
|
|
||||||
exitCode = out.getExitValue();
|
exitCode = out.getExitValue();
|
||||||
|
String exitCodeString = null;
|
||||||
|
if (exitCode != 0) {
|
||||||
|
exitCodeString = exitCode + " [0x" + Integer.toHexString(exitCode).toUpperCase() + "]";
|
||||||
|
}
|
||||||
|
|
||||||
if (out.getOutput().contains("A fatal error has been detected by the Java Runtime Environment")) {
|
if (out.getOutput().contains("A fatal error has been detected by the Java Runtime Environment")) {
|
||||||
/* Always consider "fatal error" in output as fail */
|
/* Always consider "fatal error" in output as fail */
|
||||||
errorMessage = "JVM output reports a fatal error. JVM exited with code " + exitCode + "!";
|
errorMessage = "JVM output reports a fatal error. JVM exited with code " + exitCodeString + "!";
|
||||||
} else if (valid == true) {
|
} else if (valid == true) {
|
||||||
if (!allowedExitCodes.contains(exitCode)) {
|
if (!allowedExitCodes.contains(exitCode)) {
|
||||||
errorMessage = "JVM exited with unexpected error code = " + exitCode;
|
errorMessage = "JVM exited with unexpected error code = " + exitCodeString;
|
||||||
} else if ((exitCode != 0) && (out.getOutput().isEmpty() == true)) {
|
} else if ((exitCode != 0) && (out.getOutput().isEmpty() == true)) {
|
||||||
errorMessage = "JVM exited with error(exitcode == " + exitCode + "), but with empty stdout and stderr. " +
|
errorMessage = "JVM exited with error(exitcode == " + exitCodeString + "), but with empty stdout and stderr. " +
|
||||||
"Description of error is needed!";
|
"Description of error is needed!";
|
||||||
} else if (out.getOutput().contains("is outside the allowed range")) {
|
} else if (out.getOutput().contains("is outside the allowed range")) {
|
||||||
errorMessage = "JVM output contains \"is outside the allowed range\"";
|
errorMessage = "JVM output contains \"is outside the allowed range\"";
|
||||||
|
@ -418,7 +427,7 @@ public abstract class JVMOption {
|
||||||
if (exitCode == 0) {
|
if (exitCode == 0) {
|
||||||
errorMessage = "JVM successfully exit";
|
errorMessage = "JVM successfully exit";
|
||||||
} else if (exitCode != 1) {
|
} else if (exitCode != 1) {
|
||||||
errorMessage = "JVM exited with code " + exitCode + " which not equal to 1";
|
errorMessage = "JVM exited with code " + exitCodeString + " which does not equal to 1";
|
||||||
} else if (!out.getOutput().contains(errorMessageCommandLineValue)) {
|
} else if (!out.getOutput().contains(errorMessageCommandLineValue)) {
|
||||||
errorMessage = "JVM output does not contain expected output \"" + errorMessageCommandLineValue + "\"";
|
errorMessage = "JVM output does not contain expected output \"" + errorMessageCommandLineValue + "\"";
|
||||||
}
|
}
|
||||||
|
@ -426,7 +435,7 @@ public abstract class JVMOption {
|
||||||
|
|
||||||
if (errorMessage != null) {
|
if (errorMessage != null) {
|
||||||
String fullOptionString = String.format("%s %s %s %s",
|
String fullOptionString = String.format("%s %s %s %s",
|
||||||
VMType == null ? "" : VMType, GCType == null ? "" : GCType, prependString.toString(), optionValue).trim().replaceAll(" +", " ");
|
VMType == null ? "" : VMType, explicitGC == null ? "" : explicitGC, prependString.toString(), optionValue).trim().replaceAll(" +", " ");
|
||||||
failedMessage(name, fullOptionString, valid, errorMessage);
|
failedMessage(name, fullOptionString, valid, errorMessage);
|
||||||
printOutputContent(out);
|
printOutputContent(out);
|
||||||
result = false;
|
result = false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue