]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/test/test/CMakeLists.txt
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / boost / libs / test / test / CMakeLists.txt
1 ####
2 # Unit tests for the Unit Test Framework library
3
4 if(NOT DEFINED BOOST_TEST_ROOT_DIR)
5 message(FATAL_ERROR "Please use this file from the main CMakeLists.txt from the build/ folder")
6 endif()
7
8 if(NOT TARGET boost_test_framework OR NOT TARGET boost_test_framework_shared)
9 message(FATAL_ERROR "Please use this file from the main CMakeLists.txt from the build/ folder")
10 endif()
11
12 # unit tests folder
13 set(BOOST_TEST_UNITTESTS_FOLDER ${BOOST_TEST_ROOT_DIR}/test)
14 set(BOOST_TEST_EXAMPLES_FOLDER ${BOOST_TEST_ROOT_DIR}/example)
15
16
17 # documentation tests
18 file(GLOB_RECURSE
19 BOOST_UTF_DOC_EXAMPLES
20 CONFIGURE_DEPENDS
21 ${BOOST_TEST_ROOT_DIR}/doc/examples/*.cpp)
22
23 foreach(_h IN LISTS BOOST_UTF_DOC_EXAMPLES)
24 get_filename_component(_hh ${_h} NAME_WE)
25 add_executable(doc-${_hh}
26 ${_h}
27 ${BOOST_TEST_ROOT_DIR}/doc/examples/${_hh}.output)
28 set_target_properties(doc-${_hh}
29 PROPERTIES
30 FOLDER "Doc examples"
31 VS_DEBUGGER_WORKING_DIRECTORY ${BOOST_TEST_UNITTESTS_FOLDER})
32 target_include_directories(doc-${_hh}
33 PUBLIC
34 ${BOOST_TEST_ROOT_DIR}/include/
35 ${BOOST_ROOT_DIR_ABS}/)
36
37 add_test(NAME doc-${_hh}-test
38 COMMAND doc-${_hh})
39 get_filename_component(_ext ${_h} EXT)
40 string(FIND ${_ext} "fail" _index_fail)
41 if(${_index_fail} GREATER -1)
42 set_tests_properties(doc-${_hh}-test
43 PROPERTIES
44 WILL_FAIL TRUE)
45 endif()
46 endforeach()
47
48
49 # datasets
50 file(GLOB
51 BOOST_TEST_UNITTESTS_DATASET
52 CONFIGURE_DEPENDS
53 ${BOOST_TEST_UNITTESTS_FOLDER}/test-organization-ts/datasets-test/*.cpp
54 ${BOOST_TEST_UNITTESTS_FOLDER}/test-organization-ts/datasets-test/*.hpp)
55 add_executable(boost_test_datasets ${BOOST_TEST_UNITTESTS_DATASET})
56 set_target_properties(boost_test_datasets
57 PROPERTIES
58 FOLDER "Unit tests"
59 VS_DEBUGGER_WORKING_DIRECTORY ${BOOST_TEST_UNITTESTS_FOLDER})
60 target_include_directories(boost_test_datasets
61 PUBLIC
62 ${BOOST_TEST_ROOT_DIR}/include/
63 ${BOOST_ROOT_DIR_ABS}/)
64 target_link_libraries(boost_test_datasets boost_test_framework)
65 add_test(NAME bt-unittest-dataset
66 COMMAND boost_test_datasets)
67
68
69 ####
70 # TS writing-test-ts
71
72 set(BOOST_UTF_TESTS_FIND_FILES
73 writing-test-ts
74 execution_monitor-ts
75 framework-ts
76 usage-variants-ts
77 utils-ts
78 test-organization-ts
79 smoke-ts
80 )
81
82
83 foreach(_ts IN LISTS BOOST_UTF_TESTS_FIND_FILES)
84
85 file(GLOB
86 _boost_utf_current_tsuite
87 ${BOOST_TEST_UNITTESTS_FOLDER}/${_ts}/*.cpp)
88
89 foreach(_h IN LISTS _boost_utf_current_tsuite)
90 get_filename_component(_hh ${_h} ABSOLUTE)
91 get_filename_component(_name ${_h} NAME_WE)
92 file(RELATIVE_PATH _v ${BOOST_TEST_UNITTESTS_FOLDER} ${_hh})
93
94 add_executable(${_name} ${_hh})
95 set_target_properties(${_name}
96 PROPERTIES
97 FOLDER "Unit tests/${_ts}"
98 VS_DEBUGGER_WORKING_DIRECTORY ${BOOST_TEST_UNITTESTS_FOLDER})
99 target_link_libraries(${_name}
100 PRIVATE
101 boost_test_framework) # inaccurate
102
103 add_test(NAME bt-unittest-${_name}
104 COMMAND ${_name})
105 endforeach()
106
107 unset(_boost_utf_current_tsuite)
108
109 endforeach() # test suite
110
111
112 #
113 # Example code
114 #
115
116 set(LIST_EXAMPLES
117 unit_test_example_01.cpp,shared,fail
118 unit_test_example_02.cpp,static,fail
119 unit_test_example_03.cpp,static,fail
120 unit_test_example_04.cpp,shared,fail
121 unit_test_example_05.cpp,shared,fail
122 unit_test_example_06.cpp,shared,fail
123 unit_test_example_07.cpp,shared,run
124 unit_test_example_08.cpp,shared,run
125 unit_test_example_09_1.cpp,unit_test_example_09_2.cpp,shared,run
126
127 unit_test_example_10.cpp,static,fail
128 unit_test_example_11.cpp,static,fail
129 unit_test_example_12.cpp,static,link
130 unit_test_example_13.cpp,shared,run
131 unit_test_example_15.cpp,shared,fail
132 unit_test_example_16.cpp,shared,run
133
134 const_string_test.cpp,none,run
135 named_param_example.cpp,none,run
136
137 external_main_example_1.cpp,shared,fail
138 external_main_example_2.cpp,shared,fail
139 external_main_example_3.cpp,none,fail
140 filtering_example.cpp,static,fail
141 )
142
143 foreach(_var IN LISTS LIST_EXAMPLES)
144 string(REPLACE "," ";" _var_to_list "${_var}")
145 list(REVERSE _var_to_list)
146 list(GET _var_to_list 0 action)
147 list(GET _var_to_list 1 boost_test_type)
148 list(REMOVE_AT _var_to_list 0)
149 list(REMOVE_AT _var_to_list 0)
150
151 list(GET _var_to_list 0 first_file)
152 get_filename_component(_name_example "${first_file}" NAME_WE)
153
154 set(_list_files)
155 foreach(_file IN LISTS _var_to_list)
156 set(_list_files ${_list_files} ${BOOST_TEST_EXAMPLES_FOLDER}/${_file})
157 endforeach()
158
159 add_executable(${_name_example} ${_list_files})
160 set_target_properties(${_name_example}
161 PROPERTIES
162 FOLDER "Examples"
163 VS_DEBUGGER_WORKING_DIRECTORY ${BOOST_TEST_UNITTESTS_FOLDER})
164
165 if("${boost_test_type}" STREQUAL "shared")
166 target_link_libraries(${_name_example}
167 PRIVATE
168 boost_test_framework_shared)
169 elseif("${boost_test_type}" STREQUAL "static")
170 target_link_libraries(${_name_example}
171 PRIVATE
172 boost_test_framework)
173 elseif(NOT "${boost_test_type}" STREQUAL "none")
174 message(FATAL_ERROR "Wrong action for example target '${_name_example}'")
175 endif()
176
177 if("${action}" STREQUAL "run" OR "${action}" STREQUAL "run-fail")
178 add_test(NAME bt-exampletest-${_name_example}
179 COMMAND ${_name_example})
180
181 if("${action}" STREQUAL "run-fail")
182 set_tests_properties(bt-exampletest-${_name_example}
183 PROPERTIES
184 WILL_FAIL TRUE)
185 endif()
186 endif()
187 endforeach()