Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
end of MSG examples doc revision
[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.c
9   src/xbt/ex.c
10   src/xbt/dynar.c
11   src/xbt/dict.c
12   src/xbt/swag.c
13   src/xbt/xbt_str.c
14   src/xbt/xbt_strbuff.c
15   src/xbt/config.c
16 )
17
18 if(HAVE_MC)
19   set(FILES_CONTAINING_UNITTESTS ${FILES_CONTAINING_UNITTESTS}
20       src/mc/PageStore.cpp
21       src/mc/mc_snapshot.cpp
22   )
23 endif()
24
25 ####  Nothing to change below this line to add a new tested file
26 ################################################################
27
28 foreach(file ${FILES_CONTAINING_UNITTESTS})
29   get_filename_component(basename ${file} NAME_WE)
30   get_filename_component(ext ${file} EXT)
31   set(EXTRACTED_TEST_SOURCE_FILES ${EXTRACTED_TEST_SOURCE_FILES} ${CMAKE_CURRENT_BINARY_DIR}/src/${basename}_unit${ext})
32 endforeach()
33   
34 set(EXTRACTED_TEST_SOURCE_FILES ${EXTRACTED_TEST_SOURCE_FILES} ${CMAKE_CURRENT_BINARY_DIR}/src/simgrid_units_main.c)
35
36 set_source_files_properties(${EXTRACTED_TEST_SOURCE_FILES} PROPERTIES GENERATED true)
37
38 ADD_CUSTOM_COMMAND(
39   OUTPUT  ${EXTRACTED_TEST_SOURCE_FILES}
40   DEPENDS ${CMAKE_HOME_DIRECTORY}/tools/sg_unit_extractor.pl ${FILES_CONTAINING_UNITTESTS}
41   COMMENT "Generating *_units files for testall..."
42
43   WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}
44   COMMAND           ${CMAKE_COMMAND} -E remove -f ${EXTRACTED_TEST_SOURCE_FILES}
45   COMMAND           chmod +x ${CMAKE_HOME_DIRECTORY}/tools/sg_unit_extractor.pl
46   COMMAND           ${CMAKE_HOME_DIRECTORY}/tools/sg_unit_extractor.pl --root=src/ --outdir=${CMAKE_CURRENT_BINARY_DIR}/src/ ${FILES_CONTAINING_UNITTESTS}
47 )
48
49 add_executable       (testall ${EXTRACTED_TEST_SOURCE_FILES})
50 target_link_libraries(testall simgrid)
51