diff options
author | Robert Knop <prospero@lindenlab.com> | 2009-02-25 21:02:17 +0000 |
---|---|---|
committer | Robert Knop <prospero@lindenlab.com> | 2009-02-25 21:02:17 +0000 |
commit | c88b470a8a2cdae8e69e5570b46d4b21c43368bc (patch) | |
tree | 551d764767aa1d9c095a99b586f5bb38ae3f1e57 /indra/test | |
parent | 997d24b83221aa63ef8141a9ab94434d2ba2ddc6 (diff) |
svn merge -r108815:112761 svn+ssh://svn.lindenlab.com/svn/linden/branches/server/server-1.26
The biggest things in this are Scalable Space Servers and Maint-Server-6
QAR-1209 : SSS
QAR-1295 : maint-server-6
Conflicts resolved by prospero:
C scripts/farm_distribute
C scripts/automated_build_scripts/build-linux.sh : resolved by
prospero, mostly kept the merge-right version in
the conflict, but there was one block of repeated
code from earlier that I removed.
C scripts/automated_build_scripts/build-mac.sh : kept merge-right
C indra/llcommon/llversionserver.h : svn revert
C indra/newsim/llsimparcel.h : kept *both*... working had "setArea",
merge-right had exportStream and importStream
C indra/newsim/llsimparcel.cpp : see llsimparcel.h
C indra/newsim/lltask.h : working had LLTask derived also from
LLScriptResourceConsumer, merge-right had LLTask
dervied also from LLAgentPosition. To resolve
conflict, derive from both.
C indra/newsim/lllslmanager.h : kept merge-right (had an added comment)
C indra/llmessage/llhttpnode.h : kept working (added the definition
of method LLHTTPNode::extendedResult)
C indra/lscript/lscript_execute_mono/llscriptexecutemono.cpp
C indra/lscript/lscript_execute_mono/llscriptexecutemono.h
: These two were resolved by si, in consultation with daveh
I also had to add the following stubs to
indra/newsim/tests/llgodkickutils_test.cpp in order to get it to
compile:
// LLScriptResourceConsumer interface methods in LLTask
LLScriptResource::LLScriptResource() { }
LLScriptResourcePool::LLScriptResourcePool() { }
LLScriptResourcePool LLScriptResourcePool::null;
LLScriptResourceConsumer::LLScriptResourceConsumer() { }
LLScriptResourcePool& LLScriptResourceConsumer::getScriptResourcePool() { return LLScriptResourcePool::null; }
const LLScriptResourcePool& LLScriptResourceConsumer::getScriptResourcePool() const { return LLScriptResourcePool::null; }
bool LLScriptResourceConsumer::switchScriptResourcePools(LLScriptResourcePool& new_pool) { return false; }
bool LLScriptResourceConsumer::canUseScriptResourcePool(const LLScriptResourcePool& resource_pool) { return false; }
bool LLScriptResourceConsumer::isInPool(const LLScriptResourcePool& resource_pool) { return false; }
void LLScriptResourceConsumer::setScriptResourcePool(LLScriptResourcePool& pool) { }
S32 LLTask::getUsedPublicURLs() const { return 0; }
void LLTask::setScriptResourcePool(LLScriptResourcePool& pool) { }
Diffstat (limited to 'indra/test')
-rw-r--r-- | indra/test/CMakeLists.txt | 1 | ||||
-rw-r--r-- | indra/test/llblowfish_tut.cpp | 12 | ||||
-rwxr-xr-x | indra/test/llsdmessagebuilder_tut.cpp | 556 | ||||
-rw-r--r-- | indra/test/lltimestampcache_tut.cpp | 129 | ||||
-rw-r--r-- | indra/test/lltut.cpp | 6 | ||||
-rw-r--r-- | indra/test/lltut.h | 8 | ||||
-rw-r--r-- | indra/test/test.cpp | 9 | ||||
-rw-r--r-- | indra/test/test.h | 49 |
8 files changed, 752 insertions, 18 deletions
diff --git a/indra/test/CMakeLists.txt b/indra/test/CMakeLists.txt index 0000cc237b..b9e0e3dbdd 100644 --- a/indra/test/CMakeLists.txt +++ b/indra/test/CMakeLists.txt @@ -60,6 +60,7 @@ set(test_SOURCE_FILES llstreamtools_tut.cpp llstring_tut.cpp lltemplatemessagebuilder_tut.cpp + lltimestampcache_tut.cpp lltiming_tut.cpp lltranscode_tut.cpp lltut.cpp diff --git a/indra/test/llblowfish_tut.cpp b/indra/test/llblowfish_tut.cpp index 5146bb6b97..4a128a8984 100644 --- a/indra/test/llblowfish_tut.cpp +++ b/indra/test/llblowfish_tut.cpp @@ -94,7 +94,6 @@ namespace tut template<> template<> void blowfish_object::test<1>() { -#if LL_LINUX LLUUID blank; LLBlowfishCipher cipher(&blank.mData[0], UUID_BYTES); @@ -107,15 +106,11 @@ namespace tut dst_len = cipher.requiredEncryptionSpace(8); ensure("encryption space 8", (dst_len == 16) ); -#else - skip("Blowfish only supported on Linux."); -#endif // LL_LINUX } template<> template<> void blowfish_object::test<2>() { -#if LL_LINUX LLUUID blank; LLBlowfishCipher cipher(&blank.mData[0], UUID_BYTES); @@ -129,15 +124,11 @@ namespace tut result.resize(count); ensure("encrypt null key", matchFile("blowfish.1.bin", result)); -#else - skip("Blowfish only supported on Linux."); -#endif // LL_LINUX } template<> template<> void blowfish_object::test<3>() { -#if LL_LINUX // same as base64 test id LLUUID id("526a1e07-a19d-baed-84c4-ff08a488d15e"); LLBlowfishCipher cipher(&id.mData[0], UUID_BYTES); @@ -152,8 +143,5 @@ namespace tut result.resize(count); ensure("encrypt real key", matchFile("blowfish.2.bin", result)); -#else - skip("Blowfish only supported on Linux."); -#endif // LL_LINUX } } diff --git a/indra/test/llsdmessagebuilder_tut.cpp b/indra/test/llsdmessagebuilder_tut.cpp index 60a50cf75f..27ab127772 100755 --- a/indra/test/llsdmessagebuilder_tut.cpp +++ b/indra/test/llsdmessagebuilder_tut.cpp @@ -35,6 +35,7 @@ #include "linden_common.h" #include "lltut.h" +#include "llmessagetemplate.h" #include "llsdmessagebuilder.h" #include "llsdmessagereader.h" #include "llsdtraits.h" @@ -43,10 +44,24 @@ #include "v3dmath.h" #include "v3math.h" #include "v4math.h" +#include "llsdutil_math.cpp" +#include "lltemplatemessagebuilder.h" namespace tut { + static LLTemplateMessageBuilder::message_template_name_map_t templateNameMap; + + LLMsgData* messageData = NULL; + LLMsgBlkData* messageBlockData = NULL; + struct LLSDMessageBuilderTestData { + + LLSDMessageBuilderTestData() + { + messageData = new LLMsgData("testMessage"); + messageBlockData = new LLMsgBlkData("testBlock", 0); + } + static LLSDMessageBuilder defaultBuilder() { LLSDMessageBuilder builder; @@ -61,6 +76,43 @@ namespace tut reader.setMessage("name", builder.getMessage()); return reader; } + + static void addValue(LLMsgBlkData* mbd, char* name, void* v, EMsgVariableType type, int size, int data_size = -1) + { + LLMsgVarData tmp(name, type); + tmp.addData(v, size, type, data_size); + mbd->mMemberVarData[name] = tmp; + } + + + static LLMessageBlock* defaultTemplateBlock(const EMsgVariableType type = MVT_NULL, const S32 size = 0, EMsgBlockType block = MBT_VARIABLE) + { + return createTemplateBlock(_PREHASH_Test0, type, size, block); + } + + static LLMessageBlock* createTemplateBlock(char* name, const EMsgVariableType type = MVT_NULL, const S32 size = 0, EMsgBlockType block = MBT_VARIABLE) + { + LLMessageBlock* result = new LLMessageBlock(name, block); + if(type != MVT_NULL) + { + result->addVariable(_PREHASH_Test0, type, size); + } + return result; + } + + static LLTemplateMessageBuilder* defaultTemplateBuilder(LLMessageTemplate& messageTemplate, char* name = _PREHASH_Test0) + { + templateNameMap[_PREHASH_TestMessage] = &messageTemplate; + LLTemplateMessageBuilder* builder = new LLTemplateMessageBuilder(templateNameMap); + builder->newMessage(_PREHASH_TestMessage); + builder->nextBlock(name); + return builder; + } + + static LLMessageTemplate defaultTemplate() + { + return LLMessageTemplate(_PREHASH_TestMessage, 1, MFT_HIGH); + } }; typedef test_group<LLSDMessageBuilderTestData> LLSDMessageBuilderTestGroup; @@ -280,5 +332,509 @@ namespace tut outValue = buffer; ensure_equals("Ensure String", inValue, outValue); } + + template<> template<> + void LLSDMessageBuilderTestObject::test<19>() + { + LLMsgBlkData* mbd = new LLMsgBlkData("testBlock", 0); + LLMsgData* md = new LLMsgData("testMessage"); + md->addBlock(mbd); + LLSDMessageBuilder builder = defaultBuilder(); + + builder.copyFromMessageData(*md); + LLSD output = builder.getMessage(); + + ensure("Ensure message block created when copied from legacy message to llsd", output["testBlock"].isDefined()); + } + + // MVT_FIXED + template<> template<> + void LLSDMessageBuilderTestObject::test<20>() + { + char binData[] = "abcdefghijklmnop"; + + addValue(messageBlockData, "testBinData", &binData, MVT_FIXED, sizeof(binData)); + messageData->addBlock(messageBlockData); + LLSDMessageBuilder builder = defaultBuilder(); + + builder.copyFromMessageData(*messageData); + LLSD output = builder.getMessage(); + + std::vector<U8> v = output["testBlock"][0]["testBinData"].asBinary(); + ensure("Ensure MVT_S16Array data copied from legacy to llsd give a valid vector", v.size() > 0); + + ensure_memory_matches("Ensure fixed binary data works in a message copied from legacy to llsd", + &v[0], sizeof(binData), binData, sizeof(binData)); + } + + // MVT_VARIABLE data_size 1 (U8's) + template<> template<> + void LLSDMessageBuilderTestObject::test<21>() + { + /* U8 binData[] = "abcdefghijklmnop"; + + addValue(messageBlockData, "testBinData", &binData, MVT_VARIABLE, sizeof(binData), 1); + messageData->addBlock(messageBlockData); + LLSDMessageBuilder builder = defaultBuilder(); + + builder.copyFromMessageData(*messageData); + LLSD output = builder.getMessage(); + + std::vector<U8> v = output["testBlock"][0]["testBinData"].asBinary(); + ensure("Ensure MVT_S16Array data copied from legacy to llsd give a valid vector", v.size() > 0); + + ensure_memory_matches("Ensure MVT_VARIABLE U8 binary data works in a message copied from legacy to llsd", + &v[0], sizeof(binData), binData, sizeof(binData));*/ + } + + // MVT_VARIABLE data_size 2 (U16's) + template<> template<> + void LLSDMessageBuilderTestObject::test<22>() + { + U16 binData[] = {1,2,3,4,5,6,7,8,9}; //9 shorts + + addValue(messageBlockData, "testBinData", &binData, MVT_VARIABLE, sizeof(binData) >> 1, 2); + messageData->addBlock(messageBlockData); + LLSDMessageBuilder builder = defaultBuilder(); + + builder.copyFromMessageData(*messageData); + LLSD output = builder.getMessage(); + + std::vector<U8> v = output["testBlock"][0]["testBinData"].asBinary(); + ensure("Ensure MVT_S16Array data copied from legacy to llsd give a valid vector", v.size() > 0); + + ensure_memory_matches("Ensure MVT_VARIABLE U16 binary data works in a message copied from legacy to llsd", + &v[0], sizeof(binData) >> 1, binData, sizeof(binData) >> 1); + } + + // MVT_VARIABLE data_size 4 (S32's) + template<> template<> + void LLSDMessageBuilderTestObject::test<23>() + { + U32 binData[] = {9,8,7,6,5,4,3,2,1}; + + addValue(messageBlockData, "testBinData", &binData, MVT_VARIABLE, sizeof(binData) >> 2, 4); + messageData->addBlock(messageBlockData); + LLSDMessageBuilder builder = defaultBuilder(); + + builder.copyFromMessageData(*messageData); + LLSD output = builder.getMessage(); + + std::vector<U8> v = output["testBlock"][0]["testBinData"].asBinary(); + ensure("Ensure MVT_S16Array data copied from legacy to llsd give a valid vector", v.size() > 0); + + ensure_memory_matches("Ensure MVT_VARIABLE S32 binary data works in a message copied from legacy to llsd", + &v[0], sizeof(binData) >> 2, binData, sizeof(binData) >> 2); + } + + // MVT_U8 + template<> template<> + void LLSDMessageBuilderTestObject::test<24>() + { + U8 data = 0xa5; + + addValue(messageBlockData, "testBinData", &data, MVT_U8, sizeof(data)); + messageData->addBlock(messageBlockData); + LLSDMessageBuilder builder = defaultBuilder(); + + builder.copyFromMessageData(*messageData); + LLSD output = builder.getMessage(); + + ensure_equals("Ensure MVT_U8 data works in a message copied from legacy to llsd", + output["testBlock"][0]["testBinData"].asInteger(), data); + } + + // MVT_U16 + template<> template<> + void LLSDMessageBuilderTestObject::test<25>() + { + U16 data = 0xa55a; + + addValue(messageBlockData, "testBinData", &data, MVT_U16, sizeof(data)); + messageData->addBlock(messageBlockData); + LLSDMessageBuilder builder = defaultBuilder(); + + builder.copyFromMessageData(*messageData); + LLSD output = builder.getMessage(); + + ensure_equals("Ensure MVT_U16 data works in a message copied from legacy to llsd", + output["testBlock"][0]["testBinData"].asInteger(), data); + } + + // MVT_U32 + template<> template<> + void LLSDMessageBuilderTestObject::test<26>() + { + U32 data = 0xa55a7117; + + addValue(messageBlockData, "testBinData", &data, MVT_U32, sizeof(data)); + messageData->addBlock(messageBlockData); + LLSDMessageBuilder builder = defaultBuilder(); + + builder.copyFromMessageData(*messageData); + LLSD output = builder.getMessage(); + + ensure_equals("Ensure MVT_U32 data works in a message copied from legacy to llsd", + ll_U32_from_sd(output["testBlock"][0]["testBinData"]), data); + } + + // MVT_U64 - crush into an s32: LLSD does not support 64 bit values + template<> template<> + void LLSDMessageBuilderTestObject::test<27>() + { + U64 data = U64L(0xa55a711711223344); + addValue(messageBlockData, "testBinData", &data, MVT_U64, sizeof(data)); + messageData->addBlock(messageBlockData); + LLSDMessageBuilder builder = defaultBuilder(); + + builder.copyFromMessageData(*messageData); + LLSD output = builder.getMessage(); + + ensure_equals("Ensure MVT_U64 data works in a message copied from legacy to llsd", + ll_U64_from_sd(output["testBlock"][0]["testBinData"]), data); + } + + // MVT_S8 + template<> template<> + void LLSDMessageBuilderTestObject::test<28>() + { + S8 data = -31; + + addValue(messageBlockData, "testBinData", &data, MVT_S8, sizeof(data)); + messageData->addBlock(messageBlockData); + LLSDMessageBuilder builder = defaultBuilder(); + + builder.copyFromMessageData(*messageData); + LLSD output = builder.getMessage(); + + ensure_equals("Ensure MVT_S8 data works in a message copied from legacy to llsd", + output["testBlock"][0]["testBinData"].asInteger(), data); + } + + // MVT_S16 + template<> template<> + void LLSDMessageBuilderTestObject::test<29>() + { + S16 data = -31; + + addValue(messageBlockData, "testBinData", &data, MVT_S16, sizeof(data)); + messageData->addBlock(messageBlockData); + LLSDMessageBuilder builder = defaultBuilder(); + + builder.copyFromMessageData(*messageData); + LLSD output = builder.getMessage(); + + ensure_equals("Ensure MVT_S16 data works in a message copied from legacy to llsd", + output["testBlock"][0]["testBinData"].asInteger(), data); + } + + // MVT_S32 + template<> template<> + void LLSDMessageBuilderTestObject::test<30>() + { + S32 data = -3100; + + addValue(messageBlockData, "testBinData", &data, MVT_S32, sizeof(data)); + messageData->addBlock(messageBlockData); + LLSDMessageBuilder builder = defaultBuilder(); + + builder.copyFromMessageData(*messageData); + LLSD output = builder.getMessage(); + + ensure_equals("Ensure MVT_S32 data works in a message copied from legacy to llsd", + output["testBlock"][0]["testBinData"].asInteger(), data); + } + + // MVT_S64 - crush into an s32: LLSD does not support 64 bit values + template<> template<> + void LLSDMessageBuilderTestObject::test<31>() + { + S64 data = -31003100; + + addValue(messageBlockData, "testBinData", &data, MVT_S64, sizeof(data)); + messageData->addBlock(messageBlockData); + LLSDMessageBuilder builder = defaultBuilder(); + + builder.copyFromMessageData(*messageData); + LLSD output = builder.getMessage(); + + ensure_equals("Ensure MVT_S64 data works in a message copied from legacy to llsd", + output["testBlock"][0]["testBinData"].asInteger(), (S32)data); + } + + // MVT_F32 + template<> template<> + void LLSDMessageBuilderTestObject::test<32>() + { + F32 data = 1234.1234f; + + addValue(messageBlockData, "testBinData", &data, MVT_F32, sizeof(data)); + messageData->addBlock(messageBlockData); + LLSDMessageBuilder builder = defaultBuilder(); + + builder.copyFromMessageData(*messageData); + LLSD output = builder.getMessage(); + + ensure_equals("Ensure MVT_F32 data works in a message copied from legacy to llsd", + output["testBlock"][0]["testBinData"].asReal(), data); + } + + // MVT_F64 + template<> template<> + void LLSDMessageBuilderTestObject::test<33>() + { + F64 data = 1234.1234; + + addValue(messageBlockData, "testBinData", &data, MVT_F64, sizeof(data)); + messageData->addBlock(messageBlockData); + LLSDMessageBuilder builder = defaultBuilder(); + + builder.copyFromMessageData(*messageData); + LLSD output = builder.getMessage(); + + ensure_equals("Ensure MVT_F64 data works in a message copied from legacy to llsd", + output["testBlock"][0]["testBinData"].asReal(), data); + } + + // MVT_LLVector3 + template<> template<> + void LLSDMessageBuilderTestObject::test<34>() + { + LLVector3 data(1,2,3); + + addValue(messageBlockData, "testBinData", &data, MVT_LLVector3, sizeof(data)); + messageData->addBlock(messageBlockData); + LLSDMessageBuilder builder = defaultBuilder(); + + builder.copyFromMessageData(*messageData); + LLSD output = builder.getMessage(); + + ensure_equals("Ensure MVT_LLVector3 data works in a message copied from legacy to llsd", + ll_vector3_from_sd(output["testBlock"][0]["testBinData"]), data); + } + + // MVT_LLVector3d + template<> template<> + void LLSDMessageBuilderTestObject::test<35>() + { + LLVector3d data(1,2,3); + + addValue(messageBlockData, "testBinData", &data, MVT_LLVector3d, sizeof(data)); + messageData->addBlock(messageBlockData); + LLSDMessageBuilder builder = defaultBuilder(); + + builder.copyFromMessageData(*messageData); + LLSD output = builder.getMessage(); + + ensure_equals("Ensure MVT_LLVector3 data works in a message copied from legacy to llsd", + ll_vector3d_from_sd(output["testBlock"][0]["testBinData"]), data); + } + + // MVT_LLVector4 + template<> template<> + void LLSDMessageBuilderTestObject::test<36>() + { + LLVector4 data(1,2,3,4); + LLSD v = ll_sd_from_vector4(data); + + addValue(messageBlockData, "testBinData", &data, MVT_LLVector4, sizeof(data)); + messageData->addBlock(messageBlockData); + LLSDMessageBuilder builder = defaultBuilder(); + + builder.copyFromMessageData(*messageData); + LLSD output = builder.getMessage(); + + ensure_equals("Ensure MVT_LLVector4 data works in a message copied from legacy to llsd", + output["testBlock"][0]["testBinData"], v); + } + + // MVT_LLQuaternion + template<> template<> + void LLSDMessageBuilderTestObject::test<37>() + { + LLQuaternion data(1,2,3,0); + + //we send a quaternion packed into a vec3 (w is infered) - so sizeof(vec) == 12 bytes not 16. + LLVector3 vec = data.packToVector3(); + + addValue(messageBlockData, "testBinData", &vec, MVT_LLQuaternion, sizeof(vec)); + messageData->addBlock(messageBlockData); + LLSDMessageBuilder builder = defaultBuilder(); + + builder.copyFromMessageData(*messageData); + LLSD output = builder.getMessage(); + + ensure_equals("Ensure MVT_LLQuaternion data works in a message copied from legacy to llsd", + ll_quaternion_from_sd(output["testBlock"][0]["testBinData"]), data); + } + + // MVT_LLUUID + template<> template<> + void LLSDMessageBuilderTestObject::test<38>() + { + LLUUID data("01234567-0123-0123-0123-234567abcdef"); + + addValue(messageBlockData, "testBinData", &data, MVT_LLUUID, sizeof(data)); + messageData->addBlock(messageBlockData); + LLSDMessageBuilder builder = defaultBuilder(); + + builder.copyFromMessageData(*messageData); + LLSD output = builder.getMessage(); + + std::string v = output["testBlock"][0]["testBinData"].asUUID().asString(); + + ensure_equals("Ensure MVT_LLUUID data works in a message copied from legacy to llsd", + output["testBlock"][0]["testBinData"].asUUID(), data); + } + + // MVT_BOOL + template<> template<> + void LLSDMessageBuilderTestObject::test<39>() + { + BOOL valueTrue = true; + BOOL valueFalse = false; + + LLMsgData* md = new LLMsgData("testMessage"); + LLMsgBlkData* mbd = new LLMsgBlkData("testBlock", 0); + addValue(mbd, "testBoolFalse", &valueFalse, MVT_BOOL, sizeof(BOOL)); + addValue(mbd, "testBoolTrue", &valueTrue, MVT_BOOL, sizeof(BOOL)); + md->addBlock(mbd); + LLSDMessageBuilder builder = defaultBuilder(); + + builder.copyFromMessageData(*md); + LLSD output = builder.getMessage(); + + ensure("Ensure bools work in a message copied from legacy to llsd", + output["testBlock"][0]["testBoolTrue"].asBoolean() && !output["testBlock"][0]["testBoolFalse"].asBoolean()); + } + + // MVT_IP_ADDR + template<> template<> + void LLSDMessageBuilderTestObject::test<40>() + { + U32 data(0xff887766); + LLSD v = ll_sd_from_ipaddr(data); + + addValue(messageBlockData, "testBinData", &data, MVT_IP_ADDR, sizeof(data)); + messageData->addBlock(messageBlockData); + LLSDMessageBuilder builder = defaultBuilder(); + + builder.copyFromMessageData(*messageData); + LLSD output = builder.getMessage(); + + ensure_equals("Ensure MVT_IP_ADDR data works in a message copied from legacy to llsd", + output["testBlock"][0]["testBinData"], v); + } + + // MVT_IP_PORT + template<> template<> + void LLSDMessageBuilderTestObject::test<41>() + { + U16 data = 0xff88; + + addValue(messageBlockData, "testBinData", &data, MVT_IP_PORT, sizeof(data)); + messageData->addBlock(messageBlockData); + LLSDMessageBuilder builder = defaultBuilder(); + + builder.copyFromMessageData(*messageData); + LLSD output = builder.getMessage(); + + ensure_equals("Ensure MVT_IP_PORT data works in a message copied from legacy to llsd", + output["testBlock"][0]["testBinData"].asInteger(), data); + } + + // MVT_U16Vec3 + template<> template<> + void LLSDMessageBuilderTestObject::test<42>() + { + U16 data[3] = {0,1,2}; + + addValue(messageBlockData, "testBinData", &data, MVT_U16Vec3, sizeof(data)); + messageData->addBlock(messageBlockData); + LLSDMessageBuilder builder = defaultBuilder(); + + builder.copyFromMessageData(*messageData); + LLSD output = builder.getMessage(); + + std::vector<U8> v = output["testBlock"][0]["testBinData"].asBinary(); + ensure("Ensure MVT_U16Vec3 data copied from legacy to llsd give a valid vector", v.size() > 0); + + ensure_memory_matches("Ensure MVT_U16Vec3 data works in a message copied from legacy to llsd", + (U16*)&v[0], 6, data, 6); + } + + // MVT_U16Quat + template<> template<> + void LLSDMessageBuilderTestObject::test<43>() + { + U16 data[4] = {0,1,2,4}; + + addValue(messageBlockData, "testBinData", &data, MVT_U16Quat, sizeof(data)); + messageData->addBlock(messageBlockData); + LLSDMessageBuilder builder = defaultBuilder(); + + builder.copyFromMessageData(*messageData); + LLSD output = builder.getMessage(); + + std::vector<U8> v = output["testBlock"][0]["testBinData"].asBinary(); + ensure("Ensure MVT_U16Quat data copied from legacy to llsd give a valid vector", v.size() > 0); + + ensure_memory_matches("Ensure MVT_U16Quat data works in a message copied from legacy to llsd", + (U16*)&v[0], 8, data, 8); + } + + // MVT_S16Array + template<> template<> + void LLSDMessageBuilderTestObject::test<44>() + { + S16 data[19] = {0,-1,2,-4,5,-6,7,-8,9,-10,11,-12,13,-14,15,16,17,18}; + + addValue(messageBlockData, "testBinData", &data, MVT_S16Array, sizeof(data)); + messageData->addBlock(messageBlockData); + LLSDMessageBuilder builder = defaultBuilder(); + + builder.copyFromMessageData(*messageData); + LLSD output = builder.getMessage(); + + std::vector<U8> v = output["testBlock"][0]["testBinData"].asBinary(); + ensure("Ensure MVT_S16Array data copied from legacy to llsd give a valid vector", v.size() > 0); + + ensure_memory_matches("Ensure MVT_S16Array data works in a message copied from legacy to llsd", + (U16*)&v[0], 19, data, 19); + } + + template<> template<> + void LLSDMessageBuilderTestObject::test<45>() + { + LLMessageTemplate messageTemplate = defaultTemplate(); + messageTemplate.addBlock(defaultTemplateBlock(MVT_U8, 1)); + U8 inValue = 2; + LLTemplateMessageBuilder* template_builder = defaultTemplateBuilder(messageTemplate); + template_builder->addU8(_PREHASH_Test0, inValue); + + LLSDMessageBuilder builder; + builder.copyFromMessageData(*template_builder->getCurrentMessage()); + LLSD output = builder.getMessage(); + + ensure_equals(output["Test0"][0]["Test0"].asInteger(), 2); + + } + + template<> template<> + void LLSDMessageBuilderTestObject::test<46>() + { + LLMessageTemplate messageTemplate = defaultTemplate(); + messageTemplate.addBlock(defaultTemplateBlock(MVT_VARIABLE, 1)); + std::string inValue = "testing"; + LLTemplateMessageBuilder* builder = defaultTemplateBuilder(messageTemplate); + builder->addString(_PREHASH_Test0, inValue.c_str()); + + LLSDMessageBuilder sd_builder; + sd_builder.copyFromMessageData(*builder->getCurrentMessage()); + LLSD output = sd_builder.getMessage(); + + ensure_equals(output["Test0"][0]["Test0"].asString(), std::string("testing")); + } + } diff --git a/indra/test/lltimestampcache_tut.cpp b/indra/test/lltimestampcache_tut.cpp new file mode 100644 index 0000000000..9e0de0fe60 --- /dev/null +++ b/indra/test/lltimestampcache_tut.cpp @@ -0,0 +1,129 @@ +/** + * @file lltimestampcache_tut.cpp + * @author James Tess + * @date 2008-12-03 + * + * $LicenseInfo:firstyear=2008&license=viewergpl$ + * + * Copyright (c) 2008, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlife.com/developers/opensource/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at http://secondlife.com/developers/opensource/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/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/lltut.cpp b/indra/test/lltut.cpp index 64861c3115..201e174f9c 100644 --- a/indra/test/lltut.cpp +++ b/indra/test/lltut.cpp @@ -33,10 +33,13 @@ */ #include "linden_common.h" + #include "lltut.h" +#include "lldate.h" #include "llformat.h" #include "llsd.h" +#include "lluri.h" namespace tut { @@ -74,7 +77,7 @@ namespace tut void ensure_equals(const char* m, const LLSD& actual, const LLSD& expected) { - const std::string& msg = m; + const std::string& msg = m ? m : ""; ensure_equals(msg + " type", actual.type(), expected.type()); switch (actual.type()) @@ -196,3 +199,4 @@ namespace tut } } } + diff --git a/indra/test/lltut.h b/indra/test/lltut.h index 51e2ee2709..6d50ebad33 100644 --- a/indra/test/lltut.h +++ b/indra/test/lltut.h @@ -35,13 +35,13 @@ #ifndef LL_LLTUT_H #define LL_LLTUT_H -#include <tut/tut.hpp> - -#include "lldate.h" -#include "lluri.h" #include "llmath.h" +#include <tut/tut.hpp> + +class LLDate; class LLSD; +class LLURI; namespace tut { diff --git a/indra/test/test.cpp b/indra/test/test.cpp index 566459ee90..ba81c6e49e 100644 --- a/indra/test/test.cpp +++ b/indra/test/test.cpp @@ -54,9 +54,10 @@ # include "ctype_workaround.h" #endif - namespace tut { + std::string sSourceDir; + test_runner_singleton runner; } @@ -184,6 +185,7 @@ static const apr_getopt_option_t TEST_CL_OPTIONS[] = {"verbose", 'v', 0, "Verbose output."}, {"group", 'g', 1, "Run test group specified by option argument."}, {"output", 'o', 1, "Write output to the named file."}, + {"sourcedir", 's', 1, "Project source file directory from CMake."}, {"touch", 't', 1, "Touch the given file if all tests succeed"}, {"wait", 'w', 0, "Wait for input before exit."}, {"debug", 'd', 0, "Emit full debug logs."}, @@ -302,6 +304,11 @@ int main(int argc, char **argv) output = new std::ofstream; output->open(opt_arg); break; + case 's': // --sourcedir + tut::sSourceDir = opt_arg; + // For convenience, so you can use tut::sSourceDir + "myfile" + tut::sSourceDir += '/'; + break; case 't': touch = opt_arg; break; diff --git a/indra/test/test.h b/indra/test/test.h new file mode 100644 index 0000000000..16ec4effcf --- /dev/null +++ b/indra/test/test.h @@ -0,0 +1,49 @@ +/** + * @file test.h + * @author James + * @date 2009-01-12 + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * + * Copyright (c) 2009, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlife.com/developers/opensource/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at http://secondlife.com/developers/opensource/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ +#ifndef TEST_H +#define TEST_H + +#include <string> + +namespace tut +{ + // Source code directory from CMake, used for loading test data and + // configuration. For example: + // + // loadMyConfig( sSourceDir + "config.dat" ); + // + // Use sparingly, as hitting the file system slows down test execution + // and hence every compile. JC + extern std::string sSourceDir; +} + +#endif |