summaryrefslogtreecommitdiffstats
path: root/test/h5test.c
diff options
context:
space:
mode:
authorMohamad Chaarawi <chaarawi@hdfgroup.org>2014-10-02 15:56:09 (GMT)
committerMohamad Chaarawi <chaarawi@hdfgroup.org>2014-10-02 15:56:09 (GMT)
commit26400c392b45a86e385905fd377e34603a31377a (patch)
tree26b3634a8bd9c718b1259b4f9a6ef9bb83ed7c14 /test/h5test.c
parentbd9c6d829acd95ba78b07c8d286eae81d74cd1c9 (diff)
downloadhdf5-26400c392b45a86e385905fd377e34603a31377a.zip
hdf5-26400c392b45a86e385905fd377e34603a31377a.tar.gz
hdf5-26400c392b45a86e385905fd377e34603a31377a.tar.bz2
[svn-r25659] fix filename generation with prefix for perf test.
tested h5commitest, jam & platypus parallel.
Diffstat (limited to 'test/h5test.c')
-rw-r--r--test/h5test.c94
1 files changed, 74 insertions, 20 deletions
diff --git a/test/h5test.c b/test/h5test.c
index d25b455..61a9ae0 100644
--- a/test/h5test.c
+++ b/test/h5test.c
@@ -92,6 +92,8 @@ MPI_Info h5_io_info_g=MPI_INFO_NULL;/* MPI INFO object for IO */
static const char *multi_letters = "msbrglo";
static herr_t h5_errors(hid_t estack, void *client_data);
+static char * h5_fixname_real(const char *base_name, hid_t fapl, const char *suffix,
+ char *fullname, size_t size);
/*-------------------------------------------------------------------------
@@ -268,9 +270,59 @@ h5_reset(void)
char *
h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size)
{
+ return (h5_fixname_real(base_name, fapl, ".h5", fullname, size));
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: h5_fixname_no_suffix
+ *
+ * Purpose: Same as h5_fixname but with no suffix appended
+ *
+ * Return: Success: The FULLNAME pointer.
+ *
+ * Failure: NULL if BASENAME or FULLNAME is the null
+ * pointer or if FULLNAME isn't large enough for
+ * the result.
+ *
+ *-------------------------------------------------------------------------
+ */
+char *
+h5_fixname_no_suffix(const char *base_name, hid_t fapl, char *fullname, size_t size)
+{
+ return (h5_fixname_real(base_name, fapl, NULL, fullname, size));
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: h5_fixname_real
+ *
+ * Purpose: Create a file name from a file base name like `test' and
+ * return it through the FULLNAME (at most SIZE characters
+ * counting the null terminator). The full name is created by
+ * prepending the contents of HDF5_PREFIX (separated from the
+ * base name by a slash) and appending a file extension based on
+ * the driver supplied, resulting in something like
+ * `ufs:/u/matzke/test.h5'.
+ *
+ * Return: Success: The FULLNAME pointer.
+ *
+ * Failure: NULL if BASENAME or FULLNAME is the null
+ * pointer or if FULLNAME isn't large enough for
+ * the result.
+ *
+ * Programmer: Robb Matzke
+ * Thursday, November 19, 1998
+ *
+ *-------------------------------------------------------------------------
+ */
+static char *
+h5_fixname_real(const char *base_name, hid_t fapl, const char *_suffix,
+ char *fullname, size_t size)
+{
const char *prefix = NULL;
- const char *suffix = ".h5"; /* suffix has default */
char *ptr, last = '\0';
+ const char *suffix = _suffix;
size_t i, j;
hid_t driver = -1;
int isppdriver = 0; /* if the driver is MPI parallel */
@@ -285,10 +337,12 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size)
if((driver = H5Pget_driver(fapl)) < 0)
return NULL;
- if(H5FD_FAMILY == driver)
- suffix = "%05d.h5";
- else if (H5FD_MULTI == driver)
- suffix = NULL;
+ if(suffix) {
+ if(H5FD_FAMILY == driver)
+ suffix = "%05d.h5";
+ else if (H5FD_MULTI == driver)
+ suffix = NULL;
+ }
}
/* Must first check fapl is not H5P_DEFAULT (-1) because H5FD_XXX
@@ -318,11 +372,11 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size)
*/
if(isppdriver) {
#ifdef H5_HAVE_PARALLEL
- /*
+ /*
* For parallel:
* First use command line option, then the environment
* variable, then try the constant
- */
+ */
static int explained = 0;
prefix = (paraprefix ? paraprefix : getenv_all(MPI_COMM_WORLD, 0, "HDF5_PARAPREFIX"));
@@ -335,12 +389,12 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size)
if (mpi_rank == 0)
printf("*** Hint ***\n"
- "You can use environment variable HDF5_PARAPREFIX to "
- "run parallel test files in a\n"
- "different directory or to add file type prefix. E.g.,\n"
- " HDF5_PARAPREFIX=pfs:/PFS/user/me\n"
- " export HDF5_PARAPREFIX\n"
- "*** End of Hint ***\n");
+ "You can use environment variable HDF5_PARAPREFIX to "
+ "run parallel test files in a\n"
+ "different directory or to add file type prefix. E.g.,\n"
+ " HDF5_PARAPREFIX=pfs:/PFS/user/me\n"
+ " export HDF5_PARAPREFIX\n"
+ "*** End of Hint ***\n");
explained = TRUE;
#ifdef HDF5_PARAPREFIX
@@ -352,7 +406,7 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size)
/*
* For serial:
* First use the environment variable, then try the constant
- */
+ */
prefix = HDgetenv("HDF5_PREFIX");
#ifdef HDF5_PREFIX
@@ -425,18 +479,18 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size)
return NULL;
}
} else if (HDstrlen(base_name) >= size) {
- /* Buffer is too small */
- return NULL;
+ /* Buffer is too small */
+ return NULL;
} else {
- HDstrcpy(fullname, base_name);
- }
+ HDstrcpy(fullname, base_name);
+ }
/* Append a suffix */
if (suffix) {
- if (HDstrlen(fullname) + HDstrlen(suffix) >= size)
+ if (HDstrlen(fullname) + HDstrlen(suffix) >= size)
return NULL;
- HDstrcat(fullname, suffix);
+ HDstrcat(fullname, suffix);
}
/* Remove any double slashes in the filename */