Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid
[simgrid.git] / tools / cmake / UnitTesting.cmake
1 # To add a new tested file, simply add the original file in
2 # TEST_CFILES and generated file in TEST_UNITS. The rest is automatic.
3
4 set(TEST_CFILES
5   src/xbt/cunit.c
6   src/xbt/ex.c
7   src/xbt/dynar.c
8   src/xbt/dict.c
9   src/xbt/swag.c
10   src/xbt/xbt_str.c
11   src/xbt/xbt_strbuff.c
12   src/xbt/config.c
13   )
14 set(TEST_UNITS
15   ${CMAKE_CURRENT_BINARY_DIR}/src/cunit_unit.c
16   ${CMAKE_CURRENT_BINARY_DIR}/src/ex_unit.c
17   ${CMAKE_CURRENT_BINARY_DIR}/src/dynar_unit.c
18   ${CMAKE_CURRENT_BINARY_DIR}/src/dict_unit.c
19   ${CMAKE_CURRENT_BINARY_DIR}/src/swag_unit.c
20   ${CMAKE_CURRENT_BINARY_DIR}/src/xbt_str_unit.c
21   ${CMAKE_CURRENT_BINARY_DIR}/src/xbt_strbuff_unit.c
22   ${CMAKE_CURRENT_BINARY_DIR}/src/config_unit.c
23
24   ${CMAKE_CURRENT_BINARY_DIR}/src/simgrid_units_main.c
25   )
26
27 if(HAVE_MC)
28   set(TEST_CFILES ${TEST_CFILES}
29       src/mc/PageStore.cpp
30       src/mc/mc_snapshot.cpp
31       )
32   set(TEST_UNITS ${TEST_UNITS}
33      ${CMAKE_CURRENT_BINARY_DIR}/src/PageStore_unit.cpp
34      ${CMAKE_CURRENT_BINARY_DIR}/src/mc_snapshot_unit.cpp
35      )
36 endif()
37
38 ADD_CUSTOM_COMMAND(
39   OUTPUT        ${TEST_UNITS}
40
41   DEPENDS       ${CMAKE_HOME_DIRECTORY}/tools/sg_unit_extractor.pl
42   ${TEST_CFILES}
43
44   COMMAND       ${CMAKE_COMMAND} -E remove -f ${TEST_UNITS}
45
46   COMMAND chmod +x ${CMAKE_HOME_DIRECTORY}/tools/sg_unit_extractor.pl
47
48   COMMAND ${CMAKE_HOME_DIRECTORY}/tools/sg_unit_extractor.pl --root=src/ --outdir=${CMAKE_CURRENT_BINARY_DIR}/src/ ${TEST_CFILES}
49
50   WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}
51
52   COMMENT "Generating *_units files for testall..."
53   )
54
55 ### Ensure the build of testall
56
57 set_source_files_properties(${TEST_UNITS} PROPERTIES GENERATED true)
58
59 add_executable       (testall ${TEST_UNITS})
60 target_link_libraries(testall simgrid)
61