summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>1998-11-21 03:36:51 (GMT)
committerRobb Matzke <matzke@llnl.gov>1998-11-21 03:36:51 (GMT)
commit7488c6366e878651f6bb8dc94f05eb69cd0df83b (patch)
treec2ba0295a0bec1b350fa3d4fa291b46ac75e271f
parent6345a417a3930b32ec9e5fc087e0aeb20a94aed7 (diff)
downloadhdf5-7488c6366e878651f6bb8dc94f05eb69cd0df83b.zip
hdf5-7488c6366e878651f6bb8dc94f05eb69cd0df83b.tar.gz
hdf5-7488c6366e878651f6bb8dc94f05eb69cd0df83b.tar.bz2
[svn-r936] Changes since 19981119
---------------------- ./src/H5.c ./src/H5A.c ./src/H5AC.c ./src/H5B.c ./src/H5D.c ./src/H5E.c ./src/H5F.c ./src/H5Farray.c ./src/H5Fcore.c ./src/H5Ffamily.c ./src/H5Fistore.c ./src/H5Flow.c ./src/H5Fmpio.c ./src/H5Fsec2.c ./src/H5Fsplit.c ./src/H5Fstdio.c ./src/H5G.c ./src/H5Gent.c ./src/H5Gnode.c ./src/H5Gstab.c ./src/H5HG.c ./src/H5HL.c ./src/H5I.c ./src/H5Iprivate.h ./src/H5MF.c ./src/H5MM.c ./src/H5O.c ./src/H5Oattr.c ./src/H5Ocomp.c ./src/H5Ocont.c ./src/H5Odtype.c ./src/H5Oefl.c ./src/H5Ofill.c ./src/H5Olayout.c ./src/H5Omtime.c ./src/H5Oname.c ./src/H5Osdspace.c ./src/H5Oshared.c ./src/H5Ostab.c ./src/H5P.c ./src/H5R.c ./src/H5RA.c ./src/H5S.c ./src/H5Sall.c ./src/H5Shyper.c ./src/H5Smpio.c ./src/H5Snone.c ./src/H5Spoint.c ./src/H5Sselect.c ./src/H5T.c ./src/H5TB.c ./src/H5Tbit.c ./src/H5Tconv.c ./src/H5V.c ./src/H5Z.c ./src/H5detect.c ./src/H5private.h Most of these changes are because the `interface_initialize_g' variable change from hbool_t to int. It's a one line change. Changed the way the library is closed so we have more control over the order the interfaces are shut down. Instead of registering an atexit() function for every interface in some haphazard order we just register one: H5_term_library() which then calls the H5*_term_interface() functions in a well-defined order. If the library is closed and then reopened repeatedly by calling H5close() and H5open() in a loop we only add one copy of the library termination functions with atexit(). Termination is a two-step process in order to help detect programming errors that would cause an infinite loop caused by the termination of one interface waking up some other previously terminated interface. The first step terminates the interface and *marks it as unusable*. After all interfaces are terminated then we mark them all as usable again. The FUNC_ENTER() macro has been modified to return failure or to dump core (depending on whether NDEBUG is defined) if we try to call an interface while it's shutting down. ./src/H5.c The H5dont_atexit() function returns failure if it's called more than once or if it's called too late. However, the error stack is not automatically printed on failure because the library might not be initialized yet ./test/chunk.c ./test/flush1.c ./test/flush2.c ./test/iopipe.c ./test/overhead.c ./test/ragged.c Changed the extra cast for Win32 so we do floating point division again -- it was just confusion about precedence and associativity of casting and the C coercion rules. Removed extra carriage returns inserted by broken operating system. ./src/H5Ffamily.c Fixed an bug where H5F_fam_write() lowered the EOF marker for one of the family members causing H5F_fam_read() to read zeros. ./test/h5test.h [NEW] ./test/h5test.c [NEW] ./test/Makefile.in ./test/bittests.c ./test/cmpd_dset.c ./test/dsets.c ./test/dtypes.c ./test/extend.c ./test/external.c Support library for test files. This isn't done yet but Katie's contractions are ~10 minutes apart so I figured I better back this stuff up just in case I'm not here next week... Eventually all test files will understand HDF5_DRIVER to name the low level file driver and parameters so we can easily test various drivers. They will also understand HDF5_PREFIX to prepend to the beginning of file names which is necessary for testing ROMIO with various drivers. Also, the cleanup function will know how to use the file name prefix and will understand different file driver naming schemes like file families. I'm not sure they'll understand the `gsf:' type prefixes yet. Note, the external test is completely commented out because I'm in the middle of modifying it. It will still compile and run but it doesn't test anything at the moment.
-rw-r--r--MANIFEST2
-rw-r--r--src/H5.c329
-rw-r--r--src/H5A.c32
-rw-r--r--src/H5AC.c2
-rw-r--r--src/H5B.c2
-rw-r--r--src/H5D.c57
-rw-r--r--src/H5Distore.c2
-rw-r--r--src/H5E.c2
-rw-r--r--src/H5F.c61
-rw-r--r--src/H5Farray.c2
-rw-r--r--src/H5Fcore.c2
-rw-r--r--src/H5Ffamily.c9
-rw-r--r--src/H5Fistore.c2
-rw-r--r--src/H5Flow.c2
-rw-r--r--src/H5Fmpio.c2
-rw-r--r--src/H5Fsec2.c2
-rw-r--r--src/H5Fsplit.c2
-rw-r--r--src/H5Fstdio.c2
-rw-r--r--src/H5G.c29
-rw-r--r--src/H5Gent.c2
-rw-r--r--src/H5Gnode.c2
-rw-r--r--src/H5Gstab.c2
-rw-r--r--src/H5HG.c2
-rw-r--r--src/H5HL.c2
-rw-r--r--src/H5I.c35
-rw-r--r--src/H5Iprivate.h1
-rw-r--r--src/H5MF.c2
-rw-r--r--src/H5MM.c2
-rw-r--r--src/H5O.c2
-rw-r--r--src/H5Oattr.c2
-rw-r--r--src/H5Ocomp.c2
-rw-r--r--src/H5Ocont.c2
-rw-r--r--src/H5Odtype.c2
-rw-r--r--src/H5Oefl.c2
-rw-r--r--src/H5Ofill.c2
-rw-r--r--src/H5Olayout.c2
-rw-r--r--src/H5Omtime.c2
-rw-r--r--src/H5Oname.c2
-rw-r--r--src/H5Osdspace.c2
-rw-r--r--src/H5Oshared.c2
-rw-r--r--src/H5Ostab.c2
-rw-r--r--src/H5P.c26
-rw-r--r--src/H5R.c30
-rw-r--r--src/H5RA.c28
-rw-r--r--src/H5S.c188
-rw-r--r--src/H5Sall.c2
-rw-r--r--src/H5Shyper.c2
-rw-r--r--src/H5Smpio.c2
-rw-r--r--src/H5Snone.c2
-rw-r--r--src/H5Spoint.c2
-rw-r--r--src/H5Sselect.c54
-rw-r--r--src/H5T.c228
-rw-r--r--src/H5TB.c46
-rw-r--r--src/H5Tbit.c2
-rw-r--r--src/H5Tconv.c2
-rw-r--r--src/H5V.c2
-rw-r--r--src/H5Z.c111
-rw-r--r--src/H5detect.c11
-rw-r--r--src/H5private.h39
-rw-r--r--test/.distdep245
-rw-r--r--test/Makefile.in11
-rw-r--r--test/bittests.c198
-rw-r--r--test/chunk.c2
-rw-r--r--test/cmpd_dset.c205
-rw-r--r--test/dsets.c442
-rw-r--r--test/dtypes.c643
-rw-r--r--test/extend.c114
-rw-r--r--test/external.c119
-rw-r--r--test/flush1.c12
-rw-r--r--test/flush2.c2
-rw-r--r--test/h5test.c366
-rw-r--r--test/h5test.h69
-rw-r--r--test/iopipe.c2
-rw-r--r--test/overhead.c28
-rw-r--r--test/ragged.c20
75 files changed, 1898 insertions, 1976 deletions
diff --git a/MANIFEST b/MANIFEST
index f23af24..44501b0 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -317,6 +317,8 @@
./test/flush1.c
./test/flush2.c
./test/gheap.c
+./test/h5test.c
+./test/h5test.h
./test/hyperslab.c
./test/iopipe.c
./test/istore.c
diff --git a/src/H5.c b/src/H5.c
index 42d19dc..f97409d 100644
--- a/src/H5.c
+++ b/src/H5.c
@@ -16,26 +16,6 @@ static char RcsId[] = "@(#)$Revision$";
/* $Id$ */
-/*LINTLIBRARY */
-/*+
- FILE
- hdf5.c
- HDF library support routines
-
- EXPORTED ROUTINES
- H5dont_atexit -- Indicate that an 'atexit' routine is _not_ to be installed
- H5get_libversion -- Check the version of the library
-
- LIBRARY-SCOPED ROUTINES
- H5_init_library -- initialize the HDF5 library
- H5_term_library -- shut-down the HDF5 library
- H5_init_thread -- initialize thread-specific information
-
- LOCAL ROUTINES
- H5_init_interface -- initialize the H5 interface
- + */
-
-
/* private headers */
#include <H5private.h> /*library */
#include <H5ACprivate.h> /*cache */
@@ -44,7 +24,7 @@ static char RcsId[] = "@(#)$Revision$";
#include <H5Iprivate.h> /*atoms */
#include <H5MMprivate.h> /*memory management */
#include <H5Pprivate.h> /*property lists */
-#include <H5Rpublic.h> /* References */
+#include <H5Rpublic.h> /*references */
#include <H5Sprivate.h> /*data spaces */
#include <H5Tprivate.h> /*data types */
#include <H5Zprivate.h> /*filters */
@@ -55,22 +35,13 @@ FILE *fdopen(int fd, const char *mode);
#define PABLO_MASK H5_mask
hbool_t library_initialize_g = FALSE;
-hbool_t thread_initialize_g = FALSE;
-hbool_t install_atexit_g = TRUE;
+hbool_t dont_atexit_g = FALSE;
H5_debug_t H5_debug_g; /*debugging info */
static void H5_debug_mask(const char*);
-typedef struct H5_exit {
- void (*func) (void); /* Interface function to call during exit */
- struct H5_exit *next; /* Pointer to next node with exit function */
-} H5_exit_t;
-
-H5_exit_t *lib_exit_head; /* Pointer to the head of the list of 'atexit' functions */
-
/* Interface initialization */
-static hbool_t interface_initialize_g = FALSE;
-#define INTERFACE_INIT H5_init_interface
-static herr_t H5_init_interface(void);
+static intn interface_initialize_g = 0;
+#define INTERFACE_INIT NULL
/*--------------------------------------------------------------------------
NAME
@@ -112,13 +83,17 @@ H5_init_library(void)
H5_debug_g.pkg[H5_PKG_V].name = "v";
H5_debug_g.pkg[H5_PKG_Z].name = "z";
- /* Install atexit() library cleanup routine */
- if (install_atexit_g == TRUE &&
- HDatexit(&H5_term_library) != 0) {
- HRETURN_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL,
- "unable to register atexit function");
+ /*
+ * Install atexit() library cleanup routine unless the H5dont_atexit()
+ * has been called. Once we add something to the atexit() list it stays
+ * there permanently, so we set dont_atexit_g after we add it to prevent
+ * adding it again later if the library is cosed and reopened.
+ */
+ if (!dont_atexit_g) {
+ atexit(H5_term_library);
+ dont_atexit_g = TRUE;
}
-
+
/*
* Initialize interfaces that might not be able to initialize themselves
* soon enough.
@@ -135,187 +110,113 @@ H5_init_library(void)
FUNC_LEAVE(SUCCEED);
}
-/*--------------------------------------------------------------------------
- NAME
- H5_add_exit
- PURPOSE
- Add an exit routine to the list of routines to call during 'atexit'
- USAGE
- herr_t H5_add_exit(func)
- void (*func)(void); IN: Function pointer of routine to add to chain
-
- RETURNS
- Non-negative on success/Negative on failure
- DESCRIPTION
- Pre-pend the new function to the list of function to call during the exit
- process. These routines are responsible for free'ing static buffers, etc.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- Don't make assumptions about the environment during the exit procedure...
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-herr_t
-H5_add_exit(void (*func)(void))
-{
- H5_exit_t *new_exit;
-
- FUNC_ENTER_INIT(H5_add_exit, NULL, FAIL);
-
- assert(func);
-
- if (NULL==(new_exit = H5MM_calloc(sizeof(H5_exit_t)))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
-
- new_exit->func = func;
- new_exit->next = lib_exit_head;
- lib_exit_head = new_exit;
-
- FUNC_LEAVE(SUCCEED);
-} /* end H5_add_exit() */
-
-/*--------------------------------------------------------------------------
- NAME
- H5_term_library
- PURPOSE
- Terminate various static buffers and shutdown the library.
- USAGE
- void H5_term_library()
- RETURNS
- Non-negative on success/Negative on failure
- DESCRIPTION
- Walk through the shutdown routines for the various interfaces and
- terminate them all.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- Should only ever be called by the "atexit" function, or real power-users.
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
+
+/*-------------------------------------------------------------------------
+ * Function: H5_term_library
+ *
+ * Purpose: Terminate interfaces in a well-defined order due to
+ * dependencies among the interfaces, then terminate
+ * library-specific data.
+ *
+ * Return: void
+ *
+ * Programmer: Robb Matzke
+ * Friday, November 20, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
void
H5_term_library(void)
{
- H5_exit_t *temp;
-
- temp = lib_exit_head;
- while (lib_exit_head != NULL) {
- (*lib_exit_head->func) ();
- lib_exit_head = lib_exit_head->next;
- HDfree(temp);
- temp = lib_exit_head;
- } /* end while */
-} /* end H5_term_library() */
-
-/*--------------------------------------------------------------------------
-NAME
- H5_init_thread -- Initialize thread-specific information
-USAGE
- void H5_init_thread()
-
-RETURNS
- Non-negative on success/Negative on failure
-DESCRIPTION
- Initializes any thread-specific data or routines.
-
---------------------------------------------------------------------------*/
-herr_t
-H5_init_thread(void)
-{
- FUNC_ENTER_INIT(H5_init_thread, NULL, FAIL);
-
- /* Add the "thread termination" routine to the exit chain */
- if (H5_add_exit(&H5_term_thread)<0)
- HRETURN_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL,
- "unable to set thread atexit function");
-
- FUNC_LEAVE(SUCCEED);
-} /* H5_init_thread */
-
-/*--------------------------------------------------------------------------
- NAME
- H5_term_thread
- PURPOSE
- Terminate various thread-specific objects
- USAGE
- void H5_term_thread()
- RETURNS
- Non-negative on success/Negative on failure
- DESCRIPTION
- Release the error stack and any other thread-specific resources allocated
- on a "per thread" basis.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- Can't report errors...
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-void
-H5_term_thread(void)
-{/*void*/}
+ /* Don't do anything if the library is already closed */
+ if (!library_initialize_g) return;
-/*--------------------------------------------------------------------------
-NAME
- H5_init_interface -- Initialize interface-specific information
-USAGE
- herr_t H5_init_interface()
-
-RETURNS
- Non-negative on success/Negative on failure
-DESCRIPTION
- Initializes any interface-specific data or routines.
+ /*
+ * Close interfaces in a well-defined order based on dependencies. The
+ * goal is that closing one interface doesn't reopen another that was
+ * just closed. In order to help us track down dependencies that we
+ * didn't know about, we close the interfaces in a two step process. The
+ * first step does the real work and makes the interface unusable. The
+ * second step doesn't do any work but makes it possible to reopen the
+ * interface later.
+ */
---------------------------------------------------------------------------*/
-static herr_t
-H5_init_interface(void)
-{
- FUNC_ENTER(H5_init_interface, FAIL);
+ /* Function What depends on it? */
+ /*------------------------- ------------------------------- */
+ H5D_term_interface(-1); /* */
+ H5TB_term_interface(-1); /* */
+ H5Z_term_interface(-1); /* */
+ H5A_term_interface(-1); /* */
+ H5RA_term_interface(-1); /* */
+ H5F_term_interface(-1); /* T */
+ H5G_term_interface(-1); /* */
+ H5R_term_interface(-1); /* */
+ H5S_term_interface(-1); /* */
+ H5T_native_close(-1); /* D RA */
+ H5T_term_interface(-1); /* D RA */
+ H5P_term_interface(-1); /* D */
+ H5I_term_interface(-1); /* A D F G P RA S T TB Z */
+ /*------------------------- --------------------------------- */
- FUNC_LEAVE(SUCCEED);
-} /* H5_init_interface */
+ /*
+ * Finalize the closing by calling all the functions again but with an
+ * argument of zero. This allows the interface to be reopened later.
+ */
+ H5A_term_interface(0);
+ H5D_term_interface(0);
+ H5F_term_interface(0);
+ H5G_term_interface(0);
+ H5I_term_interface(0);
+ H5P_term_interface(0);
+ H5RA_term_interface(0);
+ H5R_term_interface(0);
+ H5S_term_interface(0);
+ H5TB_term_interface(0);
+ H5T_native_close(0);
+ H5T_term_interface(0);
+ H5Z_term_interface(0);
+
+ /* Mark library as closed */
+ library_initialize_g = FALSE;
+}
-/*--------------------------------------------------------------------------
- NAME
- H5dont_atexit
- PURPOSE
- Indicates to the library that an 'atexit()' routine is _not_ to be installed
- USAGE
- herr_t H5dont_atexit(void)
- RETURNS
- Non-negative on success/Negative on failure
- DESCRIPTION
- This routine indicates to the library that an 'atexit()' cleanip routine
- should not be installed. The major (only?) purpose for this is in
- situations where the library is dynamically linked into an application and
- is un-linked from the application before 'exit()' gets callled. In those
- situations, a routine installed with 'atexit()' would jump to a routine
- which was no longer in memory, causing errors.
- In order to be effective, this routine _must_ be called before any other
- HDF function calls, and must be called each time the library is loaded/
- linked into the application. (the first time and after it's been un-loaded)
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- If this routine is used, certain memory buffers will not be de-allocated,
- although in theory a user could call HPend on their own...
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
+
+/*-------------------------------------------------------------------------
+ * Function: H5dont_atexit
+ *
+ * Purpose: Indicates that the library is not to clean up after itself
+ * when the application exits by calling exit() or returning
+ * from main(). This function must be called before any other
+ * HDF5 function or constant is used or it will have no effect.
+ *
+ * If this function is used then certain memory buffers will not
+ * be de-allocated nor will open files be flushed automatically.
+ * The application may still call H5close() explicitly to
+ * accomplish these things.
+ *
+ * Return: Success: non-negative
+ *
+ * Failure: negative if this function is called more than
+ * once or if it is called too late.
+ *
+ * Programmer: Robb Matzke
+ * Friday, November 20, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
herr_t
H5dont_atexit(void)
{
-#ifdef DONT_DO_THIS
- FUNC_ENTER_INIT(H5dont_atexit, NULL, FAIL);
-#endif /* DONT_DO_THIS */
-
- if (install_atexit_g == TRUE)
- install_atexit_g = FALSE;
-
-#ifdef DONT_DO_THIS
- FUNC_LEAVE(SUCCEED);
-#else /* DONT_DO_THIS */
+ /* FUNC_ENTER_INIT() should not be called */
+ H5_trace(FALSE, "H5dont_atexit", "");
+ if (dont_atexit_g) return FAIL;
+ dont_atexit_g = TRUE;
+ H5_trace(TRUE, NULL, "e", SUCCEED);
return(SUCCEED);
-#endif /* DONT_DO_THIS */
}
@@ -531,7 +432,7 @@ H5close (void)
* thing just to release it all right away. It is safe to call this
* function for an uninitialized library.
*/
- H5_term_library ();
+ H5_term_library();
return SUCCEED;
}
@@ -1138,6 +1039,12 @@ H5_bandwidth(char *buf/*out*/, double nbytes, double nseconds)
* Note: The TYPE string is meant to be terse and is generated by a
* separate perl script.
*
+ * WARNING: DO NOT CALL ANY HDF5 FUNCTION THAT CALLS FUNC_ENTER(). DOING
+ * SO MAY CAUSE H5_trace() TO BE INVOKED RECURSIVELY OR MAY
+ * CAUSE LIBRARY INITIALIZATIONS THAT ARE NOT DESIRED. DO NOT
+ * USE THE H5T_*_* CONSTANTS SINCE THEY CALL H5_open() WHICH
+ * INVOKES FUNC_ENTER().
+ *
* Return: void
*
* Programmer: Robb Matzke
@@ -1159,6 +1066,8 @@ H5_trace (hbool_t returning, const char *func, const char *type, ...)
void *vp = NULL;
FILE *out = H5_debug_g.trace;
+ /* FUNC_ENTER() should not be called */
+
if (!out) return; /*tracing is off*/
va_start (ap, type);
diff --git a/src/H5A.c b/src/H5A.c
index 89ee492..7ccf64d 100644
--- a/src/H5A.c
+++ b/src/H5A.c
@@ -34,12 +34,11 @@ static char RcsId[] = "$Revision$";
#define PABLO_MASK H5A_mask
/* Is the interface initialized? */
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT H5A_init_interface
static herr_t H5A_init_interface(void);
/* PRIVATE PROTOTYPES */
-static void H5A_term_interface(void);
static hid_t H5A_create(const H5G_entry_t *ent, const char *name,
const H5T_t *type, const H5S_t *space);
static hid_t H5A_open(H5G_entry_t *ent, unsigned idx);
@@ -63,26 +62,18 @@ DESCRIPTION
static herr_t
H5A_init_interface(void)
{
- herr_t ret_value = SUCCEED;
-
FUNC_ENTER(H5A_init_interface, FAIL);
/*
- * Register cleanup function.
+ * Create attribute group.
*/
- if ((ret_value = H5I_init_group(H5I_ATTR, H5I_ATTRID_HASHSIZE,
- H5A_RESERVED_ATOMS,
- (herr_t (*)(void *)) H5A_close))<0) {
+ if (H5I_init_group(H5I_ATTR, H5I_ATTRID_HASHSIZE, H5A_RESERVED_ATOMS,
+ (herr_t (*)(void *)) H5A_close)<0) {
HRETURN_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL,
- "unable to initialize attribute group");
- }
-
- if (H5_add_exit(H5A_term_interface) < 0) {
- HRETURN_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL,
- "unable to install atexit function");
+ "unable to initialize interface");
}
- FUNC_LEAVE(ret_value);
+ FUNC_LEAVE(SUCCEED);
}
@@ -94,7 +85,6 @@ H5A_init_interface(void)
USAGE
void H5A_term_interface()
RETURNS
- Non-negative on success/Negative on failure
DESCRIPTION
Release any other resources allocated.
GLOBAL VARIABLES
@@ -103,11 +93,13 @@ H5A_init_interface(void)
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-static void
-H5A_term_interface(void)
+void
+H5A_term_interface(intn status)
{
- H5I_destroy_group(H5I_ATTR);
- interface_initialize_g = FALSE;
+ if (interface_initialize_g>0) {
+ H5I_destroy_group(H5I_ATTR);
+ }
+ interface_initialize_g = status;
}
diff --git a/src/H5AC.c b/src/H5AC.c
index 73261c7..cc69208 100644
--- a/src/H5AC.c
+++ b/src/H5AC.c
@@ -36,7 +36,7 @@
*/
#define PABLO_MASK H5AC_mask
#define INTERFACE_INIT NULL
-static int interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#ifdef H5AC_SORT_BY_ADDR
static H5AC_t *current_cache_g = NULL; /*for sorting */
diff --git a/src/H5B.c b/src/H5B.c
index 8b45638..09bb967 100644
--- a/src/H5B.c
+++ b/src/H5B.c
@@ -139,7 +139,7 @@ static const H5AC_class_t H5AC_BT[1] = {{
/* Interface initialization? */
#define INTERFACE_INIT NULL
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
/*-------------------------------------------------------------------------
diff --git a/src/H5D.c b/src/H5D.c
index 15c0956..dd3cfc2 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -91,10 +91,9 @@ const H5D_xfer_t H5D_xfer_dflt = {
};
/* Interface initialization? */
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT H5D_init_interface
static herr_t H5D_init_interface(void);
-static void H5D_term_interface(void);
static herr_t H5D_init_storage(H5D_t *dataset, const H5S_t *space);
H5D_t * H5D_new(const H5D_create_t *create_parms);
@@ -114,42 +113,42 @@ DESCRIPTION
static herr_t
H5D_init_interface(void)
{
- herr_t ret_value = SUCCEED;
FUNC_ENTER(H5D_init_interface, FAIL);
/* Initialize the atom group for the dataset IDs */
- if ((ret_value = H5I_init_group(H5I_DATASET, H5I_DATASETID_HASHSIZE,
- H5D_RESERVED_ATOMS,
- (herr_t (*)(void *)) H5D_close)) >=0) {
- ret_value = H5_add_exit(H5D_term_interface);
+ if (H5I_init_group(H5I_DATASET, H5I_DATASETID_HASHSIZE, H5D_RESERVED_ATOMS,
+ (herr_t (*)(void *)) H5D_close)<0) {
+ HRETURN_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL,
+ "unable to initialize interface");
}
- FUNC_LEAVE(ret_value);
+
+ FUNC_LEAVE(SUCCEED);
}
-/*--------------------------------------------------------------------------
- NAME
- H5D_term_interface
- PURPOSE
- Terminate various H5D objects
- USAGE
- void H5D_term_interface()
- RETURNS
- Non-negative on success/Negative on failure
- DESCRIPTION
- Release the atom group and any other resources allocated.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- Can't report errors...
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-static void
-H5D_term_interface(void)
+/*-------------------------------------------------------------------------
+ * Function: H5D_term_interface
+ *
+ * Purpose: Terminate this interface.
+ *
+ * Return: void
+ *
+ * Programmer: Robb Matzke
+ * Friday, November 20, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+void
+H5D_term_interface(intn status)
{
- H5I_destroy_group(H5I_DATASET);
- interface_initialize_g = FALSE;
+ if (interface_initialize_g>0) {
+ H5I_destroy_group(H5I_DATASET);
+ }
+ interface_initialize_g = status;
}
+
/*-------------------------------------------------------------------------
* Function: H5Dcreate
diff --git a/src/H5Distore.c b/src/H5Distore.c
index 92c0dd3..89d087c 100644
--- a/src/H5Distore.c
+++ b/src/H5Distore.c
@@ -65,7 +65,7 @@
/* Interface initialization */
#define PABLO_MASK H5F_istore_mask
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
/*
diff --git a/src/H5E.c b/src/H5E.c
index 5e4ce31..3ed3c8c 100644
--- a/src/H5E.c
+++ b/src/H5E.c
@@ -110,7 +110,7 @@ static const H5E_minor_mesg_t H5E_minor_mesg_g[] = {
};
/* Interface initialization? */
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
const hbool_t H5E_clearable_g = TRUE; /* DO NOT CHANGE */
diff --git a/src/H5F.c b/src/H5F.c
index 39e9bb3..1c7baae 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -98,9 +98,8 @@ const H5F_mprop_t H5F_mount_dflt = {
};
/* Interface initialization */
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT H5F_init_interface
-static void H5F_term_interface(void);
/* PRIVATE PROTOTYPES */
static H5F_t *H5F_new(H5F_file_t *shared, const H5F_create_t *fcpl,
@@ -112,28 +111,27 @@ static herr_t H5F_locate_signature(H5F_low_t *f_handle,
haddr_t *addr/*out*/);
-/*--------------------------------------------------------------------------
-NAME
- H5F_init_interface -- Initialize interface-specific information
-USAGE
- herr_t H5F_init_interface()
-
-RETURNS
- Non-negative on success/Negative on failure
-DESCRIPTION
- Initializes any interface-specific data or routines.
-
-ERRORS
-
-Modifications:
- Robb Matzke, 4 Aug 1997
- Changed pablo mask from H5_mask to H5F_mask for the FUNC_LEAVE call.
- It was already H5F_mask for the PABLO_TRACE_ON call.
-
- rky 980816
- Added .disp, .btype, .ftype to H5F_access_t.
-
---------------------------------------------------------------------------*/
+/*-------------------------------------------------------------------------
+ * Function: H5F_init_interface
+ *
+ * Purpose: Initialize interface-specific information.
+ *
+ * Return: Success: non-negative
+ *
+ * Failure: negative
+ *
+ * Programmer: Robb Matzke
+ * Friday, November 20, 1998
+ *
+ * Modifications:
+ * Robb Matzke, 4 Aug 1997
+ * Changed pablo mask from H5_mask to H5F_mask for the FUNC_LEAVE call.
+ * It was already H5F_mask for the PABLO_TRACE_ON call.
+ *
+ * rky 980816
+ * Added .disp, .btype, .ftype to H5F_access_t.
+ *-------------------------------------------------------------------------
+ */
herr_t
H5F_init_interface(void)
{
@@ -154,9 +152,8 @@ H5F_init_interface(void)
/* Initialize the atom group for the file IDs */
if (H5I_init_group(H5I_FILE, H5I_FILEID_HASHSIZE, 0,
- (herr_t (*)(void*))H5F_close)<0 ||
- H5_add_exit(H5F_term_interface)<0) {
- HRETURN_ERROR (H5E_ATOM, H5E_CANTINIT, FAIL,
+ (herr_t (*)(void*))H5F_close)<0) {
+ HRETURN_ERROR (H5E_FILE, H5E_CANTINIT, FAIL,
"unable to initialize interface");
}
@@ -211,11 +208,13 @@ H5F_init_interface(void)
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-static void
-H5F_term_interface(void)
+void
+H5F_term_interface(intn status)
{
- H5I_destroy_group(H5I_FILE);
- interface_initialize_g = FALSE;
+ if (interface_initialize_g>0) {
+ H5I_destroy_group(H5I_FILE);
+ }
+ interface_initialize_g = status;
}
diff --git a/src/H5Farray.c b/src/H5Farray.c
index 38f3f07..c38709a 100644
--- a/src/H5Farray.c
+++ b/src/H5Farray.c
@@ -22,7 +22,7 @@
/* Interface initialization */
#define PABLO_MASK H5F_arr_mask
#define INTERFACE_INIT NULL
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
diff --git a/src/H5Fcore.c b/src/H5Fcore.c
index 557aed2..4cdd1ec 100644
--- a/src/H5Fcore.c
+++ b/src/H5Fcore.c
@@ -22,7 +22,7 @@
#define H5F_CORE_DEV 0xffff /*pseudo dev for core until we fix things */
#define PABLO_MASK H5F_core
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
static htri_t H5F_core_access(const char *name,
diff --git a/src/H5Ffamily.c b/src/H5Ffamily.c
index d9fb032..0a035e2 100644
--- a/src/H5Ffamily.c
+++ b/src/H5Ffamily.c
@@ -27,7 +27,7 @@
#include <H5MMprivate.h>
#define PABLO_MASK H5F_family
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
#define H5F_FAM_OFFSET(LF,ADDR) ((off_t)((ADDR)->offset % \
@@ -454,11 +454,14 @@ H5F_fam_write(H5F_low_t *lf, const H5F_access_t *access_parms,
/*
* Make sure the logical eof is large enough to handle the request.
+ * Do not decrease the EOF
*/
max_addr = cur_addr;
H5F_addr_inc(&max_addr, (hsize_t)nbytes);
- H5F_low_seteof(lf->u.fam.memb[membno], &max_addr);
-
+ if (H5F_addr_gt(&max_addr, &(lf->u.fam.memb[membno]->eof))) {
+ H5F_low_seteof(lf->u.fam.memb[membno], &max_addr);
+ }
+
/* Write the data to the member */
if (H5F_low_write(lf->u.fam.memb[membno],
access_parms->u.fam.memb_access, xfer_mode,
diff --git a/src/H5Fistore.c b/src/H5Fistore.c
index 92c0dd3..89d087c 100644
--- a/src/H5Fistore.c
+++ b/src/H5Fistore.c
@@ -65,7 +65,7 @@
/* Interface initialization */
#define PABLO_MASK H5F_istore_mask
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
/*
diff --git a/src/H5Flow.c b/src/H5Flow.c
index 3bed7f0..3211886 100644
--- a/src/H5Flow.c
+++ b/src/H5Flow.c
@@ -18,7 +18,7 @@
#define addr_defined(X) (((uint64_t)(-1)!=(X)->offset) ? TRUE : FALSE)
#define PABLO_MASK H5F_low
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
diff --git a/src/H5Fmpio.c b/src/H5Fmpio.c
index dc67fba..27d0871 100644
--- a/src/H5Fmpio.c
+++ b/src/H5Fmpio.c
@@ -63,7 +63,7 @@
#include <mpio.h>
#define PABLO_MASK H5F_mpio
-static hbool_t interface_initialize_g = FALSE; /* rky??? */
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
/* Global var to allow elimination of redundant metadata writes
diff --git a/src/H5Fsec2.c b/src/H5Fsec2.c
index 97ecaeb..ef54477 100644
--- a/src/H5Fsec2.c
+++ b/src/H5Fsec2.c
@@ -20,7 +20,7 @@
#include <H5MMprivate.h>
#define PABLO_MASK H5F_sec2
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
static H5F_low_t *H5F_sec2_open(const char *name,
diff --git a/src/H5Fsplit.c b/src/H5Fsplit.c
index 7655054..e4298ff 100644
--- a/src/H5Fsplit.c
+++ b/src/H5Fsplit.c
@@ -22,7 +22,7 @@
#define H5F_SPLIT_RAW_EXT ".raw"
#define PABLO_MASK H5F_split
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
static htri_t H5F_split_access(const char *name,
diff --git a/src/H5Fstdio.c b/src/H5Fstdio.c
index eff325f..d55fd19 100644
--- a/src/H5Fstdio.c
+++ b/src/H5Fstdio.c
@@ -14,7 +14,7 @@
#include <H5MMprivate.h>
#define PABLO_MASK H5F_stdio
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
static H5F_low_t *H5F_stdio_open(const char *name,
diff --git a/src/H5G.c b/src/H5G.c
index 71f2e77..ceff4dc 100644
--- a/src/H5G.c
+++ b/src/H5G.c
@@ -91,10 +91,9 @@
#define PABLO_MASK H5G_mask
/* Interface initialization */
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT H5G_init_interface
static herr_t H5G_init_interface(void);
-static void H5G_term_interface(void);
static H5G_typeinfo_t *H5G_type_g = NULL; /*object typing info */
static size_t H5G_ntypes_g = 0; /*entries in type table */
static size_t H5G_atypes_g = 0; /*entries allocated */
@@ -683,8 +682,7 @@ H5G_init_interface(void)
/* Initialize the atom group for the group IDs */
if (H5I_init_group(H5I_GROUP, H5I_GROUPID_HASHSIZE, H5G_RESERVED_ATOMS,
- (herr_t (*)(void *)) H5G_close) < 0 ||
- H5_add_exit(H5G_term_interface) < 0) {
+ (herr_t (*)(void *)) H5G_close) < 0) {
HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL,
"unable to initialize interface");
}
@@ -717,21 +715,24 @@ H5G_init_interface(void)
*
*-------------------------------------------------------------------------
*/
-static void
-H5G_term_interface(void)
+void
+H5G_term_interface(intn status)
{
size_t i;
+
+ if (interface_initialize_g>0) {
+ /* Empty the object type table */
+ for (i=0; i<H5G_ntypes_g; i++) {
+ H5MM_xfree(H5G_type_g[i].desc);
+ }
+ H5G_ntypes_g = H5G_atypes_g = 0;
+ H5G_type_g = H5MM_xfree(H5G_type_g);
- /* Empty the object type table */
- for (i=0; i<H5G_ntypes_g; i++) {
- H5MM_xfree(H5G_type_g[i].desc);
+ /* Destroy the group object id group */
+ H5I_destroy_group(H5I_GROUP);
}
- H5G_ntypes_g = H5G_atypes_g = 0;
- H5G_type_g = H5MM_xfree(H5G_type_g);
- /* Destroy the group object id group */
- H5I_destroy_group(H5I_GROUP);
- interface_initialize_g = FALSE;
+ interface_initialize_g = status;
}
diff --git a/src/H5Gent.c b/src/H5Gent.c
index 70421ca..7a37e2b 100644
--- a/src/H5Gent.c
+++ b/src/H5Gent.c
@@ -14,7 +14,7 @@
#include <H5MMprivate.h>
#define PABLO_MASK H5G_ent_mask
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
diff --git a/src/H5Gnode.c b/src/H5Gnode.c
index b7810c0..ac2004f 100644
--- a/src/H5Gnode.c
+++ b/src/H5Gnode.c
@@ -91,7 +91,7 @@ H5B_class_t H5B_SNODE[1] = {{
}};
/* Interface initialization */
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
diff --git a/src/H5Gstab.c b/src/H5Gstab.c
index 200c2e8..773c564 100644
--- a/src/H5Gstab.c
+++ b/src/H5Gstab.c
@@ -17,7 +17,7 @@
#include <H5Oprivate.h>
#define PABLO_MASK H5G_stab_mask
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
/*-------------------------------------------------------------------------
diff --git a/src/H5HG.c b/src/H5HG.c
index c72f47d..1149783 100644
--- a/src/H5HG.c
+++ b/src/H5HG.c
@@ -64,7 +64,7 @@ static const H5AC_class_t H5AC_GHEAP[1] = {{
}};
/* Interface initialization */
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
diff --git a/src/H5HL.c b/src/H5HL.c
index edc267f..d3da812 100644
--- a/src/H5HL.c
+++ b/src/H5HL.c
@@ -61,7 +61,7 @@ static const H5AC_class_t H5AC_LHEAP[1] = {{
}};
/* Interface initialization */
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
diff --git a/src/H5I.c b/src/H5I.c
index dfceb41..fa79b72 100644
--- a/src/H5I.c
+++ b/src/H5I.c
@@ -65,7 +65,7 @@ static char RcsId[] = "@(#)$Revision$";
/* Interface initialialization? */
#define PABLO_MASK H5I_mask
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT H5I_init_interface
static herr_t H5I_init_interface(void);
@@ -161,9 +161,6 @@ H5I_init_interface(void)
*/
assert(H5I_MAXID<=(1<<GROUP_BITS));
- /* Registers the cleanup routine with the exit chain */
- ret_value = H5_add_exit(&H5I_term_interface);
-
FUNC_LEAVE(ret_value);
}
@@ -920,28 +917,28 @@ H5I_release_id_node(H5I_id_info_t *id)
REVISION LOG
--------------------------------------------------------------------------*/
void
-H5I_term_interface(void)
+H5I_term_interface(intn status)
{
- H5I_id_info_t *curr;
- intn i;
+ H5I_id_info_t *curr;
+ intn i;
- /* Release the free-list if it exists */
- if (id_free_list != NULL) {
- while (id_free_list != NULL) {
+ if (interface_initialize_g>0) {
+ /* Release the free-list */
+ while (id_free_list) {
curr = id_free_list;
id_free_list = id_free_list->next;
HDfree(curr);
}
- }
- /* Release all groups */
- for (i = 0; i < (intn) H5I_MAXID; i++) {
- if (id_group_list[i] != NULL) {
- HDfree(id_group_list[i]);
- id_group_list[i] = NULL;
+ /* Release all groups */
+ for (i = 0; i < (intn) H5I_MAXID; i++) {
+ if (id_group_list[i] != NULL) {
+ HDfree(id_group_list[i]);
+ id_group_list[i] = NULL;
+ }
}
}
-
- /* Indicate interface closed */
- interface_initialize_g = FALSE;
+
+ /* Indicate interface status */
+ interface_initialize_g = status;
}
diff --git a/src/H5Iprivate.h b/src/H5Iprivate.h
index 788afb2..f2c179a 100644
--- a/src/H5Iprivate.h
+++ b/src/H5Iprivate.h
@@ -70,7 +70,6 @@ void *H5I_object (hid_t id);
H5I_type_t H5I_get_type (hid_t id);
void *H5I_remove (hid_t id);
void *H5I_search (H5I_type_t grp, H5I_search_func_t func, const void *key);
-void H5I_term_interface (void);
intn H5I_dec_ref (hid_t id);
hid_t H5I_inc_ref (hid_t id);
diff --git a/src/H5MF.c b/src/H5MF.c
index e8665db..9a12970 100644
--- a/src/H5MF.c
+++ b/src/H5MF.c
@@ -28,7 +28,7 @@
#define PABLO_MASK H5MF_mask
/* Is the interface initialized? */
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
diff --git a/src/H5MM.c b/src/H5MM.c
index bc2a7ef..5d6c2c3 100644
--- a/src/H5MM.c
+++ b/src/H5MM.c
@@ -20,7 +20,7 @@
/* Interface initialization? */
#define PABLO_MASK H5MM_mask
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
diff --git a/src/H5O.c b/src/H5O.c
index e2de522..578517e 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -45,7 +45,7 @@ static const H5AC_class_t H5AC_OHDR[1] = {{
}};
/* Interface initialization */
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT H5O_init_interface
static herr_t H5O_init_interface(void);
diff --git a/src/H5Oattr.c b/src/H5Oattr.c
index afdd533..d74d2c4 100644
--- a/src/H5Oattr.c
+++ b/src/H5Oattr.c
@@ -54,7 +54,7 @@ const H5O_class_t H5O_ATTR[1] = {{
#define H5O_ATTR_VERSION 1
/* Interface initialization */
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
/*--------------------------------------------------------------------------
diff --git a/src/H5Ocomp.c b/src/H5Ocomp.c
index 90fd622..32c4760 100644
--- a/src/H5Ocomp.c
+++ b/src/H5Ocomp.c
@@ -14,7 +14,7 @@
/* Interface initialization */
#define PABLO_MASK H5O_pline_mask
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
#define H5O_PLINE_VERSION 1
diff --git a/src/H5Ocont.c b/src/H5Ocont.c
index 3ba9b24..4cd3776 100644
--- a/src/H5Ocont.c
+++ b/src/H5Ocont.c
@@ -46,7 +46,7 @@ const H5O_class_t H5O_CONT[1] = {{
}};
/* Interface initialization */
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
/*-------------------------------------------------------------------------
diff --git a/src/H5Odtype.c b/src/H5Odtype.c
index 2ccdfec..84de73c 100644
--- a/src/H5Odtype.c
+++ b/src/H5Odtype.c
@@ -58,7 +58,7 @@ const H5O_class_t H5O_DTYPE[1] = {{
#define H5O_DTYPE_VERSION 1
/* Interface initialization */
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
/*-------------------------------------------------------------------------
diff --git a/src/H5Oefl.c b/src/H5Oefl.c
index f812c3f..0da84d2 100644
--- a/src/H5Oefl.c
+++ b/src/H5Oefl.c
@@ -40,7 +40,7 @@ const H5O_class_t H5O_EFL[1] = {{
#define H5O_EFL_VERSION 1
/* Interface initialization */
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
diff --git a/src/H5Ofill.c b/src/H5Ofill.c
index 6d77bb8..840ea01 100644
--- a/src/H5Ofill.c
+++ b/src/H5Ofill.c
@@ -40,7 +40,7 @@ const H5O_class_t H5O_FILL[1] = {{
}};
/* Interface initialization */
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
diff --git a/src/H5Olayout.c b/src/H5Olayout.c
index 363277c..b045b3d 100644
--- a/src/H5Olayout.c
+++ b/src/H5Olayout.c
@@ -40,7 +40,7 @@ const H5O_class_t H5O_LAYOUT[1] = {{
/* Interface initialization */
#define PABLO_MASK H5O_layout_mask
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
diff --git a/src/H5Omtime.c b/src/H5Omtime.c
index 86e19b8..df0294b 100644
--- a/src/H5Omtime.c
+++ b/src/H5Omtime.c
@@ -37,7 +37,7 @@ const H5O_class_t H5O_MTIME[1] = {{
}};
/* Interface initialization */
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
diff --git a/src/H5Oname.c b/src/H5Oname.c
index 50ae81e..3179350 100644
--- a/src/H5Oname.c
+++ b/src/H5Oname.c
@@ -46,7 +46,7 @@ const H5O_class_t H5O_NAME[1] = {{
}};
/* Interface initialization */
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
diff --git a/src/H5Osdspace.c b/src/H5Osdspace.c
index 4dfaaa5..2400fe9 100644
--- a/src/H5Osdspace.c
+++ b/src/H5Osdspace.c
@@ -51,7 +51,7 @@ const H5O_class_t H5O_SDSPACE[1] = {{
#define H5O_SDSPACE_VERSION 1
/* Is the interface initialized? */
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
/*--------------------------------------------------------------------------
diff --git a/src/H5Oshared.c b/src/H5Oshared.c
index ba3971f..962430b 100644
--- a/src/H5Oshared.c
+++ b/src/H5Oshared.c
@@ -42,7 +42,7 @@ const H5O_class_t H5O_SHARED[1] = {{
/* Interface initialization */
#define PABLO_MASK H5O_shared_mask
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
diff --git a/src/H5Ostab.c b/src/H5Ostab.c
index 9f48c9d..32f0528 100644
--- a/src/H5Ostab.c
+++ b/src/H5Ostab.c
@@ -46,7 +46,7 @@ const H5O_class_t H5O_STAB[1] = {{
}};
/* Interface initialization */
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
/*-------------------------------------------------------------------------
diff --git a/src/H5P.c b/src/H5P.c
index f529128..3f00ea2 100644
--- a/src/H5P.c
+++ b/src/H5P.c
@@ -28,13 +28,10 @@ static char RcsId[] = "@(#)$Revision$";
#define PABLO_MASK H5P_mask
/* Is the interface initialized? */
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT H5P_init_interface
static herr_t H5P_init_interface(void);
-/* PRIVATE PROTOTYPES */
-static void H5P_term_interface(void);
-
/*--------------------------------------------------------------------------
NAME
H5P_init_interface -- Initialize interface-specific information
@@ -83,14 +80,6 @@ H5P_init_interface(void)
"unable to initialize atom group");
}
- /*
- * Register cleanup function.
- */
- if (H5_add_exit(H5P_term_interface) < 0) {
- HRETURN_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL,
- "unable to install atexit function");
- }
-
FUNC_LEAVE(ret_value);
}
@@ -111,15 +100,18 @@ H5P_init_interface(void)
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-static void
-H5P_term_interface(void)
+void
+H5P_term_interface(intn status)
{
intn i;
- for (i = 0; i < H5P_NCLASSES; i++) {
- H5I_destroy_group((H5I_type_t)(H5I_TEMPLATE_0 + i));
+ if (interface_initialize_g>0) {
+ for (i = 0; i < H5P_NCLASSES; i++) {
+ H5I_destroy_group((H5I_type_t)(H5I_TEMPLATE_0 + i));
+ }
}
- interface_initialize_g = FALSE;
+
+ interface_initialize_g = status;
}
/*--------------------------------------------------------------------------
diff --git a/src/H5R.c b/src/H5R.c
index 209de7f..c50f09d 100644
--- a/src/H5R.c
+++ b/src/H5R.c
@@ -29,9 +29,8 @@ static char RcsId[] = "@(#)$Revision$";
/* Interface initialization */
#define PABLO_MASK H5R_mask
#define INTERFACE_INIT H5R_init_interface
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
static herr_t H5R_init_interface(void);
-static void H5R_term_interface(void);
/* Static functions */
static herr_t H5R_create(void *ref, H5G_entry_t *loc, const char *name,
@@ -55,17 +54,17 @@ DESCRIPTION
static herr_t
H5R_init_interface(void)
{
- herr_t ret_value = SUCCEED;
FUNC_ENTER(H5R_init_interface, FAIL);
/* Initialize the atom group for the file IDs */
- if ((ret_value = H5I_init_group(H5I_REFERENCE, H5I_REFID_HASHSIZE,
- H5R_RESERVED_ATOMS, (herr_t (*)(void *)) NULL)) >= 0) {
- ret_value = H5_add_exit(&H5R_term_interface);
+ if (H5I_init_group(H5I_REFERENCE, H5I_REFID_HASHSIZE, H5R_RESERVED_ATOMS,
+ (herr_t (*)(void *)) NULL)<0) {
+ HRETURN_ERROR (H5E_REFERENCE, H5E_CANTINIT, FAIL,
+ "unable to initialize interface");
}
- FUNC_LEAVE(ret_value);
-} /* end H5R_init_interface() */
+ FUNC_LEAVE(SUCCEED);
+}
/*--------------------------------------------------------------------------
@@ -85,13 +84,16 @@ H5R_init_interface(void)
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-static void
-H5R_term_interface(void)
+void
+H5R_term_interface(intn status)
{
- /* Free ID group */
- H5I_destroy_group(H5I_REFERENCE);
- interface_initialize_g = FALSE;
-} /* end H5R_term_interface() */
+ if (interface_initialize_g>0) {
+ /* Free ID group */
+ H5I_destroy_group(H5I_REFERENCE);
+ }
+
+ interface_initialize_g = status;
+}
/*--------------------------------------------------------------------------
diff --git a/src/H5RA.c b/src/H5RA.c
index d9eb0b5..5585b84 100644
--- a/src/H5RA.c
+++ b/src/H5RA.c
@@ -47,10 +47,9 @@ struct H5RA_t {
};
#define PABLO_MASK H5RA_mask
-static hbool_t interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT H5RA_init_interface
static herr_t H5RA_init_interface(void);
-static void H5RA_term_interface(void);
static H5T_t *H5RA_meta_type_g = NULL;
static herr_t H5RA_fix_overflow(H5RA_t *ra, H5T_t *type, H5RA_meta_t *meta,
@@ -74,15 +73,15 @@ static herr_t H5RA_fix_overflow(H5RA_t *ra, H5T_t *type, H5RA_meta_t *meta,
static herr_t
H5RA_init_interface(void)
{
- herr_t ret_value = SUCCEED;
H5T_t *type = NULL;
FUNC_ENTER(H5RA_init_interface, FAIL);
/* The atom group */
- if ((ret_value=H5I_init_group(H5I_RAGGED, H5I_RAGGED_HASHSIZE, 0,
- (herr_t(*)(void*))H5RA_close))>=0) {
- ret_value = H5_add_exit(H5RA_term_interface);
+ if (H5I_init_group(H5I_RAGGED, H5I_RAGGED_HASHSIZE, 0,
+ (herr_t(*)(void*))H5RA_close)<0) {
+ HRETURN_ERROR (H5E_RAGGED, H5E_CANTINIT, FAIL,
+ "unable to initialize interface");
}
/* The meta dataset type */
@@ -98,7 +97,7 @@ H5RA_init_interface(void)
}
H5RA_meta_type_g = type;
- FUNC_LEAVE(ret_value);
+ FUNC_LEAVE(SUCCEED);
}
@@ -116,13 +115,16 @@ H5RA_init_interface(void)
*
*-------------------------------------------------------------------------
*/
-static void
-H5RA_term_interface(void)
+void
+H5RA_term_interface(intn status)
{
- H5I_destroy_group(H5I_RAGGED);
- H5T_close(H5RA_meta_type_g);
- H5RA_meta_type_g = NULL;
- interface_initialize_g = FALSE;
+ if (interface_initialize_g>0) {
+ H5I_destroy_group(H5I_RAGGED);
+ H5T_close(H5RA_meta_type_g);
+ H5RA_meta_type_g = NULL;
+ }
+
+ interface_initialize_g = status;
}
diff --git a/src/H5S.c b/src/H5S.c
index 9675eae..1521a97 100644
--- a/src/H5S.c
+++ b/src/H5S.c
@@ -27,9 +27,8 @@ static char RcsId[] = "@(#)$Revision$";
/* Interface initialization */
#define PABLO_MASK H5S_mask
#define INTERFACE_INIT H5S_init_interface
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
static herr_t H5S_init_interface(void);
-static void H5S_term_interface(void);
/* Tables of file and memory conversion information */
static const H5S_fconv_t *H5S_fconv_g[H5S_SEL_N];
@@ -61,13 +60,13 @@ DESCRIPTION
static herr_t
H5S_init_interface(void)
{
- herr_t ret_value = SUCCEED;
FUNC_ENTER(H5S_init_interface, FAIL);
/* Initialize the atom group for the file IDs */
- if ((ret_value = H5I_init_group(H5I_DATASPACE, H5I_DATASPACEID_HASHSIZE,
- H5S_RESERVED_ATOMS, (herr_t (*)(void *)) H5S_close)) >= 0) {
- ret_value = H5_add_exit(&H5S_term_interface);
+ if (H5I_init_group(H5I_DATASPACE, H5I_DATASPACEID_HASHSIZE,
+ H5S_RESERVED_ATOMS, (herr_t (*)(void *))H5S_close)<0) {
+ HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL,
+ "unable to initialize interface");
}
/* Register space conversion functions */
@@ -88,7 +87,7 @@ H5S_init_interface(void)
}
#endif
- FUNC_LEAVE(ret_value);
+ FUNC_LEAVE(SUCCEED);
}
@@ -109,8 +108,8 @@ H5S_init_interface(void)
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-static void
-H5S_term_interface(void)
+void
+H5S_term_interface(intn status)
{
size_t i;
@@ -118,96 +117,101 @@ H5S_term_interface(void)
int j, nprints=0;
H5S_conv_t *path=NULL;
char buf[256];
-
- /*
- * Print statistics about each conversion path.
- */
- if (H5DEBUG(S)) {
- for (i=0; i<H5S_nconv_g; i++) {
- path = H5S_conv_g[i];
- for (j=0; j<2; j++) {
- if (0==path->stats[j].gath_ncalls &&
- 0==path->stats[j].scat_ncalls &&
- 0==path->stats[j].bkg_ncalls) {
- continue;
- }
- if (0==nprints++) {
- fprintf(H5DEBUG(S), "H5S: data space conversion "
- "statistics accumulated over life of library:\n");
- fprintf(H5DEBUG(S),
- " %-16s %10s %10s %8s %8s %8s %10s\n",
- "Memory <> File", "Bytes", "Calls",
- "User", "System", "Elapsed", "Bandwidth");
- fprintf(H5DEBUG(S),
- " %-16s %10s %10s %8s %8s %8s %10s\n",
- "--------------", "-----", "-----",
- "----", "------", "-------", "---------");
- }
-
- /* Summary */
- sprintf(buf, "%s %c %s",
- path->m->name, 0==j?'>':'<', path->f->name);
- fprintf(H5DEBUG(S), " %-16s\n", buf);
-
- /* Gather */
- if (path->stats[j].gath_ncalls) {
- H5_bandwidth(buf, (double)(path->stats[j].gath_nbytes),
- path->stats[j].gath_timer.etime);
- HDfprintf(H5DEBUG(S),
- " %16s %10Hu %10Hu %8.2f %8.2f %8.2f %10s\n",
- "gather",
- path->stats[j].gath_nbytes,
- path->stats[j].gath_ncalls,
- path->stats[j].gath_timer.utime,
- path->stats[j].gath_timer.stime,
- path->stats[j].gath_timer.etime,
- buf);
- }
-
- /* Scatter */
- if (path->stats[j].scat_ncalls) {
- H5_bandwidth(buf, (double)(path->stats[j].scat_nbytes),
- path->stats[j].scat_timer.etime);
- HDfprintf(H5DEBUG(S),
- " %16s %10Hu %10Hu %8.2f %8.2f %8.2f %10s\n",
- "scatter",
- path->stats[j].scat_nbytes,
- path->stats[j].scat_ncalls,
- path->stats[j].scat_timer.utime,
- path->stats[j].scat_timer.stime,
- path->stats[j].scat_timer.etime,
- buf);
- }
+#endif
- /* Background */
- if (path->stats[j].bkg_ncalls) {
- H5_bandwidth(buf, (double)(path->stats[j].bkg_nbytes),
- path->stats[j].bkg_timer.etime);
- HDfprintf(H5DEBUG(S),
- " %16s %10Hu %10Hu %8.2f %8.2f %8.2f %10s\n",
- "background",
- path->stats[j].bkg_nbytes,
- path->stats[j].bkg_ncalls,
- path->stats[j].bkg_timer.utime,
- path->stats[j].bkg_timer.stime,
- path->stats[j].bkg_timer.etime,
- buf);
+ if (interface_initialize_g>0) {
+#ifdef H5S_DEBUG
+ /*
+ * Print statistics about each conversion path.
+ */
+ if (H5DEBUG(S)) {
+ for (i=0; i<H5S_nconv_g; i++) {
+ path = H5S_conv_g[i];
+ for (j=0; j<2; j++) {
+ if (0==path->stats[j].gath_ncalls &&
+ 0==path->stats[j].scat_ncalls &&
+ 0==path->stats[j].bkg_ncalls) {
+ continue;
+ }
+ if (0==nprints++) {
+ fprintf(H5DEBUG(S), "H5S: data space conversion "
+ "statistics:\n");
+ fprintf(H5DEBUG(S),
+ " %-16s %10s %10s %8s %8s %8s %10s\n",
+ "Memory <> File", "Bytes", "Calls",
+ "User", "System", "Elapsed", "Bandwidth");
+ fprintf(H5DEBUG(S),
+ " %-16s %10s %10s %8s %8s %8s %10s\n",
+ "--------------", "-----", "-----",
+ "----", "------", "-------", "---------");
+ }
+
+ /* Summary */
+ sprintf(buf, "%s %c %s",
+ path->m->name, 0==j?'>':'<', path->f->name);
+ fprintf(H5DEBUG(S), " %-16s\n", buf);
+
+ /* Gather */
+ if (path->stats[j].gath_ncalls) {
+ H5_bandwidth(buf, (double)(path->stats[j].gath_nbytes),
+ path->stats[j].gath_timer.etime);
+ HDfprintf(H5DEBUG(S),
+ " %16s %10Hu %10Hu %8.2f %8.2f %8.2f "
+ "%10s\n", "gather",
+ path->stats[j].gath_nbytes,
+ path->stats[j].gath_ncalls,
+ path->stats[j].gath_timer.utime,
+ path->stats[j].gath_timer.stime,
+ path->stats[j].gath_timer.etime,
+ buf);
+ }
+
+ /* Scatter */
+ if (path->stats[j].scat_ncalls) {
+ H5_bandwidth(buf, (double)(path->stats[j].scat_nbytes),
+ path->stats[j].scat_timer.etime);
+ HDfprintf(H5DEBUG(S),
+ " %16s %10Hu %10Hu %8.2f %8.2f %8.2f "
+ "%10s\n", "scatter",
+ path->stats[j].scat_nbytes,
+ path->stats[j].scat_ncalls,
+ path->stats[j].scat_timer.utime,
+ path->stats[j].scat_timer.stime,
+ path->stats[j].scat_timer.etime,
+ buf);
+ }
+
+ /* Background */
+ if (path->stats[j].bkg_ncalls) {
+ H5_bandwidth(buf, (double)(path->stats[j].bkg_nbytes),
+ path->stats[j].bkg_timer.etime);
+ HDfprintf(H5DEBUG(S),
+ " %16s %10Hu %10Hu %8.2f %8.2f %8.2f "
+ "%10s\n", "background",
+ path->stats[j].bkg_nbytes,
+ path->stats[j].bkg_ncalls,
+ path->stats[j].bkg_timer.utime,
+ path->stats[j].bkg_timer.stime,
+ path->stats[j].bkg_timer.etime,
+ buf);
+ }
}
}
}
- }
#endif
- /* Free data types */
- H5I_destroy_group(H5I_DATASPACE);
+ /* Free data types */
+ H5I_destroy_group(H5I_DATASPACE);
- /* Clear/free conversion table */
- HDmemset(H5S_fconv_g, 0, sizeof(H5S_fconv_g));
- HDmemset(H5S_mconv_g, 0, sizeof(H5S_mconv_g));
- for (i=0; i<H5S_nconv_g; i++) H5MM_xfree(H5S_conv_g[i]);
- H5S_conv_g = H5MM_xfree(H5S_conv_g);
- H5S_nconv_g = H5S_aconv_g = 0;
- interface_initialize_g = FALSE;
+ /* Clear/free conversion table */
+ HDmemset(H5S_fconv_g, 0, sizeof(H5S_fconv_g));
+ HDmemset(H5S_mconv_g, 0, sizeof(H5S_mconv_g));
+ for (i=0; i<H5S_nconv_g; i++) H5MM_xfree(H5S_conv_g[i]);
+ H5S_conv_g = H5MM_xfree(H5S_conv_g);
+ H5S_nconv_g = H5S_aconv_g = 0;
+ }
+
+ interface_initialize_g = status;
}
diff --git a/src/H5Sall.c b/src/H5Sall.c
index 8904339..1148594 100644
--- a/src/H5Sall.c
+++ b/src/H5Sall.c
@@ -16,7 +16,7 @@
/* Interface initialization */
#define PABLO_MASK H5S_all_mask
#define INTERFACE_INIT NULL
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
static herr_t H5S_all_init (const struct H5O_layout_t *layout,
const H5S_t *space, H5S_sel_iter_t *iter);
diff --git a/src/H5Shyper.c b/src/H5Shyper.c
index a3fef1e..2392ea9 100644
--- a/src/H5Shyper.c
+++ b/src/H5Shyper.c
@@ -18,7 +18,7 @@
/* Interface initialization */
#define PABLO_MASK H5S_hyper_mask
#define INTERFACE_INIT NULL
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
/* Local datatypes */
/* Parameter block for H5S_hyper_fread & H5S_hyper_fwrite */
diff --git a/src/H5Smpio.c b/src/H5Smpio.c
index e49916e..7cf93a6 100644
--- a/src/H5Smpio.c
+++ b/src/H5Smpio.c
@@ -29,7 +29,7 @@
/* Interface initialization */
#define PABLO_MASK H5S_all_mask
#define INTERFACE_INIT NULL
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
static herr_t
H5S_mpio_all_type( const H5S_t *space, const size_t elmt_size,
diff --git a/src/H5Snone.c b/src/H5Snone.c
index 6721d98..beaeb58 100644
--- a/src/H5Snone.c
+++ b/src/H5Snone.c
@@ -16,7 +16,7 @@
/* Interface initialization */
#define PABLO_MASK H5S_none_mask
#define INTERFACE_INIT NULL
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
/*--------------------------------------------------------------------------
diff --git a/src/H5Spoint.c b/src/H5Spoint.c
index e52eb14..ae4a217 100644
--- a/src/H5Spoint.c
+++ b/src/H5Spoint.c
@@ -17,7 +17,7 @@
/* Interface initialization */
#define PABLO_MASK H5S_point_mask
#define INTERFACE_INIT NULL
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
static herr_t H5S_point_init (const struct H5O_layout_t *layout,
const H5S_t *space, H5S_sel_iter_t *iter);
diff --git a/src/H5Sselect.c b/src/H5Sselect.c
index f5db9ad..c97a350 100644
--- a/src/H5Sselect.c
+++ b/src/H5Sselect.c
@@ -18,62 +18,12 @@
/* Interface initialization */
#define PABLO_MASK H5S_select_mask
-#define INTERFACE_INIT H5S_select_init
-static intn interface_initialize_g = FALSE;
-static herr_t H5S_select_init(void);
-static void H5S_select_term(void);
+#define INTERFACE_INIT NULL
+static intn interface_initialize_g = 0;
/*--------------------------------------------------------------------------
NAME
- H5S_select_init
- PURPOSE
- Initialize selection interface
- USAGE
- herr_t H5S_select_init(void)
- RETURNS
- Non-negative on success/Negative on failure
- DESCRIPTION
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-herr_t
-H5S_select_init (void)
-{
- herr_t ret_value = SUCCEED;
- FUNC_ENTER (H5S_select_init, FAIL);
-
- /* Register the atexit function for this (sub)interface */
- ret_value = H5_add_exit(&H5S_select_term);
- FUNC_LEAVE(ret_value);
-}
-
-/*--------------------------------------------------------------------------
- NAME
- H5S_select_term
- PURPOSE
- Terminate various H5S selection objects and free lists
- USAGE
- void H5S_select_term()
- RETURNS
- Non-negative on success/Negative on failure
- DESCRIPTION
- Release the selection resources allocated.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- Can't report errors...
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-static void
-H5S_select_term(void)
-{
-}
-
-/*--------------------------------------------------------------------------
- NAME
H5S_select_copy
PURPOSE
Copy a selection from one dataspace to another
diff --git a/src/H5T.c b/src/H5T.c
index e3d84d4..c964cad 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -26,9 +26,8 @@ static char RcsId[] = "@(#)$Revision$";
#define H5T_COMPND_INC 64 /*typical max numb of members per struct */
/* Interface initialization */
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT H5T_init_interface
-static void H5T_term_interface(void);
hid_t H5T_IEEE_F32BE_g = FAIL;
hid_t H5T_IEEE_F32LE_g = FAIL;
@@ -123,23 +122,25 @@ herr_t
H5T_init_interface(void)
{
H5T_t *dt = NULL;
- herr_t ret_value = SUCCEED;
interface_initialize_g = TRUE;
FUNC_ENTER(H5T_init_interface, FAIL);
/* Initialize the atom group for the file IDs */
- if ((ret_value = H5I_init_group(H5I_DATATYPE, H5I_DATATYPEID_HASHSIZE,
- H5T_RESERVED_ATOMS,
- (herr_t (*)(void *)) H5T_close)) >= 0) {
- ret_value = H5_add_exit(&H5T_term_interface);
+ if (H5I_init_group(H5I_DATATYPE, H5I_DATATYPEID_HASHSIZE,
+ H5T_RESERVED_ATOMS, (herr_t (*)(void *))H5T_close)<0) {
+ HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
+ "unable to initialize interface");
}
/*
* Initialize pre-defined native data types from code generated during
* the library configuration by H5detect.
*/
- ret_value = H5T_native_open();
+ if (H5T_native_open()<0) {
+ HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
+ "unable to initialize interface");
+ }
/*------------------------------------------------------------
* Native types
@@ -1163,7 +1164,7 @@ H5T_init_interface(void)
"unable to register conversion function");
}
- FUNC_LEAVE(ret_value);
+ FUNC_LEAVE(SUCCEED);
}
@@ -1196,29 +1197,25 @@ H5T_unlock_cb (void *_dt, const void __unused__ *key)
FUNC_LEAVE (0);
}
-/*--------------------------------------------------------------------------
- NAME
- H5T_term_interface
- PURPOSE
- Terminate various H5T objects
- USAGE
- void H5T_term_interface()
- RETURNS
- Non-negative on success/Negative on failure
- DESCRIPTION
- Release the atom group and any other resources allocated.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- Can't report errors...
- EXAMPLES
- REVISION LOG
+
+/*-------------------------------------------------------------------------
+ * Function: H5T_term_interface
+ *
+ * Purpose: Close this interface.
+ *
+ * Return: void
+ *
+ * Programmer: Robb Matzke
+ * Friday, November 20, 1998
+ *
+ * Modifications:
* Robb Matzke, 1998-06-11
* Statistics are only printed for conversion functions that were
* called.
- *
---------------------------------------------------------------------------*/
-static void
-H5T_term_interface(void)
+ *-------------------------------------------------------------------------
+ */
+void
+H5T_term_interface(intn status)
{
intn i;
H5T_path_t *path = NULL;
@@ -1230,110 +1227,115 @@ H5T_term_interface(void)
H5T_cdata_t *cdata;
char bandwidth[32];
#endif
-
- /* Unregister all conversion functions */
- for (i=0; i<H5T_npath_g; i++) {
- path = H5T_path_g[i];
- assert (path);
- if (path->func) {
- path->cdata.command = H5T_CONV_FREE;
- if ((path->func)(FAIL, FAIL, &(path->cdata), 0, NULL, NULL)<0) {
+ if (interface_initialize_g>0) {
+ /* Unregister all conversion functions */
+ for (i=0; i<H5T_npath_g; i++) {
+ path = H5T_path_g[i];
+ assert (path);
+
+ if (path->func) {
+ path->cdata.command = H5T_CONV_FREE;
+ if ((path->func)(FAIL, FAIL, &(path->cdata), 0, NULL,
+ NULL)<0) {
#ifdef H5T_DEBUG
- if (H5DEBUG(T)) {
- fprintf (H5DEBUG(T), "H5T: conversion function failed "
- "to free private data for %s\n", path->name);
+ if (H5DEBUG(T)) {
+ fprintf (H5DEBUG(T), "H5T: conversion function failed "
+ "to free private data for %s\n", path->name);
+ }
+#endif
+ H5E_clear(); /*ignore the error*/
+ }
+#ifdef H5T_DEBUG
+ if (H5DEBUG(T) && path->cdata.stats->ncalls>0) {
+ if (0==nprint++) {
+ HDfprintf (H5DEBUG(T),
+ "H5T: type conversion statistics:\n");
+ HDfprintf (H5DEBUG(T),
+ " %-16s %10s %10s %8s %8s %8s %10s\n",
+ "Conversion", "Elmts", "Calls", "User",
+ "System", "Elapsed", "Bandwidth");
+ HDfprintf (H5DEBUG(T),
+ " %-16s %10s %10s %8s %8s %8s %10s\n",
+ "----------", "-----", "-----", "----",
+ "------", "-------", "---------");
+ }
+ nbytes = MAX (H5T_get_size (path->src),
+ H5T_get_size (path->dst));
+ nbytes *= path->cdata.stats->nelmts;
+ H5_bandwidth(bandwidth, (double)nbytes,
+ path->cdata.stats->timer.etime);
+ HDfprintf (H5DEBUG(T),
+ " %-16s %10Hd %10d %8.2f %8.2f %8.2f %10s\n",
+ path->name,
+ path->cdata.stats->nelmts,
+ path->cdata.stats->ncalls,
+ path->cdata.stats->timer.utime,
+ path->cdata.stats->timer.stime,
+ path->cdata.stats->timer.etime,
+ bandwidth);
}
#endif
- H5E_clear(); /*ignore the error*/
+ H5T_close (path->src);
+ H5T_close (path->dst);
+ H5MM_xfree (path->cdata.stats);
}
+ H5MM_xfree (path);
+ H5T_path_g[i] = NULL;
+ }
+
#ifdef H5T_DEBUG
- if (H5DEBUG(T) && path->cdata.stats->ncalls>0) {
+ /* Print debugging infor for the `noop' conversion */
+ if (H5DEBUG(T) &&
+ H5T_conv_noop==H5T_find(NULL, NULL, H5T_BKG_NO, &cdata)) {
+ if (cdata->stats->ncalls>0) {
if (0==nprint++) {
- HDfprintf (H5DEBUG(T), "H5T: type conversion statistics "
- "accumulated over life of function:\n");
HDfprintf (H5DEBUG(T),
- " %-16s %10s %10s %8s %8s %8s %10s\n",
- "Conversion", "Elmts", "Calls", "User",
- "System", "Elapsed", "Bandwidth");
- HDfprintf (H5DEBUG(T),
- " %-16s %10s %10s %8s %8s %8s %10s\n",
- "----------", "-----", "-----", "----",
- "------", "-------", "---------");
+ "H5T: type conversion statistics\n");
+ HDfprintf (H5DEBUG(T), " %-16s %10s %10s %8s %8s %8s "
+ "%10s\n", "Conversion", "Elmts", "Calls",
+ "User", "System", "Elapsed", "Bandwidth");
+ HDfprintf (H5DEBUG(T), " %-16s %10s %10s %8s %8s %8s "
+ "%10s\n", "----------", "-----", "-----",
+ "----", "------", "-------", "---------");
}
- nbytes = MAX (H5T_get_size (path->src),
- H5T_get_size (path->dst));
- nbytes *= path->cdata.stats->nelmts;
+ nbytes = cdata->stats->nelmts;
H5_bandwidth(bandwidth, (double)nbytes,
- path->cdata.stats->timer.etime);
+ cdata->stats->timer.etime);
HDfprintf (H5DEBUG(T),
" %-16s %10Hd %10d %8.2f %8.2f %8.2f %10s\n",
- path->name,
- path->cdata.stats->nelmts,
- path->cdata.stats->ncalls,
- path->cdata.stats->timer.utime,
- path->cdata.stats->timer.stime,
- path->cdata.stats->timer.etime,
+ "no-op",
+ cdata->stats->nelmts,
+ cdata->stats->ncalls,
+ cdata->stats->timer.utime,
+ cdata->stats->timer.stime,
+ cdata->stats->timer.etime,
bandwidth);
}
-#endif
- H5T_close (path->src);
- H5T_close (path->dst);
- H5MM_xfree (path->cdata.stats);
}
- H5MM_xfree (path);
- H5T_path_g[i] = NULL;
- }
-
-#ifdef H5T_DEBUG
- /* Print debugging infor for the `noop' conversion */
- if (H5DEBUG(T) &&
- H5T_conv_noop==H5T_find(NULL, NULL, H5T_BKG_NO, &cdata)) {
- if (cdata->stats->ncalls>0) {
- if (0==nprint++) {
- HDfprintf (H5DEBUG(T), "H5T: type conversion statistics "
- "accumulated over life of library:\n");
- HDfprintf (H5DEBUG(T), " %-16s %10s %10s %8s %8s %8s %10s\n",
- "Conversion", "Elmts", "Calls", "User",
- "System", "Elapsed", "Bandwidth");
- HDfprintf (H5DEBUG(T), " %-16s %10s %10s %8s %8s %8s %10s\n",
- "----------", "-----", "-----", "----",
- "------", "-------", "---------");
- }
- nbytes = cdata->stats->nelmts;
- H5_bandwidth(bandwidth, (double)nbytes, cdata->stats->timer.etime);
- HDfprintf (H5DEBUG(T),
- " %-16s %10Hd %10d %8.2f %8.2f %8.2f %10s\n",
- "no-op",
- cdata->stats->nelmts,
- cdata->stats->ncalls,
- cdata->stats->timer.utime,
- cdata->stats->timer.stime,
- cdata->stats->timer.etime,
- bandwidth);
- }
- }
#endif
- /* Clear conversion tables */
- H5T_apath_g = 0;
- H5T_npath_g = 0;
- H5T_path_g = H5MM_xfree (H5T_path_g);
+ /* Clear conversion tables */
+ H5T_apath_g = 0;
+ H5T_npath_g = 0;
+ H5T_path_g = H5MM_xfree (H5T_path_g);
- H5T_asoft_g = 0;
- H5T_nsoft_g = 0;
- H5T_soft_g = H5MM_xfree (H5T_soft_g);
+ H5T_asoft_g = 0;
+ H5T_nsoft_g = 0;
+ H5T_soft_g = H5MM_xfree (H5T_soft_g);
- /* Clear noop function */
- if ((cfunc=H5T_find (NULL, NULL, H5T_BKG_NO, &pcdata))) {
- pcdata->command = H5T_CONV_FREE;
- (cfunc)(FAIL, FAIL, pcdata, 0, NULL, NULL);
- }
+ /* Clear noop function */
+ if ((cfunc=H5T_find (NULL, NULL, H5T_BKG_NO, &pcdata))) {
+ pcdata->command = H5T_CONV_FREE;
+ (cfunc)(FAIL, FAIL, pcdata, 0, NULL, NULL);
+ }
- /* Unlock all datatypes, then free them */
- H5I_search (H5I_DATATYPE, H5T_unlock_cb, NULL);
- H5I_destroy_group(H5I_DATATYPE);
- interface_initialize_g = FALSE;
+ /* Unlock all datatypes, then free them */
+ H5I_search (H5I_DATATYPE, H5T_unlock_cb, NULL);
+ H5I_destroy_group(H5I_DATATYPE);
+ }
+
+ interface_initialize_g = status;
}
diff --git a/src/H5TB.c b/src/H5TB.c
index de6473c..93b87d6 100644
--- a/src/H5TB.c
+++ b/src/H5TB.c
@@ -43,9 +43,8 @@ static char RcsId[] = "@(#)$Revision$";
/* Interface init/term information */
#define PABLO_MASK H5TB_mask
#define INTERFACE_INIT H5TB_init_interface
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
static herr_t H5TB_init_interface(void);
-static void H5TB_term_interface(void);
/* Local information for managing buffers */
#define H5TB_RESERVED_ATOMS 0
@@ -80,15 +79,15 @@ DESCRIPTION
static herr_t
H5TB_init_interface(void)
{
- herr_t ret_value = SUCCEED;
FUNC_ENTER(H5TB_init_interface, FAIL);
/* Initialize the atom group for the file IDs */
- if ((ret_value = H5I_init_group(H5I_TEMPBUF, H5I_TEMPBUFID_HASHSIZE,
- H5TB_RESERVED_ATOMS, NULL)) >= 0) {
- ret_value = H5_add_exit(&H5TB_term_interface);
+ if (H5I_init_group(H5I_TEMPBUF, H5I_TEMPBUFID_HASHSIZE,
+ H5TB_RESERVED_ATOMS, NULL)<0) {
+ HRETURN_ERROR (H5E_INTERNAL, H5E_CANTINIT, FAIL,
+ "unable to initialize interface");
}
- FUNC_LEAVE(ret_value);
+ FUNC_LEAVE(SUCCEED);
}
@@ -109,29 +108,32 @@ H5TB_init_interface(void)
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-static void
-H5TB_term_interface(void)
+void
+H5TB_term_interface(intn status)
{
H5TB_t *curr=H5TB_list_head, /* pointer to current temp. buffer */
*next; /* pointer to next temp. buffer */
- /* Destroy the atom group */
- H5I_destroy_group(H5I_TEMPBUF);
+ if (interface_initialize_g>0) {
+ /* Destroy the atom group */
+ H5I_destroy_group(H5I_TEMPBUF);
- /* Step through the list and free the buffers */
- while(curr!=NULL) {
- next=curr->next;
+ /* Step through the list and free the buffers */
+ while(curr!=NULL) {
+ next=curr->next;
- if(curr->buf!=NULL)
- H5MM_xfree(curr->buf);
- H5MM_xfree(curr);
+ if(curr->buf!=NULL)
+ H5MM_xfree(curr->buf);
+ H5MM_xfree(curr);
- curr=next;
- } /* end while */
+ curr=next;
+ } /* end while */
- /* Reset head & tail pointers */
- H5TB_list_head=H5TB_list_tail=NULL;
- interface_initialize_g = FALSE;
+ /* Reset head & tail pointers */
+ H5TB_list_head=H5TB_list_tail=NULL;
+ }
+
+ interface_initialize_g = status;
}
/*-------------------------------------------------------------------------
diff --git a/src/H5Tbit.c b/src/H5Tbit.c
index 6a5474d..ed074ab 100644
--- a/src/H5Tbit.c
+++ b/src/H5Tbit.c
@@ -17,7 +17,7 @@
/* Interface initialization */
#define PABLO_MASK H5Tbit_mask
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
diff --git a/src/H5Tconv.c b/src/H5Tconv.c
index a1fc1aa..481437e 100644
--- a/src/H5Tconv.c
+++ b/src/H5Tconv.c
@@ -26,7 +26,7 @@ typedef struct H5T_conv_struct_t {
} H5T_conv_struct_t;
/* Interface initialization */
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
/*
diff --git a/src/H5V.c b/src/H5V.c
index 6504ed0..15cf867 100644
--- a/src/H5V.c
+++ b/src/H5V.c
@@ -13,7 +13,7 @@
#define H5V_HYPER_NDIMS H5O_LAYOUT_NDIMS
#define PABLO_MASK H5V_mask
-static hbool_t interface_initialize_g = TRUE;
+static intn interface_initialize_g = 0;
#define INTERFACE_INIT NULL
diff --git a/src/H5Z.c b/src/H5Z.c
index 1a52b78..c9c6d13 100644
--- a/src/H5Z.c
+++ b/src/H5Z.c
@@ -20,9 +20,8 @@
/* Interface initialization */
#define PABLO_MASK H5Z_mask
#define INTERFACE_INIT H5Z_init_interface
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = 0;
static herr_t H5Z_init_interface (void);
-static void H5Z_term_interface (void);
static size_t H5Z_table_alloc_g = 0;
static size_t H5Z_table_used_g = 0;
@@ -52,10 +51,8 @@ static herr_t
H5Z_init_interface (void)
{
FUNC_ENTER (H5Z_init_interface, FAIL);
- H5_add_exit (H5Z_term_interface);
- H5Z_register (H5Z_FILTER_DEFLATE, "deflate",
- H5Z_filter_deflate);
+ H5Z_register (H5Z_FILTER_DEFLATE, "deflate", H5Z_filter_deflate);
FUNC_LEAVE (SUCCEED);
}
@@ -75,69 +72,73 @@ H5Z_init_interface (void)
*
*-------------------------------------------------------------------------
*/
-static void
-H5Z_term_interface (void)
+void
+H5Z_term_interface (intn status)
{
size_t i;
-
#ifdef H5Z_DEBUG
int dir, nprint=0;
char comment[16], bandwidth[32];
+#endif
- if (H5DEBUG(Z)) {
- for (i=0; i<H5Z_table_used_g; i++) {
- for (dir=0; dir<2; dir++) {
- if (0==H5Z_table_g[i].stats[dir].total) continue;
-
- if (0==nprint++) {
- /* Print column headers */
- HDfprintf (H5DEBUG(Z), "H5Z: filter statistics "
- "accumulated over life of library:\n");
- HDfprintf (H5DEBUG(Z),
- " %-16s %10s %10s %8s %8s %8s %10s\n",
- "Filter", "Total", "Errors", "User",
- "System", "Elapsed", "Bandwidth");
+ if (interface_initialize_g>0) {
+#ifdef H5Z_DEBUG
+ if (H5DEBUG(Z)) {
+ for (i=0; i<H5Z_table_used_g; i++) {
+ for (dir=0; dir<2; dir++) {
+ if (0==H5Z_table_g[i].stats[dir].total) continue;
+
+ if (0==nprint++) {
+ /* Print column headers */
+ HDfprintf (H5DEBUG(Z), "H5Z: filter statistics "
+ "accumulated over life of library:\n");
+ HDfprintf (H5DEBUG(Z),
+ " %-16s %10s %10s %8s %8s %8s %10s\n",
+ "Filter", "Total", "Errors", "User",
+ "System", "Elapsed", "Bandwidth");
+ HDfprintf (H5DEBUG(Z),
+ " %-16s %10s %10s %8s %8s %8s %10s\n",
+ "------", "-----", "------", "----",
+ "------", "-------", "---------");
+ }
+
+ /* Truncate the comment to fit in the field */
+ HDstrncpy(comment, H5Z_table_g[i].name, sizeof comment);
+ comment[sizeof(comment)-1] = '\0';
+
+ /*
+ * Format bandwidth to have four significant digits and
+ * units of `B/s', `kB/s', `MB/s', `GB/s', or `TB/s' or
+ * the word `Inf' if the elapsed time is zero.
+ */
+ H5_bandwidth(bandwidth,
+ (double)(H5Z_table_g[i].stats[dir].total),
+ H5Z_table_g[i].stats[dir].timer.etime);
+
+ /* Print the statistics */
HDfprintf (H5DEBUG(Z),
- " %-16s %10s %10s %8s %8s %8s %10s\n",
- "------", "-----", "------", "----",
- "------", "-------", "---------");
+ " %s%-15s %10Hd %10Hd %8.2f %8.2f %8.2f "
+ "%10s\n", dir?"<":">", comment,
+ H5Z_table_g[i].stats[dir].total,
+ H5Z_table_g[i].stats[dir].errors,
+ H5Z_table_g[i].stats[dir].timer.utime,
+ H5Z_table_g[i].stats[dir].timer.stime,
+ H5Z_table_g[i].stats[dir].timer.etime,
+ bandwidth);
}
-
- /* Truncate the comment to fit in the field */
- HDstrncpy(comment, H5Z_table_g[i].name, sizeof comment);
- comment[sizeof(comment)-1] = '\0';
-
- /*
- * Format bandwidth to have four significant digits and units
- * of `B/s', `kB/s', `MB/s', `GB/s', or `TB/s' or the word
- * `Inf' if the elapsed time is zero.
- */
- H5_bandwidth(bandwidth,
- (double)(H5Z_table_g[i].stats[dir].total),
- H5Z_table_g[i].stats[dir].timer.etime);
-
- /* Print the statistics */
- HDfprintf (H5DEBUG(Z),
- " %s%-15s %10Hd %10Hd %8.2f %8.2f %8.2f "
- "%10s\n", dir?"<":">", comment,
- H5Z_table_g[i].stats[dir].total,
- H5Z_table_g[i].stats[dir].errors,
- H5Z_table_g[i].stats[dir].timer.utime,
- H5Z_table_g[i].stats[dir].timer.stime,
- H5Z_table_g[i].stats[dir].timer.etime,
- bandwidth);
}
}
- }
#endif
- /* Free the table */
- for (i=0; i<H5Z_table_used_g; i++) {
- H5MM_xfree(H5Z_table_g[i].name);
+ /* Free the table */
+ for (i=0; i<H5Z_table_used_g; i++) {
+ H5MM_xfree(H5Z_table_g[i].name);
+ }
+ H5Z_table_g = H5MM_xfree(H5Z_table_g);
+ H5Z_table_used_g = H5Z_table_alloc_g = 0;
}
- H5Z_table_g = H5MM_xfree(H5Z_table_g);
- H5Z_table_used_g = H5Z_table_alloc_g = 0;
- interface_initialize_g = FALSE;
+
+ interface_initialize_g = status;
}
diff --git a/src/H5detect.c b/src/H5detect.c
index 44b0486..57aa066 100644
--- a/src/H5detect.c
+++ b/src/H5detect.c
@@ -321,16 +321,16 @@ print_results(int nd, detected_t *d)
#include <H5MMprivate.h>\n\
#include <H5Tpkg.h>\n\
\n\
-static hbool_t interface_initialize_g = FALSE;\n\
+static intn interface_initialize_g = 0;\n\
#define INTERFACE_INIT NULL\n\
\n");
/* The interface termination function */
printf("\n\
-static void\n\
-H5T_native_close(void)\n\
+void\n\
+H5T_native_close(intn status)\n\
{\n\
- interface_initialize_g = FALSE;\n\
+ interface_initialize_g = status;\n\
}\n");
/* The interface initialization function */
@@ -340,8 +340,7 @@ H5T_native_open (void)\n\
{\n\
H5T_t *dt = NULL;\n\
\n\
- FUNC_ENTER (H5T_init, FAIL);\n\
- H5_add_exit(&H5T_native_close);\n");
+ FUNC_ENTER (H5T_init, FAIL);\n");
for (i = 0; i < nd; i++) {
diff --git a/src/H5private.h b/src/H5private.h
index 87d973a..1e55eb3 100644
--- a/src/H5private.h
+++ b/src/H5private.h
@@ -818,7 +818,6 @@ void H5_trace (hbool_t returning, const char *func, const char *type, ...);
*-------------------------------------------------------------------------
*/
extern hbool_t library_initialize_g; /*good thing C's lazy about extern! */
-extern hbool_t thread_initialize_g; /*don't decl interface_initialize_g */
/* Is `S' the name of an API function? */
#define H5_IS_API(S) ('_'!=S[2] && '_'!=S[3] && (!S[4] || '_'!=S[4]))
@@ -839,18 +838,9 @@ extern hbool_t thread_initialize_g; /*don't decl interface_initialize_g */
HRETURN_ERROR (H5E_FUNC, H5E_CANTINIT, err, \
"library initialization failed"); \
} \
- } \
+ } \
\
- /* Initialize this thread */ \
- if (!thread_initialize_g) { \
- thread_initialize_g = TRUE; \
- if (H5_init_thread()<0) { \
- HRETURN_ERROR (H5E_FUNC, H5E_CANTINIT, err, \
- "thread initialization failed"); \
- } \
- } \
- \
- /* Initialize this interface */ \
+ /* Initialize this interface or bust */ \
if (!interface_initialize_g) { \
interface_initialize_g = TRUE; \
if (interface_init_func && \
@@ -858,10 +848,14 @@ extern hbool_t thread_initialize_g; /*don't decl interface_initialize_g */
HRETURN_ERROR (H5E_FUNC, H5E_CANTINIT, err, \
"interface initialization failed"); \
} \
+ } else if (interface_initialize_g<0) { \
+ HRETURN_ERROR(H5E_FUNC, H5E_CANTINIT, err, \
+ "interface is closing"); \
+ assert("interface is closing" && 0); \
} \
\
/* Clear thread error stack entering public functions */ \
- if (H5E_clearable_g && H5_IS_API (FUNC)) { \
+ if (H5E_clearable_g && H5_IS_API (FUNC)) { \
H5E_clear (); \
} \
{
@@ -901,8 +895,21 @@ extern hbool_t thread_initialize_g; /*don't decl interface_initialize_g */
/* Private functions, not part of the publicly documented API */
herr_t H5_init_library(void);
void H5_term_library(void);
-herr_t H5_add_exit(void (*func) (void));
-herr_t H5_init_thread(void);
-void H5_term_thread(void);
+
+/* Functions to terminate interfaces */
+void H5A_term_interface(intn status);
+void H5D_term_interface(intn status);
+void H5F_term_interface(intn status);
+void H5G_term_interface(intn status);
+void H5I_term_interface(intn status);
+void H5P_term_interface(intn status);
+void H5RA_term_interface(intn status);
+void H5R_term_interface(intn status);
+void H5S_term_interface(intn status);
+void H5TB_term_interface(intn status);
+void H5T_native_close(intn status);
+void H5T_term_interface(intn status);
+void H5Z_term_interface(intn status);
+
#endif
diff --git a/test/.distdep b/test/.distdep
index 186cef4..b550592 100644
--- a/test/.distdep
+++ b/test/.distdep
@@ -1,11 +1,41 @@
+h5test.o: \
+ h5test.c \
+ h5test.h \
+ ../src/hdf5.h \
+ ../src/H5public.h \
+ ../src/H5config.h \
+ ../src/H5Ipublic.h \
+ ../src/H5Apublic.h \
+ ../src/H5ACpublic.h \
+ ../src/H5Bpublic.h \
+ ../src/H5Dpublic.h \
+ ../src/H5Epublic.h \
+ ../src/H5Fpublic.h \
+ ../src/H5Gpublic.h \
+ ../src/H5HGpublic.h \
+ ../src/H5HLpublic.h \
+ ../src/H5MFpublic.h \
+ ../src/H5MMpublic.h \
+ ../src/H5Opublic.h \
+ ../src/H5Ppublic.h \
+ ../src/H5Zpublic.h \
+ ../src/H5Rpublic.h \
+ ../src/H5RApublic.h \
+ ../src/H5Spublic.h \
+ ../src/H5Tpublic.h \
+ ../src/H5private.h \
+ ../src/H5Tpkg.h \
+ ../src/H5HGprivate.h \
+ ../src/H5Fprivate.h \
+ ../src/H5Rprivate.h \
+ ../src/H5Tprivate.h \
+ ../src/H5Gprivate.h
testhdf5.o: \
testhdf5.c \
testhdf5.h \
../src/H5private.h \
../src/H5public.h \
- ../src/H5config.h \
- ../src/H5Eprivate.h \
- ../src/H5Epublic.h
+ ../src/H5config.h
tattr.o: \
tattr.c \
testhdf5.h \
@@ -29,8 +59,7 @@ tattr.o: \
../src/H5Opublic.h \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
- ../src/H5Rpublic.h \
- ../src/H5RApublic.h
+ ../src/H5Rpublic.h
tfile.o: \
tfile.c \
testhdf5.h \
@@ -45,8 +74,7 @@ tfile.o: \
../src/H5Fprivate.h \
../src/H5Fpublic.h \
../src/H5Dpublic.h \
- ../src/H5Pprivate.h \
- ../src/H5Ppublic.h
+ ../src/H5Pprivate.h
theap.o: \
theap.c \
testhdf5.h \
@@ -64,8 +92,7 @@ theap.o: \
../src/H5Dpublic.h \
../src/H5Pprivate.h \
../src/H5Ppublic.h \
- ../src/H5Zpublic.h \
- ../src/H5HLprivate.h
+ ../src/H5Zpublic.h
tmeta.o: \
tmeta.c \
testhdf5.h \
@@ -74,8 +101,7 @@ tmeta.o: \
../src/H5config.h \
../src/H5Eprivate.h \
../src/H5Epublic.h \
- ../src/H5Ipublic.h \
- ../src/H5Fprivate.h
+ ../src/H5Ipublic.h
tohdr.o: \
tohdr.c \
testhdf5.h \
@@ -105,8 +131,7 @@ tohdr.o: \
../src/H5Tprivate.h \
../src/H5Tpublic.h \
../src/H5Sprivate.h \
- ../src/H5Spublic.h \
- ../src/H5Zprivate.h
+ ../src/H5Spublic.h
trefer.o: \
trefer.c \
testhdf5.h \
@@ -130,8 +155,7 @@ trefer.o: \
../src/H5Opublic.h \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
- ../src/H5Rpublic.h \
- ../src/H5RApublic.h
+ ../src/H5Rpublic.h
tselect.o: \
tselect.c \
testhdf5.h \
@@ -155,8 +179,7 @@ tselect.o: \
../src/H5Opublic.h \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
- ../src/H5Rpublic.h \
- ../src/H5RApublic.h
+ ../src/H5Rpublic.h
tstab.o: \
tstab.c \
testhdf5.h \
@@ -186,8 +209,7 @@ tstab.o: \
../src/H5Tprivate.h \
../src/H5Tpublic.h \
../src/H5Sprivate.h \
- ../src/H5Spublic.h \
- ../src/H5Zprivate.h
+ ../src/H5Spublic.h
th5s.o: \
th5s.c \
testhdf5.h \
@@ -212,12 +234,15 @@ th5s.o: \
../src/H5HGpublic.h \
../src/H5Tprivate.h \
../src/H5Tpublic.h \
- ../src/H5Zprivate.h
+ ../src/H5Zprivate.h \
+ ../src/H5Zpublic.h \
+ ../src/H5Pprivate.h
dtypes.o: \
dtypes.c \
- ../src/H5config.h \
+ h5test.h \
../src/hdf5.h \
../src/H5public.h \
+ ../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
@@ -237,17 +262,18 @@ dtypes.o: \
../src/H5RApublic.h \
../src/H5Spublic.h \
../src/H5Tpublic.h \
+ ../src/H5private.h \
../src/H5Tpkg.h \
../src/H5HGprivate.h \
../src/H5Fprivate.h \
- ../src/H5private.h \
- ../src/H5Rprivate.h
+ ../src/H5Rprivate.h \
+ ../src/H5Tprivate.h \
+ ../src/H5Gprivate.h
hyperslab.o: \
hyperslab.c \
../src/H5private.h \
../src/H5public.h \
- ../src/H5config.h \
- ../src/H5MMprivate.h
+ ../src/H5config.h
istore.o: \
istore.c \
../src/H5private.h \
@@ -274,12 +300,15 @@ istore.o: \
../src/H5Zpublic.h \
../src/H5Iprivate.h \
../src/H5Pprivate.h \
- ../src/H5Ppublic.h
+ ../src/H5Ppublic.h \
+ ../src/H5MMprivate.h \
+ ../src/H5MMpublic.h
dsets.o: \
dsets.c \
- ../src/H5config.h \
+ h5test.h \
../src/hdf5.h \
../src/H5public.h \
+ ../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
@@ -296,12 +325,22 @@ dsets.o: \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
../src/H5Rpublic.h \
- ../src/H5RApublic.h
+ ../src/H5RApublic.h \
+ ../src/H5Spublic.h \
+ ../src/H5Tpublic.h \
+ ../src/H5private.h \
+ ../src/H5Tpkg.h \
+ ../src/H5HGprivate.h \
+ ../src/H5Fprivate.h \
+ ../src/H5Rprivate.h \
+ ../src/H5Tprivate.h \
+ ../src/H5Gprivate.h
cmpd_dset.o: \
cmpd_dset.c \
- ../src/H5config.h \
+ h5test.h \
../src/hdf5.h \
../src/H5public.h \
+ ../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
@@ -317,34 +356,23 @@ cmpd_dset.o: \
../src/H5Opublic.h \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
- ../src/H5Rpublic.h
+ ../src/H5Rpublic.h \
+ ../src/H5RApublic.h \
+ ../src/H5Spublic.h \
+ ../src/H5Tpublic.h \
+ ../src/H5private.h \
+ ../src/H5Tpkg.h \
+ ../src/H5HGprivate.h \
+ ../src/H5Fprivate.h \
+ ../src/H5Rprivate.h \
+ ../src/H5Tprivate.h \
+ ../src/H5Gprivate.h
extend.o: \
extend.c \
- ../src/H5config.h \
+ h5test.h \
../src/hdf5.h \
../src/H5public.h \
- ../src/H5Ipublic.h \
- ../src/H5Apublic.h \
- ../src/H5ACpublic.h \
- ../src/H5Bpublic.h \
- ../src/H5Dpublic.h \
- ../src/H5Epublic.h \
- ../src/H5Fpublic.h \
- ../src/H5Gpublic.h \
- ../src/H5HGpublic.h \
- ../src/H5HLpublic.h \
- ../src/H5MFpublic.h \
- ../src/H5MMpublic.h \
- ../src/H5Opublic.h \
- ../src/H5Ppublic.h \
- ../src/H5Zpublic.h \
- ../src/H5Rpublic.h \
- ../src/H5RApublic.h
-external.o: \
- external.c \
../src/H5config.h \
- ../src/hdf5.h \
- ../src/H5public.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
@@ -360,12 +388,23 @@ external.o: \
../src/H5Opublic.h \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
- ../src/H5Rpublic.h
+ ../src/H5Rpublic.h \
+ ../src/H5RApublic.h \
+ ../src/H5Spublic.h \
+ ../src/H5Tpublic.h \
+ ../src/H5private.h \
+ ../src/H5Tpkg.h \
+ ../src/H5HGprivate.h \
+ ../src/H5Fprivate.h \
+ ../src/H5Rprivate.h \
+ ../src/H5Tprivate.h \
+ ../src/H5Gprivate.h
+
iopipe.o: \
iopipe.c \
- ../src/H5config.h \
../src/hdf5.h \
../src/H5public.h \
+ ../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
@@ -382,7 +421,9 @@ iopipe.o: \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
../src/H5Rpublic.h \
- ../src/H5RApublic.h
+ ../src/H5RApublic.h \
+ ../src/H5Spublic.h \
+ ../src/H5Tpublic.h
gheap.o: \
gheap.c \
../src/H5private.h \
@@ -399,13 +440,12 @@ gheap.o: \
../src/H5Bprivate.h \
../src/H5Bpublic.h \
../src/H5HGprivate.h \
- ../src/H5HGpublic.h \
- ../src/H5Pprivate.h
+ ../src/H5HGpublic.h
shtype.o: \
shtype.c \
- ../src/H5config.h \
../src/hdf5.h \
../src/H5public.h \
+ ../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
@@ -422,12 +462,14 @@ shtype.o: \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
../src/H5Rpublic.h \
- ../src/H5RApublic.h
+ ../src/H5RApublic.h \
+ ../src/H5Spublic.h \
+ ../src/H5Tpublic.h
big.o: \
big.c \
- ../src/H5config.h \
../src/hdf5.h \
../src/H5public.h \
+ ../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
@@ -450,9 +492,9 @@ big.o: \
../src/H5private.h
links.o: \
links.c \
- ../src/H5config.h \
../src/hdf5.h \
../src/H5public.h \
+ ../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
@@ -469,12 +511,14 @@ links.o: \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
../src/H5Rpublic.h \
- ../src/H5RApublic.h
+ ../src/H5RApublic.h \
+ ../src/H5Spublic.h \
+ ../src/H5Tpublic.h
chunk.o: \
chunk.c \
- ../src/H5config.h \
../src/hdf5.h \
../src/H5public.h \
+ ../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
@@ -490,30 +534,47 @@ chunk.o: \
../src/H5Opublic.h \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
- ../src/H5Rpublic.h
+ ../src/H5Rpublic.h \
+ ../src/H5RApublic.h \
+ ../src/H5Spublic.h \
+ ../src/H5Tpublic.h
bittests.o: \
bittests.c \
- ../src/H5Tpkg.h \
- ../src/H5HGprivate.h \
- ../src/H5HGpublic.h \
+ h5test.h \
+ ../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
- ../src/H5Fprivate.h \
- ../src/H5Fpublic.h \
../src/H5Ipublic.h \
- ../src/H5private.h \
+ ../src/H5Apublic.h \
+ ../src/H5ACpublic.h \
+ ../src/H5Bpublic.h \
../src/H5Dpublic.h \
- ../src/H5Rprivate.h \
+ ../src/H5Epublic.h \
+ ../src/H5Fpublic.h \
+ ../src/H5Gpublic.h \
+ ../src/H5HGpublic.h \
+ ../src/H5HLpublic.h \
+ ../src/H5MFpublic.h \
+ ../src/H5MMpublic.h \
+ ../src/H5Opublic.h \
+ ../src/H5Ppublic.h \
+ ../src/H5Zpublic.h \
../src/H5Rpublic.h \
- ../src/H5Tprivate.h \
+ ../src/H5RApublic.h \
+ ../src/H5Spublic.h \
../src/H5Tpublic.h \
- ../src/H5Gprivate.h \
- ../src/H5Gpublic.h
+ ../src/H5private.h \
+ ../src/H5Tpkg.h \
+ ../src/H5HGprivate.h \
+ ../src/H5Fprivate.h \
+ ../src/H5Rprivate.h \
+ ../src/H5Tprivate.h \
+ ../src/H5Gprivate.h
mtime.o: \
mtime.c \
- ../src/H5config.h \
../src/hdf5.h \
../src/H5public.h \
+ ../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
@@ -536,9 +597,9 @@ mtime.o: \
../src/H5private.h
ragged.o: \
ragged.c \
- ../src/H5config.h \
../src/hdf5.h \
../src/H5public.h \
+ ../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
@@ -561,9 +622,9 @@ ragged.o: \
../src/H5private.h
unlink.o: \
unlink.c \
- ../src/H5config.h \
../src/hdf5.h \
../src/H5public.h \
+ ../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
@@ -579,12 +640,13 @@ unlink.o: \
../src/H5Opublic.h \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
- ../src/H5Rpublic.h
+ ../src/H5Rpublic.h \
+ ../src/H5RApublic.h
overhead.o: \
overhead.c \
- ../src/H5config.h \
../src/hdf5.h \
../src/H5public.h \
+ ../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
@@ -602,12 +664,13 @@ overhead.o: \
../src/H5Zpublic.h \
../src/H5Rpublic.h \
../src/H5RApublic.h \
- ../src/H5Spublic.h
+ ../src/H5Spublic.h \
+ ../src/H5Tpublic.h
fillval.o: \
fillval.c \
- ../src/H5config.h \
../src/hdf5.h \
../src/H5public.h \
+ ../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
@@ -625,12 +688,13 @@ fillval.o: \
../src/H5Zpublic.h \
../src/H5Rpublic.h \
../src/H5RApublic.h \
- ../src/H5Spublic.h
+ ../src/H5Spublic.h \
+ ../src/H5Tpublic.h
mount.o: \
mount.c \
- ../src/H5config.h \
../src/hdf5.h \
../src/H5public.h \
+ ../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
@@ -646,12 +710,13 @@ mount.o: \
../src/H5Opublic.h \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
- ../src/H5Rpublic.h
+ ../src/H5Rpublic.h \
+ ../src/H5RApublic.h
flush1.o: \
flush1.c \
- ../src/H5config.h \
../src/hdf5.h \
../src/H5public.h \
+ ../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
@@ -668,12 +733,14 @@ flush1.o: \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
../src/H5Rpublic.h \
- ../src/H5RApublic.h
+ ../src/H5RApublic.h \
+ ../src/H5Spublic.h \
+ ../src/H5Tpublic.h
flush2.o: \
flush2.c \
- ../src/H5config.h \
../src/hdf5.h \
../src/H5public.h \
+ ../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
@@ -690,4 +757,6 @@ flush2.o: \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
../src/H5Rpublic.h \
- ../src/H5RApublic.h
+ ../src/H5RApublic.h \
+ ../src/H5Spublic.h \
+ ../src/H5Tpublic.h
diff --git a/test/Makefile.in b/test/Makefile.in
index 2003916..b8d00ab 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -9,7 +9,7 @@
# Add include directory to the C preprocessor flags and the hdf5
# library to the library list.
CPPFLAGS=-I. -I../src @CPPFLAGS@
-LIBS=../src/libhdf5.a @LIBS@
+LIBS=libh5test.a ../src/libhdf5.a @LIBS@
# These are our main targets. They should be listed in the order to be
# executed, generally most specific tests to least specific tests.
@@ -18,6 +18,11 @@ TEST_PROGS=testhdf5 gheap hyperslab istore bittests dtypes dsets cmpd_dset \
flush2
TIMINGS=iopipe chunk ragged overhead
+# The libh5test.a library provides common support code for the tests.
+LIB=libh5test.a
+LIB_SRC=h5test.c
+LIB_OBJ=$(LIB_SRC:.c=.o)
+
# Temporary files
MOSTLYCLEAN=cmpd_dset.h5 dataset.h5 extend.h5 istore.h5 tfile1.h5 tfile2.h5 \
tfile3.h5 th5s1.h5 theap.h5 tohdr.h5 tstab1.h5 tstab2.h5 \
@@ -55,8 +60,8 @@ timings _timings: $(TIMINGS)
fi; \
done;
-# How to build the tests... They all depend on the hdf5 library.
-$(TEST_PROGS): ../src/libhdf5.a
+# How to build the tests... They all depend on the test and hdf5 libraries.
+$(TEST_PROGS): libh5test.a ../src/libhdf5.a
TESTHDF5_OBJ=testhdf5.o tattr.o tfile.o theap.o tmeta.o tohdr.o trefer.o tselect.o tstab.o th5s.o
testhdf5: $(TESTHDF5_OBJ)
$(CC) $(CFLAGS) -o $@ $(TESTHDF5_OBJ) $(LDFLAGS) $(LIBS)
diff --git a/test/bittests.c b/test/bittests.c
index 6b1f1d9..2c8daef 100644
--- a/test/bittests.c
+++ b/test/bittests.c
@@ -7,6 +7,8 @@
*
* Purpose: Tests functions in H5Tbit.c
*/
+#include <h5test.h>
+
#define H5T_PACKAGE
#include <H5Tpkg.h>
@@ -38,21 +40,20 @@ test_find (void)
intn i;
ssize_t n;
- printf ("%-70s", "Testing bit search operations");
- fflush (stdout);
+ TESTING("bit search operations");
/* The zero length buffer */
memset (v1, 0xaa, sizeof v1);
n = H5T_bit_find (v1, 0, 0, H5T_BIT_LSB, TRUE);
if (-1!=n) {
- puts ("*FAILED*");
- puts (" Zero length test failed (lsb)!");
+ FAILED();
+ puts (" Zero length test failed (lsb)!");
goto failed;
}
n = H5T_bit_find (v1, 0, 0, H5T_BIT_MSB, TRUE);
if (-1!=n) {
- puts ("*FAILED*");
- puts (" Zero length test failed (msb)!");
+ FAILED();
+ puts (" Zero length test failed (msb)!");
goto failed;
}
@@ -61,14 +62,14 @@ test_find (void)
memset (v1, 0, sizeof v1);
n = H5T_bit_find (v1, 0, 8*sizeof(v1), H5T_BIT_LSB, TRUE);
if (-1!=n) {
- puts ("*FAILED*");
- puts (" Zero buffer test failed (lsb)!");
+ FAILED();
+ puts (" Zero buffer test failed (lsb)!");
goto failed;
}
n = H5T_bit_find (v1, 0, 8*sizeof(v1), H5T_BIT_MSB, TRUE);
if (-1!=n) {
- puts ("*FAILED*");
- puts (" Zero buffer test failed (msb)!");
+ FAILED();
+ puts (" Zero buffer test failed (msb)!");
goto failed;
}
@@ -78,14 +79,14 @@ test_find (void)
v1[i/8] = 1<<(i%8);
n = H5T_bit_find (v1, 0, 8*sizeof(v1), H5T_BIT_LSB, TRUE);
if ((ssize_t)i!=n) {
- puts ("*FAILED*");
- printf (" Test for set bit %d failed (lsb)!\n", i);
+ FAILED();
+ printf (" Test for set bit %d failed (lsb)!\n", i);
goto failed;
}
n = H5T_bit_find (v1, 0, 8*sizeof(v1), H5T_BIT_MSB, TRUE);
if ((ssize_t)i!=n) {
- puts ("*FAILED*");
- printf (" Test for set bit %d failed (msb)!\n", i);
+ FAILED();
+ printf (" Test for set bit %d failed (msb)!\n", i);
goto failed;
}
}
@@ -94,14 +95,14 @@ test_find (void)
memset (v1, 0xff, sizeof v1);
n = H5T_bit_find (v1, 0, 8*sizeof(v1), H5T_BIT_LSB, FALSE);
if (-1!=n) {
- puts ("*FAILED*");
- puts (" One buffer test failed (lsb)!");
+ FAILED();
+ puts (" One buffer test failed (lsb)!");
goto failed;
}
n = H5T_bit_find (v1, 0, 8*sizeof(v1), H5T_BIT_MSB, FALSE);
if (-1!=n) {
- puts ("*FAILED*");
- puts (" One buffer test failed (msb)!");
+ FAILED();
+ puts (" One buffer test failed (msb)!");
goto failed;
}
@@ -111,24 +112,24 @@ test_find (void)
v1[i/8] &= ~(1<<(i%8));
n = H5T_bit_find (v1, 0, 8*sizeof(v1), H5T_BIT_LSB, FALSE);
if ((ssize_t)i!=n) {
- puts ("*FAILED*");
- printf (" Test for clear bit %d failed (lsb)!\n", i);
+ FAILED();
+ printf (" Test for clear bit %d failed (lsb)!\n", i);
goto failed;
}
n = H5T_bit_find (v1, 0, 8*sizeof(v1), H5T_BIT_MSB, FALSE);
if ((ssize_t)i!=n) {
- puts ("*FAILED*");
- printf (" Test for clear bit %d failed (lsb)!\n", i);
+ FAILED();
+ printf (" Test for clear bit %d failed (lsb)!\n", i);
goto failed;
}
}
- puts (" PASSED");
+ PASSED();
return 0;
failed:
- printf (" v = 0x");
+ printf (" v = 0x");
for (i=0; i<(int)sizeof(v1); i++) printf ("%02x", v1[i]);
printf ("\n");
return -1;
@@ -159,8 +160,7 @@ test_copy (void)
intn i, j;
ssize_t n;
- printf ("%-70s", "Testing bit copy operations");
- fflush (stdout);
+ TESTING("bit copy operations");
for (i=0; i<NTESTS; i++) {
s_offset = rand() % (8*sizeof v1);
@@ -174,13 +174,13 @@ test_copy (void)
H5T_bit_copy (v2, d_offset, v1, s_offset, size);
for (j=0; j<(intn)sizeof(v2); j++) if (v2[j]) break;
if (size>0 && j>=(intn)sizeof(v2)) {
- puts ("*FAILED*");
- puts (" Unabled to find copied region in destination");
+ FAILED();
+ puts (" Unabled to find copied region in destination");
goto failed;
}
if (0==size && j<(intn)sizeof(v2)) {
- puts ("*FAILED*");
- puts (" Found copied bits when we shouldn't have");
+ FAILED();
+ puts (" Found copied bits when we shouldn't have");
goto failed;
}
@@ -188,26 +188,26 @@ test_copy (void)
/* Look for the zeros and ones */
n = H5T_bit_find (v2, 0, 8*sizeof(v2), H5T_BIT_LSB, 1);
if (size>0 && n!=(ssize_t)d_offset) {
- puts ("*FAILED*");
- printf (" Unable to find first copied bit in destination "
+ FAILED();
+ printf (" Unable to find first copied bit in destination "
"(n=%d)\n", (int)n);
goto failed;
}
if (0==size && n>=0) {
- puts ("*FAILED*");
- puts (" Found copied bits and shouldn't have!");
+ FAILED();
+ puts (" Found copied bits and shouldn't have!");
goto failed;
}
n = H5T_bit_find (v2, d_offset, 8*sizeof(v2)-d_offset, H5T_BIT_LSB, 0);
if (d_offset+size<8*sizeof(v2) && n!=(ssize_t)size) {
- puts ("*FAILED*");
- printf (" Unable to find last copied bit in destination "
+ FAILED();
+ printf (" Unable to find last copied bit in destination "
"(n=%d)\n", (int)n);
goto failed;
}
if (d_offset+size==8*sizeof(v2) && n>=0) {
- puts ("*FAILED*");
- puts (" High-order zeros are present and shouldn't be!");
+ FAILED();
+ puts (" High-order zeros are present and shouldn't be!");
goto failed;
}
@@ -217,41 +217,41 @@ test_copy (void)
*/
n = H5T_bit_find (v2, 0, 8*sizeof(v2), H5T_BIT_MSB, 1);
if (size>0 && (size_t)(n+1)!=d_offset+size) {
- puts ("*FAILED*");
- printf (" Unable to find last copied bit in destination "
+ FAILED();
+ printf (" Unable to find last copied bit in destination "
"(reverse, n=%d)\n", (int)n);
goto failed;
}
if (0==size && n>=0) {
- puts ("*FAILED*");
- puts (" Found copied bits but shouldn't have (reverse)!");
+ FAILED();
+ puts (" Found copied bits but shouldn't have (reverse)!");
goto failed;
}
n = H5T_bit_find (v2, 0, d_offset+size, H5T_BIT_MSB, 0);
if (d_offset>0 && n+1!=(ssize_t)d_offset) {
- puts ("*FAILED*");
- printf (" Unable to find beginning of copied data "
+ FAILED();
+ printf (" Unable to find beginning of copied data "
"(reverse, n=%d)\n", (int)n);
goto failed;
}
if (0==d_offset && n>=0) {
- puts ("*FAILED*");
- puts (" Found leading original data but shouldn't have!");
+ FAILED();
+ puts (" Found leading original data but shouldn't have!");
goto failed;
}
}
- puts (" PASSED");
+ PASSED();
return 0;
failed:
- printf (" i=%d, s_offset=%lu, d_offset=%lu, size=%lu\n",
+ printf (" i=%d, s_offset=%lu, d_offset=%lu, size=%lu\n",
i, (unsigned long)s_offset, (unsigned long)d_offset,
(unsigned long)size);
- printf (" s = 0x");
+ printf (" s = 0x");
for (j=sizeof(v1)-1; j>=0; --j) printf ("%02x", v1[j]);
- printf ("\n d = 0x");
+ printf ("\n d = 0x");
for (j=sizeof(v2)-1; j>=0; --j) printf ("%02x", v2[j]);
printf ("\n");
return -1;
@@ -282,8 +282,7 @@ test_set (void)
intn i, j;
ssize_t n;
- printf ("%-70s", "Testing bit set operations");
- fflush (stdout);
+ TESTING("bit set operations");
for (i=0; i<NTESTS; i++) {
d_offset = rand() % (8*sizeof v2);
@@ -295,13 +294,13 @@ test_set (void)
H5T_bit_set (v2, d_offset, size, TRUE);
for (j=0; j<(intn)sizeof(v2); j++) if (v2[j]) break;
if (size>0 && j>=(intn)sizeof(v2)) {
- puts ("*FAILED*");
- puts (" Unabled to find set region in buffer");
+ FAILED();
+ puts (" Unabled to find set region in buffer");
goto failed;
}
if (0==size && j<(intn)sizeof(v2)) {
- puts ("*FAILED*");
- puts (" Found set bits when we shouldn't have");
+ FAILED();
+ puts (" Found set bits when we shouldn't have");
goto failed;
}
@@ -309,26 +308,26 @@ test_set (void)
/* Look for the zeros and ones */
n = H5T_bit_find (v2, 0, 8*sizeof(v2), H5T_BIT_LSB, 1);
if (size>0 && n!=(ssize_t)d_offset) {
- puts ("*FAILED*");
- printf (" Unable to find first set bit in destination "
+ FAILED();
+ printf (" Unable to find first set bit in destination "
"(n=%d)\n", (int)n);
goto failed;
}
if (0==size && n>=0) {
- puts ("*FAILED*");
- puts (" Found set bits and shouldn't have!");
+ FAILED();
+ puts (" Found set bits and shouldn't have!");
goto failed;
}
n = H5T_bit_find (v2, d_offset, 8*sizeof(v2)-d_offset, H5T_BIT_LSB, 0);
if (d_offset+size<8*sizeof(v2) && n!=(ssize_t)size) {
- puts ("*FAILED*");
- printf (" Unable to find last set bit in destination "
+ FAILED();
+ printf (" Unable to find last set bit in destination "
"(n=%d)\n", (int)n);
goto failed;
}
if (d_offset+size==8*sizeof(v2) && n>=0) {
- puts ("*FAILED*");
- puts (" High-order zeros are present and shouldn't be!");
+ FAILED();
+ puts (" High-order zeros are present and shouldn't be!");
goto failed;
}
@@ -338,38 +337,38 @@ test_set (void)
*/
n = H5T_bit_find (v2, 0, 8*sizeof(v2), H5T_BIT_MSB, 1);
if (size>0 && (size_t)(n+1)!=d_offset+size) {
- puts ("*FAILED*");
- printf (" Unable to find last set bit in destination "
+ FAILED();
+ printf (" Unable to find last set bit in destination "
"(reverse, n=%d)\n", (int)n);
goto failed;
}
if (0==size && n>=0) {
- puts ("*FAILED*");
- puts (" Found set bits but shouldn't have (reverse)!");
+ FAILED();
+ puts (" Found set bits but shouldn't have (reverse)!");
goto failed;
}
n = H5T_bit_find (v2, 0, d_offset+size, H5T_BIT_MSB, 0);
if (d_offset>0 && n+1!=(ssize_t)d_offset) {
- puts ("*FAILED*");
- printf (" Unable to find beginning of set bit region "
+ FAILED();
+ printf (" Unable to find beginning of set bit region "
"(reverse, n=%d)\n", (int)n);
goto failed;
}
if (0==d_offset && n>=0) {
- puts ("*FAILED*");
- puts (" Found leading zeros but shouldn't have!");
+ FAILED();
+ puts (" Found leading zeros but shouldn't have!");
goto failed;
}
}
- puts (" PASSED");
+ PASSED();
return 0;
failed:
- printf (" i=%d, d_offset=%lu, size=%lu\n",
+ printf (" i=%d, d_offset=%lu, size=%lu\n",
i, (unsigned long)d_offset, (unsigned long)size);
- printf (" d = 0x");
+ printf (" d = 0x");
for (j=sizeof(v2)-1; j>=0; --j) printf ("%02x", v2[j]);
printf ("\n");
return -1;
@@ -400,8 +399,7 @@ test_clear (void)
intn i, j;
ssize_t n;
- printf ("%-70s", "Testing bit clear operations");
- fflush (stdout);
+ TESTING("bit clear operations");
for (i=0; i<NTESTS; i++) {
d_offset = rand() % (8*sizeof v2);
@@ -413,13 +411,13 @@ test_clear (void)
H5T_bit_set (v2, d_offset, size, FALSE);
for (j=0; j<(intn)sizeof(v2); j++) if (0xff!=v2[j]) break;
if (size>0 && j>=(intn)sizeof(v2)) {
- puts ("*FAILED*");
- puts (" Unabled to find cleared region in buffer");
+ FAILED();
+ puts (" Unabled to find cleared region in buffer");
goto failed;
}
if (0==size && j<(intn)sizeof(v2)) {
- puts ("*FAILED*");
- puts (" Found cleared bits when we shouldn't have");
+ FAILED();
+ puts (" Found cleared bits when we shouldn't have");
goto failed;
}
@@ -427,26 +425,26 @@ test_clear (void)
/* Look for the zeros and ones */
n = H5T_bit_find (v2, 0, 8*sizeof(v2), H5T_BIT_LSB, 0);
if (size>0 && n!=(ssize_t)d_offset) {
- puts ("*FAILED*");
- printf (" Unable to find first cleared bit in destination "
+ FAILED();
+ printf (" Unable to find first cleared bit in destination "
"(n=%d)\n", (int)n);
goto failed;
}
if (0==size && n>=0) {
- puts ("*FAILED*");
- puts (" Found cleared bits and shouldn't have!");
+ FAILED();
+ puts (" Found cleared bits and shouldn't have!");
goto failed;
}
n = H5T_bit_find (v2, d_offset, 8*sizeof(v2)-d_offset, H5T_BIT_LSB, 1);
if (d_offset+size<8*sizeof(v2) && n!=(ssize_t)size) {
- puts ("*FAILED*");
- printf (" Unable to find last cleared bit in destination "
+ FAILED();
+ printf (" Unable to find last cleared bit in destination "
"(n=%d)\n", (int)n);
goto failed;
}
if (d_offset+size==8*sizeof(v2) && n>=0) {
- puts ("*FAILED*");
- puts (" High-order ones are present and shouldn't be!");
+ FAILED();
+ puts (" High-order ones are present and shouldn't be!");
goto failed;
}
@@ -456,38 +454,38 @@ test_clear (void)
*/
n = H5T_bit_find (v2, 0, 8*sizeof(v2), H5T_BIT_MSB, 0);
if (size>0 && (size_t)(n+1)!=d_offset+size) {
- puts ("*FAILED*");
- printf (" Unable to find last cleared bit in destination "
+ FAILED();
+ printf (" Unable to find last cleared bit in destination "
"(reverse, n=%d)\n", (int)n);
goto failed;
}
if (0==size && n>=0) {
- puts ("*FAILED*");
- puts (" Found cleared bits but shouldn't have (reverse)!");
+ FAILED();
+ puts (" Found cleared bits but shouldn't have (reverse)!");
goto failed;
}
n = H5T_bit_find (v2, 0, d_offset+size, H5T_BIT_MSB, 1);
if (d_offset>0 && n+1!=(ssize_t)d_offset) {
- puts ("*FAILED*");
- printf (" Unable to find beginning of cleared bit region "
+ FAILED();
+ printf (" Unable to find beginning of cleared bit region "
"(reverse, n=%d)\n", (int)n);
goto failed;
}
if (0==d_offset && n>=0) {
- puts ("*FAILED*");
- puts (" Found leading ones but shouldn't have!");
+ FAILED();
+ puts (" Found leading ones but shouldn't have!");
goto failed;
}
}
- puts (" PASSED");
+ PASSED();
return 0;
failed:
- printf (" i=%d, d_offset=%lu, size=%lu\n",
+ printf (" i=%d, d_offset=%lu, size=%lu\n",
i, (unsigned long)d_offset, (unsigned long)size);
- printf (" d = 0x");
+ printf (" d = 0x");
for (j=sizeof(v2)-1; j>=0; --j) printf ("%02x", v2[j]);
printf ("\n");
return -1;
diff --git a/test/chunk.c b/test/chunk.c
index d847db3..e119b0c 100644
--- a/test/chunk.c
+++ b/test/chunk.c
@@ -289,7 +289,7 @@ test_diag (int op, hsize_t cache_size, hsize_t io_size, hsize_t offset)
* Win32 version 5.0 compiler.
* 1998-11-06 ptl
*/
- return (double)((hssize_t)(nio/nio_g));
+ return (double)(hssize_t)nio/(hssize_t)nio_g;
}
diff --git a/test/cmpd_dset.c b/test/cmpd_dset.c
index f50966a..f3ccf39 100644
--- a/test/cmpd_dset.c
+++ b/test/cmpd_dset.c
@@ -8,24 +8,12 @@
/* See H5private.h for how to include headers */
#undef NDEBUG
-#include <hdf5.h>
+#include <h5test.h>
-#ifdef STDC_HEADERS
-# include <assert.h>
-# include <stdio.h>
-# include <stdlib.h>
-# include <string.h>
-#endif
-
-#ifndef HAVE_ATTRIBUTE
-# undef __attribute__
-# define __attribute__(X) /*void*/
-# define __unused__ /*void*/
-#else
-# define __unused__ __attribute__((unused))
-#endif
-
-#define TEST_FILE_NAME "cmpd_dset.h5"
+const char *FILENAME[] = {
+ "cmpd_dset",
+ NULL
+};
/* The first dataset */
typedef struct s1_t {
@@ -76,54 +64,6 @@ typedef struct s5_t {
# define NY 9u
#endif
-
-/*-------------------------------------------------------------------------
- * Function: cleanup
- *
- * Purpose: Cleanup temporary test files
- *
- * Return: none
- *
- * Programmer: Albert Cheng
- * May 28, 1998
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static void
-cleanup(void)
-{
- if (!getenv ("HDF5_NOCLEANUP")) {
- remove(TEST_FILE_NAME);
- }
-}
-
-
-/*-------------------------------------------------------------------------
- * Function: display_error_cb
- *
- * Purpose: Displays the error stack after printing "*FAILED*".
- *
- * Return: Success: 0
- *
- * Failure: -1
- *
- * Programmer: Robb Matzke
- * Wednesday, March 4, 1998
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-display_error_cb (void __unused__ *client_data)
-{
- puts ("*FAILED*");
- H5Eprint (stdout);
- return 0;
-}
-
/*-------------------------------------------------------------------------
* Function: main
@@ -186,18 +126,20 @@ main (void)
/* Other variables */
unsigned int i, j;
- hid_t file, dataset, space, PRESERVE;
+ hid_t file, dataset, space, PRESERVE, fapl;
static hsize_t dim[] = {NX, NY};
hssize_t f_offset[2]; /*offset of hyperslab in file */
hsize_t h_size[2]; /*size of hyperslab */
size_t memb_size[1] = {4};
+ char filename[256];
- /* Set up error handling */
- H5Eset_auto(display_error_cb, NULL);
+ h5_reset();
/* Create the file */
- if ((file = H5Fcreate (TEST_FILE_NAME, H5F_ACC_TRUNC|H5F_ACC_DEBUG,
- H5P_DEFAULT, H5P_DEFAULT))<0) goto error;
+ fapl = h5_fileaccess();
+ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
+ if ((file = H5Fcreate (filename, H5F_ACC_TRUNC|H5F_ACC_DEBUG,
+ H5P_DEFAULT, fapl))<0) goto error;
/* Create the data space */
if ((space = H5Screate_simple (2, dim, NULL))<0) goto error;
@@ -210,8 +152,7 @@ main (void)
*######################################################################
* STEP 1: Save the original dataset natively.
*/
- printf("%-70s", "Testing basic compound write");
- fflush(stdout);
+ TESTING("basic compound write");
/* Initialize the dataset */
for (i=0; i<NX*NY; i++) {
@@ -245,7 +186,7 @@ main (void)
if (H5Dwrite (dataset, s1_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, s1)<0) {
goto error;
}
- puts(" PASSED");
+ PASSED();
/*
*######################################################################
@@ -253,8 +194,7 @@ main (void)
* it's the same as the first just to test things better, but
* in fact, we could have used s1_tid.
*/
- printf("%-70s", "Testing basic compound read");
- fflush(stdout);
+ TESTING("basic compound read");
/* Create a data type for s2 */
if ((s2_tid = H5Tcreate (H5T_COMPOUND, sizeof(s2_t)))<0) goto error;
@@ -282,12 +222,12 @@ main (void)
s1[i].c[3]!=s2[i].c[3] ||
s1[i].d!=s2[i].d ||
s1[i].e!=s2[i].e) {
- puts("*FAILED*");
- puts(" Incorrect values read from the file");
+ FAILED();
+ puts(" Incorrect values read from the file");
goto error;
}
}
- puts(" PASSED");
+ PASSED();
/*
*######################################################################
@@ -295,8 +235,7 @@ main (void)
* has the same data space but the data type is different: the
* data type is a struct whose members are in the opposite order.
*/
- printf("%-70s", "Testing reversal of struct members");
- fflush (stdout);
+ TESTING("reversal of struct members");
/* Create a data type for s3 */
if ((s3_tid = H5Tcreate (H5T_COMPOUND, sizeof(s3_t)))<0) goto error;
@@ -324,20 +263,19 @@ main (void)
s1[i].c[3]!=s3[i].c[3] ||
s1[i].d!=s3[i].d ||
s1[i].e!=s3[i].e) {
- puts("*FAILED*");
- puts(" Incorrect values read from the file");
+ FAILED();
+ puts(" Incorrect values read from the file");
goto error;
}
}
- puts(" PASSED");
+ PASSED();
/*
*######################################################################
* STEP 4: Read a subset of the members. Of the <a,b,c,d,e> members
* stored on disk we'll read <b,d>.
*/
- printf("%-70s", "Testing subset struct read");
- fflush (stdout);
+ TESTING("subset struct read");
/* Create a datatype for s4 */
if ((s4_tid = H5Tcreate (H5T_COMPOUND, sizeof(s4_t)))<0) goto error;
@@ -353,20 +291,19 @@ main (void)
for (i=0; i<NX*NY; i++) {
if (s1[i].b!=s4[i].b ||
s1[i].d!=s4[i].d) {
- puts("*FAILED*");
- puts(" Incorrect values read from the file");
+ FAILED();
+ puts(" Incorrect values read from the file");
goto error;
}
}
- puts(" PASSED");
+ PASSED();
/*
*######################################################################
* STEP 5: Read all the members into a struct which has other members
* which have already been initialized.
*/
- printf("%-70s", "Testing partially initialized superset read");
- fflush(stdout);
+ TESTING("partially initialized superset read");
/* Initialize some members */
for (i=0; i<NX*NY; i++) {
@@ -402,8 +339,8 @@ main (void)
s1[i].c[3]!=s5[i].c[3] ||
s1[i].d!=s5[i].d ||
s1[i].e!=s5[i].e) {
- puts("*FAILED*");
- puts(" Incorrect values read from the file");
+ FAILED();
+ puts(" Incorrect values read from the file");
goto error;
}
}
@@ -414,12 +351,12 @@ main (void)
s5[i].mid1 != 1001+4*i ||
s5[i].mid2 != 1002+4*i ||
s5[i].post != 1003+4*i) {
- puts("*FAILED*");
- puts(" Memory values were clobbered");
+ FAILED();
+ puts(" Memory values were clobbered");
goto error;
}
}
- puts(" PASSED");
+ PASSED();
/*
*######################################################################
@@ -427,8 +364,7 @@ main (void)
* fields unchanged. This tests member alignment and background
* buffers.
*/
- printf("%-70s", "Testing partially initialized superset write");
- fflush (stdout);
+ TESTING("partially initialized superset write");
/* Initialize `s4' with new values */
for (i=0; i<NX*NY; i++) {
@@ -456,12 +392,17 @@ main (void)
s1[i].c[3] != 8*i+5 ||
s1[i].d != 8*i+6 ||
s1[i].e != 8*i+7) {
- puts("*FAILED*");
- puts(" File values were clobbered");
+ FAILED();
+ printf(" i==%u, row=%u, col=%u\n", i, i/NY, i%NY);
+ printf(" got: {%7d,%7d,[%7d,%7d,%7d,%7d],%7d,%7d}\n",
+ s1[i].a, s1[i].b, s1[i].c[0], s1[i].c[1], s1[i].c[2],
+ s1[i].c[3], s1[i].d, s1[i].e);
+ printf(" ans: {%7d,%7d,[%7d,%7d,%7d,%7d],%7d,%7d}\n",
+ 8*i+0, 8*i+1, 8*i+2, 8*i+3, 8*i+4, 8*i+5, 8*i+6, 8*i+7);
goto error;
}
}
- puts(" PASSED");
+ PASSED();
/*
*######################################################################
@@ -469,8 +410,7 @@ main (void)
* though these data spaces are equal it tests a different part of the
* library.
*/
- printf("%-70s", "Testing explicit data space");
- fflush (stdout);
+ TESTING("explicit data space");
/* Create the data space */
if ((s7_sid = H5Screate_simple (2, dim, NULL))<0) goto error;
@@ -490,12 +430,12 @@ main (void)
s2[i].c[3] != s1[i].c[3] ||
s2[i].d != s1[i].d ||
s2[i].e != s1[i].e) {
- puts("*FAILED*");
- puts(" Incorrect values read from file");
+ FAILED();
+ puts(" Incorrect values read from file");
goto error;
}
}
- puts(" PASSED");
+ PASSED();
/*
@@ -503,8 +443,7 @@ main (void)
* STEP 8. Read a hyperslab of the file into a complete array in memory.
* The hyperslab is the middle third of the array.
*/
- printf("%-70s", "Testing hyperslab partial read to array");
- fflush (stdout);
+ TESTING("hyperslab partial read to array");
/* Create the file data space */
if ((s8_f_sid = H5Dget_space (dataset))<0) goto error;
@@ -539,8 +478,8 @@ main (void)
ps8->c[3] != ps1->c[3] ||
ps8->d != ps1->d ||
ps8->e != ps1->e) {
- puts("*FAILED*");
- puts(" Incorrect values read from file");
+ FAILED();
+ puts(" Incorrect values read from file");
goto error;
}
}
@@ -548,7 +487,7 @@ main (void)
free (s8);
s8 = NULL;
- puts(" PASSED");
+ PASSED();
/*
@@ -556,8 +495,7 @@ main (void)
* STEP 9. Read a hyperslab of the file into a hyperslab of memory. The
* part of memory not read is already initialized and must not change.
*/
- printf("%-70s", "Testing hyperslab partial read to another hyperslab");
- fflush (stdout);
+ TESTING("hyperslab partial read to another hyperslab");
/* Initialize */
for (i=0; i<NX*NY; i++) {
@@ -587,8 +525,8 @@ main (void)
ps2->c[3] != ps1->c[3] ||
ps2->d != ps1->d ||
ps2->e != ps1->e) {
- puts("*FAILED*");
- puts(" Memory values clobbered");
+ FAILED();
+ puts(" Memory values clobbered");
goto error;
}
} else {
@@ -600,22 +538,21 @@ main (void)
ps2->c[3] != (unsigned)(-1) ||
ps2->d != (unsigned)(-1) ||
ps2->e != (unsigned)(-1)) {
- puts("*FAILED*");
- puts(" Incorrect values read from file");
+ FAILED();
+ puts(" Incorrect values read from file");
goto error;
}
}
}
}
- puts(" PASSED");
+ PASSED();
/*
*######################################################################
* STEP 10. Same as step 9 except the memory array contains some members
* which are already initialized, like step 5.
*/
- printf("%-70s", "Testing hyperslab to hyperslab part initialized read");
- fflush (stdout);
+ TESTING("hyperslab to hyperslab part initialized read");
/* Initialize */
for (i=0; i<NX*NY; i++) {
@@ -650,8 +587,8 @@ main (void)
ps5->d != ps1->d ||
ps5->e != ps1->e ||
ps5->post != (unsigned)(-1)) {
- puts("*FAILED*");
- puts(" Memory values clobbered");
+ FAILED();
+ puts(" Memory values clobbered");
goto error;
}
} else {
@@ -667,22 +604,21 @@ main (void)
ps5->d != (unsigned)(-1) ||
ps5->e != (unsigned)(-1) ||
ps5->post != (unsigned)(-1)) {
- puts("*FAILED*");
- puts(" Incorrect values read from file");
+ FAILED();
+ puts(" Incorrect values read from file");
goto error;
}
}
}
}
- puts(" PASSED");
+ PASSED();
/*
*######################################################################
* Step 11: Write an array into the middle third of the dataset
* initializeing only members `b' and `d' to -1.
*/
- printf("%-70s", "Testing hyperslab part initialized write");
- fflush (stdout);
+ TESTING("hyperslab part initialized write");
/* Create the memory array and initialize all fields to zero */
ndims = 2;
@@ -721,8 +657,8 @@ main (void)
ps1->c[2] != 8*(i*NY+j)+4 ||
ps1->c[3] != 8*(i*NY+j)+5 ||
ps1->e != 8*(i*NY+j)+7) {
- puts("*FAILED*");
- puts(" Write clobbered values");
+ FAILED();
+ puts(" Write clobbered values");
goto error;
}
@@ -732,21 +668,21 @@ main (void)
(hsize_t)j<f_offset[1]+h_size[1]) {
if (ps1->b != (unsigned)(-1) ||
ps1->d != (unsigned)(-1)) {
- puts("*FAILED*");
- puts(" Wrong values written or read");
+ FAILED();
+ puts(" Wrong values written or read");
goto error;
}
} else {
if (ps1->b != 8*(i*NY+j)+1 ||
ps1->d != 8*(i*NY+j)+6) {
- puts("*FAILED*");
- puts(" Write clobbered values");
+ FAILED();
+ puts(" Write clobbered values");
goto error;
}
}
}
}
- puts(" PASSED");
+ PASSED();
/*
@@ -756,12 +692,11 @@ main (void)
H5Dclose (dataset);
H5Fclose (file);
- cleanup();
+ h5_cleanup(fapl);
puts("All compound dataset tests passed.");
return 0;
error:
- cleanup();
puts("Remaining tests have been skipped.");
puts("*** DATASET TESTS FAILED ***");
return 1;
diff --git a/test/dsets.c b/test/dsets.c
index d7e518b..be2b911 100644
--- a/test/dsets.c
+++ b/test/dsets.c
@@ -8,40 +8,13 @@
* Purpose: Tests the dataset interface (H5D)
*/
-/* See H5private.h for how to include files */
-#undef NDEBUG
-#include <hdf5.h>
-
-#ifdef STDC_HEADERS
-# include <assert.h>
-# include <math.h>
-# include <stdio.h>
-# include <stdlib.h>
-# include <string.h>
-#endif
-
-#ifdef HAVE_UNISTD_H
-# include <sys/types.h>
-# include <unistd.h>
-#endif
-
-#ifndef HAVE_ATTRIBUTE
-# undef __attribute__
-# define __attribute__(X) /*void*/
-# define __unused__ /*void*/
-#else
-# define __unused__ __attribute__((unused))
-#endif
-
-#ifndef HAVE_FUNCTION
-# undef __FUNCTION__
-# define __FUNCTION__ ""
-#endif
+#include <h5test.h>
-#define AT() printf (" at %s:%d in %s()...\n", \
- __FILE__, __LINE__, __FUNCTION__);
+const char *FILENAME[] = {
+ "dataset",
+ NULL
+};
-#define TEST_FILE_NAME "dataset.h5"
#define DSET_DEFAULT_NAME "default"
#define DSET_CHUNKED_NAME "chunked"
#define DSET_SIMPLE_IO_NAME "simple_io"
@@ -53,31 +26,6 @@
/*-------------------------------------------------------------------------
- * Function: display_error_cb
- *
- * Purpose: Displays the error stack after printing "*FAILED*".
- *
- * Return: Success: 0
- *
- * Failure: -1
- *
- * Programmer: Robb Matzke
- * Wednesday, March 4, 1998
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-display_error_cb (void __unused__ *client_data)
-{
- puts ("*FAILED*");
- H5Eprint (stdout);
- return 0;
-}
-
-
-/*-------------------------------------------------------------------------
* Function: test_create
*
* Purpose: Attempts to create a dataset.
@@ -100,11 +48,8 @@ test_create(hid_t file)
hsize_t dims[2];
herr_t status;
hsize_t csize[2];
- herr_t (*func)(void*) = NULL;
- void *client_data = NULL;
- printf("%-70s", "Testing create/open/close");
- fflush (stdout);
+ TESTING("create, open, close");
/* Create the data space */
dims[0] = 256;
@@ -132,14 +77,13 @@ test_create(hid_t file)
* dataset can only be created once. Temporarily turn off error
* reporting.
*/
- H5Eget_auto (&func, &client_data);
- H5Eset_auto (NULL, NULL);
- dataset = H5Dcreate(file, DSET_DEFAULT_NAME, H5T_NATIVE_DOUBLE, space,
- H5P_DEFAULT);
- H5Eset_auto (func, client_data);
+ H5E_BEGIN_TRY {
+ dataset = H5Dcreate(file, DSET_DEFAULT_NAME, H5T_NATIVE_DOUBLE, space,
+ H5P_DEFAULT);
+ } H5E_END_TRY;
if (dataset >= 0) {
- puts("*FAILED*");
- printf(" Library allowed overwrite of existing dataset.\n");
+ FAILED();
+ puts(" Library allowed overwrite of existing dataset.");
goto error;
}
@@ -155,13 +99,12 @@ test_create(hid_t file)
* cannot be created with this function. Temporarily turn off error
* reporting.
*/
- H5Eget_auto (&func, &client_data);
- H5Eset_auto (NULL, NULL);
- dataset = H5Dopen(file, "does_not_exist");
- H5Eset_auto (func, client_data);
+ H5E_BEGIN_TRY {
+ dataset = H5Dopen(file, "does_not_exist");
+ } H5E_END_TRY;
if (dataset >= 0) {
- puts("*FAILED*");
- printf(" Opened a non-existent dataset.\n");
+ FAILED();
+ puts(" Opened a non-existent dataset.");
goto error;
}
@@ -186,7 +129,7 @@ test_create(hid_t file)
*/
if (H5Dclose(dataset) < 0) goto error;
- puts(" PASSED");
+ PASSED();
return 0;
error:
@@ -222,8 +165,7 @@ test_simple_io(hid_t file)
hsize_t dims[2];
void *tconv_buf = NULL;
- printf("%-70s", "Testing simple I/O");
- fflush (stdout);
+ TESTING("simple I/O");
/* Initialize the dataset */
for (i = n = 0; i < 100; i++) {
@@ -235,38 +177,33 @@ test_simple_io(hid_t file)
/* Create the data space */
dims[0] = 100;
dims[1] = 200;
- space = H5Screate_simple(2, dims, NULL);
- assert(space>=0);
+ if ((space = H5Screate_simple(2, dims, NULL))<0) goto error;
/* Create a small conversion buffer to test strip mining */
tconv_buf = malloc (1000);
xfer = H5Pcreate (H5P_DATASET_XFER);
assert (xfer>=0);
- status = H5Pset_buffer (xfer, 1000, tconv_buf, NULL);
- assert (status>=0);
+ if ((status = H5Pset_buffer (xfer, 1000, tconv_buf, NULL))<0) goto error;
/* Create the dataset */
- dataset = H5Dcreate(file, DSET_SIMPLE_IO_NAME, H5T_NATIVE_INT, space,
- H5P_DEFAULT);
- assert(dataset >= 0);
+ if ((dataset = H5Dcreate(file, DSET_SIMPLE_IO_NAME, H5T_NATIVE_INT, space,
+ H5P_DEFAULT))<0) goto error;
/* Write the data to the dataset */
- status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
- xfer, points);
- if (status<0) goto error;
+ if (H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, points)<0)
+ goto error;
/* Read the dataset back */
- status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
- xfer, check);
- if (status<0) goto error;
+ if (H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, check)<0)
+ goto error;
/* Check that the values read are the same as the values written */
for (i = 0; i < 100; i++) {
for (j = 0; j < 200; j++) {
if (points[i][j] != check[i][j]) {
- puts("*FAILED*");
- printf(" Read different values than written.\n");
- printf(" At index %d,%d\n", i, j);
+ FAILED();
+ printf(" Read different values than written.\n");
+ printf(" At index %d,%d\n", i, j);
goto error;
}
}
@@ -275,7 +212,7 @@ test_simple_io(hid_t file)
H5Pclose (xfer);
H5Dclose(dataset);
free (tconv_buf);
- puts(" PASSED");
+ PASSED();
return 0;
error:
@@ -305,15 +242,13 @@ test_tconv(hid_t file)
int i;
hsize_t dims[1];
hid_t space, dataset;
- herr_t status;
out = malloc (4*1000000);
assert (out);
in = malloc (4*1000000);
assert (in);
- printf("%-70s", "Testing data type conversion");
- fflush (stdout);
+ TESTING("data type conversion");
/* Initialize the dataset */
for (i = 0; i < 1000000; i++) {
@@ -325,38 +260,40 @@ test_tconv(hid_t file)
/* Create the data space */
dims[0] = 1000000;
- space = H5Screate_simple (1, dims, NULL);
- assert(space >= 0);
+ if ((space = H5Screate_simple (1, dims, NULL))<0) goto error;
/* Create the data set */
- dataset = H5Dcreate(file, DSET_TCONV_NAME, H5T_STD_I32LE, space,
- H5P_DEFAULT);
- assert(dataset >= 0);
+ if ((dataset = H5Dcreate(file, DSET_TCONV_NAME, H5T_STD_I32LE, space,
+ H5P_DEFAULT))<0) goto error;
/* Write the data to the dataset */
- status = H5Dwrite(dataset, H5T_STD_I32LE, H5S_ALL, H5S_ALL,
- H5P_DEFAULT, out);
- assert(status >= 0);
+ if (H5Dwrite(dataset, H5T_STD_I32LE, H5S_ALL, H5S_ALL, H5P_DEFAULT,
+ out)<0) goto error;
/* Read data with byte order conversion */
- status = H5Dread(dataset, H5T_STD_I32BE, H5S_ALL, H5S_ALL,
- H5P_DEFAULT, in);
- assert(status >= 0);
+ if (H5Dread(dataset, H5T_STD_I32BE, H5S_ALL, H5S_ALL, H5P_DEFAULT, in)<0)
+ goto error;
/* Check */
for (i = 0; i < 1000000; i++) {
- assert(in[4 * i + 0] == out[4 * i + 3]);
- assert(in[4 * i + 1] == out[4 * i + 2]);
- assert(in[4 * i + 2] == out[4 * i + 1]);
- assert(in[4 * i + 3] == out[4 * i + 0]);
+ if (in[4*i+0]!=out[4*i+3] ||
+ in[4*i+1]!=out[4*i+2] ||
+ in[4*i+2]!=out[4*i+1] ||
+ in[4*i+3]!=out[4*i+0]) {
+ FAILED();
+ puts(" Read with byte order conversion failed.");
+ goto error;
+ }
}
- H5Dclose(dataset);
+ if (H5Dclose(dataset)<0) goto error;
free (out);
free (in);
-
puts(" PASSED");
return 0;
+
+ error:
+ return -1;
}
@@ -381,9 +318,6 @@ bogus(unsigned int __unused__ flags, size_t __unused__ cd_nelmts,
const unsigned int __unused__ cd_values[], size_t nbytes,
size_t __unused__ *buf_size, void __unused__ **buf)
{
-#if 0
- abort();
-#endif
return nbytes;
}
@@ -408,7 +342,6 @@ static herr_t
test_compression(hid_t file)
{
hid_t dataset, space, xfer, dc;
- herr_t status;
int points[100][200], check[100][200];
const hsize_t size[2] = {100, 200};
const hsize_t chunk_size[2] = {2, 25};
@@ -418,64 +351,57 @@ test_compression(hid_t file)
hsize_t i, j, n;
void *tconv_buf = NULL;
- printf ("%-70s", "Testing compression (setup)");
- fflush (stderr);
+ TESTING("compression (setup)");
/* Create the data space */
- space = H5Screate_simple(2, size, NULL);
- assert(space>=0);
+ if ((space = H5Screate_simple(2, size, NULL))<0) goto error;
/*
* Create a small conversion buffer to test strip mining. We
* might as well test all we can!
*/
- xfer = H5Pcreate (H5P_DATASET_XFER);
- assert (xfer>=0);
+ if ((xfer = H5Pcreate (H5P_DATASET_XFER))<0) goto error;
tconv_buf = malloc (1000);
- status = H5Pset_buffer (xfer, 1000, tconv_buf, NULL);
- assert (status>=0);
+ if (H5Pset_buffer (xfer, 1000, tconv_buf, NULL)<0) goto error;
/* Use chunked storage with compression */
- dc = H5Pcreate (H5P_DATASET_CREATE);
- H5Pset_chunk (dc, 2, chunk_size);
- H5Pset_deflate (dc, 6);
+ 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;
/* Create the dataset */
- dataset = H5Dcreate(file, DSET_COMPRESS_NAME, H5T_NATIVE_INT, space, dc);
- assert(dataset >= 0);
- puts (" PASSED");
+ if ((dataset = H5Dcreate(file, DSET_COMPRESS_NAME, H5T_NATIVE_INT, space,
+ dc))<0) goto error;
+ PASSED();
/*----------------------------------------------------------------------
* STEP 1: Read uninitialized data. It should be zero.
*----------------------------------------------------------------------
*/
- printf ("%-70s", "Testing compression (uninitialized read)");
- fflush (stdout);
+ TESTING("compression (uninitialized read)");
- status = H5Dread (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
- xfer, check);
- if (status<0) goto error;
+ if (H5Dread (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, check)<0)
+ goto error;
for (i=0; i<size[0]; i++) {
for (j=0; j<size[1]; j++) {
if (0!=check[i][j]) {
- puts("*FAILED*");
- printf(" Read a non-zero value.\n");
- printf(" At index %lu,%lu\n",
+ FAILED();
+ printf(" Read a non-zero value.\n");
+ printf(" At index %lu,%lu\n",
(unsigned long)i, (unsigned long)j);
goto error;
}
}
}
- puts (" PASSED");
+ PASSED();
/*----------------------------------------------------------------------
* STEP 2: Test compression by setting up a chunked dataset and writing
* to it.
*----------------------------------------------------------------------
*/
- printf("%-70s", "Testing compression (write)");
- fflush (stdout);
+ TESTING("compression (write)");
for (i=n=0; i<size[0]; i++) {
for (j=0; j<size[1]; j++) {
@@ -483,36 +409,33 @@ test_compression(hid_t file)
}
}
- status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
- xfer, points);
- if (status<0) goto error;
- puts (" PASSED");
+ if (H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, points)<0)
+ goto error;
+ PASSED();
/*----------------------------------------------------------------------
* STEP 3: Try to read the data we just wrote.
*----------------------------------------------------------------------
*/
- printf ("%-70s", "Testing compression (read)");
- fflush (stdout);
+ TESTING("compression (read)");
/* Read the dataset back */
- status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
- xfer, check);
- if (status<0) goto error;
+ if (H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, check)<0)
+ goto 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]) {
- puts("*FAILED*");
- printf(" Read different values than written.\n");
- printf(" At index %lu,%lu\n",
+ FAILED();
+ printf(" Read different values than written.\n");
+ printf(" At index %lu,%lu\n",
(unsigned long)i, (unsigned long)j);
goto error;
}
}
}
- puts (" PASSED");
+ PASSED();
/*----------------------------------------------------------------------
* STEP 4: Write new data over the top of the old data. The new data is
@@ -521,37 +444,33 @@ test_compression(hid_t file)
* dataset although we rewrite the whole thing.
*----------------------------------------------------------------------
*/
- printf ("%-70s", "Testing compression (modify)");
- fflush (stdout);
+ TESTING("compression (modify)");
for (i=0; i<size[0]; i++) {
for (j=0; j<size[1]/2; j++) {
points[i][j] = rand ();
}
}
- status = H5Dwrite (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
- xfer, points);
- if (status<0) goto error;
-
+ if (H5Dwrite (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, points)<0)
+ goto error;
/* Read the dataset back and check it */
- status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
- xfer, check);
- if (status<0) goto error;
+ if (H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, check)<0)
+ goto 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]) {
- puts("*FAILED*");
- printf(" Read different values than written.\n");
- printf(" At index %lu,%lu\n",
+ FAILED();
+ printf(" Read different values than written.\n");
+ printf(" At index %lu,%lu\n",
(unsigned long)i, (unsigned long)j);
goto error;
}
}
}
- puts (" PASSED");
+ PASSED();
/*----------------------------------------------------------------------
* STEP 5: Close the dataset and then open it and read it again. This
@@ -559,29 +478,26 @@ test_compression(hid_t file)
* object header.
*----------------------------------------------------------------------
*/
- printf ("%-70s", "Testing compression (re-open)");
- fflush (stdout);
+ TESTING("compression (re-open)");
- H5Dclose (dataset);
- dataset = H5Dopen (file, DSET_COMPRESS_NAME);
- status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
- xfer, check);
- if (status<0) goto error;
+ if (H5Dclose (dataset)<0) goto error;
+ if ((dataset = H5Dopen (file, DSET_COMPRESS_NAME))<0) goto error;
+ if (H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, check)<0)
+ goto 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]) {
- puts("*FAILED*");
- printf(" Read different values than written.\n");
- printf(" At index %lu,%lu\n",
+ FAILED();
+ printf(" Read different values than written.\n");
+ printf(" At index %lu,%lu\n",
(unsigned long)i, (unsigned long)j);
goto error;
}
}
}
- puts (" PASSED");
-
+ PASSED();
/*----------------------------------------------------------------------
* STEP 6: Test partial I/O by writing to and then reading from a
@@ -589,76 +505,72 @@ test_compression(hid_t file)
* boundaries (we know that case already works from above tests).
*----------------------------------------------------------------------
*/
- printf ("%-70s", "Testing compression (partial I/O)");
- fflush (stderr);
+ TESTING("compression (partial I/O)");
for (i=0; i<hs_size[0]; i++) {
for (j=0; j<hs_size[1]; j++) {
points[hs_offset[0]+i][hs_offset[1]+j] = rand ();
}
}
- H5Sselect_hyperslab(space, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL);
-
- status = H5Dwrite (dataset, H5T_NATIVE_INT, space, space, xfer, points);
- if (status<0) goto error;
- status = H5Dread (dataset, H5T_NATIVE_INT, space, space, xfer, check);
- if (status<0) goto error;
+ if (H5Sselect_hyperslab(space, H5S_SELECT_SET, hs_offset, NULL, hs_size,
+ NULL)<0) goto error;
+ if (H5Dwrite (dataset, H5T_NATIVE_INT, space, space, xfer, points)<0)
+ goto error;
+ if (H5Dread (dataset, H5T_NATIVE_INT, space, space, xfer, check)<0)
+ goto error;
/* Check that the values read are the same as the values written */
for (i=0; i<hs_size[0]; i++) {
for (j=0; j<hs_size[1]; j++) {
if (points[hs_offset[0]+i][hs_offset[1]+j] !=
check[hs_offset[0]+i][hs_offset[1]+j]) {
- puts("*FAILED*");
- printf(" Read different values than written.\n");
- printf(" At index %lu,%lu\n",
+ FAILED();
+ printf(" Read different values than written.\n");
+ printf(" At index %lu,%lu\n",
(unsigned long)(hs_offset[0]+i),
(unsigned long)(hs_offset[1]+j));
- printf(" At original: %d\n",
+ printf(" At original: %d\n",
(int)points[hs_offset[0]+i][hs_offset[1]+j]);
- printf(" At returned: %d\n",
+ printf(" At returned: %d\n",
(int)check[hs_offset[0]+i][hs_offset[1]+j]);
goto error;
}
}
}
- puts (" PASSED");
+ PASSED();
/*----------------------------------------------------------------------
* STEP 7: Register an application-defined compression method and use it
* to write and then read the dataset.
*----------------------------------------------------------------------
*/
- printf ("%-70s", "Testing compression (app-defined method)");
- fflush (stdout);
+ TESTING("compression (app-defined method)");
if (H5Zregister (H5Z_BOGUS, "bogus", bogus)<0) goto error;
if (H5Pset_filter (dc, H5Z_BOGUS, 0, 0, NULL)<0) goto error;
if (H5Dclose (dataset)<0) goto error;
if (H5Sclose (space)<0) goto error;
if ((space = H5Screate_simple (2, size, NULL))<0) goto error;
- dataset = H5Dcreate (file, DSET_BOGUS_NAME, H5T_NATIVE_INT, space, dc);
- assert (dataset>=0);
+ if ((dataset=H5Dcreate (file, DSET_BOGUS_NAME, H5T_NATIVE_INT, space,
+ dc))<0) goto error;
- status = H5Dwrite (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
- xfer, points);
- if (status<0) goto error;
- status = H5Dread (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
- xfer, check);
- if (status<0) goto error;
+ if (H5Dwrite (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, points)<0)
+ goto error;
+ if (H5Dread (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, xfer, check)<0)
+ goto error;
for (i=0; i<size[0]; i++) {
for (j=0; j<size[1]; j++) {
if (points[i][j] != check[i][j]) {
- puts("*FAILED*");
- printf(" Read different values than written.\n");
- printf(" At index %lu,%lu\n",
+ FAILED();
+ printf(" Read different values than written.\n");
+ printf(" At index %lu,%lu\n",
(unsigned long)i, (unsigned long)j);
goto error;
}
}
}
- puts (" PASSED");
+ PASSED();
@@ -666,9 +578,9 @@ test_compression(hid_t file)
* Cleanup
*----------------------------------------------------------------------
*/
- H5Pclose (xfer);
- H5Pclose (dc);
- H5Dclose(dataset);
+ if (H5Pclose (xfer)<0) goto error;
+ if (H5Pclose (dc)<0) goto error;
+ if (H5Dclose(dataset)<0) goto error;
free (tconv_buf);
return 0;
@@ -704,7 +616,7 @@ test_multiopen (hid_t file)
static hsize_t max_size[1] = {H5S_UNLIMITED};
hsize_t tmp_size[1];
- printf ("%-70s", "Testing multi-open with extending");
+ TESTING("multi-open with extending");
/* Create the dataset and open it twice */
if ((dcpl=H5Pcreate (H5P_DATASET_CREATE))<0) goto error;
@@ -723,8 +635,8 @@ test_multiopen (hid_t file)
if ((space = H5Dget_space (dset2))<0) goto error;
if (H5Sget_simple_extent_dims (space, tmp_size, NULL)<0) goto error;
if (cur_size[0]!=tmp_size[0]) {
- puts ("*FAILED*");
- printf (" Got %d instead of %d!\n",
+ FAILED();
+ printf (" Got %d instead of %d!\n",
(int)tmp_size[0], (int)cur_size[0]);
goto error;
}
@@ -733,7 +645,7 @@ test_multiopen (hid_t file)
if (H5Dclose (dset2)<0) goto error;
if (H5Sclose (space)<0) goto error;
if (H5Pclose (dcpl)<0) goto error;
- puts (" PASSED");
+ PASSED();
return 0;
error:
@@ -748,29 +660,6 @@ test_multiopen (hid_t file)
/*-------------------------------------------------------------------------
- * Function: cleanup
- *
- * Purpose: Cleanup temporary test files
- *
- * Return: none
- *
- * Programmer: Albert Cheng
- * May 28, 1998
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static void
-cleanup(void)
-{
- if (!getenv ("HDF5_NOCLEANUP")) {
- remove(TEST_FILE_NAME);
- }
-}
-
-
-/*-------------------------------------------------------------------------
* Function: main
*
* Purpose: Tests the dataset interface (H5D)
@@ -790,64 +679,43 @@ int
main(void)
{
hid_t file, grp, fapl;
- herr_t status;
int nerrors=0, mdc_nelmts;
+ char filename[1024];
- status = H5open ();
- assert (status>=0);
-
- /* Automatic error reporting to standard output */
- H5Eset_auto (display_error_cb, NULL);
-
- /* Create the file */
- fapl = H5Pcreate(H5P_FILE_ACCESS);
- assert(fapl>=0);
-
+ h5_reset();
+ fapl = h5_fileaccess();
+
#if 1
/* Turn off raw data cache */
- status = H5Pget_cache(fapl, &mdc_nelmts, NULL, NULL, NULL);
- assert(status>=0);
- status = H5Pset_cache(fapl, mdc_nelmts, 0, 0, 0.0);
- assert(status>=0);
+ if (H5Pget_cache(fapl, &mdc_nelmts, NULL, NULL, NULL)<0) goto error;
+ if (H5Pset_cache(fapl, mdc_nelmts, 0, 0, 0.0)<0) goto error;
#endif
- file = H5Fcreate(TEST_FILE_NAME, H5F_ACC_TRUNC|H5F_ACC_DEBUG,
- H5P_DEFAULT, fapl);
- assert(file >= 0);
- H5Pclose(fapl);
+ h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
+ if ((file=H5Fcreate(filename, H5F_ACC_TRUNC|H5F_ACC_DEBUG,
+ H5P_DEFAULT, fapl))<0) goto error;
/* Cause the library to emit initial messages */
- grp = H5Gcreate (file, "emit diagnostics", 0);
- H5Gset_comment(grp, ".", "Causes diagnostic messages to be emitted");
- H5Gclose (grp);
-
- status = test_create(file);
- nerrors += status < 0 ? 1 : 0;
-
- status = test_simple_io(file);
- nerrors += status < 0 ? 1 : 0;
-
- status = test_tconv(file);
- nerrors += status < 0 ? 1 : 0;
-
- status = test_compression(file);
- nerrors += status < 0 ? 1 : 0;
-
- status = test_multiopen (file);
- nerrors += status < 0 ? 1 : 0;
+ if ((grp = H5Gcreate (file, "emit diagnostics", 0))<0) goto error;
+ if (H5Gset_comment(grp, ".", "Causes diagnostic messages to be emitted")<0)
+ goto error;
+ if (H5Gclose (grp)<0) goto error;
- status = H5Fclose(file);
+ nerrors += test_create(file)<0 ?1:0;
+ nerrors += test_simple_io(file)<0 ?1:0;
+ nerrors += test_tconv(file)<0 ?1:0;
+ nerrors += test_compression(file)<0 ?1:0;
+ nerrors += test_multiopen (file)<0 ?1:0;
- if (nerrors) {
- printf("***** %d DATASET TEST%s FAILED! *****\n",
- nerrors, 1 == nerrors ? "" : "S");
- exit(1);
- }
+ if (H5Fclose(file)<0) goto error;
+ if (nerrors) goto error;
printf("All dataset tests passed.\n");
-
- status = H5close ();
- assert (status>=0);
-
- cleanup();
+ h5_cleanup(fapl);
return 0;
+
+ error:
+ nerrors = MAX(1, nerrors);
+ printf("***** %d DATASET TEST%s FAILED! *****\n",
+ nerrors, 1 == nerrors ? "" : "S");
+ return 1;
}
diff --git a/test/dtypes.c b/test/dtypes.c
index 926ecfa..fef773a 100644
--- a/test/dtypes.c
+++ b/test/dtypes.c
@@ -8,49 +8,17 @@
* Purpose: Tests the data type interface (H5T)
*/
-/* See H5private.h for how to include headers */
-#undef NDEBUG
-#include <hdf5.h>
-
-#ifdef STDC_HEADERS
-# include <assert.h>
-# include <float.h>
-# include <math.h>
-# include <signal.h>
-# include <stdio.h>
-# include <stdlib.h>
-#endif
-
-#ifdef HAVE_UNISTD_H
-# include <sys/types.h>
-# include <unistd.h>
-#endif
-#ifdef _POSIX_VERSION
-# include <sys/wait.h>
-#endif
-
-#define H5T_PACKAGE
-#include <H5Tpkg.h> /*to turn off hardware conversions*/
-
-#ifndef HAVE_ATTRIBUTE
-# undef __attribute__
-# define __attribute__(X) /*void*/
-# define __unused__ /*void*/
-#else
-# define __unused__ __attribute__((unused))
-#endif
+#include <h5test.h>
#if SIZEOF_DOUBLE != SIZEOF_LONG_DOUBLE
# define USE_LDOUBLE
#endif
-#ifndef MAX
-# define MAX(X,Y) ((X)>(Y)?(X):(Y))
-# define MIN(X,Y) ((X)<(Y)?(X):(Y))
-#endif
-
-#define FILE_NAME_1 "dtypes1.h5"
-#define FILE_NAME_2 "dtypes2.h5"
+const char *FILENAME[] = {
+ "dtypes1",
+ "dtypes2",
+ NULL
+};
typedef struct complex_t {
double re;
@@ -79,10 +47,7 @@ static int noverflows_g = 0;
/* Skip overflow tests if non-zero */
static int skip_overflow_tests_g = 0;
-/*
- * If set then all known hardware conversion functions are unregistered when
- * the library is reset.
- */
+/* Don't use hardware conversions if set */
static int without_hardware_g = 0;
/*
@@ -116,11 +81,11 @@ void some_dummy_func(float x);
static void
fpe_handler(int __unused__ signo)
{
- puts(" -SKIP-");
- puts(" Test skipped due to SIGFPE.");
+ SKIPPED();
+ puts(" Test skipped due to SIGFPE.");
#ifndef HANDLE_SIGFPE
- puts(" Remaining tests could not be run.");
- puts(" Please turn off SIGFPE on overflows and try again.");
+ puts(" Remaining tests could not be run.");
+ puts(" Please turn off SIGFPE on overflows and try again.");
#endif
exit(255);
}
@@ -234,55 +199,6 @@ generates_sigfpe(void)
/*-------------------------------------------------------------------------
- * Function: cleanup
- *
- * Purpose: Removes test files
- *
- * Return: void
- *
- * Programmer: Robb Matzke
- * Thursday, June 4, 1998
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static void
-cleanup (void)
-{
- if (!getenv ("HDF5_NOCLEANUP")) {
- remove (FILE_NAME_1);
- remove (FILE_NAME_2);
- }
-}
-
-
-/*-------------------------------------------------------------------------
- * Function: display_error_cb
- *
- * Purpose: Displays the error stack after printing "*FAILED*".
- *
- * Return: Success: 0
- *
- * Failure: -1
- *
- * Programmer: Robb Matzke
- * Wednesday, March 4, 1998
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-display_error_cb (void __unused__ *client_data)
-{
- puts ("*FAILED*");
- H5Eprint (stdout);
- return 0;
-}
-
-
-/*-------------------------------------------------------------------------
* Function: reset_hdf5
*
* Purpose: Reset the hdf5 library. This causes statistics to be printed
@@ -300,80 +216,9 @@ display_error_cb (void __unused__ *client_data)
static void
reset_hdf5(void)
{
- fflush(stdout);
- fflush(stderr);
- H5close();
- H5Eset_auto (display_error_cb, NULL);
+ h5_reset();
H5Tset_overflow(overflow_handler);
-
- if (without_hardware_g) {
- H5Tunregister(H5T_conv_char_uchar);
- H5Tunregister(H5T_conv_char_short);
- H5Tunregister(H5T_conv_char_ushort);
- H5Tunregister(H5T_conv_char_int);
- H5Tunregister(H5T_conv_char_uint);
- H5Tunregister(H5T_conv_char_long);
- H5Tunregister(H5T_conv_char_ulong);
-
- H5Tunregister(H5T_conv_uchar_char);
- H5Tunregister(H5T_conv_uchar_short);
- H5Tunregister(H5T_conv_uchar_ushort);
- H5Tunregister(H5T_conv_uchar_int);
- H5Tunregister(H5T_conv_uchar_uint);
- H5Tunregister(H5T_conv_uchar_long);
- H5Tunregister(H5T_conv_uchar_ulong);
-
- H5Tunregister(H5T_conv_short_char);
- H5Tunregister(H5T_conv_short_uchar);
- H5Tunregister(H5T_conv_short_ushort);
- H5Tunregister(H5T_conv_short_int);
- H5Tunregister(H5T_conv_short_uint);
- H5Tunregister(H5T_conv_short_long);
- H5Tunregister(H5T_conv_short_ulong);
-
- H5Tunregister(H5T_conv_ushort_char);
- H5Tunregister(H5T_conv_ushort_uchar);
- H5Tunregister(H5T_conv_ushort_short);
- H5Tunregister(H5T_conv_ushort_int);
- H5Tunregister(H5T_conv_ushort_uint);
- H5Tunregister(H5T_conv_ushort_long);
- H5Tunregister(H5T_conv_ushort_ulong);
-
- H5Tunregister(H5T_conv_int_char);
- H5Tunregister(H5T_conv_int_uchar);
- H5Tunregister(H5T_conv_int_short);
- H5Tunregister(H5T_conv_int_ushort);
- H5Tunregister(H5T_conv_int_uint);
- H5Tunregister(H5T_conv_int_long);
- H5Tunregister(H5T_conv_int_ulong);
-
- H5Tunregister(H5T_conv_uint_char);
- H5Tunregister(H5T_conv_uint_uchar);
- H5Tunregister(H5T_conv_uint_short);
- H5Tunregister(H5T_conv_uint_ushort);
- H5Tunregister(H5T_conv_uint_int);
- H5Tunregister(H5T_conv_uint_long);
- H5Tunregister(H5T_conv_uint_ulong);
-
- H5Tunregister(H5T_conv_long_char);
- H5Tunregister(H5T_conv_long_uchar);
- H5Tunregister(H5T_conv_long_short);
- H5Tunregister(H5T_conv_long_ushort);
- H5Tunregister(H5T_conv_long_int);
- H5Tunregister(H5T_conv_long_uint);
- H5Tunregister(H5T_conv_long_ulong);
-
- H5Tunregister(H5T_conv_ulong_char);
- H5Tunregister(H5T_conv_ulong_uchar);
- H5Tunregister(H5T_conv_ulong_short);
- H5Tunregister(H5T_conv_ulong_ushort);
- H5Tunregister(H5T_conv_ulong_int);
- H5Tunregister(H5T_conv_ulong_uint);
- H5Tunregister(H5T_conv_ulong_long);
-
- H5Tunregister(H5T_conv_float_double);
- H5Tunregister(H5T_conv_double_float);
- }
+ if (without_hardware_g) h5_no_hwconv();
}
@@ -398,21 +243,21 @@ test_classes(void)
{
H5T_class_t tcls;
- printf("%-70s", "Testing H5Tget_class()");
+ TESTING("H5Tget_class()");
if ((tcls=H5Tget_class(H5T_NATIVE_INT))<0) goto error;
if (H5T_INTEGER!=tcls) {
- puts("*FAILED*");
- puts(" Invalid type class for H5T_NATIVE_INT");
+ FAILED();
+ puts(" Invalid type class for H5T_NATIVE_INT");
goto error;
}
if ((tcls=H5Tget_class(H5T_NATIVE_DOUBLE))<0) goto error;
if (H5T_FLOAT!=tcls) {
- puts("*FAILED*");
- puts(" Invalid type class for H5T_NATIVE_DOUBLE");
+ FAILED();
+ puts(" Invalid type class for H5T_NATIVE_DOUBLE");
goto error;
}
- puts(" PASSED");
+ PASSED();
return 0;
error:
@@ -440,22 +285,24 @@ static herr_t
test_copy(void)
{
hid_t a_copy;
+ herr_t status;
- printf("%-70s", "Testing H5Tcopy()");
+ TESTING("H5Tcopy()");
if ((a_copy = H5Tcopy(H5T_NATIVE_SHORT)) < 0) goto error;
if (H5Tclose(a_copy) < 0) goto error;
/* We should not be able to close a built-in byte */
H5E_BEGIN_TRY {
- if (H5Tclose (H5T_NATIVE_CHAR)>=0) {
- puts ("*FAILED*");
- puts (" Should not be able to close a predefined type!");
- goto error;
- }
+ status = H5Tclose (H5T_NATIVE_CHAR);
} H5E_END_TRY;
+ if (status>=0) {
+ FAILED();
+ puts (" Should not be able to close a predefined type!");
+ goto error;
+ }
- puts(" PASSED");
+ PASSED();
return 0;
error:
@@ -485,7 +332,7 @@ test_compound(void)
complex_t tmp;
hid_t complex_id;
- printf("%-70s", "Testing compound data types");
+ TESTING("compound data types");
/* Create the empty type */
if ((complex_id = H5Tcreate(H5T_COMPOUND, sizeof tmp))<0) goto error;
@@ -497,7 +344,7 @@ test_compound(void)
H5T_NATIVE_DOUBLE)<0) goto error;
if (H5Tclose (complex_id)<0) goto error;
- puts(" PASSED");
+ PASSED();
return 0;
error:
@@ -522,29 +369,37 @@ test_compound(void)
*-------------------------------------------------------------------------
*/
static herr_t
-test_transient (void)
+test_transient (hid_t fapl)
{
static hsize_t ds_size[2] = {10, 20};
hid_t file=-1, type=-1, space=-1, dset=-1, t2=-1;
+ char filename[1024];
+ herr_t status;
- printf ("%-70s", "Testing transient data types");
- if ((file=H5Fcreate (FILE_NAME_1, H5F_ACC_TRUNC|H5F_ACC_DEBUG,
- H5P_DEFAULT, H5P_DEFAULT))<0) goto error;
- space = H5Screate_simple (2, ds_size, ds_size);
+ TESTING("transient data types");
+
+ h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
+ if ((file=H5Fcreate (filename, H5F_ACC_TRUNC|H5F_ACC_DEBUG,
+ H5P_DEFAULT, fapl))<0) goto error;
+ if ((space = H5Screate_simple (2, ds_size, ds_size))<0) goto error;
/* Predefined types cannot be modified or closed */
H5E_BEGIN_TRY {
- if (H5Tset_precision (H5T_NATIVE_INT, 256)>=0) {
- puts ("*FAILED*");
- puts (" Predefined types should not be modifiable!");
- goto error;
- }
- if (H5Tclose (H5T_NATIVE_INT)>=0) {
- puts ("*FAILED*");
- puts (" Predefined types should not be closable!");
- goto error;
- }
+ status = H5Tset_precision (H5T_NATIVE_INT, 256);
+ } H5E_END_TRY;
+ if (status>=0) {
+ FAILED();
+ puts (" Predefined types should not be modifiable!");
+ goto error;
+ }
+ H5E_BEGIN_TRY {
+ status = H5Tclose (H5T_NATIVE_INT);
} H5E_END_TRY;
+ if (status>=0) {
+ FAILED();
+ puts (" Predefined types should not be closable!");
+ goto error;
+ }
/* Copying a predefined type results in a modifiable copy */
if ((type=H5Tcopy (H5T_NATIVE_INT))<0) goto error;
@@ -552,29 +407,30 @@ test_transient (void)
/* It should not be possible to create an attribute for a transient type */
H5E_BEGIN_TRY {
- if (H5Acreate (type, "attr1", H5T_NATIVE_INT, space, H5P_DEFAULT)>=0) {
- puts ("*FAILED*");
- puts (" Attributes should not be allowed for transient types!");
- goto error;
- }
+ status = H5Acreate (type, "attr1", H5T_NATIVE_INT, space, H5P_DEFAULT);
} H5E_END_TRY;
+ if (status>=0) {
+ FAILED();
+ puts (" Attributes should not be allowed for transient types!");
+ goto error;
+ }
/* Create a dataset from a transient data type */
if (H5Tclose (type)<0) goto error;
if ((type = H5Tcopy (H5T_NATIVE_INT))<0) goto error;
- if ((dset=H5Dcreate (file, "dset1", type, space, H5P_DEFAULT))<0) {
+ if ((dset=H5Dcreate (file, "dset1", type, space, H5P_DEFAULT))<0)
goto error;
- }
/* The type returned from a dataset should not be modifiable */
if ((t2 = H5Dget_type (dset))<0) goto error;
H5E_BEGIN_TRY {
- if (H5Tset_precision (t2, 256)>=0) {
- puts ("*FAILED*");
- puts (" Dataset data types should not be modifiable!");
- goto error;
- }
+ status = H5Tset_precision (t2, 256);
} H5E_END_TRY;
+ if (status>=0) {
+ FAILED();
+ puts (" Dataset data types should not be modifiable!");
+ goto error;
+ }
if (H5Tclose (t2)<0) goto error;
/*
@@ -585,12 +441,13 @@ test_transient (void)
if ((dset=H5Dopen (file, "dset1"))<0) goto error;
if ((t2 = H5Dget_type (dset))<0) goto error;
H5E_BEGIN_TRY {
- if (H5Tset_precision (t2, 256)>=0) {
- puts ("*FAILED*");
- puts (" Dataset data types should not be modifiable!");
- goto error;
- }
+ status = H5Tset_precision (t2, 256);
} H5E_END_TRY;
+ if (status>=0) {
+ FAILED();
+ puts (" Dataset data types should not be modifiable!");
+ goto error;
+ }
if (H5Tclose (t2)<0) goto error;
/*
@@ -606,7 +463,7 @@ test_transient (void)
H5Fclose (file);
H5Tclose (type);
H5Sclose (space);
- puts (" PASSED");
+ PASSED();
return 0;
error:
@@ -638,54 +495,60 @@ test_transient (void)
*-------------------------------------------------------------------------
*/
static herr_t
-test_named (void)
+test_named (hid_t fapl)
{
hid_t file=-1, type=-1, space=-1, dset=-1, t2=-1, attr1=-1;
herr_t status;
static hsize_t ds_size[2] = {10, 20};
+ char filename[1024];
- printf ("%-70s", "Testing named data types");
- if ((file=H5Fcreate (FILE_NAME_2, H5F_ACC_TRUNC|H5F_ACC_DEBUG,
- H5P_DEFAULT, H5P_DEFAULT))<0) goto error;
- space = H5Screate_simple (2, ds_size, ds_size);
+ TESTING("named data types");
+
+ h5_fixname(FILENAME[1], fapl, filename, sizeof filename);
+ if ((file=H5Fcreate (filename, H5F_ACC_TRUNC|H5F_ACC_DEBUG,
+ H5P_DEFAULT, fapl))<0) goto error;
+ if ((space = H5Screate_simple (2, ds_size, ds_size))<0) goto error;
/* Predefined types cannot be committed */
H5E_BEGIN_TRY {
- if (H5Tcommit (file, "test_named_1 (should not exist)",
- H5T_NATIVE_INT)>=0) {
- puts ("*FAILED*");
- puts (" Predefined types should not be committable!");
- goto error;
- }
+ status = H5Tcommit (file, "test_named_1 (should not exist)",
+ H5T_NATIVE_INT);
} H5E_END_TRY;
+ if (status>=0) {
+ FAILED();
+ puts (" Predefined types should not be committable!");
+ goto error;
+ }
/* Copy a predefined data type and commit the copy */
if ((type = H5Tcopy (H5T_NATIVE_INT))<0) goto error;
if (H5Tcommit (file, "native-int", type)<0) goto error;
if ((status=H5Tcommitted (type))<0) goto error;
if (0==status) {
- puts ("*FAILED*");
- puts (" H5Tcommitted() returned false!");
+ FAILED();
+ puts (" H5Tcommitted() returned false!");
goto error;
}
/* We should not be able to modify a type after it has been committed. */
H5E_BEGIN_TRY {
- if (H5Tset_precision (type, 256)>=0) {
- puts ("*FAILED*");
- puts (" Committed type is not constant!");
- goto error;
- }
+ status = H5Tset_precision (type, 256);
} H5E_END_TRY;
+ if (status>=0) {
+ FAILED();
+ puts (" Committed type is not constant!");
+ goto error;
+ }
/* We should not be able to re-commit a committed type */
H5E_BEGIN_TRY {
- if (H5Tcommit (file, "test_named_2 (should not exist)", type)>=0) {
- puts ("*FAILED*");
- puts (" Committed types should not be recommitted!");
- goto error;
- }
+ status = H5Tcommit(file, "test_named_2 (should not exist)", type);
} H5E_END_TRY;
+ if (status>=0) {
+ FAILED();
+ puts (" Committed types should not be recommitted!");
+ goto error;
+ }
/* It should be possible to define an attribute for the named type */
if ((attr1=H5Acreate (type, "attr1", H5T_NATIVE_INT, space,
@@ -699,8 +562,8 @@ test_named (void)
if ((t2 = H5Tcopy (type))<0) goto error;
if ((status=H5Tcommitted (t2))<0) goto error;
if (status) {
- puts ("*FAILED*");
- puts (" Copying a named type should result in a transient type!");
+ FAILED();
+ puts (" Copying a named type should result in a transient type!");
goto error;
}
if (H5Tset_precision (t2, 256)<0) goto error;
@@ -713,8 +576,8 @@ test_named (void)
if ((type=H5Topen (file, "native-int"))<0) goto error;
if ((status=H5Tcommitted (type))<0) goto error;
if (!status) {
- puts ("*FAILED*");
- puts (" Opened named types should be named types!");
+ FAILED();
+ puts (" Opened named types should be named types!");
goto error;
}
@@ -727,8 +590,8 @@ test_named (void)
if ((t2 = H5Dget_type (dset))<0) goto error;
if ((status=H5Tcommitted (t2))<0) goto error;
if (!status) {
- puts ("*FAILED*");
- puts (" Dataset type should be a named type!");
+ FAILED();
+ puts (" Dataset type should be a named type!");
goto error;
}
@@ -741,8 +604,8 @@ test_named (void)
if ((t2 = H5Dget_type (dset))<0) goto error;
if ((status=H5Tcommitted (t2))<0) goto error;
if (!status) {
- puts ("*FAILED*");
- puts (" Dataset type should be a named type!");
+ FAILED();
+ puts (" Dataset type should be a named type!");
goto error;
}
@@ -762,8 +625,8 @@ test_named (void)
if ((t2 = H5Dget_type (dset))<0) goto error;
if ((status=H5Tcommitted (t2))<0) goto error;
if (!status) {
- puts ("*FAILED*");
- puts (" Dataset type should be a named type!");
+ FAILED();
+ puts (" Dataset type should be a named type!");
goto error;
}
if (H5Tclose (t2)<0) goto error;
@@ -781,7 +644,7 @@ test_named (void)
if (H5Tclose (type)<0) goto error;
if (H5Sclose (space)<0) goto error;
if (H5Fclose (file)<0) goto error;
- puts (" PASSED");
+ PASSED();
return 0;
error:
@@ -846,8 +709,7 @@ test_conv_str_1(void)
char *buf=NULL;
hid_t src_type, dst_type;
- printf("%-70s", "Testing string conversions");
- fflush(stdout);
+ TESTING("string conversions");
/*
* Convert a null-terminated string to a shorter and longer null
@@ -859,19 +721,19 @@ test_conv_str_1(void)
memcpy(buf, "abcdefghi\0abcdefghi\0", 20);
if (H5Tconvert(src_type, dst_type, 2, buf, NULL)<0) goto error;
if (memcmp(buf, "abcd\0abcd\0abcdefghi\0", 20)) {
- puts("*FAILED*");
- puts(" Truncated C-string test failed");
+ FAILED();
+ puts(" Truncated C-string test failed");
goto error;
}
if (H5Tconvert(dst_type, src_type, 2, buf, NULL)<0) goto error;
if (memcmp(buf, "abcd\0\0\0\0\0\0abcd\0\0\0\0\0\0", 20)) {
- puts("*FAILED*");
- puts(" Extended C-string test failed");
+ FAILED();
+ puts(" Extended C-string test failed");
goto error;
}
free(buf);
- H5Tclose(src_type);
- H5Tclose(dst_type);
+ if (H5Tclose(src_type)<0) goto error;
+ if (H5Tclose(dst_type)<0) goto error;
/*
* Convert a null padded string to a shorter and then longer string.
@@ -882,19 +744,19 @@ test_conv_str_1(void)
memcpy(buf, "abcdefghijabcdefghij", 20);
if (H5Tconvert(src_type, dst_type, 2, buf, NULL)<0) goto error;
if (memcmp(buf, "abcdeabcdeabcdefghij", 20)) {
- puts("*FAILED*");
- puts(" Truncated C buffer test failed");
+ FAILED();
+ puts(" Truncated C buffer test failed");
goto error;
}
if (H5Tconvert(dst_type, src_type, 2, buf, NULL)<0) goto error;
if (memcmp(buf, "abcde\0\0\0\0\0abcde\0\0\0\0\0", 20)) {
- puts("*FAILED*");
- puts(" Extended C buffer test failed");
+ FAILED();
+ puts(" Extended C buffer test failed");
goto error;
}
free(buf);
- H5Tclose(src_type);
- H5Tclose(dst_type);
+ if (H5Tclose(src_type)<0) goto error;
+ if (H5Tclose(dst_type)<0) goto error;
/*
* Convert a space-padded string to a shorter and then longer string.
@@ -905,19 +767,19 @@ test_conv_str_1(void)
memcpy(buf, "abcdefghijabcdefghij", 20);
if (H5Tconvert(src_type, dst_type, 2, buf, NULL)<0) goto error;
if (memcmp(buf, "abcdeabcdeabcdefghij", 20)) {
- puts("*FAILED*");
- puts(" Truncated Fortran-string test failed");
+ FAILED();
+ puts(" Truncated Fortran-string test failed");
goto error;
}
if (H5Tconvert(dst_type, src_type, 2, buf, NULL)<0) goto error;
if (memcmp(buf, "abcde abcde ", 20)) {
- puts("*FAILED*");
- puts(" Extended Fortran-string test failed");
+ FAILED();
+ puts(" Extended Fortran-string test failed");
goto error;
}
free(buf);
- H5Tclose(src_type);
- H5Tclose(dst_type);
+ if (H5Tclose(src_type)<0) goto error;
+ if (H5Tclose(dst_type)<0) goto error;
/*
* What happens if a null-terminated string is not null terminated? If
@@ -931,8 +793,8 @@ test_conv_str_1(void)
memcpy(buf, "abcdefghijabcdefghij", 20);
if (H5Tconvert(src_type, dst_type, 2, buf, NULL)<0) goto error;
if (memcmp(buf, "abcdefghijabcdefghij", 20)) {
- puts("*FAILED*");
- puts(" Non-terminated string test 1");
+ FAILED();
+ puts(" Non-terminated string test 1");
goto error;
}
H5Tclose(dst_type);
@@ -940,20 +802,20 @@ test_conv_str_1(void)
memcpy(buf, "abcdefghijabcdefghij", 20);
if (H5Tconvert(src_type, dst_type, 2, buf, NULL)<0) goto error;
if (memcmp(buf, "abcd\0abcd\0abcdefghij", 20)) {
- puts("*FAILED*");
- puts(" Non-terminated string test 2");
+ FAILED();
+ puts(" Non-terminated string test 2");
goto error;
}
memcpy(buf, "abcdeabcdexxxxxxxxxx", 20);
if (H5Tconvert(dst_type, src_type, 2, buf, NULL)<0) goto error;
if (memcmp(buf, "abcde\0\0\0\0\0abcde\0\0\0\0\0", 20)) {
- puts("*FAILED*");
- puts(" Non-terminated string test 2");
+ FAILED();
+ puts(" Non-terminated string test 2");
goto error;
}
free(buf);
- H5Tclose(src_type);
- H5Tclose(dst_type);
+ if (H5Tclose(src_type)<0) goto error;
+ if (H5Tclose(dst_type)<0) goto error;
/*
* Test C string to Fortran and vice versa.
@@ -964,51 +826,51 @@ test_conv_str_1(void)
memcpy(buf, "abcdefghi\0abcdefghi\0", 20);
if (H5Tconvert(src_type, dst_type, 2, buf, NULL)<0) goto error;
if (memcmp(buf, "abcdefghi abcdefghi ", 20)) {
- puts("*FAILED*");
- puts(" C string to Fortran test 1");
+ FAILED();
+ puts(" C string to Fortran test 1");
goto error;
}
if (H5Tconvert(dst_type, src_type, 2, buf, NULL)<0) goto error;
if (memcmp(buf, "abcdefghi\0abcdefghi\0", 20)) {
- puts("*FAILED*");
- puts(" Fortran to C string test 1");
+ FAILED();
+ puts(" Fortran to C string test 1");
goto error;
}
- H5Tclose(dst_type);
+ if (H5Tclose(dst_type)<0) goto error;
dst_type = mkstr(5, H5T_STR_SPACEPAD);
memcpy(buf, "abcdefgh\0\0abcdefgh\0\0", 20);
if (H5Tconvert(src_type, dst_type, 2, buf, NULL)<0) goto error;
if (memcmp(buf, "abcdeabcdeabcdefgh\0\0", 20)) {
- puts("*FAILED*");
- puts(" C string to Fortran test 2");
+ FAILED();
+ puts(" C string to Fortran test 2");
goto error;
}
if (H5Tconvert(dst_type, src_type, 2, buf, NULL)<0) goto error;
if (memcmp(buf, "abcde\0\0\0\0\0abcde\0\0\0\0\0", 20)) {
- puts("*FAILED*");
- puts(" Fortran to C string test 2");
+ FAILED();
+ puts(" Fortran to C string test 2");
goto error;
}
- H5Tclose(src_type);
- H5Tclose(dst_type);
+ if (H5Tclose(src_type)<0) goto error;
+ if (H5Tclose(dst_type)<0) goto error;
src_type = mkstr(5, H5T_STR_NULLTERM);
dst_type = mkstr(10, H5T_STR_SPACEPAD);
memcpy(buf, "abcd\0abcd\0xxxxxxxxxx", 20);
if (H5Tconvert(src_type, dst_type, 2, buf, NULL)<0) goto error;
if (memcmp(buf, "abcd abcd ", 20)) {
- puts("*FAILED*");
- puts(" C string to Fortran test 3");
+ FAILED();
+ puts(" C string to Fortran test 3");
goto error;
}
if (H5Tconvert(dst_type, src_type, 2, buf, NULL)<0) goto error;
if (memcmp(buf, "abcd\0abcd\0abcd ", 20)) {
- puts("*FAILED*");
- puts(" Fortran to C string test 3");
+ FAILED();
+ puts(" Fortran to C string test 3");
goto error;
}
free(buf);
- H5Tclose(src_type);
- H5Tclose(dst_type);
+ if (H5Tclose(src_type)<0) goto error;
+ if (H5Tclose(dst_type)<0) goto error;
/*
* Test C buffer to Fortran and vice versa.
@@ -1019,53 +881,53 @@ test_conv_str_1(void)
memcpy(buf, "abcdefghijabcdefghij", 20);
if (H5Tconvert(src_type, dst_type, 2, buf, NULL)<0) goto error;
if (memcmp(buf, "abcdefghijabcdefghij", 20)) {
- puts("*FAILED*");
- puts(" C buffer to Fortran test 1");
+ FAILED();
+ puts(" C buffer to Fortran test 1");
goto error;
}
if (H5Tconvert(dst_type, src_type, 2, buf, NULL)<0) goto error;
if (memcmp(buf, "abcdefghijabcdefghij", 20)) {
- puts("*FAILED*");
- puts(" Fortran to C buffer test 1");
+ FAILED();
+ puts(" Fortran to C buffer test 1");
goto error;
}
- H5Tclose(dst_type);
+ if (H5Tclose(dst_type)<0) goto error;
dst_type = mkstr(5, H5T_STR_SPACEPAD);
memcpy(buf, "abcdefgh\0\0abcdefgh\0\0", 20);
if (H5Tconvert(src_type, dst_type, 2, buf, NULL)<0) goto error;
if (memcmp(buf, "abcdeabcdeabcdefgh\0\0", 20)) {
- puts("*FAILED*");
- puts(" C buffer to Fortran test 2");
+ FAILED();
+ puts(" C buffer to Fortran test 2");
goto error;
}
if (H5Tconvert(dst_type, src_type, 2, buf, NULL)<0) goto error;
if (memcmp(buf, "abcde\0\0\0\0\0abcde\0\0\0\0\0", 20)) {
- puts("*FAILED*");
- puts(" Fortran to C buffer test 2");
+ FAILED();
+ puts(" Fortran to C buffer test 2");
goto error;
}
- H5Tclose(src_type);
- H5Tclose(dst_type);
+ if (H5Tclose(src_type)<0) goto error;
+ if (H5Tclose(dst_type)<0) goto error;
src_type = mkstr(5, H5T_STR_NULLPAD);
dst_type = mkstr(10, H5T_STR_SPACEPAD);
memcpy(buf, "abcd\0abcd\0xxxxxxxxxx", 20);
if (H5Tconvert(src_type, dst_type, 2, buf, NULL)<0) goto error;
if (memcmp(buf, "abcd abcd ", 20)) {
- puts("*FAILED*");
- puts(" C buffer to Fortran test 3");
+ FAILED();
+ puts(" C buffer to Fortran test 3");
goto error;
}
if (H5Tconvert(dst_type, src_type, 2, buf, NULL)<0) goto error;
if (memcmp(buf, "abcd\0abcd\0abcd ", 20)) {
- puts("*FAILED*");
- puts(" Fortran to C buffer test 3");
+ FAILED();
+ puts(" Fortran to C buffer test 3");
goto error;
}
free(buf);
- H5Tclose(src_type);
- H5Tclose(dst_type);
+ if (H5Tclose(src_type)<0) goto error;
+ if (H5Tclose(dst_type)<0) goto error;
- puts(" PASSED");
+ PASSED();
reset_hdf5();
return 0;
@@ -1120,10 +982,9 @@ test_conv_str_2(void)
(int)(i+1), (int)ntests);
printf("%-70s", s);
fflush(stdout);
-
if (H5Tconvert(c_type, f_type, nelmts, buf, NULL)<0) goto error;
if (H5Tconvert(f_type, c_type, nelmts, buf, NULL)<0) goto error;
- puts(" PASSED");
+ PASSED();
}
ret_value = 0;
@@ -1155,19 +1016,13 @@ test_conv_str_2(void)
static herr_t
test_conv_int (void)
{
- const size_t ntests=100;
- const size_t nelmts=2000;
-
- size_t i, j;
- void *buf=NULL, *saved=NULL;
unsigned char byte[4];
/*---------------------------------------------------------------------
* Test some specific overflow/underflow cases.
*---------------------------------------------------------------------
*/
- printf ("%-70s", "Testing integer overflow conversions");
- fflush (stdout);
+ TESTING("integer overflow conversions");
/* (unsigned)0x80000000 -> (unsigned)0xffff */
byte[0] = byte[1] = byte[2] = 0;
@@ -1176,10 +1031,10 @@ test_conv_int (void)
goto error;
}
if (byte[0]!=0xff || byte[1]!=0xff) {
- puts ("*FAILED*");
- printf(" src: 0x80000000 unsigned\n");
- printf(" dst: 0x%02x%02x unsigned\n", byte[1], byte[0]);
- printf(" ans: 0xffff unsigned\n");
+ FAILED();
+ printf(" src: 0x80000000 unsigned\n");
+ printf(" dst: 0x%02x%02x unsigned\n", byte[1], byte[0]);
+ printf(" ans: 0xffff unsigned\n");
goto error;
}
@@ -1189,10 +1044,10 @@ test_conv_int (void)
goto error;
}
if (byte[0]!=0xff || byte[1]!=0x7f) {
- puts ("*FAILED*");
- printf(" src: 0xffffffff unsigned\n");
- printf(" dst: 0x%02x%02x signed\n", byte[1], byte[0]);
- printf(" ans: 0x7fff signed\n");
+ FAILED();
+ printf(" src: 0xffffffff unsigned\n");
+ printf(" dst: 0x%02x%02x signed\n", byte[1], byte[0]);
+ printf(" ans: 0x7fff signed\n");
goto error;
}
@@ -1202,10 +1057,10 @@ test_conv_int (void)
goto error;
}
if (byte[0]!=0x00 || byte[1]!=0x00) {
- puts ("*FAILED*");
- printf(" src: 0xffffffff signed\n");
- printf(" dst: 0x%02x%02x unsigned\n", byte[1], byte[0]);
- printf(" ans: 0x0000 unsigned\n");
+ FAILED();
+ printf(" src: 0xffffffff signed\n");
+ printf(" dst: 0x%02x%02x unsigned\n", byte[1], byte[0]);
+ printf(" ans: 0x0000 unsigned\n");
goto error;
}
@@ -1216,10 +1071,10 @@ test_conv_int (void)
goto error;
}
if (byte[0]!=0xff || byte[1]!=0xff) {
- puts ("*FAILED*");
- printf(" src: 0x7fffffff signed\n");
- printf(" dst: 0x%02x%02x unsigned\n", byte[1], byte[0]);
- printf(" ans: 0xffff unsigned\n");
+ FAILED();
+ printf(" src: 0x7fffffff signed\n");
+ printf(" dst: 0x%02x%02x unsigned\n", byte[1], byte[0]);
+ printf(" ans: 0xffff unsigned\n");
goto error;
}
@@ -1230,10 +1085,10 @@ test_conv_int (void)
goto error;
}
if (byte[0]!=0xff || byte[1]!=0x7f) {
- puts ("*FAILED*");
- printf(" src: 0x7fffffff signed\n");
- printf(" dst: 0x%02x%02x signed\n", byte[1], byte[0]);
- printf(" ans: 0x7fff signed\n");
+ FAILED();
+ printf(" src: 0x7fffffff signed\n");
+ printf(" dst: 0x%02x%02x signed\n", byte[1], byte[0]);
+ printf(" ans: 0x7fff signed\n");
goto error;
}
@@ -1244,60 +1099,18 @@ test_conv_int (void)
goto error;
}
if (byte[0]!=0x00 || byte[1]!=0x80) {
- puts ("*FAILED*");
- printf(" src: 0xbfffffff signed\n");
- printf(" dst: 0x%02x%02x signed\n", byte[1], byte[0]);
- printf(" ans: 0x8000 signed\n");
+ FAILED();
+ printf(" src: 0xbfffffff signed\n");
+ printf(" dst: 0x%02x%02x signed\n", byte[1], byte[0]);
+ printf(" ans: 0x8000 signed\n");
goto error;
}
- puts (" PASSED");
-
-
- /*-----------------------------------------------------------------------
- * Test random cases.
- *-----------------------------------------------------------------------
- */
- printf ("%-70s", "Testing random integer conversions");
- fflush (stdout);
-
- /* Allocate buffers */
- buf = malloc (nelmts*8);
- saved = malloc (nelmts*8);
-
- for (i=0; i<ntests; i++) {
-
- /* Start with NATIVE_INT */
- for (j=0; j<nelmts; j++) ((int*)buf)[j] = rand();
- memcpy (saved, buf, nelmts*sizeof(int));
-
- /* Convert there and back */
- if (H5Tconvert (H5T_NATIVE_INT, H5T_STD_I64LE, nelmts, buf,
- NULL)<0) goto error;
- if (H5Tconvert (H5T_STD_I64LE, H5T_NATIVE_INT, nelmts, buf,
- NULL)<0) goto error;
-
- /* Check results */
- for (j=0; j<nelmts; j++) {
- if (((int*)buf)[j]!=((int*)saved)[j]) {
- puts ("*FAILED*");
- printf (" Test %lu, elmt %lu, got %d instead of %d\n",
- (unsigned long)i, (unsigned long)j,
- ((int*)buf)[j], ((int*)saved)[j]);
- goto error;
- }
- }
- }
-
- puts (" PASSED");
- free (buf);
- free (saved);
+ PASSED();
reset_hdf5();
return 0;
error:
- if (buf) free (buf);
- if (saved) free (saved);
reset_hdf5();
return -1;
}
@@ -1421,8 +1234,8 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst)
sprintf(str, "Testing random %s %s -> %s conversions",
name, src_type_name, dst_type_name);
printf("%-70s", str);
- puts("*FAILED*");
- puts(" Unknown data type.");
+ FAILED();
+ puts(" Unknown data type.");
goto error;
}
@@ -1817,10 +1630,10 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst)
}
/* Print errors */
- if (0==fails_this_test++) puts("*FAILED*");
- printf(" test %u elmt %u\n", (unsigned)i+1, (unsigned)j);
+ if (0==fails_this_test++) FAILED();
+ printf(" test %u elmt %u\n", (unsigned)i+1, (unsigned)j);
- printf(" src = ");
+ printf(" src = ");
for (k=0; k<src_size; k++) {
printf(" %02x", saved[j*src_size+ENDIAN(src_size, k)]);
}
@@ -1854,7 +1667,7 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst)
break;
}
- printf(" dst = ");
+ printf(" dst = ");
for (k=0; k<dst_size; k++) {
printf(" %02x", buf[j*dst_size+ENDIAN(dst_size, k)]);
}
@@ -1888,7 +1701,7 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst)
break;
}
- printf(" ans = ");
+ printf(" ans = ");
for (k=0; k<dst_size; k++) {
printf(" %02x", hw[ENDIAN(dst_size, k)]);
}
@@ -1923,14 +1736,14 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst)
}
if (++fails_all_tests>=max_fails) {
- puts(" maximum failures reached, aborting test...");
+ puts(" maximum failures reached, aborting test...");
goto done;
}
}
- puts(" PASSED");
+ PASSED();
}
if (noverflows_g>0) {
- printf(" %d overflow%s\n", noverflows_g, 1==noverflows_g?"":"s");
+ printf(" %d overflow%s\n", noverflows_g, 1==noverflows_g?"":"s");
}
done:
@@ -2135,9 +1948,9 @@ test_conv_flt_1 (const char *name, hid_t src, hid_t dst)
if (FLT_OTHER==src_type || FLT_OTHER==dst_type) {
sprintf(str, "Testing random %s %s -> %s conversions",
name, src_type_name, dst_type_name);
- printf ("%-70s", str);
- puts("*FAILED*");
- puts(" Unknown data type.");
+ printf("%-70s", str);
+ FAILED();
+ puts(" Unknown data type.");
goto error;
}
@@ -2157,7 +1970,7 @@ test_conv_flt_1 (const char *name, hid_t src, hid_t dst)
*/
sprintf(str, "Testing random %s %s -> %s conversions (test %d/%d)",
name, src_type_name, dst_type_name, (int)i+1, (int)ntests);
- printf ("%-70s", str);
+ printf("%-70s", str);
fflush(stdout);
fails_this_test = 0;
@@ -2321,10 +2134,10 @@ test_conv_flt_1 (const char *name, hid_t src, hid_t dst)
}
#endif
- if (0==fails_this_test++) puts("*FAILED*");
- printf(" test %u, elmt %u\n", (unsigned)i+1, (unsigned)j);
+ if (0==fails_this_test++) FAILED();
+ printf(" test %u, elmt %u\n", (unsigned)i+1, (unsigned)j);
- printf(" src =");
+ printf(" src =");
for (k=0; k<src_size; k++) {
printf(" %02x", saved[j*src_size+ENDIAN(src_size,k)]);
}
@@ -2339,7 +2152,7 @@ test_conv_flt_1 (const char *name, hid_t src, hid_t dst)
#endif
}
- printf(" dst =");
+ printf(" dst =");
for (k=0; k<dst_size; k++) {
printf(" %02x", buf[j*dst_size+ENDIAN(dst_size,k)]);
}
@@ -2354,7 +2167,7 @@ test_conv_flt_1 (const char *name, hid_t src, hid_t dst)
#endif
}
- printf(" ans =");
+ printf(" ans =");
for (k=0; k<dst_size; k++) {
printf(" %02x", hw[ENDIAN(dst_size,k)]);
}
@@ -2370,14 +2183,14 @@ test_conv_flt_1 (const char *name, hid_t src, hid_t dst)
}
if (++fails_all_tests>=max_fails) {
- puts(" maximum failures reached, aborting test...");
+ puts(" maximum failures reached, aborting test...");
goto done;
}
}
- puts(" PASSED");
+ PASSED();
}
if (noverflows_g>0) {
- printf(" %d overflow%s\n", noverflows_g, 1==noverflows_g?"":"s");
+ printf(" %d overflow%s\n", noverflows_g, 1==noverflows_g?"":"s");
}
done:
@@ -2424,15 +2237,17 @@ int
main(void)
{
unsigned long nerrors = 0;
+ hid_t fapl=-1;
reset_hdf5();
+ fapl = h5_fileaccess();
/* Do the tests */
nerrors += test_classes()<0 ? 1 : 0;
nerrors += test_copy()<0 ? 1 : 0;
nerrors += test_compound()<0 ? 1 : 0;
- nerrors += test_transient ()<0 ? 1 : 0;
- nerrors += test_named ()<0 ? 1 : 0;
+ nerrors += test_transient (fapl)<0 ? 1 : 0;
+ nerrors += test_named (fapl)<0 ? 1 : 0;
reset_hdf5();
nerrors += test_conv_str_1()<0 ? 1 : 0;
@@ -2635,6 +2450,6 @@ main(void)
exit(1);
}
printf("All data type tests passed.\n");
- cleanup ();
+ h5_cleanup (fapl);
return 0;
}
diff --git a/test/extend.c b/test/extend.c
index a13d606..42348bc 100644
--- a/test/extend.c
+++ b/test/extend.c
@@ -8,44 +8,18 @@
* Purpose: Tests extendible datasets.
*/
-/* See H5private.h for how to include headers */
-#undef NDEBUG
-#include <hdf5.h>
+#include <h5test.h>
-#ifdef STDC_HEADERS
-# include <assert.h>
-# include <stdlib.h>
-#endif
+const char *FILENAME[] = {
+ "extend",
+ NULL
+};
-#define TEST_FILE_NAME "extend.h5"
#define NX 100 /* USE AN EVEN NUMBER!*/
#define NY 100 /* USE AN EVEN NUMBER!*/
/*-------------------------------------------------------------------------
- * Function: cleanup
- *
- * Purpose: Cleanup temporary test files
- *
- * Return: none
- *
- * Programmer: Albert Cheng
- * May 28, 1998
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static void
-cleanup(void)
-{
- if (!getenv ("HDF5_NOCLEANUP")) {
- remove(TEST_FILE_NAME);
- }
-}
-
-
-/*-------------------------------------------------------------------------
* Function: main
*
* Purpose: Tests extendible datasets
@@ -65,6 +39,7 @@ int
main (void)
{
hid_t file, dataset, mem_space, file_space, cparms;
+ hid_t fapl;
herr_t status;
int i, j, k, m;
static int buf1[NY][NX], buf2[NX/2][NY/2];
@@ -74,6 +49,11 @@ main (void)
static hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED};
static hsize_t size[2];
hssize_t offset[2];
+ char filename[1024];
+
+ TESTING("dataset extend");
+ h5_reset();
+ fapl = h5_fileaccess();
/* Initialize buffer and space */
for (i=0; i<NX; i++) {
@@ -81,22 +61,19 @@ main (void)
buf1[i][j] = i*NY+j;
}
}
- mem_space = H5Screate_simple (2, dims, maxdims);
- assert (mem_space>=0);
+ if ((mem_space = H5Screate_simple (2, dims, maxdims))<0) goto error;
/* Create the file */
- file = H5Fcreate (TEST_FILE_NAME, H5F_ACC_TRUNC|H5F_ACC_DEBUG,
- H5P_DEFAULT, H5P_DEFAULT);
- assert (file>=0);
+ h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
+ if ((file = H5Fcreate (filename, H5F_ACC_TRUNC|H5F_ACC_DEBUG,
+ H5P_DEFAULT, fapl))<0) goto error;
/* Create the dataset which is originally NX by NY */
- cparms = H5Pcreate (H5P_DATASET_CREATE);
- assert (cparms>=0);
- status = H5Pset_chunk (cparms, 2, chunk_dims);
- assert (status>=0);
- dataset = H5Dcreate (file, "dataset", H5T_NATIVE_INT, mem_space, cparms);
- assert (dataset>=0);
- H5Pclose (cparms);
+ if ((cparms = H5Pcreate (H5P_DATASET_CREATE))<0) goto error;
+ if (H5Pset_chunk (cparms, 2, chunk_dims)<0) goto error;
+ if ((dataset = H5Dcreate (file, "dataset", H5T_NATIVE_INT, mem_space,
+ cparms))<0) goto error;
+ if (H5Pclose (cparms)<0) goto error;
/* Write the data */
for (i=0; i<5; i++) {
@@ -107,57 +84,60 @@ main (void)
offset[1] = j * NY;
size[0] = offset[0] + NX;
size[1] = offset[1] + NY;
- status = H5Dextend (dataset, size);
- assert (status>=0);
+ if (H5Dextend (dataset, size)<0) goto error;
/* Select a hyperslab */
- file_space = H5Dget_space (dataset);
- assert (file_space>=0);
- status = H5Sselect_hyperslab (file_space, H5S_SELECT_SET, offset, NULL, dims, NULL);
- assert (status>=0);
+ if ((file_space = H5Dget_space (dataset))<0) goto error;
+ if (H5Sselect_hyperslab (file_space, H5S_SELECT_SET, offset,
+ NULL, dims, NULL)<0) goto error;
/* Write to the hyperslab */
- status = H5Dwrite (dataset, H5T_NATIVE_INT, mem_space, file_space,
- H5P_DEFAULT, buf1);
- assert (status>=0);
- H5Sclose (file_space);
+ if (H5Dwrite (dataset, H5T_NATIVE_INT, mem_space, file_space,
+ H5P_DEFAULT, buf1)<0) goto error;
+ if (H5Sclose (file_space)<0) goto error;
}
}
- H5Sclose (mem_space);
-
+ if (H5Sclose (mem_space)<0) goto error;
/* Read the data */
- mem_space = H5Screate_simple (2, half_dims, NULL);
- file_space = H5Dget_space (dataset);
+ if ((mem_space = H5Screate_simple (2, half_dims, NULL))<0) goto error;
+ if ((file_space = H5Dget_space (dataset))<0) goto error;
for (i=0; i<10; i++) {
for (j=0; j<10; j++) {
/* Select a hyperslab */
offset[0] = i * NX/2;
offset[1] = j * NY/2;
- assert (file_space>=0);
- status = H5Sselect_hyperslab (file_space, H5S_SELECT_SET, offset, NULL, half_dims, NULL);
- assert (status>=0);
+ if (H5Sselect_hyperslab (file_space, H5S_SELECT_SET, offset,
+ NULL, half_dims, NULL)<0) goto error;
/* Read */
- status = H5Dread (dataset, H5T_NATIVE_INT, mem_space, file_space,
- H5P_DEFAULT, buf2);
- assert (status>=0);
+ if (H5Dread (dataset, H5T_NATIVE_INT, mem_space, file_space,
+ H5P_DEFAULT, buf2)<0) goto error;
/* Compare */
for (k=0; k<NX/2; k++) {
for (m=0; m<NY/2; m++) {
- assert (buf2[k][m]==buf1[(i%2)*NX/2+k][(j%2)*NY/2+m]);
+ if (buf2[k][m]!=buf1[(i%2)*NX/2+k][(j%2)*NY/2+m]) {
+ FAILED();
+ printf(" i=%d, j=%d, k=%d, m=%d\n", i, j, k, m);
+ goto error;
+ }
}
}
}
}
- H5Dclose (dataset);
- H5Fclose (file);
+ if (H5Dclose (dataset)<0) goto error;
+ if (H5Fclose (file)<0) goto error;
+ PASSED();
printf("All extend tests passed.\n");
- cleanup();
+ h5_cleanup(fapl);
return 0;
+
+ error:
+ printf("*** One or more extend tests failed ***\n");
+ return 1;
}
diff --git a/test/external.c b/test/external.c
index a6ecc16..cfb413a 100644
--- a/test/external.c
+++ b/test/external.c
@@ -7,69 +7,20 @@
*
* Purpose: Tests datasets stored in external raw files.
*/
-
-/* See H5private.h for how to include headers */
-#undef NDEBUG
-#include <H5config.h>
-
-#ifdef STDC_HEADERS
-# include <assert.h>
-# include <fcntl.h>
-# include <stdio.h>
-# include <stdlib.h>
-# include <string.h>
-#endif
-
-#ifdef HAVE_IO_H
-# include <io.h>
-#endif
-
-#ifdef HAVE_UNISTD_H
-# include <sys/types.h>
-# include <unistd.h>
-#endif
-
-#include <hdf5.h>
-
-#ifndef HAVE_ATTRIBUTE
-# undef __attribute__
-# define __attribute__(X) /*void*/
-# define __unused__ /*void*/
+#if 1 /* have to go, and this is only half baked.... 19981120 rpm*/
+int main(void) {return 0;}
#else
-# define __unused__ __attribute__((unused))
-#endif
-#define TEST_FILE_NAME1 "extern_1.h5"
-#define TEST_FILE_NAME2 "extern_2.h5"
-#define TEST_FILE_NAME3 "extern_3.h5"
+#include <h5test.h>
-static int nerrors_g = 0;
+const char *FILENAME[] = {
+ "extern_1",
+ "extern_2",
+ "extern_3",
+ NULL
+};
-
-/*-------------------------------------------------------------------------
- * Function: display_error_cb
- *
- * Purpose: Displays the error stack after printing "*FAILED*".
- *
- * Return: Success: 0
- *
- * Failure: -1
- *
- * Programmer: Robb Matzke
- * Wednesday, March 4, 1998
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-display_error_cb (void __unused__ *client_data)
-{
- puts ("*FAILED*");
- H5Eprint (stdout);
- nerrors_g++;
- return 0;
-}
+static int nerrors_g = 0;
/*-------------------------------------------------------------------------
@@ -135,7 +86,7 @@ same_contents (const char *name1, const char *name2)
*-------------------------------------------------------------------------
*/
static void
-test_1 (void)
+test_1 (hid_t fapl)
{
hid_t file, plist, space, dset, grp;
herr_t status;
@@ -143,42 +94,37 @@ test_1 (void)
herr_t (*func)(void*) = NULL;
void *client_data = NULL;
int n;
-
+ char filename[1024];
/*
* Create the file and an initial group. This causes messages about
* debugging to be emitted before we start playing games with what the
* output looks like.
*/
- file = H5Fcreate (TEST_FILE_NAME1, H5F_ACC_TRUNC|H5F_ACC_DEBUG,
- H5P_DEFAULT, H5P_DEFAULT);
- assert (file>=0);
- grp = H5Gcreate (file, "emit-diagnostics", 8);
- H5Gclose (grp);
+ h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
+ if ((file = H5Fcreate (filename, H5F_ACC_TRUNC|H5F_ACC_DEBUG,
+ H5P_DEFAULT, fapl))<0) goto error;
+ if ((grp = H5Gcreate (file, "emit-diagnostics", 8))<0) goto error;
+ if (H5Gclose (grp)<0) goto error;
/*
* A single external file for a non-extendible dataset.
*/
- do {
- printf ("%-70s", "...fixed-size data space, exact storage");
- fflush (stdout);
- plist = H5Pcreate (H5P_DATASET_CREATE);
- assert (plist>=0);
- status = H5Pset_external (plist, "ext1.data", 0, (hsize_t)400);
- assert (status>=0);
+ TESTING("fixed-size data space, exact storage");
+ if ((plist = H5Pcreate (H5P_DATASET_CREATE))<0) goto error;
+ if (H5Pset_external (plist, "ext1.data", 0, (hsize_t)400)<0) goto error;
- size[0] = max_size[0] = 100;
- space = H5Screate_simple (1, size, max_size);
- assert (space>=0);
+ size[0] = max_size[0] = 100;
+ if ((space = H5Screate_simple (1, size, max_size))<0) goto error;
+
+ /* Create the dataset, the `dset1' name is used later too */
+ if ((dset = H5Dcreate (file, "dset1", H5T_NATIVE_INT, space, plist))<0)
+ goto error;
+ if (H5Dclose (dset)<0) goto error;
+ if (H5Sclose (space)<0) goto error;
+ if (H5Pclose (plist)<0) goto error;
+ PASSED();
- /* Create the dataset, the `dset1' name is used later too */
- dset = H5Dcreate (file, "dset1", H5T_NATIVE_INT, space, plist);
- if (dset<0) break;
- H5Dclose (dset);
- puts (" PASSED");
- } while (0);
- H5Sclose (space);
- H5Pclose (plist);
/*
* A single external file which is too small to represent all the data.
@@ -490,6 +436,8 @@ test_1 (void)
/* END OF TESTS */
H5Fclose (file);
+
+ error:
}
@@ -586,7 +534,7 @@ test_2 (void)
puts (" Failed to read dataset");
break;
}
-
+
for (i=0; i<100; i++) {
if (whole[i]!=(signed)i) {
puts ("*FAILED*");
@@ -856,3 +804,4 @@ main (void)
return (nerrors_g?1:0);
}
+#endif
diff --git a/test/flush1.c b/test/flush1.c
index 17b2c46..f353100 100644
--- a/test/flush1.c
+++ b/test/flush1.c
@@ -107,13 +107,13 @@ main(void)
/* Write some data */
for (i=0; i<ds_size[0]; i++) {
- /*
- * The extra cast in the following statement is a bug workaround
- * for the Win32 version 5.0 compiler.
- * 1998-11-06 ptl
- */
+ /*
+ * The extra cast in the following statement is a bug workaround
+ * for the Win32 version 5.0 compiler.
+ * 1998-11-06 ptl
+ */
for (j=0; j<ds_size[1]; j++) {
- the_data[i][j] = (double)((hssize_t)(i/(j+1)));
+ the_data[i][j] = (double)(hssize_t)i/((hssize_t)(j+1));
}
}
if (H5Dwrite(dset, H5T_NATIVE_DOUBLE, space, space, H5P_DEFAULT,
diff --git a/test/flush2.c b/test/flush2.c
index 95818b8..42fcdab 100644
--- a/test/flush2.c
+++ b/test/flush2.c
@@ -131,7 +131,7 @@ main(void)
* for the Win32 version 5.0 compiler.
* 1998-11-06 ptl
*/
- error = fabs(the_data[i][j]-(double)((hssize_t)(i/(j+1))));
+ error = fabs(the_data[i][j]-(double)(hssize_t)i/((hssize_t)j+1));
assert(error<0.0001);
}
}
diff --git a/test/h5test.c b/test/h5test.c
new file mode 100644
index 0000000..4144455
--- /dev/null
+++ b/test/h5test.c
@@ -0,0 +1,366 @@
+/*
+ * Copyright © 1998 NCSA
+ * All rights reserved.
+ *
+ * Programmer: Robb Matzke <matzke@llnl.gov>
+ * Thursday, November 19, 1998
+ *
+ * Purpose: Provides support functions for most of the hdf5 tests cases.
+ *
+ */
+
+#undef NDEBUG /*override -DNDEBUG */
+#include <h5test.h>
+
+/*
+ * Define these environment variables or constants to influence functions in
+ * this test support library. The environment variable is used in preference
+ * to the cpp constant. If neither is defined then use some default value.
+ *
+ * HDF5_PREFIX: A string to add to the beginning of all file names.
+ * This can be used to tell MPIO what driver to use
+ * (e.g., "gfs:", "ufs:", or "nfs:") or to use a
+ * different file system (e.g., "/tmp" or "/usr/tmp").
+ * The prefix will be separated from the base file name
+ * by a slash. See h5_fixname() for details.
+ *
+ * HDF5_DRIVER: This string describes what low level file driver to
+ * use for HDF5 file access. The first word in the
+ * value is the name of the driver and subsequent data
+ * is interpreted according to the driver. See
+ * h5_fileaccess() for details.
+ *
+ */
+
+
+
+/*-------------------------------------------------------------------------
+ * Function: h5_errors
+ *
+ * Purpose: Displays the error stack after printing "*FAILED*".
+ *
+ * Return: Success: 0
+ *
+ * Failure: -1
+ *
+ * Programmer: Robb Matzke
+ * Wednesday, March 4, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+h5_errors(void __unused__ *client_data)
+{
+ FAILED();
+ H5Eprint (stdout);
+ return 0;
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: h5_cleanup
+ *
+ * Purpose: Cleanup temporary test files. The list of test files is in
+ * `extern const char *FILENAMES[]' -- these are only the base
+ * names. The file access property list is also closed.
+ *
+ * Return: none
+ *
+ * Programmer: Albert Cheng
+ * May 28, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+void
+h5_cleanup(hid_t fapl)
+{
+ char filename[1024];
+ char temp[2048];
+ int i, j;
+
+ if (!getenv("HDF5_NOCLEANUP")) {
+ for (i=0; FILENAME[i]; i++) {
+ if (NULL==h5_fixname(FILENAME[i], fapl, filename,
+ sizeof filename)) {
+ continue;
+ }
+
+ switch (H5Pget_driver(fapl)) {
+ case H5F_LOW_CORE:
+ break; /*nothing to remove*/
+
+ case H5F_LOW_SPLIT:
+ snprintf(temp, sizeof temp, "%s.raw", filename);
+ remove(temp);
+ snprintf(temp, sizeof temp, "%s.meta", filename);
+ remove(temp);
+ break;
+
+ case H5F_LOW_FAMILY:
+ for (j=0; /*void*/; j++) {
+ snprintf(temp, sizeof temp, filename, j);
+ if (access(temp, F_OK)<0) break;
+ remove(temp);
+ }
+ break;
+
+ default:
+ remove(filename);
+ break;
+ }
+ }
+ }
+ H5Pclose(fapl);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: h5_reset
+ *
+ * Purpose: Reset the library by closing it.
+ *
+ * Return: void
+ *
+ * Programmer: Robb Matzke
+ * Friday, November 20, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+void
+h5_reset(void)
+{
+ fflush(stdout);
+ fflush(stderr);
+ H5close();
+ H5Eset_auto (h5_errors, NULL);}
+
+
+/*-------------------------------------------------------------------------
+ * Function: h5_fixname
+ *
+ * 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.
+ *
+ * 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
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+char *
+h5_fixname(const char *basename, hid_t fapl, char *fullname, size_t size)
+{
+ const char *prefix=NULL, *suffix=NULL;
+ H5F_driver_t driver;
+
+ if (!basename || !fullname || size<1) return NULL;
+
+ /* First use the environment variable, then try the constant */
+ prefix = getenv("HDF5_PREFIX");
+#ifdef HDF5_PREFIX
+ if (!prefix) prefix = HDF5_PREFIX;
+#endif
+
+ /* Prepend the prefix value to the base name */
+ if (prefix && *prefix) {
+ if (snprintf(fullname, size, "%s/%s", prefix, basename)==(int)size) {
+ return NULL; /*buffer is too small*/
+ }
+ } else if (strlen(basename)>=size) {
+ return NULL; /*buffer is too small*/
+ } else {
+ strcpy(fullname, basename);
+ }
+
+ /* Append a suffix */
+ if ((driver=H5Pget_driver(fapl))<0) return NULL;
+ switch (driver) {
+ case H5F_LOW_SPLIT:
+ case H5F_LOW_CORE:
+ suffix = NULL;
+ break;
+ case H5F_LOW_FAMILY:
+ suffix = "%05d.h5";
+ break;
+ default:
+ suffix = ".h5";
+ break;
+ }
+ if (suffix) {
+ if (strlen(fullname)+strlen(suffix)>=size) return NULL;
+ strcat(fullname, suffix);
+ }
+
+ return fullname;
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: h5_fileaccess
+ *
+ * Purpose: Returns a file access template which is the default template
+ * but with a file driver set according to the constant or
+ * environment variable HDF5_DRIVER
+ *
+ * Return: Success: A file access property list
+ *
+ * Failure: -1
+ *
+ * Programmer: Robb Matzke
+ * Thursday, November 19, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+hid_t
+h5_fileaccess(void)
+{
+ const char *val = NULL;
+ const char *name;
+ char s[1024];
+ hid_t fapl = -1;
+ hsize_t fam_size = 1024*1024;
+
+ /* First use the environment variable, then the constant */
+ val = getenv("HDF5_DRIVER");
+#ifdef HDF5_DRIVER
+ if (!val) val = HDF5_DRIVER;
+#endif
+
+ if ((fapl=H5Pcreate(H5P_FILE_ACCESS))<0) return -1;
+ if (!val || !*val) return fapl; /*use default*/
+
+ strncpy(s, val, sizeof s);
+ s[sizeof(s)-1] = '\0';
+ if (NULL==(name=strtok(s, " \t\n\r"))) return fapl;
+
+ if (!strcmp(name, "sec2")) {
+ /* Unix read() and write() system calls */
+ if (H5Pset_sec2(fapl)<0) return -1;
+ } else if (!strcmp(name, "stdio")) {
+ /* C standard I/O library */
+ if (H5Pset_stdio(fapl)<0) return -1;
+ } else if (!strcmp(name, "core")) {
+ /* In-core temporary file with 1MB increment */
+ if (H5Pset_core(fapl, 1024*1024)<0) return -1;
+ } else if (!strcmp(name, "split")) {
+ /* Split meta data and raw data each using default driver */
+ if (H5Pset_split(fapl, NULL, H5P_DEFAULT, NULL, H5P_DEFAULT)<0)
+ return -1;
+ } else if (!strcmp(name, "family")) {
+ /* Family of files, each 1MB and using the default driver */
+ if ((val=strtok(NULL, " \t\n\r"))) {
+ fam_size = strtod(val, NULL) * 1024*1024;
+ }
+ if (H5Pset_family(fapl, fam_size, H5P_DEFAULT)<0) return -1;
+ } else {
+ /* Unknown driver */
+ return -1;
+ }
+
+ return fapl;
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: h5_no_hwconv
+ *
+ * Purpose: Turn off hardware data type conversions.
+ *
+ * Return: void
+ *
+ * Programmer: Robb Matzke
+ * Friday, November 20, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+void
+h5_no_hwconv(void)
+{
+ H5Tunregister(H5T_conv_char_uchar);
+ H5Tunregister(H5T_conv_char_short);
+ H5Tunregister(H5T_conv_char_ushort);
+ H5Tunregister(H5T_conv_char_int);
+ H5Tunregister(H5T_conv_char_uint);
+ H5Tunregister(H5T_conv_char_long);
+ H5Tunregister(H5T_conv_char_ulong);
+
+ H5Tunregister(H5T_conv_uchar_char);
+ H5Tunregister(H5T_conv_uchar_short);
+ H5Tunregister(H5T_conv_uchar_ushort);
+ H5Tunregister(H5T_conv_uchar_int);
+ H5Tunregister(H5T_conv_uchar_uint);
+ H5Tunregister(H5T_conv_uchar_long);
+ H5Tunregister(H5T_conv_uchar_ulong);
+
+ H5Tunregister(H5T_conv_short_char);
+ H5Tunregister(H5T_conv_short_uchar);
+ H5Tunregister(H5T_conv_short_ushort);
+ H5Tunregister(H5T_conv_short_int);
+ H5Tunregister(H5T_conv_short_uint);
+ H5Tunregister(H5T_conv_short_long);
+ H5Tunregister(H5T_conv_short_ulong);
+
+ H5Tunregister(H5T_conv_ushort_char);
+ H5Tunregister(H5T_conv_ushort_uchar);
+ H5Tunregister(H5T_conv_ushort_short);
+ H5Tunregister(H5T_conv_ushort_int);
+ H5Tunregister(H5T_conv_ushort_uint);
+ H5Tunregister(H5T_conv_ushort_long);
+ H5Tunregister(H5T_conv_ushort_ulong);
+
+ H5Tunregister(H5T_conv_int_char);
+ H5Tunregister(H5T_conv_int_uchar);
+ H5Tunregister(H5T_conv_int_short);
+ H5Tunregister(H5T_conv_int_ushort);
+ H5Tunregister(H5T_conv_int_uint);
+ H5Tunregister(H5T_conv_int_long);
+ H5Tunregister(H5T_conv_int_ulong);
+
+ H5Tunregister(H5T_conv_uint_char);
+ H5Tunregister(H5T_conv_uint_uchar);
+ H5Tunregister(H5T_conv_uint_short);
+ H5Tunregister(H5T_conv_uint_ushort);
+ H5Tunregister(H5T_conv_uint_int);
+ H5Tunregister(H5T_conv_uint_long);
+ H5Tunregister(H5T_conv_uint_ulong);
+
+ H5Tunregister(H5T_conv_long_char);
+ H5Tunregister(H5T_conv_long_uchar);
+ H5Tunregister(H5T_conv_long_short);
+ H5Tunregister(H5T_conv_long_ushort);
+ H5Tunregister(H5T_conv_long_int);
+ H5Tunregister(H5T_conv_long_uint);
+ H5Tunregister(H5T_conv_long_ulong);
+
+ H5Tunregister(H5T_conv_ulong_char);
+ H5Tunregister(H5T_conv_ulong_uchar);
+ H5Tunregister(H5T_conv_ulong_short);
+ H5Tunregister(H5T_conv_ulong_ushort);
+ H5Tunregister(H5T_conv_ulong_int);
+ H5Tunregister(H5T_conv_ulong_uint);
+ H5Tunregister(H5T_conv_ulong_long);
+
+ H5Tunregister(H5T_conv_float_double);
+ H5Tunregister(H5T_conv_double_float);
+}
diff --git a/test/h5test.h b/test/h5test.h
new file mode 100644
index 0000000..fa69b9f
--- /dev/null
+++ b/test/h5test.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright © 1998 NCSA
+ * All rights reserved.
+ *
+ * Programmer: Robb Matzke <matzke@llnl.gov>
+ * Friday, November 20, 1998
+ *
+ * Purpose: Test support stuff.
+ */
+#ifndef _H5TEST_H
+#define _H5TEST_H
+
+#undef NDEBUG
+#include <hdf5.h>
+
+#include <H5private.h>
+#ifdef STDC_HEADERS
+# include <signal.h>
+#endif
+
+#define H5T_PACKAGE
+#include <H5Tpkg.h> /*to turn off hardware conversions*/
+
+
+/*
+ * This array should contain a list of file base names created by the test.
+ * The base name is a word like `test' which will have a prefix and suffix
+ * added to result in something like `ufs:/u/matzke/test.h5'
+ */
+extern const char *FILENAME[];
+
+/*
+ * The name of the test is printed by saying TESTING("something") which will
+ * result in the string `Testing something' being flushed to standard output.
+ * If a test passes, fails, or is skipped then the PASSED(), FAILED(), or
+ * SKIPPED() macro should be called. After FAILED() or SKIPPED() the caller
+ * should print additional information to stdout indented by at least four
+ * spaces. If the h5_errors() is used for automatic error handling then
+ * the FAILED() macro is invoked automatically when an API function fails.
+ */
+#define TESTING(WHAT) {printf("%-70s", "Testing " WHAT); fflush(stdout);}
+#define PASSED() puts(" PASSED")
+#define FAILED() puts("*FAILED*")
+#define SKIPPED() puts(" -SKIP-")
+
+/*
+ * Print the current location on the standard output stream.
+ */
+#define AT() printf (" at %s:%d in %s()...\n", \
+ __FILE__, __LINE__, __FUNCTION__);
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void h5_cleanup(hid_t fapl);
+void h5_cleanup(hid_t fapl);
+herr_t h5_errors(void __unused__ *client_data);
+char *h5_fixname(const char *basename, hid_t fapl, char *fullname,
+ size_t size);
+hid_t h5_fileaccess(void);
+void h5_no_hwconv(void);
+void h5_reset(void);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/test/iopipe.c b/test/iopipe.c
index ca1b375..0e1fb12 100644
--- a/test/iopipe.c
+++ b/test/iopipe.c
@@ -188,7 +188,7 @@ main (void)
* 1998-11-06 ptl
*/
printf ("I/O request size is %1.1fMB\n",
- ((double)((hssize_t)(size[0]*size[1])))/(1024.0*1024));
+ (double)(hssize_t)(size[0]*size[1])/1024.0*1024);
/* Open the files */
file = H5Fcreate (HDF5_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
diff --git a/test/overhead.c b/test/overhead.c
index 13a6c7d..4656fa5 100644
--- a/test/overhead.c
+++ b/test/overhead.c
@@ -10,7 +10,7 @@
/* See H5private.h for how to include headers */
#undef NDEBUG
-#include <H5config.h>
+#include <hdf5.h>
#ifdef STDC_HEADERS
# include <ctype.h>
@@ -29,7 +29,9 @@
# include <unistd.h>
#endif
-#include <hdf5.h>
+#ifdef HAVE_IO_H
+# include <io.h>
+#endif
#ifndef HAVE_ATTRIBUTE
# undef __attribute__
@@ -244,14 +246,14 @@ test(fill_t fill_style, const double splits[],
if (verbose) {
if (H5Fflush(file, H5F_SCOPE_LOCAL)<0) goto error;
if (fstat(fd, &sb)<0) goto error;
- /*
+ /*
* The extra cast in the following statement is a bug workaround
* for the Win32 version 5.0 compiler.
* 1998-11-06 ptl
*/
- printf("%4lu %8.3f\n",
+ printf("%4lu %8.3f ***\n",
(unsigned long)i,
- (double)((hssize_t)((sb.st_size-i*sizeof(int))/i)));
+ (double)(hssize_t)(sb.st_size-i*sizeof(int))/(hssize_t)i);
}
}
@@ -282,14 +284,14 @@ test(fill_t fill_style, const double splits[],
abort();
}
if (fstat(fd, &sb)<0) goto error;
- /*
- * The extra cast in the following statement is a bug workaround
- * for the Win32 version 5.0 compiler.
- * 1998-11-06 ptl
- */
- printf("%-7s %8.3f\n", sname,
- (double)((hssize_t)((sb.st_size-cur_size[0]*sizeof(int))/cur_size[0])));
-
+ /*
+ * The extra cast in the following statement is a bug workaround
+ * for the Win32 version 5.0 compiler.
+ * 1998-11-06 ptl
+ */
+ printf("%-7s %8.3f\n", sname,
+ (double)(hssize_t)(sb.st_size-cur_size[0]*sizeof(int))/
+ (hssize_t)cur_size[0]);
}
close(fd);
return 0;
diff --git a/test/ragged.c b/test/ragged.c
index f9f1f99..6b75dab 100644
--- a/test/ragged.c
+++ b/test/ragged.c
@@ -8,8 +8,13 @@
/* See H5private.h for how to include headers */
#undef NDEBUG
+#include <hdf5.h>
#include <H5private.h> /*for performance monitoring*/
+#ifdef STDC_HEADERS
+# include <signal.h>
+#endif
+
#define NOTIFY_INTERVAL 2 /*seconds*/
#define TIME_LIMIT 60 /*seconds*/
#define CH_SIZE 8192*8 /*approx chunk size in bytes*/
@@ -242,7 +247,7 @@ ragged_write_all(hid_t ra, hsize_t rows_at_once)
* 1998-11-06 ptl
*/
H5_bandwidth(s,
- (double)((hssize_t)interval_nelmts)*sizeof(C_MTYPE),
+ (double)(hssize_t)interval_nelmts*sizeof(C_MTYPE),
timer.etime);
printf(" %8lu %8lu %7.3f%% %10s%s\n",
(unsigned long)(row+i), (unsigned long)total_nelmts,
@@ -261,7 +266,7 @@ ragged_write_all(hid_t ra, hsize_t rows_at_once)
* the Win32 version 5.0 compiler.
* 1998-11-06 ptl
*/
- H5_bandwidth(s, (double)((hssize_t)interval_nelmts)*sizeof(C_MTYPE),
+ H5_bandwidth(s, (double)(hssize_t)interval_nelmts*sizeof(C_MTYPE),
timer.etime);
printf(" %8lu %8lu %7.3f%% %10s\n",
(unsigned long)row, (unsigned long)total_nelmts,
@@ -375,8 +380,7 @@ ragged_read_all(hid_t ra, hsize_t rows_at_once)
* for the Win32 version 5.0 compiler.
* 1998-11-06 ptl
*/
- H5_bandwidth(s,
- (double)((hssize_t)interval_nelmts)*sizeof(C_MTYPE),
+ H5_bandwidth(s, (double)(hssize_t)interval_nelmts*sizeof(C_MTYPE),
timer.etime);
printf(" %8lu %8lu %7.3f%% %10s%s\n",
(unsigned long)(row+i), (unsigned long)total_nelmts,
@@ -403,7 +407,7 @@ ragged_read_all(hid_t ra, hsize_t rows_at_once)
* the Win32 version 5.0 compiler.
* 1998-11-06 ptl
*/
- H5_bandwidth(s, (double)((hssize_t)interval_nelmts)*sizeof(C_MTYPE),
+ H5_bandwidth(s, (double)(hssize_t)interval_nelmts*sizeof(C_MTYPE),
timer.etime);
printf(" %8lu %8lu %7.3f%% %10s\n",
(unsigned long)row, (unsigned long)total_nelmts,
@@ -540,7 +544,7 @@ ragged_read_short(hid_t ra, hsize_t rows_at_once, hsize_t width)
* 1998-11-06 ptl
*/
H5_bandwidth(s,
- (double)((hssize_t)interval_nelmts)*sizeof(C_MTYPE),
+ (double)(hssize_t)interval_nelmts*sizeof(C_MTYPE),
timer.etime);
printf(" %8lu %8lu %7.3f%% %10s%s\n",
(unsigned long)(row+i), (unsigned long)read_nelmts,
@@ -567,7 +571,7 @@ ragged_read_short(hid_t ra, hsize_t rows_at_once, hsize_t width)
* the Win32 version 5.0 compiler.
* 1998-11-06 ptl
*/
- H5_bandwidth(s, (double)((hssize_t)interval_nelmts)*sizeof(C_MTYPE),
+ H5_bandwidth(s, (double)(hssize_t)interval_nelmts*sizeof(C_MTYPE),
timer.etime);
printf(" %8lu %8lu %7.3f%% %10s\n",
(unsigned long)row, (unsigned long)read_nelmts,
@@ -579,7 +583,7 @@ ragged_read_short(hid_t ra, hsize_t rows_at_once, hsize_t width)
* Win32 version 5.0 compiler.
* 1998-11-06 ptl
*/
- H5_bandwidth(s, (double)((hssize_t)read_nelmts)*sizeof(C_MTYPE),
+ H5_bandwidth(s, (double)(hssize_t)read_nelmts*sizeof(C_MTYPE),
timer_total.etime);
printf(" %27s%10s\n", "", s);