Skip to content

Commit ef515b3

Browse files
committed
Allow cmake option to remove tests that depend on DNS lookup
1 parent 59179d5 commit ef515b3

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

.cspell.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
"MMSYSERR",
5858
"WAVEFORMATEX",
5959
"Unprepare",
60-
"DDISABLE_IMDSV1",
60+
"DDISABLE",
6161
"SENDREQUEST",
6262
"threadpool",
6363
"stdlib",

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ if (LEGACY_BUILD)
6767
option(USE_TLS_V1_2 "Set http client to enforce TLS 1.2" ON)
6868
option(USE_TLS_V1_3 "Set http client to enforce TLS 1.3" OFF)
6969
option(ENABLE_SMOKE_TESTS "Enable smoke tests" OFF)
70+
option(DISABLE_DNS_REQUIRED_TESTS "Disable unit tests that require DNS lookup to succeed, useful when using a http client that does not perform DNS lookup" OFF)
7071

7172

7273
set(AWS_USER_AGENT_CUSTOMIZATION "" CACHE STRING "User agent extension")
@@ -89,6 +90,10 @@ if (LEGACY_BUILD)
8990
add_definitions(-DENFORCE_TLS_V1_3)
9091
endif ()
9192

93+
if (DISABLE_DNS_REQUIRED_TESTS)
94+
add_definitions(-DDISABLE_DNS_REQUIRED_TESTS)
95+
endif ()
96+
9297
#From https://stackoverflow.com/questions/18968979/how-to-get-colorized-output-with-cmake
9398
if (NOT WIN32)
9499
string(ASCII 27 Esc)

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
* SPDX-License-Identifier: Apache-2.0.
44
*/
5-
5+
#ifndef DISABLE_DNS_REQUIRED_TESTS
66
#include <aws/testing/AwsCppSdkGTestSuite.h>
77
#include <aws/core/http/HttpRequest.h>
88
#include <aws/core/http/HttpResponse.h>
@@ -385,3 +385,4 @@ TEST_F(CURLHttpClientTest, TestHttpRequestWorksFine)
385385
#endif // ENABLE_CURL_CLIENT
386386
#endif // ENABLE_HTTP_CLIENT_TESTING
387387
#endif // NO_HTTP_CLIENT
388+
#endif // DISABLE_DNS_REQUIRED_TESTS

0 commit comments

Comments
 (0)