Skip to content

Commit bacab74

Browse files
Large refactor of test framework
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
1 parent 1df688c commit bacab74

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+3802
-2599
lines changed

scripts/generators/dispatch_table_helper_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def generate(self):
6060
#include <vulkan/vulkan.h>
6161
#include <vulkan/vk_layer.h>
6262
#include <string.h>
63-
#include "vk_layer_dispatch_table.h"
63+
#include "loader/generated/vk_layer_dispatch_table.h"
6464
6565
''')
6666

tests/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ endif()
6868

6969
option(ENABLE_LIVE_VERIFICATION_TESTS "Enable tests which expect to run on live drivers. Meant for manual verification only" OFF)
7070

71+
set(TEST_EXECUTION_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/executing_tests")
72+
7173
include(GoogleTest)
7274
add_subdirectory(framework)
7375

@@ -94,7 +96,11 @@ add_executable(
9496
loader_testing_main.cpp
9597
loader_fuzz_tests.cpp
9698
)
97-
target_link_libraries(test_fuzzing PUBLIC testing_dependencies vulkan)
99+
target_link_libraries(test_fuzzing PUBLIC testing_dependencies)
100+
# testing_dependencies already links to vulkan when linking statically
101+
if (NOT APPLE_STATIC_LOADER)
102+
target_link_libraries(test_fuzzing PUBLIC vulkan)
103+
endif()
98104
target_include_directories(test_fuzzing PUBLIC ${CMAKE_SOURCE_DIR}/loader ${CMAKE_SOURCE_DIR}/loader/generated)
99105

100106
# Threading tests live in separate executabe just for threading tests as it'll need support

tests/framework/CMakeLists.txt

Lines changed: 9 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -15,38 +15,15 @@
1515
# limitations under the License.
1616
# ~~~
1717

18-
add_library(testing_framework_util STATIC test_util.cpp)
19-
target_link_libraries(testing_framework_util PUBLIC loader_common_options Vulkan::Headers)
20-
21-
if(UNIX OR APPLE)
22-
target_link_libraries(testing_framework_util PUBLIC ${CMAKE_DL_LIBS})
23-
endif()
24-
25-
if(UNIX)
26-
target_compile_options(testing_framework_util PUBLIC -fPIC)
27-
endif()
28-
# Gives access to all headers in the framework folder, in the framework binary, and in the whole project (mainly for loader/generated)
29-
target_include_directories(testing_framework_util PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}" "${PROJECT_SOURCE_DIR}" "${PROJECT_SOURCE_DIR}/loader/generated")
18+
#configure the framework_config.h.in file - used to locate all the binaries generated so that it can be used in the tests
19+
#setup framework_config_temp.h.in in the current binary directory
20+
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/framework_config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/framework_config_temp.h.in")
3021

31-
if (UNIX)
32-
if (LOADER_ENABLE_ADDRESS_SANITIZER)
33-
target_compile_options(testing_framework_util PUBLIC -fsanitize=address,undefined)
34-
target_link_options(testing_framework_util PUBLIC -fsanitize=address,undefined)
35-
endif()
36-
if (LOADER_ENABLE_THREAD_SANITIZER)
37-
target_compile_options(testing_framework_util PUBLIC -fsanitize=thread)
38-
target_link_options(testing_framework_util PUBLIC -fsanitize=thread)
39-
target_compile_options(gtest PUBLIC -fsanitize=thread)
40-
target_link_options(gtest PUBLIC -fsanitize=thread)
41-
endif()
42-
endif()
22+
# setup framework_config_$<CONFIG> using framework_config_temp.h.in as a source
23+
file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/framework_config_$<CONFIG>.h" INPUT "${CMAKE_CURRENT_BINARY_DIR}/framework_config_temp.h.in")
4324

44-
if (MSVC)
45-
# silence hidden class member warnings in test framework
46-
target_compile_options(testing_framework_util PUBLIC /wd4458)
47-
# Make sure exception handling is enabled for the test framework
48-
target_compile_options(testing_framework_util PUBLIC /EHsc)
49-
endif()
25+
# Create a variable to hold the path to the correct header file, used as a compiler definition in the utils target
26+
set(FRAMEWORK_CONFIG_HEADER_PATH "${CMAKE_CURRENT_BINARY_DIR}/framework_config_$<CONFIG>.h")
5027

5128
function(AddSharedLibrary LIBRARY_NAME)
5229
set(singleValueArgs DEF_FILE)
@@ -63,26 +40,14 @@ function(AddSharedLibrary LIBRARY_NAME)
6340
endif()
6441
endfunction()
6542

43+
add_subdirectory(util)
6644
add_subdirectory(data)
6745
add_subdirectory(shim)
6846
add_subdirectory(icd)
6947
add_subdirectory(layer)
7048

71-
#configure the framework_config.h.in file - used to locate all the binaries generated so that it can be used in the tests
72-
#setup framework_config_temp.h.in in the current binary directory
73-
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/framework_config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/framework_config_temp.h.in")
74-
75-
# setup framework_config_$<CONFIG> using framework_config_temp.h.in as a source
76-
file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/framework_config_$<CONFIG>.h" INPUT "${CMAKE_CURRENT_BINARY_DIR}/framework_config_temp.h.in")
77-
78-
# Add a compiler definition for the path to framework_config.h with the correct config
79-
target_compile_definitions(testing_framework_util PUBLIC FRAMEWORK_CONFIG_HEADER="framework_config_$<CONFIG>.h")
80-
8149
add_library(testing_dependencies STATIC test_environment.cpp test_environment.h)
8250
target_link_libraries(testing_dependencies
8351
PUBLIC gtest Vulkan::Headers testing_framework_util shim-library)
8452
target_include_directories(testing_dependencies PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
85-
if (APPLE_STATIC_LOADER)
86-
target_compile_definitions(testing_dependencies PUBLIC "APPLE_STATIC_LOADER=1")
87-
target_link_libraries(testing_dependencies PUBLIC vulkan)
88-
endif()
53+

tests/framework/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,7 @@ There are many utilities that the test framework and tests have access to. These
136136
* Environment Variable Wrapper: `EnvVarWrapper` for creating, setting, getting, and removing environment variables in a RAII manner
137137
* Windows API error handling helpers
138138
* filesystem abstractions:
139-
* `create_folder`/`delete_folder`
140-
* `FolderManager`
139+
* `Folder`
141140
* Creates a new folder with the given name at construction time.
142141
* Allows writing manifests and files (eg, icd or layer binaries)
143142
* Automatically destroys the folder and all contained files at destruction

tests/framework/framework_config.h.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*/
2727

2828
#pragma once
29-
#define FRAMEWORK_BUILD_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
29+
#define TEST_EXECUTION_DIRECTORY "${TEST_EXECUTION_DIRECTORY}"
3030

3131
#define FRAMEWORK_VULKAN_LIBRARY_PATH "$<TARGET_FILE:vulkan>"
3232

tests/framework/icd/test_icd.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@
2929

3030
#include "test_icd.h"
3131

32+
#include <assert.h>
33+
#include <cstring>
34+
35+
#include <iostream>
36+
37+
#include "equality_helpers.h"
38+
3239
// export vk_icdGetInstanceProcAddr
3340
#if !defined(TEST_ICD_EXPORT_ICD_GIPA)
3441
#define TEST_ICD_EXPORT_ICD_GIPA 0

tests/framework/icd/test_icd.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@
2727

2828
#pragma once
2929

30-
#include "test_util.h"
30+
#include <array>
31+
#include <filesystem>
32+
#include <ostream>
33+
34+
#include "util/dispatchable_handle.h"
35+
#include "util/platform_wsi.h"
36+
#include "util/functions.h"
3137

3238
#include "layer/layer_util.h"
3339

@@ -70,6 +76,9 @@ inline std::ostream& operator<<(std::ostream& os, const InterfaceVersionCheck& r
7076
}
7177
return os << static_cast<uint32_t>(result);
7278
}
79+
80+
using VulkanUUID = std::array<uint8_t, VK_UUID_SIZE>;
81+
7382
// clang-format on
7483

7584
// Move only type because it holds a DispatchableHandle<VkPhysicalDevice>

tests/framework/json_writer.h

Lines changed: 0 additions & 164 deletions
This file was deleted.

tests/framework/layer/generated/vk_dispatch_table_helper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include <vulkan/vulkan.h>
2929
#include <vulkan/vk_layer.h>
3030
#include <string.h>
31-
#include "vk_layer_dispatch_table.h"
31+
#include "loader/generated/vk_layer_dispatch_table.h"
3232

3333
// clang-format off
3434
static inline void layer_init_device_dispatch_table(VkDevice device, VkLayerDispatchTable *table, PFN_vkGetDeviceProcAddr gpa) {

tests/framework/layer/layer_util.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727

2828
#pragma once
2929

30-
#include "test_util.h"
30+
#include "builder_defines.h"
31+
32+
#include "vulkan_object_wrappers.h"
3133

3234
struct LayerDefinition {
3335
BUILDER_VALUE(std::string, layerName)
@@ -38,10 +40,10 @@ struct LayerDefinition {
3840

3941
VkLayerProperties get() const noexcept {
4042
VkLayerProperties props{};
41-
copy_string_to_char_array(layerName, &props.layerName[0], VK_MAX_EXTENSION_NAME_SIZE);
43+
layerName.copy(props.layerName, VK_MAX_EXTENSION_NAME_SIZE);
4244
props.specVersion = specVersion;
4345
props.implementationVersion = implementationVersion;
44-
copy_string_to_char_array(description, &props.description[0], VK_MAX_DESCRIPTION_SIZE);
46+
description.copy(props.description, VK_MAX_DESCRIPTION_SIZE);
4547
return props;
4648
}
4749
};

0 commit comments

Comments
 (0)