8268612: a few runtime/memory tests don't check exit code

Reviewed-by: dholmes, mseledtsov
This commit is contained in:
Igor Ignatyev 2021-07-21 19:47:03 +00:00
parent 6ce52e6277
commit 9b177a7486
3 changed files with 21 additions and 20 deletions

View File

@ -329,6 +329,7 @@ public class TestLargePagesFlags {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(0);
return output;
}

View File

@ -62,6 +62,7 @@ public class ReadFromNoaccessArea {
if (output.getStdout() != null && output.getStdout().contains("WB_ReadFromNoaccessArea method is useless")) {
throw new SkippedException("There is no protected page in ReservedHeapSpace in these circumstance");
}
output.shouldNotHaveExitValue(0);
if (Platform.isWindows()) {
output.shouldContain("EXCEPTION_ACCESS_VIOLATION");
} else if (Platform.isOSX()) {
@ -76,7 +77,6 @@ public class ReadFromNoaccessArea {
// This method calls whitebox method reading from noaccess area
public static void main(String args[]) throws Exception {
WhiteBox.getWhiteBox().readFromNoaccessArea();
throw new Exception("Call of readFromNoaccessArea succeeded! This is wrong. Crash expected. Test failed.");
}
}

View File

@ -44,27 +44,27 @@ import sun.hotspot.WhiteBox;
public class ReserveMemory {
public static void main(String args[]) throws Exception {
if (args.length > 0) {
// expected to crash
WhiteBox.getWhiteBox().readReservedMemory();
throw new Exception("Read of reserved/uncommitted memory unexpectedly succeeded, expected crash!");
}
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
"-Xbootclasspath/a:.",
"-XX:+UnlockDiagnosticVMOptions",
"-XX:+WhiteBoxAPI",
"-XX:-CreateCoredumpOnCrash",
"-Xmx128m",
"ReserveMemory",
"test");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
if (Platform.isWindows()) {
output.shouldContain("EXCEPTION_ACCESS_VIOLATION");
} else if (Platform.isOSX()) {
output.shouldContain("SIGBUS");
} else {
output.shouldContain("SIGSEGV");
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
"-Xbootclasspath/a:.",
"-XX:+UnlockDiagnosticVMOptions",
"-XX:+WhiteBoxAPI",
"-XX:-CreateCoredumpOnCrash",
"-Xmx128m",
"ReserveMemory",
"test");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldNotHaveExitValue(0);
if (Platform.isWindows()) {
output.shouldContain("EXCEPTION_ACCESS_VIOLATION");
} else if (Platform.isOSX()) {
output.shouldContain("SIGBUS");
} else {
output.shouldContain("SIGSEGV");
}
}
}
}