From 74d59e7128bb02a4b49af99e44f437a736a3f62b Mon Sep 17 00:00:00 2001 From: Monty Brandenberg Date: Mon, 7 May 2012 15:16:31 -0400 Subject: Build llcorehttp as part of a viewer dependency with unit tests. This required boost::thread and the easiest path to that was to go with the 1.48 Boost release in the 3P tree (eliminating a fork for a modified 1.45 packaging). One unit test, the most important one, is failing in test_httprequest but that can be attended to later. This test issues a GET to http://localhost:2/ and that is hitting the wire but the libcurl plumbing isn't delivering the failure, only the eventual timeout. An unexpected change in behavior. --- indra/cmake/Boost.cmake | 23 ++++++---- indra/cmake/LLCoreHttp.cmake | 2 + indra/cmake/LLPrimitive.cmake | 8 ++-- indra/llcommon/linden_common.h | 4 ++ indra/llcorehttp/CMakeLists.txt | 30 ++++++------ indra/llcorehttp/_httpoprequest.cpp | 2 + indra/llcorehttp/_thread.h | 4 +- indra/llcorehttp/httpcommon.h | 2 + indra/llcorehttp/tests/all_test.cpp | 64 -------------------------- indra/llcorehttp/tests/llcorehttp_test.cpp | 66 +++++++++++++++++++++++++++ indra/llcorehttp/tests/test_bufferarray.hpp | 3 +- indra/llcorehttp/tests/test_httpheaders.hpp | 2 +- indra/llcorehttp/tests/test_httpoperation.hpp | 2 +- indra/llcorehttp/tests/test_httprequest.hpp | 12 ++--- indra/llcorehttp/tests/test_httpstatus.hpp | 2 +- indra/llcorehttp/tests/test_refcounted.hpp | 2 +- 16 files changed, 125 insertions(+), 103 deletions(-) delete mode 100644 indra/llcorehttp/tests/all_test.cpp create mode 100644 indra/llcorehttp/tests/llcorehttp_test.cpp (limited to 'indra') diff --git a/indra/cmake/Boost.cmake b/indra/cmake/Boost.cmake index 2135f0584c..24de1fc0c2 100644 --- a/indra/cmake/Boost.cmake +++ b/indra/cmake/Boost.cmake @@ -12,12 +12,13 @@ if (STANDALONE) set(BOOST_SIGNALS_LIBRARY boost_signals-mt) set(BOOST_SYSTEM_LIBRARY boost_system-mt) set(BOOST_FILESYSTEM_LIBRARY boost_filesystem-mt) + set(BOOST_THREAD_LIBRARY boost_thread-mt) else (STANDALONE) use_prebuilt_binary(boost) set(Boost_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/include) if (WINDOWS) - set(BOOST_VERSION 1_45) + set(BOOST_VERSION 1_48) if(MSVC80) set(BOOST_PROGRAM_OPTIONS_LIBRARY optimized libboost_program_options-vc80-mt-${BOOST_VERSION} @@ -37,22 +38,26 @@ else (STANDALONE) else(MSVC80) # MSVC 10.0 config set(BOOST_PROGRAM_OPTIONS_LIBRARY - optimized libboost_program_options-vc100-mt-${BOOST_VERSION} - debug libboost_program_options-vc100-mt-gd-${BOOST_VERSION}) + optimized libboost_program_options-mt + debug libboost_program_options-mt-gd) set(BOOST_REGEX_LIBRARY - optimized libboost_regex-vc100-mt-${BOOST_VERSION} - debug libboost_regex-vc100-mt-gd-${BOOST_VERSION}) + optimized libboost_regex-mt + debug libboost_regex-mt-gd) set(BOOST_SYSTEM_LIBRARY - optimized libboost_system-vc100-mt-${BOOST_VERSION} - debug libboost_system-vc100-mt-gd-${BOOST_VERSION}) + optimized libboost_system-mt + debug libboost_system-mt-gd) set(BOOST_FILESYSTEM_LIBRARY - optimized libboost_filesystem-vc100-mt-${BOOST_VERSION} - debug libboost_filesystem-vc100-mt-gd-${BOOST_VERSION}) + optimized libboost_filesystem-mt + debug libboost_filesystem-mt-gd) + set(BOOST_THREAD_LIBRARY + optimized libboost_thread-mt + debug libboost_thread-mt-gd) endif (MSVC80) elseif (DARWIN OR LINUX) set(BOOST_PROGRAM_OPTIONS_LIBRARY boost_program_options) set(BOOST_REGEX_LIBRARY boost_regex) set(BOOST_SYSTEM_LIBRARY boost_system) set(BOOST_FILESYSTEM_LIBRARY boost_filesystem) + set(BOOST_THREAD_LIBRARY boost_thread) endif (WINDOWS) endif (STANDALONE) diff --git a/indra/cmake/LLCoreHttp.cmake b/indra/cmake/LLCoreHttp.cmake index 280189da3d..61e4b23d98 100644 --- a/indra/cmake/LLCoreHttp.cmake +++ b/indra/cmake/LLCoreHttp.cmake @@ -3,12 +3,14 @@ include(CARes) include(CURL) include(OpenSSL) +include(Boost) set(LLCOREHTTP_INCLUDE_DIRS ${LIBS_OPEN_DIR}/llcorehttp ${CARES_INCLUDE_DIRS} ${CURL_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIRS} + ${BOOST_INCLUDE_DIRS} ) set(LLCOREHTTP_LIBRARIES llcorehttp) diff --git a/indra/cmake/LLPrimitive.cmake b/indra/cmake/LLPrimitive.cmake index f15a2c2649..ab39cbb6be 100644 --- a/indra/cmake/LLPrimitive.cmake +++ b/indra/cmake/LLPrimitive.cmake @@ -15,10 +15,10 @@ if (WINDOWS) optimized llprimitive debug libcollada14dom22-d optimized libcollada14dom22 - debug libboost_filesystem-vc100-mt-gd-1_45 - optimized libboost_filesystem-vc100-mt-1_45 - debug libboost_system-vc100-mt-gd-1_45 - optimized libboost_system-vc100-mt-1_45 + debug libboost_filesystem-mt-gd + optimized libboost_filesystem-mt + debug libboost_system-mt-gd + optimized libboost_system-mt ) else (WINDOWS) set(LLPRIMITIVE_LIBRARIES diff --git a/indra/llcommon/linden_common.h b/indra/llcommon/linden_common.h index bdcc98e402..50db03cb6a 100644 --- a/indra/llcommon/linden_common.h +++ b/indra/llcommon/linden_common.h @@ -82,4 +82,8 @@ #include "llfile.h" #include "llformat.h" +// Boost 1.45 had version 2 as the default for the filesystem library, +// 1.48 has version 3 as the default. Keep compatibility for now. +#define BOOST_FILESYSTEM_VERSION 2 + #endif diff --git a/indra/llcorehttp/CMakeLists.txt b/indra/llcorehttp/CMakeLists.txt index e0d1817781..a950e9180c 100644 --- a/indra/llcorehttp/CMakeLists.txt +++ b/indra/llcorehttp/CMakeLists.txt @@ -73,23 +73,24 @@ target_link_libraries( ${CARES_LIBRARIES} ${OPENSSL_LIBRARIES} ${CRYPTO_LIBRARIES} + ${BOOST_THREAD_LIBRARY} ) # tests -#if (LL_TESTS) -if (LL_TESTS AND 0) +if (LL_TESTS) +#if (LL_TESTS AND 0) SET(llcorehttp_TEST_SOURCE_FILES - test_allocator.cpp + tests/test_allocator.cpp ) set(llcorehttp_TEST_HEADER_FILS - test_httpstatus.hpp - test_refcounted.hpp - test_httpoperation.hpp - test_httprequest.hpp - test_httprequestqueue.hpp - test_httpheaders.hpp - test_bufferarray.hpp + tests/test_httpstatus.hpp + tests/test_refcounted.hpp + tests/test_httpoperation.hpp + tests/test_httprequest.hpp + tests/test_httprequestqueue.hpp + tests/test_httpheaders.hpp + tests/test_bufferarray.hpp ) set_source_files_properties(${llcorehttp_TEST_HEADER_FILES} @@ -105,13 +106,16 @@ if (LL_TESTS AND 0) ${WINDOWS_LIBRARIES} ${LLCOMMON_LIBRARIES} ${GOOGLEMOCK_LIBRARIES} + ${CURL_LIBRARIES} + ${OPENSSL_LIBRARIES} + ${CRYPTO_LIBRARIES} ) - LL_ADD_INTEGRATION_TEST(all + LL_ADD_INTEGRATION_TEST(llcorehttp "${llcorehttp_TEST_SOURCE_FILES}" "${test_libs}" ) -#endif (LL_TESTS) -endif (LL_TESTS AND 0) +endif (LL_TESTS) +#endif (LL_TESTS AND 0) diff --git a/indra/llcorehttp/_httpoprequest.cpp b/indra/llcorehttp/_httpoprequest.cpp index 316df8bd49..3c9eb71b9a 100644 --- a/indra/llcorehttp/_httpoprequest.cpp +++ b/indra/llcorehttp/_httpoprequest.cpp @@ -259,6 +259,8 @@ HttpStatus HttpOpRequest::prepareForGet(HttpService * service) HttpStatus status; mCurlHandle = curl_easy_init(); + curl_easy_setopt(mCurlHandle, CURLOPT_TIMEOUT, 30); + curl_easy_setopt(mCurlHandle, CURLOPT_CONNECTTIMEOUT, 30); curl_easy_setopt(mCurlHandle, CURLOPT_NOSIGNAL, 1); curl_easy_setopt(mCurlHandle, CURLOPT_NOPROGRESS, 1); curl_easy_setopt(mCurlHandle, CURLOPT_URL, mReqURL.c_str()); diff --git a/indra/llcorehttp/_thread.h b/indra/llcorehttp/_thread.h index 0937d698c7..46a333a749 100644 --- a/indra/llcorehttp/_thread.h +++ b/indra/llcorehttp/_thread.h @@ -27,9 +27,11 @@ #ifndef LLCOREINT_THREAD_H_ #define LLCOREINT_THREAD_H_ +#include +#include -#include "_refcounted.h" +#include "_refcounted.h" namespace LLCoreInt { diff --git a/indra/llcorehttp/httpcommon.h b/indra/llcorehttp/httpcommon.h index cd7c09f097..5fc497e720 100644 --- a/indra/llcorehttp/httpcommon.h +++ b/indra/llcorehttp/httpcommon.h @@ -93,6 +93,8 @@ /// /// +#include "linden_common.h" + #include diff --git a/indra/llcorehttp/tests/all_test.cpp b/indra/llcorehttp/tests/all_test.cpp deleted file mode 100644 index 636f6f8c05..0000000000 --- a/indra/llcorehttp/tests/all_test.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/** - * @file test_all - * @brief Main test runner - * - * $LicenseInfo:firstyear=2012&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2012, 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 - -#include -#include - -#include - -// Pull in each of the test sets -#include "test_httpstatus.hpp" -#include "test_refcounted.hpp" -#include "test_httpoperation.hpp" -#include "test_httprequest.hpp" -#include "test_httpheaders.hpp" -#include "test_bufferarray.hpp" -#include "test_httprequestqueue.hpp" - - -namespace tut -{ - test_runner_singleton runner; -} - -int main() -{ - curl_global_init(CURL_GLOBAL_ALL); - - // *FIXME: Need threaded/SSL curl setup here. - - tut::reporter reporter; - - tut::runner.get().set_callback(&reporter); - tut::runner.get().run_tests(); - return !reporter.all_ok(); - - curl_global_cleanup(); -} - diff --git a/indra/llcorehttp/tests/llcorehttp_test.cpp b/indra/llcorehttp/tests/llcorehttp_test.cpp new file mode 100644 index 0000000000..ad596d61cc --- /dev/null +++ b/indra/llcorehttp/tests/llcorehttp_test.cpp @@ -0,0 +1,66 @@ +/** + * @file llcorehttp_test + * @brief Main test runner + * + * $LicenseInfo:firstyear=2012&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2012, 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 + +#include +#include + +#include + +// Pull in each of the test sets +#include "test_httpstatus.hpp" +#include "test_refcounted.hpp" +#include "test_httpoperation.hpp" +#include "test_httprequest.hpp" +#include "test_httpheaders.hpp" +#include "test_bufferarray.hpp" +#include "test_httprequestqueue.hpp" + +#if 0 + +namespace tut +{ + test_runner_singleton runner; +} + +int main() +{ + curl_global_init(CURL_GLOBAL_ALL); + + // *FIXME: Need threaded/SSL curl setup here. + + tut::reporter reporter; + + tut::runner.get().set_callback(&reporter); + tut::runner.get().run_tests(); + return !reporter.all_ok(); + + curl_global_cleanup(); +} + +#endif diff --git a/indra/llcorehttp/tests/test_bufferarray.hpp b/indra/llcorehttp/tests/test_bufferarray.hpp index 4f5d0284a1..ecbb5ef250 100644 --- a/indra/llcorehttp/tests/test_bufferarray.hpp +++ b/indra/llcorehttp/tests/test_bufferarray.hpp @@ -26,7 +26,7 @@ #ifndef TEST_LLCORE_BUFFER_ARRAY_H_ #define TEST_LLCORE_BUFFER_ARRAY_H_ -#include +#include "bufferarray.h" #include @@ -183,7 +183,6 @@ void BufferArrayTestObjectType::test<4>() char str1[] = "abcdefghij"; size_t str1_len(strlen(str1)); char str2[] = "ABCDEFGHIJ"; - size_t str2_len(strlen(str2)); char buffer[256]; size_t len = ba->write(str1, str1_len); diff --git a/indra/llcorehttp/tests/test_httpheaders.hpp b/indra/llcorehttp/tests/test_httpheaders.hpp index d22b516691..ce0d19b058 100644 --- a/indra/llcorehttp/tests/test_httpheaders.hpp +++ b/indra/llcorehttp/tests/test_httpheaders.hpp @@ -26,7 +26,7 @@ #ifndef TEST_LLCORE_HTTP_HEADERS_H_ #define TEST_LLCORE_HTTP_HEADERS_H_ -#include +#include "httpheaders.h" #include diff --git a/indra/llcorehttp/tests/test_httpoperation.hpp b/indra/llcorehttp/tests/test_httpoperation.hpp index c9feaddb2a..6c3df1e9e3 100644 --- a/indra/llcorehttp/tests/test_httpoperation.hpp +++ b/indra/llcorehttp/tests/test_httpoperation.hpp @@ -27,7 +27,7 @@ #define TEST_LLCORE_HTTP_OPERATION_H_ #include "_httpoperation.h" -#include +#include "httphandler.h" #include diff --git a/indra/llcorehttp/tests/test_httprequest.hpp b/indra/llcorehttp/tests/test_httprequest.hpp index df5640859f..ab25a2eb1a 100644 --- a/indra/llcorehttp/tests/test_httprequest.hpp +++ b/indra/llcorehttp/tests/test_httprequest.hpp @@ -26,11 +26,11 @@ #ifndef TEST_LLCORE_HTTP_REQUEST_H_ #define TEST_LLCORE_HTTP_REQUEST_H_ -#include -#include -#include -#include -#include +#include "httprequest.h" +#include "httphandler.h" +#include "httpresponse.h" +#include "_httpservice.h" +#include "_httprequestqueue.h" #include @@ -360,7 +360,7 @@ void HttpRequestTestObjectType::test<5>() mStatus = HttpStatus(HttpStatus::EXT_CURL_EASY, CURLE_COULDNT_CONNECT); HttpHandle handle = req->requestGetByteRange(HttpRequest::DEFAULT_POLICY_ID, 0.0f, - "http://localhost:2/nothing/here", + "http://127.0.0.1:2/nothing/here", 0, 0, NULL, diff --git a/indra/llcorehttp/tests/test_httpstatus.hpp b/indra/llcorehttp/tests/test_httpstatus.hpp index fa5803a17c..38bf494dec 100644 --- a/indra/llcorehttp/tests/test_httpstatus.hpp +++ b/indra/llcorehttp/tests/test_httpstatus.hpp @@ -27,7 +27,7 @@ #ifndef TEST_HTTP_STATUS_H_ #define TEST_HTTP_STATUS_H_ -#include +#include "httpcommon.h" #include #include diff --git a/indra/llcorehttp/tests/test_refcounted.hpp b/indra/llcorehttp/tests/test_refcounted.hpp index 6a17947288..cb4b50287a 100644 --- a/indra/llcorehttp/tests/test_refcounted.hpp +++ b/indra/llcorehttp/tests/test_refcounted.hpp @@ -26,7 +26,7 @@ #ifndef TEST_LLCOREINT_REF_COUNTED_H_ #define TEST_LLCOREINT_REF_COUNTED_H_ -#include <_refcounted.h> +#include "_refcounted.h" #include "test_allocator.h" -- cgit v1.2.3