Skip to content

Commit 7ca735b

Browse files
Merge pull request #71 from awslabs/DirectoryTreeFixes
Directory tree fixes
2 parents 2b79849 + e1b519b commit 7ca735b

File tree

19 files changed

+238
-569
lines changed

19 files changed

+238
-569
lines changed

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ file(GLOB UTILS_CRYPTO_SRC "${CMAKE_CURRENT_SOURCE_DIR}/utils/crypto/*.cpp")
1515
file(GLOB UTILS_JSON_SRC "${CMAKE_CURRENT_SOURCE_DIR}/utils/json/*.cpp")
1616
file(GLOB UTILS_STREAM_SRC "${CMAKE_CURRENT_SOURCE_DIR}/utils/stream/*.cpp")
1717
file(GLOB UTILS_LOGGING_SRC "${CMAKE_CURRENT_SOURCE_DIR}/utils/logging/*.cpp")
18-
file(GLOB UTILS_MEMORY_SRC "${CMAKE_CURRENT_SOURCE_DIR}/utils/memory/*.cpp")
1918
file(GLOB UTILS_RATE_LIMITER_SRC "${CMAKE_CURRENT_SOURCE_DIR}/utils/ratelimiter/*.cpp")
2019
file(GLOB UTILS_XML_SRC "${CMAKE_CURRENT_SOURCE_DIR}/utils/xml/*.cpp")
2120

@@ -32,7 +31,6 @@ file(GLOB AWS_CPP_SDK_CORE_TESTS_SRC
3231
${UTILS_STREAM_SRC}
3332
${UTILS_XML_SRC}
3433
${UTILS_LOGGING_SRC}
35-
${UTILS_MEMORY_SRC}
3634
${UTILS_RATE_LIMITER_SRC}
3735
)
3836

@@ -49,7 +47,6 @@ if(PLATFORM_WINDOWS)
4947
source_group("Source Files\\utils\\stream" FILES ${UTILS_STREAM_SRC})
5048
source_group("Source Files\\utils\\xml" FILES ${UTILS_XML_SRC})
5149
source_group("Source Files\\utils\\logging" FILES ${UTILS_LOGGING_SRC})
52-
source_group("Source Files\\utils\\memory" FILES ${UTILS_MEMORY_SRC})
5350
source_group("Source Files\\utils\\ratelimiter" FILES ${UTILS_RATE_LIMITER_SRC})
5451
endif()
5552
endif()

aws-cpp-sdk-core-tests/RunTests.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,28 @@
1919
#include <aws/core/Aws.h>
2020
#include <aws/testing/TestingEnvironment.h>
2121
#include <aws/testing/platform/PlatformTesting.h>
22+
#include <aws/testing/MemoryTesting.h>
2223

2324
int main(int argc, char** argv)
2425
{
2526

2627
Aws::Testing::RedirectHomeToTempIfAppropriate();
2728

28-
Aws::SDKOptions options;
29+
Aws::SDKOptions options;
2930

31+
ExactTestMemorySystem memorySystem(16, 10);
32+
options.memoryManagementOptions.memoryManager = &memorySystem;
3033
Aws::Testing::InitPlatformTest(options);
3134

35+
options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Trace;
36+
3237
Aws::InitAPI(options);
3338
::testing::InitGoogleTest(&argc, argv);
3439
int retVal = RUN_ALL_TESTS();
3540
Aws::ShutdownAPI(options);
41+
EXPECT_EQ(memorySystem.GetCurrentOutstandingAllocations(), 0ULL);
42+
EXPECT_EQ(memorySystem.GetCurrentBytesAllocated(), 0ULL);
43+
EXPECT_TRUE(memorySystem.IsClean());
3644

3745
Aws::Testing::ShutdownPlatformTest(options);
3846

aws-cpp-sdk-core-tests/aws/auth/AWSCredentialsProviderTest.cpp

Lines changed: 5 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616

1717
#include <aws/external/gtest.h>
18-
#include <aws/testing/MemoryTesting.h>
1918

2019
#include <aws/testing/mocks/aws/auth/MockEC2MetadataClient.h>
2120
#include <aws/testing/platform/PlatformTesting.h>
@@ -39,7 +38,7 @@ using namespace Aws::Utils;
3938

4039
TEST(ProfileConfigFileAWSCredentialsProviderTest, TestDefaultConfig)
4140
{
42-
AWS_BEGIN_MEMORY_TEST(16, 10)
41+
4342
auto profileDirectory = ProfileConfigFileAWSCredentialsProvider::GetProfileDirectory();
4443

4544
Aws::FileSystem::CreateDirectoryIfNotExists(profileDirectory.c_str());
@@ -81,7 +80,6 @@ TEST(ProfileConfigFileAWSCredentialsProviderTest, TestDefaultConfig)
8180

8281
Aws::FileSystem::RelocateFileOrDirectory(tempFileName.c_str(), configFileName.c_str());
8382

84-
AWS_END_MEMORY_TEST
8583
}
8684

8785
class EnvironmentModifyingTest : public ::testing::Test
@@ -130,8 +128,6 @@ class EnvironmentModifyingTest : public ::testing::Test
130128

131129
TEST_F(EnvironmentModifyingTest, ProfileConfigTestWithEnvVars)
132130
{
133-
AWS_BEGIN_MEMORY_TEST(16, 10)
134-
135131
Aws::String configFileName = ProfileConfigFileAWSCredentialsProvider::GetCredentialsProfileFilename() + "_blah";
136132

137133
Aws::String oldValue = Aws::Environment::GetEnv("AWS_SHARED_CREDENTIALS_FILE");
@@ -155,14 +151,10 @@ TEST_F(EnvironmentModifyingTest, ProfileConfigTestWithEnvVars)
155151
EXPECT_STREQ("SomeProfileSecretKey", provider.GetAWSCredentials().GetAWSSecretKey().c_str());
156152

157153
Aws::FileSystem::RemoveFileIfExists(configFileName.c_str());
158-
159-
AWS_END_MEMORY_TEST
160154
}
161155

162156
TEST_F(EnvironmentModifyingTest, ProfileConfigTestWithEnvVarsButSpecifiedProfile)
163157
{
164-
AWS_BEGIN_MEMORY_TEST(16, 10)
165-
166158
Aws::String configFileName = ProfileConfigFileAWSCredentialsProvider::GetCredentialsProfileFilename() + "_blah";
167159

168160
Aws::Environment::SetEnv("AWS_SHARED_CREDENTIALS_FILE", configFileName.c_str(), 1);
@@ -189,15 +181,11 @@ TEST_F(EnvironmentModifyingTest, ProfileConfigTestWithEnvVarsButSpecifiedProfile
189181
EXPECT_STREQ("customProfileSecretKey", provider.GetAWSCredentials().GetAWSSecretKey().c_str());
190182

191183
Aws::FileSystem::RemoveFileIfExists(configFileName.c_str());
192-
193-
AWS_END_MEMORY_TEST
194184
}
195185

196186

197187
TEST_F(EnvironmentModifyingTest, ProfileConfigTestNotSetup)
198188
{
199-
AWS_BEGIN_MEMORY_TEST(16, 10)
200-
201189
Aws::String configFileName = ProfileConfigFileAWSCredentialsProvider::GetCredentialsProfileFilename();
202190
Aws::String tempFileName = configFileName + "_tempNotSetup";
203191

@@ -212,64 +200,48 @@ TEST_F(EnvironmentModifyingTest, ProfileConfigTestNotSetup)
212200
EXPECT_STREQ("", provider.GetAWSCredentials().GetAWSSecretKey().c_str());
213201

214202
Aws::FileSystem::RelocateFileOrDirectory(tempFileName.c_str(), configFileName.c_str());
215-
216-
AWS_END_MEMORY_TEST
217203
}
218204

219205
TEST_F(EnvironmentModifyingTest, TestEnvironmentVariablesExist)
220206
{
221-
AWS_BEGIN_MEMORY_TEST(16, 10)
222-
223207
Aws::Environment::SetEnv("AWS_ACCESS_KEY_ID", "Access Key", 1);
224208
Aws::Environment::SetEnv("AWS_SECRET_ACCESS_KEY", "Secret Key", 1);
225209
Aws::Environment::SetEnv("AWS_SESSION_TOKEN", "Session Token", 1);
226210

227211
EnvironmentAWSCredentialsProvider provider;
228212
ASSERT_EQ("Access Key", provider.GetAWSCredentials().GetAWSAccessKeyId());
229213
ASSERT_EQ("Secret Key", provider.GetAWSCredentials().GetAWSSecretKey());
230-
ASSERT_EQ("Session Token", provider.GetAWSCredentials().GetSessionToken());
231-
232-
AWS_END_MEMORY_TEST
214+
ASSERT_EQ("Session Token", provider.GetAWSCredentials().GetSessionToken());
233215
}
234216

235217

236218
TEST_F(EnvironmentModifyingTest, TestEnvironmentVariablesDoNotExist)
237219
{
238-
AWS_BEGIN_MEMORY_TEST(16, 10)
239-
240220
Aws::Environment::UnSetEnv("AWS_ACCESS_KEY_ID");
241221
Aws::Environment::UnSetEnv("AWS_SECRET_ACCESS_KEY");
242222

243223
EnvironmentAWSCredentialsProvider provider;
244224
ASSERT_EQ("", provider.GetAWSCredentials().GetAWSAccessKeyId());
245225
ASSERT_EQ("", provider.GetAWSCredentials().GetAWSSecretKey());
246-
247-
AWS_END_MEMORY_TEST
248226
}
249227

250228

251229

252230
TEST(InstanceProfileCredentialsProviderTest, TestEC2MetadataClientReturnsGoodData)
253231
{
254-
AWS_BEGIN_MEMORY_TEST(16, 10)
255-
256232
auto mockClient = Aws::MakeShared<MockEC2MetadataClient>(AllocationTag);
257233

258234
const char* validCredentials = "{ \"AccessKeyId\": \"goodAccessKey\", \"SecretAccessKey\": \"goodSecretKey\", \"Token\": \"goodToken\" }";
259235
mockClient->SetMockedCredentialsValue(validCredentials);
260236

261237
InstanceProfileCredentialsProvider provider(Aws::MakeShared<Aws::Config::EC2InstanceProfileConfigLoader>(AllocationTag, mockClient), 1000 * 60 * 15);
262238
ASSERT_EQ("goodAccessKey", provider.GetAWSCredentials().GetAWSAccessKeyId());
263-
ASSERT_EQ("goodSecretKey", provider.GetAWSCredentials().GetAWSSecretKey());
264-
265-
AWS_END_MEMORY_TEST
239+
ASSERT_EQ("goodSecretKey", provider.GetAWSCredentials().GetAWSSecretKey());
266240
}
267241

268242

269243
TEST(InstanceProfileCredentialsProviderTest, TestThatProviderRefreshes)
270244
{
271-
AWS_BEGIN_MEMORY_TEST(16, 10)
272-
273245
auto mockClient = Aws::MakeShared<MockEC2MetadataClient>(AllocationTag);
274246

275247
const char* validCredentials = "{ \"AccessKeyId\": \"goodAccessKey\", \"SecretAccessKey\": \"goodSecretKey\", \"Token\": \"goodToken\" }";
@@ -284,15 +256,11 @@ TEST(InstanceProfileCredentialsProviderTest, TestThatProviderRefreshes)
284256

285257
std::this_thread::sleep_for(std::chrono::milliseconds(100));
286258
ASSERT_EQ("betterAccessKey", provider.GetAWSCredentials().GetAWSAccessKeyId());
287-
ASSERT_EQ("betterSecretKey", provider.GetAWSCredentials().GetAWSSecretKey());
288-
289-
AWS_END_MEMORY_TEST
259+
ASSERT_EQ("betterSecretKey", provider.GetAWSCredentials().GetAWSSecretKey());
290260
}
291261

292262
TEST(InstanceProfileCredentialsProviderTest, TestEC2MetadataClientCouldntFindCredentials)
293263
{
294-
AWS_BEGIN_MEMORY_TEST(16, 10)
295-
296264
auto mockClient = Aws::MakeShared<MockEC2MetadataClient>(AllocationTag);
297265
const char* emptyCredentials = "";
298266
mockClient->SetMockedCredentialsValue(emptyCredentials);
@@ -304,24 +272,18 @@ TEST(InstanceProfileCredentialsProviderTest, TestEC2MetadataClientCouldntFindCre
304272
const char* missingInfo = "{ }";
305273
mockClient->SetMockedCredentialsValue(missingInfo);
306274
ASSERT_EQ("", provider.GetAWSCredentials().GetAWSAccessKeyId());
307-
ASSERT_EQ("", provider.GetAWSCredentials().GetAWSSecretKey());
308-
309-
AWS_END_MEMORY_TEST
275+
ASSERT_EQ("", provider.GetAWSCredentials().GetAWSSecretKey());
310276
}
311277

312278
TEST(InstanceProfileCredentialsProviderTest, TestEC2MetadataClientReturnsBadData)
313279
{
314-
AWS_BEGIN_MEMORY_TEST(16, 10)
315-
316280
auto mockClient = Aws::MakeShared<MockEC2MetadataClient>(AllocationTag);
317281
const char* badData = "blah blah blah, I'm bad";
318282
mockClient->SetMockedCredentialsValue(badData);
319283

320284
InstanceProfileCredentialsProvider provider(Aws::MakeShared<Aws::Config::EC2InstanceProfileConfigLoader>(AllocationTag, mockClient), 1000 * 60 * 15);
321285
ASSERT_EQ("", provider.GetAWSCredentials().GetAWSAccessKeyId());
322286
ASSERT_EQ("", provider.GetAWSCredentials().GetAWSSecretKey());
323-
324-
AWS_END_MEMORY_TEST
325287
}
326288

327289

aws-cpp-sdk-core-tests/aws/client/AWSClientTest.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
*/
1515

1616
#include <aws/external/gtest.h>
17-
#include <aws/testing/MemoryTesting.h>
1817
#include <aws/core/client/AWSClient.h>
1918
#include <aws/core/client/AWSError.h>
2019
#include <aws/core/client/ClientConfiguration.h>
@@ -73,7 +72,6 @@ class AmazonWebServiceRequestMock : public AmazonWebServiceRequest
7372

7473
TEST(AWSClientTest, TestBuildHttpRequestWithHeadersOnly)
7574
{
76-
AWS_BEGIN_MEMORY_TEST(16, 10)
7775
HeaderValueCollection headerValues;
7876
headerValues["test1"] = "testValue1";
7977
headerValues["test2"] = "testValue2";
@@ -121,13 +119,10 @@ TEST(AWSClientTest, TestBuildHttpRequestWithHeadersOnly)
121119
ASSERT_EQ("testValue2", finalHeaders["test2"]);
122120
ASSERT_EQ("www.uri.com", finalHeaders[Http::HOST_HEADER]);
123121
ASSERT_FALSE(finalHeaders[Http::USER_AGENT_HEADER].empty());
124-
125-
AWS_END_MEMORY_TEST
126-
}
122+
}
127123

128124
TEST(AWSClientTest, TestBuildHttpRequestWithHeadersAndBody)
129125
{
130-
AWS_BEGIN_MEMORY_TEST(16, 10);
131126
HeaderValueCollection headerValues;
132127
headerValues["test1"] = "testValue1";
133128
headerValues["test2"] = "testValue2";
@@ -167,6 +162,4 @@ TEST(AWSClientTest, TestBuildHttpRequestWithHeadersAndBody)
167162
Aws::StringStream contentLengthExpected;
168163
contentLengthExpected << ss->str().length();
169164
ASSERT_EQ(contentLengthExpected.str(), finalHeaders[Http::CONTENT_LENGTH_HEADER]);
170-
171-
AWS_END_MEMORY_TEST
172165
}

aws-cpp-sdk-core-tests/http/URITest.cpp

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,19 @@
1414
*/
1515

1616
#include <aws/external/gtest.h>
17-
#include <aws/testing/MemoryTesting.h>
18-
1917
#include <aws/core/http/URI.h>
2018

2119
using namespace Aws::Http;
2220
TEST(URITest, DefaultConstructor)
2321
{
24-
AWS_BEGIN_MEMORY_TEST(16, 10)
25-
2622
URI uri;
2723
EXPECT_EQ(Scheme::HTTP, uri.GetScheme());
2824
EXPECT_EQ(HTTP_DEFAULT_PORT, uri.GetPort());
29-
30-
AWS_END_MEMORY_TEST
25+
3126
}
3227

3328
TEST(URITest, TestSchemeChanges)
3429
{
35-
AWS_BEGIN_MEMORY_TEST(16, 10)
36-
3730
URI uri;
3831
EXPECT_EQ(Scheme::HTTP, uri.GetScheme());
3932
EXPECT_EQ(HTTP_DEFAULT_PORT, uri.GetPort());
@@ -53,13 +46,10 @@ TEST(URITest, TestSchemeChanges)
5346
EXPECT_EQ(Scheme::HTTPS, uri.GetScheme());
5447
EXPECT_EQ(8080, uri.GetPort());
5548

56-
AWS_END_MEMORY_TEST
5749
}
5850

5951
TEST(URITest, TestSetPath)
6052
{
61-
AWS_BEGIN_MEMORY_TEST(16, 10)
62-
6353
URI uri;
6454
Aws::String path = "/path/to/resource";
6555

@@ -71,15 +61,11 @@ TEST(URITest, TestSetPath)
7161
uri.SetPath(path);
7262
EXPECT_EQ("/path/with%20space/to/resource", uri.GetURLEncodedPath());
7363
//make sure we return an UnEncoded path properly
74-
EXPECT_EQ(path, uri.GetPath());
75-
76-
AWS_END_MEMORY_TEST
64+
EXPECT_EQ(path, uri.GetPath());
7765
}
7866

7967
TEST(URITest, TestAddQueryStringParameters)
8068
{
81-
AWS_BEGIN_MEMORY_TEST(16, 10)
82-
8369
URI uri;
8470
Aws::String path = "/path/to/resource";
8571
uri.SetPath(path);
@@ -103,14 +89,10 @@ TEST(URITest, TestAddQueryStringParameters)
10389
//let's go ahead and make sure the url is constructed properly.
10490
EXPECT_STREQ("http://www.test.com/path/to/resource?test1=value1&test%20needs%20escaping=value%20needs%20escaping",
10591
uri.GetURIString().c_str());
106-
107-
AWS_END_MEMORY_TEST
10892
}
10993

11094
TEST(URITest, TestCanonicalizeQueryStringParameters)
11195
{
112-
AWS_BEGIN_MEMORY_TEST(16, 10)
113-
11496
URI uri;
11597
Aws::String path = "/path/to/resource";
11698
uri.SetPath(path);
@@ -129,27 +111,21 @@ TEST(URITest, TestCanonicalizeQueryStringParameters)
129111
nonStandardUri.CanonicalizeQueryString();
130112
EXPECT_EQ("?nonStandard", nonStandardUri.GetQueryString());
131113

132-
AWS_END_MEMORY_TEST
133114
}
134115

135116
TEST(URITest, TestPort)
136117
{
137-
AWS_BEGIN_MEMORY_TEST(16, 10)
138-
139118
URI uri;
140119
Aws::String path = "/path/to/resource";
141120
uri.SetPath(path);
142121
uri.SetAuthority("www.test.com");
143122
uri.SetPort(8080);
144123

145124
EXPECT_STREQ("http://www.test.com:8080/path/to/resource", uri.GetURIString().c_str());
146-
147-
AWS_END_MEMORY_TEST
148125
}
149126

150127
TEST(URITest, TestParse)
151128
{
152-
AWS_BEGIN_MEMORY_TEST(16, 10)
153129

154130
const char* strUri = "https://www.test.com:8443/path/to/resource?test1=value1&test%20space=value%20space";
155131
URI uri(strUri);
@@ -177,14 +153,10 @@ TEST(URITest, TestParse)
177153
EXPECT_EQ(80, uriThatBrokeTheOtherDay.GetPort());
178154
EXPECT_EQ("/686094048/testQueueName/", uriThatBrokeTheOtherDay.GetPath());
179155
EXPECT_EQ("http://sqs.us-east-1.amazonaws.com/686094048/testQueueName/", uriThatBrokeTheOtherDay.GetURIString());
180-
181-
AWS_END_MEMORY_TEST
182156
}
183157

184158
TEST(URITest, TestParseWithColon)
185159
{
186-
AWS_BEGIN_MEMORY_TEST(16, 10)
187-
188160
const char* strUri = "https://test.com/path/1234:_Some_Path";
189161
URI uri(strUri);
190162

@@ -212,7 +184,6 @@ TEST(URITest, TestParseWithColon)
212184
EXPECT_EQ(80, complexUri.GetPort());
213185
EXPECT_STREQ("/awsnativesdkputobjectstestbucket20150702T200059Z/TestObject:1234/awsnativesdkputobjectstestbucket20150702T200059Z/TestObject:Key", complexUri.GetPath().c_str());
214186
EXPECT_STREQ(strComplexUri, complexUri.GetURIString().c_str());
215-
216-
AWS_END_MEMORY_TEST
187+
217188
}
218189

0 commit comments

Comments
 (0)