Skip to content

Commit 7923b7f

Browse files
committed
tests running the sample data
1 parent 1f92e59 commit 7923b7f

File tree

2 files changed

+72
-3
lines changed

2 files changed

+72
-3
lines changed

CMakeLists.txt

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,46 @@ target_sources(MCsquare PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/include/define_cmake
259259
#target_compile_definitions(MCsquare PRIVATE $<$<BOOL:${MCSQUARE_USE_DOUBLE_PRECISION_DATA}>:USE_DOUBLE_PRECISION_DATA> $<$<BOOL:${MCSQUARE_USE_DOUBLE_PRECISION_SCORING}>:USE_DOUBLE_PRECISION_SCORING> $<$<BOOL:${MCSQUARE_USE_DOUBLE_PRECISION_COMPUTE}>:USE_DOUBLE_PRECISION_COMPUTE>)
260260
target_compile_definitions(MCsquare PRIVATE CMAKE_BUILD)
261261

262+
add_custom_command(
263+
TARGET MCsquare
264+
POST_BUILD
265+
COMMAND ${CMAKE_COMMAND} -E copy_directory
266+
${CMAKE_CURRENT_SOURCE_DIR}/BDL
267+
$<TARGET_FILE_DIR:MCsquare>/BDL
268+
COMMENT "Copying BDL to build directory"
269+
)
270+
add_custom_command(
271+
TARGET MCsquare
272+
POST_BUILD
273+
COMMAND ${CMAKE_COMMAND} -E copy_directory
274+
${CMAKE_CURRENT_SOURCE_DIR}/Scanners
275+
$<TARGET_FILE_DIR:MCsquare>/Scanners
276+
COMMENT "Copying Scanners to build directory"
277+
)
278+
add_custom_command(
279+
TARGET MCsquare
280+
POST_BUILD
281+
COMMAND ${CMAKE_COMMAND} -E copy_directory
282+
${CMAKE_CURRENT_SOURCE_DIR}/Materials
283+
$<TARGET_FILE_DIR:MCsquare>/Materials
284+
COMMENT "Copying Materials to build directory"
285+
)
286+
add_custom_command(
287+
TARGET MCsquare
288+
POST_BUILD
289+
COMMAND ${CMAKE_COMMAND} -E copy_directory
290+
${CMAKE_CURRENT_SOURCE_DIR}/Sample_input_data
291+
$<TARGET_FILE_DIR:MCsquare>/Sample_input_data
292+
COMMENT "Copying Sample_input_data to build directory"
293+
)
294+
295+
262296

263297
install(TARGETS MCsquare RUNTIME DESTINATION ".")
264298
install(DIRECTORY Scanners DESTINATION ".")
265299
install(DIRECTORY Materials DESTINATION ".")
266300
install(DIRECTORY BDL DESTINATION ".")
301+
install(DIRECTORY Sample_input_data DESTINATION ".")
267302
if (WIN32)
268303
# This generator expression expands to full paths of runtime DLLs.
269304
install(FILES $<TARGET_RUNTIME_DLLS:MCsquare> DESTINATION "." COMPONENT Runtime)
@@ -278,16 +313,40 @@ include(CTest) # defines BUILD_TESTING and calls enable_testing()
278313
if (BUILD_TESTING)
279314
# Run: <path-to-myapp> -v
280315
add_test(NAME MCsquare.version
281-
COMMAND $<TARGET_FILE:MCsquare> -v
282-
WORKING_DIRECTORY $<TARGET_FILE_DIR:MCsquare>)
316+
COMMAND $<TARGET_FILE:MCsquare> -v)
317+
283318

284319
# Build a regex that matches your version string
285320
# (escape dots so 1.2.3 is treated literally)
286321
string(REGEX REPLACE "\\." "\\\\." _VER_RX "${PROJECT_VERSION}")
287322

288323
set_tests_properties(MCsquare.version PROPERTIES
289324
PASS_REGULAR_EXPRESSION "(${PROJECT_NAME}[[:space:]]+)?${_VER_RX}"
290-
TIMEOUT 5)
325+
TIMEOUT 5
326+
WORKING_DIRECTORY $<TARGET_FILE_DIR:MCsquare>
327+
)
328+
329+
add_test(NAME prepare_test_cfg
330+
COMMAND "${CMAKE_COMMAND}"
331+
-Dsrc=Sample_input_data/config.txt
332+
-Ddst=Sample_input_data/config_test.txt
333+
-P ${CMAKE_SOURCE_DIR}/cmake/testHistoryConfig.cmake
334+
WORKING_DIRECTORY $<TARGET_FILE_DIR:MCsquare>
335+
)
336+
set_tests_properties(prepare_test_cfg PROPERTIES
337+
FIXTURES_SETUP test_cfg
338+
)
339+
340+
add_test(NAME MCsquare.sample_data
341+
COMMAND $<TARGET_FILE:MCsquare> "Sample_input_data/config_test.txt"
342+
WORKING_DIRECTORY $<TARGET_FILE_DIR:MCsquare>)
343+
set_tests_properties(MCsquare.sample_data PROPERTIES
344+
TIMEOUT 60
345+
FIXTURES_REQUIRED test_cfg
346+
)
347+
348+
add_test(NAME MCsquare.output_created COMMAND ${CMAKE_COMMAND} -E cat Sample_input_data/Outputs/Dose.raw)
349+
set_tests_properties(MCsquare.output_created PROPERTIES DEPENDS MCsquare.sample_data WORKING_DIRECTORY $<TARGET_FILE_DIR:MCsquare>)
291350

292351
# If MKL was used set the properties
293352
if(MKL_ENV)

cmake/testHistoryConfig.cmake

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
if(NOT DEFINED src OR NOT DEFINED dst)
2+
message(FATAL_ERROR "Need -Dsrc and -Ddst")
3+
endif()
4+
5+
# Read, replace 'Num_Primaries: 10000000' -> 'Num_Primaries: 1000', write
6+
file(READ "${src}" _c)
7+
string(REGEX REPLACE "Num_Primaries[ \t]*10000000"
8+
"Num_Primaries \t1000"
9+
_c "${_c}")
10+
file(WRITE "${dst}" "${_c}")

0 commit comments

Comments
 (0)