summaryrefslogtreecommitdiffstats
path: root/test/h5test.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/h5test.c')
-rw-r--r--test/h5test.c133
1 files changed, 78 insertions, 55 deletions
diff --git a/test/h5test.c b/test/h5test.c
index 51ec2ca..f16b98f 100644
--- a/test/h5test.c
+++ b/test/h5test.c
@@ -96,7 +96,7 @@ static H5E_auto2_t err_func = NULL;
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);
+ char *fullname, size_t size, hbool_t nest_printf);
/*-------------------------------------------------------------------------
@@ -123,82 +123,75 @@ h5_errors(hid_t estack, void H5_ATTR_UNUSED *client_data)
return 0;
}
-
+
/*-------------------------------------------------------------------------
* Function: h5_clean_files
*
- * Purpose: Cleanup temporary test files.
+ * Purpose: Cleanup temporary test files (always).
* base_name contains the list of test file names.
- * The file access property list is also closed.
*
- * Return: Non-zero if cleanup actions were performed; zero otherwise.
+ * Return: void
*
- * Programmer: Quincey Koziol
- * September 13, 2015
+ * Programmer: Neil Fortner
+ * June 1, 2015
*
*-------------------------------------------------------------------------
*/
-int
+void
h5_clean_files(const char *base_name[], hid_t fapl)
{
- int retval = 0;
-
- if(GetTestCleanup()) {
- int i;
-
- for(i = 0; base_name[i]; i++) {
- char filename[1024];
- char temp[2048];
- hid_t driver;
-
- if(NULL == h5_fixname(base_name[i], fapl, filename, sizeof(filename)))
- continue;
+ int i;
- driver = H5Pget_driver(fapl);
+ for(i = 0; base_name[i]; i++) {
+ char filename[1024];
+ char temp[2048];
+ hid_t driver;
- if(driver == H5FD_FAMILY) {
- int j;
+ if(NULL == h5_fixname(base_name[i], fapl, filename, sizeof(filename)))
+ continue;
- for(j = 0; /*void*/; j++) {
- HDsnprintf(temp, sizeof temp, filename, j);
+ driver = H5Pget_driver(fapl);
- if(HDaccess(temp, F_OK) < 0)
- break;
+ if(driver == H5FD_FAMILY) {
+ int j;
- HDremove(temp);
- } /* end for */
- } else if(driver == H5FD_CORE) {
- hbool_t backing; /* Whether the core file has backing store */
+ for(j = 0; /*void*/; j++) {
+ HDsnprintf(temp, sizeof temp, filename, j);
- H5Pget_fapl_core(fapl, NULL, &backing);
+ if(HDaccess(temp, F_OK) < 0)
+ break;
- /* If the file was stored to disk with bacing store, remove it */
- if(backing)
- HDremove(filename);
- } else if (driver == H5FD_MULTI) {
- H5FD_mem_t mt;
+ HDremove(temp);
+ } /* end for */
+ } else if(driver == H5FD_CORE) {
+ hbool_t backing; /* Whether the core file has backing store */
- HDassert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES);
+ H5Pget_fapl_core(fapl, NULL, &backing);
- for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t,mt)) {
- HDsnprintf(temp, sizeof temp, "%s-%c.h5", filename, multi_letters[mt]);
- HDremove(temp); /*don't care if it fails*/
- } /* end for */
- } else {
+ /* If the file was stored to disk with bacing store, remove it */
+ if(backing)
HDremove(filename);
- }
- } /* end for */
+ } else if (driver == H5FD_MULTI) {
+ H5FD_mem_t mt;
- retval = 1;
- } /* end if */
+ HDassert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES);
+
+ for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t,mt)) {
+ HDsnprintf(temp, sizeof temp, "%s-%c.h5", filename, multi_letters[mt]);
+ HDremove(temp); /*don't care if it fails*/
+ } /* end for */
+ } else {
+ HDremove(filename);
+ }
+ } /* end for */
/* Close the FAPL used to access the file */
H5Pclose(fapl);
- return retval;
+ return;
} /* end h5_clean_files() */
-
+
/*-------------------------------------------------------------------------
* Function: h5_cleanup
*
@@ -218,8 +211,12 @@ h5_cleanup(const char *base_name[], hid_t fapl)
{
int retval = 0;
- /* Clean up the files and the FAPL */
- retval = h5_clean_files(base_name, fapl);
+ if(GetTestCleanup()) {
+ /* Clean up files in base_name, and the FAPL */
+ h5_clean_files(base_name, fapl);
+
+ retval = 1;
+ } /* end if */
/* Restore the original error reporting routine */
h5_restore_err();
@@ -330,7 +327,7 @@ 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));
+ return (h5_fixname_real(base_name, fapl, ".h5", fullname, size, FALSE));
}
@@ -350,7 +347,33 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size)
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));
+ return (h5_fixname_real(base_name, fapl, NULL, fullname, size, FALSE));
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: h5_fixname_printf
+ *
+ * Purpose: Same as h5_fixname but returns a filename that can be passed
+ * through a printf-style function once before being passed to the file
+ * driver. Basically, replaces all % characters used by the file
+ * driver with %%.
+ *
+ * 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: Neil Fortner
+ * Wednesday, July 15, 2015
+ *
+ *-------------------------------------------------------------------------
+ */
+char *
+h5_fixname_printf(const char *base_name, hid_t fapl, char *fullname, size_t size)
+{
+ return (h5_fixname_real(base_name, fapl, ".h5", fullname, size, TRUE));
}
@@ -378,7 +401,7 @@ h5_fixname_no_suffix(const char *base_name, hid_t fapl, char *fullname, size_t s
*/
static char *
h5_fixname_real(const char *base_name, hid_t fapl, const char *_suffix,
- char *fullname, size_t size)
+ char *fullname, size_t size, hbool_t nest_printf)
{
const char *prefix = NULL;
char *ptr, last = '\0';
@@ -399,7 +422,7 @@ h5_fixname_real(const char *base_name, hid_t fapl, const char *_suffix,
if(suffix) {
if(H5FD_FAMILY == driver)
- suffix = "%05d.h5";
+ suffix = nest_printf ? "%%05d.h5" : "%05d.h5";
else if (H5FD_MULTI == driver)
suffix = NULL;
}