File tree Expand file tree Collapse file tree 2 files changed +13
-9
lines changed
tests/memory_tracking_test Expand file tree Collapse file tree 2 files changed +13
-9
lines changed Original file line number Diff line number Diff line change 11if (NOT MEMORY_ALLOCATOR STREQUAL "system" )
2- # Need to ensure that the directory containing
3- # memcached_memory_tracking_test is added to the RPATH so we can
4- # successfully dlopen() the plugin.
5- link_directories (${Memcached_BINARY_DIR} )
6-
72 add_executable (memcached_memory_tracking_test
83 $<TARGET_OBJECTS:memory_tracking>
94 memory_tracking_test.cc)
105 target_link_libraries (memcached_memory_tracking_test
116 memcached_logger
127 platform gtest
138 ${MALLOC_LIBRARIES} )
9+ add_dependencies (memcached_memory_tracking_test memcached_memory_tracking_plugin)
1410
1511 add_test (NAME memcached-memory-tracking
16- WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
17- COMMAND memcached_memory_tracking_test)
12+ COMMAND memcached_memory_tracking_test $<TARGET_FILE:memcached_memory_tracking_plugin>)
1813
1914 add_library (memcached_memory_tracking_plugin MODULE
2015 memory_tracking_plugin.cc)
2116 target_link_libraries (memcached_memory_tracking_plugin platform)
22- set_target_properties (memcached_memory_tracking_plugin PROPERTIES PREFIX "" )
2317endif (NOT MEMORY_ALLOCATOR STREQUAL "system" )
Original file line number Diff line number Diff line change 3333// via DCE.
3434char * p;
3535
36+ // / Path to plugin to be loaded via dlopen.
37+ const char * pluginPath = nullptr ;
38+
3639class MemoryTrackerTest : public ::testing::Test {
3740public:
3841 // callback function for when memory is allocated.
@@ -154,7 +157,7 @@ void MemoryTrackerTest::AccountingTestThread(void* arg) {
154157
155158 // Test memory allocations performed from another shared library loaded
156159 // at runtime.
157- auto plugin = cb::io::loadLibrary (" memcached_memory_tracking_plugin " );
160+ auto plugin = cb::io::loadLibrary (pluginPath );
158161
159162 // dlopen()ing a plugin can allocate memory. Reset alloc_size.
160163 alloc_size = 0 ;
@@ -236,6 +239,13 @@ TEST_F(MemoryTrackerTest, mallocUsableSize) {
236239int main (int argc, char ** argv) {
237240 ::testing::InitGoogleTest (&argc, argv);
238241
242+ if (argc != 2 ) {
243+ std::cerr << " Usage: <memory_tracking_test> "
244+ " <path_to_memory_tracking_plugin>\n " ;
245+ return 1 ;
246+ }
247+ pluginPath = argv[1 ];
248+
239249 AllocHooks::initialize ();
240250
241251 return RUN_ALL_TESTS ();
You can’t perform that action at this time.
0 commit comments