Skip to content

Commit

Permalink
Clean up test FMUs
Browse files Browse the repository at this point in the history
This fixes most of the issues described in #763. In particular, I have:

- removed FMUs with obscure origins
- removed unused FMUs (and some other unused test files)
- properly specified the origin and licence for the remaining FMUs
- modified tests so they only use the remaining FMUs
  • Loading branch information
kyllingstad committed Jun 17, 2024
1 parent 1b5b849 commit b91c580
Show file tree
Hide file tree
Showing 23 changed files with 126 additions and 137 deletions.
8 changes: 8 additions & 0 deletions tests/data/fmi1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# FMI 1.0 test FMUs

| Name | Origin | License |
| -------------- | ------------------- | ------------------------------------------- |
| `identity.fmu` | [ViProMa demo-fmus] | [BSD 3-clause](./viproma_demo-fmus_LICENSE) |


[ViProMa demo-fmus]: https://github.com/viproma/demo-fmus
27 changes: 27 additions & 0 deletions tests/data/fmi1/viproma_demo-fmus_LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright 2015-2019, SINTEF Ocean.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Binary file removed tests/data/fmi2/Clock.fmu
Binary file not shown.
File renamed without changes.
File renamed without changes.
17 changes: 7 additions & 10 deletions tests/data/fmi2/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
The FMUs in this directory (including its subdirectories) were downloaded
from the [FMI web site] (see "Test FMUs"). They were not created by SINTEF
Ocean or the CSE Core contributors, and have nothing to do with the CSE Core
software or the Open Simulation Platform project.
# FMI 2.0 test FMUs

The FMUs are:
| Name | Origin | License |
| ---------------------- | -------------- | ----------------------------- |
| `CraneController.fmu` | OSP | [MPL 2.0](../../../LICENSE) |
| `KnuckleBoomCrane.fmu` | OSP | [MPL 2.0](../../../LICENSE) |
| `vector.fmu` | [OSP cpp-fmus] | [MIT](./osp_cpp-fmus_LICENSE) |

- [WaterTank_control.fmu], an FMI 2.0 co-simulation FMU created by OpenModelica.

For more information about these, follow the links above.

[FMI web site]: https://fmi-standard.org/downloads
[WaterTank_control.fmu]: https://trac.fmi-standard.org/browser/branches/public/Test_FMUs/FMI_2.0/CoSimulation/linux32/OpenModelica/v1.11.0/WaterTank_Control
[OSP cpp-fmus]: https://github.com/open-simulation-platform/cpp-fmus
Binary file removed tests/data/fmi2/RoomHeating_OM_RH.fmu
Binary file not shown.
Binary file removed tests/data/fmi2/WaterTank_Control.fmu
Binary file not shown.
Binary file removed tests/data/fmi2/fail.fmu
Binary file not shown.
21 changes: 21 additions & 0 deletions tests/data/fmi2/osp_cpp-fmus_LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 DNV GL AS, Kongsberg Maritime CM AS, SINTEF Ocean AS, and NTNU

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
4 changes: 2 additions & 2 deletions tests/data/msmi/OspSystemStructure.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<BaseStepSize>1e-4</BaseStepSize>
<Algorithm>fixedStep</Algorithm>
<Simulators>
<Simulator name="CraneController" source="../ssp/demo/CraneController.fmu" stepSize="2e-4">
<Simulator name="CraneController" source="../fmi2/CraneController.fmu" stepSize="2e-4">
<InitialValues>
<InitialValue variable="cl1_min">
<Real value="2.2"/>
Expand All @@ -18,7 +18,7 @@
</InitialValue>
</InitialValues>
</Simulator>
<Simulator name="KnuckleBoomCrane" source="../ssp/demo/KnuckleBoomCrane.fmu" stepSize="2.03e-4">
<Simulator name="KnuckleBoomCrane" source="../fmi2/KnuckleBoomCrane.fmu" stepSize="2.03e-4">
<InitialValues/>
</Simulator>
<Simulator name="TrueIdentity" source="../fmi1/identity.fmu" stepSize="2.03e-4">
Expand Down
4 changes: 2 additions & 2 deletions tests/data/msmi/OspSystemStructure_Bond.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<BaseStepSize>1e-4</BaseStepSize>
<Algorithm>fixedStep</Algorithm>
<Simulators>
<Simulator name="CraneController" source="../ssp/demo/CraneController.fmu" stepSize="2e-4">
<Simulator name="CraneController" source="../fmi2/CraneController.fmu" stepSize="2e-4">
<InitialValues>
<InitialValue variable="cl1_min">
<Real value="2.2"/>
Expand All @@ -16,7 +16,7 @@
</InitialValue>
</InitialValues>
</Simulator>
<Simulator name="KnuckleBoomCrane" source="../ssp/demo/KnuckleBoomCrane.fmu" stepSize="2e-4"/>
<Simulator name="KnuckleBoomCrane" source="../fmi2/KnuckleBoomCrane.fmu" stepSize="2e-4"/>
<Simulator name="TrueIdentity" source="../fmi1/identity.fmu" stepSize="2.03e-4">
<InitialValues>
<InitialValue variable="booleanIn">
Expand Down
4 changes: 2 additions & 2 deletions tests/data/msmi/OspSystemStructure_EndTime.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<BaseStepSize>1e-4</BaseStepSize>
<Algorithm>fixedStep</Algorithm>
<Simulators>
<Simulator name="CraneController" source="../ssp/demo/CraneController.fmu" stepSize="2e-4">
<Simulator name="CraneController" source="../fmi2/CraneController.fmu" stepSize="2e-4">
<InitialValues>
<InitialValue variable="cl1_min">
<Real value="2.2"/>
Expand All @@ -19,7 +19,7 @@
</InitialValue>
</InitialValues>
</Simulator>
<Simulator name="KnuckleBoomCrane" source="../ssp/demo/KnuckleBoomCrane.fmu" stepSize="2.03e-4">
<Simulator name="KnuckleBoomCrane" source="../fmi2/KnuckleBoomCrane.fmu" stepSize="2.03e-4">
<InitialValues/>
</Simulator>
<Simulator name="TrueIdentity" source="../fmi1/identity.fmu" stepSize="2.03e-4">
Expand Down
4 changes: 2 additions & 2 deletions tests/data/msmi/OspSystemStructure_proxyfmu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<BaseStepSize>1e-4</BaseStepSize>
<Algorithm>fixedStep</Algorithm>
<Simulators>
<Simulator name="CraneController" source="proxyfmu://localhost?file=../ssp/demo/CraneController.fmu" stepSize="2e-4">
<Simulator name="CraneController" source="proxyfmu://localhost?file=../fmi2/CraneController.fmu" stepSize="2e-4">
<InitialValues>
<InitialValue variable="cl1_min">
<Real value="2.2"/>
Expand All @@ -16,7 +16,7 @@
</InitialValue>
</InitialValues>
</Simulator>
<Simulator name="KnuckleBoomCrane" source="proxyfmu://localhost?file=../ssp/demo/KnuckleBoomCrane.fmu" stepSize="2e-4"/>
<Simulator name="KnuckleBoomCrane" source="proxyfmu://localhost?file=../fmi2/KnuckleBoomCrane.fmu" stepSize="2e-4"/>
<Simulator name="TrueIdentity" source="proxyfmu://localhost?file=../fmi1/identity.fmu" stepSize="2.03e-4">
<InitialValues>
<InitialValue variable="booleanIn">
Expand Down
37 changes: 0 additions & 37 deletions tests/data/msmi/OspSystemStructure_vectorSum.xml

This file was deleted.

This file was deleted.

4 changes: 2 additions & 2 deletions tests/data/ssp/demo/SystemStructure.ssd
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<ssd:System name="cse-instance" description="An example of how to use Core Simulation Environment">

<ssd:Elements>
<ssd:Component name="CraneController" source="CraneController.fmu">
<ssd:Component name="CraneController" source="../../fmi2/CraneController.fmu">
<ssd:Connectors>
<ssd:Connector name="p_Crane.e[1]" kind="output"><ssc:Real/></ssd:Connector>
<ssd:Connector name="p_Crane.e[2]" kind="output"><ssc:Real/></ssd:Connector>
Expand All @@ -21,7 +21,7 @@
<ssd:Connector name="p_Crane.f[3]" kind="input"><ssc:Real/></ssd:Connector>
</ssd:Connectors>
</ssd:Component>
<ssd:Component name="KnuckleBoomCrane" source="KnuckleBoomCrane.fmu">
<ssd:Component name="KnuckleBoomCrane" source="../../fmi2/KnuckleBoomCrane.fmu">
<ssd:Connectors>
<ssd:Connector name="p_Crane.e[1]" kind="input"><ssc:Real/></ssd:Connector>
<ssd:Connector name="p_Crane.e[2]" kind="input"><ssc:Real/></ssd:Connector>
Expand Down
4 changes: 2 additions & 2 deletions tests/data/ssp/demo/no_algorithm_element/SystemStructure.ssd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<ssd:System name="cse-instance" description="An example of how to use Core Simulation Environment">

<ssd:Elements>
<ssd:Component name="CraneController" source="../CraneController.fmu">
<ssd:Component name="CraneController" source="../../../fmi2/CraneController.fmu">
<ssd:Connectors>
<ssd:Connector name="p_Crane.e[1]" kind="output"><ssc:Real/></ssd:Connector>
<ssd:Connector name="p_Crane.e[2]" kind="output"><ssc:Real/></ssd:Connector>
Expand All @@ -20,7 +20,7 @@
<ssd:Connector name="p_Crane.f[3]" kind="input"><ssc:Real/></ssd:Connector>
</ssd:Connectors>
</ssd:Component>
<ssd:Component name="KnuckleBoomCrane" source="../KnuckleBoomCrane.fmu">
<ssd:Component name="KnuckleBoomCrane" source="../../../fmi2/KnuckleBoomCrane.fmu">
<ssd:Connectors>
<ssd:Connector name="p_Crane.e[1]" kind="input"><ssc:Real/></ssd:Connector>
<ssd:Connector name="p_Crane.e[2]" kind="input"><ssc:Real/></ssd:Connector>
Expand Down
4 changes: 2 additions & 2 deletions tests/data/ssp/demo/proxy/SystemStructure.ssd
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<ssd:Elements>

<ssd:Component name="CraneController" source="proxyfmu://localhost?file=../CraneController.fmu">
<ssd:Component name="CraneController" source="proxyfmu://localhost?file=../../../fmi2/CraneController.fmu">
<ssd:Connectors>
<ssd:Connector name="p_Crane.e[1]" kind="output">
<ssc:Real/>
Expand Down Expand Up @@ -41,7 +41,7 @@
</ssd:Connectors>
</ssd:Component>

<ssd:Component name="KnuckleBoomCrane" source="proxyfmu://localhost?file=../KnuckleBoomCrane.fmu">
<ssd:Component name="KnuckleBoomCrane" source="proxyfmu://localhost?file=../../../fmi2/KnuckleBoomCrane.fmu">
<ssd:Connectors>
<ssd:Connector name="p_Crane.e[1]" kind="input">
<ssc:Real/>
Expand Down
50 changes: 23 additions & 27 deletions tests/fmi_v2_fmu_unittest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,16 @@ BOOST_AUTO_TEST_CASE(v2_fmu)
const auto testDataDir = std::getenv("TEST_DATA_DIR");
BOOST_TEST_REQUIRE(!!testDataDir);
auto importer = fmi::importer::create();
const std::string modelName = "WaterTank_Control";
auto fmu = importer->import(
cosim::filesystem::path(testDataDir) / "fmi2" / (modelName + ".fmu"));
cosim::filesystem::path(testDataDir) / "fmi2" / "vector.fmu");

BOOST_TEST(fmu->fmi_version() == fmi::fmi_version::v2_0);
const auto d = fmu->model_description();
BOOST_TEST(d->name == "WaterTank.Control");
BOOST_TEST(d->uuid == "{ad6d7bad-97d1-4fb9-ab3e-00a0d051e42c}");
BOOST_TEST(d->description.empty());
BOOST_TEST(d->author.empty());
BOOST_TEST(d->version.empty());
BOOST_TEST(d->name == "com.open-simulation-platform.vector");
BOOST_TEST(d->uuid == "b928fd8c-743f-50d0-b4bb-98bc5a5f804e");
BOOST_TEST(d->description == "Has one input and one input, both 3D vectors. Copies the input to the output each step.");
BOOST_TEST(d->author == "SINTEF Ocean & DNV GL");
BOOST_TEST(d->version == "0.1");
BOOST_TEST(std::static_pointer_cast<fmi::v2::fmu>(fmu)->fmilib_handle() != nullptr);
BOOST_TEST(cosim::filesystem::exists(
std::static_pointer_cast<fmi::v2::fmu>(fmu)->directory() / "modelDescription.xml"));
Expand All @@ -36,31 +35,28 @@ BOOST_AUTO_TEST_CASE(v2_fmu)
cosim::to_time_point(1.0),
std::nullopt);

bool foundValve = false;
bool foundMinlevel = false;
bool foundInput0 = false;
bool foundOutput1 = false;
for (const auto& v : d->variables) {
if (v.name == "valve") {
foundValve = true;
BOOST_TEST(v.variability == variable_variability::continuous);
BOOST_TEST(v.causality == variable_causality::output);
if (v.name == "input[0]") {
foundInput0 = true;
BOOST_TEST(v.type == variable_type::real);
BOOST_TEST(v.variability == variable_variability::discrete);
BOOST_TEST(v.causality == variable_causality::input);
double start = std::get<double>(*v.start);
BOOST_TEST(start == 0.0);
const auto varID = v.reference;
double varVal = -1.0;
instance->get_real_variables(gsl::make_span(&varID, 1), gsl::make_span(&varVal, 1));
instance->get_real_variables(
gsl::make_span(&v.reference, 1), gsl::make_span(&varVal, 1));
BOOST_TEST(varVal == 0.0);
} else if (v.name == "minlevel") {
foundMinlevel = true;
BOOST_TEST(v.variability == variable_variability::fixed);
BOOST_TEST(v.causality == variable_causality::parameter);
double start = std::get<double>(*v.start);
BOOST_TEST(start == 1.0);
const auto varID = v.reference;
double varVal = -1.0;
instance->get_real_variables(gsl::make_span(&varID, 1), gsl::make_span(&varVal, 1));
BOOST_TEST(varVal == 1.0);
} else if (v.name == "output[1]") {
foundOutput1 = true;
BOOST_TEST(v.type == variable_type::real);
BOOST_TEST(v.variability == variable_variability::discrete);
BOOST_TEST(v.causality == variable_causality::output);
BOOST_TEST(!v.start.has_value());
}
}
BOOST_TEST(foundValve);
BOOST_TEST(foundMinlevel);
BOOST_TEST(foundInput0);
BOOST_TEST(foundOutput1);
}
8 changes: 4 additions & 4 deletions tests/orchestration_unittest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ BOOST_AUTO_TEST_CASE(file_uri_sub_resolver_absolute_path_test)
{
const auto testDataDir = std::getenv("TEST_DATA_DIR");
BOOST_TEST_REQUIRE(!!testDataDir);
const auto path = cosim::filesystem::path(testDataDir) / "fmi2" / "Clock.fmu";
const auto path = cosim::filesystem::path(testDataDir) / "fmi2" / "vector.fmu";
const auto uri = cosim::path_to_file_uri(path);

cosim::model_uri_resolver resolver;
resolver.add_sub_resolver(std::make_shared<cosim::fmu_file_uri_sub_resolver>());

auto model = resolver.lookup_model(uri);
BOOST_TEST(model->description()->name == "Clock");
BOOST_TEST(model->description()->name == "com.open-simulation-platform.vector");
}


Expand All @@ -31,6 +31,6 @@ BOOST_AUTO_TEST_CASE(file_uri_sub_resolver_relative_path_test)
cosim::model_uri_resolver resolver;
resolver.add_sub_resolver(std::make_shared<cosim::fmu_file_uri_sub_resolver>());

auto model = resolver.lookup_model(baseUri, "fmi2/Clock.fmu");
BOOST_TEST(model->description()->name == "Clock");
auto model = resolver.lookup_model(baseUri, "fmi2/vector.fmu");
BOOST_TEST(model->description()->name == "com.open-simulation-platform.vector");
}
Loading

0 comments on commit b91c580

Please sign in to comment.