Guard building of live_verification tests
authorCharles Giessen <charles@lunarg.com>
Tue, 15 Feb 2022 22:03:25 +0000 (15:03 -0700)
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>
Tue, 15 Feb 2022 23:51:46 +0000 (16:51 -0700)
Don't build live verification tests by default. These are meant as manual tests for
developers to run to diagnose issues or verify correctness on a real system.

tests/CMakeLists.txt
tests/framework/test_environment.cpp
tests/live_verification/dynamic_rendering_get_proc_addr.cpp

index e64b7d1..12d108b 100644 (file)
@@ -20,6 +20,7 @@
 # Use these options to force a specific sanitizer on all test executables
 option(TEST_USE_ADDRESS_SANITIZER "Linux only: Advanced memory checking" OFF)
 option(TEST_USE_THREAD_SANITIZER "Linux only: Advanced thread checking" OFF)
+option(ENABLE_LIVE_VERIFICATION_TESTS "Enable tests which expect to run on live drivers. Meant for manual verification only" OFF)
 
 include(GoogleTest)
 add_subdirectory(framework)
@@ -45,6 +46,11 @@ add_executable(
         loader_threading_tests.cpp)
 target_link_libraries(test_threading PRIVATE testing_dependencies)
 
+# executables that are meant for testing against real drivers rather than the mocks
+if (ENABLE_LIVE_VERIFICATION_TESTS)
+    add_subdirectory(live_verification)
+endif()
+
 if(WIN32)
     # Copy loader and googletest (gtest) libs to test dir so the test executable can find them.
     add_custom_command(TARGET test_regression POST_BUILD
@@ -54,10 +60,13 @@ if(WIN32)
         add_custom_command(TARGET test_regression POST_BUILD
                            COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:vulkan> $<TARGET_FILE_DIR:test_regression>)
     endif()
+
+    # Copy the gtest shared lib (if built) to the live verification tests directory so the tests finds it.
+    if(ENABLE_LIVE_VERIFICATION_TESTS)
+        add_custom_command(TARGET test_regression POST_BUILD
+                           COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:gtest> $<TARGET_FILE_DIR:dynamic_rendering_get_proc_addr>)
+    endif()
 endif()
 
 # must happen after the dll's get copied over
-gtest_discover_tests(test_regression)
-
-# executables that are meant for testing against real drivers rather than the mocks
-add_subdirectory(live_verification)
\ No newline at end of file
+gtest_discover_tests(test_regression)
\ No newline at end of file
index 5365599..5d5f2ad 100644 (file)
@@ -89,7 +89,7 @@ std::vector<VkExtensionProperties> EnumerateDeviceExtensions(InstWrapper const&
     EXPECT_EQ(VK_SUCCESS, res);
     std::vector<VkExtensionProperties> extensions;
     extensions.resize(ext_count);
-    res = inst.functions->vkEnumerateDeviceExtensionProperties(physical_device, nullptr, &ext_count, nullptr);
+    res = inst.functions->vkEnumerateDeviceExtensionProperties(physical_device, nullptr, &ext_count, extensions.data());
     EXPECT_EQ(VK_SUCCESS, res);
     extensions.resize(ext_count);
     return extensions;
index 301f63d..f4a521f 100644 (file)
@@ -65,15 +65,15 @@ int main() {
             alloc_info.commandPool = command_pool;
             funcs.vkAllocateCommandBuffers(dev, &alloc_info, &command_buffer);
             PFN_vkBeginCommandBuffer vkBeginCommandBuffer =
-                reinterpret_cast<PFN_vkBeginCommandBuffer>(vk_funcs.vkGetInstanceProcAddr(inst, "vkBeginCommandBuffer"));
+                reinterpret_cast<PFN_vkBeginCommandBuffer>(vk_funcs.vkGetInstanceProcAddr(inst.inst, "vkBeginCommandBuffer"));
             VkCommandBufferBeginInfo begin_info{};
             begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
             VkResult res = vkBeginCommandBuffer(command_buffer, &begin_info);
             assert(res == VK_SUCCESS);
 
-            // call the dynamic rendering function
+            // call the dynamic rendering function -- should not go into the physical device function trampoline.
             PFN_vkCmdBeginRenderingKHR vkCmdBeginRenderingKHR =
-                reinterpret_cast<PFN_vkCmdBeginRenderingKHR>(vk_funcs.vkGetDeviceProcAddr(dev.dev, "vkCmdBeginRenderingKHR"));
+                reinterpret_cast<PFN_vkCmdBeginRenderingKHR>(vk_funcs.vkGetInstanceProcAddr(inst.inst, "vkCmdBeginRenderingKHR"));
             VkRenderingInfoKHR rendering_info{};
             rendering_info.sType = VK_STRUCTURE_TYPE_RENDERING_INFO_KHR;
             vkCmdBeginRenderingKHR(command_buffer, &rendering_info);