-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test checking for memory leaks using crt mem tracer
- Loading branch information
Showing
5 changed files
with
137 additions
and
37 deletions.
There are no files selected for viewing
89 changes: 52 additions & 37 deletions
89
tests/aws-cpp-sdk-s3-crt-integration-tests/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,52 @@ | ||
add_project(aws-cpp-sdk-s3-crt-integration-tests | ||
"Tests for the AWS S3 CRT C++ SDK" | ||
aws-cpp-sdk-s3-crt | ||
testing-resources | ||
aws-cpp-sdk-core) | ||
|
||
file(GLOB AWS_S3_CRT_SRC | ||
"${CMAKE_CURRENT_SOURCE_DIR}/*.cpp" | ||
) | ||
|
||
file(GLOB AWS_S3_CRT_INTEGRATION_TESTS_SRC | ||
${AWS_S3_CRT_SRC} | ||
) | ||
|
||
add_definitions(-DRESOURCES_DIR="${CMAKE_CURRENT_SOURCE_DIR}/resources") | ||
|
||
if(MSVC AND BUILD_SHARED_LIBS) | ||
add_definitions(-DGTEST_LINKED_AS_SHARED_LIBRARY=1) | ||
endif() | ||
|
||
enable_testing() | ||
|
||
if(PLATFORM_ANDROID AND BUILD_SHARED_LIBS) | ||
add_library(${PROJECT_NAME} ${AWS_S3_CRT_INTEGRATION_TESTS_SRC}) | ||
else() | ||
add_executable(${PROJECT_NAME} ${AWS_S3_CRT_INTEGRATION_TESTS_SRC}) | ||
endif() | ||
|
||
set_compiler_flags(${PROJECT_NAME}) | ||
set_compiler_warnings(${PROJECT_NAME}) | ||
|
||
target_link_libraries(${PROJECT_NAME} ${PROJECT_LIBS}) | ||
|
||
if(MSVC AND BUILD_SHARED_LIBS) | ||
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/DELAYLOAD:aws-cpp-sdk-s3-crt.dll /DELAYLOAD:aws-cpp-sdk-core.dll") | ||
target_link_libraries(${PROJECT_NAME} delayimp.lib) | ||
endif() | ||
set(TEST_LIST "aws-cpp-sdk-s3-crt-integration-tests:RunTests.cpp") | ||
|
||
# Only run memlimiter test if we are building with custom memory management | ||
if (CUSTOM_MEMORY_MANAGEMENT) | ||
list(APPEND TEST_LIST "aws-cpp-sdk-s3-crt-memory-checked-integration-tests:RunTestsWithMemTracer.cpp") | ||
endif () | ||
|
||
foreach(TEST IN LISTS TEST_LIST) | ||
string(REPLACE ":" ";" TEST_ITEMS "${TEST}") | ||
list(GET TEST_ITEMS 0 TEST_PROJECT_NAME) | ||
list(GET TEST_ITEMS 1 TEST_MAIN_FILE) | ||
|
||
add_project("${TEST_PROJECT_NAME}" | ||
"Tests for the AWS S3 CRT C++ SDK" | ||
aws-cpp-sdk-s3-crt | ||
testing-resources | ||
aws-cpp-sdk-core) | ||
|
||
file(GLOB AWS_S3_CRT_SRC | ||
"${TEST_MAIN_FILE}" | ||
"BucketAndObjectOperationTest.cpp" | ||
"S3ExpressTest.cpp" | ||
) | ||
|
||
file(GLOB AWS_S3_CRT_INTEGRATION_TESTS_SRC | ||
${AWS_S3_CRT_SRC} | ||
) | ||
|
||
add_definitions(-DRESOURCES_DIR="${CMAKE_CURRENT_SOURCE_DIR}/resources") | ||
|
||
if(MSVC AND BUILD_SHARED_LIBS) | ||
add_definitions(-DGTEST_LINKED_AS_SHARED_LIBRARY=1) | ||
endif() | ||
|
||
enable_testing() | ||
|
||
if(PLATFORM_ANDROID AND BUILD_SHARED_LIBS) | ||
add_library(${PROJECT_NAME} ${AWS_S3_CRT_INTEGRATION_TESTS_SRC}) | ||
else() | ||
add_executable(${PROJECT_NAME} ${AWS_S3_CRT_INTEGRATION_TESTS_SRC}) | ||
endif() | ||
|
||
set_compiler_flags(${PROJECT_NAME}) | ||
set_compiler_warnings(${PROJECT_NAME}) | ||
|
||
target_link_libraries(${PROJECT_NAME} ${PROJECT_LIBS}) | ||
|
||
if(MSVC AND BUILD_SHARED_LIBS) | ||
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/DELAYLOAD:aws-cpp-sdk-s3-crt.dll /DELAYLOAD:aws-cpp-sdk-core.dll") | ||
target_link_libraries(${PROJECT_NAME} delayimp.lib) | ||
endif() | ||
endforeach () |
29 changes: 29 additions & 0 deletions
29
tests/aws-cpp-sdk-s3-crt-integration-tests/RunTestsWithMemTracer.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0. | ||
*/ | ||
|
||
#include <gtest/gtest.h> | ||
#include <aws/core/Aws.h> | ||
#include <aws/testing/platform/PlatformTesting.h> | ||
#include <aws/testing/TestingEnvironment.h> | ||
#include <aws/testing/MemoryTesting.h> | ||
|
||
int main(int argc, char** argv) { | ||
Aws::Testing::SetDefaultSigPipeHandler(); | ||
Aws::SDKOptions options; | ||
options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Trace; | ||
CRTMemTracerMemorySystem memorySystem{}; | ||
options.memoryManagementOptions.memoryManager = &memorySystem; | ||
Aws::Testing::InitPlatformTest(options); | ||
Aws::Testing::ParseArgs(argc, argv); | ||
|
||
Aws::InitAPI(options); | ||
::testing::InitGoogleTest(&argc, argv); | ||
int exitCode = RUN_ALL_TESTS(); | ||
|
||
Aws::ShutdownAPI(options); | ||
memorySystem.AssertNoLeaks(); | ||
Aws::Testing::ShutdownPlatformTest(options); | ||
return exitCode; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters