README.md
1
2# Loader Tests
3
4This directory contains a test suite for the Vulkan loader.
5These tests are not exhaustive — they are expected to be supplemented with other tests, such as CTS.
6
7
8## Test specific CMake Configuration
9
10| Option | Platform | Default | Description |
11| ------------------------------ | -------- | ------- | -------------------------------------------------------- |
12| BUILD_TESTS | All | `OFF` | Controls whether or not the loader tests are built. |
13| ENABLE_LIVE_VERIFICATION_TESTS | All | `OFF` | Enables building of tests meant to run with live drivers |
14
15## Running Tests
16
17For most purposes `ctest` is the desired method of running tests.
18This is because when a test fails, `ctest` will automatically printout the failing test case.
19
20Tests are organized into various executables:
21 * `test_regression` - Contains most tests.
22 * `test_threading` - Tests which need multiple threads to execute.
23 * This allows targeted testing which uses tools like ThreadSanitizer
24
25The 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
26automation is required. More details are in the tests/framework/README.md.
27The consequence of this automation: Do not relocate the build folder of the project without cleaning the CMakeCache. Most components are found by absolute
28path and thus require the contents of the folder to not be relocated.
29
30## Writing Tests
31
32The `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
33to suite the tests need. Refer to the `tests/framework/README.md` for more details.
34
35IMPORTANT NOTES:
36 * NEVER FORGET TO DESTROY A VKINSTANCE THAT WAS SUCCESSFULLY CREATED.
37 * The loader loads dynamic libraries in `vkCreateInstance` and unloads them in `vkDestroyInstance`. If these dynamic libraries aren't unloaded, they leak state
38 into the next test that runs, causing spurious failures or even crashes.
39 * Use InstWrapper helper as well as DeviceWrapper to automate this concern away.
40
41## Using a specific loader with the tests
42
43The environment variable `VK_LOADER_TEST_LOADER_PATH` can be used to specify which vulkan-loader binary should be used.
44This is useful when writing tests to exercise a bug fix.
45Simply build the loader without the fix, stash it in a known location.
46Write the fix and the test that should exercise the bug and it passes.
47Then run the test again but with this env-var set to the older loader without the fix and show that the test now fails.
48
49Basic usage example:
50```c
51VK_LOADER_TEST_LOADER_PATH="/path/to/older/loader/build" ctest --output-on-failure
52```
53