From 9479c71a07d2f6dd63ba7ac474eeb448dfc39944 Mon Sep 17 00:00:00 2001 From: Charles Giessen Date: Wed, 20 Nov 2024 16:35:28 -0600 Subject: [PATCH] Add settings file test to compare VK_LOADER_DEBUG with stderr_log These two should be identical with each other. --- tests/loader_settings_tests.cpp | 55 +++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/tests/loader_settings_tests.cpp b/tests/loader_settings_tests.cpp index 2dded90ca..d69da2ecc 100644 --- a/tests/loader_settings_tests.cpp +++ b/tests/loader_settings_tests.cpp @@ -2987,3 +2987,58 @@ TEST(SettingsFile, EnvVarsWorkTogether) { EXPECT_TRUE(string_eq(layers.at(2).layerName, add_env_var_implicit_layer)); } } + +TEST(SettingsFile, VkLoaderDebugAndSettingsFileLogAreIdentical) { + FrameworkEnvironment env{}; + env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2)).add_physical_device({}); + + const char* regular_explicit_layer = "VK_LAYER_regular_explicit_layer"; + env.add_explicit_layer(TestLayerDetails{ + ManifestLayer{}.add_layer( + ManifestLayer::LayerDescription{}.set_name(regular_explicit_layer).set_lib_path(TEST_LAYER_PATH_EXPORT_VERSION_2)), + "regular_explicit_layer.json"}); + const char* regular_implicit_layer = "VK_LAYER_regular_implicit_layer"; + env.add_implicit_layer(TestLayerDetails{ManifestLayer{}.add_layer(ManifestLayer::LayerDescription{} + .set_disable_environment("A") + .set_name(regular_implicit_layer) + .set_lib_path(TEST_LAYER_PATH_EXPORT_VERSION_2)), + "regular_implicit_layer.json"}); + + env.loader_settings.set_file_format_version({1, 0, 0}).add_app_specific_setting( + AppSpecificSettings{} + .add_stderr_log_filter("all") + .add_layer_configuration(LoaderSettingsLayerConfiguration{} + .set_name(regular_implicit_layer) + .set_path(env.get_shimmed_layer_manifest_path(1)) + .set_control("auto") + .set_treat_as_implicit_manifest(true)) + .add_layer_configuration(LoaderSettingsLayerConfiguration{} + .set_name(regular_explicit_layer) + .set_path(env.get_shimmed_layer_manifest_path(0)) + .set_control("auto")) + .add_layer_configuration(LoaderSettingsLayerConfiguration{}.set_control("unordered_layer_location"))); + env.update_loader_settings(env.loader_settings); + std::string settings_file_log; + std::string env_var_log; + env.platform_shim->clear_logs(); + { + InstWrapper inst{env.vulkan_functions}; + inst.CheckCreate(); + settings_file_log = env.platform_shim->fputs_stderr_log; + } + env.platform_shim->clear_logs(); + env.loader_settings.app_specific_settings.at(0).stderr_log.clear(); + env.update_loader_settings(env.loader_settings); + { // Now use the VK_LOADER_DEBUG=all which was set at startup + InstWrapper inst{env.vulkan_functions}; + inst.CheckCreate(); + + env_var_log = env.platform_shim->fputs_stderr_log; + } + // Because of the way the test is written, we need to remove the *one* difference between the two outputs + std::string expected_diff = + "DEBUG: Loader Settings Filters for Logging to Standard Error: ERROR | WARNING | INFO | DEBUG | PERF | DRIVER " + "| LAYER\n"; + settings_file_log.erase(settings_file_log.find(expected_diff), expected_diff.size()); + ASSERT_EQ(settings_file_log, env_var_log); +}