You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by cm...@apache.org on 2024/07/26 15:55:54 UTC

(trafficserver) branch 10.0.x updated (1de5735581 -> 3253db544c)

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

cmcfarlen pushed a change to branch 10.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


    from 1de5735581 add_allow and add_deny ACL filter actions (#11568)
     new 9c549dde38 Raise unit tests for src/proxy/http/remap from the dead. (#11259)
     new 3253db544c Unit test: enable plugin dso logic to build and run unit tests. (#11367)

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 CMakeLists.txt                                     |   1 +
 include/proxy/Plugin.h                             |   3 +
 include/proxy/http/remap/PluginFactory.h           |   2 -
 src/proxy/Plugin.cc                                |  12 +
 src/proxy/http/remap/CMakeLists.txt                |   4 +
 src/proxy/http/remap/PluginDso.cc                  |   2 +-
 src/proxy/http/remap/unit-tests/CMakeLists.txt     | 271 +++++++++++++++++++++
 .../http/remap/unit-tests/nexthop_test_stubs.cc    |   4 +-
 .../http/remap/unit-tests/plugin_init_fail.cc      |   4 +-
 .../http/remap/unit-tests/plugin_instinit_fail.cc  |   7 +-
 src/proxy/http/remap/unit-tests/plugin_misc_cb.cc  |  11 +-
 .../unit-tests/plugin_missing_deleteinstance.cc    |   7 +-
 .../remap/unit-tests/plugin_missing_doremap.cc     |   2 +-
 .../http/remap/unit-tests/plugin_missing_init.cc   |   2 +-
 .../remap/unit-tests/plugin_missing_newinstance.cc |   4 +-
 .../http/remap/unit-tests/plugin_required_cb.cc    |   4 +-
 .../proxy/http/remap/unit-tests/plugin_stub.cc     |  17 +-
 .../http/remap/unit-tests/plugin_testing_calls.cc  |   6 +-
 .../http/remap/unit-tests/plugin_testing_common.cc |  21 --
 .../http/remap/unit-tests/plugin_testing_common.h  |   2 -
 .../remap_test_dlopen_leak_suppression.txt         |  15 +-
 .../remap/unit-tests/test_NextHopConsistentHash.cc |  16 +-
 .../remap/unit-tests/test_NextHopRoundRobin.cc     |   8 +-
 .../unit-tests/test_NextHopStrategyFactory.cc      |  10 +-
 src/proxy/http/remap/unit-tests/test_PluginDso.cc  |  48 ++--
 .../http/remap/unit-tests/test_PluginFactory.cc    |   8 +-
 .../http/remap/unit-tests/test_RemapPlugin.cc      | 102 ++++----
 27 files changed, 429 insertions(+), 164 deletions(-)
 create mode 100644 src/proxy/http/remap/unit-tests/CMakeLists.txt
 copy include/tscore/ink_hw.h => src/proxy/http/remap/unit-tests/plugin_stub.cc (78%)
 copy plugins/experimental/magick/image_magic_dlopen_leak_suppression.txt => src/proxy/http/remap/unit-tests/remap_test_dlopen_leak_suppression.txt (59%)


(trafficserver) 01/02: Raise unit tests for src/proxy/http/remap from the dead. (#11259)

Posted by cm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 9c549dde3813854b24b2b3ee7dbcc214f0ab001e
Author: Walt Karas <wk...@yahooinc.com>
AuthorDate: Tue Apr 23 15:47:53 2024 -0400

    Raise unit tests for src/proxy/http/remap from the dead. (#11259)
    
    The plugin load unit tests are not currently working.
    
    (cherry picked from commit 19551e294d1fd3ff414932aaffa2895928968790)
---
 include/proxy/http/remap/PluginFactory.h           |   2 -
 src/proxy/http/remap/CMakeLists.txt                |   4 +
 src/proxy/http/remap/unit-tests/CMakeLists.txt     | 176 +++++++++++++++++++++
 .../http/remap/unit-tests/nexthop_test_stubs.cc    |   4 +-
 .../remap/unit-tests/test_NextHopConsistentHash.cc |  16 +-
 .../remap/unit-tests/test_NextHopRoundRobin.cc     |   8 +-
 .../unit-tests/test_NextHopStrategyFactory.cc      |  10 +-
 src/proxy/http/remap/unit-tests/test_PluginDso.cc  |  24 +--
 .../http/remap/unit-tests/test_PluginFactory.cc    |   4 +-
 .../http/remap/unit-tests/test_RemapPlugin.cc      |   4 +-
 10 files changed, 215 insertions(+), 37 deletions(-)

diff --git a/include/proxy/http/remap/PluginFactory.h b/include/proxy/http/remap/PluginFactory.h
index 35d9a4a3d9..9007c80c9c 100644
--- a/include/proxy/http/remap/PluginFactory.h
+++ b/include/proxy/http/remap/PluginFactory.h
@@ -31,8 +31,6 @@
 #include "proxy/http/remap/PluginDso.h"
 #include "proxy/http/remap/RemapPluginInfo.h"
 
-#include "tscore/Ptr.h"
-
 #include "tscore/ink_uuid.h"
 #include "ts/apidefs.h"
 
diff --git a/src/proxy/http/remap/CMakeLists.txt b/src/proxy/http/remap/CMakeLists.txt
index ca2540683e..ff0f63da03 100644
--- a/src/proxy/http/remap/CMakeLists.txt
+++ b/src/proxy/http/remap/CMakeLists.txt
@@ -40,3 +40,7 @@ target_link_libraries(
   PUBLIC ts::proxy ts::tscore
   PRIVATE ts::inkevent ts::inkutils yaml-cpp::yaml-cpp
 )
+
+if(BUILD_TESTING)
+  add_subdirectory(unit-tests)
+endif()
diff --git a/src/proxy/http/remap/unit-tests/CMakeLists.txt b/src/proxy/http/remap/unit-tests/CMakeLists.txt
new file mode 100644
index 0000000000..ca6793fedc
--- /dev/null
+++ b/src/proxy/http/remap/unit-tests/CMakeLists.txt
@@ -0,0 +1,176 @@
+#######################
+#
+#  Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+#  agreements.  See the NOTICE file distributed with this work for additional information regarding
+#  copyright ownership.  The ASF licenses this file to you under the Apache License, Version 2.0
+#  (the "License"); you may not use this file except in compliance with the License.  You may obtain
+#  a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software distributed under the License
+#  is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+#  or implied. See the License for the specific language governing permissions and limitations under
+#  the License.
+#
+#######################
+
+### The shared libraries built here are only used by the plugin tests  ####################
+
+function(add_plugin_ut_lib name)
+  add_library(${name} MODULE ${ARGN})
+  set_target_properties(${name} PROPERTIES PREFIX "")
+  set_target_properties(${name} PROPERTIES SUFFIX ".so")
+  target_include_directories(
+    ${name} PRIVATE "$<TARGET_PROPERTY:libswoc::libswoc,INCLUDE_DIRECTORIES>"
+                    "$<TARGET_PROPERTY:libswoc::libswoc,INTERFACE_INCLUDE_DIRECTORIES>"
+  )
+endfunction()
+
+# Test plugins will not build on OSX
+#
+# add_plugin_ut_lib(plugin_v1 plugin_misc_cb.cc)
+# target_compile_definitions(plugin_v1 PRIVATE PLUGINDSOVER=1)
+#
+# add_plugin_ut_lib(plugin_v2 plugin_misc_cb.cc)
+# target_compile_definitions(plugin_v2 PRIVATE PLUGINDSOVER=2)
+#
+# add_plugin_ut_lib(plugin_init_fail plugin_init_fail.cc)
+#
+# add_plugin_ut_lib(plugin_instinit_fail plugin_instinit_fail.cc)
+#
+# add_plugin_ut_lib(plugin_required_cb plugin_required_cb.cc)
+# target_compile_definitions(plugin_required_cb PRIVATE PLUGINDSOVER=1)
+#
+# add_plugin_ut_lib(plugin_missing_deleteinstance plugin_missing_deleteinstance.cc)
+# target_compile_definitions(plugin_missing_deleteinstance PRIVATE PLUGINDSOVER=1)
+#
+# add_plugin_ut_lib(plugin_missing_doremap plugin_missing_doremap.cc)
+# target_compile_definitions(plugin_missing_doremap PRIVATE PLUGINDSOVER=1)
+#
+# add_plugin_ut_lib(plugin_missing_init plugin_missing_init.cc)
+# target_compile_definitions(plugin_missing_init PRIVATE PLUGINDSOVER=1)
+#
+# add_plugin_ut_lib(plugin_missing_newinstance plugin_missing_newinstance.cc)
+# target_compile_definitions(plugin_missing_newinstance PRIVATE PLUGINDSOVER=1)
+#
+# add_plugin_ut_lib(plugin_testing_calls plugin_testing_calls.cc plugin_testing_common.cc)
+# target_compile_definitions(plugin_testing_calls PRIVATE PLUGINDSOVER=1)
+
+### test_PluginDso ########################################################################
+
+add_executable(test_PluginDso test_PluginDso.cc plugin_testing_common.cc ../PluginDso.cc)
+
+target_compile_definitions(test_PluginDso PRIVATE PLUGIN_DSO_TESTS)
+
+target_include_directories(test_PluginDso PRIVATE ${PROJECT_SOURCE_DIR}/tests/include)
+
+target_link_libraries(test_PluginDso PRIVATE catch2::catch2 ts::inkutils tscore libswoc::libswoc)
+
+# This test currently does not pass.
+# add_test(NAME test_PluginDso COMMAND $<TARGET_FILE:test_PluginDso>)
+
+### test_PluginFactory ########################################################################
+
+add_executable(
+  test_PluginFactory test_PluginFactory.cc plugin_testing_common.cc ../PluginFactory.cc ../PluginDso.cc
+                     ../RemapPluginInfo.cc
+)
+
+target_compile_definitions(test_PluginFactory PRIVATE PLUGIN_DSO_TESTS)
+
+target_include_directories(test_PluginFactory PRIVATE ${PROJECT_SOURCE_DIR}/tests/include)
+
+target_link_libraries(test_PluginFactory PRIVATE catch2::catch2 ts::inkutils tscore libswoc::libswoc)
+
+# This test currently does not pass.
+# add_test(NAME test_PluginFactory COMMAND $<TARGET_FILE:test_PluginFactory>)
+
+### test_RemapPluginInfo ########################################################################
+
+add_executable(test_RemapPluginInfo test_RemapPlugin.cc plugin_testing_common.cc ../PluginDso.cc ../RemapPluginInfo.cc)
+
+target_compile_definitions(test_RemapPluginInfo PRIVATE PLUGIN_DSO_TESTS)
+
+target_include_directories(test_RemapPluginInfo PRIVATE ${PROJECT_SOURCE_DIR}/tests/include)
+
+target_link_libraries(test_RemapPluginInfo PRIVATE catch2::catch2 ts::inkutils tscore libswoc::libswoc)
+
+# This test currently does not pass.
+# add_test(NAME test_RemapPluginInfo COMMAND $<TARGET_FILE:test_RemapPluginInfo>)
+
+### test_NextHopStrategyFactory ########################################################################
+
+add_executable(
+  test_NextHopStrategyFactory
+  test_NextHopStrategyFactory.cc
+  nexthop_test_stubs.cc
+  ../NextHopSelectionStrategy.cc
+  ../NextHopStrategyFactory.cc
+  ../NextHopRoundRobin.cc
+  ../NextHopConsistentHash.cc
+  ../NextHopHealthStatus.cc
+  ${PROJECT_SOURCE_DIR}/src/api/APIHooks.cc
+)
+
+target_compile_definitions(
+  test_NextHopStrategyFactory PRIVATE _NH_UNIT_TESTS_ TS_SRC_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}\"
+)
+
+target_include_directories(test_NextHopStrategyFactory PRIVATE ${PROJECT_SOURCE_DIR}/tests/include)
+
+target_link_libraries(
+  test_NextHopStrategyFactory PRIVATE catch2::catch2 ts::hdrs ts::inkutils tscore libswoc::libswoc yaml-cpp::yaml-cpp
+)
+
+add_test(NAME test_NextHopStrategyFactory COMMAND $<TARGET_FILE:test_NextHopStrategyFactory>)
+
+### test_NextHopRoundRobin ########################################################################
+
+add_executable(
+  test_NextHopRoundRobin
+  test_NextHopRoundRobin.cc
+  nexthop_test_stubs.cc
+  ../NextHopSelectionStrategy.cc
+  ../NextHopStrategyFactory.cc
+  ../NextHopRoundRobin.cc
+  ../NextHopConsistentHash.cc
+  ../NextHopHealthStatus.cc
+  ${PROJECT_SOURCE_DIR}/src/api/APIHooks.cc
+)
+
+target_compile_definitions(test_NextHopRoundRobin PRIVATE _NH_UNIT_TESTS_ TS_SRC_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}\")
+
+target_include_directories(test_NextHopRoundRobin PRIVATE ${PROJECT_SOURCE_DIR}/tests/include)
+
+target_link_libraries(
+  test_NextHopRoundRobin PRIVATE catch2::catch2 ts::hdrs ts::inkutils tscore libswoc::libswoc yaml-cpp::yaml-cpp
+)
+
+add_test(NAME test_NextHopRoundRobin COMMAND $<TARGET_FILE:test_NextHopRoundRobin>)
+
+### test_NextHopConsistentHash ########################################################################
+
+add_executable(
+  test_NextHopConsistentHash
+  test_NextHopConsistentHash.cc
+  nexthop_test_stubs.cc
+  ../NextHopSelectionStrategy.cc
+  ../NextHopStrategyFactory.cc
+  ../NextHopConsistentHash.cc
+  ../NextHopRoundRobin.cc
+  ../NextHopHealthStatus.cc
+  ${PROJECT_SOURCE_DIR}/src/api/APIHooks.cc
+)
+
+target_compile_definitions(
+  test_NextHopConsistentHash PRIVATE _NH_UNIT_TESTS_ TS_SRC_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}\"
+)
+
+target_include_directories(test_NextHopConsistentHash PRIVATE ${PROJECT_SOURCE_DIR}/tests/include)
+
+target_link_libraries(
+  test_NextHopConsistentHash PRIVATE catch2::catch2 tscore ts::hdrs ts::inkutils libswoc::libswoc yaml-cpp::yaml-cpp
+)
+
+add_test(NAME test_NextHopConsistentHash COMMAND $<TARGET_FILE:test_NextHopConsistentHash>)
diff --git a/src/proxy/http/remap/unit-tests/nexthop_test_stubs.cc b/src/proxy/http/remap/unit-tests/nexthop_test_stubs.cc
index 4d9bb46ca3..f2416c9873 100644
--- a/src/proxy/http/remap/unit-tests/nexthop_test_stubs.cc
+++ b/src/proxy/http/remap/unit-tests/nexthop_test_stubs.cc
@@ -163,7 +163,7 @@ HttpRequestData::get_client_ip()
 
 #include "api/InkAPIInternal.h"
 void
-ConfigUpdateCbTable::invoke(char const *p)
+ConfigUpdateCbTable::invoke()
 {
 }
 
@@ -207,5 +207,5 @@ HostStatus::setHostStatus(const std::string_view host, TSHostStatus status, unsi
   this->hosts_statuses[std::string(host)]->status          = status;
   this->hosts_statuses[std::string(host)]->reasons         = reason;
   this->hosts_statuses[std::string(host)]->local_down_time = down_time;
-  NH_Debug("next_hop", "setting host status for '%.*s' to %s", host.size(), host.data(), HostStatusNames[status]);
+  NH_Dbg(DbgCtl{"next_hop"}, "setting host status for '%.*s' to %s", host.size(), host.data(), HostStatusNames[status]);
 }
diff --git a/src/proxy/http/remap/unit-tests/test_NextHopConsistentHash.cc b/src/proxy/http/remap/unit-tests/test_NextHopConsistentHash.cc
index def67254c4..99860bebc1 100644
--- a/src/proxy/http/remap/unit-tests/test_NextHopConsistentHash.cc
+++ b/src/proxy/http/remap/unit-tests/test_NextHopConsistentHash.cc
@@ -52,7 +52,7 @@ SCENARIO("Testing NextHopConsistentHash class, using policy 'consistent_hash'",
   {
     // load the configuration strtegies.
     std::shared_ptr<NextHopSelectionStrategy> strategy;
-    NextHopStrategyFactory                    nhf(TS_SRC_DIR "unit-tests/consistent-hash-tests.yaml");
+    NextHopStrategyFactory                    nhf(TS_SRC_DIR "/consistent-hash-tests.yaml");
     strategy = nhf.strategyInstance("consistent-hash-1");
 
     WHEN("the config is loaded.")
@@ -191,7 +191,7 @@ SCENARIO("Testing NextHopConsistentHash class (all firstcalls), using policy 'co
   GIVEN("Loading the consistent-hash-tests.yaml config for 'consistent_hash' tests.")
   {
     std::shared_ptr<NextHopSelectionStrategy> strategy;
-    NextHopStrategyFactory                    nhf(TS_SRC_DIR "unit-tests/consistent-hash-tests.yaml");
+    NextHopStrategyFactory                    nhf(TS_SRC_DIR "/consistent-hash-tests.yaml");
     strategy = nhf.strategyInstance("consistent-hash-1");
 
     WHEN("the config is loaded.")
@@ -301,7 +301,7 @@ SCENARIO("Testing NextHop ignore_self_detect false", "[NextHopConsistentHash]")
   {
     // load the configuration strtegies.
     std::shared_ptr<NextHopSelectionStrategy> strategy;
-    NextHopStrategyFactory                    nhf(TS_SRC_DIR "unit-tests/consistent-hash-tests.yaml");
+    NextHopStrategyFactory                    nhf(TS_SRC_DIR "/consistent-hash-tests.yaml");
     strategy = nhf.strategyInstance("ignore-self-detect-false");
 
     HostStatus &hs = HostStatus::instance();
@@ -351,7 +351,7 @@ SCENARIO("Testing NextHop ignore_self_detect true", "[NextHopConsistentHash]")
   {
     // load the configuration strtegies.
     std::shared_ptr<NextHopSelectionStrategy> strategy;
-    NextHopStrategyFactory                    nhf(TS_SRC_DIR "unit-tests/consistent-hash-tests.yaml");
+    NextHopStrategyFactory                    nhf(TS_SRC_DIR "/consistent-hash-tests.yaml");
     strategy = nhf.strategyInstance("ignore-self-detect-true");
 
     HostStatus &hs = HostStatus::instance();
@@ -401,7 +401,7 @@ SCENARIO("Testing NextHopConsistentHash same host different port markdown", "[Ne
   {
     // load the configuration strtegies.
     std::shared_ptr<NextHopSelectionStrategy> strategy;
-    NextHopStrategyFactory                    nhf(TS_SRC_DIR "unit-tests/consistent-hash-tests.yaml");
+    NextHopStrategyFactory                    nhf(TS_SRC_DIR "/consistent-hash-tests.yaml");
     strategy = nhf.strategyInstance("same-host-different-port");
 
     WHEN("the config is loaded.")
@@ -469,7 +469,7 @@ SCENARIO("Testing NextHopConsistentHash hash_string override", "[NextHopConsiste
   {
     // load the configuration strtegies.
     std::shared_ptr<NextHopSelectionStrategy> strategy;
-    NextHopStrategyFactory                    nhf(TS_SRC_DIR "unit-tests/consistent-hash-tests.yaml");
+    NextHopStrategyFactory                    nhf(TS_SRC_DIR "/consistent-hash-tests.yaml");
     strategy = nhf.strategyInstance("hash-string-override");
 
     WHEN("the config is loaded.")
@@ -529,7 +529,7 @@ SCENARIO("Testing NextHopConsistentHash class (alternating rings), using policy
   GIVEN("Loading the consistent-hash-tests.yaml config for 'consistent_hash' tests.")
   {
     std::shared_ptr<NextHopSelectionStrategy> strategy;
-    NextHopStrategyFactory                    nhf(TS_SRC_DIR "unit-tests/consistent-hash-tests.yaml");
+    NextHopStrategyFactory                    nhf(TS_SRC_DIR "/consistent-hash-tests.yaml");
     strategy = nhf.strategyInstance("consistent-hash-2");
 
     WHEN("the config is loaded.")
@@ -648,7 +648,7 @@ SCENARIO("Testing NextHopConsistentHash using a peering ring_mode.")
   GIVEN("Loading the peering.yaml config for 'consistent_hash' tests.")
   {
     std::shared_ptr<NextHopSelectionStrategy> strategy;
-    NextHopStrategyFactory                    nhf(TS_SRC_DIR "unit-tests/peering.yaml");
+    NextHopStrategyFactory                    nhf(TS_SRC_DIR "/peering.yaml");
     strategy = nhf.strategyInstance("peering-group-1");
 
     WHEN("the config is loaded.")
diff --git a/src/proxy/http/remap/unit-tests/test_NextHopRoundRobin.cc b/src/proxy/http/remap/unit-tests/test_NextHopRoundRobin.cc
index 36729dada7..3672dfff12 100644
--- a/src/proxy/http/remap/unit-tests/test_NextHopRoundRobin.cc
+++ b/src/proxy/http/remap/unit-tests/test_NextHopRoundRobin.cc
@@ -48,7 +48,7 @@ SCENARIO("Testing NextHopRoundRobin class, using policy 'rr-strict'", "[NextHopR
   GIVEN("Loading the round-robin-tests.yaml config for round robin 'rr-strict' tests.")
   {
     std::shared_ptr<NextHopSelectionStrategy> strategy;
-    NextHopStrategyFactory                    nhf(TS_SRC_DIR "unit-tests/round-robin-tests.yaml");
+    NextHopStrategyFactory                    nhf(TS_SRC_DIR "/round-robin-tests.yaml");
     strategy = nhf.strategyInstance("rr-strict-exhaust-ring");
 
     WHEN("the config is loaded.")
@@ -173,7 +173,7 @@ SCENARIO("Testing NextHopRoundRobin class, using policy 'first-live'", "[NextHop
   GIVEN("Loading the round-robin-tests.yaml config for round robin 'first-live' tests.")
   {
     std::shared_ptr<NextHopSelectionStrategy> strategy;
-    NextHopStrategyFactory                    nhf(TS_SRC_DIR "unit-tests/round-robin-tests.yaml");
+    NextHopStrategyFactory                    nhf(TS_SRC_DIR "/round-robin-tests.yaml");
     strategy = nhf.strategyInstance("first-live");
 
     WHEN("the config is loaded.")
@@ -242,7 +242,7 @@ SCENARIO("Testing NextHopRoundRobin class, using policy 'rr-ip'", "[NextHopRound
   GIVEN("Loading the round-robin-tests.yaml config for round robin 'rr-ip' tests.")
   {
     std::shared_ptr<NextHopSelectionStrategy> strategy;
-    NextHopStrategyFactory                    nhf(TS_SRC_DIR "unit-tests/round-robin-tests.yaml");
+    NextHopStrategyFactory                    nhf(TS_SRC_DIR "/round-robin-tests.yaml");
     strategy = nhf.strategyInstance("rr-ip");
     sockaddr_in sa1, sa2;
     sa1.sin_port   = 10000;
@@ -329,7 +329,7 @@ SCENARIO("Testing NextHopRoundRobin class, using policy 'latched'", "[NextHopRou
   GIVEN("Loading the round-robin-tests.yaml config for round robin 'latched' tests.")
   {
     std::shared_ptr<NextHopSelectionStrategy> strategy;
-    NextHopStrategyFactory                    nhf(TS_SRC_DIR "unit-tests/round-robin-tests.yaml");
+    NextHopStrategyFactory                    nhf(TS_SRC_DIR "/round-robin-tests.yaml");
     strategy = nhf.strategyInstance("latched");
 
     WHEN("the config is loaded.")
diff --git a/src/proxy/http/remap/unit-tests/test_NextHopStrategyFactory.cc b/src/proxy/http/remap/unit-tests/test_NextHopStrategyFactory.cc
index 4f550eea90..4bce72da75 100644
--- a/src/proxy/http/remap/unit-tests/test_NextHopStrategyFactory.cc
+++ b/src/proxy/http/remap/unit-tests/test_NextHopStrategyFactory.cc
@@ -44,9 +44,9 @@ SCENARIO("factory tests loading yaml configs", "[loadConfig]")
   GIVEN("Loading the strategy.yaml with included 'hosts.yaml'.")
   {
 #ifdef TS_SRC_DIR
-    REQUIRE(chdir(TS_SRC_DIR) == 0);
+    REQUIRE(chdir(TS_SRC_DIR "/..") == 0);
 #endif
-    NextHopStrategyFactory nhf(TS_SRC_DIR "unit-tests/strategy.yaml");
+    NextHopStrategyFactory nhf(TS_SRC_DIR "/strategy.yaml");
 
     WHEN("the two files are loaded.")
     {
@@ -219,7 +219,7 @@ SCENARIO("factory tests loading yaml configs", "[loadConfig]")
 
   GIVEN("loading a yaml config, simple-strategy.yaml ")
   {
-    NextHopStrategyFactory nhf(TS_SRC_DIR "unit-tests/simple-strategy.yaml");
+    NextHopStrategyFactory nhf(TS_SRC_DIR "/simple-strategy.yaml");
 
     WHEN("loading the single file")
     {
@@ -360,7 +360,7 @@ SCENARIO("factory tests loading yaml configs", "[loadConfig]")
 
   GIVEN("loading a yaml config combining hosts and strategies into one file, combined.yaml")
   {
-    NextHopStrategyFactory nhf(TS_SRC_DIR "unit-tests/combined.yaml");
+    NextHopStrategyFactory nhf(TS_SRC_DIR "/combined.yaml");
 
     WHEN("loading the single file")
     {
@@ -782,7 +782,7 @@ SCENARIO("factory tests loading yaml configs from a directory", "[loadConfig]")
 {
   GIVEN("Loading the strategies using a directory of 'yaml' files")
   {
-    NextHopStrategyFactory nhf(TS_SRC_DIR "unit-tests/strategies-dir");
+    NextHopStrategyFactory nhf(TS_SRC_DIR "/strategies-dir");
 
     WHEN("the two files are loaded.")
     {
diff --git a/src/proxy/http/remap/unit-tests/test_PluginDso.cc b/src/proxy/http/remap/unit-tests/test_PluginDso.cc
index c4ae83d1ff..3f6a119c74 100644
--- a/src/proxy/http/remap/unit-tests/test_PluginDso.cc
+++ b/src/proxy/http/remap/unit-tests/test_PluginDso.cc
@@ -43,7 +43,7 @@ std::error_code ec;
 static fs::path sandboxDir     = getTemporaryDir();
 static fs::path runtimeDir     = sandboxDir / fs::path("runtime");
 static fs::path searchDir      = sandboxDir / fs::path("search");
-static fs::path pluginBuildDir = fs::current_path() / fs::path("unit-tests/.libs");
+static fs::path pluginBuildDir = fs::current_path();
 
 /* The following are paths used in all scenarios in the unit tests */
 static fs::path configPath      = fs::path("plugin_v1.so");
@@ -110,7 +110,7 @@ SCENARIO("loading plugins", "[plugin][core]")
 
     WHEN("loading a valid plugin")
     {
-      bool result = plugin.load(error);
+      bool result = plugin.load(error, fs::path()); // Dummy compiler path.
 
       THEN("expect it to successfully load")
       {
@@ -125,7 +125,7 @@ SCENARIO("loading plugins", "[plugin][core]")
 
     WHEN("loading a valid plugin")
     {
-      bool result = plugin.load(error);
+      bool result = plugin.load(error, fs::path()); // Dummy compiler path.
 
       THEN("expect saving the right DSO file modification time")
       {
@@ -142,7 +142,7 @@ SCENARIO("loading plugins", "[plugin][core]")
     {
       CHECK(fs::remove_all(runtimeDir, ec) > 0);
       CHECK_FALSE(fs::exists(runtimePath));
-      bool result = plugin.load(error);
+      bool result = plugin.load(error, fs::path()); // Dummy compiler path.
 
       THEN("expect it to fail")
       {
@@ -155,12 +155,12 @@ SCENARIO("loading plugins", "[plugin][core]")
     WHEN("loading a valid plugin twice in a row")
     {
       /* First attempt OK */
-      bool result = plugin.load(error);
+      bool result = plugin.load(error, fs::path()); // Dummy compiler path.
       CHECK(true == result);
       CHECK(error.empty());
 
       /* Second attempt */
-      result = plugin.load(error);
+      result = plugin.load(error, fs::path()); // Dummy compiler path.
 
       THEN("expect it to fail the second attempt")
       {
@@ -190,7 +190,7 @@ SCENARIO("loading plugins", "[plugin][core]")
     WHEN("unloading a valid plugin twice in a row")
     {
       /* First attempt OK */
-      bool result = plugin.load(error);
+      bool result = plugin.load(error, fs::path()); // Dummy compiler path.
       CHECK(true == result);
       CHECK(error.empty());
       result = plugin.unload(error);
@@ -214,7 +214,7 @@ SCENARIO("loading plugins", "[plugin][core]")
       CHECK_FALSE(fs::exists(runtimePath));
 
       /* Load and make sure it is loaded */
-      CHECK(plugin.load(error));
+      CHECK(plugin.load(error, fs::path())); // Dummy compiler path.
       /* Effective and runtime path set */
       CHECK(effectivePath == plugin.effectivePath());
       CHECK(runtimePath == plugin.runtimePath());
@@ -243,7 +243,7 @@ SCENARIO("loading plugins", "[plugin][core]")
         PluginDsoUnitTest localPlugin(configPath, effectivePath, runtimePath);
 
         /* Load and make sure it is loaded */
-        CHECK(localPlugin.load(error));
+        CHECK(localPlugin.load(error, fs::path())); // Dummy compiler path.
         /* Effective and runtime path set */
         CHECK(effectivePath == localPlugin.effectivePath());
         CHECK(runtimePath == localPlugin.runtimePath());
@@ -269,7 +269,7 @@ SCENARIO("loading plugins", "[plugin][core]")
 
     WHEN("loading the plugin")
     {
-      bool result = plugin.load(error);
+      bool result = plugin.load(error, fs::path()); // Dummy compiler path.
 
       THEN("expect the load to fail")
       {
@@ -300,7 +300,7 @@ SCENARIO("loading plugins", "[plugin][core]")
 
     WHEN("loading an invalid plugin")
     {
-      bool result = plugin.load(error);
+      bool result = plugin.load(error, fs::path()); // Dummy compiler path.
 
       THEN("expect it to fail to load")
       {
@@ -341,7 +341,7 @@ SCENARIO("looking for symbols inside a plugin DSO", "[plugin][core]")
   /* Now test away. */
   GIVEN("plugin loaded successfully")
   {
-    CHECK(plugin.load(error));
+    CHECK(plugin.load(error, fs::path())); // Dummy compiler path.
 
     WHEN("looking for an existing symbol")
     {
diff --git a/src/proxy/http/remap/unit-tests/test_PluginFactory.cc b/src/proxy/http/remap/unit-tests/test_PluginFactory.cc
index 2626c5441d..b2cf2bbed3 100644
--- a/src/proxy/http/remap/unit-tests/test_PluginFactory.cc
+++ b/src/proxy/http/remap/unit-tests/test_PluginFactory.cc
@@ -106,7 +106,7 @@ static fs::path sandboxDir     = getTemporaryDir();
 static fs::path runtimeRootDir = sandboxDir / "runtime";
 static fs::path runtimeDir     = runtimeRootDir / tempComponent;
 static fs::path searchDir      = sandboxDir / "search";
-static fs::path pluginBuildDir = fs::current_path() / "unit-tests/.libs";
+static fs::path pluginBuildDir = fs::current_path();
 
 void
 clean()
@@ -472,7 +472,7 @@ SCENARIO("multiple search dirs + multiple or no plugins installed", "[plugin][co
     fs::path              runtimePath1    = runtimeDir / effectivePath1.relative_path();
     fs::path              runtimePath2    = runtimeDir / effectivePath2.relative_path();
     fs::path              runtimePath3    = runtimeDir / effectivePath3.relative_path();
-    fs::path              pluginBuildPath = fs::current_path() / fs::path("unit-tests/.libs") / pluginName;
+    fs::path              pluginBuildPath = fs::current_path() / pluginName;
 
     std::string error;
 
diff --git a/src/proxy/http/remap/unit-tests/test_RemapPlugin.cc b/src/proxy/http/remap/unit-tests/test_RemapPlugin.cc
index cae770af06..8cf0831e03 100644
--- a/src/proxy/http/remap/unit-tests/test_RemapPlugin.cc
+++ b/src/proxy/http/remap/unit-tests/test_RemapPlugin.cc
@@ -44,7 +44,7 @@ std::error_code ec;
 static fs::path sandboxDir     = getTemporaryDir();
 static fs::path runtimeDir     = sandboxDir / "runtime";
 static fs::path searchDir      = sandboxDir / "search";
-static fs::path pluginBuildDir = fs::current_path() / "unit-tests/.libs";
+static fs::path pluginBuildDir = fs::current_path();
 
 void
 clean()
@@ -106,7 +106,7 @@ setupSandBox(const fs::path configPath)
 bool
 loadPlugin(RemapPluginUnitTest *plugin, std::string &error, PluginDebugObject *&debugObject)
 {
-  bool result = plugin->load(error);
+  bool result = plugin->load(error, fs::path()); // Dummy compiler path.
   debugObject = plugin->getDebugObject();
   return result;
 }


(trafficserver) 02/02: Unit test: enable plugin dso logic to build and run unit tests. (#11367)

Posted by cm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 3253db544cf724c53ae3868594b972600995c273
Author: Damian Meden <dm...@apache.org>
AuthorDate: Fri Jul 26 11:00:55 2024 +0200

    Unit test: enable plugin dso logic to build and run unit tests. (#11367)
    
    Unit test: enable plugin dso logic to build and run unit tests.
    This was disabled at some point. Changes were made to enable this but it
    seems they weren't enought, this make sures all the unit tests are
    running.
    
    Note:
    I had to use [[maybe_unused]] because linker will just remove the symbol
    from the object and then test will fail because it will not find the
    symbol. Using [[maybe_unused]] forces the linker to keep the symbol.
    
    (cherry picked from commit f2247cf4a7cc46d9f93e9e397a0eb5b560c081ef)
---
 CMakeLists.txt                                     |   1 +
 include/proxy/Plugin.h                             |   3 +
 src/proxy/Plugin.cc                                |  12 ++
 src/proxy/http/remap/PluginDso.cc                  |   2 +-
 src/proxy/http/remap/unit-tests/CMakeLists.txt     | 177 ++++++++++++++++-----
 .../http/remap/unit-tests/plugin_init_fail.cc      |   4 +-
 .../http/remap/unit-tests/plugin_instinit_fail.cc  |   7 +-
 src/proxy/http/remap/unit-tests/plugin_misc_cb.cc  |  11 +-
 .../unit-tests/plugin_missing_deleteinstance.cc    |   7 +-
 .../remap/unit-tests/plugin_missing_doremap.cc     |   2 +-
 .../http/remap/unit-tests/plugin_missing_init.cc   |   2 +-
 .../remap/unit-tests/plugin_missing_newinstance.cc |   4 +-
 .../http/remap/unit-tests/plugin_required_cb.cc    |   4 +-
 .../{plugin_missing_init.cc => plugin_stub.cc}     |  19 +--
 .../http/remap/unit-tests/plugin_testing_calls.cc  |   6 +-
 .../http/remap/unit-tests/plugin_testing_common.cc |  21 ---
 .../http/remap/unit-tests/plugin_testing_common.h  |   2 -
 .../remap_test_dlopen_leak_suppression.txt         |  26 +++
 src/proxy/http/remap/unit-tests/test_PluginDso.cc  |  26 +--
 .../http/remap/unit-tests/test_PluginFactory.cc    |   8 +-
 .../http/remap/unit-tests/test_RemapPlugin.cc      | 100 ++++++------
 21 files changed, 274 insertions(+), 170 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8155afe9d0..e59411340b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -60,6 +60,7 @@ set(BUILD_NUMBER
     "0"
     CACHE STRING "The build number"
 )
+
 execute_process(
   COMMAND id -nu
   OUTPUT_VARIABLE BUILD_PERSON
diff --git a/include/proxy/Plugin.h b/include/proxy/Plugin.h
index b8ca993e9b..7fe5825cc9 100644
--- a/include/proxy/Plugin.h
+++ b/include/proxy/Plugin.h
@@ -94,3 +94,6 @@ public:
     return 0;
   }
 };
+
+void enablePluginDynamicReload();
+void disablePluginDynamicReload();
diff --git a/src/proxy/Plugin.cc b/src/proxy/Plugin.cc
index 0dd11095c3..c705194558 100644
--- a/src/proxy/Plugin.cc
+++ b/src/proxy/Plugin.cc
@@ -41,6 +41,18 @@ isPluginDynamicReloadEnabled()
   return PluginDynamicReloadMode::RELOAD_ON == plugin_dynamic_reload_mode;
 }
 
+void
+enablePluginDynamicReload()
+{
+  plugin_dynamic_reload_mode = PluginDynamicReloadMode::RELOAD_ON;
+}
+
+void
+disablePluginDynamicReload()
+{
+  plugin_dynamic_reload_mode = PluginDynamicReloadMode::RELOAD_OFF;
+}
+
 void
 parsePluginDynamicReloadConfig()
 {
diff --git a/src/proxy/http/remap/PluginDso.cc b/src/proxy/http/remap/PluginDso.cc
index f8f5154e5a..1be809143d 100644
--- a/src/proxy/http/remap/PluginDso.cc
+++ b/src/proxy/http/remap/PluginDso.cc
@@ -105,7 +105,7 @@ PluginDso::load(std::string &error, const fs::path &compilerPath)
           result = false;
         }
       }
-    } else if (isDynamicReloadEnabled() && !copy(_effectivePath, _runtimePath, ec)) {
+    } else if (isDynamicReloadEnabled() && !fs::copy(_effectivePath, _runtimePath, ec)) {
       concat_error(error, "failed to create a copy");
       concat_error(error, ec.message());
       result = false;
diff --git a/src/proxy/http/remap/unit-tests/CMakeLists.txt b/src/proxy/http/remap/unit-tests/CMakeLists.txt
index ca6793fedc..04ed65782a 100644
--- a/src/proxy/http/remap/unit-tests/CMakeLists.txt
+++ b/src/proxy/http/remap/unit-tests/CMakeLists.txt
@@ -17,45 +17,65 @@
 
 ### The shared libraries built here are only used by the plugin tests  ####################
 
+######
+### Note: there are some tricks applied here to make sure this build and links on all platforms.
+###       --allow-multiple-definition is needed as faces the "multiple definition" error in some
+###       platforms. This is **ONLY** used for this tests and some plugins.
+###
+### Note#2: We currently build on OSX but we do not run the remap plugin reload tests. This will
+###         fixed shortly.
+
 function(add_plugin_ut_lib name)
   add_library(${name} MODULE ${ARGN})
-  set_target_properties(${name} PROPERTIES PREFIX "")
-  set_target_properties(${name} PROPERTIES SUFFIX ".so")
+  set_target_properties(${name} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/.libs" PREFIX "")
+  set_target_properties(${name} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/.libs" SUFFIX ".so")
+  target_link_libraries(${name} PRIVATE ts::tsapi ts::tsutil ts::tscore)
   target_include_directories(
     ${name} PRIVATE "$<TARGET_PROPERTY:libswoc::libswoc,INCLUDE_DIRECTORIES>"
                     "$<TARGET_PROPERTY:libswoc::libswoc,INTERFACE_INCLUDE_DIRECTORIES>"
   )
+  if(APPLE)
+    target_link_options(${name} PRIVATE -undefined dynamic_lookup)
+  endif()
+  remove_definitions(-DATS_BUILD) # remove the ATS_BUILD define for plugins to build without issue
 endfunction()
 
+add_compile_definitions(SRC_BUILD_DIR="${CMAKE_BINARY_DIR}")
+
 # Test plugins will not build on OSX
 #
-# add_plugin_ut_lib(plugin_v1 plugin_misc_cb.cc)
-# target_compile_definitions(plugin_v1 PRIVATE PLUGINDSOVER=1)
-#
-# add_plugin_ut_lib(plugin_v2 plugin_misc_cb.cc)
-# target_compile_definitions(plugin_v2 PRIVATE PLUGINDSOVER=2)
-#
-# add_plugin_ut_lib(plugin_init_fail plugin_init_fail.cc)
+add_plugin_ut_lib(plugin_v1 plugin_misc_cb.cc plugin_stub.cc)
+target_compile_definitions(plugin_v1 PRIVATE PLUGINDSOVER=1)
 #
-# add_plugin_ut_lib(plugin_instinit_fail plugin_instinit_fail.cc)
+add_plugin_ut_lib(plugin_v2 plugin_misc_cb.cc plugin_stub.cc)
+target_compile_definitions(plugin_v2 PRIVATE PLUGINDSOVER=2)
 #
-# add_plugin_ut_lib(plugin_required_cb plugin_required_cb.cc)
-# target_compile_definitions(plugin_required_cb PRIVATE PLUGINDSOVER=1)
+add_plugin_ut_lib(plugin_init_fail plugin_init_fail.cc plugin_stub.cc)
 #
-# add_plugin_ut_lib(plugin_missing_deleteinstance plugin_missing_deleteinstance.cc)
-# target_compile_definitions(plugin_missing_deleteinstance PRIVATE PLUGINDSOVER=1)
+add_plugin_ut_lib(plugin_instinit_fail plugin_instinit_fail.cc plugin_stub.cc)
 #
-# add_plugin_ut_lib(plugin_missing_doremap plugin_missing_doremap.cc)
-# target_compile_definitions(plugin_missing_doremap PRIVATE PLUGINDSOVER=1)
-#
-# add_plugin_ut_lib(plugin_missing_init plugin_missing_init.cc)
-# target_compile_definitions(plugin_missing_init PRIVATE PLUGINDSOVER=1)
-#
-# add_plugin_ut_lib(plugin_missing_newinstance plugin_missing_newinstance.cc)
-# target_compile_definitions(plugin_missing_newinstance PRIVATE PLUGINDSOVER=1)
-#
-# add_plugin_ut_lib(plugin_testing_calls plugin_testing_calls.cc plugin_testing_common.cc)
-# target_compile_definitions(plugin_testing_calls PRIVATE PLUGINDSOVER=1)
+add_plugin_ut_lib(plugin_required_cb plugin_required_cb.cc plugin_stub.cc)
+target_compile_definitions(plugin_required_cb PRIVATE PLUGINDSOVER=1)
+
+add_plugin_ut_lib(plugin_missing_deleteinstance plugin_missing_deleteinstance.cc plugin_stub.cc)
+target_compile_definitions(plugin_missing_deleteinstance PRIVATE PLUGINDSOVER=1)
+
+add_plugin_ut_lib(plugin_missing_doremap plugin_missing_doremap.cc plugin_stub.cc)
+target_compile_definitions(plugin_missing_doremap PRIVATE PLUGINDSOVER=1)
+
+add_plugin_ut_lib(plugin_missing_init plugin_missing_init.cc plugin_stub.cc)
+target_compile_definitions(plugin_missing_init PRIVATE PLUGINDSOVER=1)
+
+add_plugin_ut_lib(plugin_missing_newinstance plugin_missing_newinstance.cc plugin_stub.cc)
+target_compile_definitions(plugin_missing_newinstance PRIVATE PLUGINDSOVER=1)
+
+add_plugin_ut_lib(plugin_testing_calls plugin_testing_calls.cc plugin_testing_common.cc plugin_stub.cc)
+
+if(NOT APPLE)
+  target_link_options(plugin_testing_calls PRIVATE -Wl,--allow-multiple-definition)
+endif()
+
+target_compile_definitions(plugin_testing_calls PRIVATE PLUGINDSOVER=1)
 
 ### test_PluginDso ########################################################################
 
@@ -65,40 +85,101 @@ target_compile_definitions(test_PluginDso PRIVATE PLUGIN_DSO_TESTS)
 
 target_include_directories(test_PluginDso PRIVATE ${PROJECT_SOURCE_DIR}/tests/include)
 
-target_link_libraries(test_PluginDso PRIVATE catch2::catch2 ts::inkutils tscore libswoc::libswoc)
+target_link_libraries(
+  test_PluginDso PRIVATE catch2::catch2 ts::tsapi ts::configmanager ts::inkevent ts::proxy libswoc::libswoc
+)
 
-# This test currently does not pass.
-# add_test(NAME test_PluginDso COMMAND $<TARGET_FILE:test_PluginDso>)
+if(NOT APPLE)
+  target_link_options(test_PluginDso PRIVATE -Wl,--allow-multiple-definition)
+endif()
 
+if(NOT APPLE)
+  add_test(NAME test_PluginDso COMMAND $<TARGET_FILE:test_PluginDso>)
+endif()
 ### test_PluginFactory ########################################################################
 
 add_executable(
-  test_PluginFactory test_PluginFactory.cc plugin_testing_common.cc ../PluginFactory.cc ../PluginDso.cc
-                     ../RemapPluginInfo.cc
+  test_PluginFactory
+  test_PluginFactory.cc
+  plugin_testing_common.cc
+  ../PluginFactory.cc
+  ../PluginDso.cc
+  ../RemapPluginInfo.cc
+  ${PROJECT_SOURCE_DIR}/src/iocore/net/libinknet_stub.cc
+  ${PROJECT_SOURCE_DIR}/src/api/APIHooks.cc
 )
 
 target_compile_definitions(test_PluginFactory PRIVATE PLUGIN_DSO_TESTS)
 
-target_include_directories(test_PluginFactory PRIVATE ${PROJECT_SOURCE_DIR}/tests/include)
+if(NOT APPLE)
+  target_link_options(test_PluginFactory PRIVATE -Wl,--allow-multiple-definition)
+endif()
 
-target_link_libraries(test_PluginFactory PRIVATE catch2::catch2 ts::inkutils tscore libswoc::libswoc)
+target_include_directories(test_PluginFactory PRIVATE ${PROJECT_SOURCE_DIR}/tests/include)
 
-# This test currently does not pass.
-# add_test(NAME test_PluginFactory COMMAND $<TARGET_FILE:test_PluginFactory>)
+target_link_libraries(
+  test_PluginFactory
+  PRIVATE catch2::catch2
+          tscore
+          ts::tsapi
+          ts::configmanager
+          ts::hdrs
+          ts::proxy
+          ts::inkdns
+          ts::inkutils
+          ts::inknet
+          ts::inkevent
+          libswoc::libswoc
+)
 
+if(NOT APPLE)
+  add_test(NAME test_PluginFactory COMMAND $<TARGET_FILE:test_PluginFactory>)
+endif()
 ### test_RemapPluginInfo ########################################################################
 
-add_executable(test_RemapPluginInfo test_RemapPlugin.cc plugin_testing_common.cc ../PluginDso.cc ../RemapPluginInfo.cc)
+add_executable(
+  test_RemapPluginInfo test_RemapPlugin.cc plugin_testing_common.cc ../PluginDso.cc ../RemapPluginInfo.cc
+                       ${PROJECT_SOURCE_DIR}/src/iocore/net/libinknet_stub.cc ${PROJECT_SOURCE_DIR}/src/api/APIHooks.cc
+)
 
 target_compile_definitions(test_RemapPluginInfo PRIVATE PLUGIN_DSO_TESTS)
 
-target_include_directories(test_RemapPluginInfo PRIVATE ${PROJECT_SOURCE_DIR}/tests/include)
+if(NOT APPLE)
+  target_link_options(test_RemapPluginInfo PRIVATE -Wl,--allow-multiple-definition)
+endif()
 
-target_link_libraries(test_RemapPluginInfo PRIVATE catch2::catch2 ts::inkutils tscore libswoc::libswoc)
+target_include_directories(test_RemapPluginInfo PRIVATE ${PROJECT_SOURCE_DIR}/tests/include)
 
-# This test currently does not pass.
-# add_test(NAME test_RemapPluginInfo COMMAND $<TARGET_FILE:test_RemapPluginInfo>)
+target_link_libraries(
+  test_RemapPluginInfo
+  PRIVATE catch2::catch2
+          tscore
+          ts::tsapi
+          ts::configmanager
+          ts::hdrs
+          ts::proxy
+          ts::inkdns
+          ts::inkutils
+          ts::inknet
+          ts::inkevent
+          libswoc::libswoc
+)
 
+if(NOT APPLE)
+  add_test(NAME test_RemapPluginInfo COMMAND $<TARGET_FILE:test_RemapPluginInfo>)
+endif()
+
+# not in the same if as the above will be removed shortly.
+if(NOT APPLE)
+  # Disable ORD violation caused by double definition inside a stub file libinknet_stub.cc
+  # see remap_test_dlopen_leak_suppression.txt for more info.
+  set_tests_properties(
+    test_RemapPluginInfo test_PluginDso test_PluginFactory
+    PROPERTIES
+      ENVIRONMENT
+      "ASAN_OPTIONS=detect_odr_violation=0;LSAN_OPTIONS=suppressions=${CMAKE_CURRENT_SOURCE_DIR}/remap_test_dlopen_leak_suppression.txt"
+  )
+endif()
 ### test_NextHopStrategyFactory ########################################################################
 
 add_executable(
@@ -144,7 +225,14 @@ target_compile_definitions(test_NextHopRoundRobin PRIVATE _NH_UNIT_TESTS_ TS_SRC
 target_include_directories(test_NextHopRoundRobin PRIVATE ${PROJECT_SOURCE_DIR}/tests/include)
 
 target_link_libraries(
-  test_NextHopRoundRobin PRIVATE catch2::catch2 ts::hdrs ts::inkutils tscore libswoc::libswoc yaml-cpp::yaml-cpp
+  test_NextHopRoundRobin
+  PRIVATE catch2::catch2
+          ts::hdrs
+          ts::inkevent
+          ts::inkutils
+          tscore
+          libswoc::libswoc
+          yaml-cpp::yaml-cpp
 )
 
 add_test(NAME test_NextHopRoundRobin COMMAND $<TARGET_FILE:test_NextHopRoundRobin>)
@@ -170,7 +258,14 @@ target_compile_definitions(
 target_include_directories(test_NextHopConsistentHash PRIVATE ${PROJECT_SOURCE_DIR}/tests/include)
 
 target_link_libraries(
-  test_NextHopConsistentHash PRIVATE catch2::catch2 tscore ts::hdrs ts::inkutils libswoc::libswoc yaml-cpp::yaml-cpp
+  test_NextHopConsistentHash
+  PRIVATE catch2::catch2
+          tscore
+          ts::inkevent
+          ts::hdrs
+          ts::inkutils
+          libswoc::libswoc
+          yaml-cpp::yaml-cpp
 )
 
 add_test(NAME test_NextHopConsistentHash COMMAND $<TARGET_FILE:test_NextHopConsistentHash>)
diff --git a/src/proxy/http/remap/unit-tests/plugin_init_fail.cc b/src/proxy/http/remap/unit-tests/plugin_init_fail.cc
index 724e1153e0..b085d4d1d9 100644
--- a/src/proxy/http/remap/unit-tests/plugin_init_fail.cc
+++ b/src/proxy/http/remap/unit-tests/plugin_init_fail.cc
@@ -33,7 +33,7 @@
 #include "ts/remap.h"
 
 TSReturnCode
-TSRemapInit(TSRemapInterface *api_info, char *errbuf, int errbuf_size)
+TSRemapInit([[maybe_unused]] TSRemapInterface *api_info, [[maybe_unused]] char *errbuf, [[maybe_unused]] int errbuf_size)
 {
   return TS_ERROR;
 }
@@ -44,7 +44,7 @@ TSRemapDone(void)
 }
 
 TSRemapStatus
-TSRemapDoRemap(void *ih, TSHttpTxn rh, TSRemapRequestInfo *rri)
+TSRemapDoRemap([[maybe_unused]] void *ih, [[maybe_unused]] TSHttpTxn rh, [[maybe_unused]] TSRemapRequestInfo *rri)
 {
   return TSREMAP_NO_REMAP;
 }
diff --git a/src/proxy/http/remap/unit-tests/plugin_instinit_fail.cc b/src/proxy/http/remap/unit-tests/plugin_instinit_fail.cc
index c2207bcff4..fff93f20cc 100644
--- a/src/proxy/http/remap/unit-tests/plugin_instinit_fail.cc
+++ b/src/proxy/http/remap/unit-tests/plugin_instinit_fail.cc
@@ -33,7 +33,7 @@
 #include "ts/remap.h"
 
 TSReturnCode
-TSRemapInit(TSRemapInterface *api_info, char *errbuf, int errbuf_size)
+TSRemapInit([[maybe_unused]] TSRemapInterface *api_info, [[maybe_unused]] char *errbuf, [[maybe_unused]] int errbuf_size)
 {
   return TS_SUCCESS;
 }
@@ -44,7 +44,8 @@ TSRemapDone(void)
 }
 
 TSReturnCode
-TSRemapNewInstance(int argc, char *argv[], void **ih, char *errbuf, int errbuf_size)
+TSRemapNewInstance([[maybe_unused]] int argc, [[maybe_unused]] char *argv[], [[maybe_unused]] void **ih,
+                   [[maybe_unused]] char *errbuf, [[maybe_unused]] int errbuf_size)
 {
   return TS_ERROR;
 }
@@ -55,7 +56,7 @@ TSRemapDeleteInstance(void *)
 }
 
 TSRemapStatus
-TSRemapDoRemap(void *ih, TSHttpTxn rh, TSRemapRequestInfo *rri)
+TSRemapDoRemap([[maybe_unused]] void *ih, [[maybe_unused]] TSHttpTxn rh, [[maybe_unused]] TSRemapRequestInfo *rri)
 {
   return TSREMAP_NO_REMAP;
 }
diff --git a/src/proxy/http/remap/unit-tests/plugin_misc_cb.cc b/src/proxy/http/remap/unit-tests/plugin_misc_cb.cc
index 91f7c15289..e6bc943094 100644
--- a/src/proxy/http/remap/unit-tests/plugin_misc_cb.cc
+++ b/src/proxy/http/remap/unit-tests/plugin_misc_cb.cc
@@ -35,7 +35,7 @@
 PluginDebugObject debugObject;
 
 TSReturnCode
-TSRemapInit(TSRemapInterface *api_info, char *errbuf, int errbuf_size)
+TSRemapInit([[maybe_unused]] TSRemapInterface *api_info, [[maybe_unused]] char *errbuf, [[maybe_unused]] int errbuf_size)
 {
   debugObject.contextInit = pluginThreadContext;
   return TS_SUCCESS;
@@ -47,13 +47,14 @@ TSRemapDone(void)
 }
 
 TSRemapStatus
-TSRemapDoRemap(void *ih, TSHttpTxn rh, TSRemapRequestInfo *rri)
+TSRemapDoRemap([[maybe_unused]] void *ih, [[maybe_unused]] TSHttpTxn rh, [[maybe_unused]] TSRemapRequestInfo *rri)
 {
   return TSREMAP_NO_REMAP;
 }
 
 TSReturnCode
-TSRemapNewInstance(int argc, char *argv[], void **ih, char *errbuf, int errbuf_size)
+TSRemapNewInstance([[maybe_unused]] int argc, [[maybe_unused]] char *argv[], [[maybe_unused]] void **ih,
+                   [[maybe_unused]] char *errbuf, [[maybe_unused]] int errbuf_size)
 {
   debugObject.contextInitInstance = pluginThreadContext;
 
@@ -66,12 +67,12 @@ TSRemapDeleteInstance(void *)
 }
 
 void
-TSRemapOSResponse(void *ih, TSHttpTxn rh, int os_response_type)
+TSRemapOSResponse([[maybe_unused]] void *ih, [[maybe_unused]] TSHttpTxn rh, [[maybe_unused]] int os_response_type)
 {
 }
 
 void
-TSPluginInit(int argc, const char *argv[])
+TSPluginInit([[maybe_unused]] int argc, [[maybe_unused]] const char *argv[])
 {
 }
 
diff --git a/src/proxy/http/remap/unit-tests/plugin_missing_deleteinstance.cc b/src/proxy/http/remap/unit-tests/plugin_missing_deleteinstance.cc
index d569c8abe5..44c5fec748 100644
--- a/src/proxy/http/remap/unit-tests/plugin_missing_deleteinstance.cc
+++ b/src/proxy/http/remap/unit-tests/plugin_missing_deleteinstance.cc
@@ -31,19 +31,20 @@
 #include "ts/remap.h"
 
 TSReturnCode
-TSRemapInit(TSRemapInterface *api_info, char *errbuf, int errbuf_size)
+TSRemapInit([[maybe_unused]] TSRemapInterface *api_info, [[maybe_unused]] char *errbuf, [[maybe_unused]] int errbuf_size)
 {
   return TS_SUCCESS;
 }
 
 TSRemapStatus
-TSRemapDoRemap(void *ih, TSHttpTxn rh, TSRemapRequestInfo *rri)
+TSRemapDoRemap([[maybe_unused]] void *ih, [[maybe_unused]] TSHttpTxn rh, [[maybe_unused]] TSRemapRequestInfo *rri)
 {
   return TSREMAP_NO_REMAP;
 }
 
 TSReturnCode
-TSRemapNewInstance(int argc, char *argv[], void **ih, char *errbuf, int errbuf_size)
+TSRemapNewInstance([[maybe_unused]] int argc, [[maybe_unused]] char *argv[], [[maybe_unused]] void **ih,
+                   [[maybe_unused]] char *errbuf, [[maybe_unused]] int errbuf_size)
 {
   return TS_SUCCESS;
 }
diff --git a/src/proxy/http/remap/unit-tests/plugin_missing_doremap.cc b/src/proxy/http/remap/unit-tests/plugin_missing_doremap.cc
index 2664d06dec..95640610c0 100644
--- a/src/proxy/http/remap/unit-tests/plugin_missing_doremap.cc
+++ b/src/proxy/http/remap/unit-tests/plugin_missing_doremap.cc
@@ -31,7 +31,7 @@
 #include "ts/remap.h"
 
 TSReturnCode
-TSRemapInit(TSRemapInterface *api_info, char *errbuf, int errbuf_size)
+TSRemapInit([[maybe_unused]] TSRemapInterface *api_info, [[maybe_unused]] char *errbuf, [[maybe_unused]] int errbuf_size)
 {
   return TS_SUCCESS;
 }
diff --git a/src/proxy/http/remap/unit-tests/plugin_missing_init.cc b/src/proxy/http/remap/unit-tests/plugin_missing_init.cc
index f14d726c58..f657b30d21 100644
--- a/src/proxy/http/remap/unit-tests/plugin_missing_init.cc
+++ b/src/proxy/http/remap/unit-tests/plugin_missing_init.cc
@@ -31,7 +31,7 @@
 #include "ts/remap.h"
 
 TSRemapStatus
-TSRemapDoRemap(void *ih, TSHttpTxn rh, TSRemapRequestInfo *rri)
+TSRemapDoRemap([[maybe_unused]] void *ih, [[maybe_unused]] TSHttpTxn rh, [[maybe_unused]] TSRemapRequestInfo *rri)
 {
   return TSREMAP_NO_REMAP;
 }
diff --git a/src/proxy/http/remap/unit-tests/plugin_missing_newinstance.cc b/src/proxy/http/remap/unit-tests/plugin_missing_newinstance.cc
index 67262b0729..1d20c151a7 100644
--- a/src/proxy/http/remap/unit-tests/plugin_missing_newinstance.cc
+++ b/src/proxy/http/remap/unit-tests/plugin_missing_newinstance.cc
@@ -31,13 +31,13 @@
 #include "ts/remap.h"
 
 TSReturnCode
-TSRemapInit(TSRemapInterface *api_info, char *errbuf, int errbuf_size)
+TSRemapInit([[maybe_unused]] TSRemapInterface *api_info, [[maybe_unused]] char *errbuf, [[maybe_unused]] int errbuf_size)
 {
   return TS_SUCCESS;
 }
 
 TSRemapStatus
-TSRemapDoRemap(void *ih, TSHttpTxn rh, TSRemapRequestInfo *rri)
+TSRemapDoRemap([[maybe_unused]] void *ih, [[maybe_unused]] TSHttpTxn rh, [[maybe_unused]] TSRemapRequestInfo *rri)
 {
   return TSREMAP_NO_REMAP;
 }
diff --git a/src/proxy/http/remap/unit-tests/plugin_required_cb.cc b/src/proxy/http/remap/unit-tests/plugin_required_cb.cc
index e4741ffdd8..7e28281e07 100644
--- a/src/proxy/http/remap/unit-tests/plugin_required_cb.cc
+++ b/src/proxy/http/remap/unit-tests/plugin_required_cb.cc
@@ -31,13 +31,13 @@
 #include "ts/remap.h"
 
 TSReturnCode
-TSRemapInit(TSRemapInterface *api_info, char *errbuf, int errbuf_size)
+TSRemapInit([[maybe_unused]] TSRemapInterface *api_info, [[maybe_unused]] char *errbuf, [[maybe_unused]] int errbuf_size)
 {
   return TS_SUCCESS;
 }
 
 TSRemapStatus
-TSRemapDoRemap(void *ih, TSHttpTxn rh, TSRemapRequestInfo *rri)
+TSRemapDoRemap([[maybe_unused]] void *ih, [[maybe_unused]] TSHttpTxn rh, [[maybe_unused]] TSRemapRequestInfo *rri)
 {
   return TSREMAP_NO_REMAP;
 }
diff --git a/src/proxy/http/remap/unit-tests/plugin_missing_init.cc b/src/proxy/http/remap/unit-tests/plugin_stub.cc
similarity index 69%
copy from src/proxy/http/remap/unit-tests/plugin_missing_init.cc
copy to src/proxy/http/remap/unit-tests/plugin_stub.cc
index f14d726c58..c998d666a3 100644
--- a/src/proxy/http/remap/unit-tests/plugin_missing_init.cc
+++ b/src/proxy/http/remap/unit-tests/plugin_stub.cc
@@ -1,6 +1,6 @@
 /** @file
 
-  A test plugin for testing Plugin's Dynamic Shared Objects (DSO)
+  Stub file for unit tests
 
   @section license License
 
@@ -19,19 +19,10 @@
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
-
-  @section details Details
-
-  Implements code necessary for Reverse Proxy which mostly consists of
-  general purpose hostname substitution in URLs.
-
  */
 
-#include "ts/ts.h"
-#include "ts/remap.h"
+#include "iocore/eventsystem/Lock.h"
+#include "proxy/http/remap/PluginFactory.h"
 
-TSRemapStatus
-TSRemapDoRemap(void *ih, TSHttpTxn rh, TSRemapRequestInfo *rri)
-{
-  return TSREMAP_NO_REMAP;
-}
+thread_local PluginThreadContext *pluginThreadContext;
+ClassAllocator<ProxyMutex>        mutexAllocator("mutexAllocator");
diff --git a/src/proxy/http/remap/unit-tests/plugin_testing_calls.cc b/src/proxy/http/remap/unit-tests/plugin_testing_calls.cc
index b53296cb4e..db3a6f0d00 100644
--- a/src/proxy/http/remap/unit-tests/plugin_testing_calls.cc
+++ b/src/proxy/http/remap/unit-tests/plugin_testing_calls.cc
@@ -52,7 +52,7 @@ handleInitRun(char *errbuf, int errbuf_size, int &counter)
 }
 
 TSReturnCode
-TSRemapInit(TSRemapInterface *api_info, char *errbuf, int errbuf_size)
+TSRemapInit([[maybe_unused]] TSRemapInterface *api_info, char *errbuf, int errbuf_size)
 {
   TSReturnCode result = handleInitRun(errbuf, errbuf_size, debugObject.initCalled);
   return result;
@@ -87,14 +87,14 @@ TSRemapDeleteInstance(void *ih)
 }
 
 TSRemapStatus
-TSRemapDoRemap(void *ih, TSHttpTxn rh, TSRemapRequestInfo *rri)
+TSRemapDoRemap([[maybe_unused]] void *ih, [[maybe_unused]] TSHttpTxn rh, [[maybe_unused]] TSRemapRequestInfo *rri)
 {
   debugObject.doRemapCalled++;
   return TSREMAP_NO_REMAP;
 }
 
 void
-TSRemapOSResponse(void *ih, TSHttpTxn rh, int os_response_type)
+TSRemapOSResponse([[maybe_unused]] void *ih, [[maybe_unused]] TSHttpTxn rh, [[maybe_unused]] int os_response_type)
 {
 }
 
diff --git a/src/proxy/http/remap/unit-tests/plugin_testing_common.cc b/src/proxy/http/remap/unit-tests/plugin_testing_common.cc
index bf82e92cac..dc9f92a55c 100644
--- a/src/proxy/http/remap/unit-tests/plugin_testing_common.cc
+++ b/src/proxy/http/remap/unit-tests/plugin_testing_common.cc
@@ -50,24 +50,3 @@ getTemporaryDir()
 
   return fs::path(mkdtemp(dirNameTemplate));
 }
-
-// implement functions to support unit-testing of option to enable/disable dynamic reload of plugins
-static PluginDynamicReloadMode plugin_dynamic_reload_mode = PluginDynamicReloadMode::RELOAD_ON;
-
-bool
-isPluginDynamicReloadEnabled()
-{
-  return PluginDynamicReloadMode::RELOAD_ON == plugin_dynamic_reload_mode;
-}
-
-void
-enablePluginDynamicReload()
-{
-  plugin_dynamic_reload_mode = PluginDynamicReloadMode::RELOAD_ON;
-}
-
-void
-disablePluginDynamicReload()
-{
-  plugin_dynamic_reload_mode = PluginDynamicReloadMode::RELOAD_OFF;
-}
diff --git a/src/proxy/http/remap/unit-tests/plugin_testing_common.h b/src/proxy/http/remap/unit-tests/plugin_testing_common.h
index 5bd94b5f22..fe01a4bcdf 100644
--- a/src/proxy/http/remap/unit-tests/plugin_testing_common.h
+++ b/src/proxy/http/remap/unit-tests/plugin_testing_common.h
@@ -38,8 +38,6 @@
 
 #include "proxy/http/remap/PluginFactory.h"
 
-extern thread_local PluginThreadContext *pluginThreadContext;
-
 /* A temp sandbox to play with our toys used for all fun with this test-bench */
 fs::path getTemporaryDir();
 
diff --git a/src/proxy/http/remap/unit-tests/remap_test_dlopen_leak_suppression.txt b/src/proxy/http/remap/unit-tests/remap_test_dlopen_leak_suppression.txt
new file mode 100644
index 0000000000..962310f89f
--- /dev/null
+++ b/src/proxy/http/remap/unit-tests/remap_test_dlopen_leak_suppression.txt
@@ -0,0 +1,26 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+
+#     http://www.apache.org/licenses/LICENSE-2.0
+
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# From the unit tests it seems PluginDso::load results in ASan reporting a leak
+# from the function that actually calls dlopen, every handle that's created by
+# this functions also calls dlclose, which was tested by checking if there was
+# any outstanding handler open after we close them.
+# This was also tested by counting how many times a dlopen was called compared
+# against dlclose, both matched, so the last resource assume dlopen is doing
+# something nasty or ASAN is detecting a false-positive.
+# PluginDso::load
+leak:PluginDso::load
+leak:call_init
\ No newline at end of file
diff --git a/src/proxy/http/remap/unit-tests/test_PluginDso.cc b/src/proxy/http/remap/unit-tests/test_PluginDso.cc
index 3f6a119c74..72eb31f33e 100644
--- a/src/proxy/http/remap/unit-tests/test_PluginDso.cc
+++ b/src/proxy/http/remap/unit-tests/test_PluginDso.cc
@@ -35,7 +35,6 @@
 #include "proxy/http/remap/PluginDso.h"
 
 class PluginContext;
-thread_local PluginThreadContext *pluginThreadContext;
 
 std::error_code ec;
 
@@ -43,13 +42,16 @@ std::error_code ec;
 static fs::path sandboxDir     = getTemporaryDir();
 static fs::path runtimeDir     = sandboxDir / fs::path("runtime");
 static fs::path searchDir      = sandboxDir / fs::path("search");
-static fs::path pluginBuildDir = fs::current_path();
+static fs::path pluginBuildDir = fs::path{SRC_BUILD_DIR} / "src/proxy/http/remap/unit-tests/.libs";
 
 /* The following are paths used in all scenarios in the unit tests */
-static fs::path configPath      = fs::path("plugin_v1.so");
-static fs::path pluginBuildPath = pluginBuildDir / configPath;
-static fs::path effectivePath   = searchDir / configPath;
-static fs::path runtimePath     = runtimeDir / configPath;
+static fs::path configPath             = fs::path("plugin_v1.so");
+static fs::path invalidSoPath          = fs::path("invalid.so");
+static fs::path pluginBuildPath        = pluginBuildDir / configPath;
+static fs::path effectivePath          = searchDir / configPath;
+static fs::path effectivePathInvalidSo = searchDir / invalidSoPath;
+static fs::path runtimePathInvalid     = runtimeDir / invalidSoPath;
+static fs::path runtimePath            = runtimeDir / configPath;
 
 void
 clean()
@@ -289,14 +291,14 @@ SCENARIO("loading plugins", "[plugin][core]")
     CHECK(fs::create_directories(searchDir, ec));
     CHECK(fs::create_directories(runtimeDir, ec));
     /* Create an invalid plugin and make sure the effective path to it exists */
-    std::ofstream file(effectivePath.string());
+    std::ofstream file(effectivePathInvalidSo.string());
     file << "Invalid plugin DSO content";
     file.close();
-    CHECK(fs::exists(effectivePath));
+    CHECK(fs::exists(effectivePathInvalidSo));
 
     /* Instantiate and initialize a plugin DSO instance. */
     std::string       error;
-    PluginDsoUnitTest plugin(configPath, effectivePath, runtimePath);
+    PluginDsoUnitTest plugin(invalidSoPath, effectivePathInvalidSo, runtimePathInvalid);
 
     WHEN("loading an invalid plugin")
     {
@@ -305,15 +307,15 @@ SCENARIO("loading plugins", "[plugin][core]")
       THEN("expect it to fail to load")
       {
         /* After calling load() the following should be set correctly */
-        CHECK(effectivePath == plugin.effectivePath());
-        CHECK(runtimePath == plugin.runtimePath());
+        CHECK(effectivePathInvalidSo == plugin.effectivePath());
+        CHECK(runtimePathInvalid == plugin.runtimePath());
 
         /* But the load should fail and an error should be returned */
         CHECK(false == result);
         CHECK_FALSE(error.empty());
 
         /* Runtime DSO should not exist since the load failed. */
-        CHECK_FALSE(fs::exists(runtimePath));
+        CHECK_FALSE(fs::exists(runtimePathInvalid));
       }
       CHECK(fs::remove_all(sandboxDir, ec) > 0);
     }
diff --git a/src/proxy/http/remap/unit-tests/test_PluginFactory.cc b/src/proxy/http/remap/unit-tests/test_PluginFactory.cc
index b2cf2bbed3..9053d9668f 100644
--- a/src/proxy/http/remap/unit-tests/test_PluginFactory.cc
+++ b/src/proxy/http/remap/unit-tests/test_PluginFactory.cc
@@ -60,8 +60,6 @@ struct EventProcessorListener : Catch::TestEventListenerBase {
 
 CATCH_REGISTER_LISTENER(EventProcessorListener);
 
-thread_local PluginThreadContext *pluginThreadContext;
-
 std::error_code ec;
 static void    *INSTANCE_HANDLER = (void *)789;
 
@@ -106,7 +104,7 @@ static fs::path sandboxDir     = getTemporaryDir();
 static fs::path runtimeRootDir = sandboxDir / "runtime";
 static fs::path runtimeDir     = runtimeRootDir / tempComponent;
 static fs::path searchDir      = sandboxDir / "search";
-static fs::path pluginBuildDir = fs::current_path();
+static fs::path pluginBuildDir = fs::path{SRC_BUILD_DIR} / "src/proxy/http/remap/unit-tests/.libs";
 
 void
 clean()
@@ -208,7 +206,7 @@ setupConfigPathTest(const fs::path &configPath, const fs::path &pluginBuildPath,
   if (0 != mtime) {
     struct stat    sb;
     struct utimbuf new_times;
-    stat(effectivePath.c_str(), &sb);
+    CHECK(stat(effectivePath.c_str(), &sb) == 0);
     new_times.actime  = sb.st_atime; /* keep atime unchanged */
     new_times.modtime = mtime;       /* set mtime to current time */
     utime(effectivePath.c_str(), &new_times);
@@ -472,7 +470,7 @@ SCENARIO("multiple search dirs + multiple or no plugins installed", "[plugin][co
     fs::path              runtimePath1    = runtimeDir / effectivePath1.relative_path();
     fs::path              runtimePath2    = runtimeDir / effectivePath2.relative_path();
     fs::path              runtimePath3    = runtimeDir / effectivePath3.relative_path();
-    fs::path              pluginBuildPath = fs::current_path() / pluginName;
+    fs::path              pluginBuildPath = fs::path{SRC_BUILD_DIR} / "src/proxy/http/remap/unit-tests/.libs" / pluginName;
 
     std::string error;
 
diff --git a/src/proxy/http/remap/unit-tests/test_RemapPlugin.cc b/src/proxy/http/remap/unit-tests/test_RemapPlugin.cc
index 8cf0831e03..b32266d2e1 100644
--- a/src/proxy/http/remap/unit-tests/test_RemapPlugin.cc
+++ b/src/proxy/http/remap/unit-tests/test_RemapPlugin.cc
@@ -35,8 +35,6 @@
 #include "plugin_testing_common.h"
 #include "proxy/http/remap/RemapPluginInfo.h"
 
-thread_local PluginThreadContext *pluginThreadContext;
-
 static void    *INSTANCE_HANDLER = (void *)789;
 std::error_code ec;
 
@@ -44,7 +42,7 @@ std::error_code ec;
 static fs::path sandboxDir     = getTemporaryDir();
 static fs::path runtimeDir     = sandboxDir / "runtime";
 static fs::path searchDir      = sandboxDir / "search";
-static fs::path pluginBuildDir = fs::current_path();
+static fs::path pluginBuildDir = fs::path{SRC_BUILD_DIR} / "src/proxy/http/remap/unit-tests/.libs";
 
 void
 clean()
@@ -56,6 +54,8 @@ clean()
 class RemapPluginUnitTest : public RemapPluginInfo
 {
 public:
+  using Ptr = std::unique_ptr<RemapPluginUnitTest>;
+
   RemapPluginUnitTest(const fs::path &configPath, const fs::path &effectivePath, const fs::path &runtimePath)
     : RemapPluginInfo(configPath, effectivePath, runtimePath)
   {
@@ -96,7 +96,6 @@ setupSandBox(const fs::path configPath)
   fs::path effectivePath   = searchDir / configPath;
   fs::path runtimePath     = runtimeDir / configPath;
   fs::path pluginBuildPath = pluginBuildDir / configPath;
-
   /* Instantiate and initialize a plugin DSO instance. */
   RemapPluginUnitTest *plugin = new RemapPluginUnitTest(configPath, effectivePath, runtimePath);
 
@@ -112,11 +111,8 @@ loadPlugin(RemapPluginUnitTest *plugin, std::string &error, PluginDebugObject *&
 }
 
 void
-cleanupSandBox(RemapPluginInfo *plugin)
+cleanupSandBox()
 {
-  if (plugin != nullptr) {
-    delete plugin;
-  }
   clean();
 }
 
@@ -129,91 +125,91 @@ SCENARIO("loading remap plugins", "[plugin][core]")
 
   GIVEN("a plugin which has only minimum required call back functions")
   {
-    fs::path             pluginConfigPath = fs::path("plugin_required_cb.so");
-    RemapPluginUnitTest *plugin           = setupSandBox(pluginConfigPath);
+    fs::path                 pluginConfigPath = fs::path("plugin_required_cb.so");
+    RemapPluginUnitTest::Ptr plugin{setupSandBox(pluginConfigPath)};
 
     WHEN("loading")
     {
-      bool result = loadPlugin(plugin, error, debugObject);
+      bool result = loadPlugin(plugin.get(), error, debugObject);
 
       THEN("expect it to successfully load")
       {
         CHECK(true == result);
         CHECK(error.empty());
       }
-      cleanupSandBox(plugin);
+      cleanupSandBox();
     }
   }
 
   GIVEN("a plugin which is missing the plugin TSREMAP_FUNCNAME_INIT function")
   {
-    fs::path             pluginConfigPath = fs::path("plugin_missing_init.so");
-    RemapPluginUnitTest *plugin           = setupSandBox(pluginConfigPath);
+    fs::path                 pluginConfigPath = fs::path("plugin_missing_init.so");
+    RemapPluginUnitTest::Ptr plugin{setupSandBox(pluginConfigPath)};
 
     WHEN("loading")
     {
-      bool result = loadPlugin(plugin, error, debugObject);
+      bool result = loadPlugin(plugin.get(), error, debugObject);
 
       THEN("expect it to successfully load")
       {
         CHECK_FALSE(result);
         CHECK(error == plugin->getError(TSREMAP_FUNCNAME_INIT));
       }
-      cleanupSandBox(plugin);
+      cleanupSandBox();
     }
   }
 
   GIVEN("a plugin which is missing the TSREMAP_FUNCNAME_DO_REMAP function")
   {
-    fs::path             pluginConfigPath = fs::path("plugin_missing_doremap.so");
-    RemapPluginUnitTest *plugin           = setupSandBox(pluginConfigPath);
+    fs::path                 pluginConfigPath = fs::path("plugin_missing_doremap.so");
+    RemapPluginUnitTest::Ptr plugin{setupSandBox(pluginConfigPath)};
 
     WHEN("loading")
     {
-      bool result = loadPlugin(plugin, error, debugObject);
+      bool result = loadPlugin(plugin.get(), error, debugObject);
 
       THEN("expect it to fail")
       {
         CHECK_FALSE(result);
         CHECK(error == plugin->getError(TSREMAP_FUNCNAME_DO_REMAP));
       }
-      cleanupSandBox(plugin);
+      cleanupSandBox();
     }
   }
 
   GIVEN("a plugin which has TSREMAP_FUNCNAME_NEW_INSTANCE but is missing the TSREMAP_FUNCNAME_DELETE_INSTANCE function")
   {
-    fs::path             pluginConfigPath = fs::path("plugin_missing_deleteinstance.so");
-    RemapPluginUnitTest *plugin           = setupSandBox(pluginConfigPath);
+    fs::path                 pluginConfigPath = fs::path("plugin_missing_deleteinstance.so");
+    RemapPluginUnitTest::Ptr plugin{setupSandBox(pluginConfigPath)};
 
     WHEN("loading")
     {
-      bool result = loadPlugin(plugin, error, debugObject);
+      bool result = loadPlugin(plugin.get(), error, debugObject);
 
       THEN("expect it to fail")
       {
         CHECK_FALSE(result);
         CHECK(error == plugin->getError(TSREMAP_FUNCNAME_DELETE_INSTANCE, TSREMAP_FUNCNAME_NEW_INSTANCE));
       }
-      cleanupSandBox(plugin);
+      cleanupSandBox();
     }
   }
 
   GIVEN("a plugin which has TSREMAP_FUNCNAME_DELETE_INSTANCE but is missing the TSREMAP_FUNCNAME_NEW_INSTANCE function")
   {
-    fs::path             pluginConfigPath = fs::path("plugin_missing_newinstance.so");
-    RemapPluginUnitTest *plugin           = setupSandBox(pluginConfigPath);
+    fs::path                 pluginConfigPath = fs::path("plugin_missing_newinstance.so");
+    RemapPluginUnitTest::Ptr plugin{setupSandBox(pluginConfigPath)};
 
     WHEN("loading")
     {
-      bool result = loadPlugin(plugin, error, debugObject);
+      bool result = loadPlugin(plugin.get(), error, debugObject);
 
       THEN("expect it to fail")
       {
         CHECK_FALSE(result);
         CHECK(error == plugin->getError(TSREMAP_FUNCNAME_NEW_INSTANCE, TSREMAP_FUNCNAME_DELETE_INSTANCE));
       }
-      cleanupSandBox(plugin);
+      cleanupSandBox();
     }
   }
 }
@@ -247,10 +243,10 @@ SCENARIO("invoking plugin init", "[plugin][core]")
 
   GIVEN("plugin init function")
   {
-    fs::path             pluginConfigPath = fs::path("plugin_testing_calls.so");
-    RemapPluginUnitTest *plugin           = setupSandBox(pluginConfigPath);
+    fs::path                 pluginConfigPath = fs::path("plugin_testing_calls.so");
+    RemapPluginUnitTest::Ptr plugin{setupSandBox(pluginConfigPath)};
 
-    bool result = loadPlugin(plugin, error, debugObject);
+    bool result = loadPlugin(plugin.get(), error, debugObject);
     CHECK(true == result);
 
     WHEN("init succeeds")
@@ -265,7 +261,7 @@ SCENARIO("invoking plugin init", "[plugin][core]")
 
         checkCallTest(/* shouldHaveFailed */ false, result, error, expectedError, debugObject->initCalled);
       }
-      cleanupSandBox(nullptr);
+      cleanupSandBox();
     }
 
     WHEN("init fails")
@@ -281,7 +277,7 @@ SCENARIO("invoking plugin init", "[plugin][core]")
 
         checkCallTest(/* shouldHaveFailed */ true, result, error, expectedError, debugObject->initCalled);
       }
-      cleanupSandBox(plugin);
+      cleanupSandBox();
     }
   }
 }
@@ -301,10 +297,10 @@ SCENARIO("invoking plugin instance init", "[plugin][core]")
 
   GIVEN("an instance init function")
   {
-    fs::path             pluginConfigPath = fs::path("plugin_testing_calls.so");
-    RemapPluginUnitTest *plugin           = setupSandBox(pluginConfigPath);
+    fs::path                 pluginConfigPath = fs::path("plugin_testing_calls.so");
+    RemapPluginUnitTest::Ptr plugin{setupSandBox(pluginConfigPath)};
 
-    bool result = loadPlugin(plugin, error, debugObject);
+    bool result = loadPlugin(plugin.get(), error, debugObject);
     CHECK(true == result);
 
     WHEN("instance init succeeds")
@@ -329,7 +325,7 @@ SCENARIO("invoking plugin instance init", "[plugin][core]")
           CHECK(0 == strcmp(ARGV[i], debugObject->argv[i]));
         }
       }
-      cleanupSandBox(nullptr);
+      cleanupSandBox();
     }
 
     WHEN("instance init fails")
@@ -354,7 +350,7 @@ SCENARIO("invoking plugin instance init", "[plugin][core]")
           CHECK(0 == strcmp(ARGV[i], debugObject->argv[i]));
         }
       }
-      cleanupSandBox(plugin);
+      cleanupSandBox();
     }
   }
 }
@@ -368,10 +364,10 @@ SCENARIO("unloading the plugin", "[plugin][core]")
 
   GIVEN("a 'done' function")
   {
-    fs::path             pluginConfigPath = fs::path("plugin_testing_calls.so");
-    RemapPluginUnitTest *plugin           = setupSandBox(pluginConfigPath);
+    fs::path                 pluginConfigPath = fs::path("plugin_testing_calls.so");
+    RemapPluginUnitTest::Ptr plugin{setupSandBox(pluginConfigPath)};
 
-    bool result = loadPlugin(plugin, error, debugObject);
+    bool result = loadPlugin(plugin.get(), error, debugObject);
     CHECK(true == result);
 
     WHEN("'done' is called")
@@ -384,16 +380,16 @@ SCENARIO("unloading the plugin", "[plugin][core]")
       {
         CHECK(1 == debugObject->doneCalled);
       }
-      cleanupSandBox(plugin);
+      cleanupSandBox();
     }
   }
 
   GIVEN("a 'delete_instance' function")
   {
-    fs::path             pluginConfigPath = fs::path("plugin_testing_calls.so");
-    RemapPluginUnitTest *plugin           = setupSandBox(pluginConfigPath);
+    fs::path                 pluginConfigPath = fs::path("plugin_testing_calls.so");
+    RemapPluginUnitTest::Ptr plugin{setupSandBox(pluginConfigPath)};
 
-    bool result = loadPlugin(plugin, error, debugObject);
+    bool result = loadPlugin(plugin.get(), error, debugObject);
     CHECK(true == result);
 
     WHEN("'delete_instance' is called")
@@ -407,7 +403,7 @@ SCENARIO("unloading the plugin", "[plugin][core]")
         CHECK(1 == debugObject->deleteInstanceCalled);
         CHECK(INSTANCE_HANDLER == debugObject->ih);
       }
-      cleanupSandBox(plugin);
+      cleanupSandBox();
     }
   }
 }
@@ -421,10 +417,10 @@ SCENARIO("config reload", "[plugin][core]")
 
   GIVEN("a 'config reload' callback function")
   {
-    fs::path             pluginConfigPath = fs::path("plugin_testing_calls.so");
-    RemapPluginUnitTest *plugin           = setupSandBox(pluginConfigPath);
+    fs::path                 pluginConfigPath = fs::path("plugin_testing_calls.so");
+    RemapPluginUnitTest::Ptr plugin{setupSandBox(pluginConfigPath)};
 
-    bool result = loadPlugin(plugin, error, debugObject);
+    bool result = loadPlugin(plugin.get(), error, debugObject);
     CHECK(true == result);
 
     WHEN("'config reload' failed")
@@ -440,7 +436,7 @@ SCENARIO("config reload", "[plugin][core]")
         CHECK(1 == debugObject->postReloadConfigCalled);
         CHECK(TSREMAP_CONFIG_RELOAD_FAILURE == debugObject->postReloadConfigStatus);
       }
-      cleanupSandBox(plugin);
+      cleanupSandBox();
     }
 
     WHEN("'config reload' is successful and the plugin is part of the new configuration")
@@ -456,7 +452,7 @@ SCENARIO("config reload", "[plugin][core]")
         CHECK(1 == debugObject->postReloadConfigCalled);
         CHECK(TSREMAP_CONFIG_RELOAD_SUCCESS_PLUGIN_USED == debugObject->postReloadConfigStatus);
       }
-      cleanupSandBox(plugin);
+      cleanupSandBox();
     }
 
     WHEN("'config reload' is successful and the plugin is part of the new configuration")
@@ -472,7 +468,7 @@ SCENARIO("config reload", "[plugin][core]")
         CHECK(1 == debugObject->postReloadConfigCalled);
         CHECK(TSREMAP_CONFIG_RELOAD_SUCCESS_PLUGIN_UNUSED == debugObject->postReloadConfigStatus);
       }
-      cleanupSandBox(plugin);
+      cleanupSandBox();
     }
   }
 }