summaryrefslogtreecommitdiff
path: root/indra/llcommon/tests
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcommon/tests')
-rw-r--r--indra/llcommon/tests/llerror_test.cpp247
-rw-r--r--indra/llcommon/tests/lleventfilter_test.cpp14
-rw-r--r--indra/llcommon/tests/llleap_test.cpp3
-rw-r--r--indra/llcommon/tests/llmainthreadtask_test.cpp4
-rw-r--r--indra/llcommon/tests/llprocess_test.cpp3
-rw-r--r--indra/llcommon/tests/llsdserialize_test.cpp5
6 files changed, 166 insertions, 110 deletions
diff --git a/indra/llcommon/tests/llerror_test.cpp b/indra/llcommon/tests/llerror_test.cpp
index b4cdbdc6bf..63d5bdbb70 100644
--- a/indra/llcommon/tests/llerror_test.cpp
+++ b/indra/llcommon/tests/llerror_test.cpp
@@ -112,10 +112,10 @@ namespace tut
mMessages.push_back(message);
}
- int countMessages() { return (int) mMessages.size(); }
+ int countMessages() const { return (int) mMessages.size(); }
void clearMessages() { mMessages.clear(); }
- std::string message(int n)
+ std::string message(int n) const
{
std::ostringstream test_name;
test_name << "testing message " << n << ", not enough messages";
@@ -124,6 +124,16 @@ namespace tut
return mMessages[n];
}
+ void reportMessages() const
+ {
+ std::cerr << '\n';
+ int n = 0;
+ for (const auto& msg : mMessages)
+ {
+ std::cerr << std::setw(2) << n++ << ": " << msg.substr(0, 100) << '\n';
+ }
+ }
+
private:
typedef std::vector<std::string> MessageVector;
MessageVector mMessages;
@@ -134,6 +144,8 @@ namespace tut
LLError::RecorderPtr mRecorder;
LLError::SettingsStoragePtr mPriorErrorSettings;
+ auto recorder() { return std::dynamic_pointer_cast<TestRecorder>(mRecorder); }
+
ErrorTestData():
mRecorder(new TestRecorder())
{
@@ -153,27 +165,32 @@ namespace tut
int countMessages()
{
- return std::dynamic_pointer_cast<TestRecorder>(mRecorder)->countMessages();
+ return recorder()->countMessages();
}
void clearMessages()
{
- std::dynamic_pointer_cast<TestRecorder>(mRecorder)->clearMessages();
+ recorder()->clearMessages();
}
void setWantsTime(bool t)
- {
- std::dynamic_pointer_cast<TestRecorder>(mRecorder)->showTime(t);
- }
+ {
+ recorder()->showTime(t);
+ }
void setWantsMultiline(bool t)
- {
- std::dynamic_pointer_cast<TestRecorder>(mRecorder)->showMultiline(t);
- }
+ {
+ recorder()->showMultiline(t);
+ }
std::string message(int n)
{
- return std::dynamic_pointer_cast<TestRecorder>(mRecorder)->message(n);
+ return recorder()->message(n);
+ }
+
+ void reportMessages()
+ {
+ recorder()->reportMessages();
}
void ensure_message_count(int expectedCount)
@@ -181,71 +198,87 @@ namespace tut
ensure_equals("message count", countMessages(), expectedCount);
}
- std::string message_field(int msgnum, LogFieldIndex fieldnum)
- {
- std::ostringstream test_name;
- test_name << "testing message " << msgnum << ", not enough messages";
- tut::ensure(test_name.str(), msgnum < countMessages());
-
- std::string msg(message(msgnum));
-
- std::string field_value;
-
- // find the start of the field; fields are separated by a single space
- size_t scan = 0;
- int on_field = 0;
- while ( scan < msg.length() && on_field < fieldnum )
- {
- // fields are delimited by one space
- if ( ' ' == msg[scan] )
- {
- if ( on_field < FUNCTION_FIELD )
- {
- on_field++;
- }
- // except function, which may have embedded spaces so ends with " : "
- else if ( ( on_field == FUNCTION_FIELD )
- && ( ':' == msg[scan+1] && ' ' == msg[scan+2] )
- )
- {
- on_field++;
- scan +=2;
- }
- }
- scan++;
- }
- size_t start_field = scan;
- size_t fieldlen = 0;
- if ( fieldnum < FUNCTION_FIELD )
- {
- fieldlen = msg.find(' ', start_field) - start_field;
- }
- else if ( fieldnum == FUNCTION_FIELD )
- {
- fieldlen = msg.find(" : ", start_field) - start_field;
- }
- else if ( MSG_FIELD == fieldnum ) // no delimiter, just everything to the end
- {
- fieldlen = msg.length() - start_field;
- }
-
- return msg.substr(start_field, fieldlen);
- }
-
+ std::string message_field(int msgnum, LogFieldIndex fieldnum)
+ {
+ std::ostringstream test_name;
+ test_name << "testing message " << msgnum << ", not enough messages";
+ tut::ensure(test_name.str(), msgnum < countMessages());
+
+ std::string msg(message(msgnum));
+
+ std::string field_value;
+
+ // find the start of the field; fields are separated by a single space
+ size_t scan = 0;
+ int on_field = 0;
+ while ( scan < msg.length() && on_field < fieldnum )
+ {
+ // fields are delimited by one space
+ if ( ' ' == msg[scan] )
+ {
+ if ( on_field < FUNCTION_FIELD )
+ {
+ on_field++;
+ }
+ // except function, which may have embedded spaces so ends with " : "
+ else if (( on_field == FUNCTION_FIELD )
+ && ( ':' == msg[scan+1] && ' ' == msg[scan+2] )
+ )
+ {
+ on_field++;
+ scan +=2;
+ }
+ }
+ scan++;
+ }
+ size_t start_field = scan;
+ size_t fieldlen = 0;
+ if ( fieldnum < FUNCTION_FIELD )
+ {
+ fieldlen = msg.find(' ', start_field) - start_field;
+ }
+ else if ( fieldnum == FUNCTION_FIELD )
+ {
+ fieldlen = msg.find(" : ", start_field) - start_field;
+ }
+ else if ( MSG_FIELD == fieldnum ) // no delimiter, just everything to the end
+ {
+ fieldlen = msg.length() - start_field;
+ }
+
+ return msg.substr(start_field, fieldlen);
+ }
+
void ensure_message_field_equals(int msgnum, LogFieldIndex fieldnum, const std::string& expectedText)
- {
- std::ostringstream test_name;
- test_name << "testing message " << msgnum << " field " << FieldName[fieldnum] << "\n message: \"" << message(msgnum) << "\"\n ";
+ {
+ std::ostringstream test_name;
+ test_name << "testing message " << msgnum << " field " << FieldName[fieldnum] << "\n message: \"" << message(msgnum).substr(0, 100) << "\"\n ";
- ensure_equals(test_name.str(), message_field(msgnum, fieldnum), expectedText);
- }
+ try
+ {
+ ensure_equals(test_name.str(), message_field(msgnum, fieldnum), expectedText);
+ }
+ catch (const failure&)
+ {
+ reportMessages();
+ throw;
+ }
+ }
void ensure_message_does_not_contain(int n, const std::string& expectedText)
{
std::ostringstream test_name;
test_name << "testing message " << n;
- ensure_does_not_contain(test_name.str(), message(n), expectedText);
+ try
+ {
+ ensure_does_not_contain(test_name.str(), message(n), expectedText);
+ }
+ catch (const failure&)
+ {
+ reportMessages();
+ throw;
+ }
}
};
@@ -297,29 +330,33 @@ namespace tut
ensure_message_field_equals(3, MSG_FIELD, "four");
ensure_message_field_equals(3, LEVEL_FIELD, "ERROR");
ensure_message_field_equals(3, TAGS_FIELD, "#WriteTag#");
- ensure_message_count(4);
+ // LL_ERRS() produces 2 recordMessage() calls
+ ensure_message_count(5);
LLError::setDefaultLevel(LLError::LEVEL_INFO);
writeSome();
- ensure_message_field_equals(4, MSG_FIELD, "two");
- ensure_message_field_equals(5, MSG_FIELD, "three");
- ensure_message_field_equals(6, MSG_FIELD, "four");
- ensure_message_count(7);
+ ensure_message_field_equals(5, MSG_FIELD, "two");
+ ensure_message_field_equals(6, MSG_FIELD, "three");
+ ensure_message_field_equals(7, MSG_FIELD, "four");
+ // LL_ERRS() produces 2 recordMessage() calls
+ ensure_message_count(9);
LLError::setDefaultLevel(LLError::LEVEL_WARN);
writeSome();
- ensure_message_field_equals(7, MSG_FIELD, "three");
- ensure_message_field_equals(8, MSG_FIELD, "four");
- ensure_message_count(9);
+ ensure_message_field_equals(9, MSG_FIELD, "three");
+ ensure_message_field_equals(10, MSG_FIELD, "four");
+ // LL_ERRS() produces 2 recordMessage() calls
+ ensure_message_count(12);
LLError::setDefaultLevel(LLError::LEVEL_ERROR);
writeSome();
- ensure_message_field_equals(9, MSG_FIELD, "four");
- ensure_message_count(10);
+ ensure_message_field_equals(12, MSG_FIELD, "four");
+ // LL_ERRS() produces 2 recordMessage() calls
+ ensure_message_count(14);
LLError::setDefaultLevel(LLError::LEVEL_NONE);
writeSome();
- ensure_message_count(10);
+ ensure_message_count(14);
}
template<> template<>
@@ -331,7 +368,8 @@ namespace tut
ensure_message_field_equals(1, LEVEL_FIELD, "INFO");
ensure_message_field_equals(2, LEVEL_FIELD, "WARNING");
ensure_message_field_equals(3, LEVEL_FIELD, "ERROR");
- ensure_message_count(4);
+ // LL_ERRS() produces 2 recordMessage() calls
+ ensure_message_count(5);
}
template<> template<>
@@ -339,20 +377,20 @@ namespace tut
// file abbreviation
{
std::string prev, abbreviateFile = __FILE__;
- do
- {
- prev = abbreviateFile;
- abbreviateFile = LLError::abbreviateFile(abbreviateFile);
- // __FILE__ is assumed to end with
- // indra/llcommon/tests/llerror_test.cpp. This test used to call
- // abbreviateFile() exactly once, then check below whether it
- // still contained the string 'indra'. That fails if the FIRST
- // part of the pathname also contains indra! Certain developer
- // machine images put local directory trees under
- // /ngi-persist/indra, which is where we observe the problem. So
- // now, keep calling abbreviateFile() until it returns its
- // argument unchanged, THEN check.
- } while (abbreviateFile != prev);
+ do
+ {
+ prev = abbreviateFile;
+ abbreviateFile = LLError::abbreviateFile(abbreviateFile);
+ // __FILE__ is assumed to end with
+ // indra/llcommon/tests/llerror_test.cpp. This test used to call
+ // abbreviateFile() exactly once, then check below whether it
+ // still contained the string 'indra'. That fails if the FIRST
+ // part of the pathname also contains indra! Certain developer
+ // machine images put local directory trees under
+ // /ngi-persist/indra, which is where we observe the problem. So
+ // now, keep calling abbreviateFile() until it returns its
+ // argument unchanged, THEN check.
+ } while (abbreviateFile != prev);
ensure_ends_with("file name abbreviation",
abbreviateFile,
@@ -627,7 +665,8 @@ namespace tut
ensure_message_field_equals(0, LOCATION_FIELD, location);
ensure_message_field_equals(0, MSG_FIELD, "die");
- ensure_message_count(1);
+ // LL_ERRS() produces 2 recordMessage() calls
+ ensure_message_count(2);
ensure("fatal callback called", fatalWasCalled);
}
@@ -751,10 +790,12 @@ namespace tut
ensure_message_field_equals(0, MSG_FIELD, "aim west");
ensure_message_field_equals(1, MSG_FIELD, "ate eels");
- ensure_message_field_equals(2, MSG_FIELD, "buy iron");
- ensure_message_field_equals(3, MSG_FIELD, "bad word");
- ensure_message_field_equals(4, MSG_FIELD, "big easy");
- ensure_message_count(5);
+ // LL_ERRS() produces 2 recordMessage() calls
+ ensure_message_field_equals(3, MSG_FIELD, "buy iron");
+ ensure_message_field_equals(4, MSG_FIELD, "bad word");
+ ensure_message_field_equals(5, MSG_FIELD, "big easy");
+ // LL_ERRS() produces 2 recordMessage() calls
+ ensure_message_count(7);
}
template<> template<>
@@ -868,9 +909,11 @@ namespace tut
TestBeta::doAll();
ensure_message_field_equals(3, MSG_FIELD, "aim west");
ensure_message_field_equals(4, MSG_FIELD, "ate eels");
- ensure_message_field_equals(5, MSG_FIELD, "bad word");
- ensure_message_field_equals(6, MSG_FIELD, "big easy");
- ensure_message_count(7);
+ // LL_ERRS() produces 2 recordMessage() calls
+ ensure_message_field_equals(6, MSG_FIELD, "bad word");
+ ensure_message_field_equals(7, MSG_FIELD, "big easy");
+ // LL_ERRS() produces 2 recordMessage() calls
+ ensure_message_count(9);
}
}
diff --git a/indra/llcommon/tests/lleventfilter_test.cpp b/indra/llcommon/tests/lleventfilter_test.cpp
index ed7cb56506..a3d55d0cc6 100644
--- a/indra/llcommon/tests/lleventfilter_test.cpp
+++ b/indra/llcommon/tests/lleventfilter_test.cpp
@@ -51,6 +51,7 @@
// as we've carefully put all functionality except actual LLTimer calls into
// LLEventTimeoutBase, that should suffice. We're not not not trying to test
// LLTimer here.
+#if 0 // time testing needs reworking
class TestEventTimeout: public LLEventTimeoutBase
{
public:
@@ -151,6 +152,7 @@ public:
F32 mAlarmRemaining, mTimerRemaining;
LLEventTimeoutBase::Action mAlarmAction;
};
+#endif // time testing needs reworking
/*****************************************************************************
* TUT
@@ -220,6 +222,8 @@ namespace tut
void filter_object::test<2>()
{
set_test_name("LLEventTimeout::actionAfter()");
+ skip("time testing needs reworking");
+#if 0 // time testing needs reworking
LLEventPump& driver(pumps.obtain("driver"));
TestEventTimeout filter(driver);
listener0.reset(0);
@@ -285,12 +289,15 @@ namespace tut
filter.forceTimeout();
mainloop.post(17);
check_listener("no timeout 6", listener1, LLSD(0));
+#endif // time testing needs reworking
}
template<> template<>
void filter_object::test<3>()
{
set_test_name("LLEventTimeout::eventAfter()");
+ skip("time testing needs reworking");
+#if 0 // time testing needs reworking
LLEventPump& driver(pumps.obtain("driver"));
TestEventTimeout filter(driver);
listener0.reset(0);
@@ -322,12 +329,15 @@ namespace tut
filter.forceTimeout();
mainloop.post(17);
check_listener("no timeout 3", listener0, LLSD(0));
+#endif // time testing needs reworking
}
template<> template<>
void filter_object::test<4>()
{
set_test_name("LLEventTimeout::errorAfter()");
+ skip("time testing needs reworking");
+#if 0 // time testing needs reworking
WrapLLErrs capture;
LLEventPump& driver(pumps.obtain("driver"));
TestEventTimeout filter(driver);
@@ -362,12 +372,15 @@ namespace tut
filter.forceTimeout();
mainloop.post(17);
check_listener("no timeout 3", listener0, LLSD(0));
+#endif // time testing needs reworking
}
template<> template<>
void filter_object::test<5>()
{
set_test_name("LLEventThrottle");
+ skip("time testing needs reworking");
+#if 0 // time testing needs reworking
TestEventThrottle throttle(3);
Concat cat;
throttle.listen("concat", boost::ref(cat));
@@ -403,6 +416,7 @@ namespace tut
throttle.advance(5);
throttle.post(";17");
ensure_equals("17", cat.result, "136;12;17"); // "17" delivered
+#endif // time testing needs reworking
}
template<class PUMP>
diff --git a/indra/llcommon/tests/llleap_test.cpp b/indra/llcommon/tests/llleap_test.cpp
index 6fe9e3446f..a7661cc7d8 100644
--- a/indra/llcommon/tests/llleap_test.cpp
+++ b/indra/llcommon/tests/llleap_test.cpp
@@ -385,8 +385,7 @@ namespace tut
"result = '' if resp == dict(pump=replypump(), data='ack')\\\n"
" else 'bad: ' + str(resp)\n"
"send(pump='" << result.getName() << "', data=result)\n";});
- waitfor(LLLeap::create(get_test_name(),
- StringVec{PYTHON, script.getName()}));
+ waitfor(LLLeap::create(get_test_name(), StringVec{PYTHON, script.getName()}));
result.ensure();
}
diff --git a/indra/llcommon/tests/llmainthreadtask_test.cpp b/indra/llcommon/tests/llmainthreadtask_test.cpp
index 69b11ccafb..4a15e30a30 100644
--- a/indra/llcommon/tests/llmainthreadtask_test.cpp
+++ b/indra/llcommon/tests/llmainthreadtask_test.cpp
@@ -20,8 +20,8 @@
// other Linden headers
#include "../test/lltut.h"
#include "../test/sync.h"
+#include "llcallbacklist.h"
#include "llthread.h" // on_main_thread()
-#include "lleventtimer.h"
#include "lockstatic.h"
/*****************************************************************************
@@ -108,7 +108,7 @@ namespace tut
lk.unlock();
// run the task -- should unblock thread, which will immediately block
// on mSync
- LLEventTimer::updateClass();
+ LLCallbackList::instance().callFunctions();
// 'lk', having unlocked, can no longer be used to access; relock with
// a new LockStatic instance
ensure("should now have run", LockStatic()->ran);
diff --git a/indra/llcommon/tests/llprocess_test.cpp b/indra/llcommon/tests/llprocess_test.cpp
index 628f046f55..deef717e5c 100644
--- a/indra/llcommon/tests/llprocess_test.cpp
+++ b/indra/llcommon/tests/llprocess_test.cpp
@@ -259,6 +259,7 @@ public:
}
std::string getName() const { return mPath.string(); }
+ std::string getNormalName() const { return mPath.lexically_normal().make_preferred().string(); }
private:
boost::filesystem::path mPath;
@@ -590,7 +591,7 @@ namespace tut
" f.write(os.path.normcase(os.path.normpath(os.getcwd())))\n");
// Before running, call setWorkingDirectory()
py.mParams.cwd = tempdir.getName();
- std::string expected{ tempdir.getName() };
+ std::string expected{ tempdir.getNormalName() };
#if LL_WINDOWS
// SIGH, don't get tripped up by "C:" != "c:" --
// but on the Mac, using tolower() fails because "/users" != "/Users"!
diff --git a/indra/llcommon/tests/llsdserialize_test.cpp b/indra/llcommon/tests/llsdserialize_test.cpp
index 730731a927..bff647cbe8 100644
--- a/indra/llcommon/tests/llsdserialize_test.cpp
+++ b/indra/llcommon/tests/llsdserialize_test.cpp
@@ -44,8 +44,6 @@ typedef U32 uint32_t;
#include "llstring.h"
#endif
-#include "boost/range.hpp"
-
#include "llsd.h"
#include "llsdserialize.h"
#include "llsdutil.h"
@@ -2097,7 +2095,8 @@ namespace tut
NamedTempFile file("llsd", "");
python("Python " + pyformatter,
- [&](std::ostream& out){ out <<
+ [pyformatter, &file](std::ostream& out) {
+ out <<
import_llsd <<
"import struct\n"
"lenformat = struct.Struct('i')\n"