From 89fe5dab825a62a0e3fd8d248cbc91c65eb2a426 Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Fri, 15 Aug 2008 23:44:50 -0500 Subject: Second Life viewer sources 1.14.0.0 --- .../indra/test/MacTester.xcodeproj/project.pbxproj | 64 +- linden/indra/test/blowfish.1.bin | 1 + linden/indra/test/blowfish.2.bin | Bin 0 -> 40 bytes linden/indra/test/blowfish.digits.txt | 1 + linden/indra/test/blowfish.pl | 74 ++ linden/indra/test/common.cpp | 8 +- linden/indra/test/files.lst | 3 + linden/indra/test/io.cpp | 30 +- linden/indra/test/llapp_tut.cpp | 13 + linden/indra/test/llbase64_tut.cpp | 77 +++ linden/indra/test/llblowfish_tut.cpp | 144 ++++ linden/indra/test/llerror_tut.cpp | 767 +++++++++++++++++++++ linden/indra/test/llhttpclient_tut.cpp | 22 +- linden/indra/test/llpipeutil.cpp | 8 +- linden/indra/test/llrandom_tut.cpp | 160 +++-- linden/indra/test/llsd_message_system_tut.cpp | 248 +++---- linden/indra/test/llsd_new_tut.cpp | 2 + linden/indra/test/lltut.cpp | 29 + linden/indra/test/lltut.h | 6 + linden/indra/test/lluri_tut.cpp | 173 +++-- linden/indra/test/math.cpp | 2 +- linden/indra/test/test.cpp | 13 +- linden/indra/test/test.vcproj | 15 + linden/indra/test/test_llmanifest.py | 128 ++++ linden/indra/test/test_vc8.vcproj | 385 +++++++++++ 25 files changed, 2094 insertions(+), 279 deletions(-) create mode 100644 linden/indra/test/blowfish.1.bin create mode 100644 linden/indra/test/blowfish.2.bin create mode 100644 linden/indra/test/blowfish.digits.txt create mode 100755 linden/indra/test/blowfish.pl create mode 100644 linden/indra/test/llbase64_tut.cpp create mode 100644 linden/indra/test/llblowfish_tut.cpp create mode 100644 linden/indra/test/llerror_tut.cpp create mode 100644 linden/indra/test/test_llmanifest.py create mode 100644 linden/indra/test/test_vc8.vcproj (limited to 'linden/indra/test') diff --git a/linden/indra/test/MacTester.xcodeproj/project.pbxproj b/linden/indra/test/MacTester.xcodeproj/project.pbxproj index 77ba7c2..76bdc0a 100644 --- a/linden/indra/test/MacTester.xcodeproj/project.pbxproj +++ b/linden/indra/test/MacTester.xcodeproj/project.pbxproj @@ -45,8 +45,11 @@ DA306B580ACD9F3F008D9B2F /* lltiming_tut.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DA306B540ACD9F3F008D9B2F /* lltiming_tut.cpp */; }; DA306B590ACD9F3F008D9B2F /* lluri_tut.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DA306B550ACD9F3F008D9B2F /* lluri_tut.cpp */; }; DA306B5C0ACD9F6F008D9B2F /* llhttpclient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DA306B5B0ACD9F6F008D9B2F /* llhttpclient.cpp */; }; + DA4D18170B567E0D0049C10F /* llformat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DA4D18150B567E0D0049C10F /* llformat.cpp */; }; + DA4D18180B567E0D0049C10F /* llformat.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DA4D18160B567E0D0049C10F /* llformat.h */; }; + DA4D182D0B567ED70049C10F /* llerrorcontrol.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DA4D182B0B567ED70049C10F /* llerrorcontrol.h */; }; + DA9C40480B540D8A00DD6F44 /* lllivefile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DA9C40460B540D8A00DD6F44 /* lllivefile.cpp */; }; DAD1C4CC0AE2C78C0054574C /* stats.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DAD1C4CB0AE2C78C0054574C /* stats.cpp */; }; - DAD1C4DE0AE2CA0C0054574C /* llcurl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DAD1C4DD0AE2CA0C0054574C /* llcurl.cpp */; }; FD15584D0A06BE2E00DE9AE5 /* io.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD15584C0A06BE2E00DE9AE5 /* io.cpp */; }; FD15585C0A06BEB000DE9AE5 /* llbuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD1558500A06BEB000DE9AE5 /* llbuffer.cpp */; }; FD15585E0A06BEB000DE9AE5 /* llbufferstream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD1558520A06BEB000DE9AE5 /* llbufferstream.cpp */; }; @@ -84,6 +87,11 @@ FD155F5D0A08FB5100DE9AE5 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FD155F480A08FB5100DE9AE5 /* Carbon.framework */; }; FD155F610A08FD5900DE9AE5 /* llfasttimer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD155F5F0A08FD5900DE9AE5 /* llfasttimer.cpp */; }; FD155F670A08FD9100DE9AE5 /* message_string_table.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD155F660A08FD9100DE9AE5 /* message_string_table.cpp */; }; + FD23FEB90B4340F3007A29CA /* llhttpnode_tut.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD23FEB70B4340F3007A29CA /* llhttpnode_tut.cpp */; }; + FD23FEBA0B4340F3007A29CA /* lluserrelations_tut.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD23FEB80B4340F3007A29CA /* lluserrelations_tut.cpp */; }; + FD23FEBE0B43410C007A29CA /* lluserrelations.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD23FEBC0B43410C007A29CA /* lluserrelations.cpp */; }; + FD23FEBF0B43410C007A29CA /* lluserrelations.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = FD23FEBD0B43410C007A29CA /* lluserrelations.h */; }; + FD23FEC60B4341E2007A29CA /* llerror_tut.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD23FEC50B4341E2007A29CA /* llerror_tut.cpp */; }; FD396CDD0A1D37DF005DCB1F /* lltut.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD396CDC0A1D37DF005DCB1F /* lltut.cpp */; }; FD396D160A1DFB4B005DCB1F /* reflection_tut.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 386A940D0A0B5F60001DE10D /* reflection_tut.cpp */; }; FD506A0609FEB58900E297C2 /* llsdserialize.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD506A0409FEB58900E297C2 /* llsdserialize.cpp */; }; @@ -97,8 +105,6 @@ FD5DFA9109C1DF3E007E3F78 /* lldate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD5DFA9009C1DF3E007E3F78 /* lldate.cpp */; }; FD5DFA9309C1DF4E007E3F78 /* lluuid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD5DFA9209C1DF4E007E3F78 /* lluuid.cpp */; }; FD5DFA9909C1DFB7007E3F78 /* lluri.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD5DFA9709C1DFB7007E3F78 /* lluri.cpp */; }; - FD5DFAA009C1DFE2007E3F78 /* llerrorbuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD5DFA9C09C1DFE2007E3F78 /* llerrorbuffer.cpp */; }; - FD5DFAA209C1DFE2007E3F78 /* llerrorstream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD5DFA9E09C1DFE2007E3F78 /* llerrorstream.cpp */; }; FD5DFAA609C1E01D007E3F78 /* llmd5.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD5DFAA509C1E01D007E3F78 /* llmd5.cpp */; }; FD5DFAA909C1E056007E3F78 /* llerror.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD5DFAA809C1E056007E3F78 /* llerror.cpp */; }; FD5DFAAC09C1E09F007E3F78 /* llrand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD5DFAAB09C1E09F007E3F78 /* llrand.cpp */; }; @@ -144,8 +150,6 @@ FDBC10740AEEC40F00ED2E62 /* libexpat.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FD506ADA09FFE09700E297C2 /* libexpat.a */; }; FDBC10750AEEC41600ED2E62 /* lldate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD5DFA9009C1DF3E007E3F78 /* lldate.cpp */; }; FDBC10760AEEC41B00ED2E62 /* llmd5.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD5DFAA509C1E01D007E3F78 /* llmd5.cpp */; }; - FDBC10790AEEC42B00ED2E62 /* llerrorstream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD5DFA9E09C1DFE2007E3F78 /* llerrorstream.cpp */; }; - FDBC107A0AEEC42C00ED2E62 /* llerrorbuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD5DFA9C09C1DFE2007E3F78 /* llerrorbuffer.cpp */; }; FDBC107B0AEEC43200ED2E62 /* lluri.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD5DFA9709C1DFB7007E3F78 /* lluri.cpp */; }; FDBC107E0AEEC45100ED2E62 /* lltimer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD5DFAB209C1E11A007E3F78 /* lltimer.cpp */; }; FDBC107F0AEEC45400ED2E62 /* llfasttimer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD155F5F0A08FD5900DE9AE5 /* llfasttimer.cpp */; }; @@ -171,6 +175,7 @@ FDBC10AD0AEEC67700ED2E62 /* llframetimer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD1558910A06C01400DE9AE5 /* llframetimer.cpp */; }; FDCB2A670AF80D9000C44EBA /* llprocessor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FDCB2A650AF80D9000C44EBA /* llprocessor.cpp */; }; FDCB2A680AF80D9000C44EBA /* llprocessor.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = FDCB2A660AF80D9000C44EBA /* llprocessor.h */; }; + FDE7AD540B7D047700C56FE0 /* llcurl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FDE7AD520B7D047700C56FE0 /* llcurl.cpp */; }; FDEC4F5509F7EF7A007BAEEC /* llsd.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD5DF9BE09C0A68F007E3F78 /* llsd.cpp */; }; FDFAD4210AFFFCC30048A0C7 /* llhttpnode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FDFAD41F0AFFFCC30048A0C7 /* llhttpnode.cpp */; }; FDFAD4220AFFFCC30048A0C7 /* llhttpnode.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = FDFAD4200AFFFCC30048A0C7 /* llhttpnode.h */; }; @@ -216,6 +221,9 @@ FDFAD4220AFFFCC30048A0C7 /* llhttpnode.h in CopyFiles */, 91469E820B4486F20009E8F9 /* llmime.h in CopyFiles */, 91469E8E0B4489420009E8F9 /* llquaternion.h in CopyFiles */, + FD23FEBF0B43410C007A29CA /* lluserrelations.h in CopyFiles */, + DA4D18180B567E0D0049C10F /* llformat.h in CopyFiles */, + DA4D182D0B567ED70049C10F /* llerrorcontrol.h in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 1; }; @@ -252,10 +260,13 @@ DA306B540ACD9F3F008D9B2F /* lltiming_tut.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = lltiming_tut.cpp; sourceTree = ""; }; DA306B550ACD9F3F008D9B2F /* lluri_tut.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = lluri_tut.cpp; sourceTree = ""; }; DA306B5B0ACD9F6F008D9B2F /* llhttpclient.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = llhttpclient.cpp; sourceTree = ""; }; + DA4D18150B567E0D0049C10F /* llformat.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = llformat.cpp; sourceTree = ""; }; + DA4D18160B567E0D0049C10F /* llformat.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = llformat.h; sourceTree = ""; }; + DA4D182B0B567ED70049C10F /* llerrorcontrol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = llerrorcontrol.h; sourceTree = ""; }; + DA9C40460B540D8A00DD6F44 /* lllivefile.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = lllivefile.cpp; sourceTree = ""; }; + DA9C40470B540D8A00DD6F44 /* lllivefile.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = lllivefile.h; sourceTree = ""; }; DAD1C4CA0AE2C78C0054574C /* stats.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = stats.h; sourceTree = ""; }; DAD1C4CB0AE2C78C0054574C /* stats.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = stats.cpp; sourceTree = ""; }; - DAD1C4DC0AE2CA0C0054574C /* llcurl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = llcurl.h; sourceTree = ""; }; - DAD1C4DD0AE2CA0C0054574C /* llcurl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = llcurl.cpp; sourceTree = ""; }; FD15584C0A06BE2E00DE9AE5 /* io.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = io.cpp; sourceTree = ""; }; FD1558500A06BEB000DE9AE5 /* llbuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = llbuffer.cpp; sourceTree = ""; }; FD1558510A06BEB000DE9AE5 /* llbuffer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = llbuffer.h; sourceTree = ""; }; @@ -322,6 +333,11 @@ FD155F5F0A08FD5900DE9AE5 /* llfasttimer.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = llfasttimer.cpp; sourceTree = ""; }; FD155F600A08FD5900DE9AE5 /* llfasttimer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = llfasttimer.h; sourceTree = ""; }; FD155F660A08FD9100DE9AE5 /* message_string_table.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = message_string_table.cpp; sourceTree = ""; }; + FD23FEB70B4340F3007A29CA /* llhttpnode_tut.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = llhttpnode_tut.cpp; sourceTree = ""; }; + FD23FEB80B4340F3007A29CA /* lluserrelations_tut.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = lluserrelations_tut.cpp; sourceTree = ""; }; + FD23FEBC0B43410C007A29CA /* lluserrelations.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = lluserrelations.cpp; sourceTree = ""; }; + FD23FEBD0B43410C007A29CA /* lluserrelations.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = lluserrelations.h; sourceTree = ""; }; + FD23FEC50B4341E2007A29CA /* llerror_tut.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = llerror_tut.cpp; sourceTree = ""; }; FD396CD80A1D3768005DCB1F /* lltut.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = lltut.h; sourceTree = ""; }; FD396CDC0A1D37DF005DCB1F /* lltut.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lltut.cpp; sourceTree = ""; }; FD506A0409FEB58900E297C2 /* llsdserialize.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = llsdserialize.cpp; sourceTree = ""; }; @@ -340,8 +356,6 @@ FD5DFA9009C1DF3E007E3F78 /* lldate.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = lldate.cpp; sourceTree = ""; }; FD5DFA9209C1DF4E007E3F78 /* lluuid.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = lluuid.cpp; sourceTree = ""; }; FD5DFA9709C1DFB7007E3F78 /* lluri.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = lluri.cpp; sourceTree = ""; }; - FD5DFA9C09C1DFE2007E3F78 /* llerrorbuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = llerrorbuffer.cpp; sourceTree = ""; }; - FD5DFA9E09C1DFE2007E3F78 /* llerrorstream.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = llerrorstream.cpp; sourceTree = ""; }; FD5DFAA509C1E01D007E3F78 /* llmd5.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = llmd5.cpp; sourceTree = ""; }; FD5DFAA809C1E056007E3F78 /* llerror.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = llerror.cpp; sourceTree = ""; }; FD5DFAAB09C1E09F007E3F78 /* llrand.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = llrand.cpp; sourceTree = ""; }; @@ -352,7 +366,6 @@ FD7325790A0834080072A37B /* llapr.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = llapr.h; sourceTree = ""; }; FD73257A0A0834080072A37B /* lldate.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = lldate.h; sourceTree = ""; }; FD73257B0A0834080072A37B /* llerror.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = llerror.h; sourceTree = ""; }; - FD73257C0A0834080072A37B /* llerrorbuffer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = llerrorbuffer.h; sourceTree = ""; }; FD73257D0A0834080072A37B /* llstring.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = llstring.h; sourceTree = ""; }; FD73257E0A0834080072A37B /* lltimer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = lltimer.h; sourceTree = ""; }; FD73257F0A0834080072A37B /* lluri.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = lluri.h; sourceTree = ""; }; @@ -425,6 +438,8 @@ FDBC10660AEEC3A600ED2E62 /* llpriqueuemap.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = llpriqueuemap.h; sourceTree = ""; }; FDCB2A650AF80D9000C44EBA /* llprocessor.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = llprocessor.cpp; sourceTree = ""; }; FDCB2A660AF80D9000C44EBA /* llprocessor.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = llprocessor.h; sourceTree = ""; }; + FDE7AD520B7D047700C56FE0 /* llcurl.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = llcurl.cpp; sourceTree = ""; }; + FDE7AD530B7D047700C56FE0 /* llcurl.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = llcurl.h; sourceTree = ""; }; FDF2E4180ADD7B620003B83E /* TestWebServer */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = TestWebServer; sourceTree = BUILT_PRODUCTS_DIR; }; FDF2E5580ADDBB7F0003B83E /* llhttpdelayeddata.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = llhttpdelayeddata.cpp; sourceTree = ""; }; FDF2E5590ADDBB7F0003B83E /* llhttpdelayeddata.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = llhttpdelayeddata.h; sourceTree = ""; }; @@ -492,6 +507,9 @@ 08FB7795FE84155DC02AAC07 /* test */ = { isa = PBXGroup; children = ( + FD23FEC50B4341E2007A29CA /* llerror_tut.cpp */, + FD23FEB70B4340F3007A29CA /* llhttpnode_tut.cpp */, + FD23FEB80B4340F3007A29CA /* lluserrelations_tut.cpp */, DA01B1F10ADE831200A44198 /* testwebclient */, FDF2E5600ADDBB900003B83E /* testwebserver */, 91469E830B44870B0009E8F9 /* llmime_tut.cpp */, @@ -532,8 +550,6 @@ DA01B2040ADE839D00A44198 /* testwebclient.cpp */, DAD1C4CA0AE2C78C0054574C /* stats.h */, DAD1C4CB0AE2C78C0054574C /* stats.cpp */, - DAD1C4DC0AE2CA0C0054574C /* llcurl.h */, - DAD1C4DD0AE2CA0C0054574C /* llcurl.cpp */, ); path = testwebclient; sourceTree = ""; @@ -541,6 +557,8 @@ FD15584F0A06BE4100DE9AE5 /* llmessage */ = { isa = PBXGroup; children = ( + FDE7AD520B7D047700C56FE0 /* llcurl.cpp */, + FDE7AD530B7D047700C56FE0 /* llcurl.h */, 91469E7F0B4486F20009E8F9 /* llmime.cpp */, 91469E800B4486F20009E8F9 /* llmime.h */, FDFAD41F0AFFFCC30048A0C7 /* llhttpnode.cpp */, @@ -641,6 +659,10 @@ FD5DF88009C0A17D007E3F78 /* llcommon */ = { isa = PBXGroup; children = ( + DA4D18150B567E0D0049C10F /* llformat.cpp */, + DA4D18160B567E0D0049C10F /* llformat.h */, + DA9C40460B540D8A00DD6F44 /* lllivefile.cpp */, + DA9C40470B540D8A00DD6F44 /* lllivefile.h */, FDCB2A650AF80D9000C44EBA /* llprocessor.cpp */, FDCB2A660AF80D9000C44EBA /* llprocessor.h */, FDBC10660AEEC3A600ED2E62 /* llpriqueuemap.h */, @@ -663,9 +685,6 @@ FD73257A0A0834080072A37B /* lldate.h */, FD5DFAA809C1E056007E3F78 /* llerror.cpp */, FD73257B0A0834080072A37B /* llerror.h */, - FD5DFA9C09C1DFE2007E3F78 /* llerrorbuffer.cpp */, - FD73257C0A0834080072A37B /* llerrorbuffer.h */, - FD5DFA9E09C1DFE2007E3F78 /* llerrorstream.cpp */, FD155F5F0A08FD5900DE9AE5 /* llfasttimer.cpp */, FD155F600A08FD5900DE9AE5 /* llfasttimer.h */, 389CFB450A0B69C700EE2094 /* llfile.cpp */, @@ -702,6 +721,7 @@ 38A8BF690A18C38800814862 /* reflective.h */, FD5DFAB809C1E13A007E3F78 /* u64.cpp */, FD7325800A0834080072A37B /* u64.h */, + DA4D182B0B567ED70049C10F /* llerrorcontrol.h */, ); name = llcommon; path = ../llcommon; @@ -743,6 +763,8 @@ FD73259C0A08E8520072A37B /* llinventory */ = { isa = PBXGroup; children = ( + FD23FEBC0B43410C007A29CA /* lluserrelations.cpp */, + FD23FEBD0B43410C007A29CA /* lluserrelations.h */, FD73259D0A08E8A00072A37B /* llinventory.cpp */, FD73259E0A08E8A00072A37B /* llinventory.h */, FD7325AA0A08E9330072A37B /* llpermissions.cpp */, @@ -894,8 +916,6 @@ FD5DFA9109C1DF3E007E3F78 /* lldate.cpp in Sources */, FD5DFA9309C1DF4E007E3F78 /* lluuid.cpp in Sources */, FD5DFA9909C1DFB7007E3F78 /* lluri.cpp in Sources */, - FD5DFAA009C1DFE2007E3F78 /* llerrorbuffer.cpp in Sources */, - FD5DFAA209C1DFE2007E3F78 /* llerrorstream.cpp in Sources */, FD5DFAA609C1E01D007E3F78 /* llmd5.cpp in Sources */, FD5DFAA909C1E056007E3F78 /* llerror.cpp in Sources */, FD5DFAAC09C1E09F007E3F78 /* llrand.cpp in Sources */, @@ -993,6 +1013,12 @@ 91469E810B4486F20009E8F9 /* llmime.cpp in Sources */, 91469E840B44870B0009E8F9 /* llmime_tut.cpp in Sources */, 91469E8D0B4489420009E8F9 /* llquaternion.cpp in Sources */, + FD23FEB90B4340F3007A29CA /* llhttpnode_tut.cpp in Sources */, + FD23FEBA0B4340F3007A29CA /* lluserrelations_tut.cpp in Sources */, + FD23FEBE0B43410C007A29CA /* lluserrelations.cpp in Sources */, + FD23FEC60B4341E2007A29CA /* llerror_tut.cpp in Sources */, + DA9C40480B540D8A00DD6F44 /* lllivefile.cpp in Sources */, + DA4D18170B567E0D0049C10F /* llformat.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1001,15 +1027,12 @@ buildActionMask = 2147483647; files = ( DAD1C4CC0AE2C78C0054574C /* stats.cpp in Sources */, - DAD1C4DE0AE2CA0C0054574C /* llcurl.cpp in Sources */, FDBC106D0AEEC3DA00ED2E62 /* llsd.cpp in Sources */, FDBC106F0AEEC3E900ED2E62 /* lluuid.cpp in Sources */, FDBC10710AEEC3F800ED2E62 /* llsdserialize.cpp in Sources */, FDBC10720AEEC3F900ED2E62 /* llsdserialize_xml.cpp in Sources */, FDBC10750AEEC41600ED2E62 /* lldate.cpp in Sources */, FDBC10760AEEC41B00ED2E62 /* llmd5.cpp in Sources */, - FDBC10790AEEC42B00ED2E62 /* llerrorstream.cpp in Sources */, - FDBC107A0AEEC42C00ED2E62 /* llerrorbuffer.cpp in Sources */, FDBC107B0AEEC43200ED2E62 /* lluri.cpp in Sources */, FDBC107E0AEEC45100ED2E62 /* lltimer.cpp in Sources */, FDBC107F0AEEC45400ED2E62 /* llfasttimer.cpp in Sources */, @@ -1031,6 +1054,7 @@ FDBC10A90AEEC65700ED2E62 /* llstreamtools.cpp in Sources */, FDBC10AB0AEEC66100ED2E62 /* testwebclient.cpp in Sources */, FDBC10AD0AEEC67700ED2E62 /* llframetimer.cpp in Sources */, + FDE7AD540B7D047700C56FE0 /* llcurl.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/linden/indra/test/blowfish.1.bin b/linden/indra/test/blowfish.1.bin new file mode 100644 index 0000000..61286e4 --- /dev/null +++ b/linden/indra/test/blowfish.1.bin @@ -0,0 +1 @@ +.A„Ä3ŒLÜE ``òøÝKÛ@¼ûÇ;M[ÚBë·ø„>ËÊC—' \ No newline at end of file diff --git a/linden/indra/test/blowfish.2.bin b/linden/indra/test/blowfish.2.bin new file mode 100644 index 0000000..ef72d96 Binary files /dev/null and b/linden/indra/test/blowfish.2.bin differ diff --git a/linden/indra/test/blowfish.digits.txt b/linden/indra/test/blowfish.digits.txt new file mode 100644 index 0000000..fce1fed --- /dev/null +++ b/linden/indra/test/blowfish.digits.txt @@ -0,0 +1 @@ +01234567890123456789012345678901234 diff --git a/linden/indra/test/blowfish.pl b/linden/indra/test/blowfish.pl new file mode 100755 index 0000000..7940d87 --- /dev/null +++ b/linden/indra/test/blowfish.pl @@ -0,0 +1,74 @@ +#!/usr/bin/perl +use strict; +use warnings; + +# *TODO: specify test count here +use Test::More qw(no_plan); + +use Crypt::CBC; +use MIME::Base64; + +my $init_vector = "\x00" x 8; +# my $key = pack("H*", "ef5a8376eb0c99fe0dafa487d15bec19cae63d1e25fe31d8d92f7ab0398246d70ee733108e47360e16359654571cf5bab6c3375b42cee4fa"); +# my $key = "d263eb8a78034e40"; + #"8d082918aa369174"; +my $key = "\x00" x 16; + +my $cipher = Crypt::CBC->new( { cipher => 'Blowfish', + regenerate_key => 0, + key => $key, + iv => $init_vector, + header => 'none', + prepend_iv => 0, + keysize => 16 } ); + +#my $blocks = $cipher->blocksize(); +#print "blocksize $blocks\n"; + +my $len; +my $input = "01234567890123456789012345678901234\n"; +#my $input = "a whale of a tale I tell you lad, a whale of a tale for me, a whale of a tale and the fiddlers three"; +$len = length($input); +is ($len, 36, "input length"); + +$len = length($key); +is ($len, 16, "key length"); + + +my $encrypted = $cipher->encrypt($input); +is (length($encrypted), 40, "encrypted length"); + +open(FH, "blowfish.1.bin"); +my $bin = scalar ; +is ($encrypted, $bin, "matches openssl"); +close(FH); + +my $base64 = encode_base64($encrypted); +is ($base64, "LkGExDOMTNxFIGBg8gP43UvbQLz7xztNWwYF2kLrtwT4hD7LykOXJw==\n", + "base64 output"); + +my $unbase64 = decode_base64($base64); +is( $encrypted, $unbase64, "reverse base64" ); + +my $output = $cipher->decrypt($unbase64); +is ($input, $output, "reverse encrypt"); + +$key = pack("H[32]", "526a1e07a19dbaed84c4ff08a488d15e"); +$cipher = Crypt::CBC->new( { cipher => 'Blowfish', + regenerate_key => 0, + key => $key, + iv => $init_vector, + header => 'none', + prepend_iv => 0, + keysize => 16 } ); +$encrypted = $cipher->encrypt($input); +is (length($encrypted), 40, "uuid encrypted length"); +$output = $cipher->decrypt($encrypted); +is ($input, $output, "uuid reverse encrypt"); + +open(FH, "blowfish.2.bin"); +$bin = scalar ; +close(FH); +is( $encrypted, $bin, "uuid matches openssl" ); + +print encode_base64($encrypted); diff --git a/linden/indra/test/common.cpp b/linden/indra/test/common.cpp index 1be0931..97ff21c 100644 --- a/linden/indra/test/common.cpp +++ b/linden/indra/test/common.cpp @@ -109,7 +109,7 @@ namespace tut // gen up a starting point typedef std::vector buf_t; buf_t source; - srand(i); + srand(i); /* Flawfinder: ignore */ S32 size = rand() % 1000 + 10; std::generate_n( std::back_insert_iterator(source), @@ -157,7 +157,7 @@ namespace tut // gen up a starting point typedef std::vector buf_t; buf_t source; - srand(666 + i); + srand(666 + i); /* Flawfinder: ignore */ S32 size = rand() % 1000 + 10; std::generate_n( std::back_insert_iterator(source), @@ -307,7 +307,7 @@ namespace tut { // gen up a starting point std::string expected; - srand(1337 + i); + srand(1337 + i); /* Flawfinder: ignore */ S32 size = rand() % 30 + 5; std::generate_n( std::back_insert_iterator(expected), @@ -436,7 +436,7 @@ namespace tut void mem_object::test<1>() { const char HELLO_WORLD[] = "hello world"; - LLMemoryStream mem((U8*)&HELLO_WORLD[0], strlen(HELLO_WORLD)); + LLMemoryStream mem((U8*)&HELLO_WORLD[0], strlen(HELLO_WORLD)); /* Flawfinder: ignore */ std::string hello; std::string world; mem >> hello >> world; diff --git a/linden/indra/test/files.lst b/linden/indra/test/files.lst index 0f99ce9..77ce9f4 100644 --- a/linden/indra/test/files.lst +++ b/linden/indra/test/files.lst @@ -2,6 +2,9 @@ test/common.cpp test/inventory.cpp test/io.cpp test/llapp_tut.cpp +test/llbase64_tut.cpp +test/llblowfish_tut.cpp +test/llerror_tut.cpp test/llhttpclient_tut.cpp test/llhttpnode_tut.cpp test/lliohttpserver_tut.cpp diff --git a/linden/indra/test/io.cpp b/linden/indra/test/io.cpp index 2f6ba09..a86711a 100644 --- a/linden/indra/test/io.cpp +++ b/linden/indra/test/io.cpp @@ -77,7 +77,7 @@ namespace tut void buffer_object::test<2>() { const char HELLO_WORLD[] = "hello world"; - const S32 str_len = strlen(HELLO_WORLD); + const S32 str_len = strlen(HELLO_WORLD); /* Flawfinder: ignore */ LLChannelDescriptors ch = mBuffer.nextChannel(); mBuffer.append(ch.in(), (U8*)HELLO_WORLD, str_len); mBuffer.append(ch.in(), (U8*)HELLO_WORLD, str_len); @@ -99,7 +99,7 @@ namespace tut LLChannelDescriptors ch = mBuffer.nextChannel(); mBuffer.append(ch.in(), (U8*)ONE, 3); mBuffer.append(ch.in(), (U8*)TWO, 3); - char buffer[255]; + char buffer[255]; /* Flawfinder: ignore */ S32 len = 6; mBuffer.readAfter(ch.in(), NULL, (U8*)buffer, len); ensure_equals(len, 6); @@ -118,7 +118,7 @@ namespace tut LLChannelDescriptors ch = mBuffer.nextChannel(); mBuffer.append(ch.in(), (U8*)TWO, 3); mBuffer.prepend(ch.in(), (U8*)ONE, 3); - char buffer[255]; + char buffer[255]; /* Flawfinder: ignore */ S32 len = 6; mBuffer.readAfter(ch.in(), NULL, (U8*)buffer, len); ensure_equals(len, 6); @@ -136,7 +136,7 @@ namespace tut LLChannelDescriptors ch = mBuffer.nextChannel(); mBuffer.append(ch.in(), (U8*)TWO, 3); mBuffer.prepend(ch.in(), (U8*)ONE, 3); - char buffer[255]; + char buffer[255]; /* Flawfinder: ignore */ S32 len = 5; LLBufferArray::segment_iterator_t it = mBuffer.beginSegment(); U8* addr = (*it).data(); @@ -163,7 +163,7 @@ namespace tut header << "ContentLength: " << count << "\r\n\r\n"; std::string head(header.str()); mBuffer.prepend(ch.out(), (U8*)head.c_str(), head.length()); - char buffer[1024]; + char buffer[1024]; /* Flawfinder: ignore */ S32 len = response.size() + head.length(); ensure_equals("same length", len, (S32)expected.str().length()); mBuffer.readAfter(ch.out(), NULL, (U8*)buffer, len); @@ -228,11 +228,11 @@ namespace tut delete[] temp; } -/* +#if 0 template<> template<> void buffer_object::test<9>() { - char buffer[1024]; + char buffer[1024]; /* Flawfinder: ignore */ S32 size = sprintf(buffer, "%d|%d|%s|%s|%s|%s|%s|%x|%x|%x|%x|%x|%s|%s|%d|%d|%x", 7, @@ -263,7 +263,7 @@ namespace tut ensure_equals("Buffer sizes",size,(S32)post_size); ensure("Buffer content",!strcmp(buffer,post_buffer)); } -*/ +#endif /* template<> template<> @@ -287,7 +287,7 @@ namespace tut void bas_object::test<1>() { const char HELLO_WORLD[] = "hello world"; - const S32 str_len = strlen(HELLO_WORLD); + const S32 str_len = strlen(HELLO_WORLD); /* Flawfinder: ignore */ LLChannelDescriptors ch = mBuffer.nextChannel(); LLBufferStream str(ch, &mBuffer); mBuffer.append(ch.in(), (U8*)HELLO_WORLD, str_len); @@ -425,7 +425,7 @@ namespace tut ostr << ") "; bstr.flush(); const S32 BUF_LEN = 512; - char buf[BUF_LEN]; + char buf[BUF_LEN]; /* Flawfinder: ignore */ S32 actual_len = BUF_LEN; (void) mBuffer.readAfter(ch.out(), NULL, (U8*)buf, actual_len); buf[actual_len] = '\0'; @@ -479,7 +479,7 @@ namespace tut ++total_size; } need_comma = true; - srand(69 + i); + srand(69 + i); /* Flawfinder: ignore */ S32 size = rand() % 1000 + 1000; std::generate_n( std::back_insert_iterator(source), @@ -545,7 +545,7 @@ namespace tut need_comma = true; ostr << "'" << i << "':"; total_size += 7; - srand(69 + i); + srand(69 + i); /* Flawfinder: ignore */ S32 size = rand() % 1000 + 1000; std::generate_n( std::back_insert_iterator(source), @@ -601,7 +601,7 @@ namespace tut "'circuit_code': i124,'group_id': '8615c885-9cf0-bf0a-6e40-0c11462aa652','limited_to_estate': i1,'look_at': [ i0, i0, i0]," "'agent_id': '0e346d8b-4433-4d66-a6b0-fd37083abc4c','first_name': 'Kelly','start': 'url'}]}"; LLChannelDescriptors ch = mBuffer.nextChannel(); - mBuffer.append(ch.out(), (U8*)LOGIN_STREAM, strlen(LOGIN_STREAM)); + mBuffer.append(ch.out(), (U8*)LOGIN_STREAM, strlen(LOGIN_STREAM)); /* Flawfinder: ignore */ ch = mBuffer.nextChannel(); LLBufferStream istr(ch, &mBuffer); LLSD data; @@ -1119,7 +1119,7 @@ namespace tut stream << "{'task_id':ucc706f2d-0b68-68f8-11a4-f1043ff35ca0}\n{\n\tname\tObject|\n\tpermissions 0\n}"; std::vector expected_binary; expected_binary.resize(stream.str().size()); - memcpy(&expected_binary[0], stream.str().c_str(), stream.str().size()); + memcpy(&expected_binary[0], stream.str().c_str(), stream.str().size()); /* Flawfinder: ignore */ stream.str(""); stream << "[{'uri':'" << uri << "'}, {'version':i1}, " << "{'agent_id':'3c115e51-04f4-523c-9fa6-98aff1034730', 'session_id':'2c585cec-038c-40b0-b42e-a25ebab4d132', 'circuit_code':i1075, 'start':'region', 'limited_to_estate':i1 'first_name':'Phoenix', 'last_name':'Linden', 'group_title':'', 'group_id':u00000000-0000-0000-0000-000000000000, 'position':[r70.9247,r254.378,r38.7304], 'look_at':[r-0.043753,r-0.999042,r0], 'granters':[ua2e76fcd-9360-4f6d-a924-000000000003], 'texture_data':['5e481e8a-58a6-fc34-6e61-c7a36095c07f', 'c39675f5-ca90-a304-bb31-42cdb803a132', '5c989edf-88d1-b2ac-b00b-5ed4bab8e368', '6522e74d-1660-4e7f-b601-6f48c1659a77', '7ca39b4c-bd19-4699-aff7-f93fd03d3e7b', '41c58177-5eb6-5aeb-029d-bc4093f3c130', '97b75473-8b93-9b25-2a11-035b9ae93195', '1c2d8d9b-90eb-89d4-dea8-c1ed83990614', '69ec543f-e27b-c07c-9094-a8be6300f274', 'c9f8b80f-c629-4633-04ee-c566ce9fea4b', '989cddba-7ab6-01ed-67aa-74accd2a2a65', '45e319b2-6a8c-fa5c-895b-1a7149b88aef', '5748decc-f629-461c-9a36-a35a221fe21f', 'c228d1cf-4b5d-4ba8-84f4-899a0796aa97', 'c228d1cf-4b5d-4ba8-84f4-899a0796aa97', '685fbe10-ab40-f065-0aec-726cc6dfd7a1', '406f98fd-9c89-1d52-5f39-e67d508c5ee5', '685fbe10-ab40-f065-0aec-726cc6dfd7a1', 'c228d1cf-4b5d-4ba8-84f4-899a0796aa97', 'c228d1cf-4b5d-4ba8-84f4-899a0796aa97'], " @@ -1213,7 +1213,7 @@ namespace tut tmp_str << "{'task_id':ucc706f2d-0b68-68f8-11a4-f1043ff35ca0}\n{\n\tname\tObject|\n\tpermissions 0\n}"; std::vector expected_binary; expected_binary.resize(tmp_str.str().size()); - memcpy( + memcpy( /* Flawfinder: ignore */ &expected_binary[0], tmp_str.str().c_str(), tmp_str.str().size()); diff --git a/linden/indra/test/llapp_tut.cpp b/linden/indra/test/llapp_tut.cpp index a238cb3..3223f91 100644 --- a/linden/indra/test/llapp_tut.cpp +++ b/linden/indra/test/llapp_tut.cpp @@ -150,4 +150,17 @@ namespace tut bool ok = mApp->parseCommandOptions(ARGC, ARGV); ensure("command line parse failure", !ok); } + + + template<> template<> + void application_object_t::test<5>() + { + LLSD options; + options["boolean-test"] = true; + mApp->setOptionData(LLApp::PRIORITY_GENERAL_CONFIGURATION, options); + ensure("bool set", mApp->getOption("boolean-test").asBoolean()); + options["boolean-test"] = false; + mApp->setOptionData(LLApp::PRIORITY_RUNTIME_OVERRIDE, options); + ensure("bool unset", !mApp->getOption("boolean-test").asBoolean()); + } } diff --git a/linden/indra/test/llbase64_tut.cpp b/linden/indra/test/llbase64_tut.cpp new file mode 100644 index 0000000..fe02397 --- /dev/null +++ b/linden/indra/test/llbase64_tut.cpp @@ -0,0 +1,77 @@ +/** + * @file llbase64_tut.cpp + * @author James Cook + * @date 2007-02-04 + * + * Copyright (c) 2007-2007, Linden Research, Inc. + * + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlife.com/developers/opensource/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at http://secondlife.com/developers/opensource/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + */ + +#include "linden_common.h" +#include "lltut.h" + +#include "llbase64.h" + +#include +#include "lluuid.h" + +namespace tut +{ + struct base64_data + { + }; + typedef test_group base64_test; + typedef base64_test::object base64_object; + tut::base64_test base64("base64"); + + template<> template<> + void base64_object::test<1>() + { + std::string result; + + result = LLBase64::encode(NULL, 0); + ensure("encode nothing", (result == "") ); + + LLUUID nothing; + result = LLBase64::encode(¬hing.mData[0], UUID_BYTES); + ensure("encode blank uuid", + (result == "AAAAAAAAAAAAAAAAAAAAAA==") ); + + LLUUID id("526a1e07-a19d-baed-84c4-ff08a488d15e"); + result = LLBase64::encode(&id.mData[0], UUID_BYTES); + ensure("encode random uuid", + (result == "UmoeB6Gduu2ExP8IpIjRXg==") ); + + } + + template<> template<> + void base64_object::test<2>() + { + std::string result; + + U8 blob[40] = { 115, 223, 172, 255, 140, 70, 49, 125, 236, 155, 45, 199, 101, 17, 164, 131, 230, 19, 80, 64, 112, 53, 135, 98, 237, 12, 26, 72, 126, 14, 145, 143, 118, 196, 11, 177, 132, 169, 195, 134 }; + result = LLBase64::encode(&blob[0], 40); + ensure("encode 40 bytes", + (result == "c9+s/4xGMX3smy3HZRGkg+YTUEBwNYdi7QwaSH4OkY92xAuxhKnDhg==") ); + } + +} diff --git a/linden/indra/test/llblowfish_tut.cpp b/linden/indra/test/llblowfish_tut.cpp new file mode 100644 index 0000000..0d85ade --- /dev/null +++ b/linden/indra/test/llblowfish_tut.cpp @@ -0,0 +1,144 @@ +/** + * @file llblowfish_tut.cpp + * @author James Cook, james@lindenlab.com + * @date 2007-02-04 + * + * Data files generated with: + * openssl enc -bf-cbc -in blowfish.digits.txt -out blowfish.1.bin -K 00000000000000000000000000000000 -iv 0000000000000000 -p + * openssl enc -bf-cbc -in blowfish.digits.txt -out blowfish.2.bin -K 526a1e07a19dbaed84c4ff08a488d15e -iv 0000000000000000 -p + * + * Copyright (c) 2007-2007, Linden Research, Inc. + * + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlife.com/developers/opensource/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at http://secondlife.com/developers/opensource/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + */ + +#include "linden_common.h" +#include "lltut.h" + +#include "llblowfishcipher.h" + +#include +#include +#include "lluuid.h" + +namespace tut +{ + class LLData + { + public: + unsigned char* mInput; + int mInputSize; + + LLData() + { + // \n to make it easier to create text files + // for testing with command line openssl + mInput = (unsigned char*)"01234567890123456789012345678901234\n"; + mInputSize = 36; + } + + bool matchFile(const char* filename, + const std::string& data) + { + FILE* fp = fopen(filename, "rb"); + if (!fp) + { + // sometimes test is run inside the indra directory + std::string path = "test/"; + path += filename; + fp = fopen(path.c_str(), "rb"); + } + if (!fp) + { + llwarns << "unabled to open " << filename << llendl; + return false; + } + + std::string good; + good.resize(256); + size_t got = fread(&good[0], 1, 256, fp); + lldebugs << "matchFile read " << got << llendl; + fclose(fp); + good.resize(got); + + return (good == data); + } + }; + typedef test_group blowfish_test; + typedef blowfish_test::object blowfish_object; + // Create test with name that can be selected on + // command line of test app. + tut::blowfish_test blowfish("blowfish"); + + template<> template<> + void blowfish_object::test<1>() + { + LLUUID blank; + LLBlowfishCipher cipher(&blank.mData[0], UUID_BYTES); + + U32 dst_len = cipher.requiredEncryptionSpace(36); + ensure("encryption space 36", + (dst_len == 40) ); + + // Blowfish adds an additional 8-byte block if your + // input is an exact multiple of 8 + dst_len = cipher.requiredEncryptionSpace(8); + ensure("encryption space 8", + (dst_len == 16) ); + } + + template<> template<> + void blowfish_object::test<2>() + { + LLUUID blank; + LLBlowfishCipher cipher(&blank.mData[0], UUID_BYTES); + + std::string result; + result.resize(256); + U32 count = cipher.encrypt(mInput, mInputSize, + (U8*) &result[0], 256); + + ensure("encrypt output count", + (count == 40) ); + result.resize(count); + + ensure("encrypt null key", matchFile("blowfish.1.bin", result)); + } + + template<> template<> + void blowfish_object::test<3>() + { + // same as base64 test id + LLUUID id("526a1e07-a19d-baed-84c4-ff08a488d15e"); + LLBlowfishCipher cipher(&id.mData[0], UUID_BYTES); + + std::string result; + result.resize(256); + U32 count = cipher.encrypt(mInput, mInputSize, + (U8*) &result[0], 256); + + ensure("encrypt output count", + (count == 40) ); + result.resize(count); + + ensure("encrypt real key", matchFile("blowfish.2.bin", result)); + } +} diff --git a/linden/indra/test/llerror_tut.cpp b/linden/indra/test/llerror_tut.cpp new file mode 100644 index 0000000..a4b4258 --- /dev/null +++ b/linden/indra/test/llerror_tut.cpp @@ -0,0 +1,767 @@ +/** + * @file llerror_tut.cpp + * @date December 2006 + * @brief error unit tests + * + * Copyright (c) 2006-2007, Linden Research, Inc. + * + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlife.com/developers/opensource/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at http://secondlife.com/developers/opensource/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + */ + +#include "llerror.h" +namespace +{ + void test_that_error_h_includes_enough_things_to_compile_a_message() + { + llinfos << "!" << llendl; + } +} + +#include +#include "lltut.h" + +#include + +#include "llerrorcontrol.h" +#include "llsd.h" + +namespace +{ + static bool fatalWasCalled; + void fatalCall(const std::string&) { fatalWasCalled = true; } + + class TestRecorder : public LLError::Recorder + { + public: + TestRecorder() : mWantsTime(false) { } + ~TestRecorder() { LLError::removeRecorder(this); } + + void recordMessage(LLError::ELevel level, + const std::string& message) + { + mMessages.push_back(message); + } + + int countMessages() { return (int) mMessages.size(); } + void clearMessages() { mMessages.clear(); } + + void setWantsTime(bool t) { mWantsTime = t; } + bool wantsTime() { return mWantsTime; } + + std::string message(int n) + { + std::ostringstream test_name; + test_name << "testing message " << n << ", not enough messages"; + + tut::ensure(test_name.str(), n < countMessages()); + return mMessages[n]; + } + + private: + typedef std::vector MessageVector; + MessageVector mMessages; + + bool mWantsTime; + }; +} + +namespace tut +{ + struct ErrorTestData + { + TestRecorder mRecorder; + LLError::Settings* mPriorErrorSettings; + + ErrorTestData() + { + fatalWasCalled = false; + + mPriorErrorSettings = LLError::saveAndResetSettings(); + LLError::setDefaultLevel(LLError::LEVEL_DEBUG); + LLError::setFatalFunction(fatalCall); + LLError::addRecorder(&mRecorder); + } + + ~ErrorTestData() + { + LLError::removeRecorder(&mRecorder); + LLError::restoreSettings(mPriorErrorSettings); + } + + void ensure_message_count(int expectedCount) + { + ensure_equals("message count", mRecorder.countMessages(), expectedCount); + } + + void ensure_message_contains(int n, const std::string& expectedText) + { + std::ostringstream test_name; + test_name << "testing message " << n; + + ensure_contains(test_name.str(), mRecorder.message(n), expectedText); + } + + void ensure_message_does_not_contain(int n, const std::string& expectedText) + { + std::ostringstream test_name; + test_name << "testing message " << n; + + ensure_does_not_contain(test_name.str(), mRecorder.message(n), expectedText); + } + }; + + typedef test_group ErrorTestGroup; + typedef ErrorTestGroup::object ErrorTestObject; + + ErrorTestGroup errorTestGroup("error"); + + template<> template<> + void ErrorTestObject::test<1>() + // basic test of output + { + llinfos << "test" << llendl; + llinfos << "bob" << llendl; + + ensure_message_contains(0, "test"); + ensure_message_contains(1, "bob"); + } +} + +namespace +{ + void writeSome() + { + lldebugs << "one" << llendl; + llinfos << "two" << llendl; + llwarns << "three" << llendl; + llerrs << "four" << llendl; + // fatal messages write out and addtional "error" message + } +}; + +namespace tut +{ + template<> template<> + void ErrorTestObject::test<2>() + // messages are filtered based on default level + { + LLError::setDefaultLevel(LLError::LEVEL_DEBUG); + writeSome(); + ensure_message_contains(0, "one"); + ensure_message_contains(1, "two"); + ensure_message_contains(2, "three"); + ensure_message_contains(3, "error"); + ensure_message_contains(4, "four"); + ensure_message_count(5); + + LLError::setDefaultLevel(LLError::LEVEL_INFO); + writeSome(); + ensure_message_contains(5, "two"); + ensure_message_contains(6, "three"); + ensure_message_contains(7, "error"); + ensure_message_contains(8, "four"); + ensure_message_count(9); + + LLError::setDefaultLevel(LLError::LEVEL_WARN); + writeSome(); + ensure_message_contains(9, "three"); + ensure_message_contains(10, "error"); + ensure_message_contains(11, "four"); + ensure_message_count(12); + + LLError::setDefaultLevel(LLError::LEVEL_ERROR); + writeSome(); + ensure_message_contains(12, "error"); + ensure_message_contains(13, "four"); + ensure_message_count(14); + + LLError::setDefaultLevel(LLError::LEVEL_NONE); + writeSome(); + ensure_message_count(14); + } + + template<> template<> + void ErrorTestObject::test<3>() + // error type string in output + { + writeSome(); + ensure_message_contains(0, "DEBUG: "); + ensure_message_contains(1, "INFO: "); + ensure_message_contains(2, "WARNING: "); + ensure_message_does_not_contain(3, "ERROR"); + ensure_message_contains(4, "ERROR: "); + ensure_message_count(5); + } + + template<> template<> + void ErrorTestObject::test<4>() + // file abbreviation + { + std::string thisFile = __FILE__; + std::string abbreviateFile = LLError::abbreviateFile(thisFile); + + ensure_ends_with("file name abbreviation", + abbreviateFile, + "test/llerror_tut.cpp" + ); + ensure_does_not_contain("file name abbreviation", + abbreviateFile, "indra"); + + std::string someFile = +#if LL_WINDOWS + "C:/amy/bob/cam.cpp" +#else + "/amy/bob/cam.cpp" +#endif + ; + std::string someAbbreviation = LLError::abbreviateFile(someFile); + + ensure_equals("non-indra file abbreviation", + someAbbreviation, someFile); + } +} + +namespace +{ + std::string locationString(int line) + { + std::ostringstream location; + location << LLError::abbreviateFile(__FILE__) + << "(" << line << ") : "; + + return location.str(); + } + + std::string writeReturningLocation() + { + llinfos << "apple" << llendl; int this_line = __LINE__; + return locationString(this_line); + } + + std::string writeReturningLocationAndFunction() + { + llinfos << "apple" << llendl; int this_line = __LINE__; + return locationString(this_line) + __FUNCTION__; + } + + std::string errorReturningLocation() + { + llerrs << "die" << llendl; int this_line = __LINE__; + return locationString(this_line); + } +} + +namespace tut +{ + template<> template<> + void ErrorTestObject::test<5>() + // file and line information in log messages + { + std::string location = writeReturningLocation(); + // expecting default to not print location information + + LLError::setPrintLocation(true); + writeReturningLocation(); + + LLError::setPrintLocation(false); + writeReturningLocation(); + + ensure_message_does_not_contain(0, location); + ensure_message_contains(1, location); + ensure_message_does_not_contain(2, location); + } +} + +/* The following helper functions and class members all log a simple message + from some particular function scope. Each function takes a bool argument + that indicates if it should log its own name or not (in the manner that + existing log messages often do.) The functions all return their C++ + name so that test can be substantial mechanized. + */ + +std::string logFromGlobal(bool id) +{ + llinfos << (id ? "logFromGlobal: " : "") << "hi" << llendl; + return "logFromGlobal"; +} + +static std::string logFromStatic(bool id) +{ + llinfos << (id ? "logFromStatic: " : "") << "hi" << llendl; + return "logFromStatic"; +} + +namespace +{ + std::string logFromAnon(bool id) + { + llinfos << (id ? "logFromAnon: " : "") << "hi" << llendl; + return "logFromAnon"; + } +} + +namespace Foo { + std::string logFromNamespace(bool id) + { + llinfos << (id ? "Foo::logFromNamespace: " : "") << "hi" << llendl; + //return "Foo::logFromNamespace"; + // there is no standard way to get the namespace name, hence + // we won't be testing for it + return "logFromNamespace"; + } +} + +namespace +{ + class ClassWithNoLogType { + public: + std::string logFromMember(bool id) + { + llinfos << (id ? "ClassWithNoLogType::logFromMember: " : "") << "hi" << llendl; + return "ClassWithNoLogType::logFromMember"; + } + static std::string logFromStatic(bool id) + { + llinfos << (id ? "ClassWithNoLogType::logFromStatic: " : "") << "hi" << llendl; + return "ClassWithNoLogType::logFromStatic"; + } + }; + + class ClassWithLogType { + LOG_CLASS(ClassWithLogType); + public: + std::string logFromMember(bool id) + { + llinfos << (id ? "ClassWithLogType::logFromMember: " : "") << "hi" << llendl; + return "ClassWithLogType::logFromMember"; + } + static std::string logFromStatic(bool id) + { + llinfos << (id ? "ClassWithLogType::logFromStatic: " : "") << "hi" << llendl; + return "ClassWithLogType::logFromStatic"; + } + }; + + std::string logFromNamespace(bool id) { return Foo::logFromNamespace(id); } + std::string logFromClassWithNoLogTypeMember(bool id) { ClassWithNoLogType c; return c.logFromMember(id); } + std::string logFromClassWithNoLogTypeStatic(bool id) { return ClassWithNoLogType::logFromStatic(id); } + std::string logFromClassWithLogTypeMember(bool id) { ClassWithLogType c; return c.logFromMember(id); } + std::string logFromClassWithLogTypeStatic(bool id) { return ClassWithLogType::logFromStatic(id); } + + void ensure_has_once(const std::string& message, + const std::string& actual, const std::string& expected) + { + std::string::size_type n1 = actual.find(expected); + std::string::size_type n2 = std::string::npos; + if (n1 != std::string::npos) + { + n2 = std::string(actual, n1 + expected.size()).find(expected); + } + + if (n1 == std::string::npos || n2 != std::string::npos) + { + std::stringstream ss; + ss << message << ": " << "expected to find one copy of " << expected + << " in actual " << actual; + throw tut::failure(ss.str().c_str()); + } + } + + typedef std::string (*LogFromFunction)(bool); + void testLogNameOnce(TestRecorder& recorder, LogFromFunction f, + const std::string& class_name = "") + { + recorder.clearMessages(); + std::string name = f(false); + f(true); + + std::string messageWithoutName = recorder.message(0); + std::string messageWithName = recorder.message(1); + + ensure_has_once(name + " logged without name", + messageWithoutName, name); + ensure_has_once(name + " logged with name", + messageWithName, name); + + if (!class_name.empty()) + { + ensure_has_once(name + "logged without name", + messageWithoutName, class_name); + ensure_has_once(name + "logged with name", + messageWithName, class_name); + } + } +} + +namespace tut +{ + template<> template<> + // class/function information in output + void ErrorTestObject::test<6>() + { + testLogNameOnce(mRecorder, logFromGlobal); + testLogNameOnce(mRecorder, logFromStatic); + testLogNameOnce(mRecorder, logFromAnon); + testLogNameOnce(mRecorder, logFromNamespace); + //testLogNameOnce(mRecorder, logFromClassWithNoLogTypeMember, "ClassWithNoLogType"); + //testLogNameOnce(mRecorder, logFromClassWithNoLogTypeStatic, "ClassWithNoLogType"); + // XXX: figure out what the exepcted response is for these + testLogNameOnce(mRecorder, logFromClassWithLogTypeMember, "ClassWithLogType"); + testLogNameOnce(mRecorder, logFromClassWithLogTypeStatic, "ClassWithLogType"); + } +} + +namespace +{ + std::string innerLogger() + { + llinfos << "inside" << llendl; + return "moo"; + } + + std::string outerLogger() + { + llinfos << "outside(" << innerLogger() << ")" << llendl; + return "bar"; + } + + void uberLogger() + { + llinfos << "uber(" << outerLogger() << "," << innerLogger() << ")" << llendl; + } + + class LogWhileLogging + { + public: + void print(std::ostream& out) const + { + llinfos << "logging" << llendl; + out << "baz"; + } + }; + + std::ostream& operator<<(std::ostream& out, const LogWhileLogging& l) + { l.print(out); return out; } + + void metaLogger() + { + LogWhileLogging l; + llinfos << "meta(" << l << ")" << llendl; + } + +} + +namespace tut +{ + template<> template<> + // handle nested logging + void ErrorTestObject::test<7>() + { + outerLogger(); + ensure_message_contains(0, "inside"); + ensure_message_contains(1, "outside(moo)"); + ensure_message_count(2); + + uberLogger(); + ensure_message_contains(2, "inside"); + ensure_message_contains(3, "inside"); + ensure_message_contains(4, "outside(moo)"); + ensure_message_contains(5, "uber(bar,moo)"); + ensure_message_count(6); + + metaLogger(); + ensure_message_contains(6, "logging"); + ensure_message_contains(7, "meta(baz)"); + ensure_message_count(8); + } + + template<> template<> + // special handling of llerrs calls + void ErrorTestObject::test<8>() + { + LLError::setPrintLocation(false); + std::string location = errorReturningLocation(); + + ensure_message_contains(0, location + "error"); + ensure_message_contains(1, "die"); + ensure_message_count(2); + + ensure("fatal callback called", fatalWasCalled); + } +} + +namespace +{ + std::string roswell() + { + return "1947-07-08T03:04:05Z"; + } + + void ufoSighting() + { + llinfos << "ufo" << llendl; + } +} + +namespace tut +{ + template<> template<> + // time in output (for recorders that need it) + void ErrorTestObject::test<9>() + { + LLError::setTimeFunction(roswell); + + mRecorder.setWantsTime(false); + ufoSighting(); + ensure_message_contains(0, "ufo"); + ensure_message_does_not_contain(0, roswell()); + + mRecorder.setWantsTime(true); + ufoSighting(); + ensure_message_contains(1, "ufo"); + ensure_message_contains(1, roswell()); + } + + template<> template<> + // output order + void ErrorTestObject::test<10>() + { + LLError::setPrintLocation(true); + LLError::setTimeFunction(roswell); + mRecorder.setWantsTime(true); + std::string locationAndFunction = writeReturningLocationAndFunction(); + + ensure_equals("order is time type location function message", + mRecorder.message(0), + roswell() + " INFO: " + locationAndFunction + ": apple"); + } + + template<> template<> + // multiple recorders + void ErrorTestObject::test<11>() + { + TestRecorder altRecorder; + LLError::addRecorder(&altRecorder); + + llinfos << "boo" << llendl; + + ensure_message_contains(0, "boo"); + ensure_equals("alt recorder count", altRecorder.countMessages(), 1); + ensure_contains("alt recorder message 0", altRecorder.message(0), "boo"); + + LLError::setTimeFunction(roswell); + + TestRecorder anotherRecorder; + anotherRecorder.setWantsTime(true); + LLError::addRecorder(&anotherRecorder); + + llinfos << "baz" << llendl; + + std::string when = roswell(); + + ensure_message_does_not_contain(1, when); + ensure_equals("alt recorder count", altRecorder.countMessages(), 2); + ensure_does_not_contain("alt recorder message 1", altRecorder.message(1), when); + ensure_equals("another recorder count", anotherRecorder.countMessages(), 1); + ensure_contains("another recorder message 0", anotherRecorder.message(0), when); + } +} + +class TestAlpha +{ + LOG_CLASS(TestAlpha); +public: + static void doDebug() { lldebugs << "add dice" << llendl; } + static void doInfo() { llinfos << "any idea" << llendl; } + static void doWarn() { llwarns << "aim west" << llendl; } + static void doError() { llerrs << "ate eels" << llendl; } + static void doAll() { doDebug(); doInfo(); doWarn(); doError(); } +}; + +class TestBeta +{ + LOG_CLASS(TestBeta); +public: + static void doDebug() { lldebugs << "bed down" << llendl; } + static void doInfo() { llinfos << "buy iron" << llendl; } + static void doWarn() { llwarns << "bad word" << llendl; } + static void doError() { llerrs << "big easy" << llendl; } + static void doAll() { doDebug(); doInfo(); doWarn(); doError(); } +}; + +namespace tut +{ + template<> template<> + // filtering by class + void ErrorTestObject::test<12>() + { + LLError::setDefaultLevel(LLError::LEVEL_WARN); + LLError::setClassLevel("TestBeta", LLError::LEVEL_INFO); + + TestAlpha::doAll(); + TestBeta::doAll(); + + ensure_message_contains(0, "aim west"); + ensure_message_contains(1, "error"); + ensure_message_contains(2, "ate eels"); + ensure_message_contains(3, "buy iron"); + ensure_message_contains(4, "bad word"); + ensure_message_contains(5, "error"); + ensure_message_contains(6, "big easy"); + ensure_message_count(7); + } + + template<> template<> + // filtering by function, and that it will override class filtering + void ErrorTestObject::test<13>() + { + LLError::setDefaultLevel(LLError::LEVEL_DEBUG); + LLError::setClassLevel("TestBeta", LLError::LEVEL_WARN); + LLError::setFunctionLevel("TestBeta::doInfo", LLError::LEVEL_DEBUG); + LLError::setFunctionLevel("TestBeta::doError", LLError::LEVEL_NONE); + + TestBeta::doAll(); + ensure_message_contains(0, "buy iron"); + ensure_message_contains(1, "bad word"); + ensure_message_count(2); + } + + template<> template<> + // filtering by file + // and that it is overridden by both class and function filtering + void ErrorTestObject::test<14>() + { + LLError::setDefaultLevel(LLError::LEVEL_DEBUG); + LLError::setFileLevel(LLError::abbreviateFile(__FILE__), + LLError::LEVEL_WARN); + LLError::setClassLevel("TestAlpha", LLError::LEVEL_INFO); + LLError::setFunctionLevel("TestAlpha::doError", + LLError::LEVEL_NONE); + LLError::setFunctionLevel("TestBeta::doError", + LLError::LEVEL_NONE); + + TestAlpha::doAll(); + TestBeta::doAll(); + ensure_message_contains(0, "any idea"); + ensure_message_contains(1, "aim west"); + ensure_message_contains(2, "bad word"); + ensure_message_count(3); + } + + template<> template<> + // proper cached, efficient lookup of filtering + void ErrorTestObject::test<15>() + { + LLError::setDefaultLevel(LLError::LEVEL_NONE); + + TestAlpha::doInfo(); + ensure_message_count(0); + ensure_equals("first check", LLError::shouldLogCallCount(), 1); + TestAlpha::doInfo(); + ensure_message_count(0); + ensure_equals("second check", LLError::shouldLogCallCount(), 1); + + LLError::setClassLevel("TestAlpha", LLError::LEVEL_DEBUG); + TestAlpha::doInfo(); + ensure_message_count(1); + ensure_equals("third check", LLError::shouldLogCallCount(), 2); + TestAlpha::doInfo(); + ensure_message_count(2); + ensure_equals("fourth check", LLError::shouldLogCallCount(), 2); + + LLError::setClassLevel("TestAlpha", LLError::LEVEL_WARN); + TestAlpha::doInfo(); + ensure_message_count(2); + ensure_equals("fifth check", LLError::shouldLogCallCount(), 3); + TestAlpha::doInfo(); + ensure_message_count(2); + ensure_equals("sixth check", LLError::shouldLogCallCount(), 3); + } + + template<> template<> + // configuration from LLSD + void ErrorTestObject::test<16>() + { + std::string this_file = LLError::abbreviateFile(__FILE__); + LLSD config; + config["print-location"] = true; + config["default-level"] = "DEBUG"; + + LLSD set1; + set1["level"] = "WARN"; + set1["files"][0] = this_file; + + LLSD set2; + set2["level"] = "INFO"; + set2["classes"][0] = "TestAlpha"; + + LLSD set3; + set3["level"] = "NONE"; + set3["functions"][0] = "TestAlpha::doError"; + set3["functions"][1] = "TestBeta::doError"; + + config["settings"][0] = set1; + config["settings"][1] = set2; + config["settings"][2] = set3; + + LLError::configure(config); + + TestAlpha::doAll(); + TestBeta::doAll(); + ensure_message_contains(0, "any idea"); + ensure_message_contains(0, this_file); + ensure_message_contains(1, "aim west"); + ensure_message_contains(2, "bad word"); + ensure_message_count(3); + + // make sure reconfiguring works + LLSD config2; + config2["default-level"] = "WARN"; + + LLError::configure(config2); + + TestAlpha::doAll(); + TestBeta::doAll(); + ensure_message_contains(3, "aim west"); + ensure_message_does_not_contain(3, this_file); + ensure_message_contains(4, "error"); + ensure_message_contains(5, "ate eels"); + ensure_message_contains(6, "bad word"); + ensure_message_contains(7, "error"); + ensure_message_contains(8, "big easy"); + ensure_message_count(9); + } +} + +/* Tests left: + handling of classes without LOG_CLASS + + live update of filtering from file + + syslog recorder + file recorder + cerr/stderr recorder + fixed buffer recorder + windows recorder + + mutex use when logging (?) + strange careful about to crash handling (?) +*/ diff --git a/linden/indra/test/llhttpclient_tut.cpp b/linden/indra/test/llhttpclient_tut.cpp index c84d34b..ef53e71 100644 --- a/linden/indra/test/llhttpclient_tut.cpp +++ b/linden/indra/test/llhttpclient_tut.cpp @@ -32,9 +32,10 @@ */ #include +#include "linden_common.h" #include "lltut.h" - #include "llhttpclient.h" +#include "llformat.h" #include "llpipeutil.h" #include "llpumpio.h" @@ -312,4 +313,23 @@ namespace tut ensureStatusError(); ensure_equals("reason", mReason, "STATUS_ERROR"); } + + template<> template<> + void HTTPClientTestObject::test<7>() + { + // Can not use the little mini server. The blocking request 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. + LLSD expected; + + LLHTTPClient::get("http://secondlife.com/xmlhttp/homepage.php", newResult()); + runThePump(); + ensureStatusOK(); + expected = getResult(); + + LLSD result; + result = LLHTTPClient::blockingGet("http://secondlife.com/xmlhttp/homepage.php"); + LLSD body = result["body"]; + ensure_equals("echoed result matches", body.size(), expected.size()); + } } diff --git a/linden/indra/test/llpipeutil.cpp b/linden/indra/test/llpipeutil.cpp index 53c5991..2857f12 100644 --- a/linden/indra/test/llpipeutil.cpp +++ b/linden/indra/test/llpipeutil.cpp @@ -26,11 +26,15 @@ * COMPLETENESS OR PERFORMANCE. */ + +#include "linden_common.h" #include "llpipeutil.h" #include +#include #include "llbufferstream.h" +#include "lldefs.h" #include "llframetimer.h" #include "llpumpio.h" #include "llrand.h" @@ -77,8 +81,8 @@ LLIOPipe::EStatus LLPipeStringExtractor::process_impl( std::ostringstream ostr; while (istr.good()) { - char buf[1024]; - istr.read(buf, sizeof(buf)); + char buf[1024]; /* Flawfinder: ignore */ + istr.read(buf, sizeof(buf)); /* Flawfinder: ignore */ ostr.write(buf, istr.gcount()); } mString = ostr.str(); diff --git a/linden/indra/test/llrandom_tut.cpp b/linden/indra/test/llrandom_tut.cpp index 1bb795e..a842dfd 100755 --- a/linden/indra/test/llrandom_tut.cpp +++ b/linden/indra/test/llrandom_tut.cpp @@ -1,9 +1,9 @@ -/** - * @file llrandom_tut.cpp - * @author Phoenix - * @date 2007-01-25 - * - * Copyright (c) 2007-2007, Linden Research, Inc. +/** + * @file llrandom_tut.cpp + * @author Phoenix + * @date 2007-01-25 + * + * Copyright (c) 2007-2007, Linden Research, Inc. * * 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 @@ -23,47 +23,107 @@ * * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. - */ - -#include - -#include "linden_common.h" -#include "llrand.h" -#include "lltut.h" - - -namespace tut -{ - struct random - { - }; - - typedef test_group random_t; - typedef random_t::object random_object_t; - tut::random_t tut_random("random"); - - template<> template<> - void random_object_t::test<1>() - { - F32 number = 0.0f; - for(S32 ii = 0; ii < 100000; ++ii) - { - number = ll_frand(); - ensure("frand >= 0", (number >= 0.0f)); - ensure("frand < 1", (number < 1.0f)); - } - } - - template<> template<> - void random_object_t::test<2>() - { - F32 number = 0.0f; - for(S32 ii = 0; ii < 100000; ++ii) - { - number = ll_frand(2.0f) - 1.0f; - ensure("frand >= 0", (number >= -1.0f)); - ensure("frand < 1", (number <= 1.0f)); - } - } -} + * COMPLETENESS OR PERFORMANCE. + */ + +#include + +#include "linden_common.h" +#include "llrand.h" +#include "lltut.h" + + +namespace tut +{ + struct random + { + }; + + typedef test_group random_t; + typedef random_t::object random_object_t; + tut::random_t tut_random("random"); + + template<> template<> + void random_object_t::test<1>() + { + F32 number = 0.0f; + for(S32 ii = 0; ii < 100000; ++ii) + { + number = ll_frand(); + ensure("frand >= 0", (number >= 0.0f)); + ensure("frand < 1", (number < 1.0f)); + } + } + + template<> template<> + void random_object_t::test<2>() + { + F64 number = 0.0f; + for(S32 ii = 0; ii < 100000; ++ii) + { + number = ll_drand(); + ensure("drand >= 0", (number >= 0.0)); + ensure("drand < 1", (number < 1.0)); + } + } + + template<> template<> + void random_object_t::test<3>() + { + F32 number = 0.0f; + for(S32 ii = 0; ii < 100000; ++ii) + { + number = ll_frand(2.0f) - 1.0f; + ensure("frand >= 0", (number >= -1.0f)); + ensure("frand < 1", (number <= 1.0f)); + } + } + + template<> template<> + void random_object_t::test<4>() + { + F32 number = 0.0f; + for(S32 ii = 0; ii < 100000; ++ii) + { + number = ll_frand(-7.0); + ensure("drand <= 0", (number <= 0.0)); + ensure("drand > -7", (number > -7.0)); + } + } + + template<> template<> + void random_object_t::test<5>() + { + F64 number = 0.0f; + for(S32 ii = 0; ii < 100000; ++ii) + { + number = ll_drand(-2.0); + ensure("drand <= 0", (number <= 0.0)); + ensure("drand > -2", (number > -2.0)); + } + } + + template<> template<> + void random_object_t::test<6>() + { + S32 number = 0; + for(S32 ii = 0; ii < 100000; ++ii) + { + number = ll_rand(100); + ensure("rand >= 0", (number >= 0)); + ensure("rand < 100", (number < 100)); + } + } + + template<> template<> + void random_object_t::test<7>() + { + S32 number = 0; + for(S32 ii = 0; ii < 100000; ++ii) + { + number = ll_rand(-127); + ensure("rand <= 0", (number <= 0)); + ensure("rand > -127", (number > -127)); + } + } +} diff --git a/linden/indra/test/llsd_message_system_tut.cpp b/linden/indra/test/llsd_message_system_tut.cpp index b46701c..9fcc6b5 100644 --- a/linden/indra/test/llsd_message_system_tut.cpp +++ b/linden/indra/test/llsd_message_system_tut.cpp @@ -1,8 +1,8 @@ -/** - * @file llsd_message_system_tut.cpp - * @brief Testing the LLSDMessageSystem. - * - * Copyright (c) 2006-2007, Linden Research, Inc. +/** + * @file llsd_message_system_tut.cpp + * @brief Testing the LLSDMessageSystem. + * + * Copyright (c) 2006-2007, Linden Research, Inc. * * 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 @@ -22,121 +22,123 @@ * * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. - */ - -/** - * - * These classes test the LLSDMessageSystem. - * - */ - -#include -#include "llsdmessagesystem.h" -#include "llsdutil.h" - -namespace tut -{ - class LLSDMessageSystemTestData - { - public: - LLSDMessageSystemTestData() {;} - ~LLSDMessageSystemTestData() {;} - - LLSDMessageSystem mMsgSystem; - }; - - typedef test_group LLSDMessageSystemTestGroup; - typedef LLSDMessageSystemTestGroup::object LLSDMessageSystemTestObject; - LLSDMessageSystemTestGroup llsdMessageSystemTestGroup("llsd_message_system"); - - template<> template<> - void LLSDMessageSystemTestObject::test<1>() - { - LLSD input; - U32 valueIn, valueOut; - valueIn = 42; - input["Block"]["Var"] = ll_sd_from_U32(valueIn); - mMsgSystem.setInput(input); - mMsgSystem.getU32Fast("Block", "Var", valueOut); - ensure_equals("U32 from message system matches input U32", valueIn, valueOut); - } - - template<> template<> - void LLSDMessageSystemTestObject::test<2>() - { - LLSD input; - LLUUID valueIn, valueOut; - valueIn.generate(); - input["Block"]["Var"] = valueIn; - mMsgSystem.setInput(input); - mMsgSystem.getUUIDFast("Block", "Var", valueOut); - ensure_equals("UUID from message system matches input UUID", valueIn, valueOut); - } - - template<> template<> - void LLSDMessageSystemTestObject::test<3>() - { - LLSD input; - U32 valueIn, valueOut; - LLHost host("127.0.0.1:80"); - valueIn = host.getAddress(); - input["Block"]["Var"] = ll_sd_from_U32(valueIn); - mMsgSystem.setInput(input); - mMsgSystem.getIPAddrFast("Block", "Var", valueOut); - ensure_equals("IP from message system matches input IP", valueIn, valueOut); - } - - template<> template<> - void LLSDMessageSystemTestObject::test<4>() - { - LLSD input; - U16 valueIn, valueOut; - LLHost host("127.0.0.1:80"); - valueIn = host.getPort(); - input["Block"]["Var"] = (S32)valueIn; - mMsgSystem.setInput(input); - mMsgSystem.getIPPortFast("Block", "Var", valueOut); - ensure_equals("Port from message system matches input port", valueIn, valueOut); - } - - template<> template<> - void LLSDMessageSystemTestObject::test<5>() - { - LLSD input; - U64 valueIn, valueOut; - valueIn = 42; - input["Block"]["Var"] = ll_sd_from_U64(valueIn); - mMsgSystem.setInput(input); - mMsgSystem.getU64Fast("Block", "Var", valueOut); - ensure_equals("Port from message system matches input port", valueIn, valueOut); - } - - template<> template<> - void LLSDMessageSystemTestObject::test<6>() - { - LLSD input; - std::string valueIn = "Value"; - input["Block"]["Var"] = valueIn; - mMsgSystem.setInput(input); - const U32 buffLen = 16; - char buff[buffLen]; - mMsgSystem.getStringFast("Block", "Var", buffLen, buff); - ensure_equals("string read from message system matches llsd input", std::string(buff), valueIn); - } - - template<> template<> - void LLSDMessageSystemTestObject::test<7>() - { - LLSD input; - U32 valueIn, valueOut; - valueIn = 42; - input["Block"][0]["Var"] = ll_sd_from_U32(valueIn); - input["Block"][1]["Var"] = ll_sd_from_U32(valueIn + 1); - mMsgSystem.setInput(input); - mMsgSystem.getU32Fast("Block", "Var", valueOut, 0); - ensure_equals("U32 from message system matches input U32", valueIn, valueOut); - mMsgSystem.getU32Fast("Block", "Var", valueOut, 1); - ensure_equals("U32 from message system matches input U32", (valueIn + 1), valueOut); - } -} + * COMPLETENESS OR PERFORMANCE. + */ + +/** + * + * These classes test the LLSDMessageSystem. + * + */ + +#include "linden_common.h" + +#include +#include "llsdmessagesystem.h" +#include "llsdutil.h" + +namespace tut +{ + class LLSDMessageSystemTestData + { + public: + LLSDMessageSystemTestData() {;} + ~LLSDMessageSystemTestData() {;} + + LLSDMessageSystem mMsgSystem; + }; + + typedef test_group LLSDMessageSystemTestGroup; + typedef LLSDMessageSystemTestGroup::object LLSDMessageSystemTestObject; + LLSDMessageSystemTestGroup llsdMessageSystemTestGroup("llsd_message_system"); + + template<> template<> + void LLSDMessageSystemTestObject::test<1>() + { + LLSD input; + U32 valueIn, valueOut; + valueIn = 42; + input["Block"]["Var"] = ll_sd_from_U32(valueIn); + mMsgSystem.setInput(input); + mMsgSystem.getU32Fast("Block", "Var", valueOut); + ensure_equals("U32 from message system matches input U32", valueIn, valueOut); + } + + template<> template<> + void LLSDMessageSystemTestObject::test<2>() + { + LLSD input; + LLUUID valueIn, valueOut; + valueIn.generate(); + input["Block"]["Var"] = valueIn; + mMsgSystem.setInput(input); + mMsgSystem.getUUIDFast("Block", "Var", valueOut); + ensure_equals("UUID from message system matches input UUID", valueIn, valueOut); + } + + template<> template<> + void LLSDMessageSystemTestObject::test<3>() + { + LLSD input; + U32 valueIn, valueOut; + LLHost host("127.0.0.1:80"); + valueIn = host.getAddress(); + input["Block"]["Var"] = ll_sd_from_U32(valueIn); + mMsgSystem.setInput(input); + mMsgSystem.getIPAddrFast("Block", "Var", valueOut); + ensure_equals("IP from message system matches input IP", valueIn, valueOut); + } + + template<> template<> + void LLSDMessageSystemTestObject::test<4>() + { + LLSD input; + U16 valueIn, valueOut; + LLHost host("127.0.0.1:80"); + valueIn = host.getPort(); + input["Block"]["Var"] = (S32)valueIn; + mMsgSystem.setInput(input); + mMsgSystem.getIPPortFast("Block", "Var", valueOut); + ensure_equals("Port from message system matches input port", valueIn, valueOut); + } + + template<> template<> + void LLSDMessageSystemTestObject::test<5>() + { + LLSD input; + U64 valueIn, valueOut; + valueIn = 42; + input["Block"]["Var"] = ll_sd_from_U64(valueIn); + mMsgSystem.setInput(input); + mMsgSystem.getU64Fast("Block", "Var", valueOut); + ensure_equals("Port from message system matches input port", valueIn, valueOut); + } + + template<> template<> + void LLSDMessageSystemTestObject::test<6>() + { + LLSD input; + std::string valueIn = "Value"; + input["Block"]["Var"] = valueIn; + mMsgSystem.setInput(input); + const U32 buffLen = 16; + char buff[buffLen]; + mMsgSystem.getStringFast("Block", "Var", buffLen, buff); + ensure_equals("string read from message system matches llsd input", std::string(buff), valueIn); + } + + template<> template<> + void LLSDMessageSystemTestObject::test<7>() + { + LLSD input; + U32 valueIn, valueOut; + valueIn = 42; + input["Block"][0]["Var"] = ll_sd_from_U32(valueIn); + input["Block"][1]["Var"] = ll_sd_from_U32(valueIn + 1); + mMsgSystem.setInput(input); + mMsgSystem.getU32Fast("Block", "Var", valueOut, 0); + ensure_equals("U32 from message system matches input U32", valueIn, valueOut); + mMsgSystem.getU32Fast("Block", "Var", valueOut, 1); + ensure_equals("U32 from message system matches input U32", (valueIn + 1), valueOut); + } +} diff --git a/linden/indra/test/llsd_new_tut.cpp b/linden/indra/test/llsd_new_tut.cpp index e33a28a..d278a78 100644 --- a/linden/indra/test/llsd_new_tut.cpp +++ b/linden/indra/test/llsd_new_tut.cpp @@ -28,9 +28,11 @@ #include #include +#include "linden_common.h" #include "lltut.h" #include "llsd.h" +#include "llstring.h" namespace tut { diff --git a/linden/indra/test/lltut.cpp b/linden/indra/test/lltut.cpp index 31b83e6..1127f72 100644 --- a/linden/indra/test/lltut.cpp +++ b/linden/indra/test/lltut.cpp @@ -27,7 +27,10 @@ * COMPLETENESS OR PERFORMANCE. */ +#include "linden_common.h" #include "lltut.h" + +#include "llformat.h" #include "llsd.h" namespace tut @@ -154,6 +157,20 @@ namespace tut } } + void ensure_ends_with(const std::string& msg, + const std::string& actual, const std::string& expectedEnd) + { + if( actual.size() < expectedEnd.size() + || actual.rfind(expectedEnd) + != (actual.size() - expectedEnd.size()) ) + { + std::stringstream ss; + ss << msg << ": " << "expected to find " << expectedEnd + << " at end of actual " << actual; + throw failure(ss.str().c_str()); + } + } + void ensure_contains(const std::string& msg, const std::string& actual, const std::string& expectedSubString) { @@ -165,4 +182,16 @@ namespace tut throw failure(ss.str().c_str()); } } + + void ensure_does_not_contain(const std::string& msg, + const std::string& actual, const std::string& expectedSubString) + { + if( actual.find(expectedSubString, 0) != std::string::npos ) + { + std::stringstream ss; + ss << msg << ": " << "expected not to find " << expectedSubString + << " in actual " << actual; + throw failure(ss.str().c_str()); + } + } } diff --git a/linden/indra/test/lltut.h b/linden/indra/test/lltut.h index ba3df24..c8fb6bc 100644 --- a/linden/indra/test/lltut.h +++ b/linden/indra/test/lltut.h @@ -87,8 +87,14 @@ namespace tut void ensure_starts_with(const std::string& msg, const std::string& actual, const std::string& expectedStart); + void ensure_ends_with(const std::string& msg, + const std::string& actual, const std::string& expectedEnd); + void ensure_contains(const std::string& msg, const std::string& actual, const std::string& expectedSubString); + + void ensure_does_not_contain(const std::string& msg, + const std::string& actual, const std::string& expectedSubString); } diff --git a/linden/indra/test/lluri_tut.cpp b/linden/indra/test/lluri_tut.cpp index acd67cf..31ea7d6 100644 --- a/linden/indra/test/lluri_tut.cpp +++ b/linden/indra/test/lluri_tut.cpp @@ -36,51 +36,19 @@ namespace tut { struct URITestData { - void checkParts(const std::string& uriString, + void checkParts(const LLURI& u, const char* expectedScheme, const char* expectedOpaque, const char* expectedAuthority, const char* expectedPath, - const char* expectedQuery) + const char* expectedQuery = "") { - LLURI u(uriString); - ensure_equals("scheme", u.scheme(), expectedScheme); ensure_equals("opaque", u.opaque(), expectedOpaque); ensure_equals("authority", u.authority(), expectedAuthority); ensure_equals("path", u.path(), expectedPath); ensure_equals("query", u.query(), expectedQuery); } - - void checkPartsHTTP(const char* host_and_port, - const LLSD& path, - const char* expectedOpaque, - const char* expectedAuthority, - const char* expectedPath) - { - LLURI u = LLURI::buildHTTP(host_and_port, path); - ensure_equals("scheme", u.scheme(), "HTTP"); - ensure_equals("opaque", u.opaque(), expectedOpaque); - ensure_equals("authority", u.authority(), expectedAuthority); - ensure_equals("path", u.path(), expectedPath); - ensure_equals("query", u.query(), ""); - } - - void checkPartsHTTP(const char* host_and_port, - const LLSD& path, - const LLSD& args, - const char* expectedOpaque, - const char* expectedAuthority, - const char* expectedPath, - const char* expectedQuery) - { - LLURI u = LLURI::buildHTTP(host_and_port, path, args); - ensure_equals("scheme", u.scheme(), "HTTP"); - ensure_equals("opaque", u.opaque(), expectedOpaque); - ensure_equals("authority", u.authority(), expectedAuthority); - ensure_equals("path", u.path(), expectedPath); - ensure_equals("query", u.query(), expectedQuery); - } }; typedef test_group URITestGroup; @@ -114,59 +82,73 @@ namespace tut void URITestObject::test<2>() { // empty string - checkParts("", "", "", "", "", ""); + checkParts(LLURI(""), "", "", "", ""); } template<> template<> void URITestObject::test<3>() { // no scheme - checkParts("foo", "", "foo", "", "", ""); - checkParts("foo%3A", "", "foo:", "", "", ""); + checkParts(LLURI("foo"), "", "foo", "", ""); + checkParts(LLURI("foo%3A"), "", "foo:", "", ""); } template<> template<> void URITestObject::test<4>() { // scheme w/o paths - checkParts("mailto:zero@ll.com", "mailto", "zero@ll.com", "", "", ""); - checkParts("silly://abc/def?foo", "silly", "//abc/def?foo", "", "", ""); + checkParts(LLURI("mailto:zero@ll.com"), + "mailto", "zero@ll.com", "", ""); + checkParts(LLURI("silly://abc/def?foo"), + "silly", "//abc/def?foo", "", ""); } template<> template<> void URITestObject::test<5>() { // authority section - checkParts("http:///", "http", "///", "", "/", ""); - checkParts("http://abc", "http", "//abc", "abc", "", ""); - checkParts("http://a%2Fb/cd", "http", "//a/b/cd", "a/b", "/cd", ""); - checkParts("http://host?", "http", "//host?", "host", "", ""); + checkParts(LLURI("http:///"), + "http", "///", "", "/"); + + checkParts(LLURI("http://abc"), + "http", "//abc", "abc", ""); + + checkParts(LLURI("http://a%2Fb/cd"), + "http", "//a/b/cd", "a/b", "/cd"); + + checkParts(LLURI("http://host?"), + "http", "//host?", "host", ""); } template<> template<> void URITestObject::test<6>() { // path section - checkParts("http://host/a/b/", "http", "//host/a/b/", - "host", "/a/b/", ""); - checkParts("http://host/a%3Fb/", "http", "//host/a?b/", - "host", "/a?b/", ""); - checkParts("http://host/a:b/", "http", "//host/a:b/", - "host", "/a:b/", ""); + checkParts(LLURI("http://host/a/b/"), + "http", "//host/a/b/", "host", "/a/b/"); + + checkParts(LLURI("http://host/a%3Fb/"), + "http", "//host/a?b/", "host", "/a?b/"); + + checkParts(LLURI("http://host/a:b/"), + "http", "//host/a:b/", "host", "/a:b/"); } template<> template<> void URITestObject::test<7>() { // query string - checkParts("http://host/?", "http", "//host/?", - "host", "/", ""); - checkParts("http://host/?x", "http", "//host/?x", - "host", "/", "x"); - checkParts("http://host/??", "http", "//host/??", - "host", "/", "?"); - checkParts("http://host/?%3F", "http", "//host/??", - "host", "/", "?"); + checkParts(LLURI("http://host/?"), + "http", "//host/?", "host", "/", ""); + + checkParts(LLURI("http://host/?x"), + "http", "//host/?x", "host", "/", "x"); + + checkParts(LLURI("http://host/??"), + "http", "//host/??", "host", "/", "?"); + + checkParts(LLURI("http://host/?%3F"), + "http", "//host/??", "host", "/", "?"); } template<> template<> @@ -175,11 +157,15 @@ namespace tut LLSD path; path.append("x"); path.append("123"); - checkPartsHTTP("host", path, "//host/x/123", "//host", "/x/123"); + checkParts(LLURI::buildHTTP("host", path), + "http", "//host/x/123", "host", "/x/123"); + LLSD query; query["123"] = "12"; query["abcd"] = "abc"; - checkPartsHTTP("host", path, query, "//host/x/123?123=12&abcd=abc&", "//host", "/x/123", "123=12&abcd=abc&"); + checkParts(LLURI::buildHTTP("host", path, query), + "http", "//host/x/123?123=12&abcd=abc&", + "host", "/x/123", "123=12&abcd=abc&"); } template<> template<> @@ -189,7 +175,8 @@ namespace tut LLSD path; path.append("x@*//*$&^"); path.append("123"); - checkPartsHTTP("host", path, "//host/x@*//*$&^/123", "//host", "/x@*//*$&^/123"); + checkParts(LLURI::buildHTTP("host", path), + "http", "//host/x@*//*$&^/123", "host", "/x@*//*$&^/123"); } template<> template<> @@ -202,7 +189,9 @@ namespace tut LLSD query; query["123"] = "?&*#//"; query["**@&?//"] = "abc"; - checkPartsHTTP("host", path, query, "//host/x/123?**@&?//=abc&123=?&*#//&", "//host", "/x/123", "**@&?//=abc&123=?&*#//&"); + checkParts(LLURI::buildHTTP("host", path, query), + "http", "//host/x/123?**@&?//=abc&123=?&*#//&", + "host", "/x/123", "**@&?//=abc&123=?&*#//&"); } template<> template<> @@ -215,7 +204,67 @@ namespace tut LLSD query; query["123"] = "12"; query["abcd"] = "abc"; - checkPartsHTTP("hi123*33--}{:portstuffs", path, query, "//hi123*33--}{:portstuffs/x/123?123=12&abcd=abc&", "//hi123*33--}{:portstuffs", "/x/123", "123=12&abcd=abc&"); + checkParts(LLURI::buildHTTP("hi123*33--}{:portstuffs", path, query), + "http", "//hi123*33--}{:portstuffs/x/123?123=12&abcd=abc&", + "hi123*33--}{:portstuffs", "/x/123", "123=12&abcd=abc&"); + } + + template<> template<> + void URITestObject::test<12>() + { + // test funky host_port values that are actually prefixes + + checkParts(LLURI::buildHTTP("http://example.com:8080", LLSD()), + "http", "//example.com:8080", + "example.com:8080", ""); + + checkParts(LLURI::buildHTTP("http://example.com:8080/", LLSD()), + "http", "//example.com:8080/", + "example.com:8080", "/"); + + checkParts(LLURI::buildHTTP("http://example.com:8080/a/b", LLSD()), + "http", "//example.com:8080/a/b", + "example.com:8080", "/a/b"); + } + + template<> template<> + void URITestObject::test<13>() + { + const std::string unreserved = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" + "0123456789" + "-._~"; + // test escape + ensure_equals("escaping", LLURI::escape("abcdefg", "abcdef"), "abcdef%67"); + ensure_equals("escaping", LLURI::escape("|/&\\+-_!@", ""), "%7C%2F%26%5C%2B%2D%5F%21%40"); + ensure_equals("escaping as query variable", + LLURI::escape("http://10.0.1.4:12032/agent/god/agent-id/map/layer/?resume=http://station3.ll.com:12032/agent/203ad6df-b522-491d-ba48-4e24eb57aeff/send-postcard", unreserved + ":@!$'()*+,="), + "http:%2F%2F10.0.1.4:12032%2Fagent%2Fgod%2Fagent-id%2Fmap%2Flayer%2F%3Fresume=http:%2F%2Fstation3.ll.com:12032%2Fagent%2F203ad6df-b522-491d-ba48-4e24eb57aeff%2Fsend-postcard"); + } + + template<> template<> + void URITestObject::test<14>() + { + // test various build utilities + + LLUUID id("11111111-2222-3333-4444-5566778899aa"); + + + checkParts(LLURI::buildAgentPresenceURI(id, NULL), + "http", "//localhost:12040/agent/11111111-2222-3333-4444-5566778899aa/presence", + "localhost:12040", "/agent/11111111-2222-3333-4444-5566778899aa/presence"); + + checkParts(LLURI::buildBulkAgentPresenceURI(NULL), + "http", "//localhost:12040/agent/presence", + "localhost:12040", "/agent/presence"); + + checkParts(LLURI::buildAgentSessionURI(id, NULL), + "http", "//localhost:12040/agent/11111111-2222-3333-4444-5566778899aa/session", + "localhost:12040", "/agent/11111111-2222-3333-4444-5566778899aa/session"); + + checkParts(LLURI::buildAgentLoginInfoURI(id, "datasever:12345"), + "http", "//datasever:12345/agent/11111111-2222-3333-4444-5566778899aa/logininfo", + "datasever:12345", "/agent/11111111-2222-3333-4444-5566778899aa/logininfo"); } } diff --git a/linden/indra/test/math.cpp b/linden/indra/test/math.cpp index b14a798..be8a398 100644 --- a/linden/indra/test/math.cpp +++ b/linden/indra/test/math.cpp @@ -125,7 +125,7 @@ namespace tut void uuid_object::test<4>() { id.generate(); - LLString id_str = id.getString(); + std::string id_str = id.asString(); LLUUID copy(id_str.c_str()); ensure_equals("string serialization", id, copy); } diff --git a/linden/indra/test/test.cpp b/linden/indra/test/test.cpp index d90bfdb..9eb1639 100644 --- a/linden/indra/test/test.cpp +++ b/linden/indra/test/test.cpp @@ -36,6 +36,7 @@ */ #include "linden_common.h" +#include "llerrorcontrol.h" #include "lltut.h" #include @@ -178,8 +179,18 @@ void stream_groups(std::ostream& s, const char* app) } } +void wouldHaveCrashed(const std::string& message) +{ + tut::fail("llerrs message: " + message); +} + int main(int argc, char **argv) { + LLError::initForApplication("."); + LLError::setFatalFunction(wouldHaveCrashed); + LLError::setDefaultLevel(LLError::LEVEL_ERROR); + // *FIX: should come from error config file + #ifdef CTYPE_WORKAROUND ctype_workaround(); #endif @@ -213,7 +224,7 @@ int main(int argc, char **argv) if(APR_STATUS_IS_EOF(apr_err)) break; if(apr_err) { - char buf[255]; + char buf[255]; /* Flawfinder: ignore */ std::cerr << "Error parsing options: " << apr_strerror(apr_err, buf, 255) << std::endl; return 1; diff --git a/linden/indra/test/test.vcproj b/linden/indra/test/test.vcproj index f07d412..9255315 100644 --- a/linden/indra/test/test.vcproj +++ b/linden/indra/test/test.vcproj @@ -195,6 +195,9 @@ + + + + + + + + + + diff --git a/linden/indra/test/test_llmanifest.py b/linden/indra/test/test_llmanifest.py new file mode 100644 index 0000000..b20b6c1 --- /dev/null +++ b/linden/indra/test/test_llmanifest.py @@ -0,0 +1,128 @@ +#!/usr/bin/python +# @file test_llmanifest.py +# @author Ryan Williams +# @brief Test cases for LLManifest library. +# +# Copyright (c) 2006-2007, Linden Research, Inc. +# +# The source code in this file ("Source Code") is provided by Linden Lab +# to you under the terms of the GNU General Public License, version 2.0 +# ("GPL"), unless you have obtained a separate licensing agreement +# ("Other License"), formally executed by you and Linden Lab. Terms of +# the GPL can be found in doc/GPL-license.txt in this distribution, or +# online at http://secondlife.com/developers/opensource/gplv2 +# +# There are special exceptions to the terms and conditions of the GPL as +# it is applied to this Source Code. View the full text of the exception +# in the file doc/FLOSS-exception.txt in this software distribution, or +# online at http://secondlife.com/developers/opensource/flossexception +# +# By copying, modifying or distributing this software, you acknowledge +# that you have read and understood your obligations described above, +# and agree to abide by those obligations. +# +# ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO +# WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, +# COMPLETENESS OR PERFORMANCE. + +from indra import llmanifest +import os.path +import os +import unittest + +class DemoManifest(llmanifest.LLManifest): + def construct(self): + super(DemoManifest, self).construct() + if self.prefix("dir_1"): + self.path("test_a") + self.path(src="test_b", dst="test_dst_b") + self.path("*.test") + self.path("*.tex", "*.jpg") + if self.prefix("nested", dst=""): + self.path("deep") + self.end_prefix() + self.end_prefix("dir_1") + + +class Demo_ArchManifest(llmanifest.LLManifest): + pass + +class TestLLManifest(unittest.TestCase): + mode='static' + def setUp(self): + self.m = llmanifest.LLManifest("src", "dst", {'grid':'default', 'platform':'darwin', 'version':(1,2,3,4)}) + + def testproperwindowspath(self): + self.assertEqual(llmanifest.proper_windows_path("C:\Program Files", "cygwin"),"/cygdrive/c/Program Files") + self.assertEqual(llmanifest.proper_windows_path("C:\Program Files", "windows"), "C:\Program Files") + self.assertEqual(llmanifest.proper_windows_path("/cygdrive/c/Program Files/NSIS", "windows"), "C:\Program Files\NSIS") + self.assertEqual(llmanifest.proper_windows_path("/cygdrive/c/Program Files/NSIS", "cygwin"), "/cygdrive/c/Program Files/NSIS") + + def testpathancestors(self): + self.assertEqual(["dir"], [p for p in llmanifest.path_ancestors("dir")]) + self.assertEqual(["dir/sub", "dir"], [p for p in llmanifest.path_ancestors("dir/sub")]) + self.assertEqual(["dir/sub", "dir"], [p for p in llmanifest.path_ancestors("dir/sub/")]) + self.assertEqual(["dir/sub/two", "dir/sub", "dir"], [p for p in llmanifest.path_ancestors("dir/sub/two")]) + + + def testforplatform(self): + self.assertEqual(llmanifest.LLManifest.for_platform('demo'), DemoManifest) + def tmp_test(): + return llmanifest.LLManifest.for_platform('extant') + self.assertRaises(KeyError, tmp_test) + ExtantManifest = llmanifest.LLManifestRegistry('ExtantManifest', (llmanifest.LLManifest,), {}) + self.assertEqual(llmanifest.LLManifest.for_platform('extant'), ExtantManifest) + self.assertEqual(llmanifest.LLManifest.for_platform('demo', 'Arch'), Demo_ArchManifest) + + + def testprefix(self): + self.assertEqual(self.m.get_src_prefix(), "src") + self.assertEqual(self.m.get_dst_prefix(), "dst") + self.m.prefix("level1") + self.assertEqual(self.m.get_src_prefix(), "src/level1") + self.assertEqual(self.m.get_dst_prefix(), "dst/level1") + self.m.end_prefix() + self.m.prefix(src="src", dst="dst") + self.assertEqual(self.m.get_src_prefix(), "src/src") + self.assertEqual(self.m.get_dst_prefix(), "dst/dst") + self.m.end_prefix() + + def testendprefix(self): + self.assertEqual(self.m.get_src_prefix(), "src") + self.assertEqual(self.m.get_dst_prefix(), "dst") + self.m.prefix("levela") + self.m.end_prefix() + self.assertEqual(self.m.get_src_prefix(), "src") + self.assertEqual(self.m.get_dst_prefix(), "dst") + self.m.prefix("level1") + self.m.end_prefix("level1") + self.assertEqual(self.m.get_src_prefix(), "src") + self.assertEqual(self.m.get_dst_prefix(), "dst") + self.m.prefix("level1") + def tmp_test(): + self.m.end_prefix("mismatch") + self.assertRaises(ValueError, tmp_test) + + def testruncommand(self): + self.assertEqual("Hello\n", self.m.run_command("echo Hello")) + def tmp_test(): + self.m.run_command("fff_garbage") + self.assertRaises(RuntimeError, tmp_test) + + def testpathof(self): + self.assertEqual(self.m.src_path_of("a"), "src/a") + self.assertEqual(self.m.dst_path_of("a"), "dst/a") + self.m.prefix("tmp") + self.assertEqual(self.m.src_path_of("b/c"), "src/tmp/b/c") + self.assertEqual(self.m.dst_path_of("b/c"), "dst/tmp/b/c") + + def testcmakedirs(self): + self.m.cmakedirs("test_dir_DELETE/nested/dir") + self.assert_(os.path.exists("test_dir_DELETE/nested/dir")) + self.assert_(os.path.isdir("test_dir_DELETE")) + self.assert_(os.path.isdir("test_dir_DELETE/nested")) + self.assert_(os.path.isdir("test_dir_DELETE/nested/dir")) + os.removedirs("test_dir_DELETE/nested/dir") + +if __name__ == '__main__': + unittest.main() diff --git a/linden/indra/test/test_vc8.vcproj b/linden/indra/test/test_vc8.vcproj new file mode 100644 index 0000000..79af7f0 --- /dev/null +++ b/linden/indra/test/test_vc8.vcproj @@ -0,0 +1,385 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.1