Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add the Storage::read_async and Storage::write_async methods
[simgrid.git] / tools / cmake / UnitTesting.cmake
1 # This file is in charge of the unit testing in SimGrid.
2 # See http://simgrid.gforge.inria.fr/simgrid/3.13/doc/inside_tests.html#inside_tests_add_units
3
4 # To register a file containing unit tests, simply add it to
5 # FILES_CONTAINING_UNITTESTS and have a pleasant day.
6
7 set(FILES_CONTAINING_UNITTESTS
8   src/xbt/cunit.cpp
9   src/xbt/dynar.cpp
10   src/xbt/dict.cpp
11   src/xbt/xbt_str.cpp
12   src/xbt/config.cpp
13 )
14
15 ####  Nothing to change below this line to add a new tested file
16 ################################################################
17
18 foreach(file ${FILES_CONTAINING_UNITTESTS})
19   get_filename_component(basename ${file} NAME_WE)
20   get_filename_component(ext ${file} EXT)
21   set(EXTRACTED_TEST_SOURCE_FILES ${EXTRACTED_TEST_SOURCE_FILES} ${CMAKE_CURRENT_BINARY_DIR}/src/${basename}_unit${ext})
22 endforeach()
23
24 set(EXTRACTED_TEST_SOURCE_FILES ${EXTRACTED_TEST_SOURCE_FILES} ${CMAKE_CURRENT_BINARY_DIR}/src/simgrid_units_main.c)
25
26 set_source_files_properties(${EXTRACTED_TEST_SOURCE_FILES} PROPERTIES GENERATED true)
27
28 ADD_CUSTOM_COMMAND(
29   OUTPUT  ${EXTRACTED_TEST_SOURCE_FILES}
30   DEPENDS ${CMAKE_HOME_DIRECTORY}/tools/sg_unit_extractor.pl ${FILES_CONTAINING_UNITTESTS}
31   COMMENT "Generating *_units files for testall..."
32
33   WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}
34   COMMAND           ${CMAKE_COMMAND} -E remove -f ${EXTRACTED_TEST_SOURCE_FILES}
35   COMMAND           chmod +x ${CMAKE_HOME_DIRECTORY}/tools/sg_unit_extractor.pl
36   COMMAND           ${CMAKE_HOME_DIRECTORY}/tools/sg_unit_extractor.pl --root=src/ --outdir=${CMAKE_CURRENT_BINARY_DIR}/src/ ${FILES_CONTAINING_UNITTESTS}
37 )
38
39 add_executable       (testall ${EXTRACTED_TEST_SOURCE_FILES})
40 target_link_libraries(testall simgrid)
41 set_property(
42     TARGET testall
43     APPEND PROPERTY
44            INCLUDE_DIRECTORIES "${INTERNAL_INCLUDES}"
45            )
46