From: Charles Giessen Date: Fri, 23 Jun 2023 03:42:26 +0000 (-0600) Subject: Add test for layer_prop_list out of bounds indexing X-Git-Tag: upstream/1.3.268~83 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5525f02363cab9d2e47c288ae113f1221b6a649d;p=platform%2Fupstream%2FVulkan-Loader.git Add test for layer_prop_list out of bounds indexing This test makes sure that we correctly query for unknown functions implemented only in a single layer while there are other layers present. This commit successfully reproduces the error that the previous commit fixes. It was difficult to reproduce because to get an crash, the test has to have the instance_layer_list be in a different order than how they appear in expanded_activated_layer_list. --- diff --git a/tests/loader_unknown_ext_tests.cpp b/tests/loader_unknown_ext_tests.cpp index 569234e8..dd918b8f 100644 --- a/tests/loader_unknown_ext_tests.cpp +++ b/tests/loader_unknown_ext_tests.cpp @@ -1263,3 +1263,49 @@ TEST(UnknownFunction, ManyCombinations) { unknown_funcs.at(5).check(env.vulkan_functions, inst.inst, phys_dev); } } + +TEST(UnknownFunction, PhysicalDeviceFunctionInLayer) { + FrameworkEnvironment env{}; + env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2_EXPORT_ICD_GPDPA)).add_physical_device({}); + + env.add_implicit_layer(ManifestLayer{} + .add_layer(ManifestLayer::LayerDescription{} + .set_name("VK_LAYER_implicit_layer_1") + .set_lib_path(TEST_LAYER_PATH_EXPORT_VERSION_0) + .set_disable_environment("DISABLE_ME")) + .set_file_format_version({1, 0, 0}), + "implicit_layer_1.json"); + + UnknownFunction unknown_func{"vkPhysicalDeviceFunctionInLayer"}; + const char* ext_name = "VK_EXT_not_funny"; + + const char* explicit_layer_unknown_function_implement = "VK_LAYER_implement_unknown_function"; + env.add_explicit_layer( + ManifestLayer{} + .add_layer(ManifestLayer::LayerDescription{} + .set_name(explicit_layer_unknown_function_implement) + .set_lib_path(TEST_LAYER_PATH_EXPORT_VERSION_2) + .add_instance_extension(ManifestLayer::LayerDescription::Extension{ext_name, 0, {unknown_func.name}})) + .set_file_format_version({1, 1, 0}), + "implement_unknown_function.json"); + auto& layer0 = env.get_test_layer(1); + + const char* explicit_layer_to_enable_1 = "VK_LAYER_explicit_layer_1"; + env.add_explicit_layer(ManifestLayer{} + .add_layer(ManifestLayer::LayerDescription{} + .set_name(explicit_layer_to_enable_1) + .set_lib_path(TEST_LAYER_PATH_EXPORT_VERSION_2)) + .set_file_format_version({1, 2, 0}), + "explicit_layer_2.json"); + + Functions::four::physical_device::add_implementation_to_layer(unknown_func, layer0); + + InstWrapper inst{env.vulkan_functions}; + inst.create_info.add_layer(explicit_layer_to_enable_1); + inst.create_info.add_layer(explicit_layer_unknown_function_implement); + inst.CheckCreate(); + + VkPhysicalDevice phys_dev = inst.GetPhysDev(); + + unknown_func.check(env.vulkan_functions, inst.inst, phys_dev); +}