Skip to content
This repository has been archived by the owner on May 18, 2019. It is now read-only.

Commit

Permalink
Improve stack overflow detection for compliance suite
Browse files Browse the repository at this point in the history
Belonging to [master]:
  - #2596
  • Loading branch information
sjoelund authored and OpenModelica-Hudson committed Aug 9, 2018
1 parent 9489b47 commit fabb954
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions Examples/ComplianceSuite.mos
Expand Up @@ -50,7 +50,13 @@ deleteClass(ModelicaCompliance.Scoping.NameLookup.Imports.QualifiedImportConflic
deleteClass(ModelicaCompliance.Redeclare.ClassExtends.ClassExtendsNonReplaceable); getErrorString();
*/

loadString(\"record OpenModelicaSimulationResult
String resultFile, messages;
end OpenModelicaSimulationResult;\");
// Give rec a value even if we overflow the stack and fail to execute the command
rec:=OpenModelicaSimulationResult(\"\", \"\");
rec:=simulate("+OpenModelica.Scripting.typeNameString(cl)+");err:=getErrorString();
resultFile := rec.resultFile;
loadString(\"
function length input String str; output Integer len; external \\\"C\\\" len=ModelicaStrings_length(str); end length;
function substring input String str; input Integer i1,i2; output String out; external \\\"C\\\" out=ModelicaStrings_substring(str,i1,i2); end substring;
Expand All @@ -62,22 +68,9 @@ algorithm
out := OpenModelica.Scripting.stringReplace(OpenModelica.Scripting.stringReplace(OpenModelica.Scripting.stringReplace(str,\\\"'\\\",\\\"\\\"),\\\"\\\\\\\"\\\",\\\"\\\"),\\\"\\\\\\\\\\\",\\\"\\\");
end fixName;
\");
if length(err) >= 21 then
print(substring(err, 1, 21));
b := \"Error: Stack overflow\" <> substring(err, 1, 21);
else
b := true;
end if;
resultFile := \"\";
if b then
resultFile := rec.resultFile;
end if;
shouldPass := OpenModelica.Scripting.getBooleanClassAnnotation("+OpenModelica.Scripting.typeNameString(cl)+",__ModelicaAssociation.TestCase.shouldPass);
success := if shouldPass then resultFile<>\"\" else resultFile==\"\";
messages := \"\";
if b then
messages := rec.messages;
end if;
messages := rec.messages;
messages := messages + err;
messages := messages + (if not success and not shouldPass /* This is correct; try to figure out why (hint: success is a poor name) */ then \"\nSucceeded, but expected failure\" else \"\");
messages := firstPart(messages);
Expand Down

1 comment on commit fabb954

@casella
Copy link

@casella casella commented on fabb954 Aug 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this commit having a negative impact on Compile, Backend and Simulate performance of some tests in the testsuite? https://libraries.openmodelica.org/branches/history/newInst/2018-08-08%2015:45:47..2018-08-09%2010:07:57.html

Please sign in to comment.