diff options
Diffstat (limited to 'indra/llcommon/tests')
-rw-r--r-- | indra/llcommon/tests/commonmisc_test.cpp | 6 | ||||
-rw-r--r-- | indra/llcommon/tests/lleventcoro_test.cpp | 2 | ||||
-rw-r--r-- | indra/llcommon/tests/lleventfilter_test.cpp | 14 | ||||
-rw-r--r-- | indra/llcommon/tests/llinstancetracker_test.cpp | 2 | ||||
-rw-r--r-- | indra/llcommon/tests/llprocess_test.cpp | 148 | ||||
-rw-r--r-- | indra/llcommon/tests/llsdserialize_test.cpp | 2 | ||||
-rw-r--r-- | indra/llcommon/tests/lltrace_test.cpp | 4 | ||||
-rw-r--r-- | indra/llcommon/tests/llunits_test.cpp | 2 |
8 files changed, 106 insertions, 74 deletions
diff --git a/indra/llcommon/tests/commonmisc_test.cpp b/indra/llcommon/tests/commonmisc_test.cpp index 0057a1f639..b1a284225e 100644 --- a/indra/llcommon/tests/commonmisc_test.cpp +++ b/indra/llcommon/tests/commonmisc_test.cpp @@ -46,12 +46,6 @@ #include "../test/lltut.h" - -#if LL_WINDOWS -// disable overflow warnings -#pragma warning(disable: 4307) -#endif - namespace tut { struct sd_data diff --git a/indra/llcommon/tests/lleventcoro_test.cpp b/indra/llcommon/tests/lleventcoro_test.cpp index a3c54ffaa2..ab174a8bde 100644 --- a/indra/llcommon/tests/lleventcoro_test.cpp +++ b/indra/llcommon/tests/lleventcoro_test.cpp @@ -30,8 +30,6 @@ #include <boost/bind.hpp> #include <boost/range.hpp> #include <boost/utility.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/make_shared.hpp> #include "linden_common.h" diff --git a/indra/llcommon/tests/lleventfilter_test.cpp b/indra/llcommon/tests/lleventfilter_test.cpp index a01d7fe415..d7b80e2545 100644 --- a/indra/llcommon/tests/lleventfilter_test.cpp +++ b/indra/llcommon/tests/lleventfilter_test.cpp @@ -81,13 +81,13 @@ class TestEventThrottle: public LLEventThrottleBase public: TestEventThrottle(F32 interval): LLEventThrottleBase(interval), - mAlarmRemaining(-1), - mTimerRemaining(-1) + mAlarmRemaining(-1.f), + mTimerRemaining(-1.f) {} TestEventThrottle(LLEventPump& source, F32 interval): LLEventThrottleBase(source, interval), - mAlarmRemaining(-1), - mTimerRemaining(-1) + mAlarmRemaining(-1.f), + mTimerRemaining(-1.f) {} /*----- implementation of LLEventThrottleBase timing functionality -----*/ @@ -100,12 +100,12 @@ public: virtual bool alarmRunning() const /*override*/ { // decrementing to exactly 0 should mean the alarm fires - return mAlarmRemaining > 0; + return mAlarmRemaining > 0.f; } virtual void alarmCancel() /*override*/ { - mAlarmRemaining = -1; + mAlarmRemaining = -1.f; } virtual void timerSet(F32 interval) /*override*/ @@ -116,7 +116,7 @@ public: virtual F32 timerGetRemaining() const /*override*/ { // LLTimer.getRemainingTimeF32() never returns negative; 0.0 means expired - return (mTimerRemaining > 0.0)? mTimerRemaining : 0.0; + return (mTimerRemaining > 0.0f)? mTimerRemaining : 0.0f; } /*------------------- methods for manipulating time --------------------*/ diff --git a/indra/llcommon/tests/llinstancetracker_test.cpp b/indra/llcommon/tests/llinstancetracker_test.cpp index c6eb0fdf75..bf661dc051 100644 --- a/indra/llcommon/tests/llinstancetracker_test.cpp +++ b/indra/llcommon/tests/llinstancetracker_test.cpp @@ -37,8 +37,6 @@ #include <algorithm> // std::sort() #include <stdexcept> // std headers -// external library headers -#include <boost/scoped_ptr.hpp> // other Linden headers #include "../test/lltut.h" diff --git a/indra/llcommon/tests/llprocess_test.cpp b/indra/llcommon/tests/llprocess_test.cpp index 6e8422ca0c..b63cc52bec 100644 --- a/indra/llcommon/tests/llprocess_test.cpp +++ b/indra/llcommon/tests/llprocess_test.cpp @@ -1085,7 +1085,27 @@ namespace tut return false; } - std::list<LLSD> mHistory; + template <typename CALLABLE> + void checkHistory(CALLABLE&& code) + { + try + { + // we expect this lambda to contain tut::ensure() calls + std::forward<CALLABLE>(code)(mHistory); + } + catch (const failure&) + { + LL_INFOS() << "event history:" << LL_ENDL; + for (const LLSD& item : mHistory) + { + LL_INFOS() << item << LL_ENDL; + } + throw; + } + } + + using Listory = std::list<LLSD>; + Listory mHistory; LLTempBoundListener mConnection; }; @@ -1136,23 +1156,26 @@ namespace tut // finish out the run waitfor(*py.mPy); // now verify history - std::list<LLSD>::const_iterator li(listener.mHistory.begin()), - lend(listener.mHistory.end()); - ensure("no events", li != lend); - ensure_equals("history[0]", (*li)["data"].asString(), "abc"); - ensure_equals("history[0] len", (*li)["len"].asInteger(), 3); - ++li; - ensure("only 1 event", li != lend); - ensure_equals("history[1]", (*li)["data"].asString(), "abcdef"); - ensure_equals("history[0] len", (*li)["len"].asInteger(), 6); - ++li; - ensure("only 2 events", li != lend); - ensure_equals("history[2]", (*li)["data"].asString(), "abcdefghi" EOL); - ensure_equals("history[0] len", (*li)["len"].asInteger(), 9 + sizeof(EOL) - 1); - ++li; - // We DO NOT expect a whole new event for the second line because we - // disconnected. - ensure("more than 3 events", li == lend); + listener.checkHistory( + [](const EventListener::Listory& history) + { + auto li(history.begin()), lend(history.end()); + ensure("no events", li != lend); + ensure_equals("history[0]", (*li)["data"].asString(), "abc"); + ensure_equals("history[0] len", (*li)["len"].asInteger(), 3); + ++li; + ensure("only 1 event", li != lend); + ensure_equals("history[1]", (*li)["data"].asString(), "abcdef"); + ensure_equals("history[0] len", (*li)["len"].asInteger(), 6); + ++li; + ensure("only 2 events", li != lend); + ensure_equals("history[2]", (*li)["data"].asString(), "abcdefghi" EOL); + ensure_equals("history[0] len", (*li)["len"].asInteger(), 9 + sizeof(EOL) - 1); + ++li; + // We DO NOT expect a whole new event for the second line because we + // disconnected. + ensure("more than 3 events", li == lend); + }); } template<> template<> @@ -1172,14 +1195,17 @@ namespace tut // (or any other intervening layer) does crazy buffering. What we want // to ensure is that there was exactly ONE event with "eof" true, and // that it was the LAST event. - std::list<LLSD>::const_reverse_iterator rli(listener.mHistory.rbegin()), - rlend(listener.mHistory.rend()); - ensure("no events", rli != rlend); - ensure("last event not \"eof\"", (*rli)["eof"].asBoolean()); - while (++rli != rlend) - { - ensure("\"eof\" event not last", ! (*rli)["eof"].asBoolean()); - } + listener.checkHistory( + [](const EventListener::Listory& history) + { + auto rli(history.rbegin()), rlend(history.rend()); + ensure("no events", rli != rlend); + ensure("last event not \"eof\"", (*rli)["eof"].asBoolean()); + while (++rli != rlend) + { + ensure("\"eof\" event not last", ! (*rli)["eof"].asBoolean()); + } + }); } template<> template<> @@ -1202,13 +1228,17 @@ namespace tut ensure_equals("getLimit() after setlimit(10)", childout.getLimit(), 10); // okay, pump I/O to pick up output from child waitfor(*py.mPy); - ensure("no events", ! listener.mHistory.empty()); - // For all we know, that data could have arrived in several different - // bursts... probably not, but anyway, only check the last one. - ensure_equals("event[\"len\"]", - listener.mHistory.back()["len"].asInteger(), abc.length()); - ensure_equals("length of setLimit(10) data", - listener.mHistory.back()["data"].asString().length(), 10); + listener.checkHistory( + [abc](const EventListener::Listory& history) + { + ensure("no events", ! history.empty()); + // For all we know, that data could have arrived in several different + // bursts... probably not, but anyway, only check the last one. + ensure_equals("event[\"len\"]", + history.back()["len"].asInteger(), abc.length()); + ensure_equals("length of setLimit(10) data", + history.back()["data"].asString().length(), 10); + }); } template<> template<> @@ -1275,18 +1305,22 @@ namespace tut params.postend = pumpname; LLProcessPtr child = LLProcess::create(params); ensure("shouldn't have launched", ! child); - ensure_equals("number of postend events", listener.mHistory.size(), 1); - LLSD postend(listener.mHistory.front()); - ensure("has id", ! postend.has("id")); - ensure_equals("desc", postend["desc"].asString(), std::string(params.desc)); - ensure_equals("state", postend["state"].asInteger(), LLProcess::UNSTARTED); - ensure("has data", ! postend.has("data")); - std::string error(postend["string"]); - // All we get from canned parameter validation is a bool, so the - // "validation failed" message we ourselves generate can't mention - // "executable" by name. Just check that it's nonempty. - //ensure_contains("error", error, "executable"); - ensure("string", ! error.empty()); + listener.checkHistory( + [¶ms](const EventListener::Listory& history) + { + ensure_equals("number of postend events", history.size(), 1); + LLSD postend(history.front()); + ensure("has id", ! postend.has("id")); + ensure_equals("desc", postend["desc"].asString(), std::string(params.desc)); + ensure_equals("state", postend["state"].asInteger(), LLProcess::UNSTARTED); + ensure("has data", ! postend.has("data")); + std::string error(postend["string"]); + // All we get from canned parameter validation is a bool, so the + // "validation failed" message we ourselves generate can't mention + // "executable" by name. Just check that it's nonempty. + //ensure_contains("error", error, "executable"); + ensure("string", ! error.empty()); + }); } template<> template<> @@ -1308,16 +1342,20 @@ namespace tut { yield(); } - ensure("no postend event", i < timeout); - ensure_equals("number of postend events", listener.mHistory.size(), 1); - LLSD postend(listener.mHistory.front()); - ensure_equals("id", postend["id"].asInteger(), childid); - ensure("desc empty", ! postend["desc"].asString().empty()); - ensure_equals("state", postend["state"].asInteger(), LLProcess::EXITED); - ensure_equals("data", postend["data"].asInteger(), 35); - std::string str(postend["string"]); - ensure_contains("string", str, "exited"); - ensure_contains("string", str, "35"); + listener.checkHistory( + [i, timeout, childid](const EventListener::Listory& history) + { + ensure("no postend event", i < timeout); + ensure_equals("number of postend events", history.size(), 1); + LLSD postend(history.front()); + ensure_equals("id", postend["id"].asInteger(), childid); + ensure("desc empty", ! postend["desc"].asString().empty()); + ensure_equals("state", postend["state"].asInteger(), LLProcess::EXITED); + ensure_equals("data", postend["data"].asInteger(), 35); + std::string str(postend["string"]); + ensure_contains("string", str, "exited"); + ensure_contains("string", str, "35"); + }); } struct PostendListener diff --git a/indra/llcommon/tests/llsdserialize_test.cpp b/indra/llcommon/tests/llsdserialize_test.cpp index fb2af1d2db..fae9f7023f 100644 --- a/indra/llcommon/tests/llsdserialize_test.cpp +++ b/indra/llcommon/tests/llsdserialize_test.cpp @@ -1809,7 +1809,7 @@ namespace tut std::string q("\""); std::string qPYTHON(q + PYTHON + q); std::string qscript(q + scriptfile.getName() + q); - int rc = _spawnl(_P_WAIT, PYTHON.c_str(), qPYTHON.c_str(), qscript.c_str(), + int rc = (int)_spawnl(_P_WAIT, PYTHON.c_str(), qPYTHON.c_str(), qscript.c_str(), std::forward<ARGS>(args)..., NULL); if (rc == -1) { diff --git a/indra/llcommon/tests/lltrace_test.cpp b/indra/llcommon/tests/lltrace_test.cpp index 8851f87b91..923a67ac8e 100644 --- a/indra/llcommon/tests/lltrace_test.cpp +++ b/indra/llcommon/tests/lltrace_test.cpp @@ -32,6 +32,10 @@ #include "lltracerecording.h" #include "../test/lltut.h" +#ifdef LL_WINDOWS +#pragma warning(disable : 4244) // possible loss of data on conversions +#endif + namespace LLUnits { // using powers of 2 to allow strict floating point equality diff --git a/indra/llcommon/tests/llunits_test.cpp b/indra/llcommon/tests/llunits_test.cpp index 49f2d3085a..98a58eb47e 100644 --- a/indra/llcommon/tests/llunits_test.cpp +++ b/indra/llcommon/tests/llunits_test.cpp @@ -262,7 +262,7 @@ namespace tut F32 float_val = quatloos_implicit; ensure("implicit units convert implicitly to regular values", float_val == 16); - S32 int_val = quatloos_implicit; + S32 int_val = (S32)quatloos_implicit; ensure("implicit units convert implicitly to regular values", int_val == 16); // conversion of implicits |