Changeset 13831


Ignore:
Timestamp:
Oct 23, 2019 9:47:23 PM (3 weeks ago)
Author:
Christian Andersson
Message:

Added tests for segfaults of external objects. Related to ticket:5863

Location:
branches/dev-cw-2613/Python/src/tests_jmodelica
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/dev-cw-2613/Python/src/tests_jmodelica/files/Modelica/ExtFunctionTests.mo

    r13719 r13831  
    11851185end MultiUse1;
    11861186
     1187model GlobalExtFunctionDestruction
     1188    package P
     1189    record R1
     1190        R2 r2;
     1191    end R1;
     1192    record R2
     1193        Real x;
     1194    end R2;
     1195   
     1196    model EO
     1197        extends ExternalObject;
     1198        function constructor
     1199            input R1 r1;
     1200            output EO eo;
     1201            external "C" eo=eo_constructor_record(r1) annotation(Library="extObjects", Include="#include \"extObjects.h\"");
     1202        end constructor;
     1203        function destructor
     1204            input EO eo;
     1205            external "C" eo_destructor_record(eo) annotation(Library="extObjects", Include="#include \"extObjects.h\"");
     1206        end destructor;
     1207    end EO;
     1208   
     1209    function f
     1210        input EO eo;
     1211        output Real y;
     1212        external "C" y=eo_use_record(eo) annotation(Library="extObjects", Include="#include \"extObjects.h\"");
     1213    end f;
     1214   
     1215    constant EO eo = EO(R1(R2(3)));
     1216    end P;
     1217   
     1218    function f
     1219        input Real x;
     1220        output Real y = x + P.f(P.eo);
     1221    algorithm
     1222    end f;
     1223
     1224    Real y = f(time);
     1225end GlobalExtFunctionDestruction;
     1226
    11871227end ExtFunctionTests;
  • branches/dev-cw-2613/Python/src/tests_jmodelica/general/test_extfunctions.py

    r13719 r13831  
    312312    def setUpClass(cls):
    313313        SimulationTest.setup_class_base('ExtFunctionTests.mo',
     314            'ExtFunctionTests.GlobalExtFunctionDestruction')
     315
     316    @testattr(stddist_full = True)
     317    def setUp(self):
     318        self.setup_base(start_time=0.0, final_time=0.1, time_step=0.01)
     319        self.run()
     320
     321    @testattr(stddist_full = True)
     322    def test_result(self):
     323        pass #We test that there is no segfault when destroying the FMU object
     324
     325class TestGlobalExternalRecordObj(SimulationTest):
     326    @classmethod
     327    def setUpClass(cls):
     328        SimulationTest.setup_class_base('ExtFunctionTests.mo',
    314329            'ExtFunctionTests.ExtFunctionRecordObj')
    315330
Note: See TracChangeset for help on using the changeset viewer.