vulkan-1/tests: Add test for unsupported instance extensions.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2018-09-10 13:06:59 +02:00 committed by Alexandre Julliard
parent e84999bd7a
commit 931299bd33
1 changed files with 37 additions and 7 deletions

View File

@ -25,7 +25,6 @@ static VkResult create_instance(uint32_t extension_count,
const char * const *enabled_extensions, VkInstance *vk_instance) const char * const *enabled_extensions, VkInstance *vk_instance)
{ {
VkInstanceCreateInfo create_info; VkInstanceCreateInfo create_info;
VkResult vr;
create_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; create_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
create_info.pNext = NULL; create_info.pNext = NULL;
@ -36,22 +35,32 @@ static VkResult create_instance(uint32_t extension_count,
create_info.enabledExtensionCount = extension_count; create_info.enabledExtensionCount = extension_count;
create_info.ppEnabledExtensionNames = enabled_extensions; create_info.ppEnabledExtensionNames = enabled_extensions;
if ((vr = vkCreateInstance(&create_info, NULL, vk_instance)) >= 0) return vkCreateInstance(&create_info, NULL, vk_instance);
}
#define create_instance_skip(a, b, c) create_instance_skip_(__LINE__, a, b, c)
static VkResult create_instance_skip_(unsigned int line, uint32_t extension_count,
const char * const *enabled_extensions, VkInstance *vk_instance)
{
VkResult vr;
if ((vr = create_instance(extension_count, enabled_extensions, vk_instance)) >= 0)
return vr; return vr;
switch (vr) switch (vr)
{ {
case VK_ERROR_EXTENSION_NOT_PRESENT: case VK_ERROR_EXTENSION_NOT_PRESENT:
if (extension_count == 1) if (extension_count == 1)
skip("Instance extension '%s' not supported.\n", enabled_extensions[0]); skip_(__FILE__, line)("Instance extension '%s' not supported.\n", enabled_extensions[0]);
else else
skip("Instance extensions not supported.\n"); skip_(__FILE__, line)("Instance extensions not supported.\n");
break; break;
default: default:
skip("Failed to create Vulkan instance, vr %d.\n", vr); skip_(__FILE__, line)("Failed to create Vulkan instance, vr %d.\n", vr);
break; break;
} }
return vr; return vr;
} }
@ -186,7 +195,7 @@ static void test_physical_device_groups(void)
VK_KHR_DEVICE_GROUP_CREATION_EXTENSION_NAME, VK_KHR_DEVICE_GROUP_CREATION_EXTENSION_NAME,
}; };
if ((vr = create_instance(ARRAY_SIZE(extensions), extensions, &vk_instance)) < 0) if ((vr = create_instance_skip(ARRAY_SIZE(extensions), extensions, &vk_instance)) < 0)
return; return;
ok(vr == VK_SUCCESS, "Got unexpected VkResult %d.\n", vr); ok(vr == VK_SUCCESS, "Got unexpected VkResult %d.\n", vr);
@ -271,6 +280,26 @@ static void test_destroy_command_pool(VkPhysicalDevice vk_physical_device)
vkDestroyDevice(vk_device, NULL); vkDestroyDevice(vk_device, NULL);
} }
static void test_unsupported_instance_extensions(void)
{
VkInstance vk_instance;
unsigned int i;
VkResult vr;
static const char *extensions[] =
{
"VK_KHR_xcb_surface",
"VK_KHR_xlib_surface",
};
for (i = 0; i < ARRAY_SIZE(extensions); ++i)
{
vr = create_instance(1, &extensions[i], &vk_instance);
ok(vr == VK_ERROR_EXTENSION_NOT_PRESENT,
"Got VkResult %d for extension %s.\n", vr, extensions[i]);
}
}
static void for_each_device(void (*test_func)(VkPhysicalDevice)) static void for_each_device(void (*test_func)(VkPhysicalDevice))
{ {
VkPhysicalDevice *vk_physical_devices; VkPhysicalDevice *vk_physical_devices;
@ -279,7 +308,7 @@ static void for_each_device(void (*test_func)(VkPhysicalDevice))
uint32_t count; uint32_t count;
VkResult vr; VkResult vr;
if ((vr = create_instance(0, NULL, &vk_instance)) < 0) if ((vr = create_instance_skip(0, NULL, &vk_instance)) < 0)
return; return;
ok(vr == VK_SUCCESS, "Got unexpected VkResult %d.\n", vr); ok(vr == VK_SUCCESS, "Got unexpected VkResult %d.\n", vr);
@ -312,4 +341,5 @@ START_TEST(vulkan)
for_each_device(enumerate_device_queues); for_each_device(enumerate_device_queues);
test_physical_device_groups(); test_physical_device_groups();
for_each_device(test_destroy_command_pool); for_each_device(test_destroy_command_pool);
test_unsupported_instance_extensions();
} }