15db71995Sopenharmony_ci/*
25db71995Sopenharmony_ci * Copyright (c) 2021-2023 The Khronos Group Inc.
35db71995Sopenharmony_ci * Copyright (c) 2021-2023 Valve Corporation
45db71995Sopenharmony_ci * Copyright (c) 2021-2023 LunarG, Inc.
55db71995Sopenharmony_ci *
65db71995Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a copy
75db71995Sopenharmony_ci * of this software and/or associated documentation files (the "Materials"), to
85db71995Sopenharmony_ci * deal in the Materials without restriction, including without limitation the
95db71995Sopenharmony_ci * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
105db71995Sopenharmony_ci * sell copies of the Materials, and to permit persons to whom the Materials are
115db71995Sopenharmony_ci * furnished to do so, subject to the following conditions:
125db71995Sopenharmony_ci *
135db71995Sopenharmony_ci * The above copyright notice(s) and this permission notice shall be included in
145db71995Sopenharmony_ci * all copies or substantial portions of the Materials.
155db71995Sopenharmony_ci *
165db71995Sopenharmony_ci * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
175db71995Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
185db71995Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
195db71995Sopenharmony_ci *
205db71995Sopenharmony_ci * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
215db71995Sopenharmony_ci * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
225db71995Sopenharmony_ci * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE
235db71995Sopenharmony_ci * USE OR OTHER DEALINGS IN THE MATERIALS.
245db71995Sopenharmony_ci *
255db71995Sopenharmony_ci * Author: Charles Giessen <charles@lunarg.com>
265db71995Sopenharmony_ci * Author: Mark Young <markylunarg.com>
275db71995Sopenharmony_ci */
285db71995Sopenharmony_ci
295db71995Sopenharmony_ci#include "test_environment.h"
305db71995Sopenharmony_ci
315db71995Sopenharmony_ci// Don't support vk_icdNegotiateLoaderICDInterfaceVersion
325db71995Sopenharmony_ci// Loader calls vk_icdGetInstanceProcAddr second
335db71995Sopenharmony_ci// does not support vk_icdGetInstanceProcAddr
345db71995Sopenharmony_ci// must export vkGetInstanceProcAddr, vkCreateInstance, vkEnumerateInstanceExtensionProperties
355db71995Sopenharmony_ciTEST(EnvVarICDOverrideSetup, version_0_none) {
365db71995Sopenharmony_ci    FrameworkEnvironment env{};
375db71995Sopenharmony_ci    env.add_icd(TestICDDetails(TEST_ICD_PATH_EXPORT_NONE).set_discovery_type(ManifestDiscoveryType::env_var));
385db71995Sopenharmony_ci
395db71995Sopenharmony_ci    InstWrapper inst{env.vulkan_functions};
405db71995Sopenharmony_ci    inst.CheckCreate();
415db71995Sopenharmony_ci
425db71995Sopenharmony_ci    ASSERT_EQ(env.get_test_icd(0).called_vk_icd_gipa, CalledICDGIPA::vk_gipa);
435db71995Sopenharmony_ci}
445db71995Sopenharmony_ci
455db71995Sopenharmony_ci// Don't support vk_icdNegotiateLoaderICDInterfaceVersion
465db71995Sopenharmony_ci// the loader calls vk_icdGetInstanceProcAddr first
475db71995Sopenharmony_ciTEST(EnvVarICDOverrideSetup, version_1_icd_gipa) {
485db71995Sopenharmony_ci    FrameworkEnvironment env{};
495db71995Sopenharmony_ci    env.add_icd(TestICDDetails(TEST_ICD_PATH_EXPORT_ICD_GIPA).set_discovery_type(ManifestDiscoveryType::env_var));
505db71995Sopenharmony_ci
515db71995Sopenharmony_ci    InstWrapper inst{env.vulkan_functions};
525db71995Sopenharmony_ci    inst.CheckCreate();
535db71995Sopenharmony_ci
545db71995Sopenharmony_ci    ASSERT_EQ(env.get_test_icd(0).called_vk_icd_gipa, CalledICDGIPA::vk_icd_gipa);
555db71995Sopenharmony_ci}
565db71995Sopenharmony_ci
575db71995Sopenharmony_ci// support vk_icdNegotiateLoaderICDInterfaceVersion but not vk_icdGetInstanceProcAddr
585db71995Sopenharmony_ciTEST(EnvVarICDOverrideSetup, version_negotiate_interface_version_death_test) {
595db71995Sopenharmony_ci    FrameworkEnvironment env{};
605db71995Sopenharmony_ci    env.add_icd(
615db71995Sopenharmony_ci        TestICDDetails(TEST_ICD_PATH_EXPORT_NEGOTIATE_INTERFACE_VERSION).set_discovery_type(ManifestDiscoveryType::env_var));
625db71995Sopenharmony_ci
635db71995Sopenharmony_ci    InstWrapper inst{env.vulkan_functions};
645db71995Sopenharmony_ci    inst.CheckCreate(VK_ERROR_INCOMPATIBLE_DRIVER);
655db71995Sopenharmony_ci}
665db71995Sopenharmony_ci
675db71995Sopenharmony_ci// export vk_icdNegotiateLoaderICDInterfaceVersion and vk_icdGetInstanceProcAddr
685db71995Sopenharmony_ciTEST(EnvVarICDOverrideSetup, version_2_negotiate_interface_version_and_icd_gipa) {
695db71995Sopenharmony_ci    FrameworkEnvironment env{};
705db71995Sopenharmony_ci    env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2).set_discovery_type(ManifestDiscoveryType::env_var));
715db71995Sopenharmony_ci
725db71995Sopenharmony_ci    InstWrapper inst{env.vulkan_functions};
735db71995Sopenharmony_ci    inst.CheckCreate();
745db71995Sopenharmony_ci
755db71995Sopenharmony_ci    ASSERT_EQ(env.get_test_icd(0).called_vk_icd_gipa, CalledICDGIPA::vk_icd_gipa);
765db71995Sopenharmony_ci}
775db71995Sopenharmony_ci
785db71995Sopenharmony_ci// export vk_icdNegotiateLoaderICDInterfaceVersion and vk_icdGetInstanceProcAddr
795db71995Sopenharmony_ciTEST(EnvVarICDOverrideSetup, version_2_negotiate_interface_version_and_icd_gipa_unicode) {
805db71995Sopenharmony_ci    FrameworkEnvironment env{};
815db71995Sopenharmony_ci    env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2_UNICODE)
825db71995Sopenharmony_ci                    .set_discovery_type(ManifestDiscoveryType::env_var)
835db71995Sopenharmony_ci                    .set_json_name(TEST_JSON_NAME_VERSION_2_UNICODE));
845db71995Sopenharmony_ci
855db71995Sopenharmony_ci    InstWrapper inst{env.vulkan_functions};
865db71995Sopenharmony_ci    inst.CheckCreate();
875db71995Sopenharmony_ci
885db71995Sopenharmony_ci    ASSERT_EQ(env.get_test_icd(0).called_vk_icd_gipa, CalledICDGIPA::vk_icd_gipa);
895db71995Sopenharmony_ci}
905db71995Sopenharmony_ci
915db71995Sopenharmony_ci// Test VK_DRIVER_FILES environment variable
925db71995Sopenharmony_ciTEST(EnvVarICDOverrideSetup, TestOnlyDriverEnvVar) {
935db71995Sopenharmony_ci    FrameworkEnvironment env{};
945db71995Sopenharmony_ci    env.add_icd(TestICDDetails(TEST_ICD_PATH_EXPORT_NONE).set_discovery_type(ManifestDiscoveryType::env_var));
955db71995Sopenharmony_ci    env.get_test_icd(0).add_physical_device("pd0");
965db71995Sopenharmony_ci
975db71995Sopenharmony_ci    InstWrapper inst1{env.vulkan_functions};
985db71995Sopenharmony_ci    FillDebugUtilsCreateDetails(inst1.create_info, env.debug_log);
995db71995Sopenharmony_ci    inst1.CheckCreate();
1005db71995Sopenharmony_ci    EXPECT_FALSE(
1015db71995Sopenharmony_ci        env.debug_log.find("Ignoring override VK_ICD_FILENAMES, VK_DRIVER_FILES, and VK_ADD_DRIVER_FILES due to high-integrity"));
1025db71995Sopenharmony_ci
1035db71995Sopenharmony_ci    std::array<VkPhysicalDevice, 5> phys_devs_array;
1045db71995Sopenharmony_ci    uint32_t phys_dev_count = 1;
1055db71995Sopenharmony_ci    ASSERT_EQ(inst1->vkEnumeratePhysicalDevices(inst1.inst, &phys_dev_count, phys_devs_array.data()), VK_SUCCESS);
1065db71995Sopenharmony_ci    ASSERT_EQ(phys_dev_count, 1U);
1075db71995Sopenharmony_ci
1085db71995Sopenharmony_ci    for (uint32_t add = 0; add < 2; ++add) {
1095db71995Sopenharmony_ci        env.add_icd(TestICDDetails(TEST_ICD_PATH_EXPORT_NONE).set_discovery_type(ManifestDiscoveryType::env_var))
1105db71995Sopenharmony_ci            .add_physical_device("pd" + std::to_string(add) + "0")
1115db71995Sopenharmony_ci            .add_physical_device("pd" + std::to_string(add) + "1");
1125db71995Sopenharmony_ci    }
1135db71995Sopenharmony_ci
1145db71995Sopenharmony_ci    env.debug_log.clear();
1155db71995Sopenharmony_ci
1165db71995Sopenharmony_ci    InstWrapper inst2{env.vulkan_functions};
1175db71995Sopenharmony_ci    FillDebugUtilsCreateDetails(inst2.create_info, env.debug_log);
1185db71995Sopenharmony_ci    inst2.CheckCreate();
1195db71995Sopenharmony_ci
1205db71995Sopenharmony_ci    phys_dev_count = 5;
1215db71995Sopenharmony_ci    ASSERT_EQ(inst2->vkEnumeratePhysicalDevices(inst2.inst, &phys_dev_count, phys_devs_array.data()), VK_SUCCESS);
1225db71995Sopenharmony_ci    ASSERT_EQ(phys_dev_count, 5U);
1235db71995Sopenharmony_ci
1245db71995Sopenharmony_ci    env.debug_log.clear();
1255db71995Sopenharmony_ci
1265db71995Sopenharmony_ci    env.platform_shim->set_elevated_privilege(true);
1275db71995Sopenharmony_ci
1285db71995Sopenharmony_ci    InstWrapper inst3{env.vulkan_functions};
1295db71995Sopenharmony_ci    FillDebugUtilsCreateDetails(inst3.create_info, env.debug_log);
1305db71995Sopenharmony_ci    inst3.CheckCreate(VK_ERROR_INCOMPATIBLE_DRIVER);
1315db71995Sopenharmony_ci
1325db71995Sopenharmony_ci    EXPECT_TRUE(env.debug_log.find("vkCreateInstance: Found no drivers!"));
1335db71995Sopenharmony_ci
1345db71995Sopenharmony_ci    env.platform_shim->set_elevated_privilege(false);
1355db71995Sopenharmony_ci}
1365db71995Sopenharmony_ci
1375db71995Sopenharmony_ci// Test VK_DRIVER_FILES environment variable containing a path to a folder
1385db71995Sopenharmony_ciTEST(EnvVarICDOverrideSetup, TestOnlyDriverEnvVarInFolder) {
1395db71995Sopenharmony_ci    FrameworkEnvironment env{};
1405db71995Sopenharmony_ci    env.add_icd(TestICDDetails(TEST_ICD_PATH_EXPORT_NONE).set_discovery_type(ManifestDiscoveryType::env_var).set_is_dir(false));
1415db71995Sopenharmony_ci    env.get_test_icd(0).add_physical_device("pd0");
1425db71995Sopenharmony_ci
1435db71995Sopenharmony_ci    InstWrapper inst1{env.vulkan_functions};
1445db71995Sopenharmony_ci    FillDebugUtilsCreateDetails(inst1.create_info, env.debug_log);
1455db71995Sopenharmony_ci    inst1.CheckCreate();
1465db71995Sopenharmony_ci    EXPECT_FALSE(
1475db71995Sopenharmony_ci        env.debug_log.find("Ignoring override VK_ICD_FILENAMES, VK_DRIVER_FILES, and VK_ADD_DRIVER_FILES due to high-integrity"));
1485db71995Sopenharmony_ci
1495db71995Sopenharmony_ci    std::array<VkPhysicalDevice, 5> phys_devs_array;
1505db71995Sopenharmony_ci    uint32_t phys_dev_count = 1;
1515db71995Sopenharmony_ci    ASSERT_EQ(inst1->vkEnumeratePhysicalDevices(inst1.inst, &phys_dev_count, phys_devs_array.data()), VK_SUCCESS);
1525db71995Sopenharmony_ci    ASSERT_EQ(phys_dev_count, 1U);
1535db71995Sopenharmony_ci
1545db71995Sopenharmony_ci    for (uint32_t add = 0; add < 2; ++add) {
1555db71995Sopenharmony_ci        env.add_icd(TestICDDetails(TEST_ICD_PATH_EXPORT_NONE).set_discovery_type(ManifestDiscoveryType::env_var))
1565db71995Sopenharmony_ci            .add_physical_device("pd" + std::to_string(add) + "0")
1575db71995Sopenharmony_ci            .add_physical_device("pd" + std::to_string(add) + "1");
1585db71995Sopenharmony_ci    }
1595db71995Sopenharmony_ci
1605db71995Sopenharmony_ci    env.debug_log.clear();
1615db71995Sopenharmony_ci
1625db71995Sopenharmony_ci    InstWrapper inst2{env.vulkan_functions};
1635db71995Sopenharmony_ci    FillDebugUtilsCreateDetails(inst2.create_info, env.debug_log);
1645db71995Sopenharmony_ci    inst2.CheckCreate();
1655db71995Sopenharmony_ci
1665db71995Sopenharmony_ci    phys_dev_count = 5;
1675db71995Sopenharmony_ci    ASSERT_EQ(inst2->vkEnumeratePhysicalDevices(inst2.inst, &phys_dev_count, phys_devs_array.data()), VK_SUCCESS);
1685db71995Sopenharmony_ci    ASSERT_EQ(phys_dev_count, 5U);
1695db71995Sopenharmony_ci
1705db71995Sopenharmony_ci    env.debug_log.clear();
1715db71995Sopenharmony_ci
1725db71995Sopenharmony_ci    env.platform_shim->set_elevated_privilege(true);
1735db71995Sopenharmony_ci
1745db71995Sopenharmony_ci    InstWrapper inst3{env.vulkan_functions};
1755db71995Sopenharmony_ci    FillDebugUtilsCreateDetails(inst3.create_info, env.debug_log);
1765db71995Sopenharmony_ci    inst3.CheckCreate(VK_ERROR_INCOMPATIBLE_DRIVER);
1775db71995Sopenharmony_ci
1785db71995Sopenharmony_ci    EXPECT_TRUE(env.debug_log.find("vkCreateInstance: Found no drivers!"));
1795db71995Sopenharmony_ci
1805db71995Sopenharmony_ci    env.platform_shim->set_elevated_privilege(false);
1815db71995Sopenharmony_ci}
1825db71995Sopenharmony_ci
1835db71995Sopenharmony_ci#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__GNU__)
1845db71995Sopenharmony_ci// Make sure the loader reports the correct message based on if LOADER_USE_UNSAFE_FILE_SEARCH is set or not
1855db71995Sopenharmony_ciTEST(EnvVarICDOverrideSetup, NonSecureEnvVarLookup) {
1865db71995Sopenharmony_ci    FrameworkEnvironment env{};
1875db71995Sopenharmony_ci    env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2_EXPORT_ICD_GPDPA)).add_physical_device("physical_device_0");
1885db71995Sopenharmony_ci
1895db71995Sopenharmony_ci    DebugUtilsLogger log{VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT};
1905db71995Sopenharmony_ci    InstWrapper inst{env.vulkan_functions};
1915db71995Sopenharmony_ci    FillDebugUtilsCreateDetails(inst.create_info, log);
1925db71995Sopenharmony_ci    inst.CheckCreate();
1935db71995Sopenharmony_ci
1945db71995Sopenharmony_ci#if !defined(LOADER_USE_UNSAFE_FILE_SEARCH)
1955db71995Sopenharmony_ci    ASSERT_FALSE(log.find("Loader is using non-secure environment variable lookup for"));
1965db71995Sopenharmony_ci#else
1975db71995Sopenharmony_ci    ASSERT_TRUE(log.find("Loader is using non-secure environment variable lookup for"));
1985db71995Sopenharmony_ci#endif
1995db71995Sopenharmony_ci}
2005db71995Sopenharmony_ci
2015db71995Sopenharmony_ci// Check for proper handling of paths specified via environment variables.
2025db71995Sopenharmony_ciTEST(EnvVarICDOverrideSetup, XDG) {
2035db71995Sopenharmony_ci    // Set up a layer path that includes default and user-specified locations,
2045db71995Sopenharmony_ci    // so that the test app can find them.  Include some badly specified elements as well.
2055db71995Sopenharmony_ci    // Need to redirect the 'home' directory
2065db71995Sopenharmony_ci    fs::path HOME = "/home/fake_home";
2075db71995Sopenharmony_ci    EnvVarWrapper home_env_var{"HOME", HOME.str()};
2085db71995Sopenharmony_ci    EnvVarWrapper xdg_config_dirs_env_var{"XDG_CONFIG_DIRS", ":/tmp/goober:::::/tmp/goober/::::"};
2095db71995Sopenharmony_ci    EnvVarWrapper xdg_config_home_env_var{"XDG_CONFIG_HOME", ":/tmp/goober:::::/tmp/goober2/::::"};
2105db71995Sopenharmony_ci    EnvVarWrapper xdg_data_dirs_env_var{"XDG_DATA_DIRS", "::::/tmp/goober3:/tmp/goober4/with spaces:::"};
2115db71995Sopenharmony_ci    EnvVarWrapper xdg_data_home_env_var{"XDG_DATA_HOME", "::::/tmp/goober3:/tmp/goober4/with spaces:::"};
2125db71995Sopenharmony_ci
2135db71995Sopenharmony_ci    FrameworkEnvironment env{};
2145db71995Sopenharmony_ci    env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2_EXPORT_ICD_GPDPA)).add_physical_device("physical_device_0");
2155db71995Sopenharmony_ci
2165db71995Sopenharmony_ci    InstWrapper inst{env.vulkan_functions};
2175db71995Sopenharmony_ci    FillDebugUtilsCreateDetails(inst.create_info, env.debug_log);
2185db71995Sopenharmony_ci    inst.CheckCreate();
2195db71995Sopenharmony_ci
2205db71995Sopenharmony_ci    auto check_paths = [](DebugUtilsLogger const& debug_log, ManifestCategory category) {
2215db71995Sopenharmony_ci        EXPECT_TRUE(debug_log.find((fs::path("/tmp/goober/vulkan") / category_path_name(category)).str()));
2225db71995Sopenharmony_ci        EXPECT_TRUE(debug_log.find((fs::path("/tmp/goober2/vulkan") / category_path_name(category)).str()));
2235db71995Sopenharmony_ci        EXPECT_TRUE(debug_log.find((fs::path("/tmp/goober3/vulkan") / category_path_name(category)).str()));
2245db71995Sopenharmony_ci        EXPECT_TRUE(debug_log.find((fs::path("/tmp/goober4/with spaces/vulkan") / category_path_name(category)).str()));
2255db71995Sopenharmony_ci    };
2265db71995Sopenharmony_ci    check_paths(env.debug_log, ManifestCategory::icd);
2275db71995Sopenharmony_ci    check_paths(env.debug_log, ManifestCategory::implicit_layer);
2285db71995Sopenharmony_ci    check_paths(env.debug_log, ManifestCategory::explicit_layer);
2295db71995Sopenharmony_ci}
2305db71995Sopenharmony_ci// Check that a json file in the paths don't cause the loader to crash
2315db71995Sopenharmony_ciTEST(EnvVarICDOverrideSetup, XDGContainsJsonFile) {
2325db71995Sopenharmony_ci    // Set up a layer path that includes default and user-specified locations,
2335db71995Sopenharmony_ci    // so that the test app can find them.  Include some badly specified elements as well.
2345db71995Sopenharmony_ci    // Need to redirect the 'home' directory
2355db71995Sopenharmony_ci    EnvVarWrapper xdg_config_dirs_env_var{"XDG_CONFIG_DIRS", "bad_file.json"};
2365db71995Sopenharmony_ci
2375db71995Sopenharmony_ci    FrameworkEnvironment env{};
2385db71995Sopenharmony_ci    env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2_EXPORT_ICD_GPDPA)).add_physical_device("physical_device_0");
2395db71995Sopenharmony_ci
2405db71995Sopenharmony_ci    InstWrapper inst{env.vulkan_functions};
2415db71995Sopenharmony_ci    FillDebugUtilsCreateDetails(inst.create_info, env.debug_log);
2425db71995Sopenharmony_ci    inst.CheckCreate(VK_SUCCESS);
2435db71995Sopenharmony_ci}
2445db71995Sopenharmony_ci#endif
2455db71995Sopenharmony_ci
2465db71995Sopenharmony_ci// Test VK_ADD_DRIVER_FILES environment variable
2475db71995Sopenharmony_ciTEST(EnvVarICDOverrideSetup, TestOnlyAddDriverEnvVar) {
2485db71995Sopenharmony_ci    FrameworkEnvironment env{};
2495db71995Sopenharmony_ci    env.add_icd(TestICDDetails(TEST_ICD_PATH_EXPORT_NONE).set_discovery_type(ManifestDiscoveryType::add_env_var));
2505db71995Sopenharmony_ci    env.get_test_icd(0).physical_devices.emplace_back("pd0");
2515db71995Sopenharmony_ci
2525db71995Sopenharmony_ci    InstWrapper inst1{env.vulkan_functions};
2535db71995Sopenharmony_ci    FillDebugUtilsCreateDetails(inst1.create_info, env.debug_log);
2545db71995Sopenharmony_ci    inst1.CheckCreate();
2555db71995Sopenharmony_ci
2565db71995Sopenharmony_ci    std::array<VkPhysicalDevice, 1> phys_devs_array;
2575db71995Sopenharmony_ci    uint32_t phys_dev_count = 1;
2585db71995Sopenharmony_ci    ASSERT_EQ(inst1->vkEnumeratePhysicalDevices(inst1.inst, &phys_dev_count, phys_devs_array.data()), VK_SUCCESS);
2595db71995Sopenharmony_ci    ASSERT_EQ(phys_dev_count, 1U);
2605db71995Sopenharmony_ci
2615db71995Sopenharmony_ci    env.platform_shim->set_elevated_privilege(true);
2625db71995Sopenharmony_ci
2635db71995Sopenharmony_ci    InstWrapper inst2{env.vulkan_functions};
2645db71995Sopenharmony_ci    FillDebugUtilsCreateDetails(inst2.create_info, env.debug_log);
2655db71995Sopenharmony_ci    inst2.CheckCreate(VK_ERROR_INCOMPATIBLE_DRIVER);
2665db71995Sopenharmony_ci
2675db71995Sopenharmony_ci    EXPECT_TRUE(env.debug_log.find("vkCreateInstance: Found no drivers!"));
2685db71995Sopenharmony_ci
2695db71995Sopenharmony_ci    env.platform_shim->set_elevated_privilege(false);
2705db71995Sopenharmony_ci}
2715db71995Sopenharmony_ci
2725db71995Sopenharmony_ci// Test Both VK_DRIVER_FILES and VK_ADD_DRIVER_FILES environment variable
2735db71995Sopenharmony_ciTEST(EnvVarICDOverrideSetup, TestBothDriverEnvVars) {
2745db71995Sopenharmony_ci    FrameworkEnvironment env{};
2755db71995Sopenharmony_ci
2765db71995Sopenharmony_ci    // Add a driver that isn't enabled with the environment variable
2775db71995Sopenharmony_ci    env.add_icd(TestICDDetails(TEST_ICD_PATH_EXPORT_NONE).set_discovery_type(ManifestDiscoveryType::env_var));
2785db71995Sopenharmony_ci    env.get_test_icd(0).add_physical_device("pd0").add_physical_device("pd1");
2795db71995Sopenharmony_ci
2805db71995Sopenharmony_ci    env.add_icd(TestICDDetails(TEST_ICD_PATH_EXPORT_NONE).set_discovery_type(ManifestDiscoveryType::add_env_var));
2815db71995Sopenharmony_ci    env.get_test_icd(0).add_physical_device("pd2");
2825db71995Sopenharmony_ci
2835db71995Sopenharmony_ci    InstWrapper inst{env.vulkan_functions};
2845db71995Sopenharmony_ci    inst.CheckCreate();
2855db71995Sopenharmony_ci
2865db71995Sopenharmony_ci    // The enumerate should now detect both drivers because we used the add
2875db71995Sopenharmony_ci    std::array<VkPhysicalDevice, 3> phys_devs_array;
2885db71995Sopenharmony_ci    uint32_t phys_dev_count = 3;
2895db71995Sopenharmony_ci    ASSERT_EQ(inst->vkEnumeratePhysicalDevices(inst.inst, &phys_dev_count, phys_devs_array.data()), VK_SUCCESS);
2905db71995Sopenharmony_ci    ASSERT_EQ(phys_dev_count, 3U);
2915db71995Sopenharmony_ci}
2925db71995Sopenharmony_ci
2935db71995Sopenharmony_ci#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__GNU__)
2945db71995Sopenharmony_ci// Test VK_LAYER_PATH environment variable
2955db71995Sopenharmony_ciTEST(EnvVarICDOverrideSetup, TestOnlyLayerEnvVar) {
2965db71995Sopenharmony_ci    FrameworkEnvironment env{};
2975db71995Sopenharmony_ci    env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2_EXPORT_ICD_GPDPA)).add_physical_device("physical_device_0");
2985db71995Sopenharmony_ci    env.platform_shim->redirect_path("/tmp/carol", env.get_folder(ManifestLocation::explicit_layer_env_var).location());
2995db71995Sopenharmony_ci
3005db71995Sopenharmony_ci    const char* layer_name = "TestLayer";
3015db71995Sopenharmony_ci    env.add_explicit_layer(
3025db71995Sopenharmony_ci        TestLayerDetails(ManifestLayer{}.add_layer(
3035db71995Sopenharmony_ci                             ManifestLayer::LayerDescription{}.set_name(layer_name).set_lib_path(TEST_LAYER_PATH_EXPORT_VERSION_2)),
3045db71995Sopenharmony_ci                         "test_layer.json")
3055db71995Sopenharmony_ci            .set_discovery_type(ManifestDiscoveryType::env_var));
3065db71995Sopenharmony_ci
3075db71995Sopenharmony_ci    // Now set up a layer path that includes default and user-specified locations,
3085db71995Sopenharmony_ci    // so that the test app can find them.  Include some badly specified elements as well.
3095db71995Sopenharmony_ci    // Need to redirect the 'home' directory
3105db71995Sopenharmony_ci    fs::path HOME = "/home/fake_home";
3115db71995Sopenharmony_ci    EnvVarWrapper home_env_var{"HOME", HOME.str()};
3125db71995Sopenharmony_ci    std::string vk_layer_path = ":/tmp/carol::::/:";
3135db71995Sopenharmony_ci    vk_layer_path += (HOME / "/ with spaces/:::::/tandy:").str();
3145db71995Sopenharmony_ci    EnvVarWrapper layer_path_env_var{"VK_LAYER_PATH", vk_layer_path};
3155db71995Sopenharmony_ci    InstWrapper inst1{env.vulkan_functions};
3165db71995Sopenharmony_ci    inst1.create_info.add_layer(layer_name);
3175db71995Sopenharmony_ci    FillDebugUtilsCreateDetails(inst1.create_info, env.debug_log);
3185db71995Sopenharmony_ci    inst1.CheckCreate();
3195db71995Sopenharmony_ci
3205db71995Sopenharmony_ci    // look for VK_LAYER_PATHS
3215db71995Sopenharmony_ci    EXPECT_TRUE(env.debug_log.find("/tmp/carol"));
3225db71995Sopenharmony_ci    EXPECT_TRUE(env.debug_log.find("/tandy"));
3235db71995Sopenharmony_ci    EXPECT_TRUE(env.debug_log.find((HOME / "/ with spaces/").str()));
3245db71995Sopenharmony_ci
3255db71995Sopenharmony_ci    env.debug_log.clear();
3265db71995Sopenharmony_ci
3275db71995Sopenharmony_ci    env.platform_shim->set_elevated_privilege(true);
3285db71995Sopenharmony_ci
3295db71995Sopenharmony_ci    InstWrapper inst2{env.vulkan_functions};
3305db71995Sopenharmony_ci    inst2.create_info.add_layer(layer_name);
3315db71995Sopenharmony_ci    FillDebugUtilsCreateDetails(inst2.create_info, env.debug_log);
3325db71995Sopenharmony_ci    inst2.CheckCreate(VK_ERROR_LAYER_NOT_PRESENT);
3335db71995Sopenharmony_ci
3345db71995Sopenharmony_ci    EXPECT_FALSE(env.debug_log.find("/tmp/carol"));
3355db71995Sopenharmony_ci
3365db71995Sopenharmony_ci    env.platform_shim->set_elevated_privilege(false);
3375db71995Sopenharmony_ci}
3385db71995Sopenharmony_ci
3395db71995Sopenharmony_ci// Test VK_ADD_LAYER_PATH environment variable
3405db71995Sopenharmony_ciTEST(EnvVarICDOverrideSetup, TestOnlyAddLayerEnvVar) {
3415db71995Sopenharmony_ci    FrameworkEnvironment env{};
3425db71995Sopenharmony_ci    env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2_EXPORT_ICD_GPDPA)).add_physical_device("physical_device_0");
3435db71995Sopenharmony_ci    env.platform_shim->redirect_path("/tmp/carol", env.get_folder(ManifestLocation::explicit_layer_add_env_var).location());
3445db71995Sopenharmony_ci
3455db71995Sopenharmony_ci    const char* layer_name = "TestLayer";
3465db71995Sopenharmony_ci    env.add_explicit_layer(
3475db71995Sopenharmony_ci        TestLayerDetails(ManifestLayer{}.add_layer(
3485db71995Sopenharmony_ci                             ManifestLayer::LayerDescription{}.set_name(layer_name).set_lib_path(TEST_LAYER_PATH_EXPORT_VERSION_2)),
3495db71995Sopenharmony_ci                         "test_layer.json")
3505db71995Sopenharmony_ci            .set_discovery_type(ManifestDiscoveryType::add_env_var));
3515db71995Sopenharmony_ci
3525db71995Sopenharmony_ci    // Set up a layer path that includes default and user-specified locations,
3535db71995Sopenharmony_ci    // so that the test app can find them.  Include some badly specified elements as well.
3545db71995Sopenharmony_ci    // Need to redirect the 'home' directory
3555db71995Sopenharmony_ci    fs::path HOME = "/home/fake_home";
3565db71995Sopenharmony_ci    EnvVarWrapper home_env_var{"HOME", HOME.str()};
3575db71995Sopenharmony_ci    std::string vk_layer_path = ":/tmp/carol::::/:";
3585db71995Sopenharmony_ci    vk_layer_path += (HOME / "/ with spaces/:::::/tandy:").str();
3595db71995Sopenharmony_ci    EnvVarWrapper add_layer_path_env_var{"VK_ADD_LAYER_PATH", vk_layer_path};
3605db71995Sopenharmony_ci
3615db71995Sopenharmony_ci    InstWrapper inst1{env.vulkan_functions};
3625db71995Sopenharmony_ci    inst1.create_info.add_layer(layer_name);
3635db71995Sopenharmony_ci    FillDebugUtilsCreateDetails(inst1.create_info, env.debug_log);
3645db71995Sopenharmony_ci    inst1.CheckCreate();
3655db71995Sopenharmony_ci
3665db71995Sopenharmony_ci    // look for VK_ADD_LAYER_PATHS
3675db71995Sopenharmony_ci    EXPECT_TRUE(env.debug_log.find("/tmp/carol"));
3685db71995Sopenharmony_ci    EXPECT_TRUE(env.debug_log.find("/tandy"));
3695db71995Sopenharmony_ci    EXPECT_TRUE(env.debug_log.find((HOME / "/ with spaces/").str()));
3705db71995Sopenharmony_ci
3715db71995Sopenharmony_ci    env.debug_log.clear();
3725db71995Sopenharmony_ci
3735db71995Sopenharmony_ci    env.platform_shim->set_elevated_privilege(true);
3745db71995Sopenharmony_ci
3755db71995Sopenharmony_ci    InstWrapper inst2{env.vulkan_functions};
3765db71995Sopenharmony_ci    inst2.create_info.add_layer(layer_name);
3775db71995Sopenharmony_ci    FillDebugUtilsCreateDetails(inst2.create_info, env.debug_log);
3785db71995Sopenharmony_ci    inst2.CheckCreate(VK_ERROR_LAYER_NOT_PRESENT);
3795db71995Sopenharmony_ci
3805db71995Sopenharmony_ci    EXPECT_FALSE(env.debug_log.find("/tmp/carol"));
3815db71995Sopenharmony_ci
3825db71995Sopenharmony_ci    env.platform_shim->set_elevated_privilege(false);
3835db71995Sopenharmony_ci}
3845db71995Sopenharmony_ci
3855db71995Sopenharmony_ci#endif
3865db71995Sopenharmony_ci
3875db71995Sopenharmony_ci// Test that the driver filter select will only enable driver manifest files that match the filter
3885db71995Sopenharmony_ciTEST(EnvVarICDOverrideSetup, FilterSelectDriver) {
3895db71995Sopenharmony_ci    FrameworkEnvironment env{};
3905db71995Sopenharmony_ci    EnvVarWrapper filter_select_env_var{"VK_LOADER_DRIVERS_SELECT"};
3915db71995Sopenharmony_ci
3925db71995Sopenharmony_ci    env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_6).set_disable_icd_inc(true).set_json_name("ABC_ICD"));
3935db71995Sopenharmony_ci    env.add_icd(TestICDDetails{TEST_ICD_PATH_VERSION_6, VK_API_VERSION_1_2}.set_disable_icd_inc(true).set_json_name("BCD_ICD"));
3945db71995Sopenharmony_ci    env.add_icd(TestICDDetails{TEST_ICD_PATH_VERSION_6, VK_API_VERSION_1_3}.set_disable_icd_inc(true).set_json_name("CDE_ICD"));
3955db71995Sopenharmony_ci
3965db71995Sopenharmony_ci    InstWrapper inst1{env.vulkan_functions};
3975db71995Sopenharmony_ci    FillDebugUtilsCreateDetails(inst1.create_info, env.debug_log);
3985db71995Sopenharmony_ci    inst1.CheckCreate();
3995db71995Sopenharmony_ci
4005db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "ABC_ICD.json"));
4015db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("ABC_ICD.json", "ignored because not selected by env var"));
4025db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("ABC_ICD.json", "ignored because it was disabled by env var"));
4035db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "BCD_ICD.json"));
4045db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("BCD_ICD.json", "ignored because not selected by env var"));
4055db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("BCD_ICD.json", "ignored because it was disabled by env var"));
4065db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "CDE_ICD.json"));
4075db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("CDE_ICD.json", "ignored because not selected by env var"));
4085db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("CDE_ICD.json", "ignored because it was disabled by env var"));
4095db71995Sopenharmony_ci
4105db71995Sopenharmony_ci    // Match full-name
4115db71995Sopenharmony_ci    env.debug_log.clear();
4125db71995Sopenharmony_ci    filter_select_env_var.set_new_value("ABC_ICD.json");
4135db71995Sopenharmony_ci
4145db71995Sopenharmony_ci    InstWrapper inst2{env.vulkan_functions};
4155db71995Sopenharmony_ci    FillDebugUtilsCreateDetails(inst2.create_info, env.debug_log);
4165db71995Sopenharmony_ci    inst2.CheckCreate();
4175db71995Sopenharmony_ci
4185db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "ABC_ICD.json"));
4195db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("ABC_ICD.json", "ignored because not selected by env var"));
4205db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("ABC_ICD.json", "ignored because it was disabled by env var"));
4215db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "BCD_ICD.json"));
4225db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("BCD_ICD.json", "ignored because not selected by env var"));
4235db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("BCD_ICD.json", "ignored because it was disabled by env var"));
4245db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "CDE_ICD.json"));
4255db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("CDE_ICD.json", "ignored because not selected by env var"));
4265db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("CDE_ICD.json", "ignored because it was disabled by env var"));
4275db71995Sopenharmony_ci
4285db71995Sopenharmony_ci    // Match prefix
4295db71995Sopenharmony_ci    env.debug_log.clear();
4305db71995Sopenharmony_ci    filter_select_env_var.set_new_value("ABC*");
4315db71995Sopenharmony_ci
4325db71995Sopenharmony_ci    InstWrapper inst3{env.vulkan_functions};
4335db71995Sopenharmony_ci    FillDebugUtilsCreateDetails(inst3.create_info, env.debug_log);
4345db71995Sopenharmony_ci    inst3.CheckCreate();
4355db71995Sopenharmony_ci
4365db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "ABC_ICD.json"));
4375db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("ABC_ICD.json", "ignored because not selected by env var"));
4385db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("ABC_ICD.json", "ignored because it was disabled by env var"));
4395db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "BCD_ICD.json"));
4405db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("BCD_ICD.json", "ignored because not selected by env var"));
4415db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("BCD_ICD.json", "ignored because it was disabled by env var"));
4425db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "CDE_ICD.json"));
4435db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("CDE_ICD.json", "ignored because not selected by env var"));
4445db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("CDE_ICD.json", "ignored because it was disabled by env var"));
4455db71995Sopenharmony_ci
4465db71995Sopenharmony_ci    // Match suffix
4475db71995Sopenharmony_ci    env.debug_log.clear();
4485db71995Sopenharmony_ci    filter_select_env_var.set_new_value("*C_ICD.json");
4495db71995Sopenharmony_ci
4505db71995Sopenharmony_ci    InstWrapper inst4{env.vulkan_functions};
4515db71995Sopenharmony_ci    FillDebugUtilsCreateDetails(inst4.create_info, env.debug_log);
4525db71995Sopenharmony_ci    inst4.CheckCreate();
4535db71995Sopenharmony_ci
4545db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "ABC_ICD.json"));
4555db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("ABC_ICD.json", "ignored because not selected by env var"));
4565db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("ABC_ICD.json", "ignored because it was disabled by env var"));
4575db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "BCD_ICD.json"));
4585db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("BCD_ICD.json", "ignored because not selected by env var"));
4595db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("BCD_ICD.json", "ignored because it was disabled by env var"));
4605db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "CDE_ICD.json"));
4615db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("CDE_ICD.json", "ignored because not selected by env var"));
4625db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("CDE_ICD.json", "ignored because it was disabled by env var"));
4635db71995Sopenharmony_ci
4645db71995Sopenharmony_ci    // Match sub-string
4655db71995Sopenharmony_ci    env.debug_log.clear();
4665db71995Sopenharmony_ci    filter_select_env_var.set_new_value("*BC*");
4675db71995Sopenharmony_ci
4685db71995Sopenharmony_ci    InstWrapper inst5{env.vulkan_functions};
4695db71995Sopenharmony_ci    FillDebugUtilsCreateDetails(inst5.create_info, env.debug_log);
4705db71995Sopenharmony_ci    inst5.CheckCreate();
4715db71995Sopenharmony_ci
4725db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "ABC_ICD.json"));
4735db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("ABC_ICD.json", "ignored because not selected by env var"));
4745db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("ABC_ICD.json", "ignored because it was disabled by env var"));
4755db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "BCD_ICD.json"));
4765db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("BCD_ICD.json", "ignored because not selected by env var"));
4775db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("BCD_ICD.json", "ignored because it was disabled by env var"));
4785db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "CDE_ICD.json"));
4795db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("CDE_ICD.json", "ignored because not selected by env var"));
4805db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("CDE_ICD.json", "ignored because it was disabled by env var"));
4815db71995Sopenharmony_ci
4825db71995Sopenharmony_ci    // Match all with star '*'
4835db71995Sopenharmony_ci    env.debug_log.clear();
4845db71995Sopenharmony_ci    filter_select_env_var.set_new_value("*");
4855db71995Sopenharmony_ci
4865db71995Sopenharmony_ci    InstWrapper inst6{env.vulkan_functions};
4875db71995Sopenharmony_ci    FillDebugUtilsCreateDetails(inst6.create_info, env.debug_log);
4885db71995Sopenharmony_ci    inst6.CheckCreate();
4895db71995Sopenharmony_ci
4905db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "ABC_ICD.json"));
4915db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("ABC_ICD.json", "ignored because not selected by env var"));
4925db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("ABC_ICD.json", "ignored because it was disabled by env var"));
4935db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "BCD_ICD.json"));
4945db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("BCD_ICD.json", "ignored because not selected by env var"));
4955db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("BCD_ICD.json", "ignored because it was disabled by env var"));
4965db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "CDE_ICD.json"));
4975db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("CDE_ICD.json", "ignored because not selected by env var"));
4985db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("CDE_ICD.json", "ignored because it was disabled by env var"));
4995db71995Sopenharmony_ci
5005db71995Sopenharmony_ci    // Match all with special name
5015db71995Sopenharmony_ci    env.debug_log.clear();
5025db71995Sopenharmony_ci    filter_select_env_var.set_new_value("~all~");
5035db71995Sopenharmony_ci
5045db71995Sopenharmony_ci    InstWrapper inst7{env.vulkan_functions};
5055db71995Sopenharmony_ci    FillDebugUtilsCreateDetails(inst7.create_info, env.debug_log);
5065db71995Sopenharmony_ci    inst7.CheckCreate();
5075db71995Sopenharmony_ci
5085db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "ABC_ICD.json"));
5095db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("ABC_ICD.json", "ignored because not selected by env var"));
5105db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("ABC_ICD.json", "ignored because it was disabled by env var"));
5115db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "BCD_ICD.json"));
5125db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("BCD_ICD.json", "ignored because not selected by env var"));
5135db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("BCD_ICD.json", "ignored because it was disabled by env var"));
5145db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "CDE_ICD.json"));
5155db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("CDE_ICD.json", "ignored because not selected by env var"));
5165db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("CDE_ICD.json", "ignored because it was disabled by env var"));
5175db71995Sopenharmony_ci
5185db71995Sopenharmony_ci    // The full-name string is not a valid match if it doesn't also include the file extension
5195db71995Sopenharmony_ci    env.debug_log.clear();
5205db71995Sopenharmony_ci    filter_select_env_var.set_new_value("ABC_ICD");
5215db71995Sopenharmony_ci
5225db71995Sopenharmony_ci    InstWrapper inst8{env.vulkan_functions};
5235db71995Sopenharmony_ci    FillDebugUtilsCreateDetails(inst8.create_info, env.debug_log);
5245db71995Sopenharmony_ci    inst8.CheckCreate(VK_ERROR_INCOMPATIBLE_DRIVER);
5255db71995Sopenharmony_ci
5265db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "ABC_ICD.json"));
5275db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("ABC_ICD.json", "ignored because not selected by env var"));
5285db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("ABC_ICD.json", "ignored because it was disabled by env var"));
5295db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "BCD_ICD.json"));
5305db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("BCD_ICD.json", "ignored because not selected by env var"));
5315db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("BCD_ICD.json", "ignored because it was disabled by env var"));
5325db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "CDE_ICD.json"));
5335db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("CDE_ICD.json", "ignored because not selected by env var"));
5345db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("CDE_ICD.json", "ignored because it was disabled by env var"));
5355db71995Sopenharmony_ci}
5365db71995Sopenharmony_ci
5375db71995Sopenharmony_ci// Test that the driver filter disable disables driver manifest files that match the filter
5385db71995Sopenharmony_ciTEST(EnvVarICDOverrideSetup, FilterDisableDriver) {
5395db71995Sopenharmony_ci    FrameworkEnvironment env{};
5405db71995Sopenharmony_ci    EnvVarWrapper filter_disable_env_var{"VK_LOADER_DRIVERS_DISABLE"};
5415db71995Sopenharmony_ci
5425db71995Sopenharmony_ci    env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_6).set_disable_icd_inc(true).set_json_name("ABC_ICD"));
5435db71995Sopenharmony_ci    env.add_icd(TestICDDetails{TEST_ICD_PATH_VERSION_6, VK_API_VERSION_1_2}.set_disable_icd_inc(true).set_json_name("BCD_ICD"));
5445db71995Sopenharmony_ci    env.add_icd(TestICDDetails{TEST_ICD_PATH_VERSION_6, VK_API_VERSION_1_3}.set_disable_icd_inc(true).set_json_name("CDE_ICD"));
5455db71995Sopenharmony_ci
5465db71995Sopenharmony_ci    InstWrapper inst1{env.vulkan_functions};
5475db71995Sopenharmony_ci    FillDebugUtilsCreateDetails(inst1.create_info, env.debug_log);
5485db71995Sopenharmony_ci    inst1.CheckCreate();
5495db71995Sopenharmony_ci
5505db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "ABC_ICD.json"));
5515db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("ABC_ICD.json", "ignored because not selected by env var"));
5525db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("ABC_ICD.json", "ignored because it was disabled by env var"));
5535db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "BCD_ICD.json"));
5545db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("BCD_ICD.json", "ignored because not selected by env var"));
5555db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("BCD_ICD.json", "ignored because it was disabled by env var"));
5565db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "CDE_ICD.json"));
5575db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("CDE_ICD.json", "ignored because not selected by env var"));
5585db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("CDE_ICD.json", "ignored because it was disabled by env var"));
5595db71995Sopenharmony_ci
5605db71995Sopenharmony_ci    // Match full-name
5615db71995Sopenharmony_ci    env.debug_log.clear();
5625db71995Sopenharmony_ci    filter_disable_env_var.set_new_value("ABC_ICD.json");
5635db71995Sopenharmony_ci
5645db71995Sopenharmony_ci    InstWrapper inst2{env.vulkan_functions};
5655db71995Sopenharmony_ci    FillDebugUtilsCreateDetails(inst2.create_info, env.debug_log);
5665db71995Sopenharmony_ci    inst2.CheckCreate();
5675db71995Sopenharmony_ci
5685db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "ABC_ICD.json"));
5695db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("ABC_ICD.json", "ignored because not selected by env var"));
5705db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("ABC_ICD.json", "ignored because it was disabled by env var"));
5715db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "BCD_ICD.json"));
5725db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("BCD_ICD.json", "ignored because not selected by env var"));
5735db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("BCD_ICD.json", "ignored because it was disabled by env var"));
5745db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "CDE_ICD.json"));
5755db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("CDE_ICD.json", "ignored because not selected by env var"));
5765db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("CDE_ICD.json", "ignored because it was disabled by env var"));
5775db71995Sopenharmony_ci
5785db71995Sopenharmony_ci    // Match prefix
5795db71995Sopenharmony_ci    env.debug_log.clear();
5805db71995Sopenharmony_ci    filter_disable_env_var.set_new_value("ABC_*");
5815db71995Sopenharmony_ci
5825db71995Sopenharmony_ci    InstWrapper inst3{env.vulkan_functions};
5835db71995Sopenharmony_ci    FillDebugUtilsCreateDetails(inst3.create_info, env.debug_log);
5845db71995Sopenharmony_ci    inst3.CheckCreate();
5855db71995Sopenharmony_ci
5865db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "ABC_ICD.json"));
5875db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("ABC_ICD.json", "ignored because not selected by env var"));
5885db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("ABC_ICD.json", "ignored because it was disabled by env var"));
5895db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "BCD_ICD.json"));
5905db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("BCD_ICD.json", "ignored because not selected by env var"));
5915db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("BCD_ICD.json", "ignored because it was disabled by env var"));
5925db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "CDE_ICD.json"));
5935db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("CDE_ICD.json", "ignored because not selected by env var"));
5945db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("CDE_ICD.json", "ignored because it was disabled by env var"));
5955db71995Sopenharmony_ci
5965db71995Sopenharmony_ci    // Match suffix
5975db71995Sopenharmony_ci    env.debug_log.clear();
5985db71995Sopenharmony_ci    filter_disable_env_var.set_new_value("*C_ICD.json");
5995db71995Sopenharmony_ci
6005db71995Sopenharmony_ci    InstWrapper inst4{env.vulkan_functions};
6015db71995Sopenharmony_ci    FillDebugUtilsCreateDetails(inst4.create_info, env.debug_log);
6025db71995Sopenharmony_ci    inst4.CheckCreate();
6035db71995Sopenharmony_ci
6045db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "ABC_ICD.json"));
6055db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("ABC_ICD.json", "ignored because not selected by env var"));
6065db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("ABC_ICD.json", "ignored because it was disabled by env var"));
6075db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "BCD_ICD.json"));
6085db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("BCD_ICD.json", "ignored because not selected by env var"));
6095db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("BCD_ICD.json", "ignored because it was disabled by env var"));
6105db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "CDE_ICD.json"));
6115db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("CDE_ICD.json", "ignored because not selected by env var"));
6125db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("CDE_ICD.json", "ignored because it was disabled by env var"));
6135db71995Sopenharmony_ci
6145db71995Sopenharmony_ci    // Match substring
6155db71995Sopenharmony_ci    env.debug_log.clear();
6165db71995Sopenharmony_ci    filter_disable_env_var.set_new_value("*BC*");
6175db71995Sopenharmony_ci
6185db71995Sopenharmony_ci    InstWrapper inst5{env.vulkan_functions};
6195db71995Sopenharmony_ci    FillDebugUtilsCreateDetails(inst5.create_info, env.debug_log);
6205db71995Sopenharmony_ci    inst5.CheckCreate();
6215db71995Sopenharmony_ci
6225db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "ABC_ICD.json"));
6235db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("ABC_ICD.json", "ignored because not selected by env var"));
6245db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("ABC_ICD.json", "ignored because it was disabled by env var"));
6255db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "BCD_ICD.json"));
6265db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("BCD_ICD.json", "ignored because not selected by env var"));
6275db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("BCD_ICD.json", "ignored because it was disabled by env var"));
6285db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "CDE_ICD.json"));
6295db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("CDE_ICD.json", "ignored because not selected by env var"));
6305db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("CDE_ICD.json", "ignored because it was disabled by env var"));
6315db71995Sopenharmony_ci
6325db71995Sopenharmony_ci    // Match all with star '*'
6335db71995Sopenharmony_ci    env.debug_log.clear();
6345db71995Sopenharmony_ci    filter_disable_env_var.set_new_value("*");
6355db71995Sopenharmony_ci
6365db71995Sopenharmony_ci    InstWrapper inst6{env.vulkan_functions};
6375db71995Sopenharmony_ci    FillDebugUtilsCreateDetails(inst6.create_info, env.debug_log);
6385db71995Sopenharmony_ci    inst6.CheckCreate(VK_ERROR_INCOMPATIBLE_DRIVER);
6395db71995Sopenharmony_ci
6405db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "ABC_ICD.json"));
6415db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("ABC_ICD.json", "ignored because not selected by env var"));
6425db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("ABC_ICD.json", "ignored because it was disabled by env var"));
6435db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "BCD_ICD.json"));
6445db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("BCD_ICD.json", "ignored because not selected by env var"));
6455db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("BCD_ICD.json", "ignored because it was disabled by env var"));
6465db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "CDE_ICD.json"));
6475db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("CDE_ICD.json", "ignored because not selected by env var"));
6485db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("CDE_ICD.json", "ignored because it was disabled by env var"));
6495db71995Sopenharmony_ci
6505db71995Sopenharmony_ci    // Match all with special name
6515db71995Sopenharmony_ci    env.debug_log.clear();
6525db71995Sopenharmony_ci    filter_disable_env_var.set_new_value("~all~");
6535db71995Sopenharmony_ci
6545db71995Sopenharmony_ci    InstWrapper inst7{env.vulkan_functions};
6555db71995Sopenharmony_ci    FillDebugUtilsCreateDetails(inst7.create_info, env.debug_log);
6565db71995Sopenharmony_ci    inst7.CheckCreate(VK_ERROR_INCOMPATIBLE_DRIVER);
6575db71995Sopenharmony_ci
6585db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "ABC_ICD.json"));
6595db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("ABC_ICD.json", "ignored because not selected by env var"));
6605db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("ABC_ICD.json", "ignored because it was disabled by env var"));
6615db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "BCD_ICD.json"));
6625db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("BCD_ICD.json", "ignored because not selected by env var"));
6635db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("BCD_ICD.json", "ignored because it was disabled by env var"));
6645db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "CDE_ICD.json"));
6655db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("CDE_ICD.json", "ignored because not selected by env var"));
6665db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("CDE_ICD.json", "ignored because it was disabled by env var"));
6675db71995Sopenharmony_ci}
6685db71995Sopenharmony_ci
6695db71995Sopenharmony_ci// Test that the when both driver filter select and disable environment variables are present, that the
6705db71995Sopenharmony_ci// appropriate drivers are enabled and disabled
6715db71995Sopenharmony_ciTEST(EnvVarICDOverrideSetup, FilterSelectAndDisableDriver) {
6725db71995Sopenharmony_ci    FrameworkEnvironment env{};
6735db71995Sopenharmony_ci    EnvVarWrapper filter_disable_env_var{"VK_LOADER_DRIVERS_DISABLE"};
6745db71995Sopenharmony_ci    EnvVarWrapper filter_select_env_var{"VK_LOADER_DRIVERS_SELECT"};
6755db71995Sopenharmony_ci
6765db71995Sopenharmony_ci    env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_6).set_disable_icd_inc(true).set_json_name("ABC_ICD"));
6775db71995Sopenharmony_ci    env.add_icd(TestICDDetails{TEST_ICD_PATH_VERSION_6, VK_API_VERSION_1_2}.set_disable_icd_inc(true).set_json_name("BCD_ICD"));
6785db71995Sopenharmony_ci    env.add_icd(TestICDDetails{TEST_ICD_PATH_VERSION_6, VK_API_VERSION_1_3}.set_disable_icd_inc(true).set_json_name("CDE_ICD"));
6795db71995Sopenharmony_ci
6805db71995Sopenharmony_ci    InstWrapper inst1{env.vulkan_functions};
6815db71995Sopenharmony_ci    FillDebugUtilsCreateDetails(inst1.create_info, env.debug_log);
6825db71995Sopenharmony_ci    inst1.CheckCreate();
6835db71995Sopenharmony_ci
6845db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "ABC_ICD.json"));
6855db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("ABC_ICD.json", "ignored because not selected by env var"));
6865db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("ABC_ICD.json", "ignored because it was disabled by env var"));
6875db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "BCD_ICD.json"));
6885db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("BCD_ICD.json", "ignored because not selected by env var"));
6895db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("BCD_ICD.json", "ignored because it was disabled by env var"));
6905db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "CDE_ICD.json"));
6915db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("CDE_ICD.json", "ignored because not selected by env var"));
6925db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("CDE_ICD.json", "ignored because it was disabled by env var"));
6935db71995Sopenharmony_ci
6945db71995Sopenharmony_ci    // Disable two, but enable one
6955db71995Sopenharmony_ci    env.debug_log.clear();
6965db71995Sopenharmony_ci    filter_disable_env_var.set_new_value("*BC*");
6975db71995Sopenharmony_ci    filter_select_env_var.set_new_value("BCD*");
6985db71995Sopenharmony_ci
6995db71995Sopenharmony_ci    InstWrapper inst2{env.vulkan_functions};
7005db71995Sopenharmony_ci    FillDebugUtilsCreateDetails(inst2.create_info, env.debug_log);
7015db71995Sopenharmony_ci    inst2.CheckCreate();
7025db71995Sopenharmony_ci
7035db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "ABC_ICD.json"));
7045db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("ABC_ICD.json", "ignored because not selected by env var"));
7055db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("ABC_ICD.json", "ignored because it was disabled by env var"));
7065db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "BCD_ICD.json"));
7075db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("BCD_ICD.json", "ignored because not selected by env var"));
7085db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("BCD_ICD.json", "ignored because it was disabled by env var"));
7095db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "CDE_ICD.json"));
7105db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("CDE_ICD.json", "ignored because not selected by env var"));
7115db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("CDE_ICD.json", "ignored because it was disabled by env var"));
7125db71995Sopenharmony_ci
7135db71995Sopenharmony_ci    // Disable all, but enable two
7145db71995Sopenharmony_ci    env.debug_log.clear();
7155db71995Sopenharmony_ci    filter_disable_env_var.set_new_value("*");
7165db71995Sopenharmony_ci    filter_select_env_var.set_new_value("*BC*");
7175db71995Sopenharmony_ci
7185db71995Sopenharmony_ci    InstWrapper inst3{env.vulkan_functions};
7195db71995Sopenharmony_ci    FillDebugUtilsCreateDetails(inst3.create_info, env.debug_log);
7205db71995Sopenharmony_ci    inst3.CheckCreate();
7215db71995Sopenharmony_ci
7225db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "ABC_ICD.json"));
7235db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("ABC_ICD.json", "ignored because not selected by env var"));
7245db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("ABC_ICD.json", "ignored because it was disabled by env var"));
7255db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "BCD_ICD.json"));
7265db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("BCD_ICD.json", "ignored because not selected by env var"));
7275db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("BCD_ICD.json", "ignored because it was disabled by env var"));
7285db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "CDE_ICD.json"));
7295db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("CDE_ICD.json", "ignored because not selected by env var"));
7305db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("CDE_ICD.json", "ignored because it was disabled by env var"));
7315db71995Sopenharmony_ci
7325db71995Sopenharmony_ci    // Disable all, but enable all
7335db71995Sopenharmony_ci    env.debug_log.clear();
7345db71995Sopenharmony_ci    filter_disable_env_var.set_new_value("*");
7355db71995Sopenharmony_ci    filter_select_env_var.set_new_value("*");
7365db71995Sopenharmony_ci
7375db71995Sopenharmony_ci    InstWrapper inst4{env.vulkan_functions};
7385db71995Sopenharmony_ci    FillDebugUtilsCreateDetails(inst4.create_info, env.debug_log);
7395db71995Sopenharmony_ci    inst4.CheckCreate();
7405db71995Sopenharmony_ci
7415db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "ABC_ICD.json"));
7425db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("ABC_ICD.json", "ignored because not selected by env var"));
7435db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("ABC_ICD.json", "ignored because it was disabled by env var"));
7445db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "BCD_ICD.json"));
7455db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("BCD_ICD.json", "ignored because not selected by env var"));
7465db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("BCD_ICD.json", "ignored because it was disabled by env var"));
7475db71995Sopenharmony_ci    ASSERT_TRUE(env.debug_log.find_prefix_then_postfix("Found ICD manifest file", "CDE_ICD.json"));
7485db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("CDE_ICD.json", "ignored because not selected by env var"));
7495db71995Sopenharmony_ci    ASSERT_FALSE(env.debug_log.find_prefix_then_postfix("CDE_ICD.json", "ignored because it was disabled by env var"));
7505db71995Sopenharmony_ci}
751