2
0
mirror of https://github.com/HDFGroup/hdf5.git synced 2025-03-19 16:50:46 +08:00

[svn-r489] Changed more API functions to the new names as documented. Also, added

stub for testing selections.
This commit is contained in:
Quincey Koziol 1998-07-14 16:14:12 -05:00
parent 41b05e1ce0
commit bf5165c748
8 changed files with 284 additions and 114 deletions

@ -1,27 +1,9 @@
tattr.o: \
tattr.c \
testhdf5.o: \
testhdf5.c \
testhdf5.h \
../src/H5private.h \
../src/H5public.h \
../src/H5config.h \
../src/H5Eprivate.h \
../src/H5Epublic.h \
../src/H5Ipublic.h \
../src/hdf5.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
../src/H5Bpublic.h \
../src/H5Dpublic.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/H5Spublic.h
../src/H5config.h
tfile.o: \
tfile.c \
testhdf5.h \
@ -124,33 +106,34 @@ tstab.o: \
../src/H5Tpublic.h \
../src/H5Sprivate.h \
../src/H5Spublic.h
th5s.o: \
th5s.c \
testhdf5.h \
../src/H5private.h \
dtypes.o: \
dtypes.c \
../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
../src/H5Eprivate.h \
../src/H5Epublic.h \
../src/H5Ipublic.h \
../src/H5Bprivate.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
../src/H5Bpublic.h \
../src/H5Fprivate.h \
../src/H5Fpublic.h \
../src/H5Dpublic.h \
../src/H5Sprivate.h \
../src/H5Spublic.h \
../src/H5Gprivate.h \
../src/H5Epublic.h \
../src/H5Fpublic.h \
../src/H5Gpublic.h \
../src/H5Oprivate.h \
../src/H5Opublic.h \
../src/H5HGprivate.h \
../src/H5HGpublic.h \
../src/H5Tprivate.h \
../src/H5Tpublic.h \
../src/H5Zprivate.h \
../src/H5HLpublic.h \
../src/H5MFpublic.h \
../src/H5MMpublic.h \
../src/H5Opublic.h \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
../src/H5Pprivate.h
../src/H5Spublic.h \
../src/H5Tpublic.h \
../src/H5Tpkg.h \
../src/H5HGprivate.h \
../src/H5Fprivate.h \
../src/H5private.h \
../src/H5Tprivate.h \
../src/H5Gprivate.h
hyperslab.o: \
hyperslab.c \
../src/H5private.h \
@ -182,8 +165,8 @@ istore.o: \
../src/H5Tprivate.h \
../src/H5Tpublic.h \
../src/H5Sprivate.h
dsets.o: \
dsets.c \
cmpd_dset.o: \
cmpd_dset.c \
../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
@ -202,8 +185,7 @@ dsets.o: \
../src/H5Opublic.h \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
../src/H5Spublic.h \
../src/H5Tpublic.h
../src/H5Spublic.h
extend.o: \
extend.c \
../src/hdf5.h \
@ -391,17 +373,20 @@ bittests.o: \
../src/H5Gprivate.h \
../src/H5Gpublic.h \
../src/H5Bprivate.h
cmpd_dset.o: \
cmpd_dset.c \
../src/hdf5.h \
tattr.o: \
tattr.c \
testhdf5.h \
../src/H5private.h \
../src/H5public.h \
../src/H5config.h \
../src/H5Eprivate.h \
../src/H5Epublic.h \
../src/H5Ipublic.h \
../src/hdf5.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 \
@ -412,14 +397,59 @@ cmpd_dset.o: \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
../src/H5Spublic.h
testhdf5.o: \
testhdf5.c \
tselect.o: \
tselect.c \
testhdf5.h \
../src/H5private.h \
../src/H5public.h \
../src/H5config.h
dtypes.o: \
dtypes.c \
../src/H5config.h \
../src/H5Eprivate.h \
../src/H5Epublic.h \
../src/H5Ipublic.h \
../src/hdf5.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
../src/H5Bpublic.h \
../src/H5Dpublic.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/H5Spublic.h
th5s.o: \
th5s.c \
testhdf5.h \
../src/H5private.h \
../src/H5public.h \
../src/H5config.h \
../src/H5Eprivate.h \
../src/H5Epublic.h \
../src/H5Ipublic.h \
../src/H5Bprivate.h \
../src/H5Bpublic.h \
../src/H5Fprivate.h \
../src/H5Fpublic.h \
../src/H5Dpublic.h \
../src/H5Sprivate.h \
../src/H5Spublic.h \
../src/H5Gprivate.h \
../src/H5Gpublic.h \
../src/H5Oprivate.h \
../src/H5Opublic.h \
../src/H5HGprivate.h \
../src/H5HGpublic.h \
../src/H5Tprivate.h \
../src/H5Tpublic.h \
../src/H5Zprivate.h \
../src/H5Zpublic.h \
../src/H5Pprivate.h
dsets.o: \
dsets.c \
../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
@ -439,10 +469,4 @@ dtypes.o: \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
../src/H5Spublic.h \
../src/H5Tpublic.h \
../src/H5Tpkg.h \
../src/H5HGprivate.h \
../src/H5Fprivate.h \
../src/H5private.h \
../src/H5Tprivate.h \
../src/H5Gprivate.h
../src/H5Tpublic.h

@ -28,9 +28,9 @@ MOSTLYCLEAN=cmpd_dset.h5 dataset.h5 extend.h5 istore.h5 tfile1.h5 tfile2.h5 \
# source files and is used for things like dependencies, archiving, etc. The
# other source lists are for the individual tests, the files of which may
# overlap with other tests.
TEST_SRC=testhdf5.c tattr.c tfile.c theap.c tmeta.c tohdr.c tstab.c th5s.c \
dtypes.c hyperslab.c istore.c dsets.c cmpd_dset.c extend.c external.c \
iopipe.c gheap.c shtype.c big.c links.c chunk.c bittests.c
TEST_SRC=testhdf5.c tattr.c tfile.c theap.c tmeta.c tohdr.c tselect.c tstab.c \
th5s.c dtypes.c hyperslab.c istore.c dsets.c cmpd_dset.c extend.c \
external.c iopipe.c gheap.c shtype.c big.c links.c chunk.c bittests.c
TEST_OBJ=$(PROG_SRC:.c=.o)
# Private header files (not to be installed)...
@ -47,7 +47,7 @@ timings _timings: $(TIMINGS)
done;
# How to build the programs...
TESTHDF5_OBJ=testhdf5.o tattr.o tfile.o theap.o tmeta.o tohdr.o tstab.o th5s.o
TESTHDF5_OBJ=testhdf5.o tattr.o tfile.o theap.o tmeta.o tohdr.o tselect.o tstab.o th5s.o
testhdf5: $(TESTHDF5_OBJ) ../src/libhdf5.a
$(CC) $(CFLAGS) -o $@ $(TESTHDF5_OBJ) ../src/libhdf5.a $(LIBS)

@ -704,7 +704,7 @@ test_multiopen (hid_t file)
/* Get the size from the second handle */
if ((space = H5Dget_space (dset2))<0) goto error;
if (H5Sget_dims (space, tmp_size, NULL)<0) goto error;
if (H5Sextent_dims (space, tmp_size, NULL)<0) goto error;
if (cur_size[0]!=tmp_size[0]) {
puts ("*FAILED*");
printf (" Got %d instead of %d!\n",

@ -412,10 +412,10 @@ test_attr_compound_read(void)
/* Verify Dataspace */
space=H5Aget_space(attr);
CHECK(space, FAIL, "H5Aget_space");
rank=H5Sget_ndims(space);
VERIFY(rank, ATTR4_RANK, "H5Sget_ndims");
ret=H5Sget_dims(space,dims, NULL);
CHECK(ret, FAIL, "H5Sget_dims");
rank=H5Sextent_ndims(space);
VERIFY(rank, ATTR4_RANK, "H5Sextent_ndims");
ret=H5Sextent_dims(space,dims, NULL);
CHECK(ret, FAIL, "H5Sextent_dims");
if(dims[0]!=ATTR4_DIM1) {
printf("attribute dimensions different: dims[0]=%d, should be %d\n",(int)dims[0],ATTR4_DIM1);
num_errs++;
@ -797,10 +797,10 @@ test_attr_mult_read(void)
/* Verify Dataspace */
space=H5Aget_space(attr);
CHECK(space, FAIL, "H5Aget_space");
rank=H5Sget_ndims(space);
VERIFY(rank, ATTR1_RANK, "H5Sget_ndims");
ret=H5Sget_dims(space,dims, NULL);
CHECK(ret, FAIL, "H5Sget_dims");
rank=H5Sextent_ndims(space);
VERIFY(rank, ATTR1_RANK, "H5Sextent_ndims");
ret=H5Sextent_dims(space,dims, NULL);
CHECK(ret, FAIL, "H5Sextent_dims");
if(dims[0]!=ATTR1_DIM1) {
printf("attribute dimensions different: dims[0]=%d, should be %d\n",(int)dims[0],ATTR1_DIM1);
num_errs++;
@ -858,10 +858,10 @@ test_attr_mult_read(void)
/* Verify Dataspace */
space=H5Aget_space(attr);
CHECK(space, FAIL, "H5Aget_space");
rank=H5Sget_ndims(space);
VERIFY(rank, ATTR2_RANK, "H5Sget_ndims");
ret=H5Sget_dims(space,dims, NULL);
CHECK(ret, FAIL, "H5Sget_dims");
rank=H5Sextent_ndims(space);
VERIFY(rank, ATTR2_RANK, "H5Sextent_ndims");
ret=H5Sextent_dims(space,dims, NULL);
CHECK(ret, FAIL, "H5Sextent_dims");
if(dims[0]!=ATTR2_DIM1) {
printf("attribute dimensions different: dims[0]=%d, should be %d\n",(int)dims[0],ATTR2_DIM1);
num_errs++;
@ -924,10 +924,10 @@ test_attr_mult_read(void)
/* Verify Dataspace */
space=H5Aget_space(attr);
CHECK(space, FAIL, "H5Aget_space");
rank=H5Sget_ndims(space);
VERIFY(rank, ATTR3_RANK, "H5Sget_ndims");
ret=H5Sget_dims(space,dims, NULL);
CHECK(ret, FAIL, "H5Sget_dims");
rank=H5Sextent_ndims(space);
VERIFY(rank, ATTR3_RANK, "H5Sextent_ndims");
ret=H5Sextent_dims(space,dims, NULL);
CHECK(ret, FAIL, "H5Sextent_dims");
if(dims[0]!=ATTR3_DIM1) {
printf("attribute dimensions different: dims[0]=%d, should be %d\n",(int)dims[0],ATTR3_DIM1);
num_errs++;

@ -169,6 +169,7 @@ main(int argc, char *argv[])
InitTest("stab", test_stab, cleanup_stab, "Symbol Tables");
InitTest("h5s", test_h5s, cleanup_h5s, "Dataspaces");
InitTest("attr", test_attr, cleanup_attr, "Attributes");
InitTest("select", test_select, cleanup_select, "Selections");
Verbosity = 4; /* Default Verbosity is Low */
H5version(&major, &minor, &release, &patch);

@ -138,6 +138,7 @@ void test_h5t(void);
void test_h5s(void);
void test_h5d(void);
void test_attr(void);
void test_select(void);
/* Prototypes for the cleanup routines */
void cleanup_metadata(void);
@ -147,5 +148,6 @@ void cleanup_ohdr(void);
void cleanup_stab(void);
void cleanup_h5s(void);
void cleanup_attr(void);
void cleanup_select(void);
#endif /* HDF5cleanup_H */

@ -108,14 +108,14 @@ test_h5s_basic(void)
CHECK(n, UFAIL, "H5Sextent_npoints");
VERIFY(n, SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3, "H5Sextent_npoints");
rank = H5Sget_ndims(sid1);
CHECK(rank, UFAIL, "H5Sget_lrank");
VERIFY(rank, SPACE1_RANK, "H5Sget_lrank");
rank = H5Sextent_ndims(sid1);
CHECK(rank, UFAIL, "H5Sextent_ndims");
VERIFY(rank, SPACE1_RANK, "H5Sextent_ndims");
ret = H5Sget_dims(sid1, tdims, NULL);
CHECK(ret, FAIL, "H5Sget_ldims");
ret = H5Sextent_dims(sid1, tdims, NULL);
CHECK(ret, FAIL, "H5Sextent_dims");
VERIFY(HDmemcmp(tdims, dims1, SPACE1_RANK * sizeof(unsigned)), 0,
"H5Sget_ldims");
"H5Sextent_dims");
sid2 = H5Screate_simple(SPACE2_RANK, dims2, max2);
CHECK(sid2, FAIL, "H5Screate_simple");
@ -125,16 +125,16 @@ test_h5s_basic(void)
VERIFY(n, SPACE2_DIM1 * SPACE2_DIM2 * SPACE2_DIM3 * SPACE2_DIM4,
"H5Sextent_npoints");
rank = H5Sget_ndims(sid2);
CHECK(rank, UFAIL, "H5Sget_lrank");
VERIFY(rank, SPACE2_RANK, "H5Sget_lrank");
rank = H5Sextent_ndims(sid2);
CHECK(rank, UFAIL, "H5Sextent_ndims");
VERIFY(rank, SPACE2_RANK, "H5Sextent_ndims");
ret = H5Sget_dims(sid2, tdims, tmax);
CHECK(ret, FAIL, "H5Sget_ldims");
ret = H5Sextent_dims(sid2, tdims, tmax);
CHECK(ret, FAIL, "H5Sextent_dims");
VERIFY(HDmemcmp(tdims, dims2, SPACE2_RANK * sizeof(unsigned)), 0,
"H5Sget_ldims");
"H5Sextent_dims");
VERIFY(HDmemcmp(tmax, max2, SPACE2_RANK * sizeof(unsigned)), 0,
"H5Sget_ldims");
"H5Sextent_dims");
ret = H5Sclose(sid1);
CHECK(ret, FAIL, "H5Sclose");
@ -178,12 +178,12 @@ test_h5s_scalar_write(void)
CHECK(n, UFAIL, "H5Sextent_npoints");
VERIFY(n, 1, "H5Sextent_npoints");
rank = H5Sget_ndims(sid1);
CHECK(rank, UFAIL, "H5Sget_lrank");
VERIFY(rank, SPACE3_RANK, "H5Sget_lrank");
rank = H5Sextent_ndims(sid1);
CHECK(rank, UFAIL, "H5Sextent_ndims");
VERIFY(rank, SPACE3_RANK, "H5Sextent_ndims");
ret = H5Sget_dims(sid1, tdims, NULL);
VERIFY(ret, 0, "H5Sget_dims");
ret = H5Sextent_dims(sid1, tdims, NULL);
VERIFY(ret, 0, "H5Sextent_dims");
/* Create a dataset */
dataset=H5Dcreate(fid1,"Dataset1",H5T_NATIVE_UINT,sid1,H5P_DEFAULT);
@ -240,12 +240,12 @@ test_h5s_scalar_read(void)
CHECK(n, UFAIL, "H5Sextent_npoints");
VERIFY(n, 1, "H5Sextent_npoints");
rank = H5Sget_ndims(sid1);
CHECK(rank, UFAIL, "H5Sget_lrank");
VERIFY(rank, SPACE3_RANK, "H5Sget_lrank");
rank = H5Sextent_ndims(sid1);
CHECK(rank, UFAIL, "H5Sextent_ndims");
VERIFY(rank, SPACE3_RANK, "H5Sextent_ndims");
ret = H5Sget_dims(sid1, tdims, NULL);
VERIFY(ret, 0, "H5Sget_dims");
ret = H5Sextent_dims(sid1, tdims, NULL);
VERIFY(ret, 0, "H5Sextent_dims");
ret = H5Dread(dataset, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata);
CHECK(ret, FAIL, "H5Dread");
@ -317,12 +317,12 @@ test_h5s_compound_scalar_write(void)
CHECK(n, UFAIL, "H5Sextent_npoints");
VERIFY(n, 1, "H5Sextent_npoints");
rank = H5Sget_ndims(sid1);
CHECK(rank, UFAIL, "H5Sget_lrank");
VERIFY(rank, SPACE3_RANK, "H5Sget_lrank");
rank = H5Sextent_ndims(sid1);
CHECK(rank, UFAIL, "H5Sextent_ndims");
VERIFY(rank, SPACE3_RANK, "H5Sextent_ndims");
ret = H5Sget_dims(sid1, tdims, NULL);
VERIFY(ret, 0, "H5Sget_dims");
ret = H5Sextent_dims(sid1, tdims, NULL);
VERIFY(ret, 0, "H5Sextent_dims");
/* Create a dataset */
dataset=H5Dcreate(fid1,"Dataset1",tid1,sid1,H5P_DEFAULT);
@ -381,12 +381,12 @@ test_h5s_compound_scalar_read(void)
CHECK(n, UFAIL, "H5Sextent_npoints");
VERIFY(n, 1, "H5Sextent_npoints");
rank = H5Sget_ndims(sid1);
CHECK(rank, UFAIL, "H5Sget_lrank");
VERIFY(rank, SPACE3_RANK, "H5Sget_lrank");
rank = H5Sextent_ndims(sid1);
CHECK(rank, UFAIL, "H5Sextent_ndims");
VERIFY(rank, SPACE3_RANK, "H5Sextent_ndims");
ret = H5Sget_dims(sid1, tdims, NULL);
VERIFY(ret, 0, "H5Sget_dims");
ret = H5Sextent_dims(sid1, tdims, NULL);
VERIFY(ret, 0, "H5Sextent_dims");
type=H5Dget_type(dataset);
CHECK(type, FAIL, "H5Dget_type");

143
test/tselect.c Normal file

@ -0,0 +1,143 @@
/****************************************************************************
* NCSA HDF *
* Software Development Group *
* National Center for Supercomputing Applications *
* University of Illinois at Urbana-Champaign *
* 605 E. Springfield, Champaign IL 61820 *
* *
* For conditions of distribution and use, see the accompanying *
* hdf/COPYING file. *
* *
****************************************************************************/
#ifdef RCSID
static char RcsId[] = "$Revision$";
#endif
/* $Id$ */
/***********************************************************
*
* Test program: tselect
*
* Test the dataspace selection functionality
*
*************************************************************/
#include <testhdf5.h>
#include <hdf5.h>
#define FILE "tselect.h5"
/* 3-D dataset with fixed dimensions */
#define SPACE1_NAME "Space1"
#define SPACE1_RANK 3
#define SPACE1_DIM1 3
#define SPACE1_DIM2 15
#define SPACE1_DIM3 13
/* 2-D dataset with fixed dimensions */
#define SPACE2_NAME "Space2"
#define SPACE2_RANK 2
#define SPACE2_DIM1 30
#define SPACE2_DIM2 26
/* 2-D dataset with fixed dimensions */
#define SPACE3_NAME "Space3"
#define SPACE3_RANK 2
#define SPACE3_DIM1 15
#define SPACE3_DIM2 26
/****************************************************************
**
** test_select_hyper(): Test basic H5S (dataspace) selection code.
** Tests hyperslabs of various sizes and dimensionalities.
**
****************************************************************/
static void
test_select_hyper(void)
{
hid_t fid1; /* HDF5 File IDs */
hid_t dataset; /* Dataset ID */
hid_t group; /* Group ID */
hid_t sid1,sid2; /* Dataspace ID */
hid_t attr; /* Attribute ID */
hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3};
hsize_t dims2[] = {SPACE2_DIM1, SPACE2_DIM2};
hsize_t dims3[] = {SPACE3_DIM1, SPACE3_DIM2};
uint8 *wbuf, /* buffer to write to disk */
*rbuf; /* buffer read from disk */
herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Hyperslab Selection Functions\n"));
/* Allocate write & read buffers */
wbuf=malloc(sizeof(uint8)*SPACE2_DIM1*SPACE2_DIM2);
rbuf=malloc(sizeof(uint8)*SPACE3_DIM1*SPACE3_DIM2);
/* Create file */
fid1 = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
CHECK(fid1, FAIL, "H5Fcreate");
/* Create dataspace for dataset */
sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL);
CHECK(sid1, FAIL, "H5Screate_simple");
/* Create dataspace for memory */
sid2 = H5Screate_simple(SPACE2_RANK, dims2, NULL);
CHECK(sid2, FAIL, "H5Screate_simple");
/* Create a dataset */
dataset=H5Dcreate(fid1,"Dataset1",H5T_NATIVE_UCHAR,sid1,H5P_DEFAULT);
ret = H5Sclose(sid1);
CHECK(ret, FAIL, "H5Sclose");
/* Close Dataset */
ret = H5Dclose(dataset);
CHECK(ret, FAIL, "H5Dclose");
/* Close file */
ret = H5Fclose(fid1);
CHECK(ret, FAIL, "H5Fclose");
} /* test_select_hyper() */
/****************************************************************
**
** test_select(): Main H5S selection testing routine.
**
****************************************************************/
void
test_select(void)
{
/* Output message about test being performed */
MESSAGE(5, ("Testing Selections\n"));
/* These next two tests use the same file information */
test_select_hyper(); /* Test basic H5S hyperslab selection code */
} /* test_select() */
/*-------------------------------------------------------------------------
* Function: cleanup_select
*
* Purpose: Cleanup temporary test files
*
* Return: none
*
* Programmer: Albert Cheng
* July 2, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
void
cleanup_select(void)
{
remove(FILE);
}