1
1
/*
2
- * Copyright (c) 2015, 2023 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2015, 2025 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
@@ -40,7 +40,10 @@ public class TestOnError {
40
40
41
41
public static void main (String [] args ) throws Exception {
42
42
String msg = "Test Succeeded" ;
43
+ String msg1 = "OnError Test Message1" ;
44
+ String msg2 = "OnError Test Message2" ;
43
45
46
+ // Basic OnError test:
44
47
ProcessBuilder pb = ProcessTools .createLimitedTestJavaProcessBuilder (
45
48
"-XX:-CreateCoredumpOnCrash" ,
46
49
"-XX:ErrorHandlerTest=14" , // trigger potential SEGV
@@ -59,6 +62,30 @@ public static void main(String[] args) throws Exception {
59
62
both get written to stdout.
60
63
*/
61
64
output .stdoutShouldMatch ("^" + msg ); // match start of line only
65
+
66
+ // Test multiple OnError arguments:
67
+ pb = ProcessTools .createLimitedTestJavaProcessBuilder (
68
+ "-XX:-CreateCoredumpOnCrash" ,
69
+ "-XX:ErrorHandlerTest=14" ,
70
+ "-XX:OnError=echo " + msg1 ,
71
+ "-XX:OnError=echo " + msg2 ,
72
+ TestOnError .class .getName ());
73
+
74
+ output = new OutputAnalyzer (pb .start ());
75
+ output .stdoutShouldMatch ("^" + msg1 );
76
+ output .stdoutShouldMatch ("^" + msg2 );
77
+
78
+ // Test one argument with multiple commands using ; separator:
79
+ pb = ProcessTools .createLimitedTestJavaProcessBuilder (
80
+ "-XX:-CreateCoredumpOnCrash" ,
81
+ "-XX:ErrorHandlerTest=14" ,
82
+ "-XX:OnError=echo " + msg1 + ";echo " + msg2 ,
83
+ TestOnError .class .getName ());
84
+
85
+ output = new OutputAnalyzer (pb .start ());
86
+ output .stdoutShouldMatch ("^" + msg1 );
87
+ output .stdoutShouldMatch ("^" + msg2 );
88
+
62
89
System .out .println ("PASSED" );
63
90
}
64
91
}
0 commit comments