From d6751bb96948d89391af9bfc305ff4dd8ac6a237 Mon Sep 17 00:00:00 2001 From: Jerry Leung Date: Tue, 8 Jun 2021 10:04:04 -0700 Subject: [PATCH] AT-818 Support Debug mode for Mac (#71) * Added support Debug mode for macOS --- .github/workflows/mac-debug-build.yml | 89 +++++++++++++++++++ build_mac_debug64.sh | 16 +++- build_mac_release64.sh | 16 +++- src/CMakeLists.txt | 81 ++++++++--------- .../ITODBCExecution/CMakeLists.txt | 1 + .../ITODBCExecution/test_odbc_execution.cpp | 7 ++ .../ITODBCSAMLAuthentication/CMakeLists.txt | 1 - src/UnitTests/UTConn/CMakeLists.txt | 1 + 8 files changed, 159 insertions(+), 53 deletions(-) create mode 100644 .github/workflows/mac-debug-build.yml diff --git a/.github/workflows/mac-debug-build.yml b/.github/workflows/mac-debug-build.yml new file mode 100644 index 000000000..76d7bf846 --- /dev/null +++ b/.github/workflows/mac-debug-build.yml @@ -0,0 +1,89 @@ +name: Timestream ODBC Driver for Mac (Debug) + +on: + workflow_dispatch: + +env: + CI_OUTPUT_PATH: "ci-output" + ODBC_LIB_PATH: "./build/odbc/lib" + ODBC_BIN_PATH: "./build/odbc/bin" + ODBC_BUILD_PATH: "./build/odbc/build" + AWS_SDK_INSTALL_PATH: "./build/aws-sdk/install" + +jobs: + build-mac: + runs-on: macos-latest + steps: + - uses: actions/checkout@v2 + - name: run-cppcheck + run: | + brew install cppcheck + sh run_cppcheck.sh + - name: upload-cppcheck-results + if: failure() + uses: actions/upload-artifact@v2 + with: + name: cppcheck-results + path: cppcheck-results.log + - name: get-dependencies + run: | + brew unlink unixodbc + brew install curl + brew install cmake + brew install libiodbc + - name: configure-and-build-driver + run: | + ./build_mac_debug64.sh + - name: configure-aws-credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-east-1 + - name: prepare-dsn + run: | + sudo mkdir /Library/ODBC + sudo mv ./src/IntegrationTests/ITODBCConnection/odbc.ini /Library/ODBC + mkdir ${{ github.workspace }}/odbc-logs + - name: run-connection-unit-test + run: | + ./build/odbc/bin/ut_conn + - name: run-integration-connection-tests + run: | + ./build/odbc/bin/itodbc_connection + - name: run-integration-execution-tests + run: | + ./build/odbc/bin/itodbc_execution + - name: run-integration-results-tests + run: | + ./build/odbc/bin/itodbc_results + - name: run-integration-descriptors-tests + run: | + ./build/odbc/bin/itodbc_descriptors + - name: run-integration-catalog-tests + run: | + ./build/odbc/bin/itodbc_catalog + - name: run-integration-info-tests + run: | + ./build/odbc/bin/itodbc_info + - name: run-integration-pagination-tests + run: | + ./build/odbc/bin/itodbc_pagination + - name: print-test-logs + if: failure() + run: | + cat /tmp/timestreamodbc_*.log + cat ./aws_sdk_*.log + - name: print-memory-leak-logs + if: always() + run: | + cat ./leaks_* + - name: upload-integration-test-results + if: always() + uses: actions/upload-artifact@v2 + with: + name: integration-test-results-mac64 + path: | + ${{ github.workspace }}/odbc-logs/ + ${{ github.workspace }}/leaks_ + diff --git a/build_mac_debug64.sh b/build_mac_debug64.sh index 9404c6ac3..e70d11db3 100755 --- a/build_mac_debug64.sh +++ b/build_mac_debug64.sh @@ -3,12 +3,20 @@ cd src git clone --recurse-submodules -b "1.8.186" "https://github.com/aws/aws-sdk-cpp.git" -cd .. +cd aws-sdk-cpp +mkdir install +mkdir build +cd build +cmake ../ -DCMAKE_BUILD_TYPE=Debug -DBUILD_ONLY="core;sts;timestream-query" -DCUSTOM_MEMORY_MANAGEMENT="OFF" -DENABLE_TESTING="OFF" -DBUILD_SHARED_LIBS="OFF" +# Rerun to set the install prefix (https://github.com/aws/aws-sdk-cpp/issues/1156) +cmake ../ -DCMAKE_INSTALL_PREFIX=../install -DCMAKE_BUILD_TYPE=Debug -DBUILD_ONLY="core;sts;timestream-query" -DCUSTOM_MEMORY_MANAGEMENT="OFF" -DENABLE_TESTING="OFF" -DBUILD_SHARED_LIBS="OFF" +make -j 4 +make install +cd ../../../ PREFIX_PATH=$(pwd) mkdir cmake-build64 cd cmake-build64 -cmake ../src -DCMAKE_INSTALL_PREFIX=${PREFIX_PATH}/AWSSDK/ -DCMAKE_BUILD_TYPE=Debug -DBUILD_ONLY="core;sts;timestream-query" -DCUSTOM_MEMORY_MANAGEMENT="OFF" -DENABLE_RTTI="OFF" -DENABLE_TESTING="OFF" +cmake ../src -DCMAKE_BUILD_TYPE=Debug -DBUILD_WITH_TESTS=ON -DCODE_COVERAGE=ON -DBUILD_SHARED_LIBS="OFF" +make ccov-all -j 4 cd .. - -cmake --build cmake-build64 -- -j 4 diff --git a/build_mac_release64.sh b/build_mac_release64.sh index 427b5871d..3e9ee367b 100755 --- a/build_mac_release64.sh +++ b/build_mac_release64.sh @@ -3,12 +3,20 @@ cd src git clone --recurse-submodules -b "1.8.186" "https://github.com/aws/aws-sdk-cpp.git" -cd .. +cd aws-sdk-cpp +mkdir install +mkdir build +cd build +cmake ../ -DCMAKE_BUILD_TYPE=Release -DBUILD_ONLY="core;sts;timestream-query" -DCUSTOM_MEMORY_MANAGEMENT="OFF" -DENABLE_TESTING="OFF" -DBUILD_SHARED_LIBS="OFF" +# Rerun to set the install prefix (https://github.com/aws/aws-sdk-cpp/issues/1156) +cmake ../ -DCMAKE_INSTALL_PREFIX=../install -DCMAKE_BUILD_TYPE=Release -DBUILD_ONLY="core;sts;timestream-query" -DCUSTOM_MEMORY_MANAGEMENT="OFF" -DENABLE_TESTING="OFF" -DBUILD_SHARED_LIBS="OFF" +make -j 4 +make install +cd ../../../ PREFIX_PATH=$(pwd) mkdir cmake-build64 cd cmake-build64 -cmake ../src -DCMAKE_INSTALL_PREFIX=${PREFIX_PATH}/AWSSDK/ -DCMAKE_BUILD_TYPE=Release -DBUILD_ONLY="core;sts;timestream-query" -DCUSTOM_MEMORY_MANAGEMENT="OFF" -DENABLE_RTTI="OFF" -DENABLE_TESTING="OFF" +cmake ../src -DCMAKE_BUILD_TYPE=Release -DBUILD_WITH_TESTS=ON -DCODE_COVERAGE=ON -DBUILD_SHARED_LIBS="OFF" +make -j 4 cd .. - -cmake --build cmake-build64 -- -j 4 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fdbc4fcb1..bdd133a41 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -13,17 +13,12 @@ # permissions and limitations under the License. # -# Pre 3.16 versions of Windows set MD/MT incorrectly and cause linker 'warnings' which are actually serious issues -if(WIN32) cmake_minimum_required(VERSION 3.16) -else() -cmake_minimum_required(VERSION 3.13) -endif() project(global_make_list) include("${CMAKE_CURRENT_SOURCE_DIR}/modules/code-coverage.cmake") -add_code_coverage_all_targets(EXCLUDE libraries aws-cpp-sdk googletest IntegrationTests) +add_code_coverage_all_targets(EXCLUDE libraries aws-cpp-sdk googletest IntegrationTests UnitTests) if(CMAKE_SIZEOF_VOID_P EQUAL 8) set(BITNESS 64) @@ -39,21 +34,16 @@ elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../build/odbc/bin") endif() +set(CMAKE_CXX_STANDARD 17) # This wasn't being picked up on mac, causes some symbol errors if(APPLE) - set(CMAKE_CXX_STANDARD 17) add_definitions(-DHAVE_STRLCAT) - # Do not use shared libraries for AWS SDK. option(BUILD_SHARED_LIBS "Build shared libraries" OFF) - # Set BUILD_WITH_TESTS to OFF before building installer package for size optimization. - option(BUILD_WITH_TESTS "Enable testing" ON) else() - set(CMAKE_CXX_STANDARD 17) - # Use shared libraries for AWS SDK. option(BUILD_SHARED_LIBS "Build shared libraries" ON) - # Set BUILD_WITH_TESTS to OFF before building installer package for size optimization. - option(BUILD_WITH_TESTS "Enable testing" ON) endif() +# Set BUILD_WITH_TESTS to OFF before building installer package for size optimization. +option(BUILD_WITH_TESTS "Enable testing" ON) if(MSVC) add_compile_options(/W4 /WX) @@ -61,12 +51,6 @@ else() add_compile_options(-Wall -Wextra -pedantic -Werror) endif() -if(NOT WIN32) - # Unix builds require autoconf - option(AUTOCONF_ENABLE "Enable autoconf" ON) - configure_file(autoconf.h.in generated/autoconf.h @ONLY) -endif() - # Base directories set(PROJECT_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/..") set(ODFEODBC_SRC "${CMAKE_CURRENT_SOURCE_DIR}/odfesqlodbc") @@ -76,7 +60,7 @@ set(UNIT_TESTS "${CMAKE_CURRENT_SOURCE_DIR}/UnitTests") set(INSTALL_SRC "${CMAKE_CURRENT_SOURCE_DIR}/installer") set(DSN_INSTALLER_SRC "${CMAKE_CURRENT_SOURCE_DIR}/DSNInstaller") -# ODBC Driver version +# ODBC Driver version set(MAJOR 0) set(MINOR 2) set(PATCH 0) @@ -92,29 +76,41 @@ set(UT_HELPER "${UNIT_TESTS}/UTHelper") set(IT_HELPER "${INTEGRATION_TESTS}/ITODBCHelper") # Without this symbols will be exporting to Unix but not Windows -set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) # Set path for AWS SDK set(aws-cpp-sdk-base "${CMAKE_CURRENT_SOURCE_DIR}/aws-sdk-cpp") -set(aws-cpp-sdk-core_DIR "${PROJECT_ROOT}/sdk-build${BITNESS}/AWSSDK/lib/cmake/aws-cpp-sdk-core") -set(aws-cpp-sdk-sts_DIR "${PROJECT_ROOT}/sdk-build${BITNESS}/AWSSDK/lib/cmake/aws-cpp-sdk-sts") -set(aws-cpp-sdk-timestream-query_DIR "${PROJECT_ROOT}/sdk-build${BITNESS}/AWSSDK/lib/cmake/aws-cpp-sdk-timestream-query") - -set(aws-c-event-stream_DIR "${PROJECT_ROOT}/sdk-build${BITNESS}/AWSSDK/lib/aws-c-event-stream/cmake") -set(aws-c-common_DIR "${PROJECT_ROOT}/sdk-build${BITNESS}/AWSSDK/lib/aws-c-common/cmake") -set(aws-checksums_DIR "${PROJECT_ROOT}/sdk-build${BITNESS}/AWSSDK/lib/aws-checksums/cmake") +if(WIN32) + set(aws-cpp-sdk-core_DIR "${PROJECT_ROOT}/sdk-build${BITNESS}/AWSSDK/lib/cmake/aws-cpp-sdk-core") + set(aws-cpp-sdk-sts_DIR "${PROJECT_ROOT}/sdk-build${BITNESS}/AWSSDK/lib/cmake/aws-cpp-sdk-sts") + set(aws-cpp-sdk-timestream-query_DIR "${PROJECT_ROOT}/sdk-build${BITNESS}/AWSSDK/lib/cmake/aws-cpp-sdk-timestream-query") + # AWS SDK dependencies + set(aws-c-event-stream_DIR "${PROJECT_ROOT}/sdk-build${BITNESS}/AWSSDK/lib/aws-c-event-stream/cmake") + set(aws-c-common_DIR "${PROJECT_ROOT}/sdk-build${BITNESS}/AWSSDK/lib/aws-c-common/cmake") + set(aws-checksums_DIR "${PROJECT_ROOT}/sdk-build${BITNESS}/AWSSDK/lib/aws-checksums/cmake") +else() + set(aws-cpp-sdk-core_DIR "${aws-cpp-sdk-base}/install/lib/cmake/aws-cpp-sdk-core") + set(aws-cpp-sdk-sts_DIR "${aws-cpp-sdk-base}/install/lib/cmake/aws-cpp-sdk-sts") + set(aws-cpp-sdk-timestream-query_DIR "${aws-cpp-sdk-base}/install/lib/cmake/aws-cpp-sdk-timestream-query") + # AWS SDK dependencies + set(aws-c-event-stream_DIR "${aws-cpp-sdk-base}/install/lib/aws-c-event-stream/cmake") + set(aws-c-common_DIR "${aws-cpp-sdk-base}/install/lib/aws-c-common/cmake") + set(aws-checksums_DIR "${aws-cpp-sdk-base}/install/lib/aws-checksums/cmake") +endif() if (WIN32) find_package(AWSSDK REQUIRED core sts timestream-query) +else() + find_package(AWSSDK REQUIRED COMPONENTS core sts timestream-query PATHS aws-sdk-cpp/install NO_DEFAULT_PATH) endif() # General compiler definitions add_compile_definitions ( _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING - UNICODE_SUPPORT - DYNAMIC_LOAD + UNICODE_SUPPORT + DYNAMIC_LOAD _MBCS - _CRT_SECURE_NO_DEPRECATE - _USRDLL + _CRT_SECURE_NO_DEPRECATE + _USRDLL _SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING ) @@ -122,28 +118,28 @@ add_compile_definitions ( _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING # Platform specific compiler definitions if (WIN32 AND BITNESS EQUAL 64) # Windows specific - add_compile_definitions ( _WINDLL - _WIN64 + add_compile_definitions ( _WINDLL + _WIN64 _WINDOWS - WIN_EXPORT + WIN_EXPORT ) elseif (WIN32 AND BITNESS EQUAL 32) # Windows specific - add_compile_definitions ( _WINDLL - _WIN32 + add_compile_definitions ( _WINDLL + _WIN32 _WINDOWS - WIN_EXPORT + WIN_EXPORT ) elseif(APPLE) # macOS specific - add_compile_definitions ( WITH_IODBC + add_compile_definitions ( WITH_IODBC SQLCOLATTRIBUTE_SQLLEN ) # iODBC includes include_directories(/usr/local/include) elseif(UNIX) # Unix specific - add_compile_definitions ( WITH_UNIXODBC + add_compile_definitions ( WITH_UNIXODBC SQLCOLATTRIBUTE_SQLLEN ) endif() @@ -159,9 +155,6 @@ if(BUILD_WITH_TESTS) endif() # Projects to build -if (APPLE) - add_subdirectory(${aws-cpp-sdk-base}) -endif() add_subdirectory(${ODFEODBC_SRC}) add_subdirectory(${ODFEENLIST_SRC}) add_subdirectory(${INSTALL_SRC}) diff --git a/src/IntegrationTests/ITODBCExecution/CMakeLists.txt b/src/IntegrationTests/ITODBCExecution/CMakeLists.txt index b31e5efb7..53ec1b079 100644 --- a/src/IntegrationTests/ITODBCExecution/CMakeLists.txt +++ b/src/IntegrationTests/ITODBCExecution/CMakeLists.txt @@ -25,5 +25,6 @@ include_directories( ${UT_HELPER} add_executable(itodbc_execution ${SOURCE_FILES}) # Library dependencies +target_code_coverage(itodbc_execution PUBLIC AUTO ALL) target_link_libraries(itodbc_execution odfesqlodbc itodbc_helper ut_helper gtest_main) target_compile_definitions(itodbc_execution PUBLIC _UNICODE UNICODE) diff --git a/src/IntegrationTests/ITODBCExecution/test_odbc_execution.cpp b/src/IntegrationTests/ITODBCExecution/test_odbc_execution.cpp index 00fc2413e..61ecf839c 100644 --- a/src/IntegrationTests/ITODBCExecution/test_odbc_execution.cpp +++ b/src/IntegrationTests/ITODBCExecution/test_odbc_execution.cpp @@ -34,6 +34,12 @@ #include #include // clang-format on +#ifdef WIN32 +#define Sleep(milliseconds) Sleep(milliseconds) +#else +#define Sleep(milliseconds) usleep(milliseconds * 1000) +#endif + class TestSQLFetch : public Fixture {}; class TestSQLExecute : public Fixture {}; @@ -462,6 +468,7 @@ TEST_F(TestSQLCancel, QueryInProgress) { } EXPECT_LT(cnt, limit); LogAnyDiagnostics(SQL_HANDLE_STMT, m_hstmt, ret); + Sleep(1000); } // The following test case needs to change the logic of ts_communication before running. diff --git a/src/IntegrationTests/ITODBCSAMLAuthentication/CMakeLists.txt b/src/IntegrationTests/ITODBCSAMLAuthentication/CMakeLists.txt index 3781617e1..a5d79d33a 100644 --- a/src/IntegrationTests/ITODBCSAMLAuthentication/CMakeLists.txt +++ b/src/IntegrationTests/ITODBCSAMLAuthentication/CMakeLists.txt @@ -25,7 +25,6 @@ include_directories(${UT_HELPER} add_executable(itodbc_saml_authentication ${SOURCE_FILES}) # Library dependencies -target_code_coverage(itodbc_saml_authentication PUBLIC AUTO ALL) target_link_libraries(itodbc_saml_authentication odfesqlodbc itodbc_helper ut_helper gtest_main) target_compile_definitions(itodbc_saml_authentication PUBLIC _UNICODE UNICODE) diff --git a/src/UnitTests/UTConn/CMakeLists.txt b/src/UnitTests/UTConn/CMakeLists.txt index 7c5393774..6f69a6c9f 100644 --- a/src/UnitTests/UTConn/CMakeLists.txt +++ b/src/UnitTests/UTConn/CMakeLists.txt @@ -24,5 +24,6 @@ include_directories(${UT_HELPER} add_executable(ut_conn ${SOURCE_FILES}) # Library dependencies +target_code_coverage(ut_conn PUBLIC AUTO ALL) target_link_libraries(ut_conn odfesqlodbc ut_helper gtest_main) target_compile_definitions(ut_conn PUBLIC _UNICODE UNICODE)