TestState fails with assertion error on state.phase
With ExternalMedia 3.3.0 and OM nightly (i.e. >1.17), running ExternalMedia.Test.TestMedium.TestState fails with
The following assertion has been violated at time 0.002000
state.phase >= 0 and state.phase <= 2
Variable violating min/max constraint: 0 <= state.phase <= 2, has value: 1
Note that the printed value actually complies with the required assertion range! Maybe the passed value is a string or somesuch type that fails the assertion but looks identical when printed?
I suspect that this compilation warning (also reported in #10) could be connected:
TestState_functions.c:52:65: warning: incompatible pointer types passing 'ExternalMedia_Test_TestMedium_TestState_Medium_ThermodynamicState *' to parameter of type 'ExternalThermodynamicState *' (aka 'struct ExternalThermodynamicState *') [-Wincompatible-pointer-types]
TwoPhaseMedium_setState_ph_C_impl(_p_ext, _h_ext, _phase_ext, &_state_ext, MMC_STRINGDATA(MMC_REFSTRINGLIT(tmp1)), MMC_STRINGDATA(MMC_REFSTRINGLIT(tmp2)), MMC_STRINGDATA(MMC_REFSTRINGLIT(tmp3)));
^~~~~~~~~~~
<...>/Modelica/ExternalMedia 3.3.0/Resources/Include\externalmedialib.h:170:121: note: passing argument to parameter 'state' here
EXTERNALMEDIA_EXPORT void TwoPhaseMedium_setState_ph_C_impl(double p, double h, int phase, ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName);
^
An equivalent problem occurs in function TwoPhaseMedium_setState_pT_C_impl (see also #10).
Btw, I don't know if runtests.mos is actually used, but it's missing the tests TestMedium.TestConstants, TestMedium.TestState, TestMedium.TestSat.
A quick re-check with OM 1.18.1 and the new ExternalMedia 3.3.1 shows that this still occurs.
Probably related to https://github.com/OpenModelica/OpenModelica/issues/8591.
I checked with a recent OM nightly (1.21.0-dev-318) and current master (db55653) with binaries from the CI job, and the assertion does not print anymore.
The compilation warning still occurs:
TestState_functions.c:50:70: warning: incompatible pointer types passing 'ExternalMedia_Test_TestMedium_TestState_Medium_ThermodynamicState_external *' to parameter of type 'ExternalThermodynamicState *' (aka 'struct ExternalThermodynamicState *') [-Wincompatible-pointer-types]
TwoPhaseMedium_setState_ph_C_impl_wrap(_p_ext, _h_ext, _phase_ext, &_state_ext, MMC_STRINGDATA(MMC_REFSTRINGLIT(tmp1)), MMC_STRINGDATA(MMC_REFSTRINGLIT(tmp2)), MMC_STRINGDATA(MMC_REFSTRINGLIT(tmp3)));
^~~~~~~~~~~
./TestState_includes.h:13:108: note: passing argument to parameter 'state' here
void TwoPhaseMedium_setState_ph_C_impl_wrap(double p, double h, int phase, ExternalThermodynamicState *state, const char *mediumName, const char *libraryName, const char *substanceName)
The runtests.mos files seems heavily outdated/old, but that's probably easy to fix/not that relevant anymore.
This should be fixed with ExternalMedia 3.3.2, if used with OMC 1.21.0 or later