about summary refs log tree commit diff homepage
path: root/unittests
diff options
context:
space:
mode:
authorJulian Büning <julian.buening@rwth-aachen.de>2022-01-04 20:39:47 +0100
committerMartinNowack <2443641+MartinNowack@users.noreply.github.com>2022-01-05 20:22:12 +0000
commit62e27ff8cad97c12f3051a5fdcf8cd4aade96894 (patch)
treee718b5182beaf2887d06fba00f2f8be9bd265ec4 /unittests
parentacb90dc2d8cdf104740099a2d8773f5022194622 (diff)
downloadklee-62e27ff8cad97c12f3051a5fdcf8cd4aade96894.tar.gz
unittests/TestMain: show stack trace on error
Diffstat (limited to 'unittests')
-rw-r--r--unittests/CMakeLists.txt12
-rw-r--r--unittests/TestMain.cpp13
2 files changed, 23 insertions, 2 deletions
diff --git a/unittests/CMakeLists.txt b/unittests/CMakeLists.txt
index d21e6ad2..faf43a44 100644
--- a/unittests/CMakeLists.txt
+++ b/unittests/CMakeLists.txt
@@ -174,11 +174,21 @@ message(STATUS "GTEST_INCLUDE_DIR: ${GTEST_INCLUDE_DIR}")
 
 add_library(unittest_main)
 target_sources(unittest_main PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/TestMain.cpp")
-target_link_libraries(unittest_main PUBLIC gtest)
+klee_get_llvm_libs(UNITTEST_MAIN_LIBS Support)
+target_link_libraries(unittest_main
+  PUBLIC
+  gtest
+
+  PRIVATE
+  ${UNITTEST_MAIN_LIBS}
+)
 target_include_directories(unittest_main
   PUBLIC
   ${GTEST_INCLUDE_DIR}
   ${KLEE_COMPONENT_EXTRA_INCLUDE_DIRS}
+
+  PRIVATE
+  ${LLVM_INCLUDE_DIRS}
 )
 target_compile_definitions(unittest_main PUBLIC ${KLEE_COMPONENT_CXX_DEFINES})
 target_compile_options(unittest_main PUBLIC ${KLEE_COMPONENT_CXX_FLAGS})
diff --git a/unittests/TestMain.cpp b/unittests/TestMain.cpp
index 4f43342f..42dd721a 100644
--- a/unittests/TestMain.cpp
+++ b/unittests/TestMain.cpp
@@ -7,10 +7,21 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "gtest/gtest.h"
+#include "klee/Config/Version.h"
+
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Signals.h"
 
+#include "gtest/gtest.h"
 
 int main(int argc, char **argv) {
+
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 9)
+  llvm::sys::PrintStackTraceOnErrorSignal(argv[0], true);
+#else
+  llvm::sys::PrintStackTraceOnErrorSignal(true);
+#endif
+
   testing::InitGoogleTest(&argc, argv);
   return RUN_ALL_TESTS();
 }