summaryrefslogtreecommitdiffstats
path: root/test/h5test.c
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 /test/h5test.c
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.
Diffstat (limited to 'test/h5test.c')
-rw-r--r--test/h5test.c366
1 files changed, 366 insertions, 0 deletions
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);
+}