]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Reduce testHttpRequest dependencies (#2252)
authorEduard Bagdasaryan <eduard.bagdasaryan@measurement-factory.com>
Sat, 25 Oct 2025 19:51:51 +0000 (19:51 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Mon, 27 Oct 2025 02:22:47 +0000 (02:22 +0000)
No functionality changes are expected.

src/Makefile.am
src/acl/FilledChecklist.cc
src/acl/FilledChecklist.h
src/tests/Stub.am
src/tests/stub_ACLFilledChecklist.cc [new file with mode: 0644]
src/tests/stub_access_log.cc
src/tests/stub_acl.cc
src/tests/stub_adaptation_History.cc [new file with mode: 0644]
src/tests/stub_libanyp.cc
src/tests/stub_libdns.cc [new file with mode: 0644]
src/tests/stub_libformat.cc

index 5d85a9698178970bfacd79cf9134f5d15527e9a3..39650e494f348994cf12c07213b8a3c0e9d16572 100644 (file)
@@ -1929,241 +1929,67 @@ tests_testHttpReply_LDFLAGS = $(LIBADD_DL)
 
 check_PROGRAMS += tests/testHttpRequest
 tests_testHttpRequest_SOURCES = \
-       $(DELAY_POOL_SOURCE) \
-       $(DNSSOURCE) \
-       $(HTCPSOURCE) \
-       $(IPC_SOURCE) \
-       $(SNMP_SOURCE) \
-       $(WIN32_SOURCE) \
-       AccessLogEntry.cc \
-       AuthReg.h \
-       BodyPipe.cc \
-       tests/stub_CacheDigest.cc \
-       CacheDigest.h \
-       CachePeer.cc \
-       CachePeer.h \
-       CachePeers.cc \
-       CachePeers.h \
-       ClientInfo.h \
-       tests/stub_CollapsedForwarding.cc \
-       ConfigOption.cc \
+       tests/testHttpRequest.cc \
+       tests/testHttpRequestMethod.cc
+nodist_tests_testHttpRequest_SOURCES = \
+       $(TESTSOURCES) \
+       tests/stub_ACLFilledChecklist.cc \
+       tests/stub_CachePeer.cc \
        ConfigParser.cc \
-       CpuAffinityMap.cc \
-       CpuAffinityMap.h \
-       CpuAffinitySet.cc \
-       CpuAffinitySet.h \
        tests/stub_ETag.cc \
-       tests/stub_EventLoop.cc \
-       ExternalACLEntry.cc \
-       FadingCounter.cc \
-       FwdState.cc \
-       FwdState.h \
-       HappyConnOpener.cc \
-       HappyConnOpener.h \
-       HeaderMangling.cc \
-       HeaderMangling.h \
-       HttpBody.cc \
-       HttpBody.h \
-       tests/stub_HttpControlMsg.cc \
+       tests/stub_HelperChildConfig.cc \
        HttpHdrCc.cc \
-       HttpHdrCc.h \
        HttpHdrContRange.cc \
        HttpHdrRange.cc \
        HttpHdrSc.cc \
        HttpHdrScTarget.cc \
        HttpHeader.cc \
-       HttpHeader.h \
-       HttpHeaderFieldStat.h \
        HttpHeaderTools.cc \
-       HttpHeaderTools.h \
-       HttpReply.cc \
+       tests/stub_HttpReply.cc \
        HttpRequest.cc \
-       tests/testHttpRequest.cc \
-       tests/testHttpRequestMethod.cc \
-       tests/stub_HttpUpgradeProtocolAccess.cc \
-       tests/stub_Instance.cc \
-       IoStats.h \
-       tests/stub_IpcIoFile.cc \
-       LogTags.cc \
        MasterXaction.cc \
-       MasterXaction.h \
        MemBuf.cc \
-       MemObject.cc \
-       MemStore.cc \
        Notes.cc \
-       Notes.h \
-       Parsing.cc \
-       PeerPoolMgr.cc \
-       PeerPoolMgr.h \
-       Pipeline.cc \
-       Pipeline.h \
-       RefreshPattern.h \
-       RemovalPolicy.cc \
        RequestFlags.cc \
-       RequestFlags.h \
-       ResolvedPeers.cc \
-       ResolvedPeers.h \
-       SquidMath.cc \
-       SquidMath.h \
-       StatCounters.cc \
-       StatCounters.h \
        StatHist.cc \
-       StatHist.h \
-       StoreFileSystem.cc \
-       StoreIOState.cc \
-       StoreSwapLogData.cc \
        StrList.cc \
-       StrList.h \
        String.cc \
-       Transients.cc \
+       tests/stub_access_log.cc \
+       tests/stub_acl.cc \
+       tests/stub_adaptation_History.cc \
        tests/stub_cache_cf.cc \
-       cache_cf.h \
-       cache_manager.cc \
-       tests/stub_carp.cc \
-       carp.h \
-       cbdata.cc \
-       clientStream.cc \
-       tests/stub_client_db.cc \
-       client_side.cc \
-       client_side.h \
-       client_side_reply.cc \
-       client_side_request.cc \
-       dlink.cc \
-       dlink.h \
-       errorpage.cc \
-       event.cc \
-       external_acl.cc \
+       tests/stub_cache_manager.cc \
+       tests/stub_cbdata.cc \
+       tests/stub_client_side.cc \
+       tests/stub_debug.cc \
+       tests/stub_event.cc \
        tests/stub_fatal.cc \
-       fatal.h \
-       fd.cc \
-       fd.h \
-       fde.cc \
-       fqdncache.cc \
-       fqdncache.h \
-       fs_io.cc \
-       fs_io.h \
-       helper.cc \
-       hier_code.h \
-       http.cc \
-       icp_v2.cc \
-       icp_v3.cc \
-       int.cc \
-       int.h \
-       internal.cc \
-       internal.h \
-       tests/stub_ipc_Forwarder.cc \
-       ipcache.cc \
-       tests/stub_libauth.cc \
-       tests/stub_libauth_acls.cc \
-       tests/stub_libdiskio.cc \
+       tests/stub_libdns.cc \
        tests/stub_liberror.cc \
-       tests/stub_libeui.cc \
-       tests/stub_libmem.cc \
-       tests/stub_libsecurity.cc \
-       tests/stub_libstore.cc \
-       tests/stub_main_cc.cc \
-       mem_node.cc \
-       mime.cc \
-       mime.h \
+       tests/stub_libformat.cc \
+       tests/stub_liblog.cc \
+       tests/stub_libtime.cc \
        mime_header.cc \
-       mime_header.h \
-       multicast.cc \
-       multicast.h \
-       neighbors.cc \
-       neighbors.h \
-       pconn.cc \
-       peer_digest.cc \
-       peer_proxy_negotiate_auth.cc \
-       peer_proxy_negotiate_auth.h \
-       peer_select.cc \
-       peer_sourcehash.cc \
-       peer_sourcehash.h \
-       peer_userhash.cc \
-       peer_userhash.h \
-       tests/stub_redirect.cc \
-       redirect.h \
-       refresh.cc \
-       refresh.h \
-       repl_modules.h \
-       stat.cc \
-       stat.h \
-       stmem.cc \
-       store.cc \
-       store_client.cc \
-       tests/stub_store_digest.cc \
-       store_digest.h \
-       store_io.cc \
-       store_key_md5.cc \
-       store_key_md5.h \
-       store_log.cc \
-       store_log.h \
-       store_rebuild.cc \
-       store_rebuild.h \
-       tests/stub_store_stats.cc \
-       store_swapin.cc \
-       store_swapin.h \
-       store_swapout.cc \
-       tools.cc \
-       tools.h \
-       tests/stub_tunnel.cc \
-       tunnel.h \
-       urn.cc \
-       urn.h \
-       tests/stub_wccp2.cc \
-       wccp2.h \
-       wordlist.cc \
-       wordlist.h
-nodist_tests_testHttpRequest_SOURCES = \
-       $(BUILT_SOURCES) \
-       tests/stub_libtime.cc
+       tests/stub_neighbors.cc \
+       tests/stub_store.cc \
+       tests/stub_store_stats.cc
 tests_testHttpRequest_LDADD = \
-       libsquid.la \
-       clients/libclients.la \
-       servers/libservers.la \
-       helper/libhelper.la \
-       ftp/libftp.la \
-       http/libhttp.la \
-       acl/libacls.la \
-       acl/libstate.la \
-       acl/libapi.la \
-       parser/libparser.la \
-       fs/libfs.la \
-       $(SSL_LIBS) \
-       ipc/libipc.la \
-       proxyp/libproxyp.la \
-       parser/libparser.la \
-       dns/libdns.la \
        base/libbase.la \
-       mgr/libmgr.la \
-       html/libhtml.la \
-       anyp/libanyp.la \
-       $(SNMP_LIBS) \
-       icmp/libicmp.la \
-       comm/libcomm.la \
-       ip/libip.la \
-       log/liblog.la \
-       format/libformat.la \
-       store/libstore.la \
        sbuf/libsbuf.la \
-       debug/libdebug.la \
-       $(REPL_OBJS) \
-       $(ADAPTATION_LIBS) \
-       $(top_builddir)/lib/libmisccontainers.la \
+       SquidConfig.o \
+       ip/libip.la \
+       parser/libparser.la \
+       mem/libmem.la \
+       http/libhttp.la \
+       anyp/libanyp.la \
        $(top_builddir)/lib/libmiscencoding.la \
        $(top_builddir)/lib/libmiscutil.la \
-       $(LIBCAP_LIBS) \
-       $(LIBGNUTLS_LIBS) \
-       $(LIBHEIMDAL_KRB5_LIBS) \
-       $(REGEXLIB) \
-       $(SSLLIB) \
-       $(LIBCPPUNIT_LIBS) \
-       $(LIBSYSTEMD_LIBS) \
        $(COMPAT_LIB) \
-       $(LIBGSS_LIBS) \
-       $(LIBMIT_KRB5_LIBS) \
+       $(LIBCPPUNIT_LIBS) \
+       $(LIBGNUTLS_LIBS) \
        $(LIBNETFILTER_CONNTRACK_LIBS) \
        $(LIBNETTLE_LIBS) \
-       $(LIBPSAPI_LIBS) \
+       $(SSLLIB) \
        $(XTRA_LIBS)
 tests_testHttpRequest_LDFLAGS = $(LIBADD_DL)
 
index 59e338214bae4a9b73dc294a091205df4279669a..8519ff5dbb2ee0c7322173c60fbca3780202abea 100644 (file)
 
 CBDATA_CLASS_INIT(ACLFilledChecklist);
 
-ACLFilledChecklist::ACLFilledChecklist() :
-    dst_rdns(nullptr),
-#if USE_AUTH
-    auth_user_request (nullptr),
-#endif
-#if SQUID_SNMP
-    snmp_community(nullptr),
-#endif
-    requestErrorType(ERR_MAX),
-    conn_(nullptr),
-    fd_(-1),
-    destinationDomainChecked_(false),
-    sourceDomainChecked_(false)
-{
-    my_addr.setEmpty();
-    src_addr.setEmpty();
-    dst_addr.setEmpty();
-}
+ACLFilledChecklist::ACLFilledChecklist() = default;
 
 ACLFilledChecklist::~ACLFilledChecklist()
 {
@@ -198,24 +181,8 @@ ACLFilledChecklist::markSourceDomainChecked()
  *    (XXX) or eventually/asynchronously. After this callback obligations are
  *    fulfilled, checkCallback() deletes the checklist object (i.e. "this").
  */
-ACLFilledChecklist::ACLFilledChecklist(const acl_access *A, HttpRequest *http_request):
-    dst_rdns(nullptr),
-#if USE_AUTH
-    auth_user_request(nullptr),
-#endif
-#if SQUID_SNMP
-    snmp_community(nullptr),
-#endif
-    requestErrorType(ERR_MAX),
-    conn_(nullptr),
-    fd_(-1),
-    destinationDomainChecked_(false),
-    sourceDomainChecked_(false)
+ACLFilledChecklist::ACLFilledChecklist(const acl_access * const A, HttpRequest * const http_request)
 {
-    my_addr.setEmpty();
-    src_addr.setEmpty();
-    dst_addr.setEmpty();
-
     changeAcl(A);
     setRequest(http_request);
 }
index a58995390ef1b9c4e016e63efffec7a26aa4295e..f500f0e8e459c1a9dafdfdff563f0b94066dbf4d 100644 (file)
@@ -98,7 +98,7 @@ public:
     Ip::Address dst_addr;
     Ip::Address my_addr;
     SBuf dst_peer_name;
-    char *dst_rdns;
+    char *dst_rdns = nullptr;
 
     HttpRequest::Pointer request;
 
@@ -106,7 +106,7 @@ public:
     Auth::UserRequest::Pointer auth_user_request;
 #endif
 #if SQUID_SNMP
-    char *snmp_community;
+    char *snmp_community = nullptr;
 #endif
 
     // TODO: RefCount errors; do not ignore them because their "owner" is gone!
@@ -125,16 +125,16 @@ public:
 
     ExternalACLEntryPointer extacl_entry;
 
-    err_type requestErrorType;
+    err_type requestErrorType = ERR_MAX;
 
 private:
-    ConnStateData *conn_; ///< hack: client-to-Squid connection manager (if any)
-    int fd_;                        /**< may be available when conn_ is not */
+    ConnStateData *conn_ = nullptr; ///< hack: client-to-Squid connection manager (if any)
+    int fd_ = -1; /**< may be available when conn_ is not */
 
     HttpReply::Pointer reply_; ///< response added by updateReply() or nil
 
-    bool destinationDomainChecked_;
-    bool sourceDomainChecked_;
+    bool destinationDomainChecked_ = false;
+    bool sourceDomainChecked_ = false;
     /// not implemented; will cause link failures if used
     ACLFilledChecklist(const ACLFilledChecklist &);
     /// not implemented; will cause link failures if used
index 2f9d15d279e2b0666cf4b4428947b00ee7d7ebc4..67448d314410ab76c306d75d1dbe4c2fe0f0a315 100644 (file)
@@ -9,6 +9,7 @@
 ## This file is generated by scripts/source-maintenance.sh.
 
 STUB_SOURCE = \
+       tests/stub_ACLFilledChecklist.cc \
        tests/stub_CacheDigest.cc \
        tests/stub_CachePeer.cc \
        tests/stub_CollapsedForwarding.cc \
@@ -33,6 +34,7 @@ STUB_SOURCE = \
        tests/stub_UdsOp.cc \
        tests/stub_access_log.cc \
        tests/stub_acl.cc \
+       tests/stub_adaptation_History.cc \
        tests/stub_cache_cf.cc \
        tests/stub_cache_manager.cc \
        tests/stub_carp.cc \
@@ -61,6 +63,7 @@ STUB_SOURCE = \
        tests/stub_libauth_acls.cc \
        tests/stub_libcomm.cc \
        tests/stub_libdiskio.cc \
+       tests/stub_libdns.cc \
        tests/stub_liberror.cc \
        tests/stub_libeui.cc \
        tests/stub_libformat.cc \
diff --git a/src/tests/stub_ACLFilledChecklist.cc b/src/tests/stub_ACLFilledChecklist.cc
new file mode 100644 (file)
index 0000000..bfa41d8
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 1996-2025 The Squid Software Foundation and contributors
+ *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
+ */
+
+#include "squid.h"
+
+#define STUB_API "acl/FilledChecklist.cc"
+#include "tests/STUB.h"
+
+#include "ExternalACLEntry.h"
+
+#include "acl/FilledChecklist.h"
+// These stubs are not in tests/stub_acl.cc because ACLFilledChecklist requires
+// X509_free() and other heavy or difficult-to-stub dependencies that other
+// tests/stub_acl.cc users (e.g., testConfigParser) may not otherwise need.
+ACLFilledChecklist::ACLFilledChecklist() STUB
+ACLFilledChecklist::ACLFilledChecklist(const acl_access *, HttpRequest *) STUB
+ACLFilledChecklist::~ACLFilledChecklist() STUB
+void ACLFilledChecklist::syncAle(HttpRequest *, const char *) const STUB
+void ACLFilledChecklist::updateAle(const AccessLogEntry::Pointer &) STUB
+void ACLFilledChecklist::updateReply(const HttpReply::Pointer &) STUB
+void ACLFilledChecklist::verifyAle() const STUB
index f8798798eeaa91972f884b868e536a4b02601b75..d73443d433dea7e155a329fda0c3404fe2b778be 100644 (file)
@@ -12,7 +12,7 @@
 #define STUB_API "access.log.cc"
 #include "tests/STUB.h"
 
-HierarchyLogEntry::HierarchyLogEntry() STUB
+HierarchyLogEntry::HierarchyLogEntry() STUB_NOP
 
 void HierarchyLogEntry::notePeerRead() STUB
 void HierarchyLogEntry::notePeerWrite() STUB
index 3963b9bd1b68fa6c29d7e173083770eac3cd3abc..eff1f52a3218f69b53bc0d95297e3cd7f480a528 100644 (file)
 #include "tests/STUB.h"
 
 #include "acl/forward.h"
+#include "acl/Tree.h"
 
 #include "acl/Gadgets.h"
 size_t aclParseAclList(ConfigParser &, ACLList **, const char *) STUB_RETVAL(0)
+void aclDestroyAclList(ACLList **) STUB
+const Acl::Tree &Acl::ToTree(const TreePointer *) STUB_RETREF(Acl::Tree)
+
+#include "acl/Checklist.h"
+ACLChecklist::ACLChecklist() STUB
+ACLChecklist::~ACLChecklist() STUB
+const Acl::Answer &ACLChecklist::fastCheck() STUB_RETREF(Acl::Answer)
+const Acl::Answer &ACLChecklist::fastCheck(const ACLList *) STUB_RETREF(Acl::Answer)
 
diff --git a/src/tests/stub_adaptation_History.cc b/src/tests/stub_adaptation_History.cc
new file mode 100644 (file)
index 0000000..d3da81a
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 1996-2025 The Squid Software Foundation and contributors
+ *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
+ */
+
+#include "squid.h"
+
+#define STUB_API "adaptation/libadaptation.la"
+#include "tests/STUB.h"
+
+#if USE_ADAPTATION
+#include "adaptation/History.h"
+#endif
+#if ICAP_CLIENT
+#include "adaptation/icap/History.h"
+#endif
+
+#if ICAP_CLIENT
+int IcapLogfileStatus = LOG_DISABLE;
+Adaptation::Icap::History::History() STUB
+#endif
+
+#if USE_ADAPTATION
+Adaptation::History::History():
+    lastMeta(hoReply),
+    allMeta(hoReply),
+    theNextServices("")
+{
+    STUB_NOP
+}
+#endif
+
index d6c992c614d35c10fd38b4a629113380d7d73b8e..7983e667bf5135217a97f3dc3d7baa75aca174fd 100644 (file)
@@ -19,6 +19,7 @@ void AnyP::Uri::host(const char *) STUB
 static SBuf nil;
 const SBuf &AnyP::Uri::path() const STUB_RETVAL(nil)
 void AnyP::Uri::addRelativePath(const char *) STUB
+char *urlCanonicalCleanWithoutRequest(const SBuf &, const HttpRequestMethod &, const AnyP::UriScheme &) STUB_RETVAL(nullptr)
 const SBuf &AnyP::Uri::SlashPath()
 {
     static SBuf slash("/");
diff --git a/src/tests/stub_libdns.cc b/src/tests/stub_libdns.cc
new file mode 100644 (file)
index 0000000..b64f42e
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * Copyright (C) 1996-2025 The Squid Software Foundation and contributors
+ *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
+ */
+
+#include "squid.h"
+
+#define STUB_API "dns/libdns.la"
+#include "tests/STUB.h"
+
+#include "dns/LookupDetails.h"
+
+std::ostream &Dns::LookupDetails::print(std::ostream &os) const STUB_RETVAL(os)
index ce3d727e9f96e21aeb43bb71af4815cd21a8a8cd..2cae3b9b385a3cad51a5a786d2230ea769fb76be 100644 (file)
@@ -8,12 +8,17 @@
 
 #include "squid.h"
 #include "format/Format.h"
+#include "format/Quoting.h"
 
 #define STUB_API "stub_libformat.cc"
 #include "tests/STUB.h"
 
+const SBuf Format::Dash("-");
+
 void Format::Format::assemble(MemBuf &, const AccessLogEntryPointer &, int) const STUB
 bool Format::Format::parse(char const*) STUB_RETVAL(false)
 Format::Format::Format(char const*) STUB
 Format::Format::~Format() STUB
+char *Format::QuoteUrlEncodeUsername(const char *) STUB_RETVAL(nullptr)
+char *Format::QuoteMimeBlob(const char *) STUB_RETVAL(nullptr)