Commit a59e6c80 authored by Tomas Härdin's avatar Tomas Härdin

Don't pollute source tree with built FMUs

Patch all tests to pick up $FMUS_DIR
parent 0c7eee5b
build
builds
testout
*.pb.cc
*.pb.h
......@@ -16,4 +17,4 @@ tmp
*.bcf
*.snm
codelite
*.fmu
*.pyc
# Set BUILD_DIR if not set
if [ -z "${BUILD_DIR+x}" ]
then
export BUILD_DIR=$(pwd)/build
export BUILD_DIR="$(pwd)/build"
fi
export FMUS_DIR=$(pwd)/umit-fmus
export FMUS_DIR="${BUILD_DIR}/umit-fmus"
export PATH=$BUILD_DIR/install/bin:$PATH
export SERVER=fmigo-server
export MASTER=fmigo-master
......
......@@ -7,13 +7,13 @@ for e in $(fmigo-mpi -e); do export "$e"; done
if [ $USE_GPL -eq 1 ]
then
(cd ${FMUS_DIR}/me && ( ./test_me.sh || ( echo "failed modelExchange" && exit 1 ) ) )
(cd umit-fmus/me && ( ./test_me.sh || ( echo "failed modelExchange" && exit 1 ) ) )
(cd articles/truck && ( python test_gsl_trucks.py || ( echo "failed GSL truck test" && exit 1 ) ) )
fi
(cd articles/work-reports && ( ./run_tests.sh || ( echo "failed tests in work-reports" && exit 1 ) ) )
(cd ${FMUS_DIR}/tests && ( ./run_tests.sh || ( echo "failed umit-fmus tests" && exit 1 ) ) )
(cd umit-fmus/tests && ( ./run_tests.sh || ( echo "failed umit-fmus tests" && exit 1 ) ) )
(cd ${BUILD_DIR} && ( ctest || ( echo "ctest failed" && exit 1 ) ) )
(cd ${FMUS_DIR}/meWrapper && pwd &&( ./test_wrapper.sh || ( echo "failed wrapper" && exit 1 ) ) )
(cd umit-fmus/meWrapper &&( ./test_wrapper.sh || ( echo "failed wrapper" && exit 1 ) ) )
# Check -f none
touch empty_file
......@@ -42,8 +42,8 @@ done
rm temp
# Test wrapper, both Debug and Release
python umit-fmus/wrapper.py -t Debug umit-fmus/me/bouncingBall/bouncingBall.fmu ${BUILD_DIR}/bouncingBall_wrapped_Debug.fmu
python umit-fmus/wrapper.py -t Release umit-fmus/me/bouncingBall/bouncingBall.fmu ${BUILD_DIR}/bouncingBall_wrapped_Release.fmu
python umit-fmus/wrapper.py -t Debug ${FMUS_DIR}/me/bouncingBall/bouncingBall.fmu ${BUILD_DIR}/bouncingBall_wrapped_Debug.fmu
python umit-fmus/wrapper.py -t Release ${FMUS_DIR}/me/bouncingBall/bouncingBall.fmu ${BUILD_DIR}/bouncingBall_wrapped_Release.fmu
# Test alternative MPI command line
mpiexec -np 1 fmigo-mpi -f none \
......
......@@ -5,7 +5,6 @@
*.mex*
slprj/
nbproject/
*.fmu
*.log
*.aux
*.bbl
......
......@@ -37,26 +37,28 @@ function(copy_recursive TARGET BUILD_STEP distant dst)
endfunction()
function (add_fmu_internal dir target extra_srcs defs libs extra_includes console md2hdr_option xmldeps extra_resources)
set(${target}_fmu ${dir}/${target}.fmu CACHE INTERNAL "" FORCE)
set(${target}_dir ${dir} CACHE INTERNAL "" FORCE)
function (add_fmu_internal srcdir dstdir xmldir target extra_srcs defs libs extra_includes console md2hdr_option xmldeps extra_resources)
set(${target}_fmu ${dstdir}/${target}.fmu CACHE INTERNAL "" FORCE)
set(${target}_srcdir ${srcdir} CACHE INTERNAL "" FORCE)
set(${target}_dstdir ${srcdir} CACHE INTERNAL "" FORCE)
set(${target}_xmldir ${xmldir} CACHE INTERNAL "" FORCE)
set(${target}_packdir ${CMAKE_CURRENT_BINARY_DIR}/${target}/fmu CACHE INTERNAL "" FORCE)
file(GLOB fmu_sources ${${target}_dir}/sources/*)
file(GLOB fmu_sources ${${target}_srcdir}/sources/*)
set(binaries_dir ${CMAKE_CURRENT_BINARY_DIR}/${target}/binaries)
set(srcs
templates/fmi2/fmuTemplate.h
templates/fmi2/fmuTemplate_impl.h
templates/fmi2/strlcpy.h
${${target}_dir}/sources/modelDescription.h
${${target}_dstdir}/sources/modelDescription.h
${fmu_sources}
${extra_srcs}
)
set(includes
templates/fmi2
${${target}_dir}/sources
${${target}_srcdir}/sources
${extra_includes}
)
......@@ -66,16 +68,16 @@ function (add_fmu_internal dir target extra_srcs defs libs extra_includes consol
)
add_custom_command(
OUTPUT ${${target}_dir}/sources/modelDescription.h
COMMAND ${CMAKE_COMMAND} -E make_directory ${${target}_dir}/sources
OUTPUT ${${target}_dstdir}/sources/modelDescription.h
COMMAND ${CMAKE_COMMAND} -E make_directory ${${target}_dstdir}/sources
COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/wrapper/modeldescription2header.py ${md2hdr_option}
${${target}_dir}/modelDescription.xml >
${${target}_dir}/sources/modelDescription.h
DEPENDS ${${target}_dir}/modelDescription.xml ${xmldeps} ${CMAKE_CURRENT_SOURCE_DIR}/wrapper/modeldescription2header.py)
add_custom_target(${target}_md DEPENDS ${${target}_dir}/sources/modelDescription.h)
${${target}_xmldir}/modelDescription.xml >
${${target}_dstdir}/sources/modelDescription.h
DEPENDS ${${target}_xmldir}/modelDescription.xml ${xmldeps} ${CMAKE_CURRENT_SOURCE_DIR}/wrapper/modeldescription2header.py)
add_custom_target(${target}_md DEPENDS ${${target}_dstdir}/sources/modelDescription.h)
add_dependencies(${target} ${target}_md)
set_source_files_properties(${${target}_dir}/sources/modelDescription.h PROPERTIES GENERATED TRUE) # see further down
set_source_files_properties(${${target}_dstdir}/sources/modelDescription.h PROPERTIES GENERATED TRUE) # see further down
target_include_directories(${target} PUBLIC ${includes})
set_target_properties(${target} PROPERTIES PREFIX "")
......@@ -123,8 +125,8 @@ function (add_fmu_internal dir target extra_srcs defs libs extra_includes consol
)
endif ()
if (IS_DIRECTORY ${${target}_dir}/resources)
copy_recursive(${target} POST_BUILD ${${target}_dir}/resources ${${target}_packdir}/resources/)
if (IS_DIRECTORY ${${target}_srcdir}/resources)
copy_recursive(${target} POST_BUILD ${${target}_srcdir}/resources ${${target}_packdir}/resources/)
endif ()
if (NOT "${extra_resources}" STREQUAL "")
......@@ -132,7 +134,7 @@ function (add_fmu_internal dir target extra_srcs defs libs extra_includes consol
endif ()
add_custom_command(TARGET ${target} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${${target}_dir}/modelDescription.xml ${${target}_packdir}
COMMAND ${CMAKE_COMMAND} -E copy ${${target}_xmldir}/modelDescription.xml ${${target}_packdir}
)
add_custom_command(OUTPUT ${${target}_fmu}
......@@ -146,40 +148,40 @@ endfunction ()
function (add_fmu dir target extra_srcs defs libs console)
add_fmu_internal("${CMAKE_CURRENT_SOURCE_DIR}/${dir}" "${target}" "${extra_srcs}" "${defs}" "${libs}" "" "${console}" "" "" "")
add_fmu_internal("${CMAKE_CURRENT_SOURCE_DIR}/${dir}" "${CMAKE_CURRENT_BINARY_DIR}/${dir}" "${CMAKE_CURRENT_SOURCE_DIR}/${dir}" "${target}" "${extra_srcs}" "${defs}" "${libs}" "" "${console}" "" "" "")
endfunction ()
function (add_wrapped dir sourcetarget)
set(target "wrapper_${sourcetarget}")
set(srcxml "${${sourcetarget}_dir}/modelDescription.xml")
set(dstxml ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/modelDescription.xml)
set(srcxml "${${sourcetarget}_xmldir}/modelDescription.xml")
set(dstxml ${CMAKE_CURRENT_BINARY_DIR}/${dir}/modelDescription.xml)
add_custom_command(
OUTPUT ${dstxml}
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_SOURCE_DIR}/${dir}
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${dir}
COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/wrapper/xml2wrappedxml.py
-x ${srcxml} -f "${${sourcetarget}_fmu}" -i ${target} > ${dstxml}
DEPENDS ${srcxml} ${sourcetarget} ${CMAKE_CURRENT_SOURCE_DIR}/wrapper/xml2wrappedxml.py)
add_custom_target(${target}_xml DEPENDS ${dstxml})
add_fmu_internal("${CMAKE_CURRENT_SOURCE_DIR}/${dir}" "${target}" "wrapper/sources/wrapper.c" "" "cgsl;wrapperlib;fmilib" "wrapper/sources" FALSE "-w" "${target}_xml" "${${sourcetarget}_fmu}")
add_fmu_internal("${CMAKE_CURRENT_SOURCE_DIR}/${dir}" "${CMAKE_CURRENT_BINARY_DIR}/${dir}" "${CMAKE_CURRENT_BINARY_DIR}/${dir}" "${target}" "wrapper/sources/wrapper.c" "" "cgsl;wrapperlib;fmilib" "wrapper/sources" FALSE "-w" "${target}_xml" "${${sourcetarget}_fmu}")
endfunction ()
function (add_wrapped_fmu dir sourcetarget sourcefmu)
set(target wrapperfmu_${sourcetarget})
set(dstxml ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/modelDescription.xml)
set(dstxml ${CMAKE_CURRENT_BINARY_DIR}/${dir}/modelDescription.xml)
add_custom_command(
OUTPUT ${dstxml}
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_SOURCE_DIR}/${dir}
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${dir}
COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/wrapper/xml2wrappedxml.py
-f ${sourcefmu} -i ${target} > ${dstxml}
DEPENDS ${sourcefmu} ${sourcetarget}_fmu_target ${CMAKE_CURRENT_SOURCE_DIR}/wrapper/xml2wrappedxml.py)
add_custom_target(${target}_xml DEPENDS ${dstxml})
add_fmu_internal("${CMAKE_CURRENT_SOURCE_DIR}/${dir}" "${target}" "wrapper/sources/wrapper.c" "" "cgsl;wrapperlib;fmilib" "wrapper/sources" FALSE "-w" "${target}_xml" "${${sourcetarget}_fmu}")
add_fmu_internal("${CMAKE_CURRENT_BINARY_DIR}/${dir}" "${CMAKE_CURRENT_BINARY_DIR}/${dir}" "${CMAKE_CURRENT_BINARY_DIR}/${dir}" "${target}" "wrapper/sources/wrapper.c" "" "cgsl;wrapperlib;fmilib" "wrapper/sources" FALSE "-w" "${target}_xml" "${${sourcetarget}_fmu}")
endfunction ()
# wrap_existing_fmu
......@@ -206,7 +208,7 @@ function (wrap_existing_fmu2 target sourcefmu dir)
add_custom_target(${target}_xml DEPENDS ${dstxml})
#function (add_fmu_internal dir target extra_srcs defs libs extra_includes console md2hdr_option xmldeps extra_resources)
add_fmu_internal("${dir}" "${target}" "wrapper/sources/wrapper.c" "" "cgsl;wrapperlib;fmilib" "wrapper/sources" FALSE "-w" "${target}_xml" "${sourcefmu}")
add_fmu_internal("${dir}" "${dir}" "${dir}" "${target}" "wrapper/sources/wrapper.c" "" "cgsl;wrapperlib;fmilib" "wrapper/sources" FALSE "-w" "${target}_xml" "${sourcefmu}")
endfunction ()
function (wrap_existing_fmu modelIdentifier sourcefmu dir)
......
......@@ -7,15 +7,15 @@ popd
COMPARE_CSV=$(pwd)/../../compare_csv.py
mpiexec -np 2 fmigo-mpi -t 1.5 bouncingBall/bouncingBall.fmu > result
mpiexec -np 2 fmigo-mpi -t 1.5 ${FMUS_DIR}/me/bouncingBall/bouncingBall.fmu > result
python $COMPARE_CSV result tests/bouncingBall.csv
echo Bouncing Ball ok
mpiexec -np 3 fmigo-mpi -t 12 -p r,1,11,1 -c 0,x0,1,x_in springs/springs.fmu springs/springs.fmu > result
mpiexec -np 3 fmigo-mpi -t 12 -p r,1,11,1 -c 0,x0,1,x_in ${FMUS_DIR}/me/springs/springs.fmu ${FMUS_DIR}/me/springs/springs.fmu > result
python $COMPARE_CSV result tests/springs.txt
echo Springs ok
mpiexec -np 2 fmigo-mpi -p 0,v1,10:0,k_internal,1:0,k1,1 springs2/springs2.fmu > result
mpiexec -np 2 fmigo-mpi -p 0,v1,10:0,k_internal,1:0,k1,1 ${FMUS_DIR}/me/springs2/springs2.fmu > result
python $COMPARE_CSV result tests/springs2.csv
echo Springs2 ok
......
......@@ -7,8 +7,10 @@ then
exit 0
fi
DIR="${FMUS_DIR}/tests/loopsolvetest"
# Simplest test not solvable with fixed point iteration
mpiexec -np 2 fmigo-mpi -t 0.1 -L -p 0,1,1 -c 0,3,0,2 sub/sub.fmu > temp.csv
mpiexec -np 2 fmigo-mpi -t 0.1 -L -p 0,1,1 -c 0,3,0,2 ${DIR}/sub/sub.fmu > temp.csv
python ../../../compare_csv.py temp.csv simple.ref
# A bit more contrived
......@@ -18,7 +20,7 @@ mpiexec -np 5 fmigo-mpi -t 0.1 -L \
-c 1,3,0,2 \
-c 2,3,1,2:2,3,3,1 \
-c 3,3,2,2 \
sub/sub.fmu add/add.fmu sub/sub.fmu mul/mul.fmu > temp.csv
${DIR}/sub/sub.fmu ${DIR}/add/add.fmu ${DIR}/sub/sub.fmu ${DIR}/mul/mul.fmu > temp.csv
python ../../../compare_csv.py temp.csv complicated.ref
rm temp.csv
......
#!/bin/bash
set -e
FMU="${FMUS_DIR}/tests/stringtest/stringtest.fmu"
# Strip first column from CSV output so we don't depend on how time becomes formatted
mpiexec -np 2 fmigo-mpi -t 0.0 stringtest.fmu | sed -e 's/[^,]*,//' > temp.out
mpiexec -np 2 fmigo-mpi -t 0.0 $FMU | sed -e 's/[^,]*,//' > temp.out
diff --ignore-all-space - temp.out <<EOF
"",""
EOF
mpiexec -np 2 fmigo-mpi -t 0.0 -p s,0,5,hello stringtest.fmu | sed -e 's/[^,]*,//' > temp.out
mpiexec -np 2 fmigo-mpi -t 0.0 -p s,0,5,hello $FMU | sed -e 's/[^,]*,//' > temp.out
diff --ignore-all-space - temp.out <<EOF
"hello",""
EOF
# CSV escapes double quotes with double-double quotes (" -> "")
# Need to use a here-document because MS-MPI messes up quotes in program parameters (\"hello\" becomes hello, not "hello")
mpiexec -np 2 fmigo-mpi -t 0.0 -a - stringtest.fmu <<EOF | sed -e 's/[^,]*,//' > temp.out
mpiexec -np 2 fmigo-mpi -t 0.0 -a - $FMU <<EOF | sed -e 's/[^,]*,//' > temp.out
-p s,0,5,"hello"
EOF
diff --ignore-all-space - temp.out <<EOF
......@@ -22,13 +24,13 @@ diff --ignore-all-space - temp.out <<EOF
EOF
# Test with string in second position. We had a bug where main.cpp would not pop_front() m_getStringValues
mpiexec -np 2 fmigo-mpi -t 0.0 -p s,0,6,wello stringtest.fmu | sed -e 's/[^,]*,//' > temp.out
mpiexec -np 2 fmigo-mpi -t 0.0 -p s,0,6,wello $FMU | sed -e 's/[^,]*,//' > temp.out
diff --ignore-all-space - temp.out <<EOF
"","wello"
EOF
# Here-document again
mpiexec -np 2 fmigo-mpi -t 0.0 -a - stringtest.fmu <<EOF | sed -e 's/[^,]*,//' > temp.out
mpiexec -np 2 fmigo-mpi -t 0.0 -a - $FMU <<EOF | sed -e 's/[^,]*,//' > temp.out
-p s,0,6,"wello"
EOF
diff --ignore-all-space - temp.out <<EOF
......@@ -36,12 +38,12 @@ diff --ignore-all-space - temp.out <<EOF
EOF
# Do some tests with setting string parameters by name both via command line and via here-document
mpiexec -np 2 fmigo-mpi -t 0.0 -p 0,s02,wello stringtest.fmu | sed -e 's/[^,]*,//' > temp.out
mpiexec -np 2 fmigo-mpi -t 0.0 -p 0,s02,wello $FMU | sed -e 's/[^,]*,//' > temp.out
diff --ignore-all-space - temp.out <<EOF
"","wello"
EOF
mpiexec -np 2 fmigo-mpi -t 0.0 -a - stringtest.fmu <<EOF | sed -e 's/[^,]*,//' > temp.out
mpiexec -np 2 fmigo-mpi -t 0.0 -a - $FMU <<EOF | sed -e 's/[^,]*,//' > temp.out
-p 0,s02,"wello"
EOF
diff --ignore-all-space - temp.out <<EOF
......
#!/bin/bash
set -e
FMU="${FMUS_DIR}/tests/typeconvtest/typeconvtest.fmu"
# Simplest test - check that the default output is all zeroes
mpiexec -np 2 fmigo-mpi -t 0.2 typeconvtest.fmu | python check.py
mpiexec -np 2 fmigo-mpi -t 0.2 $FMU | python check.py
# Check basic type conversion, including float->int truncation
mpiexec -np 2 fmigo-mpi -t 0.2 -p r,0,8,10.9 -c r,0,0,i,0,5 -c r,0,0,b,0,6 typeconvtest.fmu | python check.py
mpiexec -np 2 fmigo-mpi -t 0.2 -p i,0,9,10 -c i,0,1,r,0,4 -c i,0,1,b,0,6 typeconvtest.fmu | python check.py
mpiexec -np 2 fmigo-mpi -t 0.2 -p b,0,10,true -c b,0,2,r,0,4 -c b,0,2,i,0,5 typeconvtest.fmu | python check.py
mpiexec -np 2 fmigo-mpi -t 0.2 -p r,0,8,10.9 -c r,0,0,i,0,5 -c r,0,0,b,0,6 $FMU | python check.py
mpiexec -np 2 fmigo-mpi -t 0.2 -p i,0,9,10 -c i,0,1,r,0,4 -c i,0,1,b,0,6 $FMU | python check.py
mpiexec -np 2 fmigo-mpi -t 0.2 -p b,0,10,true -c b,0,2,r,0,4 -c b,0,2,i,0,5 $FMU | python check.py
# Negative values
mpiexec -np 2 fmigo-mpi -t 0.2 -p r,0,8,-10.9 -c r,0,0,i,0,5 -c r,0,0,b,0,6 typeconvtest.fmu | python check.py
mpiexec -np 2 fmigo-mpi -t 0.2 -p i,0,9,-10 -c i,0,1,r,0,4 -c i,0,1,b,0,6 typeconvtest.fmu | python check.py
mpiexec -np 2 fmigo-mpi -t 0.2 -p r,0,8,-10.9 -c r,0,0,i,0,5 -c r,0,0,b,0,6 $FMU | python check.py
mpiexec -np 2 fmigo-mpi -t 0.2 -p i,0,9,-10 -c i,0,1,r,0,4 -c i,0,1,b,0,6 $FMU | python check.py
# Scaling (k=10, m=1)
mpiexec -np 2 fmigo-mpi -t 0.2 -p r,0,8,10.9 -c r,0,0,i,0,5,10,1 -c r,0,0,b,0,6,10,1 typeconvtest.fmu | python check.py 10 1
mpiexec -np 2 fmigo-mpi -t 0.2 -p i,0,9,10 -c i,0,1,r,0,4,10,1 -c i,0,1,b,0,6,10,1 typeconvtest.fmu | python check.py 10 1
mpiexec -np 2 fmigo-mpi -t 0.2 -p b,0,10,true -c b,0,2,r,0,4,10,1 -c b,0,2,i,0,5,10,1 typeconvtest.fmu | python check.py 10 1
mpiexec -np 2 fmigo-mpi -t 0.2 -p r,0,8,10.9 -c r,0,0,i,0,5,10,1 -c r,0,0,b,0,6,10,1 $FMU | python check.py 10 1
mpiexec -np 2 fmigo-mpi -t 0.2 -p i,0,9,10 -c i,0,1,r,0,4,10,1 -c i,0,1,b,0,6,10,1 $FMU | python check.py 10 1
mpiexec -np 2 fmigo-mpi -t 0.2 -p b,0,10,true -c b,0,2,r,0,4,10,1 -c b,0,2,i,0,5,10,1 $FMU | python check.py 10 1
echo Type conversion seems to work fine
mpiexec -np 2 fmigo-mpi -t 0.2 -p 0,r0,10.9 -c 0,r_out,0,i_in,10,1 -c 0,r_out,0,b_in,10,1 typeconvtest.fmu | python check.py 10 1
mpiexec -np 2 fmigo-mpi -t 0.2 -p 0,i0,10 -c 0,i_out,0,r_in,10,1 -c 0,i_out,0,b_in,10,1 typeconvtest.fmu | python check.py 10 1
mpiexec -np 2 fmigo-mpi -t 0.2 -p 0,b0,true -c 0,b_out,0,r_in,10,1 -c 0,b_out,0,i_in,10,1 typeconvtest.fmu | python check.py 10 1
mpiexec -np 2 fmigo-mpi -t 0.2 -p 0,r0,10.9 -c 0,r_out,0,i_in,10,1 -c 0,r_out,0,b_in,10,1 $FMU | python check.py 10 1
mpiexec -np 2 fmigo-mpi -t 0.2 -p 0,i0,10 -c 0,i_out,0,r_in,10,1 -c 0,i_out,0,b_in,10,1 $FMU | python check.py 10 1
mpiexec -np 2 fmigo-mpi -t 0.2 -p 0,b0,true -c 0,b_out,0,r_in,10,1 -c 0,b_out,0,i_in,10,1 $FMU | python check.py 10 1
echo String input seems to work fine
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment