From: Seonah Moon Date: Tue, 20 Oct 2020 07:13:26 +0000 (+0900) Subject: gtest: use localhost server if the proxy isn't set X-Git-Tag: submit/tizen/20201020.080343^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=391461a44e8911171c8e7412a76f97767e3e40a9;p=platform%2Fcore%2Fapi%2Fhttp.git gtest: use localhost server if the proxy isn't set Change-Id: I9caffa40c4d9c013cdb2b5a084f86c7acf38f3bb --- diff --git a/packaging/capi-network-http.spec b/packaging/capi-network-http.spec index 69d2868..00afd1a 100644 --- a/packaging/capi-network-http.spec +++ b/packaging/capi-network-http.spec @@ -51,6 +51,7 @@ export LDFLAGS+=" -lgcov" %endif %cmake -DBUILD_GTESTS=%{?gcov:1}%{!?gcov:0} \ + -DUSE_LOCALHOST_SERVER=%{?gproxy:0}%{!?gproxy:1} \ . make %{?_smp_mflags} @@ -66,7 +67,11 @@ tar xf %{name}-gcov.tar -C %{buildroot}%{_datadir}/gcov/obj %check %if 0%{?gcov:1} +%if 0%{?gproxy:1} env all_proxy=%{gproxy} tests/http-gtest # http://[proxy addr]:[port] +%else +tests/http-gtest +%endif %endif %if 0%{?gcov:1} diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d939950..dcf4a65 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,6 +1,11 @@ LINK_DIRECTORIES(${CMAKE_BINARY_DIR}) ADD_DEFINITIONS("-DHTTP_GTEST") +IF(USE_LOCALHOST_SERVER) + MESSAGE("Use localhost server.") + ADD_DEFINITIONS("-DUSE_LOCALHOST_SERVER") +ENDIF(USE_LOCALHOST_SERVER) + pkg_check_modules(gtest_pkgs REQUIRED gmock glib-2.0) INCLUDE_DIRECTORIES(${gtest_pkgs_INCLUDE_DIRS}) LINK_DIRECTORIES(${gtest_pkgs_LIBRARY_DIRS}) diff --git a/tests/http-gtest-async.cpp b/tests/http-gtest-async.cpp index acb64fc..d3946fe 100755 --- a/tests/http-gtest-async.cpp +++ b/tests/http-gtest-async.cpp @@ -27,13 +27,21 @@ extern "C" { #include "http-gtest-util.h" +#if defined USE_LOCALHOST_SERVER +#define DEFAULT_TEST_URL "http://localhost" +#else +#define DEFAULT_TEST_URL "http://www.example.com" +#endif + static bool _completed_flag; static bool _canceled_flag; static bool _paused_flag; static bool _resumed_flag; static void _completed_cb(http_transaction_h http_transaction, void *user_data); -static void _aborted_cb(http_transaction_h http_transaction, http_error_code_e error, void *user_data); +static void _aborted_cb(http_transaction_h http_transaction, + http_error_code_e error, void *user_data); + class HttpAsyncTest: public ::testing::Test { protected: http_session_h session = NULL; @@ -55,7 +63,7 @@ class HttpAsyncTest: public ::testing::Test { http_session_open_transaction(session, HTTP_METHOD_GET, &transaction); http_transaction_set_completed_cb(transaction, _completed_cb, NULL); http_transaction_set_aborted_cb(transaction, _aborted_cb, NULL); - http_transaction_request_set_uri(transaction, "http://www.example.com"); + http_transaction_request_set_uri(transaction, DEFAULT_TEST_URL); } void TearDown() override