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); ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args);
OutputAnalyzer output = new OutputAnalyzer(pb.start()); OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(0);
return output; return output;
} }

View File

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

View File

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