summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-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
16 files changed, 1269 insertions, 1209 deletions
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);