mirror of
https://github.com/Kbz-8/Pulse.git
synced 2026-01-11 15:33:34 +00:00
adding stack trace to tests
This commit is contained in:
@@ -39,6 +39,8 @@ void TestPipelineSetup()
|
||||
CleanupPulse(backend);
|
||||
}
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
void TestPipelineReadOnlyBindings()
|
||||
{
|
||||
PulseBackend backend;
|
||||
@@ -50,6 +52,8 @@ void TestPipelineReadOnlyBindings()
|
||||
#include "Shaders/ReadOnlyBindings.spv.h"
|
||||
};
|
||||
|
||||
raise(SIGSEGV);
|
||||
|
||||
PulseBufferCreateInfo buffer_create_info = { 0 };
|
||||
buffer_create_info.size = 256 * sizeof(int32_t);
|
||||
buffer_create_info.usage = PULSE_BUFFER_USAGE_STORAGE_READ;
|
||||
|
||||
@@ -1,7 +1,37 @@
|
||||
#include <signal.h>
|
||||
#include <backtrace.h>
|
||||
#include <unity/unity.h>
|
||||
|
||||
#include <Pulse.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
struct backtrace_state* state = NULL;
|
||||
static size_t trace_count = 0;
|
||||
|
||||
void ErrorCallback(void* data, const char* msg, int errnum)
|
||||
{
|
||||
fprintf(stderr, "Error in backtrace: %s (error %d)\n", msg, errnum);
|
||||
}
|
||||
|
||||
int SymbolCallback(void* data, unsigned long pc, const char* filename, int lineno, const char* function)
|
||||
{
|
||||
if(filename && function)
|
||||
fprintf(stderr, "\t#%zu\033[1;34m 0x%lx\033[1;0m in\033[1;33m %s() from %s:%d\033[1;0m\n", trace_count, pc, function, filename, lineno);
|
||||
else if(function)
|
||||
fprintf(stderr, "\t#%zu\033[1;34m 0x%lx\033[1;0m in\033[1;33m %s() from unknown:unknown\033[1;0m\n", trace_count, pc, function);
|
||||
else
|
||||
fprintf(stderr, "\t#%zu\033[1;34m 0x%lx\033[1;0m in\033[1;33m ??\()\033[1;0m\n", trace_count, pc);
|
||||
trace_count++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SignalHandler(int sig)
|
||||
{
|
||||
fprintf(stderr, "\n==========================================================\nFatal error: %s.\n<Begin of stack trace>\n", sig == SIGSEGV ? "segmentation fault" : "aborted");
|
||||
trace_count = 0;
|
||||
backtrace_full(state, 0, SymbolCallback, ErrorCallback, NULL);
|
||||
fprintf(stderr, "<End of stack trace>\n==========================================================\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
extern void TestBackend();
|
||||
extern void TestDevice();
|
||||
@@ -11,6 +41,10 @@ extern void TestPipeline();
|
||||
|
||||
int main(void)
|
||||
{
|
||||
state = backtrace_create_state(NULL, 1, ErrorCallback, NULL);
|
||||
signal(SIGSEGV, SignalHandler);
|
||||
signal(SIGABRT, SignalHandler);
|
||||
|
||||
UNITY_BEGIN();
|
||||
TestBackend();
|
||||
TestDevice();
|
||||
@@ -19,3 +53,11 @@ int main(void)
|
||||
TestPipeline();
|
||||
return UNITY_END();
|
||||
}
|
||||
|
||||
/*
|
||||
#0 0x00007ffff79ad624 in ?? () from /usr/lib/libc.so.6
|
||||
#1 0x00007ffff7953ba0 in raise () from /usr/lib/libc.so.6
|
||||
#2 0x000055555560ec86 in TestPipelineReadOnlyBindings () at Tests/Vulkan/Pipeline.c:54
|
||||
#3 0x000055555560f682 in TestPipeline () at Tests/Vulkan/Pipeline.c:228
|
||||
#4 0x000055555560ea01 in main () at Tests/Vulkan/main.c:46
|
||||
*/
|
||||
|
||||
@@ -94,6 +94,10 @@ if has_config("vulkan-tests") then
|
||||
set_group("VulkanTests")
|
||||
add_requires("unity_test")
|
||||
|
||||
if is_plat("linux") then
|
||||
add_requires("libbacktrace")
|
||||
end
|
||||
|
||||
target("VulkanUnitTests")
|
||||
set_kind("binary")
|
||||
add_deps("pulse_gpu")
|
||||
@@ -102,6 +106,7 @@ if has_config("vulkan-tests") then
|
||||
add_files("**.nzsl")
|
||||
add_packages("unity_test")
|
||||
if is_plat("linux") then
|
||||
add_packages("libbacktrace")
|
||||
set_extension(".x86_64")
|
||||
end
|
||||
target_end()
|
||||
|
||||
Reference in New Issue
Block a user