]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - test-suite/test_tools.cc
SourceFormat Enforcement
[thirdparty/squid.git] / test-suite / test_tools.cc
index a2a93c1bd8d5c86acdb424aa7d3237980a226125..009833c5027c20a7474781e55f2e6a73ce213a50 100644 (file)
@@ -1,19 +1,17 @@
 /*
- * $Id$
+ * Copyright (C) 1996-2015 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.
  */
 
-// XXX: This file is made of large pieces of src/debug.cc and src/tools.cc
+// XXX: This file is made of large pieces of src/tools.cc
 // with only a few minor modifications. TODO: redesign or delete.
 
 #include "squid.h"
-
-/* AYJ: the debug stuff here should really be in a stub_debug.cc file for tests to link */
-
-/* for correct pre-definitions of debug objects */
-/* and stream headers */
-#include "Debug.h"
-
-FILE *debug_log = NULL;
+#include "dlink.h"
+#include <iostream>
 
 void
 xassert(const char *msg, const char *file, int line)
@@ -22,145 +20,10 @@ xassert(const char *msg, const char *file, int line)
     exit (1);
 }
 
-int Debug::Levels[MAX_DEBUG_SECTIONS];
-int Debug::level;
-
-static void
-_db_print_stderr(const char *format, va_list args);
-
-void
-_db_print(const char *format,...)
-{
-    LOCAL_ARRAY(char, f, BUFSIZ);
-    va_list args1;
-    va_list args2;
-    va_list args3;
-
-    va_start(args1, format);
-    va_start(args2, format);
-    va_start(args3, format);
-
-    snprintf(f, BUFSIZ, "%s| %s",
-             "stub time", //debugLogTime(squid_curtime),
-             format);
-
-    _db_print_stderr(f, args2);
-
-    va_end(args1);
-    va_end(args2);
-    va_end(args3);
-}
-
-static void
-_db_print_stderr(const char *format, va_list args)
-{
-    /* FIXME? */
-    // if (opt_debug_stderr < Debug::level)
-
-    if (1 < Debug::level)
-        return;
-
-    vfprintf(stderr, format, args);
-}
-
-void
-fatal_dump(const char *message)
-{
-    fprintf(stderr, "Fatal: %s",message);
-    exit (1);
-}
-
-void
-fatal(const char *message)
-{
-    fprintf(stderr, "Fatal: %s", message);
-    exit (1);
-}
-
-/* used by fatalf */
-static void
-fatalvf(const char *fmt, va_list args)
-{
-    static char fatal_str[BUFSIZ];
-    vsnprintf(fatal_str, sizeof(fatal_str), fmt, args);
-    fatal(fatal_str);
-}
-
-/* printf-style interface for fatal */
-void
-fatalf(const char *fmt,...)
-{
-    va_list args;
-    va_start(args, fmt);
-    fatalvf(fmt, args);
-    va_end(args);
-}
-
-void
-debug_trap(const char *message)
-{
-    fatal(message);
-}
-
-int Debug::TheDepth = 0;
-
-std::ostream &
-Debug::getDebugOut()
-{
-    assert(TheDepth >= 0);
-    ++TheDepth;
-    if (TheDepth > 1) {
-        assert(CurrentDebug);
-        *CurrentDebug << std::endl << "reentrant debuging " << TheDepth << "-{";
-    } else {
-        assert(!CurrentDebug);
-        CurrentDebug = new std::ostringstream();
-        // set default formatting flags
-        CurrentDebug->setf(std::ios::fixed);
-        CurrentDebug->precision(2);
-    }
-    return *CurrentDebug;
-}
-
-void
-Debug::finishDebug()
-{
-    assert(TheDepth >= 0);
-    assert(CurrentDebug);
-    if (TheDepth > 1) {
-        *CurrentDebug << "}-" << TheDepth << std::endl;
-    } else {
-        assert(TheDepth == 1);
-        _db_print("%s\n", CurrentDebug->str().c_str());
-        delete CurrentDebug;
-        CurrentDebug = NULL;
-    }
-    --TheDepth;
-}
-
-void
-Debug::xassert(const char *msg, const char *file, int line)
-{
-
-    if (CurrentDebug) {
-        *CurrentDebug << "assertion failed: " << file << ":" << line <<
-        ": \"" << msg << "\"";
-    }
-    abort();
-}
-
-std::ostringstream *Debug::CurrentDebug(NULL);
-
-MemAllocator *dlink_node_pool = NULL;
-
 dlink_node *
 dlinkNodeNew()
 {
-    if (dlink_node_pool == NULL)
-        dlink_node_pool = memPoolCreate("Dlink list nodes", sizeof(dlink_node));
-
-    /* where should we call memPoolDestroy(dlink_node_pool); */
-    return static_cast<dlink_node *>(dlink_node_pool->alloc());
+    return new dlink_node;
 }
 
 /* the node needs to be unlinked FIRST */
@@ -170,7 +33,7 @@ dlinkNodeDelete(dlink_node * m)
     if (m == NULL)
         return;
 
-    dlink_node_pool->free(m);
+    delete m;
 }
 
 void
@@ -240,17 +103,3 @@ dlinkDelete(dlink_node * m, dlink_list * list)
     m->next = m->prev = NULL;
 }
 
-Ctx
-ctx_enter(const char *descr)
-{
-    return 0;
-}
-
-void
-ctx_exit(Ctx ctx) {}
-
-// for debugs()
-const char* SkipBuildPrefix(const char* path)
-{
-    return path;
-}