Add tests for longer version strings
authorCharles Giessen <charles@lunarg.com>
Sat, 10 Jun 2023 23:59:22 +0000 (17:59 -0600)
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>
Tue, 13 Jun 2023 03:37:40 +0000 (21:37 -0600)
Include tests which exercise parsing logic for versions longer than
a single character.

tests/loader_version_tests.cpp

index 757f21febde5a41f3aecb10b98c7c897a9f1e64e..548e81aad41f56f1db1d582bdd6696318dadd43b 100644 (file)
@@ -923,6 +923,22 @@ TEST(DriverManifest, UnknownManifestVersion) {
     ASSERT_TRUE(log.find("has unknown icd manifest file version 3.2.1. May cause errors."));
 }
 
+TEST(DriverManifest, LargeUnknownManifestVersion) {
+    FrameworkEnvironment env{};
+    env.add_icd(TestICDDetails(
+        ManifestICD{}.set_lib_path(TEST_ICD_PATH_VERSION_2_EXPORT_ICD_GPDPA).set_file_format_version({100, 222, 111})));
+    env.get_test_icd().physical_devices.push_back({});
+
+    DebugUtilsLogger log;
+    InstWrapper inst{env.vulkan_functions};
+    inst.create_info.set_api_version(VK_MAKE_API_VERSION(0, 1, 0, 0));
+    FillDebugUtilsCreateDetails(inst.create_info, log);
+    inst.CheckCreate();
+    ASSERT_TRUE(log.find("loader_parse_icd_manifest: "));
+    // log prints the path to the file, don't look for it since it is hard to determine inside the test what the path should be.
+    ASSERT_TRUE(log.find("has unknown icd manifest file version 100.222.111. May cause errors."));
+}
+
 TEST(LayerManifest, UnknownManifestVersion) {
     FrameworkEnvironment env{};
     env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2_EXPORT_ICD_GPDPA));
@@ -932,7 +948,7 @@ TEST(LayerManifest, UnknownManifestVersion) {
     env.add_implicit_layer(ManifestLayer{}
                                .add_layer(ManifestLayer::LayerDescription{}
                                               .set_name(implicit_layer_name)
-                                              .set_api_version(VK_MAKE_API_VERSION(1, 1, 0, 0))
+                                              .set_api_version(VK_MAKE_API_VERSION(0, 1, 0, 0))
                                               .set_lib_path(TEST_LAYER_PATH_EXPORT_VERSION_2)
                                               .set_disable_environment("DISABLE_ME"))
                                .set_file_format_version({3, 2, 1}),
@@ -948,6 +964,31 @@ TEST(LayerManifest, UnknownManifestVersion) {
     ASSERT_TRUE(log.find("has unknown layer manifest file version 3.2.1.  May cause errors."));
 }
 
+TEST(LayerManifest, LargeUnknownManifestVersion) {
+    FrameworkEnvironment env{};
+    env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2_EXPORT_ICD_GPDPA));
+    env.get_test_icd().physical_devices.push_back({});
+
+    const char* implicit_layer_name = "ImplicitTestLayer";
+    env.add_implicit_layer(ManifestLayer{}
+                               .add_layer(ManifestLayer::LayerDescription{}
+                                              .set_name(implicit_layer_name)
+                                              .set_api_version(VK_MAKE_API_VERSION(0, 1, 0, 0))
+                                              .set_lib_path(TEST_LAYER_PATH_EXPORT_VERSION_2)
+                                              .set_disable_environment("DISABLE_ME"))
+                               .set_file_format_version({100, 222, 111}),
+                           "implicit_test_layer.json");
+
+    DebugUtilsLogger log;
+    InstWrapper inst{env.vulkan_functions};
+    inst.create_info.set_api_version(VK_MAKE_API_VERSION(0, 1, 0, 0));
+    FillDebugUtilsCreateDetails(inst.create_info, log);
+    inst.CheckCreate();
+    ASSERT_TRUE(log.find("loader_add_layer_properties: "));
+    // log prints the path to the file, don't look for it since it is hard to determine inside the test what the path should be.
+    ASSERT_TRUE(log.find("has unknown layer manifest file version 100.222.111.  May cause errors."));
+}
+
 struct DriverInfo {
     DriverInfo(TestICDDetails icd_details, uint32_t driver_version, bool expect_to_find) noexcept
         : icd_details(icd_details), driver_version(driver_version), expect_to_find(expect_to_find) {}