mirror of
https://github.com/charles-lunarg/vk-bootstrap.git
synced 2024-11-25 16:24:35 +00:00
Run tests in CI scripts
Make use of CTest to manage running tests, and configure the project to allow Catch2 to work with CTest
This commit is contained in:
parent
834960e58f
commit
1ab85e9e55
114
.github/workflows/ci_build.yml
vendored
114
.github/workflows/ci_build.yml
vendored
@ -21,72 +21,64 @@ name: CI Build
|
||||
on: [push, pull_request, workflow_dispatch]
|
||||
|
||||
jobs:
|
||||
linux-build:
|
||||
name: ${{ matrix.config.name }}
|
||||
runs-on: ${{ matrix.config.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
config:
|
||||
- {
|
||||
name: "Ubuntu GCC Debug",
|
||||
os: ubuntu-latest,
|
||||
type: "debug",
|
||||
build_dir: "build",
|
||||
cc: "gcc", cxx: "g++"
|
||||
}
|
||||
- {
|
||||
name: "Ubuntu Clang Debug",
|
||||
os: ubuntu-latest,
|
||||
type: "debug",
|
||||
build_dir: "build",
|
||||
cc: "clang", cxx: "clang++"
|
||||
}
|
||||
- {
|
||||
name: "Ubuntu GCC Release",
|
||||
os: ubuntu-latest,
|
||||
type: "release",
|
||||
build_dir: "build",
|
||||
cc: "gcc", cxx: "g++"
|
||||
}
|
||||
- {
|
||||
name: "Ubuntu Clang Release",
|
||||
os: ubuntu-latest,
|
||||
type: "release",
|
||||
build_dir: "build",
|
||||
cc: "clang", cxx: "clang++"
|
||||
}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2.0.0
|
||||
linux:
|
||||
name: Linux
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
type: ["Debug", "Release"]
|
||||
cc: ["gcc", "clang"]
|
||||
cxx: ["g++", "clang++"]
|
||||
exclude:
|
||||
- cc: gcc
|
||||
cxx: clang++
|
||||
- cc: clang
|
||||
cxx: g++
|
||||
|
||||
- name: Install build dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y xorg-dev
|
||||
|
||||
- name: CMake Configure
|
||||
run: cmake -Bbuild -DVK_BOOTSTRAP_WERROR=ON -DVK_BOOTSTRAP_TEST=ON -DCMAKE_BUILD_TYPE=${{matrix.config.type}}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: lukka/get-cmake@latest
|
||||
with:
|
||||
cmakeVersion: 3.15
|
||||
|
||||
- name: CMake Build
|
||||
run: cmake --build build
|
||||
- name: Install build dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y xorg-dev
|
||||
|
||||
windows:
|
||||
name: ${{ matrix.config.name }}
|
||||
runs-on: ${{matrix.os}}
|
||||
- name: CMake Configure
|
||||
run: cmake -S. -B build -DCMAKE_BUILD_TYPE=${{matrix.type}} -DVK_BOOTSTRAP_WERROR=ON -DVK_BOOTSTRAP_TEST=ON
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
arch: [ Win32, x64 ]
|
||||
config: [ Debug, Release ]
|
||||
os: [windows-latest ]
|
||||
- name: CMake Build
|
||||
run: cmake --build build
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2.0.0
|
||||
- name: Install
|
||||
run: cmake --install build --prefix build/install
|
||||
|
||||
- name: CMake Configure
|
||||
run: cmake -Bbuild -DVK_BOOTSTRAP_WERROR=ON -DVK_BOOTSTRAP_TEST=ON -DCMAKE_BUILD_TYPE=${{matrix.config}}
|
||||
- name: Run tests
|
||||
working-directory: ./build
|
||||
run: ctest --output-on-failure -C ${{matrix.type}}
|
||||
|
||||
- name: CMake Build
|
||||
run: cmake --build build
|
||||
windows:
|
||||
name: Windows
|
||||
runs-on: windows-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
arch: [ Win32, x64 ]
|
||||
config: [ Debug, Release ]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: CMake Configure
|
||||
run: cmake -S. -B build -D CMAKE_BUILD_TYPE=${{matrix.config}} -D VK_BOOTSTRAP_WERROR=ON -D VK_BOOTSTRAP_TEST=ON -A ${{matrix.arch}}
|
||||
|
||||
- name: CMake Build
|
||||
run: cmake --build build
|
||||
|
||||
- name: Run tests
|
||||
working-directory: ./build
|
||||
run: ctest --output-on-failure -C ${{matrix.config}}
|
||||
|
@ -96,6 +96,7 @@ endif()
|
||||
option(VK_BOOTSTRAP_TEST "Test Vk-Bootstrap with glfw and Catch2" ${VK_BOOTSTRAP_TEST_DEFAULT_VALUE})
|
||||
|
||||
if(VK_BOOTSTRAP_TEST)
|
||||
enable_testing()
|
||||
add_subdirectory(ext)
|
||||
add_subdirectory(tests)
|
||||
add_subdirectory(example)
|
||||
|
@ -29,8 +29,7 @@ target_link_libraries(vk-bootstrap-test
|
||||
Catch2::Catch2WithMain
|
||||
)
|
||||
|
||||
# This should be how to make CTest aware of the tests, but unfortunately it fails to link. The tests run fine on their own, so this is left as a TODO
|
||||
# list(APPEND CMAKE_MODULE_PATH ${Catch2_SOURCE_DIR}/extras)
|
||||
# include(CTest)
|
||||
# include(Catch)
|
||||
# catch_discover_tests(vk-bootstrap-test)
|
||||
list(APPEND CMAKE_MODULE_PATH ${Catch2_SOURCE_DIR}/extras)
|
||||
include(CTest)
|
||||
include(Catch)
|
||||
catch_discover_tests(vk-bootstrap-test)
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "vulkan_mock.hpp"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
@ -14,7 +15,6 @@
|
||||
return reinterpret_cast<PFN_vkVoidFunction>(shim_##x); \
|
||||
}
|
||||
|
||||
|
||||
VulkanMock mock;
|
||||
|
||||
EXPORT_MACRO VulkanMock& get_vulkan_mock() {
|
||||
@ -80,7 +80,7 @@ VKAPI_ATTR VkResult VKAPI_CALL shim_vkCreateInstance([[maybe_unused]] const VkIn
|
||||
if (pInstance == nullptr) {
|
||||
return VK_ERROR_INITIALIZATION_FAILED;
|
||||
}
|
||||
*pInstance = reinterpret_cast<VkInstance>(0x0000ABCD);
|
||||
*pInstance = get_handle<VkInstance>(0x0000ABCDU);
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
VKAPI_ATTR void VKAPI_CALL shim_vkDestroyInstance(
|
||||
@ -93,7 +93,7 @@ VKAPI_ATTR VkResult VKAPI_CALL shim_vkCreateDebugUtilsMessengerEXT([[maybe_unuse
|
||||
if (instance == nullptr) {
|
||||
return VK_ERROR_INITIALIZATION_FAILED;
|
||||
}
|
||||
*pMessenger = reinterpret_cast<VkDebugUtilsMessengerEXT>(0xDEBE0000DEBE0000);
|
||||
*pMessenger = get_uint64_handle<VkDebugUtilsMessengerEXT>(0xDEBE0000DEBE0000U);
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
@ -176,7 +176,7 @@ VKAPI_ATTR VkResult VKAPI_CALL shim_vkCreateDevice(VkPhysicalDevice physicalDevi
|
||||
if (physicalDevice == nullptr) {
|
||||
return VK_ERROR_INITIALIZATION_FAILED;
|
||||
}
|
||||
*pDevice = reinterpret_cast<VkDevice>(0x00FEDC00);
|
||||
*pDevice = get_handle<VkDevice>(0x0000ABCDU);
|
||||
get_physical_device_details(physicalDevice).created_devices.push_back(*pDevice);
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
@ -197,7 +197,7 @@ VKAPI_ATTR void VKAPI_CALL shim_vkGetDeviceQueue(VkDevice device, uint32_t queue
|
||||
if (it != std::end(physical_devices.created_devices)) {
|
||||
if (queueFamilyIndex < physical_devices.queue_family_properties.size() &&
|
||||
queueIndex < physical_devices.queue_family_properties[queueFamilyIndex].queueCount) {
|
||||
*pQueue = reinterpret_cast<VkQueue>(0x0000CCEE);
|
||||
*pQueue = get_handle<VkQueue>(0x0000CCEEU);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -208,7 +208,7 @@ VKAPI_ATTR VkResult VKAPI_CALL shim_vkCreateCommandPool([[maybe_unused]] VkDevic
|
||||
[[maybe_unused]] const VkCommandPoolCreateInfo* pCreateInfo,
|
||||
[[maybe_unused]] const VkAllocationCallbacks* pAllocator,
|
||||
VkCommandPool* pCommandPool) {
|
||||
*pCommandPool = reinterpret_cast<VkCommandPool>(0x0000ABBB);
|
||||
*pCommandPool = get_uint64_handle<VkCommandPool>(0x0000ABBBU);
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
@ -216,7 +216,7 @@ VKAPI_ATTR VkResult VKAPI_CALL shim_vkCreateFence([[maybe_unused]] VkDevice devi
|
||||
[[maybe_unused]] const VkFenceCreateInfo* pCreateInfo,
|
||||
[[maybe_unused]] const VkAllocationCallbacks* pAllocator,
|
||||
VkFence* pFence) {
|
||||
*pFence = reinterpret_cast<VkFence>(0x0000AAAC);
|
||||
*pFence = get_uint64_handle<VkFence>(0x0000AAACU);
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
VKAPI_ATTR void VKAPI_CALL shim_vkDestroyFence(
|
||||
@ -226,15 +226,15 @@ VKAPI_ATTR VkResult VKAPI_CALL shim_vkCreateSwapchainKHR([[maybe_unused]] VkDevi
|
||||
[[maybe_unused]] const VkSwapchainCreateInfoKHR* pCreateInfo,
|
||||
[[maybe_unused]] const VkAllocationCallbacks* pAllocator,
|
||||
VkSwapchainKHR* pSwapchain) {
|
||||
*pSwapchain = reinterpret_cast<VkSwapchainKHR>(0x0000FFFE);
|
||||
*pSwapchain = get_uint64_handle<VkSwapchainKHR>(0x0000FFFEU);
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
VKAPI_ATTR VkResult VKAPI_CALL shim_vkGetSwapchainImagesKHR(
|
||||
[[maybe_unused]] VkDevice device, [[maybe_unused]] VkSwapchainKHR swapchain, uint32_t* pSwapchainImageCount, VkImage* pSwapchainImages) {
|
||||
|
||||
std::vector<VkImage> images = { reinterpret_cast<VkImage>(0x0000EDD0),
|
||||
reinterpret_cast<VkImage>(0x0000EDD1),
|
||||
reinterpret_cast<VkImage>(0x0000EDD1) };
|
||||
std::vector<VkImage> images{ get_uint64_handle<VkImage>(0x0000EDD0U),
|
||||
get_uint64_handle<VkImage>(0x0000EDD1U),
|
||||
get_uint64_handle<VkImage>(0x0000EDD1U) };
|
||||
return fill_out_count_pointer_pair(images, pSwapchainImageCount, pSwapchainImages);
|
||||
}
|
||||
|
||||
@ -242,7 +242,7 @@ VKAPI_ATTR VkResult VKAPI_CALL shim_vkCreateImageView([[maybe_unused]] VkDevice
|
||||
[[maybe_unused]] const VkImageViewCreateInfo* pCreateInfo,
|
||||
[[maybe_unused]] const VkAllocationCallbacks* pAllocator,
|
||||
VkImageView* pView) {
|
||||
if (pView) *pView = reinterpret_cast<VkImageView>(0x0000CCCE);
|
||||
if (pView) *pView = get_uint64_handle<VkImageView>(0x0000CCCEU);
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
@ -366,10 +366,13 @@ PFN_vkVoidFunction shim_vkGetInstanceProcAddr([[maybe_unused]] VkInstance instan
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
#if defined(WIN32)
|
||||
|
||||
EXPORT_MACRO VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char* pName) {
|
||||
#pragma comment(linker, "/EXPORT:" __FUNCTION__ "=" __FUNCDNAME__)
|
||||
return shim_vkGetInstanceProcAddr(instance, pName);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__GNU__)
|
||||
#define DLSYM_FUNC_NAME dlsym
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <assert.h>
|
||||
#include <cstdint>
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
@ -26,6 +27,14 @@ inline size_t get_pnext_chain_struct_size(VkStructureType type) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <typename T> T get_handle(size_t value) { return reinterpret_cast<T>(value); }
|
||||
|
||||
#if INTPTR_MAX == INT32_MAX
|
||||
template <typename T> uint64_t get_uint64_handle(uint64_t value) { return static_cast<T>(value); }
|
||||
#elif INTPTR_MAX == INT64_MAX
|
||||
template <typename T> T get_uint64_handle(uint64_t value) { return reinterpret_cast<T>(value); }
|
||||
#endif
|
||||
|
||||
struct VulkanMock {
|
||||
uint32_t api_version = VK_API_VERSION_1_3;
|
||||
std::vector<VkExtensionProperties> instance_extensions;
|
||||
@ -51,8 +60,8 @@ struct VulkanMock {
|
||||
std::vector<SurfaceDetails> surface_details;
|
||||
|
||||
VkSurfaceKHR get_new_surface(SurfaceDetails details) {
|
||||
size_t new_index = 0x123456789AB + surface_handles.size();
|
||||
surface_handles.push_back(reinterpret_cast<VkSurfaceKHR>(new_index));
|
||||
surface_handles.push_back(
|
||||
get_uint64_handle<VkSurfaceKHR>(static_cast<uint64_t>(0x123456789ABU + surface_handles.size())));
|
||||
surface_details.push_back(details);
|
||||
return surface_handles.back();
|
||||
}
|
||||
@ -78,8 +87,7 @@ struct VulkanMock {
|
||||
std::vector<PhysicalDeviceDetails> physical_devices_details;
|
||||
|
||||
void add_physical_device(PhysicalDeviceDetails details) {
|
||||
size_t new_index = 0x001122334455 + physical_device_handles.size();
|
||||
physical_device_handles.push_back(reinterpret_cast<VkPhysicalDevice>(new_index));
|
||||
physical_device_handles.push_back(get_handle<VkPhysicalDevice>(0x22334455U + physical_device_handles.size()));
|
||||
physical_devices_details.emplace_back(std::move(details));
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user