third_party_vulkan-loader/tests
Charles Giessen b411580d64 Update tests to use correct version macro
The VK_MAKE_API_VERSION macro and the VK_API_VERSION_1_X macros are better to
use. This commit switches the tests over to the non-deprecated versions of the
macros.
2022-01-28 16:24:27 -07:00
..
framework Update tests to use correct version macro 2022-01-28 16:24:27 -07:00
CMakeLists.txt Add more WSI tests, and fix some compiler warnings. 2022-01-07 16:56:38 -07:00
loader_alloc_callback_tests.cpp Refactor tests FrameworkEnvironment class 2021-12-10 17:08:23 -07:00
loader_get_proc_addr_tests.cpp Refactor tests FrameworkEnvironment class 2021-12-10 17:08:23 -07:00
loader_handle_validation_tests.cpp Consistent loader device ordering 2022-01-12 16:53:35 -07:00
loader_layer_tests.cpp Add test for implicit layer with 0.1 API version 2022-01-28 16:24:27 -07:00
loader_phys_dev_inst_ext_tests.cpp Fixup phys_dev_inst_ext_tests 2022-01-10 15:49:26 -07:00
loader_regression_tests.cpp Test EnumPhysDev to make sure handles don't change 2022-01-26 14:24:29 -07:00
loader_testing_main.cpp Fix Test folders and registry cleaning logic 2021-12-10 17:08:23 -07:00
loader_threading_tests.cpp Refactor tests FrameworkEnvironment class 2021-12-10 17:08:23 -07:00
loader_unknown_ext_tests.cpp Refactor tests FrameworkEnvironment class 2021-12-10 17:08:23 -07:00
loader_version_tests.cpp Warn when the apiVersion's variant isn't 0 2022-01-28 16:24:27 -07:00
loader_wsi_tests.cpp Update tests to use correct version macro 2022-01-28 16:24:27 -07:00
README.md Fixup tests/README to use newlines for sentences 2022-01-25 12:32:56 -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.

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