2929
3030#include < array>
3131#include < fstream>
32+ #include < string>
3233#include < utility>
3334
3435#include " json_writer.h"
@@ -462,23 +463,22 @@ TestICD& FrameworkEnvironment::add_icd(std::filesystem::path const& path, Manife
462463 return icds.back ().get_test_binary ();
463464}
464465
465- void FrameworkEnvironment::add_implicit_layer (ManifestLayer layer_manifest, const std::string& json_name ) noexcept {
466- add_layer_impl (TestLayerDetails{layer_manifest, json_name} , ManifestCategory::implicit_layer);
466+ void FrameworkEnvironment::add_implicit_layer (ManifestOptions args, ManifestLayer layer_manifest ) noexcept {
467+ add_layer_impl (args, layer_manifest , ManifestCategory::implicit_layer);
467468}
468- void FrameworkEnvironment::add_explicit_layer (ManifestLayer layer_manifest, const std::string& json_name) noexcept {
469- add_layer_impl (TestLayerDetails{layer_manifest, json_name}, ManifestCategory::explicit_layer);
470- }
471- void FrameworkEnvironment::add_implicit_layer (TestLayerDetails layer_details) noexcept {
472- add_layer_impl (layer_details, ManifestCategory::implicit_layer);
473- }
474- void FrameworkEnvironment::add_explicit_layer (TestLayerDetails layer_details) noexcept {
475- add_layer_impl (layer_details, ManifestCategory::explicit_layer);
469+ void FrameworkEnvironment::add_explicit_layer (ManifestOptions args, ManifestLayer layer_manifest) noexcept {
470+ add_layer_impl (args, layer_manifest, ManifestCategory::explicit_layer);
476471}
477472
478- void FrameworkEnvironment::add_layer_impl (TestLayerDetails layer_details, ManifestCategory category) {
473+ void FrameworkEnvironment::add_layer_impl (ManifestOptions args, ManifestLayer manifest, ManifestCategory category) {
474+ if (args.json_name .empty ()) {
475+ args.json_name = " test_layer_" + std::to_string (created_layer_count) + " .json" ;
476+ created_layer_count++;
477+ }
478+
479479 fs::Folder* fs_ptr = &get_folder (ManifestLocation::explicit_layer);
480480 EnvVarWrapper* env_var_to_use = nullptr ;
481- switch (layer_details .discovery_type ) {
481+ switch (args .discovery_type ) {
482482 case (ManifestDiscoveryType::generic):
483483 if (category == ManifestCategory::implicit_layer) fs_ptr = &get_folder (ManifestLocation::implicit_layer);
484484 break ;
@@ -490,10 +490,10 @@ void FrameworkEnvironment::add_layer_impl(TestLayerDetails layer_details, Manife
490490 fs_ptr = &get_folder (ManifestLocation::implicit_layer_env_var);
491491 env_var_to_use = &env_var_vk_implicit_layer_paths;
492492 }
493- if (layer_details .is_dir ) {
493+ if (args .is_dir ) {
494494 env_var_to_use->add_to_list (fs_ptr->location ());
495495 } else {
496- env_var_to_use->add_to_list (fs_ptr->location () / layer_details .json_name );
496+ env_var_to_use->add_to_list (fs_ptr->location () / args .json_name );
497497 }
498498 break ;
499499 case (ManifestDiscoveryType::add_env_var):
@@ -504,10 +504,10 @@ void FrameworkEnvironment::add_layer_impl(TestLayerDetails layer_details, Manife
504504 fs_ptr = &get_folder (ManifestLocation::implicit_layer_add_env_var);
505505 env_var_to_use = &add_env_var_vk_implicit_layer_paths;
506506 }
507- if (layer_details .is_dir ) {
507+ if (args .is_dir ) {
508508 env_var_to_use->add_to_list (fs_ptr->location ());
509509 } else {
510- env_var_to_use->add_to_list (fs_ptr->location () / layer_details .json_name );
510+ env_var_to_use->add_to_list (fs_ptr->location () / args .json_name );
511511 }
512512 break ;
513513 case (ManifestDiscoveryType::override_folder):
@@ -534,7 +534,7 @@ void FrameworkEnvironment::add_layer_impl(TestLayerDetails layer_details, Manife
534534 }
535535 auto & folder = *fs_ptr;
536536 size_t new_layers_start = layers.size ();
537- for (auto & layer : layer_details. layer_manifest .layers ) {
537+ for (auto & layer : manifest .layers ) {
538538 if (!layer.lib_path .empty ()) {
539539 std::filesystem::path new_lib_path = layer.lib_path .stem ();
540540 new_lib_path += " _" ;
@@ -544,59 +544,58 @@ void FrameworkEnvironment::add_layer_impl(TestLayerDetails layer_details, Manife
544544 auto new_layer_location = folder.copy_file (layer.lib_path , new_lib_path);
545545
546546#if TESTING_COMMON_UNIX_PLATFORMS
547- if (layer_details .library_path_type == LibraryPathType::default_search_paths) {
547+ if (args .library_path_type == LibraryPathType::default_search_paths) {
548548 platform_shim->add_system_library (new_lib_path, new_layer_location);
549549 }
550550#endif
551551#if defined(WIN32)
552- if (layer_details .library_path_type == LibraryPathType::default_search_paths) {
552+ if (args .library_path_type == LibraryPathType::default_search_paths) {
553553 SetDefaultDllDirectories (LOAD_LIBRARY_SEARCH_USER_DIRS);
554554 AddDllDirectory (new_layer_location.parent_path ().native ().c_str ());
555555 }
556556#endif
557557
558558 // Don't load the layer binary if using any of the wrap objects layers, since it doesn't export the same interface
559559 // functions
560- if (!layer_details.is_fake &&
561- layer.lib_path .stem ().string ().find (std::filesystem::path (TEST_LAYER_WRAP_OBJECTS).stem ().string ()) ==
562- std::string::npos) {
560+ if (!args.is_fake && layer.lib_path .stem ().string ().find (
561+ std::filesystem::path (TEST_LAYER_WRAP_OBJECTS).stem ().string ()) == std::string::npos) {
563562 layers.push_back (TestLayerHandle (new_layer_location));
564563 layers.back ().reset ();
565564 }
566- if (layer_details .library_path_type == LibraryPathType::relative) {
565+ if (args .library_path_type == LibraryPathType::relative) {
567566 layer.lib_path = std::filesystem::path (" ." ) / new_lib_path;
568- } else if (layer_details .library_path_type == LibraryPathType::default_search_paths) {
567+ } else if (args .library_path_type == LibraryPathType::default_search_paths) {
569568 layer.lib_path = new_lib_path;
570569 } else {
571570 layer.lib_path = new_layer_location;
572571 }
573572 }
574573 }
575- if (layer_details .discovery_type != ManifestDiscoveryType::none) {
574+ if (args .discovery_type != ManifestDiscoveryType::none) {
576575 // Write a manifest file to a folder as long as the discovery type isn't none
577- auto layer_manifest_loc = folder.write_manifest (layer_details .json_name , layer_details. layer_manifest .get_manifest_str ());
576+ auto layer_manifest_loc = folder.write_manifest (args .json_name , manifest .get_manifest_str ());
578577#if defined(WIN32)
579578 // only add the manifest to the registry if its a generic location (as if it was installed) - both system and user local
580- if (layer_details .discovery_type == ManifestDiscoveryType::generic) {
579+ if (args .discovery_type == ManifestDiscoveryType::generic) {
581580 platform_shim->add_manifest_to_registry (category, layer_manifest_loc);
582581 }
583- if (layer_details .discovery_type == ManifestDiscoveryType::unsecured_generic) {
582+ if (args .discovery_type == ManifestDiscoveryType::unsecured_generic) {
584583 platform_shim->add_unsecured_manifest_to_registry (category, layer_manifest_loc);
585584 }
586- if (layer_details .discovery_type == ManifestDiscoveryType::windows_app_package) {
585+ if (args .discovery_type == ManifestDiscoveryType::windows_app_package) {
587586 platform_shim->set_app_package_path (folder.location ());
588587 }
589588#endif
590589 for (size_t i = new_layers_start; i < layers.size (); i++) {
591590 layers.at (i).manifest_path = layer_manifest_loc;
592591 layers.at (i).shimmed_manifest_path = layer_manifest_loc;
593592#if TESTING_COMMON_UNIX_PLATFORMS
594- if (layer_details .discovery_type == ManifestDiscoveryType::generic) {
593+ if (args .discovery_type == ManifestDiscoveryType::generic) {
595594 layers.at (i).shimmed_manifest_path =
596595 ((category == ManifestCategory::implicit_layer)
597596 ? file_system_manager.get_path_redirect_by_manifest_location (ManifestLocation::implicit_layer)
598597 : file_system_manager.get_path_redirect_by_manifest_location (ManifestLocation::explicit_layer)) /
599- layer_details .json_name ;
598+ args .json_name ;
600599 }
601600#endif
602601 }
0 commit comments