Test when there are no devices or device extensions
authorCharles Giessen <charles@lunarg.com>
Fri, 10 Sep 2021 19:41:09 +0000 (13:41 -0600)
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>
Thu, 10 Feb 2022 23:38:15 +0000 (16:38 -0700)
Adds 2 tests:
* ZeroPhysicalDevices - Return VK_ERROR_INITIALIZATION_FAILED if the driver has zero
physical devices.
* ZeroPhyiscalDeviceExtensions - Return VK_SUCCESS if no physical device extensions are
found.

tests/loader_regression_tests.cpp

index f8583ef8c84d420ceabe1f38f9c7eee0021fdf7c..1b943891818beeb19e320110ca31baf59243e7a1 100644 (file)
@@ -347,6 +347,24 @@ TEST_F(EnumerateDeviceExtensionProperties, PropertyCountLessThanAvailable) {
     ASSERT_TRUE(device_extensions[0].specVersion == enumerated_device_exts[0].specVersion);
 }
 
+TEST_F(EnumerateDeviceExtensionProperties, ZeroPhysicalDeviceExtensions) {
+    env->get_test_icd().add_physical_device({});
+    InstWrapper inst{env->vulkan_functions};
+    inst.create_info.set_api_version(VK_MAKE_API_VERSION(0, 1, 1, 0));
+    inst.CheckCreate(VK_SUCCESS);
+
+    auto phys_dev = inst.GetPhysDev();
+    DeviceWrapper dev{inst};
+    dev.CheckCreate(phys_dev);
+
+    uint32_t ext_count = 0;
+    ASSERT_EQ(VK_SUCCESS, env->vulkan_functions.vkEnumerateDeviceExtensionProperties(phys_dev, nullptr, &ext_count, nullptr));
+    ASSERT_EQ(ext_count, 0);
+    VkExtensionProperties ext_props{};
+    ASSERT_EQ(VK_SUCCESS, env->vulkan_functions.vkEnumerateDeviceExtensionProperties(phys_dev, nullptr, &ext_count, &ext_props));
+    ASSERT_EQ(ext_count, 0);
+}
+
 TEST_F(EnumeratePhysicalDevices, OneCall) {
     auto& driver = env->get_test_icd().set_min_icd_interface_version(5);
 
@@ -453,6 +471,16 @@ TEST_F(EnumeratePhysicalDevices, TwoCallIncomplete) {
     ASSERT_EQ(physical_count, 1);
 }
 
+TEST_F(EnumeratePhysicalDevices, ZeroPhysicalDevices) {
+    InstWrapper inst{env->vulkan_functions};
+    inst.create_info.set_api_version(VK_MAKE_API_VERSION(0, 1, 1, 0));
+    inst.CheckCreate(VK_SUCCESS);
+
+    uint32_t count = 0;
+    ASSERT_EQ(VK_ERROR_INITIALIZATION_FAILED, env->vulkan_functions.vkEnumeratePhysicalDevices(inst, &count, nullptr));
+    ASSERT_EQ(count, 0);
+}
+
 TEST_F(EnumeratePhysicalDevices, ZeroPhysicalDevicesAfterCreateInstance) {
     auto& driver = env->get_test_icd().set_min_icd_interface_version(5);
     InstWrapper inst{env->vulkan_functions};
@@ -1569,4 +1597,4 @@ TEST(SortedPhysicalDevices, DeviceGroupsSortedEnabled) {
     }
 }
 #endif
-#endif  // __linux__ || __FreeBSD__
+#endif  // __linux__ || __FreeBSD__
\ No newline at end of file