aboutsummaryrefslogtreecommitdiff
path: root/tests/icd/mock_icd_tests.cpp
diff options
context:
space:
mode:
authorCharles Giessen <charles@lunarg.com>2023-08-19 16:45:26 -0600
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>2023-08-21 16:44:30 -0600
commitb441f434a036d6fe463ba944c8d7e0a9cd30faa6 (patch)
treecccb28613e907ac2ec8a46ad743ac9a07394990b /tests/icd/mock_icd_tests.cpp
parent944f91b48811d072654d3a0db4f6d704c04fadbd (diff)
downloadusermoji-b441f434a036d6fe463ba944c8d7e0a9cd30faa6.tar.xz
test: Make mock ICD tests work on windows
This does not enable testing in CI on windows, due to the loader ignoring VK_DRIVER_FILES when running in admin mode.
Diffstat (limited to 'tests/icd/mock_icd_tests.cpp')
-rw-r--r--tests/icd/mock_icd_tests.cpp38
1 files changed, 10 insertions, 28 deletions
diff --git a/tests/icd/mock_icd_tests.cpp b/tests/icd/mock_icd_tests.cpp
index ee1cbcb5..bcae57a9 100644
--- a/tests/icd/mock_icd_tests.cpp
+++ b/tests/icd/mock_icd_tests.cpp
@@ -17,25 +17,7 @@
*
*/
-#include <stdlib.h>
-
-#include <array>
-#include <iostream>
-#include <vector>
-
-#include "gtest/gtest.h"
-#include "vulkan/vulkan.h"
-
-// Location of the built binaries in this repo
-#include "binary_locations.h"
-
-#if defined(WIN32)
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-int set_environment_var(const char* name, const char* value) { return SetEnvironmentVariable(name, value); }
-#else
-int set_environment_var(const char* name, const char* value) { return setenv(name, value, 1); }
-#endif
+#include "test_common.h"
void setup_mock_icd_env_vars() {
// Necessary to point the loader at the mock driver
@@ -256,7 +238,7 @@ TEST_F(MockICD, vkGetPhysicalDeviceSurfacePresentModesKHR) {
VkSurfaceKHR surface{};
res = create_surface(instance, surface);
ASSERT_EQ(res, VK_SUCCESS);
- ASSERT_NE(surface, nullptr);
+ ASSERT_NE(surface, VK_NULL_HANDLE);
uint32_t count = 0;
std::array<VkPresentModeKHR, 6> present_modes{};
res = vkGetPhysicalDeviceSurfacePresentModesKHR(physical_device, surface, &count, nullptr);
@@ -278,7 +260,7 @@ TEST_F(MockICD, vkGetPhysicalDeviceSurfaceFormatsKHR) {
VkSurfaceKHR surface{};
res = create_surface(instance, surface);
ASSERT_EQ(res, VK_SUCCESS);
- ASSERT_NE(surface, nullptr);
+ ASSERT_NE(surface, VK_NULL_HANDLE);
uint32_t count = 0;
std::array<VkSurfaceFormatKHR, 2> surface_formats{};
res = vkGetPhysicalDeviceSurfaceFormatsKHR(physical_device, surface, &count, nullptr);
@@ -298,7 +280,7 @@ TEST_F(MockICD, vkGetPhysicalDeviceSurfaceFormats2KHR) {
VkSurfaceKHR surface{};
res = create_surface(instance, surface);
ASSERT_EQ(res, VK_SUCCESS);
- ASSERT_NE(surface, nullptr);
+ ASSERT_NE(surface, VK_NULL_HANDLE);
uint32_t count = 0;
std::array<VkSurfaceFormat2KHR, 2> surface_formats2{};
VkPhysicalDeviceSurfaceInfo2KHR surface_info{};
@@ -322,7 +304,7 @@ TEST_F(MockICD, vkGetPhysicalDeviceSurfaceSupportKHR) {
VkSurfaceKHR surface{};
res = create_surface(instance, surface);
ASSERT_EQ(res, VK_SUCCESS);
- ASSERT_NE(surface, nullptr);
+ ASSERT_NE(surface, VK_NULL_HANDLE);
VkBool32 supported = false;
res = vkGetPhysicalDeviceSurfaceSupportKHR(physical_device, 0, surface, &supported);
ASSERT_EQ(res, VK_SUCCESS);
@@ -335,7 +317,7 @@ TEST_F(MockICD, vkGetPhysicalDeviceSurfaceCapabilitiesKHR) {
VkSurfaceKHR surface{};
res = create_surface(instance, surface);
ASSERT_EQ(res, VK_SUCCESS);
- ASSERT_NE(surface, nullptr);
+ ASSERT_NE(surface, VK_NULL_HANDLE);
VkSurfaceCapabilitiesKHR surface_capabilities{};
res = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physical_device, surface, &surface_capabilities);
ASSERT_EQ(res, VK_SUCCESS);
@@ -354,7 +336,7 @@ TEST_F(MockICD, vkGetPhysicalDeviceSurfaceCapabilities2KHR) {
VkSurfaceKHR surface{};
res = create_surface(instance, surface);
ASSERT_EQ(res, VK_SUCCESS);
- ASSERT_NE(surface, nullptr);
+ ASSERT_NE(surface, VK_NULL_HANDLE);
VkSurfaceCapabilities2KHR surface_capabilities2{};
VkPhysicalDeviceSurfaceInfo2KHR surface_info{};
surface_info.surface = surface;
@@ -899,7 +881,7 @@ TEST_F(MockICD, SwapchainLifeCycle) {
VkSurfaceKHR surface{};
res = create_surface(instance, surface);
ASSERT_EQ(res, VK_SUCCESS);
- ASSERT_NE(surface, nullptr);
+ ASSERT_NE(surface, VK_NULL_HANDLE);
VkSwapchainCreateInfoKHR swapchain_create_info{};
swapchain_create_info.surface = surface;
@@ -907,7 +889,7 @@ TEST_F(MockICD, SwapchainLifeCycle) {
VkSwapchainKHR swapchain{};
res = vkCreateSwapchainKHR(device, &swapchain_create_info, nullptr, &swapchain);
ASSERT_EQ(res, VK_SUCCESS);
- ASSERT_NE(swapchain, nullptr);
+ ASSERT_NE(swapchain, VK_NULL_HANDLE);
uint32_t count = 0;
res = vkGetSwapchainImagesKHR(device, swapchain, &count, nullptr);
@@ -916,7 +898,7 @@ TEST_F(MockICD, SwapchainLifeCycle) {
std::array<VkImage, 1> swapchain_images;
res = vkGetSwapchainImagesKHR(device, swapchain, &count, swapchain_images.data());
ASSERT_EQ(res, VK_SUCCESS);
- ASSERT_NE(swapchain_images[0], nullptr);
+ ASSERT_NE(swapchain_images[0], VK_NULL_HANDLE);
uint32_t image_index = 10; // arbitrary non zero value
res = vkAcquireNextImageKHR(device, swapchain, 0, VK_NULL_HANDLE, VK_NULL_HANDLE, &image_index);