diff options
author | phish3y <logsdonevan1@gmail.com> | 2022-11-29 20:22:39 -0800 |
---|---|---|
committer | Charles Giessen <46324611+charles-lunarg@users.noreply.github.com> | 2022-12-02 12:10:52 -0600 |
commit | e70b648d0f9fd9bcf9934a4a2562c9544ca5c52f (patch) | |
tree | 7e11c51314e417e17225e3c5113dec4ca5ff6aac | |
parent | e99f20d5ec72dc3b19109026c25b7913883e96da (diff) | |
download | Vulkan-Loader-e70b648d0f9fd9bcf9934a4a2562c9544ca5c52f.tar.gz Vulkan-Loader-e70b648d0f9fd9bcf9934a4a2562c9544ca5c52f.tar.bz2 Vulkan-Loader-e70b648d0f9fd9bcf9934a4a2562c9544ca5c52f.zip |
Layers: modify TestLayerDetails so either files or directories can be set on VK_LAYER_PATH env var
-rw-r--r-- | tests/framework/test_environment.cpp | 5 | ||||
-rw-r--r-- | tests/framework/test_environment.h | 1 | ||||
-rw-r--r-- | tests/loader_layer_tests.cpp | 57 |
3 files changed, 38 insertions, 25 deletions
diff --git a/tests/framework/test_environment.cpp b/tests/framework/test_environment.cpp index 5ce4d889..308230e6 100644 --- a/tests/framework/test_environment.cpp +++ b/tests/framework/test_environment.cpp @@ -456,6 +456,11 @@ void FrameworkEnvironment::add_layer_impl(TestLayerDetails layer_details, Manife if (!env_var_vk_layer_paths.empty()) { env_var_vk_layer_paths += OS_ENV_VAR_LIST_SEPARATOR; } + if(layer_details.is_dir) { + env_var_vk_layer_paths += fs_ptr->location().str(); + } else { + env_var_vk_layer_paths += fs_ptr->location().str() + OS_ENV_VAR_LIST_SEPARATOR + layer_details.json_name; + } env_var_vk_layer_paths += fs_ptr->location().str(); set_env_var("VK_LAYER_PATH", env_var_vk_layer_paths); break; diff --git a/tests/framework/test_environment.h b/tests/framework/test_environment.h index 7d2e00e7..bcc39bfe 100644 --- a/tests/framework/test_environment.h +++ b/tests/framework/test_environment.h @@ -477,6 +477,7 @@ struct TestLayerDetails { BUILDER_VALUE(TestLayerDetails, std::string, json_name, "test_layer"); BUILDER_VALUE(TestLayerDetails, ManifestDiscoveryType, discovery_type, ManifestDiscoveryType::generic); BUILDER_VALUE(TestLayerDetails, bool, is_fake, false); + BUILDER_VALUE(TestLayerDetails, bool, is_dir, true); }; enum class ManifestLocation { diff --git a/tests/loader_layer_tests.cpp b/tests/loader_layer_tests.cpp index c530a0a4..4bbd351c 100644 --- a/tests/loader_layer_tests.cpp +++ b/tests/loader_layer_tests.cpp @@ -2096,26 +2096,17 @@ TEST(ExplicitLayers, VkLayerPathEnvVar) { env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2_EXPORT_ICD_GPDPA)); env.get_test_icd().add_physical_device({}); - const char* regular_layer_name_1 = "RegularLayer1"; - env.add_explicit_layer( + { + // verify layer loads successfully when setting VK_LAYER_PATH to a full filepath + const char* regular_layer_name_1 = "RegularLayer1"; + env.add_explicit_layer( + TestLayerDetails( ManifestLayer{}.add_layer( ManifestLayer::LayerDescription{}.set_name(regular_layer_name_1).set_lib_path(TEST_LAYER_PATH_EXPORT_VERSION_2)), - "regular_layer_1.json"); - + "regular_layer_1.json").set_discovery_type(ManifestDiscoveryType::env_var).set_is_dir(false)); - - { - // when overriding the search path to a non-existent file, instance should fail to create - InstWrapper inst(env.vulkan_functions); - inst.create_info.add_layer(regular_layer_name_1); - set_env_var("VK_LAYER_PATH", "/home/phish3y/dev/Vulkan-Loader/build/install/etc/vulkan/explicit_layer.d/regular_layer_2.json"); - inst.CheckCreate(VK_ERROR_LAYER_NOT_PRESENT); - } - { - // when overriding the search path to an existing file, count should be 1 InstWrapper inst(env.vulkan_functions); inst.create_info.add_layer(regular_layer_name_1); - set_env_var("VK_LAYER_PATH", "/home/phish3y/dev/Vulkan-Loader/build/install/etc/vulkan/explicit_layer.d/regular_layer_1.json"); inst.CheckCreate(VK_SUCCESS); auto phys_dev = inst.GetPhysDev(); uint32_t count = 0; @@ -2123,16 +2114,24 @@ TEST(ExplicitLayers, VkLayerPathEnvVar) { ASSERT_EQ(count, 1U); } { - // when overriding the search path to two existing files, count should be 2 + // verify layers load successfully when setting VK_LAYER_PATH to multiple full filepaths + const char* regular_layer_name_1 = "RegularLayer1"; + env.add_explicit_layer( + TestLayerDetails( + ManifestLayer{}.add_layer( + ManifestLayer::LayerDescription{}.set_name(regular_layer_name_1).set_lib_path(TEST_LAYER_PATH_EXPORT_VERSION_2)), + "regular_layer_1.json").set_discovery_type(ManifestDiscoveryType::env_var).set_is_dir(false)); + const char* regular_layer_name_2 = "RegularLayer2"; env.add_explicit_layer( - ManifestLayer{}.add_layer( - ManifestLayer::LayerDescription{}.set_name(regular_layer_name_2).set_lib_path(TEST_LAYER_PATH_EXPORT_VERSION_2)), - "regular_layer_2.json"); + TestLayerDetails( + ManifestLayer{}.add_layer( + ManifestLayer::LayerDescription{}.set_name(regular_layer_name_2).set_lib_path(TEST_LAYER_PATH_EXPORT_VERSION_2)), + "regular_layer_2.json").set_discovery_type(ManifestDiscoveryType::env_var).set_is_dir(false)); + InstWrapper inst(env.vulkan_functions); inst.create_info.add_layer(regular_layer_name_1); inst.create_info.add_layer(regular_layer_name_2); - set_env_var("VK_LAYER_PATH", "/home/phish3y/dev/Vulkan-Loader/build/install/etc/vulkan/explicit_layer.d/regular_layer_1.json:/home/phish3y/dev/Vulkan-Loader/build/install/etc/vulkan/explicit_layer.d/regular_layer_2.json"); inst.CheckCreate(VK_SUCCESS); auto phys_dev = inst.GetPhysDev(); uint32_t count = 0; @@ -2140,16 +2139,24 @@ TEST(ExplicitLayers, VkLayerPathEnvVar) { ASSERT_EQ(count, 2U); } { - // when overriding the search path to an existing directory with two files, count should be 2 + // verify layers load successfully when setting VK_LAYER_PATH to a directory + const char* regular_layer_name_1 = "RegularLayer1"; + env.add_explicit_layer( + TestLayerDetails( + ManifestLayer{}.add_layer( + ManifestLayer::LayerDescription{}.set_name(regular_layer_name_1).set_lib_path(TEST_LAYER_PATH_EXPORT_VERSION_2)), + "regular_layer_1.json").set_discovery_type(ManifestDiscoveryType::env_var)); + const char* regular_layer_name_2 = "RegularLayer2"; env.add_explicit_layer( - ManifestLayer{}.add_layer( - ManifestLayer::LayerDescription{}.set_name(regular_layer_name_2).set_lib_path(TEST_LAYER_PATH_EXPORT_VERSION_2)), - "regular_layer_2.json"); + TestLayerDetails( + ManifestLayer{}.add_layer( + ManifestLayer::LayerDescription{}.set_name(regular_layer_name_2).set_lib_path(TEST_LAYER_PATH_EXPORT_VERSION_2)), + "regular_layer_2.json").set_discovery_type(ManifestDiscoveryType::env_var)); + InstWrapper inst(env.vulkan_functions); inst.create_info.add_layer(regular_layer_name_1); inst.create_info.add_layer(regular_layer_name_2); - set_env_var("VK_LAYER_PATH", "/home/phish3y/dev/Vulkan-Loader/build/install/etc/vulkan/explicit_layer.d"); inst.CheckCreate(VK_SUCCESS); auto phys_dev = inst.GetPhysDev(); uint32_t count = 0; |