Skip to content

Commit bccf199

Browse files
committed
Basic aws-sdk-cpp-core-tests build
1 parent c300546 commit bccf199

37 files changed

+239
-157
lines changed

CMakeLists.txt

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ else ()
4242
set(CMAKE_CXX_EXTENSIONS OFF)
4343
set(CMAKE_CXX_STANDARD_REQUIRED ON)
4444

45+
# Setting flags for telling compiler this is a non-legacy build
46+
add_definitions(-DNON_LEGACY_BUILD)
47+
4548
# Setting build to hide symbols in targets by default
4649
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
4750
set(CMAKE_VISIBILITY_INLINES_HIDDEN YES)
@@ -56,6 +59,13 @@ else ()
5659
@ONLY
5760
)
5861

62+
message(STATUS "Generating source file SDKConfig.h for setting memory management options")
63+
configure_file(
64+
SDKConfig.h.in
65+
src/aws-cpp-sdk-core/include/aws/core/SDKConfig.h
66+
@ONLY
67+
)
68+
5969
# Validating config type and setting default if needed
6070
get_property(is_multi_conf_build GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
6171
if (NOT is_multi_conf_build)
@@ -86,13 +96,25 @@ else ()
8696

8797
# -- Dependencies --
8898
add_subdirectory(dependencies)
99+
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
100+
# Testing Dependencies
101+
if (BUILD_TESTING)
102+
message(STATUS "Building tests")
103+
# Testing dependency
104+
find_package(GTest 1.11 REQUIRED)
105+
include(GoogleTest) # for gtest_discover_tests()
106+
endif ()
107+
endif ()
89108

90109
# -- main build targets --
91110
add_subdirectory(src)
92111

93112
# -- Tests and packaging if running this as top project --
94113
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
95-
add_subdirectory(tests)
114+
# Testing Dependencies
115+
if (BUILD_TESTING)
116+
add_subdirectory(tests)
117+
endif ()
96118
add_subdirectory(packaging)
97119
endif ()
98120
message(WARNING "The dependencies are currently checked only for a basic Linux build, new ones need to be added for other platforms yet")

SDKConfig.h.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0.
4+
*/
5+
6+
#cmakedefine USE_AWS_MEMORY_MANAGEMENT
7+

cmake/Findaws-crt-cpp.cmake

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,8 @@ message(WARNING "aws-crt-cpp package is mocked for testing of experimental featu
55
# Setting include path to the submodule temporarily to unblock testing
66
# To make it build the crt submodule needs to be in-source build before calling this so generated files are created.
77
# Removing this work around soon, working in parallel in making aws-crt-cpp consumable by normal means
8-
set(aws-crt-cpp_INCLUDE_DIRS
9-
${CMAKE_CURRENT_LIST_DIR}/../crt/aws-crt-cpp/include
10-
${CMAKE_CURRENT_LIST_DIR}/../crt/aws-crt-cpp/crt/aws-c-common/include
11-
${CMAKE_CURRENT_LIST_DIR}/../crt/aws-crt-cpp/crt/aws-c-io/include
12-
${CMAKE_CURRENT_LIST_DIR}/../crt/aws-crt-cpp/crt/aws-c-mqtt/include
13-
${CMAKE_CURRENT_LIST_DIR}/../crt/aws-crt-cpp/crt/aws-c-cal/include
14-
${CMAKE_CURRENT_LIST_DIR}/../crt/aws-crt-cpp/crt/aws-c-auth/include
15-
${CMAKE_CURRENT_LIST_DIR}/../crt/aws-crt-cpp/crt/aws-c-http/include
16-
${CMAKE_CURRENT_LIST_DIR}/../crt/aws-crt-cpp/crt/aws-c-event-stream/include
17-
${CMAKE_CURRENT_LIST_DIR}/../crt/aws-crt-cpp/crt/aws-checksums/include
18-
${CMAKE_CURRENT_LIST_DIR}/../crt/aws-crt-cpp/crt/aws-c-common/generated/include
19-
PARENT_SCOPE
20-
)
8+
9+
set(aws-crt-cpp_INCLUDE_DIRS ${CMAKE_INSTALL_PREFIX}/include PARENT_SCOPE)
10+
set(aws-crt-cpp_LIB_DIRS ${CMAKE_INSTALL_PREFIX}/lib PARENT_SCOPE)
11+
2112

crt/aws-crt-cpp

Submodule aws-crt-cpp deleted from 3e55d53

dependencies/CMakeLists.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
# Testing Dependencies
2-
if (BUILD_TESTING)
3-
message(STATUS "Building tests")
4-
# Testing dependency
5-
find_package(GTest 1.11 REQUIRED)
6-
include(GoogleTest) # for gtest_discover_tests()
7-
endif ()
8-
91
# Project dependencies http library (curl or OS), tinyxml2, cJSON, ssl (open or other), CRT
102
find_package(CURL REQUIRED)
113
find_package(ZLIB REQUIRED)

src/aws-cpp-sdk-core-tests/CMakeLists.txt

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
if (NOT LEGACY_BUILD)
2-
message(WARNING "Building core with new cmake scripts not yet implemented")
2+
add_library(aws-sdk-cpp-test-resources)
3+
add_library(aws-sdk-cpp::test-resources ALIAS aws-sdk-cpp-test-resources)
4+
target_link_libraries(
5+
aws-sdk-cpp-test-resources
6+
aws-sdk-cpp::core
7+
)
8+
add_subdirectory(testing-resources)
9+
10+
add_executable(
11+
aws-core-version
12+
${CMAKE_CURRENT_LIST_DIR}/VersionTests.cpp
13+
${CMAKE_CURRENT_LIST_DIR}/RunTests.cpp
14+
)
15+
target_link_libraries(
16+
aws-core-version
17+
PRIVATE GTest::GTest
18+
PRIVATE aws-sdk-cpp::core
19+
PRIVATE aws-sdk-cpp::test-resources
20+
)
21+
22+
# add_subdirectory(monitoring)
23+
message(WARNING "Not testing everything yet...")
324
else ()
425
add_project(aws-cpp-sdk-core-tests
526
"Tests for the AWS Core C++ Library"

src/aws-cpp-sdk-core-tests/VersionTests.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
* SPDX-License-Identifier: Apache-2.0.
44
*/
55

6+
#ifdef NON_LEGACY_BUILD
7+
#include <gtest/gtest.h>
8+
#else
69
#include <aws/external/gtest.h>
10+
#endif
711
#include <aws/core/utils/StringUtils.h>
812
#include <aws/core/Version.h>
913

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
add_executable(
2+
aws-core-monitoring
3+
${CMAKE_CURRENT_LIST_DIR}/MonitoringEndToEndTest.cpp
4+
${CMAKE_CURRENT_LIST_DIR}/MonitoringTest.cpp
5+
)
6+
target_include_directories(
7+
aws-core-monitoring
8+
PRIVATE GTest::GTest
9+
)
10+
target_link_libraries(
11+
aws-core-monitoring
12+
PRIVATE GTest::GTest
13+
PRIVATE aws-sdk-cpp::core
14+
)

src/aws-cpp-sdk-core-tests/monitoring/MonitoringEndToEndTest.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
* SPDX-License-Identifier: Apache-2.0.
44
*/
55

6+
#ifdef NON_LEGACY_BUILD
7+
#include <gtest/gtest.h>
8+
#else
69
#include <aws/external/gtest.h>
10+
#endif
711
#include <aws/core/client/AWSError.h>
812
#include <aws/testing/mocks/aws/client/MockAWSClient.h>
913
#include <aws/testing/platform/PlatformTesting.h>

src/aws-cpp-sdk-core-tests/monitoring/MonitoringTest.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
* SPDX-License-Identifier: Apache-2.0.
44
*/
5-
5+
#ifdef NON_LEGACY_BUILD
6+
#include <gtest/gtest.h>
7+
#else
68
#include <aws/external/gtest.h>
9+
#endif
710
#include <aws/testing/mocks/aws/client/MockAWSClient.h>
811
#include <aws/core/monitoring/CoreMetrics.h>
912
#include <aws/core/monitoring/MonitoringInterface.h>
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
# SPDX-License-Identifier: Apache-2.0.
3+
#
4+
if (NOT LEGACY_BUILD)
5+
add_subdirectory(include)
6+
add_subdirectory(source)
7+
else()
8+
add_project(testing-resources
9+
"Testing utility library for the AWS C++ SDK"
10+
aws-cpp-sdk-core)
11+
12+
include(GenerateExportHeader)
13+
14+
file(GLOB AWS_TESTING_HEADERS "include/aws/testing/*.h")
15+
file(GLOB AWS_TESTING_EXTERNAL_HEADERS "include/aws/external/*.h")
16+
file(GLOB AWS_TESTING_AUTH_MOCKS_HEADERS "include/aws/testing/mocks/aws/auth/*.h")
17+
file(GLOB AWS_TESTING_EVENT_MOCKS_HEADERS "include/aws/testing/mocks/event/*.h")
18+
file(GLOB AWS_TESTING_HTTP_MOCKS_HEADERS "include/aws/testing/mocks/http/*.h")
19+
file(GLOB AWS_TESTING_CLIENT_MOCKS_HEADERS "include/aws/testing/mocks/aws/client/*.h")
20+
file(GLOB AWS_TESTING_MONITORING_MOCKS_HEADERS "include/aws/testing/mocks/monitoring/*.h")
21+
file(GLOB AWS_TESTING_PLATFORM_HEADERS "include/aws/testing/platform/*.h")
22+
23+
file(GLOB AWS_TESTING_SOURCE "source/*.cpp")
24+
file(GLOB AWS_TESTING_EXTERNAL_SOURCE "source/external/*.cc")
25+
26+
file(GLOB TestingResources_SHARED_SRC
27+
${AWS_TESTING_HEADERS}
28+
${AWS_TESTING_EXTERNAL_HEADERS}
29+
${AWS_TESTING_AUTH_MOCKS_HEADERS}
30+
${AWS_TESTING_EVENT_MOCKS_HEADERS}
31+
${AWS_TESTING_HTTP_MOCKS_HEADERS}
32+
${AWS_TESTING_CLIENT_MOCKS_HEADERS}
33+
${AWS_TESTING_MONITORING_MOCKS_HEADERS}
34+
${AWS_TESTING_PLATFORM_HEADERS}
35+
${AWS_TESTING_SOURCE}
36+
${AWS_TESTING_EXTERNAL_SOURCE}
37+
)
38+
39+
if(PLATFORM_ANDROID)
40+
file(GLOB AWS_TESTING_PLATFORM_ANDROID_HEADERS "include/aws/testing/platform/android/*.h")
41+
file(GLOB AWS_TESTING_PLATFORM_ANDROID_SOURCE "source/platform/android/*.cpp")
42+
43+
file(GLOB TestingResources_PLATFORM_SRC ${AWS_TESTING_ANDROID_HEADERS} ${AWS_TESTING_ANDROID_SOURCE})
44+
file(GLOB TestingResources_PLATFORM_SRC ${AWS_TESTING_PLATFORM_ANDROID_HEADERS} ${AWS_TESTING_PLATFORM_ANDROID_SOURCE})
45+
elseif(PLATFORM_WINDOWS)
46+
file(GLOB TestingResources_PLATFORM_SRC "source/platform/windows/*.cpp")
47+
elseif(PLATFORM_LINUX OR PLATFORM_APPLE)
48+
file(GLOB TestingResources_PLATFORM_SRC "source/platform/linux-shared/*.cpp")
49+
elseif(PLATFORM_CUSTOM)
50+
gather_custom_testing_source(TestingResources_PLATFORM_SRC)
51+
endif()
52+
53+
if(PLATFORM_WINDOWS)
54+
if(MSVC)
55+
source_group("Header Files\\aws\\testing" FILES ${AWS_TESTING_HEADERS})
56+
source_group("Header Files\\aws\\testing\\platform" FILES ${AWS_TESTING_PLATFORM_HEADERS})
57+
source_group("Header Files\\aws\\external" FILES ${AWS_TESTING_EXTERNAL_HEADERS})
58+
source_group("Header Files\\aws\\testing\\mocks\\aws\\auth" FILES ${AWS_TESTING_AUTH_MOCKS_HEADERS})
59+
source_group("Header Files\\aws\\testing\\mocks\\event" FILES ${AWS_TESTING_EVENT_MOCKS_HEADERS})
60+
source_group("Header Files\\aws\\testing\\mocks\\http" FILES ${AWS_TESTING_HTTP_MOCKS_HEADERS})
61+
source_group("Header Files\\aws\\testing\\mocks\\aws\\client" FILES ${AWS_TESTING_CLIENT_MOCKS_HEADERS})
62+
source_group("Header Files\\aws\\testing\\mocks\\monitoring" FILES ${AWS_TESTING_MONITORING_MOCKS_HEADERS})
63+
source_group("Source Files" FILES ${AWS_TESTING_SOURCE})
64+
source_group("Source Files\\external" FILES ${AWS_TESTING_EXTERNAL_SOURCE})
65+
source_group("Source Files\\platform\\windows" FILES ${TestingResources_PLATFORM_SRC})
66+
endif(MSVC)
67+
endif()
68+
69+
file(GLOB TestingResources_SRC
70+
${TestingResources_SHARED_SRC}
71+
${TestingResources_PLATFORM_SRC}
72+
)
73+
74+
set(INCLUDES
75+
"include"
76+
)
77+
78+
if(PLATFORM_CUSTOM)
79+
if(COMMAND add_custom_core_include_directories)
80+
add_custom_core_include_directories(CUSTOM_INCLUDE)
81+
set(INCLUDES ${INCLUDES} ${CUSTOM_INCLUDE})
82+
endif()
83+
if(COMMAND add_custom_definitions)
84+
add_custom_definitions()
85+
endif()
86+
endif()
87+
88+
include_directories(${INCLUDES})
89+
90+
if(USE_WINDOWS_DLL_SEMANTICS AND BUILD_SHARED_LIBS)
91+
add_definitions(-DAWS_TESTING_EXPORTS=1)
92+
add_definitions(-DGTEST_CREATE_SHARED_LIBRARY=1)
93+
endif()
94+
95+
if(PLATFORM_WINDOWS)
96+
add_definitions("-DDISABLE_HOME_DIR_REDIRECT")
97+
endif()
98+
99+
add_library(${PROJECT_NAME} ${TestingResources_SRC})
100+
add_library(AWS::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
101+
102+
set_compiler_flags(${PROJECT_NAME})
103+
set_compiler_warnings(${PROJECT_NAME})
104+
105+
if(PLATFORM_CUSTOM)
106+
add_custom_testing_target_compile_definitions()
107+
endif()
108+
109+
target_include_directories(${PROJECT_NAME} PUBLIC
110+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
111+
$<INSTALL_INTERFACE:include>)
112+
target_link_libraries(${PROJECT_NAME} ${PLATFORM_DEP_LIBS} ${PROJECT_LIBS})
113+
114+
if(COMMAND add_custom_testing_link_libraries)
115+
add_custom_testing_link_libraries()
116+
endif()
117+
118+
if(COMMAND add_custom_testing_target_compile_definitions)
119+
add_custom_testing_target_compile_definitions()
120+
endif()
121+
122+
setup_install()
123+
124+
install (FILES ${AWS_TESTING_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/testing)
125+
install (FILES ${AWS_TESTING_EXTERNAL_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/external)
126+
install (FILES ${AWS_TESTING_PLATFORM_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/testing/platform)
127+
install (FILES ${AWS_TESTING_AUTH_MOCKS_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/testing/mocks/aws/auth)
128+
install (FILES ${AWS_TESTING_CLIENT_MOCKS_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/testing/mocks/aws/client)
129+
install (FILES ${AWS_TESTING_EVENT_MOCKS_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/testing/mocks/event)
130+
install (FILES ${AWS_TESTING_HTTP_MOCKS_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/testing/mocks/http)
131+
install (FILES ${AWS_TESTING_MONITORING_MOCKS_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/testing/mocks/monitoring)
132+
133+
do_packaging()
134+
endif()
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
target_include_directories(
2+
aws-sdk-cpp-test-resources
3+
BEFORE
4+
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
5+
6+
)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
target_sources(
2+
aws-sdk-cpp-test-resources
3+
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/MemoryTesting.cpp
4+
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/TestingEnvironment.cpp
5+
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/platform/linux-shared/PlatformTesting.cpp
6+
)

src/aws-cpp-sdk-core/CMakeLists.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
if (NOT LEGACY_BUILD)
2-
message(WARNING "Building core with new cmake scripts not yet implemented")
32
add_library(aws-sdk-cpp-core)
43
add_library(aws-sdk-cpp::core ALIAS aws-sdk-cpp-core)
54
target_include_directories(
65
aws-sdk-cpp-core
7-
PRIVATE ${aws-crt-cpp_INCLUDE_DIRS}
6+
PUBLIC ${aws-crt-cpp_INCLUDE_DIRS}
7+
)
8+
target_link_directories(
9+
aws-sdk-cpp-core
10+
PUBLIC ${aws-crt-cpp_LIB_DIRS}
11+
)
12+
target_link_libraries(
13+
aws-sdk-cpp-core
14+
aws-crt-cpp
815
)
916
add_subdirectory(include)
1017
add_subdirectory(source)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
target_include_directories(
22
aws-sdk-cpp-core
3+
BEFORE
4+
PUBLIC ${CMAKE_CURRENT_BINARY_DIR} #For generated Headers as VersionConfig and SDKConfig
35
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
46
)

0 commit comments

Comments
 (0)