Skip to content

Commit

Permalink
Add FMI test case for enumerations including omc and OMSimulator (#6772)
Browse files Browse the repository at this point in the history
  • Loading branch information
lochel committed Oct 13, 2020
1 parent a623029 commit 8f139b3
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 0 deletions.
2 changes: 2 additions & 0 deletions testsuite/omsimulator/Makefile
Expand Up @@ -4,6 +4,8 @@ TESTFILES = \
DualMassOscillator_cs.mos \
DualMassOscillator_me.mos \
DualMassOscillator.mos \
enumeration.mos \
enumeration2.mos \
initialization_omc.mos \
initialization.mos \
initialization2_omc.mos \
Expand Down
47 changes: 47 additions & 0 deletions testsuite/omsimulator/enumeration.mos
@@ -0,0 +1,47 @@
// keywords: fmu export import
// status: correct
// teardown_command: rm -rf Enumeration.lua Enumeration.fmu Enumeration.log Enumeration_systemCall.log temp-Enumeration/

loadString("
model Enumeration
type E = enumeration(one, two, three);
input E u(start=E.one);
output E y = u;
end Enumeration;
"); getErrorString();

buildModelFMU(Enumeration, version="2.0", fmuType="me", platforms={"static"}); getErrorString();

writeFile("Enumeration.lua", "
oms_setCommandLineOption(\"--suppressPath=true\")
oms_setTempDirectory(\"./temp-Enumeration/\")

oms_newModel(\"test\")
oms_addSystem(\"test.root\", oms_system_sc)
oms_addSubModel(\"test.root.A\", \"Enumeration.fmu\")
oms_addSubModel(\"test.root.B\", \"Enumeration.fmu\")
oms_addConnection(\"test.root.A.y\", \"test.root.B.u\")
oms_setResultFile(\"test\", \"\")

oms_instantiate(\"test\")
oms_initialize(\"test\")
oms_simulate(\"test\")
oms_terminate(\"test\")
oms_delete(\"test\")
"); getErrorString();

system(getInstallationDirectoryPath() + "/bin/OMSimulator Enumeration.lua", "Enumeration_systemCall.log");
readFile("Enumeration_systemCall.log");

// Result:
// true
// ""
// "Enumeration.fmu"
// ""
// true
// ""
// 0
// "info: model doesn't contain any continuous state
// info: No result file will be created
// "
// endResult
57 changes: 57 additions & 0 deletions testsuite/omsimulator/enumeration2.mos
@@ -0,0 +1,57 @@
// keywords: fmu export import
// status: correct
// teardown_command: rm -rf Enumeration2.lua Enum1.fmu Int1.fmu Enum1.log Int1.log Enumeration2_systemCall.log temp-Enumeration2/

loadString("
model Enum1
type E = enumeration(one, two, three);
input E u;
end Enum1;
"); getErrorString();

loadString("
model Int1
output Integer y = 2;
end Int1;
"); getErrorString();

buildModelFMU(Enum1, version="2.0", fmuType="me", platforms={"static"}); getErrorString();
buildModelFMU(Int1, version="2.0", fmuType="me", platforms={"static"}); getErrorString();

writeFile("Enumeration2.lua", "
oms_setCommandLineOption(\"--suppressPath=true\")
oms_setTempDirectory(\"./temp-Enumeration2/\")

oms_newModel(\"test\")
oms_addSystem(\"test.root\", oms_system_sc)
oms_addSubModel(\"test.root.A\", \"Int1.fmu\")
oms_addSubModel(\"test.root.B\", \"Enum1.fmu\")
oms_addConnection(\"test.root.A.y\", \"test.root.B.u\")
oms_setResultFile(\"test\", \"\")

oms_instantiate(\"test\")
oms_initialize(\"test\")
oms_simulate(\"test\")
oms_terminate(\"test\")
oms_delete(\"test\")
"); getErrorString();

system(getInstallationDirectoryPath() + "/bin/OMSimulator Enumeration2.lua", "Enumeration2_systemCall.log");
readFile("Enumeration2_systemCall.log");

// Result:
// true
// ""
// true
// ""
// "Enum1.fmu"
// ""
// "Int1.fmu"
// ""
// true
// ""
// 0
// "info: model doesn't contain any continuous state
// info: No result file will be created
// "
// endResult

0 comments on commit 8f139b3

Please sign in to comment.