Skip to content

Commit

Permalink
Small cleanup of regression tests
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-lunarg committed Sep 11, 2024
1 parent 331ccf3 commit 447ebda
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 80 deletions.
2 changes: 1 addition & 1 deletion tests/loader_envvar_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ TEST(EnvVarICDOverrideSetup, XDGContainsJsonFile) {

InstWrapper inst{env.vulkan_functions};
FillDebugUtilsCreateDetails(inst.create_info, env.debug_log);
inst.CheckCreate(VK_SUCCESS);
inst.CheckCreate();
}
#endif

Expand Down
153 changes: 79 additions & 74 deletions tests/loader_layer_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void CheckLogForLayerString(FrameworkEnvironment& env, const char* implicit_laye
{
InstWrapper inst{env.vulkan_functions};
FillDebugUtilsCreateDetails(inst.create_info, env.debug_log);
inst.CheckCreate(VK_SUCCESS);
inst.CheckCreate();
if (check_for_enable) {
ASSERT_TRUE(env.debug_log.find(std::string("Insert instance layer \"") + implicit_layer_name));
} else {
Expand Down Expand Up @@ -119,7 +119,7 @@ TEST(ImplicitLayers, OnlyDisableEnvVar) {
InstWrapper inst{env.vulkan_functions};
FillDebugUtilsCreateDetails(inst.create_info, env.debug_log);
inst.create_info.add_layer(implicit_layer_name);
inst.CheckCreate(VK_SUCCESS);
inst.CheckCreate();
ASSERT_TRUE(env.debug_log.find(std::string("Insert instance layer \"") + implicit_layer_name));
}
}
Expand Down Expand Up @@ -962,7 +962,6 @@ TEST(ImplicitLayers, DuplicateLayers) {
FrameworkEnvironment env;
env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2_EXPORT_ICD_GPDPA)).add_physical_device({});

// verify layer loads successfully when setting VK_LAYER_PATH to a full filepath
const char* same_layer_name_1 = "VK_LAYER_RegularLayer1";
env.add_implicit_layer(TestLayerDetails(ManifestLayer{}.add_layer(ManifestLayer::LayerDescription{}
.set_name(same_layer_name_1)
Expand Down Expand Up @@ -1249,13 +1248,13 @@ TEST(MetaLayers, ExplicitMetaLayer) {
}
{ // don't enable the layer, shouldn't find any layers when calling vkEnumerateDeviceLayerProperties
InstWrapper inst{env.vulkan_functions};
inst.CheckCreate(VK_SUCCESS);
inst.CheckCreate();
ASSERT_NO_FATAL_FAILURE(inst.GetActiveLayers(inst.GetPhysDev(), 0));
}
{
InstWrapper inst{env.vulkan_functions};
inst.create_info.add_layer(meta_layer_name);
inst.CheckCreate(VK_SUCCESS);
inst.CheckCreate();
auto layer_props = inst.GetActiveLayers(inst.GetPhysDev(), 2);
EXPECT_TRUE(check_permutation({regular_layer_name, meta_layer_name}, layer_props));
}
Expand Down Expand Up @@ -2283,7 +2282,6 @@ TEST(ExplicitLayers, MultipleLayersInSingleManifest) {
FrameworkEnvironment env;
env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2_EXPORT_ICD_GPDPA)).add_physical_device({});

// verify layer loads successfully when setting VK_LAYER_PATH to a full filepath
const char* regular_layer_name_1 = "VK_LAYER_RegularLayer1";
const char* regular_layer_name_2 = "VK_LAYER_RegularLayer2";
const char* regular_layer_name_3 = "VK_LAYER_RegularLayer3";
Expand Down Expand Up @@ -2367,70 +2365,81 @@ TEST(ExplicitLayers, VkLayerPathEnvVar) {
FrameworkEnvironment env;
env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2_EXPORT_ICD_GPDPA)).add_physical_device({});

{
// verify layer loads successfully when setting VK_LAYER_PATH to a full filepath
const char* regular_layer_name_1 = "VK_LAYER_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));

InstWrapper inst(env.vulkan_functions);
inst.create_info.add_layer(regular_layer_name_1);
inst.CheckCreate(VK_SUCCESS);
auto layer_props = inst.GetActiveLayers(inst.GetPhysDev(), 1);
EXPECT_TRUE(string_eq(layer_props.at(0).layerName, regular_layer_name_1));
}
{
// verify layers load successfully when setting VK_LAYER_PATH to multiple full filepaths
const char* regular_layer_name_1 = "VK_LAYER_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 = "VK_LAYER_RegularLayer2";
env.add_explicit_layer(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);
inst.CheckCreate(VK_SUCCESS);
auto layer_props = inst.GetActiveLayers(inst.GetPhysDev(), 2);
EXPECT_TRUE(check_permutation({regular_layer_name_1, regular_layer_name_2}, layer_props));
}
{
// verify layers load successfully when setting VK_LAYER_PATH to a directory
const char* regular_layer_name_1 = "VK_LAYER_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 = "VK_LAYER_RegularLayer2";
env.add_explicit_layer(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);
inst.CheckCreate(VK_SUCCESS);
auto layer_props = inst.GetActiveLayers(inst.GetPhysDev(), 2);
EXPECT_TRUE(check_permutation({regular_layer_name_1, regular_layer_name_2}, layer_props));
}
// verify layer loads successfully when setting VK_LAYER_PATH to a full filepath
const char* regular_layer_name_1 = "VK_LAYER_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));

InstWrapper inst(env.vulkan_functions);
inst.create_info.add_layer(regular_layer_name_1);
inst.CheckCreate();
auto layer_props = inst.GetActiveLayers(inst.GetPhysDev(), 1);
EXPECT_TRUE(string_eq(layer_props.at(0).layerName, regular_layer_name_1));
}

TEST(ExplicitLayers, VkLayerPathEnvVarContainsMultipleFilepaths) {
FrameworkEnvironment env;
env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2_EXPORT_ICD_GPDPA)).add_physical_device({});

// verify layers load successfully when setting VK_LAYER_PATH to multiple full filepaths
const char* regular_layer_name_1 = "VK_LAYER_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 = "VK_LAYER_RegularLayer2";
env.add_explicit_layer(
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);
inst.CheckCreate();
auto layer_props = inst.GetActiveLayers(inst.GetPhysDev(), 2);
EXPECT_TRUE(check_permutation({regular_layer_name_1, regular_layer_name_2}, layer_props));
}

TEST(ExplicitLayers, VkLayerPathEnvVarIsDirectory) {
FrameworkEnvironment env;
env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2_EXPORT_ICD_GPDPA)).add_physical_device({});

// verify layers load successfully when setting VK_LAYER_PATH to a directory
const char* regular_layer_name_1 = "VK_LAYER_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 = "VK_LAYER_RegularLayer2";
env.add_explicit_layer(
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);
inst.CheckCreate();
auto layer_props = inst.GetActiveLayers(inst.GetPhysDev(), 2);
EXPECT_TRUE(check_permutation({regular_layer_name_1, regular_layer_name_2}, layer_props));
}

TEST(ExplicitLayers, DuplicateLayersInVK_LAYER_PATH) {
Expand Down Expand Up @@ -2512,7 +2521,6 @@ TEST(ExplicitLayers, DuplicateLayersInVK_ADD_LAYER_PATH) {
FrameworkEnvironment env;
env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2_EXPORT_ICD_GPDPA)).add_physical_device({});

// verify layer loads successfully when setting VK_LAYER_PATH to a full filepath
const char* same_layer_name_1 = "VK_LAYER_RegularLayer1";
env.add_explicit_layer(TestLayerDetails(ManifestLayer{}.add_layer(ManifestLayer::LayerDescription{}
.set_name(same_layer_name_1)
Expand Down Expand Up @@ -2587,7 +2595,6 @@ TEST(ExplicitLayers, CorrectOrderOfEnvVarEnabledLayers) {
FrameworkEnvironment env;
env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2_EXPORT_ICD_GPDPA)).add_physical_device({});

// verify layer loads successfully when setting VK_LAYER_PATH to a full filepath
const char* layer_name_1 = "VK_LAYER_RegularLayer1";
env.add_explicit_layer(TestLayerDetails(ManifestLayer{}.add_layer(ManifestLayer::LayerDescription{}
.set_name(layer_name_1)
Expand Down Expand Up @@ -2698,7 +2705,6 @@ TEST(ExplicitLayers, CorrectOrderOfEnvVarEnabledLayersFromSystemLocations) {
FrameworkEnvironment env;
env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2_EXPORT_ICD_GPDPA)).add_physical_device({});

// verify layer loads successfully when setting VK_LAYER_PATH to a full filepath
const char* layer_name_1 = "VK_LAYER_RegularLayer1";
env.add_explicit_layer(TestLayerDetails(ManifestLayer{}.add_layer(ManifestLayer::LayerDescription{}
.set_name(layer_name_1)
Expand Down Expand Up @@ -2758,7 +2764,6 @@ TEST(ExplicitLayers, CorrectOrderOfApplicationEnabledLayers) {
FrameworkEnvironment env;
env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2_EXPORT_ICD_GPDPA)).add_physical_device({});

// verify layer loads successfully when setting VK_LAYER_PATH to a full filepath
const char* layer_name_1 = "VK_LAYER_RegularLayer1";
env.add_explicit_layer(TestLayerDetails(ManifestLayer{}.add_layer(ManifestLayer::LayerDescription{}
.set_name(layer_name_1)
Expand Down
8 changes: 4 additions & 4 deletions tests/loader_regression_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ TEST(EnumerateDeviceExtensionProperties, ZeroPhysicalDeviceExtensions) {

InstWrapper inst{env.vulkan_functions};
inst.create_info.set_api_version(VK_MAKE_API_VERSION(0, 1, 1, 0));
inst.CheckCreate(VK_SUCCESS);
inst.CheckCreate();

auto phys_dev = inst.GetPhysDev();
DeviceWrapper dev{inst};
Expand Down Expand Up @@ -810,7 +810,7 @@ TEST(EnumeratePhysicalDevices, ZeroPhysicalDevices) {
env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2));
InstWrapper inst{env.vulkan_functions};
inst.create_info.set_api_version(VK_MAKE_API_VERSION(0, 1, 1, 0));
inst.CheckCreate(VK_SUCCESS);
inst.CheckCreate();

uint32_t count = 0;
ASSERT_EQ(VK_ERROR_INITIALIZATION_FAILED, env.vulkan_functions.vkEnumeratePhysicalDevices(inst, &count, nullptr));
Expand Down Expand Up @@ -1460,7 +1460,7 @@ TEST(TryLoadWrongBinaries, WrongImplicit) {

// We don't want to return VK_ERROR_LAYER_NOT_PRESENT for missing implicit layers because it's not the
// application asking for them.
inst.CheckCreate(VK_SUCCESS);
inst.CheckCreate();

#if !defined(__APPLE__)
// Should get an info message for the bad implicit layer
Expand Down Expand Up @@ -1593,7 +1593,7 @@ TEST(TryLoadWrongBinaries, BadImplicit) {

// We don't want to return VK_ERROR_LAYER_NOT_PRESENT for missing implicit layers because it's not the
// application asking for them.
inst.CheckCreate(VK_SUCCESS);
inst.CheckCreate();

// Should get an info message for the bad implicit
ASSERT_TRUE(log.find(std::string("Requested layer \"") + std::string(layer_name) + std::string("\" failed to load.")));
Expand Down
2 changes: 1 addition & 1 deletion tests/loader_settings_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1565,7 +1565,7 @@ TEST(SettingsFile, ImplicitLayerDisableEnvironmentVariableOverriden) {
{
InstWrapper inst{env.vulkan_functions};
FillDebugUtilsCreateDetails(inst.create_info, env.debug_log);
inst.CheckCreate(VK_SUCCESS);
inst.CheckCreate();
if (check_for_enable) {
ASSERT_TRUE(env.debug_log.find(std::string("Insert instance layer \"") + implicit_layer_name));
auto layers = inst.GetActiveLayers(inst.GetPhysDev(), 1);
Expand Down

0 comments on commit 447ebda

Please sign in to comment.