From 3c020e74f0ef37816c0488fb18e680033280e06c Mon Sep 17 00:00:00 2001 From: Mohamad Chaarawi Date: Tue, 30 Sep 2014 10:38:44 -0500 Subject: [svn-r25636] - add CMake support for testing loaded vol plugins. - some code enhancements to the plugin loading. --- src/H5PL.c | 40 ++++++++++++++++++++-------------------- test/CMakeLists.txt | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 20 deletions(-) diff --git a/src/H5PL.c b/src/H5PL.c index 96d2e84..d9ca158 100644 --- a/src/H5PL.c +++ b/src/H5PL.c @@ -130,9 +130,9 @@ static herr_t H5PL__close(H5PL_HANDLE handle); /*******************/ /* Table for opened plugin libraries */ -static size_t H5PL_table_alloc_g = 0; -static size_t H5PL_table_used_g = 0; -static H5PL_table_t *H5PL_table_g = NULL; +static size_t H5PL_filter_table_alloc_g = 0; +static size_t H5PL_filter_table_used_g = 0; +static H5PL_table_t *H5PL_filter_table_g = NULL; /* Table for opened vol plugin libraries */ static size_t H5PL_vol_table_alloc_g = 0; @@ -235,8 +235,8 @@ H5PL_term_interface(void) size_t u; /* Local index variable */ /* Close opened dynamic libraries */ - for(u = 0; u < H5PL_table_used_g; u++) - H5PL__close((H5PL_table_g[u]).handle); + for(u = 0; u < H5PL_filter_table_used_g; u++) + H5PL__close((H5PL_filter_table_g[u]).handle); /* Close opened dynamic vol libraries */ for(u = 0; u < H5PL_vol_table_used_g; u++) { @@ -245,8 +245,8 @@ H5PL_term_interface(void) } /* Free the table of dynamic libraries */ - H5PL_table_g = (H5PL_table_t *)H5MM_xfree(H5PL_table_g); - H5PL_table_used_g = H5PL_table_alloc_g = 0; + H5PL_filter_table_g = (H5PL_table_t *)H5MM_xfree(H5PL_filter_table_g); + H5PL_filter_table_used_g = H5PL_filter_table_alloc_g = 0; /* Free the table of dynamic vol libraries */ H5PL_vol_table_g = (H5PL_table_t *)H5MM_xfree(H5PL_vol_table_g); @@ -580,21 +580,21 @@ H5PL__open(H5PL_type_t pl_type, char *libname, int pl_id, const char *pl_name, c /* Successfully found plugin library, check if it's the right one */ if(plugin_info->id == pl_id) { /* Expand the table if it is too small */ - if(H5PL_table_used_g >= H5PL_table_alloc_g) { - size_t n = MAX(H5Z_MAX_NFILTERS, 2 * H5PL_table_alloc_g); - H5PL_table_t *table = (H5PL_table_t *)H5MM_realloc(H5PL_table_g, n * sizeof(H5PL_table_t)); + if(H5PL_filter_table_used_g >= H5PL_filter_table_alloc_g) { + size_t n = MAX(H5Z_MAX_NFILTERS, 2 * H5PL_filter_table_alloc_g); + H5PL_table_t *table = (H5PL_table_t *)H5MM_realloc(H5PL_filter_table_g, n * sizeof(H5PL_table_t)); if(!table) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to extend dynamic library table") - H5PL_table_g = table; - H5PL_table_alloc_g = n; + H5PL_filter_table_g = table; + H5PL_filter_table_alloc_g = n; } /* end if */ - (H5PL_table_g[H5PL_table_used_g]).handle = handle; - (H5PL_table_g[H5PL_table_used_g]).pl_type = pl_type; - (H5PL_table_g[H5PL_table_used_g]).pl_id = plugin_info->id; - H5PL_table_used_g++; + (H5PL_filter_table_g[H5PL_filter_table_used_g]).handle = handle; + (H5PL_filter_table_g[H5PL_filter_table_used_g]).pl_type = pl_type; + (H5PL_filter_table_g[H5PL_filter_table_used_g]).pl_id = plugin_info->id; + H5PL_filter_table_used_g++; /* Set the plugin info to return */ *pl_info = (const void *)plugin_info; @@ -696,15 +696,15 @@ H5PL__search_table(H5PL_type_t plugin_type, int type_id, const char *plugin_name FUNC_ENTER_STATIC /* Search in the table of already opened dynamic libraries */ - if(H5PL_TYPE_FILTER == plugin_type && H5PL_table_used_g > 0) { + if(H5PL_TYPE_FILTER == plugin_type && H5PL_filter_table_used_g > 0) { size_t i; - for(i = 0; i < H5PL_table_used_g; i++) { - if((plugin_type == (H5PL_table_g[i]).pl_type) && (type_id == (H5PL_table_g[i]).pl_id)) { + for(i = 0; i < H5PL_filter_table_used_g; i++) { + if((plugin_type == (H5PL_filter_table_g[i]).pl_type) && (type_id == (H5PL_filter_table_g[i]).pl_id)) { H5PL_get_plugin_info_t get_plugin_info; const H5Z_class2_t *plugin_info; - if(NULL == (get_plugin_info = (H5PL_get_plugin_info_t)H5PL_GET_LIB_FUNC((H5PL_table_g[i]).handle, "H5PLget_plugin_info"))) + if(NULL == (get_plugin_info = (H5PL_get_plugin_info_t)H5PL_GET_LIB_FUNC((H5PL_filter_table_g[i]).handle, "H5PLget_plugin_info"))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get function for H5PLget_plugin_info") if(NULL == (plugin_info = (const H5Z_class2_t *)(*get_plugin_info)())) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index b99447a..0d77a07 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -121,6 +121,48 @@ if (BUILD_SHARED_LIBS) "${CMAKE_BINARY_DIR}/testdir2/$" ) endforeach (test_lib ${TEST2_PLUGIN_LIBS}) + + # make vol_plugins dir + file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/voltestdir") + + #----------------------------------------------------------------------------- + # Define Test Library Sources + #----------------------------------------------------------------------------- + set (TEST_VOL_PLUGIN_LIBS + dynlibvol1 + dynlibvol2 + ) + + foreach (test_lib ${TEST_VOL_PLUGIN_LIBS}) + set (HDF5_TEST_VOL_PLUGIN_LIB_CORENAME "${test_vol_lib}") + set (HDF5_TEST_VOL_PLUGIN_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_TEST_VOL_PLUGIN_LIB_CORENAME}") + set (HDF5_TEST_VOL_PLUGIN_LIB_TARGET ${HDF5_TEST_VOL_PLUGIN_LIB_CORENAME}) + add_definitions (${HDF_EXTRA_C_FLAGS}) + INCLUDE_DIRECTORIES (${HDF5_SRC_DIR}) + + add_library (${HDF5_TEST_VOL_PLUGIN_LIB_TARGET} ${LIB_TYPE} ${HDF5_TEST_SOURCE_DIR}/${test_vol_lib}.c) + TARGET_C_PROPERTIES (${HDF5_TEST_VOL_PLUGIN_LIB_TARGET} " " " ") + target_link_libraries (${HDF5_TEST_VOL_PLUGIN_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) + H5_SET_LIB_OPTIONS ( + ${HDF5_TEST_VOL_PLUGIN_LIB_TARGET} ${HDF5_TEST_VOL_PLUGIN_LIB_NAME} + ${LIB_TYPE} + HDF5_TEST_VOL_PLUGIN_LIB_NAME_RELEASE + HDF5_TEST_VOL_PLUGIN_LIB_NAME_DEBUG + ) + set_target_properties (${HDF5_TEST_VOL_PLUGIN_LIB_TARGET} PROPERTIES FOLDER libraries/TEST_VOL_PLUGIN) + + #----------------------------------------------------------------------------- + # Copy plugin library to a plugins folder + #----------------------------------------------------------------------------- + add_custom_command ( + TARGET ${HDF5_TEST_VOL_PLUGIN_LIB_TARGET} + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different + "$" + "${CMAKE_BINARY_DIR}/voltestdir/$" + ) + endforeach (test_lib ${TEST_VOL_PLUGIN_LIBS}) endif (BUILD_SHARED_LIBS) set (testhdf5_SRCS -- cgit v0.12