WTF should have a ParkingLot for parking sleeping threads, so that locks can fit...
[WebKit-https.git] / Tools / TestWebKitAPI / CMakeLists.txt
1 set(TESTWEBKITAPI_DIR "${TOOLS_DIR}/TestWebKitAPI")
2 set(test_wtf_LIBRARIES
3     WTF
4     gtest
5 )
6
7 set(test_webcore_LIBRARIES
8     WTF
9     WebCore
10     gtest
11 )
12
13 set(TestWebKitAPI_LIBRARIES
14     WTF
15 )
16
17 if (ENABLE_WEBKIT2)
18     set(test_webkit2_api_LIBRARIES
19         JavaScriptCore
20         TestWebKitAPIBase
21         WTF
22         WebKit2
23         gtest
24     )
25     list(APPEND TestWebKitAPI_LIBRARIES
26         WebKit2
27     )
28 else ()
29     list(APPEND TestWebKitAPI_LIBRARIES
30         WebKit
31     )
32 endif ()
33
34
35 set(TestJavaScriptCore_LIBRARIES
36     JavaScriptCore
37     gtest
38 )
39
40 set(TestWTF_SOURCES
41     ${TESTWEBKITAPI_DIR}/Counters.cpp
42     ${TESTWEBKITAPI_DIR}/TestsController.cpp
43     ${TESTWEBKITAPI_DIR}/Tests/WTF/AtomicString.cpp
44     ${TESTWEBKITAPI_DIR}/Tests/WTF/CString.cpp
45     ${TESTWEBKITAPI_DIR}/Tests/WTF/CheckedArithmeticOperations.cpp
46     ${TESTWEBKITAPI_DIR}/Tests/WTF/DateMath.cpp
47     ${TESTWEBKITAPI_DIR}/Tests/WTF/Deque.cpp
48     ${TESTWEBKITAPI_DIR}/Tests/WTF/Functional.cpp
49     ${TESTWEBKITAPI_DIR}/Tests/WTF/HashMap.cpp
50     ${TESTWEBKITAPI_DIR}/Tests/WTF/HashSet.cpp
51     ${TESTWEBKITAPI_DIR}/Tests/WTF/IntegerToStringConversion.cpp
52     ${TESTWEBKITAPI_DIR}/Tests/WTF/ListHashSet.cpp
53     ${TESTWEBKITAPI_DIR}/Tests/WTF/Lock.cpp
54     ${TESTWEBKITAPI_DIR}/Tests/WTF/MD5.cpp
55     ${TESTWEBKITAPI_DIR}/Tests/WTF/MathExtras.cpp
56     ${TESTWEBKITAPI_DIR}/Tests/WTF/MediaTime.cpp
57     ${TESTWEBKITAPI_DIR}/Tests/WTF/MetaAllocator.cpp
58     ${TESTWEBKITAPI_DIR}/Tests/WTF/NakedPtr.cpp
59     ${TESTWEBKITAPI_DIR}/Tests/WTF/ParkingLot.cpp
60     ${TESTWEBKITAPI_DIR}/Tests/WTF/RedBlackTree.cpp
61     ${TESTWEBKITAPI_DIR}/Tests/WTF/Ref.cpp
62     ${TESTWEBKITAPI_DIR}/Tests/WTF/RefPtr.cpp
63     ${TESTWEBKITAPI_DIR}/Tests/WTF/SHA1.cpp
64     ${TESTWEBKITAPI_DIR}/Tests/WTF/SaturatedArithmeticOperations.cpp
65     ${TESTWEBKITAPI_DIR}/Tests/WTF/StringBuilder.cpp
66     ${TESTWEBKITAPI_DIR}/Tests/WTF/StringHasher.cpp
67     ${TESTWEBKITAPI_DIR}/Tests/WTF/StringImpl.cpp
68     ${TESTWEBKITAPI_DIR}/Tests/WTF/StringOperators.cpp
69     ${TESTWEBKITAPI_DIR}/Tests/WTF/StringView.cpp
70     ${TESTWEBKITAPI_DIR}/Tests/WTF/TemporaryChange.cpp
71     ${TESTWEBKITAPI_DIR}/Tests/WTF/Vector.cpp
72     ${TESTWEBKITAPI_DIR}/Tests/WTF/WTFString.cpp
73     ${TESTWEBKITAPI_DIR}/Tests/WTF/WorkQueue.cpp
74 )
75
76 WEBKIT_INCLUDE_CONFIG_FILES_IF_EXISTS()
77
78 include_directories(
79     ${TESTWEBKITAPI_DIR}
80     ${CMAKE_BINARY_DIR}
81     ${CMAKE_SOURCE_DIR}/Source
82     ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}
83     ${DERIVED_SOURCES_WEBCORE_DIR}
84     ${JAVASCRIPTCORE_DIR}
85     ${JAVASCRIPTCORE_DIR}/API
86     ${JAVASCRIPTCORE_DIR}/ForwardingHeaders
87     ${THIRDPARTY_DIR}/gtest/include
88     ${WEBCORE_DIR}/css
89     ${WEBCORE_DIR}/dom
90     ${WEBCORE_DIR}/editing
91     ${WEBCORE_DIR}/loader/cache
92     ${WEBCORE_DIR}/platform
93     ${WEBCORE_DIR}/platform/animation
94     ${WEBCORE_DIR}/platform/graphics
95     ${WEBCORE_DIR}/platform/text
96     ${WEBCORE_DIR}/platform/network
97     ${WEBCORE_DIR}/platform/network/soup
98     ${WEBCORE_DIR}/rendering/style
99     ${WEBKIT2_DIR}/Platform/IPC
100     ${WEBKIT2_DIR}/Shared
101     ${WEBKIT2_DIR}/Shared/API
102     ${WEBKIT2_DIR}/Shared/API/c
103     ${WEBKIT2_DIR}/Shared/Plugins
104     ${WEBKIT2_DIR}/UIProcess
105     ${WEBKIT2_DIR}/UIProcess/API
106     ${WEBKIT2_DIR}/WebProcess/InjectedBundle
107     ${WEBKIT2_DIR}/WebProcess/InjectedBundle/API/c
108     ${WTF_DIR}
109 )
110
111 if (ENABLE_WEBKIT2)
112     add_library(TestWebKitAPIInjectedBundle SHARED
113         ${bundle_harness_SOURCES}
114         ${TESTWEBKITAPI_DIR}/InjectedBundleController.cpp
115         ${TESTWEBKITAPI_DIR}/InjectedBundleMain.cpp
116         ${TESTWEBKITAPI_DIR}/PlatformUtilities.cpp
117         ${TESTWEBKITAPI_DIR}/Tests/WebKit2/CanHandleRequest_Bundle.cpp
118         ${TESTWEBKITAPI_DIR}/Tests/WebKit2/DidAssociateFormControls_Bundle.cpp
119         ${TESTWEBKITAPI_DIR}/Tests/WebKit2/DOMWindowExtensionBasic_Bundle.cpp
120         ${TESTWEBKITAPI_DIR}/Tests/WebKit2/DOMWindowExtensionNoCache_Bundle.cpp
121         ${TESTWEBKITAPI_DIR}/Tests/WebKit2/DocumentStartUserScriptAlertCrash_Bundle.cpp
122         ${TESTWEBKITAPI_DIR}/Tests/WebKit2/GetInjectedBundleInitializationUserDataCallback_Bundle.cpp
123         ${TESTWEBKITAPI_DIR}/Tests/WebKit2/HitTestResultNodeHandle_Bundle.cpp
124         ${TESTWEBKITAPI_DIR}/Tests/WebKit2/InjectedBundleBasic_Bundle.cpp
125         ${TESTWEBKITAPI_DIR}/Tests/WebKit2/InjectedBundleFrameHitTest_Bundle.cpp
126         ${TESTWEBKITAPI_DIR}/Tests/WebKit2/InjectedBundleInitializationUserDataCallbackWins_Bundle.cpp
127         ${TESTWEBKITAPI_DIR}/Tests/WebKit2/LoadCanceledNoServerRedirectCallback_Bundle.cpp
128         ${TESTWEBKITAPI_DIR}/Tests/WebKit2/MouseMoveAfterCrash_Bundle.cpp
129         ${TESTWEBKITAPI_DIR}/Tests/WebKit2/NewFirstVisuallyNonEmptyLayoutFails_Bundle.cpp
130         ${TESTWEBKITAPI_DIR}/Tests/WebKit2/NewFirstVisuallyNonEmptyLayoutForImages_Bundle.cpp
131         ${TESTWEBKITAPI_DIR}/Tests/WebKit2/NewFirstVisuallyNonEmptyLayoutFrames_Bundle.cpp
132         ${TESTWEBKITAPI_DIR}/Tests/WebKit2/NewFirstVisuallyNonEmptyLayout_Bundle.cpp
133         ${TESTWEBKITAPI_DIR}/Tests/WebKit2/ParentFrame_Bundle.cpp
134         ${TESTWEBKITAPI_DIR}/Tests/WebKit2/ResponsivenessTimerDoesntFireEarly_Bundle.cpp
135         ${TESTWEBKITAPI_DIR}/Tests/WebKit2/ShouldGoToBackForwardListItem_Bundle.cpp
136         ${TESTWEBKITAPI_DIR}/Tests/WebKit2/TextFieldDidBeginAndEndEditing_Bundle.cpp
137         ${TESTWEBKITAPI_DIR}/Tests/WebKit2/UserMessage_Bundle.cpp
138         ${TESTWEBKITAPI_DIR}/Tests/WebKit2/WillLoad_Bundle.cpp
139         ${TESTWEBKITAPI_DIR}/Tests/WebKit2/WillSendSubmitEvent_Bundle.cpp
140     )
141
142     target_link_libraries(TestWebKitAPIInjectedBundle ${TestWebKitAPI_LIBRARIES})
143     add_dependencies(TestWebKitAPIInjectedBundle ${ForwardingHeadersForTestWebKitAPI_NAME})
144
145     get_property(TestWebKitAPIInjectedBundle_PATH TARGET TestWebKitAPIInjectedBundle PROPERTY LOCATION)
146 endif ()
147
148 add_definitions(-DGTEST_LINKED_AS_SHARED_LIBRARY=1 -DGTEST_HAS_RTTI=0
149     -DTEST_WEBKIT2_RESOURCES_DIR=\"${TESTWEBKITAPI_DIR}/Tests/WebKit2\"
150     -DTEST_INJECTED_BUNDLE_PATH=\"${TestWebKitAPIInjectedBundle_PATH}\"
151 )
152
153 # FIXME: This works around compatibility problems in the old version of the third-pary
154 # googletest source code checkout. It should be removed once we upgrade to a newer version.
155 if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
156     add_definitions(-DGTEST_HAS_TR1_TUPLE=0)
157 endif ()
158
159 add_executable(TestWTF
160     ${test_main_SOURCES}
161     ${TestWTF_SOURCES}
162 )
163
164 target_link_libraries(TestWTF ${test_wtf_LIBRARIES})
165 add_dependencies(TestWTF WTF ${ForwardingHeadersForTestWebKitAPI_NAME} ${ForwardingNetworkHeadersForTestWebKitAPI_NAME})
166 add_test(TestWTF ${TESTWEBKITAPI_RUNTIME_OUTPUT_DIRECTORY_WTF}/TestWTF)
167 set_tests_properties(TestWTF PROPERTIES TIMEOUT 60)
168 set_target_properties(TestWTF PROPERTIES
169     RUNTIME_OUTPUT_DIRECTORY ${TESTWEBKITAPI_RUNTIME_OUTPUT_DIRECTORY_WTF}
170 )
171
172 # FIXME: EFL is the only port that separates the WebCore binaries. Each port ought to do closer to the same thing.
173 foreach (testName ${test_webcore_BINARIES})
174     add_executable(${testName} ${test_main_SOURCES} ${TESTWEBKITAPI_DIR}/TestsController.cpp ${TESTWEBKITAPI_DIR}/Tests/WebCore/${testName}.cpp)
175     add_test(${testName} ${TESTWEBKITAPI_RUNTIME_OUTPUT_DIRECTORY}/WebCore/${testName})
176     set_tests_properties(${testName} PROPERTIES TIMEOUT 60)
177     target_link_libraries(${testName} ${test_webcore_LIBRARIES})
178     set_target_properties(${testName} PROPERTIES
179         RUNTIME_OUTPUT_DIRECTORY ${TESTWEBKITAPI_RUNTIME_OUTPUT_DIRECTORY}/WebCore
180     )
181 endforeach ()
182
183 if (ENABLE_WEBKIT2)
184     add_library(TestWebKitAPIBase
185         ${test_main_SOURCES}
186         ${webkit2_api_harness_SOURCES}
187         ${TESTWEBKITAPI_DIR}/JavaScriptTest.cpp
188         ${TESTWEBKITAPI_DIR}/PlatformUtilities.cpp
189         ${TESTWEBKITAPI_DIR}/TestsController.cpp
190     )
191
192     add_dependencies(TestWebKitAPIBase WebKit2 ${ForwardingHeadersForTestWebKitAPI_NAME} ${ForwardingNetworkHeadersForTestWebKitAPI_NAME})
193
194     foreach (testName ${test_webkit2_api_BINARIES})
195         get_filename_component(testBaseName ${testName} NAME)
196         add_executable(${testBaseName} ${TESTWEBKITAPI_DIR}/Tests/WebKit2/${testName}.cpp)
197         add_test(${testBaseName} ${TESTWEBKITAPI_RUNTIME_OUTPUT_DIRECTORY}/WebKit2/${testBaseName})
198         set_tests_properties(${testBaseName} PROPERTIES TIMEOUT 60)
199         target_link_libraries(${testBaseName} ${test_webkit2_api_LIBRARIES})
200         set_target_properties(${testBaseName} PROPERTIES
201             RUNTIME_OUTPUT_DIRECTORY ${TESTWEBKITAPI_RUNTIME_OUTPUT_DIRECTORY}/WebKit2
202         )
203     endforeach ()
204
205     # We don't run tests that are expected to fail. We could use the WILL_FAIL
206     # property, but it reports failure when the test crashes or timeouts and would
207     # make the bot red.
208     foreach (testName ${test_webkit2_api_fail_BINARIES})
209         add_executable(${testName} ${TESTWEBKITAPI_DIR}/Tests/WebKit2/${testName}.cpp)
210         target_link_libraries(${testName} ${test_webkit2_api_LIBRARIES})
211         set_target_properties(${testName} PROPERTIES
212             RUNTIME_OUTPUT_DIRECTORY ${TESTWEBKITAPI_RUNTIME_OUTPUT_DIRECTORY}/WebKit2/failure
213         )
214     endforeach ()
215 endif ()