From 09b29a7fdec3cad2ee03b3a5de48dbb8d54e7952 Mon Sep 17 00:00:00 2001 From: Brad Kittenbrink Date: Wed, 27 Feb 2019 17:43:31 -0800 Subject: Began work for adding a test covering LLCoprocedureManager --- .../llmessage/tests/llcoproceduremanager_test.cpp | 90 ++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 indra/llmessage/tests/llcoproceduremanager_test.cpp (limited to 'indra/llmessage/tests') diff --git a/indra/llmessage/tests/llcoproceduremanager_test.cpp b/indra/llmessage/tests/llcoproceduremanager_test.cpp new file mode 100644 index 0000000000..8c4937fd84 --- /dev/null +++ b/indra/llmessage/tests/llcoproceduremanager_test.cpp @@ -0,0 +1,90 @@ +/** + * @file llcoproceduremanager_test.cpp + * @author Brad + * @date 2019-02 + * @brief LLCoprocedureManager unit test + * + * $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 "llsdserialize.h" + +#include "../llcoproceduremanager.h" + +#include "../test/lltut.h" + + +#if LL_WINDOWS +// disable unreachable code warnings +#pragma warning(disable: 4702) +#endif + +LLCoreHttpUtil::HttpCoroutineAdapter::HttpCoroutineAdapter(std::string const&, unsigned int, unsigned int) +{ + +} + +void LLCoreHttpUtil::HttpCoroutineAdapter::cancelSuspendedOperation() +{ + +} + +LLCoreHttpUtil::HttpCoroutineAdapter::~HttpCoroutineAdapter() +{ + +} + +LLCore::HttpRequest::HttpRequest() +{ + +} + +LLCore::HttpRequest::~HttpRequest() +{ + +} + +namespace tut +{ + struct coproceduremanager_test + { + coproceduremanager_test() + { + } + }; + typedef test_group coproceduremanager_t; + typedef coproceduremanager_t::object coproceduremanager_object_t; + tut::coproceduremanager_t tut_coproceduremanager("LLCoprocedureManager"); + + + template<> template<> + void coproceduremanager_object_t::test<1>() + { + int foo = 0; + LLUUID queueId = LLCoprocedureManager::instance().enqueueCoprocedure( "PoolName", "ProcName", + [&foo] (LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t & ptr, const LLUUID & id) { + foo = 1; + }); + ensure_equals("coprocedure failed to update foo", foo, 1); + } +} -- cgit v1.2.3 From 66abe4ccab7b60e9056ee03b9536b9980599d5f0 Mon Sep 17 00:00:00 2001 From: Brad Kittenbrink Date: Mon, 4 Mar 2019 13:00:52 -0800 Subject: Attempt to close LLEventCoro's LLBoundListener connection when promise has been fulfilled. --- indra/llmessage/tests/llcoproceduremanager_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llmessage/tests') diff --git a/indra/llmessage/tests/llcoproceduremanager_test.cpp b/indra/llmessage/tests/llcoproceduremanager_test.cpp index 8c4937fd84..8ba9a84356 100644 --- a/indra/llmessage/tests/llcoproceduremanager_test.cpp +++ b/indra/llmessage/tests/llcoproceduremanager_test.cpp @@ -4,7 +4,7 @@ * @date 2019-02 * @brief LLCoprocedureManager unit test * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * $LicenseInfo:firstyear=2019&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2010, Linden Research, Inc. * -- cgit v1.2.3 From 6992ad457c04a2f9b4dee96c19d1e0df3c870dbc Mon Sep 17 00:00:00 2001 From: Brad Kittenbrink Date: Tue, 5 Mar 2019 17:09:38 -0800 Subject: Lint fixes on new test file. --- .../llmessage/tests/llcoproceduremanager_test.cpp | 43 ++++++++++------------ 1 file changed, 19 insertions(+), 24 deletions(-) (limited to 'indra/llmessage/tests') diff --git a/indra/llmessage/tests/llcoproceduremanager_test.cpp b/indra/llmessage/tests/llcoproceduremanager_test.cpp index 8ba9a84356..e503798d88 100644 --- a/indra/llmessage/tests/llcoproceduremanager_test.cpp +++ b/indra/llmessage/tests/llcoproceduremanager_test.cpp @@ -41,50 +41,45 @@ LLCoreHttpUtil::HttpCoroutineAdapter::HttpCoroutineAdapter(std::string const&, unsigned int, unsigned int) { - } void LLCoreHttpUtil::HttpCoroutineAdapter::cancelSuspendedOperation() { - } LLCoreHttpUtil::HttpCoroutineAdapter::~HttpCoroutineAdapter() { - } LLCore::HttpRequest::HttpRequest() { - } LLCore::HttpRequest::~HttpRequest() { - } namespace tut { - struct coproceduremanager_test - { - coproceduremanager_test() - { - } - }; - typedef test_group coproceduremanager_t; - typedef coproceduremanager_t::object coproceduremanager_object_t; - tut::coproceduremanager_t tut_coproceduremanager("LLCoprocedureManager"); + struct coproceduremanager_test + { + coproceduremanager_test() + { + } + }; + typedef test_group coproceduremanager_t; + typedef coproceduremanager_t::object coproceduremanager_object_t; + tut::coproceduremanager_t tut_coproceduremanager("LLCoprocedureManager"); - - template<> template<> - void coproceduremanager_object_t::test<1>() - { + + template<> template<> + void coproceduremanager_object_t::test<1>() + { int foo = 0; - LLUUID queueId = LLCoprocedureManager::instance().enqueueCoprocedure( "PoolName", "ProcName", - [&foo] (LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t & ptr, const LLUUID & id) { + LLUUID queueId = LLCoprocedureManager::instance().enqueueCoprocedure("PoolName", "ProcName", + [&foo] (LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t & ptr, const LLUUID & id) { foo = 1; - }); - ensure_equals("coprocedure failed to update foo", foo, 1); - } -} + }); + ensure_equals("coprocedure failed to update foo", foo, 1); + } +} // namespace tut -- cgit v1.2.3 From 997bdfc88682de36f02931a22d3baa23f00b6ddb Mon Sep 17 00:00:00 2001 From: Brad Kittenbrink Date: Mon, 11 Mar 2019 17:42:39 -0700 Subject: First draft of boost::fibers::unbuffered_channel based implementation of LLCoprocedureManager --- .../llmessage/tests/llcoproceduremanager_test.cpp | 81 ++++++++++++++++++++++ 1 file changed, 81 insertions(+) (limited to 'indra/llmessage/tests') diff --git a/indra/llmessage/tests/llcoproceduremanager_test.cpp b/indra/llmessage/tests/llcoproceduremanager_test.cpp index e503798d88..17535abd1e 100644 --- a/indra/llmessage/tests/llcoproceduremanager_test.cpp +++ b/indra/llmessage/tests/llcoproceduremanager_test.cpp @@ -31,6 +31,12 @@ #include "../llcoproceduremanager.h" +#include + +#include +#include +#include + #include "../test/lltut.h" @@ -81,5 +87,80 @@ namespace tut foo = 1; }); ensure_equals("coprocedure failed to update foo", foo, 1); + + LLCoprocedureManager::instance().close("PoolName"); + } + + template<> template<> + void coproceduremanager_object_t::test<2>() + { + const size_t capacity = 2; + boost::fibers::buffered_channel> chan(capacity); + + boost::fibers::fiber worker([&chan]() { + chan.value_pop()(); + }); + + chan.push([]() { + LL_INFOS("Test") << "test 1" << LL_ENDL; + }); + + worker.join(); + } + + template<> template<> + void coproceduremanager_object_t::test<3>() + { + boost::fibers::unbuffered_channel> chan; + + boost::fibers::fiber worker([&chan]() { + chan.value_pop()(); + }); + + chan.push([]() { + LL_INFOS("Test") << "test 1" << LL_ENDL; + }); + + worker.join(); + } + + template<> template<> + void coproceduremanager_object_t::test<4>() + { + boost::fibers::buffered_channel> chan(4); + + boost::fibers::fiber worker([&chan]() { + std::function f; + + // using namespace std::chrono_literals; + // const auto timeout = 5s; + // boost::fibers::channel_op_status status; + while (chan.pop(f) != boost::fibers::channel_op_status::closed) + { + LL_INFOS("CoWorker") << "got coproc" << LL_ENDL; + f(); + } + LL_INFOS("CoWorker") << "got closed" << LL_ENDL; + }); + + int counter = 0; + + for (int i = 0; i < 5; ++i) + { + LL_INFOS("CoMain") << "pushing coproc " << i << LL_ENDL; + chan.push([&counter]() { + LL_INFOS("CoProc") << "in coproc" << LL_ENDL; + ++counter; + }); + } + + LL_INFOS("CoMain") << "closing channel" << LL_ENDL; + chan.close(); + + LL_INFOS("CoMain") << "joining worker" << LL_ENDL; + worker.join(); + + LL_INFOS("CoMain") << "checking count" << LL_ENDL; + ensure_equals("coprocedure failed to update counter", counter, 5); } } // namespace tut -- cgit v1.2.3 From 16453005bb8373d7228262bf79c5882f311380e9 Mon Sep 17 00:00:00 2001 From: Anchor Date: Thu, 6 Jun 2019 01:51:38 -0700 Subject: [DRTVWR-476] - update cef, fix merge --- indra/llmessage/tests/llcoproceduremanager_test.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/llmessage/tests') diff --git a/indra/llmessage/tests/llcoproceduremanager_test.cpp b/indra/llmessage/tests/llcoproceduremanager_test.cpp index 17535abd1e..9b0ef93b13 100644 --- a/indra/llmessage/tests/llcoproceduremanager_test.cpp +++ b/indra/llmessage/tests/llcoproceduremanager_test.cpp @@ -26,6 +26,8 @@ * $/LicenseInfo$ */ +#include "llwin32headers.h" + #include "linden_common.h" #include "llsdserialize.h" -- cgit v1.2.3 From ebe1ffcbf7e7cfd5b5bb49cb771c61d0afd8b10e Mon Sep 17 00:00:00 2001 From: Anchor Date: Mon, 1 Jul 2019 15:30:09 -0700 Subject: [DRTVWR-476] - temp fix to a test --- indra/llmessage/tests/llcoproceduremanager_test.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/llmessage/tests') diff --git a/indra/llmessage/tests/llcoproceduremanager_test.cpp b/indra/llmessage/tests/llcoproceduremanager_test.cpp index 9b0ef93b13..534aea2218 100644 --- a/indra/llmessage/tests/llcoproceduremanager_test.cpp +++ b/indra/llmessage/tests/llcoproceduremanager_test.cpp @@ -88,7 +88,9 @@ namespace tut [&foo] (LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t & ptr, const LLUUID & id) { foo = 1; }); - ensure_equals("coprocedure failed to update foo", foo, 1); + + // TODO: fix me. timing issues.the above coproc gets executed after a frame + //ensure_equals("coprocedure failed to update foo", foo, 1); LLCoprocedureManager::instance().close("PoolName"); } -- cgit v1.2.3 From 44768b1b02063523798d8d72f0eb4b18f9b69b7b Mon Sep 17 00:00:00 2001 From: Anchor Date: Tue, 2 Jul 2019 21:22:10 -0700 Subject: [DRTVWR-476] - temp fix to test. comment it out. access violation in release --- indra/llmessage/tests/llcoproceduremanager_test.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'indra/llmessage/tests') diff --git a/indra/llmessage/tests/llcoproceduremanager_test.cpp b/indra/llmessage/tests/llcoproceduremanager_test.cpp index 534aea2218..f2de547452 100644 --- a/indra/llmessage/tests/llcoproceduremanager_test.cpp +++ b/indra/llmessage/tests/llcoproceduremanager_test.cpp @@ -83,16 +83,19 @@ namespace tut template<> template<> void coproceduremanager_object_t::test<1>() { + // TODO: fix me. timing issues.the coproc gets executed after a frame, access violation in release + + /* int foo = 0; LLUUID queueId = LLCoprocedureManager::instance().enqueueCoprocedure("PoolName", "ProcName", [&foo] (LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t & ptr, const LLUUID & id) { foo = 1; }); - // TODO: fix me. timing issues.the above coproc gets executed after a frame - //ensure_equals("coprocedure failed to update foo", foo, 1); + ensure_equals("coprocedure failed to update foo", foo, 1); LLCoprocedureManager::instance().close("PoolName"); + */ } template<> template<> -- cgit v1.2.3 From 6f879178d6c8ec7c6a9d4fdb3f42664dea595a0a Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 19 Sep 2019 16:36:41 -0400 Subject: DRTVWR-476: Re-enable an llcoproceduremanager_test case. Use new Sync class to make the driving logic wait for the coprocedure to run. --- indra/llmessage/tests/llcoproceduremanager_test.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'indra/llmessage/tests') diff --git a/indra/llmessage/tests/llcoproceduremanager_test.cpp b/indra/llmessage/tests/llcoproceduremanager_test.cpp index f2de547452..734b986f80 100644 --- a/indra/llmessage/tests/llcoproceduremanager_test.cpp +++ b/indra/llmessage/tests/llcoproceduremanager_test.cpp @@ -40,6 +40,7 @@ #include #include "../test/lltut.h" +#include "../test/sync.h" #if LL_WINDOWS @@ -83,19 +84,18 @@ namespace tut template<> template<> void coproceduremanager_object_t::test<1>() { - // TODO: fix me. timing issues.the coproc gets executed after a frame, access violation in release - - /* + Sync sync; int foo = 0; LLUUID queueId = LLCoprocedureManager::instance().enqueueCoprocedure("PoolName", "ProcName", - [&foo] (LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t & ptr, const LLUUID & id) { + [&foo, &sync] (LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t & ptr, const LLUUID & id) { + sync.bump(); foo = 1; }); - ensure_equals("coprocedure failed to update foo", foo, 1); + sync.yield(); + ensure_equals("coprocedure failed to update foo", foo, 1); LLCoprocedureManager::instance().close("PoolName"); - */ } template<> template<> -- cgit v1.2.3 From fc2437fb5d349a094c1c64631ba6a5fd5675ddcc Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Fri, 15 Nov 2019 08:17:04 -0500 Subject: DRTVWR-476: Introduce LLCoprocedureManager::close(). Use in tests. The new close(void) method simply acquires the logic from ~LLCoprocedureManager() (which now calls close()). It's useful, even if only in test programs, to be able to shut down all existing LLCoprocedurePools without having to name them individually -- and without having to destroy the LLCoprocedureManager singleton instance. Deleting an LLSingleton should be done only once per process, whereas test programs want to reset the LLCoprocedureManager after each test. --- indra/llmessage/tests/llcoproceduremanager_test.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'indra/llmessage/tests') diff --git a/indra/llmessage/tests/llcoproceduremanager_test.cpp b/indra/llmessage/tests/llcoproceduremanager_test.cpp index 734b986f80..9db13a37b5 100644 --- a/indra/llmessage/tests/llcoproceduremanager_test.cpp +++ b/indra/llmessage/tests/llcoproceduremanager_test.cpp @@ -75,6 +75,11 @@ namespace tut coproceduremanager_test() { } + + ~coproceduremanager_test() + { + LLCoprocedureManager::instance().close(); + } }; typedef test_group coproceduremanager_t; typedef coproceduremanager_t::object coproceduremanager_object_t; -- cgit v1.2.3