summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MANIFEST1
-rw-r--r--config/cmake/FindJNI.cmake9
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/H5PL.c273
-rw-r--r--src/H5PLpkg.h50
-rw-r--r--src/H5PLpublic.h7
-rw-r--r--test/plugin.c706
7 files changed, 795 insertions, 252 deletions
diff --git a/MANIFEST b/MANIFEST
index a19c850..b312cab 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -801,6 +801,7 @@
./src/H5PBprivate.h
./src/H5PL.c
./src/H5PLmodule.h
+./src/H5PLpkg.h
./src/H5PLprivate.h
./src/H5PLpublic.h
./src/H5PLextern.h
diff --git a/config/cmake/FindJNI.cmake b/config/cmake/FindJNI.cmake
index baab2ea..c82d308 100644
--- a/config/cmake/FindJNI.cmake
+++ b/config/cmake/FindJNI.cmake
@@ -137,7 +137,6 @@ JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_LIBRARY_DIRECTORIES
/usr/lib/java/jre/lib/{libarch}
/usr/lib64/java/jre/lib/{libarch}
/usr/lib/jvm/jre/lib/{libarch}
- /usr/lib64/jvm/jre/lib/{libarch}
/usr/local/lib/java/jre/lib/{libarch}
/usr/local/share/java/jre/lib/{libarch}
/usr/lib/j2sdk1.4-sun/jre/lib/{libarch}
@@ -152,6 +151,9 @@ JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_LIBRARY_DIRECTORIES
/usr/lib/jvm/default-java/jre/lib/{libarch}
/usr/lib/jvm/default-java/jre/lib
/usr/lib/jvm/default-java/lib
+ # Arch Linux specific paths for default JVM
+ /usr/lib/jvm/default/jre/lib/{libarch}
+ /usr/lib/jvm/default/lib/{libarch}
# Ubuntu specific paths for default JVM
/usr/lib/jvm/java-8-openjdk-{libarch}/jre/lib/{libarch} # Ubuntu 15.10
/usr/lib/jvm/java-7-openjdk-{libarch}/jre/lib/{libarch} # Ubuntu 15.10
@@ -197,14 +199,11 @@ JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_INCLUDE_DIRECTORIES
/usr/lib64/java/include
/usr/local/lib/java/include
/usr/lib/jvm/java/include
- /usr/lib64/jvm/java/include
/usr/lib/jvm/java-6-sun/include
/usr/lib/jvm/java-1.5.0-sun/include
/usr/lib/jvm/java-6-sun-1.6.0.00/include # can this one be removed according to #8821 ? Alex
/usr/lib/jvm/java-6-openjdk/include
/usr/lib/jvm/java-7-openjdk/include
- /usr/lib/jvm/java-7-openjdk-i386/include
- /usr/lib/jvm/java-7-openjdk-amd64/include
/usr/lib64/jvm/java-7-openjdk/include
/usr/lib64/jvm/java-7-openjdk-amd64/include
/usr/lib/jvm/java-8-openjdk-{libarch}/include # ubuntu 15.10
@@ -216,6 +215,8 @@ JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_INCLUDE_DIRECTORIES
/opt/sun-jdk-1.5.0.04/include
# Debian specific path for default JVM
/usr/lib/jvm/default-java/include
+ # Arch specific path for default JVM
+ /usr/lib/jvm/default/include
# OpenBSD specific path for default JVM
/usr/local/jdk-1.7.0/include
/usr/local/jdk-1.6.0/include
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 9321bbd..e2acd30 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -520,6 +520,7 @@ set (H5PL_SOURCES
set (H5PL_HDRS
${HDF5_SRC_DIR}/H5PLextern.h
+ ${HDF5_SRC_DIR}/H5PLpkg.h
${HDF5_SRC_DIR}/H5PLpublic.h
)
IDE_GENERATED_PROPERTIES ("H5PL" "${H5PL_HDRS}" "${H5PL_SOURCES}" )
diff --git a/src/H5PL.c b/src/H5PL.c
index 1f7bb2a..fe7b26b 100644
--- a/src/H5PL.c
+++ b/src/H5PL.c
@@ -25,15 +25,33 @@
#include "H5private.h" /* Generic Functions */
#include "H5Eprivate.h" /* Error handling */
#include "H5MMprivate.h" /* Memory management */
-#include "H5PLprivate.h" /* Plugin */
+#include "H5PLpkg.h" /* Plugin */
#include "H5Zprivate.h" /* Filter pipeline */
/****************/
/* Local Macros */
/****************/
-
-#define H5PL_MAX_PATH_NUM 16
+#ifdef H5_HAVE_WIN32_API
+#define H5PL_EXPAND_ENV_VAR { \
+ long bufCharCount; \
+ char *tempbuf; \
+ if(NULL == (tempbuf = (char *)H5MM_malloc(H5PL_EXPAND_BUFFER_SIZE))) \
+ HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't allocate memory for expanded path") \
+ if((bufCharCount = ExpandEnvironmentStringsA(dl_path, tempbuf, H5PL_EXPAND_BUFFER_SIZE)) > H5PL_EXPAND_BUFFER_SIZE) { \
+ tempbuf = (char *)H5MM_xfree(tempbuf); \
+ HGOTO_ERROR(H5E_PLUGIN, H5E_NOSPACE, FAIL, "expanded path is too long") \
+ } \
+ if(bufCharCount == 0) { \
+ tempbuf = (char *)H5MM_xfree(tempbuf); \
+ HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "failed to expand path") \
+ } \
+ dl_path = (char *)H5MM_xfree(dl_path); \
+ dl_path = tempbuf; \
+ }
+#else
+#define H5PL_EXPAND_ENV_VAR
+#endif /* H5_HAVE_WIN32_API */
/****************************/
/* Macros for supporting
@@ -390,6 +408,235 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5PLappend
+ *
+ * Purpose: Insert a plugin path at the end of the list.
+ *
+ * Return: Non-negative or success.
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5PLappend(const char* plugin_path)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+ char *dl_path = NULL;
+
+ FUNC_ENTER_API(FAIL)
+ if(H5PL_num_paths_g == H5PL_MAX_PATH_NUM)
+ HGOTO_ERROR(H5E_PLUGIN, H5E_NOSPACE, FAIL, "too many directories in path for table")
+ if(NULL == plugin_path)
+ HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "no path provided")
+ if(NULL == (dl_path = H5MM_strdup(plugin_path)))
+ HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't allocate memory for path")
+
+ H5PL_EXPAND_ENV_VAR
+
+ H5PL_path_table_g[H5PL_num_paths_g] = dl_path;
+ H5PL_num_paths_g++;
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5PLappend() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5PLprepend
+ *
+ * Purpose: Insert a plugin path at the beginning of the list.
+ *
+ * Return: Non-negative or success.
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5PLprepend(const char* plugin_path)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+ char *dl_path = NULL;
+ unsigned int plindex;
+
+ FUNC_ENTER_API(FAIL)
+ if(H5PL_num_paths_g == H5PL_MAX_PATH_NUM)
+ HGOTO_ERROR(H5E_PLUGIN, H5E_NOSPACE, FAIL, "too many directories in path for table")
+ if(NULL == plugin_path)
+ HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "no path provided")
+ if(NULL == (dl_path = H5MM_strdup(plugin_path)))
+ HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't allocate memory for path")
+
+ H5PL_EXPAND_ENV_VAR
+
+ for (plindex = (unsigned int)H5PL_num_paths_g; plindex > 0; plindex--)
+ H5PL_path_table_g[plindex] = H5PL_path_table_g[plindex - 1];
+ H5PL_path_table_g[0] = dl_path;
+ H5PL_num_paths_g++;
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5PLprepend() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5PLreplace
+ *
+ * Purpose: Replace the path at the specified index.
+ *
+ * Return: Non-negative or success.
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5PLreplace(const char* plugin_path, unsigned int index)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+ char *dl_path = NULL;
+
+ FUNC_ENTER_API(FAIL)
+ if(NULL == plugin_path)
+ HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "no path provided")
+ if(NULL == (dl_path = H5MM_strdup(plugin_path)))
+ HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't allocate memory for path")
+
+ H5PL_EXPAND_ENV_VAR
+
+ if(H5PL_path_table_g[index])
+ H5PL_path_table_g[index] = (char *)H5MM_xfree(H5PL_path_table_g[index]);
+ H5PL_path_table_g[index] = dl_path;
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5PLreplace() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5PLinsert
+ *
+ * Purpose: Insert a plugin path at the specified index, moving other paths after the index.
+ *
+ * Return: Non-negative or success.
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5PLinsert(const char* plugin_path, unsigned int index)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+ char *dl_path = NULL;
+ unsigned int plindex;
+
+ FUNC_ENTER_API(FAIL)
+ if(H5PL_num_paths_g == H5PL_MAX_PATH_NUM)
+ HGOTO_ERROR(H5E_PLUGIN, H5E_NOSPACE, FAIL, "too many directories in path for table")
+ if(NULL == plugin_path)
+ HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "no path provided")
+ if(NULL == (dl_path = H5MM_strdup(plugin_path)))
+ HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't allocate memory for path")
+
+ H5PL_EXPAND_ENV_VAR
+
+ for(plindex = (unsigned int)H5PL_num_paths_g; plindex > index; plindex--)
+ H5PL_path_table_g[plindex] = H5PL_path_table_g[plindex - 1];
+ H5PL_path_table_g[index] = dl_path;
+ H5PL_num_paths_g++;
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5PLinsert() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5PLremove
+ *
+ * Purpose: Remove the plugin path at the specifed index and compacting the list.
+ *
+ * Return: Non-negative or success.
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5PLremove(unsigned int index)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+ unsigned int plindex;
+
+ FUNC_ENTER_API(FAIL)
+ if(H5PL_num_paths_g == 0)
+ HGOTO_ERROR(H5E_PLUGIN, H5E_NOSPACE, FAIL, "no directories in table")
+ if(NULL == H5PL_path_table_g[index])
+ HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "no directory path at index")
+ H5PL_path_table_g[index] = (char *)H5MM_xfree(H5PL_path_table_g[index]);
+ for(plindex = index; plindex < (unsigned int)H5PL_num_paths_g; plindex++)
+ H5PL_path_table_g[plindex] = H5PL_path_table_g[plindex + 1];
+ H5PL_num_paths_g--;
+ H5PL_path_table_g[H5PL_num_paths_g] = NULL;
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5PLremove() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5PLget
+ *
+ * Purpose: Query the plugin path at the specified index.
+ *
+ * Return: Success: The length of path.
+ *
+ * If `pathname' is non-NULL then write up to `size' bytes into that
+ * buffer and always return the length of the pathname.
+ * Otherwise `size' is ignored and the function does not store the pathname,
+ * just returning the number of characters required to store the pathname.
+ * If an error occurs then the buffer pointed to by `pathname' (NULL or non-NULL)
+ * is unchanged and the function returns a negative value.
+ * If a zero is returned for the name's length, then there is no pathname
+ * associated with the index.
+ *
+ *-------------------------------------------------------------------------
+ */
+ssize_t
+H5PLget(unsigned int index, char *pathname/*out*/, size_t size)
+{
+ ssize_t ret_value = 0; /* Return value */
+ ssize_t len = 0; /* Length of pathname */
+ char *dl_path = NULL;
+
+ FUNC_ENTER_API(FAIL)
+ if(H5PL_num_paths_g == 0)
+ HGOTO_ERROR(H5E_PLUGIN, H5E_NOSPACE, FAIL, "no directories in table")
+ if(NULL == (dl_path = H5PL_path_table_g[index]))
+ HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "no directory path at index")
+ len = HDstrlen(dl_path);
+ if(pathname) {
+ HDstrncpy(pathname, dl_path, MIN((size_t)(len + 1), size));
+ if((size_t)len >= size)
+ pathname[size - 1] = '\0';
+ } /* end if */
+
+ /* Set return value */
+ ret_value = len;
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5PLget() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5PLsize
+ *
+ * Purpose: Query the size of the current list of plugin paths.
+ *
+ * Return: Non-negative or success.
+ *
+ *-------------------------------------------------------------------------
+ */
+unsigned int
+H5PLsize(void)
+{
+ return (unsigned int)H5PL_num_paths_g;
+} /* end H5PLsize() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5PL__init_path_table
*
* Purpose: Initialize the path table.
@@ -422,25 +669,7 @@ H5PL__init_path_table(void)
if(NULL == dl_path)
HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't allocate memory for path")
-#ifdef H5_HAVE_WIN32_API
- else { /* Expand windows env var*/
- long bufCharCount;
- char *tempbuf;
- if(NULL == (tempbuf = (char *)H5MM_malloc(H5PL_EXPAND_BUFFER_SIZE)))
- HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't allocate memory for expanded path")
- if((bufCharCount = ExpandEnvironmentStrings(dl_path, tempbuf, H5PL_EXPAND_BUFFER_SIZE)) > H5PL_EXPAND_BUFFER_SIZE) {
- tempbuf = (char *)H5MM_xfree(tempbuf);
- HGOTO_ERROR(H5E_PLUGIN, H5E_NOSPACE, FAIL, "expanded path is too long")
- }
- if(bufCharCount == 0) {
- tempbuf = (char *)H5MM_xfree(tempbuf);
- HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "failed to expand path")
- }
- dl_path = (char *)H5MM_xfree(dl_path);
- dl_path = H5MM_strdup(tempbuf);
- tempbuf = (char *)H5MM_xfree(tempbuf);
- }
-#endif /* H5_HAVE_WIN32_API */
+ H5PL_EXPAND_ENV_VAR
/* Put paths in the path table. They are separated by ":" */
dir = HDstrtok(dl_path, H5PL_PATH_SEPARATOR);
diff --git a/src/H5PLpkg.h b/src/H5PLpkg.h
new file mode 100644
index 0000000..5cf3096
--- /dev/null
+++ b/src/H5PLpkg.h
@@ -0,0 +1,50 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+#if !(defined H5PL_FRIEND || defined H5PL_MODULE)
+#error "Do not include this file outside the H5PL package!"
+#endif
+
+#ifndef _H5PLpkg_H
+#define _H5PLpkg_H
+
+/* Include private header file */
+#include "H5PLprivate.h" /* Filter functions */
+
+/* Other private headers needed by this file */
+
+/**************************/
+/* Package Private Macros */
+/**************************/
+
+#define H5PL_MAX_PATH_NUM 16
+
+
+/****************************/
+/* Package Private Typedefs */
+/****************************/
+
+
+/*****************************/
+/* Package Private Variables */
+/*****************************/
+
+
+/******************************/
+/* Package Private Prototypes */
+/******************************/
+
+#endif /* _H5PLpkg_H */
+
diff --git a/src/H5PLpublic.h b/src/H5PLpublic.h
index 0528945..5e4dcae 100644
--- a/src/H5PLpublic.h
+++ b/src/H5PLpublic.h
@@ -44,6 +44,13 @@ extern "C" {
/* plugin state */
H5_DLL herr_t H5PLset_loading_state(unsigned int plugin_type);
H5_DLL herr_t H5PLget_loading_state(unsigned int* plugin_type/*out*/);
+H5_DLL herr_t H5PLappend(const char* plugin_path);
+H5_DLL herr_t H5PLprepend(const char* plugin_path);
+H5_DLL herr_t H5PLreplace(const char* plugin_path, unsigned int index);
+H5_DLL herr_t H5PLinsert(const char* plugin_path, unsigned int index);
+H5_DLL herr_t H5PLremove(unsigned int index);
+H5_DLL ssize_t H5PLget(unsigned int index, char *pathname/*out*/, size_t size);
+H5_DLL unsigned int H5PLsize(void);
#ifdef __cplusplus
}
diff --git a/test/plugin.c b/test/plugin.c
index a70e885..fca8916 100644
--- a/test/plugin.c
+++ b/test/plugin.c
@@ -12,24 +12,26 @@
* to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
- * Programmer: Raymond Lu
- * 13 February 2013
+ * Programmer: Raymond Lu
+ * 13 February 2013
*
- * Purpose: Tests the plugin module (H5PL)
+ * Purpose: Tests the plugin module (H5PL)
*/
#include "h5test.h"
#include "H5srcdir.h"
/*
- * This file needs to access private datatypes from the H5Z package.
+ * This file needs to access private datatypes from the H5Z and H5PL package.
*/
+#define H5PL_FRIEND
+#include "H5PLpkg.h"
#define H5Z_FRIEND
#include "H5Zpkg.h"
/* Filters for HDF5 internal test */
#define H5Z_FILTER_DYNLIB1 257
-#define H5Z_FILTER_DYNLIB2 258
+#define H5Z_FILTER_DYNLIB2 258
#define H5Z_FILTER_DYNLIB3 259
#define H5Z_FILTER_DYNLIB4 260
@@ -40,8 +42,8 @@ const char *FILENAME[] = {
#define FILENAME_BUF_SIZE 1024
/* Dataset names for testing filters */
-#define DSET_DEFLATE_NAME "deflate"
-#define DSET_DYNLIB1_NAME "dynlib1"
+#define DSET_DEFLATE_NAME "deflate"
+#define DSET_DYNLIB1_NAME "dynlib1"
#define DSET_DYNLIB2_NAME "dynlib2"
#define DSET_DYNLIB4_NAME "dynlib4"
@@ -62,7 +64,7 @@ const char *FILENAME[] = {
#define GROUP_ITERATION 1000
-int points_deflate[DSET_DIM1][DSET_DIM2],
+int points_deflate[DSET_DIM1][DSET_DIM2],
points_dynlib1[DSET_DIM1][DSET_DIM2],
points_dynlib2[DSET_DIM1][DSET_DIM2],
points_dynlib4[DSET_DIM1][DSET_DIM2],
@@ -70,14 +72,14 @@ int points_deflate[DSET_DIM1][DSET_DIM2],
/*-------------------------------------------------------------------------
- * Function: test_filter_internal
+ * Function: test_filter_internal
*
- * Purpose: Tests writing entire data and partial data with filters
+ * Purpose: Tests writing entire data and partial data with filters
*
- * Return: Success: 0
- * Failure: -1
+ * Return: Success: 0
+ * Failure: -1
*
- * Programmer: Raymond Lu
+ * Programmer: Raymond Lu
* 27 February 2013
*
*-------------------------------------------------------------------------
@@ -85,28 +87,28 @@ int points_deflate[DSET_DIM1][DSET_DIM2],
static herr_t
test_filter_internal(hid_t fid, const char *name, hid_t dcpl)
{
- hid_t dataset; /* Dataset ID */
- hid_t dxpl; /* Dataset xfer property list ID */
- hid_t write_dxpl; /* Dataset xfer property list ID for writing */
- hid_t sid; /* Dataspace ID */
- const hsize_t size[2] = {DSET_DIM1, DSET_DIM2}; /* Dataspace dimensions */
- const hsize_t hs_offset[2] = {FILTER_HS_OFFSET1, FILTER_HS_OFFSET2}; /* Hyperslab offset */
- const hsize_t hs_size[2] = {FILTER_HS_SIZE1, FILTER_HS_SIZE2}; /* Hyperslab size */
- void *tconv_buf = NULL; /* Temporary conversion buffer */
- int points[DSET_DIM1][DSET_DIM2], check[DSET_DIM1][DSET_DIM2];
- size_t i, j; /* Local index variables */
+ hid_t dataset; /* Dataset ID */
+ hid_t dxpl; /* Dataset xfer property list ID */
+ hid_t write_dxpl; /* Dataset xfer property list ID for writing */
+ hid_t sid; /* Dataspace ID */
+ const hsize_t size[2] = {DSET_DIM1, DSET_DIM2}; /* Dataspace dimensions */
+ const hsize_t hs_offset[2] = {FILTER_HS_OFFSET1, FILTER_HS_OFFSET2}; /* Hyperslab offset */
+ const hsize_t hs_size[2] = {FILTER_HS_SIZE1, FILTER_HS_SIZE2}; /* Hyperslab size */
+ void *tconv_buf = NULL; /* Temporary conversion buffer */
+ int points[DSET_DIM1][DSET_DIM2], check[DSET_DIM1][DSET_DIM2];
+ size_t i, j; /* Local index variables */
int n = 0;
/* Create the data space */
- if((sid = H5Screate_simple(2, size, NULL)) < 0) goto error;
+ if((sid = H5Screate_simple(2, size, NULL)) < 0) TEST_ERROR
/*
* Create a small conversion buffer to test strip mining. We
* might as well test all we can!
*/
- if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) goto error;
+ if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR
tconv_buf = HDmalloc((size_t)1000);
- if(H5Pset_buffer(dxpl, (size_t)1000, tconv_buf, NULL) < 0) goto error;
+ if(H5Pset_buffer(dxpl, (size_t)1000, tconv_buf, NULL) < 0) TEST_ERROR
if((write_dxpl = H5Pcopy(dxpl)) < 0) TEST_ERROR;
TESTING(" filters (setup)");
@@ -114,13 +116,13 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl)
/* Check if all the filters are available */
if(H5Pall_filters_avail(dcpl)!=TRUE) {
H5_FAILED();
- printf(" Line %d: Incorrect filter availability\n",__LINE__);
- goto error;
+ HDprintf(" Line %d: Incorrect filter availability\n",__LINE__);
+ TEST_ERROR
} /* end if */
/* Create the dataset */
if((dataset = H5Dcreate2(fid, name, H5T_NATIVE_INT, sid, H5P_DEFAULT,
- dcpl, H5P_DEFAULT)) < 0) goto error;
+ dcpl, H5P_DEFAULT)) < 0) TEST_ERROR
PASSED();
@@ -131,18 +133,18 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl)
TESTING(" filters (uninitialized read)");
if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check) < 0)
- TEST_ERROR;
+ TEST_ERROR;
for(i=0; i<(size_t)size[0]; i++) {
- for(j=0; j<(size_t)size[1]; j++) {
- if(0!=check[i][j]) {
- H5_FAILED();
- printf(" Read a non-zero value.\n");
- printf(" At index %lu,%lu\n",
- (unsigned long)i, (unsigned long)j);
- goto error;
- }
- }
+ for(j=0; j<(size_t)size[1]; j++) {
+ if(0!=check[i][j]) {
+ H5_FAILED();
+ HDprintf(" Read a non-zero value.\n");
+ HDprintf(" At index %lu,%lu\n",
+ (unsigned long)i, (unsigned long)j);
+ TEST_ERROR
+ }
+ }
}
PASSED();
@@ -155,13 +157,13 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl)
n = 0;
for(i=0; i<size[0]; i++) {
- for(j=0; j<size[1]; j++) {
- points[i][j] = (int)(n++);
- }
+ for(j=0; j<size[1]; j++) {
+ points[i][j] = (int)(n++);
+ }
}
if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, points) < 0)
- TEST_ERROR;
+ TEST_ERROR;
PASSED();
@@ -173,20 +175,20 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl)
/* Read the dataset back */
if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check) < 0)
- TEST_ERROR;
+ TEST_ERROR;
/* Check that the values read are the same as the values written */
for(i=0; i<size[0]; i++) {
- for(j=0; j<size[1]; j++) {
- if(points[i][j] != check[i][j]) {
- H5_FAILED();
- fprintf(stderr," Read different values than written.\n");
- fprintf(stderr," At index %lu,%lu\n", (unsigned long)i, (unsigned long)j);
- fprintf(stderr," At original: %d\n", (int)points[i][j]);
- fprintf(stderr," At returned: %d\n", (int)check[i][j]);
- goto error;
- }
- }
+ for(j=0; j<size[1]; j++) {
+ if(points[i][j] != check[i][j]) {
+ H5_FAILED();
+ HDfprintf(stderr," Read different values than written.\n");
+ HDfprintf(stderr," At index %lu,%lu\n", (unsigned long)i, (unsigned long)j);
+ HDfprintf(stderr," At original: %d\n", (int)points[i][j]);
+ HDfprintf(stderr," At returned: %d\n", (int)check[i][j]);
+ TEST_ERROR
+ }
+ }
}
PASSED();
@@ -201,28 +203,28 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl)
TESTING(" filters (modify)");
for(i=0; i<size[0]; i++) {
- for(j=0; j<size[1]/2; j++) {
- points[i][j] = (int)HDrandom () % RANDOM_LIMIT;
- }
+ for(j=0; j<size[1]/2; j++) {
+ points[i][j] = (int)HDrandom () % RANDOM_LIMIT;
+ }
}
if(H5Dwrite (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, points) < 0)
- TEST_ERROR;
+ TEST_ERROR;
/* Read the dataset back and check it */
if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check) < 0)
- TEST_ERROR;
+ TEST_ERROR;
/* Check that the values read are the same as the values written */
for(i=0; i<size[0]; i++) {
- for(j=0; j<size[1]; j++) {
- if(points[i][j] != check[i][j]) {
- H5_FAILED();
- printf(" Read different values than written.\n");
- printf(" At index %lu,%lu\n",
- (unsigned long)i, (unsigned long)j);
- goto error;
- }
- }
+ for(j=0; j<size[1]; j++) {
+ if(points[i][j] != check[i][j]) {
+ H5_FAILED();
+ HDprintf(" Read different values than written.\n");
+ HDprintf(" At index %lu,%lu\n",
+ (unsigned long)i, (unsigned long)j);
+ TEST_ERROR
+ }
+ }
}
PASSED();
@@ -243,14 +245,14 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl)
/* Check that the values read are the same as the values written */
for(i = 0; i < size[0]; i++)
- for(j = 0; j < size[1]; j++)
- if(points[i][j] != check[i][j]) {
- H5_FAILED();
- printf(" Read different values than written.\n");
- printf(" At index %lu,%lu\n",
- (unsigned long)i, (unsigned long)j);
- goto error;
- } /* end if */
+ for(j = 0; j < size[1]; j++)
+ if(points[i][j] != check[i][j]) {
+ H5_FAILED();
+ HDprintf(" Read different values than written.\n");
+ HDprintf(" At index %lu,%lu\n",
+ (unsigned long)i, (unsigned long)j);
+ TEST_ERROR
+ } /* end if */
PASSED();
@@ -263,60 +265,60 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl)
TESTING(" filters (partial I/O)");
for(i=0; i<(size_t)hs_size[0]; i++) {
- for(j=0; j<(size_t)hs_size[1]; j++) {
- points[(size_t)hs_offset[0]+i][(size_t)hs_offset[1]+j] = (int)HDrandom() % RANDOM_LIMIT;
- }
+ for(j=0; j<(size_t)hs_size[1]; j++) {
+ points[(size_t)hs_offset[0]+i][(size_t)hs_offset[1]+j] = (int)HDrandom() % RANDOM_LIMIT;
+ }
}
if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, hs_offset, NULL, hs_size,
- NULL) < 0) TEST_ERROR;
+ NULL) < 0) TEST_ERROR;
/* (Use the "read" DXPL because partial I/O on corrupted data test needs to ignore errors during writing) */
if(H5Dwrite (dataset, H5T_NATIVE_INT, sid, sid, dxpl, points) < 0)
- TEST_ERROR;
+ TEST_ERROR;
if(H5Dread (dataset, H5T_NATIVE_INT, sid, sid, dxpl, check) < 0)
- TEST_ERROR;
+ TEST_ERROR;
/* Check that the values read are the same as the values written */
for(i=0; i<(size_t)hs_size[0]; i++) {
- for(j=0; j<(size_t)hs_size[1]; j++) {
- if(points[(size_t)hs_offset[0]+i][(size_t)hs_offset[1]+j] !=
+ for(j=0; j<(size_t)hs_size[1]; j++) {
+ if(points[(size_t)hs_offset[0]+i][(size_t)hs_offset[1]+j] !=
check[(size_t)hs_offset[0]+i][(size_t)hs_offset[1]+j]) {
- H5_FAILED();
- fprintf(stderr," Read different values than written.\n");
- fprintf(stderr," At index %lu,%lu\n",
- (unsigned long)((size_t)hs_offset[0]+i),
- (unsigned long)((size_t)hs_offset[1]+j));
- fprintf(stderr," At original: %d\n",
- (int)points[(size_t)hs_offset[0]+i][(size_t)hs_offset[1]+j]);
- fprintf(stderr," At returned: %d\n",
- (int)check[(size_t)hs_offset[0]+i][(size_t)hs_offset[1]+j]);
- goto error;
- }
- }
+ H5_FAILED();
+ HDfprintf(stderr," Read different values than written.\n");
+ HDfprintf(stderr," At index %lu,%lu\n",
+ (unsigned long)((size_t)hs_offset[0]+i),
+ (unsigned long)((size_t)hs_offset[1]+j));
+ HDfprintf(stderr," At original: %d\n",
+ (int)points[(size_t)hs_offset[0]+i][(size_t)hs_offset[1]+j]);
+ HDfprintf(stderr," At returned: %d\n",
+ (int)check[(size_t)hs_offset[0]+i][(size_t)hs_offset[1]+j]);
+ TEST_ERROR
+ }
+ }
}
PASSED();
- /* Save the data written to the file for later comparison when the file
+ /* Save the data written to the file for later comparison when the file
* is reopened for read test */
for(i=0; i<size[0]; i++) {
for(j=0; j<size[1]; j++) {
if(!HDstrcmp(name, DSET_DEFLATE_NAME)) {
- points_deflate[i][j] = points[i][j];
+ points_deflate[i][j] = points[i][j];
} else if(!HDstrcmp(name, DSET_DYNLIB1_NAME)) {
- points_dynlib1[i][j] = points[i][j];
+ points_dynlib1[i][j] = points[i][j];
} else if(!HDstrcmp(name, DSET_DYNLIB2_NAME)) {
- points_dynlib2[i][j] = points[i][j];
+ points_dynlib2[i][j] = points[i][j];
} else if(!HDstrcmp(name, DSET_DYNLIB4_NAME)) {
points_dynlib4[i][j] = points[i][j];
}
- }
+ }
}
/* Clean up objects used for this test */
- if(H5Dclose (dataset) < 0) goto error;
- if(H5Sclose (sid) < 0) goto error;
- if(H5Pclose (dxpl) < 0) goto error;
+ if(H5Dclose (dataset) < 0) TEST_ERROR
+ if(H5Sclose (sid) < 0) TEST_ERROR
+ if(H5Pclose (dxpl) < 0) TEST_ERROR
free (tconv_buf);
return(0);
@@ -328,15 +330,15 @@ error:
}
/*-------------------------------------------------------------------------
- * Function: test_filters_for_datasets
+ * Function: test_filters_for_datasets
*
- * Purpose: Tests creating datasets and writing data with dynamically
+ * Purpose: Tests creating datasets and writing data with dynamically
* loaded filters
*
- * Return: Success: 0
- * Failure: -1
+ * Return: Success: 0
+ * Failure: -1
*
- * Programmer: Raymond Lu
+ * Programmer: Raymond Lu
* 14 March 2013
*
*-------------------------------------------------------------------------
@@ -344,7 +346,7 @@ error:
static herr_t
test_filters_for_datasets(hid_t file)
{
- hid_t dc; /* Dataset creation property list ID */
+ hid_t dc; /* Dataset creation property list ID */
const hsize_t chunk_size[2] = {FILTER_CHUNK_DIM1, FILTER_CHUNK_DIM2}; /* Chunk dimensions */
unsigned int compress_level = 9;
unsigned int dynlib4_values[4];
@@ -353,79 +355,78 @@ test_filters_for_datasets(hid_t file)
* STEP 1: Test deflation by itself.
*----------------------------------------------------------
*/
+ HDputs("Testing deflate filter");
#ifdef H5_HAVE_FILTER_DEFLATE
- puts("Testing deflate filter");
- if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error;
- if(H5Pset_chunk (dc, 2, chunk_size) < 0) goto error;
- if(H5Pset_deflate (dc, 6) < 0) goto error;
+ if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR
+ if(H5Pset_chunk (dc, 2, chunk_size) < 0) TEST_ERROR
+ if(H5Pset_deflate (dc, 6) < 0) TEST_ERROR
- if(test_filter_internal(file,DSET_DEFLATE_NAME,dc) < 0) goto error;
+ if(test_filter_internal(file,DSET_DEFLATE_NAME,dc) < 0) TEST_ERROR
/* Clean up objects used for this test */
- if(H5Pclose (dc) < 0) goto error;
+ if(H5Pclose (dc) < 0) TEST_ERROR
#else /* H5_HAVE_FILTER_DEFLATE */
- TESTING("deflate filter");
SKIPPED();
- puts(" Deflate filter not enabled");
+ HDputs(" Deflate filter not enabled");
#endif /* H5_HAVE_FILTER_DEFLATE */
/*----------------------------------------------------------
* STEP 2: Test DYNLIB1 by itself.
*----------------------------------------------------------
*/
- puts("Testing DYNLIB1 filter");
- if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error;
- if(H5Pset_chunk (dc, 2, chunk_size) < 0) goto error;
- if(H5Pset_filter (dc, H5Z_FILTER_DYNLIB1, H5Z_FLAG_MANDATORY, (size_t)1, &compress_level) < 0) goto error;
+ HDputs(" DYNLIB1 filter");
+ if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR
+ if(H5Pset_chunk (dc, 2, chunk_size) < 0) TEST_ERROR
+ if(H5Pset_filter (dc, H5Z_FILTER_DYNLIB1, H5Z_FLAG_MANDATORY, (size_t)1, &compress_level) < 0) TEST_ERROR
- if(test_filter_internal(file,DSET_DYNLIB1_NAME,dc) < 0) goto error;
+ if(test_filter_internal(file,DSET_DYNLIB1_NAME,dc) < 0) TEST_ERROR
/* Clean up objects used for this test */
- if(H5Pclose (dc) < 0) goto error;
+ if(H5Pclose (dc) < 0) TEST_ERROR
- /* Unregister the dynamic filter DYNLIB1 for testing purpose. The next time when this test is run for
+ /* Unregister the dynamic filter DYNLIB1 for testing purpose. The next time when this test is run for
* the new file format, the library's H5PL code has to search in the table of loaded plugin libraries
* for this filter. */
- if(H5Zunregister(H5Z_FILTER_DYNLIB1) < 0) goto error;
+ if(H5Zunregister(H5Z_FILTER_DYNLIB1) < 0) TEST_ERROR
/*----------------------------------------------------------
* STEP 3: Test DYNLIB2 by itself.
*----------------------------------------------------------
*/
- puts("Testing DYNLIB2 filter");
- if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error;
- if(H5Pset_chunk (dc, 2, chunk_size) < 0) goto error;
- if(H5Pset_filter (dc, H5Z_FILTER_DYNLIB2, H5Z_FLAG_MANDATORY, 0, NULL) < 0) goto error;
+ HDputs(" DYNLIB2 filter");
+ if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR
+ if(H5Pset_chunk (dc, 2, chunk_size) < 0) TEST_ERROR
+ if(H5Pset_filter (dc, H5Z_FILTER_DYNLIB2, H5Z_FLAG_MANDATORY, 0, NULL) < 0) TEST_ERROR
- if(test_filter_internal(file,DSET_DYNLIB2_NAME,dc) < 0) goto error;
+ if(test_filter_internal(file,DSET_DYNLIB2_NAME,dc) < 0) TEST_ERROR
/* Clean up objects used for this test */
- if(H5Pclose (dc) < 0) goto error;
+ if(H5Pclose (dc) < 0) TEST_ERROR
- /* Unregister the dynamic filter DYNLIB2 for testing purpose. The next time when this test is run for
+ /* Unregister the dynamic filter DYNLIB2 for testing purpose. The next time when this test is run for
* the new file format, the library's H5PL code has to search in the table of loaded plugin libraries
* for this filter. */
- if(H5Zunregister(H5Z_FILTER_DYNLIB2) < 0) goto error;
+ if(H5Zunregister(H5Z_FILTER_DYNLIB2) < 0) TEST_ERROR
/*----------------------------------------------------------
* STEP 4: Test DYNLIB4 by itself.
*----------------------------------------------------------
*/
- puts("Testing DYNLIB4 filter");
- if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error;
- if(H5Pset_chunk (dc, 2, chunk_size) < 0) goto error;
+ HDputs(" DYNLIB4 filter");
+ if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR
+ if(H5Pset_chunk (dc, 2, chunk_size) < 0) TEST_ERROR
dynlib4_values[0] = 9;
- if(H5get_libversion(&dynlib4_values[1], &dynlib4_values[2], &dynlib4_values[3]) < 0) goto error;
- if(H5Pset_filter (dc, H5Z_FILTER_DYNLIB4, H5Z_FLAG_MANDATORY, (size_t)4, dynlib4_values) < 0) goto error;
+ if(H5get_libversion(&dynlib4_values[1], &dynlib4_values[2], &dynlib4_values[3]) < 0) TEST_ERROR
+ if(H5Pset_filter (dc, H5Z_FILTER_DYNLIB4, H5Z_FLAG_MANDATORY, (size_t)4, dynlib4_values) < 0) TEST_ERROR
- if(test_filter_internal(file,DSET_DYNLIB4_NAME,dc) < 0) goto error;
+ if(test_filter_internal(file,DSET_DYNLIB4_NAME,dc) < 0) TEST_ERROR
/* Clean up objects used for this test */
- if(H5Pclose (dc) < 0) goto error;
+ if(H5Pclose (dc) < 0) TEST_ERROR
/* Unregister the dynamic filter DYNLIB4 for testing purpose. The next time when this test is run for
* the new file format, the library's H5PL code has to search in the table of loaded plugin libraries
* for this filter. */
- if(H5Zunregister(H5Z_FILTER_DYNLIB4) < 0) goto error;
+ if(H5Zunregister(H5Z_FILTER_DYNLIB4) < 0) TEST_ERROR
return 0;
@@ -434,14 +435,14 @@ error:
}
/*-------------------------------------------------------------------------
- * Function: test_read_data
+ * Function: test_read_data
*
- * Purpose: Tests reading data and compares values
+ * Purpose: Tests reading data and compares values
*
- * Return: Success: 0
- * Failure: -1
+ * Return: Success: 0
+ * Failure: -1
*
- * Programmer: Raymond Lu
+ * Programmer: Raymond Lu
* 14 March 2013
*
*-------------------------------------------------------------------------
@@ -449,10 +450,10 @@ error:
static herr_t
test_read_data(hid_t dataset, int *origin_data)
{
- int check[DSET_DIM1][DSET_DIM2];
- const hsize_t size[2] = {DSET_DIM1, DSET_DIM2}; /* Dataspace dimensions */
+ int check[DSET_DIM1][DSET_DIM2];
+ const hsize_t size[2] = {DSET_DIM1, DSET_DIM2}; /* Dataspace dimensions */
int *data_p = origin_data;
- size_t i, j; /* Local index variables */
+ size_t i, j; /* Local index variables */
/* Read the dataset back */
if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, check) < 0)
@@ -461,16 +462,16 @@ test_read_data(hid_t dataset, int *origin_data)
/* Check that the values read are the same as the values written */
for(i=0; i<size[0]; i++) {
for(j=0; j<size[1]; j++) {
- if(*data_p != check[i][j]) {
- H5_FAILED();
- fprintf(stderr," Read different values than written.\n");
- fprintf(stderr," At index %lu,%lu\n", (unsigned long)i, (unsigned long)j);
- fprintf(stderr," At original: %d\n", *data_p);
- fprintf(stderr," At returned: %d\n", (int)check[i][j]);
- goto error;
- }
+ if(*data_p != check[i][j]) {
+ H5_FAILED();
+ HDfprintf(stderr," Read different values than written.\n");
+ HDfprintf(stderr," At index %lu,%lu\n", (unsigned long)i, (unsigned long)j);
+ HDfprintf(stderr," At original: %d\n", *data_p);
+ HDfprintf(stderr," At returned: %d\n", (int)check[i][j]);
+ TEST_ERROR
+ }
data_p++;
- }
+ }
}
PASSED();
@@ -502,9 +503,9 @@ test_read_with_filters(hid_t file)
* STEP 1: Test deflation by itself.
*----------------------------------------------------------
*/
-#ifdef H5_HAVE_FILTER_DEFLATE
- TESTING("Testing deflate filter");
+ TESTING("deflate filter");
+#ifdef H5_HAVE_FILTER_DEFLATE
if(H5Zfilter_avail(H5Z_FILTER_DEFLATE) != TRUE) TEST_ERROR
if((dset = H5Dopen2(file,DSET_DEFLATE_NAME,H5P_DEFAULT)) < 0) TEST_ERROR
@@ -515,16 +516,15 @@ test_read_with_filters(hid_t file)
/* Clean up objects used for this test */
#else /* H5_HAVE_FILTER_DEFLATE */
- TESTING("deflate filter");
SKIPPED();
- puts(" Deflate filter not enabled");
+ HDputs(" Deflate filter not enabled");
#endif /* H5_HAVE_FILTER_DEFLATE */
/*----------------------------------------------------------
* STEP 2: Test DYNLIB1 by itself.
*----------------------------------------------------------
*/
- TESTING("Testing DYNLIB1 filter");
+ TESTING(" DYNLIB1 filter");
if((dset = H5Dopen2(file,DSET_DYNLIB1_NAME,H5P_DEFAULT)) < 0) TEST_ERROR
@@ -536,7 +536,7 @@ test_read_with_filters(hid_t file)
* STEP 3: Test Bogus2 by itself.
*----------------------------------------------------------
*/
- TESTING("Testing DYNLIB2 filter");
+ TESTING(" DYNLIB2 filter");
if((dset = H5Dopen2(file,DSET_DYNLIB2_NAME,H5P_DEFAULT)) < 0) TEST_ERROR
@@ -548,7 +548,7 @@ test_read_with_filters(hid_t file)
* STEP 4: Test DYNLIB4 by itself.
*----------------------------------------------------------
*/
- TESTING("Testing DYNLIB4 filter");
+ TESTING(" DYNLIB4 filter");
if((dset = H5Dopen2(file,DSET_DYNLIB4_NAME,H5P_DEFAULT)) < 0) TEST_ERROR
@@ -593,21 +593,21 @@ error:
}
/*-------------------------------------------------------------------------
- * Function: test_noread_with_filters
+ * Function: test_noread_with_filters
*
- * Purpose: Tests reading dataset created with dynamically loaded filters disabled
+ * Purpose: Tests reading dataset created with dynamically loaded filters disabled
*
- * Return: Success: 0
- * Failure: -1
+ * Return: Success: 0
+ * Failure: -1
*
*-------------------------------------------------------------------------
*/
static herr_t
test_noread_with_filters(hid_t file)
{
- hid_t dset; /* Dataset ID */
+ hid_t dset; /* Dataset ID */
unsigned plugin_state; /* status of plugins */
- TESTING("Testing DYNLIB1 filter with plugins disabled");
+ TESTING("DYNLIB1 filter with plugins disabled");
/* disable filter plugin */
if(H5PLget_loading_state(&plugin_state) < 0) TEST_ERROR
@@ -634,14 +634,14 @@ error:
}
/*-------------------------------------------------------------------------
- * Function: test_filters_for_groups
+ * Function: test_filters_for_groups
*
- * Purpose: Tests creating group with dynamically loaded filters
+ * Purpose: Tests creating group with dynamically loaded filters
*
- * Return: Success: 0
- * Failure: -1
+ * Return: Success: 0
+ * Failure: -1
*
- * Programmer: Raymond Lu
+ * Programmer: Raymond Lu
* 1 April 2013
*
*-------------------------------------------------------------------------
@@ -649,32 +649,32 @@ error:
static herr_t
test_filters_for_groups(hid_t file)
{
- hid_t gcpl, gid, group;
+ hid_t gcpl, gid, group;
int i;
char gname[256];
- TESTING("Testing DYNLIB3 filter for group");
+ TESTING("DYNLIB3 filter for group");
- if((gcpl = H5Pcreate(H5P_GROUP_CREATE)) < 0) goto error;
-
- /* Use DYNLIB3 for creating groups */
- if(H5Pset_filter (gcpl, H5Z_FILTER_DYNLIB3, H5Z_FLAG_MANDATORY, (size_t)0, NULL) < 0) goto error;
+ if((gcpl = H5Pcreate(H5P_GROUP_CREATE)) < 0) TEST_ERROR
+
+ /* Use DYNLIB3 for creating groups */
+ if(H5Pset_filter (gcpl, H5Z_FILTER_DYNLIB3, H5Z_FLAG_MANDATORY, (size_t)0, NULL) < 0) TEST_ERROR
/* Create a group using this filter */
- if((gid = H5Gcreate2(file, "group1", H5P_DEFAULT, gcpl, H5P_DEFAULT)) < 0) goto error;
+ if((gid = H5Gcreate2(file, "group1", H5P_DEFAULT, gcpl, H5P_DEFAULT)) < 0) TEST_ERROR
/* Create multiple groups under "group1" */
for (i=0; i < GROUP_ITERATION; i++) {
- sprintf(gname, "group_%d", i);
- if((group = H5Gcreate2(gid, gname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error;
- if(H5Gclose(group) < 0) goto error;
+ HDsprintf(gname, "group_%d", i);
+ if((group = H5Gcreate2(gid, gname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Gclose(group) < 0) TEST_ERROR
}
/* Close the group */
- if(H5Gclose(gid) < 0) goto error;
+ if(H5Gclose(gid) < 0) TEST_ERROR
/* Clean up objects used for this test */
- if(H5Pclose (gcpl) < 0) goto error;
+ if(H5Pclose (gcpl) < 0) TEST_ERROR
PASSED();
@@ -685,14 +685,14 @@ error:
}
/*-------------------------------------------------------------------------
- * Function: test_groups_with_filters
+ * Function: test_groups_with_filters
*
- * Purpose: Tests opening group with dynamically loaded filters
+ * Purpose: Tests opening group with dynamically loaded filters
*
- * Return: Success: 0
- * Failure: -1
+ * Return: Success: 0
+ * Failure: -1
*
- * Programmer: Raymond Lu
+ * Programmer: Raymond Lu
* 1 April 2013
*
*-------------------------------------------------------------------------
@@ -700,24 +700,24 @@ error:
static herr_t
test_groups_with_filters(hid_t file)
{
- hid_t gid, group;
+ hid_t gid, group;
int i;
char gname[256];
- TESTING("Testing opening groups with DYNLIB3 filter");
+ TESTING("opening groups with DYNLIB3 filter");
/* Open the top group */
- if((gid = H5Gopen2(file, "group1", H5P_DEFAULT)) < 0) goto error;
+ if((gid = H5Gopen2(file, "group1", H5P_DEFAULT)) < 0) TEST_ERROR
/* Create multiple groups under "group1" */
for (i=0; i < GROUP_ITERATION; i++) {
- sprintf(gname, "group_%d", i);
- if((group = H5Gopen2(gid, gname, H5P_DEFAULT)) < 0) goto error;
- if(H5Gclose(group) < 0) goto error;
+ HDsprintf(gname, "group_%d", i);
+ if((group = H5Gopen2(gid, gname, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Gclose(group) < 0) TEST_ERROR
}
/* Close the group */
- if(H5Gclose(gid) < 0) goto error;
+ if(H5Gclose(gid) < 0) TEST_ERROR
PASSED();
@@ -727,32 +727,283 @@ error:
return -1;
}
+
+/*-------------------------------------------------------------------------
+ * Function: test_filter_path_apis
+ *
+ * Purpose: Tests accessing the path table for dynamically loaded filters
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+test_filter_path_apis(void)
+{
+ unsigned int i;
+ unsigned int ndx;
+ herr_t ret;
+ ssize_t pathlen = -1;
+ char pathname[256];
+ char tempname[256];
+
+ HDputs("Testing access to the filter path table");
+
+ ndx = H5PLsize();
+
+ TESTING(" remove");
+ /* Remove all existing paths*/
+ for (i=ndx; i > 0; i--) {
+ if (H5PLremove(i-1) < 0) {
+ HDfprintf(stderr," at %d: %s\n", i, pathname);
+ TEST_ERROR
+ }
+ }
+ /* Verify the table is empty */
+ if (H5PLsize() > 0) TEST_ERROR
+ PASSED();
+
+ TESTING(" remove (exceed)");
+ /* Exceed the min path removal */
+ H5E_BEGIN_TRY {
+ ret = H5PLremove(0);
+ } H5E_END_TRY
+ if (ret >= 0)
+ TEST_ERROR
+ PASSED();
+
+ TESTING(" append");
+ /* Create multiple paths to fill table */
+ for (i=0; i < H5PL_MAX_PATH_NUM; i++) {
+ HDsprintf(pathname, "a_path_%d", i);
+ if (H5PLappend(pathname) < 0) {
+ HDfprintf(stderr," at %d: %s\n", i, pathname);
+ TEST_ERROR
+ }
+ }
+ /* Verify the table is full */
+ if (H5PLsize() != H5PL_MAX_PATH_NUM) TEST_ERROR
+ PASSED();
+
+ TESTING(" append (exceed)");
+ /* Exceed the max path append */
+ H5E_BEGIN_TRY {
+ HDsprintf(pathname, "a_path_%d", H5PL_MAX_PATH_NUM);
+ ret = H5PLappend(pathname);
+ } H5E_END_TRY
+ if (ret >= 0)
+ TEST_ERROR
+
+ /* Exceed the max path removal */
+ H5E_BEGIN_TRY {
+ ret = H5PLremove(H5PL_MAX_PATH_NUM);
+ } H5E_END_TRY
+ if (ret >= 0)
+ TEST_ERROR
+ PASSED();
+
+ TESTING(" get (path name)");
+ if ((pathlen = H5PLget(0, NULL, 0)) <= 0) {
+ HDfprintf(stderr," get path 0 length failed\n");
+ TEST_ERROR
+ }
+ if (pathlen != 8) {
+ TEST_ERROR
+ }
+ if ((pathlen = H5PLget(0, pathname, 256)) <= 0) {
+ HDfprintf(stderr," get 0 len: %d : %s\n", pathlen, pathname);
+ TEST_ERROR
+ }
+ if (strcmp(pathname, "a_path_0") != 0) {
+ HDfprintf(stderr," get 0: %s\n", pathname);
+ TEST_ERROR
+ }
+ PASSED();
+
+ TESTING(" get (bounds)");
+ if ((pathlen = H5PLget(1, pathname, 256)) <= 0)
+ TEST_ERROR
+ if (strcmp(pathname, "a_path_1") != 0) {
+ HDfprintf(stderr," get 1: %s\n", pathname);
+ TEST_ERROR
+ }
+ if ((pathlen = H5PLget(H5PL_MAX_PATH_NUM - 1, pathname, 256)) <= 0)
+ TEST_ERROR
+ HDsprintf(tempname, "a_path_%d", H5PL_MAX_PATH_NUM - 1);
+ if (strcmp(pathname, tempname) != 0) {
+ HDfprintf(stderr," get %d: %s\n", H5PL_MAX_PATH_NUM - 1, pathname);
+ TEST_ERROR
+ }
+ PASSED();
+
+ TESTING(" get (bounds exceed)");
+ H5E_BEGIN_TRY {
+ pathlen = H5PLget(H5PL_MAX_PATH_NUM, NULL, 0);
+ } H5E_END_TRY
+ if (pathlen > 0)
+ TEST_ERROR
+ PASSED();
+
+ TESTING(" remove (verify for prepend)");
+ /* Remove one path*/
+ if (H5PLremove(8) < 0) TEST_ERROR
+
+ /* Verify that the entries were moved */
+ if ((pathlen = H5PLget(8, pathname, 256)) <= 0)
+ TEST_ERROR
+ if (strcmp(pathname, "a_path_9") != 0) {
+ HDfprintf(stderr," get 8: %s\n", pathname);
+ TEST_ERROR
+ }
+ PASSED();
+
+ /* Verify the table is not full */
+ if (H5PLsize() != H5PL_MAX_PATH_NUM - 1) TEST_ERROR
+
+ TESTING(" prepend");
+ /* Prepend one path*/
+ HDsprintf(pathname, "a_path_%d", H5PL_MAX_PATH_NUM + 1);
+ if (H5PLprepend(pathname) < 0) {
+ HDfprintf(stderr," prepend %d: %s\n", H5PL_MAX_PATH_NUM + 1, pathname);
+ TEST_ERROR
+ }
+
+ /* Verify the table is full */
+ if (H5PLsize() != H5PL_MAX_PATH_NUM) TEST_ERROR
+
+ /* Verify that the entries were moved */
+ if (H5PLget(8, pathname, 256) <= 0)
+ TEST_ERROR
+ if (strcmp(pathname, "a_path_7") != 0) {
+ HDfprintf(stderr," get 8: %s\n", pathname);
+ TEST_ERROR
+ }
+ if (H5PLget(0, pathname, 256) <= 0)
+ TEST_ERROR
+ HDsprintf(tempname, "a_path_%d", H5PL_MAX_PATH_NUM + 1);
+ if (strcmp(pathname, tempname) != 0) {
+ HDfprintf(stderr," get 0: %s\n", pathname);
+ TEST_ERROR
+ }
+ PASSED();
+
+ TESTING(" prepend (exceed)");
+ /* Exceed the max path prepend */
+ H5E_BEGIN_TRY {
+ HDsprintf(pathname, "a_path_%d", H5PL_MAX_PATH_NUM + 2);
+ ret = H5PLprepend(pathname);
+ } H5E_END_TRY
+ if (ret >= 0)
+ TEST_ERROR
+ PASSED();
+
+ TESTING(" replace");
+ /* Replace one path*/
+ HDsprintf(pathname, "a_path_%d", H5PL_MAX_PATH_NUM + 4);
+ if (H5PLreplace(pathname, 1) < 0) {
+ HDfprintf(stderr," replace 1: %s\n", pathname);
+ TEST_ERROR
+ }
+
+ /* Verify the table is full */
+ if (H5PLsize() != H5PL_MAX_PATH_NUM) TEST_ERROR
+
+ /* Verify that the entries were not moved */
+ if (H5PLget(0, pathname, 256) <= 0)
+ TEST_ERROR
+ HDsprintf(tempname, "a_path_%d", H5PL_MAX_PATH_NUM + 1);
+ if (strcmp(pathname, tempname) != 0) {
+ HDfprintf(stderr," get 0: %s\n", pathname);
+ TEST_ERROR
+ }
+ if (H5PLget(2, pathname, 256) <= 0)
+ TEST_ERROR
+ if (strcmp(pathname, "a_path_1") != 0) {
+ HDfprintf(stderr," get 2: %s\n", pathname);
+ TEST_ERROR
+ }
+ PASSED();
+
+ TESTING(" remove (verify for insert)");
+ /* Remove one path*/
+ if (H5PLremove(4) < 0) TEST_ERROR
+
+ /* Verify that the entries were moved */
+ if (H5PLget(4, pathname, 256) <= 0)
+ TEST_ERROR
+ if (strcmp(pathname, "a_path_4") != 0) {
+ HDfprintf(stderr," get 4: %s\n", pathname);
+ TEST_ERROR
+ }
+ PASSED();
+
+ /* Verify the table is not full */
+ if (H5PLsize() != 15) TEST_ERROR
+
+ TESTING(" insert");
+ /* Insert one path*/
+ HDsprintf(pathname, "a_path_%d", H5PL_MAX_PATH_NUM + 5);
+ if (H5PLinsert(pathname, 3) < 0){
+ HDfprintf(stderr," insert 3: %s\n", pathname);
+ TEST_ERROR
+ }
+
+ /* Verify that the entries were moved */
+ if (H5PLget(4, pathname, 256) <= 0)
+ TEST_ERROR
+ if (strcmp(pathname, "a_path_2") != 0){
+ HDfprintf(stderr," get 4: %s\n", pathname);
+ TEST_ERROR
+ }
+ PASSED();
+
+ /* Verify the table is full */
+ if (H5PLsize() != H5PL_MAX_PATH_NUM) TEST_ERROR
+
+ TESTING(" insert (exceed)");
+ /* Exceed the max path insert */
+ H5E_BEGIN_TRY {
+ HDsprintf(pathname, "a_path_%d", H5PL_MAX_PATH_NUM + 6);
+ ret = H5PLinsert(pathname, 12);
+ } H5E_END_TRY
+ if (ret >= 0)
+ TEST_ERROR
+
+ PASSED ();
+
+ return 0;
+
+error:
+ return -1;
+}
+
/*-------------------------------------------------------------------------
- * Function: main
+ * Function: main
*
- * Purpose: Tests the plugin module (H5PL)
+ * Purpose: Tests the plugin module (H5PL)
*
- * Return: Success: exit(EXIT_SUCCESS)
+ * Return: Success: exit(EXIT_SUCCESS)
*
- * Failure: exit(EXIT_FAILURE)
+ * Failure: exit(EXIT_FAILURE)
*
- * Programmer: Raymond Lu
- * 14 March 2013
+ * Programmer: Raymond Lu
+ * 14 March 2013
*
*-------------------------------------------------------------------------
*/
int
main(void)
{
- char filename[FILENAME_BUF_SIZE];
- hid_t file, fapl, fapl2;
+ char filename[FILENAME_BUF_SIZE];
+ hid_t file, fapl, fapl2;
unsigned new_format;
int mdc_nelmts;
size_t rdcc_nelmts;
size_t rdcc_nbytes;
double rdcc_w0;
- int nerrors = 0;
+ int nerrors = 0;
/* Testing setup */
h5_reset();
@@ -760,10 +1011,10 @@ main(void)
/* Turn off the chunk cache, so all the chunks are immediately written to disk */
if(H5Pget_cache(fapl, &mdc_nelmts, &rdcc_nelmts, &rdcc_nbytes, &rdcc_w0) < 0)
- TEST_ERROR
+ TEST_ERROR
rdcc_nbytes = 0;
if(H5Pset_cache(fapl, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0) < 0)
- TEST_ERROR
+ TEST_ERROR
/* Copy the file access property list */
if((fapl2 = H5Pcopy(fapl)) < 0) TEST_ERROR
@@ -779,36 +1030,36 @@ main(void)
/* Set the FAPL for the type of format */
if(new_format) {
- puts("\nTesting with new file format:");
+ HDputs("\nTesting with new file format:");
my_fapl = fapl2;
} /* end if */
else {
- puts("Testing with old file format:");
+ HDputs("Testing with old file format:");
my_fapl = fapl;
} /* end else */
/* Create the file for this test */
if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0)
- TEST_ERROR
+ TEST_ERROR
/* Test dynamically loaded filters for chunked dataset */
- nerrors += (test_filters_for_datasets(file) < 0 ? 1 : 0);
+ nerrors += (test_filters_for_datasets(file) < 0 ? 1 : 0);
/* Test dynamically loaded filters for groups */
nerrors += (test_filters_for_groups(file) < 0 ? 1 : 0);
if(H5Fclose(file) < 0)
- TEST_ERROR
+ TEST_ERROR
} /* end for */
/* Close FAPL */
if(H5Pclose(fapl2) < 0) TEST_ERROR
if(H5Pclose(fapl) < 0) TEST_ERROR
-
+
/* Restore the default error handler (set in h5_reset()) */
h5_restore_err();
- puts("\nTesting reading data with with dynamic plugin filters:");
+ HDputs("\nTesting reading data with with dynamic plugin filters:");
/* Close the library so that all loaded plugin libraries are unloaded */
h5_reset();
@@ -816,13 +1067,13 @@ main(void)
/* Reopen the file for testing data reading */
if((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0)
- TEST_ERROR
+ TEST_ERROR
/* Read the data with filters */
- nerrors += (test_read_with_filters(file) < 0 ? 1 : 0);
+ nerrors += (test_read_with_filters(file) < 0 ? 1 : 0);
/* Open the groups with filters */
- nerrors += (test_groups_with_filters(file) < 0 ? 1 : 0);
+ nerrors += (test_groups_with_filters(file) < 0 ? 1 : 0);
/* Restore the default error handler (set in h5_reset()) */
h5_restore_err();
@@ -839,18 +1090,21 @@ main(void)
nerrors += (test_noread_with_filters(file) < 0 ? 1 : 0);
if(H5Fclose(file) < 0)
- TEST_ERROR
+ TEST_ERROR
+
+ /* Test the APIs for access to the filter plugin path table */
+ nerrors += (test_filter_path_apis() < 0 ? 1 : 0);
if(nerrors)
- TEST_ERROR
- printf("All plugin tests passed.\n");
+ TEST_ERROR
+ HDprintf("All plugin tests passed.\n");
h5_cleanup(FILENAME, fapl);
return 0;
error:
nerrors = MAX(1, nerrors);
- printf("***** %d PLUGIN TEST%s FAILED! *****\n",
+ HDprintf("***** %d PLUGIN TEST%s FAILED! *****\n",
nerrors, 1 == nerrors ? "" : "S");
return 1;
}