summaryrefslogtreecommitdiff
path: root/indra/test
diff options
context:
space:
mode:
Diffstat (limited to 'indra/test')
-rw-r--r--indra/test/CMakeLists.txt1
-rw-r--r--indra/test/io.cpp2
-rw-r--r--indra/test/llevents_tut.cpp1
-rw-r--r--indra/test/llhttpdate_tut.cpp7
-rw-r--r--indra/test/lltut.h2
-rw-r--r--indra/test/test.cpp79
6 files changed, 72 insertions, 20 deletions
diff --git a/indra/test/CMakeLists.txt b/indra/test/CMakeLists.txt
index 3dcddf9dc2..745c0eedf8 100644
--- a/indra/test/CMakeLists.txt
+++ b/indra/test/CMakeLists.txt
@@ -71,6 +71,7 @@ if (WINDOWS)
PROPERTIES
LINK_FLAGS "/NODEFAULTLIB:LIBCMT"
LINK_FLAGS_DEBUG "/NODEFAULTLIB:\"LIBCMT;LIBCMTD;MSVCRT\""
+ RUNTIME_OUTPUT_DIRECTORY "${EXE_STAGING_DIR}"
)
elseif (DARWIN)
# Support our "@executable_path/../Resources" load path for our test
diff --git a/indra/test/io.cpp b/indra/test/io.cpp
index 3bb549a98a..f77402065a 100644
--- a/indra/test/io.cpp
+++ b/indra/test/io.cpp
@@ -293,7 +293,7 @@ namespace tut
len = BUFFER_LEN;
last = mBuffer.readAfter(ch.in(), last, (U8*)buf, len);
char* newline = strchr((char*)buf, '\n');
- S32 offset = -((len - 1) - (newline - buf));
+ S32 offset = -((len - 1) - (S32)(newline - buf));
++newline;
*newline = '\0';
last_line.assign(buf);
diff --git a/indra/test/llevents_tut.cpp b/indra/test/llevents_tut.cpp
index 875ca9ad89..bf5cd3f853 100644
--- a/indra/test/llevents_tut.cpp
+++ b/indra/test/llevents_tut.cpp
@@ -44,7 +44,6 @@
#include <typeinfo>
// external library headers
#include <boost/bind.hpp>
-#include <boost/shared_ptr.hpp>
#include <boost/assign/list_of.hpp>
// other Linden headers
#include "tests/listener.h" // must PRECEDE lltut.h
diff --git a/indra/test/llhttpdate_tut.cpp b/indra/test/llhttpdate_tut.cpp
index a47602dec5..b580b09a9f 100644
--- a/indra/test/llhttpdate_tut.cpp
+++ b/indra/test/llhttpdate_tut.cpp
@@ -112,13 +112,8 @@ namespace tut
void httpdate_object::test<4>()
{
// test localization of http dates
-#if LL_WINDOWS
- const char *en_locale = "english";
- const char *fr_locale = "french";
-#else
- const char *en_locale = "en_GB.UTF-8";
+ const char *en_locale = "en_US.UTF-8";
const char *fr_locale = "fr_FR.UTF-8";
-#endif
std::string prev_locale = LLStringUtil::getLocale();
std::string prev_clocale = std::string(setlocale(LC_TIME, NULL));
diff --git a/indra/test/lltut.h b/indra/test/lltut.h
index e56b4e8d1c..581a08654d 100644
--- a/indra/test/lltut.h
+++ b/indra/test/lltut.h
@@ -135,7 +135,7 @@ namespace tut
inline void ensure_memory_matches(const void* actual, U32 actual_len, const void* expected,U32 expected_len)
{
- ensure_memory_matches(NULL, actual, actual_len, expected, expected_len);
+ ensure_memory_matches("", actual, actual_len, expected, expected_len);
}
template <class T,class Q>
diff --git a/indra/test/test.cpp b/indra/test/test.cpp
index cc2c130072..09147a65a3 100644
--- a/indra/test/test.cpp
+++ b/indra/test/test.cpp
@@ -36,7 +36,6 @@
#include "linden_common.h"
#include "llerrorcontrol.h"
-#include "llexception.h"
#include "lltut.h"
#include "chained_callback.h"
#include "stringize.h"
@@ -54,15 +53,15 @@
# include "ctype_workaround.h"
#endif
-#if LL_MSVC
-#pragma warning (push)
-#pragma warning (disable : 4702) // warning C4702: unreachable code
-#endif
#include <boost/iostreams/tee.hpp>
#include <boost/iostreams/stream.hpp>
-#if LL_MSVC
-#pragma warning (pop)
-#endif
+
+// On Mac, got:
+// #error "Boost.Stacktrace requires `_Unwind_Backtrace` function. Define
+// `_GNU_SOURCE` macro or `BOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED` if
+// _Unwind_Backtrace is available without `_GNU_SOURCE`."
+#define BOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED
+#include <boost/stacktrace.hpp>
#include <fstream>
@@ -103,7 +102,7 @@ public:
virtual void recordMessage(LLError::ELevel level, const std::string& message)
{
- LL_PROFILE_ZONE_SCOPED
+ LL_PROFILE_ZONE_SCOPED;
mFile << message << std::endl;
}
@@ -513,6 +512,64 @@ void wouldHaveCrashed(const std::string& message)
static LLTrace::ThreadRecorder* sMasterThreadRecorder = NULL;
+// this is used in platform-generic code -- define outside #if LL_WINDOWS
+struct Windows_SEH_exception: public std::runtime_error
+{
+ Windows_SEH_exception(const std::string& what): std::runtime_error(what) {}
+};
+
+#if LL_WINDOWS
+
+static constexpr U32 STATUS_MSC_EXCEPTION = 0xE06D7363; // compiler specific
+static constexpr U32 STATUS_STACK_FULL = 0xC00000FD;
+
+U32 seh_filter(U32 code, struct _EXCEPTION_POINTERS*)
+{
+ if (code == STATUS_MSC_EXCEPTION)
+ {
+ // C++ exception, go on -- but TUT is supposed to have caught those already?!
+ return EXCEPTION_CONTINUE_SEARCH;
+ }
+ else
+ {
+ // This is a non-C++ exception, e.g. hardware check.
+ // By the time the handler gets control, the stack has been unwound,
+ // so report the stack trace now at filter() time.
+ // Sadly, even though, at the time of this writing, stack overflow is
+ // the problem we would most like to diagnose, calling another
+ // function when the stack is already blown only terminates us faster.
+ if (code != STATUS_STACK_FULL)
+ {
+ std::cerr << boost::stacktrace::stacktrace() << std::endl;
+ }
+ // pass control into the handler block
+ return EXCEPTION_EXECUTE_HANDLER;
+ }
+}
+
+template <typename CALLABLE0, typename CALLABLE1>
+void seh_catcher(CALLABLE0&& trycode, CALLABLE1&& handler)
+{
+ __try
+ {
+ trycode();
+ }
+ __except (seh_filter(GetExceptionCode(), GetExceptionInformation()))
+ {
+ handler(GetExceptionCode());
+ }
+}
+
+#else // not LL_WINDOWS
+
+template <typename CALLABLE0, typename CALLABLE1>
+void seh_catcher(CALLABLE0&& trycode, CALLABLE1&&)
+{
+ trycode();
+}
+
+#endif // not LL_WINDOWS
+
int main(int argc, char **argv)
{
ll_init_apr();
@@ -645,7 +702,7 @@ int main(int argc, char **argv)
// a chained_callback subclass must be linked with previous
mycallback->link();
- LL::seh::catcher(
+ seh_catcher(
// __try
[test_group]
{
@@ -659,7 +716,7 @@ int main(int argc, char **argv)
}
},
// __except
- [mycallback](U32 code, const std::string& /*stacktrace*/)
+ [mycallback](U32 code)
{
static std::map<U32, const char*> codes = {
{ 0xC0000005, "Access Violation" },