From f09aec878e6e83bfcc72c43fd56fc4780ebc6434 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Wed, 17 Sep 2014 17:30:04 +0200 Subject: [PATCH] Added unit test for backtrace. --- winpr/libwinpr/utils/test/CMakeLists.txt | 1 + winpr/libwinpr/utils/test/TestBacktrace.c | 28 +++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 winpr/libwinpr/utils/test/TestBacktrace.c diff --git a/winpr/libwinpr/utils/test/CMakeLists.txt b/winpr/libwinpr/utils/test/CMakeLists.txt index 199780d9b..b7a42fbd6 100644 --- a/winpr/libwinpr/utils/test/CMakeLists.txt +++ b/winpr/libwinpr/utils/test/CMakeLists.txt @@ -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 diff --git a/winpr/libwinpr/utils/test/TestBacktrace.c b/winpr/libwinpr/utils/test/TestBacktrace.c new file mode 100644 index 000000000..f26c83bb7 --- /dev/null +++ b/winpr/libwinpr/utils/test/TestBacktrace.c @@ -0,0 +1,28 @@ + +#include + +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