]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix unit test issue after rev.1498
authorAmos Jeffries <squid3@treenet.co.nz>
Fri, 18 Jul 2014 11:02:16 +0000 (04:02 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Fri, 18 Jul 2014 11:02:16 +0000 (04:02 -0700)
Moves service_name global definition to tools.h where it can be
accessible to more unit tests, in particular tests outside of
src/Makefile.am

Adds stub_SBuf.cc for use by unit tests not actually needing SBuf.

src/globals.h
src/ip/testAddress.cc
src/ipc/Port.cc
src/tests/Stub.list
src/tests/stub_SBuf.cc [new file with mode: 0644]
src/tests/stub_tools.cc
src/tools.cc
src/tools.h
test-suite/Makefile.am

index e90bb92efb0bb2f682325d15d19255719be6c611..568c0acf86f8f45d41ac7b2dd4ab22e2719405fc 100644 (file)
@@ -53,7 +53,6 @@ extern const char *null_string;       /* "" */
 extern const char *version_string;     /* VERSION */
 extern const char *appname_string;     /* PACKAGE */
 extern char const *visible_appname_string; /* NULL */
-extern SBuf service_name;        /* SBuf(APP_SHORTNAME) */
 extern const char *fdTypeStr[];
 extern const char *hier_strings[];
 extern const char *memStatusStr[];
index eb36a73c79cbf9de95f552d5ff764b4089f8ac95..49d60d1d8c5be5d9c67047ca552d4ee1dcdbb20f 100644 (file)
@@ -19,6 +19,8 @@
 
 CPPUNIT_TEST_SUITE_REGISTRATION( testIpAddress );
 
+#include "tests/stub_SBuf.cc"
+
 /* so that we don't break POD dependency just for the test */
 struct timeval current_time;
 double current_dtime;
index 409b1d97f6e989a548f91c3d76aaa9ad2adf052f..4970973c2cd67c269596a7bdecad88c198e25014 100644 (file)
@@ -8,8 +8,8 @@
 #include "comm/Connection.h"
 #include "comm/Read.h"
 #include "CommCalls.h"
-#include "globals.h"
 #include "ipc/Port.h"
+#include "tools.h"
 
 static const char channelPathPfx[] = DEFAULT_STATEDIR "/";
 static const char coordinatorAddrLabel[] = "-coordinator";
index a72341207eacef5dcd0442afe839f1d26e48e2d4..3a266a96e6b039360cc32ce77fad69cdfdebad9f 100644 (file)
@@ -13,6 +13,7 @@ STUB_SOURCE= tests/STUB.h \
        tests/stub_MemObject.cc \
        tests/stub_MemStore.cc \
        tests/stub_Port.cc \
+       tests/stub_SBuf.cc \
        tests/stub_SBufDetailedStats.cc \
        tests/stub_StatHist.cc \
        tests/stub_StoreMeta.cc \
diff --git a/src/tests/stub_SBuf.cc b/src/tests/stub_SBuf.cc
new file mode 100644 (file)
index 0000000..66e8713
--- /dev/null
@@ -0,0 +1,60 @@
+#include "squid.h"
+
+#define STUB_API "SBuf.cc"
+#include "tests/STUB.h"
+
+#include "SBuf.h"
+
+InstanceIdDefinitions(SBuf, "SBuf");
+
+SBufStats SBuf::stats;
+const SBuf::size_type SBuf::npos;
+const SBuf::size_type SBuf::maxSize;
+
+SBufStats::SBufStats() {}
+std::ostream& SBufStats::dump(std::ostream &os) const STUB_RETVAL(os)
+SBufStats& SBufStats::operator +=(const SBufStats&) STUB_RETVAL(*this)
+
+SBuf::SBuf() {}
+SBuf::SBuf(const SBuf &S) {}
+SBuf::SBuf(const char *S, size_type n) {}
+SBuf::SBuf(const String &S) {}
+SBuf::SBuf(const std::string &s) {}
+SBuf::~SBuf() {}
+SBuf& SBuf::assign(const SBuf &S) STUB_RETVAL(*this)
+SBuf& SBuf::assign(const char *S, size_type n) STUB_RETVAL(*this)
+void clear() STUB
+SBuf& SBuf::append(const SBuf & S) STUB_RETVAL(*this)
+SBuf& SBuf::append(const char * S, size_type Ssize) STUB_RETVAL(*this)
+SBuf& Printf(const char *fmt, ...);
+SBuf& SBuf::appendf(const char *fmt, ...) STUB_RETVAL(*this)
+SBuf& SBuf::vappendf(const char *fmt, va_list vargs) STUB_RETVAL(*this)
+std::ostream& SBuf::print(std::ostream &os) const STUB_RETVAL(os)
+std::ostream& SBuf::dump(std::ostream &os) const STUB_RETVAL(os)
+void SBuf::setAt(size_type pos, char toset) STUB
+int SBuf::compare(const SBuf &S, const SBufCaseSensitive isCaseSensitive, const size_type n) const STUB_RETVAL(-1)
+int SBuf::compare(const char *s, const SBufCaseSensitive isCaseSensitive, const size_type n) const STUB_RETVAL(-1)
+bool SBuf::startsWith(const SBuf &S, const SBufCaseSensitive isCaseSensitive) const STUB_RETVAL(false)
+bool SBuf::operator ==(const SBuf & S) const STUB_RETVAL(false)
+bool SBuf::operator !=(const SBuf & S) const STUB_RETVAL(false)
+SBuf SBuf::consume(size_type n) STUB_RETVAL(*this)
+const SBufStats& SBuf::GetStats() STUB_RETVAL(SBuf::stats)
+SBuf::size_type SBuf::copy(char *dest, size_type n) const STUB_RETVAL(0)
+const char* SBuf::rawContent() const STUB_RETVAL(NULL)
+char *SBuf::rawSpace(size_type minSize) STUB_RETVAL(NULL)
+void SBuf::forceSize(size_type newSize) STUB
+const char* SBuf::c_str() STUB_RETVAL("")
+void SBuf::reserveCapacity(size_type minCapacity) STUB
+SBuf& SBuf::chop(size_type pos, size_type n) STUB_RETVAL(*this)
+SBuf& SBuf::trim(const SBuf &toRemove, bool atBeginning, bool atEnd) STUB_RETVAL(*this)
+SBuf SBuf::substr(size_type pos, size_type n) const STUB_RETVAL(*this)
+SBuf::size_type SBuf::find(char c, size_type startPos) const STUB_RETVAL(SBuf::npos)
+SBuf::size_type SBuf::find(const SBuf & str, size_type startPos) const STUB_RETVAL(SBuf::npos)
+SBuf::size_type SBuf::rfind(char c, size_type endPos) const STUB_RETVAL(SBuf::npos)
+SBuf::size_type SBuf::rfind(const SBuf &str, size_type endPos) const STUB_RETVAL(SBuf::npos)
+SBuf::size_type SBuf::findFirstOf(const CharacterSet &set, size_type startPos) const STUB_RETVAL(SBuf::npos)
+SBuf::size_type SBuf::findFirstNotOf(const CharacterSet &set, size_type startPos) const STUB_RETVAL(SBuf::npos)
+int SBuf::scanf(const char *format, ...) STUB_RETVAL(-1)
+SBuf SBuf::toLower() const STUB_RETVAL(*this)
+SBuf SBuf::toUpper() const STUB_RETVAL(*this)
+String SBuf::toString() const STUB_RETVAL(String(""))
index fbc20a97978ac17e8f1a132d84d7c5be559c6742..c03a511352b999d24ce7722e63dcde0c55f6d93f 100644 (file)
@@ -1,10 +1,12 @@
 #include "squid.h"
-#include "tools.h"
+// XXX: need src/ to avoid clashes with ip/tools.h in testIpAddress
+#include "src/tools.h"
 
 #define STUB_API "tools.cc"
 #include "tests/STUB.h"
 
 int DebugSignal = -1;
+SBuf service_name(APP_SHORTNAME);
 void releaseServerSockets(void) STUB
 char * dead_msg(void) STUB_RETVAL(NULL)
 void mail_warranty(void) STUB
index 466e284f2430a9e4ba527ea4fc2e4088ad0b6c02..324bdaab0d49b3cce78459fd5e5321c4c0ce027b 100644 (file)
@@ -82,6 +82,7 @@ Thanks!\n"
 static void mail_warranty(void);
 static void restoreCapabilities(int keep);
 int DebugSignal = -1;
+SBuf service_name(APP_SHORTNAME);
 
 #if _SQUID_LINUX_
 /* Workaround for crappy glic header files */
index 8ee906e2dab4aa83e4528351d55d70fd1e38c2c0..49a49a3a41a80f6d045c8d381aab7283309ceae2 100644 (file)
@@ -34,6 +34,7 @@
 #define SQUID_TOOLS_H_
 
 #include "Packer.h"
+#include "SBuf.h"
 #include "SquidString.h"
 #include "typedefs.h"
 
@@ -41,6 +42,10 @@ class MemBuf;
 
 extern int DebugSignal;
 
+/// The Squid -n parameter service name.
+/// Default is APP_SHORTNAME ('squid').
+extern SBuf service_name;
+
 void kb_incr(kb_t *, size_t);
 void parseEtcHosts(void);
 int getMyPort(void);
index 6aeb5187d41a2d88b1cd6c2baaf064b026b055c8..d9d39e0822e4f673c08fde0c5df559cb94f27bff 100644 (file)
@@ -52,11 +52,14 @@ check_PROGRAMS += debug \
 tcp_banger2_LDADD = $(top_builddir)/lib/libmiscutil.la
 
 
-DEBUG_SOURCE = test_tools.cc stub_debug.cc stub_tools.cc stub_fatal.cc
+DEBUG_SOURCE = test_tools.cc stub_debug.cc stub_SBuf.cc stub_tools.cc stub_fatal.cc
 
 stub_debug.cc: $(top_srcdir)/src/tests/stub_debug.cc
        cp $(top_srcdir)/src/tests/stub_debug.cc .
 
+stub_SBuf.cc: $(top_srcdir)/src/tests/stub_SBuf.cc
+       cp $(top_srcdir)/src/tests/stub_SBuf.cc .
+
 stub_tools.cc: $(top_srcdir)/src/tests/stub_tools.cc
        cp $(top_srcdir)/src/tests/stub_tools.cc .