From ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Thu, 30 Apr 2009 13:04:20 -0500 Subject: Second Life viewer sources 1.23.0-RC --- linden/indra/test/CMakeLists.txt | 14 +- linden/indra/test/assembly_tut.cpp | 86 ---- linden/indra/test/common.cpp | 37 +- linden/indra/test/inventory.cpp | 3 +- linden/indra/test/io.cpp | 3 +- linden/indra/test/llapp_tut.cpp | 5 +- linden/indra/test/llassetuploadqueue_tut.cpp | 3 +- linden/indra/test/llbase64_tut.cpp | 3 +- linden/indra/test/llbitpack_tut.cpp | 5 +- linden/indra/test/llblowfish_tut.cpp | 15 +- linden/indra/test/llbuffer_tut.cpp | 5 +- linden/indra/test/llcontrol_tut.cpp | 5 +- linden/indra/test/lldatapacker_tut.cpp | 5 +- linden/indra/test/lldate_tut.cpp | 5 +- linden/indra/test/lldir_tut.cpp | 5 +- linden/indra/test/llerror_tut.cpp | 5 +- linden/indra/test/llhost_tut.cpp | 5 +- linden/indra/test/llhttpclient_tut.cpp | 7 +- linden/indra/test/llhttpdate_tut.cpp | 3 +- linden/indra/test/llhttpnode_tut.cpp | 6 +- linden/indra/test/llinventoryparcel_tut.cpp | 3 +- linden/indra/test/lliohttpserver_tut.cpp | 3 +- linden/indra/test/lljoint_tut.cpp | 5 +- linden/indra/test/llmessageconfig_tut.cpp | 3 +- linden/indra/test/llmessagetemplateparser_tut.cpp | 3 +- linden/indra/test/llmime_tut.cpp | 5 +- linden/indra/test/llmodularmath_tut.cpp | 5 +- linden/indra/test/llnamevalue_tut.cpp | 3 +- linden/indra/test/llpartdata_tut.cpp | 5 +- linden/indra/test/llpermissions_tut.cpp | 5 +- linden/indra/test/llpipeutil.cpp | 3 +- linden/indra/test/llpipeutil.h | 3 +- linden/indra/test/llquaternion_tut.cpp | 5 +- linden/indra/test/llrandom_tut.cpp | 5 +- linden/indra/test/llsaleinfo_tut.cpp | 7 +- linden/indra/test/llscriptresource_tut.cpp | 204 ++++++++ linden/indra/test/llsd_new_tut.cpp | 5 +- linden/indra/test/llsdmessagebuilder_tut.cpp | 561 ++++++++++++++++++++- linden/indra/test/llsdmessagereader_tut.cpp | 5 +- linden/indra/test/llsdserialize_tut.cpp | 13 +- linden/indra/test/llsdtraits.h | 3 +- linden/indra/test/llsdutil_tut.cpp | 3 +- linden/indra/test/llservicebuilder_tut.cpp | 5 +- linden/indra/test/llstreamtools_tut.cpp | 5 +- linden/indra/test/llstring_tut.cpp | 13 +- linden/indra/test/lltemplatemessagebuilder_tut.cpp | 12 +- linden/indra/test/lltimestampcache_tut.cpp | 130 +++++ linden/indra/test/lltiming_tut.cpp | 3 +- linden/indra/test/lltranscode_tut.cpp | 95 ++++ linden/indra/test/lltut.cpp | 17 +- linden/indra/test/lltut.h | 15 +- linden/indra/test/lluri_tut.cpp | 3 +- linden/indra/test/lluserrelations_tut.cpp | 5 +- linden/indra/test/lluuidhashmap_tut.cpp | 5 +- linden/indra/test/llxfer_tut.cpp | 3 +- linden/indra/test/llxorcipher_tut.cpp | 3 +- linden/indra/test/m3math_tut.cpp | 5 +- linden/indra/test/mass_properties_tut.cpp | 25 +- linden/indra/test/math.cpp | 3 +- linden/indra/test/message_tut.cpp | 14 +- linden/indra/test/mock_http_client.cpp | 3 +- linden/indra/test/mock_http_client.h | 3 +- linden/indra/test/prim_linkability_tut.cpp | 25 +- linden/indra/test/reflection_tut.cpp | 5 +- linden/indra/test/test.cpp | 34 +- linden/indra/test/test.h | 50 ++ linden/indra/test/test_llmanifest.py | 3 +- linden/indra/test/v2math_tut.cpp | 5 +- linden/indra/test/v3color_tut.cpp | 7 +- linden/indra/test/v3dmath_tut.cpp | 7 +- linden/indra/test/v3math_tut.cpp | 5 +- linden/indra/test/v4color_tut.cpp | 5 +- linden/indra/test/v4coloru_tut.cpp | 5 +- linden/indra/test/v4math_tut.cpp | 5 +- linden/indra/test/xform_tut.cpp | 5 +- 75 files changed, 1338 insertions(+), 272 deletions(-) delete mode 100644 linden/indra/test/assembly_tut.cpp create mode 100644 linden/indra/test/llscriptresource_tut.cpp create mode 100644 linden/indra/test/lltimestampcache_tut.cpp create mode 100644 linden/indra/test/lltranscode_tut.cpp create mode 100644 linden/indra/test/test.h (limited to 'linden/indra/test') diff --git a/linden/indra/test/CMakeLists.txt b/linden/indra/test/CMakeLists.txt index acb571b..2033d67 100644 --- a/linden/indra/test/CMakeLists.txt +++ b/linden/indra/test/CMakeLists.txt @@ -10,7 +10,9 @@ include(LLMath) include(LLMessage) include(LLVFS) include(LLXML) +include(LScript) include(Linking) +include(Tut) include_directories( ${LLCOMMON_INCLUDE_DIRS} @@ -20,13 +22,14 @@ include_directories( ${LLINVENTORY_INCLUDE_DIRS} ${LLVFS_INCLUDE_DIRS} ${LLXML_INCLUDE_DIRS} + ${LSCRIPT_INCLUDE_DIRS} ) set(test_SOURCE_FILES common.cpp inventory.cpp io.cpp - llapp_tut.cpp +# llapp_tut.cpp # Temporarily removed until thread issues can be solved llbase64_tut.cpp llblowfish_tut.cpp llbuffer_tut.cpp @@ -48,6 +51,7 @@ set(test_SOURCE_FILES llquaternion_tut.cpp llrandom_tut.cpp llsaleinfo_tut.cpp + llscriptresource_tut.cpp llsdmessagebuilder_tut.cpp llsdmessagereader_tut.cpp llsd_new_tut.cpp @@ -57,7 +61,9 @@ set(test_SOURCE_FILES llstreamtools_tut.cpp llstring_tut.cpp lltemplatemessagebuilder_tut.cpp + lltimestampcache_tut.cpp lltiming_tut.cpp + lltranscode_tut.cpp lltut.cpp lluri_tut.cpp lluuidhashmap_tut.cpp @@ -108,7 +114,9 @@ target_link_libraries(test ${LLMATH_LIBRARIES} ${LLVFS_LIBRARIES} ${LLXML_LIBRARIES} + ${LSCRIPT_LIBRARIES} ${LLCOMMON_LIBRARIES} + ${APRICONV_LIBRARIES} ${PTHREAD_LIBRARY} ${WINDOWS_LIBRARIES} ${DL_LIBRARY} @@ -117,8 +125,8 @@ target_link_libraries(test if (WINDOWS) set_target_properties(test PROPERTIES - LINK_FLAGS "/NODEFAULTLIB:MSVCRT" - LINK_FLAGS_DEBUG "/NODEFAULTLIB:LIBCMT" + LINK_FLAGS "/NODEFAULTLIB:LIBCMT" + LINK_FLAGS_DEBUG "/NODEFAULTLIB:\"LIBCMT;LIBCMTD;MSVCRT\"" ) endif (WINDOWS) diff --git a/linden/indra/test/assembly_tut.cpp b/linden/indra/test/assembly_tut.cpp deleted file mode 100644 index 82a2b03..0000000 --- a/linden/indra/test/assembly_tut.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/** - * @file assembly_tut.cpp - * @brief Tests for lscript/lscript_execute_mono - * - * $LicenseInfo:firstyear=2007&license=internal$ - * - * Copyright (c) 2007-2009, Linden Research, Inc. - * - * The following source code is PROPRIETARY AND CONFIDENTIAL. Use of - * this source code is governed by the Linden Lab Source Code Disclosure - * Agreement ("Agreement") previously entered between you and Linden - * Lab. By accessing, using, copying, modifying or distributing this - * software, you acknowledge that you have been informed of your - * obligations under the Agreement 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 "linden_common.h" -#include "lltut.h" - -#include "lscript_execute_mono/assembly.cpp" - -#include -#include - - -namespace tut -{ - struct assembly_data - { - }; - typedef test_group assembly_test; - typedef assembly_test::object assembly_object; - tut::assembly_test assembly("assembly"); - - // Create some random junk, its not important at the moment. - U8* createTestBuffer(U32 size) - { - U8* result = new U8[size]; - memset(result, 0, size); - return result; - } - - template<> template<> - void assembly_object::test<1>() - { - ensure("Assembly map not empty before creation", sAssemblyMap.empty()); - { - U32 size = 10; - U8* buffer = createTestBuffer(size); - boost::intrusive_ptr assembly1 = LLAssembly::create("Assembly1", - buffer, size); - - ensure("created assembly with ref count of 1", - assembly1->mRefCount == 1); - - ensure("sAssemblyMap.size() == 1", sAssemblyMap.size() == 1); - - size = 200; - buffer = createTestBuffer(size); - boost::intrusive_ptr assembly2 = LLAssembly::create("Assembly2", - buffer, size); - - ensure("created second assembly with ref count == 1", - assembly2->mRefCount == 1); - - ensure("sAssemblyMap.size() == 2", sAssemblyMap.size() == 2); - - size = 10; - buffer = createTestBuffer(size); - boost::intrusive_ptr assembly3 = LLAssembly::create("Assembly1", - buffer, size); - - ensure("created with ref count of 2", - assembly3->mRefCount == 2); - - ensure("sAssemblyMap.size() == 2", sAssemblyMap.size() == 2); - } - - ensure("Assembly map not empty after creation", sAssemblyMap.empty()); - } -} diff --git a/linden/indra/test/common.cpp b/linden/indra/test/common.cpp index ae84f18..c8e6268 100644 --- a/linden/indra/test/common.cpp +++ b/linden/indra/test/common.cpp @@ -19,7 +19,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -48,6 +49,7 @@ #include "llsd.h" #include "llsdserialize.h" #include "u64.h" +#include "llhash.h" #if LL_WINDOWS // disable overflow warnings @@ -638,3 +640,36 @@ namespace tut } +namespace tut +{ + struct hash_data + { + }; + typedef test_group hash_test; + typedef hash_test::object hash_object; + tut::hash_test hash_tester("hash_test"); + + template<> template<> + void hash_object::test<1>() + { + const char * str1 = "test string one"; + const char * same_as_str1 = "test string one"; + + size_t hash1 = llhash(str1); + size_t same_as_hash1 = llhash(same_as_str1); + + + ensure("Hashes from identical strings should be equal", hash1 == same_as_hash1); + + char str[100]; + strcpy( str, "Another test" ); + + size_t hash2 = llhash(str); + + strcpy( str, "Different string, same pointer" ); + + size_t hash3 = llhash(str); + + ensure("Hashes from same pointer but different string should not be equal", hash2 != hash3); + } +} diff --git a/linden/indra/test/inventory.cpp b/linden/indra/test/inventory.cpp index 64d7bff..8cd356b 100644 --- a/linden/indra/test/inventory.cpp +++ b/linden/indra/test/inventory.cpp @@ -19,7 +19,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, diff --git a/linden/indra/test/io.cpp b/linden/indra/test/io.cpp index fe161c5..483eb9d 100644 --- a/linden/indra/test/io.cpp +++ b/linden/indra/test/io.cpp @@ -19,7 +19,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, diff --git a/linden/indra/test/llapp_tut.cpp b/linden/indra/test/llapp_tut.cpp index 8453e50..3f5ac38 100644 --- a/linden/indra/test/llapp_tut.cpp +++ b/linden/indra/test/llapp_tut.cpp @@ -18,7 +18,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -30,7 +31,7 @@ * $/LicenseInfo$ */ -#include +#include #include "linden_common.h" #include "llapp.h" diff --git a/linden/indra/test/llassetuploadqueue_tut.cpp b/linden/indra/test/llassetuploadqueue_tut.cpp index 8ece4a5..241574e 100644 --- a/linden/indra/test/llassetuploadqueue_tut.cpp +++ b/linden/indra/test/llassetuploadqueue_tut.cpp @@ -17,7 +17,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, diff --git a/linden/indra/test/llbase64_tut.cpp b/linden/indra/test/llbase64_tut.cpp index 898c68b..8598986 100644 --- a/linden/indra/test/llbase64_tut.cpp +++ b/linden/indra/test/llbase64_tut.cpp @@ -18,7 +18,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, diff --git a/linden/indra/test/llbitpack_tut.cpp b/linden/indra/test/llbitpack_tut.cpp index 92782ab..be1dcb2 100644 --- a/linden/indra/test/llbitpack_tut.cpp +++ b/linden/indra/test/llbitpack_tut.cpp @@ -19,7 +19,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -31,7 +32,7 @@ * $/LicenseInfo$ */ -#include +#include #include "linden_common.h" #include "bitpack.h" #include "lltut.h" diff --git a/linden/indra/test/llblowfish_tut.cpp b/linden/indra/test/llblowfish_tut.cpp index e1386fa..4a128a8 100644 --- a/linden/indra/test/llblowfish_tut.cpp +++ b/linden/indra/test/llblowfish_tut.cpp @@ -22,7 +22,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -93,9 +94,6 @@ namespace tut template<> template<> void blowfish_object::test<1>() { -#if LL_WINDOWS - skip_fail("Blowfish only supported on Linux."); -#else LLUUID blank; LLBlowfishCipher cipher(&blank.mData[0], UUID_BYTES); @@ -108,15 +106,11 @@ namespace tut dst_len = cipher.requiredEncryptionSpace(8); ensure("encryption space 8", (dst_len == 16) ); -#endif // LL_WINDOWS } template<> template<> void blowfish_object::test<2>() { -#if LL_WINDOWS - skip_fail("Blowfish only supported on Linux."); -#else LLUUID blank; LLBlowfishCipher cipher(&blank.mData[0], UUID_BYTES); @@ -130,15 +124,11 @@ namespace tut result.resize(count); ensure("encrypt null key", matchFile("blowfish.1.bin", result)); -#endif // LL_WINDOWS } template<> template<> void blowfish_object::test<3>() { -#if LL_WINDOWS - skip_fail("Blowfish only supported on Linux."); -#else // same as base64 test id LLUUID id("526a1e07-a19d-baed-84c4-ff08a488d15e"); LLBlowfishCipher cipher(&id.mData[0], UUID_BYTES); @@ -153,6 +143,5 @@ namespace tut result.resize(count); ensure("encrypt real key", matchFile("blowfish.2.bin", result)); -#endif // LL_WINDOWS } } diff --git a/linden/indra/test/llbuffer_tut.cpp b/linden/indra/test/llbuffer_tut.cpp index 46708ce..a0b6379 100644 --- a/linden/indra/test/llbuffer_tut.cpp +++ b/linden/indra/test/llbuffer_tut.cpp @@ -19,7 +19,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -31,7 +32,7 @@ * $/LicenseInfo$ */ -#include +#include #include "linden_common.h" #include "lltut.h" #include "llbuffer.h" diff --git a/linden/indra/test/llcontrol_tut.cpp b/linden/indra/test/llcontrol_tut.cpp index 68e8a92..2e2c1dd 100644 --- a/linden/indra/test/llcontrol_tut.cpp +++ b/linden/indra/test/llcontrol_tut.cpp @@ -18,7 +18,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -32,7 +33,7 @@ #include "linden_common.h" -#include +#include #include "lltut.h" #include "llcontrol.h" diff --git a/linden/indra/test/lldatapacker_tut.cpp b/linden/indra/test/lldatapacker_tut.cpp index dd424af..6c0fa56 100644 --- a/linden/indra/test/lldatapacker_tut.cpp +++ b/linden/indra/test/lldatapacker_tut.cpp @@ -19,7 +19,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -31,7 +32,7 @@ * $/LicenseInfo$ */ -#include +#include #include "lltut.h" #include "linden_common.h" #include "lldatapacker.h" diff --git a/linden/indra/test/lldate_tut.cpp b/linden/indra/test/lldate_tut.cpp index 5a0fb96..630d34e 100644 --- a/linden/indra/test/lldate_tut.cpp +++ b/linden/indra/test/lldate_tut.cpp @@ -19,7 +19,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -31,7 +32,7 @@ * $/LicenseInfo$ */ -#include +#include #include "linden_common.h" #include "lldate.h" diff --git a/linden/indra/test/lldir_tut.cpp b/linden/indra/test/lldir_tut.cpp index 4d9be65..2b0dde0 100644 --- a/linden/indra/test/lldir_tut.cpp +++ b/linden/indra/test/lldir_tut.cpp @@ -18,7 +18,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -30,7 +31,7 @@ * $/LicenseInfo$ */ -#include +#include #include "linden_common.h" #include "lltut.h" diff --git a/linden/indra/test/llerror_tut.cpp b/linden/indra/test/llerror_tut.cpp index d6a4c07..c4f52f6 100644 --- a/linden/indra/test/llerror_tut.cpp +++ b/linden/indra/test/llerror_tut.cpp @@ -18,7 +18,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -41,7 +42,7 @@ namespace } } -#include +#include #include "lltut.h" #include diff --git a/linden/indra/test/llhost_tut.cpp b/linden/indra/test/llhost_tut.cpp index c9e7c3b..dd792d9 100644 --- a/linden/indra/test/llhost_tut.cpp +++ b/linden/indra/test/llhost_tut.cpp @@ -19,7 +19,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -31,7 +32,7 @@ * $/LicenseInfo$ */ -#include +#include #include "linden_common.h" #include "lltut.h" #include "llhost.h" diff --git a/linden/indra/test/llhttpclient_tut.cpp b/linden/indra/test/llhttpclient_tut.cpp index 7f3b646..d1bf8ae 100644 --- a/linden/indra/test/llhttpclient_tut.cpp +++ b/linden/indra/test/llhttpclient_tut.cpp @@ -17,7 +17,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -35,7 +36,7 @@ * */ -#include +#include #include "linden_common.h" // These are too slow on Windows to actually include in the build. JC @@ -345,7 +346,7 @@ namespace tut // won't ever let it run. Instead get from a known LLSD // source and compare results with the non-blocking get which // is tested against the mini server earlier. - skip_fail("secondlife.com is not reliable enough for unit tests."); + skip("secondlife.com is not reliable enough for unit tests."); LLSD expected; diff --git a/linden/indra/test/llhttpdate_tut.cpp b/linden/indra/test/llhttpdate_tut.cpp index 76a39c6..b764696 100644 --- a/linden/indra/test/llhttpdate_tut.cpp +++ b/linden/indra/test/llhttpdate_tut.cpp @@ -18,7 +18,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, diff --git a/linden/indra/test/llhttpnode_tut.cpp b/linden/indra/test/llhttpnode_tut.cpp index 04be854..e17d1e0 100644 --- a/linden/indra/test/llhttpnode_tut.cpp +++ b/linden/indra/test/llhttpnode_tut.cpp @@ -18,7 +18,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -85,7 +86,8 @@ namespace tut void result(const LLSD& result) { mResult = result; } void status(S32 code, const std::string& message) { } - + void extendedResult(S32 code, const std::string& message, const LLSD& headers) { } + private: Response() {;} // Must be accessed through LLPointer. }; diff --git a/linden/indra/test/llinventoryparcel_tut.cpp b/linden/indra/test/llinventoryparcel_tut.cpp index 9c5c54c..63669e8 100644 --- a/linden/indra/test/llinventoryparcel_tut.cpp +++ b/linden/indra/test/llinventoryparcel_tut.cpp @@ -18,7 +18,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, diff --git a/linden/indra/test/lliohttpserver_tut.cpp b/linden/indra/test/lliohttpserver_tut.cpp index ca0c211..7d3b312 100644 --- a/linden/indra/test/lliohttpserver_tut.cpp +++ b/linden/indra/test/lliohttpserver_tut.cpp @@ -18,7 +18,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, diff --git a/linden/indra/test/lljoint_tut.cpp b/linden/indra/test/lljoint_tut.cpp index 45b4cc7..a84d2b6 100644 --- a/linden/indra/test/lljoint_tut.cpp +++ b/linden/indra/test/lljoint_tut.cpp @@ -19,7 +19,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -34,7 +35,7 @@ #ifdef THIS_DOESNT_LINK // THIS DOESN'T LINK! -#include +#include #include "lltut.h" #include "linden_common.h" #include "m4math.h" diff --git a/linden/indra/test/llmessageconfig_tut.cpp b/linden/indra/test/llmessageconfig_tut.cpp index c4b506d..ddc1d07 100644 --- a/linden/indra/test/llmessageconfig_tut.cpp +++ b/linden/indra/test/llmessageconfig_tut.cpp @@ -18,7 +18,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, diff --git a/linden/indra/test/llmessagetemplateparser_tut.cpp b/linden/indra/test/llmessagetemplateparser_tut.cpp index 7158c8a..02acc15 100644 --- a/linden/indra/test/llmessagetemplateparser_tut.cpp +++ b/linden/indra/test/llmessagetemplateparser_tut.cpp @@ -18,7 +18,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, diff --git a/linden/indra/test/llmime_tut.cpp b/linden/indra/test/llmime_tut.cpp index c2185e3..ab87731 100644 --- a/linden/indra/test/llmime_tut.cpp +++ b/linden/indra/test/llmime_tut.cpp @@ -19,7 +19,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -31,7 +32,7 @@ * $/LicenseInfo$ */ -#include +#include #include "linden_common.h" #include "llmime.h" #include "llsdserialize.h" diff --git a/linden/indra/test/llmodularmath_tut.cpp b/linden/indra/test/llmodularmath_tut.cpp index 32bcbe0..519e045 100644 --- a/linden/indra/test/llmodularmath_tut.cpp +++ b/linden/indra/test/llmodularmath_tut.cpp @@ -19,7 +19,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -31,7 +32,7 @@ * $/LicenseInfo$ */ -#include +#include #include "linden_common.h" #include "lltut.h" #include "llmodularmath.h" diff --git a/linden/indra/test/llnamevalue_tut.cpp b/linden/indra/test/llnamevalue_tut.cpp index 72e4571..2a7ca0c 100644 --- a/linden/indra/test/llnamevalue_tut.cpp +++ b/linden/indra/test/llnamevalue_tut.cpp @@ -19,7 +19,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, diff --git a/linden/indra/test/llpartdata_tut.cpp b/linden/indra/test/llpartdata_tut.cpp index ffd26ac..cb31b81 100644 --- a/linden/indra/test/llpartdata_tut.cpp +++ b/linden/indra/test/llpartdata_tut.cpp @@ -19,7 +19,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -31,7 +32,7 @@ * $/LicenseInfo$ */ -#include +#include #include "lltut.h" #include "linden_common.h" #include "lldatapacker.h" diff --git a/linden/indra/test/llpermissions_tut.cpp b/linden/indra/test/llpermissions_tut.cpp index 10af319..9dbb964 100644 --- a/linden/indra/test/llpermissions_tut.cpp +++ b/linden/indra/test/llpermissions_tut.cpp @@ -19,7 +19,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -31,7 +32,7 @@ * $/LicenseInfo$ */ -#include +#include #include "linden_common.h" #include "lltut.h" #include "message.h" diff --git a/linden/indra/test/llpipeutil.cpp b/linden/indra/test/llpipeutil.cpp index 32084a2..9c81fa3 100644 --- a/linden/indra/test/llpipeutil.cpp +++ b/linden/indra/test/llpipeutil.cpp @@ -18,7 +18,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, diff --git a/linden/indra/test/llpipeutil.h b/linden/indra/test/llpipeutil.h index 49aaac4..acff2d8 100644 --- a/linden/indra/test/llpipeutil.h +++ b/linden/indra/test/llpipeutil.h @@ -18,7 +18,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, diff --git a/linden/indra/test/llquaternion_tut.cpp b/linden/indra/test/llquaternion_tut.cpp index 0223749..b5b1047 100644 --- a/linden/indra/test/llquaternion_tut.cpp +++ b/linden/indra/test/llquaternion_tut.cpp @@ -19,7 +19,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -31,7 +32,7 @@ * $/LicenseInfo$ */ -#include +#include #include "linden_common.h" #include "lltut.h" diff --git a/linden/indra/test/llrandom_tut.cpp b/linden/indra/test/llrandom_tut.cpp index c1c45b0..0a5d595 100644 --- a/linden/indra/test/llrandom_tut.cpp +++ b/linden/indra/test/llrandom_tut.cpp @@ -18,7 +18,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -30,7 +31,7 @@ * $/LicenseInfo$ */ -#include +#include #include "linden_common.h" #include "llrand.h" diff --git a/linden/indra/test/llsaleinfo_tut.cpp b/linden/indra/test/llsaleinfo_tut.cpp index d91bca4..7f8219c 100644 --- a/linden/indra/test/llsaleinfo_tut.cpp +++ b/linden/indra/test/llsaleinfo_tut.cpp @@ -19,7 +19,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -31,7 +32,7 @@ * $/LicenseInfo$ */ -#include +#include #include "linden_common.h" #include "lltut.h" #include "llsaleinfo.h" @@ -53,7 +54,7 @@ namespace tut S32 sale_price = 10000; LLSaleInfo llsaleinfo(LLSaleInfo::FS_COPY, sale_price); - char* sale= "copy"; + const char* sale= "copy"; LLSD llsd_obj1 = ll_create_sd_from_sale_info(llsaleinfo); LLSaleInfo saleinfo1 = ll_sale_info_from_sd(llsd_obj1); diff --git a/linden/indra/test/llscriptresource_tut.cpp b/linden/indra/test/llscriptresource_tut.cpp new file mode 100644 index 0000000..705fdd1 --- /dev/null +++ b/linden/indra/test/llscriptresource_tut.cpp @@ -0,0 +1,204 @@ +/** + * @file llscriptresource_tut.cpp + * @brief Test LLScriptResource + * + * $LicenseInfo:firstyear=2008&license=viewergpl$ + * + * Copyright (c) 2008-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://secondlifegrid.net/programs/open_source/licensing/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://secondlifegrid.net/programs/open_source/licensing/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 +#include "linden_common.h" + +#include "lltut.h" + +#include "llscriptresource.h" +#include "llscriptresourceconsumer.h" +#include "llscriptresourcepool.h" + +class TestConsumer : public LLScriptResourceConsumer +{ +public: + TestConsumer() + : mUsedURLs(0) + { } + + // LLScriptResourceConsumer interface: + S32 getUsedPublicURLs() const + { + return mUsedURLs; + } + + // Test details: + S32 mUsedURLs; +}; + + +namespace tut +{ + class LLScriptResourceTestData + { + }; + + typedef test_group LLScriptResourceTestGroup; + typedef LLScriptResourceTestGroup::object LLScriptResourceTestObject; + LLScriptResourceTestGroup scriptResourceTestGroup("scriptResource"); + + template<> template<> + void LLScriptResourceTestObject::test<1>() + { + LLScriptResource resource; + U32 total = 42; + + resource.setTotal(total); + ensure_equals("Verify set/get total", resource.getTotal(), total); + ensure_equals("Verify all resources are initially available",resource.getAvailable(),total); + + // Requesting too many, releasing non-allocated + ensure("Request total + 1 resources should fail",!resource.request(total + 1)); + ensure_equals("Verify all resources available after failed request",resource.getAvailable(),total); + + ensure("Releasing resources when none allocated should fail",!resource.release()); + ensure_equals("All resources should be available after failed release",resource.getAvailable(),total); + + ensure("Request one resource", resource.request()); + ensure_equals("Verify available resources after successful request",resource.getAvailable(),total - 1); + + // Is this right? Or should we release all used resources if we try to release more than are currently used? + ensure("Release more resources than allocated",!resource.release(2)); + ensure_equals("Verify resource availability after failed release",resource.getAvailable(),total - 1); + + ensure("Release a resource",resource.release()); + ensure_equals("Verify all resources available after successful release",resource.getAvailable(),total); + } + + + template<> template<> + void LLScriptResourceTestObject::test<2>() + { + LLScriptResource resource; + U32 total = 42; + + resource.setTotal(total); + + S32 resources_to_request = 30; + ensure("Get multiple resources resources",resource.request(resources_to_request)); + ensure_equals("Verify available resources is correct after request of multiple resources",resource.getAvailable(), total - resources_to_request); + + S32 resources_to_release = (resources_to_request / 2); + ensure("Release some resources",resource.release(resources_to_release)); + + S32 expected_available = (total - resources_to_request + resources_to_release); + ensure_equals("Verify available resources after release of some resources",resource.getAvailable(), expected_available); + + resources_to_release = (resources_to_request - resources_to_release); + ensure("Release remaining resources",resource.release(resources_to_release)); + + ensure_equals("Verify available resources after release of remaining resources",resource.getAvailable(), total); + } + + template<> template<> + void LLScriptResourceTestObject::test<3>() + { + LLScriptResource resource; + + U32 total = 42; + resource.setTotal(total); + + ensure("Request all resources",resource.request(total)); + + U32 low_total = 10; + ensure("Release all resources",resource.release(total)); + ensure_equals("Verify all resources available after releasing",resource.getAvailable(),total); + + resource.setTotal(low_total); + ensure_equals("Verify low total resources are available after set",resource.getAvailable(),low_total); + } + + + template<> template<> + void LLScriptResourceTestObject::test<4>() + { + S32 big_resource_total = 100; + S32 small_resource_total = 10; + LLScriptResourcePool big_pool; + big_pool.getPublicURLResource().setTotal(big_resource_total); + LLScriptResourcePool small_pool; + small_pool.getPublicURLResource().setTotal(small_resource_total); + + TestConsumer consumer; + LLScriptResourcePool& initial_pool = consumer.getScriptResourcePool(); + ensure("Initial resource pool is 'null'.", (&initial_pool == &LLScriptResourcePool::null)); + + consumer.switchScriptResourcePools(big_pool); + LLScriptResourcePool& get_pool = consumer.getScriptResourcePool(); + ensure("Get resource that was set.", (&big_pool == &get_pool)); + + ensure_equals("No public urls in use yet.", consumer.getUsedPublicURLs(),0); + + S32 request_urls = 5; + consumer.mUsedURLs = request_urls; + consumer.getScriptResourcePool().getPublicURLResource().request(request_urls); + + ensure_equals("Available urls on big_pool is 5 less than total.", + big_pool.getPublicURLResource().getAvailable(), big_resource_total - request_urls); + + ensure("Switching from big pool to small pool", + consumer.switchScriptResourcePools(small_pool)); + + ensure_equals("All resources available to big pool again", + big_pool.getPublicURLResource().getAvailable(), big_resource_total); + + ensure_equals("Available urls on small pool is 5 less than total.", + small_pool.getPublicURLResource().getAvailable(), small_resource_total - request_urls); + + ensure("Switching from small pool to big pool", + consumer.switchScriptResourcePools(big_pool)); + + consumer.getScriptResourcePool().getPublicURLResource().release(request_urls); + + request_urls = 50; // Too many for the small_pool + + consumer.mUsedURLs = request_urls; + consumer.getScriptResourcePool().getPublicURLResource().request(request_urls); + + // Verify big pool has them + ensure_equals("Available urls on big pool is 50 less than total.", + big_pool.getPublicURLResource().getAvailable(), big_resource_total - request_urls); + + // Verify can't switch to small_pool + ensure("Switching to small pool with too many resources", + !consumer.switchScriptResourcePools(small_pool)); + + // Verify big pool still accounting for used resources + ensure_equals("Available urls on big_pool is still 50 less than total.", + big_pool.getPublicURLResource().getAvailable(), big_resource_total - request_urls); + + // Verify small pool still has all resources available. + ensure_equals("All resources in small pool are still available.", + small_pool.getPublicURLResource().getAvailable(), small_resource_total); + } +} diff --git a/linden/indra/test/llsd_new_tut.cpp b/linden/indra/test/llsd_new_tut.cpp index 7332d97..d73a0a3 100644 --- a/linden/indra/test/llsd_new_tut.cpp +++ b/linden/indra/test/llsd_new_tut.cpp @@ -18,7 +18,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -30,7 +31,7 @@ * $/LicenseInfo$ */ -#include +#include #include "linden_common.h" #include "lltut.h" diff --git a/linden/indra/test/llsdmessagebuilder_tut.cpp b/linden/indra/test/llsdmessagebuilder_tut.cpp index 81a5b96..27ab127 100755 --- a/linden/indra/test/llsdmessagebuilder_tut.cpp +++ b/linden/indra/test/llsdmessagebuilder_tut.cpp @@ -18,7 +18,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -30,10 +31,11 @@ * $/LicenseInfo$ */ -#include +#include #include "linden_common.h" #include "lltut.h" +#include "llmessagetemplate.h" #include "llsdmessagebuilder.h" #include "llsdmessagereader.h" #include "llsdtraits.h" @@ -42,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; @@ -60,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 LLSDMessageBuilderTestGroup; @@ -279,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 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 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 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 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 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 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 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/linden/indra/test/llsdmessagereader_tut.cpp b/linden/indra/test/llsdmessagereader_tut.cpp index f94fef3..36cfe5e 100755 --- a/linden/indra/test/llsdmessagereader_tut.cpp +++ b/linden/indra/test/llsdmessagereader_tut.cpp @@ -18,7 +18,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -30,7 +31,7 @@ * $/LicenseInfo$ */ -#include +#include #include "linden_common.h" #include "lltut.h" #include "v3dmath.h" diff --git a/linden/indra/test/llsdserialize_tut.cpp b/linden/indra/test/llsdserialize_tut.cpp index 467470a..6fcbe4b 100644 --- a/linden/indra/test/llsdserialize_tut.cpp +++ b/linden/indra/test/llsdserialize_tut.cpp @@ -18,7 +18,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -30,7 +31,7 @@ * $/LicenseInfo$ */ -#include +#include #if !LL_WINDOWS #include @@ -242,7 +243,7 @@ namespace tut try { - ensure_equals(msg, w, v); + ensure_equals(msg.c_str(), w, v); } catch (...) { @@ -490,7 +491,7 @@ namespace tut LLSD parsed_result; mParser->reset(); // reset() call is needed since test code re-uses mParser S32 parsed_count = mParser->parse(input, parsed_result, in.size()); - ensure_equals(msg, parsed_result, expected_value); + ensure_equals(msg.c_str(), parsed_result, expected_value); // This count check is really only useful for expected // parse failures, since the ensures equal will already @@ -1283,7 +1284,7 @@ namespace tut count4, count3); ensure_equals( - msg + " (binaryandnotation)", + (msg + " (binaryandnotation)").c_str(), actual_value_notation, input); } @@ -1318,7 +1319,7 @@ namespace tut "ensureBinaryAndXML xml count2", count4, count3); - ensure_equals(msg + " (binaryandxml)", actual_value_xml, input); + ensure_equals((msg + " (binaryandxml)").c_str(), actual_value_xml, input); } }; diff --git a/linden/indra/test/llsdtraits.h b/linden/indra/test/llsdtraits.h index b652f6c..efe2dd5 100644 --- a/linden/indra/test/llsdtraits.h +++ b/linden/indra/test/llsdtraits.h @@ -17,7 +17,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, diff --git a/linden/indra/test/llsdutil_tut.cpp b/linden/indra/test/llsdutil_tut.cpp index 63e3d31..0c4bbc2 100644 --- a/linden/indra/test/llsdutil_tut.cpp +++ b/linden/indra/test/llsdutil_tut.cpp @@ -19,7 +19,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, diff --git a/linden/indra/test/llservicebuilder_tut.cpp b/linden/indra/test/llservicebuilder_tut.cpp index 4b5a76a..e6cf46f 100644 --- a/linden/indra/test/llservicebuilder_tut.cpp +++ b/linden/indra/test/llservicebuilder_tut.cpp @@ -18,7 +18,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception +* online at +* http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -30,7 +31,7 @@ * $/LicenseInfo$ */ -#include +#include #include "linden_common.h" #include "lltut.h" diff --git a/linden/indra/test/llstreamtools_tut.cpp b/linden/indra/test/llstreamtools_tut.cpp index b96c2c4..089ba4f 100644 --- a/linden/indra/test/llstreamtools_tut.cpp +++ b/linden/indra/test/llstreamtools_tut.cpp @@ -19,7 +19,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -31,7 +32,7 @@ * $/LicenseInfo$ */ -#include +#include #include "linden_common.h" #include "llstreamtools.h" diff --git a/linden/indra/test/llstring_tut.cpp b/linden/indra/test/llstring_tut.cpp index d17dd15..b622107 100644 --- a/linden/indra/test/llstring_tut.cpp +++ b/linden/indra/test/llstring_tut.cpp @@ -19,7 +19,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -33,7 +34,7 @@ #include "linden_common.h" -#include +#include #include "lltut.h" #include "llstring.h" @@ -417,8 +418,8 @@ namespace tut template<> template<> void string_index_object_t::test<26>() { - char* str1 = NULL; - char* str2 = NULL; + const char* str1 = NULL; + const char* str2 = NULL; ensure("1: compareStrings failed", LLStringUtil::compareStrings(str1, str2) == 0); str2 = "A"; @@ -436,8 +437,8 @@ namespace tut template<> template<> void string_index_object_t::test<27>() { - char* str1 = NULL; - char* str2 = NULL; + const char* str1 = NULL; + const char* str2 = NULL; ensure("1: compareInsensitive failed", LLStringUtil::compareInsensitive(str1, str2) == 0); str2 = "A"; diff --git a/linden/indra/test/lltemplatemessagebuilder_tut.cpp b/linden/indra/test/lltemplatemessagebuilder_tut.cpp index 6460013..5b33d02 100644 --- a/linden/indra/test/lltemplatemessagebuilder_tut.cpp +++ b/linden/indra/test/lltemplatemessagebuilder_tut.cpp @@ -18,7 +18,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -30,7 +31,7 @@ * $/LicenseInfo$ */ -#include +#include #include "linden_common.h" #include "lltut.h" @@ -59,6 +60,9 @@ namespace tut if(! init) { ll_init_apr(); + const F32 circuit_heartbeat_interval=5; + const F32 circuit_timeout=100; + start_messaging_system("notafile", 13035, LL_VERSION_MAJOR, LL_VERSION_MINOR, @@ -66,7 +70,9 @@ namespace tut FALSE, "notasharedsecret", NULL, - false); + false, + circuit_heartbeat_interval, + circuit_timeout); //init_prehash_data(); init = true; } diff --git a/linden/indra/test/lltimestampcache_tut.cpp b/linden/indra/test/lltimestampcache_tut.cpp new file mode 100644 index 0000000..3b102a3 --- /dev/null +++ b/linden/indra/test/lltimestampcache_tut.cpp @@ -0,0 +1,130 @@ +/** + * @file lltimestampcache_tut.cpp + * @author James Tess + * @date 2008-12-03 + * + * $LicenseInfo:firstyear=2008&license=viewergpl$ + * + * Copyright (c) 2008-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://secondlifegrid.net/programs/open_source/licensing/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://secondlifegrid.net/programs/open_source/licensing/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 + +#include "linden_common.h" +#include "../mapserver/lltimestampcache.h" +#include "lltut.h" + + +namespace tut +{ + struct LLTimestampCacheTestData + { + }; + + typedef test_group LLTimestampCacheTestGroup; + typedef LLTimestampCacheTestGroup::object LLTimestampCacheTestObject; + + LLTimestampCacheTestGroup timestampCacheTestGroup("LLTimestampCache"); + + // Most common usage + template<> template<> + void LLTimestampCacheTestObject::test<1>() + { + LLTimestampCache 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 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 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 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 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/linden/indra/test/lltiming_tut.cpp b/linden/indra/test/lltiming_tut.cpp index c6cf643..4ca6cb5 100644 --- a/linden/indra/test/lltiming_tut.cpp +++ b/linden/indra/test/lltiming_tut.cpp @@ -18,7 +18,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, diff --git a/linden/indra/test/lltranscode_tut.cpp b/linden/indra/test/lltranscode_tut.cpp new file mode 100644 index 0000000..eb21979 --- /dev/null +++ b/linden/indra/test/lltranscode_tut.cpp @@ -0,0 +1,95 @@ +/** + * @file llscriptresource_tut.cpp + * @brief Test LLScriptResource + * + * $LicenseInfo:firstyear=2008&license=viewergpl$ + * + * Copyright (c) 2008-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://secondlifegrid.net/programs/open_source/licensing/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://secondlifegrid.net/programs/open_source/licensing/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 +#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 LLTranscodeTestGroup; + typedef LLTranscodeTestGroup::object LLTranscodeTestObject; + LLTranscodeTestGroup transcodeTestGroup("transcode"); + + template<> template<> + void LLTranscodeTestObject::test<1>() + { +#if LL_WINDOWS + skip("Windows APR libs can't transcode."); +#endif + // 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/linden/indra/test/lltut.cpp b/linden/indra/test/lltut.cpp index bea6716..201e174 100644 --- a/linden/indra/test/lltut.cpp +++ b/linden/indra/test/lltut.cpp @@ -19,7 +19,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -32,14 +33,16 @@ */ #include "linden_common.h" + #include "lltut.h" +#include "lldate.h" #include "llformat.h" #include "llsd.h" +#include "lluri.h" namespace tut { - template<> void ensure_equals(const char* msg, const LLDate& actual, const LLDate& expected) { @@ -47,7 +50,6 @@ namespace tut actual.secondsSinceEpoch(), expected.secondsSinceEpoch()); } - template<> void ensure_equals(const char* msg, const LLURI& actual, const LLURI& expected) { @@ -55,7 +57,6 @@ namespace tut actual.asString(), expected.asString()); } - template<> void ensure_equals(const char* msg, const std::vector& actual, const std::vector& expected) { @@ -73,11 +74,10 @@ namespace tut } } - template<> 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()) @@ -128,7 +128,7 @@ namespace tut { ensure_equals(msg + " map keys", actual_iter->first, expected_iter->first); - ensure_equals(msg + "[" + actual_iter->first + "]", + ensure_equals((msg + "[" + actual_iter->first + "]").c_str(), actual_iter->second, expected_iter->second); ++actual_iter; ++expected_iter; @@ -141,7 +141,7 @@ namespace tut for(int i = 0; i < actual.size(); ++i) { - ensure_equals(msg + llformat("[%d]", i), + ensure_equals((msg + llformat("[%d]", i)).c_str(), actual[i], expected[i]); } return; @@ -199,3 +199,4 @@ namespace tut } } } + diff --git a/linden/indra/test/lltut.h b/linden/indra/test/lltut.h index 5c905b2..3a0cc04 100644 --- a/linden/indra/test/lltut.h +++ b/linden/indra/test/lltut.h @@ -19,7 +19,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -34,13 +35,13 @@ #ifndef LL_LLTUT_H #define LL_LLTUT_H -#include +#include "is_approx_equal_fraction.h" // instead of llmath.h -#include "lldate.h" -#include "lluri.h" -#include "llmath.h" +#include +class LLDate; class LLSD; +class LLURI; namespace tut { @@ -108,19 +109,15 @@ namespace tut const Q& actual,const T& expected) { ensure_equals(msg.c_str(), actual, expected); } - template<> void ensure_equals(const char* msg, const LLDate& actual, const LLDate& expected); - template<> void ensure_equals(const char* msg, const LLURI& actual, const LLURI& expected); - template<> void ensure_equals(const char* msg, const std::vector& actual, const std::vector& expected); - template<> void ensure_equals(const char* msg, const LLSD& actual, const LLSD& expected); diff --git a/linden/indra/test/lluri_tut.cpp b/linden/indra/test/lluri_tut.cpp index b4541da..2ee15be 100644 --- a/linden/indra/test/lluri_tut.cpp +++ b/linden/indra/test/lluri_tut.cpp @@ -18,7 +18,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, diff --git a/linden/indra/test/lluserrelations_tut.cpp b/linden/indra/test/lluserrelations_tut.cpp index d07d4b9..4e3cc41 100644 --- a/linden/indra/test/lluserrelations_tut.cpp +++ b/linden/indra/test/lluserrelations_tut.cpp @@ -19,7 +19,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -31,7 +32,7 @@ * $/LicenseInfo$ */ -#include +#include #include "linden_common.h" #include "lluserrelations.h" diff --git a/linden/indra/test/lluuidhashmap_tut.cpp b/linden/indra/test/lluuidhashmap_tut.cpp index 3eac5df..3c6c9cb 100644 --- a/linden/indra/test/lluuidhashmap_tut.cpp +++ b/linden/indra/test/lluuidhashmap_tut.cpp @@ -19,7 +19,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -31,7 +32,7 @@ * $/LicenseInfo$ */ -#include +#include #include "linden_common.h" #include "lluuidhashmap.h" #include "llsdserialize.h" diff --git a/linden/indra/test/llxfer_tut.cpp b/linden/indra/test/llxfer_tut.cpp index 527441d..3adc59c 100644 --- a/linden/indra/test/llxfer_tut.cpp +++ b/linden/indra/test/llxfer_tut.cpp @@ -18,7 +18,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, diff --git a/linden/indra/test/llxorcipher_tut.cpp b/linden/indra/test/llxorcipher_tut.cpp index e466aa2..7586edd 100644 --- a/linden/indra/test/llxorcipher_tut.cpp +++ b/linden/indra/test/llxorcipher_tut.cpp @@ -19,7 +19,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, diff --git a/linden/indra/test/m3math_tut.cpp b/linden/indra/test/m3math_tut.cpp index 9c25925..05007cc 100644 --- a/linden/indra/test/m3math_tut.cpp +++ b/linden/indra/test/m3math_tut.cpp @@ -19,7 +19,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -31,7 +32,7 @@ * $/LicenseInfo$ */ -#include +#include #include "lltut.h" #include "linden_common.h" #include "m3math.h" diff --git a/linden/indra/test/mass_properties_tut.cpp b/linden/indra/test/mass_properties_tut.cpp index f7f994b..4180065 100644 --- a/linden/indra/test/mass_properties_tut.cpp +++ b/linden/indra/test/mass_properties_tut.cpp @@ -4,16 +4,27 @@ * @date 2007-12-20 * @brief Tests for the LLPrimMassProperties and LLObjectMassProperties classes * - * $LicenseInfo:firstyear=2007&license=internal$ + * $LicenseInfo:firstyear=2007&license=viewergpl$ * * Copyright (c) 2007-2009, Linden Research, Inc. * - * The following source code is PROPRIETARY AND CONFIDENTIAL. Use of - * this source code is governed by the Linden Lab Source Code Disclosure - * Agreement ("Agreement") previously entered between you and Linden - * Lab. By accessing, using, copying, modifying or distributing this - * software, you acknowledge that you have been informed of your - * obligations under the Agreement and agree to abide by those obligations. + * 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://secondlifegrid.net/programs/open_source/licensing/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://secondlifegrid.net/programs/open_source/licensing/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, diff --git a/linden/indra/test/math.cpp b/linden/indra/test/math.cpp index 3b9c6ef..308569f 100644 --- a/linden/indra/test/math.cpp +++ b/linden/indra/test/math.cpp @@ -19,7 +19,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, diff --git a/linden/indra/test/message_tut.cpp b/linden/indra/test/message_tut.cpp index ca3729d..3fede26 100644 --- a/linden/indra/test/message_tut.cpp +++ b/linden/indra/test/message_tut.cpp @@ -18,7 +18,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -30,7 +31,7 @@ * $/LicenseInfo$ */ -#include +#include #include "linden_common.h" #include "lltut.h" @@ -50,6 +51,7 @@ namespace { mStatus = code; } + virtual void extendedResult(S32 code, const std::string& message, const LLSD& headers) { } S32 mStatus; }; } @@ -70,6 +72,9 @@ namespace tut //init_prehash_data(); init = true; } + const F32 circuit_heartbeat_interval=5; + const F32 circuit_timeout=100; + // currently test disconnected message system start_messaging_system("notafile", 13035, @@ -79,7 +84,10 @@ namespace tut FALSE, "notasharedsecret", NULL, - false); + false, + circuit_heartbeat_interval, + circuit_timeout + ); // generate temp dir std::ostringstream ostr; #if LL_WINDOWS diff --git a/linden/indra/test/mock_http_client.cpp b/linden/indra/test/mock_http_client.cpp index 4230630..7bcc781 100644 --- a/linden/indra/test/mock_http_client.cpp +++ b/linden/indra/test/mock_http_client.cpp @@ -17,7 +17,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, diff --git a/linden/indra/test/mock_http_client.h b/linden/indra/test/mock_http_client.h index cf8f9bf..067d933 100644 --- a/linden/indra/test/mock_http_client.h +++ b/linden/indra/test/mock_http_client.h @@ -17,7 +17,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, diff --git a/linden/indra/test/prim_linkability_tut.cpp b/linden/indra/test/prim_linkability_tut.cpp index 7198af1..a1bb31d 100644 --- a/linden/indra/test/prim_linkability_tut.cpp +++ b/linden/indra/test/prim_linkability_tut.cpp @@ -4,16 +4,27 @@ * @date 2007-04-23 * @brief Tests for the LLPrimLinkInfo template which computes the linkability of prims * - * $LicenseInfo:firstyear=2007&license=internal$ + * $LicenseInfo:firstyear=2007&license=viewergpl$ * * Copyright (c) 2007-2009, Linden Research, Inc. * - * The following source code is PROPRIETARY AND CONFIDENTIAL. Use of - * this source code is governed by the Linden Lab Source Code Disclosure - * Agreement ("Agreement") previously entered between you and Linden - * Lab. By accessing, using, copying, modifying or distributing this - * software, you acknowledge that you have been informed of your - * obligations under the Agreement and agree to abide by those obligations. + * 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://secondlifegrid.net/programs/open_source/licensing/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://secondlifegrid.net/programs/open_source/licensing/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, diff --git a/linden/indra/test/reflection_tut.cpp b/linden/indra/test/reflection_tut.cpp index e39c10e..d49be85 100644 --- a/linden/indra/test/reflection_tut.cpp +++ b/linden/indra/test/reflection_tut.cpp @@ -18,7 +18,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -30,7 +31,7 @@ * $/LicenseInfo$ */ -#include +#include #include "linden_common.h" #include "lltut.h" diff --git a/linden/indra/test/test.cpp b/linden/indra/test/test.cpp index 10a2088..ba81c6e 100644 --- a/linden/indra/test/test.cpp +++ b/linden/indra/test/test.cpp @@ -19,7 +19,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -53,9 +54,10 @@ # include "ctype_workaround.h" #endif - namespace tut { + std::string sSourceDir; + test_runner_singleton runner; } @@ -68,7 +70,6 @@ public: mPassedTests(0), mFailedTests(0), mSkippedTests(0), - mSkippedFailTests(0), mStream(stream) { } @@ -107,10 +108,6 @@ public: break; case tut::test_result::skip: ++mSkippedTests; - out << "skipped"; - break; - case tut::test_result::skip_fail: - ++mSkippedFailTests; out << "skipped known failure"; break; default: @@ -159,12 +156,7 @@ private: if (mSkippedTests > 0) { - stream << "Skipped Tests: " << mSkippedTests << std::endl; - } - - if (mSkippedFailTests > 0) - { - stream << "Skipped known failures: " << mSkippedFailTests + stream << "Skipped known failures: " << mSkippedTests << std::endl; } @@ -183,7 +175,6 @@ protected: int mPassedTests; int mFailedTests; int mSkippedTests; - int mSkippedFailTests; std::ostream *mStream; }; @@ -194,7 +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."}, - {"skip", 's', 1, "Skip test number specified by option argument. Only works when a specific group is being tested"}, + {"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."}, @@ -226,8 +217,6 @@ void stream_usage(std::ostream& s, const char* app) s << "\tList all available test groups." << std::endl; s << " " << app << " --group=uuid" << std::endl; s << "\tRun the test group 'uuid'." << std::endl; - s << " " << app << " --skip=2" << std::endl; - s << "\tSkip test case 2." << std::endl; } void stream_groups(std::ostream& s, const char* app) @@ -276,7 +265,6 @@ int main(int argc, char **argv) // values used for controlling application bool verbose_mode = false; bool wait_at_exit = false; - int skip_test_id = 0; std::string test_group; // values use for options parsing @@ -302,9 +290,6 @@ int main(int argc, char **argv) case 'g': test_group.assign(opt_arg); break; - case 's': - skip_test_id = atoi(opt_arg); - break; case 'h': stream_usage(std::cout, argv[0]); return 0; @@ -319,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; @@ -347,7 +337,7 @@ int main(int argc, char **argv) } else { - tut::runner.get().run_tests(test_group, skip_test_id); + tut::runner.get().run_tests(test_group); } if (wait_at_exit) diff --git a/linden/indra/test/test.h b/linden/indra/test/test.h new file mode 100644 index 0000000..cee1851 --- /dev/null +++ b/linden/indra/test/test.h @@ -0,0 +1,50 @@ +/** + * @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://secondlifegrid.net/programs/open_source/licensing/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://secondlifegrid.net/programs/open_source/licensing/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 + +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 diff --git a/linden/indra/test/test_llmanifest.py b/linden/indra/test/test_llmanifest.py index 6217e6a..e645c88 100644 --- a/linden/indra/test/test_llmanifest.py +++ b/linden/indra/test/test_llmanifest.py @@ -19,7 +19,8 @@ online at http://secondlifegrid.net/programs/open_source/licensing/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://secondlifegrid.net/programs/open_source/licensing/flossexception +online at +http://secondlifegrid.net/programs/open_source/licensing/flossexception By copying, modifying or distributing this software, you acknowledge that you have read and understood your obligations described above, diff --git a/linden/indra/test/v2math_tut.cpp b/linden/indra/test/v2math_tut.cpp index da4b082..08a091a 100644 --- a/linden/indra/test/v2math_tut.cpp +++ b/linden/indra/test/v2math_tut.cpp @@ -19,7 +19,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -31,7 +32,7 @@ * $/LicenseInfo$ */ -#include +#include #include "linden_common.h" #include "lltut.h" diff --git a/linden/indra/test/v3color_tut.cpp b/linden/indra/test/v3color_tut.cpp index 57ef9cc..26d3068 100644 --- a/linden/indra/test/v3color_tut.cpp +++ b/linden/indra/test/v3color_tut.cpp @@ -19,7 +19,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -31,7 +32,7 @@ * $/LicenseInfo$ */ -#include +#include #include "linden_common.h" #include "lltut.h" #include "v3color.h" @@ -59,7 +60,7 @@ namespace tut const F32 vec[3] = {2.0f, 3.2f,1.f}; LLColor3 llcolor3b(vec); ensure("3:LLColor3:Fail to initialize " ,(2.0f == llcolor3b.mV[0]) && (3.2f == llcolor3b.mV[1]) && (1.f == llcolor3b.mV[2])); - char* str = "561122"; + const char* str = "561122"; LLColor3 llcolor3c(str); v1 = (F32)86.0f/255.0f; // 0x56 = 86 v2 = (F32)17.0f/255.0f; // 0x11 = 17 diff --git a/linden/indra/test/v3dmath_tut.cpp b/linden/indra/test/v3dmath_tut.cpp index cf67498..598d72a 100644 --- a/linden/indra/test/v3dmath_tut.cpp +++ b/linden/indra/test/v3dmath_tut.cpp @@ -19,7 +19,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -31,7 +32,7 @@ * $/LicenseInfo$ */ -#include +#include #include "linden_common.h" #include "lltut.h" #include "llquaternion.h" @@ -510,7 +511,7 @@ namespace tut void v3dmath_object::test<24>() { #if LL_WINDOWS && _MSC_VER < 1400 - skip_fail("This fails on VS2003!"); + skip("This fails on VS2003!"); #else F64 x = 10., y = 20., z = -15.; F64 angle1, angle2; diff --git a/linden/indra/test/v3math_tut.cpp b/linden/indra/test/v3math_tut.cpp index 64e07a7..7cbcb23 100644 --- a/linden/indra/test/v3math_tut.cpp +++ b/linden/indra/test/v3math_tut.cpp @@ -19,7 +19,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -31,7 +32,7 @@ * $/LicenseInfo$ */ -#include +#include #include "linden_common.h" #include "lltut.h" #include "llquaternion.h" diff --git a/linden/indra/test/v4color_tut.cpp b/linden/indra/test/v4color_tut.cpp index d08bb57..b9142e7 100644 --- a/linden/indra/test/v4color_tut.cpp +++ b/linden/indra/test/v4color_tut.cpp @@ -19,7 +19,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -32,7 +33,7 @@ */ -#include +#include #include "linden_common.h" #include "lltut.h" #include "v4coloru.h" diff --git a/linden/indra/test/v4coloru_tut.cpp b/linden/indra/test/v4coloru_tut.cpp index ddf1463..1630b4e 100644 --- a/linden/indra/test/v4coloru_tut.cpp +++ b/linden/indra/test/v4coloru_tut.cpp @@ -19,7 +19,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -32,7 +33,7 @@ */ -#include +#include #include "linden_common.h" #include "lltut.h" #include "llsd.h" diff --git a/linden/indra/test/v4math_tut.cpp b/linden/indra/test/v4math_tut.cpp index 946524a..cc37be3 100644 --- a/linden/indra/test/v4math_tut.cpp +++ b/linden/indra/test/v4math_tut.cpp @@ -19,7 +19,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -31,7 +32,7 @@ * $/LicenseInfo$ */ -#include +#include #include "linden_common.h" #include "lltut.h" #include "llquaternion.h" diff --git a/linden/indra/test/xform_tut.cpp b/linden/indra/test/xform_tut.cpp index 8387696..55e70c1 100644 --- a/linden/indra/test/xform_tut.cpp +++ b/linden/indra/test/xform_tut.cpp @@ -19,7 +19,8 @@ * 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://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -31,7 +32,7 @@ * $/LicenseInfo$ */ -#include +#include #include "linden_common.h" #include "lltut.h" #include "xform.h" -- cgit v1.1