From bf1a56763a826e8e80708df06a695f981e85a77f Mon Sep 17 00:00:00 2001 From: Chris McFarlen Date: Mon, 7 Mar 2022 15:57:35 -0600 Subject: [PATCH 1/4] Enable all iocore/cache tests --- iocore/cache/Makefile.am | 2 -- 1 file changed, 2 deletions(-) diff --git a/iocore/cache/Makefile.am b/iocore/cache/Makefile.am index 9363ccbca5c..c38c201718b 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 \ From a06c25edf8d52b1ce523ebb597719b298ca85472 Mon Sep 17 00:00:00 2001 From: Chris McFarlen Date: Mon, 7 Mar 2022 16:57:15 -0600 Subject: [PATCH 2/4] fix compare singed mismatch --- iocore/cache/test/test_RWW.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iocore/cache/test/test_RWW.cc b/iocore/cache/test/test_RWW.cc index ee86681d58b..dab2f607195 100644 --- a/iocore/cache/test/test_RWW.cc +++ b/iocore/cache/test/test_RWW.cc @@ -275,7 +275,7 @@ class CacheRWWErrorTest : public CacheRWWTest 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); } From 8886b742b574e27c14859ba7f8cb7aa579c9ecda Mon Sep 17 00:00:00 2001 From: Chris McFarlen Date: Tue, 8 Mar 2022 16:35:52 -0600 Subject: [PATCH 3/4] use a new temp prefix dir for each run to allow parallel make check --- iocore/cache/test/main.cc | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/iocore/cache/test/main.cc b/iocore/cache/test/main.cc index 3585ab68bea..5343529b2f6 100644 --- a/iocore/cache/test/main.cc +++ b/iocore/cache/test/main.cc @@ -24,9 +24,23 @@ #define CATCH_CONFIG_MAIN #include "main.h" +#include +#include + #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]; + snprintf(buffer, sizeof(buffer), "%s/cachetest.XXXXXX", getenv("TMPDIR") ?: "/tmp"); + auto prefix = std::filesystem::path(mkdtemp(buffer)); + std::filesystem::create_directories(prefix / "var" / "trafficserver"); + return prefix.string(); +} + void test_done() { @@ -48,7 +62,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 +80,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); From 58c51411d8a9910452268f930dc836d61fe0e96c Mon Sep 17 00:00:00 2001 From: Chris McFarlen Date: Tue, 15 Mar 2022 12:51:24 -0500 Subject: [PATCH 4/4] use ts::file::path instead of std::filesystem to create temp directories. --- iocore/cache/test/main.cc | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/iocore/cache/test/main.cc b/iocore/cache/test/main.cc index 5343529b2f6..0e2379d3bde 100644 --- a/iocore/cache/test/main.cc +++ b/iocore/cache/test/main.cc @@ -23,9 +23,9 @@ #define CATCH_CONFIG_MAIN #include "main.h" +#include "tscore/ts_file.h" #include -#include #define THREADS 1 #define DIAGS_LOG_FILE "diags.log" @@ -35,9 +35,19 @@ std::string temp_prefix() { char buffer[PATH_MAX]; - snprintf(buffer, sizeof(buffer), "%s/cachetest.XXXXXX", getenv("TMPDIR") ?: "/tmp"); - auto prefix = std::filesystem::path(mkdtemp(buffer)); - std::filesystem::create_directories(prefix / "var" / "trafficserver"); + 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(); }