summaryrefslogtreecommitdiff
path: root/indra/test
diff options
context:
space:
mode:
Diffstat (limited to 'indra/test')
-rw-r--r--indra/test/llhttpclient_tut.cpp2
-rw-r--r--indra/test/lliohttpserver_tut.cpp29
-rw-r--r--indra/test/llmessageconfig_tut.cpp207
-rw-r--r--indra/test/llsd_new_tut.cpp77
-rwxr-xr-xindra/test/llsdmessagebuilder_tut.cpp259
-rwxr-xr-xindra/test/llsdmessagereader_tut.cpp300
-rw-r--r--indra/test/llsdtraits.h78
-rw-r--r--indra/test/llservicebuilder_tut.cpp76
-rw-r--r--indra/test/test_llmanifest.py2
9 files changed, 953 insertions, 77 deletions
diff --git a/indra/test/llhttpclient_tut.cpp b/indra/test/llhttpclient_tut.cpp
index 865af98761..b169499543 100644
--- a/indra/test/llhttpclient_tut.cpp
+++ b/indra/test/llhttpclient_tut.cpp
@@ -216,7 +216,7 @@ namespace tut
template<> template<>
void HTTPClientTestObject::test<1>()
{
- LLHTTPClient::get("http://www.google.com/", newResult());
+ LLHTTPClient::get("http://www.secondlife.com/", newResult());
runThePump();
ensureStatusOK();
ensure("result object wasn't destroyed", mResultDeleted);
diff --git a/indra/test/lliohttpserver_tut.cpp b/indra/test/lliohttpserver_tut.cpp
index 1284a1fc0d..2f64cc81d7 100644
--- a/indra/test/lliohttpserver_tut.cpp
+++ b/indra/test/lliohttpserver_tut.cpp
@@ -97,7 +97,7 @@ namespace tut
LLSD context;
chain.push_back(LLIOPipe::ptr_t(injector));
- LLCreateHTTPPipe(chain, mRoot);
+ LLCreateHTTPPipe(chain, mRoot, LLSD());
chain.push_back(LLIOPipe::ptr_t(extractor));
pump->addChain(chain, DEFAULT_CHAIN_EXPIRY_SECS);
@@ -278,6 +278,33 @@ namespace tut
);
}
+ template<> template<>
+ void HTTPServiceTestObject::test<7>()
+ {
+ // test large request
+ std::stringstream stream;
+
+ //U32 size = 36 * 1024 * 1024;
+ //U32 size = 36 * 1024;
+ //std::vector<char> data(size);
+ //memset(&(data[0]), '1', size);
+ //data[size - 1] = '\0';
+
+
+ //std::string result = httpPOST("web/echo", &(data[0]));
+
+ stream << "<llsd><array>";
+ for(U32 i = 0; i < 1000000; ++i)
+ {
+ stream << "<integer>42</integer>";
+ }
+ stream << "</array></llsd>";
+ llinfos << "HTTPServiceTestObject::test<7>"
+ << stream.str().length() << llendl;
+ std::string result = httpPOST("web/echo", stream.str());
+ ensure_starts_with("large echo status", result, "HTTP/1.0 200 OK\r\n");
+ }
+
/* TO DO:
test generation of not found and method not allowed errors
*/
diff --git a/indra/test/llmessageconfig_tut.cpp b/indra/test/llmessageconfig_tut.cpp
new file mode 100644
index 0000000000..c9a62e5230
--- /dev/null
+++ b/indra/test/llmessageconfig_tut.cpp
@@ -0,0 +1,207 @@
+/**
+ * @file llmessageconfig_tut.cpp
+ * @date March 2007
+ * @brief LLMessageConfig unit tests
+ *
+ * Copyright (c) 2006-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+#include <tut/tut.h>
+#include "lltut.h"
+#include "llmessageconfig.h"
+#include "llsdserialize.h"
+#include "llfile.h"
+#include "lltimer.h"
+#include "llframetimer.h"
+
+namespace tut
+{
+ ///var/tmp/babbage/dev/message-liberation/etc
+ static const char file_name[] = "/tmp/message.xml";
+ static const F32 refreshRate = 6.0*1000.0; // milliseconds
+
+ struct LLMessageConfigTestData {
+
+ LLSD getCurrentConfig()
+ {
+ LLSD data;
+ // store aside the current config to overwrite the test ones
+ // when the test finishes
+ llifstream in_file(file_name);
+ if (in_file.is_open())
+ {
+ LLSDSerialize::fromXML(data, in_file);
+ }
+ return data;
+ }
+
+ void writeConfigFile(const LLSD& config)
+ {
+ LLMessageConfig::initClass("simulator", "/tmp");
+ llofstream file(file_name);
+ if (file.is_open())
+ {
+ LLSDSerialize::toPrettyXML(config, file);
+ }
+ file.close();
+ ms_sleep(refreshRate);
+ LLFrameTimer::updateFrameTime();
+ }
+ };
+
+ typedef test_group<LLMessageConfigTestData> LLMessageConfigTestGroup;
+ typedef LLMessageConfigTestGroup::object LLMessageConfigTestObject;
+ LLMessageConfigTestGroup llMessageConfigTestGroup("LLMessageConfig");
+
+ template<> template<>
+ void LLMessageConfigTestObject::test<1>()
+ // tests server defaults
+ {
+ LLSD config_backup = getCurrentConfig();
+ LLSD config;
+ config["serverDefaults"]["simulator"] = "template";
+ writeConfigFile(config);
+ ensure_equals("Ensure server default is not llsd",
+ LLMessageConfig::isServerDefaultBuilderLLSD(),
+ false);
+ ensure_equals("Ensure server default is template",
+ LLMessageConfig::isServerDefaultBuilderTemplate(),
+ true);
+ writeConfigFile(config_backup);
+ }
+
+ template<> template<>
+ void LLMessageConfigTestObject::test<2>()
+ // tests message builders
+ {
+ LLSD config_backup = getCurrentConfig();
+ LLSD config;
+ config["serverDefaults"]["simulator"] = "template";
+ config["messages"]["msg1"]["builder"] = "template";
+ config["messages"]["msg2"]["builder"] = "llsd";
+ writeConfigFile(config);
+ ensure_equals("Ensure msg template builder not llsd",
+ LLMessageConfig::isMessageBuiltLLSD("msg1"),
+ false);
+ ensure_equals("Ensure msg template builder",
+ LLMessageConfig::isMessageBuiltTemplate("msg1"),
+ true);
+ ensure_equals("Ensure msg llsd builder",
+ LLMessageConfig::isMessageBuiltLLSD("msg2"),
+ true);
+ ensure_equals("Ensure msg llsd builder not template",
+ LLMessageConfig::isMessageBuiltTemplate("msg2"),
+ false);
+ writeConfigFile(config_backup);
+ }
+
+ template<> template<>
+ void LLMessageConfigTestObject::test<4>()
+ // tests message builder defaults
+ {
+ LLSD config_backup = getCurrentConfig();
+ LLSD config;
+ config["serverDefaults"]["simulator"] = "llsd";
+ config["messages"]["msg1"]["trusted-sender"] = true;
+ writeConfigFile(config);
+ ensure_equals("Ensure missing message defaults to server builder, not template",
+ LLMessageConfig::isMessageBuiltTemplate("Test"),
+ false);
+ ensure_equals("Ensure missing message default to server builder llsd",
+ LLMessageConfig::isMessageBuiltLLSD("Test"),
+ true);
+ ensure_equals("Ensure missing builder defaults to server builder, not template",
+ LLMessageConfig::isMessageBuiltTemplate("msg1"),
+ false);
+ ensure_equals("Ensure missing builder default to server builder llsd",
+ LLMessageConfig::isMessageBuiltLLSD("msg1"),
+ true);
+
+ ensure_equals("Ensure server default is not llsd",
+ LLMessageConfig::isServerDefaultBuilderLLSD(),
+ true);
+ ensure_equals("Ensure server default is template",
+ LLMessageConfig::isServerDefaultBuilderTemplate(),
+ false);
+
+ writeConfigFile(config_backup);
+ }
+
+ template<> template<>
+ void LLMessageConfigTestObject::test<3>()
+ // tests trusted/untrusted senders
+ {
+ LLSD config_backup = getCurrentConfig();
+ LLSD config;
+ config["serverDefaults"]["simulator"] = "template";
+ config["messages"]["msg1"]["builder"] = "llsd";
+ config["messages"]["msg1"]["trusted-sender"] = false;
+ config["messages"]["msg2"]["builder"] = "llsd";
+ config["messages"]["msg2"]["trusted-sender"] = true;
+ writeConfigFile(config);
+ ensure_equals("Ensure untrusted is not trusted",
+ LLMessageConfig::isMessageTrusted("msg1"),
+ false);
+ ensure_equals("Ensure untrusted is untrusted",
+ LLMessageConfig::isValidUntrustedMessage("msg1"),
+ true);
+ ensure_equals("Ensure trusted is trusted",
+ LLMessageConfig::isMessageTrusted("msg2"),
+ true);
+ ensure_equals("Ensure trusted is not untrusted",
+ LLMessageConfig::isValidUntrustedMessage("msg2"),
+ false);
+ writeConfigFile(config_backup);
+ }
+
+ template<> template<>
+ void LLMessageConfigTestObject::test<5>()
+ // tests trusted/untrusted without flag, only builder
+ {
+ LLSD config_backup = getCurrentConfig();
+ LLSD config;
+ config["serverDefaults"]["simulator"] = "template";
+ config["messages"]["msg1"]["builder"] = "llsd";
+ writeConfigFile(config);
+ ensure_equals("Ensure missing trusted is not trusted",
+ LLMessageConfig::isMessageTrusted("msg1"),
+ false);
+ ensure_equals("Ensure missing trusted is not untrusted",
+ LLMessageConfig::isValidUntrustedMessage("msg1"),
+ false);
+ writeConfigFile(config_backup);
+ }
+
+ template<> template<>
+ void LLMessageConfigTestObject::test<6>()
+ // tests message builder defaults
+ {
+ LLSD config_backup = getCurrentConfig();
+ LLSD config;
+ config["serverDefaults"]["simulator"] = "template";
+ config["messages"]["msg1"]["trusted-sender"] = true;
+ writeConfigFile(config);
+ ensure_equals("Ensure missing message defaults to server builder, not template",
+ LLMessageConfig::isMessageBuiltTemplate("Test"),
+ true);
+ ensure_equals("Ensure missing message default to server builder llsd",
+ LLMessageConfig::isMessageBuiltLLSD("Test"),
+ false);
+ ensure_equals("Ensure missing builder defaults to server builder, not template",
+ LLMessageConfig::isMessageBuiltTemplate("msg1"),
+ true);
+ ensure_equals("Ensure missing builder default to server builder llsd",
+ LLMessageConfig::isMessageBuiltLLSD("msg1"),
+ false);
+
+ ensure_equals("Ensure server default is not llsd",
+ LLMessageConfig::isServerDefaultBuilderLLSD(),
+ false);
+ ensure_equals("Ensure server default is template",
+ LLMessageConfig::isServerDefaultBuilderTemplate(),
+ true);
+
+ writeConfigFile(config_backup);
+ }
+}
diff --git a/indra/test/llsd_new_tut.cpp b/indra/test/llsd_new_tut.cpp
index 2354698239..0ceb4302ff 100644
--- a/indra/test/llsd_new_tut.cpp
+++ b/indra/test/llsd_new_tut.cpp
@@ -12,82 +12,11 @@
#include "linden_common.h"
#include "lltut.h"
-#include "llsd.h"
+#include "llsdtraits.h"
#include "llstring.h"
namespace tut
{
- template<class T>
- class SDTraits
- {
- protected:
- typedef T (LLSD::*Getter)() const;
-
- LLSD::Type type;
- Getter getter;
-
- public:
- SDTraits();
-
- T get(const LLSD& actual)
- {
- return (actual.*getter)();
- }
-
- bool checkType(const LLSD& actual)
- {
- return actual.type() == type;
- }
- };
-
- template<>
- SDTraits<LLSD::Boolean>::SDTraits()
- : type(LLSD::TypeBoolean), getter(&LLSD::asBoolean)
- { }
-
- template<>
- SDTraits<LLSD::Integer>::SDTraits()
- : type(LLSD::TypeInteger), getter(&LLSD::asInteger)
- { }
-
- template<>
- SDTraits<LLSD::Real>::SDTraits()
- : type(LLSD::TypeReal), getter(&LLSD::asReal)
- { }
-
- template<>
- SDTraits<LLSD::UUID>::SDTraits()
- : type(LLSD::TypeUUID), getter(&LLSD::asUUID)
- { }
-
- template<>
- SDTraits<LLSD::String>::SDTraits()
- : type(LLSD::TypeString), getter(&LLSD::asString)
- { }
-
- template<>
- class SDTraits<LLString> : public SDTraits<LLSD::String>
- { };
-
- template<>
- class SDTraits<const char*> : public SDTraits<LLSD::String>
- { };
-
- template<>
- SDTraits<LLSD::Date>::SDTraits()
- : type(LLSD::TypeDate), getter(&LLSD::asDate)
- { }
-
- template<>
- SDTraits<LLSD::URI>::SDTraits()
- : type(LLSD::TypeURI), getter(&LLSD::asURI)
- { }
-
- template<>
- SDTraits<LLSD::Binary>::SDTraits()
- : type(LLSD::TypeBinary), getter(&LLSD::asBinary)
- { }
-
class SDCleanupCheck
{
private:
@@ -126,7 +55,7 @@ namespace tut
static void ensureTypeAndValue(const char* msg, const LLSD& actual,
T expectedValue)
{
- SDTraits<T> traits;
+ LLSDTraits<T> traits;
std::string s(msg);
@@ -334,7 +263,7 @@ namespace tut
}
LLSD u(str);
- SDTraits<T> traits;
+ LLSDTraits<T> traits;
ensure_equals(msg + " value", traits.get(u), vExpected);
}
diff --git a/indra/test/llsdmessagebuilder_tut.cpp b/indra/test/llsdmessagebuilder_tut.cpp
new file mode 100755
index 0000000000..b153292abc
--- /dev/null
+++ b/indra/test/llsdmessagebuilder_tut.cpp
@@ -0,0 +1,259 @@
+/**
+ * @file llsdmessagebuilder_tut.cpp
+ * @date February 2006
+ * @brief LLSDMessageBuilder unit tests
+ *
+ * Copyright (c) 2006-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+#include <tut/tut.h>
+#include "lltut.h"
+
+#include "llsdmessagebuilder.h"
+#include "llsdmessagereader.h"
+#include "llsdtraits.h"
+#include "llquaternion.h"
+#include "u64.h"
+#include "v3dmath.h"
+#include "v3math.h"
+#include "v4math.h"
+
+namespace tut
+{
+ struct LLSDMessageBuilderTestData {
+ static LLSDMessageBuilder defaultBuilder()
+ {
+ LLSDMessageBuilder builder;
+ builder.newMessage("name");
+ builder.nextBlock("block");
+ return builder;
+ }
+
+ static LLSDMessageReader setReader(const LLSDMessageBuilder& builder)
+ {
+ LLSDMessageReader reader;
+ reader.setMessage("name", builder.getMessage());
+ return reader;
+ }
+ };
+
+ typedef test_group<LLSDMessageBuilderTestData> LLSDMessageBuilderTestGroup;
+ typedef LLSDMessageBuilderTestGroup::object LLSDMessageBuilderTestObject;
+ LLSDMessageBuilderTestGroup llsdMessageBuilderTestGroup("LLSDMessageBuilder");
+
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<1>()
+ // construction and test of undefined
+ {
+ LLSDMessageBuilder builder = defaultBuilder();
+ LLSDMessageReader reader = setReader(builder);
+ }
+
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<2>()
+ // BOOL
+ {
+ BOOL outValue, inValue = TRUE;
+ LLSDMessageBuilder builder = defaultBuilder();
+ builder.addBOOL("var", inValue);
+ LLSDMessageReader reader = setReader(builder);
+ reader.getBOOL("block", "var", outValue);
+ ensure_equals("Ensure BOOL", inValue, outValue);
+ }
+
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<3>()
+ // U8
+ {
+ U8 outValue, inValue = 2;
+ LLSDMessageBuilder builder = defaultBuilder();
+ builder.addU8("var", inValue);
+ LLSDMessageReader reader = setReader(builder);
+ reader.getU8("block", "var", outValue);
+ ensure_equals("Ensure U8", inValue, outValue);
+ }
+
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<4>()
+ // S16
+ {
+ S16 outValue, inValue = 90;
+ LLSDMessageBuilder builder = defaultBuilder();
+ builder.addS16("var", inValue);
+ LLSDMessageReader reader = setReader(builder);
+ reader.getS16("block", "var", outValue);
+ ensure_equals("Ensure S16", inValue, outValue);
+ }
+
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<5>()
+ // U16
+ {
+ U16 outValue, inValue = 3;
+ LLSDMessageBuilder builder = defaultBuilder();
+ builder.addU16("var", inValue);
+ LLSDMessageReader reader = setReader(builder);
+ reader.getU16("block", "var", outValue);
+ ensure_equals("Ensure U16", inValue, outValue);
+ }
+
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<6>()
+ // S32
+ {
+ S32 outValue, inValue = 44;
+ LLSDMessageBuilder builder = defaultBuilder();
+ builder.addS32("var", inValue);
+ LLSDMessageReader reader = setReader(builder);
+ reader.getS32("block", "var", outValue);
+ ensure_equals("Ensure S32", inValue, outValue);
+ }
+
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<7>()
+ // F32
+ {
+ F32 outValue, inValue = 121.44;
+ LLSDMessageBuilder builder = defaultBuilder();
+ builder.addF32("var", inValue);
+ LLSDMessageReader reader = setReader(builder);
+ reader.getF32("block", "var", outValue);
+ ensure_equals("Ensure F32", inValue, outValue);
+ }
+
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<8>()
+ // U32
+ {
+ U32 outValue, inValue = 88;
+ LLSDMessageBuilder builder = defaultBuilder();
+ builder.addU32("var", inValue);
+ LLSDMessageReader reader = setReader(builder);
+ reader.getU32("block", "var", outValue);
+ ensure_equals("Ensure U32", inValue, outValue);
+ }
+
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<9>()
+ // U64
+ {
+ U64 outValue, inValue = 121;
+ LLSDMessageBuilder builder = defaultBuilder();
+ builder.addU64("var", inValue);
+ LLSDMessageReader reader = setReader(builder);
+ reader.getU64("block", "var", outValue);
+ ensure_equals("Ensure U64", inValue, outValue);
+ }
+
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<10>()
+ // F64
+ {
+ F64 outValue, inValue = 3232143.33;
+ LLSDMessageBuilder builder = defaultBuilder();
+ builder.addF64("var", inValue);
+ LLSDMessageReader reader = setReader(builder);
+ reader.getF64("block", "var", outValue);
+ ensure_equals("Ensure F64", inValue, outValue);
+ }
+
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<11>()
+ // Vector3
+ {
+ LLVector3 outValue, inValue = LLVector3(1,2,3);
+ LLSDMessageBuilder builder = defaultBuilder();
+ builder.addVector3("var", inValue);
+ LLSDMessageReader reader = setReader(builder);
+ reader.getVector3("block", "var", outValue);
+ ensure_equals("Ensure Vector3", inValue, outValue);
+ }
+
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<12>()
+ // Vector4
+ {
+ LLVector4 outValue, inValue = LLVector4(1,2,3,4);
+ LLSDMessageBuilder builder = defaultBuilder();
+ builder.addVector4("var", inValue);
+ LLSDMessageReader reader = setReader(builder);
+ reader.getVector4("block", "var", outValue);
+ ensure_equals("Ensure Vector4", inValue, outValue);
+ }
+
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<13>()
+ // Vector3d
+ {
+ LLVector3d outValue, inValue = LLVector3d(1,2,3);
+ LLSDMessageBuilder builder = defaultBuilder();
+ builder.addVector3d("var", inValue);
+ LLSDMessageReader reader = setReader(builder);
+ reader.getVector3d("block", "var", outValue);
+ ensure_equals("Ensure Vector3d", inValue, outValue);
+ }
+
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<14>()
+ // Quaternion
+ {
+ LLQuaternion outValue, inValue = LLQuaternion(1,2,3,4);
+ LLSDMessageBuilder builder = defaultBuilder();
+ builder.addQuat("var", inValue);
+ LLSDMessageReader reader = setReader(builder);
+ reader.getQuat("block", "var", outValue);
+ ensure_equals("Ensure Quaternion", inValue, outValue);
+ }
+
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<15>()
+ // UUID
+ {
+ LLUUID outValue, inValue;
+ inValue.generate();
+ LLSDMessageBuilder builder = defaultBuilder();
+ builder.addUUID("var", inValue);
+ LLSDMessageReader reader = setReader(builder);
+ reader.getUUID("block", "var", outValue);
+ ensure_equals("Ensure UUID", inValue, outValue);
+ }
+
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<16>()
+ // IPAddr
+ {
+ U32 outValue, inValue = 12344556;
+ LLSDMessageBuilder builder = defaultBuilder();
+ builder.addIPAddr("var", inValue);
+ LLSDMessageReader reader = setReader(builder);
+ reader.getIPAddr("block", "var", outValue);
+ ensure_equals("Ensure IPAddr", inValue, outValue);
+ }
+
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<17>()
+ // IPPort
+ {
+ U16 outValue, inValue = 80;
+ LLSDMessageBuilder builder = defaultBuilder();
+ builder.addIPPort("var", inValue);
+ LLSDMessageReader reader = setReader(builder);
+ reader.getIPPort("block", "var", outValue);
+ ensure_equals("Ensure IPPort", inValue, outValue);
+ }
+
+ template<> template<>
+ void LLSDMessageBuilderTestObject::test<18>()
+ {
+ std::string outValue, inValue = "testing";
+ LLSDMessageBuilder builder = defaultBuilder();
+ builder.addString("var", inValue.c_str());
+ LLSDMessageReader reader = setReader(builder);
+ char buffer[MAX_STRING];
+ reader.getString("block", "var", MAX_STRING, buffer);
+ outValue = buffer;
+ ensure_equals("Ensure String", inValue, outValue);
+ }
+}
+
diff --git a/indra/test/llsdmessagereader_tut.cpp b/indra/test/llsdmessagereader_tut.cpp
new file mode 100755
index 0000000000..31810ae00e
--- /dev/null
+++ b/indra/test/llsdmessagereader_tut.cpp
@@ -0,0 +1,300 @@
+/**
+ * @file llsdmessagereader_tut.cpp
+ * @date February 2006
+ * @brief LLSDMessageReader unit tests
+ *
+ * Copyright (c) 2006-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+#include <tut/tut.h>
+#include "lltut.h"
+
+#include "llsdmessagereader.h"
+#include "llsdutil.h"
+
+namespace tut
+{
+ struct LLSDMessageReaderTestData {
+ static void ensureMessageName(const std::string& msg_name,
+ const LLSD& msg_data,
+ const std::string& expected_name)
+ {
+ LLSDMessageReader msg;
+ msg.setMessage(msg_name, msg_data);
+ ensure_equals("Ensure name", std::string(msg.getMessageName()),
+ expected_name);
+ }
+
+ static void ensureNumberOfBlocks(const LLSD& msg_data,
+ const std::string& block,
+ S32 expected_number)
+ {
+ LLSDMessageReader msg;
+ msg.setMessage("fakename", msg_data);
+ ensure_equals("Ensure number of blocks", msg.getNumberOfBlocks(block.c_str()),
+ expected_number);
+ }
+
+ static void ensureMessageSize(const LLSD& msg_data,
+ S32 expected_size)
+ {
+ LLSDMessageReader msg;
+ msg.setMessage("fakename", msg_data);
+ ensure_equals( "Ensure size", msg.getMessageSize(), expected_size);
+ }
+
+ static void ensureBool(const LLSD& msg_data,
+ const std::string& block,
+ const std::string& var,
+ S32 blocknum,
+ BOOL expected)
+ {
+ LLSDMessageReader msg;
+ msg.setMessage("fakename", msg_data);
+ BOOL test_data;
+ msg.getBOOL(block.c_str(), var.c_str(), test_data, blocknum);
+ ensure_equals( "Ensure bool field", test_data, expected);
+ }
+ };
+
+ typedef test_group<LLSDMessageReaderTestData> LLSDMessageReaderTestGroup;
+ typedef LLSDMessageReaderTestGroup::object LLSDMessageReaderTestObject;
+ LLSDMessageReaderTestGroup llsdMessageReaderTestGroup("LLSDMessageReader");
+
+ template<> template<>
+ void LLSDMessageReaderTestObject::test<1>()
+ // construction and test of empty LLSD
+ {
+ LLSD message = LLSD::emptyMap();
+
+ ensureMessageName("", message, "");
+ ensureNumberOfBlocks(message, "Fakeblock", 0);
+ ensureMessageSize(message, 0);
+ }
+
+ template<> template<>
+ void LLSDMessageReaderTestObject::test<2>()
+ // construction and test of simple message with one block
+ {
+ LLSD message = LLSD::emptyMap();
+ message["block1"] = LLSD::emptyArray();
+ message["block1"][0] = LLSD::emptyMap();
+ message["block1"][0]["Field1"] = 0;
+
+ ensureMessageName("name2", message, "name2");
+ ensureNumberOfBlocks(message, "block1", 1);
+ ensureMessageSize(message, 0);
+ }
+
+ template<> template<>
+ void LLSDMessageReaderTestObject::test<3>()
+ // multiple blocks
+ {
+ LLSD message = LLSD::emptyMap();
+ message["block1"] = LLSD::emptyArray();
+ BOOL bool_true = TRUE;
+ BOOL bool_false = FALSE;
+ message["block1"][0] = LLSD::emptyMap();
+ message["block1"][0]["BoolField1"] = bool_true;
+ message["block1"][1] = LLSD::emptyMap();
+ message["block1"][1]["BoolField1"] = bool_false;
+ message["block1"][1]["BoolField2"] = bool_true;
+
+ ensureMessageName("name3", message, "name3");
+ ensureBool(message, "block1", "BoolField1", 0, TRUE);
+ ensureBool(message, "block1", "BoolField1", 1, FALSE);
+ ensureBool(message, "block1", "BoolField2", 1, TRUE);
+ ensureNumberOfBlocks(message, "block1", 2);
+ ensureMessageSize(message, 0);
+ }
+
+ template<typename T>
+ LLSDMessageReader testType(const T& value)
+ {
+ LLSD message = LLSD::emptyMap();
+ message["block"][0]["var"] = value;
+ LLSDMessageReader msg;
+ msg.setMessage("fakename", message);
+ return msg;
+ }
+
+ template<> template<>
+ void LLSDMessageReaderTestObject::test<4>()
+ // S8
+ {
+ S8 outValue, inValue = -3;
+ LLSDMessageReader msg = testType(inValue);
+ msg.getS8("block", "var", outValue);
+ ensure_equals("Ensure S8", outValue, inValue);
+ }
+ template<> template<>
+ void
+ LLSDMessageReaderTestObject::test<5>()
+ // U8
+ {
+ U8 outValue, inValue = 2;
+ LLSDMessageReader msg = testType(inValue);
+ msg.getU8("block", "var", outValue);
+ ensure_equals("Ensure U8", outValue, inValue);
+ }
+ template<> template<>
+ void LLSDMessageReaderTestObject::test<6>()
+ // S16
+ {
+ S16 outValue, inValue = 90;
+ LLSDMessageReader msg = testType(inValue);
+ msg.getS16("block", "var", outValue);
+ ensure_equals("Ensure S16", outValue, inValue);
+ }
+ template<> template<>
+ void LLSDMessageReaderTestObject::test<7>()
+ // U16
+ {
+ U16 outValue, inValue = 3;
+ LLSDMessageReader msg = testType(inValue);
+ msg.getU16("block", "var", outValue);
+ ensure_equals("Ensure S16", outValue, inValue);
+ }
+ template<> template<>
+ void LLSDMessageReaderTestObject::test<8>()
+ // S32
+ {
+ S32 outValue, inValue = 44;
+ LLSDMessageReader msg = testType(inValue);
+ msg.getS32("block", "var", outValue);
+ ensure_equals("Ensure S32", outValue, inValue);
+ }
+ template<> template<>
+ void LLSDMessageReaderTestObject::test<9>()
+ // F32
+ {
+ F32 outValue, inValue = 121.44;
+ LLSDMessageReader msg = testType(inValue);
+ msg.getF32("block", "var", outValue);
+ ensure_equals("Ensure F32", outValue, inValue);
+ }
+ template<> template<>
+ void LLSDMessageReaderTestObject::test<10>()
+ // U32
+ {
+ U32 outValue, inValue = 88;
+ LLSD sdValue = ll_sd_from_U32(inValue);
+ LLSDMessageReader msg = testType(sdValue);
+ msg.getU32("block", "var", outValue);
+ ensure_equals("Ensure U32", outValue, inValue);
+ }
+ template<> template<>
+ void LLSDMessageReaderTestObject::test<11>()
+ // U64
+ {
+ U64 outValue, inValue = 121;
+ LLSD sdValue = ll_sd_from_U64(inValue);
+ LLSDMessageReader msg = testType(sdValue);
+ msg.getU64("block", "var", outValue);
+ ensure_equals("Ensure U64", outValue, inValue);
+ }
+ template<> template<>
+ void LLSDMessageReaderTestObject::test<12>()
+ // F64
+ {
+ F64 outValue, inValue = 3232143.33;
+ LLSDMessageReader msg = testType(inValue);
+ msg.getF64("block", "var", outValue);
+ ensure_equals("Ensure F64", outValue, inValue);
+ }
+ template<> template<>
+ void LLSDMessageReaderTestObject::test<13>()
+ // String
+ {
+ std::string outValue, inValue = "testing";
+ LLSDMessageReader msg = testType<std::string>(inValue.c_str());
+
+ char buffer[MAX_STRING];
+ msg.getString("block", "var", MAX_STRING, buffer);
+ outValue = buffer;
+ ensure_equals("Ensure String", outValue, inValue);
+ }
+ template<> template<>
+ void LLSDMessageReaderTestObject::test<14>()
+ // Vector3
+ {
+ LLVector3 outValue, inValue = LLVector3(1,2,3);
+ LLSD sdValue = ll_sd_from_vector3(inValue);
+ LLSDMessageReader msg = testType(sdValue);
+ msg.getVector3("block", "var", outValue);
+ ensure_equals("Ensure Vector3", outValue, inValue);
+ }
+ template<> template<>
+ void LLSDMessageReaderTestObject::test<15>()
+ // Vector4
+ {
+ LLVector4 outValue, inValue = LLVector4(1,2,3,4);
+ LLSD sdValue = ll_sd_from_vector4(inValue);
+ LLSDMessageReader msg = testType(sdValue);
+ msg.getVector4("block", "var", outValue);
+ ensure_equals("Ensure Vector4", outValue, inValue);
+ }
+ template<> template<>
+ void LLSDMessageReaderTestObject::test<16>()
+ // Vector3d
+ {
+ LLVector3d outValue, inValue = LLVector3d(1,2,3);
+ LLSD sdValue = ll_sd_from_vector3d(inValue);
+ LLSDMessageReader msg = testType(sdValue);
+ msg.getVector3d("block", "var", outValue);
+ ensure_equals("Ensure Vector3d", outValue, inValue);
+ }
+ template<> template<>
+ void LLSDMessageReaderTestObject::test<17>()
+ // Quaternion
+ {
+ LLQuaternion outValue, inValue = LLQuaternion(1,2,3,4);
+ LLSD sdValue = ll_sd_from_quaternion(inValue);
+ LLSDMessageReader msg = testType(sdValue);
+ msg.getQuat("block", "var", outValue);
+ ensure_equals("Ensure Quaternion", outValue, inValue);
+ }
+ template<> template<>
+ void LLSDMessageReaderTestObject::test<18>()
+ // UUID
+ {
+ LLUUID outValue, inValue;
+ inValue.generate();
+ LLSDMessageReader msg = testType(inValue);
+ msg.getUUID("block", "var", outValue);
+ ensure_equals("Ensure UUID", outValue, inValue);
+ }
+ template<> template<>
+ void LLSDMessageReaderTestObject::test<19>()
+ // IPAddr
+ {
+ U32 outValue, inValue = 12344556;
+ LLSD sdValue = ll_sd_from_ipaddr(inValue);
+ LLSDMessageReader msg = testType(sdValue);
+ msg.getIPAddr("block", "var", outValue);
+ ensure_equals("Ensure IPAddr", outValue, inValue);
+ }
+ template<> template<>
+ void LLSDMessageReaderTestObject::test<20>()
+ // IPPort
+ {
+ U16 outValue, inValue = 80;
+ LLSDMessageReader msg = testType(inValue);
+ msg.getIPPort("block", "var", outValue);
+ ensure_equals("Ensure IPPort", outValue, inValue);
+ }
+ template<> template<>
+ void LLSDMessageReaderTestObject::test<21>()
+ // Binary
+ {
+ std::vector<U8> outValue(2), inValue(2);
+ inValue[0] = 0;
+ inValue[1] = 1;
+
+ LLSDMessageReader msg = testType(inValue);
+ msg.getBinaryData("block", "var", &(outValue[0]), inValue.size());
+ ensure_equals("Ensure Binary", outValue, inValue);
+ }
+}
+
diff --git a/indra/test/llsdtraits.h b/indra/test/llsdtraits.h
new file mode 100644
index 0000000000..2e6a96a425
--- /dev/null
+++ b/indra/test/llsdtraits.h
@@ -0,0 +1,78 @@
+#ifndef LLSDTRAITS_H
+#define LLSDTRAITS_H
+
+#include "llsd.h"
+#include "llstring.h"
+
+template<class T>
+class LLSDTraits
+{
+ protected:
+ typedef T (LLSD::*Getter)() const;
+
+ LLSD::Type type;
+ Getter getter;
+
+ public:
+ LLSDTraits();
+
+ T get(const LLSD& actual)
+ {
+ return (actual.*getter)();
+ }
+
+ bool checkType(const LLSD& actual)
+ {
+ return actual.type() == type;
+ }
+};
+
+template<> inline
+LLSDTraits<LLSD::Boolean>::LLSDTraits()
+ : type(LLSD::TypeBoolean), getter(&LLSD::asBoolean)
+{ }
+
+template<> inline
+LLSDTraits<LLSD::Integer>::LLSDTraits()
+ : type(LLSD::TypeInteger), getter(&LLSD::asInteger)
+{ }
+
+template<> inline
+LLSDTraits<LLSD::Real>::LLSDTraits()
+ : type(LLSD::TypeReal), getter(&LLSD::asReal)
+{ }
+
+template<> inline
+LLSDTraits<LLSD::UUID>::LLSDTraits()
+ : type(LLSD::TypeUUID), getter(&LLSD::asUUID)
+{ }
+
+template<> inline
+LLSDTraits<LLSD::String>::LLSDTraits()
+ : type(LLSD::TypeString), getter(&LLSD::asString)
+{ }
+
+template<>
+class LLSDTraits<LLString> : public LLSDTraits<LLSD::String>
+{ };
+
+template<>
+class LLSDTraits<const char*> : public LLSDTraits<LLSD::String>
+{ };
+
+template<> inline
+LLSDTraits<LLSD::Date>::LLSDTraits()
+ : type(LLSD::TypeDate), getter(&LLSD::asDate)
+{ }
+
+template<> inline
+LLSDTraits<LLSD::URI>::LLSDTraits()
+ : type(LLSD::TypeURI), getter(&LLSD::asURI)
+{ }
+
+template<> inline
+LLSDTraits<LLSD::Binary>::LLSDTraits()
+ : type(LLSD::TypeBinary), getter(&LLSD::asBinary)
+{ }
+
+#endif // LLSDTRAITS_H
diff --git a/indra/test/llservicebuilder_tut.cpp b/indra/test/llservicebuilder_tut.cpp
new file mode 100644
index 0000000000..b4a814ebb9
--- /dev/null
+++ b/indra/test/llservicebuilder_tut.cpp
@@ -0,0 +1,76 @@
+/**
+* @file llservicebuilder_tut.cpp
+* @brief LLServiceBuilder unit tests
+* @date March 2007
+*
+* Copyright (c) 2006-$CurrentYear$, Linden Research, Inc.
+* $License$
+*/
+
+#include <tut/tut.h>
+#include "lltut.h"
+
+#include "llsd.h"
+#include "llservicebuilder.h"
+
+namespace tut
+{
+
+ struct ServiceBuilderTestData {
+ LLServiceBuilder mServiceBuilder;
+ };
+
+ typedef test_group<ServiceBuilderTestData> ServiceBuilderTestGroup;
+ typedef ServiceBuilderTestGroup::object ServiceBuilderTestObject;
+
+ ServiceBuilderTestGroup serviceBuilderTestGroup("ServiceBuilder");
+
+ template<> template<>
+ void ServiceBuilderTestObject::test<1>()
+ {
+ //Simple service build and reply with no mapping
+ LLSD test_block;
+ test_block["service-builder"] = "/agent/name";
+ mServiceBuilder.createServiceDefinition("ServiceBuilderTest", test_block["service-builder"]);
+ std::string test_url = mServiceBuilder.buildServiceURI("ServiceBuilderTest");
+ ensure_equals("Basic URL Creation", test_url , "/agent/name");
+ }
+
+ template<> template<>
+ void ServiceBuilderTestObject::test<2>()
+ {
+ //Simple replace test
+ LLSD test_block;
+ test_block["service-builder"] = "/agent/{$agent-id}/name";
+ mServiceBuilder.createServiceDefinition("ServiceBuilderTest", test_block["service-builder"]);
+ LLSD data_map;
+ data_map["agent-id"] = "257c631f-a0c5-4f29-8a9f-9031feaae6c6";
+ std::string test_url = mServiceBuilder.buildServiceURI("ServiceBuilderTest", data_map);
+ ensure_equals("Replacement URL Creation", test_url , "/agent/257c631f-a0c5-4f29-8a9f-9031feaae6c6/name");
+ }
+
+ template<> template<>
+ void ServiceBuilderTestObject::test<3>()
+ {
+ //Incorrect service test
+ LLSD test_block;
+ test_block["service-builder"] = "/agent/{$agent-id}/name";
+ mServiceBuilder.createServiceDefinition("ServiceBuilderTest", test_block["service-builder"]);
+ std::string test_url = mServiceBuilder.buildServiceURI("ServiceBuilder");
+ ensure_equals("Replacement URL Creation for Non-existant Service", test_url , "");
+ }
+
+ template<> template<>
+ void ServiceBuilderTestObject::test<4>()
+ {
+ //Incorrect service test
+ LLSD test_block;
+ test_block["service-builder"] = "/agent/{$agent-id}/name";
+ mServiceBuilder.createServiceDefinition("ServiceBuilderTest", test_block["service-builder"]);
+ LLSD data_map;
+ data_map["agent_id"] = "257c631f-a0c5-4f29-8a9f-9031feaae6c6";
+ std::string test_url = mServiceBuilder.buildServiceURI("ServiceBuilderTest", data_map);
+ ensure_equals("Replacement URL Creation for Non-existant Service", test_url , "/agent/{$agent-id}/name");
+ }
+}
+
diff --git a/indra/test/test_llmanifest.py b/indra/test/test_llmanifest.py
index cc464237a2..f4fc2820eb 100644
--- a/indra/test/test_llmanifest.py
+++ b/indra/test/test_llmanifest.py
@@ -87,7 +87,7 @@ class TestLLManifest(unittest.TestCase):
def testruncommand(self):
self.assertEqual("Hello\n", self.m.run_command("echo Hello"))
def tmp_test():
- self.m.run_command("fff_garbage")
+ self.m.run_command("test_command_that_should_not_be_found")
self.assertRaises(RuntimeError, tmp_test)
def testpathof(self):