Replaced assert() with new macro TEST() in all tests, to check conditions also in Release configuration.

This commit is contained in:
Adam Sawicki 2018-10-03 16:15:27 +02:00
parent 4868c1f523
commit a7d7769959
4 changed files with 227 additions and 198 deletions

View File

@ -16,6 +16,7 @@
#include <utility> #include <utility>
#include <chrono> #include <chrono>
#include <string> #include <string>
#include <exception>
#include <cassert> #include <cassert>
#include <cstdlib> #include <cstdlib>
@ -25,7 +26,21 @@
typedef std::chrono::high_resolution_clock::time_point time_point; typedef std::chrono::high_resolution_clock::time_point time_point;
typedef std::chrono::high_resolution_clock::duration duration; typedef std::chrono::high_resolution_clock::duration duration;
#define ERR_GUARD_VULKAN(Expr) do { VkResult res__ = (Expr); if (res__ < 0) assert(0); } while(0) #ifdef _DEBUG
#define TEST(expr) do { \
if(!(expr)) { \
assert(0 && #expr); \
} \
} while(0)
#else
#define TEST(expr) do { \
if(!(expr)) { \
throw std::runtime_error("TEST FAILED: " #expr); \
} \
} while(0)
#endif
#define ERR_GUARD_VULKAN(expr) TEST((expr) >= 0)
extern VkPhysicalDevice g_hPhysicalDevice; extern VkPhysicalDevice g_hPhysicalDevice;
extern VkDevice g_hDevice; extern VkDevice g_hDevice;

View File

@ -128,7 +128,7 @@ void SparseBindingImage::Init(RandomNumberGenerator& rand)
// But it doesn't help. Looks like a bug in Vulkan validation layers. // But it doesn't help. Looks like a bug in Vulkan validation layers.
uint32_t sparseMemReqCount = 0; uint32_t sparseMemReqCount = 0;
vkGetImageSparseMemoryRequirements(g_hDevice, m_Image, &sparseMemReqCount, nullptr); vkGetImageSparseMemoryRequirements(g_hDevice, m_Image, &sparseMemReqCount, nullptr);
assert(sparseMemReqCount <= 8); TEST(sparseMemReqCount <= 8);
VkSparseImageMemoryRequirements sparseMemReq[8]; VkSparseImageMemoryRequirements sparseMemReq[8];
vkGetImageSparseMemoryRequirements(g_hDevice, m_Image, &sparseMemReqCount, sparseMemReq); vkGetImageSparseMemoryRequirements(g_hDevice, m_Image, &sparseMemReqCount, sparseMemReq);

File diff suppressed because it is too large Load Diff

View File

@ -1767,10 +1767,24 @@ static LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
PostMessage(hWnd, WM_CLOSE, 0, 0); PostMessage(hWnd, WM_CLOSE, 0, 0);
break; break;
case 'T': case 'T':
Test(); try
{
Test();
}
catch(const std::exception& ex)
{
printf("ERROR: %s\n", ex.what());
}
break; break;
case 'S': case 'S':
TestSparseBinding(); try
{
TestSparseBinding();
}
catch(const std::exception& ex)
{
printf("ERROR: %s\n", ex.what());
}
break; break;
} }
return 0; return 0;