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

dmeden pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new f2247cf4a7 Unit test: enable plugin dso logic to build and run unit 
tests. (#11367)
f2247cf4a7 is described below

commit f2247cf4a7cc46d9f93e9e397a0eb5b560c081ef
Author: Damian Meden <[email protected]>
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.
---
 CMakeLists.txt                                     |   1 +
 include/proxy/Plugin.h                             |   3 +
 src/proxy/Plugin.cc                                |  12 ++
 src/proxy/http/remap/PluginDso.cc                  |  10 +-
 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, 278 insertions(+), 174 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 733af8b6f3..a9d4549e77 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -61,6 +61,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 def6fff9c4..f7b548df6d 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;
@@ -282,15 +282,15 @@ PluginDso::clean(std::string &error)
 void
 PluginDso::acquire()
 {
-  ++this->_instanceCount;
-  PluginDbg(_dbg_ctl(), "plugin DSO acquire (ref-count:%d, dso-addr:%p)", 
this->_instanceCount.load(), this);
+  this->refcount_inc();
+  PluginDbg(_dbg_ctl(), "plugin DSO acquire (ref-count:%d, dso-addr:%p)", 
this->refcount(), this);
 }
 
 void
 PluginDso::release()
 {
-  PluginDbg(_dbg_ctl(), "plugin DSO release (ref-count:%d, dso-addr:%p)", 
this->_instanceCount.load() - 1, this);
-  if (0 == --this->_instanceCount) {
+  PluginDbg(_dbg_ctl(), "plugin DSO release (ref-count:%d, dso-addr:%p)", 
this->refcount() - 1, this);
+  if (0 == this->refcount_dec()) {
     PluginDbg(_dbg_ctl(), "unloading plugin DSO '%s' (dso-addr:%p)", 
_configPath.c_str(), this);
     _plugins->remove(this);
   }
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();
     }
   }
 }


Reply via email to