Skip to content

Commit

Permalink
Allow cmake option to remove tests that depend on DNS lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
sbiscigl committed Jan 2, 2025
1 parent 59179d5 commit ef515b3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"MMSYSERR",
"WAVEFORMATEX",
"Unprepare",
"DDISABLE_IMDSV1",
"DDISABLE",
"SENDREQUEST",
"threadpool",
"stdlib",
Expand Down
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ if (LEGACY_BUILD)
option(USE_TLS_V1_2 "Set http client to enforce TLS 1.2" ON)
option(USE_TLS_V1_3 "Set http client to enforce TLS 1.3" OFF)
option(ENABLE_SMOKE_TESTS "Enable smoke tests" OFF)
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)


set(AWS_USER_AGENT_CUSTOMIZATION "" CACHE STRING "User agent extension")
Expand All @@ -89,6 +90,10 @@ if (LEGACY_BUILD)
add_definitions(-DENFORCE_TLS_V1_3)
endif ()

if (DISABLE_DNS_REQUIRED_TESTS)
add_definitions(-DDISABLE_DNS_REQUIRED_TESTS)
endif ()

#From https://stackoverflow.com/questions/18968979/how-to-get-colorized-output-with-cmake
if (NOT WIN32)
string(ASCII 27 Esc)
Expand Down
3 changes: 2 additions & 1 deletion tests/aws-cpp-sdk-core-tests/http/HttpClientTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/

#ifndef DISABLE_DNS_REQUIRED_TESTS
#include <aws/testing/AwsCppSdkGTestSuite.h>
#include <aws/core/http/HttpRequest.h>
#include <aws/core/http/HttpResponse.h>
Expand Down Expand Up @@ -385,3 +385,4 @@ TEST_F(CURLHttpClientTest, TestHttpRequestWorksFine)
#endif // ENABLE_CURL_CLIENT
#endif // ENABLE_HTTP_CLIENT_TESTING
#endif // NO_HTTP_CLIENT
#endif // DISABLE_DNS_REQUIRED_TESTS

0 comments on commit ef515b3

Please sign in to comment.