Skip to content

Get real path to layer & driver binaries & Refactor test framework#1746

Merged
charles-lunarg merged 4 commits into
KhronosGroup:mainfrom
charles-lunarg:print_actually_loaded_macos_binary
Jul 29, 2025
Merged

Get real path to layer & driver binaries & Refactor test framework#1746
charles-lunarg merged 4 commits into
KhronosGroup:mainfrom
charles-lunarg:print_actually_loaded_macos_binary

Conversation

@charles-lunarg

Copy link
Copy Markdown
Collaborator

Queries the real path of loaded layers and drivers so that logging messages
contain the exact path used, instead of the path the loader gave to dlopen/
LoadLibrary. This ensures that logs are as accurate as can be, as the dynamic
linker may not respect the passed in library (due to environment variables
or other mechanisms which change which binary is loaded).

This requires normalizing paths before comparison, as the path given to
dlopen/LoadLibrary may represent the same location as the queried path, but
might not be identical strings. Normalization is done using the realpath()
function on platforms that support it, and a fallback implementation is
used elsewhere. The implementation only removes extra directory separators
("//"), extra current directory specifiers ("/./"), and removes relative
to parent directory specifiers ("/foo/../").

  • Large refactor of test framework

Makes many changes to test infrastructure:

  • Generate the VkResult string printer
  • Split test_util into separate files for maintainability
  • Move new files into tests/framework/util
  • Move FolderManager into separate file from test_environment
  • Rename COMMON_UNIX_PLATFORMS to TESTING_COMMON_UNIX_PLATFORMS
  • Rewrote unix path redirection logic, relies on FileSystemManager
    • Relative paths are actually relative now
  • Split unsecured folder location into unsecured driver/implicit layer/explicit layer/settings
  • Fix bugs in tests that are attributable to old path redirection logic.
  • Use normalized paths in test framework - ie normalize paths so they can be compared easily
  • Make running with elevated privileges a framework level setting
  • Split tests that change elevated privileges into separate tests
  • Framework can set home & xdg env-vars at startup
  • Platform specific folders are only defined on those platforms
  • PlatformShim::add_manifest is now windows only, reflecting that only windows implemented it

Queries the real path of loaded layers and drivers so that logging messages
contain the exact path used, instead of the path the loader gave to dlopen/
LoadLibrary. This ensures that logs are as accurate as can be, as the dynamic
linker may not respect the passed in library (due to environment variables
or other mechanisms which change which binary is loaded).

This requires normalizing paths before comparison, as the path given to
dlopen/LoadLibrary may represent the same location as the queried path, but
might not be identical strings. Normalization is done using the realpath()
function on platforms that support it, and a fallback implementation is
used elsewhere. The implementation only removes extra directory separators
("//"), extra current directory specifiers ("/./"), and removes relative
to parent directory specifiers ("/foo/../").
Makes many changes to test infrastructure:
* Split test_util into separate files for maintainability
* Move new files into tests/framework/util
* Move FolderManager into separate file from test_environment
* Rename COMMON_UNIX_PLATFORMS to TESTING_COMMON_UNIX_PLATFORMS
* Rewrote unix path redirection logic, relies on FileSystemManager
  * Relative paths are actually relative now
* Split unsecured folder location into unsecured driver/implicit layer/explicit layer/settings
* Fix bugs in tests that are attributable to old path redirection logic.
* Use normalized paths in test framework - ie normalize paths so they can be compared easily
* Make running with elevated privileges a framework level setting
* Split tests that change elevated privileges into separate tests
* Framework can set home & xdg env-vars at startup
* Platform specific folders are only defined on those platforms
* PlatformShim::add_manifest is now windows only, reflecting that only windows implemented it
The searching for the loader_settings.json file relied on faulty assumptions about which paths would be used,
notably ignoring XDG env-vars, as well as SYSCONFDIR, EXTRASYSCONFDIR, and the fallback xdg paths.
@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build queued with queue ID 497523.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build queued with queue ID 497540.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build # 3125 running.

@ci-tester-lunarg

Copy link
Copy Markdown

CI Vulkan-Loader build # 3125 passed.

@charles-lunarg

Copy link
Copy Markdown
Collaborator Author

While this PR does make changes to the loader source, it should not affect behavior of applications for the following reason: All of the logic to get the 'real' path to a binary is done after loading the binary, meaning that paths are not modified at all before calling dlopen/LoadLibrary. This ensures that existing behavior remains correct. The main change is to the paths that are printed in the log, meaning that the user will have a much better indication of what actually was loaded, instead of just printing the path that was attempted to be loaded. For this reason, I am going to go ahead and merge it in.

@charles-lunarg charles-lunarg merged commit 508795c into KhronosGroup:main Jul 29, 2025
44 checks passed
@charles-lunarg charles-lunarg deleted the print_actually_loaded_macos_binary branch July 29, 2025 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants