summaryrefslogtreecommitdiff
path: root/indra/llcommon/tests
diff options
context:
space:
mode:
authorandreykproductengine <akleshchev@productengine.com>2015-04-29 15:28:21 +0300
committerandreykproductengine <akleshchev@productengine.com>2015-04-29 15:28:21 +0300
commit5f397bdd1831b1be593982ca8fc88dbe1a0cad07 (patch)
tree1d0b8a8973a30bf3c65f09da653b0e7c009053fd /indra/llcommon/tests
parent1382e9bae647d6b548cd9a1fc78339e5929ea202 (diff)
parentfde0868231a25b8c9ce03a86cb53f1738d35688d (diff)
Merge from viewer-release
Diffstat (limited to 'indra/llcommon/tests')
-rwxr-xr-xindra/llcommon/tests/lldependencies_test.cpp46
-rwxr-xr-xindra/llcommon/tests/llerror_test.cpp30
-rwxr-xr-xindra/llcommon/tests/lleventcoro_test.cpp1
-rwxr-xr-xindra/llcommon/tests/llframetimer_test.cpp33
-rwxr-xr-xindra/llcommon/tests/llleap_test.cpp27
-rwxr-xr-xindra/llcommon/tests/llprocess_test.cpp6
-rwxr-xr-xindra/llcommon/tests/llsdserialize_test.cpp41
-rwxr-xr-xindra/llcommon/tests/llstring_test.cpp4
8 files changed, 90 insertions, 98 deletions
diff --git a/indra/llcommon/tests/lldependencies_test.cpp b/indra/llcommon/tests/lldependencies_test.cpp
index 5395d785b6..b5e189a465 100755
--- a/indra/llcommon/tests/lldependencies_test.cpp
+++ b/indra/llcommon/tests/lldependencies_test.cpp
@@ -37,29 +37,14 @@
// associated header
#include "../lldependencies.h"
// other Linden headers
-#include "../test/lltut.h"
-
-using boost::assign::list_of;
#if LL_WINDOWS
#pragma warning (disable : 4675) // "resolved by ADL" -- just as I want!
#endif
-typedef LLDependencies<> StringDeps;
-typedef StringDeps::KeyList StringList;
-
-// We use the very cool boost::assign::list_of() construct to specify vectors
-// of strings inline. For reasons on which I'm not entirely clear, though, it
-// needs a helper function. You can use list_of() to construct an implicit
-// StringList (std::vector<std::string>) by conversion, e.g. for a function
-// parameter -- but if you simply write StringList(list_of("etc.")), you get
-// ambiguity errors. Shrug!
-template<typename CONTAINER>
-CONTAINER make(const CONTAINER& data)
-{
- return data;
-}
-
+/*****************************************************************************
+* Display helpers: must be defined BEFORE lltut.h!
+*****************************************************************************/
// Display an arbitary value as itself...
template<typename T>
std::ostream& display(std::ostream& out, const T& value)
@@ -113,6 +98,31 @@ std::ostream& operator<<(std::ostream& out, const std::set<ENTRY>& set)
return out;
}
+/*****************************************************************************
+* Now we can #include lltut.h
+*****************************************************************************/
+#include "../test/lltut.h"
+
+/*****************************************************************************
+* Other helpers
+*****************************************************************************/
+using boost::assign::list_of;
+
+typedef LLDependencies<> StringDeps;
+typedef StringDeps::KeyList StringList;
+
+// We use the very cool boost::assign::list_of() construct to specify vectors
+// of strings inline. For reasons on which I'm not entirely clear, though, it
+// needs a helper function. You can use list_of() to construct an implicit
+// StringList (std::vector<std::string>) by conversion, e.g. for a function
+// parameter -- but if you simply write StringList(list_of("etc.")), you get
+// ambiguity errors. Shrug!
+template<typename CONTAINER>
+CONTAINER make(const CONTAINER& data)
+{
+ return data;
+}
+
const std::string& extract_key(const LLDependencies<>::value_type& entry)
{
return entry.first;
diff --git a/indra/llcommon/tests/llerror_test.cpp b/indra/llcommon/tests/llerror_test.cpp
index a5aaff10c5..f51279e817 100755
--- a/indra/llcommon/tests/llerror_test.cpp
+++ b/indra/llcommon/tests/llerror_test.cpp
@@ -38,6 +38,9 @@
namespace
{
+#ifdef __clang__
+# pragma clang diagnostic ignored "-Wunused-function"
+#endif
void test_that_error_h_includes_enough_things_to_compile_a_message()
{
LL_INFOS() << "!" << LL_ENDL;
@@ -381,8 +384,6 @@ namespace
};
std::string logFromNamespace(bool id) { return Foo::logFromNamespace(id); }
- std::string logFromClassWithNoLogTypeMember(bool id) { ClassWithNoLogType c; return c.logFromMember(id); }
- std::string logFromClassWithNoLogTypeStatic(bool id) { return ClassWithNoLogType::logFromStatic(id); }
std::string logFromClassWithLogTypeMember(bool id) { ClassWithLogType c; return c.logFromMember(id); }
std::string logFromClassWithLogTypeStatic(bool id) { return ClassWithLogType::logFromStatic(id); }
@@ -393,8 +394,8 @@ namespace
if (n1 == std::string::npos)
{
std::stringstream ss;
- ss << message << ": " << "expected to find a copy of " << expected
- << " in actual " << actual;
+ ss << message << ": " << "expected to find a copy of '" << expected
+ << "' in actual '" << actual << "'";
throw tut::failure(ss.str().c_str());
}
}
@@ -435,9 +436,6 @@ namespace tut
testLogName(mRecorder, logFromStatic);
testLogName(mRecorder, logFromAnon);
testLogName(mRecorder, logFromNamespace);
- //testLogName(mRecorder, logFromClassWithNoLogTypeMember, "ClassWithNoLogType");
- //testLogName(mRecorder, logFromClassWithNoLogTypeStatic, "ClassWithNoLogType");
- // XXX: figure out what the exepcted response is for these
testLogName(mRecorder, logFromClassWithLogTypeMember, "ClassWithLogType");
testLogName(mRecorder, logFromClassWithLogTypeStatic, "ClassWithLogType");
}
@@ -457,11 +455,6 @@ namespace
return "bar";
}
- void uberLogger()
- {
- LL_INFOS() << "uber(" << outerLogger() << "," << innerLogger() << ")" << LL_ENDL;
- }
-
class LogWhileLogging
{
public:
@@ -494,17 +487,10 @@ namespace tut
ensure_message_contains(1, "outside(moo)");
ensure_message_count(2);
- uberLogger();
- ensure_message_contains(2, "inside");
- ensure_message_contains(3, "inside");
- ensure_message_contains(4, "outside(moo)");
- ensure_message_contains(5, "uber(bar,moo)");
- ensure_message_count(6);
-
metaLogger();
- ensure_message_contains(6, "logging");
- ensure_message_contains(7, "meta(baz)");
- ensure_message_count(8);
+ ensure_message_contains(2, "logging");
+ ensure_message_contains(3, "meta(baz)");
+ ensure_message_count(4);
}
template<> template<>
diff --git a/indra/llcommon/tests/lleventcoro_test.cpp b/indra/llcommon/tests/lleventcoro_test.cpp
index cb5e15eff2..2096807e53 100755
--- a/indra/llcommon/tests/lleventcoro_test.cpp
+++ b/indra/llcommon/tests/lleventcoro_test.cpp
@@ -94,7 +94,6 @@ using coroutines::coroutine;
template<typename Iter>
bool match(Iter first, Iter last, std::string match) {
std::string::iterator i = match.begin();
- i != match.end();
for(; (first != last) && (i != match.end()); ++i) {
if (*first != *i)
return false;
diff --git a/indra/llcommon/tests/llframetimer_test.cpp b/indra/llcommon/tests/llframetimer_test.cpp
index 8ac1c91a3a..be372bb855 100755
--- a/indra/llcommon/tests/llframetimer_test.cpp
+++ b/indra/llcommon/tests/llframetimer_test.cpp
@@ -84,25 +84,34 @@ namespace tut
template<> template<>
void frametimer_object_t::test<3>()
{
+ clock_t t1 = clock();
+ ms_sleep(200);
+ clock_t t2 = clock();
+ clock_t elapsed = t2 - t1 + 1;
+ std::cout << "Note: using clock(), ms_sleep() actually took " << (long)elapsed << "ms" << std::endl;
+
F64 seconds_since_epoch = LLFrameTimer::getTotalSeconds();
seconds_since_epoch += 2.0;
LLFrameTimer timer;
timer.setExpiryAt(seconds_since_epoch);
- ensure("timer not expired on create", !timer.hasExpired());
- int ii;
- for(ii = 0; ii < 10; ++ii)
+ /*
+ * Note that the ms_sleep(200) below is only guaranteed to return
+ * in 200ms _or_more_, so it should be true that by the 10th
+ * iteration we've gotten to the 2 seconds requested above
+ * and the timer should expire, but it can expire in fewer iterations
+ * if one or more of the ms_sleep calls takes longer.
+ * (as it did when we moved to Mac OS X 10.10)
+ */
+ int iterations_until_expiration = 0;
+ while ( !timer.hasExpired() )
{
- ms_sleep(150);
- LLFrameTimer::updateFrameTime();
- }
- ensure("timer not expired after a bit", !timer.hasExpired());
- for(ii = 0; ii < 10; ++ii)
- {
- ms_sleep(100);
- LLFrameTimer::updateFrameTime();
+ ms_sleep(200);
+ LLFrameTimer::updateFrameTime();
+ iterations_until_expiration++;
}
- ensure("timer expired", timer.hasExpired());
+ ensure("timer took too long to expire", iterations_until_expiration <= 10);
}
+
/*
template<> template<>
void frametimer_object_t::test<4>()
diff --git a/indra/llcommon/tests/llleap_test.cpp b/indra/llcommon/tests/llleap_test.cpp
index 9ea822cb8d..2d88e2c676 100755
--- a/indra/llcommon/tests/llleap_test.cpp
+++ b/indra/llcommon/tests/llleap_test.cpp
@@ -17,7 +17,7 @@
// std headers
// external library headers
#include <boost/assign/list_of.hpp>
-#include <boost/lambda/lambda.hpp>
+#include <boost/phoenix/core/argument.hpp>
#include <boost/foreach.hpp>
// other Linden headers
#include "../test/lltut.h"
@@ -38,24 +38,7 @@ StringVec sv(const StringVec& listof) { return listof; }
#define sleep(secs) _sleep((secs) * 1000)
#endif
-#if ! LL_WINDOWS
const size_t BUFFERED_LENGTH = 1023*1024; // try wrangling just under a megabyte of data
-#else
-// "Then there's Windows... sigh." The "very large message" test is flaky in a
-// way that seems to point to either the OS (nonblocking writes to pipes) or
-// possibly the apr_file_write() function. Poring over log messages reveals
-// that at some point along the way apr_file_write() returns 11 (Resource
-// temporarily unavailable, i.e. EAGAIN) and says it wrote 0 bytes -- even
-// though it did write the chunk! Our next write attempt retries the same
-// chunk, resulting in the chunk being duplicated at the child end, corrupting
-// the data stream. Much as I would love to be able to fix it for real, such a
-// fix would appear to require distinguishing bogus EAGAIN returns from real
-// ones -- how?? Empirically this behavior is only observed when writing a
-// "very large message". To be able to move forward at all, try to bypass this
-// particular failure by adjusting the size of a "very large message" on
-// Windows.
-const size_t BUFFERED_LENGTH = 65336;
-#endif // LL_WINDOWS
void waitfor(const std::vector<LLLeap*>& instances, int timeout=60)
{
@@ -109,7 +92,7 @@ namespace tut
llleap_data():
reader(".py",
// This logic is adapted from vita.viewerclient.receiveEvent()
- boost::lambda::_1 <<
+ boost::phoenix::placeholders::arg1 <<
"import re\n"
"import os\n"
"import sys\n"
@@ -403,7 +386,7 @@ namespace tut
AckAPI api;
Result result;
NamedTempFile script("py",
- boost::lambda::_1 <<
+ boost::phoenix::placeholders::arg1 <<
"from " << reader_module << " import *\n"
// make a request on our little API
"request(pump='" << api.getName() << "', data={})\n"
@@ -441,7 +424,7 @@ namespace tut
ReqIDAPI api;
Result result;
NamedTempFile script("py",
- boost::lambda::_1 <<
+ boost::phoenix::placeholders::arg1 <<
"import sys\n"
"from " << reader_module << " import *\n"
// Note that since reader imports llsd, this
@@ -484,7 +467,7 @@ namespace tut
ReqIDAPI api;
Result result;
NamedTempFile script("py",
- boost::lambda::_1 <<
+ boost::phoenix::placeholders::arg1 <<
"import sys\n"
"from " << reader_module << " import *\n"
// Generate a very large string value.
diff --git a/indra/llcommon/tests/llprocess_test.cpp b/indra/llcommon/tests/llprocess_test.cpp
index e4e766d51b..5ba343b183 100755
--- a/indra/llcommon/tests/llprocess_test.cpp
+++ b/indra/llcommon/tests/llprocess_test.cpp
@@ -85,7 +85,7 @@ static std::string readfile(const std::string& pathname, const std::string& desc
}
std::ifstream inf(pathname.c_str());
std::string output;
- tut::ensure(STRINGIZE("No output " << use_desc), std::getline(inf, output));
+ tut::ensure(STRINGIZE("No output " << use_desc), bool(std::getline(inf, output)));
std::string more;
while (std::getline(inf, more))
{
@@ -154,7 +154,7 @@ struct PythonProcessLauncher
void launch()
{
mPy = LLProcess::create(mParams);
- tut::ensure(STRINGIZE("Couldn't launch " << mDesc << " script"), mPy);
+ tut::ensure(STRINGIZE("Couldn't launch " << mDesc << " script"), bool(mPy));
}
/// Run Python script and wait for it to complete.
@@ -873,7 +873,7 @@ namespace tut
std::string threw; \
/* Both the following calls should work. */ \
(PROCESS).GETPIPE(VALID); \
- ensure(#GETOPTPIPE "(" #VALID ") failed", (PROCESS).GETOPTPIPE(VALID)); \
+ ensure(#GETOPTPIPE "(" #VALID ") failed", bool((PROCESS).GETOPTPIPE(VALID))); \
/* pass obviously bogus PIPESLOT */ \
CATCH_IN(threw, LLProcess::NoPipe, (PROCESS).GETPIPE(LLProcess::FILESLOT(4))); \
ensure_contains("didn't reject bad slot", threw, "no slot"); \
diff --git a/indra/llcommon/tests/llsdserialize_test.cpp b/indra/llcommon/tests/llsdserialize_test.cpp
index b5893135ea..6fbb9abfc0 100755
--- a/indra/llcommon/tests/llsdserialize_test.cpp
+++ b/indra/llcommon/tests/llsdserialize_test.cpp
@@ -46,9 +46,10 @@ typedef U32 uint32_t;
#include "boost/range.hpp"
#include "boost/foreach.hpp"
#include "boost/function.hpp"
-#include "boost/lambda/lambda.hpp"
-#include "boost/lambda/bind.hpp"
-namespace lambda = boost::lambda;
+#include "boost/bind.hpp"
+#include "boost/phoenix/bind/bind_function.hpp"
+#include "boost/phoenix/core/argument.hpp"
+using namespace boost::phoenix;
#include "../llsd.h"
#include "../llsdserialize.h"
@@ -1612,6 +1613,20 @@ namespace tut
"print 'Running on', sys.platform\n");
}
+ // helper for test<3>
+ static void writeLLSDArray(std::ostream& out, const LLSD& array)
+ {
+ BOOST_FOREACH(LLSD item, llsd::inArray(array))
+ {
+ LLSDSerialize::toNotation(item, out);
+ // It's important to separate with newlines because Python's llsd
+ // module doesn't support parsing from a file stream, only from a
+ // string, so we have to know how much of the file to read into a
+ // string.
+ out << '\n';
+ }
+ }
+
template<> template<>
void TestPythonCompatibleObject::test<3>()
{
@@ -1639,26 +1654,16 @@ namespace tut
" assert False, 'Too many data items'\n";
// Create an llsdXXXXXX file containing 'data' serialized to
- // notation. It's important to separate with newlines because Python's
- // llsd module doesn't support parsing from a file stream, only from a
- // string, so we have to know how much of the file to read into a
- // string.
+ // notation.
NamedTempFile file("llsd",
// NamedTempFile's boost::function constructor
// takes a callable. To this callable it passes the
// std::ostream with which it's writing the
- // NamedTempFile. This lambda-based expression
- // first calls LLSD::Serialize() with that ostream,
- // then streams a newline to it, etc.
- (lambda::bind(LLSDSerialize::toNotation, cdata[0], lambda::_1),
- lambda::_1 << '\n',
- lambda::bind(LLSDSerialize::toNotation, cdata[1], lambda::_1),
- lambda::_1 << '\n',
- lambda::bind(LLSDSerialize::toNotation, cdata[2], lambda::_1),
- lambda::_1 << '\n'));
+ // NamedTempFile.
+ boost::bind(writeLLSDArray, _1, cdata));
python("read C++ notation",
- lambda::_1 <<
+ placeholders::arg1 <<
import_llsd <<
"def parse_each(iterable):\n"
" for item in iterable:\n"
@@ -1679,7 +1684,7 @@ namespace tut
NamedTempFile file("llsd", "");
python("write Python notation",
- lambda::_1 <<
+ placeholders::arg1 <<
"from __future__ import with_statement\n" <<
import_llsd <<
"DATA = [\n"
diff --git a/indra/llcommon/tests/llstring_test.cpp b/indra/llcommon/tests/llstring_test.cpp
index 93d3968dbf..a7aa347222 100755
--- a/indra/llcommon/tests/llstring_test.cpp
+++ b/indra/llcommon/tests/llstring_test.cpp
@@ -27,11 +27,11 @@
*/
#include "linden_common.h"
-#include "../test/lltut.h"
#include <boost/assign/list_of.hpp>
#include "../llstring.h"
-#include "StringVec.h"
+#include "StringVec.h" // must come BEFORE lltut.h
+#include "../test/lltut.h"
using boost::assign::list_of;