Added unit test for backtrace.
This commit is contained in:
parent
3830a9f580
commit
f09aec878e
@ -7,6 +7,7 @@ set(${MODULE_PREFIX}_DRIVER ${MODULE_NAME}.c)
|
||||
set(${MODULE_PREFIX}_TESTS
|
||||
TestIni.c
|
||||
TestImage.c
|
||||
TestBacktrace.c
|
||||
TestQueue.c
|
||||
TestPrint.c
|
||||
TestPubSub.c
|
||||
|
28
winpr/libwinpr/utils/test/TestBacktrace.c
Normal file
28
winpr/libwinpr/utils/test/TestBacktrace.c
Normal file
@ -0,0 +1,28 @@
|
||||
|
||||
#include <winpr/debug.h>
|
||||
|
||||
int TestBacktrace(int argc, char* argv[])
|
||||
{
|
||||
int rc = -1;
|
||||
size_t used, x;
|
||||
char **msg;
|
||||
void *stack = winpr_backtrace(20);
|
||||
if (!stack)
|
||||
{
|
||||
fprintf(stderr, "winpr_backtrace failed!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
msg = winpr_backtrace_symbols(stack, &used);
|
||||
if (msg)
|
||||
{
|
||||
for (x=0; x<used; x++)
|
||||
printf("%zd: %s\n", x, msg[x]);
|
||||
rc = 0;
|
||||
}
|
||||
winpr_backtrace_symbols_fd(stack, stdout);
|
||||
|
||||
winpr_backtrace_free(stack);
|
||||
|
||||
return rc;
|
||||
}
|
Loading…
Reference in New Issue
Block a user