diff --git a/.builder/actions/build_samples.py b/.builder/actions/build_samples.py index 79475011b..e85d31949 100644 --- a/.builder/actions/build_samples.py +++ b/.builder/actions/build_samples.py @@ -71,6 +71,8 @@ def run(self, env): '-DCMAKE_BUILD_TYPE=RelWithDebInfo']) # append extra cmake configs steps[-1].extend(cmd_args.cmake_extra) + if sys.platform == "linux" or sys.platform == "linux2": + steps[-1].extend(env.config['cmake_args']) steps.append(['cmake', '--build', build_path, '--config', 'RelWithDebInfo']) @@ -84,6 +86,8 @@ def run(self, env): '-DCMAKE_BUILD_TYPE=RelWithDebInfo']) # append extra cmake configs steps[-1].extend(cmd_args.cmake_extra) + if sys.platform == "linux" or sys.platform == "linux2": + steps[-1].extend(env.config['cmake_args']) steps.append(['cmake', '--build', build_path, '--config', 'RelWithDebInfo']) @@ -97,6 +101,8 @@ def run(self, env): '-DCMAKE_BUILD_TYPE=RelWithDebInfo']) # append extra cmake configs steps[-1].extend(cmd_args.cmake_extra) + if sys.platform == "linux" or sys.platform == "linux2": + steps[-1].extend(env.config['cmake_args']) steps.append(['cmake', '--build', build_path, '--config', 'RelWithDebInfo']) @@ -108,6 +114,8 @@ def run(self, env): f'-H{sample_path}', f'-DCMAKE_PREFIX_PATH={env.install_dir}', '-DCMAKE_BUILD_TYPE=RelWithDebInfo']) + if sys.platform == "linux" or sys.platform == "linux2": + steps[-1].extend(env.config['cmake_args']) steps.append(['cmake', '--build', build_path, '--config', 'RelWithDebInfo']) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ed420b850..1f9af8294 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -747,3 +747,234 @@ jobs: - name: Check for edits to code-generated files run: | ./utils/check_codegen_edits.py + + clang-sanitizers: + runs-on: ubuntu-22.04 # latest + continue-on-error: true # TODO temporary for debugging purpose + strategy: + fail-fast: false # TODO temporary for debugging purpose + matrix: + sanitizer-variants: ["tsan", "asan"] + permissions: + id-token: write # This is required for requesting the JWT + steps: + - name: Build ${{ env.PACKAGE_NAME }} + consumers + run: | + echo "Downloading source" + git clone --recursive https://github.com/aws/aws-iot-device-sdk-cpp-v2.git --branch ${{ env.HEAD_REF || github.ref_name }} + echo "Running builder" + python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')" + python builder.pyz build -p ${{ env.PACKAGE_NAME }} --variant ${{ matrix.sanitizer-variants }} + - name: Running samples in CI setup + run: | + python3 -m pip install boto3 + sudo apt-get update -y + sudo apt-get install softhsm -y + softhsm2-util --version + - name: configure AWS credentials (Fleet provisioning) + if: always() + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_FLEET_PROVISIONING_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run Fleet Provisioning service client test for MQTT311 + if: always() + working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests + run: | + export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils + python3 ./test_cases/test_fleet_provisioning.py --config-file test_cases/mqtt3_fleet_provisioning_cfg.json --thing-name-prefix Fleet_Thing_ + - name: run Fleet Provisioning service client test for MQTT5 + if: always() + working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests + run: | + export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils + python3 ./test_cases/test_fleet_provisioning.py --config-file test_cases/mqtt5_fleet_provisioning_cfg.json --thing-name-prefix Fleet_Thing_ + - name: run Fleet Provisioning with CSR service client test for MQTT311 + if: always() + working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests + run: | + export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils + python3 ./test_cases/test_fleet_provisioning.py --config-file test_cases/mqtt3_fleet_provisioning_with_csr_cfg.json --thing-name-prefix Fleet_Thing_ + - name: run Fleet Provisioning with CSR service client test for MQTT5 + if: always() + working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests + run: | + export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils + python3 ./test_cases/test_fleet_provisioning.py --config-file test_cases/mqtt5_fleet_provisioning_with_csr_cfg.json --thing-name-prefix Fleet_Thing_ + - name: configure AWS credentials (Jobs) + if: always() + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_JOBS_SERVICE_CLIENT_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run mqtt3 Jobs serviceTests + if: always() + working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests + run: | + export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils + python3 ./test_cases/test_jobs_execution.py --config-file ${{ env.CI_SERVICE_TESTS_CFG_FOLDER }}/mqtt3_jobs_cfg.json + - name: run mqtt5 Jobs serviceTests + if: always() + working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests + run: | + export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils + python3 ./test_cases/test_jobs_execution.py --config-file ${{ env.CI_SERVICE_TESTS_CFG_FOLDER }}/mqtt5_jobs_cfg.json + - name: configure AWS credentials (Shadow) + if: always() + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_SHADOW_SERVICE_CLIENT_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run Shadow service client test for MQTT5 + if: always() + working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests + run: | + export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils + python3 ./test_cases/test_shadow_update.py --config-file test_cases/mqtt5_shadow_cfg.json + - name: run Shadow service client test for MQTT311 + if: always() + working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests + run: | + export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils + python3 ./test_cases/test_shadow_update.py --config-file test_cases/mqtt3_shadow_cfg.json + - name: run Named Shadow service client test for MQTT311 + if: always() + working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests + run: | + export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils + python3 ./test_cases/test_shadow_update.py --config-file test_cases/mqtt3_named_shadow_cfg.json + - name: run Named Shadow service client test for MQTT5 + if: always() + working-directory: ./aws-iot-device-sdk-cpp-v2/servicetests + run: | + export PYTHONPATH=${{ github.workspace }}/aws-iot-device-sdk-cpp-v2/utils + python3 ./test_cases/test_shadow_update.py --config-file test_cases/mqtt5_named_shadow_cfg.json + - name: configure AWS credentials (Connect and PubSub) + if: always() + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_PUBSUB_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run Basic Connect sample + if: always() + run: | + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_basic_connect_cfg.json + - name: run Websocket Connect sample + if: always() + run: | + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_websocket_connect_cfg.json + - name: run MQTT3 PubSub sample + if: always() + run: | + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_pubsub_cfg.json + - name: run PKCS11 Connect sample + if: always() + run: | + mkdir -p /tmp/tokens + export SOFTHSM2_CONF=/tmp/softhsm2.conf + echo "directories.tokendir = /tmp/tokens" > /tmp/softhsm2.conf + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_pkcs11_connect_cfg.json + - name: configure AWS credentials (MQTT5) + if: always() + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_MQTT5_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run MQTT5 PubSub sample + if: always() + run: | + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_mqtt5_pubsub_cfg.json + - name: run MQTT5 Shared Subscription sample + if: always() + run: | + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_mqtt5_shared_subscription_cfg.json + - name: configure AWS credentials (Jobs) + if: always() + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_JOBS_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run Jobs sample + if: always() + run: | + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_jobs_cfg.json + - name: run Mqtt5 Jobs sample + if: always() + run: | + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_jobs_mqtt5_cfg.json + - name: configure AWS credentials (Cognito) + if: always() + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_COGNITO_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run CognitoConnect sample + if: always() + run: | + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_cognito_connect_cfg.json + - name: configure AWS credentials (Custom Authorizer) + if: always() + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_CUSTOM_AUTHORIZER_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run CustomAuthorizerConnect sample + if: always() + run: | + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_custom_authorizer_connect_cfg.json + - name: configure AWS credentials (Shadow) + if: always() + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_SHADOW_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run Shadow sample + if: always() + run: | + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_shadow_cfg.json + - name: run Mqtt5 Shadow sample + if: always() + run: | + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_shadow_mqtt5_cfg.json + - name: configure AWS credentials (Fleet provisioning) + if: always() + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_FLEET_PROVISIONING_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run Fleet Provisioning sample + if: always() + run: | + echo "Generating UUID for IoT thing" + Sample_UUID=$(python3 -c "import uuid; print (uuid.uuid4())") + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_fleet_provisioning_cfg.json --input_uuid ${Sample_UUID} + python3 ${{ env.CI_UTILS_FOLDER }}/delete_iot_thing_ci.py --thing_name "Fleet_Thing_${Sample_UUID}" --region "us-east-1" + - name: run Mqtt5 Fleet Provisioning sample + if: always() + run: | + echo "Generating UUID for IoT thing" + Sample_UUID=$(python3 -c "import uuid; print (uuid.uuid4())") + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_fleet_provisioning_mqtt5_cfg.json --input_uuid ${Sample_UUID} + python3 ${{ env.CI_UTILS_FOLDER }}/delete_iot_thing_ci.py --thing_name "Fleet_Thing_${Sample_UUID}" --region "us-east-1" + - name: configure AWS credentials (Secure tunneling) + if: always() + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_SECURE_TUNNEL }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + # Secure Tunneling has special requirements, so it uses a different Python file + - name: run Secure Tunneling sample + if: always() + run: | + python3 ${{ env.CI_UTILS_FOLDER }}/run_secure_tunnel_ci.py --sample_file "./aws-iot-device-sdk-cpp-v2/build/samples/secure_tunneling/secure_tunnel/secure-tunnel" --sample_region ${{ env.AWS_DEFAULT_REGION }} + - name: configure AWS credentials (X509) + if: always() + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ env.CI_X509_ROLE }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} + - name: run X509 sample + if: always() + run: | + python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_x509_connect_cfg.json + # TODO Add GG tests. diff --git a/CMakeLists.txt b/CMakeLists.txt index b9e38de0e..b41c64b99 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,6 +98,8 @@ else() include(AwsFindPackage) endif() +include(AwsSanitizers) + aws_use_package(aws-crt-cpp) add_subdirectory(jobs) diff --git a/builder.json b/builder.json index 293a06351..f1b1b3787 100644 --- a/builder.json +++ b/builder.json @@ -29,6 +29,18 @@ "build" ] }, + "tsan": { + "cmake_args": [ + "-DENABLE_SANITIZERS=ON", + "-DSANITIZERS=thread" + ] + }, + "asan": { + "cmake_args": [ + "-DENABLE_SANITIZERS=ON", + "-DSANITIZERS=address,undefined" + ] + }, "build_gg_samples_only": { "!build_steps": [ "build", diff --git a/devicedefender/CMakeLists.txt b/devicedefender/CMakeLists.txt index c53bd520d..ff5096e80 100644 --- a/devicedefender/CMakeLists.txt +++ b/devicedefender/CMakeLists.txt @@ -102,7 +102,9 @@ if (BUILD_DEPS) endif() endif() -target_link_libraries(IotDeviceDefender-cpp IotDeviceCommon-cpp) +aws_add_sanitizers(IotDeviceDefender-cpp) + +target_link_libraries(IotDeviceDefender-cpp PUBLIC IotDeviceCommon-cpp) install(FILES ${AWS_IOTDEVICEDEFENDER_HEADERS} DESTINATION "include/aws/iotdevicedefender/" COMPONENT Development) diff --git a/devicedefender/tests/CMakeLists.txt b/devicedefender/tests/CMakeLists.txt index 4ec1f7c32..59706fd98 100644 --- a/devicedefender/tests/CMakeLists.txt +++ b/devicedefender/tests/CMakeLists.txt @@ -19,4 +19,5 @@ if (UNIX AND NOT APPLE) add_net_test_case(Mqtt5DeviceDefenderCustomMetricSuccess) add_net_test_case(Mqtt5DeviceDefenderCustomMetricFail) generate_cpp_test_driver(${TEST_BINARY_NAME}) + aws_add_sanitizers(${TEST_BINARY_NAME}) endif() diff --git a/discovery/CMakeLists.txt b/discovery/CMakeLists.txt index d3557c476..666997544 100644 --- a/discovery/CMakeLists.txt +++ b/discovery/CMakeLists.txt @@ -101,7 +101,8 @@ if (BUILD_DEPS) endif() endif() -target_link_libraries(Discovery-cpp ${DEP_AWS_LIBS}) +aws_add_sanitizers(Discovery-cpp) +target_link_libraries(Discovery-cpp PUBLIC ${DEP_AWS_LIBS}) install(FILES ${AWS_DISCOVERY_HEADERS} DESTINATION "include/aws/discovery/" COMPONENT Development) diff --git a/eventstream_rpc/CMakeLists.txt b/eventstream_rpc/CMakeLists.txt index 193d4173b..4086705c6 100644 --- a/eventstream_rpc/CMakeLists.txt +++ b/eventstream_rpc/CMakeLists.txt @@ -99,8 +99,8 @@ if (NOT IS_SUBDIRECTORY_INCLUDE) aws_use_package(aws-crt-cpp) endif() - -target_link_libraries(EventstreamRpc-cpp ${DEP_AWS_LIBS}) +aws_add_sanitizers(EventstreamRpc-cpp) +target_link_libraries(EventstreamRpc-cpp PUBLIC ${DEP_AWS_LIBS}) install(FILES ${AWS_EVENTSTREAMRPC_HEADERS} DESTINATION "include/aws/eventstreamrpc/" COMPONENT Development) diff --git a/eventstream_rpc/tests/CMakeLists.txt b/eventstream_rpc/tests/CMakeLists.txt index 988b2ef12..34f726082 100644 --- a/eventstream_rpc/tests/CMakeLists.txt +++ b/eventstream_rpc/tests/CMakeLists.txt @@ -47,6 +47,7 @@ add_test_case(OperateWhileDisconnected) #add_test_case(EchoOperation) #add_test_case(StressTestClient) generate_cpp_test_driver(${TEST_BINARY_NAME}) +aws_add_sanitizers(${TEST_BINARY_NAME}) target_include_directories(${TEST_BINARY_NAME} PUBLIC $ $) diff --git a/greengrass_ipc/CMakeLists.txt b/greengrass_ipc/CMakeLists.txt index 890c8c188..448d50054 100644 --- a/greengrass_ipc/CMakeLists.txt +++ b/greengrass_ipc/CMakeLists.txt @@ -47,7 +47,7 @@ if (WIN32) endif() add_library(GreengrassIpc-cpp ${AWS_GREENGRASSIPC_CPP_SRC}) -target_link_libraries(GreengrassIpc-cpp EventstreamRpc-cpp) +target_link_libraries(GreengrassIpc-cpp PUBLIC EventstreamRpc-cpp) set_target_properties(GreengrassIpc-cpp PROPERTIES LINKER_LANGUAGE CXX) @@ -107,8 +107,8 @@ if (NOT IS_SUBDIRECTORY_INCLUDE) aws_use_package(aws-crt-cpp) endif() - -target_link_libraries(GreengrassIpc-cpp ${DEP_AWS_LIBS}) +aws_add_sanitizers(GreengrassIpc-cpp) +target_link_libraries(GreengrassIpc-cpp PUBLIC ${DEP_AWS_LIBS}) install(FILES ${AWS_GREENGRASSIPC_HEADERS} DESTINATION "include/aws/greengrass/" COMPONENT Development) diff --git a/identity/CMakeLists.txt b/identity/CMakeLists.txt index 09ea945a5..db299003a 100644 --- a/identity/CMakeLists.txt +++ b/identity/CMakeLists.txt @@ -103,7 +103,8 @@ if (BUILD_DEPS) endif() endif() -target_link_libraries(IotIdentity-cpp ${DEP_AWS_LIBS}) +aws_add_sanitizers(IotIdentity-cpp) +target_link_libraries(IotIdentity-cpp PUBLIC ${DEP_AWS_LIBS}) install(FILES ${AWS_IOTIDENTITY_HEADERS} DESTINATION "include/aws/iotidentity/" COMPONENT Development) diff --git a/iotdevicecommon/CMakeLists.txt b/iotdevicecommon/CMakeLists.txt index 9ab28e8b0..43267b556 100644 --- a/iotdevicecommon/CMakeLists.txt +++ b/iotdevicecommon/CMakeLists.txt @@ -104,7 +104,9 @@ if (BUILD_DEPS) aws_use_package(aws-c-iot) endif() -target_link_libraries(IotDeviceCommon-cpp ${DEP_AWS_LIBS}) +aws_add_sanitizers(IotDeviceCommon-cpp) + +target_link_libraries(IotDeviceCommon-cpp PUBLIC ${DEP_AWS_LIBS}) install(FILES ${AWS_IOTDEVICECOMMON_HEADERS} DESTINATION "include/aws/iotdevicecommon/" COMPONENT Development) diff --git a/jobs/CMakeLists.txt b/jobs/CMakeLists.txt index 5f436f8ec..627ec3601 100644 --- a/jobs/CMakeLists.txt +++ b/jobs/CMakeLists.txt @@ -103,7 +103,9 @@ if (BUILD_DEPS) endif() endif() -target_link_libraries(IotJobs-cpp ${DEP_AWS_LIBS}) +aws_add_sanitizers(IotJobs-cpp) + +target_link_libraries(IotJobs-cpp PUBLIC ${DEP_AWS_LIBS}) install(FILES ${AWS_IOTJOBS_HEADERS} DESTINATION "include/aws/iotjobs/" COMPONENT Development) diff --git a/samples/device_defender/basic_report/CMakeLists.txt b/samples/device_defender/basic_report/CMakeLists.txt index 0e54da9d3..94ab3d329 100644 --- a/samples/device_defender/basic_report/CMakeLists.txt +++ b/samples/device_defender/basic_report/CMakeLists.txt @@ -24,6 +24,14 @@ if (UNIX AND NOT APPLE) find_package(IotDeviceCommon-cpp REQUIRED) find_package(IotDeviceDefender-cpp REQUIRED) - target_link_libraries(${PROJECT_NAME} AWS::aws-crt-cpp AWS::IotDeviceCommon-cpp AWS::IotDeviceDefender-cpp) + if (ENABLE_SANITIZERS AND UNIX AND NOT APPLE) + include(GNUInstallDirs) + list(APPEND CMAKE_MODULE_PATH "${CMAKE_PREFIX_PATH}/${CMAKE_INSTALL_LIBDIR}/cmake") + include(AwsSanitizers) + enable_language(C) + aws_add_sanitizers(${PROJECT_NAME}) + endif() + + target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-crt-cpp AWS::IotDeviceCommon-cpp AWS::IotDeviceDefender-cpp) endif() diff --git a/samples/device_defender/mqtt5_basic_report/CMakeLists.txt b/samples/device_defender/mqtt5_basic_report/CMakeLists.txt index f7f87ccb0..2e7f79785 100644 --- a/samples/device_defender/mqtt5_basic_report/CMakeLists.txt +++ b/samples/device_defender/mqtt5_basic_report/CMakeLists.txt @@ -24,6 +24,14 @@ if (UNIX AND NOT APPLE) find_package(IotDeviceCommon-cpp REQUIRED) find_package(IotDeviceDefender-cpp REQUIRED) - target_link_libraries(${PROJECT_NAME} AWS::aws-crt-cpp AWS::IotDeviceCommon-cpp AWS::IotDeviceDefender-cpp) + if (ENABLE_SANITIZERS AND UNIX AND NOT APPLE) + include(GNUInstallDirs) + list(APPEND CMAKE_MODULE_PATH "${CMAKE_PREFIX_PATH}/${CMAKE_INSTALL_LIBDIR}/cmake") + include(AwsSanitizers) + enable_language(C) + aws_add_sanitizers(${PROJECT_NAME}) + endif() + + target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-crt-cpp AWS::IotDeviceCommon-cpp AWS::IotDeviceDefender-cpp) endif() diff --git a/samples/fleet_provisioning/fleet_provisioning/CMakeLists.txt b/samples/fleet_provisioning/fleet_provisioning/CMakeLists.txt index 71b470d6d..271c5b10f 100644 --- a/samples/fleet_provisioning/fleet_provisioning/CMakeLists.txt +++ b/samples/fleet_provisioning/fleet_provisioning/CMakeLists.txt @@ -25,4 +25,12 @@ find_package(IotIdentity-cpp REQUIRED) install(TARGETS ${PROJECT_NAME} DESTINATION bin) +if (ENABLE_SANITIZERS AND UNIX AND NOT APPLE) + include(GNUInstallDirs) + list(APPEND CMAKE_MODULE_PATH "${CMAKE_PREFIX_PATH}/${CMAKE_INSTALL_LIBDIR}/cmake") + include(AwsSanitizers) + enable_language(C) + aws_add_sanitizers(${PROJECT_NAME}) +endif() + target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-crt-cpp AWS::IotIdentity-cpp) diff --git a/samples/fleet_provisioning/mqtt5_fleet_provisioning/CMakeLists.txt b/samples/fleet_provisioning/mqtt5_fleet_provisioning/CMakeLists.txt index 644023257..b117e6e68 100644 --- a/samples/fleet_provisioning/mqtt5_fleet_provisioning/CMakeLists.txt +++ b/samples/fleet_provisioning/mqtt5_fleet_provisioning/CMakeLists.txt @@ -25,4 +25,12 @@ find_package(IotIdentity-cpp REQUIRED) install(TARGETS ${PROJECT_NAME} DESTINATION bin) +if (ENABLE_SANITIZERS AND UNIX AND NOT APPLE) + include(GNUInstallDirs) + list(APPEND CMAKE_MODULE_PATH "${CMAKE_PREFIX_PATH}/${CMAKE_INSTALL_LIBDIR}/cmake") + include(AwsSanitizers) + enable_language(C) + aws_add_sanitizers(${PROJECT_NAME}) +endif() + target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-crt-cpp AWS::IotIdentity-cpp) diff --git a/samples/greengrass/basic_discovery/CMakeLists.txt b/samples/greengrass/basic_discovery/CMakeLists.txt index b565c8d50..3f75a0e80 100644 --- a/samples/greengrass/basic_discovery/CMakeLists.txt +++ b/samples/greengrass/basic_discovery/CMakeLists.txt @@ -25,4 +25,12 @@ find_package(Discovery-cpp REQUIRED) install(TARGETS ${PROJECT_NAME} DESTINATION bin) +if (ENABLE_SANITIZERS AND UNIX AND NOT APPLE) + include(GNUInstallDirs) + list(APPEND CMAKE_MODULE_PATH "${CMAKE_PREFIX_PATH}/${CMAKE_INSTALL_LIBDIR}/cmake") + include(AwsSanitizers) + enable_language(C) + aws_add_sanitizers(${PROJECT_NAME}) +endif() + target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-crt-cpp AWS::Discovery-cpp) diff --git a/samples/greengrass/ipc/CMakeLists.txt b/samples/greengrass/ipc/CMakeLists.txt index e7b96c8e0..b604623f6 100644 --- a/samples/greengrass/ipc/CMakeLists.txt +++ b/samples/greengrass/ipc/CMakeLists.txt @@ -25,4 +25,12 @@ find_package(GreengrassIpc-cpp REQUIRED) install(TARGETS ${PROJECT_NAME} DESTINATION bin) +if (ENABLE_SANITIZERS AND UNIX AND NOT APPLE) + include(GNUInstallDirs) + list(APPEND CMAKE_MODULE_PATH "${CMAKE_PREFIX_PATH}/${CMAKE_INSTALL_LIBDIR}/cmake") + include(AwsSanitizers) + enable_language(C) + aws_add_sanitizers(${PROJECT_NAME}) +endif() + target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-crt-cpp AWS::EventstreamRpc-cpp AWS::GreengrassIpc-cpp) diff --git a/samples/jobs/job_execution/CMakeLists.txt b/samples/jobs/job_execution/CMakeLists.txt index c0009043c..25633c572 100644 --- a/samples/jobs/job_execution/CMakeLists.txt +++ b/samples/jobs/job_execution/CMakeLists.txt @@ -25,4 +25,12 @@ find_package(IotJobs-cpp REQUIRED) install(TARGETS ${PROJECT_NAME} DESTINATION bin) +if (ENABLE_SANITIZERS AND UNIX AND NOT APPLE) + include(GNUInstallDirs) + list(APPEND CMAKE_MODULE_PATH "${CMAKE_PREFIX_PATH}/${CMAKE_INSTALL_LIBDIR}/cmake") + include(AwsSanitizers) + enable_language(C) + aws_add_sanitizers(${PROJECT_NAME}) +endif() + target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-crt-cpp AWS::IotJobs-cpp) diff --git a/samples/jobs/mqtt5_job_execution/CMakeLists.txt b/samples/jobs/mqtt5_job_execution/CMakeLists.txt index ec06a6d41..da1e4aebf 100644 --- a/samples/jobs/mqtt5_job_execution/CMakeLists.txt +++ b/samples/jobs/mqtt5_job_execution/CMakeLists.txt @@ -25,4 +25,12 @@ find_package(IotJobs-cpp REQUIRED) install(TARGETS ${PROJECT_NAME} DESTINATION bin) +if (ENABLE_SANITIZERS AND UNIX AND NOT APPLE) + include(GNUInstallDirs) + list(APPEND CMAKE_MODULE_PATH "${CMAKE_PREFIX_PATH}/${CMAKE_INSTALL_LIBDIR}/cmake") + include(AwsSanitizers) + enable_language(C) + aws_add_sanitizers(${PROJECT_NAME}) +endif() + target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-crt-cpp AWS::IotJobs-cpp) diff --git a/samples/jobs/mqtt5_job_execution/main.cpp b/samples/jobs/mqtt5_job_execution/main.cpp index d3e3dbcd8..6782ccb8f 100644 --- a/samples/jobs/mqtt5_job_execution/main.cpp +++ b/samples/jobs/mqtt5_job_execution/main.cpp @@ -209,6 +209,7 @@ int main(int argc, char *argv[]) } else { + fprintf(stderr, "No pending jobs, exiting\n"); exit(-1); } } diff --git a/samples/mqtt/basic_connect/CMakeLists.txt b/samples/mqtt/basic_connect/CMakeLists.txt index 0174831a0..aee43a095 100644 --- a/samples/mqtt/basic_connect/CMakeLists.txt +++ b/samples/mqtt/basic_connect/CMakeLists.txt @@ -22,4 +22,12 @@ endif () find_package(aws-crt-cpp REQUIRED) -target_link_libraries(${PROJECT_NAME} AWS::aws-crt-cpp) +if (ENABLE_SANITIZERS AND UNIX AND NOT APPLE) + include(GNUInstallDirs) + list(APPEND CMAKE_MODULE_PATH "${CMAKE_PREFIX_PATH}/${CMAKE_INSTALL_LIBDIR}/cmake") + include(AwsSanitizers) + enable_language(C) + aws_add_sanitizers(${PROJECT_NAME}) +endif() + +target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-crt-cpp) diff --git a/samples/mqtt/cognito_connect/CMakeLists.txt b/samples/mqtt/cognito_connect/CMakeLists.txt index 394ebe1c4..983246398 100644 --- a/samples/mqtt/cognito_connect/CMakeLists.txt +++ b/samples/mqtt/cognito_connect/CMakeLists.txt @@ -22,4 +22,12 @@ endif () find_package(aws-crt-cpp REQUIRED) -target_link_libraries(${PROJECT_NAME} AWS::aws-crt-cpp) +if (ENABLE_SANITIZERS AND UNIX AND NOT APPLE) + include(GNUInstallDirs) + list(APPEND CMAKE_MODULE_PATH "${CMAKE_PREFIX_PATH}/${CMAKE_INSTALL_LIBDIR}/cmake") + include(AwsSanitizers) + enable_language(C) + aws_add_sanitizers(${PROJECT_NAME}) +endif() + +target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-crt-cpp) diff --git a/samples/mqtt/custom_authorizer_connect/CMakeLists.txt b/samples/mqtt/custom_authorizer_connect/CMakeLists.txt index 266c53351..77d1100af 100644 --- a/samples/mqtt/custom_authorizer_connect/CMakeLists.txt +++ b/samples/mqtt/custom_authorizer_connect/CMakeLists.txt @@ -22,4 +22,12 @@ endif () find_package(aws-crt-cpp REQUIRED) -target_link_libraries(${PROJECT_NAME} AWS::aws-crt-cpp) +if (ENABLE_SANITIZERS AND UNIX AND NOT APPLE) + include(GNUInstallDirs) + list(APPEND CMAKE_MODULE_PATH "${CMAKE_PREFIX_PATH}/${CMAKE_INSTALL_LIBDIR}/cmake") + include(AwsSanitizers) + enable_language(C) + aws_add_sanitizers(${PROJECT_NAME}) +endif() + +target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-crt-cpp) diff --git a/samples/mqtt/pkcs11_connect/CMakeLists.txt b/samples/mqtt/pkcs11_connect/CMakeLists.txt index e512589f0..b06cec15b 100644 --- a/samples/mqtt/pkcs11_connect/CMakeLists.txt +++ b/samples/mqtt/pkcs11_connect/CMakeLists.txt @@ -32,4 +32,12 @@ endif() find_package(aws-crt-cpp REQUIRED) -target_link_libraries(${PROJECT_NAME} AWS::aws-crt-cpp) +if (ENABLE_SANITIZERS AND UNIX AND NOT APPLE) + include(GNUInstallDirs) + list(APPEND CMAKE_MODULE_PATH "${CMAKE_PREFIX_PATH}/${CMAKE_INSTALL_LIBDIR}/cmake") + include(AwsSanitizers) + enable_language(C) + aws_add_sanitizers(${PROJECT_NAME}) +endif() + +target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-crt-cpp) diff --git a/samples/mqtt/pkcs12_connect/CMakeLists.txt b/samples/mqtt/pkcs12_connect/CMakeLists.txt index 43c996fad..65096cc2f 100644 --- a/samples/mqtt/pkcs12_connect/CMakeLists.txt +++ b/samples/mqtt/pkcs12_connect/CMakeLists.txt @@ -22,4 +22,12 @@ endif () find_package(aws-crt-cpp REQUIRED) -target_link_libraries(${PROJECT_NAME} AWS::aws-crt-cpp) +if (ENABLE_SANITIZERS AND UNIX AND NOT APPLE) + include(GNUInstallDirs) + list(APPEND CMAKE_MODULE_PATH "${CMAKE_PREFIX_PATH}/${CMAKE_INSTALL_LIBDIR}/cmake") + include(AwsSanitizers) + enable_language(C) + aws_add_sanitizers(${PROJECT_NAME}) +endif() + +target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-crt-cpp) diff --git a/samples/mqtt/websocket_connect/CMakeLists.txt b/samples/mqtt/websocket_connect/CMakeLists.txt index 7d7253569..5f70786f9 100644 --- a/samples/mqtt/websocket_connect/CMakeLists.txt +++ b/samples/mqtt/websocket_connect/CMakeLists.txt @@ -22,4 +22,12 @@ endif () find_package(aws-crt-cpp REQUIRED) -target_link_libraries(${PROJECT_NAME} AWS::aws-crt-cpp) +if (ENABLE_SANITIZERS AND UNIX AND NOT APPLE) + include(GNUInstallDirs) + list(APPEND CMAKE_MODULE_PATH "${CMAKE_PREFIX_PATH}/${CMAKE_INSTALL_LIBDIR}/cmake") + include(AwsSanitizers) + enable_language(C) + aws_add_sanitizers(${PROJECT_NAME}) +endif() + +target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-crt-cpp) diff --git a/samples/mqtt/windows_cert_connect/CMakeLists.txt b/samples/mqtt/windows_cert_connect/CMakeLists.txt index 4448aa28d..ef9f0b6cb 100644 --- a/samples/mqtt/windows_cert_connect/CMakeLists.txt +++ b/samples/mqtt/windows_cert_connect/CMakeLists.txt @@ -22,4 +22,12 @@ endif () find_package(aws-crt-cpp REQUIRED) +if (ENABLE_SANITIZERS AND UNIX AND NOT APPLE) + include(GNUInstallDirs) + list(APPEND CMAKE_MODULE_PATH "${CMAKE_PREFIX_PATH}/${CMAKE_INSTALL_LIBDIR}/cmake") + include(AwsSanitizers) + enable_language(C) + aws_add_sanitizers(${PROJECT_NAME}) +endif() + target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-crt-cpp) diff --git a/samples/mqtt/x509_credentials_provider_connect/CMakeLists.txt b/samples/mqtt/x509_credentials_provider_connect/CMakeLists.txt index 48b55ab3b..bc681341a 100644 --- a/samples/mqtt/x509_credentials_provider_connect/CMakeLists.txt +++ b/samples/mqtt/x509_credentials_provider_connect/CMakeLists.txt @@ -22,4 +22,12 @@ endif () find_package(aws-crt-cpp REQUIRED) -target_link_libraries(${PROJECT_NAME} AWS::aws-crt-cpp) +if (ENABLE_SANITIZERS AND UNIX AND NOT APPLE) + include(GNUInstallDirs) + list(APPEND CMAKE_MODULE_PATH "${CMAKE_PREFIX_PATH}/${CMAKE_INSTALL_LIBDIR}/cmake") + include(AwsSanitizers) + enable_language(C) + aws_add_sanitizers(${PROJECT_NAME}) +endif() + +target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-crt-cpp) diff --git a/samples/mqtt5/mqtt5_pubsub/CMakeLists.txt b/samples/mqtt5/mqtt5_pubsub/CMakeLists.txt index 5435c3f58..7bf71eb99 100644 --- a/samples/mqtt5/mqtt5_pubsub/CMakeLists.txt +++ b/samples/mqtt5/mqtt5_pubsub/CMakeLists.txt @@ -22,4 +22,12 @@ endif () find_package(aws-crt-cpp REQUIRED) -target_link_libraries(${PROJECT_NAME} AWS::aws-crt-cpp) +if (ENABLE_SANITIZERS AND UNIX AND NOT APPLE) + include(GNUInstallDirs) + list(APPEND CMAKE_MODULE_PATH "${CMAKE_PREFIX_PATH}/${CMAKE_INSTALL_LIBDIR}/cmake") + include(AwsSanitizers) + enable_language(C) + aws_add_sanitizers(${PROJECT_NAME}) +endif() + +target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-crt-cpp) diff --git a/samples/mqtt5/mqtt5_shared_subscription/CMakeLists.txt b/samples/mqtt5/mqtt5_shared_subscription/CMakeLists.txt index eae2822d9..0500606e0 100644 --- a/samples/mqtt5/mqtt5_shared_subscription/CMakeLists.txt +++ b/samples/mqtt5/mqtt5_shared_subscription/CMakeLists.txt @@ -22,4 +22,12 @@ endif () find_package(aws-crt-cpp REQUIRED) -target_link_libraries(${PROJECT_NAME} AWS::aws-crt-cpp) +if (ENABLE_SANITIZERS AND UNIX AND NOT APPLE) + include(GNUInstallDirs) + list(APPEND CMAKE_MODULE_PATH "${CMAKE_PREFIX_PATH}/${CMAKE_INSTALL_LIBDIR}/cmake") + include(AwsSanitizers) + enable_language(C) + aws_add_sanitizers(${PROJECT_NAME}) +endif() + +target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-crt-cpp) diff --git a/samples/pub_sub/basic_pub_sub/CMakeLists.txt b/samples/pub_sub/basic_pub_sub/CMakeLists.txt index 21e471903..cb58fa5a8 100644 --- a/samples/pub_sub/basic_pub_sub/CMakeLists.txt +++ b/samples/pub_sub/basic_pub_sub/CMakeLists.txt @@ -22,4 +22,12 @@ endif () find_package(aws-crt-cpp REQUIRED) -target_link_libraries(${PROJECT_NAME} AWS::aws-crt-cpp) +if (ENABLE_SANITIZERS AND UNIX AND NOT APPLE) + include(GNUInstallDirs) + list(APPEND CMAKE_MODULE_PATH "${CMAKE_PREFIX_PATH}/${CMAKE_INSTALL_LIBDIR}/cmake") + include(AwsSanitizers) + enable_language(C) + aws_add_sanitizers(${PROJECT_NAME}) +endif() + +target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-crt-cpp) diff --git a/samples/pub_sub/cycle_pub_sub/CMakeLists.txt b/samples/pub_sub/cycle_pub_sub/CMakeLists.txt index 947aaa0a5..d01edd67a 100644 --- a/samples/pub_sub/cycle_pub_sub/CMakeLists.txt +++ b/samples/pub_sub/cycle_pub_sub/CMakeLists.txt @@ -22,4 +22,12 @@ endif () find_package(aws-crt-cpp REQUIRED) -target_link_libraries(${PROJECT_NAME} AWS::aws-crt-cpp) +if (ENABLE_SANITIZERS AND UNIX AND NOT APPLE) + include(GNUInstallDirs) + list(APPEND CMAKE_MODULE_PATH "${CMAKE_PREFIX_PATH}/${CMAKE_INSTALL_LIBDIR}/cmake") + include(AwsSanitizers) + enable_language(C) + aws_add_sanitizers(${PROJECT_NAME}) +endif() + +target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-crt-cpp) diff --git a/samples/secure_tunneling/secure_tunnel/CMakeLists.txt b/samples/secure_tunneling/secure_tunnel/CMakeLists.txt index 41ef2c4f3..d10ad625d 100644 --- a/samples/secure_tunneling/secure_tunnel/CMakeLists.txt +++ b/samples/secure_tunneling/secure_tunnel/CMakeLists.txt @@ -26,4 +26,12 @@ find_package(IotSecureTunneling-cpp REQUIRED) install(TARGETS ${PROJECT_NAME} DESTINATION bin) -target_link_libraries(${PROJECT_NAME} AWS::aws-crt-cpp AWS::IotDeviceCommon-cpp AWS::IotSecureTunneling-cpp) +if (ENABLE_SANITIZERS AND UNIX AND NOT APPLE) + include(GNUInstallDirs) + list(APPEND CMAKE_MODULE_PATH "${CMAKE_PREFIX_PATH}/${CMAKE_INSTALL_LIBDIR}/cmake") + include(AwsSanitizers) + enable_language(C) + aws_add_sanitizers(${PROJECT_NAME}) +endif() + +target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-crt-cpp AWS::IotDeviceCommon-cpp AWS::IotSecureTunneling-cpp) diff --git a/samples/secure_tunneling/tunnel_notification/CMakeLists.txt b/samples/secure_tunneling/tunnel_notification/CMakeLists.txt index 69388d69e..50c1dc185 100644 --- a/samples/secure_tunneling/tunnel_notification/CMakeLists.txt +++ b/samples/secure_tunneling/tunnel_notification/CMakeLists.txt @@ -26,4 +26,12 @@ find_package(IotSecureTunneling-cpp REQUIRED) install(TARGETS ${PROJECT_NAME} DESTINATION bin) +if (ENABLE_SANITIZERS AND UNIX AND NOT APPLE) + include(GNUInstallDirs) + list(APPEND CMAKE_MODULE_PATH "${CMAKE_PREFIX_PATH}/${CMAKE_INSTALL_LIBDIR}/cmake") + include(AwsSanitizers) + enable_language(C) + aws_add_sanitizers(${PROJECT_NAME}) +endif() + target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-crt-cpp AWS::IotDeviceCommon-cpp AWS::IotSecureTunneling-cpp) diff --git a/samples/shadow/mqtt5_shadow_sync/CMakeLists.txt b/samples/shadow/mqtt5_shadow_sync/CMakeLists.txt index 3dc9c1f07..5c7173ef7 100644 --- a/samples/shadow/mqtt5_shadow_sync/CMakeLists.txt +++ b/samples/shadow/mqtt5_shadow_sync/CMakeLists.txt @@ -25,4 +25,12 @@ find_package(IotShadow-cpp REQUIRED) install(TARGETS ${PROJECT_NAME} DESTINATION bin) +if (ENABLE_SANITIZERS AND UNIX AND NOT APPLE) + include(GNUInstallDirs) + list(APPEND CMAKE_MODULE_PATH "${CMAKE_PREFIX_PATH}/${CMAKE_INSTALL_LIBDIR}/cmake") + include(AwsSanitizers) + enable_language(C) + aws_add_sanitizers(${PROJECT_NAME}) +endif() + target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-crt-cpp AWS::IotShadow-cpp) diff --git a/samples/shadow/shadow_sync/CMakeLists.txt b/samples/shadow/shadow_sync/CMakeLists.txt index cf2270af4..0ec66f2aa 100644 --- a/samples/shadow/shadow_sync/CMakeLists.txt +++ b/samples/shadow/shadow_sync/CMakeLists.txt @@ -25,4 +25,12 @@ find_package(IotShadow-cpp REQUIRED) install(TARGETS ${PROJECT_NAME} DESTINATION bin) +if (ENABLE_SANITIZERS AND UNIX AND NOT APPLE) + include(GNUInstallDirs) + list(APPEND CMAKE_MODULE_PATH "${CMAKE_PREFIX_PATH}/${CMAKE_INSTALL_LIBDIR}/cmake") + include(AwsSanitizers) + enable_language(C) + aws_add_sanitizers(${PROJECT_NAME}) +endif() + target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-crt-cpp AWS::IotShadow-cpp) diff --git a/secure_tunneling/CMakeLists.txt b/secure_tunneling/CMakeLists.txt index 5b15026b6..b8ac29df4 100644 --- a/secure_tunneling/CMakeLists.txt +++ b/secure_tunneling/CMakeLists.txt @@ -102,7 +102,9 @@ if (BUILD_DEPS) endif() endif() -target_link_libraries(IotSecureTunneling-cpp IotDeviceCommon-cpp) +aws_add_sanitizers(IotSecureTunneling-cpp) + +target_link_libraries(IotSecureTunneling-cpp PUBLIC IotDeviceCommon-cpp) install(FILES ${AWS_IOTSECURETUNNELING_HEADERS} DESTINATION "include/aws/iotsecuretunneling/" COMPONENT Development) @@ -132,4 +134,3 @@ configure_file("cmake/iotsecuretunneling-cpp-config.cmake" install(FILES "${CMAKE_CURRENT_BINARY_DIR}/iotsecuretunneling-cpp-config.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/IotSecureTunneling-cpp/cmake/" COMPONENT Development) - diff --git a/secure_tunneling/tests/CMakeLists.txt b/secure_tunneling/tests/CMakeLists.txt index de0cc2592..a13629bb7 100644 --- a/secure_tunneling/tests/CMakeLists.txt +++ b/secure_tunneling/tests/CMakeLists.txt @@ -25,4 +25,12 @@ find_package(IotSecureTunneling-cpp REQUIRED) install(TARGETS ${PROJECT_NAME} DESTINATION bin) -target_link_libraries(${PROJECT_NAME} AWS::aws-crt-cpp AWS::IotDeviceCommon-cpp AWS::IotSecureTunneling-cpp) +if (ENABLE_SANITIZERS AND UNIX AND NOT APPLE) + include(GNUInstallDirs) + list(APPEND CMAKE_MODULE_PATH "${CMAKE_PREFIX_PATH}/${CMAKE_INSTALL_LIBDIR}/cmake") + include(AwsSanitizers) + enable_language(C) + aws_add_sanitizers(${PROJECT_NAME}) +endif() + +target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-crt-cpp AWS::IotDeviceCommon-cpp AWS::IotSecureTunneling-cpp) diff --git a/servicetests/tests/FleetProvisioning/CMakeLists.txt b/servicetests/tests/FleetProvisioning/CMakeLists.txt index b6a778f9d..624156a8d 100644 --- a/servicetests/tests/FleetProvisioning/CMakeLists.txt +++ b/servicetests/tests/FleetProvisioning/CMakeLists.txt @@ -25,4 +25,12 @@ find_package(IotIdentity-cpp REQUIRED) install(TARGETS ${PROJECT_NAME} DESTINATION bin) +if (ENABLE_SANITIZERS AND UNIX AND NOT APPLE) + include(GNUInstallDirs) + list(APPEND CMAKE_MODULE_PATH "${CMAKE_PREFIX_PATH}/${CMAKE_INSTALL_LIBDIR}/cmake") + include(AwsSanitizers) + enable_language(C) + aws_add_sanitizers(${PROJECT_NAME}) +endif() + target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-crt-cpp AWS::IotIdentity-cpp) diff --git a/servicetests/tests/JobsExecution/CMakeLists.txt b/servicetests/tests/JobsExecution/CMakeLists.txt index 77dc0b6e1..e0a1d2078 100644 --- a/servicetests/tests/JobsExecution/CMakeLists.txt +++ b/servicetests/tests/JobsExecution/CMakeLists.txt @@ -25,4 +25,12 @@ find_package(IotJobs-cpp REQUIRED) install(TARGETS ${PROJECT_NAME} DESTINATION bin) +if (ENABLE_SANITIZERS AND UNIX AND NOT APPLE) + include(GNUInstallDirs) + list(APPEND CMAKE_MODULE_PATH "${CMAKE_PREFIX_PATH}/${CMAKE_INSTALL_LIBDIR}/cmake") + include(AwsSanitizers) + enable_language(C) + aws_add_sanitizers(${PROJECT_NAME}) +endif() + target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-crt-cpp AWS::IotJobs-cpp) diff --git a/servicetests/tests/ShadowUpdate/CMakeLists.txt b/servicetests/tests/ShadowUpdate/CMakeLists.txt index 567781ffe..873e3b209 100644 --- a/servicetests/tests/ShadowUpdate/CMakeLists.txt +++ b/servicetests/tests/ShadowUpdate/CMakeLists.txt @@ -25,4 +25,12 @@ find_package(IotShadow-cpp REQUIRED) install(TARGETS ${PROJECT_NAME} DESTINATION bin) +if (ENABLE_SANITIZERS AND UNIX AND NOT APPLE) + include(GNUInstallDirs) + list(APPEND CMAKE_MODULE_PATH "${CMAKE_PREFIX_PATH}/${CMAKE_INSTALL_LIBDIR}/cmake") + include(AwsSanitizers) + enable_language(C) + aws_add_sanitizers(${PROJECT_NAME}) +endif() + target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-crt-cpp AWS::IotShadow-cpp) diff --git a/shadow/CMakeLists.txt b/shadow/CMakeLists.txt index 1f717b8c5..c09613825 100644 --- a/shadow/CMakeLists.txt +++ b/shadow/CMakeLists.txt @@ -103,7 +103,9 @@ if (BUILD_DEPS) endif() endif() -target_link_libraries(IotShadow-cpp ${DEP_AWS_LIBS}) +aws_add_sanitizers(IotShadow-cpp) + +target_link_libraries(IotShadow-cpp PUBLIC ${DEP_AWS_LIBS}) install(FILES ${AWS_IOTSHADOW_HEADERS} DESTINATION "include/aws/iotshadow/" COMPONENT Development) diff --git a/utils/run_sample_ci.py b/utils/run_sample_ci.py index 1e87c537e..fbfa034ef 100644 --- a/utils/run_sample_ci.py +++ b/utils/run_sample_ci.py @@ -290,7 +290,11 @@ def launch_sample(): elif (config_json['language'] == "CPP"): try: sample_return = subprocess.run( - args=config_json_arguments_list, executable=config_json['sample_file'], timeout=600, stderr=subprocess.STDOUT, stdout=subprocess.PIPE) + args=config_json_arguments_list, executable=config_json['sample_file'], timeout=600, capture_output=True, text=True) + print("stdout:") + print(sample_return.stdout) + print("stderr:") + print(sample_return.stderr) exit_code = sample_return.returncode except subprocess.TimeoutExpired as timeOut: sys.exit(-1)