diff options
author | Robb Matzke <matzke@llnl.gov> | 1997-12-11 18:49:26 (GMT) |
---|---|---|
committer | Robb Matzke <matzke@llnl.gov> | 1997-12-11 18:49:26 (GMT) |
commit | dbf689c4e6dcb07b7956baeac90e8fd1b3fb7ddf (patch) | |
tree | c93893402a16d77d3c6f2de70abfb22690ad4601 | |
parent | efc14a5341042f5d04f0578bd9820495f1e11d79 (diff) | |
download | hdf5-dbf689c4e6dcb07b7956baeac90e8fd1b3fb7ddf.zip hdf5-dbf689c4e6dcb07b7956baeac90e8fd1b3fb7ddf.tar.gz hdf5-dbf689c4e6dcb07b7956baeac90e8fd1b3fb7ddf.tar.bz2 |
[svn-r143] ./test/dsets.c
Added test for creation of chunked datasets.
./test/dsets.c
./test/istore.c
./test/tfile.c
Template changes.
./test/th5p.c
Accommodated changes to H5P.
-rw-r--r-- | test/dsets.c | 78 | ||||
-rw-r--r-- | test/istore.c | 4 | ||||
-rw-r--r-- | test/tfile.c | 156 | ||||
-rw-r--r-- | test/th5p.c | 10 |
4 files changed, 153 insertions, 95 deletions
diff --git a/test/dsets.c b/test/dsets.c index 382cb9b..51a023c 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -16,6 +16,9 @@ #define AT() printf (" at %s:%d in %s()...\n", \ __FILE__, __LINE__, __FUNCTION__); +#define DSET_DEFAULT_NAME "default" +#define DSET_CHUNKED_NAME "chunked" +#define DSET_SIMPLE_IO_NAME "simple_io" /*------------------------------------------------------------------------- @@ -37,9 +40,10 @@ static herr_t test_create (hid_t file) { - hid_t dataset, space; + hid_t dataset, space, create_parms; intn dims[2]; herr_t status; + size_t csize[2]; printf ("%-70s", "Testing create/open/close"); @@ -51,8 +55,11 @@ test_create (hid_t file) status = H5Pset_space (space, 2, dims); assert (status>=0); - /* Create the dataset */ - dataset = H5Dcreate (file, "dataset_01", H5T_NATIVE_DOUBLE, space, + /* + * Create a dataset using the default dataset creation properties. We're + * not sure what they are, so we won't check. + */ + dataset = H5Dcreate (file, DSET_DEFAULT_NAME, H5T_NATIVE_DOUBLE, space, H5C_DEFAULT); if (dataset<0) { puts ("*FAILED*"); @@ -73,8 +80,11 @@ test_create (hid_t file) goto error; } - /* Try creating a dataset that already exists. This should fail. */ - dataset = H5Dcreate (file, "dataset_01", H5T_NATIVE_DOUBLE, space, + /* + * Try creating a dataset that already exists. This should fail since a + * dataset can only be created once. + */ + dataset = H5Dcreate (file, DSET_DEFAULT_NAME, H5T_NATIVE_DOUBLE, space, H5C_DEFAULT); if (dataset>=0) { puts ("*FAILED*"); @@ -85,13 +95,16 @@ test_create (hid_t file) goto error; } - /* Try opening and closing an existing dataset */ - dataset = H5Dopen (file, "dataset_01"); + /* + * Open the dataset we created above and then close it. This is how + * existing datasets are accessed. + */ + dataset = H5Dopen (file, DSET_DEFAULT_NAME); if (dataset<0) { puts ("*FAILED*"); if (!isatty (1)) { AT (); - printf (" Cannot open dataset `dataset_01'.\n"); + printf (" Cannot open dataset `%s'.\n", DSET_DEFAULT_NAME); } goto error; } @@ -104,7 +117,10 @@ test_create (hid_t file) goto error; } - /* Try opening a non-existent dataset. This should fail */ + /* + * Try opening a non-existent dataset. This should fail since new datasets + * cannot be created with this function. + */ dataset = H5Dopen (file, "does_not_exist"); if (dataset>=0) { puts ("*FAILED*"); @@ -114,6 +130,48 @@ test_create (hid_t file) } goto error; } + + /* + * Create a new dataset that uses chunked storage instead of the default + * layout. + */ + create_parms = H5Ccreate (H5C_DATASET_CREATE); + assert (create_parms>=0); + status = H5Cset_prop (create_parms, H5D_LAYOUT, H5D_CHUNKED); + assert (status>=0); + status = H5Cset_prop (create_parms, H5D_CHUNK_NDIMS, 2); + assert (status>=0); + csize[0] = 5; + csize[1] = 100; + status = H5Cset_prop (create_parms, H5D_CHUNK_SIZE, csize); + assert (status>=0); + + dataset = H5Dcreate (file, DSET_CHUNKED_NAME, H5T_NATIVE_DOUBLE, space, + create_parms); + if (dataset<0) { + puts ("*FAILED*"); + if (!isatty (1)) { + AT (); + printf (" Could not create a chunked dataset.\n"); + } + goto error; + } + + /* + * Close the chunked dataset. + */ + if (H5Dclose (dataset)<0) { + puts ("*FAILED*"); + if (!isatty (1)) { + AT (); + printf (" Cannot close chunked dataset.\n"); + } + goto error; + } + + + + puts (" PASSED"); return SUCCEED; @@ -167,7 +225,7 @@ test_simple_io (hid_t file) assert (status>=0); /* Create the dataset */ - dataset = H5Dcreate (file, "dataset_02", H5T_NATIVE_INT, space, + dataset = H5Dcreate (file, DSET_SIMPLE_IO_NAME, H5T_NATIVE_INT, space, H5C_DEFAULT); assert (dataset>=0); diff --git a/test/istore.c b/test/istore.c index 589829e..20b1179 100644 --- a/test/istore.c +++ b/test/istore.c @@ -523,7 +523,7 @@ main (int argc, char *argv[]) herr_t status; int nerrors = 0; uintn size_of_test; - uint8 offset_size; + size_t offset_size; H5G_entry_t *ent = NULL; hid_t template_id; H5F_create_t *creation_template = NULL; @@ -559,7 +559,7 @@ main (int argc, char *argv[]) */ offset_size = 8; template_id = H5Ccreate (H5C_FILE_CREATE); - H5Csetparm (template_id, H5F_OFFSET_SIZE, &offset_size); + H5Cset_prop (template_id, H5F_SIZEOF_ADDR, offset_size); creation_template = H5Aatom_object (template_id); /* Create the test file */ diff --git a/test/tfile.c b/test/tfile.c index ffd2d19..8827d87 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -61,8 +61,9 @@ static void test_file_create(void) { hid_t fid1,fid2,fid3; /* HDF5 File IDs */ hid_t tmpl1,tmpl2; /* File creation templates */ - uintn parm; /* File-creation parameters */ - uint8 parm2; /* File-creation parameters */ + size_t parm; /* File-creation parameters */ + size_t parm2; /* File-creation parameters */ + int iparm; herr_t ret; /* Generic return value */ /* Output message about test being performed */ @@ -81,25 +82,25 @@ static void test_file_create(void) CHECK(tmpl1,FAIL,"H5Fget_create_template"); /* Get the file-creation parameters */ - ret=H5Cgetparm(tmpl1,H5F_USERBLOCK_SIZE,&parm); - CHECK(ret,FAIL,"H5Cgetparm"); - VERIFY(parm,F1_USERBLOCK_SIZE,"H5Cgetparm"); + ret = H5Cget_prop (tmpl1, H5F_SIZEOF_USERBLOCK, &parm); + CHECK(ret,FAIL,"H5Cget_prop"); + VERIFY(parm,F1_USERBLOCK_SIZE,"H5Cget_prop"); - ret=H5Cgetparm(tmpl1,H5F_OFFSET_SIZE,&parm2); - CHECK(ret,FAIL,"H5Cgetparm"); - VERIFY(parm2,F1_OFFSET_SIZE,"H5Cgetparm"); + ret = H5Cget_prop (tmpl1, H5F_SIZEOF_ADDR, &parm2); + CHECK(ret,FAIL,"H5Cget_prop"); + VERIFY(parm2,F1_OFFSET_SIZE,"H5Cget_prop"); - ret=H5Cgetparm(tmpl1,H5F_LENGTH_SIZE,&parm2); - CHECK(ret,FAIL,"H5Cgetparm"); - VERIFY(parm2,F1_LENGTH_SIZE,"H5Cgetparm"); + ret = H5Cget_prop (tmpl1, H5F_SIZEOF_SIZE, &parm2); + CHECK(ret,FAIL,"H5Cget_prop"); + VERIFY(parm2,F1_LENGTH_SIZE,"H5Cget_prop"); - ret=H5Cgetparm(tmpl1,H5F_SYM_LEAF_K,&parm); - CHECK(ret,FAIL,"H5Cgetparm"); - VERIFY(parm,F1_SYM_LEAF_K,"H5Cgetparm"); + ret = H5Cget_prop (tmpl1, H5F_SYM_LEAF_K, &iparm); + CHECK(ret,FAIL,"H5Cget_prop"); + VERIFY(iparm,F1_SYM_LEAF_K,"H5Cget_prop"); - ret=H5Cgetparm(tmpl1,H5F_SYM_INTERN_K,&parm); - CHECK(ret,FAIL,"H5Cgetparm"); - VERIFY(parm,F1_SYM_INTERN_K,"H5Cgetparm"); + ret =H5Cget_prop (tmpl1, H5F_SYM_INTERN_K, &iparm); + CHECK(ret,FAIL,"H5Cget_prop"); + VERIFY(iparm,F1_SYM_INTERN_K,"H5Cget_prop"); /* Release file-creation template */ ret=H5Mclose(tmpl1); @@ -115,24 +116,22 @@ static void test_file_create(void) /* Set the new file-creation parameters */ parm=F2_USERBLOCK_SIZE; - ret=H5Csetparm(tmpl1,H5F_USERBLOCK_SIZE,&parm); - CHECK(ret,FAIL,"H5Csetparm"); + ret = H5Cset_prop (tmpl1, H5F_SIZEOF_USERBLOCK, parm); + CHECK(ret,FAIL,"H5Cset_prop"); parm2=F2_OFFSET_SIZE; - ret=H5Csetparm(tmpl1,H5F_OFFSET_SIZE,&parm2); - CHECK(ret,FAIL,"H5Csetparm"); + ret = H5Cset_prop (tmpl1, H5F_SIZEOF_ADDR, parm2); + CHECK(ret,FAIL,"H5Cset_prop"); parm2=F2_LENGTH_SIZE; - ret=H5Csetparm(tmpl1,H5F_LENGTH_SIZE,&parm2); - CHECK(ret,FAIL,"H5Csetparm"); + ret = H5Cset_prop (tmpl1, H5F_SIZEOF_SIZE, parm2); + CHECK(ret,FAIL,"H5Cset_prop"); - parm=F2_SYM_LEAF_K; - ret=H5Csetparm(tmpl1,H5F_SYM_LEAF_K,&parm); - CHECK(ret,FAIL,"H5Csetparm"); + ret = H5Cset_prop (tmpl1, H5F_SYM_LEAF_K, F2_SYM_LEAF_K); + CHECK(ret,FAIL,"H5Cset_prop"); - parm=F2_SYM_INTERN_K; - ret=H5Csetparm(tmpl1,H5F_SYM_INTERN_K,&parm); - CHECK(ret,FAIL,"H5Csetparm"); + ret = H5Cset_prop (tmpl1, H5F_SYM_INTERN_K, F2_SYM_INTERN_K); + CHECK(ret,FAIL,"H5Cset_prop"); /* Try to create second file, with non-standard file-creation template params */ fid2=H5Fcreate(FILE2,H5ACC_OVERWRITE,tmpl1,0); @@ -147,25 +146,25 @@ static void test_file_create(void) CHECK(tmpl1,FAIL,"H5Fget_create_template"); /* Get the file-creation parameters */ - ret=H5Cgetparm(tmpl1,H5F_USERBLOCK_SIZE,&parm); - CHECK(ret,FAIL,"H5Cgetparm"); - VERIFY(parm,F2_USERBLOCK_SIZE,"H5Cgetparm"); + ret = H5Cget_prop (tmpl1, H5F_SIZEOF_USERBLOCK, &parm); + CHECK(ret,FAIL,"H5Cget_prop"); + VERIFY(parm,F2_USERBLOCK_SIZE,"H5Cget_prop"); - ret=H5Cgetparm(tmpl1,H5F_OFFSET_SIZE,&parm2); - CHECK(ret,FAIL,"H5Cgetparm"); - VERIFY(parm2,F2_LENGTH_SIZE,"H5Cgetparm"); + ret = H5Cget_prop (tmpl1, H5F_SIZEOF_SIZE, &parm2); + CHECK(ret,FAIL,"H5Cget_prop"); + VERIFY(parm2,F2_LENGTH_SIZE,"H5Cget_prop"); - ret=H5Cgetparm(tmpl1,H5F_LENGTH_SIZE,&parm2); - CHECK(ret,FAIL,"H5Cgetparm"); - VERIFY(parm2,F2_OFFSET_SIZE,"H5Cgetparm"); + ret = H5Cget_prop (tmpl1, H5F_SIZEOF_ADDR, &parm2); + CHECK(ret,FAIL,"H5Cget_prop"); + VERIFY(parm2,F2_OFFSET_SIZE,"H5Cget_prop"); - ret=H5Cgetparm(tmpl1,H5F_SYM_LEAF_K,&parm); - CHECK(ret,FAIL,"H5Cgetparm"); - VERIFY(parm,F2_SYM_LEAF_K,"H5Cgetparm"); + ret = H5Cget_prop (tmpl1, H5F_SYM_LEAF_K, &iparm); + CHECK(ret,FAIL,"H5Cget_prop"); + VERIFY(iparm,F2_SYM_LEAF_K,"H5Cget_prop"); - ret=H5Cgetparm(tmpl1,H5F_SYM_INTERN_K,&parm); - CHECK(ret,FAIL,"H5Cgetparm"); - VERIFY(parm,F2_SYM_INTERN_K,"H5Cgetparm"); + ret = H5Cget_prop (tmpl1, H5F_SYM_INTERN_K, &iparm); + CHECK(ret,FAIL,"H5Cget_prop"); + VERIFY(iparm,F2_SYM_INTERN_K,"H5Cget_prop"); /* Clone the file-creation template */ tmpl2=H5Mcopy(tmpl1); @@ -177,8 +176,8 @@ static void test_file_create(void) /* Set the new file-creation parameter */ parm=F3_USERBLOCK_SIZE; - ret=H5Csetparm(tmpl2,H5F_USERBLOCK_SIZE,&parm); - CHECK(ret,FAIL,"H5Csetparm"); + ret = H5Cset_prop (tmpl2, H5F_SIZEOF_USERBLOCK, parm); + CHECK(ret,FAIL,"H5Cset_prop"); /* Try to create second file, with non-standard file-creation template params */ fid3=H5Fcreate(FILE3,H5ACC_OVERWRITE,tmpl2,0); @@ -193,25 +192,25 @@ static void test_file_create(void) CHECK(tmpl1,FAIL,"H5Fget_create_template"); /* Get the file-creation parameters */ - ret=H5Cgetparm(tmpl1,H5F_USERBLOCK_SIZE,&parm); - CHECK(ret,FAIL,"H5Cgetparm"); - VERIFY(parm,F3_USERBLOCK_SIZE,"H5Cgetparm"); + ret = H5Cget_prop (tmpl1, H5F_SIZEOF_USERBLOCK, &parm); + CHECK(ret,FAIL,"H5Cget_prop"); + VERIFY(parm,F3_USERBLOCK_SIZE,"H5Cget_prop"); - ret=H5Cgetparm(tmpl1,H5F_OFFSET_SIZE,&parm2); - CHECK(ret,FAIL,"H5Cgetparm"); - VERIFY(parm2,F3_LENGTH_SIZE,"H5Cgetparm"); + ret = H5Cget_prop (tmpl1, H5F_SIZEOF_ADDR, &parm2); + CHECK(ret,FAIL,"H5Cget_prop"); + VERIFY(parm2,F3_LENGTH_SIZE,"H5Cget_prop"); - ret=H5Cgetparm(tmpl1,H5F_LENGTH_SIZE,&parm2); - CHECK(ret,FAIL,"H5Cgetparm"); - VERIFY(parm2,F3_OFFSET_SIZE,"H5Cgetparm"); + ret = H5Cget_prop (tmpl1, H5F_SIZEOF_SIZE, &parm2); + CHECK(ret,FAIL,"H5Cget_prop"); + VERIFY(parm2,F3_OFFSET_SIZE,"H5Cget_prop"); - ret=H5Cgetparm(tmpl1,H5F_SYM_LEAF_K,&parm); - CHECK(ret,FAIL,"H5Cgetparm"); - VERIFY(parm,F3_SYM_LEAF_K,"H5Cgetparm"); + ret = H5Cget_prop (tmpl1, H5F_SYM_LEAF_K, &iparm); + CHECK(ret,FAIL,"H5Cget_prop"); + VERIFY(iparm,F3_SYM_LEAF_K,"H5Cget_prop"); - ret=H5Cgetparm(tmpl1,H5F_SYM_INTERN_K,&parm); - CHECK(ret,FAIL,"H5Cgetparm"); - VERIFY(parm,F3_SYM_INTERN_K,"H5Cgetparm"); + ret = H5Cget_prop (tmpl1, H5F_SYM_INTERN_K, &iparm); + CHECK(ret,FAIL,"H5Cget_prop"); + VERIFY(iparm,F3_SYM_INTERN_K,"H5Cget_prop"); /* Release file-creation template */ ret=H5Mclose(tmpl1); @@ -240,8 +239,9 @@ static void test_file_open(void) { hid_t fid1; /* HDF5 File IDs */ hid_t tmpl1; /* File creation templates */ - uintn parm; /* File-creation parameters */ - uint8 parm2; /* File-creation parameters */ + size_t parm; /* File-creation parameters */ + size_t parm2; /* File-creation parameters */ + int iparm; herr_t ret; /* Generic return value */ /* Output message about test being performed */ @@ -256,25 +256,25 @@ static void test_file_open(void) CHECK(tmpl1,FAIL,"H5Fget_create_template"); /* Get the file-creation parameters */ - ret=H5Cgetparm(tmpl1,H5F_USERBLOCK_SIZE,&parm); - CHECK(ret,FAIL,"H5Cgetparm"); - VERIFY(parm,F2_USERBLOCK_SIZE,"H5Cgetparm"); + ret = H5Cget_prop (tmpl1, H5F_SIZEOF_USERBLOCK, &parm); + CHECK(ret,FAIL,"H5Cget_prop"); + VERIFY(parm,F2_USERBLOCK_SIZE,"H5Cget_prop"); - ret=H5Cgetparm(tmpl1,H5F_OFFSET_SIZE,&parm2); - CHECK(ret,FAIL,"H5Cgetparm"); - VERIFY(parm2,F2_OFFSET_SIZE,"H5Cgetparm"); + ret = H5Cget_prop (tmpl1, H5F_SIZEOF_ADDR, &parm2); + CHECK(ret,FAIL,"H5Cget_prop"); + VERIFY(parm2,F2_OFFSET_SIZE,"H5Cget_prop"); - ret=H5Cgetparm(tmpl1,H5F_LENGTH_SIZE,&parm2); - CHECK(ret,FAIL,"H5Cgetparm"); - VERIFY(parm2,F2_LENGTH_SIZE,"H5Cgetparm"); + ret = H5Cget_prop (tmpl1, H5F_SIZEOF_SIZE, &parm2); + CHECK(ret,FAIL,"H5Cget_prop"); + VERIFY(parm2,F2_LENGTH_SIZE,"H5Cget_prop"); - ret=H5Cgetparm(tmpl1,H5F_SYM_LEAF_K,&parm); - CHECK(ret,FAIL,"H5Cgetparm"); - VERIFY(parm,F2_SYM_LEAF_K,"H5Cgetparm"); + ret = H5Cget_prop (tmpl1, H5F_SYM_LEAF_K, &iparm); + CHECK(ret,FAIL,"H5Cget_prop"); + VERIFY(iparm,F2_SYM_LEAF_K,"H5Cget_prop"); - ret=H5Cgetparm(tmpl1,H5F_SYM_INTERN_K,&parm); - CHECK(ret,FAIL,"H5Cgetparm"); - VERIFY(parm,F2_SYM_INTERN_K,"H5Cgetparm"); + ret = H5Cget_prop (tmpl1, H5F_SYM_INTERN_K, &iparm); + CHECK(ret,FAIL,"H5Cget_prop"); + VERIFY(iparm,F2_SYM_INTERN_K,"H5Cget_prop"); /* Release file-creation template */ ret=H5Mclose(tmpl1); diff --git a/test/th5p.c b/test/th5p.c index a39f7de..eb8528b 100644 --- a/test/th5p.c +++ b/test/th5p.c @@ -58,7 +58,7 @@ static void test_h5p_basic(void) hid_t fid1; /* HDF5 File IDs */ hid_t sid1,sid2; /* Dataspace ID */ uint32 rank; /* Logical rank of dataspace */ - uint32 dims1[]={SPACE1_DIM1,SPACE1_DIM2,SPACE1_DIM3}, /* dataspace dim sizes */ + size_t dims1[]={SPACE1_DIM1,SPACE1_DIM2,SPACE1_DIM3}, /* dataspace dim sizes */ dims2[]={SPACE2_DIM1,SPACE2_DIM2,SPACE2_DIM3,SPACE2_DIM4}, tdims[4]; /* Dimension array to test with */ uintn n; /* number of dataspace elements */ @@ -81,11 +81,11 @@ static void test_h5p_basic(void) CHECK(n,UFAIL,"H5Pnelem"); VERIFY(n,SPACE1_DIM1*SPACE1_DIM2*SPACE1_DIM3,"H5Pnelem"); - rank=H5Pget_lrank(sid1); + rank=H5Pget_ndims(sid1); CHECK(rank,UFAIL,"H5Pget_lrank"); VERIFY(rank,SPACE1_RANK,"H5Pget_lrank"); - ret=H5Pget_ldims(sid1,tdims); + ret=H5Pget_dims(sid1,tdims); CHECK(ret,FAIL,"H5Pget_ldims"); VERIFY(HDmemcmp(tdims,dims1,SPACE1_RANK*sizeof(uint32)),0,"H5Pget_ldims"); @@ -99,11 +99,11 @@ static void test_h5p_basic(void) CHECK(n,UFAIL,"H5Pnelem"); VERIFY(n,SPACE2_DIM1*SPACE2_DIM2*SPACE2_DIM3*SPACE2_DIM4,"H5Pnelem"); - rank=H5Pget_lrank(sid2); + rank=H5Pget_ndims(sid2); CHECK(rank,UFAIL,"H5Pget_lrank"); VERIFY(rank,SPACE2_RANK,"H5Pget_lrank"); - ret=H5Pget_ldims(sid2,tdims); + ret=H5Pget_dims(sid2,tdims); CHECK(ret,FAIL,"H5Pget_ldims"); VERIFY(HDmemcmp(tdims,dims2,SPACE2_RANK*sizeof(uint32)),0,"H5Pget_ldims"); |