summaryrefslogtreecommitdiff
path: root/indra/test
diff options
context:
space:
mode:
authorAndrey Lihatskiy <118752495+marchcat@users.noreply.github.com>2025-12-04 00:30:33 +0200
committerGitHub <noreply@github.com>2025-12-04 00:30:33 +0200
commit8c134d5a4a9f08a87104530fe910bc39434cacf2 (patch)
treedad5ddf6daf7f5e1bc7b47cd670a99ca73d4c5a1 /indra/test
parent2c3ce8fb8ce3967d957e13d48627b45dd32f0e00 (diff)
parent590f58dbad3dc3db3482dba86bf2619a87a7dad5 (diff)
Merge pull request #5020 from secondlife/marchcat/slua-linux
develop-linux → SLua PV merge
Diffstat (limited to 'indra/test')
-rw-r--r--indra/test/CMakeLists.txt76
-rwxr-xr-xindra/test/blowfish.1.bin1
-rwxr-xr-xindra/test/blowfish.2.binbin40 -> 0 bytes
-rw-r--r--indra/test/blowfish.digits.txt1
-rwxr-xr-xindra/test/blowfish.pl79
-rw-r--r--indra/test/llblowfish_tut.cpp141
-rw-r--r--indra/test/llevents_tut.cpp31
-rw-r--r--indra/test/lltut.h4
-rw-r--r--indra/test/test.cpp19
9 files changed, 79 insertions, 273 deletions
diff --git a/indra/test/CMakeLists.txt b/indra/test/CMakeLists.txt
index f80286a630..87b4e5e454 100644
--- a/indra/test/CMakeLists.txt
+++ b/indra/test/CMakeLists.txt
@@ -10,10 +10,30 @@ include(Tut)
include(LLAddBuildTest)
include(bugsplat)
+set(test_lib_SOURCE_FILES
+ lltut.cpp
+ test.cpp
+ )
+
+set(test_lib_HEADER_FILES
+ CMakeLists.txt
+ lltut.h
+ )
+
+list(APPEND test_lib_SOURCE_FILES ${test_lib_HEADER_FILES})
+
+add_library(lltut_runner_lib ${test_lib_SOURCE_FILES})
+
+target_link_libraries(lltut_runner_lib PRIVATE llcommon)
+
+set_target_properties(lltut_runner_lib
+ PROPERTIES
+ FOLDER "Tests"
+ )
+
set(test_SOURCE_FILES
io.cpp
llapp_tut.cpp
- llblowfish_tut.cpp
llbuffer_tut.cpp
lldoubledispatch_tut.cpp
llevents_tut.cpp
@@ -31,9 +51,7 @@ set(test_SOURCE_FILES
llservicebuilder_tut.cpp
llstreamtools_tut.cpp
lltemplatemessagebuilder_tut.cpp
- lltut.cpp
message_tut.cpp
- test.cpp
)
set(test_HEADER_FILES
@@ -57,6 +75,7 @@ list(APPEND test_SOURCE_FILES ${test_HEADER_FILES})
add_executable(lltest ${test_SOURCE_FILES})
target_link_libraries(lltest
+ lltut_runner_lib
llinventory
llmessage
llmath
@@ -66,14 +85,27 @@ target_link_libraries(lltest
llcorehttp
)
+set_target_properties(lltest
+ PROPERTIES
+ FOLDER "Tests"
+ )
+
if (WINDOWS)
set_target_properties(lltest
- PROPERTIES
+ PROPERTIES
LINK_FLAGS "/NODEFAULTLIB:LIBCMT"
LINK_FLAGS_DEBUG "/NODEFAULTLIB:\"LIBCMT;LIBCMTD;MSVCRT\""
RUNTIME_OUTPUT_DIRECTORY "${EXE_STAGING_DIR}"
)
elseif (DARWIN)
+ set_target_properties(lltut_runner_lib
+ PROPERTIES
+ OSX_ARCHITECTURES ${LL_MACOS_TEST_ARCHITECTURE}
+ )
+ set_target_properties(lltest
+ PROPERTIES
+ OSX_ARCHITECTURES ${LL_MACOS_TEST_ARCHITECTURE}
+ )
# Support our "@executable_path/../Resources" load path for our test
# executable. This SHOULD properly be "$<TARGET_FILE_DIR:lltest>/Resources",
# but the CMake $<TARGET_FILE_DIR> generator expression isn't evaluated by
@@ -82,32 +114,24 @@ elseif (DARWIN)
SYMBOLIC)
endif (WINDOWS)
-set(TEST_EXE $<TARGET_FILE:lltest>)
-
-SET_TEST_PATH(LD_LIBRARY_PATH)
+# This should cause the test executable to be built, but not
+# run if LL_TESTS is disabled. This will hopefully keep the
+# tests up to date with any code changes changes even if
+# developers choose to disable LL_TESTS.
+if (LL_TESTS)
+ set(TEST_EXE $<TARGET_FILE:lltest>)
-LL_TEST_COMMAND(command
- "${LD_LIBRARY_PATH}"
- "${TEST_EXE}"
- "--output=${CMAKE_CURRENT_BINARY_DIR}/cpp_test_results.txt"
- "--touch=${CMAKE_CURRENT_BINARY_DIR}/cpp_tests_ok.txt")
+ SET_TEST_PATH(LD_LIBRARY_PATH)
-ADD_CUSTOM_COMMAND(
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/cpp_tests_ok.txt
- COMMAND ${command}
- DEPENDS lltest
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- COMMENT "C++ unit tests"
- )
+ LL_TEST_COMMAND(command
+ "${LD_LIBRARY_PATH}"
+ "${TEST_EXE}"
+ "--output=${CMAKE_CURRENT_BINARY_DIR}/cpp_test_results.txt"
+ "--touch=${CMAKE_CURRENT_BINARY_DIR}/cpp_tests_ok.txt")
-set(test_results ${CMAKE_CURRENT_BINARY_DIR}/cpp_tests_ok.txt)
+ add_test(NAME "C++ unit tests" COMMAND ${command} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
-# This should cause the test executable to be built, but not
-# run if LL_TESTS is disabled. This will hopefully keep the
-# tests up to date with any code changes changes even if
-# developers choose to disable LL_TESTS.
-if (LL_TESTS)
- add_custom_target(tests_ok ALL DEPENDS ${test_results})
+ add_dependencies(BUILD_TESTS lltest)
if(DARWIN)
# Support our "@executable_path/../Resources" load path for our test
# executable. This SHOULD properly be "$<TARGET_FILE_DIR:lltest>/Resources",
diff --git a/indra/test/blowfish.1.bin b/indra/test/blowfish.1.bin
deleted file mode 100755
index 61286e45e3..0000000000
--- a/indra/test/blowfish.1.bin
+++ /dev/null
@@ -1 +0,0 @@
-.A„Ä3ŒLÜE ``òøÝKÛ@¼ûÇ;M[ÚBë·ø„>ËÊC—' \ No newline at end of file
diff --git a/indra/test/blowfish.2.bin b/indra/test/blowfish.2.bin
deleted file mode 100755
index ef72d96bbf..0000000000
--- a/indra/test/blowfish.2.bin
+++ /dev/null
Binary files differ
diff --git a/indra/test/blowfish.digits.txt b/indra/test/blowfish.digits.txt
deleted file mode 100644
index fce1fed943..0000000000
--- a/indra/test/blowfish.digits.txt
+++ /dev/null
@@ -1 +0,0 @@
-01234567890123456789012345678901234
diff --git a/indra/test/blowfish.pl b/indra/test/blowfish.pl
deleted file mode 100755
index 30f41dcd4c..0000000000
--- a/indra/test/blowfish.pl
+++ /dev/null
@@ -1,79 +0,0 @@
-#!/usr/bin/perl
-#
-# Test Perl Crypt::CBC Blowfish algorithm and initial parameter settings
-# for compatibility with OpenSSL's Blowfish algorithm/settings.
-#
-# Used by outbound LSL email (openssl C library) and mailglue (Perl library)
-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 <FH>;
-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 <FH>;
-close(FH);
-is( $encrypted, $bin, "uuid matches openssl" );
-
-print encode_base64($encrypted);
diff --git a/indra/test/llblowfish_tut.cpp b/indra/test/llblowfish_tut.cpp
deleted file mode 100644
index a8690ccb33..0000000000
--- a/indra/test/llblowfish_tut.cpp
+++ /dev/null
@@ -1,141 +0,0 @@
-/**
- * @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
- *
- * $LicenseInfo:firstyear=2007&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#include "linden_common.h"
-#include "lltut.h"
-
-#include "llblowfishcipher.h"
-
-#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 std::string& filename,
- const std::string& data)
- {
- LLFILE* fp = LLFile::fopen(filename, "rb");
- if (!fp)
- {
- // sometimes test is run inside the indra directory
- std::string path = "test/";
- path += filename;
- fp = LLFile::fopen(path, "rb");
- }
- if (!fp)
- {
- LL_WARNS() << "unable to open " << filename << LL_ENDL;
- return false;
- }
-
- std::string good;
- good.resize(256);
- size_t got = fread(&good[0], 1, 256, fp);
- LL_DEBUGS() << "matchFile read " << got << LL_ENDL;
- fclose(fp);
- good.resize(got);
-
- return (good == data);
- }
- };
- typedef test_group<LLData> 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/indra/test/llevents_tut.cpp b/indra/test/llevents_tut.cpp
index bf5cd3f853..c5d5dcb9d4 100644
--- a/indra/test/llevents_tut.cpp
+++ b/indra/test/llevents_tut.cpp
@@ -44,15 +44,12 @@
#include <typeinfo>
// external library headers
#include <boost/bind.hpp>
-#include <boost/assign/list_of.hpp>
// other Linden headers
#include "tests/listener.h" // must PRECEDE lltut.h
#include "lltut.h"
#include "catch_and_store_what_in.h"
#include "stringize.h"
-using boost::assign::list_of;
-
template<typename T>
T make(const T& value)
{
@@ -178,7 +175,7 @@ void events_object::test<2>()
LLBoundListener bound0 = listener0.listenTo(per_frame, &Listener::callstop);
LLBoundListener bound1 = listener1.listenTo(per_frame, &Listener::call,
// after listener0
- make<LLEventPump::NameList>(list_of(listener0.getName())));
+ make<LLEventPump::NameList>(LLEventPump::NameList{ listener0.getName() }));
ensure("enabled", per_frame.enabled());
ensure("connected 0", bound0.connected());
ensure("unblocked 0", !bound0.blocked());
@@ -278,24 +275,24 @@ void events_object::test<6>()
button.listen("Mary",
boost::bind(&Collect::add, boost::ref(collector), "Mary", _1),
// state that "Mary" must come after "checked"
- make<NameList> (list_of("checked")));
+ make<NameList>(NameList{ "checked" }));
button.listen("checked",
boost::bind(&Collect::add, boost::ref(collector), "checked", _1),
// "checked" must come after "spot"
- make<NameList> (list_of("spot")));
+ make<NameList>(NameList{ "spot" }));
button.listen("spot",
boost::bind(&Collect::add, boost::ref(collector), "spot", _1));
button.post(1);
- ensure_equals(collector.result, make<StringVec>(list_of("spot")("checked")("Mary")));
+ ensure_equals(collector.result, make<StringVec>(StringVec{ "spot", "checked", "Mary" }));
collector.clear();
button.stopListening("Mary");
button.listen("Mary",
boost::bind(&Collect::add, boost::ref(collector), "Mary", _1),
LLEventPump::empty, // no after dependencies
// now "Mary" must come before "spot"
- make<NameList>(list_of("spot")));
+ make<NameList>(NameList{ "spot" }));
button.post(2);
- ensure_equals(collector.result, make<StringVec>(list_of("Mary")("spot")("checked")));
+ ensure_equals(collector.result, make<StringVec>(StringVec{ "Mary", "spot", "checked" }));
collector.clear();
button.stopListening("spot");
std::string threw = catch_what<LLEventPump::Cycle>(
@@ -303,7 +300,7 @@ void events_object::test<6>()
button.listen("spot",
boost::bind(&Collect::add, boost::ref(collector), "spot", _1),
// after "Mary" and "checked" -- whoops!
- make<NameList>(list_of("Mary")("checked")));
+ make<NameList>(NameList{ "Mary", "checked" }));
});
// Obviously the specific wording of the exception text can
// change; go ahead and change the test to match.
@@ -321,20 +318,18 @@ void events_object::test<6>()
ensure_contains("cyclic dependencies", threw,
"after (\"Mary\", \"checked\") -> \"spot\"");
button.listen("yellow",
- boost::bind(&Collect::add, boost::ref(collector), "yellow", _1),
- make<NameList>(list_of("checked")));
+ boost::bind(&Collect::add, boost::ref(collector), "yellow", _1), make<NameList>(NameList{ "checked" }));
button.listen("shoelaces",
- boost::bind(&Collect::add, boost::ref(collector), "shoelaces", _1),
- make<NameList>(list_of("checked")));
+ boost::bind(&Collect::add, boost::ref(collector), "shoelaces", _1), make<NameList>(NameList{ "checked" }));
button.post(3);
- ensure_equals(collector.result, make<StringVec>(list_of("Mary")("checked")("yellow")("shoelaces")));
+ ensure_equals(collector.result, make<StringVec>(StringVec{ "Mary", "checked", "yellow", "shoelaces" }));
collector.clear();
threw = catch_what<LLEventPump::OrderChange>(
[&button, &collector](){
button.listen("of",
boost::bind(&Collect::add, boost::ref(collector), "of", _1),
- make<NameList>(list_of("shoelaces")),
- make<NameList>(list_of("yellow")));
+ make<NameList>(NameList{ "shoelaces" }),
+ make<NameList>(NameList{ "yellow" }));
});
// Same remarks about the specific wording of the exception. Just
// ensure that it contains enough information to clarify the
@@ -347,7 +342,7 @@ void events_object::test<6>()
ensure_contains("old order", threw, "was: Mary, checked, yellow, shoelaces");
ensure_contains("new order", threw, "now: Mary, checked, shoelaces, of, yellow");
button.post(4);
- ensure_equals(collector.result, make<StringVec>(list_of("Mary")("checked")("yellow")("shoelaces")));
+ ensure_equals(collector.result, make<StringVec>(StringVec{ "Mary", "checked", "yellow", "shoelaces" }));
}
template<> template<>
diff --git a/indra/test/lltut.h b/indra/test/lltut.h
index 581a08654d..fdc1cd7dfe 100644
--- a/indra/test/lltut.h
+++ b/indra/test/lltut.h
@@ -75,12 +75,12 @@ namespace tut
// overloads declared above.
// turn off warnings about unused functions from clang for tut package
-#if __clang__
+#if LL_CLANG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-function"
#endif
#include <tut/tut.hpp>
-#if __clang__
+#if LL_CLANG
#pragma clang diagnostic pop
#endif
diff --git a/indra/test/test.cpp b/indra/test/test.cpp
index 172b6e3542..fd8034b811 100644
--- a/indra/test/test.cpp
+++ b/indra/test/test.cpp
@@ -77,12 +77,14 @@ public:
virtual void replay(std::ostream&) {}
};
-class RecordToTempFile : public LLError::Recorder, public boost::noncopyable
+class RecordToTempFile : public LLError::Recorder
{
public:
+ RecordToTempFile(const RecordToTempFile&) = delete;
+ RecordToTempFile& operator=(const RecordToTempFile&) = delete;
+
RecordToTempFile()
: LLError::Recorder(),
- boost::noncopyable(),
mTempFile("log", ""),
mFile(mTempFile.getName().c_str())
{
@@ -108,7 +110,7 @@ public:
void replay(std::ostream& out)
{
mFile.close();
- std::ifstream inf(mTempFile.getName().c_str());
+ llifstream inf(mTempFile.getName().c_str());
std::string line;
while (std::getline(inf, line))
{
@@ -121,12 +123,14 @@ private:
llofstream mFile;
};
-class LLReplayLogReal: public LLReplayLog, public boost::noncopyable
+class LLReplayLogReal: public LLReplayLog
{
public:
+ LLReplayLogReal(const LLReplayLogReal&) = delete;
+ LLReplayLogReal& operator=(const LLReplayLogReal&) = delete;
+
LLReplayLogReal(LLError::ELevel level)
: LLReplayLog(),
- boost::noncopyable(),
mOldSettings(LLError::saveAndResetSettings()),
mRecorder(new RecordToTempFile())
{
@@ -505,6 +509,11 @@ static LLTrace::ThreadRecorder* sMasterThreadRecorder = NULL;
int main(int argc, char **argv)
{
+ // Call Tracy first thing to have it allocate memory
+ // https://github.com/wolfpld/tracy/issues/196
+ LL_PROFILER_FRAME_END;
+ LL_PROFILER_SET_THREAD_NAME("App");
+
ll_init_apr();
apr_getopt_t* os = NULL;
if(APR_SUCCESS != apr_getopt_init(&os, gAPRPoolp, argc, argv))