function(test_castem2 test_arg)
  foreach(rm ${IEEE754_ROUNDING_MODES})
    set(test "castem2${test_arg}_${rm}_mtest")
    set(file "${CMAKE_CURRENT_SOURCE_DIR}/castem2${test_arg}.mtest")
    set(_mtest_args)
    list(APPEND _mtest_args --rounding-direction-mode=${rm} )
    list(APPEND _mtest_args --verbose=level0)
    list(APPEND _mtest_args --result-file-output=false)
    list(APPEND _mtest_args --@interface@=umat)
    list(APPEND _mtest_args --@library@="$<TARGET_FILE:MFrontCastemBehaviours>")
    list(APPEND _mtest_args --@top_srcdir@=${PROJECT_SOURCE_DIR})
    list(APPEND _mtest_args --@mplibrary@="$<TARGET_FILE:MFrontMaterialProperties-castem>")
    list(APPEND _mtest_args --@reference_file@="${_REFERENCE_FILE}")
    if(_NO_XML_OUTPUT)
      list(APPEND _mtest_args --xml-output=false)
    else(_NO_XML_OUTPUT)
      list(APPEND _mtest_args --xml-output=true)
    endif(_NO_XML_OUTPUT)
    add_test(NAME ${test} COMMAND mtest ${_mtest_args} ${file})
    if((CMAKE_HOST_WIN32) AND (NOT MSYS))
     set_property(TEST ${test}
       PROPERTY ENVIRONMENT "PATH=$<TARGET_FILE_DIR:TFELMTest>\;$<TARGET_FILE_DIR:TFELMFront>\;$<TARGET_FILE_DIR:MFrontLogStream>\;$<TARGET_FILE_DIR:TFELMaterial>\;$<TARGET_FILE_DIR:TFELNUMODIS>\;$<TARGET_FILE_DIR:TFELMathParser>\;$<TARGET_FILE_DIR:TFELGlossary>\;$<TARGET_FILE_DIR:TFELSystem>\;$<TARGET_FILE_DIR:TFELUtilities>\;$<TARGET_FILE_DIR:TFELException>\;$<TARGET_FILE_DIR:TFELTests>\;$<TARGET_FILE_DIR:TFELConfig>\;$<TARGET_FILE_DIR:TFELUnicodeSupport>\;$ENV{PATH}")
    endif((CMAKE_HOST_WIN32) AND (NOT MSYS))
    if(TFEL_APPEND_SUFFIX)
      install(FILES ${file}
        DESTINATION "share/doc/mfront-${TFEL_SUFFIX}/tests/behaviours/castem2"
        COMPONENT mtest)
    else(TFEL_APPEND_SUFFIX)
      install(FILES ${file}
        DESTINATION "share/doc/mfront/tests/behaviours/castem2"
        COMPONENT mtest)
    endif(TFEL_APPEND_SUFFIX)
  endforeach(rm ${IEEE754_ROUNDING_MODES})
endfunction(test_castem2)

test_castem2(elasticity)
test_castem2(elasticity2)
test_castem2(elasticity3)
test_castem2(elasticity4)
test_castem2(elasticity5)
test_castem2(elasticity6)
test_castem2(elasticity7)
test_castem2(elasticity8)
test_castem2(elasticity9)
test_castem2(elasticity10)
test_castem2(elasticity11)
test_castem2(elasticity12)
test_castem2(elasticity13)
test_castem2(elasticity14)
test_castem2(elasticity15)
test_castem2(elasticity16)
test_castem2(druckerprager)
test_castem2(druckerprager2)
test_castem2(norton)
test_castem2(norton2)
test_castem2(implicitnorton)
test_castem2(implicitnorton3)
test_castem2(stressrelaxation)
test_castem2(strainhardeningcreep)
test_castem2(plasticity)
test_castem2(plasisocin)
test_castem2(viscoplasisocin)
test_castem2(chaboche)
test_castem2(chaboche2)
test_castem2(monocrystal)
test_castem2(monocrystal-2)
test_castem2(implicitmonocrystal)
test_castem2(implicitmonocrystal-2)
test_castem2(monocrystal_dd_cfc)
test_castem2(monocrystal_dd_cfc_numericaljacobian)
test_castem2(monocrystal_dd_cfc_irradiation)
test_castem2(monocrystal_dd_cc)
test_castem2(monocrystal_dd_cc_numericaljacobian)
test_castem2(monocrystal_dd_cc_irradiation_numericaljacobian)
test_castem2(implicithayhurst)
test_castem2(gursontvergaardneedlemanplasticflow)
test_castem2(gursontvergaardneedlemanviscoplasticflow)
test_castem2(ellipticcreep)
test_castem2(burger)
test_castem2(tssf)
test_castem2(saintvenantkirchhoffelasticity-uniaxialloading-sig11-1D)
test_castem2(saintvenantkirchhoffelasticity-uniaxialloading-sig22-1D)
test_castem2(saintvenantkirchhoffelasticity-uniaxialloading-sig33-1D)
test_castem2(saintvenantkirchhoffelasticity-uniaxialloading-sig11-2D)
test_castem2(saintvenantkirchhoffelasticity-uniaxialloading-sig22-2D)
test_castem2(saintvenantkirchhoffelasticity-uniaxialloading-sig33-2D)
test_castem2(saintvenantkirchhoffelasticity-uniaxialloading-sig11-3D)
test_castem2(saintvenantkirchhoffelasticity-uniaxialloading-sig22-3D)
test_castem2(saintvenantkirchhoffelasticity-uniaxialloading-sig33-3D)
test_castem2(saintvenantkirchhoffelasticity-uniaxialloading-1-1D)
test_castem2(saintvenantkirchhoffelasticity-uniaxialloading-2-1D)
test_castem2(saintvenantkirchhoffelasticity-uniaxialloading-3-1D)
test_castem2(saintvenantkirchhoffelasticity-uniaxialloading-1-2D)
test_castem2(saintvenantkirchhoffelasticity-uniaxialloading-2-2D)
test_castem2(saintvenantkirchhoffelasticity-uniaxialloading-3-2D)
test_castem2(saintvenantkirchhoffelasticity-shear-1-2D)
test_castem2(saintvenantkirchhoffelasticity-shear-2-2D)
test_castem2(saintvenantkirchhoffelasticity-uniaxialloading-1-3D)
test_castem2(saintvenantkirchhoffelasticity-uniaxialloading-2-3D)
test_castem2(saintvenantkirchhoffelasticity-uniaxialloading-3-3D)
test_castem2(saintvenantkirchhoffelasticity-shear-1-3D)
test_castem2(saintvenantkirchhoffelasticity-shear-2-3D)
test_castem2(saintvenantkirchhoffelasticity-shear-3-3D)
test_castem2(saintvenantkirchhoffelasticity-shear-4-3D)
test_castem2(saintvenantkirchhoffelasticity-shear-5-3D)
test_castem2(saintvenantkirchhoffelasticity-shear-6-3D)
test_castem2(finiterotationsmallstrainelasticity-uniaxialloading-1-1D)
test_castem2(finiterotationsmallstrainelasticity-uniaxialloading-2-1D)
test_castem2(finiterotationsmallstrainelasticity-uniaxialloading-3-1D)
test_castem2(finiterotationsmallstrainelasticity-uniaxialloading-1-2D)
test_castem2(finiterotationsmallstrainelasticity-uniaxialloading-2-2D)
test_castem2(finiterotationsmallstrainelasticity-uniaxialloading-3-2D)
test_castem2(finiterotationsmallstrainelasticity-shear-1-2D)
test_castem2(finiterotationsmallstrainelasticity-shear-2-2D)
test_castem2(finiterotationsmallstrainelasticity-uniaxialloading-1-3D)
test_castem2(finiterotationsmallstrainelasticity-uniaxialloading-2-3D)
test_castem2(finiterotationsmallstrainelasticity-uniaxialloading-3-3D)
test_castem2(finiterotationsmallstrainelasticity-shear-1-3D)
test_castem2(finiterotationsmallstrainelasticity-shear-2-3D)
test_castem2(finiterotationsmallstrainelasticity-shear-3-3D)
test_castem2(finiterotationsmallstrainelasticity-shear-4-3D)
test_castem2(finiterotationsmallstrainelasticity-shear-5-3D)
test_castem2(finiterotationsmallstrainelasticity-shear-6-3D)
test_castem2(finiterotationsmallstrainelasticity2-uniaxialloading-1-1D)
test_castem2(finiterotationsmallstrainelasticity2-uniaxialloading-2-1D)
test_castem2(finiterotationsmallstrainelasticity2-uniaxialloading-3-1D)
test_castem2(finiterotationsmallstrainelasticity2-uniaxialloading-1-2D)
test_castem2(finiterotationsmallstrainelasticity2-uniaxialloading-2-2D)
test_castem2(finiterotationsmallstrainelasticity2-uniaxialloading-3-2D)
test_castem2(finiterotationsmallstrainelasticity2-shear-1-2D)
test_castem2(finiterotationsmallstrainelasticity2-shear-2-2D)
test_castem2(finiterotationsmallstrainelasticity2-uniaxialloading-1-3D)
test_castem2(finiterotationsmallstrainelasticity2-uniaxialloading-2-3D)
test_castem2(finiterotationsmallstrainelasticity2-uniaxialloading-3-3D)
test_castem2(finiterotationsmallstrainelasticity2-shear-1-3D)
test_castem2(finiterotationsmallstrainelasticity2-shear-2-3D)
test_castem2(finiterotationsmallstrainelasticity2-shear-3-3D)
test_castem2(finiterotationsmallstrainelasticity2-shear-4-3D)
test_castem2(finiterotationsmallstrainelasticity2-shear-5-3D)
test_castem2(finiterotationsmallstrainelasticity2-shear-6-3D)

test_castem2(elasticity_malls-uniaxialloading-1-1D)
test_castem2(elasticity_malls-uniaxialloading-1-2D)
test_castem2(elasticity_malls-uniaxialloading-1-3D)
test_castem2(elasticity_malls-uniaxialloading-2-1D)
test_castem2(elasticity_malls-uniaxialloading-2-2D)
test_castem2(elasticity_malls-uniaxialloading-2-3D)
test_castem2(elasticity_malls-uniaxialloading-3-1D)
test_castem2(elasticity_malls-uniaxialloading-3-2D)
test_castem2(elasticity_malls-uniaxialloading-3-3D)
test_castem2(mieheapellambrechtlogarithmicstrainelasticity-uniaxialloading-1-1D)
test_castem2(mieheapellambrechtlogarithmicstrainelasticity-uniaxialloading-1-2D)
test_castem2(mieheapellambrechtlogarithmicstrainelasticity-uniaxialloading-1-3D)
test_castem2(mieheapellambrechtlogarithmicstrainelasticity-uniaxialloading-2-1D)
test_castem2(mieheapellambrechtlogarithmicstrainelasticity-uniaxialloading-2-2D)
test_castem2(mieheapellambrechtlogarithmicstrainelasticity-uniaxialloading-2-3D)
test_castem2(mieheapellambrechtlogarithmicstrainelasticity-uniaxialloading-3-1D)
test_castem2(mieheapellambrechtlogarithmicstrainelasticity-uniaxialloading-3-2D)
test_castem2(mieheapellambrechtlogarithmicstrainelasticity-uniaxialloading-3-3D)
test_castem2(mieheapellambrechtlogarithmicstrainelasticity2-uniaxialloading-1-1D)
test_castem2(mieheapellambrechtlogarithmicstrainelasticity2-uniaxialloading-1-2D)
test_castem2(mieheapellambrechtlogarithmicstrainelasticity2-uniaxialloading-1-3D)
test_castem2(mieheapellambrechtlogarithmicstrainelasticity2-uniaxialloading-2-1D)
test_castem2(mieheapellambrechtlogarithmicstrainelasticity2-uniaxialloading-2-2D)
test_castem2(mieheapellambrechtlogarithmicstrainelasticity2-uniaxialloading-2-3D)
test_castem2(mieheapellambrechtlogarithmicstrainelasticity2-uniaxialloading-3-1D)
test_castem2(mieheapellambrechtlogarithmicstrainelasticity2-uniaxialloading-3-2D)
test_castem2(mieheapellambrechtlogarithmicstrainelasticity2-uniaxialloading-3-3D)
test_castem2(mieheapellambrechtlogarithmicstrainelasticity3-uniaxialloading-1-1D)
test_castem2(mieheapellambrechtlogarithmicstrainelasticity3-uniaxialloading-1-2D)
test_castem2(mieheapellambrechtlogarithmicstrainelasticity3-uniaxialloading-1-3D)
test_castem2(mieheapellambrechtlogarithmicstrainelasticity3-uniaxialloading-2-1D)
test_castem2(mieheapellambrechtlogarithmicstrainelasticity3-uniaxialloading-2-2D)
test_castem2(mieheapellambrechtlogarithmicstrainelasticity3-uniaxialloading-2-3D)
test_castem2(mieheapellambrechtlogarithmicstrainelasticity3-uniaxialloading-3-1D)
test_castem2(mieheapellambrechtlogarithmicstrainelasticity3-uniaxialloading-3-2D)
test_castem2(mieheapellambrechtlogarithmicstrainelasticity3-uniaxialloading-3-3D)
test_castem2(mieheapellambrechtlogarithmicstrainnortoncreep-uniaxialloading-1-1D)
test_castem2(mieheapellambrechtlogarithmicstrainnortoncreep-uniaxialloading-1-2D)
test_castem2(mieheapellambrechtlogarithmicstrainnortoncreep-uniaxialloading-1-3D)
test_castem2(mieheapellambrechtlogarithmicstrainnortoncreep-uniaxialloading-2-1D)
test_castem2(mieheapellambrechtlogarithmicstrainnortoncreep-uniaxialloading-2-2D)
test_castem2(mieheapellambrechtlogarithmicstrainnortoncreep-uniaxialloading-2-3D)
test_castem2(mieheapellambrechtlogarithmicstrainnortoncreep-uniaxialloading-3-1D)
test_castem2(mieheapellambrechtlogarithmicstrainnortoncreep-uniaxialloading-3-2D)
test_castem2(mieheapellambrechtlogarithmicstrainnortoncreep-uniaxialloading-3-3D)
