Commit Graph

36 Commits

Author SHA1 Message Date
Charles Giessen 1c30270eee Fix tests compiler warnings from bool conversions
While set_env_var did return a boolean, this caused odd performance warnings
on old compilers and wasn't being used by the tests.
2022-03-09 15:06:30 -07:00
Charles Giessen a4f4aaad22 Expand unknown function handling tests
Add tests for unknown device functions queried with both vkGetDeviceProcAddr
and vkGetInstanceProcAddr. Also loops enough times to exhaust the available
unknown function supply.

Had to fix the vk_layerGetPhysicalDeviceProcAddr in TestLayer to make the tests
pass.

MacOS currently skips tests which use vkGetInstanceProcAddr. This is due to the
need for unknown functions being lower priority and so do not warrent the time
needed to write the assembly necessary to resolve the issue fully.
2022-02-15 10:48:53 -07:00
Charles Giessen f2d1b6e536 Update tests function loading implementation
Remove the need for macros and use well crafted helper loading functions which
can figure out the type to convert to based on the type being assigned.
2022-02-15 10:48:53 -07:00
Mark Young f9bb0a4c6d Test layer pre-instance functions
Add tests to verify that the 3 pre-instance functions are properly
intercepted by the layer when everything is well-defined.

Also include two fixes:
 1) Disable environment variable value of 0 should be treated the same as not present
 2) The vkEnumerateInstanceVersion override path was broken, missing a NULL check
2022-02-15 10:47:36 -07:00
Charles Giessen 9850f714d2 Add test for implicit layer with 0.1 API version
The loader disables implicit layers if their API version isn't the same or
greater than the application. Make sure this still works even with pre 1.0
versions.
2022-01-28 16:24:27 -07:00
Charles Giessen 99e5c4c542 Add TestLayerDetails helper struct
Increasingly it is common to need more control over what the framework
environment does when adding layers. While only a refactor, this change
makes it easier to extend the functionality by adding data to the
TestLayerDetails struct.

The code to check whether the lib_path specified in add_layer_impl was
improved by using the `.stem()` functionality of the fs::path abstraction.

size_t was replaced with uint32_t where the compiler gave warnings.
2022-01-25 12:32:56 -07:00
Charles Giessen 7d50dfc706 Add meta layer blacklist test 2022-01-25 12:32:56 -07:00
Charles Giessen 0a0d8d1396 Add meta layer fields to layer manifest in tests 2022-01-25 12:32:56 -07:00
Charles Giessen 6e5c65d627 Simplify test framework FolderManager write function
Condense the overloaded write function from taking either an icd manifest or a layer manifest
and only take a string. This reduces the amount of copy-paste code.
2022-01-25 12:32:56 -07:00
Charles Giessen 1bc42ec6a2 Add VK_LOADER_TEST_LOADER_PATH env-var for tests
The environment variable VK_LOADER_TEST_LOADER_PATH allows running of tests
using a different binary than the one built by the repo. This is extremely
useful for checking that a test exercises a bugfix, by quickly allowing the
running of the same test on the current 'fixed' loader and an older 'broken'
loader.
2022-01-18 15:51:14 -07:00
Charles Giessen 1b2f8a03f2 Fix Test folders and registry cleaning logic
The test framework was not clearing out old registry values after successive
test runs. The new logic now correctly clears out the files and registry keys
after each run.
2021-12-10 17:08:23 -07:00
Charles Giessen 9f855da02b Use builders in test framework components
Make use of BUILDER_VALUE and BUILDER_VECTOR in the various structs of the test
framework. This allows easier usage of the components by allowing a builder
style continuation of setting parameters in the drivers and physical devices.
2021-12-10 17:08:23 -07:00
Charles Giessen a92b915ee5 Add Builder Pattern helpers to test framework
Allows quick creation of builders in test code.
2021-12-10 17:08:23 -07:00
Charles Giessen 62ce3e7409 Fix per-platform defines in test framework not showing up
Need to use target_compile_definitions instead of target_compile_options.
Also appears that generator expressions do not play nicely, so best to revert
to classic if-else chains.
2021-12-01 14:02:09 -07:00
Mark Young 035140a542 Update loader to include handle validation
Validate the Vulkan dispatchable handles (VkInstance, VkPhysicalDevice, etc) for
any trampoline functions the loader uses to query the dispatch table from.
This is so we can at least report errors before something bad happens.

Also, add tests to the test framework to catch this case.  Right now they simply
check to make sure we aborted, but they don't know why the loader aborted.
Eventually, we need to come back and check the loader messages and make sure it
aborted for the reasons we want.

Fix a generator warning in dispatch_table_helper_generator.py where a compare was
the wrong type.

Fixes GH Issue #64.
2021-11-19 10:32:13 -07:00
Charles Giessen be8d1315b6 test: Fix compiler warnings in MSVC
Warnings/fixes include:
* strcpy/strncpy/wstrcpy
* Dropping static on inline functions
* Use localtime_s
* Name shadowing
* Use wcstombs_s
* 32<->64 bit int conversion
* Silence spurious C4996 generated in vs2015
2021-11-04 12:19:14 -06:00
Eleni Maria Stea 91d68b7849 loader: include FreeBSD in supported platforms
Added FreeBSD in supported platforms in vk_loader_platform.h, and tests,
defined BSD_VISIBLE and included some necessary header files for
Vulkan-Loader to compile on FreeBSD.

v2: did the same in loader/loader.c (Charles Giessen)
v3: did the same in the tests (Charles Giessen)
v4: applied this downstream patch from Jan Beich because there's no /proc
on FreeBSD: https://github.com/freebsd/freebsd-ports/blob/7caf52e37ba2174dc50a7440d63eec70d7d58ebc/graphics/vulkan-loader/files/patch-loader_vk__loader__platform.h (Jan Beich)
v4: rebased to master and modified tests/loader_regression_tests.cpp,
tests/loader_testing_main.cpp
v5: moved the definition of __BSD_VISIBLE 1 (required for alloca to
work) in CMakeLists.txt from header files (Charles Giessen)
v6: replaced ${CMAKE_SYSTEM_NAME} with CMAKE_SYSTEM_NAME in
loader/CMakeLists.txt to match the style of previous checks (Jan Beich)
v7: replaced add_compile_definitions with target_compile_definitions to
prevent the macro from being applied unnecessarily (Charles Giessen)
2021-10-20 10:29:26 -06:00
Charles Giessen 3ae6a46f02 test: Use correct path in json files
Previously a Windows path in a json file did not include the correct
backslahses. This commit rectifies that.
2021-10-05 12:09:50 -06:00
Charles Giessen 9d6accbc50 test: Add XDG & VK_LAYER_PATH tests
Tests check to see if the paths are searched by looking at the log.
Makde FrameworkEnvironment contain a debug_log, this is to prevent any
lifetime issues. This prevents the possibility of creating a DebugUtilsLogger
after the InstWrapper.
Had to redo the test framework a bit to make them work.
2021-09-30 22:39:41 -06:00
Charles Giessen 5f96256afb test: Add test which calls GetPDProps inside CreateInstance
This test makes sure that any layer calling GetPDProps inside of CreateInstance
succeeds and doesn't crash.
2021-09-10 13:59:45 -06:00
Charles Giessen fea09c7783 test: Add callback to layers create instance and device
This allows some code to be written inside the test which then gets run
during the call to vkCreateInstance and vkCreateDevice.
2021-09-10 13:59:45 -06:00
Charles Giessen 61b0faf565 test: Fix extra } in layer manifest printer 2021-09-09 11:14:49 -06:00
Charles Giessen d76cef07ce test: Improved Test Wrapper interface
Made InstanceWrapper and DeviceWrapper simpler to use by moving them to test_environment
then making the Create() member functions and doing the gtest assertions in the function
itself.

Additionally:
Removed the `detail` namespace in the test_environment.
Renamed get_new_test_icd/layer to just `reset_icd/layer`. This is clearer about what it
is doing and makes the interface more expressive with code such as
`env->reset_icd().SetMinInterfaceVersion(5);`
2021-09-06 18:19:14 -06:00
Charles Giessen 85ba7418d6 test: Add TestICD DeviceGroup support
Add support for tests which use device groups by adding a new structure that
holds pointes to PhysicalDevice structs and implementing the necessary vulkan
API calls.

This commit also:
 - Formats test_icd.cpp
 - Makes vk_icdGetPhysicalDeviceProcAddr return stuff by refactoring the
   instance procaddr functions
2021-08-31 15:04:40 -06:00
Charles Giessen 584448e98d test: Add DebugUtilsWrapper
This wrapper allows easy reading of the log output through the debug utils
messenger infrastructure. Since getting the stdout/stderr is not well
supported by googletest, this allows tests to be written which check for
specific log messages to be emitted, allowing another way to verify the
loader is behaving as expected.
2021-08-26 10:51:15 -06:00
Charles Giessen e8ed23923c test: Make MetaLayer test add extensions
Needed to fixup more of the manifest writer in the process
2021-08-06 16:00:06 -06:00
Charles Giessen f572032fd6 test: Make invalid meta layer test more comprehensive
This required fixing a few bugsin the Manifest file printing logic
2021-08-06 16:00:06 -06:00
Charles Giessen 6e53c1e511 test: Add simple invalid-meta layer test
Creates a meta layer whose component layers do not exist
2021-08-06 16:00:06 -06:00
Charles Giessen 79307a1afd test: Add basic threading test
Requires adding ability for device to return functions with
vkGetDeviceProcAddr that aren't necessarily useable functions.

Also added checks to make sure that the handle passed in by the loader
to the TestICD is the 'right handle' where necessary, as some functions
do not need to know which device is being called on, just that it is correct.
2021-07-30 10:33:15 -06:00
Charles Giessen 81314c2f89 test: Use a new string_eq function instead of raw strcmp
Change-Id: I703763133c42eb78ae3c6e194450411e3f784e35
2021-07-06 10:03:29 -06:00
Charles Giessen 57c6c8e8c7 test: Drop fp_ from function pointer names
Change-Id: Ibd047e99f442d4a9755ac186e16b3620d3544e37
2021-07-06 10:03:29 -06:00
Charles Giessen 76b10a878e test: Delete old temp folders when starting tests/framework/test_util
Make sure the work space is clean before starting a test, this is mainly for developer builds, as CI
runs will generally wipe the entire build tree instead.
2021-06-23 15:15:56 -06:00
Charles Giessen 2e9d8dc1a8 test: Add revamped allocation tests
Creates a memory tracker class and rewrites the existing allocation tests.

Change-Id: I09ca2dc5b4d83f775ae0e3fd362a3fa4f7255d27
2021-06-23 15:15:56 -06:00
Charles Giessen 820fc25d1d test: Fix framework to work on MacOS
Main issue was getting function redireciton to work, dyld-interposer accomplishes that.
It required making the shim-library a dylib, but otherwise only required minor changes.

Change-Id: I7b7e2c86cc0c0b082f58241a7e146b74af72e792
2021-06-22 12:03:05 -06:00
Charles Giessen b9f4dd01e2 test: Delete files properly on windows
Move windows specific error reporting to test_util.h
This allows for its use anywhere its required.

Change-Id: I14a0da85dc0d3f4e651b99aa005469b47d98d940
2021-06-07 14:07:38 -07:00
Charles Giessen 3743707e47 test: Add framework cmake and utilities
Create the CMake infrastructure for a testing framework.
`test_util.h/.cpp` contains the core macros, wrappers, and utilities.
framework_config.h.in is the header that other components include
to get the full path to binaries on a system.

Change-Id: I3e24a3ee4ff24da499a3bca63059e3b872d3981c
2021-05-27 16:59:28 -06:00