diff --git a/CMakeLists.txt b/CMakeLists.txt index 3853dfa14..47973650a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,11 @@ if(POLICY CMP0042) cmake_policy(SET CMP0042 OLD) endif() +# Force OLD style of implicitly dereferencing variables +if(POLICY CMP0054) + cmake_policy(SET CMP0054 OLD) +endif() + # Title the project and define the versioning project(${PROJECT_NAME_STR} C CXX) @@ -60,6 +65,8 @@ option(CASS_BUILD_STATIC "Build static library" OFF) option(CASS_BUILD_EXAMPLES "Build examples" OFF) option(CASS_BUILD_DOCS "Build documentation" OFF) option(CASS_BUILD_TESTS "Build tests" OFF) +option(CASS_BUILD_INTEGRATION_TESTS "Build integration tests" OFF) +option(CASS_BUILD_UNIT_TESTS "Build unit tests" OFF) option(CASS_INSTALL_HEADER "Install header file" ON) option(CASS_MULTICORE_COMPILATION "Enable multicore compilation" OFF) option(CASS_USE_STATIC_LIBS "Link static libraries when building executables" OFF) @@ -69,8 +76,18 @@ option(CASS_USE_OPENSSL "Use OpenSSL" ON) option(CASS_USE_TCMALLOC "Use tcmalloc" OFF) option(CASS_USE_SPARSEHASH "Use sparsehash" OFF) option(CASS_USE_ZLIB "Use zlib" OFF) +option(CASS_USE_LIBSSH2 "Use libssh2 for integration tests" ON) +# Handle testing dependencies if(CASS_BUILD_TESTS) + # Enable integration and unit tests for backwards compatibility + set(CASS_BUILD_INTEGRATION_TESTS ON) + set(CASS_BUILD_UNIT_TESTS ON) +endif() +if(CASS_BUILD_INTEGRATION_TESTS) + set(CASS_USE_OPENSSL ON) # Required for integration tests +endif() +if(CASS_BUILD_UNIT_TESTS) set(CASS_BUILD_STATIC ON) # Required for unit tests endif() @@ -142,7 +159,7 @@ set(CASS_LIBS ${CASS_LIBS} ${LIBUV_LIBRARY}) #------------------------ # Boost -if(CASS_USE_BOOST_ATOMIC OR CASS_BUILD_TESTS) +if(CASS_USE_BOOST_ATOMIC OR CASS_BUILD_INTEGRATION_TESTS OR CASS_BUILD_UNIT_TESTS) # Allow for boost directory to be specified on the command line set(ENV{BOOST_ROOT} "${PROJECT_SOURCE_DIR}/lib/boost/") if(BOOST_ROOT_DIR) @@ -178,7 +195,7 @@ if(CASS_USE_BOOST_ATOMIC OR CASS_BUILD_TESTS) endif() # Ensure unit and integration test boost components exist - if(CASS_BUILD_TESTS) + if(CASS_BUILD_UNIT_TESTS OR CASS_BUILD_INTEGRATION_TESTS) find_package(Boost ${CASS_MINIMUM_BOOST_VERSION} COMPONENTS chrono date_time filesystem log log_setup system regex thread unit_test_framework) if(NOT Boost_FOUND) message(FATAL_ERROR "Boost [chrono, date_time, filesystem, log, log_setup, system, regex, thread, and unit_test_framework] are required to build tests") @@ -295,21 +312,24 @@ endif() #-------------------- # libssh2 -if(CASS_BUILD_TESTS) - # Setup the root directory for libssh2 - set(LIBSSH2_ROOT "${PROJECT_SOURCE_DIR}/lib/libssh2/" $ENV{LIBSSH2_ROOT}) - set(LIBSSH2_ROOT ${LIBSSH2_ROOT} ${LIBSSH2_ROOT_DIR} $ENV{LIBSSH2_ROOT_DIR}) - - # Discover libssh2 - find_package(LIBSSH2 REQUIRED) - if(NOT LIBSSH2_FOUND) - message(FATAL_ERROR "libssh2 are required to build tests") - endif() - - # Assign test libraries (additional boost and libssh2 dependencies) - set(CASS_TEST_LIBS ${Boost_LIBRARIES} ${LIBSSH2_LIBRARIES}) - if(UNIX) - set(CASS_TEST_LIBS ${CASS_TEST_LIBS} pthread) +if(CASS_BUILD_INTEGRATION_TESTS) + if(CASS_USE_LIBSSH2) + # Setup the root directory for libssh2 + set(LIBSSH2_ROOT "${PROJECT_SOURCE_DIR}/lib/libssh2/" $ENV{LIBSSH2_ROOT}) + set(LIBSSH2_ROOT ${LIBSSH2_ROOT} ${LIBSSH2_ROOT_DIR} $ENV{LIBSSH2_ROOT_DIR}) + + # Discover libssh2 + find_package(LIBSSH2 QUIET) + if(LIBSSH2_FOUND) + # Assign test libraries (additional boost and libssh2 dependencies) + set(CASS_TEST_LIBS ${Boost_LIBRARIES} ${LIBSSH2_LIBRARIES}) + if(UNIX) + set(CASS_TEST_LIBS ${CASS_TEST_LIBS} pthread) + endif() + add_definitions(-DCASS_USE_LIBSSH2) + else() + message(STATUS "libssh2 is Unavailable: Building integration tests without libssh2 support") + endif() endif() endif() @@ -400,8 +420,8 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") string(REPLACE "/INCREMENTAL" "/INCREMENTAL:NO" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") # Create specific linker flags + set(WINDOWS_LINKER_FLAGS "/INCREMENTAL:NO /LTCG /NODEFAULTLIB:LIBCMT.LIB /NODEFAULTLIB:LIBCMTD.LIB") if(CASS_USE_STATIC_LIBS) - set(WINDOWS_LINKER_FLAGS "/INCREMENTAL:NO /LTCG /NODEFAULTLIB:LIBCMT.LIB /NODEFAULTLIB:LIBCMTD.LIB") set(PROJECT_CXX_LINKER_FLAGS "${WINDOWS_LINKER_FLAGS}") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${WINDOWS_LINKER_FLAGS}") endif() @@ -631,10 +651,11 @@ set(INSTALL_DLL_EXE_DIR "bin") #----------------------------- # Add the unit and integration tests to the build process -if(CASS_BUILD_TESTS) +if(CASS_BUILD_UNIT_TESTS) # Add the unit test project add_subdirectory(test/unit_tests) - +endif() +if(CASS_BUILD_INTEGRATION_TESTS) # Add CCM bridge as a dependency for integration tests add_subdirectory("${PROJECT_SOURCE_DIR}/test/ccm_bridge") set(CCM_BRIDGE_INCLUDES "${PROJECT_SOURCE_DIR}/test/ccm_bridge/src") diff --git a/test/ccm_bridge/CMakeLists.txt b/test/ccm_bridge/CMakeLists.txt index 553a3ae58..010dade43 100644 --- a/test/ccm_bridge/CMakeLists.txt +++ b/test/ccm_bridge/CMakeLists.txt @@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 2.6.4) # Clear INCLUDE_DIRECTORIES to not include project-level includes set_property(DIRECTORY PROPERTY INCLUDE_DIRECTORIES) +# Force OLD style of leaving VERSION variables untouched if(POLICY CMP0048) cmake_policy(SET CMP0048 OLD) endif() @@ -30,17 +31,19 @@ file(GLOB CCM_BRIDGE_INC_FILES ${PROJECT_SOURCE_DIR}/src/*.hpp) file(GLOB CCM_BRIDGE_SRC_FILES ${PROJECT_SOURCE_DIR}/src/*.cpp) # Build up the include paths -set(INTEGRATION_TESTS_INCLUDES ${PROJECT_SOURCE_DIR}/src - ${Boost_INCLUDE_DIRS} - ${LIBSSH2_INCLUDE_DIRS}) +set(INTEGRATION_TESTS_INCLUDES ${PROJECT_SOURCE_DIR}/src ${Boost_INCLUDE_DIRS}) +if(LIBSSH2_FOUND) + set(INTEGRATION_TESTS_INCLUDES ${INTEGRATION_TESTS_INCLUDES} ${LIBSSH2_INCLUDE_DIRS}) +endif() # Assign the include directories include_directories(${INTEGRATION_TESTS_INCLUDES}) # Build up the libraries paths -set(INTEGRATION_TESTS_LIBS ${Boost_LIBRARIES} - ${LIBSSH2_LIBRARIES} - ${OPENSSL_LIBRARIES}) +set(INTEGRATION_TESTS_LIBS ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES}) +if(LIBSSH2_FOUND) + set(INTEGRATION_TEST_LIBS ${INTEGRATION_TEST_LIBS} ${LIBSSH2_LIBRARIES}) +endif() if(ZLIB_FOUND) set(INTEGRATION_TESTS_LIBS ${INTEGRATION_TESTS_LIBS} ${ZLIB_LIBRARIES}) endif() diff --git a/test/ccm_bridge/src/bridge.cpp b/test/ccm_bridge/src/bridge.cpp index 61df1136b..b6735c49c 100644 --- a/test/ccm_bridge/src/bridge.cpp +++ b/test/ccm_bridge/src/bridge.cpp @@ -44,6 +44,7 @@ #endif #include "bridge.hpp" +#ifdef CASS_USE_LIBSSH2 #include #define LIBSSH2_INIT_ALL 0 #ifdef OPENSSL_CLEANUP @@ -53,6 +54,12 @@ # include # include #endif +#else +#ifdef _MSC_VER +// ssize_t is defined in libssh2 and used by local command execution +typedef SSIZE_T ssize_t; +#endif +#endif #include #include @@ -125,26 +132,33 @@ CCM::Bridge::Bridge(CassVersion cassandra_version /*= DEFAULT_CASSANDRA_VERSION* const std::string& password /*= DEFAULT_PASSWORD*/, const std::string& public_key /*= ""*/, const std::string& private_key /*= ""*/) - : session_(NULL) - , channel_(NULL) - , socket_(NULL) + : socket_(NULL) , cassandra_version_(cassandra_version) , use_asfgit_(use_asfgit) , cluster_prefix_(cluster_prefix) - , deployment_type_(deployment_type) , authentication_type_(authentication_type) +#ifdef CASS_USE_LIBSSH2 + , session_(NULL) + , channel_(NULL) + , deployment_type_(deployment_type) , host_(host) { +#else + // Force local deployment only + , deployment_type_(DeploymentType::LOCAL) + , host_("127.0.0.1") { +#endif #ifdef _WIN32 # ifdef _DEBUG // Enable automatic execution of the memory leak detection upon exit _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); # endif #endif +#ifdef CASS_USE_LIBSSH2 // Determine if libssh2 needs to be initialized - if (deployment_type == DeploymentType::REMOTE) { + if (deployment_type_ == DeploymentType::REMOTE) { // Initialize the socket try { - initialize_socket(host, port); + initialize_socket(host_, port); } catch (SocketException &se) { // Re-throw the exception as a BridgeException finalize_libssh2(); @@ -155,20 +169,27 @@ CCM::Bridge::Bridge(CassVersion cassandra_version /*= DEFAULT_CASSANDRA_VERSION* initialize_libssh2(); // Authenticate and establish the libssh2 connection - establish_libssh2_connection(authentication_type, username, password, public_key, private_key); + establish_libssh2_connection(authentication_type_, username, password, public_key, private_key); } +#endif } CCM::Bridge::Bridge(const std::string& configuration_file) - : session_(NULL) - , channel_(NULL) - , socket_(NULL) + : socket_(NULL) , cassandra_version_(DEFAULT_CASSANDRA_VERSION) , use_asfgit_(DEFAULT_USE_ASFGIT) , cluster_prefix_(DEFAULT_CLUSTER_PREFIX) - , deployment_type_(DEFAULT_DEPLOYMENT) , authentication_type_(DEFAULT_AUTHENTICATION) +#ifdef CASS_USE_LIBSSH2 + , session_(NULL) + , channel_(NULL) + , deployment_type_(DEFAULT_DEPLOYMENT) , host_(DEFAULT_HOST) { +#else + // Force local + , deployment_type_(DeploymentType::LOCAL) + , host_("127.0.0.1") { +#endif // Initialize the default remote configuration settings short port = DEFAULT_REMOTE_DEPLOYMENT_PORT; @@ -203,6 +224,7 @@ CCM::Bridge::Bridge(const std::string& configuration_file) LOG_ERROR("Invalid Flag [" << value << "] for Use ASF git: Using default [" << DEFAULT_USE_ASFGIT << "]"); use_asfgit_ = DEFAULT_USE_ASFGIT; } +#ifdef CASS_USE_LIBSSH2 } else if (key.compare(CCM_CONFIGURATION_KEY_DEPLOYMENT_TYPE) == 0) { // Determine the deployment type bool is_found = false; @@ -216,6 +238,7 @@ CCM::Bridge::Bridge(const std::string& configuration_file) if (!is_found) { LOG_ERROR("Invalid Deployment Type: Using default " << DEFAULT_DEPLOYMENT.to_string()); } +#endif } else if (key.compare(CCM_CONFIGURATION_KEY_AUTHENTICATION_TYPE) == 0) { // Determine the authentication type bool is_found = false; @@ -229,8 +252,10 @@ CCM::Bridge::Bridge(const std::string& configuration_file) if (!is_found) { LOG_ERROR("Invalid Authentication Type [" << value << "]: Using default " << DEFAULT_AUTHENTICATION.to_string()); } +#ifdef CASS_USE_LIBSSH2 } else if (key.compare(CCM_CONFIGURATION_KEY_HOST) == 0) { host_ = value; +#endif } else if (key.compare(CCM_CONFIGURATION_KEY_SSH_PORT) == 0) { //Convert the value std::stringstream valueStream(value); @@ -240,6 +265,7 @@ CCM::Bridge::Bridge(const std::string& configuration_file) LOG_ERROR("Invalid Port: Using default [" << DEFAULT_REMOTE_DEPLOYMENT_PORT << "]"); port = DEFAULT_REMOTE_DEPLOYMENT_PORT; } +#ifdef CASS_USE_LIBSSH2 } else if (key.compare(CCM_CONFIGURATION_KEY_SSH_USERNAME) == 0) { username = value; } else if (key.compare(CCM_CONFIGURATION_KEY_SSH_PASSWORD) == 0) { @@ -248,6 +274,7 @@ CCM::Bridge::Bridge(const std::string& configuration_file) public_key = value; } else if (key.compare(CCM_CONFIGURATION_KEY_SSH_PRIVATE_KEY) == 0) { private_key = value; +#endif } else { LOG_ERROR("Invalid Configuration Option: Key " << key << " with value " << value); } @@ -265,6 +292,7 @@ CCM::Bridge::Bridge(const std::string& configuration_file) LOG("Cassandra Version: " << cassandra_version_.to_string()); LOG("Cluster Prefix: " << cluster_prefix_); LOG("Deployment Type: " << deployment_type_.to_string()); +#ifdef CASS_USE_LIBSSH2 if (deployment_type_ == DeploymentType::REMOTE) { LOG("Authentication Type: " << authentication_type_.to_string()); LOG("Port: " << port); @@ -276,6 +304,7 @@ CCM::Bridge::Bridge(const std::string& configuration_file) LOG("Private Key: " << private_key); } } +#endif #ifdef _WIN32 # ifdef _DEBUG @@ -283,6 +312,7 @@ CCM::Bridge::Bridge(const std::string& configuration_file) _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); # endif #endif +#ifdef CASS_USE_LIBSSH2 // Determine if libssh2 needs to be initialized if (deployment_type_ == DeploymentType::REMOTE) { // Initialize the socket @@ -301,13 +331,16 @@ CCM::Bridge::Bridge(const std::string& configuration_file) // Authenticate and establish the libssh2 connection establish_libssh2_connection(authentication_type_, username, password, public_key, private_key); } +#endif } CCM::Bridge::~Bridge() { +#ifdef CASS_USE_LIBSSH2 if (deployment_type_ == DeploymentType::REMOTE) { close_libssh2_terminal(); finalize_libssh2(); } +#endif } void CCM::Bridge::clear_cluster_data() { @@ -519,6 +552,11 @@ bool CCM::Bridge::start_cluster(std::vector jvm_arguments /*= DEFA start_command.push_back("start"); start_command.push_back("--wait-other-notice"); start_command.push_back("--wait-for-binary-proto"); +#ifdef _WIN32 + if (cassandra_version_ >= "2.2.4") { + start_command.push_back("--quiet-windows"); + } +#endif for (std::vector::const_iterator iterator = jvm_arguments.begin(); iterator != jvm_arguments.end(); ++iterator) { std::string jvm_argument = trim(*iterator); if (!jvm_argument.empty()) { @@ -718,6 +756,11 @@ bool CCM::Bridge::start_node(unsigned int node, std::vector jvm_arg start_node_command.push_back("start"); start_node_command.push_back("--wait-other-notice"); start_node_command.push_back("--wait-for-binary-proto"); +#ifdef _WIN32 + if (cassandra_version_ >= "2.2.4") { + start_node_command.push_back("--quiet-windows"); + } +#endif for (std::vector::const_iterator iterator = jvm_arguments.begin(); iterator != jvm_arguments.end(); ++iterator) { std::string jvm_argument = trim(*iterator); if (!jvm_argument.empty()) { @@ -874,6 +917,7 @@ bool CCM::Bridge::is_node_up(unsigned int node) { return false; } +#ifdef CASS_USE_LIBSSH2 void CCM::Bridge::initialize_socket(const std::string& host, short port) { // Initialize the socket socket_ = new Socket(); @@ -1140,6 +1184,7 @@ std::string CCM::Bridge::execute_libssh2_command(const std::vector& close_libssh2_terminal(); return output; } +#endif std::string CCM::Bridge::execute_local_command(const std::vector& command) { // Execute the command locally @@ -1176,6 +1221,7 @@ std::string CCM::Bridge::execute_local_command(const std::vector& c return output; } +#ifdef CASS_USE_LIBSSH2 std::string CCM::Bridge::read_libssh2_terminal() { ssize_t bytes_read_error_code = 0; char buffer[512]; @@ -1214,6 +1260,7 @@ std::string CCM::Bridge::read_libssh2_terminal() { return output; } +#endif std::string CCM::Bridge::execute_ccm_command(const std::vector& command) { // Create the CCM command @@ -1226,9 +1273,12 @@ std::string CCM::Bridge::execute_ccm_command(const std::vector& com std::string output; if (deployment_type_ == DeploymentType::LOCAL) { output = execute_local_command(ccm_command); - } else if (deployment_type_ == DeploymentType::REMOTE) { + } +#ifdef CASS_USE_LIBSSH2 + else if (deployment_type_ == DeploymentType::REMOTE) { output = execute_libssh2_command(ccm_command); } +#endif if (!output.empty()) LOG(trim(output)); return output; diff --git a/test/ccm_bridge/src/bridge.hpp b/test/ccm_bridge/src/bridge.hpp index 85a863f8b..9dc3be2a1 100644 --- a/test/ccm_bridge/src/bridge.hpp +++ b/test/ccm_bridge/src/bridge.hpp @@ -26,9 +26,11 @@ #include #include +#ifdef CASS_USE_LIBSSH2 // Forward declarations for libssh2 typedef struct _LIBSSH2_SESSION LIBSSH2_SESSION; typedef struct _LIBSSH2_CHANNEL LIBSSH2_CHANNEL; +#endif #if defined(_MSC_VER) # define CCM_BRIDGE_DEPRECATED(func) __declspec(deprecated) func @@ -182,7 +184,7 @@ namespace CCM { * @param data_center_two_nodes Number of nodes for DC2 (default: 0) * @param is_ssl True if SSL should be enabled; false otherwise * (default: false) - * @param is_client_authentiction True if client authentication should be + * @param is_client_authentication True if client authentication should be * enabled; false otherwise (default: false) * @return True if cluster was created or switched; false otherwise */ @@ -305,7 +307,7 @@ namespace CCM { * Decommission a node on the active Cassandra cluster * * @param node Node to decommission - * @return True if node was decommisioned; false otherwise + * @return True if node was decommissioned; false otherwise */ bool decommission_node(unsigned int node); @@ -446,7 +448,7 @@ namespace CCM { * NOTE: This method may check the status of the node multiple times * * @param node Node to check `DOWN` status - * @return True if node is no longer acceptting connections; false otherwise + * @return True if node is no longer accepting connections; false otherwise */ bool is_node_down(unsigned int node); @@ -461,6 +463,7 @@ namespace CCM { bool is_node_up(unsigned int node); private: +#ifdef CASS_USE_LIBSSH2 /** * SSH session handle for establishing connection */ @@ -469,6 +472,7 @@ namespace CCM { * SSH channel handle for interacting with the session */ LIBSSH2_CHANNEL* channel_; +#endif /** * Socket instance */ @@ -498,11 +502,13 @@ namespace CCM { */ AuthenticationType authentication_type_; /** - * Host/IP address to use when establishing SSH connection for remote CCM - * command execution + * IP address to use when establishing SSH connection for remote CCM + * command execution and/or IP address to use for server connection IP + * generation */ std::string host_; +#ifdef CASS_USE_LIBSSH2 /** * Initialize the socket * @@ -565,6 +571,7 @@ namespace CCM { * @return Output from executed command */ std::string execute_libssh2_command(const std::vector& command); +#endif /** * Execute a local command @@ -574,6 +581,7 @@ namespace CCM { */ std::string execute_local_command(const std::vector& command); +#ifdef CASS_USE_LIBSSH2 /** * Read the output (stdout and stderr) from the libssh2 terminal * @@ -585,6 +593,7 @@ namespace CCM { * Finalize the libssh2 library usage and socket used by libssh2 */ void finalize_libssh2(); +#endif /** * Execute the CCM command diff --git a/test/ccm_bridge/src/cass_version.hpp b/test/ccm_bridge/src/cass_version.hpp index 21b2289c3..311671a49 100644 --- a/test/ccm_bridge/src/cass_version.hpp +++ b/test/ccm_bridge/src/cass_version.hpp @@ -20,13 +20,6 @@ #include #include -#ifdef major -# undef major -#endif -#ifdef minor -# undef minor -#endif - namespace CCM { /** @@ -37,15 +30,15 @@ namespace CCM { /** * Major portion of version number */ - unsigned short major; + unsigned short major_version; /** * Minor portion of version number */ - unsigned short minor; + unsigned short minor_version; /** * Patch portion of version number */ - unsigned short patch; + unsigned short patch_version; /** * Extra portion of version number */ @@ -57,22 +50,22 @@ namespace CCM { * @param version_string String representation to convert */ CassVersion(const std::string& version_string) - : major(0) - , minor(0) - , patch(0) + : major_version(0) + , minor_version(0) + , patch_version(0) , extra("") { from_string(version_string); } int compare(const CassVersion& rhs) { - if (major < rhs.major) return -1; - if (major > rhs.major) return 1; + if (major_version < rhs.major_version) return -1; + if (major_version > rhs.major_version) return 1; - if (minor < rhs.minor) return -1; - if (minor > rhs.minor) return 1; + if (minor_version < rhs.minor_version) return -1; + if (minor_version > rhs.minor_version) return 1; - if (patch < rhs.patch) return -1; - if (patch > rhs.patch) return 1; + if (patch_version < rhs.patch_version) return -1; + if (patch_version > rhs.patch_version) return 1; return 0; } @@ -263,7 +256,7 @@ namespace CCM { */ std::string to_string(bool is_extra_requested = true) { std::stringstream version_string; - version_string << major << "." << minor << "." << patch; + version_string << major_version << "." << minor_version << "." << patch_version; if (is_extra_requested && !extra.empty()) { version_string << "-" << extra; } @@ -287,9 +280,9 @@ namespace CCM { // Convert to tokens and assign version parameters std::istringstream tokens(version); - if (tokens >> major) { - if (tokens >> minor) { - if (tokens >> patch) { + if (tokens >> major_version) { + if (tokens >> minor_version) { + if (tokens >> patch_version) { tokens >> extra; } } diff --git a/test/ccm_bridge/src/deployment_type.cpp b/test/ccm_bridge/src/deployment_type.cpp index fa97c5120..bf37cca1c 100644 --- a/test/ccm_bridge/src/deployment_type.cpp +++ b/test/ccm_bridge/src/deployment_type.cpp @@ -21,7 +21,9 @@ using namespace CCM; // Constant value definitions for deployment type const DeploymentType DeploymentType::LOCAL("LOCAL", 0, "Local"); +#ifdef CASS_USE_LIBSSH2 const DeploymentType DeploymentType::REMOTE("REMOTE", 1, "Remote"); +#endif // Static declarations for deployment type std::set DeploymentType::constants_; @@ -41,7 +43,9 @@ const std::string& DeploymentType::to_string() const { const std::set& DeploymentType::get_constants() { if (constants_.empty()) { constants_.insert(LOCAL); +#ifdef CASS_USE_LIBSSH2 constants_.insert(REMOTE); +#endif } return constants_; diff --git a/test/ccm_bridge/src/deployment_type.hpp b/test/ccm_bridge/src/deployment_type.hpp index 97ca4a468..c3899def0 100644 --- a/test/ccm_bridge/src/deployment_type.hpp +++ b/test/ccm_bridge/src/deployment_type.hpp @@ -35,10 +35,12 @@ namespace CCM { * Local deployment type; commands are executed through local process */ static const DeploymentType LOCAL; +#ifdef CASS_USE_LIBSSH2 /** * Remote deployment type; commands are executed though libssh2 */ static const DeploymentType REMOTE; +#endif /** * Name of constant diff --git a/test/integration_tests/src/test_async.cpp b/test/integration_tests/src/test_async.cpp index df5c745af..b9eb90618 100644 --- a/test/integration_tests/src/test_async.cpp +++ b/test/integration_tests/src/test_async.cpp @@ -55,7 +55,7 @@ struct AsyncTests : public test_utils::SingleSessionTest { test_utils::CassStatementPtr statement(cass_statement_new(insert_query.c_str(), 3)); // Determine if bound parameters can be used based on C* version - if (version.major == 1) { + if (version.major_version == 1) { insert_query = str(boost::format("INSERT INTO %s (id, num, str) VALUES(%s, %s, 'row%s')") % table_name % test_utils::Value::to_string(id) % i % i); statement = test_utils::CassStatementPtr(cass_statement_new(insert_query.c_str(), 0)); } else { diff --git a/test/integration_tests/src/test_basics.cpp b/test/integration_tests/src/test_basics.cpp index 1b956dea6..314b2f770 100644 --- a/test/integration_tests/src/test_basics.cpp +++ b/test/integration_tests/src/test_basics.cpp @@ -62,7 +62,7 @@ struct BasicTests : public test_utils::SingleSessionTest { test_utils::CassStatementPtr insert_statement(cass_statement_new(insert_query.c_str(), 2)); // Determine if bound parameters can be used based on C* version - if (version.major == 1) { + if (version.major_version == 1) { test_utils::CassPreparedPtr prepared = test_utils::prepare(session, insert_query); insert_statement = test_utils::CassStatementPtr(cass_prepared_bind(prepared.get())); } @@ -77,7 +77,7 @@ struct BasicTests : public test_utils::SingleSessionTest { test_utils::CassStatementPtr select_statement(cass_statement_new(select_query.c_str(), 1)); // Determine if bound parameters can be used based on C* version - if (version.major == 1) { + if (version.major_version == 1) { test_utils::CassPreparedPtr prepared = test_utils::prepare(session, select_query); select_statement = test_utils::CassStatementPtr(cass_prepared_bind(prepared.get())); } @@ -150,7 +150,7 @@ struct BasicTests : public test_utils::SingleSessionTest { test_utils::CassStatementPtr insert_statement(cass_statement_new(insert_query.c_str(), 3)); // Determine if bound parameters can be used based on C* version - if (version.major == 1) { + if (version.major_version == 1) { test_utils::CassPreparedPtr prepared = test_utils::prepare(session, insert_query); insert_statement = test_utils::CassStatementPtr(cass_prepared_bind(prepared.get())); } @@ -166,7 +166,7 @@ struct BasicTests : public test_utils::SingleSessionTest { test_utils::CassStatementPtr select_statement(cass_statement_new(select_query.c_str(), 1)); // Determine if bound parameters can be used based on C* version - if (version.major == 1) { + if (version.major_version == 1) { test_utils::CassPreparedPtr prepared = test_utils::prepare(session, select_query.c_str()); select_statement = test_utils::CassStatementPtr(cass_prepared_bind(prepared.get())); } @@ -246,7 +246,7 @@ struct BasicTests : public test_utils::SingleSessionTest { test_utils::CassStatementPtr insert_statement(cass_statement_new(insert_query.c_str(), 2)); // Determine if bound parameters can be used based on C* version - if (version.major == 1) { + if (version.major_version == 1) { test_utils::CassPreparedPtr prepared = test_utils::prepare(session, insert_query); insert_statement = test_utils::CassStatementPtr(cass_prepared_bind(prepared.get())); } @@ -261,7 +261,7 @@ struct BasicTests : public test_utils::SingleSessionTest { test_utils::CassStatementPtr select_statement(cass_statement_new(select_query.c_str(), 1)); // Determine if bound parameters can be used based on C* version - if (version.major == 1) { + if (version.major_version == 1) { test_utils::CassPreparedPtr prepared = test_utils::prepare(session, select_query); select_statement = test_utils::CassStatementPtr(cass_prepared_bind(prepared.get())); } @@ -332,7 +332,7 @@ BOOST_FIXTURE_TEST_SUITE(basics, BasicTests) BOOST_AUTO_TEST_CASE(basic_types) { - if ((version.major >= 2 && version.minor >= 2) || version.major >= 3) { + if ((version.major_version >= 2 && version.minor_version >= 2) || version.major_version >= 3) { insert_single_value(CASS_VALUE_TYPE_TINY_INT, 123); insert_single_value(CASS_VALUE_TYPE_SMALL_INT, 123); insert_single_value(CASS_VALUE_TYPE_DATE, test_utils::Value::min_value() + 1u); @@ -392,7 +392,7 @@ BOOST_AUTO_TEST_CASE(basic_types) BOOST_AUTO_TEST_CASE(min_max) { - if ((version.major >= 2 && version.minor >= 2) || version.major >= 3) { + if ((version.major_version >= 2 && version.minor_version >= 2) || version.major_version >= 3) { insert_min_max_value(CASS_VALUE_TYPE_TINY_INT); insert_min_max_value(CASS_VALUE_TYPE_SMALL_INT); insert_min_max_value(CASS_VALUE_TYPE_DATE); @@ -434,7 +434,7 @@ BOOST_AUTO_TEST_CASE(null) insert_null_value(CASS_VALUE_TYPE_DOUBLE); insert_null_value(CASS_VALUE_TYPE_FLOAT); insert_null_value(CASS_VALUE_TYPE_INT); - if ((version.major >= 2 && version.minor >= 2) || version.major >= 3) { + if ((version.major_version >= 2 && version.minor_version >= 2) || version.major_version >= 3) { insert_null_value(CASS_VALUE_TYPE_TINY_INT); insert_null_value(CASS_VALUE_TYPE_SMALL_INT); insert_null_value(CASS_VALUE_TYPE_DATE); @@ -493,7 +493,7 @@ BOOST_AUTO_TEST_CASE(counters) test_utils::CassStatementPtr statement(cass_statement_new(update_query.c_str(), 1)); // Determine if bound parameters can be used based on C* version - if (version.major == 1) { + if (version.major_version == 1) { update_query = str(boost::format("UPDATE %s SET incdec = incdec %s %d WHERE tweet_id = %d;") % test_utils::SIMPLE_TABLE % ((i % 2) == 0 ? "-" : "+") % i % tweet_id); statement = test_utils::CassStatementPtr(cass_statement_new(update_query.c_str(), 0)); @@ -535,7 +535,7 @@ BOOST_AUTO_TEST_CASE(rows_in_rows_out) test_utils::CassStatementPtr statement(cass_statement_new(insert_query.c_str(), 4)); // Determine if bound parameters can be used based on C* version - if (version.major == 1) { + if (version.major_version == 1) { std::string insert_query(boost::str(boost::format("INSERT INTO %s (tweet_id, t1, t2, t3) VALUES (%s, %s, %s, %s);") % test_utils::SIMPLE_TABLE % i % (i + 1) % (i + 2) % (i + 3))); statement = test_utils::CassStatementPtr(cass_statement_new(insert_query.c_str(), 0)); @@ -653,7 +653,7 @@ BOOST_AUTO_TEST_CASE(unset_parameters) test_utils::CassStatementPtr statement(cass_statement_new(insert_query.c_str(), 2)); // Determine if bound parameters can be used based on C* version - if (version.major == 1) { + if (version.major_version == 1) { test_utils::CassPreparedPtr prepared = test_utils::prepare(session, insert_query); statement = test_utils::CassStatementPtr(cass_prepared_bind(prepared.get())); } diff --git a/test/integration_tests/src/test_batch.cpp b/test/integration_tests/src/test_batch.cpp index 4f9a591c0..fb6e359b5 100644 --- a/test/integration_tests/src/test_batch.cpp +++ b/test/integration_tests/src/test_batch.cpp @@ -72,7 +72,7 @@ BOOST_AUTO_TEST_SUITE(batch) BOOST_AUTO_TEST_CASE(prepared) { CCM::CassVersion version = test_utils::get_version(); - if (version.major != 1) { + if (version.major_version != 1) { BatchTests tester; test_utils::CassBatchPtr batch(cass_batch_new(CASS_BATCH_TYPE_LOGGED)); std::string insert_query = str(boost::format("INSERT INTO %s (tweet_id, test_val) VALUES(?, ?);") % BatchTests::SIMPLE_TABLE_NAME); @@ -102,7 +102,7 @@ BOOST_AUTO_TEST_CASE(prepared) BOOST_AUTO_TEST_CASE(simple) { CCM::CassVersion version = test_utils::get_version(); - if (version.major != 1) { + if (version.major_version != 1) { BatchTests tester; test_utils::CassBatchPtr batch(cass_batch_new(CASS_BATCH_TYPE_LOGGED)); std::string insert_query = str(boost::format("INSERT INTO %s (tweet_id, test_val) VALUES(?, ?);") % BatchTests::SIMPLE_TABLE_NAME); @@ -128,7 +128,7 @@ BOOST_AUTO_TEST_CASE(simple) BOOST_AUTO_TEST_CASE(mixed) { CCM::CassVersion version = test_utils::get_version(); - if (version.major != 1) { + if (version.major_version != 1) { BatchTests tester; test_utils::CassBatchPtr batch(cass_batch_new(CASS_BATCH_TYPE_LOGGED)); std::string insert_query = str(boost::format("INSERT INTO %s (tweet_id, test_val) VALUES(?, ?);") % BatchTests::SIMPLE_TABLE_NAME); @@ -164,7 +164,7 @@ BOOST_AUTO_TEST_CASE(mixed) BOOST_AUTO_TEST_CASE(invalid_batch_type) { CCM::CassVersion version = test_utils::get_version(); - if (version.major != 1) { + if (version.major_version != 1) { BatchTests tester; test_utils::CassBatchPtr batch(cass_batch_new(CASS_BATCH_TYPE_LOGGED)); std::string update_query = str(boost::format("UPDATE %s SET test_val = test_val + ? WHERE tweet_id = ?;") % BatchTests::COUNTER_TABLE_NAME); @@ -187,7 +187,7 @@ BOOST_AUTO_TEST_CASE(invalid_batch_type) BOOST_AUTO_TEST_CASE(counter_mixed) { CCM::CassVersion version = test_utils::get_version(); - if (version.major != 1) { + if (version.major_version != 1) { BatchTests tester; test_utils::CassBatchPtr batch(cass_batch_new(CASS_BATCH_TYPE_COUNTER)); std::string update_query = str(boost::format("UPDATE %s SET test_val = test_val + ? WHERE tweet_id = ?;") % BatchTests::COUNTER_TABLE_NAME); diff --git a/test/integration_tests/src/test_by_name.cpp b/test/integration_tests/src/test_by_name.cpp index 9389a51db..9090dcd7c 100644 --- a/test/integration_tests/src/test_by_name.cpp +++ b/test/integration_tests/src/test_by_name.cpp @@ -226,7 +226,7 @@ BOOST_AUTO_TEST_CASE(get_invalid_name) test_utils::CassStatementPtr statement(cass_statement_new(insert_query.c_str(), 2)); // Determine if bound parameters can be used based on C* version - if (version.major == 1) { + if (version.major_version == 1) { test_utils::CassPreparedPtr prepared = test_utils::prepare(session, insert_query.c_str()); statement = test_utils::CassStatementPtr(cass_prepared_bind(prepared.get())); } diff --git a/test/integration_tests/src/test_collections.cpp b/test/integration_tests/src/test_collections.cpp index 7689ed5f5..4d24dcc68 100644 --- a/test/integration_tests/src/test_collections.cpp +++ b/test/integration_tests/src/test_collections.cpp @@ -48,7 +48,7 @@ struct CollectionsTests : public test_utils::MultipleNodesTest { test_utils::CassStatementPtr statement(cass_statement_new(query.c_str(), 1)); // Determine if bound parameters can be used based on C* version - if (version.major == 1) { + if (version.major_version == 1) { test_utils::CassPreparedPtr prepared = test_utils::prepare(session, query.c_str()); statement = test_utils::CassStatementPtr(cass_prepared_bind(prepared.get())); } @@ -100,7 +100,7 @@ struct CollectionsTests : public test_utils::MultipleNodesTest { test_utils::execute_query(session.get(), str(boost::format("USE %s") % test_utils::SIMPLE_KEYSPACE)); - if ((version.major >= 2 && version.minor >= 2) || version.major >= 3) { + if ((version.major_version >= 2 && version.minor_version >= 2) || version.major_version >= 3) { { std::vector values; for (cass_int8_t i = 1; i <= 3; ++i) values.push_back(i); @@ -218,7 +218,7 @@ struct CollectionsTests : public test_utils::MultipleNodesTest { test_utils::CassStatementPtr statement(cass_statement_new(query.c_str(), 1)); // Determine if bound parameters can be used based on C* version - if (version.major == 1) { + if (version.major_version == 1) { test_utils::CassPreparedPtr prepared = test_utils::prepare(session, query.c_str()); statement = test_utils::CassStatementPtr(cass_prepared_bind(prepared.get())); } @@ -269,7 +269,7 @@ struct CollectionsTests : public test_utils::MultipleNodesTest { test_utils::execute_query(session.get(), str(boost::format("USE %s") % test_utils::SIMPLE_KEYSPACE)); - if ((version.major >= 2 && version.minor >= 2) || version.major >= 3) { + if ((version.major_version >= 2 && version.minor_version >= 2) || version.major_version >= 3) { { std::map values; values[1] = 2; diff --git a/test/integration_tests/src/test_custom_payload.cpp b/test/integration_tests/src/test_custom_payload.cpp index a73e6142a..28b6036c7 100644 --- a/test/integration_tests/src/test_custom_payload.cpp +++ b/test/integration_tests/src/test_custom_payload.cpp @@ -29,7 +29,7 @@ BOOST_AUTO_TEST_SUITE(custom_payload) BOOST_AUTO_TEST_CASE(simple) { CCM::CassVersion version = test_utils::get_version(); - if ((version.major >= 2 && version.minor >= 2) || version.major >= 3) { + if ((version.major_version >= 2 && version.minor_version >= 2) || version.major_version >= 3) { boost::shared_ptr ccm(new CCM::Bridge("config.txt")); if (ccm->create_cluster()) { // Ensure the cluster is down before updating JVM argument diff --git a/test/integration_tests/src/test_datatypes.cpp b/test/integration_tests/src/test_datatypes.cpp index 87e16aaac..a723bbbac 100644 --- a/test/integration_tests/src/test_datatypes.cpp +++ b/test/integration_tests/src/test_datatypes.cpp @@ -50,7 +50,7 @@ struct DataTypesTests : public test_utils::SingleSessionTest { std::string insert_query = "INSERT INTO " + table_name + "(key, value) VALUES(? , ?)"; test_utils::CassStatementPtr statement(cass_statement_new(insert_query.c_str(), 2)); // Determine if bound parameters can be used based on C* version - if (version.major == 1) { + if (version.major_version == 1) { test_utils::CassPreparedPtr prepared = test_utils::prepare(session, insert_query); statement = test_utils::CassStatementPtr(cass_prepared_bind(prepared.get())); } @@ -146,7 +146,7 @@ BOOST_AUTO_TEST_CASE(read_write_primitives) { insert_value(CASS_VALUE_TYPE_DOUBLE, 3.141592653589793); insert_value(CASS_VALUE_TYPE_FLOAT, 3.1415926f); insert_value(CASS_VALUE_TYPE_INT, 123); - if ((version.major >= 2 && version.minor >= 2) || version.major >= 3) { + if ((version.major_version >= 2 && version.minor_version >= 2) || version.major_version >= 3) { insert_value(CASS_VALUE_TYPE_SMALL_INT, 123); insert_value(CASS_VALUE_TYPE_TINY_INT, 123); insert_value(CASS_VALUE_TYPE_DATE, test_utils::Value::min_value() + 1u); diff --git a/test/integration_tests/src/test_metrics.cpp b/test/integration_tests/src/test_metrics.cpp index 8886d735f..ee2514add 100644 --- a/test/integration_tests/src/test_metrics.cpp +++ b/test/integration_tests/src/test_metrics.cpp @@ -176,7 +176,7 @@ BOOST_AUTO_TEST_CASE(timeouts) { * Check for pending request timeouts */ CCM::CassVersion version = test_utils::get_version(); - if ((version.major <= 2 && version.minor < 1) || version.major < 2) { + if ((version.major_version <= 2 && version.minor_version < 1) || version.major_version < 2) { // Limit the connections to one cass_cluster_set_core_connections_per_host(cluster_.get(), 1); cass_cluster_set_max_connections_per_host(cluster_.get(), 1); diff --git a/test/integration_tests/src/test_named_parameters.cpp b/test/integration_tests/src/test_named_parameters.cpp index 60c3a448e..de65cf904 100644 --- a/test/integration_tests/src/test_named_parameters.cpp +++ b/test/integration_tests/src/test_named_parameters.cpp @@ -165,7 +165,7 @@ BOOST_AUTO_TEST_SUITE(named_parameters) */ BOOST_AUTO_TEST_CASE(ordered_unordered_read_write) { CCM::CassVersion version = test_utils::get_version(); - if ((version.major >= 2 && version.minor >= 1) || version.major >= 3) { + if ((version.major_version >= 2 && version.minor_version >= 1) || version.major_version >= 3) { NamedParametersTests tester; std::string create_table = "CREATE TABLE ordered_unordered_read_write(key int PRIMARY KEY, value_text text, value_uuid uuid, value_blob blob, value_list_floats list)"; std::string insert_query = "INSERT INTO ordered_unordered_read_write(key, value_text, value_uuid, value_blob, value_list_floats) VALUES (:key, :one_text, :two_uuid, :three_blob, :four_list_floats)"; @@ -316,7 +316,7 @@ BOOST_AUTO_TEST_CASE(ordered_unordered_read_write) { */ BOOST_AUTO_TEST_CASE(all_primitives) { CCM::CassVersion version = test_utils::get_version(); - if ((version.major >= 2 && version.minor >= 1) || version.major >= 3) { + if ((version.major_version >= 2 && version.minor_version >= 1) || version.major_version >= 3) { NamedParametersTests tester; for (unsigned int i = 0; i < 2; ++i) { bool is_prepared = i == 0 ? false : true; @@ -353,7 +353,7 @@ BOOST_AUTO_TEST_CASE(all_primitives) { tester.insert_primitive_value(CASS_VALUE_TYPE_DOUBLE, 3.141592653589793, is_prepared); tester.insert_primitive_value(CASS_VALUE_TYPE_FLOAT, 3.1415926f, is_prepared); tester.insert_primitive_value(CASS_VALUE_TYPE_INT, 123, is_prepared); - if ((version.major >= 2 && version.minor >= 2) || version.major >= 3) { + if ((version.major_version >= 2 && version.minor_version >= 2) || version.major_version >= 3) { tester.insert_primitive_value(CASS_VALUE_TYPE_SMALL_INT, 123, is_prepared); tester.insert_primitive_value(CASS_VALUE_TYPE_TINY_INT, 123, is_prepared); } @@ -392,7 +392,7 @@ BOOST_AUTO_TEST_CASE(all_primitives) { */ BOOST_AUTO_TEST_CASE(all_primitives_batched) { CCM::CassVersion version = test_utils::get_version(); - if ((version.major >= 2 && version.minor >= 1) || version.major >= 3) { + if ((version.major_version >= 2 && version.minor_version >= 1) || version.major_version >= 3) { NamedParametersTests tester; { @@ -427,7 +427,7 @@ BOOST_AUTO_TEST_CASE(all_primitives_batched) { tester.insert_primitive_batch_value(CASS_VALUE_TYPE_DOUBLE, 3.141592653589793, TOTAL_NUMBER_OF_BATCHES); tester.insert_primitive_batch_value(CASS_VALUE_TYPE_FLOAT, 3.1415926f, TOTAL_NUMBER_OF_BATCHES); tester.insert_primitive_batch_value(CASS_VALUE_TYPE_INT, 123, TOTAL_NUMBER_OF_BATCHES); - if ((version.major >= 2 && version.minor >= 2) || version.major >= 3) { + if ((version.major_version >= 2 && version.minor_version >= 2) || version.major_version >= 3) { tester.insert_primitive_batch_value(CASS_VALUE_TYPE_SMALL_INT, 123, TOTAL_NUMBER_OF_BATCHES); tester.insert_primitive_batch_value(CASS_VALUE_TYPE_TINY_INT, 123, TOTAL_NUMBER_OF_BATCHES); } @@ -465,7 +465,7 @@ BOOST_AUTO_TEST_CASE(all_primitives_batched) { */ BOOST_AUTO_TEST_CASE(invalid_name) { CCM::CassVersion version = test_utils::get_version(); - if ((version.major >= 2 && version.minor >= 1) || version.major >= 3) { + if ((version.major_version >= 2 && version.minor_version >= 1) || version.major_version >= 3) { NamedParametersTests tester; std::string create_table = "CREATE TABLE named_parameter_invalid(key int PRIMARY KEY, value text)"; std::string insert_query = "INSERT INTO named_parameter_invalid(key, value) VALUES (:key_name, :value_name)"; diff --git a/test/integration_tests/src/test_outage.cpp b/test/integration_tests/src/test_outage.cpp index 14554e572..3e1aa9508 100644 --- a/test/integration_tests/src/test_outage.cpp +++ b/test/integration_tests/src/test_outage.cpp @@ -177,7 +177,7 @@ struct OutageTests : public test_utils::MultipleNodesTest { test_utils::CassStatementPtr statement(cass_statement_new(query.c_str(), 3)); // Determine if bound parameters can be used based on C* version - if (version.major == 1) { + if (version.major_version == 1) { test_utils::CassPreparedPtr prepared = test_utils::prepare(session, query.c_str()); statement = test_utils::CassStatementPtr(cass_prepared_bind(prepared.get())); } diff --git a/test/integration_tests/src/test_paging.cpp b/test/integration_tests/src/test_paging.cpp index 093660a5c..6da2b07db 100644 --- a/test/integration_tests/src/test_paging.cpp +++ b/test/integration_tests/src/test_paging.cpp @@ -47,7 +47,7 @@ struct PagingTests : public test_utils::SingleSessionTest { test_utils::CassStatementPtr statement(cass_statement_new(insert_query.c_str(), 3)); // Determine if bound parameters can be used based on C* version - if (version.major == 1) { + if (version.major_version == 1) { test_utils::CassPreparedPtr prepared = test_utils::prepare(session, insert_query.c_str()); statement = test_utils::CassStatementPtr(cass_prepared_bind(prepared.get())); } diff --git a/test/integration_tests/src/test_pool.cpp b/test/integration_tests/src/test_pool.cpp index 75426c195..f7afb1f62 100644 --- a/test/integration_tests/src/test_pool.cpp +++ b/test/integration_tests/src/test_pool.cpp @@ -54,7 +54,7 @@ BOOST_AUTO_TEST_CASE(no_hosts_backpressure) { // Limit backpressure test to lower version of C* (difficult to produce in later versions deterministically) CCM::CassVersion version = test_utils::get_version(); - if ((version.major <= 2 && version.minor < 1) || version.major < 2) { + if ((version.major_version <= 2 && version.minor_version < 1) || version.major_version < 2) { TestPool tester; cass_cluster_set_num_threads_io(tester.cluster, 1); reinterpret_cast(tester.cluster)->config().set_core_connections_per_host(0);// bypassing API param check @@ -192,7 +192,7 @@ static void connection_interruptions(void *data) { BOOST_AUTO_TEST_CASE(dont_recycle_pool_on_timeout) { // Limit backpressure test to lower version of C* (difficult to produce in later versions deterministically) CCM::CassVersion version = test_utils::get_version(); - if ((version.major <= 2 && version.minor < 1) || version.major < 2) { + if ((version.major_version <= 2 && version.minor_version < 1) || version.major_version < 2) { TestPool tester; // Add a second node diff --git a/test/integration_tests/src/test_prepared.cpp b/test/integration_tests/src/test_prepared.cpp index d329cab7b..9ad5abe50 100644 --- a/test/integration_tests/src/test_prepared.cpp +++ b/test/integration_tests/src/test_prepared.cpp @@ -110,7 +110,7 @@ struct PreparedTests : public test_utils::SingleSessionTest { test_utils::execute_query(session, str(boost::format(test_utils::CREATE_KEYSPACE_SIMPLE_FORMAT) % test_utils::SIMPLE_KEYSPACE % "1")); test_utils::execute_query(session, str(boost::format("USE %s") % test_utils::SIMPLE_KEYSPACE)); - if ((version.major >= 2 && version.minor >= 2) || version.major >= 3) { + if ((version.major_version >= 2 && version.minor_version >= 2) || version.major_version >= 3) { test_utils::execute_query(session, str(boost::format(test_utils::CREATE_TABLE_ALL_TYPES_V4) % ALL_TYPE_TABLE_NAME)); column_size_ = 15; } else { @@ -121,7 +121,7 @@ struct PreparedTests : public test_utils::SingleSessionTest { columns_ = "id, text_sample, int_sample, bigint_sample, float_sample, double_sample, decimal_sample, " "blob_sample, boolean_sample, timestamp_sample, inet_sample"; values_ = "?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?"; - if ((version.major >= 2 && version.minor >= 2) || version.major >= 3) { + if ((version.major_version >= 2 && version.minor_version >= 2) || version.major_version >= 3) { columns_ += ", tinyint_sample, smallint_sample, date_sample, time_sample"; values_ += ", ?, ?, ?, ?"; } @@ -152,7 +152,7 @@ struct PreparedTests : public test_utils::SingleSessionTest { cass_statement_bind_bool(statement.get(), 8, all_types.boolean_sample); cass_statement_bind_int64(statement.get(), 9, all_types.timestamp_sample); cass_statement_bind_inet(statement.get(), 10, all_types.inet_sample); - if ((version.major >= 2 && version.minor >= 2) || version.major >= 3) { + if ((version.major_version >= 2 && version.minor_version >= 2) || version.major_version >= 3) { cass_statement_bind_int8(statement.get(), 11, all_types.tinyint_sample); cass_statement_bind_int16(statement.get(), 12, all_types.smallint_sample); cass_statement_bind_uint32(statement.get(), 13, all_types.date_sample.date); @@ -199,7 +199,7 @@ struct PreparedTests : public test_utils::SingleSessionTest { BOOST_REQUIRE(cass_value_get_inet(cass_row_get_column(row, 10), &output.inet_sample) == CASS_OK); BOOST_REQUIRE(test_utils::Value::equal(input.inet_sample, output.inet_sample)); - if ((version.major >= 2 && version.minor >= 2) || version.major >= 3) { + if ((version.major_version >= 2 && version.minor_version >= 2) || version.major_version >= 3) { BOOST_REQUIRE(cass_value_get_int8(cass_row_get_column(row, 11), &output.tinyint_sample) == CASS_OK); BOOST_REQUIRE(test_utils::Value::equal(input.tinyint_sample, output.tinyint_sample)); @@ -255,7 +255,7 @@ BOOST_AUTO_TEST_CASE(bound_all_types_different_values) all_types[0].boolean_sample = cass_true; all_types[0].timestamp_sample = 1123200000; all_types[0].inet_sample = cass_inet_init_v4(address1); - if ((version.major >= 2 && version.minor >= 2) || version.major >= 3) { + if ((version.major_version >= 2 && version.minor_version >= 2) || version.major_version >= 3) { all_types[0].tinyint_sample = 37; all_types[0].smallint_sample = 456; all_types[0].date_sample = test_utils::Value::max_value(); @@ -273,7 +273,7 @@ BOOST_AUTO_TEST_CASE(bound_all_types_different_values) all_types[1].boolean_sample = cass_false; all_types[1].timestamp_sample = 0; all_types[1].inet_sample = cass_inet_init_v4(address2); - if ((version.major >= 2 && version.minor >= 2) || version.major >= 3) { + if ((version.major_version >= 2 && version.minor_version >= 2) || version.major_version >= 3) { all_types[1].tinyint_sample = 0; all_types[1].smallint_sample = 0; all_types[1].date_sample = 0; @@ -291,7 +291,7 @@ BOOST_AUTO_TEST_CASE(bound_all_types_different_values) all_types[2].boolean_sample = cass_true; all_types[2].timestamp_sample = -13462502400; all_types[2].inet_sample = cass_inet_init_v4(address3); - if ((version.major >= 2 && version.minor >= 2) || version.major >= 3) { + if ((version.major_version >= 2 && version.minor_version >= 2) || version.major_version >= 3) { all_types[2].tinyint_sample = 127; all_types[2].smallint_sample = 32767; all_types[2].date_sample = test_utils::Value::min_value(); diff --git a/test/integration_tests/src/test_serial_consistency.cpp b/test/integration_tests/src/test_serial_consistency.cpp index d2e97f1a1..49b4e789e 100644 --- a/test/integration_tests/src/test_serial_consistency.cpp +++ b/test/integration_tests/src/test_serial_consistency.cpp @@ -57,7 +57,7 @@ BOOST_AUTO_TEST_SUITE(serial_consistency) BOOST_AUTO_TEST_CASE(simple) { CCM::CassVersion version = test_utils::get_version(); - if (version.major != 1) { + if (version.major_version != 1) { SerialConsistencyTests tester; for (int i = 0; i < 2; ++i) { test_utils::CassFuturePtr future = tester.insert_row("abc", 99, CASS_CONSISTENCY_SERIAL); @@ -78,7 +78,7 @@ BOOST_AUTO_TEST_CASE(simple) BOOST_AUTO_TEST_CASE(invalid) { CCM::CassVersion version = test_utils::get_version(); - if (version.major != 1) { + if (version.major_version != 1) { SerialConsistencyTests tester; test_utils::CassFuturePtr future = tester.insert_row("abc", 99, CASS_CONSISTENCY_ONE); // Invalid diff --git a/test/integration_tests/src/test_server_failures.cpp b/test/integration_tests/src/test_server_failures.cpp index fccd1897a..a67437717 100644 --- a/test/integration_tests/src/test_server_failures.cpp +++ b/test/integration_tests/src/test_server_failures.cpp @@ -51,7 +51,7 @@ BOOST_AUTO_TEST_SUITE(server_failures) */ BOOST_AUTO_TEST_CASE(function_failure) { CCM::CassVersion version = test_utils::get_version(); - if ((version.major >= 2 && version.minor >= 2) || version.major >= 3) { + if ((version.major_version >= 2 && version.minor_version >= 2) || version.major_version >= 3) { ServerFailuresTest tester; std::string create_table = "CREATE TABLE server_function_failures (id int PRIMARY KEY, value double)"; std::string insert_query = "INSERT INTO server_function_failures(id, value) VALUES (?, ?)"; @@ -93,7 +93,7 @@ BOOST_AUTO_TEST_SUITE(server_failures) */ BOOST_AUTO_TEST_CASE(already_exists) { CCM::CassVersion version = test_utils::get_version(); - if ((version.major >= 2 && version.minor >= 2) || version.major >= 3) { + if ((version.major_version >= 2 && version.minor_version >= 2) || version.major_version >= 3) { ServerFailuresTest tester; std::string create_table = "CREATE TABLE already_exists_table (id int PRIMARY KEY, value double)"; std::string create_keyspace = str(boost::format(test_utils::CREATE_KEYSPACE_SIMPLE_FORMAT) % test_utils::SIMPLE_KEYSPACE % "1"); diff --git a/test/integration_tests/src/test_stress.cpp b/test/integration_tests/src/test_stress.cpp index 6f5090e2a..7ee05f98d 100644 --- a/test/integration_tests/src/test_stress.cpp +++ b/test/integration_tests/src/test_stress.cpp @@ -98,7 +98,7 @@ struct StressTests : public test_utils::MultipleNodesTest { bool insert_task(const std::string& query, CassConsistency consistency, int rows_per_id) { bool is_successful = true; for (int i = 0; i < rows_per_id; ++i) { - if (version.major == 1) { + if (version.major_version == 1) { if (!create_and_execute_insert(query, consistency)) { is_successful = false; } diff --git a/test/integration_tests/src/test_timestamps.cpp b/test/integration_tests/src/test_timestamps.cpp index 1ae77d37d..0ef0c7b58 100644 --- a/test/integration_tests/src/test_timestamps.cpp +++ b/test/integration_tests/src/test_timestamps.cpp @@ -89,7 +89,7 @@ BOOST_AUTO_TEST_SUITE(timestamps) BOOST_AUTO_TEST_CASE(statement_and_batch) { CCM::CassVersion version = test_utils::get_version(); - if ((version.major >= 2 && version.minor >= 1) || version.major >= 3) { + if ((version.major_version >= 2 && version.minor_version >= 1) || version.major_version >= 3) { TimestampsTest tester; std::string table_name("table_" + test_utils::generate_unique_str(tester.uuid_gen)); std::string create_table = "CREATE TABLE " + table_name + "(key text PRIMARY KEY, value text)"; @@ -156,7 +156,7 @@ BOOST_AUTO_TEST_CASE(statement_and_batch) BOOST_AUTO_TEST_CASE(generator) { CCM::CassVersion version = test_utils::get_version(); - if ((version.major >= 2 && version.minor >= 1) || version.major >= 3) { + if ((version.major_version >= 2 && version.minor_version >= 1) || version.major_version >= 3) { TimestampsTest tester; cass::SharedRefPtr gen(new TestTimestampGenerator(1234)); @@ -229,7 +229,7 @@ BOOST_AUTO_TEST_CASE(generator) BOOST_AUTO_TEST_CASE(server_side) { CCM::CassVersion version = test_utils::get_version(); - if ((version.major >= 2 && version.minor >= 1) || version.major >= 3) { + if ((version.major_version >= 2 && version.minor_version >= 1) || version.major_version >= 3) { TimestampsTest tester; // Server-side is the default timestamp generator std::string table_name("table_" + test_utils::generate_unique_str(tester.uuid_gen)); diff --git a/test/integration_tests/src/test_tuples.cpp b/test/integration_tests/src/test_tuples.cpp index 480009343..d0c83ab88 100644 --- a/test/integration_tests/src/test_tuples.cpp +++ b/test/integration_tests/src/test_tuples.cpp @@ -321,7 +321,7 @@ BOOST_AUTO_TEST_SUITE(tuples) */ BOOST_AUTO_TEST_CASE(read_write) { CCM::CassVersion version = test_utils::get_version(); - if ((version.major >= 2 && version.minor >= 1) || version.major >= 3) { + if ((version.major_version >= 2 && version.minor_version >= 1) || version.major_version >= 3) { TupleTests tester; std::string create_table = "CREATE TABLE tuple_read_write(key int PRIMARY KEY, value frozen>)"; std::string insert_query = "INSERT INTO tuple_read_write(key, value) VALUES (?, ?)"; @@ -445,7 +445,7 @@ BOOST_AUTO_TEST_CASE(read_write) { */ BOOST_AUTO_TEST_CASE(varying_size) { CCM::CassVersion version = test_utils::get_version(); - if ((version.major >= 2 && version.minor >= 1) || version.major >= 3) { + if ((version.major_version >= 2 && version.minor_version >= 1) || version.major_version >= 3) { TupleTests tester; // Create some varying size tuple tests (primitives) @@ -486,7 +486,7 @@ BOOST_AUTO_TEST_CASE(varying_size) { tester.insert_varying_sized_value(CASS_VALUE_TYPE_DOUBLE, 3.141592653589793, size, nested_collection_type); tester.insert_varying_sized_value(CASS_VALUE_TYPE_FLOAT, 3.1415926f, size, nested_collection_type); tester.insert_varying_sized_value(CASS_VALUE_TYPE_INT, 123, size, nested_collection_type); - if ((version.major >= 2 && version.minor >= 2) || version.major >= 3) { + if ((version.major_version >= 2 && version.minor_version >= 2) || version.major_version >= 3) { tester.insert_varying_sized_value(CASS_VALUE_TYPE_SMALL_INT, 123, size, nested_collection_type); tester.insert_varying_sized_value(CASS_VALUE_TYPE_TINY_INT, 123, size, nested_collection_type); tester.insert_varying_sized_value(CASS_VALUE_TYPE_DATE, @@ -531,7 +531,7 @@ BOOST_AUTO_TEST_CASE(varying_size) { */ BOOST_AUTO_TEST_CASE(null) { CCM::CassVersion version = test_utils::get_version(); - if ((version.major >= 2 && version.minor >= 1) || version.major >= 3) { + if ((version.major_version >= 2 && version.minor_version >= 1) || version.major_version >= 3) { TupleTests tester; // Create some varying size null tuple tests @@ -553,7 +553,7 @@ BOOST_AUTO_TEST_CASE(null) { tester.insert_varying_sized_null_value(CASS_VALUE_TYPE_UUID, size, nested_collection_type); tester.insert_varying_sized_null_value(CASS_VALUE_TYPE_INET, size, nested_collection_type); tester.insert_varying_sized_null_value(CASS_VALUE_TYPE_TIMEUUID, size, nested_collection_type); - if ((version.major >= 2 && version.minor >= 2) || version.major >= 3) { + if ((version.major_version >= 2 && version.minor_version >= 2) || version.major_version >= 3) { tester.insert_varying_sized_null_value(CASS_VALUE_TYPE_TINY_INT, size, nested_collection_type); tester.insert_varying_sized_null_value(CASS_VALUE_TYPE_SMALL_INT, size, nested_collection_type); tester.insert_varying_sized_null_value(CASS_VALUE_TYPE_DATE, size, nested_collection_type); @@ -579,7 +579,7 @@ BOOST_AUTO_TEST_CASE(null) { */ BOOST_AUTO_TEST_CASE(invalid) { CCM::CassVersion version = test_utils::get_version(); - if ((version.major >= 2 && version.minor >= 1) || version.major >= 3) { + if ((version.major_version >= 2 && version.minor_version >= 1) || version.major_version >= 3) { TupleTests tester; std::string create_table = "CREATE TABLE tuple_invalid(key int PRIMARY KEY, value frozen>)"; std::string insert_query = "INSERT INTO tuple_invalid(key, value) VALUES (?, ?)"; diff --git a/test/integration_tests/src/test_udts.cpp b/test/integration_tests/src/test_udts.cpp index ffb0fe335..ad3282644 100644 --- a/test/integration_tests/src/test_udts.cpp +++ b/test/integration_tests/src/test_udts.cpp @@ -265,7 +265,7 @@ BOOST_AUTO_TEST_SUITE(udts) */ BOOST_AUTO_TEST_CASE(read_write) { CCM::CassVersion version = test_utils::get_version(); - if ((version.major >= 2 && version.minor >= 1) || version.major >= 3) { + if ((version.major_version >= 2 && version.minor_version >= 1) || version.major_version >= 3) { UDTTests tester; std::string create_table = "CREATE TABLE user (id uuid PRIMARY KEY, addr frozen
)"; std::string insert_query = "INSERT INTO user(id, addr) VALUES (?, ?)"; @@ -384,7 +384,7 @@ BOOST_AUTO_TEST_CASE(read_write) { */ BOOST_AUTO_TEST_CASE(invalid) { CCM::CassVersion version = test_utils::get_version(); - if ((version.major >= 2 && version.minor >= 1) || version.major >= 3) { + if ((version.major_version >= 2 && version.minor_version >= 1) || version.major_version >= 3) { UDTTests tester; std::string invalid_udt_missing_frozen_keyword = "CREATE TYPE invalid_udt (id uuid, address address)"; std::string invalid_parent_udt = "CREATE TYPE invalid_udt (address frozen
)"; @@ -392,7 +392,7 @@ BOOST_AUTO_TEST_CASE(invalid) { std::string insert_query = "INSERT INTO invalid_udt_user(id, invalid) VALUES (?, ?)"; { - if (version.major < 3) { + if (version.major_version < 3) { // Ensure UDT cannot be created when missing frozen keyword BOOST_REQUIRE_EQUAL(test_utils::execute_query_with_error(tester.session, invalid_udt_missing_frozen_keyword.c_str()), CASS_ERROR_SERVER_INVALID_QUERY); } @@ -441,7 +441,7 @@ BOOST_AUTO_TEST_CASE(invalid) { */ BOOST_AUTO_TEST_CASE(text_types) { CCM::CassVersion version = test_utils::get_version(); - if ((version.major >= 2 && version.minor >= 1) || version.major >= 3) { + if ((version.major_version >= 2 && version.minor_version >= 1) || version.major_version >= 3) { UDTTests tester; std::string nested_type = "CREATE TYPE nested_type (value_1 int, value_2 int)"; std::string parent_type = "CREATE TYPE parent_type (name text, values frozen)"; diff --git a/test/integration_tests/src/test_version1.cpp b/test/integration_tests/src/test_version1.cpp index 198e0af7f..14a0d313b 100644 --- a/test/integration_tests/src/test_version1.cpp +++ b/test/integration_tests/src/test_version1.cpp @@ -197,7 +197,7 @@ BOOST_AUTO_TEST_CASE(query_param_error) CassString message; cass_future_error_message(future.get(), &message.data, &message.length); BOOST_REQUIRE(code == CASS_ERROR_SERVER_INVALID_QUERY); - if (version.major == 1) { + if (version.major_version == 1) { BOOST_REQUIRE(std::string(message.data, message.length).find("Cannot execute query with bind variables") != std::string::npos); } else { BOOST_REQUIRE(std::string(message.data, message.length).find("Invalid amount of bind variables") != std::string::npos); diff --git a/test/integration_tests/src/test_warnings.cpp b/test/integration_tests/src/test_warnings.cpp index b555f230b..015c327a8 100644 --- a/test/integration_tests/src/test_warnings.cpp +++ b/test/integration_tests/src/test_warnings.cpp @@ -29,7 +29,7 @@ BOOST_AUTO_TEST_SUITE(warnings) BOOST_AUTO_TEST_CASE(aggregate_without_partition_key) { CCM::CassVersion version = test_utils::get_version(); - if ((version.major >= 2 && version.minor >= 2) || version.major >= 3) { + if ((version.major_version >= 2 && version.minor_version >= 2) || version.major_version >= 3) { WarningsTests tester; test_utils::CassStatementPtr statement(cass_statement_new("SELECT sum(gossip_generation) FROM system.local", 0)); test_utils::CassLog::reset("Server-side warning: Aggregation query used without partition key"); diff --git a/topics/building/README.md b/topics/building/README.md index 2d86a2ced..50e317609 100644 --- a/topics/building/README.md +++ b/topics/building/README.md @@ -22,7 +22,7 @@ dependencies being installed. ### Test Dependencies - [boost 1.55+](http://www.boost.org) -- [libssh2](http://www.libssh2.org) +- [libssh2](http://www.libssh2.org) (optional) ## Linux/OS X The driver has been built using both Clang (Ubuntu 12.04/14.04 and OS X) and GCC @@ -211,11 +211,11 @@ Usage: VC_BUILD.BAT [OPTION...] --DEBUG Enable debug build --RELEASE Enable release build (default) --DISABLE-CLEAN Disable clean build + --DEPENDENCIES-ONLY Build dependencies only --TARGET-COMPILER [version] 140, 120, 110, 100, or WINSDK --DISABLE-OPENSSL Disable OpenSSL support --ENABLE-EXAMPLES Enable example builds --ENABLE-PACKAGES [version] Enable package generation (*) - --ENABLE-TESTS [boost-root-dir] Enable test builds --ENABLE-ZLIB Enable zlib --GENERATE-SOLUTION Generate Visual Studio solution (**) --INSTALL-DIR [install-dir] Override installation directory @@ -225,6 +225,16 @@ Usage: VC_BUILD.BAT [OPTION...] --X64 Target 64-bit build (***) --USE-BOOST-ATOMIC Use Boost atomic + Testing Arguments + + --ENABLE-TESTS + [boost-root-dir] Enable test builds + --ENABLE-INTEGRATION-TESTS + [boost-root-dir] Enable integration tests build + --ENABLE-UNIT-TESTS + [boost-root-dir] Enable unit tests build + --ENABLE-LIBSSH2 Enable libssh2 (remote server testing) + --HELP Display this message * Packages are only generated using detected installations of Visual Studio @@ -309,9 +319,6 @@ obtained and select from the following list: - Visual Studio 2015 (Windows SDK 10.0) - Boost v1.59 [32-bit](http://sourceforge.net/projects/boost/files/boost-binaries/1.59.0/boost_1_59_0-msvc-14.0-32.exe/download)/[64-bit](http://sourceforge.net/projects/boost/files/boost-binaries/1.59.0/boost_1_59_0-msvc-14.0-64.exe/download) -**NOTE:** Ensure the Boost library directory structure is configured correctly -by renaming the library directory to _lib_ (e.g. lib64-msvc-14.0 to lib). - #### Building the Driver with the Tests ```dos diff --git a/vc_build.bat b/vc_build.bat index a6d6f010b..4bb349988 100644 --- a/vc_build.bat +++ b/vc_build.bat @@ -1,5 +1,5 @@ @ECHO OFF -REM Copyright 2014-2015 DataStax +REM Copyright 2014-2016 DataStax REM REM Licensed under the Apache License, Version 2.0 (the "License"); REM you may not use this file except in compliance with the License. @@ -40,6 +40,9 @@ SET ARGUMENT_DISABLE_OPENSSL=--DISABLE-OPENSSL SET ARGUMENT_ENABLE_EXAMPLES=--ENABLE-EXAMPLES SET ARGUMENT_ENABLE_BUILD_PACKAGES=--ENABLE-PACKAGES SET ARGUMENT_ENABLE_TESTS=--ENABLE-TESTS +SET ARGUMENT_ENABLE_INTEGRATION_TESTS=--ENABLE-INTEGRATION-TESTS +SET ARGUMENT_ENABLE_UNIT_TESTS=--ENABLE-UNIT-TESTS +SET ARGUMENT_ENABLE_LIBSSH2=--ENABLE-LIBSSH2 SET ARGUMENT_ENABLE_ZLIB=--ENABLE-ZLIB SET ARGUMENT_GENERATE_SOLUTION=--GENERATE-SOLUTION SET ARGUMENT_INSTALLATION_DIRECTORY=--INSTALL-DIR @@ -111,7 +114,8 @@ SET LIBUV_PACKAGE_VERSION=1.8.0 SET GYP_REPOSITORY_URL=https://chromium.googlesource.com/external/gyp.git SET LIBSSH2_REPOSITORY_URL=https://github.com/libssh2/libssh2.git SET LIBSSH2_DIRECTORY=libssh2 -SET LIBSSH2_BRANCH_TAG_VERSION=master +SET LIBSSH2_BRANCH_TAG_VERSION=libssh2-1.7.0 +SET LIBSSH2_PACKAGE_VERSION=1.7.0 SET OPENSSL_REPOSITORY_URL=https://github.com/openssl/openssl.git SET OPENSSL_DIRECTORY=openssl SET OPENSSL_BRANCH_TAG_VERSION=OpenSSL_1_0_2f @@ -148,14 +152,18 @@ SET BUILD_DEPENDENCIES_ONLY=%FALSE% SET ENABLE_BUILD_PACKAGES=%FALSE% SET ENABLE_CLEAN_BUILD=%TRUE% SET ENABLE_EXAMPLES=%FALSE% -SET ENABLE_LIBSSH2=%FALSE% SET ENABLE_OPENSSL=%TRUE% SET ENABLE_TESTS=%FALSE% +SET ENABLE_INTEGRATION_TESTS=%FALSE% +SET ENABLE_UNIT_TESTS=%FALSE% +SET ENABLE_LIBSSH2=%FALSE% SET ENABLE_ZLIB=%FALSE% SET GENERATE_SOLUTION=%FALSE% SET LIBRARY_TYPE=%LIBRARY_TYPE_SHARED% SET TARGET_ARCHITECTURE=%SYSTEM_ARCHITECTURE% SET USE_BOOST_ATOMIC=%FALSE% +SET ARGUMENT_IS_TEST=%FALSE% +SET IS_TESTING_ENABLED=%FALSE% REM Parse command line arguments :ARGUMENT_LOOP @@ -240,25 +248,52 @@ IF NOT [%1] == [] ( ) ) - REM Enable build of tests + REM Enable testing (enable test type (all, integration, or unit) IF "!ARGUMENT!" == "!ARGUMENT_ENABLE_TESTS!" ( + SET ARGUMENT_IS_TEST=!TRUE! SET ENABLE_TESTS=!TRUE! + ) + IF "!ARGUMENT!" == "!ARGUMENT_ENABLE_INTEGRATION_TESTS!" ( + SET ARGUMENT_IS_TEST=!TRUE! + SET ENABLE_INTEGRATION_TESTS=!TRUE! + ) + IF "!ARGUMENT!" == "!ARGUMENT_ENABLE_UNIT_TESTS!" ( + SET ARGUMENT_IS_TEST=!TRUE! + SET ENABLE_UNIT_TESTS=!TRUE! + ) + IF !ARGUMENT_IS_TEST! EQU == !TRUE! ( + REM Ensure testing type hasn't been previously established + IF !IS_TESTING_ENABLED! EQU !FALSE! ( + REM Indicate testing is enabled + SET IS_TESTING_ENABLED=!TRUE! - REM Make sure the Boost root directory exists - IF [%2] == [] ( - ECHO Invalid Boost Root Directory: Location of Boost must be supplied - EXIT /B !EXIT_CODE_MISSING_BUILD_DEPENDENCY! - ) ELSE ( - REM Get the Boost root directory - SET "BOOST_ROOT_DIRECTORY=%2" - IF NOT EXIST "!BOOST_ROOT_DIRECTORY!" ( - ECHO Invalid Boost Root Directory: Location does not exist [%2] + REM Make sure the Boost root directory exists + IF [%2] == [] ( + ECHO Invalid Boost Root Directory: Location of Boost must be supplied EXIT /B !EXIT_CODE_MISSING_BUILD_DEPENDENCY! + ) ELSE ( + REM Get the Boost root directory + SET "BOOST_ROOT_DIRECTORY=%2" + IF NOT EXIST "!BOOST_ROOT_DIRECTORY!" ( + ECHO Invalid Boost Root Directory: Location does not exist [%2] + EXIT /B !EXIT_CODE_MISSING_BUILD_DEPENDENCY! + ) + SHIFT ) - SHIFT + + REM Reset the argument flag + SET ARGUMENT_IS_TEST=!FALSE! + ) ELSE ( + REM Determine which tests were previously parsed + ECHO Testing Already Indicated: Indicate one type [all, integration, or unit] ) ) + REM Enable libssh2 (clone and build) + IF "!ARGUMENT!" == "!ARGUMENT_ENABLE_LIBSSH2!" ( + SET ENABLE_LIBSSH2=!TRUE! + ) + REM Enable zlib (clone and build) IF "!ARGUMENT!" == "!ARGUMENT_ENABLE_ZLIB!" ( SET ENABLE_ZLIB=!TRUE! @@ -312,12 +347,25 @@ IF NOT [%1] == [] ( GOTO :ARGUMENT_LOOP ) -REM Ensure static builds, OpenSSL is enabled, and packages are disabled -IF !ENABLE_TESTS! EQU !TRUE! ( - REM Enable test dependencies +REM Ensure OpenSSL is enabled if libssh2 or integration tests are enabled +IF !ENABLE_OPENSSL! EQU !FALSE! ( + IF !ENABLE_LIBSSH2! EQU !TRUE! ( + SET ENABLE_OPENSSL=!TRUE! + ECHO OpenSSL is Required for libssh2: Enabling OpenSSL + ) +) +IF !ENABLE_OPENSSL! EQU !FALSE! ( + IF !ENABLE_TESTS! EQU !TRUE! SET ENABLE_OPENSSL=!TRUE! + IF !ENABLE_INTEGRATION_TESTS! EQU !TRUE! SET ENABLE_OPENSSL=!TRUE! + IF !ENABLE_OPENSSL! EQU !TRUE! ( + ECHO OpenSSL is Required for Integration Tests: Enabling OpenSSL + ) +) + +REM Ensure static builds are enabled and packages are disabled (if tests) +IF !IS_TESTING_ENABLED! EQU !TRUE! ( + REM Force static for static linking SET LIBRARY_TYPE=!LIBRARY_TYPE_STATIC! - SET ENABLE_LIBSSH2=!TRUE! - SET ENABLE_OPENSSL=!TRUE! REM Determine if package build should be disabled IF !ENABLE_BUILD_PACKAGES! EQU !TRUE! ( @@ -570,21 +618,24 @@ IF "!ENABLE_BUILD_PACKAGES!" == "!FALSE!" ( IF !BUILD_DEPENDENCIES_ONLY! EQU !TRUE! SET USE_BOOST_ATOMIC=!FALSE! REM Display summary of build options - ECHO Build Type: !BUILD_TYPE! - ECHO Clean Build: !ENABLE_CLEAN_BUILD! - ECHO Dependencies Only: !BUILD_DEPENDENCIES_ONLY! - ECHO Examples Enabled: !ENABLE_EXAMPLES! - ECHO Library Type: !LIBRARY_TYPE! - ECHO OpenSSL Enabled: !ENABLE_OPENSSL! - ECHO Tests Enabled: !ENABLE_TESTS! - ECHO zlib Enabled: !ENABLE_ZLIB! - ECHO Generate Solution !GENERATE_SOLUTION! - ECHO Target Architecture: !TARGET_ARCHITECTURE! - ECHO Use Boost Atomic: !USE_BOOST_ATOMIC! + ECHO Build Type: !BUILD_TYPE! + ECHO Clean Build: !ENABLE_CLEAN_BUILD! + ECHO Dependencies Only: !BUILD_DEPENDENCIES_ONLY! + ECHO Examples Enabled: !ENABLE_EXAMPLES! + ECHO Library Type: !LIBRARY_TYPE! + ECHO OpenSSL Enabled: !ENABLE_OPENSSL! + ECHO Tests Enabled: !ENABLE_TESTS! + ECHO Integration Tests Enabled: !ENABLE_INTEGRATION_TESTS! + ECHO Unit Tests Enabled: !ENABLE_UNIT_TESTS! + ECHO libssh2 Enabled: !ENABLE_LIBSSH2! + ECHO zlib Enabled: !ENABLE_ZLIB! + ECHO Generate Solution !GENERATE_SOLUTION! + ECHO Target Architecture: !TARGET_ARCHITECTURE! + ECHO Use Boost Atomic: !USE_BOOST_ATOMIC! IF NOT DEFINED WINDOWS_SDK_SELECTED ( - ECHO Visual Studio: !VISUAL_STUDIO_VERSION! + ECHO Visual Studio: !VISUAL_STUDIO_VERSION! ) ELSE ( - ECHO Windows SDK: !WINDOWS_SDK_VERSION! + ECHO Windows SDK: !WINDOWS_SDK_VERSION! ) ECHO. ) ELSE ( @@ -594,9 +645,15 @@ IF "!ENABLE_BUILD_PACKAGES!" == "!FALSE!" ( SET ENABLE_EXAMPLES=!FALSE! SET ENABLE_OPENSSL=!TRUE! SET ENABLE_TESTS=!FALSE! + SET ENABLE_INTEGRATION_TESTS=!FALSE! + SET ENABLE_UNIT_TESTS=!FALSE! SET ENABLE_ZLIB=!FALSE! SET GENERATE_SOLUTION=!FALSE! - IF !BUILD_DEPENDENCIES_ONLY! EQU !FALSE! SET USE_BOOST_ATOMIC=!TRUE! + IF !BUILD_DEPENDENCIES_ONLY! EQU !FALSE! ( + SET USE_BOOST_ATOMIC=!TRUE! + SET ENABLE_LIBSSH2=!FALSE! + ) + REM Add common 7-zip locations to system path SET "PATH=!PATH!;!PROGRAMFILES!\7-zip;!PROGRAMFILES(X86)!\7-zip" @@ -631,7 +688,7 @@ ECHO Cloning Library Dependencies REM Determine if Boost atomic dependency is required IF !USE_BOOST_ATOMIC! EQU !TRUE! ( REM Determine if Boost atomic should be cloned - IF !ENABLE_TESTS! EQU !FALSE! ( + IF !IS_TESTING_ENABLED! EQU !FALSE! ( REM Clone Boost atomic and checkout the appropriate tag ECHO Gathering Boost atomic ^(and dependencies^) !BOOST_BRANCH_TAG_VERSION! > "!LOG_BOOST_CLONE!" ECHO | SET /P=Gathering Boost atomic ^(and dependencies^) !BOOST_BRANCH_TAG_VERSION! ... @@ -756,7 +813,7 @@ IF "!ENABLE_BUILD_PACKAGES!" == "!FALSE!" ( IF !ERRORLEVEL! NEQ 0 EXIT /B !ERRORLEVEL! ) ) ELSE ( - REM Indicate zlib is disable + REM Indicate zlib is disabled SET ABSOLUTE_ZLIB_LIBRARY_DIRECTORY= ) @@ -768,15 +825,21 @@ IF "!ENABLE_BUILD_PACKAGES!" == "!FALSE!" ( CALL :BUILDOPENSSL "!ABSOLUTE_DEPENDENCIES_DIRECTORY!\!DEPENDENCIES_SOURCE_DIRECTORY!\!OPENSSL_DIRECTORY!" "!ABSOLUTE_OPENSSL_LIBRARY_DIRECTORY!" "!ABSOLUTE_ZLIB_LIBRARY_DIRECTORY!" !TARGET_ARCHITECTURE! !LIBRARY_TYPE! !FALSE! "!LOG_OPENSSL_BUILD!" IF !ERRORLEVEL! NEQ 0 EXIT /B !ERRORLEVEL! ) + ) ELSE ( + REM Indicate OpenSSL is disabled + SET ABSOLUTE_OPENSSL_LIBRARY_DIRECTORY= ) REM Determine is libssh2 should be built IF !ENABLE_LIBSSH2! EQU !TRUE! ( REM Determine if libssh2 needs to be built IF NOT EXIST "!ABSOLUTE_LIBSSH2_LIBRARY_DIRECTORY!" ( - CALL :BUILDLIBSSH2 "!ABSOLUTE_DEPENDENCIES_DIRECTORY!\!DEPENDENCIES_SOURCE_DIRECTORY!\!LIBSSH2_DIRECTORY!" "!ABSOLUTE_LIBSSH2_LIBRARY_DIRECTORY!" "!ABSOLUTE_OPENSSL_LIBRARY_DIRECTORY!" "!ABSOLUTE_ZLIB_LIBRARY_DIRECTORY!" !TARGET_ARCHITECTURE! !VISUAL_STUDIO_INTERNAL_SHORTHAND_VERSION! "!LOG_LIBSSH2_BUILD!" + CALL :BUILDLIBSSH2 "!ABSOLUTE_DEPENDENCIES_DIRECTORY!\!DEPENDENCIES_SOURCE_DIRECTORY!\!LIBSSH2_DIRECTORY!" "!ABSOLUTE_LIBSSH2_LIBRARY_DIRECTORY!" "!ABSOLUTE_OPENSSL_LIBRARY_DIRECTORY!" "!ABSOLUTE_ZLIB_LIBRARY_DIRECTORY!" !TARGET_ARCHITECTURE! !VISUAL_STUDIO_INTERNAL_SHORTHAND_VERSION! !FALSE! "!LOG_LIBSSH2_BUILD!" IF !ERRORLEVEL! NEQ 0 EXIT /B !ERRORLEVEL! ) + ) ELSE ( + REM Indicate libssh2 is disabled + SET ABSOLUTE_LIBSSH2_LIBRARY_DIRECTORY= ) REM Determine if driver should be built @@ -793,7 +856,7 @@ IF "!ENABLE_BUILD_PACKAGES!" == "!FALSE!" ( IF NOT EXIST "!DRIVER_INSTALLATION_DIRECTORY!" ( SET BOOST_DEPENDENCY_SOURCE_DIRECTORY= IF !USE_BOOST_ATOMIC! EQU !TRUE! SET "BOOST_DEPENDENCY_SOURCE_DIRECTORY=!ABSOLUTE_DEPENDENCIES_DIRECTORY!\!DEPENDENCIES_SOURCE_DIRECTORY!\!BOOST_DIRECTORY!" - CALL :BUILDDRIVER "!ABSOLUTE_BATCH_DIRECTORY!" "!ABSOLUTE_BUILD_DIRECTORY!\!DRIVER_DRIVER_DIRECTORY!" "!DRIVER_INSTALLATION_DIRECTORY!" "!ABSOLUTE_LIBUV_LIBRARY_DIRECTORY!" "!ABSOLUTE_OPENSSL_LIBRARY_DIRECTORY!" "!BOOST_ROOT_DIRECTORY!" "!ABSOLUTE_LIBSSH2_LIBRARY_DIRECTORY!" "!ABSOLUTE_ZLIB_LIBRARY_DIRECTORY!" !BUILD_TYPE! !TARGET_ARCHITECTURE! !LIBRARY_TYPE! !VISUAL_STUDIO_INTERNAL_SHORTHAND_VERSION! !ENABLE_EXAMPLES! !GENERATE_SOLUTION! "!BOOST_DEPENDENCY_SOURCE_DIRECTORY!" "!LOG_DRIVER_BUILD!" + CALL :BUILDDRIVER "!ABSOLUTE_BATCH_DIRECTORY!" "!ABSOLUTE_BUILD_DIRECTORY!\!DRIVER_DRIVER_DIRECTORY!" "!DRIVER_INSTALLATION_DIRECTORY!" "!ABSOLUTE_LIBUV_LIBRARY_DIRECTORY!" "!ABSOLUTE_OPENSSL_LIBRARY_DIRECTORY!" "!ABSOLUTE_ZLIB_LIBRARY_DIRECTORY!" "!BOOST_ROOT_DIRECTORY!" "!ABSOLUTE_LIBSSH2_LIBRARY_DIRECTORY!" !BUILD_TYPE! !TARGET_ARCHITECTURE! !LIBRARY_TYPE! !VISUAL_STUDIO_INTERNAL_SHORTHAND_VERSION! !ENABLE_EXAMPLES! !ENABLE_TESTS! !ENABLE_INTEGRATION_TESTS! !ENABLE_UNIT_TESTS! !GENERATE_SOLUTION! "!BOOST_DEPENDENCY_SOURCE_DIRECTORY!" "!LOG_DRIVER_BUILD!" IF !ERRORLEVEL! NEQ 0 EXIT /B !ERRORLEVEL! ) @@ -891,10 +954,20 @@ IF "!ENABLE_BUILD_PACKAGES!" == "!FALSE!" ( IF EXIST "!ABSOLUTE_BUILD_DIRECTORY!\!DRIVER_DRIVER_DIRECTORY!" CALL :CLEANDIRECTORY "!ABSOLUTE_BUILD_DIRECTORY!\!DRIVER_DRIVER_DIRECTORY!" "Cleaning driver library directory" SET BOOST_DEPENDENCY_SOURCE_DIRECTORY= IF !VISUAL_STUDIO_VERSION! EQU 2010 SET "BOOST_DEPENDENCY_SOURCE_DIRECTORY=!ABSOLUTE_DEPENDENCIES_DIRECTORY!\!DEPENDENCIES_SOURCE_DIRECTORY!\!BOOST_DIRECTORY!" - CALL :BUILDDRIVER "!ABSOLUTE_BATCH_DIRECTORY!" "!ABSOLUTE_BUILD_DIRECTORY!\!DRIVER_DRIVER_DIRECTORY!" "!ABSOLUTE_DRIVER_PACKAGE_INSTALLATION_DIRECTORY!" "!ABSOLUTE_DEPENDENCY_PACKAGE_LIBUV_INSTALLATION_DIRECTORY!" "!ABSOLUTE_DEPENDENCY_PACKAGE_OPENSSL_INSTALLATION_DIRECTORY!" "" "" "" !BUILD_TYPE_RELEASE! %%C %%D !VISUAL_STUDIO_INTERNAL_SHORTHAND_VERSION! !FALSE! !GENERATE_SOLUTION! "!BOOST_DEPENDENCY_SOURCE_DIRECTORY!" "!LOG_DRIVER_BUILD!" + CALL :BUILDDRIVER "!ABSOLUTE_BATCH_DIRECTORY!" "!ABSOLUTE_BUILD_DIRECTORY!\!DRIVER_DRIVER_DIRECTORY!" "!ABSOLUTE_DRIVER_PACKAGE_INSTALLATION_DIRECTORY!" "!ABSOLUTE_DEPENDENCY_PACKAGE_LIBUV_INSTALLATION_DIRECTORY!" "!ABSOLUTE_DEPENDENCY_PACKAGE_OPENSSL_INSTALLATION_DIRECTORY!" "" "" "" !BUILD_TYPE_RELEASE! %%C %%D !VISUAL_STUDIO_INTERNAL_SHORTHAND_VERSION! !FALSE! !FALSE! !FALSE! !FALSE! !GENERATE_SOLUTION! "!BOOST_DEPENDENCY_SOURCE_DIRECTORY!" "!LOG_DRIVER_BUILD!" IF !ERRORLEVEL! NEQ 0 EXIT /B !ERRORLEVEL! ) + REM Build libssh2 (static) as well for dependency only builds + IF !ENABLE_LIBSSH2! EQU !TRUE! ( + IF "%%D" == "!LIBRARY_TYPE_STATIC!" ( + SET DEPENDENCY_PACKAGE_LIBSSH2_INSTALLATION_DIRECTORY=!DEPENDENCY_PACKAGE_INSTALLATION_DIRECTORY!\!LIBSSH2_DIRECTORY! + SET "ABSOLUTE_DEPENDENCY_PACKAGE_LIBSSH2_INSTALLATION_DIRECTORY=!ABSOLUTE_PACKAGES_DIRECTORY!\!DEPENDENCY_PACKAGE_LIBSSH2_INSTALLATION_DIRECTORY!" + CALL :BUILDLIBSSH2 "!ABSOLUTE_DEPENDENCIES_DIRECTORY!\!DEPENDENCIES_SOURCE_DIRECTORY!\!LIBSSH2_DIRECTORY!" "!ABSOLUTE_DEPENDENCY_PACKAGE_LIBSSH2_INSTALLATION_DIRECTORY!" "!ABSOLUTE_DEPENDENCY_PACKAGE_OPENSSL_INSTALLATION_DIRECTORY!" "" %%C !VISUAL_STUDIO_INTERNAL_SHORTHAND_VERSION! !TRUE! "!LOG_LIBSSH2_BUILD!" + IF !ERRORLEVEL! NEQ 0 EXIT /B !ERRORLEVEL! + ) + ) + REM Clean-up the dependency packages IF NOT EXIST "!ABSOLUTE_DEPENDENCY_PACKAGE_LIBUV_INSTALLATION_DIRECTORY!\..\!LIBRARY_INCLUDE_DIRECTORY!" MOVE /Y "!ABSOLUTE_DEPENDENCY_PACKAGE_LIBUV_INSTALLATION_DIRECTORY!\!LIBRARY_INCLUDE_DIRECTORY!" "!ABSOLUTE_DEPENDENCY_PACKAGE_LIBUV_INSTALLATION_DIRECTORY!\..\!LIBRARY_INCLUDE_DIRECTORY!" >> "!LOG_PACKAGE_BUILD!" 2>&1 IF EXIST "!ABSOLUTE_DEPENDENCY_PACKAGE_LIBUV_INSTALLATION_DIRECTORY!\!LIBRARY_INCLUDE_DIRECTORY!" RMDIR /S /Q "!ABSOLUTE_DEPENDENCY_PACKAGE_LIBUV_INSTALLATION_DIRECTORY!\!LIBRARY_INCLUDE_DIRECTORY!" >> "!LOG_PACKAGE_BUILD!" 2>&1 @@ -914,7 +987,7 @@ IF "!ENABLE_BUILD_PACKAGES!" == "!FALSE!" ( REM Skip a line on the display ECHO. - ) + ) REM Build the zip packages for the current target architecture and Visual Studio version IF !BUILD_DEPENDENCIES_ONLY! EQU !FALSE! ( @@ -946,6 +1019,17 @@ IF "!ENABLE_BUILD_PACKAGES!" == "!FALSE!" ( EXIT /B !EXIT_CODE_PACKAGE_FAILED! ) ECHO done. + IF !ENABLE_LIBSSH2! EQU !TRUE! ( + ECHO | SET /P=Building the libssh2 package for Win%%C MSVC!VISUAL_STUDIO_INTERNAL_VERSION! ... + ECHO !ZIP! a -tzip "!ABSOLUTE_PACKAGES_DIRECTORY!\libssh2-!LIBSSH2_PACKAGE_VERSION!-win%%C-msvc!VISUAL_STUDIO_INTERNAL_VERSION!.zip" -r !ABSOLUTE_DRIVER_PACKAGE_INSTALLATION_DIRECTORY!\!DEPENDENCIES_DIRECTORY!\!LIBSSH2_DIRECTORY!\ >> "!LOG_PACKAGE_BUILD!" + !ZIP! a -tzip "!ABSOLUTE_PACKAGES_DIRECTORY!\libssh2-!LIBSSH2_PACKAGE_VERSION!-win%%C-msvc!VISUAL_STUDIO_INTERNAL_VERSION!.zip" -r "!ABSOLUTE_DRIVER_PACKAGE_INSTALLATION_DIRECTORY!\!DEPENDENCIES_DIRECTORY!\!LIBSSH2_DIRECTORY!\*" >> "!LOG_PACKAGE_BUILD!" 2>&1 + IF NOT !ERRORLEVEL! EQU 0 ( + ECHO FAILED! + ECHO See !LOG_PACKAGE_BUILD! for more details + EXIT /B !EXIT_CODE_PACKAGE_FAILED! + ) + ECHO done. + ) ECHO. REM Reset the system PATH @@ -995,7 +1079,6 @@ REM Display the help message and exit with error code ECHO !ARGUMENT_DISABLE_OPENSSL! Disable OpenSSL support ECHO !ARGUMENT_ENABLE_EXAMPLES! Enable example builds ECHO !ARGUMENT_ENABLE_BUILD_PACKAGES! [version] Enable package generation - ECHO !ARGUMENT_ENABLE_TESTS! [boost-root-dir] Enable test builds ECHO !ARGUMENT_ENABLE_ZLIB! Enable zlib ECHO !ARGUMENT_GENERATE_SOLUTION! Generate Visual Studio solution ECHO !ARGUMENT_INSTALLATION_DIRECTORY! [install-dir] Override installation directory @@ -1010,6 +1093,16 @@ REM Display the help message and exit with error code ) ECHO !ARGUMENT_USE_BOOST_ATOMIC! Use Boost atomic ECHO. + ECHO Testing Arguments + ECHO. + ECHO !ARGUMENT_ENABLE_TESTS! + ECHO [boost-root-dir] Enable test builds + ECHO !ARGUMENT_ENABLE_INTEGRATION_TESTS! + ECHO [boost-root-dir] Enable integration tests build + ECHO !ARGUMENT_ENABLE_UNIT_TESTS! + ECHO [boost-root-dir] Enable unit tests build + ECHO !ARGUMENT_ENABLE_LIBSSH2! Enable libssh2 ^(remote server testing^) + ECHO. ECHO !ARGUMENT_HELP! Display this message EXIT /B @@ -1414,8 +1507,10 @@ REM indicates zlib disabled REM @param target-architecture 32 or 64-bit REM @param visual-studio-version Shortened Visual Studio version; empty REM string indicates Windows SDK build +REM @param is-clean-after-install True if clean should be performed after +REM install; false otherwise REM @param log-filename Absolute path and filename for log output -:BUILDLIBSSH2 [source-directory] [install-directory] [openssl-library-directory] [zlib-library-directory] [target-architecture] [visual-studio-version] [log-filename] +:BUILDLIBSSH2 [source-directory] [install-directory] [openssl-library-directory] [zlib-library-directory] [target-architecture] [visual-studio-version] [is-clean-after-install] [log-filename] REM Create library variables from arguments SET "LIBSSH2_SOURCE_DIRECTORY=%~1" SHIFT @@ -1429,6 +1524,8 @@ REM @param log-filename Absolute path and filename for log output SHIFT SET "LIBSSH2_VISUAL_STUDIO_VERSION=%~1" SHIFT + SET LIBSSH2_IS_CLEAN_AFTER_INSTALL=%~1 + SHIFT SET "LIBSSH2_LOG_FILENAME=%~1" REM Build libssh2 dependency @@ -1470,6 +1567,11 @@ REM @param log-filename Absolute path and filename for log output EXIT /B !EXIT_CODE_BUILD_DEPENDENCY_FAILED! ) ECHO done. + IF !LIBSSH2_IS_CLEAN_AFTER_INSTALL! EQU !TRUE! ( + ECHO | SET /P=Cleaning libssh2 build ... + DEL /S /Q * >> "!LIBSSH2_LOG_FILENAME!" 2>&1 + ECHO done. + ) POPD EXIT /B @@ -1481,24 +1583,28 @@ REM @param install-directory Location to install driver library REM @param libuv-library-directory Library directory for libuv REM @param openssl-library-directory Library directory for OpenSSL; empty REM string indicates OpenSSL disabled +REM @param zlib-library-directory Library directory for zlib; empty string +REM indicates zlib is not required REM @param boost-library-directory Library directory for Boost; empty string REM indicates tests are disabled REM @param libssh2-library-directory Library directory for libssh2; empty REM string indicates tests are disabled -REM @param zlib-library-directory Library directory for zlib; empty string -REM indicates zlib is not required REM @param build-type Debug or release REM @param target-architecture 32 or 64-bit REM @param library-type Shared or static REM @param visual-studio-version Shortened Visual Studio version; empty REM string indicates Windows SDK build REM @param build-examples True to build examples; false otherwise +REM @param build-test True to build tests; false otherwise +REM @param build-integration-test True to build integration tests; false +REM otherwise +REM @param build-unit-test True to build unit tests; false otherwise REM @param generate-solution True to generate visual studio solution file; REM false to perform build using NMake REM @param boost-atomic-directory Library directory for atomic; empty string -REM indicates Boost atomic is not being used +REM indicates Boost atomic is not being used REM @param log-filename Absolute path and filename for log output -:BUILDDRIVER [source-directory] [build-directory] [install-directory] [libuv-library-directory] [openssl-library-directory] [boost-library-directory] [libssh2-library-directory] [zlib-library-directory] [build-type] [target-architecture] [library-type] [visual-studio-version] [build-examples] [generate-solution] [boost-atomic-directory] [log-filename] +:BUILDDRIVER [source-directory] [build-directory] [install-directory] [libuv-library-directory] [openssl-library-directory] [zlib-library-directory] [boost-library-directory] [libssh2-library-directory] [build-type] [target-architecture] [library-type] [visual-studio-version] [build-examples] [build-tests] [build-integration-tests] [build-unit-tests] [generate-solution] [boost-atomic-directory] [log-filename] REM Create driver variables from arguments SET "DRIVER_SOURCE_DIRECTORY=%~1" SHIFT @@ -1510,11 +1616,11 @@ REM @param log-filename Absolute path and filename for log output SHIFT SET "DRIVER_OPENSSL_LIBRARY_DIRECTORY=%~1" SHIFT - SET "BOOST_LIBRARY_DIRECTORY=%~1" + SET "DRIVER_ZLIB_LIBRARY_DIRECTORY=%~1" SHIFT - SET "TESTS_LIBSSH2_LIBRARY_DIRECTORY=%~1" + SET "TESTS_BOOST_LIBRARY_DIRECTORY=%~1" SHIFT - SET "TESTS_ZLIB_LIBRARY_DIRECTORY=%~1" + SET "TESTS_LIBSSH2_LIBRARY_DIRECTORY=%~1" SHIFT SET "DRIVER_BUILD_TYPE=%~1" SHIFT @@ -1526,6 +1632,12 @@ REM @param log-filename Absolute path and filename for log output SHIFT SET "DRIVER_BUILD_EXAMPLES=%~1" SHIFT + SET "DRIVER_BUILD_TESTS=%~1" + SHIFT + SET "DRIVER_BUILD_INTEGRATION_TESTS=%~1" + SHIFT + SET "DRIVER_BUILD_UNIT_TESTS=%~1" + SHIFT SET "DRIVER_GENERATE_SOLUTION=%~1" SHIFT SET "DRIVER_BOOST_DEPENDENCY_SOURCE_DIRECTORY=%~1" @@ -1553,11 +1665,16 @@ REM @param log-filename Absolute path and filename for log output SET DRIVER_BUILD_EXAMPLES=OFF ) SET "DRIVER_CMAKE_COMMAND_LINE=!DRIVER_CMAKE_COMMAND_LINE! -DCASS_MULTICORE_COMPILATION=ON -DCMAKE_INSTALL_PREFIX=^"!DRIVER_INSTALL_DIRECTORY!^" -DCMAKE_BUILD_TYPE=!DRIVER_BUILD_TYPE! -DCASS_BUILD_EXAMPLES=!DRIVER_BUILD_EXAMPLES! -DLIBUV_ROOT_DIR=^"!DRIVER_LIBUV_LIBRARY_DIRECTORY!^"" - IF !ENABLE_OPENSSL! EQU !TRUE! ( + IF NOT "!DRIVER_OPENSSL_LIBRARY_DIRECTORY!" == "" ( SET "DRIVER_CMAKE_COMMAND_LINE=!DRIVER_CMAKE_COMMAND_LINE! -DCASS_USE_OPENSSL=ON -DOPENSSL_ROOT_DIR=^"!DRIVER_OPENSSL_LIBRARY_DIRECTORY!^"" ) ELSE ( SET "DRIVER_CMAKE_COMMAND_LINE=!DRIVER_CMAKE_COMMAND_LINE! -DCASS_USE_OPENSSL=OFF" ) + IF NOT "!DRIVER_ZLIB_LIBRARY_DIRECTORY!" == "" ( + SET "DRIVER_CMAKE_COMMAND_LINE=!DRIVER_CMAKE_COMMAND_LINE! -DCASS_USE_ZLIB=ON -DZLIB_ROOT_DIR=^"!DRIVER_ZLIB_LIBRARY_DIRECTORY!^"" + ) ELSE ( + SET "DRIVER_CMAKE_COMMAND_LINE=!DRIVER_CMAKE_COMMAND_LINE! -DCASS_USE_ZLIB=OFF" + ) IF "!DRIVER_LIBRARY_TYPE!" == "!LIBRARY_TYPE_SHARED!" ( SET "DRIVER_CMAKE_COMMAND_LINE=!DRIVER_CMAKE_COMMAND_LINE! -DCASS_BUILD_STATIC=OFF" SET DRIVER_VISUAL_STUDIO_TARGETS=cassandra @@ -1565,19 +1682,28 @@ REM @param log-filename Absolute path and filename for log output SET "DRIVER_CMAKE_COMMAND_LINE=!DRIVER_CMAKE_COMMAND_LINE! -DCASS_BUILD_STATIC=ON -DCASS_USE_STATIC_LIBS=ON" SET DRIVER_VISUAL_STUDIO_TARGETS=cassandra_static ) - IF NOT "!TESTS_ZLIB_LIBRARY_DIRECTORY!" == "" ( - SET "DRIVER_CMAKE_COMMAND_LINE=!DRIVER_CMAKE_COMMAND_LINE! -DCASS_USE_ZLIB=ON -DZLIB_ROOT_DIR=^"!TESTS_ZLIB_LIBRARY_DIRECTORY!^"" - ) ELSE ( - SET "DRIVER_CMAKE_COMMAND_LINE=!DRIVER_CMAKE_COMMAND_LINE! -DCASS_USE_ZLIB=OFF" - ) - IF NOT "!BOOST_LIBRARY_DIRECTORY!" == "" ( - IF NOT "!TESTS_LIBSSH2_LIBRARY_DIRECTORY!" == "" ( - SET "DRIVER_CMAKE_COMMAND_LINE=!DRIVER_CMAKE_COMMAND_LINE! -DCASS_BUILD_TESTS=ON -DBOOST_ROOT_DIR=^"!BOOST_LIBRARY_DIRECTORY!^" -DLIBSSH2_ROOT_DIR=^"!TESTS_LIBSSH2_LIBRARY_DIRECTORY!^"" + IF !DRIVER_BUILD_TESTS! EQU !TRUE! SET "DRIVER_CMAKE_COMMAND_LINE=!DRIVER_CMAKE_COMMAND_LINE! -DCASS_BUILD_TESTS=ON" + IF !DRIVER_BUILD_INTEGRATION_TESTS! EQU !TRUE! SET "DRIVER_CMAKE_COMMAND_LINE=!DRIVER_CMAKE_COMMAND_LINE! -DCASS_BUILD_INTEGRATION_TESTS=ON" + IF !DRIVER_BUILD_UNIT_TESTS! EQU !TRUE! SET "DRIVER_CMAKE_COMMAND_LINE=!DRIVER_CMAKE_COMMAND_LINE! -DCASS_BUILD_UNIT_TESTS=ON" + IF NOT "!TESTS_BOOST_LIBRARY_DIRECTORY!" == "" ( + REM Determine if using Boost distributed or include/lib binaries + SET "BOOST_DISTRIBUTION_ROOT_DIRECTORY=!TESTS_BOOST_LIBRARY_DIRECTORY!" + SET "BOOST_DISTRIBUTION_INCLUDE_DIRECTORY=!BOOST_DISTRIBUTION_ROOT_DIRECTORY!" + SET "BOOST_DISTRIBUTION_LIBRARY_DIRECTORY=!BOOST_DISTRIBUTION_ROOT_DIRECTORY!\lib!DRIVER_TARGET_ARCHITECTURE!-msvc-!DRIVER_VISUAL_STUDIO_VERSION!.0" + IF NOT EXIST "!BOOST_DISTRIBUTION_LIBRARY_DIRECTORY!" ( + SET "DRIVER_CMAKE_COMMAND_LINE=!DRIVER_CMAKE_COMMAND_LINE! -DBOOST_ROOT_DIR=^"!TESTS_BOOST_LIBRARY_DIRECTORY!^"" + ) ELSE ( + SET "DRIVER_CMAKE_COMMAND_LINE=!DRIVER_CMAKE_COMMAND_LINE! -DBOOST_ROOT=^"!BOOST_DISTRIBUTION_ROOT_DIRECTORY!^" -DBOOST_INCLUDEDIR=^"!BOOST_DISTRIBUTION_INCLUDE_DIRECTORY!^" -DBOOST_LIBRARYDIR=^"!BOOST_DISTRIBUTION_LIBRARY_DIRECTORY!^"" ) ) + IF NOT "!TESTS_LIBSSH2_LIBRARY_DIRECTORY!" == "" ( + SET "DRIVER_CMAKE_COMMAND_LINE=!DRIVER_CMAKE_COMMAND_LINE! -DCASS_USE_LIBSSH2=ON -DLIBSSH2_ROOT_DIR=^"!TESTS_LIBSSH2_LIBRARY_DIRECTORY!^"" + ) ELSE ( + SET "DRIVER_CMAKE_COMMAND_LINE=!DRIVER_CMAKE_COMMAND_LINE! -DCASS_USE_LIBSSH2=OFF" + ) IF NOT "!DRIVER_BOOST_DEPENDENCY_SOURCE_DIRECTORY!" == "" ( SET "DRIVER_CMAKE_COMMAND_LINE=!DRIVER_CMAKE_COMMAND_LINE! -DCASS_USE_BOOST_ATOMIC=ON" - IF "!BOOST_LIBRARY_DIRECTORY!" == "" ( + IF "!TESTS_BOOST_LIBRARY_DIRECTORY!" == "" ( SET "DRIVER_CMAKE_COMMAND_LINE=!DRIVER_CMAKE_COMMAND_LINE! -DBOOST_ROOT_DIR=^"!DRIVER_BOOST_DEPENDENCY_SOURCE_DIRECTORY!^"" ) )