Added unit test for backtrace.

This commit is contained in:
Armin Novak 2014-09-17 17:30:04 +02:00
parent 3830a9f580
commit f09aec878e
2 changed files with 29 additions and 0 deletions

View File

@ -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

View 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;
}