This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 9.2.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/9.2.x by this push:
     new 42c24ea  Enable all iocore/cache tests (#8718)
42c24ea is described below

commit 42c24eadcd7bfa724bfaf948a1be2f2dd32781e5
Author: Chris McFarlen <[email protected]>
AuthorDate: Mon Mar 21 14:44:55 2022 -0500

    Enable all iocore/cache tests (#8718)
    
    Co-authored-by: Chris McFarlen <[email protected]>
    (cherry picked from commit ddd7ef8cb2291c163558c498a829faa6e690cd70)
---
 iocore/cache/Makefile.am      |  2 --
 iocore/cache/test/main.cc     | 28 +++++++++++++++++++++++++---
 iocore/cache/test/test_RWW.cc |  2 +-
 3 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/iocore/cache/Makefile.am b/iocore/cache/Makefile.am
index 9363ccb..c38c201 100644
--- a/iocore/cache/Makefile.am
+++ b/iocore/cache/Makefile.am
@@ -117,7 +117,6 @@ test_LDADD = \
        @YAMLCPP_LIBS@ \
        -lm
 
-if EXPENSIVE_TESTS
 check_PROGRAMS = \
   test_Cache \
   test_RWW \
@@ -130,7 +129,6 @@ check_PROGRAMS = \
   test_Update_L_to_S \
   test_Update_S_to_L \
   test_Update_header
-endif
 
 test_main_SOURCES = \
   ./test/main.cc \
diff --git a/iocore/cache/test/main.cc b/iocore/cache/test/main.cc
index 3585ab6..0e2379d 100644
--- a/iocore/cache/test/main.cc
+++ b/iocore/cache/test/main.cc
@@ -23,10 +23,34 @@
 
 #define CATCH_CONFIG_MAIN
 #include "main.h"
+#include "tscore/ts_file.h"
+
+#include <unistd.h>
 
 #define THREADS 1
 #define DIAGS_LOG_FILE "diags.log"
 
+// Create a new temp directory and return it
+std::string
+temp_prefix()
+{
+  char buffer[PATH_MAX];
+  std::error_code err;
+  const char *tmpdir = getenv("TMPDIR");
+  if (tmpdir == nullptr) {
+    tmpdir = "/tmp";
+  }
+  snprintf(buffer, sizeof(buffer), "%s/cachetest.XXXXXX", tmpdir);
+  auto prefix = ts::file::path(mkdtemp(buffer));
+  bool result = ts::file::create_directories(prefix / "var" / "trafficserver", 
err, 0755);
+  if (!result) {
+    Debug("cache test", "Failed to create directories for test: %s(%s)", 
prefix.c_str(), err.message().c_str());
+  }
+  ink_assert(result);
+
+  return prefix.string();
+}
+
 void
 test_done()
 {
@@ -48,7 +72,7 @@ struct EventProcessorListener : Catch::TestEventListenerBase {
     diags->show_location                      = SHOW_LOCATION_DEBUG;
 
     mime_init();
-    Layout::create();
+    Layout::create(temp_prefix());
     RecProcessInit(RECM_STAND_ALONE);
     LibRecordsConfigInit();
     ink_net_init(ts::ModuleVersion(1, 0, ts::ModuleVersion::PRIVATE));
@@ -66,8 +90,6 @@ struct EventProcessorListener : Catch::TestEventListenerBase {
 
     std::string src_dir       = std::string(TS_ABS_TOP_SRCDIR) + 
"/iocore/cache/test";
     Layout::get()->sysconfdir = src_dir;
-    Layout::get()->prefix     = src_dir;
-    ::remove("./test/var/trafficserver/cache.db");
   }
 };
 CATCH_REGISTER_LISTENER(EventProcessorListener);
diff --git a/iocore/cache/test/test_RWW.cc b/iocore/cache/test/test_RWW.cc
index ee86681..dab2f60 100644
--- a/iocore/cache/test/test_RWW.cc
+++ b/iocore/cache/test/test_RWW.cc
@@ -275,7 +275,7 @@ public:
     case VC_EVENT_ERROR:
     case VC_EVENT_EOS:
       if (this->_size == LARGE_FILE) {
-        REQUIRE(base->vio->ndone >= 1 * 1024 * 1024 - sizeof(Doc));
+        REQUIRE(base->vio->ndone >= int64_t(1 * 1024 * 1024 - sizeof(Doc)));
       } else {
         REQUIRE(base->vio->ndone == 0);
       }

Reply via email to