From 9f157d0d8c776d178dc8633257f15e1724899580 Mon Sep 17 00:00:00 2001 From: Zhengxi Li Date: Mon, 17 Apr 2023 21:31:42 +0000 Subject: [PATCH 1/3] Added mock functions --- proxy/http/unit_tests/test_HttpTransact.cc | 273 ++++++++++++++++++++- 1 file changed, 272 insertions(+), 1 deletion(-) diff --git a/proxy/http/unit_tests/test_HttpTransact.cc b/proxy/http/unit_tests/test_HttpTransact.cc index caa07e9e724..61c23863bf7 100644 --- a/proxy/http/unit_tests/test_HttpTransact.cc +++ b/proxy/http/unit_tests/test_HttpTransact.cc @@ -570,4 +570,275 @@ TEST_CASE("HttpTransact", "[http]") #include "HttpSessionManager.h" HttpSessionManager httpSessionManager; -StatPagesManager statPagesManager; \ No newline at end of file +StatPagesManager statPagesManager; + +// Mock functions to prevent linking issues +bool +StatPagesManager::is_stat_page(URL *url) +{ + ink_assert(false); + return false; +} + +void +forceLinkRegressionHttpTransact() +{ + ink_assert(false); +}; + +#include "remap/NextHopSelectionStrategy.h" + +bool +NextHopSelectionStrategy::nextHopExists(TSHttpTxn, void *) +{ + ink_assert(false); + return true; +}; + +void +NextHopSelectionStrategy::markNextHop(tsapi_httptxn *, char const *, int, NHCmd, void *, long) +{ + ink_assert(false); +}; + +const char * +HttpRequestData::get_host() +{ + ink_assert(false); + return nullptr; +} + +#include "I_Machine.h" + +Machine * +Machine::instance() +{ + ink_assert(false); + return nullptr; +} + +bool +Machine::is_self(sockaddr const *) +{ + ink_assert(false); + return false; +} + +void +SSLProxySession::init(NetVConnection const &) +{ + ink_assert(false); +}; + +#include "HttpSM.h" + +VConnection * +HttpSM::do_transform_open() +{ + ink_assert(false); + return nullptr; +} + +void +HttpSM::do_range_setup_if_necessary() +{ + ink_assert(false); +}; + +void +HttpSM::set_ua_half_close_flag() +{ + ink_assert(false); +}; + +void +HttpSM::do_hostdb_update_if_necessary() +{ + ink_assert(false); +}; + +int +HttpSM::populate_client_protocol(std::string_view *result, int n) const +{ + ink_assert(false); + return 0; +} + +void +HttpSM::milestone_update_api_time() +{ + ink_assert(false); +} + +HTTPVersion +HttpSM::get_server_version(HTTPHdr &hdr) const +{ + ink_assert(false); + return {}; +} + +#include "HttpDebugNames.h" + +const char * +HttpDebugNames::get_cache_action_name(HttpTransact::CacheAction_t t) +{ + ink_assert(false); + return nullptr; +} + +const char * +HttpDebugNames::get_server_state_name(HttpTransact::ServerState_t state) +{ + ink_assert(false); + return nullptr; +} + +const char * +HttpDebugNames::get_api_hook_name(TSHttpHookID t) +{ + ink_assert(false); + return nullptr; +} + +#include "HttpTransactCache.h" + +bool +HttpTransactCache::validate_ifrange_header_if_any(HTTPHdr *request, HTTPHdr *response) +{ + ink_assert(false); + return false; +} + +HTTPStatus +HttpTransactCache::match_response_to_request_conditionals(HTTPHdr *request, HTTPHdr *response, ink_time_t response_received_time) +{ + ink_assert(false); + return HTTP_STATUS_NONE; +} + +bool +HttpTransactCache::match_content_encoding(MIMEField *accept_field, const char *encoding_identifier) +{ + ink_assert(false); + return false; +} + +const IpAllow::ACL & +ProxyTransaction::get_acl() const +{ + ink_assert(false); + return IpAllow::DENY_ALL_ACL; +} + +bool +ResolveInfo::set_active(HostDBInfo *info) +{ + ink_assert(false); + return false; +} + +#include "ParentSelection.h" + +void +ParentSelectionStrategy::markParentDown(ParentResult *result, unsigned int fail_threshold, unsigned int retry_time) +{ + ink_assert(false); +}; + +void +ParentSelectionStrategy::markParentUp(ParentResult *result) +{ + ink_assert(false); +} + +void +ParentConfigParams::findParent(HttpRequestData *, ParentResult *, unsigned int, unsigned int) +{ + ink_assert(false); +} + +void +ParentConfigParams::nextParent(HttpRequestData *, ParentResult *, unsigned int, unsigned int) +{ + ink_assert(false); +} +bool +ParentConfigParams::parentExists(HttpRequestData *rdata) +{ + ink_assert(false); + return false; +} + +bool +ParentConfigParams::apiParentExists(HttpRequestData *rdata) +{ + ink_assert(false); + return false; +} + +mapping_type +request_url_remap_redirect(HTTPHdr *request_header, URL *redirect_url, UrlRewrite *table) +{ + ink_assert(false); + return NONE; +} + +void +RemapPluginInst::osResponse(TSHttpTxn rh, int os_response_type) +{ + ink_assert(false); +} + +bool +ResolveInfo::select_next_rr() +{ + ink_assert(false); + return false; +} + +bool +response_url_remap(HTTPHdr *response_header, UrlRewrite *table) +{ + ink_assert(false); + return false; +} + +HostDBInfo * +HostDBRecord::find(sockaddr const *addr) +{ + ink_assert(false); + return nullptr; +} + +void +getCacheControl(CacheControlResult *result, HttpRequestData *rdata, const OverridableHttpConfigParams *h_txn_conf, char *tag) +{ + ink_assert(false); +} + +void +IpAllow::release() +{ + ink_assert(false); +} + +#include "HttpBodyFactory.h" + +char * +HttpBodyFactory::fabricate_with_old_api(const char *type, HttpTransact::State *context, int64_t max_buffer_length, + int64_t *resulting_buffer_length, char *content_language_out_buf, + size_t content_language_buf_size, char *content_type_out_buf, size_t content_type_buf_size, + int format_size, const char *format) +{ + ink_assert(false); + return nullptr; +} + +#include "Log.h" + +int +Log::error(char const *, ...) +{ + ink_assert(false); + return 0; +} From ddfe85e66994a61a895f770e8f4b52df6703a40c Mon Sep 17 00:00:00 2001 From: Zhengxi Li Date: Mon, 24 Apr 2023 03:12:21 +0000 Subject: [PATCH 2/3] Revert "Added mock functions" This reverts commit 8499ae63bf3b6dc04e2f84d45a82b3c2e5ab636d. --- proxy/http/unit_tests/test_HttpTransact.cc | 273 +-------------------- 1 file changed, 1 insertion(+), 272 deletions(-) diff --git a/proxy/http/unit_tests/test_HttpTransact.cc b/proxy/http/unit_tests/test_HttpTransact.cc index 61c23863bf7..caa07e9e724 100644 --- a/proxy/http/unit_tests/test_HttpTransact.cc +++ b/proxy/http/unit_tests/test_HttpTransact.cc @@ -570,275 +570,4 @@ TEST_CASE("HttpTransact", "[http]") #include "HttpSessionManager.h" HttpSessionManager httpSessionManager; -StatPagesManager statPagesManager; - -// Mock functions to prevent linking issues -bool -StatPagesManager::is_stat_page(URL *url) -{ - ink_assert(false); - return false; -} - -void -forceLinkRegressionHttpTransact() -{ - ink_assert(false); -}; - -#include "remap/NextHopSelectionStrategy.h" - -bool -NextHopSelectionStrategy::nextHopExists(TSHttpTxn, void *) -{ - ink_assert(false); - return true; -}; - -void -NextHopSelectionStrategy::markNextHop(tsapi_httptxn *, char const *, int, NHCmd, void *, long) -{ - ink_assert(false); -}; - -const char * -HttpRequestData::get_host() -{ - ink_assert(false); - return nullptr; -} - -#include "I_Machine.h" - -Machine * -Machine::instance() -{ - ink_assert(false); - return nullptr; -} - -bool -Machine::is_self(sockaddr const *) -{ - ink_assert(false); - return false; -} - -void -SSLProxySession::init(NetVConnection const &) -{ - ink_assert(false); -}; - -#include "HttpSM.h" - -VConnection * -HttpSM::do_transform_open() -{ - ink_assert(false); - return nullptr; -} - -void -HttpSM::do_range_setup_if_necessary() -{ - ink_assert(false); -}; - -void -HttpSM::set_ua_half_close_flag() -{ - ink_assert(false); -}; - -void -HttpSM::do_hostdb_update_if_necessary() -{ - ink_assert(false); -}; - -int -HttpSM::populate_client_protocol(std::string_view *result, int n) const -{ - ink_assert(false); - return 0; -} - -void -HttpSM::milestone_update_api_time() -{ - ink_assert(false); -} - -HTTPVersion -HttpSM::get_server_version(HTTPHdr &hdr) const -{ - ink_assert(false); - return {}; -} - -#include "HttpDebugNames.h" - -const char * -HttpDebugNames::get_cache_action_name(HttpTransact::CacheAction_t t) -{ - ink_assert(false); - return nullptr; -} - -const char * -HttpDebugNames::get_server_state_name(HttpTransact::ServerState_t state) -{ - ink_assert(false); - return nullptr; -} - -const char * -HttpDebugNames::get_api_hook_name(TSHttpHookID t) -{ - ink_assert(false); - return nullptr; -} - -#include "HttpTransactCache.h" - -bool -HttpTransactCache::validate_ifrange_header_if_any(HTTPHdr *request, HTTPHdr *response) -{ - ink_assert(false); - return false; -} - -HTTPStatus -HttpTransactCache::match_response_to_request_conditionals(HTTPHdr *request, HTTPHdr *response, ink_time_t response_received_time) -{ - ink_assert(false); - return HTTP_STATUS_NONE; -} - -bool -HttpTransactCache::match_content_encoding(MIMEField *accept_field, const char *encoding_identifier) -{ - ink_assert(false); - return false; -} - -const IpAllow::ACL & -ProxyTransaction::get_acl() const -{ - ink_assert(false); - return IpAllow::DENY_ALL_ACL; -} - -bool -ResolveInfo::set_active(HostDBInfo *info) -{ - ink_assert(false); - return false; -} - -#include "ParentSelection.h" - -void -ParentSelectionStrategy::markParentDown(ParentResult *result, unsigned int fail_threshold, unsigned int retry_time) -{ - ink_assert(false); -}; - -void -ParentSelectionStrategy::markParentUp(ParentResult *result) -{ - ink_assert(false); -} - -void -ParentConfigParams::findParent(HttpRequestData *, ParentResult *, unsigned int, unsigned int) -{ - ink_assert(false); -} - -void -ParentConfigParams::nextParent(HttpRequestData *, ParentResult *, unsigned int, unsigned int) -{ - ink_assert(false); -} -bool -ParentConfigParams::parentExists(HttpRequestData *rdata) -{ - ink_assert(false); - return false; -} - -bool -ParentConfigParams::apiParentExists(HttpRequestData *rdata) -{ - ink_assert(false); - return false; -} - -mapping_type -request_url_remap_redirect(HTTPHdr *request_header, URL *redirect_url, UrlRewrite *table) -{ - ink_assert(false); - return NONE; -} - -void -RemapPluginInst::osResponse(TSHttpTxn rh, int os_response_type) -{ - ink_assert(false); -} - -bool -ResolveInfo::select_next_rr() -{ - ink_assert(false); - return false; -} - -bool -response_url_remap(HTTPHdr *response_header, UrlRewrite *table) -{ - ink_assert(false); - return false; -} - -HostDBInfo * -HostDBRecord::find(sockaddr const *addr) -{ - ink_assert(false); - return nullptr; -} - -void -getCacheControl(CacheControlResult *result, HttpRequestData *rdata, const OverridableHttpConfigParams *h_txn_conf, char *tag) -{ - ink_assert(false); -} - -void -IpAllow::release() -{ - ink_assert(false); -} - -#include "HttpBodyFactory.h" - -char * -HttpBodyFactory::fabricate_with_old_api(const char *type, HttpTransact::State *context, int64_t max_buffer_length, - int64_t *resulting_buffer_length, char *content_language_out_buf, - size_t content_language_buf_size, char *content_type_out_buf, size_t content_type_buf_size, - int format_size, const char *format) -{ - ink_assert(false); - return nullptr; -} - -#include "Log.h" - -int -Log::error(char const *, ...) -{ - ink_assert(false); - return 0; -} +StatPagesManager statPagesManager; \ No newline at end of file From 4500b947d51a6f27abae5e48ac011893075040a8 Mon Sep 17 00:00:00 2001 From: Zhengxi Li Date: Mon, 24 Apr 2023 03:13:38 +0000 Subject: [PATCH 3/3] link with libs --- proxy/http/Makefile.am | 25 +++++++++++++++------- proxy/http/unit_tests/test_HttpTransact.cc | 4 ---- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/proxy/http/Makefile.am b/proxy/http/Makefile.am index c580f4e51d1..c0a0cae54f4 100644 --- a/proxy/http/Makefile.am +++ b/proxy/http/Makefile.am @@ -129,22 +129,31 @@ test_HttpTransact_CPPFLAGS = \ -I$(abs_top_srcdir)/tests/include if OS_LINUX -test_HttpTransact_LDFLAGS = $(AM_LDFLAGS)\ - -Wl,--unresolved-symbols=ignore-all +test_HttpTransact_LDFLAGS = $(AM_LDFLAGS) else test_HttpTransact_LDFLAGS = $(AM_LDFLAGS)\ -Wl,-undefined -Wl,suppress -Wl,-flat_namespace -Wl,-dead_strip endif -test_HttpTransact_LDADD = \ +test_HttpTransact_LDADD = \ + $(top_builddir)/proxy/http/libhttp.a \ + $(top_builddir)/proxy/http/remap/libhttp_remap.a \ + $(top_builddir)/proxy/logging/liblogging.a \ + $(top_builddir)/proxy/hdrs/libhdrs.a \ + $(top_builddir)/iocore/utils/libinkutils.a \ + $(top_builddir)/iocore/hostdb/libinkhostdb.a \ + $(top_builddir)/iocore/dns/libinkdns.a \ + $(top_builddir)/iocore/cache/libinkcache.a \ + $(top_builddir)/lib/fastlz/libfastlz.a \ + $(top_builddir)/iocore/aio/libinkaio.a \ $(top_builddir)/src/tscore/libtscore.la \ + $(top_builddir)/src/tscpp/util/libtscpputil.la \ + $(top_builddir)/proxy/libproxy.a \ + $(top_builddir)/iocore/net/libinknet.a \ $(top_builddir)/src/records/librecords_p.a \ - $(top_builddir)/proxy/ProxySession.o \ - $(top_builddir)/proxy/http/HttpTransact.o \ - $(top_builddir)/proxy/http/HttpTransactHeaders.o \ - $(top_builddir)/proxy/hdrs/libhdrs.a \ $(top_builddir)/iocore/eventsystem/libinkevent.a \ - @SWOC_LIBS@ + -lz -llzma -lcrypto -lresolv -lssl \ + @LIBPCRE@ @HWLOC_LIBS@ @SWOC_LIBS@ test_HttpTransact_SOURCES = \ ../../iocore/cache/test/stub.cc \ diff --git a/proxy/http/unit_tests/test_HttpTransact.cc b/proxy/http/unit_tests/test_HttpTransact.cc index caa07e9e724..518e1732362 100644 --- a/proxy/http/unit_tests/test_HttpTransact.cc +++ b/proxy/http/unit_tests/test_HttpTransact.cc @@ -567,7 +567,3 @@ TEST_CASE("HttpTransact", "[http]") } } } - -#include "HttpSessionManager.h" -HttpSessionManager httpSessionManager; -StatPagesManager statPagesManager; \ No newline at end of file