summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorRye <rye@alchemyviewer.org>2025-12-09 19:27:14 -0500
committerAndrey Kleshchev <117672381+akleshchev@users.noreply.github.com>2025-12-11 21:37:03 +0200
commit3b88739957d8b0d5072646e571d27b743e68fe2e (patch)
treee9cdd325e282735c1f3e7021bef7e8d0e983083b /indra
parent0e70989f6804f71a5efb2ff7e1352fb556321446 (diff)
Rework legacy lltest executable into individual integration tests and restore some disabled tests
Removes dead llprimlinkinfo and related test Remove dead llassetuploadqueue llhttpclient lltimestampcache lltranscode tests Remove dead mock_http_client Remove duplicate hex_dump.h Fix crash in LLDataPacker test
Diffstat (limited to 'indra')
-rw-r--r--indra/llcommon/CMakeLists.txt14
-rw-r--r--indra/llcommon/llsdjson.cpp1
-rw-r--r--indra/llcommon/tests/llapp_test.cpp (renamed from indra/test/llapp_tut.cpp)0
-rw-r--r--indra/llcommon/tests/lldoubledispatch_test.cpp (renamed from indra/test/lldoubledispatch_tut.cpp)0
-rw-r--r--indra/llcommon/tests/llevents_test.cpp (renamed from indra/test/llevents_tut.cpp)0
-rw-r--r--indra/llcommon/tests/llhttpdate_test.cpp (renamed from indra/test/llhttpdate_tut.cpp)0
-rw-r--r--indra/llcommon/tests/llsd_test.cpp (renamed from indra/test/llsd_new_tut.cpp)2
-rw-r--r--indra/llcommon/tests/llsdserialize_test.cpp6
-rw-r--r--indra/llcommon/tests/llsdutil_test.cpp (renamed from indra/test/llsdutil_tut.cpp)0
-rw-r--r--indra/llcommon/tests/llstreamtools_test.cpp (renamed from indra/test/llstreamtools_tut.cpp)0
-rw-r--r--indra/llinventory/CMakeLists.txt3
-rw-r--r--indra/llinventory/tests/llpermissions_test.cpp (renamed from indra/test/llpermissions_tut.cpp)0
-rw-r--r--indra/llinventory/tests/llsaleinfo_test.cpp (renamed from indra/test/llsaleinfo_tut.cpp)0
-rw-r--r--indra/llinventory/tests/lluserrelations_test.cpp (renamed from indra/test/lluserrelations_tut.cpp)0
-rw-r--r--indra/llmessage/CMakeLists.txt15
-rw-r--r--indra/llmessage/tests/io_test.cpp (renamed from indra/test/io.cpp)0
-rw-r--r--indra/llmessage/tests/llbuffer_test.cpp (renamed from indra/test/llbuffer_tut.cpp)0
-rw-r--r--indra/llmessage/tests/llcurl_stub.cpp99
-rw-r--r--indra/llmessage/tests/lldatapacker_test.cpp (renamed from indra/test/lldatapacker_tut.cpp)12
-rw-r--r--indra/llmessage/tests/llhttpclient_test.cpp311
-rw-r--r--indra/llmessage/tests/llhttpnode_test.cpp (renamed from indra/test/llhttpnode_tut.cpp)0
-rw-r--r--indra/llmessage/tests/lliohttpserver_test.cpp (renamed from indra/test/lliohttpserver_tut.cpp)0
-rw-r--r--indra/llmessage/tests/llmessageconfig_test.cpp (renamed from indra/test/llmessageconfig_tut.cpp)0
-rw-r--r--indra/llmessage/tests/llmessagetemplateparser_test.cpp (renamed from indra/test/llmessagetemplateparser_tut.cpp)0
-rw-r--r--indra/llmessage/tests/llpipeutil.cpp (renamed from indra/test/llpipeutil.cpp)0
-rw-r--r--indra/llmessage/tests/llpipeutil.h (renamed from indra/test/llpipeutil.h)0
-rw-r--r--indra/llmessage/tests/llsdmessagebuilder_test.cpp (renamed from indra/test/llsdmessagebuilder_tut.cpp)0
-rw-r--r--indra/llmessage/tests/llsdmessagereader_test.cpp (renamed from indra/test/llsdmessagereader_tut.cpp)0
-rw-r--r--indra/llmessage/tests/llservicebuilder_test.cpp (renamed from indra/test/llservicebuilder_tut.cpp)0
-rw-r--r--indra/llmessage/tests/lltemplatemessagebuilder_test.cpp (renamed from indra/test/lltemplatemessagebuilder_tut.cpp)0
-rw-r--r--indra/llmessage/tests/llxorcipher_test.cpp (renamed from indra/test/llxorcipher_tut.cpp)0
-rw-r--r--indra/llmessage/tests/message_test.cpp (renamed from indra/test/message_tut.cpp)0
-rw-r--r--indra/llprimitive/llprimlinkinfo.h393
-rw-r--r--indra/test/CMakeLists.txt120
-rw-r--r--indra/test/hexdump.h97
-rw-r--r--indra/test/llassetuploadqueue_tut.cpp195
-rw-r--r--indra/test/lltimestampcache_tut.cpp124
-rw-r--r--indra/test/lltranscode_tut.cpp86
-rw-r--r--indra/test/mock_http_client.cpp82
-rw-r--r--indra/test/mock_http_client.h190
-rw-r--r--indra/test/prim_linkability_tut.cpp495
41 files changed, 55 insertions, 2190 deletions
diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt
index c3b892b204..7311c6faf6 100644
--- a/indra/llcommon/CMakeLists.txt
+++ b/indra/llcommon/CMakeLists.txt
@@ -317,16 +317,20 @@ if (LL_TESTS)
LL_ADD_INTEGRATION_TEST(classic_callback "" "${test_libs}")
LL_ADD_INTEGRATION_TEST(commonmisc "" "${test_libs}")
LL_ADD_INTEGRATION_TEST(lazyeventapi "" "${test_libs}")
+ LL_ADD_INTEGRATION_TEST(llapp "" "${test_libs}")
LL_ADD_INTEGRATION_TEST(llbase64 "" "${test_libs}")
LL_ADD_INTEGRATION_TEST(llcond "" "${test_libs}")
LL_ADD_INTEGRATION_TEST(lldate "" "${test_libs}")
LL_ADD_INTEGRATION_TEST(lldeadmantimer "" "${test_libs}")
LL_ADD_INTEGRATION_TEST(lldependencies "" "${test_libs}")
+ LL_ADD_INTEGRATION_TEST(lldoubledispatch "" "${test_libs}")
LL_ADD_INTEGRATION_TEST(llerror "" "${test_libs}")
LL_ADD_INTEGRATION_TEST(lleventcoro "" "${test_libs}")
LL_ADD_INTEGRATION_TEST(lleventdispatcher "" "${test_libs}")
LL_ADD_INTEGRATION_TEST(lleventfilter "" "${test_libs}")
+ LL_ADD_INTEGRATION_TEST(llevents "" "${test_libs}")
LL_ADD_INTEGRATION_TEST(llframetimer "" "${test_libs}")
+ LL_ADD_INTEGRATION_TEST(llhttpdate "" "${test_libs}")
LL_ADD_INTEGRATION_TEST(llheteromap "" "${test_libs}")
LL_ADD_INTEGRATION_TEST(llinstancetracker "" "${test_libs}")
LL_ADD_INTEGRATION_TEST(llleap "" "${test_libs}")
@@ -336,9 +340,12 @@ if (LL_TESTS)
LL_ADD_INTEGRATION_TEST(llprocessor "" "${test_libs}")
LL_ADD_INTEGRATION_TEST(llprocinfo "" "${test_libs}")
LL_ADD_INTEGRATION_TEST(llrand "" "${test_libs}")
+ LL_ADD_INTEGRATION_TEST(llsd "" "${test_libs}")
LL_ADD_INTEGRATION_TEST(llsdserialize "" "${test_libs}")
+ LL_ADD_INTEGRATION_TEST(llsdutil "" "llcommon;llmath")
LL_ADD_INTEGRATION_TEST(llsingleton "" "${test_libs}")
LL_ADD_INTEGRATION_TEST(llstreamqueue "" "${test_libs}")
+ LL_ADD_INTEGRATION_TEST(llstreamtools "" "${test_libs}")
LL_ADD_INTEGRATION_TEST(llstring "" "${test_libs}")
LL_ADD_INTEGRATION_TEST(lltrace "" "${test_libs}")
LL_ADD_INTEGRATION_TEST(lltreeiterators "" "${test_libs}")
@@ -354,4 +361,11 @@ if (LL_TESTS)
## throwing and catching exceptions.
##LL_ADD_INTEGRATION_TEST(llexception "" "${test_libs}")
+ # Skip precompiled header for tests that need special handling
+ set_source_files_properties(
+ tests/llsd_test.cpp
+ PROPERTIES
+ SKIP_PRECOMPILE_HEADERS TRUE
+ )
+
endif (LL_TESTS)
diff --git a/indra/llcommon/llsdjson.cpp b/indra/llcommon/llsdjson.cpp
index 542a3c26e3..9abca48670 100644
--- a/indra/llcommon/llsdjson.cpp
+++ b/indra/llcommon/llsdjson.cpp
@@ -26,7 +26,6 @@
// Must turn on conditional declarations in header file so definitions end up
// with proper linkage.
-#define LLSD_DEBUG_INFO
#include "linden_common.h"
#include "llsdjson.h"
diff --git a/indra/test/llapp_tut.cpp b/indra/llcommon/tests/llapp_test.cpp
index 114af6edbf..114af6edbf 100644
--- a/indra/test/llapp_tut.cpp
+++ b/indra/llcommon/tests/llapp_test.cpp
diff --git a/indra/test/lldoubledispatch_tut.cpp b/indra/llcommon/tests/lldoubledispatch_test.cpp
index 79c4edc058..79c4edc058 100644
--- a/indra/test/lldoubledispatch_tut.cpp
+++ b/indra/llcommon/tests/lldoubledispatch_test.cpp
diff --git a/indra/test/llevents_tut.cpp b/indra/llcommon/tests/llevents_test.cpp
index c5d5dcb9d4..c5d5dcb9d4 100644
--- a/indra/test/llevents_tut.cpp
+++ b/indra/llcommon/tests/llevents_test.cpp
diff --git a/indra/test/llhttpdate_tut.cpp b/indra/llcommon/tests/llhttpdate_test.cpp
index b580b09a9f..b580b09a9f 100644
--- a/indra/test/llhttpdate_tut.cpp
+++ b/indra/llcommon/tests/llhttpdate_test.cpp
diff --git a/indra/test/llsd_new_tut.cpp b/indra/llcommon/tests/llsd_test.cpp
index cc084df045..9cc93bcd14 100644
--- a/indra/test/llsd_new_tut.cpp
+++ b/indra/llcommon/tests/llsd_test.cpp
@@ -26,9 +26,9 @@
*/
#define LLSD_DEBUG_INFO
-#include <tut/tut.hpp>
#include "linden_common.h"
#include "lltut.h"
+#include "llsd.h"
#include "llsdtraits.h"
#include "llstring.h"
diff --git a/indra/llcommon/tests/llsdserialize_test.cpp b/indra/llcommon/tests/llsdserialize_test.cpp
index ee315051d8..272eb55521 100644
--- a/indra/llcommon/tests/llsdserialize_test.cpp
+++ b/indra/llcommon/tests/llsdserialize_test.cpp
@@ -52,7 +52,7 @@ typedef U32 uint32_t;
#include "llformat.h"
#include "llmemorystream.h"
-#include "../test/hexdump.h"
+#include "hexdump.h"
#include "../test/lltut.h"
#include "../test/namedtempfile.h"
#include "stringize.h"
@@ -1921,12 +1921,12 @@ namespace tut
int bufflen{ static_cast<int>(buffstr.length()) };
out.write(reinterpret_cast<const char*>(&bufflen), sizeof(bufflen));
LL_DEBUGS() << "Wrote length: "
- << hexdump(reinterpret_cast<const char*>(&bufflen),
+ << LL::hexdump(reinterpret_cast<const char*>(&bufflen),
sizeof(bufflen))
<< LL_ENDL;
out.write(buffstr.c_str(), buffstr.length());
LL_DEBUGS() << "Wrote data: "
- << hexmix(buffstr.c_str(), buffstr.length())
+ << LL::hexmix(buffstr.c_str(), buffstr.length())
<< LL_ENDL;
}
}
diff --git a/indra/test/llsdutil_tut.cpp b/indra/llcommon/tests/llsdutil_test.cpp
index 4b25a02f30..4b25a02f30 100644
--- a/indra/test/llsdutil_tut.cpp
+++ b/indra/llcommon/tests/llsdutil_test.cpp
diff --git a/indra/test/llstreamtools_tut.cpp b/indra/llcommon/tests/llstreamtools_test.cpp
index 970afb3b02..970afb3b02 100644
--- a/indra/test/llstreamtools_tut.cpp
+++ b/indra/llcommon/tests/llstreamtools_test.cpp
diff --git a/indra/llinventory/CMakeLists.txt b/indra/llinventory/CMakeLists.txt
index 22966bc55b..e8f76eaa7d 100644
--- a/indra/llinventory/CMakeLists.txt
+++ b/indra/llinventory/CMakeLists.txt
@@ -75,4 +75,7 @@ if (LL_TESTS)
set(test_libs llinventory llmath llcorehttp llfilesystem )
LL_ADD_INTEGRATION_TEST(inventorymisc "" "${test_libs}")
LL_ADD_INTEGRATION_TEST(llparcel "" "${test_libs}")
+ LL_ADD_INTEGRATION_TEST(llpermissions "" "${test_libs}")
+ LL_ADD_INTEGRATION_TEST(llsaleinfo "" "${test_libs}")
+ LL_ADD_INTEGRATION_TEST(lluserrelations "" "${test_libs}")
endif (LL_TESTS)
diff --git a/indra/test/llpermissions_tut.cpp b/indra/llinventory/tests/llpermissions_test.cpp
index 1328939004..1328939004 100644
--- a/indra/test/llpermissions_tut.cpp
+++ b/indra/llinventory/tests/llpermissions_test.cpp
diff --git a/indra/test/llsaleinfo_tut.cpp b/indra/llinventory/tests/llsaleinfo_test.cpp
index 1da7101aa3..1da7101aa3 100644
--- a/indra/test/llsaleinfo_tut.cpp
+++ b/indra/llinventory/tests/llsaleinfo_test.cpp
diff --git a/indra/test/lluserrelations_tut.cpp b/indra/llinventory/tests/lluserrelations_test.cpp
index 80a659da65..80a659da65 100644
--- a/indra/test/lluserrelations_tut.cpp
+++ b/indra/llinventory/tests/lluserrelations_test.cpp
diff --git a/indra/llmessage/CMakeLists.txt b/indra/llmessage/CMakeLists.txt
index 86e262f56a..2e51e1b5d4 100644
--- a/indra/llmessage/CMakeLists.txt
+++ b/indra/llmessage/CMakeLists.txt
@@ -215,9 +215,22 @@ if (LL_TESTS)
llcommon
)
- #LL_ADD_INTEGRATION_TEST(llavatarnamecache "" "${test_libs}")
+ LL_ADD_INTEGRATION_TEST(io "tests/llpipeutil.cpp" "${test_libs}")
+ LL_ADD_INTEGRATION_TEST(llavatarnamecache "" "${test_libs}")
+ LL_ADD_INTEGRATION_TEST(llbuffer "" "${test_libs}")
+ LL_ADD_INTEGRATION_TEST(lldatapacker "" "${test_libs}")
LL_ADD_INTEGRATION_TEST(llhost "" "${test_libs}")
+ LL_ADD_INTEGRATION_TEST(llhttpnode "" "${test_libs}")
+ LL_ADD_INTEGRATION_TEST(lliohttpserver "tests/llpipeutil.cpp" "${test_libs}")
+ LL_ADD_INTEGRATION_TEST(llsdmessagebuilder "" "${test_libs}")
+ LL_ADD_INTEGRATION_TEST(llsdmessagereader "" "${test_libs}")
+ LL_ADD_INTEGRATION_TEST(llmessageconfig "" "${test_libs}")
+ LL_ADD_INTEGRATION_TEST(llmessagetemplateparser "" "${test_libs}")
LL_ADD_INTEGRATION_TEST(llpartdata "" "${test_libs}")
+ LL_ADD_INTEGRATION_TEST(llservicebuilder "" "${test_libs}")
+ LL_ADD_INTEGRATION_TEST(lltemplatemessagebuilder "" "${test_libs}")
LL_ADD_INTEGRATION_TEST(llxfer_file "" "${test_libs}")
+ LL_ADD_INTEGRATION_TEST(llxorcipher "" "${test_libs}")
+ LL_ADD_INTEGRATION_TEST(message "" "${test_libs}")
endif (LL_TESTS)
diff --git a/indra/test/io.cpp b/indra/llmessage/tests/io_test.cpp
index f77402065a..f77402065a 100644
--- a/indra/test/io.cpp
+++ b/indra/llmessage/tests/io_test.cpp
diff --git a/indra/test/llbuffer_tut.cpp b/indra/llmessage/tests/llbuffer_test.cpp
index 330a4f288f..330a4f288f 100644
--- a/indra/test/llbuffer_tut.cpp
+++ b/indra/llmessage/tests/llbuffer_test.cpp
diff --git a/indra/llmessage/tests/llcurl_stub.cpp b/indra/llmessage/tests/llcurl_stub.cpp
deleted file mode 100644
index 78c195580c..0000000000
--- a/indra/llmessage/tests/llcurl_stub.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/**
- * @file llcurl_stub.cpp
- * @brief stub class to allow unit testing
- *
- * $LicenseInfo:firstyear=2008&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#ifndef LL_CURL_STUB_CPP
-#define LL_CURL_STUB_CPP
-
-
-#include "linden_common.h"
-#include "llcurl.h"
-#include "llhttpconstants.cpp"
-
-LLCurl::Responder::Responder()
-{
-}
-
-void LLCurl::Responder::httpCompleted()
-{
- if (isGoodStatus())
- {
- httpSuccess();
- }
- else
- {
- httpFailure();
- }
-}
-
-void LLCurl::Responder::completedRaw(LLChannelDescriptors const&,
- std::shared_ptr<LLBufferArray> const&)
-{
-}
-
-void LLCurl::Responder::httpFailure()
-{
-}
-
-LLCurl::Responder::~Responder ()
-{
-}
-
-void LLCurl::Responder::httpSuccess()
-{
-}
-
-std::string LLCurl::Responder::dumpResponse() const
-{
- return "dumpResponse()";
-}
-
-void LLCurl::Responder::successResult(const LLSD& content)
-{
- setResult(HTTP_OK, "", content);
- httpSuccess();
-}
-
-void LLCurl::Responder::failureResult(S32 status, const std::string& reason, const LLSD& content)
-{
- setResult(status, reason, content);
- httpFailure();
-}
-
-
-void LLCurl::Responder::completeResult(S32 status, const std::string& reason, const LLSD& content)
-{
- setResult(status, reason, content);
- httpCompleted();
-}
-
-void LLCurl::Responder::setResult(S32 status, const std::string& reason, const LLSD& content /* = LLSD() */)
-{
- mStatus = status;
- mReason = reason;
- mContent = content;
-}
-
-#endif
diff --git a/indra/test/lldatapacker_tut.cpp b/indra/llmessage/tests/lldatapacker_test.cpp
index 2e975ee637..746817936d 100644
--- a/indra/test/lldatapacker_tut.cpp
+++ b/indra/llmessage/tests/lldatapacker_test.cpp
@@ -26,9 +26,10 @@
* $/LicenseInfo$
*/
-#include <tut/tut.hpp>
-#include "lltut.h"
#include "linden_common.h"
+
+#include "lltut.h"
+
#include "lldatapacker.h"
#include "v4color.h"
#include "v4coloru.h"
@@ -38,6 +39,7 @@
#include "llsdserialize.h"
#define TEST_FILE_NAME "datapacker_test.txt"
+
namespace tut
{
struct datapacker_test
@@ -188,11 +190,11 @@ namespace tut
template<> template<>
void datapacker_test_object_t::test<5>()
{
- U8 buf[] = "SecondLife is virtual World";
+ U8* buf = new U8[]("SecondLife is virtual World");
S32 size = sizeof(buf);
LLDataPackerBinaryBuffer lldp(buf, size);
- U8 new_buf[] = "Its Amazing";
- size = sizeof(new_buf);
+ U8* new_buf = new U8[]("Its Amazing");
+ size = sizeof(new_buf)-1;
lldp.assignBuffer(new_buf, size);
ensure("LLDataPackerBinaryBuffer::assignBuffer failed" , ((lldp.getBufferSize() == size) && (0 == lldp.getCurrentSize()))) ;
}
diff --git a/indra/llmessage/tests/llhttpclient_test.cpp b/indra/llmessage/tests/llhttpclient_test.cpp
deleted file mode 100644
index 1881144d3e..0000000000
--- a/indra/llmessage/tests/llhttpclient_test.cpp
+++ /dev/null
@@ -1,311 +0,0 @@
-/**
- * @file llhttpclient_test.cpp
- * @brief Testing the HTTP client classes.
- *
- * $LicenseInfo:firstyear=2006&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-/**
- *
- * These classes test the HTTP client framework.
- *
- */
-
-#include <tut/tut.hpp>
-#include "linden_common.h"
-
-#include "lltut.h"
-#include "llhttpclient.h"
-#include "llformat.h"
-#include "llpipeutil.h"
-#include "llproxy.h"
-#include "llpumpio.h"
-
-#include "lliosocket.h"
-#include "llstring.h"
-#include "stringize.h"
-#include "llcleanup.h"
-
-namespace tut
-{
- struct HTTPClientTestData
- {
- public:
- HTTPClientTestData():
- PORT(LLStringUtil::getenv("PORT")),
- // Turning NULL PORT into empty string doesn't make things work;
- // that's just to keep this initializer from blowing up. We test
- // PORT separately in the constructor body.
- local_server(STRINGIZE("http://127.0.0.1:" << PORT << "/"))
- {
- ensure("Set environment variable PORT to local test server port", !PORT.empty());
- apr_pool_create(&mPool, NULL);
- LLCurl::initClass(false);
- mClientPump = new LLPumpIO(mPool);
-
- LLHTTPClient::setPump(*mClientPump);
- }
-
- ~HTTPClientTestData()
- {
- delete mClientPump;
- SUBSYSTEM_CLEANUP(LLProxy);
- apr_pool_destroy(mPool);
- }
-
- void runThePump(float timeout = 100.0f)
- {
- LLTimer timer;
- timer.setTimerExpirySec(timeout);
-
- while(!mSawCompleted && !mSawCompletedHeader && !timer.hasExpired())
- {
- LLFrameTimer::updateFrameTime();
- if (mClientPump)
- {
- mClientPump->pump();
- mClientPump->callback();
- }
- }
- }
-
- const std::string PORT;
- const std::string local_server;
-
- private:
- apr_pool_t* mPool;
- LLPumpIO* mClientPump;
-
- protected:
- void ensureStatusOK()
- {
- if (mSawError)
- {
- std::string msg =
- llformat("httpFailure() called when not expected, status %d",
- mStatus);
- fail(msg);
- }
- }
-
- void ensureStatusError()
- {
- if (!mSawError)
- {
- fail("httpFailure() wasn't called");
- }
- }
-
- LLSD getResult()
- {
- return mResult;
- }
- LLSD getHeader()
- {
- return mHeader;
- }
-
- protected:
- bool mSawError;
- U32 mStatus;
- std::string mReason;
- bool mSawCompleted;
- bool mSawCompletedHeader;
- LLSD mResult;
- LLSD mHeader;
- bool mResultDeleted;
-
- class Result : public LLHTTPClient::Responder
- {
- protected:
- Result(HTTPClientTestData& client)
- : mClient(client)
- {
- }
-
- public:
- static Result* build(HTTPClientTestData& client)
- {
- return new Result(client);
- }
-
- ~Result()
- {
- mClient.mResultDeleted = true;
- }
-
- protected:
- virtual void httpFailure()
- {
- mClient.mSawError = true;
- mClient.mStatus = getStatus();
- mClient.mReason = getReason();
- }
-
- virtual void httpSuccess()
- {
- mClient.mResult = getContent();
- }
-
- virtual void httpCompleted()
- {
- LLHTTPClient::Responder::httpCompleted();
-
- mClient.mSawCompleted = true;
- mClient.mSawCompletedHeader = true;
- mClient.mHeader = getResponseHeaders();
- }
-
- private:
- HTTPClientTestData& mClient;
- };
-
- friend class Result;
-
- protected:
- LLHTTPClient::ResponderPtr newResult()
- {
- mSawError = false;
- mStatus = 0;
- mSawCompleted = false;
- mSawCompletedHeader = false;
- mResult.clear();
- mHeader.clear();
- mResultDeleted = false;
-
- return Result::build(*this);
- }
- };
-
-
- typedef test_group<HTTPClientTestData> HTTPClientTestGroup;
- typedef HTTPClientTestGroup::object HTTPClientTestObject;
- HTTPClientTestGroup httpClientTestGroup("http_client");
-
- template<> template<>
- void HTTPClientTestObject::test<1>()
- {
- LLHTTPClient::get(local_server, newResult());
- runThePump();
- ensureStatusOK();
- ensure("result object wasn't destroyed", mResultDeleted);
- }
-
- template<> template<>
- void HTTPClientTestObject::test<2>()
- {
- // Please nobody listen on this particular port...
- LLHTTPClient::get("http://127.0.0.1:7950", newResult());
- runThePump();
- ensureStatusError();
- }
-
- template<> template<>
- void HTTPClientTestObject::test<3>()
- {
- LLSD sd;
-
- sd["list"][0]["one"] = 1;
- sd["list"][0]["two"] = 2;
- sd["list"][1]["three"] = 3;
- sd["list"][1]["four"] = 4;
-
- LLHTTPClient::post(local_server + "web/echo", sd, newResult());
- runThePump();
- ensureStatusOK();
- ensure_equals("echoed result matches", getResult(), sd);
- }
-
- template<> template<>
- void HTTPClientTestObject::test<4>()
- {
- LLSD sd;
-
- sd["message"] = "This is my test message.";
-
- LLHTTPClient::put(local_server + "test/storage", sd, newResult());
- runThePump();
- ensureStatusOK();
-
- LLHTTPClient::get(local_server + "test/storage", newResult());
- runThePump();
- ensureStatusOK();
- ensure_equals("echoed result matches", getResult(), sd);
-
- }
-
- template<> template<>
- void HTTPClientTestObject::test<5>()
- {
- LLSD sd;
- sd["status"] = 543;
- sd["reason"] = "error for testing";
-
- LLHTTPClient::post(local_server + "test/error", sd, newResult());
- runThePump();
- ensureStatusError();
- ensure_contains("reason", mReason, sd["reason"]);
- }
-
- template<> template<>
- void HTTPClientTestObject::test<6>()
- {
- const F32 timeout = 1.0f;
- LLHTTPClient::get(local_server + "test/timeout", newResult(), LLSD(), timeout);
- runThePump(timeout * 5.0f);
- ensureStatusError();
- ensure_equals("reason", mReason, "STATUS_EXPIRED");
- }
-
- template<> template<>
- void HTTPClientTestObject::test<7>()
- {
- LLHTTPClient::get(local_server, newResult());
- runThePump();
- ensureStatusOK();
- LLSD expected = getResult();
-
- LLSD result;
- result = LLHTTPClient::blockingGet(local_server);
- LLSD body = result["body"];
- ensure_equals("echoed result matches", body.size(), expected.size());
- }
- template<> template<>
- void HTTPClientTestObject::test<8>()
- {
- // This is testing for the presence of the Header in the returned results
- // from an HTTP::get call.
- LLHTTPClient::get(local_server, newResult());
- runThePump();
- ensureStatusOK();
- LLSD header = getHeader();
- ensure("got a header", ! header.emptyMap().asBoolean());
- }
- template<> template<>
- void HTTPClientTestObject::test<9>()
- {
- LLHTTPClient::head(local_server, newResult());
- runThePump();
- ensureStatusOK();
- ensure("result object wasn't destroyed", mResultDeleted);
- }
-}
diff --git a/indra/test/llhttpnode_tut.cpp b/indra/llmessage/tests/llhttpnode_test.cpp
index c38dee120b..c38dee120b 100644
--- a/indra/test/llhttpnode_tut.cpp
+++ b/indra/llmessage/tests/llhttpnode_test.cpp
diff --git a/indra/test/lliohttpserver_tut.cpp b/indra/llmessage/tests/lliohttpserver_test.cpp
index 7034f4a063..7034f4a063 100644
--- a/indra/test/lliohttpserver_tut.cpp
+++ b/indra/llmessage/tests/lliohttpserver_test.cpp
diff --git a/indra/test/llmessageconfig_tut.cpp b/indra/llmessage/tests/llmessageconfig_test.cpp
index 93443467a2..93443467a2 100644
--- a/indra/test/llmessageconfig_tut.cpp
+++ b/indra/llmessage/tests/llmessageconfig_test.cpp
diff --git a/indra/test/llmessagetemplateparser_tut.cpp b/indra/llmessage/tests/llmessagetemplateparser_test.cpp
index f665fdde4d..f665fdde4d 100644
--- a/indra/test/llmessagetemplateparser_tut.cpp
+++ b/indra/llmessage/tests/llmessagetemplateparser_test.cpp
diff --git a/indra/test/llpipeutil.cpp b/indra/llmessage/tests/llpipeutil.cpp
index 1dd4bdfa3c..1dd4bdfa3c 100644
--- a/indra/test/llpipeutil.cpp
+++ b/indra/llmessage/tests/llpipeutil.cpp
diff --git a/indra/test/llpipeutil.h b/indra/llmessage/tests/llpipeutil.h
index 97d9e1c85c..97d9e1c85c 100644
--- a/indra/test/llpipeutil.h
+++ b/indra/llmessage/tests/llpipeutil.h
diff --git a/indra/test/llsdmessagebuilder_tut.cpp b/indra/llmessage/tests/llsdmessagebuilder_test.cpp
index 6804c3e29e..6804c3e29e 100644
--- a/indra/test/llsdmessagebuilder_tut.cpp
+++ b/indra/llmessage/tests/llsdmessagebuilder_test.cpp
diff --git a/indra/test/llsdmessagereader_tut.cpp b/indra/llmessage/tests/llsdmessagereader_test.cpp
index dd6520ea33..dd6520ea33 100644
--- a/indra/test/llsdmessagereader_tut.cpp
+++ b/indra/llmessage/tests/llsdmessagereader_test.cpp
diff --git a/indra/test/llservicebuilder_tut.cpp b/indra/llmessage/tests/llservicebuilder_test.cpp
index 0bc17865d6..0bc17865d6 100644
--- a/indra/test/llservicebuilder_tut.cpp
+++ b/indra/llmessage/tests/llservicebuilder_test.cpp
diff --git a/indra/test/lltemplatemessagebuilder_tut.cpp b/indra/llmessage/tests/lltemplatemessagebuilder_test.cpp
index ddf1c3dbcc..ddf1c3dbcc 100644
--- a/indra/test/lltemplatemessagebuilder_tut.cpp
+++ b/indra/llmessage/tests/lltemplatemessagebuilder_test.cpp
diff --git a/indra/test/llxorcipher_tut.cpp b/indra/llmessage/tests/llxorcipher_test.cpp
index 9acac53604..9acac53604 100644
--- a/indra/test/llxorcipher_tut.cpp
+++ b/indra/llmessage/tests/llxorcipher_test.cpp
diff --git a/indra/test/message_tut.cpp b/indra/llmessage/tests/message_test.cpp
index 11cd710ef6..11cd710ef6 100644
--- a/indra/test/message_tut.cpp
+++ b/indra/llmessage/tests/message_test.cpp
diff --git a/indra/llprimitive/llprimlinkinfo.h b/indra/llprimitive/llprimlinkinfo.h
deleted file mode 100644
index 67e40fd5be..0000000000
--- a/indra/llprimitive/llprimlinkinfo.h
+++ /dev/null
@@ -1,393 +0,0 @@
-/**
- * @file llprimlinkinfo.h
- * @author andrew@lindenlab.com
- * @brief A template for determining which prims in a set are linkable
- *
- * $LicenseInfo:firstyear=2007&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-
-#ifndef LL_PRIM_LINK_INFO_H
-#define LL_PRIM_LINK_INFO_H
-
-// system includes
-#include <iostream>
-#include <map>
-#include <list>
-#include <vector>
-
-// common includes
-#include "stdtypes.h"
-#include "v3math.h"
-#include "llquaternion.h"
-#include "llsphere.h"
-
-
-const F32 MAX_OBJECT_SPAN = 54.f; // max distance from outside edge of an object to the farthest edge
-const F32 OBJECT_SPAN_BONUS = 2.f; // infinitesimally small prims can always link up to this distance
-const S32 MAX_PRIMS_PER_OBJECT = 256;
-
-
-template < typename DATA_TYPE >
-class LLPrimLinkInfo
-{
-public:
- LLPrimLinkInfo();
- LLPrimLinkInfo( DATA_TYPE data, const LLSphere& sphere );
- ~LLPrimLinkInfo();
-
- void set( DATA_TYPE data, const LLSphere& sphere );
- void append( DATA_TYPE data, const LLSphere& sphere );
- void getData( std::list< DATA_TYPE >& data_list ) const;
- F32 getDiameter() const;
- LLVector3 getCenter() const;
-
- // returns 'true' if this info can link with other_info
- bool canLink( const LLPrimLinkInfo< DATA_TYPE >& other_info );
-
- S32 getPrimCount() const { return mDataMap.size(); }
-
- void mergeLinkableSet( typename std::list< LLPrimLinkInfo < DATA_TYPE > >& unlinked );
-
- void transform(const LLVector3& position, const LLQuaternion& rotation);
-
-private:
- // returns number of merges made
- S32 merge(LLPrimLinkInfo< DATA_TYPE >& other_info);
-
- // returns number of collapses made
- static S32 collapse(typename std::list< LLPrimLinkInfo < DATA_TYPE > >& unlinked );
-
- void computeBoundingSphere();
-
- // Internal utility to encapsulate the link rules
- F32 get_max_linkable_span(const LLSphere& first, const LLSphere& second);
- F32 get_span(const LLSphere& first, const LLSphere& second);
-
-private:
- std::map< DATA_TYPE, LLSphere > mDataMap;
- LLSphere mBoundingSphere;
-};
-
-
-
-template < typename DATA_TYPE >
-LLPrimLinkInfo< DATA_TYPE >::LLPrimLinkInfo()
-: mBoundingSphere( LLVector3(0.f, 0.f, 0.f), 0.f )
-{
-}
-
-template < typename DATA_TYPE >
-LLPrimLinkInfo< DATA_TYPE >::LLPrimLinkInfo( DATA_TYPE data, const LLSphere& sphere)
-: mBoundingSphere(sphere)
-{
- mDataMap[data] = sphere;
-}
-
-template < typename DATA_TYPE >
-LLPrimLinkInfo< DATA_TYPE >::~LLPrimLinkInfo()
-{
- mDataMap.clear();
-}
-
-template < typename DATA_TYPE >
-void LLPrimLinkInfo< DATA_TYPE>::set( DATA_TYPE data, const LLSphere& sphere )
-{
- if (!mDataMap.empty())
- {
- mDataMap.clear();
- }
- mDataMap[data] = sphere;
- mBoundingSphere = sphere;
-}
-
-template < typename DATA_TYPE >
-void LLPrimLinkInfo< DATA_TYPE>::append( DATA_TYPE data, const LLSphere& sphere )
-{
- mDataMap[data] = sphere;
- if (!mBoundingSphere.contains(sphere))
- {
- computeBoundingSphere();
- }
-}
-
-template < typename DATA_TYPE >
-void LLPrimLinkInfo< DATA_TYPE >::getData( std::list< DATA_TYPE >& data_list) const
-{
- typename std::map< DATA_TYPE, LLSphere >::const_iterator map_itr;
- for (map_itr = mDataMap.begin(); map_itr != mDataMap.end(); ++map_itr)
- {
- data_list.push_back(map_itr->first);
- }
-}
-
-template < typename DATA_TYPE >
-F32 LLPrimLinkInfo< DATA_TYPE >::getDiameter() const
-{
- return 2.f * mBoundingSphere.getRadius();
-}
-
-template < typename DATA_TYPE >
-LLVector3 LLPrimLinkInfo< DATA_TYPE >::getCenter() const
-{
- return mBoundingSphere.getCenter();
-}
-
-template < typename DATA_TYPE >
-F32 LLPrimLinkInfo< DATA_TYPE >::get_max_linkable_span(const LLSphere& first, const LLSphere& second)
-{
- F32 max_span = 3.f * (first.getRadius() + second.getRadius()) + OBJECT_SPAN_BONUS;
- if (max_span > MAX_OBJECT_SPAN)
- {
- max_span = MAX_OBJECT_SPAN;
- }
-
- return max_span;
-}
-
-template < typename DATA_TYPE >
-F32 LLPrimLinkInfo< DATA_TYPE >::get_span(const LLSphere& first, const LLSphere& second)
-{
- F32 span = (first.getCenter() - second.getCenter()).length()
- + first.getRadius() + second.getRadius();
- return span;
-}
-
-// static
-// returns 'true' if this info can link with any part of other_info
-template < typename DATA_TYPE >
-bool LLPrimLinkInfo< DATA_TYPE >::canLink(const LLPrimLinkInfo& other_info)
-{
- F32 max_span = get_max_linkable_span(mBoundingSphere, other_info.mBoundingSphere);
-
- F32 span = get_span(mBoundingSphere, other_info.mBoundingSphere);
-
- if (span <= max_span)
- {
- // The entire other_info fits inside the max span.
- return TRUE;
- }
- else if (span > max_span + 2.f * other_info.mBoundingSphere.getRadius())
- {
- // there is no way any piece of other_info could link with this one
- return FALSE;
- }
-
- // there may be a piece of other_info that is linkable
- typename std::map< DATA_TYPE, LLSphere >::const_iterator map_itr;
- for (map_itr = other_info.mDataMap.begin(); map_itr != other_info.mDataMap.end(); ++map_itr)
- {
- const LLSphere& other_sphere = (*map_itr).second;
- max_span = get_max_linkable_span(mBoundingSphere, other_sphere);
-
- span = get_span(mBoundingSphere, other_sphere);
-
- if (span <= max_span)
- {
- // found one piece that is linkable
- return TRUE;
- }
- }
- return FALSE;
-}
-
-// merges elements of 'unlinked'
-// returns number of links made (NOT final prim count, NOR linked prim count)
-// and removes any linkable infos from 'unlinked'
-template < typename DATA_TYPE >
-void LLPrimLinkInfo< DATA_TYPE >::mergeLinkableSet(std::list< LLPrimLinkInfo< DATA_TYPE > > & unlinked)
-{
- bool linked_something = true;
- while (linked_something)
- {
- linked_something = false;
-
- typename std::list< LLPrimLinkInfo< DATA_TYPE > >::iterator other_itr = unlinked.begin();
- while ( other_itr != unlinked.end()
- && getPrimCount() < MAX_PRIMS_PER_OBJECT )
- {
- S32 merge_count = merge(*other_itr);
- if (merge_count > 0)
- {
- linked_something = true;
- }
- if (0 == (*other_itr).getPrimCount())
- {
- unlinked.erase(other_itr++);
- }
- else
- {
- ++other_itr;
- }
- }
- if (!linked_something
- && unlinked.size() > 1)
- {
- S32 collapse_count = collapse(unlinked);
- if (collapse_count > 0)
- {
- linked_something = true;
- }
- }
- }
-}
-
-// transforms all of the spheres into a new reference frame
-template < typename DATA_TYPE >
-void LLPrimLinkInfo< DATA_TYPE >::transform(const LLVector3& position, const LLQuaternion& rotation)
-{
- typename std::map< DATA_TYPE, LLSphere >::iterator map_itr;
- for (map_itr = mDataMap.begin(); map_itr != mDataMap.end(); ++map_itr)
- {
- (*map_itr).second.setCenter((*map_itr).second.getCenter() * rotation + position);
- }
- mBoundingSphere.setCenter(mBoundingSphere.getCenter() * rotation + position);
-}
-
-// private
-// returns number of links made
-template < typename DATA_TYPE >
-S32 LLPrimLinkInfo< DATA_TYPE >::merge(LLPrimLinkInfo& other_info)
-{
- S32 link_count = 0;
-
-// F32 other_radius = other_info.mBoundingSphere.getRadius();
-// other_info.computeBoundingSphere();
-// if ( other_radius != other_info.mBoundingSphere.getRadius() )
-// {
-// LL_INFOS() << "Other bounding sphere changed!!" << LL_ENDL;
-// }
-
-// F32 this_radius = mBoundingSphere.getRadius();
-// computeBoundingSphere();
-// if ( this_radius != mBoundingSphere.getRadius() )
-// {
-// LL_INFOS() << "This bounding sphere changed!!" << LL_ENDL;
-// }
-
-
- F32 max_span = get_max_linkable_span(mBoundingSphere, other_info.mBoundingSphere);
-
- // F32 center_dist = (mBoundingSphere.getCenter() - other_info.mBoundingSphere.getCenter()).length();
- // LL_INFOS() << "objects are " << center_dist << "m apart" << LL_ENDL;
- F32 span = get_span(mBoundingSphere, other_info.mBoundingSphere);
-
- F32 span_limit = max_span + (2.f * other_info.mBoundingSphere.getRadius());
- if (span > span_limit)
- {
- // there is no way any piece of other_info could link with this one
- // LL_INFOS() << "span too large: " << span << " vs. " << span_limit << LL_ENDL;
- return 0;
- }
-
- bool completely_linkable = (span <= max_span) ? true : false;
-
- typename std::map< DATA_TYPE, LLSphere >::iterator map_itr = other_info.mDataMap.begin();
- while (map_itr != other_info.mDataMap.end()
- && getPrimCount() < MAX_PRIMS_PER_OBJECT )
- {
- DATA_TYPE other_data = (*map_itr).first;
- LLSphere& other_sphere = (*map_itr).second;
-
- if (!completely_linkable)
- {
- max_span = get_max_linkable_span(mBoundingSphere, other_sphere);
-
- F32 span = get_span(mBoundingSphere, other_sphere);
-
- if (span > max_span)
- {
- ++map_itr;
- continue;
- }
- }
-
- mDataMap[other_data] = other_sphere;
- ++link_count;
-
- if (!mBoundingSphere.contains(other_sphere) )
- {
- computeBoundingSphere();
- }
-
- // remove from the other info
- other_info.mDataMap.erase(map_itr++);
- }
-
- if (link_count > 0 && other_info.getPrimCount() > 0)
- {
- other_info.computeBoundingSphere();
- }
- return link_count;
-}
-
-// links any linkable elements of unlinked
-template < typename DATA_TYPE >
-S32 LLPrimLinkInfo< DATA_TYPE >::collapse(std::list< LLPrimLinkInfo< DATA_TYPE > > & unlinked)
-{
- S32 link_count = 0;
- bool linked_something = true;
- while (linked_something)
- {
- linked_something = false;
-
- typename std::list< LLPrimLinkInfo< DATA_TYPE > >::iterator this_itr = unlinked.begin();
- typename std::list< LLPrimLinkInfo< DATA_TYPE > >::iterator other_itr = this_itr;
- ++other_itr;
- while ( other_itr != unlinked.end() )
-
- {
- S32 merge_count = (*this_itr).merge(*other_itr);
- if (merge_count > 0)
- {
- linked_something = true;
- link_count += merge_count;
- }
- if (0 == (*other_itr).getPrimCount())
- {
- unlinked.erase(other_itr++);
- }
- else
- {
- ++other_itr;
- }
- }
- }
- return link_count;
-}
-
-
-template < typename DATA_TYPE >
-void LLPrimLinkInfo< DATA_TYPE >::computeBoundingSphere()
-{
- std::vector< LLSphere > sphere_list;
- typename std::map< DATA_TYPE, LLSphere >::const_iterator map_itr;
- for (map_itr = mDataMap.begin(); map_itr != mDataMap.end(); ++map_itr)
- {
- sphere_list.push_back(map_itr->second);
- }
- mBoundingSphere = LLSphere::getBoundingSphere(sphere_list);
-}
-
-
-#endif
-
diff --git a/indra/test/CMakeLists.txt b/indra/test/CMakeLists.txt
index 87b4e5e454..c1e63a7470 100644
--- a/indra/test/CMakeLists.txt
+++ b/indra/test/CMakeLists.txt
@@ -17,128 +17,34 @@ set(test_lib_SOURCE_FILES
set(test_lib_HEADER_FILES
CMakeLists.txt
- lltut.h
- )
-
-list(APPEND test_lib_SOURCE_FILES ${test_lib_HEADER_FILES})
-
-add_library(lltut_runner_lib ${test_lib_SOURCE_FILES})
-
-target_link_libraries(lltut_runner_lib PRIVATE llcommon)
-
-set_target_properties(lltut_runner_lib
- PROPERTIES
- FOLDER "Tests"
- )
-
-set(test_SOURCE_FILES
- io.cpp
- llapp_tut.cpp
- llbuffer_tut.cpp
- lldoubledispatch_tut.cpp
- llevents_tut.cpp
- llhttpdate_tut.cpp
- llhttpnode_tut.cpp
- lliohttpserver_tut.cpp
- llmessageconfig_tut.cpp
- llpermissions_tut.cpp
- llpipeutil.cpp
- llsaleinfo_tut.cpp
- llsdmessagebuilder_tut.cpp
- llsdmessagereader_tut.cpp
- llsd_new_tut.cpp
- llsdutil_tut.cpp
- llservicebuilder_tut.cpp
- llstreamtools_tut.cpp
- lltemplatemessagebuilder_tut.cpp
- message_tut.cpp
- )
-
-set(test_HEADER_FILES
- CMakeLists.txt
+ catch_and_store_what_in.h
+ chained_callback.h
debug.h
- llpipeutil.h
llsdtraits.h
+ lltestapp.h
lltut.h
+ namedtempfile.h
+ print.h
+ setenv.h
sync.h
+ test.h
)
-if (NOT WINDOWS)
- list(APPEND test_SOURCE_FILES
- llmessagetemplateparser_tut.cpp
- )
-endif (NOT WINDOWS)
-
-list(APPEND test_SOURCE_FILES ${test_HEADER_FILES})
+list(APPEND test_lib_SOURCE_FILES ${test_lib_HEADER_FILES})
-add_executable(lltest ${test_SOURCE_FILES})
+add_library(lltut_runner_lib ${test_lib_SOURCE_FILES})
-target_link_libraries(lltest
- lltut_runner_lib
- llinventory
- llmessage
- llmath
- llfilesystem
- llxml
- llcommon
- llcorehttp
- )
+target_link_libraries(lltut_runner_lib PRIVATE llcommon)
-set_target_properties(lltest
+set_target_properties(lltut_runner_lib
PROPERTIES
FOLDER "Tests"
)
-if (WINDOWS)
- set_target_properties(lltest
- PROPERTIES
- LINK_FLAGS "/NODEFAULTLIB:LIBCMT"
- LINK_FLAGS_DEBUG "/NODEFAULTLIB:\"LIBCMT;LIBCMTD;MSVCRT\""
- RUNTIME_OUTPUT_DIRECTORY "${EXE_STAGING_DIR}"
- )
-elseif (DARWIN)
+if (DARWIN)
set_target_properties(lltut_runner_lib
PROPERTIES
OSX_ARCHITECTURES ${LL_MACOS_TEST_ARCHITECTURE}
)
- set_target_properties(lltest
- PROPERTIES
- OSX_ARCHITECTURES ${LL_MACOS_TEST_ARCHITECTURE}
- )
- # Support our "@executable_path/../Resources" load path for our test
- # executable. This SHOULD properly be "$<TARGET_FILE_DIR:lltest>/Resources",
- # but the CMake $<TARGET_FILE_DIR> generator expression isn't evaluated by
- # CREATE_LINK, so fudge it.
- file(CREATE_LINK "../sharedlibs/Release/Resources" "${CMAKE_BINARY_DIR}/test/Resources"
- SYMBOLIC)
-endif (WINDOWS)
-
-# This should cause the test executable to be built, but not
-# run if LL_TESTS is disabled. This will hopefully keep the
-# tests up to date with any code changes changes even if
-# developers choose to disable LL_TESTS.
-if (LL_TESTS)
- set(TEST_EXE $<TARGET_FILE:lltest>)
-
- SET_TEST_PATH(LD_LIBRARY_PATH)
-
- LL_TEST_COMMAND(command
- "${LD_LIBRARY_PATH}"
- "${TEST_EXE}"
- "--output=${CMAKE_CURRENT_BINARY_DIR}/cpp_test_results.txt"
- "--touch=${CMAKE_CURRENT_BINARY_DIR}/cpp_tests_ok.txt")
-
- add_test(NAME "C++ unit tests" COMMAND ${command} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
-
- add_dependencies(BUILD_TESTS lltest)
- if(DARWIN)
- # Support our "@executable_path/../Resources" load path for our test
- # executable. This SHOULD properly be "$<TARGET_FILE_DIR:lltest>/Resources",
- # but the CMake $<TARGET_FILE_DIR> generator expression isn't evaluated by
- # CREATE_LINK, so fudge it.
- add_custom_command( TARGET lltest POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E create_symlink ${SHARED_LIB_STAGING_DIR} ${CMAKE_BINARY_DIR}/test/Resources
- )
- endif()
-endif (LL_TESTS)
+endif ()
diff --git a/indra/test/hexdump.h b/indra/test/hexdump.h
deleted file mode 100644
index 95f1e297c3..0000000000
--- a/indra/test/hexdump.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/**
- * @file hexdump.h
- * @author Nat Goodspeed
- * @date 2023-09-08
- * @brief Provide hexdump() and hexmix() ostream formatters
- *
- * $LicenseInfo:firstyear=2023&license=viewerlgpl$
- * Copyright (c) 2023, Linden Research, Inc.
- * $/LicenseInfo$
- */
-
-#if ! defined(LL_HEXDUMP_H)
-#define LL_HEXDUMP_H
-
-#include <cctype>
-#include <iomanip>
-#include <iostream>
-#include <string_view>
-
-// Format a given byte string as 2-digit hex values, no separators
-// Usage: std::cout << hexdump(somestring) << ...
-class hexdump
-{
-public:
- hexdump(const std::string_view& data):
- hexdump(data.data(), data.length())
- {}
-
- hexdump(const char* data, size_t len):
- hexdump(reinterpret_cast<const unsigned char*>(data), len)
- {}
-
- hexdump(const unsigned char* data, size_t len):
- mData(data, data + len)
- {}
-
- friend std::ostream& operator<<(std::ostream& out, const hexdump& self)
- {
- auto oldfmt{ out.flags() };
- auto oldfill{ out.fill() };
- out.setf(std::ios_base::hex, std::ios_base::basefield);
- out.fill('0');
- for (auto c : self.mData)
- {
- out << std::setw(2) << unsigned(c);
- }
- out.setf(oldfmt, std::ios_base::basefield);
- out.fill(oldfill);
- return out;
- }
-
-private:
- std::vector<unsigned char> mData;
-};
-
-// Format a given byte string as a mix of printable characters and, for each
-// non-printable character, "\xnn"
-// Usage: std::cout << hexmix(somestring) << ...
-class hexmix
-{
-public:
- hexmix(const std::string_view& data):
- mData(data)
- {}
-
- hexmix(const char* data, size_t len):
- mData(data, len)
- {}
-
- friend std::ostream& operator<<(std::ostream& out, const hexmix& self)
- {
- auto oldfmt{ out.flags() };
- auto oldfill{ out.fill() };
- out.setf(std::ios_base::hex, std::ios_base::basefield);
- out.fill('0');
- for (auto c : self.mData)
- {
- // std::isprint() must be passed an unsigned char!
- if (std::isprint(static_cast<unsigned char>(c)))
- {
- out << c;
- }
- else
- {
- out << "\\x" << std::setw(2) << unsigned(c);
- }
- }
- out.setf(oldfmt, std::ios_base::basefield);
- out.fill(oldfill);
- return out;
- }
-
-private:
- std::string mData;
-};
-
-#endif /* ! defined(LL_HEXDUMP_H) */
diff --git a/indra/test/llassetuploadqueue_tut.cpp b/indra/test/llassetuploadqueue_tut.cpp
deleted file mode 100644
index be5f9e4288..0000000000
--- a/indra/test/llassetuploadqueue_tut.cpp
+++ /dev/null
@@ -1,195 +0,0 @@
-/**
- * @file asset_upload_queue_tut.cpp
- * @brief Tests for newview/llassetuploadqueue.cpp
- *
- * $LicenseInfo:firstyear=2007&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#include "linden_common.h"
-#include "lltut.h"
-
-#include "mock_http_client.h"
-#include "../newview/llassetuploadqueue.cpp"
-
-// Mock implementation.
-LLAssetUploadResponder::LLAssetUploadResponder(const LLSD& post_data,
- const LLUUID& vfile_id,
- LLAssetType::EType asset_type)
-{
-}
-
-LLAssetUploadResponder::LLAssetUploadResponder(const LLSD& post_data, const std::string& file_name)
-{
-}
-
-LLAssetUploadResponder::~LLAssetUploadResponder()
-{
-}
-
-void LLAssetUploadResponder::httpFailure()
-{
-}
-
-void LLAssetUploadResponder::httpSuccess()
-{
-}
-
-void LLAssetUploadResponder::uploadUpload(const LLSD& content)
-{
-}
-
-void LLAssetUploadResponder::uploadComplete(const LLSD& content)
-{
-}
-
-void LLAssetUploadResponder::uploadFailure(const LLSD& content)
-{
-}
-
-LLUpdateTaskInventoryResponder::LLUpdateTaskInventoryResponder(const LLSD& post_data,
- const LLUUID& vfile_id,
- LLAssetType::EType asset_type) :
- LLAssetUploadResponder(post_data, vfile_id, asset_type)
-{
-}
-
-LLUpdateTaskInventoryResponder::LLUpdateTaskInventoryResponder(const LLSD& post_data,
- const std::string& file_name) :
- LLAssetUploadResponder(post_data, file_name)
-{
-}
-
-LLUpdateTaskInventoryResponder::LLUpdateTaskInventoryResponder(const LLSD& post_data,
- const std::string& file_name,
- const LLUUID& queue_id) :
- LLAssetUploadResponder(post_data, file_name)
-{
-}
-
-void LLUpdateTaskInventoryResponder::uploadComplete(const LLSD& content)
-{
-}
-
-namespace tut
-{
- class asset_upload_queue_test_data : public MockHttpClient {};
- typedef test_group<asset_upload_queue_test_data> asset_upload_queue_test;
- typedef asset_upload_queue_test::object asset_upload_queue_object;
- tut::asset_upload_queue_test asset_upload_queue("asset_upload_queue");
-
- void queue(LLAssetUploadQueue& q, const std::string& filename)
- {
- LLUUID task_id;
- LLUUID item_id;
- BOOL is_running = FALSE;
- BOOL is_target_mono = TRUE;
- LLUUID queue_id;
- q.queue(filename, task_id, item_id, is_running, is_target_mono, queue_id);
- }
-
- class LLTestSupplier : public LLAssetUploadQueueSupplier
- {
- public:
-
- void set(LLAssetUploadQueue* queue) {mQueue = queue;}
-
- virtual LLAssetUploadQueue* get() const
- {
- return mQueue;
- }
-
- private:
- LLAssetUploadQueue* mQueue;
- };
-
- template<> template<>
- void asset_upload_queue_object::test<1>()
- {
- setupTheServer();
- reset();
- LLTestSupplier* supplier = new LLTestSupplier();
- LLAssetUploadQueue q("http://localhost:8888/test/success", supplier);
- supplier->set(&q);
- queue(q, "foo.bar");
- ensure("upload queue not empty before request", q.isEmpty());
- runThePump(10);
- ensure("upload queue not empty after request", q.isEmpty());
- }
-
- template<> template<>
- void asset_upload_queue_object::test<2>()
- {
- reset();
- LLTestSupplier* supplier = new LLTestSupplier();
- LLAssetUploadQueue q("http://localhost:8888/test/error", supplier);
- supplier->set(&q);
- queue(q, "foo.bar");
- ensure("upload queue not empty before request", q.isEmpty());
- runThePump(10);
- ensure("upload queue not empty after request", q.isEmpty());
- }
-
- template<> template<>
- void asset_upload_queue_object::test<3>()
- {
- reset();
- LLTestSupplier* supplier = new LLTestSupplier();
- LLAssetUploadQueue q("http://localhost:8888/test/timeout", supplier);
- supplier->set(&q);
- queue(q, "foo.bar");
- ensure("upload queue not empty before request", q.isEmpty());
- runThePump(10);
- ensure("upload queue not empty after request", q.isEmpty());
- }
-
- template<> template<>
- void asset_upload_queue_object::test<4>()
- {
- reset();
- LLTestSupplier* supplier = new LLTestSupplier();
- LLAssetUploadQueue q("http://localhost:8888/test/success", supplier);
- supplier->set(&q);
- queue(q, "foo.bar");
- queue(q, "baz.bar");
- ensure("upload queue empty before request", !q.isEmpty());
- runThePump(10);
- ensure("upload queue not empty before request", q.isEmpty());
- runThePump(10);
- ensure("upload queue not empty after request", q.isEmpty());
- }
-
- template<> template<>
- void asset_upload_queue_object::test<5>()
- {
- reset();
- LLTestSupplier* supplier = new LLTestSupplier();
- LLAssetUploadQueue q("http://localhost:8888/test/success", supplier);
- supplier->set(&q);
- queue(q, "foo.bar");
- runThePump(10);
- ensure("upload queue not empty before request", q.isEmpty());
- queue(q, "baz.bar");
- ensure("upload queue not empty after request", q.isEmpty());
- runThePump(10);
- killServer();
- }
-}
diff --git a/indra/test/lltimestampcache_tut.cpp b/indra/test/lltimestampcache_tut.cpp
deleted file mode 100644
index 857dfe6e6e..0000000000
--- a/indra/test/lltimestampcache_tut.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-/**
- * @file lltimestampcache_tut.cpp
- * @author James Tess
- * @date 2008-12-03
- *
- * $LicenseInfo:firstyear=2008&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#include <tut/tut.hpp>
-
-#include "linden_common.h"
-#include "../mapserver/lltimestampcache.h"
-#include "lltut.h"
-
-
-namespace tut
-{
- struct LLTimestampCacheTestData
- {
- };
-
- typedef test_group<LLTimestampCacheTestData> LLTimestampCacheTestGroup;
- typedef LLTimestampCacheTestGroup::object LLTimestampCacheTestObject;
-
- LLTimestampCacheTestGroup timestampCacheTestGroup("LLTimestampCache");
-
- // Most common usage
- template<> template<>
- void LLTimestampCacheTestObject::test<1>()
- {
- LLTimestampCache<std::string, std::string> cache;
- // put in some data
- cache.insert("key1", "val1", 1);
- cache.insert("key2", "val2", 2);
- cache.insert("key3", "val3", 3);
- ensure_equals("size is 3", cache.size(), 3);
- // check some items
- ensure("has key1", cache.has("key1"));
- ensure("no invalid key", !cache.has("invalid key"));
- // get some items
- ensure_equals("get key1", cache.get("key1", 4), "val1");
- ensure_equals("get invalid key",
- cache.get("invalid key", 4), std::string() );
- // timestamps
- ensure_equals("key1 timestamp updated", cache.getTimestamp("key1"), 4);
- ensure_equals("invalid key timestamp",
- cache.getTimestamp("invalid key"), 0);
- }
-
- // New empty cache shouldn't have any entries
- template<> template<>
- void LLTimestampCacheTestObject::test<2>()
- {
- LLTimestampCache<std::string, std::string> cache;
- ensure_equals("starts empty", cache.size(), 0);
- ensure_equals("has nothing", cache.has("foo"), false);
- ensure_equals("gets nothing", cache.get("foo", 0), std::string() );
- U32 max_time = 0xFFFFFFFF;
- ensure_equals("erases nothing", cache.eraseBefore(max_time), 0);
- }
-
- // Non empty cache
- template<> template<>
- void LLTimestampCacheTestObject::test<3>()
- {
- LLTimestampCache<std::string, std::string> cache;
- cache.insert("foo", "bar", 123);
- ensure_equals("size one", cache.size(), 1);
- ensure_equals("has it", cache.has("foo"), true);
- ensure_equals("timestamp correct", cache.getTimestamp("foo"), 123);
- std::string value = cache.get("foo", 456);
- ensure_equals("get value", value, "bar");
- ensure_equals("timestamp updated", cache.getTimestamp("foo"), 456);
- ensure_equals("erase nothing", cache.eraseBefore(0), 0);
- ensure_equals("erase one", cache.eraseBefore(789), 1);
- ensure_equals("empty after erase", cache.size(), 0);
- }
-
- // Recache of item should update timestamp
- template<> template<>
- void LLTimestampCacheTestObject::test<4>()
- {
- LLTimestampCache<std::string, std::string> cache;
- cache.insert("foo", "bar", 123);
- cache.insert("foo", "bar", 456);
- ensure_equals("duplicate suppressed", cache.size(), 1);
- ensure_equals("timestamp replaced", cache.getTimestamp("foo"), 456);
- }
-
- // Erasing some items
- template<> template<>
- void LLTimestampCacheTestObject::test<5>()
- {
- LLTimestampCache<std::string, std::string> cache;
- cache.insert("key1", "val1", 1);
- cache.insert("key2", "val2", 2);
- cache.insert("key3", "val3", 3);
- cache.insert("key4", "val4", 4);
- size_t erased = cache.eraseBefore(3);
- ensure_equals("erase range", erased, 2);
- ensure_equals("cache post erase", cache.size(), 2);
- ensure_equals("has key3", cache.has("key3"), true);
- ensure_equals("not has key2", cache.has("key2"), false);
- }
-}
diff --git a/indra/test/lltranscode_tut.cpp b/indra/test/lltranscode_tut.cpp
deleted file mode 100644
index 23d554d46d..0000000000
--- a/indra/test/lltranscode_tut.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- * @file llscriptresource_tut.cpp
- * @brief Test LLScriptResource
- *
- * $LicenseInfo:firstyear=2008&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-//#include <tut/tut.h>
-#include "linden_common.h"
-
-#include "lltut.h"
-
-#include "../newsim/lltranscode.cpp" // include TU to pull in newsim implementation.
-
-static const char test_utf8[] = "Edelwei\xc3\x9f";
-static const char test_utf7[] = "Edelwei+AN8-";
-static const char test_latin1[] = "Edelwei\xdf";
-static const char test_latin2[] = "Edelwei\xdf";
-
-namespace tut
-{
- class LLTranscodeTestData
- {
- };
-
- typedef test_group<LLTranscodeTestData> LLTranscodeTestGroup;
- typedef LLTranscodeTestGroup::object LLTranscodeTestObject;
- LLTranscodeTestGroup transcodeTestGroup("transcode");
-
- template<> template<>
- void LLTranscodeTestObject::test<1>()
- {
- // Test utf8
- std::stringstream input;
- std::stringstream output;
-
- input.str(test_utf7);
- output.clear();
- LLTranscode::transcode("charset=UTF-7", input, output);
- ensure_equals("UTF-7 to UTF-8 transcoding", output.str(),
- std::string(test_utf8));
-
- input.str(test_latin1);
- output.clear();
- LLTranscode::transcode("", input, output);
- ensure_equals("Default (latin_1) to UTF8 transcoding", output.str(),
- std::string(test_utf8));
-
- input.str(test_latin1);
- output.clear();
- LLTranscode::transcode("charset=iso-8859-1", input, output);
- ensure_equals("latin_1 (ISO-8859-1) to UTF8 transcoding", output.str(),
- std::string(test_utf8));
-
- input.str(test_latin2);
- output.clear();
- LLTranscode::transcode("charset=iso-8859-2", input, output);
- ensure_equals("latin_2 (ISO-8859-2) to UTF8 transcoding", output.str(),
- std::string(test_utf8));
-
- input.str(test_utf8);
- output.clear();
- LLTranscode::transcode("charset=utf-8", input, output);
- ensure_equals("UTF8 to UTF8 transcoding", output.str(),
- std::string(test_utf8));
- }
-}
diff --git a/indra/test/mock_http_client.cpp b/indra/test/mock_http_client.cpp
deleted file mode 100644
index a97d31c7f4..0000000000
--- a/indra/test/mock_http_client.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/**
- * @file mock_http_client.cpp
- * @brief Framework for testing HTTP requests
- *
- * $LicenseInfo:firstyear=2007&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#include "linden_common.h"
-#include "llhttpnode.h"
-
-namespace tut
-{
- class SuccessNode : public LLHTTPNode
- {
- public:
- void get(ResponsePtr r, const LLSD& context) const
- {
- LLSD result;
- result["state"] = "complete";
- result["test"] = "test";
- r->result(result);
- }
- void post(ResponsePtr r, const LLSD& context, const LLSD& input) const
- {
- LLSD result;
- result["state"] = "complete";
- result["test"] = "test";
- r->result(result);
- }
- };
-
- class ErrorNode : public LLHTTPNode
- {
- public:
- void get(ResponsePtr r, const LLSD& context) const
- { r->status(599, "Intentional error"); }
- void post(ResponsePtr r, const LLSD& context, const LLSD& input) const
- { r->status(input["status"], input["reason"]); }
- };
-
- class TimeOutNode : public LLHTTPNode
- {
- public:
- void get(ResponsePtr r, const LLSD& context) const
- {
- /* do nothing, the request will eventually time out */
- }
- };
-
- LLSD storage;
-
- class LLSDStorageNode : public LLHTTPNode
- {
- public:
- LLSD get() const{ return storage; }
- LLSD put(const LLSD& value) const{ storage = value; return LLSD(); }
- };
-
- LLHTTPRegistration<LLSDStorageNode> gStorageNode("/test/storage");
- LLHTTPRegistration<SuccessNode> gSuccessNode("/test/success");
- LLHTTPRegistration<ErrorNode> gErrorNode("/test/error");
- LLHTTPRegistration<TimeOutNode> gTimeOutNode("/test/timeout");
-}
diff --git a/indra/test/mock_http_client.h b/indra/test/mock_http_client.h
deleted file mode 100644
index ef268abc6e..0000000000
--- a/indra/test/mock_http_client.h
+++ /dev/null
@@ -1,190 +0,0 @@
-/**
- * @file mock_http_client.cpp
- * @brief Framework for testing HTTP requests
- *
- * $LicenseInfo:firstyear=2007&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#include "llsdhttpserver.h"
-#include "lliohttpserver.h"
-#include "llhttpclient.h"
-#include "llformat.h"
-#include "llpipeutil.h"
-#include "llpumpio.h"
-
-namespace tut
-{
- struct MockHttpClient
- {
- public:
- MockHttpClient()
- {
- apr_pool_create(&mPool, NULL);
- mServerPump = new LLPumpIO(mPool);
- mClientPump = new LLPumpIO(mPool);
-
- LLHTTPClient::setPump(*mClientPump);
- }
-
- ~MockHttpClient()
- {
- delete mServerPump;
- delete mClientPump;
- apr_pool_destroy(mPool);
- }
-
- void setupTheServer()
- {
- LLHTTPNode& root = LLIOHTTPServer::create(mPool, *mServerPump, 8888);
-
- LLHTTPStandardServices::useServices();
- LLHTTPRegistrar::buildAllServices(root);
- }
-
- void runThePump(float timeout = 100.0f)
- {
- LLTimer timer;
- timer.setTimerExpirySec(timeout);
-
- while(!mSawCompleted && !timer.hasExpired())
- {
- if (mServerPump)
- {
- mServerPump->pump();
- mServerPump->callback();
- }
- if (mClientPump)
- {
- mClientPump->pump();
- mClientPump->callback();
- }
- }
- }
-
- void killServer()
- {
- delete mServerPump;
- mServerPump = NULL;
- }
-
- private:
- apr_pool_t* mPool;
- LLPumpIO* mServerPump;
- LLPumpIO* mClientPump;
-
-
- protected:
- void ensureStatusOK()
- {
- if (mSawError)
- {
- std::string msg =
- llformat("httpFailure() called when not expected, status %d",
- mStatus);
- fail(msg);
- }
- }
-
- void ensureStatusError()
- {
- if (!mSawError)
- {
- fail("httpFailure() wasn't called");
- }
- }
-
- LLSD getResult()
- {
- return mResult;
- }
-
- protected:
- bool mSawError;
- S32 mStatus;
- std::string mReason;
- bool mSawCompleted;
- LLSD mResult;
- bool mResultDeleted;
-
- class Result : public LLHTTPClient::Responder
- {
- protected:
- Result(MockHttpClient& client)
- : mClient(client)
- {
- }
-
- public:
- static boost::intrusive_ptr<Result> build(MockHttpClient& client)
- {
- return boost::intrusive_ptr<Result>(new Result(client));
- }
-
- ~Result()
- {
- mClient.mResultDeleted = true;
- }
-
- protected:
- virtual void httpFailure()
- {
- mClient.mSawError = true;
- mClient.mStatus = getStatus();
- mClient.mReason = getReason();
- }
-
- virtual void httpSuccess()
- {
- mClient.mResult = getContent();
- }
-
- virtual void httpCompleted()
- {
- LLHTTPClient::Responder::httpCompleted();
-
- mClient.mSawCompleted = true;
- }
-
- private:
- MockHttpClient& mClient;
- };
-
- friend class Result;
-
- protected:
-
- void reset()
- {
- mSawError = false;
- mStatus = 0;
- mSawCompleted = false;
- mResult.clear();
- mResultDeleted = false;
- }
-
- LLHTTPClient::ResponderPtr newResult()
- {
- reset();
- return Result::build(*this);
- }
- };
-}
diff --git a/indra/test/prim_linkability_tut.cpp b/indra/test/prim_linkability_tut.cpp
deleted file mode 100644
index 3603b25f18..0000000000
--- a/indra/test/prim_linkability_tut.cpp
+++ /dev/null
@@ -1,495 +0,0 @@
-/**
- * @file linkability.cpp
- * @author andrew@lindenlab.com
- * @date 2007-04-23
- * @brief Tests for the LLPrimLinkInfo template which computes the linkability of prims
- *
- * $LicenseInfo:firstyear=2007&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#include "linden_common.h"
-#include "lltut.h"
-#include "llprimlinkinfo.h"
-#include "llrand.h"
-
-
-// helper function
-void randomize_sphere(LLSphere& sphere, F32 center_range, F32 radius_range)
-{
- F32 radius = ll_frand(2.f * radius_range) - radius_range;
- LLVector3 center;
- for (S32 i=0; i<3; ++i)
- {
- center.mV[i] = ll_frand(2.f * center_range) - center_range;
- }
- sphere.setRadius(radius);
- sphere.setCenter(center);
-}
-
-// helper function. Same as above with a min and max radius.
-void randomize_sphere(LLSphere& sphere, F32 center_range, F32 minimum_radius, F32 maximum_radius)
-{
- F32 radius = ll_frand(maximum_radius - minimum_radius) + minimum_radius;
- LLVector3 center;
- for (S32 i=0; i<3; ++i)
- {
- center.mV[i] = ll_frand(2.f * center_range) - center_range;
- }
- sphere.setRadius(radius);
- sphere.setCenter(center);
-}
-
-// helper function
-bool random_sort( const LLPrimLinkInfo< S32 >&, const LLPrimLinkInfo< S32 >& b)
-{
- return (ll_rand(64) < 32);
-}
-
-namespace tut
-{
- struct linkable_data
- {
- LLPrimLinkInfo<S32> info;
- };
-
- typedef test_group<linkable_data> linkable_test;
- typedef linkable_test::object linkable_object;
- tut::linkable_test wtf("prim linkability");
-
- template<> template<>
- void linkable_object::test<1>()
- {
- // Here we test the boundary of the LLPrimLinkInfo::canLink() method
- // between semi-random middle-sized objects.
-
- S32 number_of_tests = 100;
- for (S32 test = 0; test < number_of_tests; ++test)
- {
- // compute the radii that would provide the above max link distance
- F32 first_radius = 0.f;
- F32 second_radius = 0.f;
-
- // compute a random center for the first sphere
- // compute some random max link distance
- F32 max_link_span = ll_frand(MAX_OBJECT_SPAN);
- if (max_link_span < OBJECT_SPAN_BONUS)
- {
- max_link_span += OBJECT_SPAN_BONUS;
- }
- LLVector3 first_center(
- ll_frand(2.f * max_link_span) - max_link_span,
- ll_frand(2.f * max_link_span) - max_link_span,
- ll_frand(2.f * max_link_span) - max_link_span);
-
- // put the second sphere at the right distance from the origin
- // such that it is within the max_link_distance of the first
- LLVector3 direction(ll_frand(2.f) - 1.f, ll_frand(2.f) - 1.f, ll_frand(2.f) - 1.f);
- direction.normalize();
- F32 half_milimeter = 0.0005f;
- LLVector3 second_center;
-
- // max_span = 3 * (first_radius + second_radius) + OBJECT_SPAN_BONUS
- // make sure they link at short distances
- {
- second_center = first_center + (OBJECT_SPAN_BONUS - half_milimeter) * direction;
- LLPrimLinkInfo<S32> first_info(0, LLSphere(first_center, first_radius) );
- LLPrimLinkInfo<S32> second_info(1, LLSphere(second_center, second_radius) );
- ensure("these nearby objects should link", first_info.canLink(second_info) );
- }
-
- // make sure they fail to link if we move them apart just a little bit
- {
- second_center = first_center + (OBJECT_SPAN_BONUS + half_milimeter) * direction;
- LLPrimLinkInfo<S32> first_info(0, LLSphere(first_center, first_radius) );
- LLPrimLinkInfo<S32> second_info(1, LLSphere(second_center, second_radius) );
- ensure("these nearby objects should NOT link", !first_info.canLink(second_info) );
- }
-
- // make sure the objects link or not at medium distances
- {
- first_radius = 0.3f * ll_frand(max_link_span - OBJECT_SPAN_BONUS);
-
- // This is the exact second radius that will link at exactly our random max_link_distance
- second_radius = ((max_link_span - OBJECT_SPAN_BONUS) / 3.f) - first_radius;
- second_center = first_center + (max_link_span - first_radius - second_radius - half_milimeter) * direction;
-
- LLPrimLinkInfo<S32> first_info(0, LLSphere(first_center, first_radius) );
- LLPrimLinkInfo<S32> second_info(1, LLSphere(second_center, second_radius) );
-
- ensure("these objects should link", first_info.canLink(second_info) );
- }
-
- // make sure they fail to link if we move them apart just a little bit
- {
- // move the second sphere such that it is a little too far from the first
- second_center += (2.f * half_milimeter) * direction;
- LLPrimLinkInfo<S32> first_info(0, LLSphere(first_center, first_radius) );
- LLPrimLinkInfo<S32> second_info(1, LLSphere(second_center, second_radius) );
-
- ensure("these objects should NOT link", !first_info.canLink(second_info) );
- }
-
- // make sure things don't link at far distances
- {
- second_center = first_center + (MAX_OBJECT_SPAN + 2.f * half_milimeter) * direction;
- second_radius = 0.3f * MAX_OBJECT_SPAN;
- LLPrimLinkInfo<S32> first_info(0, LLSphere(first_center, first_radius) );
- LLPrimLinkInfo<S32> second_info(1, LLSphere(second_center, second_radius) );
- ensure("these objects should NOT link", !first_info.canLink(second_info) );
- }
-
- }
- }
-
- template<> template<>
- void linkable_object::test<2>()
- {
-
- // Consider a row of eight spheres in a row, each 10m in diameter and centered
- // at 10m intervals: 01234567.
-
- F32 radius = 5.f;
- F32 spacing = 10.f;
-
- LLVector3 line_direction(ll_frand(2.f) - 1.f, ll_frand(2.f) - 1.f, ll_frand(2.f) - 1.f);
- line_direction.normalize();
-
- LLVector3 first_center(ll_frand(2.f * spacing) -spacing, ll_frand(2.f * spacing) - spacing, ll_frand(2.f * spacing) - spacing);
-
- LLPrimLinkInfo<S32> infos[8];
-
- for (S32 index = 0; index < 8; ++index)
- {
- LLVector3 center = first_center + ((F32)(index) * spacing) * line_direction;
- infos[index].set(index, LLSphere(center, radius));
- }
-
- // Max span for 2 spheres of 5m radius is 3 * (5 + 5) + 1 = 31m
- // spheres 0&2 have a 30m span (from outside edge to outside edge) and should link
- {
- LLPrimLinkInfo<S32> root_info = infos[0];
- std::list< LLPrimLinkInfo<S32> > info_list;
- info_list.push_back(infos[2]);
- root_info.mergeLinkableSet(info_list);
- S32 prim_count = root_info.getPrimCount();
- ensure_equals("0&2 prim count should be 2", prim_count, 2);
- ensure_equals("0&2 unlinkable list should have length 0", (S32) info_list.size(), 0);
- }
-
-
- // spheres 0&3 have a 40 meter span and should NOT link outright
- {
- LLPrimLinkInfo<S32> root_info = infos[0];
- std::list< LLPrimLinkInfo<S32> > info_list;
- info_list.push_back(infos[3]);
- root_info.mergeLinkableSet(info_list);
- S32 prim_count = root_info.getPrimCount();
- ensure_equals("0&4 prim count should be 1", prim_count, 1);
- ensure_equals("0&4 unlinkable list should have length 1", (S32) info_list.size(), 1);
- }
-
-
- // spheres 0-4 should link no matter what order : 01234
- // Total span = 50m, 012 link with a r=15.5 giving max span of 3 * (15.5 + 5) + 1 = 62.5, but the cap is 54m
- {
- LLPrimLinkInfo<S32> root_info = infos[0];
- std::list< LLPrimLinkInfo<S32> > info_list;
- for (S32 index = 1; index < 5; ++index)
- {
- info_list.push_back(infos[index]);
- }
- root_info.mergeLinkableSet(info_list);
- S32 prim_count = root_info.getPrimCount();
- ensure_equals("01234 prim count should be 5", prim_count, 5);
- ensure_equals("01234 unlinkable list should have length 0", (S32) info_list.size(), 0);
- }
-
-
- // spheres 0-5 should link no matter what order : 04321
- {
- LLPrimLinkInfo<S32> root_info = infos[0];
- std::list< LLPrimLinkInfo<S32> > info_list;
- for (S32 index = 4; index > 0; --index)
- {
- info_list.push_back(infos[index]);
- }
- root_info.mergeLinkableSet(info_list);
- S32 prim_count = root_info.getPrimCount();
- ensure_equals("04321 prim count should be 5", prim_count, 5);
- ensure_equals("04321 unlinkable list should have length 0", (S32) info_list.size(), 0);
- }
-
- // spheres 0-4 should link no matter what order : 01423
- {
- LLPrimLinkInfo<S32> root_info = infos[0];
- std::list< LLPrimLinkInfo<S32> > info_list;
- info_list.push_back(infos[1]);
- info_list.push_back(infos[4]);
- info_list.push_back(infos[2]);
- info_list.push_back(infos[3]);
- root_info.mergeLinkableSet(info_list);
- S32 prim_count = root_info.getPrimCount();
- ensure_equals("01423 prim count should be 5", prim_count, 5);
- ensure_equals("01423 unlinkable list should have length 0", (S32) info_list.size(), 0);
- }
-
- // spheres 0-5 should NOT fully link, only 0-4
- {
- LLPrimLinkInfo<S32> root_info = infos[0];
- std::list< LLPrimLinkInfo<S32> > info_list;
- for (S32 index = 1; index < 6; ++index)
- {
- info_list.push_back(infos[index]);
- }
- root_info.mergeLinkableSet(info_list);
- S32 prim_count = root_info.getPrimCount();
- ensure_equals("012345 prim count should be 5", prim_count, 5);
- ensure_equals("012345 unlinkable list should have length 1", (S32) info_list.size(), 1);
- std::list< LLPrimLinkInfo<S32> >::iterator info_itr = info_list.begin();
- if (info_itr != info_list.end())
- {
- // examine the contents of the unlinked info
- std::list<S32> unlinked_indecies;
- info_itr->getData(unlinked_indecies);
- // make sure there is only one index in the unlinked_info
- ensure_equals("012345 unlinkable index count should be 1", (S32) unlinked_indecies.size(), 1);
- // make sure its value is 6
- std::list<S32>::iterator unlinked_index_itr = unlinked_indecies.begin();
- S32 unlinkable_index = *unlinked_index_itr;
- ensure_equals("012345 unlinkable index should be 5", (S32) unlinkable_index, 5);
- }
- }
-
- // spheres 0-7 should NOT fully link, only 0-5
- {
- LLPrimLinkInfo<S32> root_info = infos[0];
- std::list< LLPrimLinkInfo<S32> > info_list;
- for (S32 index = 1; index < 8; ++index)
- {
- info_list.push_back(infos[index]);
- }
- root_info.mergeLinkableSet(info_list);
- S32 prim_count = root_info.getPrimCount();
- ensure_equals("01234567 prim count should be 5", prim_count, 5);
- // Should be 1 linkinfo on unlinkable that has 2 prims
- ensure_equals("01234567 unlinkable list should have length 1", (S32) info_list.size(), 1);
- std::list< LLPrimLinkInfo<S32> >::iterator info_itr = info_list.begin();
- if (info_itr != info_list.end())
- {
- // make sure there is only one index in the unlinked_info
- std::list<S32> unlinked_indecies;
- info_itr->getData(unlinked_indecies);
- ensure_equals("0123456 unlinkable index count should be 3", (S32) unlinked_indecies.size(), 3);
-
- // make sure its values are 6 and 7
- std::list<S32>::iterator unlinked_index_itr = unlinked_indecies.begin();
- S32 unlinkable_index = *unlinked_index_itr;
- ensure_equals("0123456 first unlinkable index should be 5", (S32) unlinkable_index, 5);
- ++unlinked_index_itr;
- unlinkable_index = *unlinked_index_itr;
- ensure_equals("0123456 second unlinkable index should be 6", (S32) unlinkable_index, 6);
- ++unlinked_index_itr;
- unlinkable_index = *unlinked_index_itr;
- ensure_equals("0123456 third unlinkable index should be 7", (S32) unlinkable_index, 7);
-
- }
- }
- }
-
- template<> template<>
- void linkable_object::test<3>()
- {
- // Here we test the link results between an LLPrimLinkInfo and a set of
- // randomized LLPrimLinkInfos where the expected results are known.
- S32 number_of_tests = 5;
- for (S32 test = 0; test < number_of_tests; ++test)
- {
- // the radii are known
- F32 first_radius = 1.f;
- F32 second_radius = 2.f;
- F32 third_radius = 3.f;
-
- // compute the distances
- F32 half_milimeter = 0.0005f;
- F32 max_first_second_span = 3.f * (first_radius + second_radius) + OBJECT_SPAN_BONUS;
- F32 linkable_distance = max_first_second_span - first_radius - second_radius - half_milimeter;
-
- F32 max_full_span = 3.f * (0.5f * max_first_second_span + third_radius) + OBJECT_SPAN_BONUS;
- F32 unlinkable_distance = max_full_span - 0.5f * linkable_distance - third_radius + half_milimeter;
-
- // compute some random directions
- LLVector3 first_direction(ll_frand(2.f) - 1.f, ll_frand(2.f) - 1.f, ll_frand(2.f) - 1.f);
- first_direction.normalize();
- LLVector3 second_direction(ll_frand(2.f) - 1.f, ll_frand(2.f) - 1.f, ll_frand(2.f) - 1.f);
- second_direction.normalize();
- LLVector3 third_direction(ll_frand(2.f) - 1.f, ll_frand(2.f) - 1.f, ll_frand(2.f) - 1.f);
- third_direction.normalize();
-
- // compute the centers
- LLVector3 first_center = ll_frand(10.f) * first_direction;
- LLVector3 second_center = first_center + ll_frand(linkable_distance) * second_direction;
- LLVector3 first_join_center = 0.5f * (first_center + second_center);
- LLVector3 third_center = first_join_center + unlinkable_distance * third_direction;
-
- // make sure the second info links and the third does not
- {
- // initialize the infos
- S32 index = 0;
- LLPrimLinkInfo<S32> first_info(index++, LLSphere(first_center, first_radius));
- LLPrimLinkInfo<S32> second_info(index++, LLSphere(second_center, second_radius));
- LLPrimLinkInfo<S32> third_info(index++, LLSphere(third_center, third_radius));
-
- // put the second and third infos in a list
- std::list< LLPrimLinkInfo<S32> > info_list;
- info_list.push_back(second_info);
- info_list.push_back(third_info);
-
- // merge the list with the first_info
- first_info.mergeLinkableSet(info_list);
- S32 prim_count = first_info.getPrimCount();
-
- ensure_equals("prim count should be 2", prim_count, 2);
- ensure_equals("unlinkable list should have length 1", (S32) info_list.size(), 1);
- }
-
- // reverse the order and make sure we get the same results
- {
- // initialize the infos
- S32 index = 0;
- LLPrimLinkInfo<S32> first_info(index++, LLSphere(first_center, first_radius));
- LLPrimLinkInfo<S32> second_info(index++, LLSphere(second_center, second_radius));
- LLPrimLinkInfo<S32> third_info(index++, LLSphere(third_center, third_radius));
-
- // build the list in the reverse order
- std::list< LLPrimLinkInfo<S32> > info_list;
- info_list.push_back(third_info);
- info_list.push_back(second_info);
-
- // merge the list with the first_info
- first_info.mergeLinkableSet(info_list);
- S32 prim_count = first_info.getPrimCount();
-
- ensure_equals("prim count should be 2", prim_count, 2);
- ensure_equals("unlinkable list should have length 1", (S32) info_list.size(), 1);
- }
- }
- }
-
- template<> template<>
- void linkable_object::test<4>()
- {
- // Here we test whether linkability is invarient under permutations
- // of link order. To do this we generate a bunch of random spheres
- // and then try to link them in different ways.
- //
- // NOTE: the linkability will only be invarient if there is only one
- // linkable solution. Multiple solutions will exist if the set of
- // candidates are larger than the maximum linkable distance, or more
- // numerous than a single linked object can contain. This is easily
- // understood by considering a very large set of link candidates,
- // and first linking preferentially to the left until linking fails,
- // then doing the same to the right -- the final solutions will differ.
- // Hence for this test we must generate candidate sets that lie within
- // the linkability envelope of a single object.
- //
- // NOTE: a random set of objects will tend to either be totally linkable
- // or totally not. That is, the random orientations that
-
- F32 root_center_range = 0.f;
- F32 min_prim_radius = 0.1f;
- F32 max_prim_radius = 2.f;
-
- // Linkability is min(MAX_OBJECT_SPAN,3 *( R1 + R2 ) + BONUS)
- // 3 * (min_prim_radius + min_prim_radius) + OBJECT_SPAN_BONUS = 6 * min_prim_radius + OBJECT_SPAN_BONUS;
- // Use .45 instead of .5 to gaurantee objects are within the minimum span.
- F32 child_center_range = 0.45f * ( (6*min_prim_radius) + OBJECT_SPAN_BONUS );
-
- S32 number_of_tests = 100;
- S32 number_of_spheres = 10;
- S32 number_of_scrambles = 10;
- S32 number_of_random_bubble_sorts = 10;
-
- for (S32 test = 0; test < number_of_tests; ++test)
- {
- LLSphere sphere;
- S32 sphere_index = 0;
-
- // build the root piece
- randomize_sphere(sphere, root_center_range, min_prim_radius, max_prim_radius);
- info.set( sphere_index++, sphere );
-
- // build the unlinked pieces
- std::list< LLPrimLinkInfo<S32> > info_list;
- for (; sphere_index < number_of_spheres; ++sphere_index)
- {
- randomize_sphere(sphere, child_center_range, min_prim_radius, max_prim_radius);
- LLPrimLinkInfo<S32> child_info( sphere_index, sphere );
- info_list.push_back(child_info);
- }
-
- // declare the variables used to store the results
- std::list<S32> first_linked_list;
-
- {
- // the link attempt will modify our original info's, so we
- // have to make copies of the originals for testing
- LLPrimLinkInfo<S32> test_info( 0, LLSphere(info.getCenter(), 0.5f * info.getDiameter()) );
- std::list< LLPrimLinkInfo<S32> > test_list;
- test_list.assign(info_list.begin(), info_list.end());
-
- // try to link
- test_info.mergeLinkableSet(test_list);
-
- ensure("All prims should link, but did not.",test_list.empty());
-
- // store the results
- test_info.getData(first_linked_list);
- first_linked_list.sort();
- }
-
- // try to link the spheres in various random orders
- for (S32 scramble = 0; scramble < number_of_scrambles; ++scramble)
- {
- LLPrimLinkInfo<S32> test_info(0, LLSphere(info.getCenter(), 0.5f * info.getDiameter()) );
-
- // scramble the order of the info_list
- std::list< LLPrimLinkInfo<S32> > test_list;
- test_list.assign(info_list.begin(), info_list.end());
- for (S32 i = 0; i < number_of_random_bubble_sorts; i++)
- {
- test_list.sort(random_sort);
- }
-
- // try to link
- test_info.mergeLinkableSet(test_list);
-
- // get the results
- std::list<S32> linked_list;
- test_info.getData(linked_list);
- linked_list.sort();
-
- ensure_equals("linked set size should be order independent",linked_list.size(),first_linked_list.size());
- }
- }
- }
-}
-