@@ -55,7 +55,8 @@ void throwsAndRecoversFromStackOverflow(CompilerHelper.CompilerConfig config) th
5555 compileArgs .add (sourceDir .resolve ("StackOverflowApp.java" ).toString ());
5656
5757 int compileResult = CompilerHelper .compile (config .jdkHome , compileArgs );
58- assertEquals (0 , compileResult , "StackOverflowApp should compile with " + config );
58+ assertEquals (0 , compileResult , "StackOverflowApp should compile with " + config +
59+ " error: " + CompilerHelper .getLastErrorLog ());
5960
6061 CompilerHelper .copyDirectory (javaApiDir , classesDir );
6162 Files .copy (sourceDir .resolve ("native_report.c" ), classesDir .resolve ("native_report.c" ));
@@ -92,22 +93,12 @@ void throwsAndRecoversFromStackOverflow(CompilerHelper.CompilerConfig config) th
9293 "StackOverflowApp probe run exited with code " + probeResult .exitCode
9394 + ". Output:\n " + probeResult .output
9495 + probeDiagnostics );
95- assertTrue (probeResult .output .contains ("PROBE_CONSTANT" ),
96- "StackOverflowApp probe run should succeed. Output was:\n " + probeResult .output + probeDiagnostics );
9796 ProcessResult smokeResult = runProcess (Arrays .asList (executable .toString (), "smoke" ), buildDir );
9897 String smokeDiagnostics = buildDiagnostics (srcRoot , executable , smokeResult );
9998 assertEquals (0 , smokeResult .exitCode ,
10099 "StackOverflowApp smoke run exited with code " + smokeResult .exitCode
101100 + ". Output:\n " + smokeResult .output
102101 + smokeDiagnostics );
103- assertTrue (smokeResult .output .contains ("PROBE_CONSTANT_ONE" ),
104- "StackOverflowApp smoke run should emit PROBE_CONSTANT_ONE. Output was:\n "
105- + smokeResult .output + smokeDiagnostics );
106- assertTrue (smokeResult .output .contains ("PROBE_CONSTANT_TWO" ),
107- "StackOverflowApp smoke run should emit PROBE_CONSTANT_TWO. Output was:\n "
108- + smokeResult .output
109- + "\n Missing PROBE_CONSTANT_TWO suggests a crash between the first and second print."
110- + smokeDiagnostics );
111102
112103 ProcessResult result = runProcess (Arrays .asList (executable .toString (), "overflow" , "run" ), buildDir );
113104 String diagnostics = buildDiagnostics (srcRoot , executable , result );
@@ -121,10 +112,11 @@ void throwsAndRecoversFromStackOverflow(CompilerHelper.CompilerConfig config) th
121112
122113 private String appSource () {
123114 return "public class StackOverflowApp {\n " +
115+ " private int counter;\n " +
124116 " private static native void report(String msg);\n " +
125- " private static native void reportConstant();\n " +
126- " private static native void reportConstantTwice();\n " +
127117 " private static void triggerOverflow() {\n " +
118+ " report(\" Calling ...\" + counter);\n " +
119+ " counter++;" +
128120 " triggerOverflow();\n " +
129121 " }\n " +
130122 " private static int boundedRecursion(int depth) {\n " +
@@ -134,14 +126,7 @@ private String appSource() {
134126 " return depth + boundedRecursion(depth - 1);\n " +
135127 " }\n " +
136128 " public static void main(String[] args) {\n " +
137- " if (args == null || args.length == 0) {\n " +
138- " reportConstant();\n " +
139- " return;\n " +
140- " }\n " +
141- " if (args.length == 1) {\n " +
142- " reportConstantTwice();\n " +
143- " return;\n " +
144- " }\n " +
129+ " report(\" Starting test...\" );\n " +
145130 " try {\n " +
146131 " triggerOverflow();\n " +
147132 " } catch (StackOverflowError err) {\n " +
@@ -154,16 +139,6 @@ private String appSource() {
154139 private String nativeReportSource () {
155140 return "#include \" cn1_globals.h\" \n " +
156141 "#include <stdio.h>\n " +
157- "void StackOverflowApp_reportConstant__(CODENAME_ONE_THREAD_STATE) {\n " +
158- " printf(\" PROBE_CONSTANT\\ n\" );\n " +
159- " fflush(stdout);\n " +
160- "}\n " +
161- "void StackOverflowApp_reportConstantTwice__(CODENAME_ONE_THREAD_STATE) {\n " +
162- " printf(\" PROBE_CONSTANT_ONE\\ n\" );\n " +
163- " fflush(stdout);\n " +
164- " printf(\" PROBE_CONSTANT_TWO\\ n\" );\n " +
165- " fflush(stdout);\n " +
166- "}\n " +
167142 "void StackOverflowApp_report___java_lang_String(CODENAME_ONE_THREAD_STATE, JAVA_OBJECT msg) {\n " +
168143 " struct String_Struct {\n " +
169144 " JAVA_OBJECT header;\n " +
@@ -247,7 +222,9 @@ private String buildDiagnostics(Path srcRoot, Path executable, ProcessResult res
247222 diagnostics .append ("\n report snippet: " )
248223 .append (extractSnippet (appSourceText , "StackOverflowApp_report___java_lang_String" , 120 ));
249224 }
250- if (!result .output .isEmpty ()) {
225+ if (result .output .isEmpty ()) {
226+ diagnostics .append ("\n ***No output printed" );
227+ } else {
251228 diagnostics .append ("\n Output length: " ).append (result .output .length ());
252229 }
253230 return diagnostics .toString ();
0 commit comments