• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# ~~~
2# Copyright (c) 2014-2022 Valve Corporation
3# Copyright (c) 2014-2022 LunarG, Inc.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9#     http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16# ~~~
17
18
19# By default, tests and loader are built without sanitizers
20# Use these options to force a specific sanitizer on all test executables
21option(TEST_USE_ADDRESS_SANITIZER "Linux only: Advanced memory checking" OFF)
22option(TEST_USE_THREAD_SANITIZER "Linux only: Advanced thread checking" OFF)
23option(ENABLE_LIVE_VERIFICATION_TESTS "Enable tests which expect to run on live drivers. Meant for manual verification only" OFF)
24
25include(GoogleTest)
26add_subdirectory(framework)
27
28add_executable(
29    test_regression
30        loader_testing_main.cpp
31        loader_alloc_callback_tests.cpp
32        loader_envvar_tests.cpp
33        loader_get_proc_addr_tests.cpp
34        loader_debug_ext_tests.cpp
35        loader_handle_validation_tests.cpp
36        loader_layer_tests.cpp
37        loader_regression_tests.cpp
38        loader_phys_dev_inst_ext_tests.cpp
39        loader_version_tests.cpp
40        loader_unknown_ext_tests.cpp
41        loader_wsi_tests.cpp)
42target_link_libraries(test_regression PUBLIC testing_dependencies)
43set_target_properties(test_regression ${LOADER_STANDARD_CXX_PROPERTIES})
44target_compile_definitions(test_regression PUBLIC VK_NO_PROTOTYPES)
45
46# Threading tests live in separate executabe just for threading tests as it'll need support
47# in the test harness to enable in CI, as thread sanitizer doesn't work with address sanitizer enabled.
48add_executable(
49    test_threading
50        loader_testing_main.cpp
51        loader_threading_tests.cpp)
52target_link_libraries(test_threading PUBLIC testing_dependencies)
53set_target_properties(test_threading ${LOADER_STANDARD_CXX_PROPERTIES})
54target_compile_definitions(test_threading PUBLIC VK_NO_PROTOTYPES)
55
56# executables that are meant for testing against real drivers rather than the mocks
57if (ENABLE_LIVE_VERIFICATION_TESTS)
58    add_subdirectory(live_verification)
59endif()
60
61if(WIN32)
62    # Copy loader and googletest (gtest) libs to test dir so the test executable can find them.
63    add_custom_command(TARGET test_regression POST_BUILD
64                       COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:gtest> $<TARGET_FILE_DIR:test_regression>)
65    # Copy the loader shared lib (if built) to the test application directory so the test app finds it.
66    if(TARGET vulkan)
67        add_custom_command(TARGET test_regression POST_BUILD
68                           COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:vulkan> $<TARGET_FILE_DIR:test_regression>)
69    endif()
70
71    # Copy the gtest shared lib (if built) to the live verification tests directory so the tests finds it.
72    if(ENABLE_LIVE_VERIFICATION_TESTS)
73        add_custom_command(TARGET test_regression POST_BUILD
74                           COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:gtest> $<TARGET_FILE_DIR:dynamic_rendering_get_proc_addr>)
75    endif()
76endif()
77
78# must happen after the dll's get copied over
79if(NOT CMAKE_CROSSCOMPILING)
80    gtest_discover_tests(test_regression PROPERTIES DISCOVERY_TIMEOUT 100)
81else()
82    gtest_add_tests(TARGET test_regression)
83endif()
84