third_party_vulkan-loader/tests
Charles Giessen 38e9dc8faf Test framework now shims registry functions
Previously the way the test framework worked was to fake the registry using a
special windows API call. However this led to brittle tests and was incompatible
with googletest's death test capabilities.

These death tests highlighted that the current set of them didn't use the built in
matcher to verify a correct crash/abort. This commit also amends all uses of
ASSERT_DEATH to provide the relevant death message.

If a driver reports an interface version greater than 0 but doesn't export
vk_icdGetInstanceProcAddr, the loader will now skip the driver.
2022-03-14 23:31:26 -06:00
..
framework Test framework now shims registry functions 2022-03-14 23:31:26 -06:00
live_verification Refactor CMake to user correct C/C++ Standard 2022-03-09 15:06:30 -07:00
CMakeLists.txt Set VK_NO_PROTOTYPES on test targets 2022-03-09 15:06:30 -07:00
loader_alloc_callback_tests.cpp loader log error if a requested layer not loaded 2022-01-31 14:35:07 -07:00
loader_debug_ext_tests.cpp Fix Windows build and add proper phys dev group sorting 2022-02-16 08:29:42 -07:00
loader_envvar_tests.cpp Test framework now shims registry functions 2022-03-14 23:31:26 -06:00
loader_get_proc_addr_tests.cpp Make vkGetInstanceProcAddr able to get itself 2022-02-05 19:04:36 -07:00
loader_handle_validation_tests.cpp Test framework now shims registry functions 2022-03-14 23:31:26 -06:00
loader_layer_tests.cpp Fix compiler warnings in tests on MSVC 2022-03-09 15:06:30 -07:00
loader_phys_dev_inst_ext_tests.cpp Fix tests compiler warnings from bool conversions 2022-03-09 15:06:30 -07:00
loader_regression_tests.cpp Fix compiler warnings in tests on MSVC 2022-03-09 15:06:30 -07:00
loader_testing_main.cpp Test framework now shims registry functions 2022-03-14 23:31:26 -06:00
loader_threading_tests.cpp Refactor tests FrameworkEnvironment class 2021-12-10 17:08:23 -07:00
loader_unknown_ext_tests.cpp Test framework now shims registry functions 2022-03-14 23:31:26 -06:00
loader_version_tests.cpp Add "additive" environment variables 2022-03-04 15:38:46 -07:00
loader_wsi_tests.cpp Test framework now shims registry functions 2022-03-14 23:31:26 -06:00
README.md Update build.md and README.md for the tests 2022-02-15 16:51:46 -07:00

Loader Tests

This directory contains a test suite for the Vulkan loader. These tests are not exhaustive — they are expected to be supplemented with other tests, such as CTS.

Test specific CMake Configuration

Option Platform Default Description
BUILD_TESTS All OFF Controls whether or not the loader tests are built.
ENABLE_LIVE_VERIFICATION_TESTS All OFF Enables building of tests meant to run with live drivers
TEST_USE_ADDRESS_SANITIZER Linux OFF Enables Address Sanitizer in the loader and tests
TEST_USE_THREAD_SANITIZER Linux OFF Enables Thread Sanitizer in the loader and tests

Running Tests

For most purposes ctest is the desired method of running tests. This is because when a test fails, ctest will automatically printout the failing test case.

Tests are organized into various executables:

  • test_regression - Contains most tests.
  • test_threading - Tests which need multiple threads to execute.
    • This allows targeted testing which uses tools like ThreadSanitizer

The loader test framework is designed to be easy to use, as simple as just running a single executable. To achieve that requires extensive build script automation is required. More details are in the tests/framework/README.md. The consequence of this automation: Do not relocate the build folder of the project without cleaning the CMakeCache. Most components are found by absolute path and thus require the contents of the folder to not be relocated.

Writing Tests

The test_environment.h/cpp are the primary tool used when creating new tests. Either use the existing child classes of FrameworkEnvironment or create a new one to suite the tests need. Refer to the tests/framework/README.md for more details.

IMPORTANT NOTES:

  • NEVER FORGET TO DESTROY A VKINSTANCE THAT WAS SUCCESSFULLY CREATED.
    • The loader loads dynamic libraries in vkCreateInstance and unloads them in vkDestroyInstance. If these dynamic libraries aren't unloaded, they leak state into the next test that runs, causing spurious failures or even crashes.
    • Use InstWrapper helper as well as DeviceWrapper to automate this concern away.

Using a specific loader with the tests

The environment variable VK_LOADER_TEST_LOADER_PATH can be used to specify which vulkan-loader binary should be used. This is useful when writing tests to exercise a bug fix. Simply build the loader without the fix, stash it in a known location. Write the fix and the test that should exercise the bug and it passes. Then run the test again but with this env-var set to the older loader without the fix and show that the test now fails.

Basic usage example:

VK_LOADER_TEST_LOADER_PATH="/path/to/older/loader/build" ctest --output-on-failure