THRIFT-3437 Fixed MinGW-w64 build Client: Build Patch: Antonio Di Monaco This closes #771
Project: http://git-wip-us.apache.org/repos/asf/thrift/repo Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/796667b2 Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/796667b2 Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/796667b2 Branch: refs/heads/master Commit: 796667b29f91682871cec310571e66b1259fffb0 Parents: fe3f336 Author: Antonio Di Monaco <t...@becrux.com> Authored: Mon Jan 4 23:05:19 2016 +0100 Committer: Nobuaki Sukegawa <ns...@apache.org> Committed: Wed Jan 6 04:35:12 2016 +0900 ---------------------------------------------------------------------- build/cmake/DefineOptions.cmake | 43 +++++++++++--------- lib/cpp/CMakeLists.txt | 6 ++- lib/cpp/src/thrift/cxxfunctional.h | 8 +++- .../src/thrift/protocol/TCompactProtocol.tcc | 2 + .../src/thrift/server/TNonblockingServer.cpp | 18 +++++++- lib/cpp/src/thrift/transport/THttpServer.cpp | 6 +-- lib/cpp/src/thrift/transport/TPipe.cpp | 2 +- lib/cpp/src/thrift/transport/TPipeServer.cpp | 2 +- lib/cpp/src/thrift/transport/TServerSocket.cpp | 4 ++ lib/cpp/src/thrift/transport/TSocket.cpp | 4 ++ lib/cpp/src/thrift/windows/GetTimeOfDay.cpp | 12 ++++++ lib/cpp/test/CMakeLists.txt | 10 +++-- lib/cpp/test/OpenSSLManualInitTest.cpp | 15 +++++++ lib/cpp/test/SecurityTest.cpp | 10 ++--- lib/cpp/test/TFileTransportTest.cpp | 41 +++++++++++++++++++ lib/cpp/test/TSSLSocketInterruptTest.cpp | 10 ++--- lib/cpp/test/TransportTest.cpp | 20 +++++++++ lib/cpp/test/ZlibTest.cpp | 26 ++++++++++++ lib/cpp/test/processor/ProcessorTest.cpp | 11 +++++ lib/cpp/test/qt/TQTcpServerTest.cpp | 16 ++++---- 20 files changed, 216 insertions(+), 50 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/thrift/blob/796667b2/build/cmake/DefineOptions.cmake ---------------------------------------------------------------------- diff --git a/build/cmake/DefineOptions.cmake b/build/cmake/DefineOptions.cmake index 695a615..3198db4 100644 --- a/build/cmake/DefineOptions.cmake +++ b/build/cmake/DefineOptions.cmake @@ -120,6 +120,8 @@ if (NOT WITH_SHARED_LIB AND NOT WITH_STATIC_LIB) message(FATAL_ERROR "Cannot build with both shared and static outputs disabled!") endif() +option(WITH_DYN_LINK_TEST "Build with Boost dynamic link test library" OFF) + #NOTE: C++ compiler options are defined in the lib/cpp/CMakeLists.txt # Visual Studio only options @@ -135,23 +137,23 @@ endmacro(MESSAGE_DEP flag summary) macro(PRINT_CONFIG_SUMMARY) message(STATUS "----------------------------------------------------------") -message(STATUS "Thrift version: ${thrift_VERSION} (${thrift_VERSION_MAJOR}.${thrift_VERSION_MINOR}.${thrift_VERSION_PATCH})") -message(STATUS "Thrift package version: ${PACKAGE_VERSION}") +message(STATUS "Thrift version: ${thrift_VERSION} (${thrift_VERSION_MAJOR}.${thrift_VERSION_MINOR}.${thrift_VERSION_PATCH})") +message(STATUS "Thrift package version: ${PACKAGE_VERSION}") message(STATUS "Build configuration Summary") -message(STATUS " Build Thrift compiler: ${BUILD_COMPILER}") -message(STATUS " Build with unit tests: ${BUILD_TESTING}") +message(STATUS " Build Thrift compiler: ${BUILD_COMPILER}") +message(STATUS " Build with unit tests: ${BUILD_TESTING}") MESSAGE_DEP(HAVE_COMPILER "Disabled because BUILD_THRIFT=OFF and no valid THRIFT_COMPILER is given") -message(STATUS " Build examples: ${BUILD_EXAMPLES}") +message(STATUS " Build examples: ${BUILD_EXAMPLES}") MESSAGE_DEP(HAVE_COMPILER "Disabled because BUILD_THRIFT=OFF and no valid THRIFT_COMPILER is given") -message(STATUS " Build Thrift libraries: ${BUILD_LIBRARIES}") +message(STATUS " Build Thrift libraries: ${BUILD_LIBRARIES}") message(STATUS " Language libraries:") -message(STATUS " Build C++ library: ${BUILD_CPP}") +message(STATUS " Build C++ library: ${BUILD_CPP}") MESSAGE_DEP(WITH_CPP "Disabled by via WITH_CCP=OFF") MESSAGE_DEP(Boost_FOUND "Boost headers missing") -message(STATUS " Build C (GLib) library: ${BUILD_C_GLIB}") +message(STATUS " Build C (GLib) library: ${BUILD_C_GLIB}") MESSAGE_DEP(WITH_C_GLIB "Disabled by via WITH_C_GLIB=OFF") MESSAGE_DEP(GLIB_FOUND "GLib missing") -message(STATUS " Build Java library: ${BUILD_JAVA}") +message(STATUS " Build Java library: ${BUILD_JAVA}") MESSAGE_DEP(WITH_JAVA "Disabled by via WITH_JAVA=OFF") if(ANDROID) MESSAGE_DEP(GRADLE_FOUND "Gradle missing") @@ -159,22 +161,23 @@ else() MESSAGE_DEP(JAVA_FOUND "Java Runtime missing") MESSAGE_DEP(ANT_FOUND "Ant missing") endif() -message(STATUS " Build Python library: ${BUILD_PYTHON}") +message(STATUS " Build Python library: ${BUILD_PYTHON}") MESSAGE_DEP(WITH_PYTHON "Disabled by via WITH_PYTHON=OFF") MESSAGE_DEP(PYTHONLIBS_FOUND "Python libraries missing") -message(STATUS " Build Haskell library: ${BUILD_HASKELL}") +message(STATUS " Build Haskell library: ${BUILD_HASKELL}") MESSAGE_DEP(WITH_HASKELL "Disabled by via WITH_HASKELL=OFF") MESSAGE_DEP(GHC_FOUND "GHC missing") MESSAGE_DEP(CABAL_FOUND "Cabal missing") message(STATUS " Library features:") -message(STATUS " Build shared libraries: ${WITH_SHARED_LIB}") -message(STATUS " Build static libraries: ${WITH_STATIC_LIB}") -message(STATUS " Build with ZLIB support: ${WITH_ZLIB}") -message(STATUS " Build with libevent support: ${WITH_LIBEVENT}") -message(STATUS " Build with Qt4 support: ${WITH_QT4}") -message(STATUS " Build with Qt5 support: ${WITH_QT5}") -message(STATUS " Build with OpenSSL support: ${WITH_OPENSSL}") -message(STATUS " Build with Boost thread support: ${WITH_BOOSTTHREADS}") -message(STATUS " Build with C++ std::thread support: ${WITH_STDTHREADS}") +message(STATUS " Build shared libraries: ${WITH_SHARED_LIB}") +message(STATUS " Build static libraries: ${WITH_STATIC_LIB}") +message(STATUS " Build with ZLIB support: ${WITH_ZLIB}") +message(STATUS " Build with libevent support: ${WITH_LIBEVENT}") +message(STATUS " Build with Qt4 support: ${WITH_QT4}") +message(STATUS " Build with Qt5 support: ${WITH_QT5}") +message(STATUS " Build with OpenSSL support: ${WITH_OPENSSL}") +message(STATUS " Build with Boost thread support: ${WITH_BOOSTTHREADS}") +message(STATUS " Build with C++ std::thread support: ${WITH_STDTHREADS}") +message(STATUS " Build with Boost dynamic link test library: ${WITH_DYN_LINK_TEST}") message(STATUS "----------------------------------------------------------") endmacro(PRINT_CONFIG_SUMMARY) http://git-wip-us.apache.org/repos/asf/thrift/blob/796667b2/lib/cpp/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/lib/cpp/CMakeLists.txt b/lib/cpp/CMakeLists.txt index 9404112..33cefcb 100755 --- a/lib/cpp/CMakeLists.txt +++ b/lib/cpp/CMakeLists.txt @@ -169,7 +169,11 @@ set( thriftcppqt_SOURCES include(ThriftMacros) ADD_LIBRARY_THRIFT(thrift ${thriftcpp_SOURCES} ${thriftcpp_threads_SOURCES}) -TARGET_LINK_LIBRARIES_THRIFT(thrift ${SYSLIBS}) +if(WIN32) + TARGET_LINK_LIBRARIES_THRIFT(thrift ${SYSLIBS} ws2_32) +else() + TARGET_LINK_LIBRARIES_THRIFT(thrift ${SYSLIBS}) +endif() if(WITH_LIBEVENT) find_package(Libevent REQUIRED) # Libevent comes with CMake support form upstream http://git-wip-us.apache.org/repos/asf/thrift/blob/796667b2/lib/cpp/src/thrift/cxxfunctional.h ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/cxxfunctional.h b/lib/cpp/src/thrift/cxxfunctional.h index dadaac3..32933a4 100644 --- a/lib/cpp/src/thrift/cxxfunctional.h +++ b/lib/cpp/src/thrift/cxxfunctional.h @@ -34,7 +34,7 @@ * In MSVC 11 all of the implementations live in std, with aliases * in std::tr1 to point to the ones in std. */ -#ifdef _WIN32 +#if defined(_WIN32) && !defined(__MINGW32__) #define _THRIFT_USING_MICROSOFT_STDLIB 1 #endif @@ -105,7 +105,11 @@ }}} // apache::thrift::stdcxx #elif _THRIFT_USING_GNU_LIBSTDCXX - #include <tr1/functional> + #ifdef USE_BOOST_THREAD + #include <boost/tr1/functional.hpp> + #else + #include <tr1/functional> + #endif namespace apache { namespace thrift { namespace stdcxx { using ::std::tr1::function; http://git-wip-us.apache.org/repos/asf/thrift/blob/796667b2/lib/cpp/src/thrift/protocol/TCompactProtocol.tcc ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/protocol/TCompactProtocol.tcc b/lib/cpp/src/thrift/protocol/TCompactProtocol.tcc index 4d660e8..6bbf9ef 100644 --- a/lib/cpp/src/thrift/protocol/TCompactProtocol.tcc +++ b/lib/cpp/src/thrift/protocol/TCompactProtocol.tcc @@ -21,6 +21,8 @@ #include <limits> +#include "thrift/config.h" + /* * TCompactProtocol::i*ToZigzag depend on the fact that the right shift * operator on a signed integer is an arithmetic (sign-extending) shift. http://git-wip-us.apache.org/repos/asf/thrift/blob/796667b2/lib/cpp/src/thrift/server/TNonblockingServer.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/server/TNonblockingServer.cpp b/lib/cpp/src/thrift/server/TNonblockingServer.cpp index 7344b8b..96ee517 100644 --- a/lib/cpp/src/thrift/server/TNonblockingServer.cpp +++ b/lib/cpp/src/thrift/server/TNonblockingServer.cpp @@ -69,6 +69,10 @@ #define PRIu64 "I64u" #endif +#if (_WIN32_WINNT < 0x0600) + #define AI_ADDRCONFIG 0x0400 +#endif + namespace apache { namespace thrift { namespace server { @@ -1024,6 +1028,10 @@ void TNonblockingServer::handleEvent(THRIFT_SOCKET fd, short which) { * Creates a socket to listen on and binds it to the local port. */ void TNonblockingServer::createAndListenOnSocket() { +#ifdef _WIN32 + TWinsockSingleton::create(); +#endif // _WIN32 + THRIFT_SOCKET s; struct addrinfo hints, *res, *res0; @@ -1129,10 +1137,16 @@ void TNonblockingServer::listenSocket(THRIFT_SOCKET s) { serverSocket_ = s; if (!port_) { - sockaddr_in addr; + struct sockaddr_storage addr; socklen_t size = sizeof(addr); if (!getsockname(serverSocket_, reinterpret_cast<sockaddr*>(&addr), &size)) { - listenPort_ = ntohs(addr.sin_port); + if (addr.ss_family == AF_INET6) { + const struct sockaddr_in6* sin = reinterpret_cast<const struct sockaddr_in6*>(&addr); + listenPort_ = ntohs(sin->sin6_port); + } else { + const struct sockaddr_in* sin = reinterpret_cast<const struct sockaddr_in*>(&addr); + listenPort_ = ntohs(sin->sin_port); + } } else { GlobalOutput.perror("TNonblocking: failed to get listen port: ", THRIFT_GET_SOCKET_ERROR); } http://git-wip-us.apache.org/repos/asf/thrift/blob/796667b2/lib/cpp/src/thrift/transport/THttpServer.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/transport/THttpServer.cpp b/lib/cpp/src/thrift/transport/THttpServer.cpp index a20d612..c89ab94 100644 --- a/lib/cpp/src/thrift/transport/THttpServer.cpp +++ b/lib/cpp/src/thrift/transport/THttpServer.cpp @@ -23,8 +23,8 @@ #include <thrift/transport/THttpServer.h> #include <thrift/transport/TSocket.h> -#ifdef _MSC_VER -#include <Shlwapi.h> +#if defined(_MSC_VER) || defined(__MINGW32__) + #include <Shlwapi.h> #endif namespace apache { @@ -39,7 +39,7 @@ THttpServer::THttpServer(boost::shared_ptr<TTransport> transport) : THttpTranspo THttpServer::~THttpServer() { } -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__MINGW32__) #define THRIFT_strncasecmp(str1, str2, len) _strnicmp(str1, str2, len) #define THRIFT_strcasestr(haystack, needle) StrStrIA(haystack, needle) #else http://git-wip-us.apache.org/repos/asf/thrift/blob/796667b2/lib/cpp/src/thrift/transport/TPipe.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/transport/TPipe.cpp b/lib/cpp/src/thrift/transport/TPipe.cpp index b1e1b72..75ce5d2 100644 --- a/lib/cpp/src/thrift/transport/TPipe.cpp +++ b/lib/cpp/src/thrift/transport/TPipe.cpp @@ -45,7 +45,7 @@ void pseudo_sync_write(HANDLE pipe, HANDLE event, const uint8_t* buf, uint32_t l class TPipeImpl : boost::noncopyable { public: TPipeImpl() {} - virtual ~TPipeImpl() = 0 {} + virtual ~TPipeImpl() {} virtual uint32_t read(uint8_t* buf, uint32_t len) = 0; virtual void write(const uint8_t* buf, uint32_t len) = 0; virtual HANDLE getPipeHandle() = 0; // doubles as the read handle for anon pipe http://git-wip-us.apache.org/repos/asf/thrift/blob/796667b2/lib/cpp/src/thrift/transport/TPipeServer.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/transport/TPipeServer.cpp b/lib/cpp/src/thrift/transport/TPipeServer.cpp index 7923102..cf6b410 100644 --- a/lib/cpp/src/thrift/transport/TPipeServer.cpp +++ b/lib/cpp/src/thrift/transport/TPipeServer.cpp @@ -43,7 +43,7 @@ using boost::shared_ptr; class TPipeServerImpl : boost::noncopyable { public: TPipeServerImpl() {} - virtual ~TPipeServerImpl() = 0 {} + virtual ~TPipeServerImpl() {} virtual void interrupt() = 0; virtual boost::shared_ptr<TTransport> acceptImpl() = 0; http://git-wip-us.apache.org/repos/asf/thrift/blob/796667b2/lib/cpp/src/thrift/transport/TServerSocket.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/transport/TServerSocket.cpp b/lib/cpp/src/thrift/transport/TServerSocket.cpp index 347da4d..dad0882 100644 --- a/lib/cpp/src/thrift/transport/TServerSocket.cpp +++ b/lib/cpp/src/thrift/transport/TServerSocket.cpp @@ -60,6 +60,10 @@ #endif // _WIN32 #endif +#if defined(_WIN32) && (_WIN32_WINNT < 0x0600) + #define AI_ADDRCONFIG 0x0400 +#endif + template <class T> inline const SOCKOPT_CAST_T* const_cast_sockopt(const T* v) { return reinterpret_cast<const SOCKOPT_CAST_T*>(v); http://git-wip-us.apache.org/repos/asf/thrift/blob/796667b2/lib/cpp/src/thrift/transport/TSocket.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/transport/TSocket.cpp b/lib/cpp/src/thrift/transport/TSocket.cpp index 6ce524b..6de6d4e 100644 --- a/lib/cpp/src/thrift/transport/TSocket.cpp +++ b/lib/cpp/src/thrift/transport/TSocket.cpp @@ -53,6 +53,10 @@ #endif // _WIN32 #endif +#if defined(_WIN32) && (_WIN32_WINNT < 0x0600) + #define AI_ADDRCONFIG 0x0400 +#endif + template <class T> inline const SOCKOPT_CAST_T* const_cast_sockopt(const T* v) { return reinterpret_cast<const SOCKOPT_CAST_T*>(v); http://git-wip-us.apache.org/repos/asf/thrift/blob/796667b2/lib/cpp/src/thrift/windows/GetTimeOfDay.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/src/thrift/windows/GetTimeOfDay.cpp b/lib/cpp/src/thrift/windows/GetTimeOfDay.cpp index 654d005..fba077c 100644 --- a/lib/cpp/src/thrift/windows/GetTimeOfDay.cpp +++ b/lib/cpp/src/thrift/windows/GetTimeOfDay.cpp @@ -23,17 +23,28 @@ // win32 #include <time.h> +#if defined(__MINGW32__) + #include <sys/time.h> +#endif + #if defined(_MSC_VER) || defined(_MSC_EXTENSIONS) #define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64 #else #define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL #endif +#if !defined(__MINGW32__) struct timezone { int tz_minuteswest; /* minutes W of Greenwich */ int tz_dsttime; /* type of dst correction */ }; +#endif +#if defined(__MINGW32__) +int thrift_gettimeofday(struct timeval* tv, struct timezone* tz) { + return gettimeofday(tv,tz); +} +#else int thrift_gettimeofday(struct timeval* tv, struct timezone* tz) { FILETIME ft; unsigned __int64 tmpres(0); @@ -79,6 +90,7 @@ int thrift_gettimeofday(struct timeval* tv, struct timezone* tz) { return 0; } +#endif int thrift_sleep(unsigned int seconds) { ::Sleep(seconds * 1000); http://git-wip-us.apache.org/repos/asf/thrift/blob/796667b2/lib/cpp/test/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/lib/cpp/test/CMakeLists.txt b/lib/cpp/test/CMakeLists.txt index 5d017b4..7fb2aa3 100644 --- a/lib/cpp/test/CMakeLists.txt +++ b/lib/cpp/test/CMakeLists.txt @@ -23,6 +23,10 @@ find_package(Boost 1.53.0 REQUIRED COMPONENTS chrono filesystem system thread un include_directories(SYSTEM "${Boost_INCLUDE_DIRS}") include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}") +if (WITH_DYN_LINK_TEST) + add_definitions( -DBOOST_TEST_DYN_LINK ) +endif() + #Make sure gen-cpp files can be included include_directories("${CMAKE_CURRENT_BINARY_DIR}") @@ -106,7 +110,7 @@ target_link_libraries(TInterruptTest ${Boost_LIBRARIES} ) LINK_AGAINST_THRIFT_LIBRARY(TInterruptTest thrift) -if (NOT MSVC AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") +if (NOT MSVC AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND NOT MINGW) target_link_libraries(TInterruptTest -lrt) endif () add_test(NAME TInterruptTest COMMAND TInterruptTest "${CMAKE_CURRENT_SOURCE_DIR}/../../../test/keys") @@ -117,7 +121,7 @@ target_link_libraries(TServerIntegrationTest ${Boost_LIBRARIES} ) LINK_AGAINST_THRIFT_LIBRARY(TServerIntegrationTest thrift) -if (NOT MSVC AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") +if (NOT MSVC AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND NOT MINGW) target_link_libraries(TServerIntegrationTest -lrt) endif () add_test(NAME TServerIntegrationTest COMMAND TServerIntegrationTest) @@ -303,7 +307,7 @@ target_link_libraries(SecurityTest ${Boost_LIBRARIES} ) LINK_AGAINST_THRIFT_LIBRARY(SecurityTest thrift) -if (NOT MSVC AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") +if (NOT MSVC AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND NOT MINGW) target_link_libraries(SecurityTest -lrt) endif () add_test(NAME SecurityTest COMMAND SecurityTest "${CMAKE_CURRENT_SOURCE_DIR}/../../../test/keys") http://git-wip-us.apache.org/repos/asf/thrift/blob/796667b2/lib/cpp/test/OpenSSLManualInitTest.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/test/OpenSSLManualInitTest.cpp b/lib/cpp/test/OpenSSLManualInitTest.cpp index 6afd7ce..5cd5e48 100644 --- a/lib/cpp/test/OpenSSLManualInitTest.cpp +++ b/lib/cpp/test/OpenSSLManualInitTest.cpp @@ -67,6 +67,20 @@ void test_openssl_availability() { openssl_cleanup(); } +#ifdef BOOST_TEST_DYN_LINK +bool init_unit_test_suite() { + boost::unit_test::test_suite* suite = &boost::unit_test::framework::master_test_suite(); + suite->p_name.value = "OpenSSLManualInit"; + + suite->add(BOOST_TEST_CASE(test_openssl_availability)); + + return true; +} + +int main( int argc, char* argv[] ) { + return ::boost::unit_test::unit_test_main(&init_unit_test_suite,argc,argv); +} +#else boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) { THRIFT_UNUSED_VARIABLE(argc); THRIFT_UNUSED_VARIABLE(argv); @@ -77,3 +91,4 @@ boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) { return NULL; } +#endif \ No newline at end of file http://git-wip-us.apache.org/repos/asf/thrift/blob/796667b2/lib/cpp/test/SecurityTest.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/test/SecurityTest.cpp b/lib/cpp/test/SecurityTest.cpp index 213efd4..1369077 100644 --- a/lib/cpp/test/SecurityTest.cpp +++ b/lib/cpp/test/SecurityTest.cpp @@ -108,8 +108,8 @@ struct SecurityFixture : public TestPortFixture pServerSocketFactory.reset(new TSSLSocketFactory(static_cast<apache::thrift::transport::SSLProtocol>(protocol))); pServerSocketFactory->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH"); - pServerSocketFactory->loadCertificate(certFile("server.crt").native().c_str()); - pServerSocketFactory->loadPrivateKey(certFile("server.key").native().c_str()); + pServerSocketFactory->loadCertificate(certFile("server.crt").string().c_str()); + pServerSocketFactory->loadPrivateKey(certFile("server.key").string().c_str()); pServerSocketFactory->server(true); pServerSocket.reset(new TSSLServerSocket("localhost", m_serverPort, pServerSocketFactory)); boost::shared_ptr<TTransport> connectedClient; @@ -160,9 +160,9 @@ struct SecurityFixture : public TestPortFixture { pClientSocketFactory.reset(new TSSLSocketFactory(static_cast<apache::thrift::transport::SSLProtocol>(protocol))); pClientSocketFactory->authenticate(true); - pClientSocketFactory->loadCertificate(certFile("client.crt").native().c_str()); - pClientSocketFactory->loadPrivateKey(certFile("client.key").native().c_str()); - pClientSocketFactory->loadTrustedCertificates(certFile("CA.pem").native().c_str()); + pClientSocketFactory->loadCertificate(certFile("client.crt").string().c_str()); + pClientSocketFactory->loadPrivateKey(certFile("client.key").string().c_str()); + pClientSocketFactory->loadTrustedCertificates(certFile("CA.pem").string().c_str()); pClientSocket = pClientSocketFactory->createSocket("localhost", m_serverPort); pClientSocket->open(); http://git-wip-us.apache.org/repos/asf/thrift/blob/796667b2/lib/cpp/test/TFileTransportTest.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/test/TFileTransportTest.cpp b/lib/cpp/test/TFileTransportTest.cpp index 294c9a6..8551b78 100644 --- a/lib/cpp/test/TFileTransportTest.cpp +++ b/lib/cpp/test/TFileTransportTest.cpp @@ -30,6 +30,14 @@ #include <thrift/transport/TFileTransport.h> +#ifdef __MINGW32__ + #include <io.h> + #include <unistd.h> + #include <sys/types.h> + #include <fcntl.h> + #include <sys\stat.h> +#endif + using namespace apache::thrift::transport; /************************************************************************** @@ -91,6 +99,19 @@ private: class TempFile { public: TempFile(const char* directory, const char* prefix) { + #ifdef __MINGW32__ + size_t path_len = strlen(prefix) + 8; + path_ = new char[path_len]; + snprintf(path_, path_len, "%sXXXXXX", prefix); + if (_mktemp_s(path_,path_len) == 0) { + fd_ = open(path_,O_CREAT | O_RDWR | O_BINARY,S_IREAD | S_IWRITE); + if (fd_ < 0) { + throw apache::thrift::TException("_mktemp_s() failed"); + } + } else { + throw apache::thrift::TException("_mktemp_s() failed"); + } + #else size_t path_len = strlen(directory) + strlen(prefix) + 8; path_ = new char[path_len]; snprintf(path_, path_len, "%s/%sXXXXXX", directory, prefix); @@ -99,6 +120,7 @@ public: if (fd_ < 0) { throw apache::thrift::TException("mkstemp() failed"); } + #endif } ~TempFile() { @@ -367,6 +389,24 @@ void parse_args(int argc, char* argv[]) { } } +#ifdef BOOST_TEST_DYN_LINK +static int myArgc = 0; +static char **myArgv = NULL; + +bool init_unit_test_suite() { + boost::unit_test::framework::master_test_suite().p_name.value = "TFileTransportTest"; + + // Parse arguments + parse_args(myArgc,myArgv); + return true; +} + +int main( int argc, char* argv[] ) { + myArgc = argc; + myArgv = argv; + return ::boost::unit_test::unit_test_main(&init_unit_test_suite,argc,argv); +} +#else boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) { boost::unit_test::framework::master_test_suite().p_name.value = "TFileTransportTest"; @@ -374,3 +414,4 @@ boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) { parse_args(argc, argv); return NULL; } +#endif \ No newline at end of file http://git-wip-us.apache.org/repos/asf/thrift/blob/796667b2/lib/cpp/test/TSSLSocketInterruptTest.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/test/TSSLSocketInterruptTest.cpp b/lib/cpp/test/TSSLSocketInterruptTest.cpp index c723d0e..f19b159 100644 --- a/lib/cpp/test/TSSLSocketInterruptTest.cpp +++ b/lib/cpp/test/TSSLSocketInterruptTest.cpp @@ -119,8 +119,8 @@ boost::shared_ptr<TSSLSocketFactory> createServerSocketFactory() { pServerSocketFactory.reset(new TSSLSocketFactory()); pServerSocketFactory->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH"); - pServerSocketFactory->loadCertificate(certFile("server.crt").native().c_str()); - pServerSocketFactory->loadPrivateKey(certFile("server.key").native().c_str()); + pServerSocketFactory->loadCertificate(certFile("server.crt").string().c_str()); + pServerSocketFactory->loadPrivateKey(certFile("server.key").string().c_str()); pServerSocketFactory->server(true); return pServerSocketFactory; } @@ -130,9 +130,9 @@ boost::shared_ptr<TSSLSocketFactory> createClientSocketFactory() { pClientSocketFactory.reset(new TSSLSocketFactory()); pClientSocketFactory->authenticate(true); - pClientSocketFactory->loadCertificate(certFile("client.crt").native().c_str()); - pClientSocketFactory->loadPrivateKey(certFile("client.key").native().c_str()); - pClientSocketFactory->loadTrustedCertificates(certFile("CA.pem").native().c_str()); + pClientSocketFactory->loadCertificate(certFile("client.crt").string().c_str()); + pClientSocketFactory->loadPrivateKey(certFile("client.key").string().c_str()); + pClientSocketFactory->loadTrustedCertificates(certFile("CA.pem").string().c_str()); return pClientSocketFactory; } http://git-wip-us.apache.org/repos/asf/thrift/blob/796667b2/lib/cpp/test/TransportTest.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/test/TransportTest.cpp b/lib/cpp/test/TransportTest.cpp index c056a5d..6cc2c87 100644 --- a/lib/cpp/test/TransportTest.cpp +++ b/lib/cpp/test/TransportTest.cpp @@ -1024,6 +1024,25 @@ BOOST_GLOBAL_FIXTURE(global_fixture); BOOST_GLOBAL_FIXTURE(global_fixture) #endif +#ifdef BOOST_TEST_DYN_LINK +bool init_unit_test_suite() { + struct timeval tv; + THRIFT_GETTIMEOFDAY(&tv, NULL); + int seed = tv.tv_sec ^ tv.tv_usec; + + initrand(seed); + + boost::unit_test::test_suite* suite = &boost::unit_test::framework::master_test_suite(); + suite->p_name.value = "TransportTest"; + TransportTestGen transport_test_generator(suite, 1); + transport_test_generator.generate(); + return true; +} + +int main( int argc, char* argv[] ) { + return ::boost::unit_test::unit_test_main(&init_unit_test_suite,argc,argv); +} +#else boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) { THRIFT_UNUSED_VARIABLE(argc); THRIFT_UNUSED_VARIABLE(argv); @@ -1039,3 +1058,4 @@ boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) { transport_test_generator.generate(); return NULL; } +#endif http://git-wip-us.apache.org/repos/asf/thrift/blob/796667b2/lib/cpp/test/ZlibTest.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/test/ZlibTest.cpp b/lib/cpp/test/ZlibTest.cpp index fa237a2..e155970 100644 --- a/lib/cpp/test/ZlibTest.cpp +++ b/lib/cpp/test/ZlibTest.cpp @@ -412,6 +412,31 @@ void print_usage(FILE* f, const char* argv0) { fprintf(f, " --help\n"); } +#ifdef BOOST_TEST_DYN_LINK +bool init_unit_test_suite() { + uint32_t seed = static_cast<uint32_t>(time(NULL)); +#ifdef HAVE_INTTYPES_H + printf("seed: %" PRIu32 "\n", seed); +#endif + rng.seed(seed); + + boost::unit_test::test_suite* suite = &boost::unit_test::framework::master_test_suite(); + suite->p_name.value = "ZlibTest"; + + uint32_t buf_len = 1024 * 32; + add_tests(suite, gen_uniform_buffer(buf_len, 'a'), buf_len, "uniform"); + add_tests(suite, gen_compressible_buffer(buf_len), buf_len, "compressible"); + add_tests(suite, gen_random_buffer(buf_len), buf_len, "random"); + + suite->add(BOOST_TEST_CASE(test_no_write)); + + return true; +} + +int main( int argc, char* argv[] ) { + return ::boost::unit_test::unit_test_main(&init_unit_test_suite,argc,argv); +} +#else boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) { THRIFT_UNUSED_VARIABLE(argc); THRIFT_UNUSED_VARIABLE(argv); @@ -433,3 +458,4 @@ boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) { return NULL; } +#endif http://git-wip-us.apache.org/repos/asf/thrift/blob/796667b2/lib/cpp/test/processor/ProcessorTest.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/test/processor/ProcessorTest.cpp b/lib/cpp/test/processor/ProcessorTest.cpp index 5aaa57e..0066657 100644 --- a/lib/cpp/test/processor/ProcessorTest.cpp +++ b/lib/cpp/test/processor/ProcessorTest.cpp @@ -908,9 +908,20 @@ DEFINE_NOFRAME_TESTS(TSimpleServer, Untemplated) // TODO: We should test TEventServer in the future. // For now, it is known not to work correctly with TProcessorEventHandler. +#ifdef BOOST_TEST_DYN_LINK +bool init_unit_test_suite() { + unit_test::framework::master_test_suite().p_name.value = "ProcessorTest"; + return true; +} + +int main( int argc, char* argv[] ) { + return ::boost::unit_test::unit_test_main(&init_unit_test_suite,argc,argv); +} +#else unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) { THRIFT_UNUSED_VARIABLE(argc); THRIFT_UNUSED_VARIABLE(argv); unit_test::framework::master_test_suite().p_name.value = "ProcessorTest"; return NULL; } +#endif http://git-wip-us.apache.org/repos/asf/thrift/blob/796667b2/lib/cpp/test/qt/TQTcpServerTest.cpp ---------------------------------------------------------------------- diff --git a/lib/cpp/test/qt/TQTcpServerTest.cpp b/lib/cpp/test/qt/TQTcpServerTest.cpp index 79c0dfc..0cad6a9 100644 --- a/lib/cpp/test/qt/TQTcpServerTest.cpp +++ b/lib/cpp/test/qt/TQTcpServerTest.cpp @@ -1,18 +1,20 @@ #define BOOST_TEST_MODULE TQTcpServerTest #include <QTest> -#include <boost/smart_ptr.hpp> #include <iostream> #include <QTcpServer> #include <QTcpSocket> #include <QHostAddress> -#include "thrift/protocol/TBinaryProtocol.h" -#include "thrift/async/TAsyncProcessor.h" -#include "thrift/qt/TQTcpServer.h" -#include "thrift/qt/TQIODeviceTransport.h" - -#include "gen-cpp/ParentService.h" +#ifndef Q_MOC_RUN + #include <boost/smart_ptr.hpp> + #include "thrift/protocol/TBinaryProtocol.h" + #include "thrift/async/TAsyncProcessor.h" + #include "thrift/qt/TQTcpServer.h" + #include "thrift/qt/TQIODeviceTransport.h" + + #include "gen-cpp/ParentService.h" +#endif using namespace apache::thrift;