Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Bugfixes + test suitx
[simgrid.git] / buildtools / 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/set.c
10         src/xbt/swag.c
11         src/xbt/xbt_str.c
12         src/xbt/xbt_strbuff.c
13         src/xbt/xbt_sha.c
14         src/xbt/config.c
15         src/xbt/xbt_synchro.c
16         src/xbt/threadpool.c
17 )
18 set(TEST_UNITS
19         ${CMAKE_CURRENT_BINARY_DIR}/src/cunit_unit.c
20         ${CMAKE_CURRENT_BINARY_DIR}/src/ex_unit.c
21         ${CMAKE_CURRENT_BINARY_DIR}/src/dynar_unit.c
22         ${CMAKE_CURRENT_BINARY_DIR}/src/dict_unit.c
23         ${CMAKE_CURRENT_BINARY_DIR}/src/set_unit.c
24         ${CMAKE_CURRENT_BINARY_DIR}/src/swag_unit.c
25         ${CMAKE_CURRENT_BINARY_DIR}/src/xbt_str_unit.c
26         ${CMAKE_CURRENT_BINARY_DIR}/src/xbt_strbuff_unit.c
27         ${CMAKE_CURRENT_BINARY_DIR}/src/xbt_sha_unit.c
28         ${CMAKE_CURRENT_BINARY_DIR}/src/config_unit.c
29         ${CMAKE_CURRENT_BINARY_DIR}/src/xbt_synchro_unit.c
30         ${CMAKE_CURRENT_BINARY_DIR}/src/threadpool_unit.c
31         
32         ${CMAKE_CURRENT_BINARY_DIR}/src/simgrid_units_main.c
33 )
34
35
36
37 ADD_CUSTOM_COMMAND(
38         OUTPUT  ${TEST_UNITS}
39                 
40         DEPENDS ${CMAKE_HOME_DIRECTORY}/tools/sg_unit_extractor.pl
41                 ${TEST_CFILES}
42
43         COMMAND ${CMAKE_COMMAND} -E remove -f ${TEST_UNITS}
44
45         COMMAND chmod +x ${CMAKE_HOME_DIRECTORY}/tools/sg_unit_extractor.pl
46
47         COMMAND ${CMAKE_HOME_DIRECTORY}/tools/sg_unit_extractor.pl --root=src/ --outdir=${CMAKE_CURRENT_BINARY_DIR}/src/ ${TEST_CFILES}
48
49         WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}
50
51         COMMENT "Generating *_units files for testall..."
52 )
53
54
55 ### Ensure the build of testall
56
57 set_source_files_properties(${TEST_UNITS} PROPERTIES GENERATED true)
58
59 set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}/src/")
60 add_executable(testall ${TEST_UNITS})
61
62 ### Add definitions for compile
63 if(NOT WIN32)
64     target_link_libraries(testall gras m)
65 else(NOT WIN32)
66     target_link_libraries(testall gras)
67 endif(NOT WIN32)
68         
69 add_dependencies(testall $(TEST_UNITS))