summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>1998-02-28 18:19:05 (GMT)
committerRobb Matzke <matzke@llnl.gov>1998-02-28 18:19:05 (GMT)
commit808a5e6be1b7f1025c6b1182e160cefbce0f8e68 (patch)
tree59eabaf3e7991d5791b83dbaa0d5797fc5e44ae9 /test
parent0b4d32bb4a12fe0e34026c0f069aa99bf34cd834 (diff)
downloadhdf5-808a5e6be1b7f1025c6b1182e160cefbce0f8e68.zip
hdf5-808a5e6be1b7f1025c6b1182e160cefbce0f8e68.tar.gz
hdf5-808a5e6be1b7f1025c6b1182e160cefbce0f8e68.tar.bz2
[svn-r302] Changes since 19980227
---------------------- ./html/Errors.html [NEW] ./html/H5.user.html ./MANIFEST Documents the new error handling interface and gives examples. ./src/H5.c ./src/H5private.h ./src/H5Apublic.h ./src/H5E.c ./src/H5Eprivate.h ./src/H5Epublic.h Rewrote error handling. Got rid of `push' overloading and added a few API functions. The error stack is statically allocated and not entered into H5A, simplifying error handling within the error handler. Rudimentary support for threads. Changed the names of some errors. ./src/H5G.c ./src/H5Gnode.c ./src/H5H.c ./src/H5O.c ./src/H5T.c Changed H5ECLEAR to H5E_clear(). ./src/Makefile.in Alphabetized source list. ./test/dsets.c Turned off error reporting around functions that are expected to fail. Error messages are sent to stdout. ./test/testhdf5.c ./test/testhdf5.h Turned off automatic error reporting since this file mostly calls internal functions and does its own error reporting.
Diffstat (limited to 'test')
-rw-r--r--test/dsets.c21
-rw-r--r--test/testhdf5.c7
-rw-r--r--test/testhdf5.h88
3 files changed, 79 insertions, 37 deletions
diff --git a/test/dsets.c b/test/dsets.c
index 5d05288..8b373b0 100644
--- a/test/dsets.c
+++ b/test/dsets.c
@@ -11,11 +11,9 @@
#include <hdf5.h>
#include <math.h>
#include <stdio.h>
+#include <stdlib.h>
#include <unistd.h>
-#include <H5Eprivate.h>
-
-
#ifndef HAVE_FUNCTION
#undef __FUNCTION__
#define __FUNCTION__ ""
@@ -83,12 +81,16 @@ test_create(hid_t file)
}
goto error;
}
+
/*
* Try creating a dataset that already exists. This should fail since a
- * dataset can only be created once.
+ * dataset can only be created once. Temporarily turn off error
+ * reporting.
*/
+ H5Eset_auto (NULL, NULL);
dataset = H5Dcreate(file, DSET_DEFAULT_NAME, H5T_NATIVE_DOUBLE, space,
H5P_DEFAULT);
+ H5Eset_auto ((herr_t(*)(void*))H5Eprint, stdout);
if (dataset >= 0) {
puts("*FAILED*");
if (!isatty(1)) {
@@ -97,6 +99,7 @@ test_create(hid_t file)
}
goto error;
}
+
/*
* Open the dataset we created above and then close it. This is how
* existing datasets are accessed.
@@ -118,11 +121,15 @@ test_create(hid_t file)
}
goto error;
}
+
/*
* Try opening a non-existent dataset. This should fail since new datasets
- * cannot be created with this function.
+ * cannot be created with this function. Temporarily turn off error
+ * reporting.
*/
+ H5Eset_auto (NULL, NULL);
dataset = H5Dopen(file, "does_not_exist");
+ H5Eset_auto ((herr_t(*)(void*))H5Eprint, stdout);
if (dataset >= 0) {
puts("*FAILED*");
if (!isatty(1)) {
@@ -312,7 +319,6 @@ test_tconv(hid_t file)
/* Write the data to the dataset */
status = H5Dwrite(dataset, H5T_NATIVE_INT32, H5S_ALL, H5S_ALL,
H5P_DEFAULT, out);
- if (status<0) H5Eprint (H5E_thrdid_g, stdout);
assert(status >= 0);
/* Create a new type with the opposite byte order */
@@ -374,6 +380,9 @@ main(void)
status = H5open ();
assert (status>=0);
+ /* Automatic error reporting to standard output */
+ H5Eset_auto ((herr_t(*)(void*))H5Eprint, stdout);
+
unlink("dataset.h5");
file = H5Fcreate("dataset.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
assert(file >= 0);
diff --git a/test/testhdf5.c b/test/testhdf5.c
index b122606..40abfb5 100644
--- a/test/testhdf5.c
+++ b/test/testhdf5.c
@@ -152,6 +152,13 @@ main(int argc, char *argv[])
setbuf(stdout, NULL);
#endif
+ /*
+ * Turn off automatic error reporting since we do it ourselves. Besides,
+ * half the functions this test calls are private, so automatic error
+ * reporting wouldn't do much good since it's triggered at the API layer.
+ */
+ H5Eset_auto (NULL, NULL);
+
/* Tests are generally arranged from least to most complexity... */
InitTest("metadata", test_metadata, "Encode/decode metadata code");
InitTest("file", test_file, "Low-Level File I/O");
diff --git a/test/testhdf5.h b/test/testhdf5.h
index ed9e0a3..0288880 100644
--- a/test/testhdf5.h
+++ b/test/testhdf5.h
@@ -31,51 +31,77 @@ extern int Verbosity;
/* Use %ld to print the value because long should cover most cases. */
/* Used to make certain a return value _is_not_ a value */
-#define CHECK(ret, val, where) \
-do {if (Verbosity>9) print_func(" Call to routine: %15s at line %4d in %s returned %ld \n",where,(int)__LINE__,__FILE__,(long)ret);\
-if(ret == val) {print_func("*** UNEXPECTED RETURN from %s is %ld at line %4d in %s\n", where, (long)ret, (int)__LINE__,__FILE__); num_errs++;H5Eprint (H5E_thrdid_g, stdout);} H5Eclear(H5E_thrdid_g);\
+#define CHECK(ret, val, where) do { \
+ if (Verbosity>9) print_func(" Call to routine: %15s at line %4d " \
+ "in %s returned %ld \n", \
+ where, (int)__LINE__, __FILE__, \
+ (long)ret); \
+ if (ret == val) { \
+ print_func("*** UNEXPECTED RETURN from %s is %ld at line %4d " \
+ "in %s\n", where, (long)ret, (int)__LINE__, __FILE__); \
+ num_errs++; \
+ H5Eprint (stdout); \
+ } \
+ H5Eclear(); \
} while(0)
-#define CHECK_I(ret,where) { \
- if (Verbosity>9) { \
+#define CHECK_I(ret,where) { \
+ if (Verbosity>9) { \
print_func(" Call to routine: %15s at line %4d in %s returned %ld\n", \
- (where), (int)__LINE__, __FILE__, (long)(ret)); \
- } \
- if ((ret)<0) { \
+ (where), (int)__LINE__, __FILE__, (long)(ret)); \
+ } \
+ if ((ret)<0) { \
print_func ("*** UNEXPECTED RETURN from %s is %ld line %4d in %s\n", \
- (where), (long)(ret), (int)__LINE__, __FILE__); \
- H5Eprint (H5E_thrdid_g, stdout); \
- num_errs++; \
- } \
- H5Eclear (H5E_thrdid_g); \
+ (where), (long)(ret), (int)__LINE__, __FILE__); \
+ H5Eprint (stdout); \
+ num_errs++; \
+ } \
+ H5Eclear (); \
}
-#define CHECK_PTR(ret,where) { \
- if (Verbosity>9) { \
+#define CHECK_PTR(ret,where) { \
+ if (Verbosity>9) { \
print_func(" Call to routine: %15s at line %4d in %s returned %p\n", \
- (where), (int)__LINE__, __FILE__, (ret)); \
- } \
- if (!(ret)) { \
+ (where), (int)__LINE__, __FILE__, (ret)); \
+ } \
+ if (!(ret)) { \
print_func ("*** UNEXPECTED RETURN from %s is NULL line %4d in %s\n", \
- (where), (int)__LINE__, __FILE__); \
- H5Eprint (H5E_thrdid_g, stdout); \
- num_errs++; \
- } \
- H5Eclear (H5E_thrdid_g); \
+ (where), (int)__LINE__, __FILE__); \
+ H5Eprint (stdout); \
+ num_errs++; \
+ } \
+ H5Eclear (); \
}
/* Used to make certain a return value _is_ a value */
-#define VERIFY(x, val, where) \
-do {if (Verbosity>9) print_func(" Call to routine: %15s at line %4d in %s had value %ld \n",where,(int)__LINE__,__FILE__,(long)x);\
-if(x != val) {print_func("*** UNEXPECTED VALUE from %s is %ld at line %4d in %s\n", where, (long)x,(int)__LINE__,__FILE__); H5Eprint (H5E_thrdid_g, stdout);num_errs++;}H5Eclear(H5E_thrdid_g); \
+#define VERIFY(x, val, where) do { \
+ if (Verbosity>9) { \
+ print_func(" Call to routine: %15s at line %4d in %s had value " \
+ "%ld \n", where, (int)__LINE__, __FILE__, (long)x); \
+ } \
+ if (x != val) { \
+ print_func("*** UNEXPECTED VALUE from %s is %ld at line %4d " \
+ "in %s\n", where, (long)x, (int)__LINE__, __FILE__); \
+ H5Eprint (stdout); \
+ num_errs++; \
+ } \
+ H5Eclear(); \
} while(0)
/* Used to document process through a test and to check for errors */
-#define RESULT(ret,func) \
-do { \
-if (Verbosity>8) print_func(" Call to routine: %15s at line %4d in %s returned %ld \n",func,(int)__LINE__,__FILE__,(long)ret); \
-if (Verbosity>9) HEprint(stdout,0); \
-if(ret == FAIL) {print_func("*** UNEXPECTED RETURN from %s is %ld at line %4d in %s\n", func, (long)ret,(int)__LINE__,__FILE__); H5Eprint (H5E_thrdid_g, stdout); num_errs++;} H5Eclear(H5E_thrdid_g);\
+#define RESULT(ret,func) do { \
+ if (Verbosity>8) { \
+ print_func(" Call to routine: %15s at line %4d in %s returned " \
+ "%ld\n", func, (int)__LINE__, __FILE__, (long)ret); \
+ } \
+ if (Verbosity>9) HEprint(stdout, 0); \
+ if (ret == FAIL) { \
+ print_func("*** UNEXPECTED RETURN from %s is %ld at line %4d " \
+ "in %s\n", func, (long)ret, (int)__LINE__, __FILE__); \
+ H5Eprint (stdout); \
+ num_errs++; \
+ } \
+ H5Eclear(); \
} while(0)
/* Used to document process through a test */