summaryrefslogtreecommitdiffstats
path: root/hl/test
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2020-09-30 14:27:10 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2020-09-30 14:27:10 (GMT)
commitb2d661b508a7fc7a2592c13bc6bdc175551f075d (patch)
tree13baeb0d83a7c2a4c6299993c182b1227c2f6114 /hl/test
parent29ab58b58dce556639ea3154e262895773a8a8df (diff)
downloadhdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.zip
hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.gz
hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.bz2
Clang-format of source files
Diffstat (limited to 'hl/test')
-rw-r--r--hl/test/gen_test_ds.c393
-rw-r--r--hl/test/gen_test_ld.c430
-rw-r--r--hl/test/h5hltest.h19
-rw-r--r--hl/test/pal_rgb.h7
-rw-r--r--hl/test/test_ds.c3979
-rw-r--r--hl/test/test_dset_append.c869
-rw-r--r--hl/test/test_file_image.c180
-rw-r--r--hl/test/test_h5do_compat.c90
-rw-r--r--hl/test/test_image.c746
-rw-r--r--hl/test/test_ld.c1268
-rw-r--r--hl/test/test_lite.c2044
-rw-r--r--hl/test/test_packet.c776
-rw-r--r--hl/test/test_packet_vlen.c1068
-rw-r--r--hl/test/test_table.c1815
14 files changed, 6860 insertions, 6824 deletions
diff --git a/hl/test/gen_test_ds.c b/hl/test/gen_test_ds.c
index a43af77..27c3a0b 100644
--- a/hl/test/gen_test_ds.c
+++ b/hl/test/gen_test_ds.c
@@ -29,9 +29,9 @@
/* prototypes */
static hid_t open_test_file(const char *fileext);
-herr_t create_long_dataset(hid_t fid, const char *dsname, const char *dsidx);
-herr_t test_attach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx);
-herr_t test_detach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx);
+herr_t create_long_dataset(hid_t fid, const char *dsname, const char *dsidx);
+herr_t test_attach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx);
+herr_t test_detach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx);
herr_t test_set_scalename(hid_t fid, hid_t did, const char *name, const char *scalename, unsigned int idx);
herr_t test_cmp_scalename(hid_t fid, hid_t did, const char *name, const char *scalename, unsigned int idx);
@@ -41,47 +41,46 @@ static int test_long_scalenames(const char *filename);
static int test_samelong_scalenames(const char *filename);
static int test_foreign_scaleattached(const char *filename);
-
-#define DIM_DATA 12
-#define DIM1_SIZE 3
-#define DIM2_SIZE 4
-#define DIM3_SIZE 12
-#define DIM4_SIZE 2
-#define DIM0 0
-#define DIM1 1
-#define DIM2 2
-#define DIM3 3
-
-#define DATASET_NAME "dset_"
-#define DS_1_NAME "ds_1_"
-#define DS_2_NAME "ds_2_"
-#define DS_3_NAME "ds_3_"
-#define DS_4_NAME "ds_4_"
-
-#define SCALE_1_NAME "scalename_1_"
-#define SCALE_2_NAME "scalename_2_"
-#define SCALE_3_NAME "scalename_3_"
-#define SCALE_4_NAME "scalename_4_"
-
-#define FILENAME "test_ds_"
-#define FILEEXT ".h5"
+#define DIM_DATA 12
+#define DIM1_SIZE 3
+#define DIM2_SIZE 4
+#define DIM3_SIZE 12
+#define DIM4_SIZE 2
+#define DIM0 0
+#define DIM1 1
+#define DIM2 2
+#define DIM3 3
+
+#define DATASET_NAME "dset_"
+#define DS_1_NAME "ds_1_"
+#define DS_2_NAME "ds_2_"
+#define DS_3_NAME "ds_3_"
+#define DS_4_NAME "ds_4_"
+
+#define SCALE_1_NAME "scalename_1_"
+#define SCALE_2_NAME "scalename_2_"
+#define SCALE_3_NAME "scalename_3_"
+#define SCALE_4_NAME "scalename_4_"
+
+#define FILENAME "test_ds_"
+#define FILEEXT ".h5"
/*-------------------------------------------------------------------------
* the main program
*-------------------------------------------------------------------------
*/
-int main(int argc , char **argv)
+int
+main(int argc, char **argv)
{
- int nerrors=0;
+ int nerrors = 0;
char filename[65];
-
if (argc < 2) {
HDprintf("Usage: gen_test [le | be]\n");
return 1;
}
- if ( argv[1] && (strcmp("le",argv[1])!=0) && (strcmp("be",argv[1])!=0) ) {
+ if (argv[1] && (strcmp("le", argv[1]) != 0) && (strcmp("be", argv[1]) != 0)) {
HDprintf("Usage: gen_test [le | be]\n");
return 1;
}
@@ -90,26 +89,28 @@ int main(int argc , char **argv)
strcpy(filename, FILENAME);
strcat(filename, argv[1]);
strcat(filename, FILEEXT);
- if(H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT) < 0) {
+ if (H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT) < 0) {
nerrors = 1;
goto error;
}
- nerrors += test_long_attachscales(filename) < 0 ? 1 : 0;
- nerrors += test_duplicatelong_attachscales(filename) < 0 ? 1 : 0;
- nerrors += test_samelong_scalenames(filename) < 0 ? 1 : 0;
- nerrors += test_foreign_scaleattached(filename) < 0 ? 1 : 0;
- nerrors += test_long_scalenames(filename) < 0 ? 1 : 0;
+ nerrors += test_long_attachscales(filename) < 0 ? 1 : 0;
+ nerrors += test_duplicatelong_attachscales(filename) < 0 ? 1 : 0;
+ nerrors += test_samelong_scalenames(filename) < 0 ? 1 : 0;
+ nerrors += test_foreign_scaleattached(filename) < 0 ? 1 : 0;
+ nerrors += test_long_scalenames(filename) < 0 ? 1 : 0;
- if(nerrors) goto error;
+ if (nerrors)
+ goto error;
HDprintf("Dimension scales file generation passed.\n");
return 0;
error:
- HDprintf("***** %d DIMENSION SCALES FILE GENERATION FAILED! *****\n",nerrors);
+ HDprintf("***** %d DIMENSION SCALES FILE GENERATION FAILED! *****\n", nerrors);
return 1;
}
-static hid_t open_test_file(const char *fileext)
+static hid_t
+open_test_file(const char *fileext)
{
char filename[65];
@@ -125,191 +126,197 @@ static hid_t open_test_file(const char *fileext)
*-------------------------------------------------------------------------
*/
-herr_t create_long_dataset(hid_t fid, const char *name, const char *dsidx)
+herr_t
+create_long_dataset(hid_t fid, const char *name, const char *dsidx)
{
- int rank = 4;
- int rankds = 1;
- hsize_t dims[4] = {DIM1_SIZE,DIM2_SIZE,DIM3_SIZE,DIM4_SIZE};
- long buf[DIM_DATA*3*2] = {1,2,3,4,5,6,7,8,9,10,11,12,
- 1,2,3,4,5,6,7,8,9,10,11,12,1,2,3,4,5,6,7,8,9,10,11,12,
- 1,2,3,4,5,6,7,8,9,10,11,12,1,2,3,4,5,6,7,8,9,10,11,12,
- 1,2,3,4,5,6,7,8,9,10,11,12};
- hsize_t s1_dim[1] = {DIM1_SIZE};
- hsize_t s2_dim[1] = {DIM2_SIZE};
- hsize_t s3_dim[1] = {DIM3_SIZE};
- hsize_t s4_dim[1] = {DIM4_SIZE};
- long s1_wbuf[DIM1_SIZE] = {10,20,30};
- long s2_wbuf[DIM2_SIZE] = {100,200,300,400};
- long s3_wbuf[DIM3_SIZE] = {10,10,10,20,20,20,30,30,30,40,40,40};
- long s4_wbuf[DIM4_SIZE] = {18,18};
+ int rank = 4;
+ int rankds = 1;
+ hsize_t dims[4] = {DIM1_SIZE, DIM2_SIZE, DIM3_SIZE, DIM4_SIZE};
+ long buf[DIM_DATA * 3 * 2] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5, 6,
+ 7, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5, 6,
+ 7, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
+ hsize_t s1_dim[1] = {DIM1_SIZE};
+ hsize_t s2_dim[1] = {DIM2_SIZE};
+ hsize_t s3_dim[1] = {DIM3_SIZE};
+ hsize_t s4_dim[1] = {DIM4_SIZE};
+ long s1_wbuf[DIM1_SIZE] = {10, 20, 30};
+ long s2_wbuf[DIM2_SIZE] = {100, 200, 300, 400};
+ long s3_wbuf[DIM3_SIZE] = {10, 10, 10, 20, 20, 20, 30, 30, 30, 40, 40, 40};
+ long s4_wbuf[DIM4_SIZE] = {18, 18};
/* make a dataset */
- if(H5LTmake_dataset_long(fid, name, rank, dims, buf) >= 0) {
+ if (H5LTmake_dataset_long(fid, name, rank, dims, buf) >= 0) {
/* make a DS dataset for the first dimension */
char dsname[32];
strcpy(dsname, DS_1_NAME);
strcat(dsname, dsidx);
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_long(fid, dsname, rankds, s1_dim, s1_wbuf) < 0)
+ if (H5LTmake_dataset_long(fid, dsname, rankds, s1_dim, s1_wbuf) < 0)
return FAIL;
strcpy(dsname, DS_2_NAME);
strcat(dsname, dsidx);
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_long(fid, dsname, rankds, s2_dim, s2_wbuf) < 0)
+ if (H5LTmake_dataset_long(fid, dsname, rankds, s2_dim, s2_wbuf) < 0)
return FAIL;
strcpy(dsname, DS_3_NAME);
strcat(dsname, dsidx);
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_long(fid, dsname, rankds, s3_dim, s3_wbuf) < 0)
+ if (H5LTmake_dataset_long(fid, dsname, rankds, s3_dim, s3_wbuf) < 0)
return FAIL;
strcpy(dsname, DS_4_NAME);
strcat(dsname, dsidx);
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_long(fid, dsname, rankds, s4_dim, s4_wbuf) < 0)
+ if (H5LTmake_dataset_long(fid, dsname, rankds, s4_dim, s4_wbuf) < 0)
return FAIL;
- }
- else
- return FAIL;
+ }
+ else
+ return FAIL;
return SUCCEED;
}
-herr_t test_attach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx)
+herr_t
+test_attach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx)
{
- herr_t ret_value = FAIL;
- hid_t dsid = -1;
+ herr_t ret_value = FAIL;
+ hid_t dsid = -1;
- if((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) {
- if(H5DSis_attached(did, dsid, idx) == 0) {
- if(H5DSattach_scale(did, dsid, idx) >= 0) {
- if(H5DSis_attached(did, dsid, idx) > 0) {
+ if ((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) {
+ if (H5DSis_attached(did, dsid, idx) == 0) {
+ if (H5DSattach_scale(did, dsid, idx) >= 0) {
+ if (H5DSis_attached(did, dsid, idx) > 0) {
/* HDprintf(" scale attached "); */
ret_value = SUCCEED;
}
- else if(H5DSis_attached(did, dsid, idx) == 0) {
+ else if (H5DSis_attached(did, dsid, idx) == 0) {
HDprintf(" scale not attached ");
}
}
}
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
ret_value = FAIL;
}
return ret_value;
}
-herr_t test_detach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx)
+herr_t
+test_detach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx)
{
- herr_t ret_value = FAIL;
- hid_t dsid = -1;
+ herr_t ret_value = FAIL;
+ hid_t dsid = -1;
- if((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) {
- if(H5DSis_attached(did, dsid, idx) == 1) {
- if(H5DSdetach_scale(did, dsid, idx) >= 0) {
- if(H5DSis_attached(did, dsid, idx) == 0) {
+ if ((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) {
+ if (H5DSis_attached(did, dsid, idx) == 1) {
+ if (H5DSdetach_scale(did, dsid, idx) >= 0) {
+ if (H5DSis_attached(did, dsid, idx) == 0) {
ret_value = SUCCEED;
}
}
}
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
ret_value = FAIL;
}
return ret_value;
}
-herr_t test_set_scalename(hid_t fid, hid_t did, const char *name, const char *scalename, unsigned int idx)
+herr_t
+test_set_scalename(hid_t fid, hid_t did, const char *name, const char *scalename, unsigned int idx)
{
- herr_t ret_value = FAIL;
- hid_t dsid = -1;
+ herr_t ret_value = FAIL;
+ hid_t dsid = -1;
- if((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) {
- if(H5DSis_attached(did, dsid, idx) == 1) {
- if(H5DSset_scale(dsid, scalename) >= 0) {
- if(H5DSis_attached(did, dsid, idx) == 1) {
- ret_value = SUCCEED;
+ if ((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) {
+ if (H5DSis_attached(did, dsid, idx) == 1) {
+ if (H5DSset_scale(dsid, scalename) >= 0) {
+ if (H5DSis_attached(did, dsid, idx) == 1) {
+ ret_value = SUCCEED;
}
}
}
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
ret_value = FAIL;
}
return ret_value;
}
-herr_t test_cmp_scalename(hid_t fid, hid_t did, const char *name, const char *scalename, unsigned int idx)
+herr_t
+test_cmp_scalename(hid_t fid, hid_t did, const char *name, const char *scalename, unsigned int idx)
{
herr_t ret_value = FAIL;
- hid_t dsid = -1;
+ hid_t dsid = -1;
ssize_t name_len;
- char *name_out=NULL;
-
- if((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) {
- if(H5DSis_attached(did, dsid, idx) == 1) {
- if((name_len=H5DSget_scale_name(dsid,NULL,(size_t)0)) > 0) {
- name_out = (char*)HDmalloc((size_t)name_len * sizeof (char));
- if(name_out != NULL) {
- if(H5DSget_scale_name(dsid, name_out, (size_t)name_len) >= 0) {
- if(strcmp(scalename,name_out)==0) {
+ char * name_out = NULL;
+
+ if ((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) {
+ if (H5DSis_attached(did, dsid, idx) == 1) {
+ if ((name_len = H5DSget_scale_name(dsid, NULL, (size_t)0)) > 0) {
+ name_out = (char *)HDmalloc((size_t)name_len * sizeof(char));
+ if (name_out != NULL) {
+ if (H5DSget_scale_name(dsid, name_out, (size_t)name_len) >= 0) {
+ if (strcmp(scalename, name_out) == 0) {
ret_value = SUCCEED;
}
HDfree(name_out);
- name_out=NULL;
+ name_out = NULL;
}
}
}
}
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
ret_value = FAIL;
}
return ret_value;
}
-static int test_long_attachscales(const char *filename)
+static int
+test_long_attachscales(const char *filename)
{
- hid_t fid = -1;
- hid_t did = -1;
- char dsname[32];
- char scalename[32];
+ hid_t fid = -1;
+ hid_t did = -1;
+ char dsname[32];
+ char scalename[32];
strcpy(dsname, DATASET_NAME);
strcat(dsname, "al");
HL_TESTING2("test_long_attachscales");
- if((fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
+ if ((fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
goto out;
/* make a dataset */
- if(create_long_dataset(fid, dsname, "al") < 0)
+ if (create_long_dataset(fid, dsname, "al") < 0)
goto out;
- if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
+ if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
strcpy(scalename, DS_1_NAME);
strcat(scalename, "al");
- if(test_attach_scale(fid, did, scalename, DIM0) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM0) < 0)
goto out;
strcpy(scalename, DS_2_NAME);
strcat(scalename, "al");
- if(test_attach_scale(fid, did, scalename, DIM1) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM1) < 0)
goto out;
strcpy(scalename, DS_3_NAME);
strcat(scalename, "al");
- if(test_attach_scale(fid, did, scalename, DIM2) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM2) < 0)
goto out;
strcpy(scalename, DS_4_NAME);
strcat(scalename, "al");
- if(test_attach_scale(fid, did, scalename, DIM3) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM3) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
@@ -321,56 +328,59 @@ static int test_long_attachscales(const char *filename)
return SUCCEED;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-static int test_duplicatelong_attachscales(const char *filename)
+static int
+test_duplicatelong_attachscales(const char *filename)
{
- hid_t fid = -1;
- hid_t did = -1;
- char dsname[32];
- char scalename[32];
+ hid_t fid = -1;
+ hid_t did = -1;
+ char dsname[32];
+ char scalename[32];
strcpy(dsname, DATASET_NAME);
strcat(dsname, "al2");
HL_TESTING2("test_duplicatelong_attachscales");
- if((fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
+ if ((fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
goto out;
/* make a dataset 2 */
- if(create_long_dataset(fid, dsname, "al2") < 0)
+ if (create_long_dataset(fid, dsname, "al2") < 0)
goto out;
- if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
+ if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
strcpy(scalename, DS_1_NAME);
strcat(scalename, "al");
- if(test_attach_scale(fid, did, scalename, DIM0) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM0) < 0)
goto out;
strcpy(scalename, DS_2_NAME);
strcat(scalename, "al");
- if(test_attach_scale(fid, did, scalename, DIM1) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM1) < 0)
goto out;
strcpy(scalename, DS_3_NAME);
strcat(scalename, "al");
- if(test_attach_scale(fid, did, scalename, DIM2) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM2) < 0)
goto out;
strcpy(scalename, DS_4_NAME);
strcat(scalename, "al");
- if(test_attach_scale(fid, did, scalename, DIM3) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM3) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
@@ -382,71 +392,75 @@ static int test_duplicatelong_attachscales(const char *filename)
return SUCCEED;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-static int test_long_scalenames(const char *filename) {
- hid_t fid = -1;
- hid_t did = -1;
- char dsname[32];
- char scalename[32];
- char name[32];
+static int
+test_long_scalenames(const char *filename)
+{
+ hid_t fid = -1;
+ hid_t did = -1;
+ char dsname[32];
+ char scalename[32];
+ char name[32];
strcpy(dsname, DATASET_NAME);
strcat(dsname, "al");
- if((fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
+ if ((fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
goto out;
HL_TESTING2("set long scale/cmp scale name");
- if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
+ if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
strcpy(scalename, DS_1_NAME);
strcat(scalename, "al");
strcpy(name, SCALE_1_NAME);
strcat(name, "al");
- if(test_set_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
strcpy(scalename, DS_2_NAME);
strcat(scalename, "al");
strcpy(name, SCALE_2_NAME);
strcat(name, "al");
- if(test_set_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
strcpy(scalename, DS_3_NAME);
strcat(scalename, "al");
strcpy(name, SCALE_3_NAME);
strcat(name, "al");
- if(test_set_scalename(fid, did, scalename, name, DIM2) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM2) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM2) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM2) < 0)
goto out;
strcpy(scalename, DS_4_NAME);
strcat(scalename, "al");
strcpy(name, SCALE_4_NAME);
strcat(name, "al");
- if(test_set_scalename(fid, did, scalename, name, DIM3) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM3) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM3) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM3) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
@@ -458,72 +472,76 @@ static int test_long_scalenames(const char *filename) {
return SUCCEED;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-static int test_samelong_scalenames(const char *filename) {
- hid_t fid = -1;
- hid_t did = -1;
- char dsname[32];
- char scalename[32];
- char name[32];
+static int
+test_samelong_scalenames(const char *filename)
+{
+ hid_t fid = -1;
+ hid_t did = -1;
+ char dsname[32];
+ char scalename[32];
+ char name[32];
strcpy(dsname, DATASET_NAME);
strcat(dsname, "al2");
- if((fid = open_test_file(filename)) < 0)
+ if ((fid = open_test_file(filename)) < 0)
goto out;
HL_TESTING2("set same long scale/cmp scale name");
- if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
+ if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
strcpy(scalename, DS_1_NAME);
strcat(scalename, "al");
strcpy(name, DS_1_NAME);
strcat(name, "al");
- if(test_set_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
strcpy(scalename, DS_2_NAME);
strcat(scalename, "al");
strcpy(name, DS_2_NAME);
strcat(name, "al");
- if(test_set_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
strcpy(scalename, DS_3_NAME);
strcat(scalename, "al");
strcpy(name, DS_3_NAME);
strcat(name, "al");
- if(test_set_scalename(fid, did, scalename, name, DIM2) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM2) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM2) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM2) < 0)
goto out;
strcpy(scalename, DS_4_NAME);
strcat(scalename, "al");
strcpy(name, DS_4_NAME);
strcat(name, "al");
- if(test_set_scalename(fid, did, scalename, name, DIM3) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM3) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM3) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM3) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
@@ -535,43 +553,46 @@ static int test_samelong_scalenames(const char *filename) {
return SUCCEED;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-static int test_foreign_scaleattached(const char *filename)
+static int
+test_foreign_scaleattached(const char *filename)
{
- herr_t ret_value = FAIL;
- hid_t fid = -1;
- hid_t did = -1;
- hid_t dsid = -1;
+ herr_t ret_value = FAIL;
+ hid_t fid = -1;
+ hid_t did = -1;
+ hid_t dsid = -1;
HL_TESTING2("test_foreign_scaleattached");
- if((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
+ if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
goto out;
- if((did = H5Dopen2(fid, "/dset_al", H5P_DEFAULT)) >= 0) {
- if((dsid = H5Dopen2(fid, "/ds_4_al", H5P_DEFAULT)) >= 0) {
- if(H5DSis_attached(did, dsid, 3) == 1) {
+ if ((did = H5Dopen2(fid, "/dset_al", H5P_DEFAULT)) >= 0) {
+ if ((dsid = H5Dopen2(fid, "/ds_4_al", H5P_DEFAULT)) >= 0) {
+ if (H5DSis_attached(did, dsid, 3) == 1) {
ret_value = SUCCEED;
}
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
}
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
goto out;
- if(ret_value == FAIL)
+ if (ret_value == FAIL)
goto out;
PASSED();
@@ -580,10 +601,12 @@ static int test_foreign_scaleattached(const char *filename)
return 0;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
diff --git a/hl/test/gen_test_ld.c b/hl/test/gen_test_ld.c
index 981aded..2a3beb5 100644
--- a/hl/test/gen_test_ld.c
+++ b/hl/test/gen_test_ld.c
@@ -31,28 +31,28 @@
* DSET_NONE: fixed dimension setting, contiguous, H5D_ALLOC_TIME_LATE
* DSET_NOMAX: fixed dimension setting, chunked, H5D_ALLOC_TIME_INCR
*/
-#define ONE_DIMS0 10
-#define MAX_ONE_DIMS0 100
+#define ONE_DIMS0 10
+#define MAX_ONE_DIMS0 100
-#define DSET_ONE "DSET_ONE"
-#define DSET_NONE "DSET_NONE"
-#define DSET_NOMAX "DSET_NOMAX"
-#define DSET_ALLOC_LATE "DSET_ALLOC_LATE"
+#define DSET_ONE "DSET_ONE"
+#define DSET_NONE "DSET_NONE"
+#define DSET_NOMAX "DSET_NOMAX"
+#define DSET_ALLOC_LATE "DSET_ALLOC_LATE"
#define DSET_ALLOC_EARLY "DSET_ALLOC_EARLY"
-#define DSET_CMPD "DSET_CMPD"
-#define DSET_CMPD_ESC "DSET_CMPD_ESC"
-#define DSET_NULL "DSET_NULL"
-#define DSET_SCALAR "DSET_SCALAR"
+#define DSET_CMPD "DSET_CMPD"
+#define DSET_CMPD_ESC "DSET_CMPD_ESC"
+#define DSET_NULL "DSET_NULL"
+#define DSET_SCALAR "DSET_SCALAR"
-#define TWO_DIMS0 4
-#define TWO_DIMS1 10
-#define MAX_TWO_DIMS0 60
-#define MAX_TWO_DIMS1 100
+#define TWO_DIMS0 4
+#define TWO_DIMS1 10
+#define MAX_TWO_DIMS0 60
+#define MAX_TWO_DIMS1 100
-#define DSET_TWO "DSET_TWO"
-#define DSET_CMPD_TWO "DSET_CMPD_TWO"
+#define DSET_TWO "DSET_TWO"
+#define DSET_CMPD_TWO "DSET_CMPD_TWO"
-#define CHUNK_SIZE 2
+#define CHUNK_SIZE 2
#define FILE "test_ld.h5"
@@ -65,7 +65,7 @@ typedef struct sub22_t {
typedef struct sub2_t {
unsigned int a;
- sub22_t b;
+ sub22_t b;
unsigned int c;
} sub2_t;
@@ -76,9 +76,9 @@ typedef struct sub4_t {
typedef struct set_t {
unsigned int field1;
- sub2_t field2;
- double field3;
- sub4_t field4;
+ sub2_t field2;
+ double field3;
+ sub4_t field4;
} set_t;
/*
@@ -90,119 +90,119 @@ typedef struct set_t {
**************************************************************************************
*/
static int
-generate_dset(hid_t fid, const char *dname, int ndims, hsize_t *dims,
- hsize_t *maxdims, hid_t dtid, void *data)
+generate_dset(hid_t fid, const char *dname, int ndims, hsize_t *dims, hsize_t *maxdims, hid_t dtid,
+ void *data)
{
- hid_t dcpl = -1; /* Dataset creation property */
- hid_t did = -1; /* Dataset id */
- hid_t sid = -1; /* Dataspace id */
- int i; /* Local index variable */
+ hid_t dcpl = -1; /* Dataset creation property */
+ hid_t did = -1; /* Dataset id */
+ hid_t sid = -1; /* Dataspace id */
+ int i; /* Local index variable */
/* Create the dataspace */
- if((sid = H5Screate_simple(ndims, dims, maxdims)) < 0)
- goto done;
+ if ((sid = H5Screate_simple(ndims, dims, maxdims)) < 0)
+ goto done;
/* Set up dataset's creation properties */
- if(!HDstrcmp(dname, DSET_NONE))
- dcpl = H5P_DEFAULT;
+ if (!HDstrcmp(dname, DSET_NONE))
+ dcpl = H5P_DEFAULT;
else {
- hsize_t chunk_dims[H5S_MAX_RANK]; /* Dimension sizes for chunks */
-
- if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
- goto done;
- for(i = 0; i < ndims; i++)
- chunk_dims[i] = CHUNK_SIZE;
- if(H5Pset_chunk(dcpl, ndims, chunk_dims) < 0)
- goto done;
+ hsize_t chunk_dims[H5S_MAX_RANK]; /* Dimension sizes for chunks */
+
+ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ goto done;
+ for (i = 0; i < ndims; i++)
+ chunk_dims[i] = CHUNK_SIZE;
+ if (H5Pset_chunk(dcpl, ndims, chunk_dims) < 0)
+ goto done;
} /* end else */
- if(!HDstrcmp(dname, DSET_ALLOC_LATE)) {
- if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE) < 0)
- goto done;
+ if (!HDstrcmp(dname, DSET_ALLOC_LATE)) {
+ if (H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE) < 0)
+ goto done;
} /* end if */
- else if(!HDstrcmp(dname, DSET_ALLOC_EARLY)) {
- if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0)
- goto done;
+ else if (!HDstrcmp(dname, DSET_ALLOC_EARLY)) {
+ if (H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0)
+ goto done;
} /* end if */
/* Create the dataset */
- if((did = H5Dcreate2(fid, dname, dtid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
- goto done;
+ if ((did = H5Dcreate2(fid, dname, dtid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
+ goto done;
/* Write to the dataset */
- if(H5Dwrite(did, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0)
- goto done;
+ if (H5Dwrite(did, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0)
+ goto done;
/* Closing */
- if(H5Pclose(dcpl) < 0)
+ if (H5Pclose(dcpl) < 0)
goto done;
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
goto done;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto done;
- return(SUCCEED);
+ return (SUCCEED);
done:
H5E_BEGIN_TRY
- H5Sclose(sid);
- H5Pclose(dcpl);
- H5Dclose(did);
+ H5Sclose(sid);
+ H5Pclose(dcpl);
+ H5Dclose(did);
H5E_END_TRY
- return(FAIL);
+ return (FAIL);
} /* generate_dset() */
int
main(void)
{
- hid_t fid; /* File id */
- hid_t fapl; /* File access property list */
- hsize_t cur_dims[1]; /* Dimension sizes */
- hsize_t max_dims[1]; /* Maximum dimension sizes */
- hsize_t cur2_dims[2]; /* Current dimension sizes */
- hsize_t max2_dims[2]; /* Maximum dimension sizes */
- hid_t set_tid, esc_set_tid; /* Compound type id */
- hid_t sub22_tid; /* Compound type id */
- hid_t sub2_tid, esc_sub2_tid; /* Compound type id */
- hid_t sub4_tid, esc_sub4_tid; /* Compound type id */
- hid_t null_did, null_sid; /* H5S_NULL dataset & dataspace ids */
- hid_t scalar_did, scalar_sid; /* H5S_SCALAR dataset & dataspace ids */
- int one_data[ONE_DIMS0]; /* Buffer for data */
- int two_data[TWO_DIMS0*TWO_DIMS1]; /* Buffer for data */
- set_t one_cbuf[ONE_DIMS0]; /* Buffer for data with compound type */
- set_t two_cbuf[TWO_DIMS0*TWO_DIMS1]; /* Buffer for data with compound type */
- int i; /* Local index variable */
+ hid_t fid; /* File id */
+ hid_t fapl; /* File access property list */
+ hsize_t cur_dims[1]; /* Dimension sizes */
+ hsize_t max_dims[1]; /* Maximum dimension sizes */
+ hsize_t cur2_dims[2]; /* Current dimension sizes */
+ hsize_t max2_dims[2]; /* Maximum dimension sizes */
+ hid_t set_tid, esc_set_tid; /* Compound type id */
+ hid_t sub22_tid; /* Compound type id */
+ hid_t sub2_tid, esc_sub2_tid; /* Compound type id */
+ hid_t sub4_tid, esc_sub4_tid; /* Compound type id */
+ hid_t null_did, null_sid; /* H5S_NULL dataset & dataspace ids */
+ hid_t scalar_did, scalar_sid; /* H5S_SCALAR dataset & dataspace ids */
+ int one_data[ONE_DIMS0]; /* Buffer for data */
+ int two_data[TWO_DIMS0 * TWO_DIMS1]; /* Buffer for data */
+ set_t one_cbuf[ONE_DIMS0]; /* Buffer for data with compound type */
+ set_t two_cbuf[TWO_DIMS0 * TWO_DIMS1]; /* Buffer for data with compound type */
+ int i; /* Local index variable */
/* Create a file access property list */
- if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
goto done;
/* Set to use latest library format */
- if((H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST)) < 0)
+ if ((H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST)) < 0)
goto done;
/* Create a file */
- if((fid = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
- goto done;
+ if ((fid = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ goto done;
/* Initialization for one-dimensional dataset */
cur_dims[0] = ONE_DIMS0;
max_dims[0] = MAX_ONE_DIMS0;
- for(i = 0; i < ONE_DIMS0; i++)
+ for (i = 0; i < ONE_DIMS0; i++)
one_data[i] = i;
/* Generate DSET_ONE, DSET_NONE, DSET_NOMAX, DSET_ALLOC_LATE, DSET_EARLY */
- if(generate_dset(fid, DSET_ONE, 1, cur_dims, max_dims, H5T_NATIVE_INT, one_data) < 0)
- goto done;
- if(generate_dset(fid, DSET_NONE, 1, cur_dims, NULL, H5T_NATIVE_INT, one_data) < 0)
- goto done;
- if(generate_dset(fid, DSET_NOMAX, 1, cur_dims, NULL, H5T_NATIVE_INT, one_data) < 0)
- goto done;
- if(generate_dset(fid, DSET_ALLOC_LATE, 1, cur_dims, max_dims, H5T_NATIVE_INT, one_data) < 0)
- goto done;
- if(generate_dset(fid, DSET_ALLOC_EARLY, 1, cur_dims, max_dims, H5T_NATIVE_INT, one_data) < 0)
- goto done;
+ if (generate_dset(fid, DSET_ONE, 1, cur_dims, max_dims, H5T_NATIVE_INT, one_data) < 0)
+ goto done;
+ if (generate_dset(fid, DSET_NONE, 1, cur_dims, NULL, H5T_NATIVE_INT, one_data) < 0)
+ goto done;
+ if (generate_dset(fid, DSET_NOMAX, 1, cur_dims, NULL, H5T_NATIVE_INT, one_data) < 0)
+ goto done;
+ if (generate_dset(fid, DSET_ALLOC_LATE, 1, cur_dims, max_dims, H5T_NATIVE_INT, one_data) < 0)
+ goto done;
+ if (generate_dset(fid, DSET_ALLOC_EARLY, 1, cur_dims, max_dims, H5T_NATIVE_INT, one_data) < 0)
+ goto done;
/* Initialization for two-dimensional dataset */
cur2_dims[0] = TWO_DIMS0;
@@ -210,99 +210,99 @@ main(void)
max2_dims[0] = MAX_TWO_DIMS0;
max2_dims[1] = MAX_TWO_DIMS1;
- for(i = 0; i < (TWO_DIMS0 * TWO_DIMS1); i++)
+ for (i = 0; i < (TWO_DIMS0 * TWO_DIMS1); i++)
two_data[i] = i;
/* Generate DSET_TWO */
- if(generate_dset(fid, DSET_TWO, 2, cur2_dims, max2_dims, H5T_NATIVE_INT, two_data) < 0)
- goto done;
+ if (generate_dset(fid, DSET_TWO, 2, cur2_dims, max2_dims, H5T_NATIVE_INT, two_data) < 0)
+ goto done;
/* Initialization for one-dimensional compound typed dataset */
cur_dims[0] = ONE_DIMS0;
max_dims[0] = MAX_ONE_DIMS0;
for (i = 0; i < ONE_DIMS0; i++) {
- one_cbuf[i].field1 = 1;
- one_cbuf[i].field2.a = 2;
- one_cbuf[i].field2.c = 4;
+ one_cbuf[i].field1 = 1;
+ one_cbuf[i].field2.a = 2;
+ one_cbuf[i].field2.c = 4;
one_cbuf[i].field2.b.a = 20;
one_cbuf[i].field2.b.b = 40;
one_cbuf[i].field2.b.c = 80;
- one_cbuf[i].field3 = 3.0f;
- one_cbuf[i].field4.a = 4;
- one_cbuf[i].field4.b = 8;
+ one_cbuf[i].field3 = 3.0f;
+ one_cbuf[i].field4.a = 4;
+ one_cbuf[i].field4.b = 8;
} /* end for */
/* Create the compound type */
- if((sub22_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub22_t))) < 0)
- goto done;
- if(H5Tinsert(sub22_tid, "a", HOFFSET(sub22_t, a), H5T_NATIVE_INT) < 0)
- goto done;
- if(H5Tinsert(sub22_tid, "b", HOFFSET(sub22_t, b), H5T_NATIVE_INT) < 0)
- goto done;
- if(H5Tinsert(sub22_tid, "c", HOFFSET(sub22_t, c), H5T_NATIVE_INT) < 0)
- goto done;
-
- if((sub2_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub2_t))) < 0)
- goto done;
- if(H5Tinsert(sub2_tid, "a", HOFFSET(sub2_t, a), H5T_NATIVE_INT) < 0)
- goto done;
- if(H5Tinsert(sub2_tid, "b", HOFFSET(sub2_t, b), sub22_tid) < 0)
- goto done;
- if(H5Tinsert(sub2_tid, "c", HOFFSET(sub2_t, c), H5T_NATIVE_INT) < 0)
- goto done;
-
- if((sub4_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub4_t))) < 0)
- goto done;
- if(H5Tinsert(sub4_tid, "a", HOFFSET(sub4_t, a), H5T_NATIVE_INT) < 0)
- goto done;
- if(H5Tinsert(sub4_tid, "b", HOFFSET(sub4_t, b), H5T_NATIVE_INT) < 0)
- goto done;
-
- if((set_tid = H5Tcreate(H5T_COMPOUND, sizeof(set_t))) < 0)
- goto done;
- if(H5Tinsert(set_tid, "field1", HOFFSET(set_t, field1), H5T_NATIVE_INT) < 0)
- goto done;
- if(H5Tinsert(set_tid, "field2", HOFFSET(set_t, field2), sub2_tid) < 0)
- goto done;
- if(H5Tinsert(set_tid, "field3", HOFFSET(set_t, field3), H5T_NATIVE_DOUBLE) < 0)
- goto done;
- if(H5Tinsert(set_tid, "field4", HOFFSET(set_t, field4), sub4_tid) < 0)
- goto done;
+ if ((sub22_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub22_t))) < 0)
+ goto done;
+ if (H5Tinsert(sub22_tid, "a", HOFFSET(sub22_t, a), H5T_NATIVE_INT) < 0)
+ goto done;
+ if (H5Tinsert(sub22_tid, "b", HOFFSET(sub22_t, b), H5T_NATIVE_INT) < 0)
+ goto done;
+ if (H5Tinsert(sub22_tid, "c", HOFFSET(sub22_t, c), H5T_NATIVE_INT) < 0)
+ goto done;
+
+ if ((sub2_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub2_t))) < 0)
+ goto done;
+ if (H5Tinsert(sub2_tid, "a", HOFFSET(sub2_t, a), H5T_NATIVE_INT) < 0)
+ goto done;
+ if (H5Tinsert(sub2_tid, "b", HOFFSET(sub2_t, b), sub22_tid) < 0)
+ goto done;
+ if (H5Tinsert(sub2_tid, "c", HOFFSET(sub2_t, c), H5T_NATIVE_INT) < 0)
+ goto done;
+
+ if ((sub4_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub4_t))) < 0)
+ goto done;
+ if (H5Tinsert(sub4_tid, "a", HOFFSET(sub4_t, a), H5T_NATIVE_INT) < 0)
+ goto done;
+ if (H5Tinsert(sub4_tid, "b", HOFFSET(sub4_t, b), H5T_NATIVE_INT) < 0)
+ goto done;
+
+ if ((set_tid = H5Tcreate(H5T_COMPOUND, sizeof(set_t))) < 0)
+ goto done;
+ if (H5Tinsert(set_tid, "field1", HOFFSET(set_t, field1), H5T_NATIVE_INT) < 0)
+ goto done;
+ if (H5Tinsert(set_tid, "field2", HOFFSET(set_t, field2), sub2_tid) < 0)
+ goto done;
+ if (H5Tinsert(set_tid, "field3", HOFFSET(set_t, field3), H5T_NATIVE_DOUBLE) < 0)
+ goto done;
+ if (H5Tinsert(set_tid, "field4", HOFFSET(set_t, field4), sub4_tid) < 0)
+ goto done;
/* Create the compound type with escape/separator characters */
- if((esc_sub2_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub2_t))) < 0)
- goto done;
- if(H5Tinsert(esc_sub2_tid, ".a", HOFFSET(sub2_t, a), H5T_NATIVE_INT) < 0)
- goto done;
- if(H5Tinsert(esc_sub2_tid, ",b", HOFFSET(sub2_t, b), sub22_tid) < 0)
- goto done;
- if(H5Tinsert(esc_sub2_tid, "\\c", HOFFSET(sub2_t, c), H5T_NATIVE_INT) < 0)
- goto done;
-
- if((esc_sub4_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub4_t))) < 0)
- goto done;
- if(H5Tinsert(esc_sub4_tid, "a.", HOFFSET(sub4_t, a), H5T_NATIVE_INT) < 0)
- goto done;
- if(H5Tinsert(esc_sub4_tid, "b,", HOFFSET(sub4_t, b), H5T_NATIVE_INT) < 0)
- goto done;
-
- if((esc_set_tid = H5Tcreate(H5T_COMPOUND, sizeof(set_t))) < 0)
- goto done;
- if(H5Tinsert(esc_set_tid, "field,1", HOFFSET(set_t, field1), H5T_NATIVE_INT) < 0)
- goto done;
- if(H5Tinsert(esc_set_tid, "field2.", HOFFSET(set_t, field2), esc_sub2_tid) < 0)
- goto done;
- if(H5Tinsert(esc_set_tid, "field\\3", HOFFSET(set_t, field3), H5T_NATIVE_DOUBLE) < 0)
- goto done;
- if(H5Tinsert(esc_set_tid, "field4,", HOFFSET(set_t, field4), esc_sub4_tid) < 0)
- goto done;
+ if ((esc_sub2_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub2_t))) < 0)
+ goto done;
+ if (H5Tinsert(esc_sub2_tid, ".a", HOFFSET(sub2_t, a), H5T_NATIVE_INT) < 0)
+ goto done;
+ if (H5Tinsert(esc_sub2_tid, ",b", HOFFSET(sub2_t, b), sub22_tid) < 0)
+ goto done;
+ if (H5Tinsert(esc_sub2_tid, "\\c", HOFFSET(sub2_t, c), H5T_NATIVE_INT) < 0)
+ goto done;
+
+ if ((esc_sub4_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub4_t))) < 0)
+ goto done;
+ if (H5Tinsert(esc_sub4_tid, "a.", HOFFSET(sub4_t, a), H5T_NATIVE_INT) < 0)
+ goto done;
+ if (H5Tinsert(esc_sub4_tid, "b,", HOFFSET(sub4_t, b), H5T_NATIVE_INT) < 0)
+ goto done;
+
+ if ((esc_set_tid = H5Tcreate(H5T_COMPOUND, sizeof(set_t))) < 0)
+ goto done;
+ if (H5Tinsert(esc_set_tid, "field,1", HOFFSET(set_t, field1), H5T_NATIVE_INT) < 0)
+ goto done;
+ if (H5Tinsert(esc_set_tid, "field2.", HOFFSET(set_t, field2), esc_sub2_tid) < 0)
+ goto done;
+ if (H5Tinsert(esc_set_tid, "field\\3", HOFFSET(set_t, field3), H5T_NATIVE_DOUBLE) < 0)
+ goto done;
+ if (H5Tinsert(esc_set_tid, "field4,", HOFFSET(set_t, field4), esc_sub4_tid) < 0)
+ goto done;
/* Generate DSET_CMPD, DSET_CMPD_ESC */
- if(generate_dset(fid, DSET_CMPD, 1, cur_dims, max_dims, set_tid, one_cbuf) < 0)
- goto done;
- if(generate_dset(fid, DSET_CMPD_ESC, 1, cur_dims, max_dims, esc_set_tid, one_cbuf) < 0)
- goto done;
+ if (generate_dset(fid, DSET_CMPD, 1, cur_dims, max_dims, set_tid, one_cbuf) < 0)
+ goto done;
+ if (generate_dset(fid, DSET_CMPD_ESC, 1, cur_dims, max_dims, esc_set_tid, one_cbuf) < 0)
+ goto done;
/* Initialization for two-dimensional compound typed dataset */
cur2_dims[0] = TWO_DIMS0;
@@ -311,76 +311,90 @@ main(void)
max2_dims[0] = MAX_TWO_DIMS1;
for (i = 0; i < (TWO_DIMS0 * TWO_DIMS1); i++) {
- two_cbuf[i].field1 = 1;
- two_cbuf[i].field2.a = 2;
- two_cbuf[i].field2.c = 4;
+ two_cbuf[i].field1 = 1;
+ two_cbuf[i].field2.a = 2;
+ two_cbuf[i].field2.c = 4;
two_cbuf[i].field2.b.a = 20;
two_cbuf[i].field2.b.b = 40;
two_cbuf[i].field2.b.c = 80;
- two_cbuf[i].field3 = 3.0f;
- two_cbuf[i].field4.a = 4;
- two_cbuf[i].field4.b = 8;
+ two_cbuf[i].field3 = 3.0f;
+ two_cbuf[i].field4.a = 4;
+ two_cbuf[i].field4.b = 8;
} /* end for */
/* Generate DSET_CMPD_TWO */
- if(generate_dset(fid, DSET_CMPD_TWO, 2, cur2_dims, max2_dims, set_tid, two_cbuf) < 0)
- goto done;
+ if (generate_dset(fid, DSET_CMPD_TWO, 2, cur2_dims, max2_dims, set_tid, two_cbuf) < 0)
+ goto done;
/* Create NULL dataspace */
- if((null_sid = H5Screate(H5S_NULL)) < 0)
- goto done;
+ if ((null_sid = H5Screate(H5S_NULL)) < 0)
+ goto done;
/* Create the NULL dataset */
- if((null_did = H5Dcreate2(fid, DSET_NULL, H5T_NATIVE_UINT, null_sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- goto done;
+ if ((null_did = H5Dcreate2(fid, DSET_NULL, H5T_NATIVE_UINT, null_sid, H5P_DEFAULT, H5P_DEFAULT,
+ H5P_DEFAULT)) < 0)
+ goto done;
/* Create SCALAR dataspace */
- if((scalar_sid = H5Screate(H5S_SCALAR)) < 0)
- goto done;
+ if ((scalar_sid = H5Screate(H5S_SCALAR)) < 0)
+ goto done;
/* Create the SCALAR dataset */
- if((scalar_did = H5Dcreate2(fid, DSET_SCALAR, H5T_NATIVE_INT, scalar_sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- goto done;
+ if ((scalar_did = H5Dcreate2(fid, DSET_SCALAR, H5T_NATIVE_INT, scalar_sid, H5P_DEFAULT, H5P_DEFAULT,
+ H5P_DEFAULT)) < 0)
+ goto done;
/* Closing */
- if(H5Dclose(scalar_did) < 0) goto done;
- if(H5Sclose(scalar_sid) < 0) goto done;
+ if (H5Dclose(scalar_did) < 0)
+ goto done;
+ if (H5Sclose(scalar_sid) < 0)
+ goto done;
- if(H5Dclose(null_did) < 0) goto done;
- if(H5Sclose(null_sid) < 0) goto done;
+ if (H5Dclose(null_did) < 0)
+ goto done;
+ if (H5Sclose(null_sid) < 0)
+ goto done;
- if(H5Tclose(sub22_tid) < 0) goto done;
- if(H5Tclose(sub2_tid) < 0) goto done;
- if(H5Tclose(sub4_tid) < 0) goto done;
- if(H5Tclose(set_tid) < 0) goto done;
- if(H5Tclose(esc_sub2_tid) < 0) goto done;
- if(H5Tclose(esc_sub4_tid) < 0) goto done;
- if(H5Tclose(esc_set_tid) < 0) goto done;
+ if (H5Tclose(sub22_tid) < 0)
+ goto done;
+ if (H5Tclose(sub2_tid) < 0)
+ goto done;
+ if (H5Tclose(sub4_tid) < 0)
+ goto done;
+ if (H5Tclose(set_tid) < 0)
+ goto done;
+ if (H5Tclose(esc_sub2_tid) < 0)
+ goto done;
+ if (H5Tclose(esc_sub4_tid) < 0)
+ goto done;
+ if (H5Tclose(esc_set_tid) < 0)
+ goto done;
- if(H5Pclose(fapl) < 0) goto done;
- if(H5Fclose(fid) < 0) goto done;
+ if (H5Pclose(fapl) < 0)
+ goto done;
+ if (H5Fclose(fid) < 0)
+ goto done;
exit(EXIT_SUCCESS);
done:
H5E_BEGIN_TRY
- H5Tclose(sub22_tid);
- H5Tclose(sub2_tid);
- H5Tclose(sub4_tid);
- H5Tclose(set_tid);
- H5Tclose(esc_sub2_tid);
- H5Tclose(esc_sub4_tid);
- H5Tclose(esc_set_tid);
-
- H5Dclose(null_did);
- H5Sclose(null_sid);
- H5Dclose(scalar_did);
- H5Sclose(scalar_sid);
-
- H5Pclose(fapl);
- H5Fclose(fid);
+ H5Tclose(sub22_tid);
+ H5Tclose(sub2_tid);
+ H5Tclose(sub4_tid);
+ H5Tclose(set_tid);
+ H5Tclose(esc_sub2_tid);
+ H5Tclose(esc_sub4_tid);
+ H5Tclose(esc_set_tid);
+
+ H5Dclose(null_did);
+ H5Sclose(null_sid);
+ H5Dclose(scalar_did);
+ H5Sclose(scalar_sid);
+
+ H5Pclose(fapl);
+ H5Fclose(fid);
H5E_END_TRY
exit(EXIT_FAILURE);
} /* main() */
-
diff --git a/hl/test/h5hltest.h b/hl/test/h5hltest.h
index 6cf5062..4ccdd78 100644
--- a/hl/test/h5hltest.h
+++ b/hl/test/h5hltest.h
@@ -28,13 +28,24 @@
#include "H5HLprivate2.h"
/* Macros used in HL tests */
-#define HL_TESTING2(WHAT) {HDprintf("Testing %-62s", WHAT); HDfflush(stdout);}
-#define HL_TESTING3(WHAT) {HDprintf("Testing %-62s", WHAT); HDfflush(stdout);}
+#define HL_TESTING2(WHAT) \
+ { \
+ HDprintf("Testing %-62s", WHAT); \
+ HDfflush(stdout); \
+ }
+#define HL_TESTING3(WHAT) \
+ { \
+ HDprintf("Testing %-62s", WHAT); \
+ HDfflush(stdout); \
+ }
/* Implements verbose 'assert' with 'goto error' exit */
-#define VERIFY(condition, string) do { if (!(condition)) FAIL_PUTS_ERROR(string) } while(0)
+#define VERIFY(condition, string) \
+ do { \
+ if (!(condition)) \
+ FAIL_PUTS_ERROR(string) \
+ } while (0)
int test_packet_table_with_varlen(void);
#endif /* _H5HLTEST_H */
-
diff --git a/hl/test/pal_rgb.h b/hl/test/pal_rgb.h
index 488ee42..137d5d9 100644
--- a/hl/test/pal_rgb.h
+++ b/hl/test/pal_rgb.h
@@ -271,10 +271,3 @@ const unsigned char pal_rgb[256*3] = {
127,0,0
};
/* clang-format on */
-
-
-
-
-
-
-
diff --git a/hl/test/test_ds.c b/hl/test/test_ds.c
index 5550dd1..9e56ff0 100644
--- a/hl/test/test_ds.c
+++ b/hl/test/test_ds.c
@@ -27,27 +27,43 @@ static herr_t op_stop(hid_t did, unsigned dim, hid_t dsid, void *visitor_data);
/* prototypes */
static hid_t create_test_file(const char *fileext);
static hid_t open_test_file(const char *fileext);
-herr_t create_char_dataset(hid_t fid, const char *dsidx, int fulldims);
-herr_t create_short_dataset(hid_t fid, const char *dsidx, int fulldims);
-herr_t create_int_dataset(hid_t fid, const char *dsidx, int fulldims);
-herr_t create_long_dataset(hid_t fid, const char *dsname, const char *dsidx, int fulldims);
-herr_t create_float_dataset(hid_t fid, const char *dsidx, int fulldims);
-herr_t create_DS1_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, char *s_wbuf, char *s1_wbuf);
-herr_t create_DS2_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, char *s_wbuf, char *s1_wbuf, char *s2_wbuf);
-herr_t create_DS3_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, char *s_wbuf, char *s1_wbuf, char *s2_wbuf, char *s3_wbuf);
-herr_t create_DS1_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, short *s_wbuf, short *s1_wbuf);
-herr_t create_DS2_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, short *s_wbuf, short *s1_wbuf, short *s2_wbuf);
-herr_t create_DS3_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, short *s_wbuf, short *s1_wbuf, short *s2_wbuf, short *s3_wbuf);
-herr_t create_DS1_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, int *s_wbuf, int *s1_wbuf);
-herr_t create_DS2_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, int *s_wbuf, int *s1_wbuf, int *s2_wbuf);
-herr_t create_DS3_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, int *s_wbuf, int *s1_wbuf, int *s2_wbuf, int *s3_wbuf);
-herr_t create_DS1_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf, long *s1_wbuf);
-herr_t create_DS2_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf, long *s1_wbuf, long *s2_wbuf);
-herr_t create_DS3_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf, long *s1_wbuf, long *s2_wbuf, long *s3_wbuf);
-herr_t create_DS4_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf, long *s1_wbuf, long *s2_wbuf, long *s3_wbuf, long *s4_wbuf);
-herr_t create_DS1_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, float *s_wbuf, float *s1_wbuf);
-herr_t create_DS2_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, float *s_wbuf, float *s1_wbuf, float *s2_wbuf);
-herr_t create_DS3_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, float *s_wbuf, float *s1_wbuf, float *s2_wbuf, float *s3_wbuf);
+herr_t create_char_dataset(hid_t fid, const char *dsidx, int fulldims);
+herr_t create_short_dataset(hid_t fid, const char *dsidx, int fulldims);
+herr_t create_int_dataset(hid_t fid, const char *dsidx, int fulldims);
+herr_t create_long_dataset(hid_t fid, const char *dsname, const char *dsidx, int fulldims);
+herr_t create_float_dataset(hid_t fid, const char *dsidx, int fulldims);
+herr_t create_DS1_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, char *s_wbuf,
+ char *s1_wbuf);
+herr_t create_DS2_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, char *s_wbuf,
+ char *s1_wbuf, char *s2_wbuf);
+herr_t create_DS3_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, char *s_wbuf,
+ char *s1_wbuf, char *s2_wbuf, char *s3_wbuf);
+herr_t create_DS1_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, short *s_wbuf,
+ short *s1_wbuf);
+herr_t create_DS2_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, short *s_wbuf,
+ short *s1_wbuf, short *s2_wbuf);
+herr_t create_DS3_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, short *s_wbuf,
+ short *s1_wbuf, short *s2_wbuf, short *s3_wbuf);
+herr_t create_DS1_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, int *s_wbuf,
+ int *s1_wbuf);
+herr_t create_DS2_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, int *s_wbuf,
+ int *s1_wbuf, int *s2_wbuf);
+herr_t create_DS3_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, int *s_wbuf,
+ int *s1_wbuf, int *s2_wbuf, int *s3_wbuf);
+herr_t create_DS1_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf,
+ long *s1_wbuf);
+herr_t create_DS2_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf,
+ long *s1_wbuf, long *s2_wbuf);
+herr_t create_DS3_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf,
+ long *s1_wbuf, long *s2_wbuf, long *s3_wbuf);
+herr_t create_DS4_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf,
+ long *s1_wbuf, long *s2_wbuf, long *s3_wbuf, long *s4_wbuf);
+herr_t create_DS1_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, float *s_wbuf,
+ float *s1_wbuf);
+herr_t create_DS2_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, float *s_wbuf,
+ float *s1_wbuf, float *s2_wbuf);
+herr_t create_DS3_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, float *s_wbuf,
+ float *s1_wbuf, float *s2_wbuf, float *s3_wbuf);
herr_t test_attach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx);
herr_t test_detach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx);
herr_t test_set_scalename(hid_t fid, hid_t did, const char *name, const char *scalename, unsigned int idx);
@@ -76,64 +92,64 @@ static int test_rank(void);
static int test_types(void);
static int test_iterators(void);
static int test_data(void);
-static int read_data( const char* fname, int ndims, hsize_t *dims, float **buf );
+static int read_data(const char *fname, int ndims, hsize_t *dims, float **buf);
static int test_attach_detach(void);
-#define RANK1 1
-#define RANK 2
-#define DIM_DATA 12
-#define DIM1_SIZE 3
-#define DIM2_SIZE 4
-#define DIM3_SIZE 12
-#define DIM4_SIZE 2
-#define DIM0 0
-#define DIM1 1
-#define DIM2 2
-#define DIM3 3
-
-#define DATASET_NAME "dset_"
-#define DS_1_NAME "ds_1_"
-#define DS_11_NAME "ds_11_"
-#define DS_2_NAME "ds_2_"
-#define DS_21_NAME "ds_21_"
-#define DS_22_NAME "ds_22_"
-#define DS_3_NAME "ds_3_"
-#define DS_31_NAME "ds_31_"
-#define DS_32_NAME "ds_32_"
-#define DS_33_NAME "ds_33_"
-#define DS_4_NAME "ds_4_"
-#define DS_41_NAME "ds_41_"
-#define DS_42_NAME "ds_42_"
-#define DS_43_NAME "ds_43_"
-#define DS_44_NAME "ds_44_"
-
-#define SCALE_1_NAME "scalename_1_"
-#define SCALE_11_NAME "scalename_11_"
-#define SCALE_2_NAME "scalename_2_"
-#define SCALE_21_NAME "scalename_21_"
-#define SCALE_22_NAME "scalename_22_"
-#define SCALE_3_NAME "scalename_3_"
-#define SCALE_31_NAME "scalename_31_"
-#define SCALE_32_NAME "scalename_32_"
-#define SCALE_33_NAME "scalename_33_"
-#define SCALE_4_NAME "scalename_4_"
-
-#define DIM0_LABEL "Latitude"
-#define DIM1_LABEL "Longitude"
-
-#define FOREIGN_FILE1 "test_ds_le.h5"
-#define FOREIGN_FILE2 "test_ds_be.h5"
-#define FILENAME "test_ds"
-#define FILEEXT ".h5"
-
-#define FILE1 "test_ds3.h5"
-#define FILE2 "test_ds4.h5"
-#define FILE3 "test_ds5.h5"
-#define FILE4 "test_ds6.h5"
-#define FILE5 "test_ds7.h5"
-#define FILE6 "test_ds8.h5"
-#define FILE7 "test_ds9.h5"
-#define FILE8 "test_ds10.h5"
+#define RANK1 1
+#define RANK 2
+#define DIM_DATA 12
+#define DIM1_SIZE 3
+#define DIM2_SIZE 4
+#define DIM3_SIZE 12
+#define DIM4_SIZE 2
+#define DIM0 0
+#define DIM1 1
+#define DIM2 2
+#define DIM3 3
+
+#define DATASET_NAME "dset_"
+#define DS_1_NAME "ds_1_"
+#define DS_11_NAME "ds_11_"
+#define DS_2_NAME "ds_2_"
+#define DS_21_NAME "ds_21_"
+#define DS_22_NAME "ds_22_"
+#define DS_3_NAME "ds_3_"
+#define DS_31_NAME "ds_31_"
+#define DS_32_NAME "ds_32_"
+#define DS_33_NAME "ds_33_"
+#define DS_4_NAME "ds_4_"
+#define DS_41_NAME "ds_41_"
+#define DS_42_NAME "ds_42_"
+#define DS_43_NAME "ds_43_"
+#define DS_44_NAME "ds_44_"
+
+#define SCALE_1_NAME "scalename_1_"
+#define SCALE_11_NAME "scalename_11_"
+#define SCALE_2_NAME "scalename_2_"
+#define SCALE_21_NAME "scalename_21_"
+#define SCALE_22_NAME "scalename_22_"
+#define SCALE_3_NAME "scalename_3_"
+#define SCALE_31_NAME "scalename_31_"
+#define SCALE_32_NAME "scalename_32_"
+#define SCALE_33_NAME "scalename_33_"
+#define SCALE_4_NAME "scalename_4_"
+
+#define DIM0_LABEL "Latitude"
+#define DIM1_LABEL "Longitude"
+
+#define FOREIGN_FILE1 "test_ds_le.h5"
+#define FOREIGN_FILE2 "test_ds_be.h5"
+#define FILENAME "test_ds"
+#define FILEEXT ".h5"
+
+#define FILE1 "test_ds3.h5"
+#define FILE2 "test_ds4.h5"
+#define FILE3 "test_ds5.h5"
+#define FILE4 "test_ds6.h5"
+#define FILE5 "test_ds7.h5"
+#define FILE6 "test_ds8.h5"
+#define FILE7 "test_ds9.h5"
+#define FILE8 "test_ds10.h5"
#define DIMENSION_LIST "DIMENSION_LIST"
#define REFERENCE_LIST "REFERENCE_LIST"
@@ -142,57 +158,57 @@ static int test_attach_detach(void);
* the main program
*-------------------------------------------------------------------------
*/
-int main(void)
+int
+main(void)
{
- int nerrors=0;
+ int nerrors = 0;
/* create file to be used in following tests */
- if(create_test_file("1") < 0) {
+ if (create_test_file("1") < 0) {
nerrors = 1;
goto error;
}
- nerrors += test_char_attachscales("1") < 0 ? 1 : 0;
- nerrors += test_short_attachscales("1") < 0 ? 1 : 0;
- nerrors += test_int_attachscales("1") < 0 ? 1 : 0;
- nerrors += test_long_attachscales("1") < 0 ? 1 : 0;
- nerrors += test_float_attachscales("1") < 0 ? 1 : 0;
- nerrors += test_char_scalenames("1") < 0 ? 1 : 0;
- nerrors += test_short_scalenames("1") < 0 ? 1 : 0;
- nerrors += test_int_scalenames("1") < 0 ? 1 : 0;
- nerrors += test_long_scalenames("1") < 0 ? 1 : 0;
- nerrors += test_float_scalenames("1") < 0 ? 1 : 0;
- nerrors += test_numberofscales("1") < 0 ? 1 : 0;
- if(create_test_file("2") < 0) {
+ nerrors += test_char_attachscales("1") < 0 ? 1 : 0;
+ nerrors += test_short_attachscales("1") < 0 ? 1 : 0;
+ nerrors += test_int_attachscales("1") < 0 ? 1 : 0;
+ nerrors += test_long_attachscales("1") < 0 ? 1 : 0;
+ nerrors += test_float_attachscales("1") < 0 ? 1 : 0;
+ nerrors += test_char_scalenames("1") < 0 ? 1 : 0;
+ nerrors += test_short_scalenames("1") < 0 ? 1 : 0;
+ nerrors += test_int_scalenames("1") < 0 ? 1 : 0;
+ nerrors += test_long_scalenames("1") < 0 ? 1 : 0;
+ nerrors += test_float_scalenames("1") < 0 ? 1 : 0;
+ nerrors += test_numberofscales("1") < 0 ? 1 : 0;
+ if (create_test_file("2") < 0) {
nerrors = 1;
goto error;
}
- nerrors += test_long_attachscales("2") < 0 ? 1 : 0;
- nerrors += test_duplicatelong_attachscales("2") < 0 ? 1 : 0;
- nerrors += test_samelong_scalenames("2") < 0 ? 1 : 0;
- nerrors += test_foreign_scaleattached(FOREIGN_FILE1) < 0 ? 1 : 0;
- nerrors += test_foreign_scaleattached(FOREIGN_FILE2) < 0 ? 1 : 0;
- nerrors += test_detachscales() < 0 ? 1 : 0;
- nerrors += test_attach_detach() < 0 ? 1 : 0;
-/* the following tests have not been rewritten to match those above */
- nerrors += test_simple() < 0 ?1:0;
- nerrors += test_errors() < 0 ?1:0;
- nerrors += test_errors2() < 0 ?1:0;
- nerrors += test_rank() < 0 ?1:0;
- nerrors += test_iterators() < 0 ?1:0;
- nerrors += test_types() < 0 ?1:0;
- nerrors += test_data() < 0 ?1:0;
-
-
- if(nerrors) goto error;
+ nerrors += test_long_attachscales("2") < 0 ? 1 : 0;
+ nerrors += test_duplicatelong_attachscales("2") < 0 ? 1 : 0;
+ nerrors += test_samelong_scalenames("2") < 0 ? 1 : 0;
+ nerrors += test_foreign_scaleattached(FOREIGN_FILE1) < 0 ? 1 : 0;
+ nerrors += test_foreign_scaleattached(FOREIGN_FILE2) < 0 ? 1 : 0;
+ nerrors += test_detachscales() < 0 ? 1 : 0;
+ nerrors += test_attach_detach() < 0 ? 1 : 0;
+ /* the following tests have not been rewritten to match those above */
+ nerrors += test_simple() < 0 ? 1 : 0;
+ nerrors += test_errors() < 0 ? 1 : 0;
+ nerrors += test_errors2() < 0 ? 1 : 0;
+ nerrors += test_rank() < 0 ? 1 : 0;
+ nerrors += test_iterators() < 0 ? 1 : 0;
+ nerrors += test_types() < 0 ? 1 : 0;
+ nerrors += test_data() < 0 ? 1 : 0;
+
+ if (nerrors)
+ goto error;
HDprintf("All dimension scales tests passed.\n");
return 0;
error:
- HDprintf("***** %d DIMENSION SCALES TEST%s FAILED! *****\n",nerrors, 1 == nerrors ? "" : "S");
+ HDprintf("***** %d DIMENSION SCALES TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S");
return 1;
}
-
/*-------------------------------------------------------------------------
* DS API test
*
@@ -211,7 +227,8 @@ error:
*-------------------------------------------------------------------------
*/
-static hid_t create_test_file(const char *fileext)
+static hid_t
+create_test_file(const char *fileext)
{
char filename[65];
@@ -220,7 +237,8 @@ static hid_t create_test_file(const char *fileext)
return H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
}
-static hid_t open_test_file(const char *fileext)
+static hid_t
+open_test_file(const char *fileext)
{
char filename[65];
@@ -233,261 +251,270 @@ static hid_t open_test_file(const char *fileext)
* create "data" dataset
*-------------------------------------------------------------------------
*/
-herr_t create_char_dataset(hid_t fid, const char *dsidx, int fulldims)
+herr_t
+create_char_dataset(hid_t fid, const char *dsidx, int fulldims)
{
- int rank = 3;
- int rankds = 1;
- hsize_t dims[3] = {DIM1_SIZE,DIM2_SIZE,DIM3_SIZE};
- char buf[DIM1_SIZE*DIM2_SIZE*DIM3_SIZE];
- hsize_t s1_dim[1] = {DIM1_SIZE};
- hsize_t s2_dim[1] = {DIM2_SIZE};
- hsize_t s3_dim[1] = {DIM3_SIZE};
- char s1_wbuf[DIM1_SIZE] = {1,2,3};
- char s11_wbuf[DIM1_SIZE] = {10,20,30};
- char s2_wbuf[DIM2_SIZE] = {10,20,30,40};
- char s21_wbuf[DIM2_SIZE] = {1,2,3,4};
- char s22_wbuf[DIM2_SIZE] = {5,10,50,100};
- char s3_wbuf[DIM3_SIZE] = {10,10,10,20,20,20,30,30,30,40,40,40};
- char s31_wbuf[DIM3_SIZE] = {1,1,1,2,2,2,3,3,3,4,4,4};
- char s32_wbuf[DIM3_SIZE] = {5,5,5,10,10,10,50,50,50,100,100,100};
- char s33_wbuf[DIM3_SIZE] = {6,6,6,12,12,12,53,53,53,120,120,120};
+ int rank = 3;
+ int rankds = 1;
+ hsize_t dims[3] = {DIM1_SIZE, DIM2_SIZE, DIM3_SIZE};
+ char buf[DIM1_SIZE * DIM2_SIZE * DIM3_SIZE];
+ hsize_t s1_dim[1] = {DIM1_SIZE};
+ hsize_t s2_dim[1] = {DIM2_SIZE};
+ hsize_t s3_dim[1] = {DIM3_SIZE};
+ char s1_wbuf[DIM1_SIZE] = {1, 2, 3};
+ char s11_wbuf[DIM1_SIZE] = {10, 20, 30};
+ char s2_wbuf[DIM2_SIZE] = {10, 20, 30, 40};
+ char s21_wbuf[DIM2_SIZE] = {1, 2, 3, 4};
+ char s22_wbuf[DIM2_SIZE] = {5, 10, 50, 100};
+ char s3_wbuf[DIM3_SIZE] = {10, 10, 10, 20, 20, 20, 30, 30, 30, 40, 40, 40};
+ char s31_wbuf[DIM3_SIZE] = {1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4};
+ char s32_wbuf[DIM3_SIZE] = {5, 5, 5, 10, 10, 10, 50, 50, 50, 100, 100, 100};
+ char s33_wbuf[DIM3_SIZE] = {6, 6, 6, 12, 12, 12, 53, 53, 53, 120, 120, 120};
char name[64];
HDsnprintf(name, sizeof(name), "%s%s", DATASET_NAME, dsidx);
/* make a dataset */
- if(H5LTmake_dataset_char(fid, name, rank, dims, buf) >= 0) {
- if(fulldims==0) {
+ if (H5LTmake_dataset_char(fid, name, rank, dims, buf) >= 0) {
+ if (fulldims == 0) {
/* make a DS dataset for the first dimension */
- if(create_DS1_char_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, NULL) < 0)
- return FAIL;
+ if (create_DS1_char_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, NULL) < 0)
+ return FAIL;
/* make a DS dataset for the second dimension */
- if(create_DS2_char_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, NULL, NULL) < 0)
- return FAIL;
+ if (create_DS2_char_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, NULL, NULL) < 0)
+ return FAIL;
/* make a DS dataset for the third dimension */
- if(create_DS3_char_datasets(fid, dsidx, rankds, s3_dim, s3_wbuf, NULL, NULL, NULL) < 0)
- return FAIL;
+ if (create_DS3_char_datasets(fid, dsidx, rankds, s3_dim, s3_wbuf, NULL, NULL, NULL) < 0)
+ return FAIL;
}
else {
- if(create_DS1_char_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, s11_wbuf) < 0)
- return FAIL;
+ if (create_DS1_char_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, s11_wbuf) < 0)
+ return FAIL;
- if(create_DS2_char_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, s21_wbuf, s22_wbuf) < 0)
- return FAIL;
+ if (create_DS2_char_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, s21_wbuf, s22_wbuf) < 0)
+ return FAIL;
- if(create_DS3_char_datasets(fid, dsidx, rankds, s3_dim, s3_wbuf, s31_wbuf, s32_wbuf, s33_wbuf) < 0)
- return FAIL;
+ if (create_DS3_char_datasets(fid, dsidx, rankds, s3_dim, s3_wbuf, s31_wbuf, s32_wbuf, s33_wbuf) <
+ 0)
+ return FAIL;
}
- }
- else
- return FAIL;
+ }
+ else
+ return FAIL;
return SUCCEED;
}
-herr_t create_short_dataset(hid_t fid, const char *dsidx, int fulldims)
+herr_t
+create_short_dataset(hid_t fid, const char *dsidx, int fulldims)
{
- int rank = 3;
- int rankds = 1;
- hsize_t dims[3] = {DIM1_SIZE,DIM2_SIZE,DIM3_SIZE};
- short buf[DIM1_SIZE*DIM2_SIZE*DIM3_SIZE];
- hsize_t s1_dim[1] = {DIM1_SIZE};
- hsize_t s2_dim[1] = {DIM2_SIZE};
- hsize_t s3_dim[1] = {DIM3_SIZE};
- short s1_wbuf[DIM1_SIZE] = {10,20,30};
- short s11_wbuf[DIM1_SIZE] = {10,100,300};
- short s2_wbuf[DIM2_SIZE] = {100,200,300,400};
- short s21_wbuf[DIM2_SIZE] = {10,20,30,40};
- short s22_wbuf[DIM2_SIZE] = {5,10,50,300};
- short s3_wbuf[DIM3_SIZE] = {10,10,10,20,20,20,30,30,30,40,40,40};
- short s31_wbuf[DIM3_SIZE] = {1,1,1,2,2,2,3,3,3,4,4,4};
- short s32_wbuf[DIM3_SIZE] = {5,5,5,10,10,10,50,50,50,100,100,100};
- short s33_wbuf[DIM3_SIZE] = {6,6,6,12,12,12,53,53,53,140,140,140};
+ int rank = 3;
+ int rankds = 1;
+ hsize_t dims[3] = {DIM1_SIZE, DIM2_SIZE, DIM3_SIZE};
+ short buf[DIM1_SIZE * DIM2_SIZE * DIM3_SIZE];
+ hsize_t s1_dim[1] = {DIM1_SIZE};
+ hsize_t s2_dim[1] = {DIM2_SIZE};
+ hsize_t s3_dim[1] = {DIM3_SIZE};
+ short s1_wbuf[DIM1_SIZE] = {10, 20, 30};
+ short s11_wbuf[DIM1_SIZE] = {10, 100, 300};
+ short s2_wbuf[DIM2_SIZE] = {100, 200, 300, 400};
+ short s21_wbuf[DIM2_SIZE] = {10, 20, 30, 40};
+ short s22_wbuf[DIM2_SIZE] = {5, 10, 50, 300};
+ short s3_wbuf[DIM3_SIZE] = {10, 10, 10, 20, 20, 20, 30, 30, 30, 40, 40, 40};
+ short s31_wbuf[DIM3_SIZE] = {1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4};
+ short s32_wbuf[DIM3_SIZE] = {5, 5, 5, 10, 10, 10, 50, 50, 50, 100, 100, 100};
+ short s33_wbuf[DIM3_SIZE] = {6, 6, 6, 12, 12, 12, 53, 53, 53, 140, 140, 140};
char name[64];
HDsnprintf(name, sizeof(name), "%s%s", DATASET_NAME, dsidx);
/* make a dataset */
- if(H5LTmake_dataset_short(fid, name, rank, dims, buf) >= 0) {
- if(fulldims==0) {
+ if (H5LTmake_dataset_short(fid, name, rank, dims, buf) >= 0) {
+ if (fulldims == 0) {
/* make a DS dataset for the first dimension */
- if(create_DS1_short_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, NULL) < 0)
- return FAIL;
+ if (create_DS1_short_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, NULL) < 0)
+ return FAIL;
/* make a DS dataset for the second dimension */
- if(create_DS2_short_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, NULL, NULL) < 0)
- return FAIL;
+ if (create_DS2_short_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, NULL, NULL) < 0)
+ return FAIL;
/* make a DS dataset for the third dimension */
- if(create_DS3_short_datasets(fid, dsidx, rankds, s3_dim, s3_wbuf, NULL, NULL, NULL) < 0)
- return FAIL;
+ if (create_DS3_short_datasets(fid, dsidx, rankds, s3_dim, s3_wbuf, NULL, NULL, NULL) < 0)
+ return FAIL;
}
else {
- if(create_DS1_short_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, s11_wbuf) < 0)
- return FAIL;
+ if (create_DS1_short_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, s11_wbuf) < 0)
+ return FAIL;
- if(create_DS2_short_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, s21_wbuf, s22_wbuf) < 0)
- return FAIL;
+ if (create_DS2_short_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, s21_wbuf, s22_wbuf) < 0)
+ return FAIL;
- if(create_DS3_short_datasets(fid, dsidx, rankds, s3_dim, s3_wbuf, s31_wbuf, s32_wbuf, s33_wbuf) < 0)
- return FAIL;
+ if (create_DS3_short_datasets(fid, dsidx, rankds, s3_dim, s3_wbuf, s31_wbuf, s32_wbuf, s33_wbuf) <
+ 0)
+ return FAIL;
}
- }
- else
- return FAIL;
+ }
+ else
+ return FAIL;
return SUCCEED;
}
-herr_t create_int_dataset(hid_t fid, const char *dsidx, int fulldims)
+herr_t
+create_int_dataset(hid_t fid, const char *dsidx, int fulldims)
{
- int rank = RANK;
- int rankds = 1;
- hsize_t dims[RANK] = {DIM1_SIZE,DIM2_SIZE};
- int buf[DIM1_SIZE*DIM2_SIZE];
- hsize_t s1_dim[1] = {DIM1_SIZE};
- hsize_t s2_dim[1] = {DIM2_SIZE};
- int s1_wbuf[DIM1_SIZE] = {10,20,30};
- int s11_wbuf[DIM1_SIZE] = {10,100,300};
- int s2_wbuf[DIM2_SIZE] = {100,200,300,400};
- int s21_wbuf[DIM2_SIZE] = {10,20,30,40};
- int s22_wbuf[DIM2_SIZE] = {5,10,50,300};
+ int rank = RANK;
+ int rankds = 1;
+ hsize_t dims[RANK] = {DIM1_SIZE, DIM2_SIZE};
+ int buf[DIM1_SIZE * DIM2_SIZE];
+ hsize_t s1_dim[1] = {DIM1_SIZE};
+ hsize_t s2_dim[1] = {DIM2_SIZE};
+ int s1_wbuf[DIM1_SIZE] = {10, 20, 30};
+ int s11_wbuf[DIM1_SIZE] = {10, 100, 300};
+ int s2_wbuf[DIM2_SIZE] = {100, 200, 300, 400};
+ int s21_wbuf[DIM2_SIZE] = {10, 20, 30, 40};
+ int s22_wbuf[DIM2_SIZE] = {5, 10, 50, 300};
char name[64];
HDsnprintf(name, sizeof(name), "%s%s", DATASET_NAME, dsidx);
/* make a dataset */
- if(H5LTmake_dataset_int(fid, name, rank, dims, buf) >= 0) {
- if(fulldims==0) {
+ if (H5LTmake_dataset_int(fid, name, rank, dims, buf) >= 0) {
+ if (fulldims == 0) {
/* make a DS dataset for the first dimension */
- if(create_DS1_int_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, NULL) < 0)
- return FAIL;
+ if (create_DS1_int_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, NULL) < 0)
+ return FAIL;
/* make a DS dataset for the second dimension */
- if(create_DS2_int_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, NULL, NULL) < 0)
- return FAIL;
+ if (create_DS2_int_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, NULL, NULL) < 0)
+ return FAIL;
}
else {
- if(create_DS1_int_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, s11_wbuf) < 0)
- return FAIL;
+ if (create_DS1_int_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, s11_wbuf) < 0)
+ return FAIL;
- if(create_DS2_int_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, s21_wbuf, s22_wbuf) < 0)
- return FAIL;
+ if (create_DS2_int_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, s21_wbuf, s22_wbuf) < 0)
+ return FAIL;
}
- }
- else
- return FAIL;
+ }
+ else
+ return FAIL;
return SUCCEED;
}
-herr_t create_long_dataset(hid_t fid, const char *dsname, const char *dsidx, int fulldims)
+herr_t
+create_long_dataset(hid_t fid, const char *dsname, const char *dsidx, int fulldims)
{
- int rank = 4;
- int rankds = 1;
- hsize_t dims[4] = {DIM1_SIZE,DIM2_SIZE,DIM3_SIZE,DIM4_SIZE};
- long *buf;
- hsize_t s1_dim[1] = {DIM1_SIZE};
- hsize_t s2_dim[1] = {DIM2_SIZE};
- hsize_t s3_dim[1] = {DIM3_SIZE};
- hsize_t s4_dim[1] = {DIM4_SIZE};
- long s1_wbuf[DIM1_SIZE] = {10,20,30};
- long s11_wbuf[DIM1_SIZE] = {10,100,300};
- long s2_wbuf[DIM2_SIZE] = {100,200,300,400};
- long s21_wbuf[DIM2_SIZE] = {10,20,30,40};
- long s22_wbuf[DIM2_SIZE] = {5,10,50,300};
- long s3_wbuf[DIM3_SIZE] = {10,10,10,20,20,20,30,30,30,40,40,40};
- long s31_wbuf[DIM3_SIZE] = {1,1,1,2,2,2,3,3,3,4,4,4};
- long s32_wbuf[DIM3_SIZE] = {5,5,5,10,10,10,50,50,50,100,100,100};
- long s33_wbuf[DIM3_SIZE] = {6,6,6,12,12,12,53,53,53,140,140,140};
- long s4_wbuf[DIM4_SIZE] = {18,18};
- long s41_wbuf[DIM4_SIZE] = {8,8};
- long s42_wbuf[DIM4_SIZE] = {80,80};
- long s43_wbuf[DIM4_SIZE] = {180,180};
- long s44_wbuf[DIM4_SIZE] = {280,280};
+ int rank = 4;
+ int rankds = 1;
+ hsize_t dims[4] = {DIM1_SIZE, DIM2_SIZE, DIM3_SIZE, DIM4_SIZE};
+ long * buf;
+ hsize_t s1_dim[1] = {DIM1_SIZE};
+ hsize_t s2_dim[1] = {DIM2_SIZE};
+ hsize_t s3_dim[1] = {DIM3_SIZE};
+ hsize_t s4_dim[1] = {DIM4_SIZE};
+ long s1_wbuf[DIM1_SIZE] = {10, 20, 30};
+ long s11_wbuf[DIM1_SIZE] = {10, 100, 300};
+ long s2_wbuf[DIM2_SIZE] = {100, 200, 300, 400};
+ long s21_wbuf[DIM2_SIZE] = {10, 20, 30, 40};
+ long s22_wbuf[DIM2_SIZE] = {5, 10, 50, 300};
+ long s3_wbuf[DIM3_SIZE] = {10, 10, 10, 20, 20, 20, 30, 30, 30, 40, 40, 40};
+ long s31_wbuf[DIM3_SIZE] = {1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4};
+ long s32_wbuf[DIM3_SIZE] = {5, 5, 5, 10, 10, 10, 50, 50, 50, 100, 100, 100};
+ long s33_wbuf[DIM3_SIZE] = {6, 6, 6, 12, 12, 12, 53, 53, 53, 140, 140, 140};
+ long s4_wbuf[DIM4_SIZE] = {18, 18};
+ long s41_wbuf[DIM4_SIZE] = {8, 8};
+ long s42_wbuf[DIM4_SIZE] = {80, 80};
+ long s43_wbuf[DIM4_SIZE] = {180, 180};
+ long s44_wbuf[DIM4_SIZE] = {280, 280};
/* Allocate buffer */
- if(NULL == (buf = (long *)HDmalloc(sizeof(long) * DIM1_SIZE * DIM2_SIZE * DIM3_SIZE * DIM4_SIZE)))
- return FAIL;
+ if (NULL == (buf = (long *)HDmalloc(sizeof(long) * DIM1_SIZE * DIM2_SIZE * DIM3_SIZE * DIM4_SIZE)))
+ return FAIL;
/* make a dataset */
- if(H5LTmake_dataset_long(fid, dsname, rank, dims, buf) >= 0) {
- if(fulldims==0) {
+ if (H5LTmake_dataset_long(fid, dsname, rank, dims, buf) >= 0) {
+ if (fulldims == 0) {
/* make a DS dataset for the first dimension */
- if(create_DS1_long_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, NULL) < 0)
- return FAIL;
+ if (create_DS1_long_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, NULL) < 0)
+ return FAIL;
/* make a DS dataset for the second dimension */
- if(create_DS2_long_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, NULL, NULL) < 0)
- return FAIL;
+ if (create_DS2_long_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, NULL, NULL) < 0)
+ return FAIL;
/* make a DS dataset for the third dimension */
- if(create_DS3_long_datasets(fid, dsidx, rankds, s3_dim, s3_wbuf, NULL, NULL, NULL) < 0)
- return FAIL;
+ if (create_DS3_long_datasets(fid, dsidx, rankds, s3_dim, s3_wbuf, NULL, NULL, NULL) < 0)
+ return FAIL;
/* make a DS dataset for the fourth dimension */
- if(create_DS4_long_datasets(fid, dsidx, rankds, s4_dim, s4_wbuf, NULL, NULL, NULL, NULL) < 0)
- return FAIL;
+ if (create_DS4_long_datasets(fid, dsidx, rankds, s4_dim, s4_wbuf, NULL, NULL, NULL, NULL) < 0)
+ return FAIL;
}
else {
- if(create_DS1_long_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, s11_wbuf) < 0)
- return FAIL;
+ if (create_DS1_long_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, s11_wbuf) < 0)
+ return FAIL;
- if(create_DS2_long_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, s21_wbuf, s22_wbuf) < 0)
- return FAIL;
+ if (create_DS2_long_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, s21_wbuf, s22_wbuf) < 0)
+ return FAIL;
- if(create_DS3_long_datasets(fid, dsidx, rankds, s3_dim, s3_wbuf, s31_wbuf, s32_wbuf, s33_wbuf) < 0)
- return FAIL;
+ if (create_DS3_long_datasets(fid, dsidx, rankds, s3_dim, s3_wbuf, s31_wbuf, s32_wbuf, s33_wbuf) <
+ 0)
+ return FAIL;
- if(create_DS4_long_datasets(fid, dsidx, rankds, s4_dim, s4_wbuf, s41_wbuf, s42_wbuf, s43_wbuf, s44_wbuf) < 0)
- return FAIL;
+ if (create_DS4_long_datasets(fid, dsidx, rankds, s4_dim, s4_wbuf, s41_wbuf, s42_wbuf, s43_wbuf,
+ s44_wbuf) < 0)
+ return FAIL;
}
- }
- else
- return FAIL;
+ }
+ else
+ return FAIL;
HDfree(buf);
return SUCCEED;
}
-herr_t create_float_dataset(hid_t fid, const char *dsidx, int fulldims)
+herr_t
+create_float_dataset(hid_t fid, const char *dsidx, int fulldims)
{
- int rank = RANK;
- int rankds = 1;
- hsize_t dims[RANK] = {DIM1_SIZE,DIM2_SIZE};
- float buf[DIM1_SIZE*DIM2_SIZE];
- hsize_t s1_dim[1] = {DIM1_SIZE};
- hsize_t s2_dim[1] = {DIM2_SIZE};
- float s1_wbuf[DIM1_SIZE] = {10,20,30};
- float s11_wbuf[DIM1_SIZE] = {10,100,300};
- float s2_wbuf[DIM2_SIZE] = {100,200,300,400};
- float s21_wbuf[DIM2_SIZE] = {10,20,30,40};
- float s22_wbuf[DIM2_SIZE] = {5,10,50,300};
+ int rank = RANK;
+ int rankds = 1;
+ hsize_t dims[RANK] = {DIM1_SIZE, DIM2_SIZE};
+ float buf[DIM1_SIZE * DIM2_SIZE];
+ hsize_t s1_dim[1] = {DIM1_SIZE};
+ hsize_t s2_dim[1] = {DIM2_SIZE};
+ float s1_wbuf[DIM1_SIZE] = {10, 20, 30};
+ float s11_wbuf[DIM1_SIZE] = {10, 100, 300};
+ float s2_wbuf[DIM2_SIZE] = {100, 200, 300, 400};
+ float s21_wbuf[DIM2_SIZE] = {10, 20, 30, 40};
+ float s22_wbuf[DIM2_SIZE] = {5, 10, 50, 300};
char name[64];
HDsnprintf(name, sizeof(name), "%s%s", DATASET_NAME, dsidx);
/* make a dataset */
- if(H5LTmake_dataset_float(fid, name, rank, dims, buf) >= 0) {
- if(fulldims==0) {
+ if (H5LTmake_dataset_float(fid, name, rank, dims, buf) >= 0) {
+ if (fulldims == 0) {
/* make a DS dataset for the first dimension */
- if(create_DS1_float_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, NULL) < 0)
- return FAIL;
+ if (create_DS1_float_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, NULL) < 0)
+ return FAIL;
/* make a DS dataset for the second dimension */
- if(create_DS2_float_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, NULL, NULL) < 0)
- return FAIL;
+ if (create_DS2_float_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, NULL, NULL) < 0)
+ return FAIL;
}
else {
- if(create_DS1_float_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, s11_wbuf) < 0)
- return FAIL;
+ if (create_DS1_float_datasets(fid, dsidx, rankds, s1_dim, s1_wbuf, s11_wbuf) < 0)
+ return FAIL;
- if(create_DS2_float_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, s21_wbuf, s22_wbuf) < 0)
- return FAIL;
+ if (create_DS2_float_datasets(fid, dsidx, rankds, s2_dim, s2_wbuf, s21_wbuf, s22_wbuf) < 0)
+ return FAIL;
}
- }
- else
- return FAIL;
+ }
+ else
+ return FAIL;
return SUCCEED;
}
@@ -495,21 +522,23 @@ herr_t create_float_dataset(hid_t fid, const char *dsidx, int fulldims)
* create 2 dimension scales datasets for first dimension
*-------------------------------------------------------------------------
*/
-herr_t create_DS1_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, char *s_wbuf, char *s1_wbuf)
+herr_t
+create_DS1_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, char *s_wbuf,
+ char *s1_wbuf)
{
char name[64];
HDsnprintf(name, sizeof(name), "%s%s", DS_1_NAME, dsidx);
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_char(fid, name, rankds, s_dim, s_wbuf) < 0)
+ if (H5LTmake_dataset_char(fid, name, rankds, s_dim, s_wbuf) < 0)
return FAIL;
- if(s1_wbuf != NULL) {
+ if (s1_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_11_NAME, dsidx);
/* make a DS dataset with an alternate scale for the first dimension */
- if(H5LTmake_dataset_char(fid, name, rankds, s_dim, s1_wbuf) < 0)
+ if (H5LTmake_dataset_char(fid, name, rankds, s_dim, s1_wbuf) < 0)
return FAIL;
}
@@ -520,29 +549,31 @@ herr_t create_DS1_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_
* create 3 dimension scales datasets for second dimension
*-------------------------------------------------------------------------
*/
-herr_t create_DS2_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, char *s_wbuf, char *s1_wbuf, char *s2_wbuf)
+herr_t
+create_DS2_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, char *s_wbuf,
+ char *s1_wbuf, char *s2_wbuf)
{
char name[64];
HDsnprintf(name, sizeof(name), "%s%s", DS_2_NAME, dsidx);
/* make a DS dataset for the second dimension */
- if(H5LTmake_dataset_char(fid, name, rankds, s_dim, s_wbuf) < 0)
+ if (H5LTmake_dataset_char(fid, name, rankds, s_dim, s_wbuf) < 0)
return FAIL;
- if(s1_wbuf != NULL) {
+ if (s1_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_21_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_char(fid, name, rankds, s_dim, s1_wbuf) < 0)
+ if (H5LTmake_dataset_char(fid, name, rankds, s_dim, s1_wbuf) < 0)
return FAIL;
}
- if(s2_wbuf != NULL) {
+ if (s2_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_22_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_char(fid, name, rankds, s_dim, s2_wbuf) < 0)
+ if (H5LTmake_dataset_char(fid, name, rankds, s_dim, s2_wbuf) < 0)
return FAIL;
}
@@ -553,37 +584,39 @@ herr_t create_DS2_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_
* create 1 dimension scales datasets for third dimension of dataset
*-------------------------------------------------------------------------
*/
-herr_t create_DS3_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, char *s_wbuf, char *s1_wbuf, char *s2_wbuf, char *s3_wbuf)
+herr_t
+create_DS3_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, char *s_wbuf,
+ char *s1_wbuf, char *s2_wbuf, char *s3_wbuf)
{
char name[64];
HDsnprintf(name, sizeof(name), "%s%s", DS_3_NAME, dsidx);
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_char(fid, name, rankds, s_dim, s_wbuf) < 0)
+ if (H5LTmake_dataset_char(fid, name, rankds, s_dim, s_wbuf) < 0)
return FAIL;
- if(s1_wbuf != NULL) {
+ if (s1_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_31_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_char(fid, name, rankds, s_dim, s1_wbuf) < 0)
+ if (H5LTmake_dataset_char(fid, name, rankds, s_dim, s1_wbuf) < 0)
return FAIL;
}
- if(s2_wbuf != NULL) {
+ if (s2_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_32_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_char(fid, name, rankds, s_dim, s2_wbuf) < 0)
+ if (H5LTmake_dataset_char(fid, name, rankds, s_dim, s2_wbuf) < 0)
return FAIL;
}
- if(s3_wbuf != NULL) {
+ if (s3_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_33_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_char(fid, name, rankds, s_dim, s3_wbuf) < 0)
+ if (H5LTmake_dataset_char(fid, name, rankds, s_dim, s3_wbuf) < 0)
return FAIL;
}
@@ -594,21 +627,23 @@ herr_t create_DS3_char_datasets(hid_t fid, const char *dsidx, int rankds, hsize_
* create 2 dimension scales datasets for first dimension
*-------------------------------------------------------------------------
*/
-herr_t create_DS1_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, short *s_wbuf, short *s1_wbuf)
+herr_t
+create_DS1_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, short *s_wbuf,
+ short *s1_wbuf)
{
char name[64];
HDsnprintf(name, sizeof(name), "%s%s", DS_1_NAME, dsidx);
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_short(fid, name, rankds, s_dim, s_wbuf) < 0)
+ if (H5LTmake_dataset_short(fid, name, rankds, s_dim, s_wbuf) < 0)
return FAIL;
- if(s1_wbuf != NULL) {
+ if (s1_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_11_NAME, dsidx);
/* make a DS dataset with an alternate scale for the first dimension */
- if(H5LTmake_dataset_short(fid, name, rankds, s_dim, s1_wbuf) < 0)
+ if (H5LTmake_dataset_short(fid, name, rankds, s_dim, s1_wbuf) < 0)
return FAIL;
}
@@ -619,29 +654,31 @@ herr_t create_DS1_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize
* create 3 dimension scales datasets for second dimension
*-------------------------------------------------------------------------
*/
-herr_t create_DS2_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, short *s_wbuf, short *s1_wbuf, short *s2_wbuf)
+herr_t
+create_DS2_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, short *s_wbuf,
+ short *s1_wbuf, short *s2_wbuf)
{
char name[64];
HDsnprintf(name, sizeof(name), "%s%s", DS_2_NAME, dsidx);
/* make a DS dataset for the second dimension */
- if(H5LTmake_dataset_short(fid, name, rankds, s_dim, s_wbuf) < 0)
+ if (H5LTmake_dataset_short(fid, name, rankds, s_dim, s_wbuf) < 0)
return FAIL;
- if(s1_wbuf != NULL) {
+ if (s1_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_21_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_short(fid, name, rankds, s_dim, s1_wbuf) < 0)
+ if (H5LTmake_dataset_short(fid, name, rankds, s_dim, s1_wbuf) < 0)
return FAIL;
}
- if(s2_wbuf != NULL) {
+ if (s2_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_22_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_short(fid, name, rankds, s_dim, s2_wbuf) < 0)
+ if (H5LTmake_dataset_short(fid, name, rankds, s_dim, s2_wbuf) < 0)
return FAIL;
}
@@ -652,37 +689,39 @@ herr_t create_DS2_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize
* create 1 dimension scales datasets for third dimension of dataset
*-------------------------------------------------------------------------
*/
-herr_t create_DS3_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, short *s_wbuf, short *s1_wbuf, short *s2_wbuf, short *s3_wbuf)
+herr_t
+create_DS3_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, short *s_wbuf,
+ short *s1_wbuf, short *s2_wbuf, short *s3_wbuf)
{
char name[64];
HDsnprintf(name, sizeof(name), "%s%s", DS_3_NAME, dsidx);
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_short(fid, name, rankds, s_dim, s_wbuf) < 0)
+ if (H5LTmake_dataset_short(fid, name, rankds, s_dim, s_wbuf) < 0)
return FAIL;
- if(s1_wbuf != NULL) {
+ if (s1_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_31_NAME, dsidx);
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_short(fid, name, rankds, s_dim, s1_wbuf) < 0)
+ if (H5LTmake_dataset_short(fid, name, rankds, s_dim, s1_wbuf) < 0)
return FAIL;
}
- if(s2_wbuf != NULL) {
+ if (s2_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_32_NAME, dsidx);
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_short(fid, name, rankds, s_dim, s2_wbuf) < 0)
+ if (H5LTmake_dataset_short(fid, name, rankds, s_dim, s2_wbuf) < 0)
return FAIL;
}
- if(s3_wbuf != NULL) {
+ if (s3_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_33_NAME, dsidx);
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_short(fid, name, rankds, s_dim, s3_wbuf) < 0)
+ if (H5LTmake_dataset_short(fid, name, rankds, s_dim, s3_wbuf) < 0)
return FAIL;
}
@@ -693,21 +732,22 @@ herr_t create_DS3_short_datasets(hid_t fid, const char *dsidx, int rankds, hsize
* create 2 dimension scales datasets for first dimension
*-------------------------------------------------------------------------
*/
-herr_t create_DS1_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, int *s_wbuf, int *s1_wbuf)
+herr_t
+create_DS1_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, int *s_wbuf, int *s1_wbuf)
{
char name[64];
HDsnprintf(name, sizeof(name), "%s%s", DS_1_NAME, dsidx);
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_int(fid, name, rankds, s_dim, s_wbuf) < 0)
+ if (H5LTmake_dataset_int(fid, name, rankds, s_dim, s_wbuf) < 0)
return FAIL;
- if(s1_wbuf != NULL) {
+ if (s1_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_11_NAME, dsidx);
/* make a DS dataset with an alternate scale for the first dimension */
- if(H5LTmake_dataset_int(fid, name, rankds, s_dim, s1_wbuf) < 0)
+ if (H5LTmake_dataset_int(fid, name, rankds, s_dim, s1_wbuf) < 0)
return FAIL;
}
@@ -718,29 +758,31 @@ herr_t create_DS1_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t
* create 3 dimension scales datasets for second dimension
*-------------------------------------------------------------------------
*/
-herr_t create_DS2_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, int *s_wbuf, int *s1_wbuf, int *s2_wbuf)
+herr_t
+create_DS2_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, int *s_wbuf, int *s1_wbuf,
+ int *s2_wbuf)
{
char name[64];
HDsnprintf(name, sizeof(name), "%s%s", DS_2_NAME, dsidx);
/* make a DS dataset for the second dimension */
- if(H5LTmake_dataset_int(fid, name, rankds, s_dim, s_wbuf) < 0)
+ if (H5LTmake_dataset_int(fid, name, rankds, s_dim, s_wbuf) < 0)
return FAIL;
- if(s1_wbuf != NULL) {
+ if (s1_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_21_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_int(fid, name, rankds, s_dim, s1_wbuf) < 0)
+ if (H5LTmake_dataset_int(fid, name, rankds, s_dim, s1_wbuf) < 0)
return FAIL;
}
- if(s2_wbuf != NULL) {
+ if (s2_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_22_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_int(fid, name, rankds, s_dim, s2_wbuf) < 0)
+ if (H5LTmake_dataset_int(fid, name, rankds, s_dim, s2_wbuf) < 0)
return FAIL;
}
@@ -751,37 +793,39 @@ herr_t create_DS2_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t
* create 1 dimension scales datasets for third dimension of dataset
*-------------------------------------------------------------------------
*/
-herr_t create_DS3_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, int *s_wbuf, int *s1_wbuf, int *s2_wbuf, int *s3_wbuf)
+herr_t
+create_DS3_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, int *s_wbuf, int *s1_wbuf,
+ int *s2_wbuf, int *s3_wbuf)
{
char name[64];
HDsnprintf(name, sizeof(name), "%s%s", DS_3_NAME, dsidx);
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_int(fid, name, rankds, s_dim, s_wbuf) < 0)
+ if (H5LTmake_dataset_int(fid, name, rankds, s_dim, s_wbuf) < 0)
return FAIL;
- if(s1_wbuf != NULL) {
+ if (s1_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_31_NAME, dsidx);
/* make a DS dataset with an alternate scale for the first dimension */
- if(H5LTmake_dataset_int(fid, name, rankds, s_dim, s1_wbuf) < 0)
+ if (H5LTmake_dataset_int(fid, name, rankds, s_dim, s1_wbuf) < 0)
return FAIL;
}
- if(s2_wbuf != NULL) {
+ if (s2_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_32_NAME, dsidx);
/* make a DS dataset with an alternate scale for the first dimension */
- if(H5LTmake_dataset_int(fid, name, rankds, s_dim, s2_wbuf) < 0)
+ if (H5LTmake_dataset_int(fid, name, rankds, s_dim, s2_wbuf) < 0)
return FAIL;
}
- if(s3_wbuf != NULL) {
+ if (s3_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_33_NAME, dsidx);
/* make a DS dataset with an alternate scale for the first dimension */
- if(H5LTmake_dataset_int(fid, name, rankds, s_dim, s3_wbuf) < 0)
+ if (H5LTmake_dataset_int(fid, name, rankds, s_dim, s3_wbuf) < 0)
return FAIL;
}
@@ -792,21 +836,23 @@ herr_t create_DS3_int_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t
* create 2 dimension scales datasets for first dimension
*-------------------------------------------------------------------------
*/
-herr_t create_DS1_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf, long *s1_wbuf)
+herr_t
+create_DS1_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf,
+ long *s1_wbuf)
{
char name[64];
HDsnprintf(name, sizeof(name), "%s%s", DS_1_NAME, dsidx);
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s_wbuf) < 0)
+ if (H5LTmake_dataset_long(fid, name, rankds, s_dim, s_wbuf) < 0)
return FAIL;
- if(s1_wbuf != NULL) {
+ if (s1_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_11_NAME, dsidx);
/* make a DS dataset with an alternate scale for the first dimension */
- if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s1_wbuf) < 0)
+ if (H5LTmake_dataset_long(fid, name, rankds, s_dim, s1_wbuf) < 0)
return FAIL;
}
@@ -817,29 +863,31 @@ herr_t create_DS1_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_
* create 3 dimension scales datasets for second dimension
*-------------------------------------------------------------------------
*/
-herr_t create_DS2_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf, long *s1_wbuf, long *s2_wbuf)
+herr_t
+create_DS2_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf,
+ long *s1_wbuf, long *s2_wbuf)
{
char name[64];
HDsnprintf(name, sizeof(name), "%s%s", DS_2_NAME, dsidx);
/* make a DS dataset for the second dimension */
- if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s_wbuf) < 0)
+ if (H5LTmake_dataset_long(fid, name, rankds, s_dim, s_wbuf) < 0)
return FAIL;
- if(s1_wbuf != NULL) {
+ if (s1_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_21_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s1_wbuf) < 0)
+ if (H5LTmake_dataset_long(fid, name, rankds, s_dim, s1_wbuf) < 0)
return FAIL;
}
- if(s2_wbuf != NULL) {
+ if (s2_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_22_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s2_wbuf) < 0)
+ if (H5LTmake_dataset_long(fid, name, rankds, s_dim, s2_wbuf) < 0)
return FAIL;
}
@@ -850,37 +898,39 @@ herr_t create_DS2_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_
* create 3 dimension scales datasets for third dimension of dataset
*-------------------------------------------------------------------------
*/
-herr_t create_DS3_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf, long *s1_wbuf, long *s2_wbuf, long *s3_wbuf)
+herr_t
+create_DS3_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf,
+ long *s1_wbuf, long *s2_wbuf, long *s3_wbuf)
{
char name[64];
HDsnprintf(name, sizeof(name), "%s%s", DS_3_NAME, dsidx);
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s_wbuf) < 0)
+ if (H5LTmake_dataset_long(fid, name, rankds, s_dim, s_wbuf) < 0)
return FAIL;
- if(s1_wbuf != NULL) {
+ if (s1_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_31_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s1_wbuf) < 0)
+ if (H5LTmake_dataset_long(fid, name, rankds, s_dim, s1_wbuf) < 0)
return FAIL;
}
- if(s2_wbuf != NULL) {
+ if (s2_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_32_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s2_wbuf) < 0)
+ if (H5LTmake_dataset_long(fid, name, rankds, s_dim, s2_wbuf) < 0)
return FAIL;
}
- if(s3_wbuf != NULL) {
+ if (s3_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_33_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s3_wbuf) < 0)
+ if (H5LTmake_dataset_long(fid, name, rankds, s_dim, s3_wbuf) < 0)
return FAIL;
}
@@ -891,45 +941,47 @@ herr_t create_DS3_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_
* create 4 dimension scales datasets for third dimension of dataset
*-------------------------------------------------------------------------
*/
-herr_t create_DS4_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf, long *s1_wbuf, long *s2_wbuf, long *s3_wbuf, long *s4_wbuf)
+herr_t
+create_DS4_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, long *s_wbuf,
+ long *s1_wbuf, long *s2_wbuf, long *s3_wbuf, long *s4_wbuf)
{
char name[64];
HDsnprintf(name, sizeof(name), "%s%s", DS_4_NAME, dsidx);
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s_wbuf) < 0)
+ if (H5LTmake_dataset_long(fid, name, rankds, s_dim, s_wbuf) < 0)
return FAIL;
- if(s1_wbuf != NULL) {
+ if (s1_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_41_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s1_wbuf) < 0)
+ if (H5LTmake_dataset_long(fid, name, rankds, s_dim, s1_wbuf) < 0)
return FAIL;
}
- if(s2_wbuf != NULL) {
+ if (s2_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_42_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s2_wbuf) < 0)
+ if (H5LTmake_dataset_long(fid, name, rankds, s_dim, s2_wbuf) < 0)
return FAIL;
}
- if(s3_wbuf != NULL) {
+ if (s3_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_43_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s3_wbuf) < 0)
+ if (H5LTmake_dataset_long(fid, name, rankds, s_dim, s3_wbuf) < 0)
return FAIL;
}
- if(s4_wbuf != NULL) {
+ if (s4_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_44_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_long(fid, name, rankds, s_dim, s4_wbuf) < 0)
+ if (H5LTmake_dataset_long(fid, name, rankds, s_dim, s4_wbuf) < 0)
return FAIL;
}
@@ -940,21 +992,23 @@ herr_t create_DS4_long_datasets(hid_t fid, const char *dsidx, int rankds, hsize_
* create 2 dimension scales datasets for first dimension
*-------------------------------------------------------------------------
*/
-herr_t create_DS1_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, float *s_wbuf, float *s1_wbuf)
+herr_t
+create_DS1_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, float *s_wbuf,
+ float *s1_wbuf)
{
char name[64];
HDsnprintf(name, sizeof(name), "%s%s", DS_1_NAME, dsidx);
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_float(fid, name, rankds, s_dim, s_wbuf) < 0)
+ if (H5LTmake_dataset_float(fid, name, rankds, s_dim, s_wbuf) < 0)
return FAIL;
- if(s1_wbuf != NULL) {
+ if (s1_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_11_NAME, dsidx);
/* make a DS dataset with an alternate scale for the first dimension */
- if(H5LTmake_dataset_float(fid, name, rankds, s_dim, s1_wbuf) < 0)
+ if (H5LTmake_dataset_float(fid, name, rankds, s_dim, s1_wbuf) < 0)
return FAIL;
}
@@ -965,29 +1019,31 @@ herr_t create_DS1_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize
* create 3 dimension scales datasets for second dimension
*-------------------------------------------------------------------------
*/
-herr_t create_DS2_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, float *s_wbuf, float *s1_wbuf, float *s2_wbuf)
+herr_t
+create_DS2_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, float *s_wbuf,
+ float *s1_wbuf, float *s2_wbuf)
{
char name[64];
HDsnprintf(name, sizeof(name), "%s%s", DS_2_NAME, dsidx);
/* make a DS dataset for the second dimension */
- if(H5LTmake_dataset_float(fid, name, rankds, s_dim, s_wbuf) < 0)
+ if (H5LTmake_dataset_float(fid, name, rankds, s_dim, s_wbuf) < 0)
return FAIL;
- if(s1_wbuf != NULL) {
+ if (s1_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_21_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_float(fid, name, rankds, s_dim, s1_wbuf) < 0)
+ if (H5LTmake_dataset_float(fid, name, rankds, s_dim, s1_wbuf) < 0)
return FAIL;
}
- if(s2_wbuf != NULL) {
+ if (s2_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_22_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_float(fid, name, rankds, s_dim, s2_wbuf) < 0)
+ if (H5LTmake_dataset_float(fid, name, rankds, s_dim, s2_wbuf) < 0)
return FAIL;
}
@@ -998,144 +1054,151 @@ herr_t create_DS2_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize
* create 3 dimension scales datasets for third dimension of dataset
*-------------------------------------------------------------------------
*/
-herr_t create_DS3_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, float *s_wbuf, float *s1_wbuf, float *s2_wbuf, float *s3_wbuf)
+herr_t
+create_DS3_float_datasets(hid_t fid, const char *dsidx, int rankds, hsize_t *s_dim, float *s_wbuf,
+ float *s1_wbuf, float *s2_wbuf, float *s3_wbuf)
{
char name[64];
HDsnprintf(name, sizeof(name), "%s%s", DS_3_NAME, dsidx);
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_float(fid, name, rankds, s_dim, s_wbuf) < 0)
+ if (H5LTmake_dataset_float(fid, name, rankds, s_dim, s_wbuf) < 0)
return FAIL;
- if(s1_wbuf != NULL) {
+ if (s1_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_31_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_float(fid, name, rankds, s_dim, s1_wbuf) < 0)
+ if (H5LTmake_dataset_float(fid, name, rankds, s_dim, s1_wbuf) < 0)
return FAIL;
}
- if(s2_wbuf != NULL) {
+ if (s2_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_32_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_float(fid, name, rankds, s_dim, s2_wbuf) < 0)
+ if (H5LTmake_dataset_float(fid, name, rankds, s_dim, s2_wbuf) < 0)
return FAIL;
}
- if(s3_wbuf != NULL) {
+ if (s3_wbuf != NULL) {
HDsnprintf(name, sizeof(name), "%s%s", DS_33_NAME, dsidx);
/* make a DS dataset with an alternate scale for the second dimension */
- if(H5LTmake_dataset_float(fid, name, rankds, s_dim, s3_wbuf) < 0)
+ if (H5LTmake_dataset_float(fid, name, rankds, s_dim, s3_wbuf) < 0)
return FAIL;
}
return SUCCEED;
}
-herr_t test_attach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx)
+herr_t
+test_attach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx)
{
- herr_t ret_value = FAIL;
- hid_t dsid = -1;
+ herr_t ret_value = FAIL;
+ hid_t dsid = -1;
- if((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) {
- if(H5DSis_attached(did, dsid, idx) == 0) {
- if(H5DSattach_scale(did, dsid, idx) >= 0) {
- if(H5DSis_attached(did, dsid, idx) > 0) {
+ if ((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) {
+ if (H5DSis_attached(did, dsid, idx) == 0) {
+ if (H5DSattach_scale(did, dsid, idx) >= 0) {
+ if (H5DSis_attached(did, dsid, idx) > 0) {
ret_value = SUCCEED;
}
- else if(H5DSis_attached(did, dsid, idx) == 0) {
+ else if (H5DSis_attached(did, dsid, idx) == 0) {
HDprintf(" scale not attached ");
}
}
}
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
ret_value = FAIL;
}
return ret_value;
}
-herr_t test_detach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx)
+herr_t
+test_detach_scale(hid_t fid, hid_t did, const char *name, unsigned int idx)
{
- herr_t ret_value = FAIL;
- hid_t dsid = -1;
+ herr_t ret_value = FAIL;
+ hid_t dsid = -1;
- if((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) {
- if(H5DSis_attached(did, dsid, idx) == 1) {
- if(H5DSdetach_scale(did, dsid, idx) >= 0) {
- if(H5DSis_attached(did, dsid, idx) == 0) {
+ if ((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) {
+ if (H5DSis_attached(did, dsid, idx) == 1) {
+ if (H5DSdetach_scale(did, dsid, idx) >= 0) {
+ if (H5DSis_attached(did, dsid, idx) == 0) {
ret_value = SUCCEED;
}
}
}
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
ret_value = FAIL;
}
return ret_value;
}
-herr_t test_set_scalename(hid_t fid, hid_t did, const char *name, const char *scalename, unsigned int idx)
+herr_t
+test_set_scalename(hid_t fid, hid_t did, const char *name, const char *scalename, unsigned int idx)
{
- herr_t ret_value = FAIL;
- hid_t dsid = -1;
+ herr_t ret_value = FAIL;
+ hid_t dsid = -1;
- if((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) {
- if(H5DSis_attached(did, dsid, idx) == 1) {
- if(H5DSset_scale(dsid, scalename) >= 0) {
- if(H5DSis_attached(did, dsid, idx) == 1) {
- ret_value = SUCCEED;
+ if ((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) {
+ if (H5DSis_attached(did, dsid, idx) == 1) {
+ if (H5DSset_scale(dsid, scalename) >= 0) {
+ if (H5DSis_attached(did, dsid, idx) == 1) {
+ ret_value = SUCCEED;
}
}
}
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
ret_value = FAIL;
}
return ret_value;
}
-herr_t test_cmp_scalename(hid_t fid, hid_t did, const char *name, const char *scalename, unsigned int idx)
+herr_t
+test_cmp_scalename(hid_t fid, hid_t did, const char *name, const char *scalename, unsigned int idx)
{
herr_t ret_value = FAIL;
- hid_t dsid = -1;
+ hid_t dsid = -1;
ssize_t name_len;
- char *name_out=NULL;
-
- if((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) {
- if(H5DSis_attached(did, dsid, idx) == 1) {
- if((name_len=H5DSget_scale_name(dsid,NULL,(size_t)0)) > 0) {
- name_out = (char*)HDmalloc(((size_t)name_len+1) * sizeof (char));
- if(name_out != NULL) {
- if(H5DSget_scale_name(dsid, name_out, (size_t)name_len+1) >= 0) {
- if(HDstrncmp(scalename, name_out, (size_t)name_len)==0) {
+ char * name_out = NULL;
+
+ if ((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) {
+ if (H5DSis_attached(did, dsid, idx) == 1) {
+ if ((name_len = H5DSget_scale_name(dsid, NULL, (size_t)0)) > 0) {
+ name_out = (char *)HDmalloc(((size_t)name_len + 1) * sizeof(char));
+ if (name_out != NULL) {
+ if (H5DSget_scale_name(dsid, name_out, (size_t)name_len + 1) >= 0) {
+ if (HDstrncmp(scalename, name_out, (size_t)name_len) == 0) {
ret_value = SUCCEED;
}
HDfree(name_out);
- name_out=NULL;
+ name_out = NULL;
}
}
}
}
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
ret_value = FAIL;
}
return ret_value;
}
-static int test_detachscales(void)
+static int
+test_detachscales(void)
{
- hid_t fid = -1;
- hid_t did = -1;
- hid_t dsid = -1;
- int rank1 = 1;
- int rank3 = 3;
- hsize_t dims[] = {1,2,3}; /*some bogus numbers, not important for the test*/
- int *buf = NULL;
+ hid_t fid = -1;
+ hid_t did = -1;
+ hid_t dsid = -1;
+ int rank1 = 1;
+ int rank3 = 3;
+ hsize_t dims[] = {1, 2, 3}; /*some bogus numbers, not important for the test*/
+ int * buf = NULL;
char dname[16];
int i;
@@ -1146,52 +1209,52 @@ static int test_detachscales(void)
HL_TESTING2("test_detachscales");
- if((fid = H5Fcreate("test_detach.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if ((fid = H5Fcreate("test_detach.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
/* make datasets; they are three dimensional*/
- for (i=0; i < 2; i++) {
- HDsprintf(dname,"D%d", i);
- if(H5LTmake_dataset_int(fid, dname, rank3, dims, buf) < 0)
+ for (i = 0; i < 2; i++) {
+ HDsprintf(dname, "D%d", i);
+ if (H5LTmake_dataset_int(fid, dname, rank3, dims, buf) < 0)
goto out;
}
/* create datasets and make them dim. scales */
- for (i=0; i < 4; i++) {
+ for (i = 0; i < 4; i++) {
HDsprintf(dname, "DS%d", i);
- if(H5LTmake_dataset_int(fid, dname, rank1, dims, buf) < 0)
+ if (H5LTmake_dataset_int(fid, dname, rank1, dims, buf) < 0)
goto out;
}
/* attach scales to the first dataset; first dimension will have
two scales attached */
- if((did = H5Dopen2(fid, "D0", H5P_DEFAULT)) >= 0) {
- for (i=0; i<4; i++) {
- HDsprintf(dname, "DS%d", i);
- if((dsid = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0)
- goto out;
- if(H5DSattach_scale(did, dsid, (unsigned int) i%3) < 0)
- goto out;
- if(H5Dclose(dsid) < 0)
- goto out;
+ if ((did = H5Dopen2(fid, "D0", H5P_DEFAULT)) >= 0) {
+ for (i = 0; i < 4; i++) {
+ HDsprintf(dname, "DS%d", i);
+ if ((dsid = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0)
+ goto out;
+ if (H5DSattach_scale(did, dsid, (unsigned int)i % 3) < 0)
+ goto out;
+ if (H5Dclose(dsid) < 0)
+ goto out;
}
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
goto out;
- /* attach scales to the second dataset */
- if((did = H5Dopen2(fid, "D1", H5P_DEFAULT)) >= 0) {
- for (i=0; i<3; i++) {
- HDsprintf(dname, "DS%d", i);
- if((dsid = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0)
- goto out;
- if(H5DSattach_scale(did, dsid, (unsigned int) i) < 0)
- goto out;
- if(H5Dclose(dsid) < 0)
- goto out;
+ /* attach scales to the second dataset */
+ if ((did = H5Dopen2(fid, "D1", H5P_DEFAULT)) >= 0) {
+ for (i = 0; i < 3; i++) {
+ HDsprintf(dname, "DS%d", i);
+ if ((dsid = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0)
+ goto out;
+ if (H5DSattach_scale(did, dsid, (unsigned int)i) < 0)
+ goto out;
+ if (H5Dclose(dsid) < 0)
+ goto out;
}
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
@@ -1200,107 +1263,109 @@ static int test_detachscales(void)
/* detach DS0 from first dimension of D0 and D1; then check
that DS0 doesn't have attribute REFERENCE _LIST */
- if((dsid = H5Dopen2(fid, "DS0", H5P_DEFAULT)) < 0)
- goto out;
+ if ((dsid = H5Dopen2(fid, "DS0", H5P_DEFAULT)) < 0)
+ goto out;
- for (i=0; i<2; i++) {
+ for (i = 0; i < 2; i++) {
HDsprintf(dname, "D%d", i);
- if((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0)
goto out;
- if(H5DSdetach_scale(did, dsid, (unsigned int)0) < 0)
+ if (H5DSdetach_scale(did, dsid, (unsigned int)0) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
/* Check that attribute "REFERENCE_LIST" doesn't exist anymore */
- if(H5Aexists(dsid, REFERENCE_LIST)!= 0)
+ if (H5Aexists(dsid, REFERENCE_LIST) != 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
/* Check that DS3 is the only dim. scale attached to the first
dimension of D0 */
- if((did = H5Dopen2(fid, "D0", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "D0", H5P_DEFAULT)) < 0)
goto out;
- if((dsid = H5Dopen2(fid, "DS3", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "DS3", H5P_DEFAULT)) < 0)
goto out;
- if(H5DSis_attached(did, dsid, (unsigned int) 0) <= 0)
+ if (H5DSis_attached(did, dsid, (unsigned int)0) <= 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
/* Detach the rest of the scales DS3, DS1, DS2 from D0 and make
sure that attribute "DIMENSION_LIST" doesn't exist anymore */
- if((did = H5Dopen2(fid, "D0", H5P_DEFAULT)) >= 0) {
- for (i=1; i<4; i++) {
- HDsprintf(dname, "DS%d", i);
- if((dsid = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0)
- goto out;
- if(H5DSdetach_scale(did, dsid, (unsigned int) i%3) < 0)
- goto out;
- if(H5Dclose(dsid) < 0)
- goto out;
+ if ((did = H5Dopen2(fid, "D0", H5P_DEFAULT)) >= 0) {
+ for (i = 1; i < 4; i++) {
+ HDsprintf(dname, "DS%d", i);
+ if ((dsid = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0)
+ goto out;
+ if (H5DSdetach_scale(did, dsid, (unsigned int)i % 3) < 0)
+ goto out;
+ if (H5Dclose(dsid) < 0)
+ goto out;
}
/* Check that attribute "DIMENSION_LIST" doesn't exist anymore */
- if(H5Aexists(did, DIMENSION_LIST)!= 0)
+ if (H5Aexists(did, DIMENSION_LIST) != 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
goto out;
-
PASSED();
H5Fclose(fid);
return SUCCEED;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Dclose(dsid);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-static int test_char_attachscales(const char *fileext)
+static int
+test_char_attachscales(const char *fileext)
{
- hid_t fid = -1;
- hid_t did = -1;
- char dsname[32];
- char scalename[32];
+ hid_t fid = -1;
+ hid_t did = -1;
+ char dsname[32];
+ char scalename[32];
HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "ac");
HL_TESTING2("test_char_attachscales");
- if((fid = open_test_file(fileext)) < 0)
+ if ((fid = open_test_file(fileext)) < 0)
goto out;
/* make a dataset */
- if(create_char_dataset(fid, "ac", 0) < 0)
+ if (create_char_dataset(fid, "ac", 0) < 0)
goto out;
- if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
+ if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "ac");
- if(test_attach_scale(fid, did, scalename, DIM0) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM0) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_2_NAME, "ac");
- if(test_attach_scale(fid, did, scalename, DIM1) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM1) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_3_NAME, "ac");
- if(test_attach_scale(fid, did, scalename, DIM2) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM2) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
@@ -1312,72 +1377,75 @@ static int test_char_attachscales(const char *fileext)
return SUCCEED;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-static int test_short_attachscales(const char *fileext)
+static int
+test_short_attachscales(const char *fileext)
{
- hid_t fid = -1;
- hid_t did = -1;
- char dsname[32];
- char scalename[32];
+ hid_t fid = -1;
+ hid_t did = -1;
+ char dsname[32];
+ char scalename[32];
HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "as");
HL_TESTING2("test_short_attachscales");
- if((fid = open_test_file(fileext)) < 0)
+ if ((fid = open_test_file(fileext)) < 0)
goto out;
/* make a dataset */
- if(create_short_dataset(fid, "as", 1) < 0)
+ if (create_short_dataset(fid, "as", 1) < 0)
goto out;
- if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
+ if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "as");
- if(test_attach_scale(fid, did, scalename, DIM0) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM0) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_11_NAME, "as");
- if(test_attach_scale(fid, did, scalename, DIM0) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM0) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_2_NAME, "as");
- if(test_attach_scale(fid, did, scalename, DIM1) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM1) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_21_NAME, "as");
- if(test_attach_scale(fid, did, scalename, DIM1) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM1) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_22_NAME, "as");
- if(test_attach_scale(fid, did, scalename, DIM1) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM1) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_3_NAME, "as");
- if(test_attach_scale(fid, did, scalename, DIM2) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM2) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_31_NAME, "as");
- if(test_attach_scale(fid, did, scalename, DIM2) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM2) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_32_NAME, "as");
- if(test_attach_scale(fid, did, scalename, DIM2) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM2) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_33_NAME, "as");
- if(test_attach_scale(fid, did, scalename, DIM2) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM2) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
@@ -1389,56 +1457,59 @@ static int test_short_attachscales(const char *fileext)
return SUCCEED;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-static int test_int_attachscales(const char *fileext)
+static int
+test_int_attachscales(const char *fileext)
{
- hid_t fid = -1;
- hid_t did = -1;
- char dsname[32];
- char scalename[32];
+ hid_t fid = -1;
+ hid_t did = -1;
+ char dsname[32];
+ char scalename[32];
HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "a");
HL_TESTING2("test_int_attachscales");
- if((fid = open_test_file(fileext)) < 0)
+ if ((fid = open_test_file(fileext)) < 0)
goto out;
/* make a dataset */
- if(create_int_dataset(fid, "a", 1) < 0)
+ if (create_int_dataset(fid, "a", 1) < 0)
goto out;
- if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
+ if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "a");
- if(test_attach_scale(fid, did, scalename, DIM0) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM0) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_11_NAME, "a");
- if(test_attach_scale(fid, did, scalename, DIM0) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM0) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_2_NAME, "a");
- if(test_attach_scale(fid, did, scalename, DIM1) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM1) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_21_NAME, "a");
- if(test_attach_scale(fid, did, scalename, DIM1) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM1) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_22_NAME, "a");
- if(test_attach_scale(fid, did, scalename, DIM1) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM1) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
@@ -1450,52 +1521,55 @@ static int test_int_attachscales(const char *fileext)
return SUCCEED;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-static int test_long_attachscales(const char *fileext)
+static int
+test_long_attachscales(const char *fileext)
{
- hid_t fid = -1;
- hid_t did = -1;
- char dsname[32];
- char scalename[32];
+ hid_t fid = -1;
+ hid_t did = -1;
+ char dsname[32];
+ char scalename[32];
HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "al");
HL_TESTING2("test_long_attachscales");
- if((fid = open_test_file(fileext)) < 0)
+ if ((fid = open_test_file(fileext)) < 0)
goto out;
/* make a dataset */
- if(create_long_dataset(fid, dsname, "al", 0) < 0)
+ if (create_long_dataset(fid, dsname, "al", 0) < 0)
goto out;
- if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
+ if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "al");
- if(test_attach_scale(fid, did, scalename, DIM0) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM0) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_2_NAME, "al");
- if(test_attach_scale(fid, did, scalename, DIM1) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM1) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_3_NAME, "al");
- if(test_attach_scale(fid, did, scalename, DIM2) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM2) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_4_NAME, "al");
- if(test_attach_scale(fid, did, scalename, DIM3) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM3) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
@@ -1507,52 +1581,55 @@ static int test_long_attachscales(const char *fileext)
return SUCCEED;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-static int test_duplicatelong_attachscales(const char *fileext)
+static int
+test_duplicatelong_attachscales(const char *fileext)
{
- hid_t fid = -1;
- hid_t did = -1;
- char dsname[32];
- char scalename[32];
+ hid_t fid = -1;
+ hid_t did = -1;
+ char dsname[32];
+ char scalename[32];
HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "al2");
HL_TESTING2("test_duplicatelong_attachscales");
- if((fid = open_test_file(fileext)) < 0)
+ if ((fid = open_test_file(fileext)) < 0)
goto out;
/* make a dataset 2 */
- if(create_long_dataset(fid, dsname, "al2", 0) < 0)
+ if (create_long_dataset(fid, dsname, "al2", 0) < 0)
goto out;
- if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
+ if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "al");
- if(test_attach_scale(fid, did, scalename, DIM0) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM0) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_2_NAME, "al");
- if(test_attach_scale(fid, did, scalename, DIM1) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM1) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_3_NAME, "al");
- if(test_attach_scale(fid, did, scalename, DIM2) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM2) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_4_NAME, "al");
- if(test_attach_scale(fid, did, scalename, DIM3) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM3) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
@@ -1564,56 +1641,59 @@ static int test_duplicatelong_attachscales(const char *fileext)
return SUCCEED;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-static int test_float_attachscales(const char *fileext)
+static int
+test_float_attachscales(const char *fileext)
{
- hid_t fid = -1;
- hid_t did = -1;
- char dsname[32];
- char scalename[32];
+ hid_t fid = -1;
+ hid_t did = -1;
+ char dsname[32];
+ char scalename[32];
HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "af");
HL_TESTING2("test_float_attachscales");
- if((fid = open_test_file(fileext)) < 0)
+ if ((fid = open_test_file(fileext)) < 0)
goto out;
/* make a dataset */
- if(create_float_dataset(fid, "af", 1) < 0)
+ if (create_float_dataset(fid, "af", 1) < 0)
goto out;
- if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
+ if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "af");
- if(test_attach_scale(fid, did, scalename, DIM0) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM0) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_11_NAME, "af");
- if(test_attach_scale(fid, did, scalename, DIM0) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM0) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_2_NAME, "af");
- if(test_attach_scale(fid, did, scalename, DIM1) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM1) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_21_NAME, "af");
- if(test_attach_scale(fid, did, scalename, DIM1) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM1) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_22_NAME, "af");
- if(test_attach_scale(fid, did, scalename, DIM1) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM1) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
@@ -1625,45 +1705,48 @@ static int test_float_attachscales(const char *fileext)
return SUCCEED;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-static int test_numberofscales(const char *fileext)
+static int
+test_numberofscales(const char *fileext)
{
- hid_t fid = -1;
- hid_t did = -1;
- int nscales; /* number of scales in DIM */
- char dsname[32];
- char scalename[32];
+ hid_t fid = -1;
+ hid_t did = -1;
+ int nscales; /* number of scales in DIM */
+ char dsname[32];
+ char scalename[32];
HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "a");
HL_TESTING2("test_numberofscales");
- if((fid = open_test_file(fileext)) < 0)
+ if ((fid = open_test_file(fileext)) < 0)
goto out;
- if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
- if((nscales = H5DSget_num_scales(did, 0)) < 0)
+ if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
+ if ((nscales = H5DSget_num_scales(did, 0)) < 0)
goto out;
- if(nscales != 2)
+ if (nscales != 2)
goto out;
- if((nscales = H5DSget_num_scales(did, 1)) < 0)
+ if ((nscales = H5DSget_num_scales(did, 1)) < 0)
goto out;
- if(nscales != 3)
+ if (nscales != 3)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
@@ -1672,28 +1755,28 @@ static int test_numberofscales(const char *fileext)
HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "b");
/* make a dataset */
- if(create_int_dataset(fid, "b", 1) < 0)
+ if (create_int_dataset(fid, "b", 1) < 0)
goto out;
/* make a DS dataset for the first dimension */
- if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
+ if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "b");
- if(test_attach_scale(fid, did, scalename, DIM0) < 0)
+ if (test_attach_scale(fid, did, scalename, DIM0) < 0)
goto out;
- if((nscales = H5DSget_num_scales(did, 0)) < 0)
+ if ((nscales = H5DSget_num_scales(did, 0)) < 0)
goto out;
- if(nscales != 1)
+ if (nscales != 1)
goto out;
- if((nscales = H5DSget_num_scales(did, 1)) < 0)
+ if ((nscales = H5DSget_num_scales(did, 1)) < 0)
goto out;
- if(nscales != 0)
+ if (nscales != 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
@@ -1705,55 +1788,59 @@ static int test_numberofscales(const char *fileext)
return SUCCEED;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-static int test_char_scalenames(const char *fileext) {
- hid_t fid = -1;
- hid_t did = -1;
- char dsname[32];
- char scalename[32];
- char name[32];
+static int
+test_char_scalenames(const char *fileext)
+{
+ hid_t fid = -1;
+ hid_t did = -1;
+ char dsname[32];
+ char scalename[32];
+ char name[32];
HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "ac");
- if((fid = open_test_file(fileext)) < 0)
+ if ((fid = open_test_file(fileext)) < 0)
goto out;
HL_TESTING2("set char scale/cmp scale name");
- if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
+ if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "ac");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_1_NAME, "ac");
- if(test_set_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_2_NAME, "ac");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_2_NAME, "ac");
- if(test_set_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_3_NAME, "ac");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_3_NAME, "ac");
- if(test_set_scalename(fid, did, scalename, name, DIM2) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM2) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM2) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM2) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
@@ -1765,103 +1852,107 @@ static int test_char_scalenames(const char *fileext) {
return SUCCEED;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-static int test_short_scalenames(const char *fileext) {
- hid_t fid = -1;
- hid_t did = -1;
- char dsname[32];
- char scalename[32];
- char name[32];
+static int
+test_short_scalenames(const char *fileext)
+{
+ hid_t fid = -1;
+ hid_t did = -1;
+ char dsname[32];
+ char scalename[32];
+ char name[32];
HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "as");
- if((fid = open_test_file(fileext)) < 0)
+ if ((fid = open_test_file(fileext)) < 0)
goto out;
HL_TESTING2("set short scale/cmp scale name");
- if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
+ if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "as");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_1_NAME, "as");
- if(test_set_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_11_NAME, "as");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_11_NAME, "as");
- if(test_set_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_2_NAME, "as");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_2_NAME, "as");
- if(test_set_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_21_NAME, "as");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_21_NAME, "as");
- if(test_set_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_22_NAME, "as");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_22_NAME, "as");
- if(test_set_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_3_NAME, "as");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_3_NAME, "as");
- if(test_set_scalename(fid, did, scalename, name, DIM2) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM2) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM2) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM2) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_31_NAME, "as");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_31_NAME, "as");
- if(test_set_scalename(fid, did, scalename, name, DIM2) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM2) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM2) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM2) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_32_NAME, "as");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_32_NAME, "as");
- if(test_set_scalename(fid, did, scalename, name, DIM2) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM2) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM2) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM2) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_33_NAME, "as");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_33_NAME, "as");
- if(test_set_scalename(fid, did, scalename, name, DIM2) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM2) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM2) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM2) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
@@ -1873,71 +1964,75 @@ static int test_short_scalenames(const char *fileext) {
return SUCCEED;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-static int test_int_scalenames(const char *fileext) {
- hid_t fid = -1;
- hid_t did = -1;
- char dsname[32];
- char scalename[32];
- char name[32];
+static int
+test_int_scalenames(const char *fileext)
+{
+ hid_t fid = -1;
+ hid_t did = -1;
+ char dsname[32];
+ char scalename[32];
+ char name[32];
HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "a");
- if((fid = open_test_file(fileext)) < 0)
+ if ((fid = open_test_file(fileext)) < 0)
goto out;
HL_TESTING2("set int scale/cmp scale name");
- if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
+ if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "a");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_1_NAME, "a");
- if(test_set_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_11_NAME, "a");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_11_NAME, "a");
- if(test_set_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_2_NAME, "a");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_2_NAME, "a");
- if(test_set_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_21_NAME, "a");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_21_NAME, "a");
- if(test_set_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_22_NAME, "a");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_22_NAME, "a");
- if(test_set_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
@@ -1949,63 +2044,67 @@ static int test_int_scalenames(const char *fileext) {
return 0;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-static int test_long_scalenames(const char *fileext) {
- hid_t fid = -1;
- hid_t did = -1;
- char dsname[32];
- char scalename[32];
- char name[32];
+static int
+test_long_scalenames(const char *fileext)
+{
+ hid_t fid = -1;
+ hid_t did = -1;
+ char dsname[32];
+ char scalename[32];
+ char name[32];
HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "al");
- if((fid = open_test_file(fileext)) < 0)
+ if ((fid = open_test_file(fileext)) < 0)
goto out;
HL_TESTING2("set long scale/cmp scale name");
- if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
+ if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "al");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_1_NAME, "al");
- if(test_set_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_2_NAME, "al");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_2_NAME, "al");
- if(test_set_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_3_NAME, "al");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_3_NAME, "al");
- if(test_set_scalename(fid, did, scalename, name, DIM2) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM2) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM2) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM2) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_4_NAME, "al");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_4_NAME, "al");
- if(test_set_scalename(fid, did, scalename, name, DIM3) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM3) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM3) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM3) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
@@ -2017,63 +2116,67 @@ static int test_long_scalenames(const char *fileext) {
return SUCCEED;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-static int test_samelong_scalenames(const char *fileext) {
- hid_t fid = -1;
- hid_t did = -1;
- char dsname[32];
- char scalename[32];
- char name[32];
+static int
+test_samelong_scalenames(const char *fileext)
+{
+ hid_t fid = -1;
+ hid_t did = -1;
+ char dsname[32];
+ char scalename[32];
+ char name[32];
HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "al2");
- if((fid = open_test_file(fileext)) < 0)
+ if ((fid = open_test_file(fileext)) < 0)
goto out;
HL_TESTING2("set same long scale/cmp scale name");
- if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
+ if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "al");
HDsnprintf(name, sizeof(name), "%s%s", DS_1_NAME, "al");
- if(test_set_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_2_NAME, "al");
HDsnprintf(name, sizeof(name), "%s%s", DS_2_NAME, "al");
- if(test_set_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_3_NAME, "al");
HDsnprintf(name, sizeof(name), "%s%s", DS_3_NAME, "al");
- if(test_set_scalename(fid, did, scalename, name, DIM2) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM2) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM2) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM2) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_4_NAME, "al");
HDsnprintf(name, sizeof(name), "%s%s", DS_4_NAME, "al");
- if(test_set_scalename(fid, did, scalename, name, DIM3) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM3) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM3) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM3) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
@@ -2085,71 +2188,75 @@ static int test_samelong_scalenames(const char *fileext) {
return SUCCEED;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-static int test_float_scalenames(const char *fileext) {
- hid_t fid = -1;
- hid_t did = -1;
- char dsname[32];
- char scalename[32];
- char name[32];
+static int
+test_float_scalenames(const char *fileext)
+{
+ hid_t fid = -1;
+ hid_t did = -1;
+ char dsname[32];
+ char scalename[32];
+ char name[32];
HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "af");
- if((fid = open_test_file(fileext)) < 0)
+ if ((fid = open_test_file(fileext)) < 0)
goto out;
HL_TESTING2("set float scale/cmp scale name");
- if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
+ if ((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "af");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_1_NAME, "af");
- if(test_set_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_11_NAME, "af");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_11_NAME, "af");
- if(test_set_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM0) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_2_NAME, "af");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_2_NAME, "af");
- if(test_set_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_21_NAME, "af");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_21_NAME, "af");
- if(test_set_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_22_NAME, "af");
HDsnprintf(name, sizeof(name), "%s%s", SCALE_22_NAME, "af");
- if(test_set_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_set_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
- if(test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
+ if (test_cmp_scalename(fid, did, scalename, name, DIM1) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
@@ -2161,44 +2268,47 @@ static int test_float_scalenames(const char *fileext) {
return 0;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-static int test_foreign_scaleattached(const char *fileforeign)
+static int
+test_foreign_scaleattached(const char *fileforeign)
{
- herr_t ret_value = FAIL;
- hid_t fid = -1;
- hid_t did = -1;
- hid_t dsid = -1;
- const char *filename = H5_get_srcdir_filename(fileforeign);
+ herr_t ret_value = FAIL;
+ hid_t fid = -1;
+ hid_t did = -1;
+ hid_t dsid = -1;
+ const char *filename = H5_get_srcdir_filename(fileforeign);
HL_TESTING2("test_foreign_scaleattached");
- if((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
+ if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
goto out;
- if((did = H5Dopen2(fid, "/dset_al", H5P_DEFAULT)) >= 0) {
- if((dsid = H5Dopen2(fid, "/ds_4_al", H5P_DEFAULT)) >= 0) {
- if(H5DSis_attached(did, dsid, 3) == 1) {
+ if ((did = H5Dopen2(fid, "/dset_al", H5P_DEFAULT)) >= 0) {
+ if ((dsid = H5Dopen2(fid, "/ds_4_al", H5P_DEFAULT)) >= 0) {
+ if (H5DSis_attached(did, dsid, 3) == 1) {
ret_value = SUCCEED;
}
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
}
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
else
goto out;
- if(ret_value == FAIL)
+ if (ret_value == FAIL)
goto out;
PASSED();
@@ -2207,1225 +2317,1206 @@ static int test_foreign_scaleattached(const char *fileforeign)
return 0;
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-static int test_simple(void)
+static int
+test_simple(void)
{
- hid_t fid = -1;
- hid_t did = -1;
- hid_t dsid = -1;
- hid_t sid = -1;
- hid_t gid = -1;
- int rank = RANK;
- int rankds = 1;
- hsize_t dims[RANK] = {DIM1_SIZE,DIM2_SIZE};
- int buf[DIM_DATA] = {1,2,3,4,5,6,7,8,9,10,11,12};
- hsize_t s1_dim[1] = {DIM1_SIZE};
- hsize_t s2_dim[1] = {DIM2_SIZE};
- char sname[30];
- char dname[30];
- int s1_wbuf[DIM1_SIZE] = {10,20,30};
- int s11_wbuf[DIM1_SIZE] = {10,100,300};
- int s2_wbuf[DIM2_SIZE] = {100,200,300,400};
- int s21_wbuf[DIM2_SIZE] = {10,20,30,40};
- int s22_wbuf[DIM2_SIZE] = {5,10,50,300};
- char dim0_label[16];
- char dim1_label[16];
- char *dim0_labeld;
- char *dim1_labeld;
- char dim0_labels[3];
- char dim1_labels[3];
- ssize_t dim0_label_size;
- ssize_t dim1_label_size;
+ hid_t fid = -1;
+ hid_t did = -1;
+ hid_t dsid = -1;
+ hid_t sid = -1;
+ hid_t gid = -1;
+ int rank = RANK;
+ int rankds = 1;
+ hsize_t dims[RANK] = {DIM1_SIZE, DIM2_SIZE};
+ int buf[DIM_DATA] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
+ hsize_t s1_dim[1] = {DIM1_SIZE};
+ hsize_t s2_dim[1] = {DIM2_SIZE};
+ char sname[30];
+ char dname[30];
+ int s1_wbuf[DIM1_SIZE] = {10, 20, 30};
+ int s11_wbuf[DIM1_SIZE] = {10, 100, 300};
+ int s2_wbuf[DIM2_SIZE] = {100, 200, 300, 400};
+ int s21_wbuf[DIM2_SIZE] = {10, 20, 30, 40};
+ int s22_wbuf[DIM2_SIZE] = {5, 10, 50, 300};
+ char dim0_label[16];
+ char dim1_label[16];
+ char * dim0_labeld;
+ char * dim1_labeld;
+ char dim0_labels[3];
+ char dim1_labels[3];
+ ssize_t dim0_label_size;
+ ssize_t dim1_label_size;
unsigned int dim;
- int scale_idx;
- int nscales;
- ssize_t name_len;
- char *name_out=NULL;
- char snames[3];
- int i, j;
+ int scale_idx;
+ int nscales;
+ ssize_t name_len;
+ char * name_out = NULL;
+ char snames[3];
+ int i, j;
HDprintf("Testing API functions\n");
/*-------------------------------------------------------------------------
- * create a file for the test
- *-------------------------------------------------------------------------
- */
+ * create a file for the test
+ *-------------------------------------------------------------------------
+ */
/* create a file using default properties */
- if((fid=H5Fcreate(FILE1,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
+ if ((fid = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
/*-------------------------------------------------------------------------
- * create datasets: 1 "data" dataset and 4 dimension scales
- *-------------------------------------------------------------------------
- */
+ * create datasets: 1 "data" dataset and 4 dimension scales
+ *-------------------------------------------------------------------------
+ */
/* make a dataset */
- if(H5LTmake_dataset_int(fid,"dset_a",rank,dims,buf) < 0)
+ if (H5LTmake_dataset_int(fid, "dset_a", rank, dims, buf) < 0)
goto out;
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_int(fid,"ds_a_1",rankds,s1_dim,s1_wbuf) < 0)
+ if (H5LTmake_dataset_int(fid, "ds_a_1", rankds, s1_dim, s1_wbuf) < 0)
goto out;
/* make a DS dataset with an alternate scale for the 2nd dimension */
- if(H5LTmake_dataset_int(fid,"ds_a_11",rankds,s1_dim,s11_wbuf) < 0)
+ if (H5LTmake_dataset_int(fid, "ds_a_11", rankds, s1_dim, s11_wbuf) < 0)
goto out;
/* make a DS dataset for the second dimension */
- if(H5LTmake_dataset_int(fid,"ds_a_2",rankds,s2_dim,s2_wbuf) < 0)
+ if (H5LTmake_dataset_int(fid, "ds_a_2", rankds, s2_dim, s2_wbuf) < 0)
goto out;
/* make a DS dataset with an alternate scale for the 2nd dimension */
- if(H5LTmake_dataset_int(fid,"ds_a_21",rankds,s2_dim,s21_wbuf) < 0)
+ if (H5LTmake_dataset_int(fid, "ds_a_21", rankds, s2_dim, s21_wbuf) < 0)
goto out;
/* make a DS dataset with an alternate scale for the 2nd dimension */
- if(H5LTmake_dataset_int(fid,"ds_a_22",rankds,s2_dim,s22_wbuf) < 0)
+ if (H5LTmake_dataset_int(fid, "ds_a_22", rankds, s2_dim, s22_wbuf) < 0)
goto out;
/* get the dataset id for "dset_a" */
- if((did = H5Dopen2(fid,"dset_a", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_a", H5P_DEFAULT)) < 0)
goto out;
/*-------------------------------------------------------------------------
- * attach the DS_1_NAME dimension scale to "dset_a"
- *-------------------------------------------------------------------------
- */
+ * attach the DS_1_NAME dimension scale to "dset_a"
+ *-------------------------------------------------------------------------
+ */
/* get the DS dataset id */
- if((dsid = H5Dopen2(fid,"ds_a_1", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_a_1", H5P_DEFAULT)) < 0)
goto out;
/* attach the DS_1_NAME dimension scale to "dset_a" at dimension 0 */
- if(H5DSattach_scale(did,dsid,DIM0) < 0)
+ if (H5DSattach_scale(did, dsid, DIM0) < 0)
goto out;
/* close DS id */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
/*-------------------------------------------------------------------------
- * attach the DS_11_NAME dimension scale to "dset_a"
- *-------------------------------------------------------------------------
- */
+ * attach the DS_11_NAME dimension scale to "dset_a"
+ *-------------------------------------------------------------------------
+ */
/* get the DS dataset id */
- if((dsid = H5Dopen2(fid,"ds_a_11", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_a_11", H5P_DEFAULT)) < 0)
goto out;
/* attach the DS_11_NAME dimension scale to "dset_a" at dimension 0 */
- if(H5DSattach_scale(did,dsid,DIM0) < 0)
+ if (H5DSattach_scale(did, dsid, DIM0) < 0)
goto out;
/* close DS id */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
/*-------------------------------------------------------------------------
- * attach the DS_2_NAME dimension scale to "dset_a"
- *-------------------------------------------------------------------------
- */
+ * attach the DS_2_NAME dimension scale to "dset_a"
+ *-------------------------------------------------------------------------
+ */
/* get the DS dataset id */
- if((dsid = H5Dopen2(fid,"ds_a_2", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_a_2", H5P_DEFAULT)) < 0)
goto out;
/* attach the "ds2" dimension scale to "dset_a" as the 2nd dimension */
- if(H5DSattach_scale(did,dsid,DIM1) < 0)
+ if (H5DSattach_scale(did, dsid, DIM1) < 0)
goto out;
/* close DS id */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
/*-------------------------------------------------------------------------
- * attach the DS_21_NAME dimension scale to "dset_a"
- *-------------------------------------------------------------------------
- */
+ * attach the DS_21_NAME dimension scale to "dset_a"
+ *-------------------------------------------------------------------------
+ */
/* get the DS dataset id */
- if((dsid = H5Dopen2(fid,"ds_a_21", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_a_21", H5P_DEFAULT)) < 0)
goto out;
/* attach the DS_21_NAME dimension scale to "dset_a" as the 2nd dimension */
- if(H5DSattach_scale(did,dsid,DIM1) < 0)
+ if (H5DSattach_scale(did, dsid, DIM1) < 0)
goto out;
/* close DS id */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
/*-------------------------------------------------------------------------
- * attach the DS_22_NAME dimension scale to "dset_a"
- *-------------------------------------------------------------------------
- */
+ * attach the DS_22_NAME dimension scale to "dset_a"
+ *-------------------------------------------------------------------------
+ */
/* get the DS dataset id */
- if((dsid = H5Dopen2(fid,"ds_a_22", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_a_22", H5P_DEFAULT)) < 0)
goto out;
/* attach the "ds22" dimension scale to "dset_a" as the 2nd dimension */
- if(H5DSattach_scale(did,dsid,DIM1) < 0)
+ if (H5DSattach_scale(did, dsid, DIM1) < 0)
goto out;
/* close DS id */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
/* close dataset ID of "dset_a" */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
/*-------------------------------------------------------------------------
- * create datasets: 1 "data" dataset and 1 dimension scale
- *-------------------------------------------------------------------------
- */
+ * create datasets: 1 "data" dataset and 1 dimension scale
+ *-------------------------------------------------------------------------
+ */
/* make a dataset */
- if(H5LTmake_dataset_int(fid,"dset_b",rank,dims,buf) < 0)
+ if (H5LTmake_dataset_int(fid, "dset_b", rank, dims, buf) < 0)
goto out;
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_int(fid,"ds_b_1",rankds,s1_dim,s1_wbuf) < 0)
+ if (H5LTmake_dataset_int(fid, "ds_b_1", rankds, s1_dim, s1_wbuf) < 0)
goto out;
/*-------------------------------------------------------------------------
- * attach the scale to "dset_b"
- *-------------------------------------------------------------------------
- */
+ * attach the scale to "dset_b"
+ *-------------------------------------------------------------------------
+ */
- if((did = H5Dopen2(fid,"dset_b", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_b", H5P_DEFAULT)) < 0)
goto out;
- if((dsid = H5Dopen2(fid,"ds_b_1", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_b_1", H5P_DEFAULT)) < 0)
goto out;
- if(H5DSattach_scale(did,dsid,0) < 0)
+ if (H5DSattach_scale(did, dsid, 0) < 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
/* close dataset ID of "dset_b" */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
-
-
/*-------------------------------------------------------------------------
- * H5DSdetach_scale
- *-------------------------------------------------------------------------
- */
+ * H5DSdetach_scale
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("detach scales ");
-
/*-------------------------------------------------------------------------
- * create datasets: one "data" dataset and 4 dimension scales
- *-------------------------------------------------------------------------
- */
+ * create datasets: one "data" dataset and 4 dimension scales
+ *-------------------------------------------------------------------------
+ */
/* make a dataset */
- if(H5LTmake_dataset_int(fid, "dset_c", rank, dims, buf) < 0)
+ if (H5LTmake_dataset_int(fid, "dset_c", rank, dims, buf) < 0)
goto out;
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_int(fid, "ds_c_1", rankds, s1_dim, s1_wbuf) < 0)
+ if (H5LTmake_dataset_int(fid, "ds_c_1", rankds, s1_dim, s1_wbuf) < 0)
goto out;
/* make a DS dataset for the second dimension */
- if(H5LTmake_dataset_int(fid, "ds_c_2", rankds, s2_dim, s2_wbuf) < 0)
+ if (H5LTmake_dataset_int(fid, "ds_c_2", rankds, s2_dim, s2_wbuf) < 0)
goto out;
/* make a DS dataset with an alternate scale for the 2nd dimension */
- if(H5LTmake_dataset_int(fid, "ds_c_21", rankds, s2_dim, s2_wbuf) < 0)
+ if (H5LTmake_dataset_int(fid, "ds_c_21", rankds, s2_dim, s2_wbuf) < 0)
goto out;
/* make a DS dataset with an alternate scale for the 2nd dimension */
- if(H5LTmake_dataset_int(fid, "ds_c_22", rankds, s2_dim, s2_wbuf) < 0)
+ if (H5LTmake_dataset_int(fid, "ds_c_22", rankds, s2_dim, s2_wbuf) < 0)
goto out;
-
/*-------------------------------------------------------------------------
- * attach the scales to "dset_c"
- *-------------------------------------------------------------------------
- */
+ * attach the scales to "dset_c"
+ *-------------------------------------------------------------------------
+ */
- if((did = H5Dopen2(fid,"dset_c", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_c", H5P_DEFAULT)) < 0)
goto out;
- if((dsid = H5Dopen2(fid,"ds_c_1", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_c_1", H5P_DEFAULT)) < 0)
goto out;
- if(H5DSattach_scale(did, dsid, 0) < 0)
+ if (H5DSattach_scale(did, dsid, 0) < 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if((dsid = H5Dopen2(fid,"ds_c_2", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_c_2", H5P_DEFAULT)) < 0)
goto out;
- if(H5DSattach_scale(did, dsid, 1) < 0)
+ if (H5DSattach_scale(did, dsid, 1) < 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if((dsid = H5Dopen2(fid,"ds_c_21", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_c_21", H5P_DEFAULT)) < 0)
goto out;
- if(H5DSattach_scale(did, dsid, 1) < 0)
+ if (H5DSattach_scale(did, dsid, 1) < 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if((dsid = H5Dopen2(fid,"ds_c_22", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_c_22", H5P_DEFAULT)) < 0)
goto out;
- if(H5DSattach_scale(did, dsid, 1) < 0)
+ if (H5DSattach_scale(did, dsid, 1) < 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
/*-------------------------------------------------------------------------
- * verify if "dset_c" has dimension scales
- *-------------------------------------------------------------------------
- */
+ * verify if "dset_c" has dimension scales
+ *-------------------------------------------------------------------------
+ */
- if((did = H5Dopen2(fid,"dset_c", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_c", H5P_DEFAULT)) < 0)
goto out;
/* verify that "dset_c" has 1 dimension scale at DIM 0 */
- if((nscales = H5DSget_num_scales(did, 0)) < 0)
+ if ((nscales = H5DSget_num_scales(did, 0)) < 0)
goto out;
- if(nscales != 1)
+ if (nscales != 1)
goto out;
/* verify that "dset_c" has 3 dimension scales at DIM 1 */
- if((nscales = H5DSget_num_scales(did, 1)) < 0)
+ if ((nscales = H5DSget_num_scales(did, 1)) < 0)
goto out;
- if(nscales != 3)
+ if (nscales != 3)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
/*-------------------------------------------------------------------------
- * detach the "ds_c_21" dimension scale to "dset_c"
- *-------------------------------------------------------------------------
- */
+ * detach the "ds_c_21" dimension scale to "dset_c"
+ *-------------------------------------------------------------------------
+ */
/* get the dataset id for "dset_c" */
- if((did = H5Dopen2(fid,"dset_c", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_c", H5P_DEFAULT)) < 0)
goto out;
/* get the DS dataset id */
- if((dsid = H5Dopen2(fid,"ds_c_21", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_c_21", H5P_DEFAULT)) < 0)
goto out;
/* detach the "ds_c_21" dimension scale to "dset_c" in DIM 1 */
- if(H5DSdetach_scale(did, dsid, 1) < 0)
+ if (H5DSdetach_scale(did, dsid, 1) < 0)
goto out;
/* close DS id */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
/* close dataset ID of "dset_c" */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
/*-------------------------------------------------------------------------
- * "dset_c" must have now 2 dimension scales at DIM 1
- *-------------------------------------------------------------------------
- */
+ * "dset_c" must have now 2 dimension scales at DIM 1
+ *-------------------------------------------------------------------------
+ */
- if((did = H5Dopen2(fid,"dset_c", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_c", H5P_DEFAULT)) < 0)
goto out;
/* verify that "dset_c" has 2 dimension scales at DIM 1 */
- if((nscales = H5DSget_num_scales(did, 1)) < 0)
+ if ((nscales = H5DSget_num_scales(did, 1)) < 0)
goto out;
- if(nscales != 2)
+ if (nscales != 2)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
/*-------------------------------------------------------------------------
- * detach the "ds_c_22" dimension scale to "dset_c"
- *-------------------------------------------------------------------------
- */
+ * detach the "ds_c_22" dimension scale to "dset_c"
+ *-------------------------------------------------------------------------
+ */
/* get the dataset id for "dset_c" */
- if((did = H5Dopen2(fid,"dset_c", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_c", H5P_DEFAULT)) < 0)
goto out;
/* get the DS dataset id */
- if((dsid = H5Dopen2(fid,"ds_c_22", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_c_22", H5P_DEFAULT)) < 0)
goto out;
/* detach the "ds_c_22" dimension scale to "dset_c" in DIM 1 */
- if(H5DSdetach_scale(did, dsid, 1) < 0)
+ if (H5DSdetach_scale(did, dsid, 1) < 0)
goto out;
/* close DS id */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
/* close dataset ID of "dset_c" */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
/*-------------------------------------------------------------------------
- * "dset_c" must have now 1 dimension scale at DIM 1
- *-------------------------------------------------------------------------
- */
+ * "dset_c" must have now 1 dimension scale at DIM 1
+ *-------------------------------------------------------------------------
+ */
- if((did = H5Dopen2(fid,"dset_c", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_c", H5P_DEFAULT)) < 0)
goto out;
/* verify that "dset_c" has 1 dimension scale at DIM 1 */
- if((nscales = H5DSget_num_scales(did, 1)) < 0)
+ if ((nscales = H5DSget_num_scales(did, 1)) < 0)
goto out;
- if(nscales != 1)
+ if (nscales != 1)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
/*-------------------------------------------------------------------------
- * detach the "ds_c_2" dimension scale to "dset_c"
- *-------------------------------------------------------------------------
- */
+ * detach the "ds_c_2" dimension scale to "dset_c"
+ *-------------------------------------------------------------------------
+ */
/* get the dataset id for "dset_c" */
- if((did = H5Dopen2(fid,"dset_c", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_c", H5P_DEFAULT)) < 0)
goto out;
/* get the DS dataset id */
- if((dsid = H5Dopen2(fid,"ds_c_2", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_c_2", H5P_DEFAULT)) < 0)
goto out;
/* detach the "ds_c_2" dimension scale to "dset_c" in DIM 1 */
- if(H5DSdetach_scale(did, dsid, 1) < 0)
+ if (H5DSdetach_scale(did, dsid, 1) < 0)
goto out;
/* close DS id */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
/* close dataset ID of "dset_c" */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
/*-------------------------------------------------------------------------
- * "dset_c" must have now 0 dimension scales at DIM 1
- *-------------------------------------------------------------------------
- */
+ * "dset_c" must have now 0 dimension scales at DIM 1
+ *-------------------------------------------------------------------------
+ */
- if((did = H5Dopen2(fid,"dset_c", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_c", H5P_DEFAULT)) < 0)
goto out;
/* verify that "dset_c" has 1 dimension scale at DIM 1 */
- if((nscales = H5DSget_num_scales(did, 1)) < 0)
+ if ((nscales = H5DSget_num_scales(did, 1)) < 0)
goto out;
- if(nscales != 0)
+ if (nscales != 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
-
/*-------------------------------------------------------------------------
- * create 3 datasets: 1 "data" dataset and 2 dimension scales
- *-------------------------------------------------------------------------
- */
- if(H5LTmake_dataset_int(fid,"dset_d",rank,dims,NULL) < 0)
+ * create 3 datasets: 1 "data" dataset and 2 dimension scales
+ *-------------------------------------------------------------------------
+ */
+ if (H5LTmake_dataset_int(fid, "dset_d", rank, dims, NULL) < 0)
goto out;
- if(H5LTmake_dataset_int(fid,"ds_d_1",rankds,s1_dim,NULL) < 0)
+ if (H5LTmake_dataset_int(fid, "ds_d_1", rankds, s1_dim, NULL) < 0)
goto out;
- if(H5LTmake_dataset_int(fid,"ds_d_2",rankds,s2_dim,NULL) < 0)
+ if (H5LTmake_dataset_int(fid, "ds_d_2", rankds, s2_dim, NULL) < 0)
goto out;
/*-------------------------------------------------------------------------
- * attach them
- *-------------------------------------------------------------------------
- */
- if((did = H5Dopen2(fid,"dset_d", H5P_DEFAULT)) < 0)
+ * attach them
+ *-------------------------------------------------------------------------
+ */
+ if ((did = H5Dopen2(fid, "dset_d", H5P_DEFAULT)) < 0)
goto out;
- if((dsid = H5Dopen2(fid,"ds_d_1", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_d_1", H5P_DEFAULT)) < 0)
goto out;
- if(H5DSattach_scale(did, dsid, 0) < 0)
+ if (H5DSattach_scale(did, dsid, 0) < 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if((dsid = H5Dopen2(fid,"ds_d_2", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_d_2", H5P_DEFAULT)) < 0)
goto out;
- if(H5DSattach_scale(did, dsid, 1) < 0)
+ if (H5DSattach_scale(did, dsid, 1) < 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
/*-------------------------------------------------------------------------
- * verify
- *-------------------------------------------------------------------------
- */
+ * verify
+ *-------------------------------------------------------------------------
+ */
- if((did = H5Dopen2(fid,"dset_d", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_d", H5P_DEFAULT)) < 0)
goto out;
- if((dsid = H5Dopen2(fid,"ds_d_1", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_d_1", H5P_DEFAULT)) < 0)
goto out;
- if(H5DSis_attached(did,dsid,DIM0)<=0)
+ if (H5DSis_attached(did, dsid, DIM0) <= 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if((dsid = H5Dopen2(fid,"ds_d_2", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_d_2", H5P_DEFAULT)) < 0)
goto out;
- if(H5DSis_attached(did,dsid,DIM1)<=0)
+ if (H5DSis_attached(did, dsid, DIM1) <= 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
-
/*-------------------------------------------------------------------------
- * detach
- *-------------------------------------------------------------------------
- */
+ * detach
+ *-------------------------------------------------------------------------
+ */
/* get the dataset id for "dset_d" */
- if((did = H5Dopen2(fid,"dset_d", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_d", H5P_DEFAULT)) < 0)
goto out;
/* get the DS dataset id */
- if((dsid = H5Dopen2(fid,"ds_d_1", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_d_1", H5P_DEFAULT)) < 0)
goto out;
/* detach the dimension scale to "dset_d" in DIM 0 */
- if(H5DSdetach_scale(did,dsid,DIM0) < 0)
+ if (H5DSdetach_scale(did, dsid, DIM0) < 0)
goto out;
/* verify attach, it must return 0 for no attach */
- if(H5DSis_attached(did,dsid,DIM0)!=0)
+ if (H5DSis_attached(did, dsid, DIM0) != 0)
goto out;
/* close DS id */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
/* close dataset ID of "dset_d" */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
/*-------------------------------------------------------------------------
- * attach again
- *-------------------------------------------------------------------------
- */
+ * attach again
+ *-------------------------------------------------------------------------
+ */
/* get the dataset id for "dset_d" */
- if((did = H5Dopen2(fid,"dset_d", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_d", H5P_DEFAULT)) < 0)
goto out;
/* get the DS dataset id */
- if((dsid = H5Dopen2(fid,"ds_d_1", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_d_1", H5P_DEFAULT)) < 0)
goto out;
/* attach "ds_d_1" again in DIM 0 */
- if(H5DSattach_scale(did,dsid,DIM0) < 0)
+ if (H5DSattach_scale(did, dsid, DIM0) < 0)
goto out;
/* verify attach, it must return 1 for attach */
- if(H5DSis_attached(did,dsid,DIM0)!=1)
+ if (H5DSis_attached(did, dsid, DIM0) != 1)
goto out;
/* verify that "ds_d_1" has only 1 scale at DIM0 */
- if((nscales = H5DSget_num_scales(did,DIM0)) < 0)
+ if ((nscales = H5DSget_num_scales(did, DIM0)) < 0)
goto out;
- if(nscales != 1)
+ if (nscales != 1)
goto out;
/* close DS id */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
/* close dataset ID of "dset_d" */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
/*-------------------------------------------------------------------------
- * detach/detach
- *-------------------------------------------------------------------------
- */
+ * detach/detach
+ *-------------------------------------------------------------------------
+ */
/* get the dataset id for "dset_d" */
- if((did = H5Dopen2(fid,"dset_d", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_d", H5P_DEFAULT)) < 0)
goto out;
/* get the DS dataset id */
- if((dsid = H5Dopen2(fid,"ds_d_2", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_d_2", H5P_DEFAULT)) < 0)
goto out;
/* detach the "ds_d_2" dimension scale to "dset_d" in DIM 1 */
- if(H5DSdetach_scale(did,dsid,DIM1) < 0)
+ if (H5DSdetach_scale(did, dsid, DIM1) < 0)
goto out;
/* detach again, it should fail */
- if(H5DSdetach_scale(did,dsid,DIM1)==SUCCEED)
+ if (H5DSdetach_scale(did, dsid, DIM1) == SUCCEED)
goto out;
/* verify attach, it must return 0 for no attach */
- if(H5DSis_attached(did,dsid,DIM1)!=0)
+ if (H5DSis_attached(did, dsid, DIM1) != 0)
goto out;
/* verify that "ds_d_1" has no scale at DIM1 */
- if((nscales = H5DSget_num_scales(did,DIM1)) < 0)
+ if ((nscales = H5DSget_num_scales(did, DIM1)) < 0)
goto out;
- if(nscales != 0)
+ if (nscales != 0)
goto out;
/* close DS id */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
/* close dataset ID of "dset_d" */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
/*-------------------------------------------------------------------------
- * attach twice
- *-------------------------------------------------------------------------
- */
+ * attach twice
+ *-------------------------------------------------------------------------
+ */
/* get the dataset id for "dset_d" */
- if((did = H5Dopen2(fid,"dset_d", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_d", H5P_DEFAULT)) < 0)
goto out;
/* get the DS dataset id */
- if((dsid = H5Dopen2(fid,"ds_d_2", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_d_2", H5P_DEFAULT)) < 0)
goto out;
/* attach "ds_d_2" in DIM 1 */
- if(H5DSattach_scale(did,dsid,DIM1) < 0)
+ if (H5DSattach_scale(did, dsid, DIM1) < 0)
goto out;
/* verify attach, it must return 1 for attach */
- if(H5DSis_attached(did,dsid,DIM1)!=1)
+ if (H5DSis_attached(did, dsid, DIM1) != 1)
goto out;
/* verify that "ds_d_2" has only 1 scale at DIM1 */
- if((nscales = H5DSget_num_scales(did,DIM0)) < 0)
+ if ((nscales = H5DSget_num_scales(did, DIM0)) < 0)
goto out;
- if(nscales != 1)
+ if (nscales != 1)
goto out;
/* attach "ds_d_2" again in DIM 1 */
- if(H5DSattach_scale(did,dsid,DIM1) < 0)
+ if (H5DSattach_scale(did, dsid, DIM1) < 0)
goto out;
/* verify attach, it must return 1 for attach */
- if(H5DSis_attached(did,dsid,DIM1)!=1)
+ if (H5DSis_attached(did, dsid, DIM1) != 1)
goto out;
/* verify that "ds_d_2" has only 1 scale at DIM1 */
- if((nscales = H5DSget_num_scales(did,DIM0)) < 0)
+ if ((nscales = H5DSget_num_scales(did, DIM0)) < 0)
goto out;
- if(nscales != 1)
+ if (nscales != 1)
goto out;
/* close DS id */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
/* close dataset ID of "dset_d" */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
/*-------------------------------------------------------------------------
- * create 10 datasets: 5 "data" dataset and 5 dimension scales
- *-------------------------------------------------------------------------
- */
+ * create 10 datasets: 5 "data" dataset and 5 dimension scales
+ *-------------------------------------------------------------------------
+ */
/* create a group */
- if((gid = H5Gcreate2(fid, "grp", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if ((gid = H5Gcreate2(fid, "grp", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
/* create the data space for the dataset */
- if((sid = H5Screate_simple(rank,dims,NULL)) < 0)
+ if ((sid = H5Screate_simple(rank, dims, NULL)) < 0)
goto out;
- for(i = 0; i < 5; i++) {
- HDsprintf(dname,"dset_%d",i);
- if((did = H5Dcreate2(gid, dname, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ for (i = 0; i < 5; i++) {
+ HDsprintf(dname, "dset_%d", i);
+ if ((did = H5Dcreate2(gid, dname, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
- HDsprintf(sname,"ds_%d",i);
- if((dsid = H5Dcreate2(gid, sname, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ HDsprintf(sname, "ds_%d", i);
+ if ((dsid = H5Dcreate2(gid, sname, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
- if(H5DSset_scale(dsid,"scale") < 0)
+ if (H5DSset_scale(dsid, "scale") < 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
/*-------------------------------------------------------------------------
- * attach for DIM 0
- *-------------------------------------------------------------------------
- */
+ * attach for DIM 0
+ *-------------------------------------------------------------------------
+ */
- for(i = 0; i < 5; i++) {
+ for (i = 0; i < 5; i++) {
HDsprintf(dname, "dset_%d", i);
- if((did = H5Dopen2(gid, dname, H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(gid, dname, H5P_DEFAULT)) < 0)
goto out;
- for(j = 0; j < 5; j++) {
+ for (j = 0; j < 5; j++) {
HDsprintf(sname, "ds_%d", j);
- if((dsid = H5Dopen2(gid, sname, H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(gid, sname, H5P_DEFAULT)) < 0)
goto out;
- if(H5DSattach_scale(did, dsid, DIM0) < 0)
+ if (H5DSattach_scale(did, dsid, DIM0) < 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
}
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
/*-------------------------------------------------------------------------
- * dettach for DIM0
- *-------------------------------------------------------------------------
- */
+ * dettach for DIM0
+ *-------------------------------------------------------------------------
+ */
- for(i = 0; i < 5; i++) {
+ for (i = 0; i < 5; i++) {
HDsprintf(dname, "dset_%d", i);
- if((did = H5Dopen2(gid, dname, H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(gid, dname, H5P_DEFAULT)) < 0)
goto out;
- for(j = 0; j < 5; j++) {
+ for (j = 0; j < 5; j++) {
HDsprintf(sname, "ds_%d", j);
- if((dsid = H5Dopen2(gid, sname, H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(gid, sname, H5P_DEFAULT)) < 0)
goto out;
- if(H5DSdetach_scale(did, dsid, DIM0) < 0)
+ if (H5DSdetach_scale(did, dsid, DIM0) < 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
}
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
-
/*-------------------------------------------------------------------------
- * attach again for DIM0
- *-------------------------------------------------------------------------
- */
+ * attach again for DIM0
+ *-------------------------------------------------------------------------
+ */
- for(i=0; i<5; i++) {
- HDsprintf(dname,"dset_%d",i);
- if((did = H5Dopen2(gid,dname, H5P_DEFAULT)) < 0)
+ for (i = 0; i < 5; i++) {
+ HDsprintf(dname, "dset_%d", i);
+ if ((did = H5Dopen2(gid, dname, H5P_DEFAULT)) < 0)
goto out;
- for(j=0; j<5; j++) {
- HDsprintf(sname,"ds_%d",j);
- if((dsid = H5Dopen2(gid,sname, H5P_DEFAULT)) < 0)
+ for (j = 0; j < 5; j++) {
+ HDsprintf(sname, "ds_%d", j);
+ if ((dsid = H5Dopen2(gid, sname, H5P_DEFAULT)) < 0)
goto out;
- if(H5DSattach_scale(did,dsid,DIM0) < 0)
+ if (H5DSattach_scale(did, dsid, DIM0) < 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
}
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
}
/* close */
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
goto out;
- if(H5Gclose(gid) < 0)
+ if (H5Gclose(gid) < 0)
goto out;
-
-
/*-------------------------------------------------------------------------
- * create a dataset and attach only to 1 dimension
- *-------------------------------------------------------------------------
- */
+ * create a dataset and attach only to 1 dimension
+ *-------------------------------------------------------------------------
+ */
/* make a dataset */
- if(H5LTmake_dataset_int(fid,"dset_e",rank,dims,NULL) < 0)
+ if (H5LTmake_dataset_int(fid, "dset_e", rank, dims, NULL) < 0)
goto out;
/* make a scale */
- if(H5LTmake_dataset_int(fid,"ds_e_1",rankds,s1_dim,NULL) < 0)
+ if (H5LTmake_dataset_int(fid, "ds_e_1", rankds, s1_dim, NULL) < 0)
goto out;
/* attach the DS to dimension 1 */
- if((did = H5Dopen2(fid,"dset_e", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_e", H5P_DEFAULT)) < 0)
goto out;
- if((dsid = H5Dopen2(fid,"ds_e_1", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_e_1", H5P_DEFAULT)) < 0)
goto out;
- if(H5DSattach_scale(did,dsid,DIM1) < 0)
+ if (H5DSattach_scale(did, dsid, DIM1) < 0)
goto out;
- if(H5DSis_attached(did,dsid,DIM1)<=0)
+ if (H5DSis_attached(did, dsid, DIM1) <= 0)
goto out;
-
/* try to detach all dimensions. for dimensions 0 and 2, it is an error */
- for(i=0; i<rank; i++) {
- if( i==1 ) {
- if(H5DSdetach_scale(did,dsid,(unsigned)i) < 0)
+ for (i = 0; i < rank; i++) {
+ if (i == 1) {
+ if (H5DSdetach_scale(did, dsid, (unsigned)i) < 0)
goto out;
}
else {
- if(H5DSdetach_scale(did,dsid,(unsigned)i)!=FAIL)
+ if (H5DSdetach_scale(did, dsid, (unsigned)i) != FAIL)
goto out;
}
}
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
PASSED();
-
-
/*-------------------------------------------------------------------------
- * H5DSset_label, H5DSget_label
- *-------------------------------------------------------------------------
- */
+ * H5DSset_label, H5DSget_label
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("set/get label");
- if((did = H5Dopen2(fid,"dset_a", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_a", H5P_DEFAULT)) < 0)
goto out;
/*-------------------------------------------------------------------------
- * set label
- *-------------------------------------------------------------------------
- */
+ * set label
+ *-------------------------------------------------------------------------
+ */
- if(H5DSset_label(did,DIM0,DIM0_LABEL) < 0)
+ if (H5DSset_label(did, DIM0, DIM0_LABEL) < 0)
goto out;
/* check getting a label which does not exist */
- if(H5DSget_label(did,DIM1,dim1_label,sizeof(dim1_label)) != 0)
+ if (H5DSget_label(did, DIM1, dim1_label, sizeof(dim1_label)) != 0)
goto out;
- if(H5DSset_label(did,DIM1,DIM1_LABEL) < 0)
+ if (H5DSset_label(did, DIM1, DIM1_LABEL) < 0)
goto out;
/*-------------------------------------------------------------------------
- * get the scale name using a static buffer
- *-------------------------------------------------------------------------
- */
+ * get the scale name using a static buffer
+ *-------------------------------------------------------------------------
+ */
- if(H5DSget_label(did,DIM0,dim0_label,sizeof(dim0_label)) < 0)
+ if (H5DSget_label(did, DIM0, dim0_label, sizeof(dim0_label)) < 0)
goto out;
- if(H5DSget_label(did,DIM1,dim1_label,sizeof(dim1_label)) < 0)
+ if (H5DSget_label(did, DIM1, dim1_label, sizeof(dim1_label)) < 0)
goto out;
- if(HDstrncmp(DIM0_LABEL,dim0_label,sizeof(dim0_label))!=0)
+ if (HDstrncmp(DIM0_LABEL, dim0_label, sizeof(dim0_label)) != 0)
goto out;
- if(HDstrncmp(DIM1_LABEL,dim1_label,sizeof(dim1_label))!=0)
+ if (HDstrncmp(DIM1_LABEL, dim1_label, sizeof(dim1_label)) != 0)
goto out;
/*-------------------------------------------------------------------------
- * get the scale name using a dynamic buffer
- *-------------------------------------------------------------------------
- */
+ * get the scale name using a dynamic buffer
+ *-------------------------------------------------------------------------
+ */
- if((dim0_label_size=H5DSget_label(did,DIM0,NULL,(size_t)0)) < 0)
+ if ((dim0_label_size = H5DSget_label(did, DIM0, NULL, (size_t)0)) < 0)
goto out;
- if((dim1_label_size=H5DSget_label(did,DIM1,NULL,(size_t)0)) < 0)
+ if ((dim1_label_size = H5DSget_label(did, DIM1, NULL, (size_t)0)) < 0)
goto out;
/* allocate */
- dim0_labeld = (char*)HDmalloc((size_t)dim0_label_size * sizeof (char));
- dim1_labeld = (char*)HDmalloc((size_t)dim1_label_size * sizeof (char));
- if( dim0_labeld==NULL || dim1_labeld==NULL)
+ dim0_labeld = (char *)HDmalloc((size_t)dim0_label_size * sizeof(char));
+ dim1_labeld = (char *)HDmalloc((size_t)dim1_label_size * sizeof(char));
+ if (dim0_labeld == NULL || dim1_labeld == NULL)
goto out;
- if(H5DSget_label(did,DIM0,dim0_labeld,(size_t)dim0_label_size) < 0)
+ if (H5DSget_label(did, DIM0, dim0_labeld, (size_t)dim0_label_size) < 0)
goto out;
- if(H5DSget_label(did,DIM1,dim1_labeld,(size_t)dim1_label_size) < 0)
+ if (H5DSget_label(did, DIM1, dim1_labeld, (size_t)dim1_label_size) < 0)
goto out;
- if(HDstrncmp(DIM0_LABEL,dim0_labeld,(size_t)(dim0_label_size-1))!=0)
+ if (HDstrncmp(DIM0_LABEL, dim0_labeld, (size_t)(dim0_label_size - 1)) != 0)
goto out;
- if(HDstrncmp(DIM1_LABEL,dim1_labeld,(size_t)(dim1_label_size-1))!=0)
+ if (HDstrncmp(DIM1_LABEL, dim1_labeld, (size_t)(dim1_label_size - 1)) != 0)
goto out;
- if(dim0_labeld) {
+ if (dim0_labeld) {
HDfree(dim0_labeld);
- dim0_labeld=NULL;
+ dim0_labeld = NULL;
}
- if(dim1_labeld) {
+ if (dim1_labeld) {
HDfree(dim1_labeld);
- dim1_labeld=NULL;
+ dim1_labeld = NULL;
}
-
/*-------------------------------------------------------------------------
- * get the label using a static buffer smaller than the string length
- *-------------------------------------------------------------------------
- */
+ * get the label using a static buffer smaller than the string length
+ *-------------------------------------------------------------------------
+ */
- if(H5DSget_label(did,DIM0,dim0_labels,sizeof(dim0_labels)) < 0)
+ if (H5DSget_label(did, DIM0, dim0_labels, sizeof(dim0_labels)) < 0)
goto out;
- if(H5DSget_label(did,DIM1,dim1_labels,sizeof(dim1_labels)) < 0)
+ if (H5DSget_label(did, DIM1, dim1_labels, sizeof(dim1_labels)) < 0)
goto out;
- if(HDstrncmp(DIM0_LABEL,dim0_labels,sizeof(dim0_labels)-1)!=0)
+ if (HDstrncmp(DIM0_LABEL, dim0_labels, sizeof(dim0_labels) - 1) != 0)
goto out;
- if(HDstrncmp(DIM1_LABEL,dim1_labels,sizeof(dim1_labels)-1)!=0)
+ if (HDstrncmp(DIM1_LABEL, dim1_labels, sizeof(dim1_labels) - 1) != 0)
goto out;
- if(H5Dclose(did))
+ if (H5Dclose(did))
goto out;
PASSED();
/*-------------------------------------------------------------------------
- * H5DSget_scale_name, H5DSget_scale_name
- *-------------------------------------------------------------------------
- */
-
+ * H5DSget_scale_name, H5DSget_scale_name
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("set scale/get scale name");
- if((dsid = H5Dopen2(fid,"ds_a_1", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_a_1", H5P_DEFAULT)) < 0)
goto out;
- if(H5DSset_scale(dsid,"Latitude set 0") < 0)
+ if (H5DSset_scale(dsid, "Latitude set 0") < 0)
goto out;
/* verify that DS_1_NAME is a dimension scale dataset */
- if((H5DSis_scale(dsid)) == 0)
+ if ((H5DSis_scale(dsid)) == 0)
goto out;
/*-------------------------------------------------------------------------
- * get the scale name using a dynamic buffer
- *-------------------------------------------------------------------------
- */
+ * get the scale name using a dynamic buffer
+ *-------------------------------------------------------------------------
+ */
/* get the length of the scale name (pass NULL in name) */
- if((name_len=H5DSget_scale_name(dsid,NULL,(size_t)0)) < 0)
+ if ((name_len = H5DSget_scale_name(dsid, NULL, (size_t)0)) < 0)
goto out;
/* allocate a buffer */
- name_out = (char*)HDmalloc(((size_t)name_len+1) * sizeof (char));
- if(name_out == NULL)
+ name_out = (char *)HDmalloc(((size_t)name_len + 1) * sizeof(char));
+ if (name_out == NULL)
goto out;
/* get the scale name using this buffer */
- if(H5DSget_scale_name(dsid, name_out, (size_t)name_len+1) < 0)
+ if (H5DSget_scale_name(dsid, name_out, (size_t)name_len + 1) < 0)
goto out;
- if(HDstrncmp("Latitude set 0",name_out, (size_t)name_len)!=0)
+ if (HDstrncmp("Latitude set 0", name_out, (size_t)name_len) != 0)
goto out;
- if(name_out) {
+ if (name_out) {
HDfree(name_out);
- name_out=NULL;
+ name_out = NULL;
}
/*-------------------------------------------------------------------------
- * get the scale name using a static buffer
- *-------------------------------------------------------------------------
- */
+ * get the scale name using a static buffer
+ *-------------------------------------------------------------------------
+ */
/* get the scale name using this buffer */
- if(H5DSget_scale_name(dsid, sname, sizeof(sname)) < 0)
+ if (H5DSget_scale_name(dsid, sname, sizeof(sname)) < 0)
goto out;
- if(HDstrncmp("Latitude set 0", sname, sizeof(sname))!=0)
+ if (HDstrncmp("Latitude set 0", sname, sizeof(sname)) != 0)
goto out;
/*-------------------------------------------------------------------------
- * get the scale name using a static buffer smaller than the string length
- *-------------------------------------------------------------------------
- */
+ * get the scale name using a static buffer smaller than the string length
+ *-------------------------------------------------------------------------
+ */
/* get the scale name using this buffer */
- if(H5DSget_scale_name(dsid, snames, sizeof (snames)) < 0)
+ if (H5DSget_scale_name(dsid, snames, sizeof(snames)) < 0)
goto out;
- if(HDstrncmp("Latitude set 0",snames,sizeof(snames)-1)!=0)
+ if (HDstrncmp("Latitude set 0", snames, sizeof(snames) - 1) != 0)
goto out;
- if(H5Dclose(dsid))
+ if (H5Dclose(dsid))
goto out;
/*-------------------------------------------------------------------------
- * add scale names
- *-------------------------------------------------------------------------
- */
+ * add scale names
+ *-------------------------------------------------------------------------
+ */
- if((dsid = H5Dopen2(fid,"ds_a_11", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_a_11", H5P_DEFAULT)) < 0)
goto out;
- if(H5DSset_scale(dsid,"Latitude set 1") < 0)
+ if (H5DSset_scale(dsid, "Latitude set 1") < 0)
goto out;
- if(H5Dclose(dsid))
+ if (H5Dclose(dsid))
goto out;
- if((dsid = H5Dopen2(fid,"ds_a_2", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_a_2", H5P_DEFAULT)) < 0)
goto out;
- if(H5DSset_scale(dsid,"Longitude set 0") < 0)
+ if (H5DSset_scale(dsid, "Longitude set 0") < 0)
goto out;
- if(H5Dclose(dsid))
+ if (H5Dclose(dsid))
goto out;
- if((dsid = H5Dopen2(fid,"ds_a_21", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_a_21", H5P_DEFAULT)) < 0)
goto out;
- if(H5DSset_scale(dsid,"Longitude set 1") < 0)
+ if (H5DSset_scale(dsid, "Longitude set 1") < 0)
goto out;
- if(H5Dclose(dsid))
+ if (H5Dclose(dsid))
goto out;
- if((dsid = H5Dopen2(fid,"ds_a_22", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_a_22", H5P_DEFAULT)) < 0)
goto out;
- if(H5DSset_scale(dsid,"Longitude set 2") < 0)
+ if (H5DSset_scale(dsid, "Longitude set 2") < 0)
goto out;
- if(H5Dclose(dsid))
+ if (H5Dclose(dsid))
goto out;
PASSED();
/*-------------------------------------------------------------------------
- * H5DSiterate_scales
- *-------------------------------------------------------------------------
- */
-
+ * H5DSiterate_scales
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("iterate scales");
-
/*-------------------------------------------------------------------------
- * test 6: test iterate scales with a function verify_scale
- *-------------------------------------------------------------------------
- */
+ * test 6: test iterate scales with a function verify_scale
+ *-------------------------------------------------------------------------
+ */
/* get the dataset id for "dset_a" */
- if((did = H5Dopen2(fid,"dset_a", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_a", H5P_DEFAULT)) < 0)
goto out;
dim = 0;
/* iterate trough the 1st dimension of "dset_a" and verify that its DS is valid */
- if(H5DSiterate_scales(did,dim,NULL,verify_scale,NULL) < 0)
+ if (H5DSiterate_scales(did, dim, NULL, verify_scale, NULL) < 0)
goto out;
/* iterate trough the 2nd dimension of "dset_a" and verify that its DS is valid
start at DS index 2 */
- dim = 1;
+ dim = 1;
scale_idx = 2;
- if(H5DSiterate_scales(did,dim,&scale_idx,verify_scale,NULL) < 0)
+ if (H5DSiterate_scales(did, dim, &scale_idx, verify_scale, NULL) < 0)
goto out;
/* close dataset ID of "dset_a" */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
-
/*-------------------------------------------------------------------------
- * test iterate scales with a function read_scale
- *-------------------------------------------------------------------------
- */
-
+ * test iterate scales with a function read_scale
+ *-------------------------------------------------------------------------
+ */
/* get the dataset id for "dset_a" */
- if((did = H5Dopen2(fid,"dset_a", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_a", H5P_DEFAULT)) < 0)
goto out;
dim = 0;
/* iterate trough the 1st dimension of "dset_a" and read the DS */
- if(H5DSiterate_scales(did,dim,NULL,read_scale,s1_wbuf) < 0)
+ if (H5DSiterate_scales(did, dim, NULL, read_scale, s1_wbuf) < 0)
goto out;
/* iterate trough the 2nd dimension of "dset_a" and read the DS
start at DS index 2 */
- dim = 1;
+ dim = 1;
scale_idx = 2;
- if(H5DSiterate_scales(did, dim, &scale_idx, read_scale, s22_wbuf) < 0)
+ if (H5DSiterate_scales(did, dim, &scale_idx, read_scale, s22_wbuf) < 0)
goto out;
/* close dataset ID of "dset_a" */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
-
/*-------------------------------------------------------------------------
- * test iterate scales with a function match_dim_scale
- *-------------------------------------------------------------------------
- */
+ * test iterate scales with a function match_dim_scale
+ *-------------------------------------------------------------------------
+ */
/* get the dataset id for "dset_a" */
- if((did = H5Dopen2(fid,"dset_a", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_a", H5P_DEFAULT)) < 0)
goto out;
/* get dataset space */
- if((sid = H5Dget_space(did)) < 0)
+ if ((sid = H5Dget_space(did)) < 0)
goto out;
/* get rank */
- if((rank = H5Sget_simple_extent_ndims(sid)) < 0)
+ if ((rank = H5Sget_simple_extent_ndims(sid)) < 0)
goto out;
/* get dimensions of dataset */
- if(H5Sget_simple_extent_dims(sid,dims,NULL) < 0)
+ if (H5Sget_simple_extent_dims(sid, dims, NULL) < 0)
goto out;
{
- int match_size; /* does this scale size matches the dataset DIM size */
- int idx = 0; /* scale index to start iterating, on return, index where iterator stoped */
+ int match_size; /* does this scale size matches the dataset DIM size */
+ int idx = 0; /* scale index to start iterating, on return, index where iterator stoped */
/* iterate trough all the dimensions */
- for(dim=0; dim<(unsigned)rank; dim++) {
- if((match_size=H5DSiterate_scales(did,dim,&idx,match_dim_scale,NULL)) < 0)
+ for (dim = 0; dim < (unsigned)rank; dim++) {
+ if ((match_size = H5DSiterate_scales(did, dim, &idx, match_dim_scale, NULL)) < 0)
goto out;
/* "dset_a" was defined with all dimension scales size matching the size of its dimensions */
- if(match_size==0)
+ if (match_size == 0)
goto out;
/* both DS_1_NAME and DS_2_NAME are the on the first index */
- if(idx!=0)
+ if (idx != 0)
goto out;
}
}
-
/* close */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
goto out;
-
/*-------------------------------------------------------------------------
- * test iterate scales with a function match_dim_scale
- *-------------------------------------------------------------------------
- */
+ * test iterate scales with a function match_dim_scale
+ *-------------------------------------------------------------------------
+ */
/*-------------------------------------------------------------------------
- * create 3 datasets: 1 "data" dataset and dimension scales (some are empty)
- *-------------------------------------------------------------------------
- */
- if(H5LTmake_dataset_int(fid, "dset_f", rank, dims, buf) < 0)
+ * create 3 datasets: 1 "data" dataset and dimension scales (some are empty)
+ *-------------------------------------------------------------------------
+ */
+ if (H5LTmake_dataset_int(fid, "dset_f", rank, dims, buf) < 0)
goto out;
- if(H5LTmake_dataset_int(fid,"ds_f_1",rankds,s1_dim,NULL) < 0)
+ if (H5LTmake_dataset_int(fid, "ds_f_1", rankds, s1_dim, NULL) < 0)
goto out;
- if(H5LTmake_dataset_int(fid, "ds_f_11", rankds, s1_dim, s1_wbuf) < 0)
+ if (H5LTmake_dataset_int(fid, "ds_f_11", rankds, s1_dim, s1_wbuf) < 0)
goto out;
- if(H5LTmake_dataset_int(fid,"ds_f_2",rankds,s2_dim,NULL) < 0)
+ if (H5LTmake_dataset_int(fid, "ds_f_2", rankds, s2_dim, NULL) < 0)
goto out;
/*-------------------------------------------------------------------------
- * attach them
- *-------------------------------------------------------------------------
- */
- if((did = H5Dopen2(fid,"dset_f", H5P_DEFAULT)) < 0)
+ * attach them
+ *-------------------------------------------------------------------------
+ */
+ if ((did = H5Dopen2(fid, "dset_f", H5P_DEFAULT)) < 0)
goto out;
- if((dsid = H5Dopen2(fid,"ds_f_1", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_f_1", H5P_DEFAULT)) < 0)
goto out;
- if(H5DSattach_scale(did,dsid,DIM0) < 0)
+ if (H5DSattach_scale(did, dsid, DIM0) < 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if((dsid = H5Dopen2(fid,"ds_f_11", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_f_11", H5P_DEFAULT)) < 0)
goto out;
- if(H5DSattach_scale(did,dsid,DIM0) < 0)
+ if (H5DSattach_scale(did, dsid, DIM0) < 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if((dsid = H5Dopen2(fid,"ds_f_2", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_f_2", H5P_DEFAULT)) < 0)
goto out;
- if(H5DSattach_scale(did,dsid,DIM1) < 0)
+ if (H5DSattach_scale(did, dsid, DIM1) < 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
/*-------------------------------------------------------------------------
- * verify match
- *-------------------------------------------------------------------------
- */
+ * verify match
+ *-------------------------------------------------------------------------
+ */
/* get the dataset id for "dset_f" */
- if((did = H5Dopen2(fid,"dset_f", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_f", H5P_DEFAULT)) < 0)
goto out;
/* get dataset space */
- if((sid = H5Dget_space(did)) < 0)
+ if ((sid = H5Dget_space(did)) < 0)
goto out;
/* get rank */
- if((rank = H5Sget_simple_extent_ndims(sid)) < 0)
+ if ((rank = H5Sget_simple_extent_ndims(sid)) < 0)
goto out;
/* get dimensions of dataset */
- if(H5Sget_simple_extent_dims(sid,dims,NULL) < 0)
+ if (H5Sget_simple_extent_dims(sid, dims, NULL) < 0)
goto out;
{
int match_size; /* does this scale size matches the dataset DIM size */
int idx; /* scale index to start iterating, on return, index where iterator stoped */
/* iterate trough all the dimensions */
- for(dim=0; dim<(unsigned)rank; dim++) {
+ for (dim = 0; dim < (unsigned)rank; dim++) {
/* always start at 1st scale */
- idx=0;
+ idx = 0;
- if((match_size=H5DSiterate_scales(did,dim,&idx,match_dim_scale,NULL)) < 0)
+ if ((match_size = H5DSiterate_scales(did, dim, &idx, match_dim_scale, NULL)) < 0)
goto out;
/* "dset_e" was defined with :
dim 0: 2 scales, first is empty
dim 1: 1 scale, empty */
- switch(dim) {
- case 0: /* for DIM 0, we get a valid scale at IDX 1 */
- if(match_size!=1 && idx!=1)
- goto out;
- break;
- case 1: /* for DIM 1, we get no valid scales */
- if(match_size!=0 && idx!=0)
- goto out;
- break;
- default:
- HDassert(0);
- break;
- }/*switch*/
- }/*for*/
+ switch (dim) {
+ case 0: /* for DIM 0, we get a valid scale at IDX 1 */
+ if (match_size != 1 && idx != 1)
+ goto out;
+ break;
+ case 1: /* for DIM 1, we get no valid scales */
+ if (match_size != 0 && idx != 0)
+ goto out;
+ break;
+ default:
+ HDassert(0);
+ break;
+ } /*switch*/
+ } /*for*/
}
/* close */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
goto out;
PASSED();
-
/*-------------------------------------------------------------------------
- * end
- *-------------------------------------------------------------------------
- */
+ * end
+ *-------------------------------------------------------------------------
+ */
/* close */
H5Fclose(fid);
return 0;
- /* error zone */
- out:
+/* error zone */
+out:
H5E_BEGIN_TRY
{
H5Dclose(did);
@@ -3433,13 +3524,12 @@ static int test_simple(void)
H5Fclose(fid);
H5Sclose(sid);
H5Gclose(gid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-
-
/*-------------------------------------------------------------------------
* Function: verify_scale
*
@@ -3457,29 +3547,29 @@ static int test_simple(void)
*-------------------------------------------------------------------------
*/
-static herr_t verify_scale(hid_t dset, unsigned dim, hid_t scale_id, void *visitor_data)
+static herr_t
+verify_scale(hid_t dset, unsigned dim, hid_t scale_id, void *visitor_data)
{
/* define a default zero value for return. This will cause the iterator to continue */
int ret = 0;
/* unused */
- dset=dset;
- dim=dim;
- visitor_data=visitor_data;
+ dset = dset;
+ dim = dim;
+ visitor_data = visitor_data;
/* define a positive value for return value. This will cause the iterator to
immediately return that positive value, indicating short-circuit success
*/
/* the parameter DS dataset must be a valid DS dataset */
- if((H5DSis_scale(scale_id))==1) {
+ if ((H5DSis_scale(scale_id)) == 1) {
ret = 1;
}
return ret;
}
-
/*-------------------------------------------------------------------------
* Function: read_scale
*
@@ -3498,47 +3588,48 @@ static herr_t verify_scale(hid_t dset, unsigned dim, hid_t scale_id, void *visit
*-------------------------------------------------------------------------
*/
-static herr_t read_scale(hid_t dset, unsigned dim, hid_t scale_id, void *visitor_data)
+static herr_t
+read_scale(hid_t dset, unsigned dim, hid_t scale_id, void *visitor_data)
{
- int ret = 0; /* define a default zero value for return. This will cause the iterator to continue */
- hid_t sid = -1; /* space ID */
- hid_t tid = -1; /* file type ID */
+ int ret = 0; /* define a default zero value for return. This will cause the iterator to continue */
+ hid_t sid = -1; /* space ID */
+ hid_t tid = -1; /* file type ID */
hid_t mtid = -1; /* memory type ID */
hssize_t nelmts; /* number of data elements */
- char *buf=NULL; /* data buffer */
+ char * buf = NULL; /* data buffer */
size_t size;
int i;
- char *data = (char*) visitor_data;
+ char * data = (char *)visitor_data;
/* unused */
- dset=dset;
- dim=dim;
+ dset = dset;
+ dim = dim;
/* get space */
- if((sid = H5Dget_space(scale_id)) < 0)
+ if ((sid = H5Dget_space(scale_id)) < 0)
goto out;
/* get type */
- if((tid = H5Dget_type(scale_id)) < 0)
+ if ((tid = H5Dget_type(scale_id)) < 0)
goto out;
/* get size of the DS array */
- if((nelmts = H5Sget_simple_extent_npoints(sid)) < 0)
+ if ((nelmts = H5Sget_simple_extent_npoints(sid)) < 0)
goto out;
/* get type */
- if((mtid=H5Tget_native_type(tid,H5T_DIR_DEFAULT)) < 0)
+ if ((mtid = H5Tget_native_type(tid, H5T_DIR_DEFAULT)) < 0)
goto out;
/* get type size */
- if((size=H5Tget_size(mtid))==0)
+ if ((size = H5Tget_size(mtid)) == 0)
goto out;
- if(nelmts) {
- buf=(char *)HDmalloc(((size_t)nelmts*size));
- if(buf==NULL)
+ if (nelmts) {
+ buf = (char *)HDmalloc(((size_t)nelmts * size));
+ if (buf == NULL)
goto out;
- if(H5Dread(scale_id,mtid,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf) < 0)
+ if (H5Dread(scale_id, mtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
goto out;
- for(i=0; i<nelmts; i++) {
- if(buf[i] != data[i]) {
+ for (i = 0; i < nelmts; i++) {
+ if (buf[i] != data[i]) {
HDprintf("read and write buffers differ\n");
goto out;
}
@@ -3546,33 +3637,33 @@ static herr_t read_scale(hid_t dset, unsigned dim, hid_t scale_id, void *visitor
} /* if */
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
goto out;
- if(H5Tclose(tid) < 0)
+ if (H5Tclose(tid) < 0)
goto out;
- if(H5Tclose(mtid) < 0)
+ if (H5Tclose(mtid) < 0)
goto out;
- if(buf)
+ if (buf)
HDfree(buf);
-
return ret;
/* error zone */
out:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Sclose(sid);
H5Tclose(tid);
H5Tclose(mtid);
- if(buf) {
+ if (buf) {
HDfree(buf);
}
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return FAIL;
}
-
/*-------------------------------------------------------------------------
* Function: match_dim_scale
*
@@ -3590,71 +3681,70 @@ out:
*-------------------------------------------------------------------------
*/
-static herr_t match_dim_scale(hid_t did, unsigned dim, hid_t dsid, void *visitor_data)
+static herr_t
+match_dim_scale(hid_t did, unsigned dim, hid_t dsid, void *visitor_data)
{
- int ret = 0; /* define a default zero value for return. This will cause the iterator to continue */
- hid_t sid; /* space ID */
- hssize_t nelmts; /* size of a dimension scale array */
- hsize_t dims[H5S_MAX_RANK]; /* dimensions of dataset */
- hsize_t storage_size;
+ int ret = 0; /* define a default zero value for return. This will cause the iterator to continue */
+ hid_t sid; /* space ID */
+ hssize_t nelmts; /* size of a dimension scale array */
+ hsize_t dims[H5S_MAX_RANK]; /* dimensions of dataset */
+ hsize_t storage_size;
/* Stop compiler from whining about "unused parameters" */
visitor_data = visitor_data;
/*-------------------------------------------------------------------------
- * get DID (dataset) space info
- *-------------------------------------------------------------------------
- */
+ * get DID (dataset) space info
+ *-------------------------------------------------------------------------
+ */
/* get dataset space */
- if((sid = H5Dget_space(did)) < 0)
+ if ((sid = H5Dget_space(did)) < 0)
goto out;
/* get dimensions of dataset */
- if(H5Sget_simple_extent_dims(sid,dims,NULL) < 0)
+ if (H5Sget_simple_extent_dims(sid, dims, NULL) < 0)
goto out;
/* close the dataspace id */
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
goto out;
/*-------------------------------------------------------------------------
- * get DSID (scale) space info
- *-------------------------------------------------------------------------
- */
+ * get DSID (scale) space info
+ *-------------------------------------------------------------------------
+ */
/* get the space for the scale */
- if((sid = H5Dget_space(dsid)) < 0)
+ if ((sid = H5Dget_space(dsid)) < 0)
goto out;
/* get size of the DS array */
- if((nelmts = H5Sget_simple_extent_npoints(sid)) < 0)
+ if ((nelmts = H5Sget_simple_extent_npoints(sid)) < 0)
goto out;
/* close */
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
goto out;
/* the size of the DS array must match the dimension of the dataset */
- if(nelmts == (hssize_t)dims[dim])
+ if (nelmts == (hssize_t)dims[dim])
ret = 1;
/* if the scale is empty assume it cannot be used */
- storage_size=H5Dget_storage_size(dsid);
+ storage_size = H5Dget_storage_size(dsid);
- if(storage_size==0)
+ if (storage_size == 0)
ret = 0;
return ret;
out:
- H5E_BEGIN_TRY {
- H5Sclose(sid);
- } H5E_END_TRY;
+ H5E_BEGIN_TRY { H5Sclose(sid); }
+ H5E_END_TRY;
return FAIL;
}
-
/*-------------------------------------------------------------------------
* Function: op_continue
*
@@ -3672,14 +3762,15 @@ out:
*-------------------------------------------------------------------------
*/
-static herr_t op_continue(hid_t dset, unsigned dim, hid_t scale_id, void *visitor_data)
+static herr_t
+op_continue(hid_t dset, unsigned dim, hid_t scale_id, void *visitor_data)
{
/* Stop compiler from whining about "unused parameters" */
- dset = dset;
- dim = dim;
+ dset = dset;
+ dim = dim;
scale_id = scale_id;
- if ( visitor_data != NULL ) {
+ if (visitor_data != NULL) {
(*(int *)visitor_data)++;
}
@@ -3704,14 +3795,15 @@ static herr_t op_continue(hid_t dset, unsigned dim, hid_t scale_id, void *visito
*-------------------------------------------------------------------------
*/
-static herr_t op_stop(hid_t dset, unsigned dim, hid_t scale_id, void *visitor_data)
+static herr_t
+op_stop(hid_t dset, unsigned dim, hid_t scale_id, void *visitor_data)
{
/* Stop compiler from whining about "unused parameters" */
- dset = dset;
- dim = dim;
+ dset = dset;
+ dim = dim;
scale_id = scale_id;
- if ( visitor_data != NULL ) {
+ if (visitor_data != NULL) {
(*(int *)visitor_data)++;
}
@@ -3724,360 +3816,356 @@ static herr_t op_stop(hid_t dset, unsigned dim, hid_t scale_id, void *visitor_da
*-------------------------------------------------------------------------
*/
-static int test_errors(void)
+static int
+test_errors(void)
{
- hid_t fid; /* file ID */
- int rank = RANK; /* rank of data dataset */
- int rankds = 1; /* rank of DS dataset */
- hsize_t dims[RANK] = {DIM1_SIZE,DIM2_SIZE}; /* size of data dataset */
- hsize_t s1_dim[1] = {DIM1_SIZE}; /* size of DS 1 dataset */
- hid_t did = -1; /* dataset ID */
- hid_t dsid = -1; /* scale ID */
- hid_t gid = -1; /* group ID */
- hid_t sid = -1; /* space ID */
- hid_t sidds = -1; /* space ID */
- hsize_t pal_dims[] = {9,3};
+ hid_t fid; /* file ID */
+ int rank = RANK; /* rank of data dataset */
+ int rankds = 1; /* rank of DS dataset */
+ hsize_t dims[RANK] = {DIM1_SIZE, DIM2_SIZE}; /* size of data dataset */
+ hsize_t s1_dim[1] = {DIM1_SIZE}; /* size of DS 1 dataset */
+ hid_t did = -1; /* dataset ID */
+ hid_t dsid = -1; /* scale ID */
+ hid_t gid = -1; /* group ID */
+ hid_t sid = -1; /* space ID */
+ hid_t sidds = -1; /* space ID */
+ hsize_t pal_dims[] = {9, 3};
HDprintf("Testing error conditions\n");
/*-------------------------------------------------------------------------
- * create a file, spaces, dataset and group ids
- *-------------------------------------------------------------------------
- */
+ * create a file, spaces, dataset and group ids
+ *-------------------------------------------------------------------------
+ */
/* create a file using default properties */
- if((fid = H5Fcreate(FILE2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if ((fid = H5Fcreate(FILE2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
/* create a group */
- if((gid = H5Gcreate2(fid, "grp", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if ((gid = H5Gcreate2(fid, "grp", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
/* create the data space for the dataset */
- if((sid = H5Screate_simple(rank, dims, NULL)) < 0)
+ if ((sid = H5Screate_simple(rank, dims, NULL)) < 0)
goto out;
/* create the data space for the scale */
- if((sidds = H5Screate_simple(rankds, s1_dim, NULL)) < 0)
+ if ((sidds = H5Screate_simple(rankds, s1_dim, NULL)) < 0)
goto out;
/* create a dataset */
- if((did = H5Dcreate2(fid, "dset_a", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if ((did = H5Dcreate2(fid, "dset_a", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
/* create a dataset for the scale */
- if((dsid = H5Dcreate2(fid, "ds_a", H5T_NATIVE_INT, sidds, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dcreate2(fid, "ds_a", H5T_NATIVE_INT, sidds, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
/*-------------------------------------------------------------------------
- * attempt to attach a dataset to itself, it should fail
- *-------------------------------------------------------------------------
- */
+ * attempt to attach a dataset to itself, it should fail
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("attach a dataset to itself");
- if(H5DSattach_scale(did, did, 0) == SUCCEED)
+ if (H5DSattach_scale(did, did, 0) == SUCCEED)
goto out;
PASSED();
/*-------------------------------------------------------------------------
- * attempt to attach a group with a dataset, it should fail
- *-------------------------------------------------------------------------
- */
+ * attempt to attach a group with a dataset, it should fail
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("attach a group with a dataset");
- if(H5DSattach_scale(gid,dsid,0)==SUCCEED)
+ if (H5DSattach_scale(gid, dsid, 0) == SUCCEED)
goto out;
PASSED();
/*-------------------------------------------------------------------------
- * attempt to attach a dataset with a group, it should fail
- *-------------------------------------------------------------------------
- */
+ * attempt to attach a dataset with a group, it should fail
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("attach a dataset with a group");
- if(H5DSattach_scale(did,gid,0)==SUCCEED)
+ if (H5DSattach_scale(did, gid, 0) == SUCCEED)
goto out;
PASSED();
/*-------------------------------------------------------------------------
- * attempt to set scale for a group, it should fail
- *-------------------------------------------------------------------------
- */
+ * attempt to set scale for a group, it should fail
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("set scale for a group");
- if(H5DSset_scale(gid,"scale 1")==SUCCEED)
+ if (H5DSset_scale(gid, "scale 1") == SUCCEED)
goto out;
PASSED();
/*-------------------------------------------------------------------------
- * close IDs for this set
- *-------------------------------------------------------------------------
- */
+ * close IDs for this set
+ *-------------------------------------------------------------------------
+ */
/* close */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
goto out;
- if(H5Sclose(sidds) < 0)
+ if (H5Sclose(sidds) < 0)
goto out;
- if(H5Gclose(gid) < 0)
+ if (H5Gclose(gid) < 0)
goto out;
-
/*-------------------------------------------------------------------------
- * try to attach a scale that has scales
- *-------------------------------------------------------------------------
- */
+ * try to attach a scale that has scales
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("attach a scale that has scales");
/* create the data space for the scale */
- if((sidds = H5Screate_simple(rankds, s1_dim, NULL)) < 0)
+ if ((sidds = H5Screate_simple(rankds, s1_dim, NULL)) < 0)
goto out;
/* create a dataset "ds_b" for the scale */
- if((dsid = H5Dcreate2(fid, "ds_b", H5T_NATIVE_INT, sidds, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dcreate2(fid, "ds_b", H5T_NATIVE_INT, sidds, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
/* open the previous written "ds_a" */
- if((did = H5Dopen2(fid,"ds_a", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "ds_a", H5P_DEFAULT)) < 0)
goto out;
/* attach "ds_b" to "ds_a", valid */
- if(H5DSattach_scale(did, dsid, 0) < 0)
+ if (H5DSattach_scale(did, dsid, 0) < 0)
goto out;
/* close */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
- if(H5Sclose(sidds) < 0)
+ if (H5Sclose(sidds) < 0)
goto out;
/* open the previous written "dset_a" */
- if((did = H5Dopen2(fid, "dset_a", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_a", H5P_DEFAULT)) < 0)
goto out;
/* open the previous written "ds_a" */
- if((dsid = H5Dopen2(fid, "ds_a", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_a", H5P_DEFAULT)) < 0)
goto out;
/* try to attach "ds_a" to "dset_a", not valid */
- if(H5DSattach_scale(did,dsid,0)==SUCCEED)
+ if (H5DSattach_scale(did, dsid, 0) == SUCCEED)
goto out;
/* close */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
/* open the previous written "ds_a" */
- if((did = H5Dopen2(fid,"ds_a", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "ds_a", H5P_DEFAULT)) < 0)
goto out;
/* open the previous written "ds_b" */
- if((dsid = H5Dopen2(fid,"ds_b", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_b", H5P_DEFAULT)) < 0)
goto out;
/* detach "ds_b" to "ds_a" */
- if(H5DSdetach_scale(did,dsid,0) < 0)
+ if (H5DSdetach_scale(did, dsid, 0) < 0)
goto out;
/* close */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
PASSED();
/*-------------------------------------------------------------------------
- * try to attach a dataset that is a scale
- *-------------------------------------------------------------------------
- */
+ * try to attach a dataset that is a scale
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("attach to a dataset that is a scale");
/* open the previous written "ds_b", that is a scale */
- if((dsid = H5Dopen2(fid,"ds_b", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_b", H5P_DEFAULT)) < 0)
goto out;
/* open the previous written "ds_a" */
- if((did = H5Dopen2(fid,"ds_a", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "ds_a", H5P_DEFAULT)) < 0)
goto out;
/* try to attach "ds_a" to "ds_b", not valid */
- if(H5DSattach_scale(dsid,did,0)==SUCCEED)
+ if (H5DSattach_scale(dsid, did, 0) == SUCCEED)
goto out;
/* close */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
PASSED();
/*-------------------------------------------------------------------------
- * try to attach a scale to an image, pallete or table
- *-------------------------------------------------------------------------
- */
+ * try to attach a scale to an image, pallete or table
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("attach to a dataset that is a reserved class dataset");
/* make an image */
- if(H5IMmake_image_8bit(fid,"image",(hsize_t)100,(hsize_t)50,NULL) < 0)
+ if (H5IMmake_image_8bit(fid, "image", (hsize_t)100, (hsize_t)50, NULL) < 0)
goto out;
/* make a palette */
- if(H5IMmake_palette(fid,"pallete",pal_dims,NULL) < 0)
+ if (H5IMmake_palette(fid, "pallete", pal_dims, NULL) < 0)
goto out;
/* open the previous written "ds_b" */
- if((dsid = H5Dopen2(fid,"ds_b", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_b", H5P_DEFAULT)) < 0)
goto out;
/* open the image dataset */
- if((did = H5Dopen2(fid,"image", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "image", H5P_DEFAULT)) < 0)
goto out;
/* try to attach "ds_a" to the image, not valid */
- if(H5DSattach_scale(did,dsid,0)==SUCCEED)
+ if (H5DSattach_scale(did, dsid, 0) == SUCCEED)
goto out;
/* close */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
PASSED();
/*-------------------------------------------------------------------------
- * is scale
- *-------------------------------------------------------------------------
- */
+ * is scale
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("is scale");
/* open a non scale dataset */
- if((did = H5Dopen2(fid,"dset_a", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_a", H5P_DEFAULT)) < 0)
goto out;
/* verify that it is not a dimension scale dataset */
- if((H5DSis_scale(did))==1)
+ if ((H5DSis_scale(did)) == 1)
goto out;
/* close */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
/* open the group. */
- if((gid = H5Gopen2(fid, "grp", H5P_DEFAULT)) < 0)
+ if ((gid = H5Gopen2(fid, "grp", H5P_DEFAULT)) < 0)
goto out;
/* verify that it is not a dimension scale dataset */
- if((H5DSis_scale(gid))==1)
+ if ((H5DSis_scale(gid)) == 1)
goto out;
/* close */
- if(H5Gclose(gid) < 0)
+ if (H5Gclose(gid) < 0)
goto out;
PASSED();
-
/*-------------------------------------------------------------------------
- * detach
- *-------------------------------------------------------------------------
- */
+ * detach
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("detach scale from dataset it is not attached to");
/* open the previous written "ds_a" */
- if((dsid = H5Dopen2(fid,"ds_a", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_a", H5P_DEFAULT)) < 0)
goto out;
/* open the previous written "dset_a" */
- if((did = H5Dopen2(fid,"dset_a", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_a", H5P_DEFAULT)) < 0)
goto out;
/* try to detach "ds_a" from "dset_a" */
- if(H5DSdetach_scale(did,dsid,0)==SUCCEED)
+ if (H5DSdetach_scale(did, dsid, 0) == SUCCEED)
goto out;
/* close */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
PASSED();
-
/*-------------------------------------------------------------------------
- * detach
- *-------------------------------------------------------------------------
- */
+ * detach
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("detach scale from group");
/* open the previous written "ds_a" */
- if((dsid = H5Dopen2(fid,"ds_a", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_a", H5P_DEFAULT)) < 0)
goto out;
/* open the group. */
- if((gid = H5Gopen2(fid, "grp", H5P_DEFAULT)) < 0)
+ if ((gid = H5Gopen2(fid, "grp", H5P_DEFAULT)) < 0)
goto out;
/* try to detach "ds_a" from "grp" */
- if(H5DSdetach_scale(gid,dsid,0)==SUCCEED)
+ if (H5DSdetach_scale(gid, dsid, 0) == SUCCEED)
goto out;
/* close */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if(H5Gclose(gid) < 0)
+ if (H5Gclose(gid) < 0)
goto out;
PASSED();
-
/*-------------------------------------------------------------------------
- * detach
- *-------------------------------------------------------------------------
- */
+ * detach
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("detach scale when scale is group");
/* open the previous written "dset_a" */
- if((did = H5Dopen2(fid,"dset_a", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_a", H5P_DEFAULT)) < 0)
goto out;
/* open the group. */
- if((gid = H5Gopen2(fid, "grp", H5P_DEFAULT)) < 0)
+ if ((gid = H5Gopen2(fid, "grp", H5P_DEFAULT)) < 0)
goto out;
/* try to detach "grp" from "dset_a" */
- if(H5DSdetach_scale(did,gid,0)==SUCCEED)
+ if (H5DSdetach_scale(did, gid, 0) == SUCCEED)
goto out;
/* close */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
- if(H5Gclose(gid) < 0)
+ if (H5Gclose(gid) < 0)
goto out;
PASSED();
-
/* close */
- if(H5Fclose(fid) < 0)
+ if (H5Fclose(fid) < 0)
goto out;
return 0;
@@ -4092,183 +4180,180 @@ out:
H5Dclose(dsid);
H5Gclose(gid);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-
-
/*-------------------------------------------------------------------------
* test iterators
*-------------------------------------------------------------------------
*/
-static int test_iterators(void)
+static int
+test_iterators(void)
{
- hid_t fid; /* file ID */
- int rank = RANK; /* rank of data dataset */
- int rankds = 1; /* rank of DS dataset */
- hsize_t dims[RANK] = {DIM1_SIZE,DIM2_SIZE}; /* size of data dataset */
- hsize_t s1_dim[1] = {DIM1_SIZE}; /* size of DS 1 dataset */
- hid_t gid = -1; /* group ID */
- hid_t did = -1; /* dataset ID */
- hid_t dsid = -1; /* scale ID */
- char dname[30]; /* dataset name */
+ hid_t fid; /* file ID */
+ int rank = RANK; /* rank of data dataset */
+ int rankds = 1; /* rank of DS dataset */
+ hsize_t dims[RANK] = {DIM1_SIZE, DIM2_SIZE}; /* size of data dataset */
+ hsize_t s1_dim[1] = {DIM1_SIZE}; /* size of DS 1 dataset */
+ hid_t gid = -1; /* group ID */
+ hid_t did = -1; /* dataset ID */
+ hid_t dsid = -1; /* scale ID */
+ char dname[30]; /* dataset name */
int i;
HDprintf("Testing iterators\n");
/*-------------------------------------------------------------------------
- * create a file, spaces, dataset and group ids
- *-------------------------------------------------------------------------
- */
+ * create a file, spaces, dataset and group ids
+ *-------------------------------------------------------------------------
+ */
/* create a file using default properties */
- if((fid=H5Fcreate(FILE3,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
+ if ((fid = H5Fcreate(FILE3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
/* create a group */
- if((gid = H5Gcreate2(fid, "grp", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if ((gid = H5Gcreate2(fid, "grp", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
/* close */
- if(H5Gclose(gid) < 0)
+ if (H5Gclose(gid) < 0)
goto out;
/* make a dataset */
- if(H5LTmake_dataset_int(fid,"dset_a",rank,dims,NULL) < 0)
+ if (H5LTmake_dataset_int(fid, "dset_a", rank, dims, NULL) < 0)
goto out;
/* make a DS dataset */
- if(H5LTmake_dataset_int(fid,"ds_a",rankds,s1_dim,NULL) < 0)
+ if (H5LTmake_dataset_int(fid, "ds_a", rankds, s1_dim, NULL) < 0)
goto out;
/*-------------------------------------------------------------------------
- * iterate when the dataset has no scales
- *-------------------------------------------------------------------------
- */
+ * iterate when the dataset has no scales
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("iterate when the dataset has no scales ");
/* get the dataset id for "dset_a" */
- if((did = H5Dopen2(fid,"dset_a", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_a", H5P_DEFAULT)) < 0)
goto out;
/* try to iterate trough the 1st dimension of "dset_a", return error */
- if(H5DSiterate_scales(did,0,NULL,verify_scale,NULL) < 0)
+ if (H5DSiterate_scales(did, 0, NULL, verify_scale, NULL) < 0)
goto out;
/* close */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
PASSED();
-
/*-------------------------------------------------------------------------
- * iterate on dimension that is outside the rank
- *-------------------------------------------------------------------------
- */
+ * iterate on dimension that is outside the rank
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("iterate on dimension that is outside the rank ");
/* get the dataset id for "dset_a" */
- if((did = H5Dopen2(fid,"dset_a", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_a", H5P_DEFAULT)) < 0)
goto out;
/* try to iterate trough the 3rd dimension of "dset_a", return error */
- if(H5DSiterate_scales(did,3,NULL,verify_scale,NULL)==SUCCEED)
+ if (H5DSiterate_scales(did, 3, NULL, verify_scale, NULL) == SUCCEED)
goto out;
/* close */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
PASSED();
/*-------------------------------------------------------------------------
- * iterate for dimension with many scales
- *-------------------------------------------------------------------------
- */
+ * iterate for dimension with many scales
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("iterate for dimension with many scales ");
/* open the previously written "dset_a" */
- if((did = H5Dopen2(fid,"dset_a", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_a", H5P_DEFAULT)) < 0)
goto out;
- for(i=0; i<100; i++) {
+ for (i = 0; i < 100; i++) {
/* make a DS */
- HDsprintf(dname,"ds_%d",i);
- if(H5LTmake_dataset_int(fid,dname,rankds,s1_dim,NULL) < 0)
+ HDsprintf(dname, "ds_%d", i);
+ if (H5LTmake_dataset_int(fid, dname, rankds, s1_dim, NULL) < 0)
goto out;
/* open */
- if((dsid = H5Dopen2(fid,dname, H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0)
goto out;
/* attach */
- if(H5DSattach_scale(did,dsid,0) < 0)
+ if (H5DSattach_scale(did, dsid, 0) < 0)
goto out;
/* close */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
}
/* iterate trough the 1st dimension of "dset_a" */
- if(H5DSiterate_scales(did,0,NULL,op_continue,NULL) < 0)
+ if (H5DSiterate_scales(did, 0, NULL, op_continue, NULL) < 0)
goto out;
/* close */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
PASSED();
/*-------------------------------------------------------------------------
- * iterate on group
- *-------------------------------------------------------------------------
- */
+ * iterate on group
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("iterate on group ");
/* open */
- if((gid = H5Gopen2(fid, "grp", H5P_DEFAULT)) < 0)
+ if ((gid = H5Gopen2(fid, "grp", H5P_DEFAULT)) < 0)
goto out;
/* try to iterate, return error */
- if(H5DSiterate_scales(gid,0,NULL,verify_scale,NULL)==SUCCEED)
+ if (H5DSiterate_scales(gid, 0, NULL, verify_scale, NULL) == SUCCEED)
goto out;
/* close */
- if(H5Gclose(gid) < 0)
+ if (H5Gclose(gid) < 0)
goto out;
PASSED();
-
/*-------------------------------------------------------------------------
- * iterate in deleted scales
- *-------------------------------------------------------------------------
- */
+ * iterate in deleted scales
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("iterate in deleted scales ");
- if(H5Ldelete(fid, "ds_0", H5P_DEFAULT) < 0)
+ if (H5Ldelete(fid, "ds_0", H5P_DEFAULT) < 0)
goto out;
/* open the previously written "dset_a" */
- if((did = H5Dopen2(fid, "dset_a", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_a", H5P_DEFAULT)) < 0)
goto out;
/* iterate */
- if(H5DSiterate_scales(did, 0, NULL, op_continue, NULL) == SUCCEED)
+ if (H5DSiterate_scales(did, 0, NULL, op_continue, NULL) == SUCCEED)
goto out;
/* close */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
PASSED();
-
/* close */
- if(H5Fclose(fid) < 0)
+ if (H5Fclose(fid) < 0)
goto out;
return 0;
@@ -4280,201 +4365,202 @@ out:
H5Gclose(gid);
H5Dclose(did);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-
/*-------------------------------------------------------------------------
* test several ranks
*-------------------------------------------------------------------------
*/
-static int test_rank(void)
+static int
+test_rank(void)
{
- hid_t fid; /* file ID */
- hid_t did = -1; /* dataset ID */
- hid_t dsid = -1; /* scale ID */
- hid_t sid = -1; /* space ID */
- hid_t sidds = -1; /* space ID */
- hsize_t dims1[1] = {DIM1_SIZE}; /* size of data dataset */
- hsize_t dims2[2] = {DIM1_SIZE,DIM2_SIZE}; /* size of data dataset */
- hsize_t dims3[3] = {DIM1_SIZE,DIM2_SIZE,DIM3_SIZE}; /* size of data dataset */
- hsize_t dimss[2] = {1,1}; /* size of data dataset */
- char name[30]; /* dataset name buffer */
- char names[30]; /* dataset scale name buffer */
- char namel[30]; /* dataset label name buffer */
- int bufi[1]={2};
- float buff[1]={1};
+ hid_t fid; /* file ID */
+ hid_t did = -1; /* dataset ID */
+ hid_t dsid = -1; /* scale ID */
+ hid_t sid = -1; /* space ID */
+ hid_t sidds = -1; /* space ID */
+ hsize_t dims1[1] = {DIM1_SIZE}; /* size of data dataset */
+ hsize_t dims2[2] = {DIM1_SIZE, DIM2_SIZE}; /* size of data dataset */
+ hsize_t dims3[3] = {DIM1_SIZE, DIM2_SIZE, DIM3_SIZE}; /* size of data dataset */
+ hsize_t dimss[2] = {1, 1}; /* size of data dataset */
+ char name[30]; /* dataset name buffer */
+ char names[30]; /* dataset scale name buffer */
+ char namel[30]; /* dataset label name buffer */
+ int bufi[1] = {2};
+ float buff[1] = {1};
int i;
HDprintf("Testing ranks\n");
/*-------------------------------------------------------------------------
- * create a file, a dataset, scales
- *-------------------------------------------------------------------------
- */
+ * create a file, a dataset, scales
+ *-------------------------------------------------------------------------
+ */
/* create a file using default properties */
- if((fid=H5Fcreate(FILE4,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
+ if ((fid = H5Fcreate(FILE4, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
/* make a dataset a 3D data dataset */
- if(H5LTmake_dataset_int(fid,"dset_a",3,dims3,NULL) < 0)
+ if (H5LTmake_dataset_int(fid, "dset_a", 3, dims3, NULL) < 0)
goto out;
/* make a 1D scale dataset */
- if(H5LTmake_dataset_int(fid,"ds_a_0",1,dims1,NULL) < 0)
+ if (H5LTmake_dataset_int(fid, "ds_a_0", 1, dims1, NULL) < 0)
goto out;
/* make a 2D scale dataset */
- if(H5LTmake_dataset_int(fid,"ds_a_1",2,dims2,NULL) < 0)
+ if (H5LTmake_dataset_int(fid, "ds_a_1", 2, dims2, NULL) < 0)
goto out;
/* make a 3D scale dataset */
- if(H5LTmake_dataset_int(fid,"ds_a_2",3,dims3,NULL) < 0)
+ if (H5LTmake_dataset_int(fid, "ds_a_2", 3, dims3, NULL) < 0)
goto out;
/*-------------------------------------------------------------------------
- * attach
- *-------------------------------------------------------------------------
- */
+ * attach
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("attach");
- if((did = H5Dopen2(fid,"dset_a", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_a", H5P_DEFAULT)) < 0)
goto out;
- for(i=0; i<3; i++) {
- HDsprintf(name,"ds_a_%d",i);
- if((dsid = H5Dopen2(fid,name, H5P_DEFAULT)) < 0)
+ for (i = 0; i < 3; i++) {
+ HDsprintf(name, "ds_a_%d", i);
+ if ((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) < 0)
goto out;
- if(H5DSattach_scale(did,dsid,(unsigned)i) < 0)
+ if (H5DSattach_scale(did, dsid, (unsigned)i) < 0)
goto out;
- if(H5DSis_attached(did,dsid,(unsigned)i)<=0)
+ if (H5DSis_attached(did, dsid, (unsigned)i) <= 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
}
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
PASSED();
-
/*-------------------------------------------------------------------------
- * detach
- *-------------------------------------------------------------------------
- */
+ * detach
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("detach");
- if((did = H5Dopen2(fid,"dset_a", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_a", H5P_DEFAULT)) < 0)
goto out;
- for(i=0; i<3; i++) {
- HDsprintf(name,"ds_a_%d",i);
- if((dsid = H5Dopen2(fid,name, H5P_DEFAULT)) < 0)
+ for (i = 0; i < 3; i++) {
+ HDsprintf(name, "ds_a_%d", i);
+ if ((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) < 0)
goto out;
- if(H5DSdetach_scale(did,dsid,(unsigned)i) < 0)
+ if (H5DSdetach_scale(did, dsid, (unsigned)i) < 0)
goto out;
- if(H5DSis_attached(did,dsid,(unsigned)i)!=0)
+ if (H5DSis_attached(did, dsid, (unsigned)i) != 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
}
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
PASSED();
/*-------------------------------------------------------------------------
- * attach, set, get names, labels
- *-------------------------------------------------------------------------
- */
+ * attach, set, get names, labels
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("attach, set, get names, labels");
- if((did = H5Dopen2(fid,"dset_a", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_a", H5P_DEFAULT)) < 0)
goto out;
- for(i=0; i<3; i++) {
- HDsprintf(name,"ds_a_%d",i);
- if((dsid = H5Dopen2(fid,name, H5P_DEFAULT)) < 0)
+ for (i = 0; i < 3; i++) {
+ HDsprintf(name, "ds_a_%d", i);
+ if ((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) < 0)
goto out;
- if(H5DSset_scale(dsid,name) < 0)
+ if (H5DSset_scale(dsid, name) < 0)
goto out;
- if(H5DSattach_scale(did,dsid,(unsigned)i) < 0)
+ if (H5DSattach_scale(did, dsid, (unsigned)i) < 0)
goto out;
- if(H5DSis_attached(did,dsid,(unsigned)i)<=0)
+ if (H5DSis_attached(did, dsid, (unsigned)i) <= 0)
goto out;
- if(H5DSget_scale_name(dsid,names,sizeof(names)) < 0)
+ if (H5DSget_scale_name(dsid, names, sizeof(names)) < 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
- if(H5DSset_label(did,(unsigned)i,name) < 0)
+ if (H5DSset_label(did, (unsigned)i, name) < 0)
goto out;
- if(H5DSget_label(did,(unsigned)i,namel,sizeof(namel)) < 0)
+ if (H5DSget_label(did, (unsigned)i, namel, sizeof(namel)) < 0)
goto out;
- if(HDstrncmp(name, names, sizeof(names))!=0)
+ if (HDstrncmp(name, names, sizeof(names)) != 0)
goto out;
- if(HDstrncmp(name, namel, sizeof(namel))!=0)
+ if (HDstrncmp(name, namel, sizeof(namel)) != 0)
goto out;
}
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
PASSED();
/*-------------------------------------------------------------------------
- * attach a scalar scale
- *-------------------------------------------------------------------------
- */
+ * attach a scalar scale
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("attach a scalar scale");
/* create the data space for the dataset */
- if((sid = H5Screate_simple(2, dimss, NULL)) < 0)
+ if ((sid = H5Screate_simple(2, dimss, NULL)) < 0)
goto out;
/* create a dataset of rank 2 */
- if((did = H5Dcreate2(fid, "dset_b", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if ((did = H5Dcreate2(fid, "dset_b", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
/* create a scalar space */
- if((sidds = H5Screate(H5S_SCALAR)) < 0)
+ if ((sidds = H5Screate(H5S_SCALAR)) < 0)
goto out;
/* create a dataset of scalar rank for the scale */
- if((dsid = H5Dcreate2(fid, "ds_b_1", H5T_NATIVE_FLOAT, sidds, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dcreate2(fid, "ds_b_1", H5T_NATIVE_FLOAT, sidds, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) <
+ 0)
goto out;
/* write */
- if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, bufi) < 0)
+ if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, bufi) < 0)
goto out;
- if(H5Dwrite(dsid, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buff) < 0)
+ if (H5Dwrite(dsid, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buff) < 0)
goto out;
/* attach */
- if(H5DSattach_scale(did, dsid, 0) < 0)
+ if (H5DSattach_scale(did, dsid, 0) < 0)
goto out;
- if(H5DSattach_scale(did, dsid, 1) < 0)
+ if (H5DSattach_scale(did, dsid, 1) < 0)
goto out;
/* close */
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
goto out;
- if(H5Sclose(sidds) < 0)
+ if (H5Sclose(sidds) < 0)
goto out;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
PASSED();
/*-------------------------------------------------------------------------
- * close
- *-------------------------------------------------------------------------
- */
- if(H5Fclose(fid) < 0)
+ * close
+ *-------------------------------------------------------------------------
+ */
+ if (H5Fclose(fid) < 0)
goto out;
return 0;
@@ -4488,173 +4574,174 @@ out:
H5Sclose(sidds);
H5Sclose(sid);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-
/*-------------------------------------------------------------------------
* attach scales with several datatypes
*-------------------------------------------------------------------------
*/
-static int test_types(void)
+static int
+test_types(void)
{
- hid_t fid; /* file ID */
- hid_t did = -1; /* dataset ID */
- hid_t dsid = -1; /* DS dataset ID */
- int rank = RANK; /* rank of data dataset */
- int rankds = 1; /* rank of DS dataset */
- hsize_t dims[RANK] = {DIM1_SIZE,DIM2_SIZE}; /* size of data dataset */
- int buf[DIM_DATA] = {1,2,3,4,5,6,7,8,9,10,11,12}; /* data of data dataset */
- hsize_t s1_dim[1] = {DIM1_SIZE}; /* size of DS 1 dataset */
- hsize_t s2_dim[1] = {DIM2_SIZE}; /* size of DS 2 dataset */
- float s1_float[DIM1_SIZE] = {10,20,30}; /* data of DS 1 dataset */
- unsigned short s2_ushort[DIM2_SIZE] = {10,20,30,40}; /* data of DS 2 dataset */
- const char *s1_str = "ABC";
- const char *s2_str = "ABCD";
+ hid_t fid; /* file ID */
+ hid_t did = -1; /* dataset ID */
+ hid_t dsid = -1; /* DS dataset ID */
+ int rank = RANK; /* rank of data dataset */
+ int rankds = 1; /* rank of DS dataset */
+ hsize_t dims[RANK] = {DIM1_SIZE, DIM2_SIZE}; /* size of data dataset */
+ int buf[DIM_DATA] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; /* data of data dataset */
+ hsize_t s1_dim[1] = {DIM1_SIZE}; /* size of DS 1 dataset */
+ hsize_t s2_dim[1] = {DIM2_SIZE}; /* size of DS 2 dataset */
+ float s1_float[DIM1_SIZE] = {10, 20, 30}; /* data of DS 1 dataset */
+ unsigned short s2_ushort[DIM2_SIZE] = {10, 20, 30, 40}; /* data of DS 2 dataset */
+ const char * s1_str = "ABC";
+ const char * s2_str = "ABCD";
HDprintf("Testing scales with several datatypes\n");
/*-------------------------------------------------------------------------
- * create a file for the test
- *-------------------------------------------------------------------------
- */
+ * create a file for the test
+ *-------------------------------------------------------------------------
+ */
/* create a file using default properties */
- if((fid=H5Fcreate(FILE5,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
+ if ((fid = H5Fcreate(FILE5, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
/*-------------------------------------------------------------------------
- * create datasets: 1 "data" dataset and 2 dimension scales
- *-------------------------------------------------------------------------
- */
+ * create datasets: 1 "data" dataset and 2 dimension scales
+ *-------------------------------------------------------------------------
+ */
/* make a dataset */
- if(H5LTmake_dataset_int(fid,"dset_a",rank,dims,buf) < 0)
+ if (H5LTmake_dataset_int(fid, "dset_a", rank, dims, buf) < 0)
goto out;
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_float(fid,DS_1_NAME,rankds,s1_dim,s1_float) < 0)
+ if (H5LTmake_dataset_float(fid, DS_1_NAME, rankds, s1_dim, s1_float) < 0)
goto out;
/* make a DS dataset for the second dimension */
- if(H5LTmake_dataset(fid,DS_2_NAME,rankds,s2_dim,H5T_NATIVE_USHORT,s2_ushort) < 0)
+ if (H5LTmake_dataset(fid, DS_2_NAME, rankds, s2_dim, H5T_NATIVE_USHORT, s2_ushort) < 0)
goto out;
/*-------------------------------------------------------------------------
- * floating point and short scales
- *-------------------------------------------------------------------------
- */
+ * floating point and short scales
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("floating point and short scales");
/* get the dataset id for "dset_a" */
- if((did = H5Dopen2(fid,"dset_a", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_a", H5P_DEFAULT)) < 0)
goto out;
/* get the DS dataset id */
- if((dsid = H5Dopen2(fid,DS_1_NAME, H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, DS_1_NAME, H5P_DEFAULT)) < 0)
goto out;
/* attach the DS_1_NAME dimension scale to "dset_a" at dimension 0 */
- if(H5DSattach_scale(did,dsid,DIM0) < 0)
+ if (H5DSattach_scale(did, dsid, DIM0) < 0)
goto out;
/* set name */
- if(H5DSset_scale(dsid,SCALE_1_NAME) < 0)
+ if (H5DSset_scale(dsid, SCALE_1_NAME) < 0)
goto out;
/* close DS id */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
/* get the DS dataset id */
- if((dsid = H5Dopen2(fid,DS_2_NAME, H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, DS_2_NAME, H5P_DEFAULT)) < 0)
goto out;
/* attach the DS_2_NAME dimension scale to "dset_a" at dimension 1 */
- if(H5DSattach_scale(did,dsid,DIM1) < 0)
+ if (H5DSattach_scale(did, dsid, DIM1) < 0)
goto out;
/* set name */
- if(H5DSset_scale(dsid,SCALE_2_NAME) < 0)
+ if (H5DSset_scale(dsid, SCALE_2_NAME) < 0)
goto out;
/* close DS id */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
/* set a label */
- if(H5DSset_label(did,DIM0,DIM0_LABEL) < 0)
+ if (H5DSset_label(did, DIM0, DIM0_LABEL) < 0)
goto out;
- if(H5DSset_label(did,DIM1,DIM1_LABEL) < 0)
+ if (H5DSset_label(did, DIM1, DIM1_LABEL) < 0)
goto out;
/* close */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
PASSED();
/*-------------------------------------------------------------------------
- * create datasets: 1 "data" dataset and 2 dimension scales
- *-------------------------------------------------------------------------
- */
+ * create datasets: 1 "data" dataset and 2 dimension scales
+ *-------------------------------------------------------------------------
+ */
/* make a dataset */
- if(H5LTmake_dataset_int(fid,"dset_b",rank,dims,buf) < 0)
+ if (H5LTmake_dataset_int(fid, "dset_b", rank, dims, buf) < 0)
goto out;
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_string(fid,"ds_b_1",s1_str) < 0)
+ if (H5LTmake_dataset_string(fid, "ds_b_1", s1_str) < 0)
goto out;
/* make a DS dataset for the second dimension */
- if(H5LTmake_dataset_string(fid,"ds_b_2",s2_str) < 0)
+ if (H5LTmake_dataset_string(fid, "ds_b_2", s2_str) < 0)
goto out;
/*-------------------------------------------------------------------------
- * floating point and short scales
- *-------------------------------------------------------------------------
- */
+ * floating point and short scales
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("string scales");
/* get the dataset id for "dset_b" */
- if((did = H5Dopen2(fid,"dset_b", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset_b", H5P_DEFAULT)) < 0)
goto out;
/* get the DS dataset id */
- if((dsid = H5Dopen2(fid,"ds_b_1", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_b_1", H5P_DEFAULT)) < 0)
goto out;
/* attach the DS_1_NAME dimension scale to "dset_b" at dimension 0 */
- if(H5DSattach_scale(did,dsid,DIM0) < 0)
+ if (H5DSattach_scale(did, dsid, DIM0) < 0)
goto out;
/* set name */
- if(H5DSset_scale(dsid,SCALE_1_NAME) < 0)
+ if (H5DSset_scale(dsid, SCALE_1_NAME) < 0)
goto out;
/* close DS id */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
/* get the DS dataset id */
- if((dsid = H5Dopen2(fid,"ds_b_2", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds_b_2", H5P_DEFAULT)) < 0)
goto out;
/* attach the DS_2_NAME dimension scale to "dset_b" at dimension 1 */
- if(H5DSattach_scale(did,dsid,DIM1) < 0)
+ if (H5DSattach_scale(did, dsid, DIM1) < 0)
goto out;
/* set name */
- if(H5DSset_scale(dsid,SCALE_2_NAME) < 0)
+ if (H5DSset_scale(dsid, SCALE_2_NAME) < 0)
goto out;
/* close DS id */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
/* set a label */
- if(H5DSset_label(did,DIM0,DIM0_LABEL) < 0)
+ if (H5DSset_label(did, DIM0, DIM0_LABEL) < 0)
goto out;
- if(H5DSset_label(did,DIM1,DIM1_LABEL) < 0)
+ if (H5DSset_label(did, DIM1, DIM1_LABEL) < 0)
goto out;
/* close */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
PASSED();
/*-------------------------------------------------------------------------
- * close
- *-------------------------------------------------------------------------
- */
- if(H5Fclose(fid) < 0)
+ * close
+ *-------------------------------------------------------------------------
+ */
+ if (H5Fclose(fid) < 0)
goto out;
return 0;
@@ -4666,7 +4753,8 @@ out:
H5Dclose(did);
H5Dclose(dsid);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
@@ -4676,144 +4764,142 @@ out:
*-------------------------------------------------------------------------
*/
-static int test_data(void)
+static int
+test_data(void)
{
- hid_t fid; /* file ID */
- hid_t did = -1; /* dataset ID */
- hid_t dsid = -1; /* DS dataset ID */
- hid_t dcpl; /* dataset creation property list */
- hid_t sid; /* dataspace ID */
- float *vals=NULL; /* array to hold data values */
- float *latbuf=NULL; /* array to hold the latitude values */
- float *lonbuf=NULL; /* array to hold the longitude values */
- hsize_t dims[2]; /* array to hold dimensions */
- hsize_t latdims[1]; /* array to hold dimensions */
- hsize_t londims[1]; /* array to hold dimensions */
- float fill=-99; /* fill value */
-
+ hid_t fid; /* file ID */
+ hid_t did = -1; /* dataset ID */
+ hid_t dsid = -1; /* DS dataset ID */
+ hid_t dcpl; /* dataset creation property list */
+ hid_t sid; /* dataspace ID */
+ float * vals = NULL; /* array to hold data values */
+ float * latbuf = NULL; /* array to hold the latitude values */
+ float * lonbuf = NULL; /* array to hold the longitude values */
+ hsize_t dims[2]; /* array to hold dimensions */
+ hsize_t latdims[1]; /* array to hold dimensions */
+ hsize_t londims[1]; /* array to hold dimensions */
+ float fill = -99; /* fill value */
HDprintf("Testing reading ASCII data and generate HDF5 data with scales\n");
/*-------------------------------------------------------------------------
- * create a file for the test
- *-------------------------------------------------------------------------
- */
+ * create a file for the test
+ *-------------------------------------------------------------------------
+ */
/* create a file using default properties */
- if((fid=H5Fcreate(FILE6,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
+ if ((fid = H5Fcreate(FILE6, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
/*-------------------------------------------------------------------------
- * generating scales
- *-------------------------------------------------------------------------
- */
+ * generating scales
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("generating scales");
/*-------------------------------------------------------------------------
- * create datasets: 1 "data" dataset and 2 dimension scales
- *-------------------------------------------------------------------------
- */
+ * create datasets: 1 "data" dataset and 2 dimension scales
+ *-------------------------------------------------------------------------
+ */
/* read the latitude */
- if(read_data("dslat.txt",1,latdims,&latbuf) < 0)
+ if (read_data("dslat.txt", 1, latdims, &latbuf) < 0)
goto out;
/* make a DS dataset for the first dimension */
- if(H5LTmake_dataset_float(fid, "lat", 1, latdims, latbuf) < 0)
+ if (H5LTmake_dataset_float(fid, "lat", 1, latdims, latbuf) < 0)
goto out;
- HDfree( latbuf );
+ HDfree(latbuf);
latbuf = NULL;
- /* read the longitude */
- if(read_data("dslon.txt",1,londims,&lonbuf) < 0)
+ /* read the longitude */
+ if (read_data("dslon.txt", 1, londims, &lonbuf) < 0)
goto out;
/* make a DS dataset for the second dimension */
- if(H5LTmake_dataset_float(fid, "lon", 1, londims, lonbuf) < 0)
+ if (H5LTmake_dataset_float(fid, "lon", 1, londims, lonbuf) < 0)
goto out;
- HDfree( lonbuf );
+ HDfree(lonbuf);
lonbuf = NULL;
/* make a dataset for the data. a fill value is set */
- if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
goto out;
- if(H5Pset_fill_value(dcpl, H5T_NATIVE_FLOAT, &fill) < 0)
+ if (H5Pset_fill_value(dcpl, H5T_NATIVE_FLOAT, &fill) < 0)
goto out;
/* read ASCII bathymetry data and dimensions to create dataset */
- if(read_data("dsdata.txt",2,dims,&vals) < 0)
+ if (read_data("dsdata.txt", 2, dims, &vals) < 0)
goto out;
- if((sid = H5Screate_simple(2, dims, NULL)) < 0)
+ if ((sid = H5Screate_simple(2, dims, NULL)) < 0)
goto out;
- if((did = H5Dcreate2(fid, "data", H5T_NATIVE_FLOAT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
+ if ((did = H5Dcreate2(fid, "data", H5T_NATIVE_FLOAT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
goto out;
- if(H5Dwrite(did, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, vals) < 0)
+ if (H5Dwrite(did, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, vals) < 0)
goto out;
- HDfree ( vals );
+ HDfree(vals);
vals = NULL;
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
- if(H5Pclose(dcpl) < 0)
+ if (H5Pclose(dcpl) < 0)
goto out;
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
goto out;
/*-------------------------------------------------------------------------
- * attach
- *-------------------------------------------------------------------------
- */
+ * attach
+ *-------------------------------------------------------------------------
+ */
/* get the dataset id for "data" */
- if((did = H5Dopen2(fid,"data", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "data", H5P_DEFAULT)) < 0)
goto out;
/* get the DS dataset id */
- if((dsid = H5Dopen2(fid,"lat", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "lat", H5P_DEFAULT)) < 0)
goto out;
/* attach the DS_1_NAME dimension scale to "data" at dimension 0 */
- if(H5DSattach_scale(did,dsid,DIM0) < 0)
+ if (H5DSattach_scale(did, dsid, DIM0) < 0)
goto out;
/* set name */
- if(H5DSset_scale(dsid,SCALE_1_NAME) < 0)
+ if (H5DSset_scale(dsid, SCALE_1_NAME) < 0)
goto out;
/* close DS id */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
/* get the DS dataset id */
- if((dsid = H5Dopen2(fid,"lon", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "lon", H5P_DEFAULT)) < 0)
goto out;
/* attach the DS_2_NAME dimension scale to "data" at dimension 1 */
- if(H5DSattach_scale(did,dsid,DIM1) < 0)
+ if (H5DSattach_scale(did, dsid, DIM1) < 0)
goto out;
/* set name */
- if(H5DSset_scale(dsid,SCALE_2_NAME) < 0)
+ if (H5DSset_scale(dsid, SCALE_2_NAME) < 0)
goto out;
/* close DS id */
- if(H5Dclose(dsid) < 0)
+ if (H5Dclose(dsid) < 0)
goto out;
/* set a label */
- if(H5DSset_label(did,DIM0,DIM0_LABEL) < 0)
+ if (H5DSset_label(did, DIM0, DIM0_LABEL) < 0)
goto out;
- if(H5DSset_label(did,DIM1,DIM1_LABEL) < 0)
+ if (H5DSset_label(did, DIM1, DIM1_LABEL) < 0)
goto out;
/* close */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
goto out;
PASSED();
-
-
/*-------------------------------------------------------------------------
- * close
- *-------------------------------------------------------------------------
- */
- if(H5Fclose(fid) < 0)
+ * close
+ *-------------------------------------------------------------------------
+ */
+ if (H5Fclose(fid) < 0)
goto out;
return 0;
@@ -4825,20 +4911,19 @@ out:
H5Dclose(did);
H5Dclose(dsid);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
if (latbuf)
- HDfree( latbuf );
+ HDfree(latbuf);
if (lonbuf)
- HDfree( lonbuf );
+ HDfree(lonbuf);
if (vals)
- HDfree( vals );
+ HDfree(vals);
return FAIL;
}
-
-
/*-------------------------------------------------------------------------
* read_data
* utility function to read ASCII data
@@ -4852,34 +4937,32 @@ out:
*-------------------------------------------------------------------------
*/
-static int read_data( const char* fname,
- int ndims,
- hsize_t *dims,
- float **buf )
+static int
+read_data(const char *fname, int ndims, hsize_t *dims, float **buf)
{
- int i, n;
- unsigned j;
- char str[20];
- size_t nelms;
- FILE *f;
- float val;
+ int i, n;
+ unsigned j;
+ char str[20];
+ size_t nelms;
+ FILE * f;
+ float val;
const char *data_file = H5_get_srcdir_filename(fname);
/* read first data file */
f = HDfopen(data_file, "r");
- if( f == NULL ) {
- HDprintf( "Could not open file %s\n", data_file );
+ if (f == NULL) {
+ HDprintf("Could not open file %s\n", data_file);
return -1;
}
- for(i=0, nelms=1; i < ndims; i++) {
- if(fscanf( f, "%s %u", str, &j) && HDferror(f)) {
- HDprintf( "fscanf error in file %s\n", data_file );
+ for (i = 0, nelms = 1; i < ndims; i++) {
+ if (fscanf(f, "%s %u", str, &j) && HDferror(f)) {
+ HDprintf("fscanf error in file %s\n", data_file);
HDfclose(f);
return -1;
} /* end if */
- if(fscanf( f, "%d",&n ) < 0 && HDferror(f)) {
- HDprintf( "fscanf error in file %s\n", data_file );
+ if (fscanf(f, "%d", &n) < 0 && HDferror(f)) {
+ HDprintf("fscanf error in file %s\n", data_file);
HDfclose(f);
return -1;
} /* end if */
@@ -4887,17 +4970,17 @@ static int read_data( const char* fname,
nelms *= (size_t)n;
}
- *buf = (float*) HDmalloc (nelms * sizeof( float ));
+ *buf = (float *)HDmalloc(nelms * sizeof(float));
- if ( *buf == NULL ) {
- HDprintf( "memory allocation failed\n" );
+ if (*buf == NULL) {
+ HDprintf("memory allocation failed\n");
HDfclose(f);
return -1;
}
- for(j = 0; j < nelms; j++) {
- if(fscanf( f, "%f",&val ) < 0 && HDferror(f)) {
- HDprintf( "fscanf error in file %s\n", data_file );
+ for (j = 0; j < nelms; j++) {
+ if (fscanf(f, "%f", &val) < 0 && HDferror(f)) {
+ HDprintf("fscanf error in file %s\n", data_file);
HDfclose(f);
return -1;
} /* end if */
@@ -4906,67 +4989,64 @@ static int read_data( const char* fname,
HDfclose(f);
return 1;
-
}
-
/*-------------------------------------------------------------------------
* test parameter errors
*-------------------------------------------------------------------------
*/
-static int test_errors2(void)
+static int
+test_errors2(void)
{
- hid_t fid; /* file ID */
- hid_t did = -1; /* dataset ID */
- hid_t dsid = -1; /* scale ID */
- hsize_t dimd[2] = {3,3}; /* size of data dataset */
- hsize_t dims[1] = {3}; /* size of scale dataset */
- char lbuf[255]; /* label buffer */
- ssize_t label_len; /* label length */
- int scale_idx; /* scale index */
- int nscales; /* number of scales in DIM */
- int count; /* visitor data */
+ hid_t fid; /* file ID */
+ hid_t did = -1; /* dataset ID */
+ hid_t dsid = -1; /* scale ID */
+ hsize_t dimd[2] = {3, 3}; /* size of data dataset */
+ hsize_t dims[1] = {3}; /* size of scale dataset */
+ char lbuf[255]; /* label buffer */
+ ssize_t label_len; /* label length */
+ int scale_idx; /* scale index */
+ int nscales; /* number of scales in DIM */
+ int count; /* visitor data */
HDprintf("Testing parameter errors\n");
/*-------------------------------------------------------------------------
- * create a file, a dataset, scales
- *-------------------------------------------------------------------------
- */
+ * create a file, a dataset, scales
+ *-------------------------------------------------------------------------
+ */
/* create a file using default properties */
- if ((fid=H5Fcreate(FILE7,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
+ if ((fid = H5Fcreate(FILE7, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
/* make a dataset */
- if (H5LTmake_dataset_int(fid,"dset",2,dimd,NULL) < 0)
+ if (H5LTmake_dataset_int(fid, "dset", 2, dimd, NULL) < 0)
goto out;
/* make a scale dataset */
- if(H5LTmake_dataset_int(fid,"ds1",1,dims,NULL) < 0)
+ if (H5LTmake_dataset_int(fid, "ds1", 1, dims, NULL) < 0)
goto out;
/* make a scale dataset */
- if(H5LTmake_dataset_int(fid,"ds2",1,dims,NULL) < 0)
+ if (H5LTmake_dataset_int(fid, "ds2", 1, dims, NULL) < 0)
goto out;
-
HL_TESTING2("attach scales");
-
/*-------------------------------------------------------------------------
- * attach with invalid indices
- *-------------------------------------------------------------------------
- */
+ * attach with invalid indices
+ *-------------------------------------------------------------------------
+ */
- if ((did = H5Dopen2(fid,"dset", H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, "dset", H5P_DEFAULT)) < 0)
goto out;
- if ((dsid = H5Dopen2(fid,"ds1", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds1", H5P_DEFAULT)) < 0)
goto out;
- if (H5DSattach_scale(did,dsid,2) == SUCCEED)
+ if (H5DSattach_scale(did, dsid, 2) == SUCCEED)
goto out;
- if (H5DSattach_scale(did,dsid,0) < 0)
+ if (H5DSattach_scale(did, dsid, 0) < 0)
goto out;
if (H5Dclose(dsid) < 0)
goto out;
@@ -4978,16 +5058,16 @@ static int test_errors2(void)
HL_TESTING2("detach scales");
/*-------------------------------------------------------------------------
- * detach with invalid indices
- *-------------------------------------------------------------------------
- */
- if ((did = H5Dopen2(fid,"dset", H5P_DEFAULT)) < 0)
+ * detach with invalid indices
+ *-------------------------------------------------------------------------
+ */
+ if ((did = H5Dopen2(fid, "dset", H5P_DEFAULT)) < 0)
goto out;
- if ((dsid = H5Dopen2(fid,"ds1", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds1", H5P_DEFAULT)) < 0)
goto out;
- if (H5DSdetach_scale(did,dsid,2) == SUCCEED)
+ if (H5DSdetach_scale(did, dsid, 2) == SUCCEED)
goto out;
- if (H5DSdetach_scale(did,dsid,0) < 0)
+ if (H5DSdetach_scale(did, dsid, 0) < 0)
goto out;
if (H5Dclose(dsid) < 0)
goto out;
@@ -4999,22 +5079,22 @@ static int test_errors2(void)
HL_TESTING2("set/get label");
/*-------------------------------------------------------------------------
- * set/get label invalid indices
- *-------------------------------------------------------------------------
- */
- if ((did = H5Dopen2(fid,"dset", H5P_DEFAULT)) < 0)
+ * set/get label invalid indices
+ *-------------------------------------------------------------------------
+ */
+ if ((did = H5Dopen2(fid, "dset", H5P_DEFAULT)) < 0)
goto out;
- if (H5DSset_label(did,2,"label")== SUCCEED)
+ if (H5DSset_label(did, 2, "label") == SUCCEED)
goto out;
- if (H5DSset_label(did,0,"label") < 0)
+ if (H5DSset_label(did, 0, "label") < 0)
goto out;
- if (H5DSget_label(did,2,lbuf,sizeof(lbuf)) == SUCCEED)
+ if (H5DSget_label(did, 2, lbuf, sizeof(lbuf)) == SUCCEED)
goto out;
- if ((label_len=H5DSget_label(did,0,NULL,0)) < 0)
+ if ((label_len = H5DSget_label(did, 0, NULL, 0)) < 0)
goto out;
- if ( label_len != HDstrlen("label") )
+ if (label_len != HDstrlen("label"))
goto out;
- if (H5DSget_label(did,0,lbuf,sizeof(lbuf)) < 0)
+ if (H5DSget_label(did, 0, lbuf, sizeof(lbuf)) < 0)
goto out;
if (H5Dclose(did) < 0)
goto out;
@@ -5023,70 +5103,68 @@ static int test_errors2(void)
HL_TESTING2("iterate scales");
-
/*-------------------------------------------------------------------------
- * iterate_scales invalid indices and return DS_IDX and visitor data
- *-------------------------------------------------------------------------
- */
- if ((did = H5Dopen2(fid,"dset", H5P_DEFAULT)) < 0)
+ * iterate_scales invalid indices and return DS_IDX and visitor data
+ *-------------------------------------------------------------------------
+ */
+ if ((did = H5Dopen2(fid, "dset", H5P_DEFAULT)) < 0)
goto out;
- if ((dsid = H5Dopen2(fid,"ds1", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds1", H5P_DEFAULT)) < 0)
goto out;
- if (H5DSattach_scale(did,dsid,0) < 0)
+ if (H5DSattach_scale(did, dsid, 0) < 0)
goto out;
if (H5Dclose(dsid) < 0)
goto out;
- if ((dsid = H5Dopen2(fid,"ds2", H5P_DEFAULT)) < 0)
+ if ((dsid = H5Dopen2(fid, "ds2", H5P_DEFAULT)) < 0)
goto out;
- if (H5DSattach_scale(did,dsid,0) < 0)
+ if (H5DSattach_scale(did, dsid, 0) < 0)
goto out;
if (H5Dclose(dsid) < 0)
goto out;
- if((nscales = H5DSget_num_scales(did,0)) < 0)
+ if ((nscales = H5DSget_num_scales(did, 0)) < 0)
goto out;
- if(nscales!=2)
+ if (nscales != 2)
goto out;
/* invalid DIM */
- if (H5DSiterate_scales(did,2,NULL,op_continue,NULL)== SUCCEED)
+ if (H5DSiterate_scales(did, 2, NULL, op_continue, NULL) == SUCCEED)
goto out;
/* invalid DS_IDX */
scale_idx = 2;
- if (H5DSiterate_scales(did,0,&scale_idx,op_continue,NULL)== SUCCEED)
+ if (H5DSiterate_scales(did, 0, &scale_idx, op_continue, NULL) == SUCCEED)
goto out;
/* continue iteration */
scale_idx = 0;
- count = 0;
- if (H5DSiterate_scales(did,0,&scale_idx,op_continue,(void *)&count) < 0)
+ count = 0;
+ if (H5DSiterate_scales(did, 0, &scale_idx, op_continue, (void *)&count) < 0)
goto out;
- if ( scale_idx != 1 && count != nscales ) {
+ if (scale_idx != 1 && count != nscales) {
goto out;
}
/* stop iteration */
scale_idx = 0;
- count = 0;
- if (H5DSiterate_scales(did,0,&scale_idx,op_stop,(void *)&count) < 0)
+ count = 0;
+ if (H5DSiterate_scales(did, 0, &scale_idx, op_stop, (void *)&count) < 0)
goto out;
- if ( scale_idx != 0 && count != 1 ) {
+ if (scale_idx != 0 && count != 1) {
goto out;
}
-
if (H5Dclose(did) < 0)
goto out;
/*-------------------------------------------------------------------------
- * close
- *-------------------------------------------------------------------------
- */
- if(H5Fclose(fid) < 0)
+ * close
+ *-------------------------------------------------------------------------
+ */
+ if (H5Fclose(fid) < 0)
goto out;
PASSED();
@@ -5100,7 +5178,8 @@ out:
H5Dclose(did);
H5Dclose(dsid);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
@@ -5110,220 +5189,219 @@ out:
*-------------------------------------------------------------------------
*/
-static int test_attach_detach(void)
+static int
+test_attach_detach(void)
{
- hid_t fid; /* file ID */
- hid_t gid; /* group ID */
- hid_t sid; /* dataspace ID */
- hid_t dcpl_id; /* dataset creation property */
- hid_t dsid = -1; /* DS dataset ID */
- hid_t var1_id, var2_id, var3_id; /* DS component name */
- hsize_t dims[RANK1] = {DIM1};
+ hid_t fid; /* file ID */
+ hid_t gid; /* group ID */
+ hid_t sid; /* dataspace ID */
+ hid_t dcpl_id; /* dataset creation property */
+ hid_t dsid = -1; /* DS dataset ID */
+ hid_t var1_id, var2_id, var3_id; /* DS component name */
+ hsize_t dims[RANK1] = {DIM1};
HL_TESTING2("permutations of attaching and detaching");
- if((fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- goto out;
+ if ((fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
- if((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0)
- goto out;
+ if ((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0)
+ goto out;
/* Create dimension scale. */
- if((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0)
- goto out;
+ if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ goto out;
- if((sid = H5Screate_simple(1, dims, dims)) < 0)
- goto out;
+ if ((sid = H5Screate_simple(1, dims, dims)) < 0)
+ goto out;
- if((dsid = H5Dcreate2(gid, DS_3_NAME, H5T_IEEE_F32BE, sid,
- H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0)
- goto out;
+ if ((dsid = H5Dcreate2(gid, DS_3_NAME, H5T_IEEE_F32BE, sid, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0)
+ goto out;
- if(H5Sclose(sid) < 0)
- goto out;
- if(H5Pclose(dcpl_id) < 0)
- goto out;
+ if (H5Sclose(sid) < 0)
+ goto out;
+ if (H5Pclose(dcpl_id) < 0)
+ goto out;
- if(H5DSset_scale(dsid, DS_3_NAME) < 0)
- goto out;
+ if (H5DSset_scale(dsid, DS_3_NAME) < 0)
+ goto out;
/* Create a variable that uses this dimension scale. */
- if((sid = H5Screate_simple(DIM1, dims, dims)) < 0)
- goto out;
+ if ((sid = H5Screate_simple(DIM1, dims, dims)) < 0)
+ goto out;
- if((var1_id = H5Dcreate2(gid, DS_31_NAME, H5T_NATIVE_FLOAT, sid,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- goto out;
+ if ((var1_id =
+ H5Dcreate2(gid, DS_31_NAME, H5T_NATIVE_FLOAT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
- if(H5Sclose(sid) < 0)
- goto out;
+ if (H5Sclose(sid) < 0)
+ goto out;
- if(H5DSattach_scale(var1_id, dsid, 0) < 0)
- goto out;
+ if (H5DSattach_scale(var1_id, dsid, 0) < 0)
+ goto out;
/* Create another variable that uses this dimension scale. */
- if((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0)
- goto out;
+ if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ goto out;
- if(H5Pset_attr_creation_order(dcpl_id, H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED) < 0)
- goto out;
+ if (H5Pset_attr_creation_order(dcpl_id, H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED) < 0)
+ goto out;
- if((sid = H5Screate_simple(DIM1, dims, dims)) < 0)
- goto out;
+ if ((sid = H5Screate_simple(DIM1, dims, dims)) < 0)
+ goto out;
- if((var2_id = H5Dcreate2(gid, DS_32_NAME, H5T_NATIVE_FLOAT, sid,
- H5P_DEFAULT, H5P_DEFAULT,H5P_DEFAULT)) < 0)
- goto out;
+ if ((var2_id =
+ H5Dcreate2(gid, DS_32_NAME, H5T_NATIVE_FLOAT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
- if(H5Pclose(dcpl_id) < 0)
- goto out;
+ if (H5Pclose(dcpl_id) < 0)
+ goto out;
- if(H5Sclose(sid) < 0)
- goto out;
+ if (H5Sclose(sid) < 0)
+ goto out;
/* Create 3rd variable that uses this dimension scale. */
- if((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0)
- goto out;
+ if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ goto out;
- if(H5Pset_attr_creation_order(dcpl_id, H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED) < 0)
- goto out;
+ if (H5Pset_attr_creation_order(dcpl_id, H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED) < 0)
+ goto out;
- if((sid = H5Screate_simple(DIM1, dims, dims)) < 0)
- goto out;
+ if ((sid = H5Screate_simple(DIM1, dims, dims)) < 0)
+ goto out;
- if((var3_id = H5Dcreate2(gid, DS_33_NAME, H5T_NATIVE_FLOAT, sid,
- H5P_DEFAULT, H5P_DEFAULT,H5P_DEFAULT)) < 0)
- goto out;
+ if ((var3_id =
+ H5Dcreate2(gid, DS_33_NAME, H5T_NATIVE_FLOAT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
- if(H5Pclose(dcpl_id) < 0)
- goto out;
+ if (H5Pclose(dcpl_id) < 0)
+ goto out;
- if(H5Sclose(sid) < 0)
- goto out;
+ if (H5Sclose(sid) < 0)
+ goto out;
/* Attached var2 scale */
- if(H5DSattach_scale(var2_id, dsid, 0) < 0)
- goto out;
+ if (H5DSattach_scale(var2_id, dsid, 0) < 0)
+ goto out;
/* Detach the var2 scale */
- if(H5DSdetach_scale(var2_id, dsid, 0) < 0)
- goto out;
+ if (H5DSdetach_scale(var2_id, dsid, 0) < 0)
+ goto out;
/* Check if in correct state of detached and attached */
- if(H5DSis_attached(var1_id, dsid, 0) == 0) /* should still be attached */
- goto out;
- if(H5DSis_attached(var2_id, dsid, 0) != 0) /* should not be attached */
- goto out;
+ if (H5DSis_attached(var1_id, dsid, 0) == 0) /* should still be attached */
+ goto out;
+ if (H5DSis_attached(var2_id, dsid, 0) != 0) /* should not be attached */
+ goto out;
/* Detach the var1 scale */
- if(H5DSdetach_scale(var1_id, dsid, 0) < 0)
- goto out;
+ if (H5DSdetach_scale(var1_id, dsid, 0) < 0)
+ goto out;
/* Check if in correct state of detached and attached */
- if(H5DSis_attached(var1_id, dsid, 0) != 0) /* should not be attached */
- goto out;
- if(H5DSis_attached(var2_id, dsid, 0) != 0) /* should not be attached */
- goto out;
+ if (H5DSis_attached(var1_id, dsid, 0) != 0) /* should not be attached */
+ goto out;
+ if (H5DSis_attached(var2_id, dsid, 0) != 0) /* should not be attached */
+ goto out;
/* Attach the DS again and remove them in the opposite order */
- if(H5DSattach_scale(var1_id, dsid, 0) < 0)
- goto out;
+ if (H5DSattach_scale(var1_id, dsid, 0) < 0)
+ goto out;
- if(H5DSattach_scale(var2_id, dsid, 0) < 0)
- goto out;
+ if (H5DSattach_scale(var2_id, dsid, 0) < 0)
+ goto out;
/* Detach the var1 scale */
- if(H5DSdetach_scale(var1_id, dsid, 0) < 0)
- goto out;
+ if (H5DSdetach_scale(var1_id, dsid, 0) < 0)
+ goto out;
/* Check if in correct state of detached and attached */
- if(H5DSis_attached(var1_id, dsid, 0) != 0) /* should not be attached */
- goto out;
- if(H5DSis_attached(var2_id, dsid, 0) == 0) /* should still be attached */
- goto out;
+ if (H5DSis_attached(var1_id, dsid, 0) != 0) /* should not be attached */
+ goto out;
+ if (H5DSis_attached(var2_id, dsid, 0) == 0) /* should still be attached */
+ goto out;
/* Detach the var2 scale */
- if(H5DSdetach_scale(var2_id, dsid, 0) < 0)
- goto out;
+ if (H5DSdetach_scale(var2_id, dsid, 0) < 0)
+ goto out;
/* Check if in correct state of detached and attached */
- if(H5DSis_attached(var1_id, dsid, 0) != 0) /* should not be attached */
- goto out;
- if(H5DSis_attached(var2_id, dsid, 0) != 0) /* should not be attached */
- goto out;
+ if (H5DSis_attached(var1_id, dsid, 0) != 0) /* should not be attached */
+ goto out;
+ if (H5DSis_attached(var2_id, dsid, 0) != 0) /* should not be attached */
+ goto out;
/***************************************************
* Attach Three DS and remove the middle one first
*****************************************************/
- if(H5DSattach_scale(var1_id, dsid, 0) < 0)
- goto out;
-
- if(H5DSattach_scale(var2_id, dsid, 0) < 0)
- goto out;
+ if (H5DSattach_scale(var1_id, dsid, 0) < 0)
+ goto out;
- if(H5DSattach_scale(var3_id, dsid, 0) < 0)
- goto out;
+ if (H5DSattach_scale(var2_id, dsid, 0) < 0)
+ goto out;
+ if (H5DSattach_scale(var3_id, dsid, 0) < 0)
+ goto out;
/* Detach the var2 scale */
- if(H5DSdetach_scale(var2_id, dsid, 0) < 0)
- goto out;
+ if (H5DSdetach_scale(var2_id, dsid, 0) < 0)
+ goto out;
/* Check if in correct state of detached and attached */
- if(H5DSis_attached(var1_id, dsid, 0) == 0) /* should still be attached */
- goto out;
- if(H5DSis_attached(var2_id, dsid, 0) != 0) /* should not be attached */
- goto out;
- if(H5DSis_attached(var3_id, dsid, 0) == 0) /* should still be attached */
- goto out;
+ if (H5DSis_attached(var1_id, dsid, 0) == 0) /* should still be attached */
+ goto out;
+ if (H5DSis_attached(var2_id, dsid, 0) != 0) /* should not be attached */
+ goto out;
+ if (H5DSis_attached(var3_id, dsid, 0) == 0) /* should still be attached */
+ goto out;
/* Detach the var3 scale */
- if(H5DSdetach_scale(var3_id, dsid, 0) < 0)
- goto out;
+ if (H5DSdetach_scale(var3_id, dsid, 0) < 0)
+ goto out;
/* Check if in correct state of detached and attached */
- if(H5DSis_attached(var1_id, dsid, 0) == 0) /* should still be attached */
- goto out;
- if(H5DSis_attached(var2_id, dsid, 0) != 0) /* should not be attached */
- goto out;
- if(H5DSis_attached(var3_id, dsid, 0) != 0) /* should not be attached */
- goto out;
+ if (H5DSis_attached(var1_id, dsid, 0) == 0) /* should still be attached */
+ goto out;
+ if (H5DSis_attached(var2_id, dsid, 0) != 0) /* should not be attached */
+ goto out;
+ if (H5DSis_attached(var3_id, dsid, 0) != 0) /* should not be attached */
+ goto out;
/* Detach the var1 scale */
- if(H5DSdetach_scale(var1_id, dsid, 0) < 0)
- goto out;
+ if (H5DSdetach_scale(var1_id, dsid, 0) < 0)
+ goto out;
/* Check if in correct state of detached and attached */
- if(H5DSis_attached(var1_id, dsid, 0) != 0) /* should not be attached */
- goto out;
- if(H5DSis_attached(var2_id, dsid, 0) != 0) /* should not be attached */
- goto out;
- if(H5DSis_attached(var3_id, dsid, 0) != 0) /* should not be attached */
- goto out;
+ if (H5DSis_attached(var1_id, dsid, 0) != 0) /* should not be attached */
+ goto out;
+ if (H5DSis_attached(var2_id, dsid, 0) != 0) /* should not be attached */
+ goto out;
+ if (H5DSis_attached(var3_id, dsid, 0) != 0) /* should not be attached */
+ goto out;
/*-------------------------------------------------------------------------
- * close
- *-------------------------------------------------------------------------
- */
+ * close
+ *-------------------------------------------------------------------------
+ */
- if(H5Dclose(var1_id) < 0)
- goto out;
- if(H5Dclose(var2_id) < 0)
- goto out;
- if(H5Dclose(var3_id) < 0)
- goto out;
- if(H5Dclose(dsid) < 0)
- goto out;
- if(H5Gclose(gid) < 0)
- goto out;
- if(H5Fclose(fid) < 0)
- goto out;
+ if (H5Dclose(var1_id) < 0)
+ goto out;
+ if (H5Dclose(var2_id) < 0)
+ goto out;
+ if (H5Dclose(var3_id) < 0)
+ goto out;
+ if (H5Dclose(dsid) < 0)
+ goto out;
+ if (H5Gclose(gid) < 0)
+ goto out;
+ if (H5Fclose(fid) < 0)
+ goto out;
PASSED();
@@ -5333,13 +5411,14 @@ static int test_attach_detach(void)
out:
H5E_BEGIN_TRY
{
- H5Dclose(var1_id);
- H5Dclose(var2_id);
- H5Dclose(var3_id);
+ H5Dclose(var1_id);
+ H5Dclose(var2_id);
+ H5Dclose(var3_id);
H5Dclose(dsid);
H5Gclose(gid);
H5Fclose(fid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
diff --git a/hl/test/test_dset_append.c b/hl/test/test_dset_append.c
index 455c0e8..9c5efdd 100644
--- a/hl/test/test_dset_append.c
+++ b/hl/test/test_dset_append.c
@@ -1,35 +1,35 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-* Copyright by The HDF Group. *
-* Copyright by the Board of Trustees of the University of Illinois. *
-* All rights reserved. *
-* *
-* This file is part of HDF5. The full HDF5 copyright notice, including *
-* terms governing use, modification, and redistribution, is contained in *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
* distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "h5hltest.h"
#include "H5DOpublic.h"
#if defined(H5_HAVE_ZLIB_H) && !defined(H5_ZLIB_HEADER)
-# define H5_ZLIB_HEADER "zlib.h"
+#define H5_ZLIB_HEADER "zlib.h"
#endif
#if defined(H5_ZLIB_HEADER)
-#include H5_ZLIB_HEADER /* "zlib.h" */
+#include H5_ZLIB_HEADER /* "zlib.h" */
#endif
-#define FILENAME "test_append.h5"
-#define DNAME_NOTSET "dataset_notset"
-#define DNAME_UNLIM "dataset_unlim"
-#define DNAME_LESS "dataset_less"
-#define DNAME_VARY "dataset_vary"
-#define DNAME_ROW "dataset_row"
-#define DNAME_COLUMN "dataset_column"
-#define DBUGNAME1 "dataset_bug1"
-#define DBUGNAME2 "dataset_bug2"
+#define FILENAME "test_append.h5"
+#define DNAME_NOTSET "dataset_notset"
+#define DNAME_UNLIM "dataset_unlim"
+#define DNAME_LESS "dataset_less"
+#define DNAME_VARY "dataset_vary"
+#define DNAME_ROW "dataset_row"
+#define DNAME_COLUMN "dataset_column"
+#define DBUGNAME1 "dataset_bug1"
+#define DBUGNAME2 "dataset_bug2"
/*-------------------------------------------------------------------------
* Function: test_dataset_append_notset
@@ -48,67 +48,67 @@
static int
test_dataset_append_notset(hid_t fid)
{
- hid_t did = -1; /* Dataset ID */
- hid_t sid = -1; /* Dataspace ID */
- hid_t dcpl = -1; /* A copy of dataset creation property */
- hid_t ffapl = -1; /* The file's file access property list */
-
- hsize_t dims[2] = {0, 10}; /* Current dimension sizes */
- hsize_t maxdims[2] = {H5S_UNLIMITED, 20}; /* Maximum dimension sizes */
- hsize_t chunk_dims[2] = {2,5}; /* Chunk dimension sizes */
- int lbuf[10]; /* The data buffers */
- int i, j; /* Local index variables */
- h5_stat_t sb1, sb2; /* File info */
+ hid_t did = -1; /* Dataset ID */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t dcpl = -1; /* A copy of dataset creation property */
+ hid_t ffapl = -1; /* The file's file access property list */
+
+ hsize_t dims[2] = {0, 10}; /* Current dimension sizes */
+ hsize_t maxdims[2] = {H5S_UNLIMITED, 20}; /* Maximum dimension sizes */
+ hsize_t chunk_dims[2] = {2, 5}; /* Chunk dimension sizes */
+ int lbuf[10]; /* The data buffers */
+ int i, j; /* Local index variables */
+ h5_stat_t sb1, sb2; /* File info */
HL_TESTING2("Append flush with H5DOappend()--append rows with default dapl");
/* Get the file's file access property list */
- if((ffapl = H5Fget_access_plist(fid)) < 0)
+ if ((ffapl = H5Fget_access_plist(fid)) < 0)
FAIL_STACK_ERROR;
/* Set to create a chunked dataset with extendible dimensions */
- if((sid = H5Screate_simple(2, dims, maxdims)) < 0)
+ if ((sid = H5Screate_simple(2, dims, maxdims)) < 0)
FAIL_STACK_ERROR;
- if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
FAIL_STACK_ERROR;
- if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0)
+ if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0)
FAIL_STACK_ERROR;
/* Create the dataset */
- if((did = H5Dcreate2(fid, DNAME_NOTSET, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
+ if ((did = H5Dcreate2(fid, DNAME_NOTSET, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
FAIL_STACK_ERROR;
/* Append 6 rows to the dataset */
- for(i = 0; i < 6; i++) {
- for(j = 0; j < 10; j++)
+ for (i = 0; i < 6; i++) {
+ for (j = 0; j < 10; j++)
lbuf[j] = (i * 10) + (j + 1);
/* Append without boundary, callback and flush */
- if(H5DOappend(did, H5P_DEFAULT, 0, (size_t)1, H5T_NATIVE_INT, lbuf) < 0)
+ if (H5DOappend(did, H5P_DEFAULT, 0, (size_t)1, H5T_NATIVE_INT, lbuf) < 0)
FAIL_STACK_ERROR;
} /* end for */
/* File size when not flushed */
- if(HDstat(FILENAME, &sb1) < 0)
+ if (HDstat(FILENAME, &sb1) < 0)
TEST_ERROR;
/* Close the dataset */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
FAIL_STACK_ERROR;
/* File size after flushing */
- if(HDstat(FILENAME, &sb2) < 0)
+ if (HDstat(FILENAME, &sb2) < 0)
TEST_ERROR;
/* File size before flushing should be less */
- if(sb1.st_size > sb2.st_size)
+ if (sb1.st_size > sb2.st_size)
TEST_ERROR;
/* Closing */
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
FAIL_STACK_ERROR;
- if(H5Pclose(dcpl) < 0)
+ if (H5Pclose(dcpl) < 0)
FAIL_STACK_ERROR;
- if(H5Pclose(ffapl) < 0)
+ if (H5Pclose(ffapl) < 0)
FAIL_STACK_ERROR;
PASSED();
@@ -116,12 +116,14 @@ test_dataset_append_notset(hid_t fid)
return 0;
error:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Pclose(dcpl);
H5Pclose(sid);
H5Dclose(did);
H5Pclose(ffapl);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return 1;
} /* test_dataset_append_notset() */
@@ -130,7 +132,7 @@ error:
static herr_t
flush_func(hid_t H5_ATTR_UNUSED obj_id, void *_udata)
{
- unsigned *flush_ct = (unsigned*)_udata;
+ unsigned *flush_ct = (unsigned *)_udata;
++(*flush_ct);
return 0;
}
@@ -161,125 +163,125 @@ append_func(hid_t H5_ATTR_UNUSED dset_id, hsize_t H5_ATTR_UNUSED *cur_dims, void
static int
test_dataset_append_rows_columns(hid_t fid)
{
- hid_t did = -1; /* Dataset ID */
- hid_t sid = -1; /* Dataspace ID */
- hid_t dcpl = -1; /* A copy of dataset creation property */
- hid_t dapl = -1; /* A copy of dataset access property */
- hid_t ffapl = -1; /* The file's file access property list */
+ hid_t did = -1; /* Dataset ID */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t dcpl = -1; /* A copy of dataset creation property */
+ hid_t dapl = -1; /* A copy of dataset access property */
+ hid_t ffapl = -1; /* The file's file access property list */
- hsize_t dims[2] = {0, 10}; /* Current dimension sizes */
- hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Maximum dimension sizes */
- hsize_t chunk_dims[2] = {2,5}; /* Chunk dimension sizes */
- int lbuf[10], cbuf[6]; /* The data buffers */
- int buf[6][13], rbuf[6][13]; /* The data buffers */
+ hsize_t dims[2] = {0, 10}; /* Current dimension sizes */
+ hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Maximum dimension sizes */
+ hsize_t chunk_dims[2] = {2, 5}; /* Chunk dimension sizes */
+ int lbuf[10], cbuf[6]; /* The data buffers */
+ int buf[6][13], rbuf[6][13]; /* The data buffers */
- hsize_t boundary[2] = {1, 1}; /* Boundary sizes */
- unsigned append_ct = 0; /* The # of appends */
- unsigned *flush_ptr; /* Points to the flush counter */
+ hsize_t boundary[2] = {1, 1}; /* Boundary sizes */
+ unsigned append_ct = 0; /* The # of appends */
+ unsigned *flush_ptr; /* Points to the flush counter */
- int i, j; /* Local index variables */
+ int i, j; /* Local index variables */
HL_TESTING2("Append flush with H5DOappend()--append rows & columns");
/* Get the file's file access property list */
- if((ffapl = H5Fget_access_plist(fid)) < 0)
+ if ((ffapl = H5Fget_access_plist(fid)) < 0)
FAIL_STACK_ERROR;
/* Set to create a chunked dataset with 2 extendible dimensions */
- if((sid = H5Screate_simple(2, dims, maxdims)) < 0)
+ if ((sid = H5Screate_simple(2, dims, maxdims)) < 0)
FAIL_STACK_ERROR;
- if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
FAIL_STACK_ERROR;
- if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0)
+ if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0)
FAIL_STACK_ERROR;
/* Set append flush property */
- if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0)
+ if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0)
FAIL_STACK_ERROR;
- if(H5Pset_append_flush(dapl, 2, boundary, append_func, &append_ct) < 0)
+ if (H5Pset_append_flush(dapl, 2, boundary, append_func, &append_ct) < 0)
FAIL_STACK_ERROR;
/* Create the dataset */
- if((did = H5Dcreate2(fid, DNAME_UNLIM, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0)
+ if ((did = H5Dcreate2(fid, DNAME_UNLIM, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0)
TEST_ERROR;
/* Append 6 rows to the dataset */
- for(i = 0; i < 6; i++) {
- for(j = 0; j < 10; j++)
+ for (i = 0; i < 6; i++) {
+ for (j = 0; j < 10; j++)
lbuf[j] = buf[i][j] = (i * 10) + (j + 1);
- if(H5DOappend(did, H5P_DEFAULT, 0, (size_t)1, H5T_NATIVE_INT, lbuf) < 0)
+ if (H5DOappend(did, H5P_DEFAULT, 0, (size_t)1, H5T_NATIVE_INT, lbuf) < 0)
TEST_ERROR;
} /* end for */
/* Verify the # of appends */
- if(append_ct != 6)
+ if (append_ct != 6)
TEST_ERROR;
/* Retrieve and verify object flush counts */
- if(H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0)
+ if (H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0)
FAIL_STACK_ERROR;
- if(*flush_ptr != 6)
+ if (*flush_ptr != 6)
TEST_ERROR;
/* Append 3 columns to the dataset */
- for(i = 0; i < 3; i++) {
- for(j = 0; j < 6; j++)
+ for (i = 0; i < 3; i++) {
+ for (j = 0; j < 6; j++)
cbuf[j] = buf[j][i + 10] = ((i * 6) + (j + 1)) * -1;
- if(H5DOappend(did, H5P_DEFAULT, 1, (size_t)1, H5T_NATIVE_INT, cbuf) < 0)
+ if (H5DOappend(did, H5P_DEFAULT, 1, (size_t)1, H5T_NATIVE_INT, cbuf) < 0)
TEST_ERROR;
} /* end for */
/* Verify the # of appends */
- if(append_ct != 9)
+ if (append_ct != 9)
TEST_ERROR;
/* Retrieve and verify object flush counts */
- if(H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0)
+ if (H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0)
FAIL_STACK_ERROR;
- if(*flush_ptr != 9)
+ if (*flush_ptr != 9)
TEST_ERROR;
/* Read the dataset */
- if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0)
+ if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0)
FAIL_STACK_ERROR;
/* Verify the data */
- for(i = 0; i < 6; i++)
- for(j = 0; j < 13; j++)
- if(buf[i][j] != rbuf[i][j])
+ for (i = 0; i < 6; i++)
+ for (j = 0; j < 13; j++)
+ if (buf[i][j] != rbuf[i][j])
TEST_ERROR;
/* Clear the buffer */
HDmemset(rbuf, 0, sizeof(rbuf));
/* Close the dataset */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
FAIL_STACK_ERROR;
/* Open the dataset again */
- if((did = H5Dopen2(fid, DNAME_UNLIM, H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, DNAME_UNLIM, H5P_DEFAULT)) < 0)
FAIL_STACK_ERROR;
/* Read the dataset */
- if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0)
+ if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0)
FAIL_STACK_ERROR;
/* Verify the data */
- for(i = 0; i < 6; i++)
- for(j = 0; j < 13; j++)
- if(buf[i][j] != rbuf[i][j])
+ for (i = 0; i < 6; i++)
+ for (j = 0; j < 13; j++)
+ if (buf[i][j] != rbuf[i][j])
TEST_ERROR;
/* Closing */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
FAIL_STACK_ERROR;
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
FAIL_STACK_ERROR;
- if(H5Pclose(dapl) < 0)
+ if (H5Pclose(dapl) < 0)
FAIL_STACK_ERROR;
- if(H5Pclose(dcpl) < 0)
+ if (H5Pclose(dcpl) < 0)
FAIL_STACK_ERROR;
- if(H5Pclose(ffapl) < 0)
+ if (H5Pclose(ffapl) < 0)
FAIL_STACK_ERROR;
PASSED();
@@ -287,13 +289,15 @@ test_dataset_append_rows_columns(hid_t fid)
return 0;
error:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Pclose(dapl);
H5Pclose(dcpl);
H5Pclose(sid);
H5Dclose(did);
H5Pclose(ffapl);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return 1;
} /* test_dataset_append_rows_columns() */
@@ -315,105 +319,105 @@ error:
static int
test_dataset_append_rows(hid_t fid)
{
- hid_t did = -1; /* Dataset ID */
- hid_t sid = -1; /* Dataspace ID */
- hid_t dcpl = -1; /* A copy of dataset creation property */
- hid_t dapl = -1; /* A copy of dataset access property */
- hid_t ffapl = -1; /* The file's file access property list */
-
- hsize_t dims[2] = {0, 10}; /* Current dimension sizes */
- hsize_t maxdims[2] = {H5S_UNLIMITED, 10}; /* Maximum dimension sizes */
- hsize_t chunk_dims[2] = {2,5}; /* Chunk dimension sizes */
- int lbuf[10]; /* The data buffer */
- int buf[6][10], rbuf[6][10]; /* The data buffers */
- int i, j; /* Local index variables */
-
- hsize_t boundary[2] = {1, 0}; /* Boundary sizes */
- unsigned append_ct = 0; /* The # of appends */
- unsigned *flush_ptr; /* Points to the flush counter */
+ hid_t did = -1; /* Dataset ID */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t dcpl = -1; /* A copy of dataset creation property */
+ hid_t dapl = -1; /* A copy of dataset access property */
+ hid_t ffapl = -1; /* The file's file access property list */
+
+ hsize_t dims[2] = {0, 10}; /* Current dimension sizes */
+ hsize_t maxdims[2] = {H5S_UNLIMITED, 10}; /* Maximum dimension sizes */
+ hsize_t chunk_dims[2] = {2, 5}; /* Chunk dimension sizes */
+ int lbuf[10]; /* The data buffer */
+ int buf[6][10], rbuf[6][10]; /* The data buffers */
+ int i, j; /* Local index variables */
+
+ hsize_t boundary[2] = {1, 0}; /* Boundary sizes */
+ unsigned append_ct = 0; /* The # of appends */
+ unsigned *flush_ptr; /* Points to the flush counter */
HL_TESTING2("Append flush with H5DOappend()--append rows");
/* Get the file's file access property list */
- if((ffapl = H5Fget_access_plist(fid)) < 0)
+ if ((ffapl = H5Fget_access_plist(fid)) < 0)
FAIL_STACK_ERROR;
/* Set to create a chunked dataset with 1 extendible dimension */
- if((sid = H5Screate_simple(2, dims, maxdims)) < 0)
+ if ((sid = H5Screate_simple(2, dims, maxdims)) < 0)
FAIL_STACK_ERROR;
- if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
FAIL_STACK_ERROR;
- if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0)
+ if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0)
FAIL_STACK_ERROR;
/* Set append flush property */
- if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0)
+ if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0)
FAIL_STACK_ERROR;
- if(H5Pset_append_flush(dapl, 2, boundary, append_func, &append_ct) < 0)
+ if (H5Pset_append_flush(dapl, 2, boundary, append_func, &append_ct) < 0)
FAIL_STACK_ERROR;
/* Create the dataset */
- if((did = H5Dcreate2(fid, DNAME_ROW, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0)
+ if ((did = H5Dcreate2(fid, DNAME_ROW, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0)
TEST_ERROR;
/* Append 6 rows to the dataset */
- for(i = 0; i < 6; i++) {
- for(j = 0; j < 10; j++)
+ for (i = 0; i < 6; i++) {
+ for (j = 0; j < 10; j++)
lbuf[j] = buf[i][j] = (i * 10) + (j + 1);
- if(H5DOappend(did, H5P_DEFAULT, 0, (size_t)1, H5T_NATIVE_INT, lbuf) < 0)
+ if (H5DOappend(did, H5P_DEFAULT, 0, (size_t)1, H5T_NATIVE_INT, lbuf) < 0)
TEST_ERROR;
} /* end for */
/* Verify the # of appends */
- if(append_ct != 6)
+ if (append_ct != 6)
TEST_ERROR;
- if(H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0)
+ if (H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0)
FAIL_STACK_ERROR;
- if(*flush_ptr != 6)
+ if (*flush_ptr != 6)
TEST_ERROR;
/* Read the dataset */
- if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0)
+ if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0)
FAIL_STACK_ERROR;
/* Verify the data */
- for(i = 0; i < 6; i++)
- for(j = 0; j < 10; j++)
- if(buf[i][j] != rbuf[i][j])
+ for (i = 0; i < 6; i++)
+ for (j = 0; j < 10; j++)
+ if (buf[i][j] != rbuf[i][j])
TEST_ERROR;
/* Clear the buffer */
HDmemset(rbuf, 0, sizeof(rbuf));
/* Close the dataset */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
FAIL_STACK_ERROR;
/* Open the dataset again */
- if((did = H5Dopen2(fid, DNAME_ROW, H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, DNAME_ROW, H5P_DEFAULT)) < 0)
FAIL_STACK_ERROR;
/* Read the dataset */
- if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0)
+ if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0)
FAIL_STACK_ERROR;
/* Verify the data */
- for(i = 0; i < 6; i++)
- for(j = 0; j < 10; j++)
- if(buf[i][j] != rbuf[i][j])
+ for (i = 0; i < 6; i++)
+ for (j = 0; j < 10; j++)
+ if (buf[i][j] != rbuf[i][j])
TEST_ERROR;
/* Closing */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
FAIL_STACK_ERROR;
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
FAIL_STACK_ERROR;
- if(H5Pclose(dapl) < 0)
+ if (H5Pclose(dapl) < 0)
FAIL_STACK_ERROR;
- if(H5Pclose(dcpl) < 0)
+ if (H5Pclose(dcpl) < 0)
FAIL_STACK_ERROR;
- if(H5Pclose(ffapl) < 0)
+ if (H5Pclose(ffapl) < 0)
FAIL_STACK_ERROR;
PASSED();
@@ -421,13 +425,15 @@ test_dataset_append_rows(hid_t fid)
return 0;
error:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Pclose(dapl);
H5Pclose(dcpl);
H5Pclose(sid);
H5Dclose(did);
H5Pclose(ffapl);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return 1;
} /* test_dataset_append_rows() */
@@ -449,106 +455,106 @@ error:
static int
test_dataset_append_columns(hid_t fid)
{
- hid_t did = -1; /* Dataset ID */
- hid_t sid = -1; /* Dataspace ID */
- hid_t dcpl = -1; /* A copy of dataset creation property */
- hid_t dapl = -1; /* A copy of dataset access property */
- hid_t ffapl = -1; /* The file's file access property list */
-
- hsize_t dims[2] = {6, 0}; /* Current dimension sizes */
- hsize_t maxdims[2] = {6, H5S_UNLIMITED}; /* Maximum dimension sizes */
- hsize_t chunk_dims[2] = {2,5}; /* Chunk dimension sizes */
- int cbuf[6]; /* The data buffer */
- int buf[6][3], rbuf[6][3]; /* The data buffers */
- int i, j; /* Local index variable */
-
- hsize_t boundary[2] = {0, 1}; /* Boundary sizes */
- unsigned append_ct = 0; /* The # of appends */
- unsigned *flush_ptr; /* Points to the flush counter */
+ hid_t did = -1; /* Dataset ID */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t dcpl = -1; /* A copy of dataset creation property */
+ hid_t dapl = -1; /* A copy of dataset access property */
+ hid_t ffapl = -1; /* The file's file access property list */
+
+ hsize_t dims[2] = {6, 0}; /* Current dimension sizes */
+ hsize_t maxdims[2] = {6, H5S_UNLIMITED}; /* Maximum dimension sizes */
+ hsize_t chunk_dims[2] = {2, 5}; /* Chunk dimension sizes */
+ int cbuf[6]; /* The data buffer */
+ int buf[6][3], rbuf[6][3]; /* The data buffers */
+ int i, j; /* Local index variable */
+
+ hsize_t boundary[2] = {0, 1}; /* Boundary sizes */
+ unsigned append_ct = 0; /* The # of appends */
+ unsigned *flush_ptr; /* Points to the flush counter */
HL_TESTING2("Append flush with H5DOappend()--append columns");
/* Get the file's file access property list */
- if((ffapl = H5Fget_access_plist(fid)) < 0)
+ if ((ffapl = H5Fget_access_plist(fid)) < 0)
FAIL_STACK_ERROR;
/* Set to create a chunked dataset with 1 extendible dimension */
- if((sid = H5Screate_simple(2, dims, maxdims)) < 0)
+ if ((sid = H5Screate_simple(2, dims, maxdims)) < 0)
FAIL_STACK_ERROR;
- if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
FAIL_STACK_ERROR;
- if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0)
+ if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0)
FAIL_STACK_ERROR;
/* Set append flush property */
- if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0)
+ if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0)
FAIL_STACK_ERROR;
- if(H5Pset_append_flush(dapl, 2, boundary, append_func, &append_ct) < 0)
+ if (H5Pset_append_flush(dapl, 2, boundary, append_func, &append_ct) < 0)
FAIL_STACK_ERROR;
/* Create the dataset */
- if((did = H5Dcreate2(fid, DNAME_COLUMN, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0)
+ if ((did = H5Dcreate2(fid, DNAME_COLUMN, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0)
TEST_ERROR;
/* Append 3 columns to the dataset */
- for(i = 0; i < 3; i++) {
- for(j = 0; j < 6; j++)
+ for (i = 0; i < 3; i++) {
+ for (j = 0; j < 6; j++)
cbuf[j] = buf[j][i] = ((i * 6) + (j + 1)) * -1;
- if(H5DOappend(did, H5P_DEFAULT, 1, (size_t)1, H5T_NATIVE_INT, cbuf) < 0)
+ if (H5DOappend(did, H5P_DEFAULT, 1, (size_t)1, H5T_NATIVE_INT, cbuf) < 0)
TEST_ERROR;
} /* end for */
/* Verify the # of appends */
- if(append_ct != 3)
+ if (append_ct != 3)
TEST_ERROR;
/* Retrieve and verify object flush counts */
- if(H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0)
+ if (H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0)
FAIL_STACK_ERROR;
- if(*flush_ptr != 3)
+ if (*flush_ptr != 3)
TEST_ERROR;
/* Read the dataset */
- if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0)
+ if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0)
FAIL_STACK_ERROR;
/* Verify the data */
- for(i = 0; i < 6; i++)
- for(j = 0; j < 3; j++)
- if(buf[i][j] != rbuf[i][j])
+ for (i = 0; i < 6; i++)
+ for (j = 0; j < 3; j++)
+ if (buf[i][j] != rbuf[i][j])
TEST_ERROR;
/* Clear the buffer */
HDmemset(rbuf, 0, sizeof(rbuf));
/* Close the dataset */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
FAIL_STACK_ERROR;
/* Open the dataset again */
- if((did = H5Dopen2(fid, DNAME_COLUMN, H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, DNAME_COLUMN, H5P_DEFAULT)) < 0)
FAIL_STACK_ERROR;
/* Read the dataset */
- if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0)
+ if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0)
FAIL_STACK_ERROR;
/* Verify the data */
- for(i = 0; i < 6; i++)
- for(j = 0; j < 3; j++)
- if(buf[i][j] != rbuf[i][j])
+ for (i = 0; i < 6; i++)
+ for (j = 0; j < 3; j++)
+ if (buf[i][j] != rbuf[i][j])
TEST_ERROR;
/* Closing */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
FAIL_STACK_ERROR;
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
FAIL_STACK_ERROR;
- if(H5Pclose(dapl) < 0)
+ if (H5Pclose(dapl) < 0)
FAIL_STACK_ERROR;
- if(H5Pclose(dcpl) < 0)
+ if (H5Pclose(dcpl) < 0)
FAIL_STACK_ERROR;
- if(H5Pclose(ffapl) < 0)
+ if (H5Pclose(ffapl) < 0)
FAIL_STACK_ERROR;
PASSED();
@@ -556,13 +562,15 @@ test_dataset_append_columns(hid_t fid)
return 0;
error:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Pclose(dapl);
H5Pclose(dcpl);
H5Pclose(sid);
H5Dclose(did);
H5Pclose(ffapl);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return 1;
} /* test_dataset_append_columns() */
@@ -593,123 +601,123 @@ error:
static int
test_dataset_append_BUG1(hid_t fid)
{
- hid_t did = -1; /* Dataset ID */
- hid_t sid = -1; /* Dataspace ID */
- hid_t dcpl = -1; /* Dataset creation property */
- hid_t dapl = -1; /* Dataset access property */
- hid_t ffapl = -1; /* The file's file access property list */
-
- hsize_t dims[2] = {0, 10}; /* Current dimension sizes */
- hsize_t maxdims[2] = {H5S_UNLIMITED, 50}; /* Maximum dimension sizes */
- hsize_t chunk_dims[2] = {2,5}; /* Chunk dimension sizes */
- int lbuf[10], cbuf[6]; /* The data buffers */
- int buf[6][13], rbuf[6][13]; /* The data buffers */
- int i, j; /* Local index variables */
-
- hsize_t boundary[2] = {1, 1}; /* Boundary sizes */
- unsigned append_ct = 0; /* The # of appends */
- unsigned *flush_ptr; /* Points to the flush counter */
+ hid_t did = -1; /* Dataset ID */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t dcpl = -1; /* Dataset creation property */
+ hid_t dapl = -1; /* Dataset access property */
+ hid_t ffapl = -1; /* The file's file access property list */
+
+ hsize_t dims[2] = {0, 10}; /* Current dimension sizes */
+ hsize_t maxdims[2] = {H5S_UNLIMITED, 50}; /* Maximum dimension sizes */
+ hsize_t chunk_dims[2] = {2, 5}; /* Chunk dimension sizes */
+ int lbuf[10], cbuf[6]; /* The data buffers */
+ int buf[6][13], rbuf[6][13]; /* The data buffers */
+ int i, j; /* Local index variables */
+
+ hsize_t boundary[2] = {1, 1}; /* Boundary sizes */
+ unsigned append_ct = 0; /* The # of appends */
+ unsigned *flush_ptr; /* Points to the flush counter */
HL_TESTING2("Append flush with H5DOappend()--append rows & columns--BUG1");
/* Get the file's file access property list */
- if((ffapl = H5Fget_access_plist(fid)) < 0)
+ if ((ffapl = H5Fget_access_plist(fid)) < 0)
FAIL_STACK_ERROR;
/* Set to create a chunked dataset with 2 extendible dimensions */
- if((sid = H5Screate_simple(2, dims, maxdims)) < 0)
+ if ((sid = H5Screate_simple(2, dims, maxdims)) < 0)
FAIL_STACK_ERROR;
- if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
FAIL_STACK_ERROR;
- if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0)
+ if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0)
FAIL_STACK_ERROR;
/* Set append flush property */
- if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0)
+ if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0)
FAIL_STACK_ERROR;
- if(H5Pset_append_flush(dapl, 2, boundary, append_func, &append_ct) < 0)
+ if (H5Pset_append_flush(dapl, 2, boundary, append_func, &append_ct) < 0)
FAIL_STACK_ERROR;
/* Create the dataset */
- if((did = H5Dcreate2(fid, DBUGNAME1, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0)
+ if ((did = H5Dcreate2(fid, DBUGNAME1, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0)
TEST_ERROR;
/* Append 6 rows to the dataset */
- for(i = 0; i < 6; i++) {
- for(j = 0; j < 10; j++)
+ for (i = 0; i < 6; i++) {
+ for (j = 0; j < 10; j++)
lbuf[j] = buf[i][j] = (i * 10) + (j + 1);
- if(H5DOappend(did, H5P_DEFAULT, 0, (size_t)1, H5T_NATIVE_INT, lbuf) < 0)
+ if (H5DOappend(did, H5P_DEFAULT, 0, (size_t)1, H5T_NATIVE_INT, lbuf) < 0)
TEST_ERROR;
} /* end for */
/* Verify the # of appends */
- if(append_ct != 6)
+ if (append_ct != 6)
TEST_ERROR;
/* Retrieve and verify object flush counts */
- if(H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0)
+ if (H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0)
FAIL_STACK_ERROR;
- if(*flush_ptr != 6)
+ if (*flush_ptr != 6)
TEST_ERROR;
/* Append 3 columns to the dataset */
- for(i = 0; i < 3; i++) {
- for(j = 0; j < 6; j++)
- cbuf[j] = buf[j][i+10] = ((i * 6) + (j + 1)) * -1;
- if(H5DOappend(did, H5P_DEFAULT, 1, (size_t)1, H5T_NATIVE_INT, cbuf) < 0)
+ for (i = 0; i < 3; i++) {
+ for (j = 0; j < 6; j++)
+ cbuf[j] = buf[j][i + 10] = ((i * 6) + (j + 1)) * -1;
+ if (H5DOappend(did, H5P_DEFAULT, 1, (size_t)1, H5T_NATIVE_INT, cbuf) < 0)
TEST_ERROR;
} /* end for */
/* Verify the # of appends */
- if(append_ct != 9)
+ if (append_ct != 9)
TEST_ERROR;
/* Retrieve and verify object flush counts */
- if(H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0)
+ if (H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0)
FAIL_STACK_ERROR;
- if(*flush_ptr != 9)
+ if (*flush_ptr != 9)
TEST_ERROR;
/* Read the dataset */
- if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0)
+ if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0)
FAIL_STACK_ERROR;
/* Verify the data */
- for(i = 0; i < 6; i++)
- for(j = 0; j < 13; j++)
- if(buf[i][j] != rbuf[i][j])
+ for (i = 0; i < 6; i++)
+ for (j = 0; j < 13; j++)
+ if (buf[i][j] != rbuf[i][j])
TEST_ERROR;
HDmemset(rbuf, 0, sizeof(rbuf));
/* Close the dataset */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
FAIL_STACK_ERROR;
/* Open the dataset again */
- if((did = H5Dopen2(fid, DBUGNAME1, H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, DBUGNAME1, H5P_DEFAULT)) < 0)
FAIL_STACK_ERROR;
/* Read the dataset */
- if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0)
+ if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0)
FAIL_STACK_ERROR;
/* Verify the data */
- for(i = 0; i < 6; i++)
- for(j = 0; j < 13; j++)
- if(buf[i][j] != rbuf[i][j])
+ for (i = 0; i < 6; i++)
+ for (j = 0; j < 13; j++)
+ if (buf[i][j] != rbuf[i][j])
TEST_ERROR;
/* Closing */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
FAIL_STACK_ERROR;
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
FAIL_STACK_ERROR;
- if(H5Pclose(dapl) < 0)
+ if (H5Pclose(dapl) < 0)
FAIL_STACK_ERROR;
- if(H5Pclose(dcpl) < 0)
+ if (H5Pclose(dcpl) < 0)
FAIL_STACK_ERROR;
- if(H5Pclose(ffapl) < 0)
+ if (H5Pclose(ffapl) < 0)
FAIL_STACK_ERROR;
PASSED();
@@ -717,13 +725,15 @@ test_dataset_append_BUG1(hid_t fid)
return 0;
error:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Pclose(dcpl);
H5Pclose(dapl);
H5Pclose(sid);
H5Dclose(did);
H5Pclose(ffapl);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return 1;
} /* test_dataset_append_BUG1() */
@@ -754,124 +764,123 @@ error:
static int
test_dataset_append_BUG2(hid_t fid)
{
- hid_t did = -1; /* Dataset ID */
- hid_t sid = -1; /* Dataspace ID */
- hid_t dcpl = -1; /* Dataset creation property */
- hid_t dapl = -1; /* Dataset access property */
- hid_t ffapl = -1; /* The file's file access property list */
-
- hsize_t dims[2] = {0, 10}; /* Current dimension sizes */
- hsize_t maxdims[2] = {50, H5S_UNLIMITED}; /* Maximum dimension sizes */
- hsize_t chunk_dims[2] = {2,5}; /* Chunk dimension sizes */
- int lbuf[10], cbuf[6]; /* Data buffers */
- int buf[6][13], rbuf[6][13]; /* Data buffers */
- int i, j; /* Local index variables */
-
- hsize_t boundary[2] = {1, 1}; /* Boundary sizes */
- unsigned append_ct = 0; /* The # of appends */
- unsigned *flush_ptr; /* Points to the flush counter */
+ hid_t did = -1; /* Dataset ID */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t dcpl = -1; /* Dataset creation property */
+ hid_t dapl = -1; /* Dataset access property */
+ hid_t ffapl = -1; /* The file's file access property list */
+
+ hsize_t dims[2] = {0, 10}; /* Current dimension sizes */
+ hsize_t maxdims[2] = {50, H5S_UNLIMITED}; /* Maximum dimension sizes */
+ hsize_t chunk_dims[2] = {2, 5}; /* Chunk dimension sizes */
+ int lbuf[10], cbuf[6]; /* Data buffers */
+ int buf[6][13], rbuf[6][13]; /* Data buffers */
+ int i, j; /* Local index variables */
+
+ hsize_t boundary[2] = {1, 1}; /* Boundary sizes */
+ unsigned append_ct = 0; /* The # of appends */
+ unsigned *flush_ptr; /* Points to the flush counter */
HL_TESTING2("Append flush with H5DOappend()--append rows & columns--BUG2");
/* Get the file's file access property list */
- if((ffapl = H5Fget_access_plist(fid)) < 0)
+ if ((ffapl = H5Fget_access_plist(fid)) < 0)
FAIL_STACK_ERROR;
/* Set to create a chunked dataset with 2 extendible dimensions */
- if((sid = H5Screate_simple(2, dims, maxdims)) < 0)
+ if ((sid = H5Screate_simple(2, dims, maxdims)) < 0)
FAIL_STACK_ERROR;
- if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
FAIL_STACK_ERROR;
- if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0)
+ if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0)
FAIL_STACK_ERROR;
/* Set append flush property */
- if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0)
+ if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0)
FAIL_STACK_ERROR;
- if(H5Pset_append_flush(dapl, 2, boundary, append_func, &append_ct) < 0)
+ if (H5Pset_append_flush(dapl, 2, boundary, append_func, &append_ct) < 0)
FAIL_STACK_ERROR;
/* Create the dataset */
- if((did = H5Dcreate2(fid, DBUGNAME2, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0)
+ if ((did = H5Dcreate2(fid, DBUGNAME2, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0)
TEST_ERROR;
/* Append 6 rows to the dataset */
- for(i = 0; i < 6; i++) {
- for(j = 0; j < 10; j++)
+ for (i = 0; i < 6; i++) {
+ for (j = 0; j < 10; j++)
lbuf[j] = buf[i][j] = (i * 10) + (j + 1);
- if(H5DOappend(did, H5P_DEFAULT, 0, (size_t)1, H5T_NATIVE_INT, lbuf) < 0)
+ if (H5DOappend(did, H5P_DEFAULT, 0, (size_t)1, H5T_NATIVE_INT, lbuf) < 0)
TEST_ERROR;
} /* end for */
/* Verify the # of appends */
- if(append_ct != 6)
+ if (append_ct != 6)
TEST_ERROR;
/* Retrieve and verify object flush counts */
- if(H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0)
+ if (H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0)
FAIL_STACK_ERROR;
- if(*flush_ptr != 6)
+ if (*flush_ptr != 6)
TEST_ERROR;
-
/* Append 3 columns to the dataset */
- for(i = 0; i < 3; i++) {
- for(j = 0; j < 6; j++)
- cbuf[j] = buf[j][i+10] = ((i * 6) + (j + 1)) * -1;
- if(H5DOappend(did, H5P_DEFAULT, 1, (size_t)1, H5T_NATIVE_INT, cbuf) < 0)
+ for (i = 0; i < 3; i++) {
+ for (j = 0; j < 6; j++)
+ cbuf[j] = buf[j][i + 10] = ((i * 6) + (j + 1)) * -1;
+ if (H5DOappend(did, H5P_DEFAULT, 1, (size_t)1, H5T_NATIVE_INT, cbuf) < 0)
TEST_ERROR;
} /* end for */
/* Verify the # of appends */
- if(append_ct != 9)
+ if (append_ct != 9)
TEST_ERROR;
/* Retrieve and verify object flush counts */
- if(H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0)
+ if (H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0)
FAIL_STACK_ERROR;
- if(*flush_ptr != 9)
+ if (*flush_ptr != 9)
TEST_ERROR;
/* Read the dataset */
- if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0)
+ if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0)
FAIL_STACK_ERROR;
/* Verify the data */
- for(i = 0; i < 6; i++)
- for(j = 0; j < 13; j++)
- if(buf[i][j] != rbuf[i][j])
+ for (i = 0; i < 6; i++)
+ for (j = 0; j < 13; j++)
+ if (buf[i][j] != rbuf[i][j])
TEST_ERROR;
HDmemset(rbuf, 0, sizeof(rbuf));
/* Close the dataset */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
FAIL_STACK_ERROR;
/* Open the dataset again */
- if((did = H5Dopen2(fid, DBUGNAME2, H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, DBUGNAME2, H5P_DEFAULT)) < 0)
FAIL_STACK_ERROR;
/* Read the dataset */
- if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0)
+ if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0)
FAIL_STACK_ERROR;
/* Verify the data */
- for(i = 0; i < 6; i++)
- for(j = 0; j < 13; j++)
- if(buf[i][j] != rbuf[i][j])
+ for (i = 0; i < 6; i++)
+ for (j = 0; j < 13; j++)
+ if (buf[i][j] != rbuf[i][j])
TEST_ERROR;
/* Closing */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
FAIL_STACK_ERROR;
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
FAIL_STACK_ERROR;
- if(H5Pclose(dapl) < 0)
+ if (H5Pclose(dapl) < 0)
FAIL_STACK_ERROR;
- if(H5Pclose(dcpl) < 0)
+ if (H5Pclose(dcpl) < 0)
FAIL_STACK_ERROR;
- if(H5Pclose(ffapl) < 0)
+ if (H5Pclose(ffapl) < 0)
FAIL_STACK_ERROR;
PASSED();
@@ -879,18 +888,19 @@ test_dataset_append_BUG2(hid_t fid)
return 0;
error:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Pclose(dcpl);
H5Pclose(dapl);
H5Pclose(sid);
H5Dclose(did);
H5Pclose(ffapl);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return 1;
} /* test_dataset_append_BUG2() */
-
/*-------------------------------------------------------------------------
* Function: test_dataset_append_less
*
@@ -909,127 +919,127 @@ error:
static int
test_dataset_append_less(hid_t fid)
{
- hid_t did = -1; /* Dataset ID */
- hid_t sid = -1; /* Dataspace ID */
- hid_t dcpl = -1; /* A copy of dataset creation property */
- hid_t dapl = -1; /* A copy of dataset access property */
- hid_t ffapl = -1; /* The file's file access property list */
-
- hsize_t dims[2] = {0, 10}; /* Current dimension sizes */
- hsize_t maxdims[2] = {100, 100}; /* Maximum dimension sizes */
- hsize_t chunk_dims[2] = {2,5}; /* Chunk dimension sizes */
- int lbuf[20], cbuf[6][3]; /* Data buffers */
- int buf[6][13], rbuf[6][13]; /* Data buffers */
- int i, j, k; /* Local index variables */
-
- hsize_t boundary[2] = {3, 3}; /* Boundary sizes */
- unsigned append_ct = 0; /* The # of appends */
- unsigned *flush_ptr; /* Points to the flush counter */
+ hid_t did = -1; /* Dataset ID */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t dcpl = -1; /* A copy of dataset creation property */
+ hid_t dapl = -1; /* A copy of dataset access property */
+ hid_t ffapl = -1; /* The file's file access property list */
+
+ hsize_t dims[2] = {0, 10}; /* Current dimension sizes */
+ hsize_t maxdims[2] = {100, 100}; /* Maximum dimension sizes */
+ hsize_t chunk_dims[2] = {2, 5}; /* Chunk dimension sizes */
+ int lbuf[20], cbuf[6][3]; /* Data buffers */
+ int buf[6][13], rbuf[6][13]; /* Data buffers */
+ int i, j, k; /* Local index variables */
+
+ hsize_t boundary[2] = {3, 3}; /* Boundary sizes */
+ unsigned append_ct = 0; /* The # of appends */
+ unsigned *flush_ptr; /* Points to the flush counter */
HL_TESTING2("Append flush with H5DOappend()--append size < boundary size");
/* Get the file's file access property list */
- if((ffapl = H5Fget_access_plist(fid)) < 0)
+ if ((ffapl = H5Fget_access_plist(fid)) < 0)
FAIL_STACK_ERROR;
/* Set to create a chunked dataset with 2 extendible dimensions */
- if((sid = H5Screate_simple(2, dims, maxdims)) < 0)
+ if ((sid = H5Screate_simple(2, dims, maxdims)) < 0)
FAIL_STACK_ERROR;
- if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
FAIL_STACK_ERROR;
- if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0)
+ if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0)
FAIL_STACK_ERROR;
/* Set append flush property */
- if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0)
+ if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0)
FAIL_STACK_ERROR;
- if(H5Pset_append_flush(dapl, 2, boundary, append_func, &append_ct) < 0)
+ if (H5Pset_append_flush(dapl, 2, boundary, append_func, &append_ct) < 0)
FAIL_STACK_ERROR;
/* Create the dataset */
- if((did = H5Dcreate2(fid, DNAME_LESS, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0)
+ if ((did = H5Dcreate2(fid, DNAME_LESS, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0)
TEST_ERROR;
/* Append to the dataset 2 rows at a time for 3 times */
- for(i = 0, k = 0; i < 6; i++) {
- for(j = 0; j < 10; j++, k++)
+ for (i = 0, k = 0; i < 6; i++) {
+ for (j = 0; j < 10; j++, k++)
buf[i][j] = lbuf[k] = (i * 10) + (j + 1);
- if((i + 1) % 2 == 0) {
- if(H5DOappend(did, H5P_DEFAULT, 0, (size_t)2, H5T_NATIVE_INT, lbuf) < 0)
+ if ((i + 1) % 2 == 0) {
+ if (H5DOappend(did, H5P_DEFAULT, 0, (size_t)2, H5T_NATIVE_INT, lbuf) < 0)
TEST_ERROR;
k = 0;
} /* end if */
- } /* end for */
+ } /* end for */
/* Verify the # of appends */
- if(append_ct != 2)
+ if (append_ct != 2)
TEST_ERROR;
/* Retrieve and verify object flush counts */
- if(H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0)
+ if (H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0)
FAIL_STACK_ERROR;
- if(*flush_ptr != 2)
+ if (*flush_ptr != 2)
TEST_ERROR;
/* Append 3 columns to the dataset, once */
- for(i = 0; i < 3; i++)
- for(j = 0; j < 6; j++, k++)
+ for (i = 0; i < 3; i++)
+ for (j = 0; j < 6; j++, k++)
cbuf[j][i] = buf[j][i + 10] = ((i * 6) + (j + 1)) * -1;
- if(H5DOappend(did, H5P_DEFAULT, 1, (size_t)3, H5T_NATIVE_INT, cbuf) < 0)
+ if (H5DOappend(did, H5P_DEFAULT, 1, (size_t)3, H5T_NATIVE_INT, cbuf) < 0)
TEST_ERROR;
/* Verify the # of appends */
- if(append_ct != 3)
+ if (append_ct != 3)
TEST_ERROR;
/* Retrieve and verify object flush counts */
- if(H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0)
+ if (H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0)
FAIL_STACK_ERROR;
- if(*flush_ptr != 3)
+ if (*flush_ptr != 3)
TEST_ERROR;
/* Read the dataset */
- if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0)
+ if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0)
FAIL_STACK_ERROR;
/* Verify the data */
- for(i = 0; i < 6; i++)
- for(j = 0; j < 13; j++)
- if(buf[i][j] != rbuf[i][j])
+ for (i = 0; i < 6; i++)
+ for (j = 0; j < 13; j++)
+ if (buf[i][j] != rbuf[i][j])
TEST_ERROR;
/* Clear the buffer */
HDmemset(rbuf, 0, sizeof(rbuf));
/* Close the dataset */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
FAIL_STACK_ERROR;
/* Open the dataset again */
- if((did = H5Dopen2(fid, DNAME_LESS, H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, DNAME_LESS, H5P_DEFAULT)) < 0)
FAIL_STACK_ERROR;
/* Read the dataset */
- if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0)
+ if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0)
FAIL_STACK_ERROR;
/* Verify the data */
- for(i = 0; i < 6; i++)
- for(j = 0; j < 13; j++)
- if(buf[i][j] != rbuf[i][j])
+ for (i = 0; i < 6; i++)
+ for (j = 0; j < 13; j++)
+ if (buf[i][j] != rbuf[i][j])
TEST_ERROR;
/* Closing */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
FAIL_STACK_ERROR;
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
FAIL_STACK_ERROR;
- if(H5Pclose(dapl) < 0)
+ if (H5Pclose(dapl) < 0)
FAIL_STACK_ERROR;
- if(H5Pclose(dcpl) < 0)
+ if (H5Pclose(dcpl) < 0)
FAIL_STACK_ERROR;
- if(H5Pclose(ffapl) < 0)
+ if (H5Pclose(ffapl) < 0)
FAIL_STACK_ERROR;
PASSED();
@@ -1037,13 +1047,15 @@ test_dataset_append_less(hid_t fid)
return 0;
error:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Pclose(dapl);
H5Pclose(dcpl);
H5Pclose(sid);
H5Dclose(did);
H5Pclose(ffapl);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return 1;
} /* test_dataset_append_less() */
@@ -1069,122 +1081,122 @@ error:
static int
test_dataset_append_vary(hid_t fid)
{
- hid_t did = -1; /* Dataset ID */
- hid_t sid = -1; /* Dataspace ID */
- hid_t dcpl = -1; /* A copy of dataset creation property */
- hid_t dapl = -1; /* A copy of dataset access property */
- hid_t ffapl = -1; /* The file's file access property list */
-
- hsize_t dims[2] = {0, 10}; /* Current dimension sizes */
- hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Maximum dimension sizes */
- hsize_t chunk_dims[2] = {2,5}; /* Chunk dimension sizes */
- int lbuf[60], cbuf[6][3]; /* Data buffers */
- int buf[6][13], rbuf[6][13]; /* Data buffers */
- int i, j, k; /* Local index variables */
-
- hsize_t boundary[2] = {3, 7}; /* Boundary sizes */
- unsigned append_ct = 0; /* The # of appends */
- unsigned *flush_ptr; /* Points to the flush counter */
+ hid_t did = -1; /* Dataset ID */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t dcpl = -1; /* A copy of dataset creation property */
+ hid_t dapl = -1; /* A copy of dataset access property */
+ hid_t ffapl = -1; /* The file's file access property list */
+
+ hsize_t dims[2] = {0, 10}; /* Current dimension sizes */
+ hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Maximum dimension sizes */
+ hsize_t chunk_dims[2] = {2, 5}; /* Chunk dimension sizes */
+ int lbuf[60], cbuf[6][3]; /* Data buffers */
+ int buf[6][13], rbuf[6][13]; /* Data buffers */
+ int i, j, k; /* Local index variables */
+
+ hsize_t boundary[2] = {3, 7}; /* Boundary sizes */
+ unsigned append_ct = 0; /* The # of appends */
+ unsigned *flush_ptr; /* Points to the flush counter */
HL_TESTING2("Append flush with H5DOappend()--append & boundary size vary");
/* Get the file's file access property list */
- if((ffapl = H5Fget_access_plist(fid)) < 0)
+ if ((ffapl = H5Fget_access_plist(fid)) < 0)
FAIL_STACK_ERROR;
/* Set to create a chunked dataset with 2 extendible dimensions */
- if((sid = H5Screate_simple(2, dims, maxdims)) < 0)
+ if ((sid = H5Screate_simple(2, dims, maxdims)) < 0)
FAIL_STACK_ERROR;
- if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
FAIL_STACK_ERROR;
- if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0)
+ if (H5Pset_chunk(dcpl, 2, chunk_dims) < 0)
FAIL_STACK_ERROR;
/* Set append flush property */
- if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0)
+ if ((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0)
FAIL_STACK_ERROR;
- if(H5Pset_append_flush(dapl, 2, boundary, append_func, &append_ct) < 0)
+ if (H5Pset_append_flush(dapl, 2, boundary, append_func, &append_ct) < 0)
FAIL_STACK_ERROR;
/* Create the dataset */
- if((did = H5Dcreate2(fid, DNAME_VARY, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0)
+ if ((did = H5Dcreate2(fid, DNAME_VARY, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0)
TEST_ERROR;
/* Append 6 rows to the dataset, once */
- for(i = 0, k = 0; i < 6; i++)
- for(j = 0; j < 10; j++, k++)
+ for (i = 0, k = 0; i < 6; i++)
+ for (j = 0; j < 10; j++, k++)
buf[i][j] = lbuf[k] = (i * 10) + (j + 1);
- if(H5DOappend(did, H5P_DEFAULT, 0, (size_t)6, H5T_NATIVE_INT, lbuf) < 0)
+ if (H5DOappend(did, H5P_DEFAULT, 0, (size_t)6, H5T_NATIVE_INT, lbuf) < 0)
TEST_ERROR;
/* Verify the # of appends */
- if(append_ct != 1)
+ if (append_ct != 1)
TEST_ERROR;
/* Retrieve and verify object flush counts */
- if(H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0)
+ if (H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0)
FAIL_STACK_ERROR;
- if(*flush_ptr != 1)
+ if (*flush_ptr != 1)
TEST_ERROR;
/* Append 3 columns to the dataset, once */
- for(i = 0; i < 3; i++)
- for(j = 0; j < 6; j++, k++)
+ for (i = 0; i < 3; i++)
+ for (j = 0; j < 6; j++, k++)
cbuf[j][i] = buf[j][i + 10] = ((i * 6) + (j + 1)) * -1;
- if(H5DOappend(did, H5P_DEFAULT, 1, (size_t)3, H5T_NATIVE_INT, cbuf) < 0)
+ if (H5DOappend(did, H5P_DEFAULT, 1, (size_t)3, H5T_NATIVE_INT, cbuf) < 0)
TEST_ERROR;
/* Verify the # of appends */
- if(append_ct != 1)
+ if (append_ct != 1)
TEST_ERROR;
/* Retrieve and verify object flush counts */
- if(H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0)
+ if (H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0)
FAIL_STACK_ERROR;
- if(*flush_ptr != 1)
+ if (*flush_ptr != 1)
TEST_ERROR;
/* Read the dataset */
- if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0)
+ if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0)
FAIL_STACK_ERROR;
/* Verify the data */
- for(i = 0; i < 6; i++)
- for(j = 0; j < 13; j++)
- if(buf[i][j] != rbuf[i][j])
+ for (i = 0; i < 6; i++)
+ for (j = 0; j < 13; j++)
+ if (buf[i][j] != rbuf[i][j])
TEST_ERROR;
/* Clear the dataset */
HDmemset(rbuf, 0, sizeof(rbuf));
/* Close the dataset */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
FAIL_STACK_ERROR;
/* Open the dataset again */
- if((did = H5Dopen2(fid, DNAME_VARY, H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, DNAME_VARY, H5P_DEFAULT)) < 0)
FAIL_STACK_ERROR;
/* Read the dataset */
- if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0)
+ if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0)
FAIL_STACK_ERROR;
/* Verify the data */
- for(i = 0; i < 6; i++)
- for(j = 0; j < 13; j++)
- if(buf[i][j] != rbuf[i][j])
+ for (i = 0; i < 6; i++)
+ for (j = 0; j < 13; j++)
+ if (buf[i][j] != rbuf[i][j])
TEST_ERROR;
/* Closing */
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
FAIL_STACK_ERROR;
- if(H5Sclose(sid) < 0)
+ if (H5Sclose(sid) < 0)
FAIL_STACK_ERROR;
- if(H5Pclose(dapl) < 0)
+ if (H5Pclose(dapl) < 0)
FAIL_STACK_ERROR;
- if(H5Pclose(dcpl) < 0)
+ if (H5Pclose(dcpl) < 0)
FAIL_STACK_ERROR;
- if(H5Pclose(ffapl) < 0)
+ if (H5Pclose(ffapl) < 0)
FAIL_STACK_ERROR;
PASSED();
@@ -1192,13 +1204,15 @@ test_dataset_append_vary(hid_t fid)
return 0;
error:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Pclose(dapl);
H5Pclose(dcpl);
H5Pclose(sid);
H5Dclose(did);
H5Pclose(ffapl);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return 1;
} /* test_dataset_append_vary() */
@@ -1215,64 +1229,66 @@ error:
*
*-------------------------------------------------------------------------
*/
-int main(void)
+int
+main(void)
{
- hid_t fid = -1; /* File ID */
- hid_t fapl = -1; /* File access property list */
- unsigned flush_ct = 0; /* The # of flushes */
- int nerrors = 0; /* The # of errors encountered */
+ hid_t fid = -1; /* File ID */
+ hid_t fapl = -1; /* File access property list */
+ unsigned flush_ct = 0; /* The # of flushes */
+ int nerrors = 0; /* The # of errors encountered */
/* Get a copy of file access property list */
- if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
FAIL_STACK_ERROR;
/* Set to use the latest library format */
- if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
FAIL_STACK_ERROR;
/* Set object flush property */
- if(H5Pset_object_flush_cb(fapl, flush_func, &flush_ct) < 0)
+ if (H5Pset_object_flush_cb(fapl, flush_func, &flush_ct) < 0)
FAIL_STACK_ERROR;
/* Create the test file */
- if((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
FAIL_STACK_ERROR;
nerrors += test_dataset_append_notset(fid);
nerrors += test_dataset_append_rows(fid);
- flush_ct = 0; /* Reset flush counter */
+ flush_ct = 0; /* Reset flush counter */
nerrors += test_dataset_append_columns(fid);
- flush_ct = 0; /* Reset flush counter */
+ flush_ct = 0; /* Reset flush counter */
nerrors += test_dataset_append_rows_columns(fid);
-/*
- * The following tests illustrate the scenarios when H5DOappend does not work with extensible array indexing:
- * - when the the dataset has 1 unlimited dimension and the other dimension is fixed but extendible
- * - the dataset expands along 1 dimension and then expands along the other dimension
- */
- flush_ct = 0; /* Reset flush counter */
+ /*
+ * The following tests illustrate the scenarios when H5DOappend does not work with extensible array
+ * indexing:
+ * - when the the dataset has 1 unlimited dimension and the other dimension is fixed but extendible
+ * - the dataset expands along 1 dimension and then expands along the other dimension
+ */
+ flush_ct = 0; /* Reset flush counter */
nerrors += test_dataset_append_BUG1(fid);
- flush_ct = 0; /* Reset flush counter */
+ flush_ct = 0; /* Reset flush counter */
nerrors += test_dataset_append_BUG2(fid);
- flush_ct = 0; /* Reset flush counter */
+ flush_ct = 0; /* Reset flush counter */
nerrors += test_dataset_append_less(fid);
- flush_ct = 0; /* Reset flush counter */
+ flush_ct = 0; /* Reset flush counter */
nerrors += test_dataset_append_vary(fid);
/* Closing */
- if(H5Pclose(fapl) < 0)
+ if (H5Pclose(fapl) < 0)
FAIL_STACK_ERROR;
- if(H5Fclose(fid) < 0)
+ if (H5Fclose(fid) < 0)
FAIL_STACK_ERROR;
/* Check for errors */
- if(nerrors)
+ if (nerrors)
goto error;
return EXIT_SUCCESS;
@@ -1280,4 +1296,3 @@ int main(void)
error:
return EXIT_FAILURE;
}
-
diff --git a/hl/test/test_file_image.c b/hl/test/test_file_image.c
index 504a3f5..712107e 100644
--- a/hl/test/test_file_image.c
+++ b/hl/test/test_file_image.c
@@ -1,15 +1,15 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-* Copyright by The HDF Group. *
-* Copyright by the Board of Trustees of the University of Illinois. *
-* All rights reserved. *
-* *
-* This file is part of HDF5. The full HDF5 copyright notice, including *
-* terms governing use, modification, and redistribution, is contained in *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
* distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "h5hltest.h"
#include "H5LTpublic.h"
@@ -21,8 +21,8 @@
/* For superblock version 0, 1: the offset to "file consistency flags" is 20 with size of 4 bytes */
/* The file consistency flags is the "status_flags" field in H5F_super_t */
/* Note: the offset and size will be different when using superblock version 2 for the test file */
-#define SUPER_STATUS_FLAGS_OFF_V0_V1 20
-#define SUPER_STATUS_FLAGS_SIZE_V0_V1 4
+#define SUPER_STATUS_FLAGS_OFF_V0_V1 20
+#define SUPER_STATUS_FLAGS_SIZE_V0_V1 4
/* Test of file image operations.
@@ -47,32 +47,32 @@
buffers if appropriate. */
/*-------------------------------------------------------------------------
-* test file image operations
-*-------------------------------------------------------------------------
-*/
+ * test file image operations
+ *-------------------------------------------------------------------------
+ */
static int
test_file_image(size_t open_images, size_t nflags, unsigned *flags)
{
- hid_t *file_id, *dset_id, file_space, plist; /* HDF5 ids */
- hsize_t dims1[RANK] = {2,3}; /* original dimension of datasets */
- hsize_t max_dims[RANK] = {H5S_UNLIMITED, H5S_UNLIMITED};
- int data1[6] = {1,2,3,4,5,6}; /* original contents of dataset */
- int data2[6] = {7,8,9,10,11,12}; /* "wrong" contents of dataset */
- hsize_t dims3[RANK]; /* array to read dataset dimensions */
- int data3[15]; /* array to read dataset contents */
- hsize_t dims4[RANK] = {3,5}; /* extended dimensions of datasets */
- int data4[15] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
- /* extended contents of dataset */
- ssize_t *buf_size; /* pointer to array of buffer sizes */
- void **buf_ptr; /* pointer to array of pointers to image buffers */
- char **filename; /* pointer to array of pointers to filenames */
- unsigned *input_flags; /* pointer to array of flag combinations */
- size_t i, j, k, nrow, n_values;
- herr_t status1;
- void *handle_ptr = NULL; /* pointers to driver buffer */
+ hid_t * file_id, *dset_id, file_space, plist; /* HDF5 ids */
+ hsize_t dims1[RANK] = {2, 3}; /* original dimension of datasets */
+ hsize_t max_dims[RANK] = {H5S_UNLIMITED, H5S_UNLIMITED};
+ int data1[6] = {1, 2, 3, 4, 5, 6}; /* original contents of dataset */
+ int data2[6] = {7, 8, 9, 10, 11, 12}; /* "wrong" contents of dataset */
+ hsize_t dims3[RANK]; /* array to read dataset dimensions */
+ int data3[15]; /* array to read dataset contents */
+ hsize_t dims4[RANK] = {3, 5}; /* extended dimensions of datasets */
+ int data4[15] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ /* extended contents of dataset */
+ ssize_t * buf_size; /* pointer to array of buffer sizes */
+ void ** buf_ptr; /* pointer to array of pointers to image buffers */
+ char ** filename; /* pointer to array of pointers to filenames */
+ unsigned * input_flags; /* pointer to array of flag combinations */
+ size_t i, j, k, nrow, n_values;
+ herr_t status1;
+ void * handle_ptr = NULL; /* pointers to driver buffer */
unsigned char **core_buf_ptr_ptr = NULL;
- VERIFY(open_images > 1 , "The number of open images must be greater than 1");
+ VERIFY(open_images > 1, "The number of open images must be greater than 1");
VERIFY(nflags > 0, "The number of flag combinations must be greater than 0");
@@ -131,7 +131,8 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags)
FAIL_PUTS_ERROR("H5Pset_chunk() failed");
/* create and write an integer type dataset named "dset" */
- if ((dset_id[i] = H5Dcreate2(file_id[i], DSET_NAME, H5T_NATIVE_INT, file_space, H5P_DEFAULT, plist, H5P_DEFAULT)) < 0)
+ if ((dset_id[i] = H5Dcreate2(file_id[i], DSET_NAME, H5T_NATIVE_INT, file_space, H5P_DEFAULT, plist,
+ H5P_DEFAULT)) < 0)
FAIL_PUTS_ERROR("H5Dcreate() failed");
/* dataset in open image 1 is written with "wrong" data */
@@ -172,7 +173,7 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags)
/* buffer for file image 2 is filled with counter data (non-valid image) */
if (i == 2) {
for (j = 0; j < (size_t)buf_size[i]; j++)
- ((char*)(buf_ptr[i]))[j] = (char)j;
+ ((char *)(buf_ptr[i]))[j] = (char)j;
} /* end if */
/* buffers for the rest of the file images are filled with data from the respective files */
else {
@@ -181,7 +182,7 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags)
} /* end else */
/* file close */
- if (H5Fclose (file_id[i]) < 0)
+ if (H5Fclose(file_id[i]) < 0)
FAIL_PUTS_ERROR("H5Fclose() failed");
} /* end for */
@@ -193,10 +194,12 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags)
for (i = 0; i < open_images; i++) {
/* open file image 2 filled with counter data (non-valid image) */
if (i == 2) {
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
/* attempt to set file image in the core driver */
file_id[i] = H5LTopen_file_image(buf_ptr[i], (size_t)buf_size[i], input_flags[i]);
- } H5E_END_TRY
+ }
+ H5E_END_TRY
VERIFY(file_id[i] < 0, "H5LTopen_file_image() should have failed");
} /* end if */
@@ -208,36 +211,41 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags)
/* get pointer to the image buffer of the core driver */
if (H5Fget_vfd_handle(file_id[i], H5P_DEFAULT, &handle_ptr) < 0)
- FAIL_PUTS_ERROR("H5Fget_vfd_handle() failed");
+ FAIL_PUTS_ERROR("H5Fget_vfd_handle() failed");
core_buf_ptr_ptr = (unsigned char **)handle_ptr;
/* test whether the user buffer has been copied or not */
if (input_flags[i] & H5LT_FILE_IMAGE_DONT_COPY)
- VERIFY(*core_buf_ptr_ptr == buf_ptr[i], "vfd buffer and user buffer should have been the same");
+ VERIFY(*core_buf_ptr_ptr == buf_ptr[i],
+ "vfd buffer and user buffer should have been the same");
else
VERIFY(*core_buf_ptr_ptr != buf_ptr[i], "vfd buffer and user buffer should be different");
- /*
+ /*
* When the vfd and user buffers are different and H5LT_FILE_IMAGE_OPEN_RW is enabled,
* status_flags in the superblock needs to be cleared in the vfd buffer for
* the comparison to proceed as expected. The user buffer as returned from H5Fget_file_image()
* has already cleared status_flags. The superblock's status_flags is used for the
* implementation of file locking.
*/
- if(input_flags[i] & H5LT_FILE_IMAGE_OPEN_RW && !(input_flags[i] & H5LT_FILE_IMAGE_DONT_COPY)) {
+ if (input_flags[i] & H5LT_FILE_IMAGE_OPEN_RW && !(input_flags[i] & H5LT_FILE_IMAGE_DONT_COPY)) {
void *tmp_ptr = HDmalloc((size_t)buf_size[i]);
/* Copy vfd buffer to a temporary buffer */
HDmemcpy(tmp_ptr, (void *)*core_buf_ptr_ptr, (size_t)buf_size[i]);
- /* Clear status_flags in the superblock for the vfd buffer: file locking is using status_flags */
- HDmemset((uint8_t *)tmp_ptr + SUPER_STATUS_FLAGS_OFF_V0_V1, (int)0, (size_t)SUPER_STATUS_FLAGS_SIZE_V0_V1);
+ /* Clear status_flags in the superblock for the vfd buffer: file locking is using status_flags
+ */
+ HDmemset((uint8_t *)tmp_ptr + SUPER_STATUS_FLAGS_OFF_V0_V1, (int)0,
+ (size_t)SUPER_STATUS_FLAGS_SIZE_V0_V1);
/* Does the comparision */
- if(HDmemcmp(tmp_ptr, buf_ptr[i], (size_t)buf_size[i]) != 0)
+ if (HDmemcmp(tmp_ptr, buf_ptr[i], (size_t)buf_size[i]) != 0)
FAIL_PUTS_ERROR("comparison of TMP vfd and user buffer failed");
/* Free the temporary buffer */
- if(tmp_ptr) HDfree(tmp_ptr);
- } else {
+ if (tmp_ptr)
+ HDfree(tmp_ptr);
+ }
+ else {
/* test whether the contents of the user buffer and driver buffer */
/* are equal. */
@@ -245,7 +253,7 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags)
FAIL_PUTS_ERROR("comparison of vfd and user buffer failed");
}
} /* end else */
- } /* end for */
+ } /* end for */
PASSED();
@@ -272,7 +280,7 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags)
FAIL_PUTS_ERROR("H5Sget_simple_extent_dims() failed");
/* read dataset */
- if (H5Dread(dset_id[i], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data3) < 0)
+ if (H5Dread(dset_id[i], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data3) < 0)
FAIL_PUTS_ERROR("H5Dread() failed");
/* compute number of elements in dataset */
@@ -286,7 +294,7 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags)
/* compare file image values with original data */
for (j = 0; j < n_values / nrow; j++)
for (k = 0; k < nrow; k++)
- if (data3[j * nrow + k ] == data1[j * nrow + k ])
+ if (data3[j * nrow + k] == data1[j * nrow + k])
FAIL_PUTS_ERROR("comparison of image values with original data should have failed");
} /* end if */
/* verify contents for the rest of the file images */
@@ -294,12 +302,12 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags)
/* compare file image values with original data */
for (j = 0; j < n_values / nrow; j++)
for (k = 0; k < nrow; k++)
- if (data3[j * nrow + k ] != data1[j * nrow + k ])
+ if (data3[j * nrow + k] != data1[j * nrow + k])
FAIL_PUTS_ERROR("comparison of image values with original data failed");
} /* end else */
/* close dataspace */
- if (H5Sclose (file_space) < 0)
+ if (H5Sclose(file_space) < 0)
FAIL_PUTS_ERROR("H5Sclose() failed");
} /* end for */
@@ -318,23 +326,26 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags)
/* test data write when file image access is read-only */
if (!(input_flags[i] & H5LT_FILE_IMAGE_OPEN_RW)) {
/* write dataset without extending it */
- H5E_BEGIN_TRY {
- status1 = H5Dwrite(dset_id[i], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data1);
- } H5E_END_TRY;
+ H5E_BEGIN_TRY
+ {
+ status1 = H5Dwrite(dset_id[i], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data1);
+ }
+ H5E_END_TRY;
VERIFY(status1 < 0, "H5Dwrite() should have failed");
/* extend dimensions of dataset */
- H5E_BEGIN_TRY {
- status1 = H5Dset_extent(dset_id[i], dims4);
- } H5E_END_TRY;
+ H5E_BEGIN_TRY { status1 = H5Dset_extent(dset_id[i], dims4); }
+ H5E_END_TRY;
VERIFY(status1 < 0, "H5Dset_extent() should have failed");
/* write extended dataset */
- H5E_BEGIN_TRY {
- status1 = H5Dwrite(dset_id[i], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data4);
- } H5E_END_TRY;
+ H5E_BEGIN_TRY
+ {
+ status1 = H5Dwrite(dset_id[i], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data4);
+ }
+ H5E_END_TRY;
VERIFY(status1 < 0, "H5Dwrite() should have failed");
@@ -344,7 +355,8 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags)
} /* end if */
/* test data write where file image access is read-write */
else {
- if ((input_flags[i] & H5LT_FILE_IMAGE_DONT_COPY) && (input_flags[i] & H5LT_FILE_IMAGE_DONT_RELEASE)) {
+ if ((input_flags[i] & H5LT_FILE_IMAGE_DONT_COPY) &&
+ (input_flags[i] & H5LT_FILE_IMAGE_DONT_RELEASE)) {
/* This test is disabled currently, since the new attribute causes the file
* to increase in size, but the realloc call in H5FD_core_write() fails, causing
* the flush operation to fail and the file to fail to close, eventually
@@ -396,13 +408,13 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags)
H5Aclose(attr_id);
} H5E_END_TRY;
#endif
- if (H5Dclose(dset_id[i]) < 0)
- FAIL_PUTS_ERROR("H5Dclose() failed");
- dset_id[i] = -1;
+ if (H5Dclose(dset_id[i]) < 0)
+ FAIL_PUTS_ERROR("H5Dclose() failed");
+ dset_id[i] = -1;
} /* end if */
else {
/* write dataset without extending it */
- if (H5Dwrite(dset_id[i], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data1) < 0)
+ if (H5Dwrite(dset_id[i], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data1) < 0)
FAIL_PUTS_ERROR("H5Dwrite() failed");
/* extend dimensions of dataset */
@@ -410,15 +422,15 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags)
FAIL_PUTS_ERROR("H5Dset_extent() failed");
/* write extended dataset */
- if (H5Dwrite(dset_id[i], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data4) < 0)
+ if (H5Dwrite(dset_id[i], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data4) < 0)
FAIL_PUTS_ERROR("H5Dwrite() failed");
/* close dataset */
if (H5Dclose(dset_id[i]) < 0)
FAIL_PUTS_ERROR("H5Dclose() failed");
} /* end else */
- } /* end else */
- } /* end for */
+ } /* end else */
+ } /* end for */
PASSED();
@@ -427,7 +439,7 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags)
/* read open file images and verify data */
for (i = 0; i < open_images; i++) {
/* if opening the file image failed, continue next iteration */
- if ((dset_id[i] < 0) || (file_id[i] < 0) || (!(input_flags[i] & H5LT_FILE_IMAGE_OPEN_RW )))
+ if ((dset_id[i] < 0) || (file_id[i] < 0) || (!(input_flags[i] & H5LT_FILE_IMAGE_OPEN_RW)))
continue;
/* open dataset in file image */
@@ -443,7 +455,7 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags)
FAIL_PUTS_ERROR("H5Sget_simple_extent_dims() failed");
/* read dataset */
- if (H5Dread(dset_id[i], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data3) < 0)
+ if (H5Dread(dset_id[i], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data3) < 0)
FAIL_PUTS_ERROR("H5Dread() failed");
/* compute number of elements in dataset */
@@ -455,11 +467,11 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags)
/* verify contents for the file images */
for (j = 0; j < n_values / nrow; j++)
for (k = 0; k < nrow; k++)
- if (data3[j * nrow + k ] != data4[j * nrow + k ])
+ if (data3[j * nrow + k] != data4[j * nrow + k])
FAIL_PUTS_ERROR("comparison of image values with original data failed");
/* close dataspace */
- if (H5Sclose (file_space) < 0)
+ if (H5Sclose(file_space) < 0)
FAIL_PUTS_ERROR("H5Sclose() failed");
/* close dataset */
@@ -485,7 +497,8 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags)
FAIL_PUTS_ERROR("HDremove() failed");
/* free shared buffer if appropriate */
- if (!(input_flags[i] & H5LT_FILE_IMAGE_DONT_COPY) || (input_flags[i] & H5LT_FILE_IMAGE_DONT_RELEASE)) {
+ if (!(input_flags[i] & H5LT_FILE_IMAGE_DONT_COPY) ||
+ (input_flags[i] & H5LT_FILE_IMAGE_DONT_RELEASE)) {
VERIFY(buf_ptr[i] != NULL, "buffer pointer must be non NULL");
HDfree(buf_ptr[i]);
} /* end if */
@@ -512,15 +525,16 @@ error:
}
/*-------------------------------------------------------------------------
-* the main program
-*-------------------------------------------------------------------------
-*/
-int main( void )
+ * the main program
+ *-------------------------------------------------------------------------
+ */
+int
+main(void)
{
- int nerrors = 0;
- size_t open_images = 10; /* number of open file images */
- size_t nflags = 8; /* number of flag combinations */
- unsigned flags[8]; /* array with flag combinations */
+ int nerrors = 0;
+ size_t open_images = 10; /* number of open file images */
+ size_t nflags = 8; /* number of flag combinations */
+ unsigned flags[8]; /* array with flag combinations */
/* set flag combinations for testing */
flags[0] = 0;
@@ -533,14 +547,14 @@ int main( void )
flags[7] = H5LT_FILE_IMAGE_OPEN_RW | H5LT_FILE_IMAGE_DONT_COPY | H5LT_FILE_IMAGE_DONT_RELEASE;
/* Test file image operations. The flag combinations are assigned to file images in round-robin fashion */
- nerrors += test_file_image(open_images, nflags, flags) < 0? 1 : 0;
+ nerrors += test_file_image(open_images, nflags, flags) < 0 ? 1 : 0;
- if (nerrors) goto error;
+ if (nerrors)
+ goto error;
HDprintf("File image tests passed.\n");
return 0;
error:
- HDprintf("***** %d IMAGE TEST%s FAILED! *****\n",nerrors, 1 == nerrors ? "" : "S");
+ HDprintf("***** %d IMAGE TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S");
return 1;
}
-
diff --git a/hl/test/test_h5do_compat.c b/hl/test/test_h5do_compat.c
index 75028fb..7efef3f 100644
--- a/hl/test/test_h5do_compat.c
+++ b/hl/test/test_h5do_compat.c
@@ -20,12 +20,11 @@
#ifndef H5_NO_DEPRECATED_SYMBOLS
-#define FILE_NAME "h5do_compat.h5"
-#define DATASET_NAME "direct_chunk_io"
-
-#define NX 8
-#define CHUNK_NX 4
+#define FILE_NAME "h5do_compat.h5"
+#define DATASET_NAME "direct_chunk_io"
+#define NX 8
+#define CHUNK_NX 4
/*-------------------------------------------------------------------------
* Function: test_direct_chunk_write
@@ -40,12 +39,12 @@
static hid_t
create_dataset(hid_t fid)
{
- hid_t did = H5I_INVALID_HID;
- hid_t sid = H5I_INVALID_HID;
- hid_t dcpl_id = H5I_INVALID_HID;
- hsize_t dims[1] = {NX};
- hsize_t maxdims[1] = {H5S_UNLIMITED};
- hsize_t chunk_dims[1] = {CHUNK_NX};
+ hid_t did = H5I_INVALID_HID;
+ hid_t sid = H5I_INVALID_HID;
+ hid_t dcpl_id = H5I_INVALID_HID;
+ hsize_t dims[1] = {NX};
+ hsize_t maxdims[1] = {H5S_UNLIMITED};
+ hsize_t chunk_dims[1] = {CHUNK_NX};
int data[NX];
int i;
@@ -79,19 +78,19 @@ create_dataset(hid_t fid)
return did;
- error:
- H5E_BEGIN_TRY {
+error:
+ H5E_BEGIN_TRY
+ {
H5Dclose(did);
H5Sclose(sid);
H5Pclose(dcpl_id);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
return H5I_INVALID_HID;
} /* end create_dataset() */
-
-
/*-------------------------------------------------------------------------
* Function: test_direct_chunk_write
*
@@ -105,11 +104,11 @@ create_dataset(hid_t fid)
static int
test_direct_chunk_write(hid_t did)
{
- unsigned filter_mask = 0;
- int chunk_data[CHUNK_NX];
- hsize_t offset[1];
- size_t data_size;
- int i;
+ unsigned filter_mask = 0;
+ int chunk_data[CHUNK_NX];
+ hsize_t offset[1];
+ size_t data_size;
+ int i;
HL_TESTING2("H5DOwrite_chunk wrapper");
@@ -124,7 +123,7 @@ test_direct_chunk_write(hid_t did)
* dataset, using the direct writing function.
*/
offset[0] = 0;
- for (i = 0; i < NX/CHUNK_NX; i++) {
+ for (i = 0; i < NX / CHUNK_NX; i++) {
if (H5DOwrite_chunk(did, H5P_DEFAULT, filter_mask, offset, data_size, chunk_data) < 0)
TEST_ERROR
offset[0] += CHUNK_NX;
@@ -138,7 +137,6 @@ error:
return 1;
} /* test_direct_chunk_write() */
-
/*-------------------------------------------------------------------------
* Function: test_direct_chunk_read
*
@@ -152,22 +150,22 @@ error:
static int
test_direct_chunk_read(hid_t did)
{
- hid_t mem_sid = H5I_INVALID_HID;
- hid_t file_sid = H5I_INVALID_HID;
- hsize_t dims[1] = {NX};
- hsize_t chunk_dims[1] = {CHUNK_NX};
+ hid_t mem_sid = H5I_INVALID_HID;
+ hid_t file_sid = H5I_INVALID_HID;
+ hsize_t dims[1] = {NX};
+ hsize_t chunk_dims[1] = {CHUNK_NX};
- unsigned filter_mask;
- int chunk_data[CHUNK_NX]; /* Chunk read with H5DOread_chunk */
- int check[CHUNK_NX]; /* Chunk read with H5Dread */
- hsize_t offset[1];
+ unsigned filter_mask;
+ int chunk_data[CHUNK_NX]; /* Chunk read with H5DOread_chunk */
+ int check[CHUNK_NX]; /* Chunk read with H5Dread */
+ hsize_t offset[1];
- hsize_t start[1]; /* Start of hyperslab */
- hsize_t stride[1]; /* Stride of hyperslab */
- hsize_t count[1]; /* Block count */
- hsize_t block[1]; /* Block sizes */
+ hsize_t start[1]; /* Start of hyperslab */
+ hsize_t stride[1]; /* Stride of hyperslab */
+ hsize_t count[1]; /* Block count */
+ hsize_t block[1]; /* Block sizes */
- int i,j;
+ int i, j;
HL_TESTING2("H5DOread_chunk wrapper");
@@ -178,7 +176,7 @@ test_direct_chunk_read(hid_t did)
TEST_ERROR
/* For each chunk in the dataset, compare the result of H5Dread and H5DOread_chunk. */
- for (i = 0; i < NX/CHUNK_NX; i++) {
+ for (i = 0; i < NX / CHUNK_NX; i++) {
/* Select hyperslab for one chunk in the file */
start[0] = (hsize_t)i * CHUNK_NX;
@@ -197,7 +195,7 @@ test_direct_chunk_read(hid_t did)
/* Read the raw chunk back */
HDmemset(chunk_data, 0, CHUNK_NX * sizeof(int));
filter_mask = UINT_MAX;
- offset[0] = (hsize_t)i * CHUNK_NX;
+ offset[0] = (hsize_t)i * CHUNK_NX;
if (H5DOread_chunk(did, H5P_DEFAULT, offset, &filter_mask, chunk_data) < 0)
TEST_ERROR
@@ -221,10 +219,12 @@ test_direct_chunk_read(hid_t did)
return 0;
error:
- H5E_BEGIN_TRY {
+ H5E_BEGIN_TRY
+ {
H5Sclose(mem_sid);
H5Sclose(file_sid);
- } H5E_END_TRY;
+ }
+ H5E_END_TRY;
H5_FAILED();
return 1;
@@ -232,7 +232,6 @@ error:
#endif /* H5_NO_DEPRECATED_SYMBOLS */
-
/*-------------------------------------------------------------------------
* Function: main
*
@@ -244,7 +243,8 @@ error:
*
*-------------------------------------------------------------------------
*/
-int main( void )
+int
+main(void)
{
#ifdef H5_NO_DEPRECATED_SYMBOLS
@@ -254,9 +254,9 @@ int main( void )
#else
- hid_t fid = H5I_INVALID_HID;
- hid_t did = H5I_INVALID_HID;
- int nerrors = 0;
+ hid_t fid = H5I_INVALID_HID;
+ hid_t did = H5I_INVALID_HID;
+ int nerrors = 0;
if ((fid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto error;
diff --git a/hl/test/test_image.c b/hl/test/test_image.c
index 06a0ff3..0cdb2d3 100644
--- a/hl/test/test_image.c
+++ b/hl/test/test_image.c
@@ -1,15 +1,15 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-* Copyright by The HDF Group. *
-* Copyright by the Board of Trustees of the University of Illinois. *
-* All rights reserved. *
-* *
-* This file is part of HDF5. The full HDF5 copyright notice, including *
-* terms governing use, modification, and redistribution, is contained in *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
* distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "h5hltest.h"
#include "H5srcdir.h"
@@ -35,10 +35,9 @@
#define PAL3_NAME "earth"
#define PAL4_NAME "blue-red"
-
-#define WIDTH 400
-#define HEIGHT 200
-#define PAL_ENTRIES 256
+#define WIDTH 400
+#define HEIGHT 200
+#define PAL_ENTRIES 256
/* struct to store RGB values read from a .pal file */
typedef struct rgb_t {
@@ -51,54 +50,57 @@ typedef struct rgb_t {
static int test_simple(void);
static int test_data(void);
static int test_generate(void);
-static int read_data(const char* file_name, hsize_t *width, hsize_t *height );
-static int read_palette(const char* file_name, rgb_t *palette, size_t palette_size);
+static int read_data(const char *file_name, hsize_t *width, hsize_t *height);
+static int read_palette(const char *file_name, rgb_t *palette, size_t palette_size);
/* globals */
unsigned char *image_data = NULL;
/*-------------------------------------------------------------------------
-* the main program
-*-------------------------------------------------------------------------
-*/
+ * the main program
+ *-------------------------------------------------------------------------
+ */
-int main(void)
+int
+main(void)
{
- int nerrors=0;
+ int nerrors = 0;
- nerrors += test_simple()<0 ?1:0;
- nerrors += test_data()<0 ?1:0;
- nerrors += test_generate()<0 ?1:0;
+ nerrors += test_simple() < 0 ? 1 : 0;
+ nerrors += test_data() < 0 ? 1 : 0;
+ nerrors += test_generate() < 0 ? 1 : 0;
- if (nerrors) goto error;
+ if (nerrors)
+ goto error;
HDprintf("All image tests passed.\n");
return 0;
error:
- HDprintf("***** %d IMAGE TEST%s FAILED! *****\n",nerrors, 1 == nerrors ? "" : "S");
+ HDprintf("***** %d IMAGE TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S");
return 1;
}
/*-------------------------------------------------------------------------
-* a simple test that generates images and palettes
-*-------------------------------------------------------------------------
-*/
+ * a simple test that generates images and palettes
+ *-------------------------------------------------------------------------
+ */
-static int test_simple(void)
+static int
+test_simple(void)
{
- hsize_t width = WIDTH;
- hsize_t height = HEIGHT;
- hsize_t planes;
- hid_t fid;
- int i, j, n, space;
- hsize_t u;
- char interlace[20];
- hssize_t npals;
+ hsize_t width = WIDTH;
+ hsize_t height = HEIGHT;
+ hsize_t planes;
+ hid_t fid;
+ int i, j, n, space;
+ hsize_t u;
+ char interlace[20];
+ hssize_t npals;
/* 8-bit image */
unsigned char *buf1 = NULL;
- unsigned char pal[ PAL_ENTRIES * 3 ]; /* palette array */
- hsize_t pal_dims[2] = {PAL_ENTRIES,3}; /* palette dimensions */
+ unsigned char pal[PAL_ENTRIES * 3]; /* palette array */
+ hsize_t pal_dims[2] = {PAL_ENTRIES, 3}; /* palette dimensions */
/* 24-bit image */
unsigned char *buf2 = NULL;
@@ -106,395 +108,373 @@ static int test_simple(void)
/* read data */
unsigned char *buf1_out = NULL;
unsigned char *buf2_out = NULL;
- unsigned char pal_out[ PAL_ENTRIES * 3 ]; /* palette array */
- hsize_t pal_dims_out[2]; /* palette dimensions */
+ unsigned char pal_out[PAL_ENTRIES * 3]; /* palette array */
+ hsize_t pal_dims_out[2]; /* palette dimensions */
/* Allocate image buffers */
buf1 = (unsigned char *)HDmalloc(WIDTH * HEIGHT);
HDassert(buf1);
- buf2 = (unsigned char *)HDmalloc(WIDTH * HEIGHT * 3);
+ buf2 = (unsigned char *)HDmalloc(WIDTH * HEIGHT * 3);
HDassert(buf2);
buf1_out = (unsigned char *)HDmalloc(WIDTH * HEIGHT);
HDassert(buf1_out);
- buf2_out = (unsigned char *)HDmalloc(WIDTH * HEIGHT * 3);
+ buf2_out = (unsigned char *)HDmalloc(WIDTH * HEIGHT * 3);
HDassert(buf2_out);
/* create an image */
- space = WIDTH*HEIGHT / PAL_ENTRIES;
- for (i=0, j=0, n=0; i < WIDTH*HEIGHT; i++, j++ )
- {
+ space = WIDTH * HEIGHT / PAL_ENTRIES;
+ for (i = 0, j = 0, n = 0; i < WIDTH * HEIGHT; i++, j++) {
buf1[i] = (unsigned char)n;
- if ( j > space )
- {
+ if (j > space) {
n++;
- j=0;
+ j = 0;
}
-
}
/* create an image */
- space = WIDTH*HEIGHT / 256;
- for (i=0, j=0, n=0; i < WIDTH*HEIGHT*3; i+=3, j++ )
- {
- buf2[i] = (unsigned char)n;
- buf2[i+1] = 0;
- buf2[i+2] = (unsigned char)(255 - n);
- if ( j > space )
- {
+ space = WIDTH * HEIGHT / 256;
+ for (i = 0, j = 0, n = 0; i < WIDTH * HEIGHT * 3; i += 3, j++) {
+ buf2[i] = (unsigned char)n;
+ buf2[i + 1] = 0;
+ buf2[i + 2] = (unsigned char)(255 - n);
+ if (j > space) {
n++;
- j=0;
+ j = 0;
}
}
/*-------------------------------------------------------------------------
- * define a palette, blue to red tones
- *-------------------------------------------------------------------------
- */
- for ( i=0, n=0; i<PAL_ENTRIES*3; i+=3, n++)
- {
- pal[i] =(unsigned char)n; /* red */
- pal[i+1]=0; /* green */
- pal[i+2]=(unsigned char)(255 - n); /* blue */
+ * define a palette, blue to red tones
+ *-------------------------------------------------------------------------
+ */
+ for (i = 0, n = 0; i < PAL_ENTRIES * 3; i += 3, n++) {
+ pal[i] = (unsigned char)n; /* red */
+ pal[i + 1] = 0; /* green */
+ pal[i + 2] = (unsigned char)(255 - n); /* blue */
}
/* Create a new HDF5 file using default properties. */
- fid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT );
+ fid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
/*-------------------------------------------------------------------------
- * Indexed image test
- *-------------------------------------------------------------------------
- */
+ * Indexed image test
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("indexed image");
/* Write image */
- if ( H5IMmake_image_8bit( fid, IMAGE1_NAME, width, height, buf1 ) < 0 )
+ if (H5IMmake_image_8bit(fid, IMAGE1_NAME, width, height, buf1) < 0)
goto out;
/* Make a palette */
- if ( H5IMmake_palette( fid, PAL_NAME, pal_dims, pal ) < 0 )
+ if (H5IMmake_palette(fid, PAL_NAME, pal_dims, pal) < 0)
goto out;
/* Attach a palette to the image dataset */
- if ( H5IMlink_palette( fid, IMAGE1_NAME, PAL_NAME ) < 0 )
+ if (H5IMlink_palette(fid, IMAGE1_NAME, PAL_NAME) < 0)
goto out;
/* Read image */
- if ( H5IMget_image_info( fid, IMAGE1_NAME, &width, &height, &planes, interlace, &npals ) < 0 )
+ if (H5IMget_image_info(fid, IMAGE1_NAME, &width, &height, &planes, interlace, &npals) < 0)
goto out;
- if ( H5IMread_image( fid, IMAGE1_NAME, buf1_out ) < 0 )
+ if (H5IMread_image(fid, IMAGE1_NAME, buf1_out) < 0)
goto out;
- for (u = 0; u < height*width*planes; u++)
- {
- if ( buf1[u] != buf1_out[u] )
+ for (u = 0; u < height * width * planes; u++) {
+ if (buf1[u] != buf1_out[u])
goto out;
-
}
-
PASSED();
/*-------------------------------------------------------------------------
- * True color image test
- *-------------------------------------------------------------------------
- */
+ * True color image test
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("true color image");
/* Write image */
- if ( H5IMmake_image_24bit( fid, IMAGE2_NAME, width, height, "INTERLACE_PIXEL", buf2 ) )
+ if (H5IMmake_image_24bit(fid, IMAGE2_NAME, width, height, "INTERLACE_PIXEL", buf2))
goto out;
/* Read image */
- if ( H5IMget_image_info( fid, IMAGE2_NAME, &width, &height, &planes, interlace, &npals ) < 0 )
+ if (H5IMget_image_info(fid, IMAGE2_NAME, &width, &height, &planes, interlace, &npals) < 0)
goto out;
- if ( H5IMread_image( fid, IMAGE2_NAME, buf2_out ) < 0 )
+ if (H5IMread_image(fid, IMAGE2_NAME, buf2_out) < 0)
goto out;
- for (u = 0; u < height*width*planes; u++)
- {
- if ( buf2[u] != buf2_out[u] )
+ for (u = 0; u < height * width * planes; u++) {
+ if (buf2[u] != buf2_out[u])
goto out;
}
-
PASSED();
/*-------------------------------------------------------------------------
- * H5IMget_npalettes test
- *-------------------------------------------------------------------------
- */
+ * H5IMget_npalettes test
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("pallete functions");
- if ( H5IMget_npalettes( fid, IMAGE1_NAME, &npals ) < 0 )
+ if (H5IMget_npalettes(fid, IMAGE1_NAME, &npals) < 0)
goto out;
/*-------------------------------------------------------------------------
- * H5IMget_palette_info test
- *-------------------------------------------------------------------------
- */
+ * H5IMget_palette_info test
+ *-------------------------------------------------------------------------
+ */
- if ( H5IMget_palette_info( fid, IMAGE1_NAME, 0, pal_dims_out ) < 0 )
+ if (H5IMget_palette_info(fid, IMAGE1_NAME, 0, pal_dims_out) < 0)
goto out;
- for (i = 0; i < 2; i++)
- {
- if ( pal_dims[i] != pal_dims_out[i] )
+ for (i = 0; i < 2; i++) {
+ if (pal_dims[i] != pal_dims_out[i])
goto out;
}
/*-------------------------------------------------------------------------
- * H5IMget_palette test
- *-------------------------------------------------------------------------
- */
+ * H5IMget_palette test
+ *-------------------------------------------------------------------------
+ */
- if ( H5IMget_palette( fid, IMAGE1_NAME, 0, pal_out ) < 0 )
+ if (H5IMget_palette(fid, IMAGE1_NAME, 0, pal_out) < 0)
goto out;
- for (i = 0; i < PAL_ENTRIES * 3; i++)
- {
- if ( pal[i] != pal_out[i] )
+ for (i = 0; i < PAL_ENTRIES * 3; i++) {
+ if (pal[i] != pal_out[i])
goto out;
}
/*-------------------------------------------------------------------------
- * H5IMis_image test
- *-------------------------------------------------------------------------
- */
+ * H5IMis_image test
+ *-------------------------------------------------------------------------
+ */
- if ( H5IMis_image( fid, IMAGE1_NAME ) < 0 )
+ if (H5IMis_image(fid, IMAGE1_NAME) < 0)
goto out;
- if ( H5IMis_image( fid, IMAGE2_NAME ) < 0 )
+ if (H5IMis_image(fid, IMAGE2_NAME) < 0)
goto out;
/*-------------------------------------------------------------------------
- * H5IMis_palette test
- *-------------------------------------------------------------------------
- */
+ * H5IMis_palette test
+ *-------------------------------------------------------------------------
+ */
- if ( H5IMis_palette( fid, PAL_NAME ) < 0 )
+ if (H5IMis_palette(fid, PAL_NAME) < 0)
goto out;
/*-------------------------------------------------------------------------
- * end tests
- *-------------------------------------------------------------------------
- */
+ * end tests
+ *-------------------------------------------------------------------------
+ */
- if(buf1)
+ if (buf1)
HDfree(buf1);
- if(buf2)
+ if (buf2)
HDfree(buf2);
- if(buf1_out)
+ if (buf1_out)
HDfree(buf1_out);
- if(buf2_out)
+ if (buf2_out)
HDfree(buf2_out);
/* Close the file. */
- if(H5Fclose( fid ) < 0)
+ if (H5Fclose(fid) < 0)
goto out;
-
PASSED();
return 0;
/* error zone, gracefully close */
out:
- if(buf1)
+ if (buf1)
HDfree(buf1);
- if(buf2)
+ if (buf2)
HDfree(buf2);
- if(buf1_out)
+ if (buf1_out)
HDfree(buf1_out);
- if(buf2_out)
+ if (buf2_out)
HDfree(buf2_out);
- H5E_BEGIN_TRY {
- H5Fclose(fid);
- } H5E_END_TRY;
+ H5E_BEGIN_TRY { H5Fclose(fid); }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-
/*-------------------------------------------------------------------------
-* read sample realistic image data from ASCII files
-*-------------------------------------------------------------------------
-*/
+ * read sample realistic image data from ASCII files
+ *-------------------------------------------------------------------------
+ */
-static int test_data(void)
+static int
+test_data(void)
{
- hid_t fid;
- hsize_t pal_dims[2];
- hsize_t width;
- hsize_t height;
- unsigned char pal[256*3]; /* buffer to hold an HDF5 palette */
- rgb_t rgb[256]; /* buffer to hold a .pal file palette */
- int i, n;
+ hid_t fid;
+ hsize_t pal_dims[2];
+ hsize_t width;
+ hsize_t height;
+ unsigned char pal[256 * 3]; /* buffer to hold an HDF5 palette */
+ rgb_t rgb[256]; /* buffer to hold a .pal file palette */
+ int i, n;
/* create a file using default properties */
- if ((fid=H5Fcreate(FILE2,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT))<0)
+ if ((fid = H5Fcreate(FILE2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
HDprintf("Testing read ascii image data and generate images\n");
/*-------------------------------------------------------------------------
- * read 8bit image data
- *-------------------------------------------------------------------------
- */
+ * read 8bit image data
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("make indexed image");
/* read first data file */
- if (read_data(DATA_FILE1,&width,&height)<0)
+ if (read_data(DATA_FILE1, &width, &height) < 0)
goto out;
/* make an image */
- if (H5IMmake_image_8bit(fid,IMAGE1_NAME,width,height,image_data)<0)
+ if (H5IMmake_image_8bit(fid, IMAGE1_NAME, width, height, image_data) < 0)
goto out;
PASSED();
-
HL_TESTING2("attaching palettes");
/*-------------------------------------------------------------------------
- * palette #1. rainbow palette. data is contained in "pal_rgb.h"
- *-------------------------------------------------------------------------
- */
+ * palette #1. rainbow palette. data is contained in "pal_rgb.h"
+ *-------------------------------------------------------------------------
+ */
/* initialize the palette data */
pal_dims[0] = 256;
pal_dims[1] = 3;
/* make a palette */
- if (H5IMmake_palette(fid,PAL1_NAME,pal_dims,pal_rgb)<0)
+ if (H5IMmake_palette(fid, PAL1_NAME, pal_dims, pal_rgb) < 0)
goto out;
/* attach a palette to the image dataset */
- if (H5IMlink_palette(fid,IMAGE1_NAME,PAL1_NAME)<0)
+ if (H5IMlink_palette(fid, IMAGE1_NAME, PAL1_NAME) < 0)
goto out;
/*-------------------------------------------------------------------------
- * palette #2. sepia palette.
- * read a PAL file and attach the palette to the HDF5 file
- *-------------------------------------------------------------------------
- */
+ * palette #2. sepia palette.
+ * read a PAL file and attach the palette to the HDF5 file
+ *-------------------------------------------------------------------------
+ */
/* read a PAL file */
if (read_palette(PAL2_FILE, rgb, (sizeof(rgb) / sizeof(rgb[0]))) < 0)
goto out;
/* transfer to the HDF5 buffer */
- for ( i=0, n=0; i<256*3; i+=3, n++)
- {
- pal[i] =rgb[n].r;
- pal[i+1]=rgb[n].g;
- pal[i+2]=rgb[n].b;
+ for (i = 0, n = 0; i < 256 * 3; i += 3, n++) {
+ pal[i] = rgb[n].r;
+ pal[i + 1] = rgb[n].g;
+ pal[i + 2] = rgb[n].b;
}
/* make a palette */
- if (H5IMmake_palette(fid,PAL2_NAME,pal_dims,pal)<0)
+ if (H5IMmake_palette(fid, PAL2_NAME, pal_dims, pal) < 0)
goto out;
/* attach the palette to the image dataset */
- if (H5IMlink_palette(fid,IMAGE1_NAME,PAL2_NAME)<0)
+ if (H5IMlink_palette(fid, IMAGE1_NAME, PAL2_NAME) < 0)
goto out;
/*-------------------------------------------------------------------------
- * palette #3. earth palette.
- * read a PAL file and attach the palette to the HDF5 file
- *-------------------------------------------------------------------------
- */
+ * palette #3. earth palette.
+ * read a PAL file and attach the palette to the HDF5 file
+ *-------------------------------------------------------------------------
+ */
/* read a PAL file */
if (read_palette(PAL3_FILE, rgb, (sizeof(rgb) / sizeof(rgb[0]))) < 0)
goto out;
/* transfer to the HDF5 buffer */
- for ( i=0, n=0; i<256*3; i+=3, n++)
- {
- pal[i] =rgb[n].r;
- pal[i+1]=rgb[n].g;
- pal[i+2]=rgb[n].b;
+ for (i = 0, n = 0; i < 256 * 3; i += 3, n++) {
+ pal[i] = rgb[n].r;
+ pal[i + 1] = rgb[n].g;
+ pal[i + 2] = rgb[n].b;
}
/* make a palette */
- if (H5IMmake_palette(fid,PAL3_NAME,pal_dims,pal)<0)
+ if (H5IMmake_palette(fid, PAL3_NAME, pal_dims, pal) < 0)
goto out;
/* attach the palette to the image dataset */
- if (H5IMlink_palette(fid,IMAGE1_NAME,PAL3_NAME)<0)
+ if (H5IMlink_palette(fid, IMAGE1_NAME, PAL3_NAME) < 0)
goto out;
PASSED();
-
/*-------------------------------------------------------------------------
- * palette #4. blue-red
- * make a palette whith blue to red colors
- *-------------------------------------------------------------------------
- */
- for ( i=0, n=0; i<256*3; i+=3, n++)
- {
- pal[i] =(unsigned char)n;
- pal[i+1]=0;
- pal[i+2]=(unsigned char)(255 - n);
+ * palette #4. blue-red
+ * make a palette whith blue to red colors
+ *-------------------------------------------------------------------------
+ */
+ for (i = 0, n = 0; i < 256 * 3; i += 3, n++) {
+ pal[i] = (unsigned char)n;
+ pal[i + 1] = 0;
+ pal[i + 2] = (unsigned char)(255 - n);
}
/* make a palette */
- if (H5IMmake_palette(fid,PAL4_NAME,pal_dims,pal)<0)
+ if (H5IMmake_palette(fid, PAL4_NAME, pal_dims, pal) < 0)
goto out;
/* attach the palette to the image dataset */
- if (H5IMlink_palette(fid,IMAGE1_NAME,PAL4_NAME)<0)
+ if (H5IMlink_palette(fid, IMAGE1_NAME, PAL4_NAME) < 0)
goto out;
-
/*-------------------------------------------------------------------------
- * true color image example with pixel interlace
- *-------------------------------------------------------------------------
- */
+ * true color image example with pixel interlace
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("make true color image with pixel interlace");
/* read second data file */
- if ((read_data(DATA_FILE2,&width,&height))<0)
+ if ((read_data(DATA_FILE2, &width, &height)) < 0)
goto out;
/* make image */
- if ((H5IMmake_image_24bit(fid,IMAGE2_NAME,width,height,"INTERLACE_PIXEL",image_data))<0)
+ if ((H5IMmake_image_24bit(fid, IMAGE2_NAME, width, height, "INTERLACE_PIXEL", image_data)) < 0)
goto out;
PASSED();
/*-------------------------------------------------------------------------
- * True color image example with plane interlace
- *-------------------------------------------------------------------------
- */
+ * True color image example with plane interlace
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("make true color image with plane interlace");
/* read third data file */
- if ((read_data(DATA_FILE3,&width,&height))<0)
+ if ((read_data(DATA_FILE3, &width, &height)) < 0)
goto out;
/* make image */
- if ((H5IMmake_image_24bit(fid,IMAGE3_NAME,width,height,"INTERLACE_PLANE",image_data))<0)
+ if ((H5IMmake_image_24bit(fid, IMAGE3_NAME, width, height, "INTERLACE_PLANE", image_data)) < 0)
goto out;
PASSED();
-
/*-------------------------------------------------------------------------
- * close
- *-------------------------------------------------------------------------
- */
- if (H5Fclose(fid)<0)
+ * close
+ *-------------------------------------------------------------------------
+ */
+ if (H5Fclose(fid) < 0)
goto out;
/* Release memory buffer */
@@ -505,18 +485,16 @@ static int test_data(void)
/* error zone, gracefully close */
out:
/* Release memory buffer */
- if(image_data)
+ if (image_data)
HDfree(image_data);
- H5E_BEGIN_TRY {
- H5Fclose(fid);
- } H5E_END_TRY;
+ H5E_BEGIN_TRY { H5Fclose(fid); }
+ H5E_END_TRY;
H5_FAILED();
return FAIL;
}
-
/*
The following test provides an examples of how to generate HDF5 image data from
floating point data. In the example we use real life topographic data
@@ -530,34 +508,34 @@ http://modb.oce.ulg.ac.be/
*/
-static int test_generate(void)
+static int
+test_generate(void)
{
- hid_t fid;
- hsize_t pal_dims[2] = { 256, 3 };
- float *data = NULL;
- int imax, jmax, kmax;
- int n_elements;
- float valex, xmin, xmax, value;
- FILE *f = NULL;
+ hid_t fid;
+ hsize_t pal_dims[2] = {256, 3};
+ float * data = NULL;
+ int imax, jmax, kmax;
+ int n_elements;
+ float valex, xmin, xmax, value;
+ FILE * f = NULL;
const char *data_file = H5_get_srcdir_filename(DATA_FILE4);
- int i;
- int retval = FAIL;
+ int i;
+ int retval = FAIL;
/* create a file using default properties */
- if ((fid=H5Fcreate(FILE3,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT))<0)
+ if ((fid = H5Fcreate(FILE3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto out;
HDprintf("Testing read and process data and make indexed images\n");
/*-------------------------------------------------------------------------
- * read data; the file data format is described below
- *-------------------------------------------------------------------------
- */
+ * read data; the file data format is described below
+ *-------------------------------------------------------------------------
+ */
- f = HDfopen( data_file, "r" ) ;
- if ( f == NULL )
- {
- HDprintf( "Could not find file %s. Try set $srcdir \n", data_file );
+ f = HDfopen(data_file, "r");
+ if (f == NULL) {
+ HDprintf("Could not find file %s. Try set $srcdir \n", data_file);
goto out;
}
@@ -596,45 +574,43 @@ static int test_generate(void)
!
*/
-
- if(fscanf( f, "%d %d %d", &imax, &jmax, &kmax ) < 0 && HDferror(f)) {
- HDprintf( "fscanf error in file %s.\n", data_file );
+ if (fscanf(f, "%d %d %d", &imax, &jmax, &kmax) < 0 && HDferror(f)) {
+ HDprintf("fscanf error in file %s.\n", data_file);
goto out;
} /* end if */
- if(fscanf( f, "%f %f %f", &valex, &xmin, &xmax ) < 0 && HDferror(f)) {
- HDprintf( "fscanf error in file %s.\n", data_file );
+ if (fscanf(f, "%f %f %f", &valex, &xmin, &xmax) < 0 && HDferror(f)) {
+ HDprintf("fscanf error in file %s.\n", data_file);
goto out;
} /* end if */
/* Sanity check on scanned-in values */
- if(imax < 1 || jmax < 1 || kmax < 1)
+ if (imax < 1 || jmax < 1 || kmax < 1)
goto out;
/* Test product for integer overflow */
- if(imax > INT_MAX / jmax)
+ if (imax > INT_MAX / jmax)
goto out;
- if(imax * jmax > INT_MAX / kmax)
+ if (imax * jmax > INT_MAX / kmax)
goto out;
n_elements = imax * jmax * kmax;
/* Test buffer sizes for overflow */
- if(n_elements > INT_MAX / (int)sizeof(unsigned char))
+ if (n_elements > INT_MAX / (int)sizeof(unsigned char))
goto out;
- if(n_elements > INT_MAX / (int)sizeof(float))
+ if (n_elements > INT_MAX / (int)sizeof(float))
goto out;
data = (float *)HDmalloc((size_t)n_elements * sizeof(float));
- if(NULL == data)
+ if (NULL == data)
goto out;
image_data = (unsigned char *)HDmalloc((size_t)n_elements * sizeof(unsigned char));
- if(NULL == image_data)
+ if (NULL == image_data)
goto out;
- for ( i = 0; i < n_elements; i++ )
- {
- if(fscanf( f, "%f ", &value ) < 0 && HDferror(f)) {
- HDprintf( "fscanf error in file %s.\n", data_file );
+ for (i = 0; i < n_elements; i++) {
+ if (fscanf(f, "%f ", &value) < 0 && HDferror(f)) {
+ HDprintf("fscanf error in file %s.\n", data_file);
goto out;
} /* end if */
data[i] = value;
@@ -643,93 +619,90 @@ static int test_generate(void)
f = NULL;
/*-------------------------------------------------------------------------
- * transform the data from floating point to unsigned char
- * we are processing all the data here
- *-------------------------------------------------------------------------
- */
+ * transform the data from floating point to unsigned char
+ * we are processing all the data here
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("make indexed image from all the data");
- for ( i = 0; i < n_elements; i++ )
- image_data[i] = (unsigned char)(( 255 * (data[i] - xmin ) ) / (xmax - xmin ));
+ for (i = 0; i < n_elements; i++)
+ image_data[i] = (unsigned char)((255 * (data[i] - xmin)) / (xmax - xmin));
/* Make the image */
- if ((H5IMmake_image_8bit(fid,"All data",(hsize_t)imax,(hsize_t)jmax,image_data))<0)
+ if ((H5IMmake_image_8bit(fid, "All data", (hsize_t)imax, (hsize_t)jmax, image_data)) < 0)
goto out;
PASSED();
/*-------------------------------------------------------------------------
- * transform the data from floating point to unsigned char
- * here we just process the land data
- *-------------------------------------------------------------------------
- */
+ * transform the data from floating point to unsigned char
+ * here we just process the land data
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("make indexed image from land data");
- for ( i = 0; i < n_elements; i++ )
- {
- if ( data[i] < 0 )
+ for (i = 0; i < n_elements; i++) {
+ if (data[i] < 0)
image_data[i] = 0;
else
- image_data[i] = (unsigned char)(( 255 * (data[i] ) ) / xmax );
+ image_data[i] = (unsigned char)((255 * (data[i])) / xmax);
}
/* make the image */
- if ((H5IMmake_image_8bit(fid,"Land data",(hsize_t)imax,(hsize_t)jmax,image_data))<0)
+ if ((H5IMmake_image_8bit(fid, "Land data", (hsize_t)imax, (hsize_t)jmax, image_data)) < 0)
goto out;
PASSED();
/*-------------------------------------------------------------------------
- * transform the data from floating point to unsigned char
- * here we just process the sea data
- *-------------------------------------------------------------------------
- */
+ * transform the data from floating point to unsigned char
+ * here we just process the sea data
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("make indexed image from sea data");
- for ( i = 0; i < n_elements; i++ )
- {
- if ( data[i] > 0 )
+ for (i = 0; i < n_elements; i++) {
+ if (data[i] > 0)
image_data[i] = 0;
else
- image_data[i] = (unsigned char)(( 255 * (data[i] - xmin ) ) / xmin );
+ image_data[i] = (unsigned char)((255 * (data[i] - xmin)) / xmin);
}
/* make the image */
- if ((H5IMmake_image_8bit(fid,"Sea data",(hsize_t)imax,(hsize_t)jmax,image_data))<0)
+ if ((H5IMmake_image_8bit(fid, "Sea data", (hsize_t)imax, (hsize_t)jmax, image_data)) < 0)
goto out;
PASSED();
/*-------------------------------------------------------------------------
- * make a palette and attach it to the datasets
- *-------------------------------------------------------------------------
- */
+ * make a palette and attach it to the datasets
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("attaching palettes");
/* make a palette */
- if ((H5IMmake_palette(fid,PAL1_NAME,pal_dims,pal_rgb))<0)
+ if ((H5IMmake_palette(fid, PAL1_NAME, pal_dims, pal_rgb)) < 0)
goto out;
/* attach the palette to the image datasets */
- if ((H5IMlink_palette(fid,"All data",PAL1_NAME))<0)
+ if ((H5IMlink_palette(fid, "All data", PAL1_NAME)) < 0)
goto out;
- if ((H5IMlink_palette(fid,"Land data",PAL1_NAME))<0)
+ if ((H5IMlink_palette(fid, "Land data", PAL1_NAME)) < 0)
goto out;
- if ((H5IMlink_palette(fid,"Sea data",PAL1_NAME))<0)
+ if ((H5IMlink_palette(fid, "Sea data", PAL1_NAME)) < 0)
goto out;
PASSED();
-
/*-------------------------------------------------------------------------
- * close
- *-------------------------------------------------------------------------
- */
- if (H5Fclose(fid)<0)
+ * close
+ *-------------------------------------------------------------------------
+ */
+ if (H5Fclose(fid) < 0)
goto out;
/* Release memory buffers */
@@ -742,122 +715,121 @@ static int test_generate(void)
/* error zone, gracefully close */
out:
/* Release memory buffers */
- if(data)
+ if (data)
HDfree(data);
- if(image_data)
+ if (image_data)
HDfree(image_data);
- H5E_BEGIN_TRY {
- H5Fclose(fid);
- } H5E_END_TRY;
- if(f)
+ H5E_BEGIN_TRY { H5Fclose(fid); }
+ H5E_END_TRY;
+ if (f)
HDfclose(f);
H5_FAILED();
return retval;
}
-
/*-------------------------------------------------------------------------
-* read_data
-* utility function to read ASCII image data
-* the files have a header of the type
-*
-* components
-* n
-* height
-* n
-* width
-* n
-*
-* followed by the image data
-*
-*-------------------------------------------------------------------------
-*/
-
-static int read_data(const char* fname, /*IN*/
- hsize_t *width, /*OUT*/
- hsize_t *height /*OUT*/)
+ * read_data
+ * utility function to read ASCII image data
+ * the files have a header of the type
+ *
+ * components
+ * n
+ * height
+ * n
+ * width
+ * n
+ *
+ * followed by the image data
+ *
+ *-------------------------------------------------------------------------
+ */
+
+static int
+read_data(const char *fname, /*IN*/
+ hsize_t * width, /*OUT*/
+ hsize_t * height /*OUT*/)
{
- int i, n;
- int color_planes;
- char str[20];
- FILE *f = NULL;
- int w, h;
- int n_elements;
+ int i, n;
+ int color_planes;
+ char str[20];
+ FILE * f = NULL;
+ int w, h;
+ int n_elements;
const char *data_file = H5_get_srcdir_filename(fname);
- int ret_val = -1;
+ int ret_val = -1;
/*-------------------------------------------------------------------------
- * read
- *-------------------------------------------------------------------------
- */
+ * read
+ *-------------------------------------------------------------------------
+ */
- if(NULL == (f = HDfopen(data_file, "r"))) {
- HDprintf( "Could not open file %s. Try set $srcdir \n", data_file );
+ if (NULL == (f = HDfopen(data_file, "r"))) {
+ HDprintf("Could not open file %s. Try set $srcdir \n", data_file);
goto out;
}
- if(fscanf(f, "%s", str) < 0 && HDferror(f)) {
- HDprintf( "fscanf error in file %s.\n", data_file );
+ if (fscanf(f, "%s", str) < 0 && HDferror(f)) {
+ HDprintf("fscanf error in file %s.\n", data_file);
goto out;
} /* end if */
- if(fscanf(f, "%d", &color_planes) < 0 && HDferror(f)) {
- HDprintf( "fscanf error in file %s.\n", data_file );
+ if (fscanf(f, "%d", &color_planes) < 0 && HDferror(f)) {
+ HDprintf("fscanf error in file %s.\n", data_file);
goto out;
} /* end if */
- if(fscanf(f, "%s", str) < 0 && HDferror(f)) {
- HDprintf( "fscanf error in file %s.\n", data_file );
+ if (fscanf(f, "%s", str) < 0 && HDferror(f)) {
+ HDprintf("fscanf error in file %s.\n", data_file);
goto out;
} /* end if */
- if(fscanf(f, "%d", &h) < 0 && HDferror(f)) {
- HDprintf( "fscanf error in file %s.\n", data_file );
+ if (fscanf(f, "%d", &h) < 0 && HDferror(f)) {
+ HDprintf("fscanf error in file %s.\n", data_file);
goto out;
} /* end if */
- if(fscanf(f, "%s", str) < 0 && HDferror(f)) {
- HDprintf( "fscanf error in file %s.\n", data_file );
+ if (fscanf(f, "%s", str) < 0 && HDferror(f)) {
+ HDprintf("fscanf error in file %s.\n", data_file);
goto out;
} /* end if */
- if(fscanf(f, "%d", &w) < 0 && HDferror(f)) {
- HDprintf( "fscanf error in file %s.\n", data_file );
+ if (fscanf(f, "%d", &w) < 0 && HDferror(f)) {
+ HDprintf("fscanf error in file %s.\n", data_file);
goto out;
} /* end if */
/* Check product for overflow */
- if(w < 1 || h < 1 || color_planes < 1)
+ if (w < 1 || h < 1 || color_planes < 1)
goto out;
- if(w > INT_MAX / h)
+ if (w > INT_MAX / h)
goto out;
- if(w * h > INT_MAX / color_planes)
+ if (w * h > INT_MAX / color_planes)
goto out;
/* Compute buffer size */
n_elements = w * h * color_planes;
/* Check buffer size for overflow */
- if(n_elements > INT_MAX / (int)sizeof(unsigned char))
+ if (n_elements > INT_MAX / (int)sizeof(unsigned char))
goto out;
/* Release the buffer, if it was previously allocated */
- if(image_data)
+ if (image_data)
HDfree(image_data);
/* Allocate the image data buffer */
image_data = (unsigned char *)HDmalloc((size_t)n_elements * sizeof(unsigned char));
- if(NULL == image_data)
+ if (NULL == image_data)
goto out;
- *width = (hsize_t)w;
+ *width = (hsize_t)w;
*height = (hsize_t)h;
/* Read data elements */
- for(i = 0; i < n_elements; i++) {
- if(fscanf(f, "%d", &n) < 0 && HDferror(f)) {
- HDprintf( "fscanf error in file %s.\n", data_file );
+ for (i = 0; i < n_elements; i++) {
+ if (fscanf(f, "%d", &n) < 0 && HDferror(f)) {
+ HDprintf("fscanf error in file %s.\n", data_file);
goto out;
} /* end if */
image_data[i] = (unsigned char)n;
@@ -867,123 +839,108 @@ static int read_data(const char* fname, /*IN*/
ret_val = 1;
out:
- if(f)
+ if (f)
HDfclose(f);
return ret_val;
} /* end read_data() */
-
/*-------------------------------------------------------------------------
-* read_palette
-* Read an ASCII palette file .PAL into an array
-* the files have a header of the type
-*
-* Parameters:
-* fname - name of file to read.
-* palette - array of rgb_t to store the read palette.
-* palette_size - number of elements in 'palette' array
-*
-*-------------------------------------------------------------------------
-*/
-
+ * read_palette
+ * Read an ASCII palette file .PAL into an array
+ * the files have a header of the type
+ *
+ * Parameters:
+ * fname - name of file to read.
+ * palette - array of rgb_t to store the read palette.
+ * palette_size - number of elements in 'palette' array
+ *
+ *-------------------------------------------------------------------------
+ */
#define STRING_JASC "JASC-PAL"
#define VERSION_JASC "0100"
#define STRING_CWPAL "CWPAL"
#define VERSION_CWPAL "100"
-static int read_palette(const char* fname,
- rgb_t *palette,
- size_t palette_size)
+static int
+read_palette(const char *fname, rgb_t *palette, size_t palette_size)
{
- FILE *file;
- char buffer[80];
- unsigned u;
- unsigned int red;
- unsigned int green;
- unsigned int blue;
- unsigned nentries;
- const char *data_file = H5_get_srcdir_filename(fname);
+ FILE * file;
+ char buffer[80];
+ unsigned u;
+ unsigned int red;
+ unsigned int green;
+ unsigned int blue;
+ unsigned nentries;
+ const char * data_file = H5_get_srcdir_filename(fname);
/* ensure the given palette is valid */
if (!palette)
return -1;
/* open the input file */
- if (!(file = HDfopen(data_file, "r")))
- {
- HDprintf( "Could not open file %s. Try set $srcdir \n", data_file );
+ if (!(file = HDfopen(data_file, "r"))) {
+ HDprintf("Could not open file %s. Try set $srcdir \n", data_file);
return -1;
}
/* read the file ident string */
- if (HDfgets(buffer, sizeof(buffer), file) == NULL)
- {
+ if (HDfgets(buffer, sizeof(buffer), file) == NULL) {
HDfclose(file);
return -1;
}
/* ensure it matches the palette file ident string */
- if ( HDstrncmp(buffer, STRING_JASC, sizeof(STRING_JASC) - 1) != 0 &&
- HDstrncmp(buffer, STRING_CWPAL, sizeof(STRING_CWPAL) - 1) != 0 )
- {
+ if (HDstrncmp(buffer, STRING_JASC, sizeof(STRING_JASC) - 1) != 0 &&
+ HDstrncmp(buffer, STRING_CWPAL, sizeof(STRING_CWPAL) - 1) != 0) {
HDfclose(file);
return -1;
}
/* read the version string */
- if (HDfgets(buffer, sizeof(buffer), file) == NULL)
- {
+ if (HDfgets(buffer, sizeof(buffer), file) == NULL) {
HDfclose(file);
return -1;
}
/* ensure it matches the palette file version string */
- if ( HDstrncmp(buffer, VERSION_JASC, sizeof(VERSION_JASC) - 1) != 0 &&
- HDstrncmp(buffer, VERSION_CWPAL, sizeof(VERSION_CWPAL) - 1) != 0 )
- {
+ if (HDstrncmp(buffer, VERSION_JASC, sizeof(VERSION_JASC) - 1) != 0 &&
+ HDstrncmp(buffer, VERSION_CWPAL, sizeof(VERSION_CWPAL) - 1) != 0) {
HDfclose(file);
return -1;
}
/* read the number of colors */
- if (HDfgets(buffer, sizeof(buffer), file) == NULL)
- {
+ if (HDfgets(buffer, sizeof(buffer), file) == NULL) {
HDfclose(file);
return -1;
}
-
/* extract the number of colors.
check for missing version or number of colors
in this case it reads the first entry
*/
- if ( HDstrlen( buffer ) > 4 )
- {
+ if (HDstrlen(buffer) > 4) {
HDfclose(file);
return -1;
}
- if (sscanf(buffer, "%u", &nentries) != 1)
- {
+ if (sscanf(buffer, "%u", &nentries) != 1) {
HDfclose(file);
return -1;
}
/* ensure there are a sensible number of colors in the palette */
- if ((nentries > 256) || (nentries > palette_size))
- {
+ if ((nentries > 256) || (nentries > palette_size)) {
HDfclose(file);
- return(-1);
+ return (-1);
}
/* read the palette entries */
- for (u = 0; u < nentries; u++)
- {
+ for (u = 0; u < nentries; u++) {
/* extract the red, green and blue color components. */
- if (fscanf(file, "%u %u %u", &red, &green, &blue) != 3)
- {
+ if (fscanf(file, "%u %u %u", &red, &green, &blue) != 3) {
HDfclose(file);
return -1;
}
@@ -998,4 +955,3 @@ static int read_palette(const char* fname,
return (int)nentries;
}
-
diff --git a/hl/test/test_ld.c b/hl/test/test_ld.c
index 7de409f..cc98fc9 100644
--- a/hl/test/test_ld.c
+++ b/hl/test/test_ld.c
@@ -1,15 +1,15 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-* Copyright by The HDF Group. *
-* Copyright by the Board of Trustees of the University of Illinois. *
-* All rights reserved. *
-* *
-* This file is part of HDF5. The full HDF5 copyright notice, including *
-* terms governing use, modification, and redistribution, is contained in *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
* distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "h5hltest.h"
#include "H5srcdir.h"
@@ -21,17 +21,17 @@
#define COPY_FILENAME "COPY_test_ld.h5"
/* Dataset names */
-#define DSET_ONE "DSET_ONE"
-#define DSET_ALLOC_LATE "DSET_ALLOC_LATE"
+#define DSET_ONE "DSET_ONE"
+#define DSET_ALLOC_LATE "DSET_ALLOC_LATE"
#define DSET_ALLOC_EARLY "DSET_ALLOC_EARLY"
-#define DSET_TWO "DSET_TWO"
-#define TWO_DIM_1 4
-#define TWO_DIM_2 10
-#define DSET_CMPD "DSET_CMPD"
-#define DSET_CMPD_ESC "DSET_CMPD_ESC"
-#define DSET_CMPD_TWO "DSET_CMPD_TWO"
-#define DSET_NULL "DSET_NULL"
-#define DSET_SCALAR "DSET_SCALAR"
+#define DSET_TWO "DSET_TWO"
+#define TWO_DIM_1 4
+#define TWO_DIM_2 10
+#define DSET_CMPD "DSET_CMPD"
+#define DSET_CMPD_ESC "DSET_CMPD_ESC"
+#define DSET_CMPD_TWO "DSET_CMPD_TWO"
+#define DSET_NULL "DSET_NULL"
+#define DSET_SCALAR "DSET_SCALAR"
/* Selected compound field members for testing */
#define VALID_FIELDS1 "field1,field2.a,field3,field4" /* TEMPORORAY */
@@ -52,7 +52,7 @@
* Test variations (retained original) for one-dimensional dataset:
* Varies from 10->13; 10->9, 10->10, 10->1, 10->11
*/
-#define ONE_NTESTS 5
+#define ONE_NTESTS 5
int one_tests[ONE_NTESTS] = {3, -1, 0, -9, 1};
/*
@@ -61,88 +61,92 @@ int one_tests[ONE_NTESTS] = {3, -1, 0, -9, 1};
* {4,10}->{3,12}; {4,10}->{3,9}; {4,10}->{3,10};
* {4,10}->{4,12}; {4,10}->{4,9}; {4,10}->{4,10}
*/
-#define TWO_NTESTS 9
-int two_tests[TWO_NTESTS][2] = { {2,2}, {2,-1}, {2,0},
- {-1,2}, {-1,-1}, {-1,0},
- {0,2}, {0,-1}, {0,0} };
-
+#define TWO_NTESTS 9
+int two_tests[TWO_NTESTS][2] = {{2, 2}, {2, -1}, {2, 0}, {-1, 2}, {-1, -1}, {-1, 0}, {0, 2}, {0, -1}, {0, 0}};
/* Verify that the two input values are the same */
-#define VERIFY_EQUAL(_x, _y) \
-{ \
- long __x = (long)_x, __y = (long)_y; \
- if(__x != __y) TEST_ERROR \
-}
+#define VERIFY_EQUAL(_x, _y) \
+ { \
+ long __x = (long)_x, __y = (long)_y; \
+ if (__x != __y) \
+ TEST_ERROR \
+ }
/* Temporary buffer for reading in the test file */
-#define TMP_BUF_SIZE 2048
-char g_tmp_buf[TMP_BUF_SIZE];
+#define TMP_BUF_SIZE 2048
+char g_tmp_buf[TMP_BUF_SIZE];
/* Macros for verifying compound fields */
/* Verify all fields */
-#define VERIFY_ELMTS_ALL(ent1, ent2) { \
- VERIFY_EQUAL(ent1.field1, ent2.field1); \
- VERIFY_EQUAL(ent1.field2.a, ent2.field2.a); \
- VERIFY_EQUAL(ent1.field2.b.a, ent2.field2.b.a); \
- VERIFY_EQUAL(ent1.field2.b.b, ent2.field2.b.b); \
- VERIFY_EQUAL(ent1.field2.b.c, ent2.field2.b.c); \
- VERIFY_EQUAL(ent1.field2.c, ent2.field2.c); \
- VERIFY_EQUAL(ent1.field3, ent2.field3); \
- VERIFY_EQUAL(ent1.field4.a, ent2.field4.a); \
-}
+#define VERIFY_ELMTS_ALL(ent1, ent2) \
+ { \
+ VERIFY_EQUAL(ent1.field1, ent2.field1); \
+ VERIFY_EQUAL(ent1.field2.a, ent2.field2.a); \
+ VERIFY_EQUAL(ent1.field2.b.a, ent2.field2.b.a); \
+ VERIFY_EQUAL(ent1.field2.b.b, ent2.field2.b.b); \
+ VERIFY_EQUAL(ent1.field2.b.c, ent2.field2.b.c); \
+ VERIFY_EQUAL(ent1.field2.c, ent2.field2.c); \
+ VERIFY_EQUAL(ent1.field3, ent2.field3); \
+ VERIFY_EQUAL(ent1.field4.a, ent2.field4.a); \
+ }
/* Verify fields selected in VALID_FIELDS1 */
-#define VERIFY_ELMTS_VALID1(ent1, ent2) { \
- VERIFY_EQUAL(ent1.field1, ent2.field1); \
- VERIFY_EQUAL(ent1.field2_a, ent2.field2.a); \
- VERIFY_EQUAL(ent1.field3, ent2.field3); \
- VERIFY_EQUAL(ent1.field4.a, ent2.field4.a); \
- VERIFY_EQUAL(ent1.field4.b, ent2.field4.b); \
-}
+#define VERIFY_ELMTS_VALID1(ent1, ent2) \
+ { \
+ VERIFY_EQUAL(ent1.field1, ent2.field1); \
+ VERIFY_EQUAL(ent1.field2_a, ent2.field2.a); \
+ VERIFY_EQUAL(ent1.field3, ent2.field3); \
+ VERIFY_EQUAL(ent1.field4.a, ent2.field4.a); \
+ VERIFY_EQUAL(ent1.field4.b, ent2.field4.b); \
+ }
/* Verify fields selected in VALID_FIELDS2 */
-#define VERIFY_ELMTS_VALID2(ent1, ent2) { \
- VERIFY_EQUAL(ent1.field2_b_a, ent2.field2.b.a); \
- VERIFY_EQUAL(ent1.field2_c, ent2.field2.c); \
- VERIFY_EQUAL(ent1.field4_b, ent2.field4.b); \
-}
+#define VERIFY_ELMTS_VALID2(ent1, ent2) \
+ { \
+ VERIFY_EQUAL(ent1.field2_b_a, ent2.field2.b.a); \
+ VERIFY_EQUAL(ent1.field2_c, ent2.field2.c); \
+ VERIFY_EQUAL(ent1.field4_b, ent2.field4.b); \
+ }
/* The types of 2-dimensional dataset: DSET_TWO or DSET_CMPD_TWO */
-#define TWO_NONE 0 /* DSET_TWO */
-#define TWO_CMPD_NULL 1 /* DSET_CMPD_TWO with NULL fields */
-#define TWO_CMPD_VALID1 2 /* DSET_CMPD_TWO with VALID_FIELDS1 or VALID_ESC_FIELDS1 */
-#define TWO_CMPD_VALID2 3 /* DSET_CMPD_TWO with VALID_FIELDS2 or VALID_ESC_FIELDS2 */
-
-#define VERIFY_ELMTS(type, k, ind, _ldbuf, _buf) { \
- if(type == TWO_NONE) { \
- int *iib = (int *)_ldbuf; \
- int *ib = (int *)_buf; \
- \
- VERIFY_EQUAL(iib[k], ib[ind + n]) \
- } else if(type == TWO_CMPD_NULL) { \
- set_t *ccb = (set_t *)_ldbuf; \
- set_t *cb = (set_t *)_buf; \
- \
- VERIFY_ELMTS_ALL(ccb[k], cb[ind + n]) \
- } else if(type == TWO_CMPD_VALID1) { \
- test_valid_fields1 *vb1 = (test_valid_fields1 *)_ldbuf; \
- set_t *cb = (set_t *)_buf; \
- \
- VERIFY_ELMTS_VALID1(vb1[k], cb[ind + n]) \
- } else if(type == TWO_CMPD_VALID2) { \
- test_valid_fields2 *vb2 = (test_valid_fields2 *)_ldbuf; \
- set_t *cb = (set_t *)_buf; \
- \
- VERIFY_ELMTS_VALID2(vb2[k], cb[ind + n]) \
- } \
-}
+#define TWO_NONE 0 /* DSET_TWO */
+#define TWO_CMPD_NULL 1 /* DSET_CMPD_TWO with NULL fields */
+#define TWO_CMPD_VALID1 2 /* DSET_CMPD_TWO with VALID_FIELDS1 or VALID_ESC_FIELDS1 */
+#define TWO_CMPD_VALID2 3 /* DSET_CMPD_TWO with VALID_FIELDS2 or VALID_ESC_FIELDS2 */
+
+#define VERIFY_ELMTS(type, k, ind, _ldbuf, _buf) \
+ { \
+ if (type == TWO_NONE) { \
+ int *iib = (int *)_ldbuf; \
+ int *ib = (int *)_buf; \
+ \
+ VERIFY_EQUAL(iib[k], ib[ind + n]) \
+ } \
+ else if (type == TWO_CMPD_NULL) { \
+ set_t *ccb = (set_t *)_ldbuf; \
+ set_t *cb = (set_t *)_buf; \
+ \
+ VERIFY_ELMTS_ALL(ccb[k], cb[ind + n]) \
+ } \
+ else if (type == TWO_CMPD_VALID1) { \
+ test_valid_fields1 *vb1 = (test_valid_fields1 *)_ldbuf; \
+ set_t * cb = (set_t *)_buf; \
+ \
+ VERIFY_ELMTS_VALID1(vb1[k], cb[ind + n]) \
+ } \
+ else if (type == TWO_CMPD_VALID2) { \
+ test_valid_fields2 *vb2 = (test_valid_fields2 *)_ldbuf; \
+ set_t * cb = (set_t *)_buf; \
+ \
+ VERIFY_ELMTS_VALID2(vb2[k], cb[ind + n]) \
+ } \
+ }
/* Tests for test_LD_elmts_pipe() */
-#define ONE_TESTS 3
-int onetests[ONE_TESTS] = {3, 9, 1};
-#define TWO_TESTS 5
-int twotests[TWO_TESTS][2] = { {2,2}, {2,-1}, {2,0}, {-1,2}, {0,2} };
-
+#define ONE_TESTS 3
+int onetests[ONE_TESTS] = {3, 9, 1};
+#define TWO_TESTS 5
+int twotests[TWO_TESTS][2] = {{2, 2}, {2, -1}, {2, 0}, {-1, 2}, {0, 2}};
static herr_t test_LD_dims_params(const char *file);
static herr_t test_LD_dims(const char *file);
@@ -153,7 +157,7 @@ static herr_t test_LD_elmts_invalid(const char *file);
static herr_t test_LD_elmts_one(const char *file, const char *dname, const char *fields);
static herr_t test_LD_elmts_two(const char *file, const char *dname, const char *fields);
-static herr_t verify_elmts_two(int type, hsize_t *ext_dims, hsize_t *prev_dims, void *_ldbuf, void *_buf);
+static herr_t verify_elmts_two(int type, hsize_t *ext_dims, hsize_t *prev_dims, void *_ldbuf, void *_buf);
/* data structures for compound data type */
typedef struct sub22_t {
@@ -163,9 +167,9 @@ typedef struct sub22_t {
} sub22_t;
typedef struct sub2_t {
- int a;
+ int a;
sub22_t b;
- int c;
+ int c;
} sub2_t;
typedef struct sub4_t {
@@ -174,7 +178,7 @@ typedef struct sub4_t {
} sub4_t;
typedef struct set_t {
- int field1;
+ int field1;
sub2_t field2;
double field3;
sub4_t field4;
@@ -190,8 +194,8 @@ typedef struct set_t {
/* VALID_FIELDS1 "field1,field2.a,field3,field4" */
/* VALID_ESC_FIELDS1 "field\\,1,field2\\..\\.a,field\\\\3,field4\\," */
typedef struct test_valid_fields1 {
- int field1;
- int field2_a;
+ int field1;
+ int field2_a;
double field3;
sub4_t field4;
} test_valid_fields1;
@@ -204,16 +208,14 @@ typedef struct test_valid_fields2 {
int field4_b;
} test_valid_fields2;
-
/* Temporary buffers for tests: test_LD_elmts_one() & test_LD_elmts_two() */
-#define TEST_BUF_SIZE 100
-int *iibuf; /* buffer for storing retrieved elements */
-int *ibuf; /* buffer for storing retrieved elements (integer) */
-set_t *cbuf; /* buffer for storing retrieved elemnets (compound) */
-set_t *ccbuf; /* buffer for storing retrieved elemnets (compound) */
-test_valid_fields1 *vbuf1; /* buffer for storing retrieved elements (FIELDS1) */
-test_valid_fields2 *vbuf2; /* buffer for storing retrieved elements (FIELDS2) */
-
+#define TEST_BUF_SIZE 100
+int * iibuf; /* buffer for storing retrieved elements */
+int * ibuf; /* buffer for storing retrieved elements (integer) */
+set_t * cbuf; /* buffer for storing retrieved elemnets (compound) */
+set_t * ccbuf; /* buffer for storing retrieved elemnets (compound) */
+test_valid_fields1 *vbuf1; /* buffer for storing retrieved elements (FIELDS1) */
+test_valid_fields2 *vbuf2; /* buffer for storing retrieved elements (FIELDS2) */
/*
*********************************************************************************
@@ -231,109 +233,108 @@ test_valid_fields2 *vbuf2; /* buffer for storing retrieved elements (FIELDS2)
static herr_t
test_LD_dims_params(const char *file)
{
- hid_t fid=-1; /* file identifier */
- hid_t did=-1; /* dataset identifier */
- hsize_t one_cur_dims[1]; /* current dimension sizes for 1-dimensonal dataset */
- hsize_t two_cur_dims[2]; /* current dimension sizes for 2-dimensional dataset */
- hid_t invalid_id = -1;
- herr_t ret; /* return value */
+ hid_t fid = -1; /* file identifier */
+ hid_t did = -1; /* dataset identifier */
+ hsize_t one_cur_dims[1]; /* current dimension sizes for 1-dimensonal dataset */
+ hsize_t two_cur_dims[2]; /* current dimension sizes for 2-dimensional dataset */
+ hid_t invalid_id = -1;
+ herr_t ret; /* return value */
const char *filename = H5_get_srcdir_filename(file);
HL_TESTING2("H5LDget_dset_dims");
/* Open the copied file */
- if((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
- FAIL_STACK_ERROR
+ if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
/*
* 1. Verify failure with negative dataset id
*/
- H5E_BEGIN_TRY {
- ret = H5LDget_dset_dims(invalid_id, one_cur_dims);
- } H5E_END_TRY;
+ H5E_BEGIN_TRY { ret = H5LDget_dset_dims(invalid_id, one_cur_dims); }
+ H5E_END_TRY;
VERIFY_EQUAL(ret, FAIL)
/*
* 2. Verify failure for NULL cur_dims
*/
- if((did = H5Dopen2(fid, DSET_ALLOC_EARLY, H5P_DEFAULT)) < 0)
- FAIL_STACK_ERROR
- H5E_BEGIN_TRY {
- ret = H5LDget_dset_dims(did, NULL);
- } H5E_END_TRY;
+ if ((did = H5Dopen2(fid, DSET_ALLOC_EARLY, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+ H5E_BEGIN_TRY { ret = H5LDget_dset_dims(did, NULL); }
+ H5E_END_TRY;
VERIFY_EQUAL(ret, FAIL)
- if(H5Dclose(did) < 0)
- FAIL_STACK_ERROR
+ if (H5Dclose(did) < 0)
+ FAIL_STACK_ERROR
/*
* 3. Verify for nonNULL cur_dims
*/
- if((did = H5Dopen2(fid, DSET_ALLOC_LATE, H5P_DEFAULT)) < 0)
- FAIL_STACK_ERROR
- if(H5LDget_dset_dims(did, one_cur_dims) < 0)
- FAIL_STACK_ERROR
+ if ((did = H5Dopen2(fid, DSET_ALLOC_LATE, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+ if (H5LDget_dset_dims(did, one_cur_dims) < 0)
+ FAIL_STACK_ERROR
VERIFY_EQUAL(one_cur_dims[0], 10)
- if(H5Dclose(did) < 0)
- FAIL_STACK_ERROR
+ if (H5Dclose(did) < 0)
+ FAIL_STACK_ERROR
/*
* 4. Verify nonNULL cur_dims for a 2-dimensional dataset
*/
- if((did = H5Dopen2(fid, DSET_CMPD_TWO, H5P_DEFAULT)) < 0)
- FAIL_STACK_ERROR
- if(H5LDget_dset_dims(did, two_cur_dims) < 0)
- FAIL_STACK_ERROR
+ if ((did = H5Dopen2(fid, DSET_CMPD_TWO, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+ if (H5LDget_dset_dims(did, two_cur_dims) < 0)
+ FAIL_STACK_ERROR
VERIFY_EQUAL(two_cur_dims[0], TWO_DIM_1)
VERIFY_EQUAL(two_cur_dims[1], TWO_DIM_2)
- if(H5Dclose(did) < 0)
- FAIL_STACK_ERROR
+ if (H5Dclose(did) < 0)
+ FAIL_STACK_ERROR
/*
* 5. Verify nonNULL cur_dims for dataset with H5S_NULL dataspace
*/
one_cur_dims[0] = 0;
- if((did = H5Dopen2(fid, DSET_NULL, H5P_DEFAULT)) < 0)
- FAIL_STACK_ERROR
+ if ((did = H5Dopen2(fid, DSET_NULL, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
- if(H5LDget_dset_dims(did, one_cur_dims) < 0)
- FAIL_STACK_ERROR
+ if (H5LDget_dset_dims(did, one_cur_dims) < 0)
+ FAIL_STACK_ERROR
VERIFY_EQUAL(one_cur_dims[0], 0)
- if(H5Dclose(did) < 0)
- FAIL_STACK_ERROR
+ if (H5Dclose(did) < 0)
+ FAIL_STACK_ERROR
/*
* 6. Verify nonNULL cur_dims for dataset with H5S_SCALAR dataspace
*/
one_cur_dims[0] = 0;
- if((did = H5Dopen2(fid, DSET_SCALAR, H5P_DEFAULT)) < 0)
- FAIL_STACK_ERROR
+ if ((did = H5Dopen2(fid, DSET_SCALAR, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
- if(H5LDget_dset_dims(did, one_cur_dims) < 0)
- FAIL_STACK_ERROR
+ if (H5LDget_dset_dims(did, one_cur_dims) < 0)
+ FAIL_STACK_ERROR
VERIFY_EQUAL(one_cur_dims[0], 0)
- if(H5Dclose(did) < 0)
- FAIL_STACK_ERROR
+ if (H5Dclose(did) < 0)
+ FAIL_STACK_ERROR
/* Close the file */
- if(H5Fclose(fid) < 0)
- FAIL_STACK_ERROR
+ if (H5Fclose(fid) < 0)
+ FAIL_STACK_ERROR
PASSED();
return 0;
error:
- H5E_BEGIN_TRY {
- H5Dclose(did);
- H5Fclose(fid);
- } H5E_END_TRY;
+ H5E_BEGIN_TRY
+ {
+ H5Dclose(did);
+ H5Fclose(fid);
+ }
+ H5E_END_TRY;
- return(-1);
+ return (-1);
} /* test_LD_dims_params() */
-
/*
*********************************************************************************
*
@@ -374,93 +375,93 @@ error:
static herr_t
test_LD_dims(const char *file)
{
- hid_t fid=-1; /* file identifier */
- hid_t did=-1; /* dataset identifier */
- hsize_t one_prev_dims[1]; /* original dimension sizes for 1-dimensonal dataset */
- hsize_t one_cur_dims[1]; /* current dimension sizes for 1-dimensonal dataset */
- hsize_t one_ext_dims[1]; /* extended dimension sizes for 1-dimensonal dataset */
- hsize_t two_prev_dims[2]; /* original dimension sizes for 2-dimensional dataset */
- hsize_t two_cur_dims[2]; /* current dimension sizes for 2-dimensional dataset */
- hsize_t two_ext_dims[2]; /* extended dimension sizes for 2-dimensional dataset*/
- int i; /* local index variable */
+ hid_t fid = -1; /* file identifier */
+ hid_t did = -1; /* dataset identifier */
+ hsize_t one_prev_dims[1]; /* original dimension sizes for 1-dimensonal dataset */
+ hsize_t one_cur_dims[1]; /* current dimension sizes for 1-dimensonal dataset */
+ hsize_t one_ext_dims[1]; /* extended dimension sizes for 1-dimensonal dataset */
+ hsize_t two_prev_dims[2]; /* original dimension sizes for 2-dimensional dataset */
+ hsize_t two_cur_dims[2]; /* current dimension sizes for 2-dimensional dataset */
+ hsize_t two_ext_dims[2]; /* extended dimension sizes for 2-dimensional dataset*/
+ int i; /* local index variable */
HL_TESTING2("H5LDget_dset_dims with H5Dset_extent");
/* Make a copy of the test file */
- if(h5_make_local_copy(file, COPY_FILENAME) < 0)
+ if (h5_make_local_copy(file, COPY_FILENAME) < 0)
TEST_ERROR
/* Open the copied file */
- if((fid = H5Fopen(COPY_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
- FAIL_STACK_ERROR
+ if ((fid = H5Fopen(COPY_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
/*
* Testing with one-dimensional dataset: DSET_ONE
*/
- if((did = H5Dopen2(fid, DSET_ONE, H5P_DEFAULT)) < 0)
- FAIL_STACK_ERROR
+ if ((did = H5Dopen2(fid, DSET_ONE, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
/* Retrieve dimension sizes */
- if(H5LDget_dset_dims(did, one_prev_dims) < 0)
- FAIL_STACK_ERROR
+ if (H5LDget_dset_dims(did, one_prev_dims) < 0)
+ FAIL_STACK_ERROR
- for(i = 0; i < ONE_NTESTS; i++) {
+ for (i = 0; i < ONE_NTESTS; i++) {
- /* Set up the extended dimension sizes */
- one_ext_dims[0] = (hsize_t)((int)one_prev_dims[0] + one_tests[i]);
+ /* Set up the extended dimension sizes */
+ one_ext_dims[0] = (hsize_t)((int)one_prev_dims[0] + one_tests[i]);
- /* Change the dimension size */
- if(H5Dset_extent(did, one_ext_dims) < 0)
- FAIL_STACK_ERROR
+ /* Change the dimension size */
+ if (H5Dset_extent(did, one_ext_dims) < 0)
+ FAIL_STACK_ERROR
- /* Retrieve the dimension size */
- if(H5LDget_dset_dims(did, one_cur_dims) < 0)
- FAIL_STACK_ERROR
+ /* Retrieve the dimension size */
+ if (H5LDget_dset_dims(did, one_cur_dims) < 0)
+ FAIL_STACK_ERROR
- /* Verify that the retrieved dimension size is correct as expected */
- VERIFY_EQUAL(one_cur_dims[0], one_ext_dims[0])
+ /* Verify that the retrieved dimension size is correct as expected */
+ VERIFY_EQUAL(one_cur_dims[0], one_ext_dims[0])
}
/* Close the dataset */
- if(H5Dclose(did) < 0)
- FAIL_STACK_ERROR
+ if (H5Dclose(did) < 0)
+ FAIL_STACK_ERROR
/*
* Testing with two-dimensional dataset: DSET_TWO
*/
- if((did = H5Dopen2(fid, DSET_TWO, H5P_DEFAULT)) < 0)
- FAIL_STACK_ERROR
+ if ((did = H5Dopen2(fid, DSET_TWO, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
/* Retrieve the dimension sizes */
- if(H5LDget_dset_dims(did, two_prev_dims) < 0)
- FAIL_STACK_ERROR
+ if (H5LDget_dset_dims(did, two_prev_dims) < 0)
+ FAIL_STACK_ERROR
- for(i = 0; i < TWO_NTESTS; i++) {
+ for (i = 0; i < TWO_NTESTS; i++) {
- /* Set up the extended dimension sizes */
- two_ext_dims[0] = (hsize_t)((int)two_prev_dims[0] + two_tests[i][0]);
- two_ext_dims[1] = (hsize_t) ((int)two_prev_dims[1] + two_tests[i][1]);
+ /* Set up the extended dimension sizes */
+ two_ext_dims[0] = (hsize_t)((int)two_prev_dims[0] + two_tests[i][0]);
+ two_ext_dims[1] = (hsize_t)((int)two_prev_dims[1] + two_tests[i][1]);
- /* Change the dimension sizes */
- if(H5Dset_extent(did, two_ext_dims) < 0)
- FAIL_STACK_ERROR
+ /* Change the dimension sizes */
+ if (H5Dset_extent(did, two_ext_dims) < 0)
+ FAIL_STACK_ERROR
- /* Retrieve the dimension sizes */
- if(H5LDget_dset_dims(did, two_cur_dims) < 0)
- FAIL_STACK_ERROR
+ /* Retrieve the dimension sizes */
+ if (H5LDget_dset_dims(did, two_cur_dims) < 0)
+ FAIL_STACK_ERROR
- /* Verify that the retrieved dimension sizes are correct as expected */
- VERIFY_EQUAL(two_cur_dims[0], two_ext_dims[0])
- VERIFY_EQUAL(two_cur_dims[1], two_ext_dims[1])
+ /* Verify that the retrieved dimension sizes are correct as expected */
+ VERIFY_EQUAL(two_cur_dims[0], two_ext_dims[0])
+ VERIFY_EQUAL(two_cur_dims[1], two_ext_dims[1])
} /* end TWO_NTESTS */
/* Close the dataset */
- if(H5Dclose(did) < 0)
- FAIL_STACK_ERROR
+ if (H5Dclose(did) < 0)
+ FAIL_STACK_ERROR
/* Close the file */
- if(H5Fclose(fid) < 0)
- FAIL_STACK_ERROR
+ if (H5Fclose(fid) < 0)
+ FAIL_STACK_ERROR
/* Remove the copied file */
HDremove(COPY_FILENAME);
@@ -469,15 +470,16 @@ test_LD_dims(const char *file)
return 0;
error:
- H5E_BEGIN_TRY {
- H5Dclose(did);
- H5Fclose(fid);
- } H5E_END_TRY;
- return(-1);
+ H5E_BEGIN_TRY
+ {
+ H5Dclose(did);
+ H5Fclose(fid);
+ }
+ H5E_END_TRY;
+ return (-1);
} /* test_LD_dims() */
-
/*
**********************************************************************************
*
@@ -509,33 +511,32 @@ error:
static int
test_LD_size(const char *file)
{
- hid_t fid=-1; /* file identifier */
- hid_t did=-1; /* dataset identifier */
- hid_t dtid=-1; /* dataset's datatype identifier */
- hid_t invalid_id=-1;
- hid_t memb0_tid=-1; /* type identifier for a member in the compound type */
- hid_t memb1_tid=-1; /* type identifier for a member in the compound type */
- hid_t memb2_tid=-1; /* type identifier for a member in the compound type */
- hid_t memb3_tid=-1; /* type identifier for a member in the compound type */
- hid_t memb_tid=-1; /* type identifier for a member in the compound type */
- hid_t memb_tid2=-1; /* type identifier for a member in the compound type */
- size_t dsize; /* size of the dataset's datatype */
- size_t ck_dsize; /* size of the dataset's datatype to be checked against */
+ hid_t fid = -1; /* file identifier */
+ hid_t did = -1; /* dataset identifier */
+ hid_t dtid = -1; /* dataset's datatype identifier */
+ hid_t invalid_id = -1;
+ hid_t memb0_tid = -1; /* type identifier for a member in the compound type */
+ hid_t memb1_tid = -1; /* type identifier for a member in the compound type */
+ hid_t memb2_tid = -1; /* type identifier for a member in the compound type */
+ hid_t memb3_tid = -1; /* type identifier for a member in the compound type */
+ hid_t memb_tid = -1; /* type identifier for a member in the compound type */
+ hid_t memb_tid2 = -1; /* type identifier for a member in the compound type */
+ size_t dsize; /* size of the dataset's datatype */
+ size_t ck_dsize; /* size of the dataset's datatype to be checked against */
const char *filename = H5_get_srcdir_filename(file);
HL_TESTING2("H5LDget_dset_type_size");
/* Open the file */
- if((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
- FAIL_STACK_ERROR
+ if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
/*
* Verify failure with an invalid dataset id
*/
- H5E_BEGIN_TRY {
- dsize = H5LDget_dset_type_size(invalid_id, NULL);
- } H5E_END_TRY;
+ H5E_BEGIN_TRY { dsize = H5LDget_dset_type_size(invalid_id, NULL); }
+ H5E_END_TRY;
VERIFY_EQUAL(dsize, 0)
/*
@@ -544,91 +545,91 @@ test_LD_size(const char *file)
*/
/* Open dataset DSET_CMPD */
- if((did = H5Dopen2(fid, DSET_CMPD, H5P_DEFAULT)) < 0)
- FAIL_STACK_ERROR
+ if ((did = H5Dopen2(fid, DSET_CMPD, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
/* Return size of the whole element */
- if((dsize = H5LDget_dset_type_size(did, NULL)) == 0)
- FAIL_STACK_ERROR
+ if ((dsize = H5LDget_dset_type_size(did, NULL)) == 0)
+ FAIL_STACK_ERROR
/* Get the dataset's datatype and then its datatype size */
- if((dtid = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0)
+ if ((dtid = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0)
FAIL_STACK_ERROR
- if((ck_dsize = H5Tget_size(dtid)) == 0)
- FAIL_STACK_ERROR
+ if ((ck_dsize = H5Tget_size(dtid)) == 0)
+ FAIL_STACK_ERROR
/* Verify case #1 */
VERIFY_EQUAL(dsize, ck_dsize)
/* Get datatype id for each member */
- if((memb0_tid = H5Tget_member_type(dtid, 0)) < 0) /* "field1" */
- FAIL_STACK_ERROR
- if((memb1_tid = H5Tget_member_type(dtid, 1)) < 0) /* "field2" */
- FAIL_STACK_ERROR
- if((memb2_tid = H5Tget_member_type(dtid, 2)) < 0) /* "field3" */
- FAIL_STACK_ERROR
- if((memb3_tid = H5Tget_member_type(dtid, 3)) < 0) /* "field4" */
- FAIL_STACK_ERROR
+ if ((memb0_tid = H5Tget_member_type(dtid, 0)) < 0) /* "field1" */
+ FAIL_STACK_ERROR
+ if ((memb1_tid = H5Tget_member_type(dtid, 1)) < 0) /* "field2" */
+ FAIL_STACK_ERROR
+ if ((memb2_tid = H5Tget_member_type(dtid, 2)) < 0) /* "field3" */
+ FAIL_STACK_ERROR
+ if ((memb3_tid = H5Tget_member_type(dtid, 3)) < 0) /* "field4" */
+ FAIL_STACK_ERROR
/* Obtain size for VALID_FIELDS1: "field1,field2.a,field3,field4" */
- if((dsize = H5LDget_dset_type_size(did, VALID_FIELDS1)) == 0)
- FAIL_STACK_ERROR
+ if ((dsize = H5LDget_dset_type_size(did, VALID_FIELDS1)) == 0)
+ FAIL_STACK_ERROR
/* Get the datatype size for "field1" */
- if((ck_dsize = H5Tget_size(memb0_tid)) == 0)
- FAIL_STACK_ERROR
+ if ((ck_dsize = H5Tget_size(memb0_tid)) == 0)
+ FAIL_STACK_ERROR
/* Add the datatype size for "field2.a" */
- if((memb_tid = H5Tget_member_type(memb1_tid, 0)) < 0)
- FAIL_STACK_ERROR
- if((ck_dsize += H5Tget_size(memb_tid)) == 0)
- FAIL_STACK_ERROR
- if(H5Tclose(memb_tid) < 0)
- FAIL_STACK_ERROR
+ if ((memb_tid = H5Tget_member_type(memb1_tid, 0)) < 0)
+ FAIL_STACK_ERROR
+ if ((ck_dsize += H5Tget_size(memb_tid)) == 0)
+ FAIL_STACK_ERROR
+ if (H5Tclose(memb_tid) < 0)
+ FAIL_STACK_ERROR
/* Add the datatype size for "field3" */
- if((ck_dsize += H5Tget_size(memb2_tid)) == 0)
- FAIL_STACK_ERROR
+ if ((ck_dsize += H5Tget_size(memb2_tid)) == 0)
+ FAIL_STACK_ERROR
/* Add the datatype size for "field4" */
- if((ck_dsize += H5Tget_size(memb3_tid)) == 0)
- FAIL_STACK_ERROR
+ if ((ck_dsize += H5Tget_size(memb3_tid)) == 0)
+ FAIL_STACK_ERROR
/* Verify case #2 */
VERIFY_EQUAL(dsize, ck_dsize)
/* Obtain datatype size for VALID_FIELDS2: "field2.b.a,field2.c,field4.b" */
- if((dsize = H5LDget_dset_type_size(did, VALID_FIELDS2)) == 0)
- FAIL_STACK_ERROR
+ if ((dsize = H5LDget_dset_type_size(did, VALID_FIELDS2)) == 0)
+ FAIL_STACK_ERROR
/* Get the datatype size for "field2.b.a" */
- if((memb_tid = H5Tget_member_type(memb1_tid, 1)) < 0)
- FAIL_STACK_ERROR
- if((memb_tid2 = H5Tget_member_type(memb_tid, 0)) < 0)
- FAIL_STACK_ERROR
- if((ck_dsize = H5Tget_size(memb_tid2)) == 0)
- FAIL_STACK_ERROR
- if(H5Tclose(memb_tid) < 0)
- FAIL_STACK_ERROR
- if(H5Tclose(memb_tid2) < 0)
- FAIL_STACK_ERROR
+ if ((memb_tid = H5Tget_member_type(memb1_tid, 1)) < 0)
+ FAIL_STACK_ERROR
+ if ((memb_tid2 = H5Tget_member_type(memb_tid, 0)) < 0)
+ FAIL_STACK_ERROR
+ if ((ck_dsize = H5Tget_size(memb_tid2)) == 0)
+ FAIL_STACK_ERROR
+ if (H5Tclose(memb_tid) < 0)
+ FAIL_STACK_ERROR
+ if (H5Tclose(memb_tid2) < 0)
+ FAIL_STACK_ERROR
/* Add the datatype size for "field2.c" */
- if((memb_tid = H5Tget_member_type(memb1_tid, 2)) < 0)
- FAIL_STACK_ERROR
- if((ck_dsize += H5Tget_size(memb_tid)) == 0)
- FAIL_STACK_ERROR
- if(H5Tclose(memb_tid) < 0)
- FAIL_STACK_ERROR
+ if ((memb_tid = H5Tget_member_type(memb1_tid, 2)) < 0)
+ FAIL_STACK_ERROR
+ if ((ck_dsize += H5Tget_size(memb_tid)) == 0)
+ FAIL_STACK_ERROR
+ if (H5Tclose(memb_tid) < 0)
+ FAIL_STACK_ERROR
/* Add the datatype size for "field4.b" */
- if((memb_tid = H5Tget_member_type(memb3_tid, 1)) < 0)
- FAIL_STACK_ERROR
- if((ck_dsize += H5Tget_size(memb_tid)) == 0)
- FAIL_STACK_ERROR
- if(H5Tclose(memb_tid) < 0)
- FAIL_STACK_ERROR
+ if ((memb_tid = H5Tget_member_type(memb3_tid, 1)) < 0)
+ FAIL_STACK_ERROR
+ if ((ck_dsize += H5Tget_size(memb_tid)) == 0)
+ FAIL_STACK_ERROR
+ if (H5Tclose(memb_tid) < 0)
+ FAIL_STACK_ERROR
/* Verify case #3 */
VERIFY_EQUAL(dsize, ck_dsize)
@@ -652,18 +653,18 @@ test_LD_size(const char *file)
VERIFY_EQUAL(dsize, 0)
/* Closing */
- if(H5Tclose(memb0_tid) < 0)
- FAIL_STACK_ERROR
- if(H5Tclose(memb1_tid) < 0)
- FAIL_STACK_ERROR
- if(H5Tclose(memb2_tid) < 0)
- FAIL_STACK_ERROR
- if(H5Tclose(memb3_tid) < 0)
- FAIL_STACK_ERROR
- if(H5Tclose(dtid) < 0)
- FAIL_STACK_ERROR
- if(H5Dclose(did) < 0)
- FAIL_STACK_ERROR
+ if (H5Tclose(memb0_tid) < 0)
+ FAIL_STACK_ERROR
+ if (H5Tclose(memb1_tid) < 0)
+ FAIL_STACK_ERROR
+ if (H5Tclose(memb2_tid) < 0)
+ FAIL_STACK_ERROR
+ if (H5Tclose(memb3_tid) < 0)
+ FAIL_STACK_ERROR
+ if (H5Tclose(dtid) < 0)
+ FAIL_STACK_ERROR
+ if (H5Dclose(did) < 0)
+ FAIL_STACK_ERROR
/*
* Testing one-dimensional dataset with compound datatype and
@@ -672,91 +673,91 @@ test_LD_size(const char *file)
*/
/* Open dataset DSET_CMPD_ESC */
- if((did = H5Dopen2(fid, DSET_CMPD_ESC, H5P_DEFAULT)) < 0)
- FAIL_STACK_ERROR
+ if ((did = H5Dopen2(fid, DSET_CMPD_ESC, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
/* Return size of the whole element */
- if((dsize = H5LDget_dset_type_size(did, NULL)) == 0)
- FAIL_STACK_ERROR
+ if ((dsize = H5LDget_dset_type_size(did, NULL)) == 0)
+ FAIL_STACK_ERROR
/* Get the dataset's datatype and then its datatype size */
- if((dtid = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0)
+ if ((dtid = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+ if ((ck_dsize = H5Tget_size(dtid)) == 0)
FAIL_STACK_ERROR
- if((ck_dsize = H5Tget_size(dtid)) == 0)
- FAIL_STACK_ERROR
/* Verify case #1 */
VERIFY_EQUAL(dsize, ck_dsize)
/* Get datatype id for each member */
- if((memb0_tid = H5Tget_member_type(dtid, 0)) < 0) /* "field,1" */
- FAIL_STACK_ERROR
- if((memb1_tid = H5Tget_member_type(dtid, 1)) < 0) /* "field2." */
- FAIL_STACK_ERROR
- if((memb2_tid = H5Tget_member_type(dtid, 2)) < 0) /* "field\3" */
- FAIL_STACK_ERROR
- if((memb3_tid = H5Tget_member_type(dtid, 3)) < 0) /* "field4," */
- FAIL_STACK_ERROR
+ if ((memb0_tid = H5Tget_member_type(dtid, 0)) < 0) /* "field,1" */
+ FAIL_STACK_ERROR
+ if ((memb1_tid = H5Tget_member_type(dtid, 1)) < 0) /* "field2." */
+ FAIL_STACK_ERROR
+ if ((memb2_tid = H5Tget_member_type(dtid, 2)) < 0) /* "field\3" */
+ FAIL_STACK_ERROR
+ if ((memb3_tid = H5Tget_member_type(dtid, 3)) < 0) /* "field4," */
+ FAIL_STACK_ERROR
/* Obtain size for VALID_ESC_FIELDS1: "field\\,1,field2\\..\\.a,field\\\\3,field4\\," */
- if((dsize = H5LDget_dset_type_size(did, VALID_ESC_FIELDS1)) == 0)
- FAIL_STACK_ERROR
+ if ((dsize = H5LDget_dset_type_size(did, VALID_ESC_FIELDS1)) == 0)
+ FAIL_STACK_ERROR
/* Get the datatype size for "field\\,1" */
- if((ck_dsize = H5Tget_size(memb0_tid)) == 0)
- FAIL_STACK_ERROR
+ if ((ck_dsize = H5Tget_size(memb0_tid)) == 0)
+ FAIL_STACK_ERROR
/* Add the datatype size for "field2\\..\\.a" */
- if((memb_tid = H5Tget_member_type(memb1_tid, 0)) < 0)
- FAIL_STACK_ERROR
- if((ck_dsize += H5Tget_size(memb_tid)) == 0)
- FAIL_STACK_ERROR
- if(H5Tclose(memb_tid) < 0)
- FAIL_STACK_ERROR
+ if ((memb_tid = H5Tget_member_type(memb1_tid, 0)) < 0)
+ FAIL_STACK_ERROR
+ if ((ck_dsize += H5Tget_size(memb_tid)) == 0)
+ FAIL_STACK_ERROR
+ if (H5Tclose(memb_tid) < 0)
+ FAIL_STACK_ERROR
/* Add the datatype size for "field\\\\3" */
- if((ck_dsize += H5Tget_size(memb2_tid)) == 0)
- FAIL_STACK_ERROR
+ if ((ck_dsize += H5Tget_size(memb2_tid)) == 0)
+ FAIL_STACK_ERROR
/* Add the datatype size for "field4\\," */
- if((ck_dsize += H5Tget_size(memb3_tid)) == 0)
- FAIL_STACK_ERROR
+ if ((ck_dsize += H5Tget_size(memb3_tid)) == 0)
+ FAIL_STACK_ERROR
/* Verify case #2 */
VERIFY_EQUAL(dsize, ck_dsize)
/* Obtain datatype size for VALID_ESC_FIELDS2:
"field2\\..\\,b.a,field2\\..\\\\c,field4\\,.b\\," */
- if((dsize = H5LDget_dset_type_size(did, VALID_ESC_FIELDS2)) == 0)
- FAIL_STACK_ERROR
+ if ((dsize = H5LDget_dset_type_size(did, VALID_ESC_FIELDS2)) == 0)
+ FAIL_STACK_ERROR
/* Get the datatype size for "field2\..,b.a" */
- if((memb_tid = H5Tget_member_type(memb1_tid, 1)) < 0)
- FAIL_STACK_ERROR
- if((memb_tid2 = H5Tget_member_type(memb_tid, 0)) < 0)
- FAIL_STACK_ERROR
- if((ck_dsize = H5Tget_size(memb_tid2)) == 0)
- FAIL_STACK_ERROR
- if(H5Tclose(memb_tid) < 0)
- FAIL_STACK_ERROR
- if(H5Tclose(memb_tid2) < 0)
- FAIL_STACK_ERROR
+ if ((memb_tid = H5Tget_member_type(memb1_tid, 1)) < 0)
+ FAIL_STACK_ERROR
+ if ((memb_tid2 = H5Tget_member_type(memb_tid, 0)) < 0)
+ FAIL_STACK_ERROR
+ if ((ck_dsize = H5Tget_size(memb_tid2)) == 0)
+ FAIL_STACK_ERROR
+ if (H5Tclose(memb_tid) < 0)
+ FAIL_STACK_ERROR
+ if (H5Tclose(memb_tid2) < 0)
+ FAIL_STACK_ERROR
/* Add the datatype size for "field2\..\\c" */
- if((memb_tid = H5Tget_member_type(memb1_tid, 2)) < 0)
- FAIL_STACK_ERROR
- if((ck_dsize += H5Tget_size(memb_tid)) == 0)
- FAIL_STACK_ERROR
- if(H5Tclose(memb_tid) < 0)
- FAIL_STACK_ERROR
+ if ((memb_tid = H5Tget_member_type(memb1_tid, 2)) < 0)
+ FAIL_STACK_ERROR
+ if ((ck_dsize += H5Tget_size(memb_tid)) == 0)
+ FAIL_STACK_ERROR
+ if (H5Tclose(memb_tid) < 0)
+ FAIL_STACK_ERROR
/* Add the datatype size for "field4\,.b\," */
- if((memb_tid = H5Tget_member_type(memb3_tid, 1)) < 0)
- FAIL_STACK_ERROR
- if((ck_dsize += H5Tget_size(memb_tid)) == 0)
- FAIL_STACK_ERROR
- if(H5Tclose(memb_tid) < 0)
- FAIL_STACK_ERROR
+ if ((memb_tid = H5Tget_member_type(memb3_tid, 1)) < 0)
+ FAIL_STACK_ERROR
+ if ((ck_dsize += H5Tget_size(memb_tid)) == 0)
+ FAIL_STACK_ERROR
+ if (H5Tclose(memb_tid) < 0)
+ FAIL_STACK_ERROR
/* Verify case #3 */
VERIFY_EQUAL(dsize, ck_dsize)
@@ -780,42 +781,43 @@ test_LD_size(const char *file)
VERIFY_EQUAL(dsize, 0)
/* Closing */
- if(H5Tclose(memb0_tid) < 0)
- FAIL_STACK_ERROR
- if(H5Tclose(memb1_tid) < 0)
- FAIL_STACK_ERROR
- if(H5Tclose(memb2_tid) < 0)
- FAIL_STACK_ERROR
- if(H5Tclose(memb3_tid) < 0)
- FAIL_STACK_ERROR
- if(H5Tclose(dtid) < 0)
- FAIL_STACK_ERROR
- if(H5Dclose(did) < 0)
- FAIL_STACK_ERROR
-
- if(H5Fclose(fid) < 0)
- FAIL_STACK_ERROR
+ if (H5Tclose(memb0_tid) < 0)
+ FAIL_STACK_ERROR
+ if (H5Tclose(memb1_tid) < 0)
+ FAIL_STACK_ERROR
+ if (H5Tclose(memb2_tid) < 0)
+ FAIL_STACK_ERROR
+ if (H5Tclose(memb3_tid) < 0)
+ FAIL_STACK_ERROR
+ if (H5Tclose(dtid) < 0)
+ FAIL_STACK_ERROR
+ if (H5Dclose(did) < 0)
+ FAIL_STACK_ERROR
+
+ if (H5Fclose(fid) < 0)
+ FAIL_STACK_ERROR
PASSED();
return 0;
error:
- H5E_BEGIN_TRY {
- H5Tclose(memb0_tid);
- H5Tclose(memb1_tid);
- H5Tclose(memb2_tid);
- H5Tclose(memb3_tid);
- H5Tclose(memb_tid);
- H5Tclose(memb_tid2);
- H5Tclose(dtid);
- H5Dclose(did);
- H5Fclose(fid);
- } H5E_END_TRY;
- return(-1);
+ H5E_BEGIN_TRY
+ {
+ H5Tclose(memb0_tid);
+ H5Tclose(memb1_tid);
+ H5Tclose(memb2_tid);
+ H5Tclose(memb3_tid);
+ H5Tclose(memb_tid);
+ H5Tclose(memb_tid2);
+ H5Tclose(dtid);
+ H5Dclose(did);
+ H5Fclose(fid);
+ }
+ H5E_END_TRY;
+ return (-1);
} /* test_LD_size() */
-
/*
**************************************************************************************
* Testing for the High Level public routine: H5LDget_dset_elmts()
@@ -839,32 +841,32 @@ error:
static int
test_LD_elmts_invalid(const char *file)
{
- hid_t fid=-1; /* file identifier */
- hid_t did=-1; /* dataset identifier */
- hid_t sid=-1; /* dataspace identifier */
- hid_t invalid_id=-1;
- int ret; /* return value */
- hsize_t cur_dims[2]; /* current dimension sizes of the dataset */
- hsize_t prev_dims[2]; /* previous dimension sizes of the dataset */
- char tbuf[2]; /* temporary buffer for testing */
- int ndims; /* # of dimension sizes */
- int i; /* local index variable */
+ hid_t fid = -1; /* file identifier */
+ hid_t did = -1; /* dataset identifier */
+ hid_t sid = -1; /* dataspace identifier */
+ hid_t invalid_id = -1;
+ int ret; /* return value */
+ hsize_t cur_dims[2]; /* current dimension sizes of the dataset */
+ hsize_t prev_dims[2]; /* previous dimension sizes of the dataset */
+ char tbuf[2]; /* temporary buffer for testing */
+ int ndims; /* # of dimension sizes */
+ int i; /* local index variable */
const char *filename = H5_get_srcdir_filename(file);
HL_TESTING2("H5LDget_dset_elmts on invalid conditions");
/* Open the copied file */
- if((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
- FAIL_STACK_ERROR
+ if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
/*
* Testing two-dimensional dataset: DSET_TWO
*/
/* Open dataset: DSET_TWO */
- if((did = H5Dopen2(fid, DSET_TWO, H5P_DEFAULT)) < 0)
- FAIL_STACK_ERROR
+ if ((did = H5Dopen2(fid, DSET_TWO, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
/* Verify failure from case #1: cur_dims and prev_dims are NULL */
ret = H5LDget_dset_elmts(did, NULL, NULL, NULL, NULL);
@@ -878,16 +880,16 @@ test_LD_elmts_invalid(const char *file)
ret = H5LDget_dset_elmts(did, NULL, prev_dims, NULL, NULL);
VERIFY_EQUAL(ret, FAIL)
- if((sid = H5Dget_space(did)) < 0)
- FAIL_STACK_ERROR
+ if ((sid = H5Dget_space(did)) < 0)
+ FAIL_STACK_ERROR
/* Get the # of dimensions and current dimension sizes */
- if((ndims = H5Sget_simple_extent_dims(sid, cur_dims, NULL)) < 0)
- FAIL_STACK_ERROR
+ if ((ndims = H5Sget_simple_extent_dims(sid, cur_dims, NULL)) < 0)
+ FAIL_STACK_ERROR
/* Set up valid cur_dims and prev_dims */
- for(i = 0; i < ndims; i++)
- prev_dims[i] = cur_dims[i] - 1;
+ for (i = 0; i < ndims; i++)
+ prev_dims[i] = cur_dims[i] - 1;
/* Verify failure from case #4: FIELDS is nonNULL but the dataset is not compound datatype */
ret = H5LDget_dset_elmts(did, prev_dims, cur_dims, "field1", tbuf);
@@ -900,12 +902,12 @@ test_LD_elmts_invalid(const char *file)
/* Verify failure from case #6: cur_dims is not > than prev_dims */
cur_dims[0] = prev_dims[0] - 1;
cur_dims[1] = prev_dims[1] - 1;
- ret = H5LDget_dset_elmts(did, prev_dims, cur_dims, NULL, tbuf);
+ ret = H5LDget_dset_elmts(did, prev_dims, cur_dims, NULL, tbuf);
VERIFY_EQUAL(ret, FAIL)
/* Close DSET_TWO */
- if(H5Dclose(did) < 0)
- FAIL_STACK_ERROR
+ if (H5Dclose(did) < 0)
+ FAIL_STACK_ERROR
/*
* Testing one-dimensional dataset with compound datatype:
@@ -913,18 +915,17 @@ test_LD_elmts_invalid(const char *file)
*/
/* Verify failure from case #1: an invalid dataset id */
- H5E_BEGIN_TRY {
- ret = H5LDget_dset_elmts(invalid_id, prev_dims, cur_dims, NULL, tbuf);
- } H5E_END_TRY;
+ H5E_BEGIN_TRY { ret = H5LDget_dset_elmts(invalid_id, prev_dims, cur_dims, NULL, tbuf); }
+ H5E_END_TRY;
VERIFY_EQUAL(ret, FAIL)
/* Open dataset: DSET_CMPD */
- if((did = H5Dopen2(fid, DSET_CMPD, H5P_DEFAULT)) < 0)
- FAIL_STACK_ERROR
+ if ((did = H5Dopen2(fid, DSET_CMPD, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
/* Retrieve the current dimension sizes */
- if(H5LDget_dset_dims(did, cur_dims) < 0)
- FAIL_STACK_ERROR
+ if (H5LDget_dset_dims(did, cur_dims) < 0)
+ FAIL_STACK_ERROR
/* Set up valid cur_dims, prev_dims */
prev_dims[0] = cur_dims[0] - 1;
@@ -934,27 +935,28 @@ test_LD_elmts_invalid(const char *file)
VERIFY_EQUAL(ret, FAIL)
/* Close DSET_CMPD */
- if(H5Dclose(did) < 0)
- FAIL_STACK_ERROR
+ if (H5Dclose(did) < 0)
+ FAIL_STACK_ERROR
/* Close the file */
- if(H5Fclose(fid) < 0)
- FAIL_STACK_ERROR
+ if (H5Fclose(fid) < 0)
+ FAIL_STACK_ERROR
PASSED();
return 0;
error:
- H5E_BEGIN_TRY {
- H5Sclose(sid);
- H5Dclose(did);
- H5Fclose(fid);
- } H5E_END_TRY;
- return(-1);
+ H5E_BEGIN_TRY
+ {
+ H5Sclose(sid);
+ H5Dclose(did);
+ H5Fclose(fid);
+ }
+ H5E_END_TRY;
+ return (-1);
} /* test_LD_elmts_invalid() */
-
/*
**************************************************************************************
* Testing for the High Level public routine: H5LDget_dset_elmts()
@@ -977,122 +979,122 @@ error:
static herr_t
test_LD_elmts_one(const char *file, const char *dname, const char *fields)
{
- hid_t fid=-1; /* file identifier */
- hid_t did=-1; /* dataset identifier */
- hid_t dtype=-1; /* dataset's data type */
- hsize_t ext_dims[1]; /* extended dimension sizes of the dataset */
- hsize_t prev_dims[1]; /* previous dimension sizes of the dataset */
- int i, j; /* local index variable */
- int ret = 0; /* return value */
+ hid_t fid = -1; /* file identifier */
+ hid_t did = -1; /* dataset identifier */
+ hid_t dtype = -1; /* dataset's data type */
+ hsize_t ext_dims[1]; /* extended dimension sizes of the dataset */
+ hsize_t prev_dims[1]; /* previous dimension sizes of the dataset */
+ int i, j; /* local index variable */
+ int ret = 0; /* return value */
HL_TESTING2("H5LDget_dset_elmts: one-dimensional dataset");
/* Copy the test file */
- if(h5_make_local_copy(file, COPY_FILENAME) < 0)
+ if (h5_make_local_copy(file, COPY_FILENAME) < 0)
TEST_ERROR
- for(i = 0; i < TEST_BUF_SIZE; i++) {
- cbuf[i].field1 = i;
- cbuf[i].field2.a = i;
- cbuf[i].field2.b.a = i;
- cbuf[i].field2.b.b = i;
- cbuf[i].field2.b.c = i;
- cbuf[i].field2.c = i;
- cbuf[i].field3 = (double)i;
- cbuf[i].field4.a = i;
- cbuf[i].field4.b = i;
- ibuf[i] = i;
+ for (i = 0; i < TEST_BUF_SIZE; i++) {
+ cbuf[i].field1 = i;
+ cbuf[i].field2.a = i;
+ cbuf[i].field2.b.a = i;
+ cbuf[i].field2.b.b = i;
+ cbuf[i].field2.b.c = i;
+ cbuf[i].field2.c = i;
+ cbuf[i].field3 = (double)i;
+ cbuf[i].field4.a = i;
+ cbuf[i].field4.b = i;
+ ibuf[i] = i;
} /* end for */
/* Open the copied file */
- if((fid = H5Fopen(COPY_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
- FAIL_STACK_ERROR
+ if ((fid = H5Fopen(COPY_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
/* Open the dataset */
- if((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0)
- FAIL_STACK_ERROR
+ if ((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
/* Get the dataset's data type */
- if((dtype = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0)
- FAIL_STACK_ERROR
+ if ((dtype = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
/* Get current dimension sizes before extending the dataset's dimension sizes */
- if(H5LDget_dset_dims(did, prev_dims) < 0)
- FAIL_STACK_ERROR
-
- /* Loop through different variations of extending the dataset */
- for(i = 0; i < ONE_NTESTS; i++) {
- HDmemset(vbuf1, 0, TEST_BUF_SIZE * sizeof(test_valid_fields1));
- HDmemset(vbuf2, 0, TEST_BUF_SIZE * sizeof(test_valid_fields2));
- HDmemset(ccbuf, 0, TEST_BUF_SIZE * sizeof(set_t));
- HDmemset(iibuf, 0, TEST_BUF_SIZE * sizeof(int));
-
- ext_dims[0] = (hsize_t)((int)prev_dims[0] + one_tests[i]);
-
- /* Change the dimension sizes of the dataset */
- if(H5Dset_extent(did, ext_dims) < 0)
+ if (H5LDget_dset_dims(did, prev_dims) < 0)
FAIL_STACK_ERROR
- /* Initialize data */
- if(!HDstrcmp(dname, DSET_CMPD) || !HDstrcmp(dname, DSET_CMPD_ESC)) {
- if(H5Dwrite(did, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, cbuf) < 0)
- FAIL_STACK_ERROR
- } /* end if */
- else if(!HDstrcmp(dname, DSET_ONE)) {
- if(H5Dwrite(did, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, ibuf) < 0)
- FAIL_STACK_ERROR
- } /* end if */
+ /* Loop through different variations of extending the dataset */
+ for (i = 0; i < ONE_NTESTS; i++) {
+ HDmemset(vbuf1, 0, TEST_BUF_SIZE * sizeof(test_valid_fields1));
+ HDmemset(vbuf2, 0, TEST_BUF_SIZE * sizeof(test_valid_fields2));
+ HDmemset(ccbuf, 0, TEST_BUF_SIZE * sizeof(set_t));
+ HDmemset(iibuf, 0, TEST_BUF_SIZE * sizeof(int));
+
+ ext_dims[0] = (hsize_t)((int)prev_dims[0] + one_tests[i]);
+
+ /* Change the dimension sizes of the dataset */
+ if (H5Dset_extent(did, ext_dims) < 0)
+ FAIL_STACK_ERROR
+
+ /* Initialize data */
+ if (!HDstrcmp(dname, DSET_CMPD) || !HDstrcmp(dname, DSET_CMPD_ESC)) {
+ if (H5Dwrite(did, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, cbuf) < 0)
+ FAIL_STACK_ERROR
+ } /* end if */
+ else if (!HDstrcmp(dname, DSET_ONE)) {
+ if (H5Dwrite(did, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, ibuf) < 0)
+ FAIL_STACK_ERROR
+ } /* end if */
- /* There are changes in dimension sizes */
- if(one_tests[i] > 0) {
- if(!HDstrcmp(dname, DSET_CMPD) || !HDstrcmp(dname, DSET_CMPD_ESC)) {
- if(fields) {
- if(!HDstrcmp(fields, VALID_FIELDS1) || !HDstrcmp(fields, VALID_ESC_FIELDS1)) {
+ /* There are changes in dimension sizes */
+ if (one_tests[i] > 0) {
+ if (!HDstrcmp(dname, DSET_CMPD) || !HDstrcmp(dname, DSET_CMPD_ESC)) {
+ if (fields) {
+ if (!HDstrcmp(fields, VALID_FIELDS1) || !HDstrcmp(fields, VALID_ESC_FIELDS1)) {
/* Retrieve the elmemts in BUF */
- if(H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, vbuf1) < 0)
+ if (H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, vbuf1) < 0)
TEST_ERROR
- for(j = 0; j < one_tests[i]; j++)
+ for (j = 0; j < one_tests[i]; j++)
VERIFY_ELMTS_VALID1(vbuf1[j], cbuf[prev_dims[0] + (hsize_t)j])
} /* end if */
- else if(!HDstrcmp(fields, VALID_FIELDS2) || !HDstrcmp(fields, VALID_ESC_FIELDS2)) {
+ else if (!HDstrcmp(fields, VALID_FIELDS2) || !HDstrcmp(fields, VALID_ESC_FIELDS2)) {
/* Retrieve the elmemts in BUF */
- if(H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, vbuf2) < 0)
+ if (H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, vbuf2) < 0)
TEST_ERROR
- for(j = 0; j < one_tests[i]; j++)
+ for (j = 0; j < one_tests[i]; j++)
VERIFY_ELMTS_VALID2(vbuf2[j], cbuf[prev_dims[0] + (hsize_t)j])
} /* end else-if */
else
- TEST_ERROR
- } /* end if */
+ TEST_ERROR
+ } /* end if */
else {
- /* Retrieve the elmemts in BUF */
- if(H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, ccbuf) < 0)
- TEST_ERROR
- for(j = 0; j < one_tests[i]; j++)
- VERIFY_ELMTS_ALL(ccbuf[j], cbuf[prev_dims[0] + (hsize_t)j])
- } /* end else-if */
- } /* end if */
+ /* Retrieve the elmemts in BUF */
+ if (H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, ccbuf) < 0)
+ TEST_ERROR
+ for (j = 0; j < one_tests[i]; j++)
+ VERIFY_ELMTS_ALL(ccbuf[j], cbuf[prev_dims[0] + (hsize_t)j])
+ } /* end else-if */
+ } /* end if */
else {
- /* Retrieve the elmemts in BUF */
- if(H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, iibuf) < 0)
- TEST_ERROR
- for(j = 0; j < one_tests[i]; j++)
- VERIFY_EQUAL(iibuf[j], ibuf[prev_dims[0] + (hsize_t)j])
- } /* end else */
- } /* end if */
+ /* Retrieve the elmemts in BUF */
+ if (H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, iibuf) < 0)
+ TEST_ERROR
+ for (j = 0; j < one_tests[i]; j++)
+ VERIFY_EQUAL(iibuf[j], ibuf[prev_dims[0] + (hsize_t)j])
+ } /* end else */
+ } /* end if */
else {
/* Verify failure when changes between prev_dims and ext_dims are same/decrease */
ret = H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, iibuf);
VERIFY_EQUAL(ret, FAIL)
} /* end else */
- } /* end for */
+ } /* end for */
/* Closing */
- if(H5Tclose(dtype) < 0)
+ if (H5Tclose(dtype) < 0)
FAIL_STACK_ERROR
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
FAIL_STACK_ERROR
- if(H5Fclose(fid) < 0)
+ if (H5Fclose(fid) < 0)
FAIL_STACK_ERROR
/* Remove the copied file */
@@ -1102,15 +1104,16 @@ test_LD_elmts_one(const char *file, const char *dname, const char *fields)
return 0;
error:
- H5E_BEGIN_TRY {
- H5Tclose(dtype);
- H5Dclose(did);
- H5Fclose(fid);
- } H5E_END_TRY;
- return(-1);
+ H5E_BEGIN_TRY
+ {
+ H5Tclose(dtype);
+ H5Dclose(did);
+ H5Fclose(fid);
+ }
+ H5E_END_TRY;
+ return (-1);
} /* test_LD_elmts_one() */
-
/*
**************************************************************************************
*
@@ -1132,36 +1135,35 @@ error:
**************************************************************************************
*/
static herr_t
-verify_elmts_two(int type, hsize_t *ext_dims, hsize_t *prev_dims, void *_ldbuf, void *_buf)
+verify_elmts_two(int type, hsize_t *ext_dims, hsize_t *prev_dims, void *_ldbuf, void *_buf)
{
- int k, m; /* Local index variable */
+ int k, m; /* Local index variable */
k = 0;
- for(m = 0; m < (int)ext_dims[0]; m++) {
- int n, ind; /* Local index variable */
-
- ind = m * (int)ext_dims[1];
- if(m < (int)prev_dims[0]) {
- for(n = (int)prev_dims[1]; n < (int)ext_dims[1]; n++) {
- VERIFY_ELMTS(type, k, ind, _ldbuf, _buf)
- ++k;
- } /* end for */
- } /* end if */
+ for (m = 0; m < (int)ext_dims[0]; m++) {
+ int n, ind; /* Local index variable */
+
+ ind = m * (int)ext_dims[1];
+ if (m < (int)prev_dims[0]) {
+ for (n = (int)prev_dims[1]; n < (int)ext_dims[1]; n++) {
+ VERIFY_ELMTS(type, k, ind, _ldbuf, _buf)
+ ++k;
+ } /* end for */
+ } /* end if */
else {
- for(n = 0; n < (int)ext_dims[1]; n++) {
- VERIFY_ELMTS(type, k, ind, _ldbuf, _buf)
- ++k;
- } /* end for */
- } /* end else */
- } /* end for */
+ for (n = 0; n < (int)ext_dims[1]; n++) {
+ VERIFY_ELMTS(type, k, ind, _ldbuf, _buf)
+ ++k;
+ } /* end for */
+ } /* end else */
+ } /* end for */
- return(0);
+ return (0);
error:
- return(-1);
+ return (-1);
} /* verify_elmts_two() */
-
/*
**************************************************************************************
* Testing for the High Level public routine: H5LDget_dset_elmts()
@@ -1188,126 +1190,126 @@ error:
static herr_t
test_LD_elmts_two(const char *file, const char *dname, const char *fields)
{
- hid_t fid=-1; /* file identifier */
- hid_t did=-1; /* dataset identifier */
- hid_t dtype=-1; /* dataset's data type */
- hsize_t ext_dims[2]; /* extended dimension sizes of the dataset */
- hsize_t prev_dims[2]; /* previous dimension sizes of the dataset */
- int i; /* local index variable */
- int ret = 0; /* return value */
+ hid_t fid = -1; /* file identifier */
+ hid_t did = -1; /* dataset identifier */
+ hid_t dtype = -1; /* dataset's data type */
+ hsize_t ext_dims[2]; /* extended dimension sizes of the dataset */
+ hsize_t prev_dims[2]; /* previous dimension sizes of the dataset */
+ int i; /* local index variable */
+ int ret = 0; /* return value */
HL_TESTING2("H5LDget_dset_elmts: two-dimensional dataset");
/* Copy the test file */
- if(h5_make_local_copy(file, COPY_FILENAME) < 0)
+ if (h5_make_local_copy(file, COPY_FILENAME) < 0)
TEST_ERROR
- for(i = 0; i < TEST_BUF_SIZE; i++) {
- cbuf[i].field1 = i;
- cbuf[i].field2.a = i;
- cbuf[i].field2.b.a = i;
- cbuf[i].field2.b.b = i;
- cbuf[i].field2.b.c = i;
- cbuf[i].field2.c = i;
- cbuf[i].field3 = (double)i;
- cbuf[i].field4.a = i;
- cbuf[i].field4.b = i;
- ibuf[i] = i;
+ for (i = 0; i < TEST_BUF_SIZE; i++) {
+ cbuf[i].field1 = i;
+ cbuf[i].field2.a = i;
+ cbuf[i].field2.b.a = i;
+ cbuf[i].field2.b.b = i;
+ cbuf[i].field2.b.c = i;
+ cbuf[i].field2.c = i;
+ cbuf[i].field3 = (double)i;
+ cbuf[i].field4.a = i;
+ cbuf[i].field4.b = i;
+ ibuf[i] = i;
} /* end for */
/* Open the copied file */
- if((fid = H5Fopen(COPY_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
- FAIL_STACK_ERROR
+ if ((fid = H5Fopen(COPY_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
/* Open the dataset */
- if((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0)
- FAIL_STACK_ERROR
+ if ((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
/* Get the dataset's data type */
- if((dtype = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0)
- FAIL_STACK_ERROR
+ if ((dtype = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
/* Get current dimension sizes before extending the dataset's dimension sizes */
- if(H5LDget_dset_dims(did, prev_dims) < 0)
- FAIL_STACK_ERROR
-
- /* Loop through different variations of extending the dataset */
- for(i = 0; i < TWO_NTESTS; i++) {
- HDmemset(vbuf1, 0, TEST_BUF_SIZE * sizeof(test_valid_fields1));
- HDmemset(vbuf2, 0, TEST_BUF_SIZE * sizeof(test_valid_fields2));
- HDmemset(ccbuf, 0, TEST_BUF_SIZE * sizeof(set_t));
- HDmemset(iibuf, 0, TEST_BUF_SIZE * sizeof(int));
-
- ext_dims[0] = (hsize_t)((int)prev_dims[0] + two_tests[i][0]);
- ext_dims[1] = (hsize_t)((int)prev_dims[1] + two_tests[i][1]);
-
- /* Change the dimension sizes of the dataset */
- if(H5Dset_extent(did, ext_dims) < 0)
+ if (H5LDget_dset_dims(did, prev_dims) < 0)
FAIL_STACK_ERROR
- /* Initialize data */
- if(!HDstrcmp(dname, DSET_CMPD_TWO)) {
- if(H5Dwrite(did, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, cbuf) < 0)
- FAIL_STACK_ERROR
- } /* end if */
- else if(!HDstrcmp(dname, DSET_TWO)) {
- if(H5Dwrite(did, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, ibuf) < 0)
- FAIL_STACK_ERROR
- } /* end else-if */
+ /* Loop through different variations of extending the dataset */
+ for (i = 0; i < TWO_NTESTS; i++) {
+ HDmemset(vbuf1, 0, TEST_BUF_SIZE * sizeof(test_valid_fields1));
+ HDmemset(vbuf2, 0, TEST_BUF_SIZE * sizeof(test_valid_fields2));
+ HDmemset(ccbuf, 0, TEST_BUF_SIZE * sizeof(set_t));
+ HDmemset(iibuf, 0, TEST_BUF_SIZE * sizeof(int));
+
+ ext_dims[0] = (hsize_t)((int)prev_dims[0] + two_tests[i][0]);
+ ext_dims[1] = (hsize_t)((int)prev_dims[1] + two_tests[i][1]);
+
+ /* Change the dimension sizes of the dataset */
+ if (H5Dset_extent(did, ext_dims) < 0)
+ FAIL_STACK_ERROR
+
+ /* Initialize data */
+ if (!HDstrcmp(dname, DSET_CMPD_TWO)) {
+ if (H5Dwrite(did, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, cbuf) < 0)
+ FAIL_STACK_ERROR
+ } /* end if */
+ else if (!HDstrcmp(dname, DSET_TWO)) {
+ if (H5Dwrite(did, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, ibuf) < 0)
+ FAIL_STACK_ERROR
+ } /* end else-if */
else
TEST_ERROR
- /* There are changes in dimension sizes */
- if(two_tests[i][0] > 0 || two_tests[i][1] > 0) {
- if(!HDstrcmp(dname, DSET_CMPD_TWO)) {
- if(fields) {
- if(!HDstrcmp(fields, VALID_FIELDS1) || !HDstrcmp(fields, VALID_ESC_FIELDS1)) {
+ /* There are changes in dimension sizes */
+ if (two_tests[i][0] > 0 || two_tests[i][1] > 0) {
+ if (!HDstrcmp(dname, DSET_CMPD_TWO)) {
+ if (fields) {
+ if (!HDstrcmp(fields, VALID_FIELDS1) || !HDstrcmp(fields, VALID_ESC_FIELDS1)) {
/* Retrieve the elmemts in BUF */
- if(H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, vbuf1) < 0)
+ if (H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, vbuf1) < 0)
TEST_ERROR
- if(verify_elmts_two(TWO_CMPD_VALID1, ext_dims, prev_dims, vbuf1, cbuf) < 0)
+ if (verify_elmts_two(TWO_CMPD_VALID1, ext_dims, prev_dims, vbuf1, cbuf) < 0)
TEST_ERROR
} /* end if */
- else if(!HDstrcmp(fields, VALID_FIELDS2) || !HDstrcmp(fields, VALID_ESC_FIELDS2)) {
+ else if (!HDstrcmp(fields, VALID_FIELDS2) || !HDstrcmp(fields, VALID_ESC_FIELDS2)) {
/* Retrieve the elmemts in BUF */
- if(H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, vbuf2) < 0)
+ if (H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, vbuf2) < 0)
TEST_ERROR
- if(verify_elmts_two(TWO_CMPD_VALID2, ext_dims, prev_dims, vbuf2, cbuf) < 0)
+ if (verify_elmts_two(TWO_CMPD_VALID2, ext_dims, prev_dims, vbuf2, cbuf) < 0)
TEST_ERROR
} /* end else-if */
else
TEST_ERROR
- } /* end if */
+ } /* end if */
else {
- /* Retrieve the elmemts in BUF */
- if(H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, ccbuf) < 0)
- TEST_ERROR
- if(verify_elmts_two(TWO_CMPD_NULL, ext_dims, prev_dims, ccbuf, cbuf) < 0)
- TEST_ERROR
- } /* end else */
- } /* end if */
+ /* Retrieve the elmemts in BUF */
+ if (H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, ccbuf) < 0)
+ TEST_ERROR
+ if (verify_elmts_two(TWO_CMPD_NULL, ext_dims, prev_dims, ccbuf, cbuf) < 0)
+ TEST_ERROR
+ } /* end else */
+ } /* end if */
else { /* DSET_TWO */
- /* Retrieve the elmemts in BUF */
- if(H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, iibuf) < 0)
- TEST_ERROR
- if(verify_elmts_two(TWO_NONE, ext_dims, prev_dims, iibuf, ibuf) < 0)
- TEST_ERROR
- } /* end else */
- } /* end if */
+ /* Retrieve the elmemts in BUF */
+ if (H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, iibuf) < 0)
+ TEST_ERROR
+ if (verify_elmts_two(TWO_NONE, ext_dims, prev_dims, iibuf, ibuf) < 0)
+ TEST_ERROR
+ } /* end else */
+ } /* end if */
else {
- /* Verify failure when changes between prev_dims and ext_dims are same/decrease */
- ret = H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, iibuf);
- VERIFY_EQUAL(ret, FAIL)
- } /* end else */
- } /* end for */
+ /* Verify failure when changes between prev_dims and ext_dims are same/decrease */
+ ret = H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, iibuf);
+ VERIFY_EQUAL(ret, FAIL)
+ } /* end else */
+ } /* end for */
/* Closing */
- if(H5Tclose(dtype) < 0)
- FAIL_STACK_ERROR;
- if(H5Dclose(did) < 0)
- FAIL_STACK_ERROR;
- if(H5Fclose(fid) < 0)
- FAIL_STACK_ERROR;
+ if (H5Tclose(dtype) < 0)
+ FAIL_STACK_ERROR;
+ if (H5Dclose(did) < 0)
+ FAIL_STACK_ERROR;
+ if (H5Fclose(fid) < 0)
+ FAIL_STACK_ERROR;
/* Remove the copied file */
HDremove(COPY_FILENAME);
@@ -1316,37 +1318,40 @@ test_LD_elmts_two(const char *file, const char *dname, const char *fields)
return 0;
error:
- H5E_BEGIN_TRY {
- H5Tclose(dtype);
- H5Dclose(did);
- H5Fclose(fid);
- } H5E_END_TRY;
- return(-1);
+ H5E_BEGIN_TRY
+ {
+ H5Tclose(dtype);
+ H5Dclose(did);
+ H5Fclose(fid);
+ }
+ H5E_END_TRY;
+ return (-1);
} /* test_LD_elmts_two() */
/*
* Tests for High Level routines:
* H5LDget_dset_dims(), H5LDget_dset_elmts, H5LDget_dset_type_size()
*/
-int main(void)
+int
+main(void)
{
- int nerrors = 0;
+ int nerrors = 0;
/* Set up temporary buffers for tests: test_LD_elmts_one() & test_LD_elmts_two() */
- if(NULL == (ibuf = (int *)HDmalloc(sizeof(int) * TEST_BUF_SIZE)))
- FAIL_STACK_ERROR;
- if(NULL == (iibuf = (int *)HDmalloc(sizeof(int) * TEST_BUF_SIZE)))
- FAIL_STACK_ERROR;
+ if (NULL == (ibuf = (int *)HDmalloc(sizeof(int) * TEST_BUF_SIZE)))
+ FAIL_STACK_ERROR;
+ if (NULL == (iibuf = (int *)HDmalloc(sizeof(int) * TEST_BUF_SIZE)))
+ FAIL_STACK_ERROR;
- if(NULL == (cbuf = (set_t *)HDmalloc(sizeof(set_t) * TEST_BUF_SIZE)))
- FAIL_STACK_ERROR;
- if(NULL == (ccbuf = (set_t *)HDmalloc(sizeof(set_t) * TEST_BUF_SIZE)))
- FAIL_STACK_ERROR;
+ if (NULL == (cbuf = (set_t *)HDmalloc(sizeof(set_t) * TEST_BUF_SIZE)))
+ FAIL_STACK_ERROR;
+ if (NULL == (ccbuf = (set_t *)HDmalloc(sizeof(set_t) * TEST_BUF_SIZE)))
+ FAIL_STACK_ERROR;
- if(NULL == (vbuf1 = (test_valid_fields1 *)HDmalloc(sizeof(test_valid_fields1) * TEST_BUF_SIZE)))
- FAIL_STACK_ERROR;
- if(NULL == (vbuf2 = (test_valid_fields2 *)HDmalloc(sizeof(test_valid_fields2) * TEST_BUF_SIZE)))
- FAIL_STACK_ERROR;
+ if (NULL == (vbuf1 = (test_valid_fields1 *)HDmalloc(sizeof(test_valid_fields1) * TEST_BUF_SIZE)))
+ FAIL_STACK_ERROR;
+ if (NULL == (vbuf2 = (test_valid_fields2 *)HDmalloc(sizeof(test_valid_fields2) * TEST_BUF_SIZE)))
+ FAIL_STACK_ERROR;
/*
* Testing H5LDget_dset_dims()
@@ -1396,28 +1401,27 @@ int main(void)
nerrors += test_LD_elmts_two(FILE, DSET_CMPD_TWO, VALID_FIELDS2);
/* Free temporary buffers */
- if(ibuf)
+ if (ibuf)
HDfree(ibuf);
- if(iibuf)
+ if (iibuf)
HDfree(iibuf);
- if(cbuf)
+ if (cbuf)
HDfree(cbuf);
- if(ccbuf)
+ if (ccbuf)
HDfree(ccbuf);
- if(vbuf1)
+ if (vbuf1)
HDfree(vbuf1);
- if(vbuf2)
+ if (vbuf2)
HDfree(vbuf2);
/* check for errors */
- if(nerrors)
- goto error;
+ if (nerrors)
+ goto error;
puts("All tests for H5LD high level routines passed.");
- return(0);
+ return (0);
error:
- return(1);
+ return (1);
} /* main() */
-
diff --git a/hl/test/test_lite.c b/hl/test/test_lite.c
index f3e6e97..558211e 100644
--- a/hl/test/test_lite.c
+++ b/hl/test/test_lite.c
@@ -1,21 +1,21 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-* Copyright by The HDF Group. *
-* Copyright by the Board of Trustees of the University of Illinois. *
-* All rights reserved. *
-* *
-* This file is part of HDF5. The full HDF5 copyright notice, including *
-* terms governing use, modification, and redistribution, is contained in *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
* distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "h5hltest.h"
#include "H5srcdir.h"
#include "H5LTpublic.h"
-#define FILE_NAME "test_lite1.h5"
+#define FILE_NAME "test_lite1.h5"
#define FILE_NAME2 "test_lite2.h5"
#define FILE_NAME3 "test_lite3.h5"
#define FILE_NAME4 "test_lite4.h5"
@@ -33,78 +33,76 @@
#define DIM 6
#define ATTR_NAME_SUB "att"
-#define ATTR1_NAME "attr string"
-#define ATTR2_NAME "attr char"
-#define ATTR3_NAME "attr short"
-#define ATTR4_NAME "attr int"
+#define ATTR1_NAME "attr string"
+#define ATTR2_NAME "attr char"
+#define ATTR3_NAME "attr short"
+#define ATTR4_NAME "attr int"
#define ATTR_NAME_EXT "att int ext"
-#define ATTR5_NAME "attr long"
-#define ATTR6_NAME "attr uchar"
-#define ATTR7_NAME "attr ushort"
-#define ATTR8_NAME "attr uint"
-#define ATTR9_NAME "attr ulong"
-#define ATTR10_NAME "attr float"
-#define ATTR11_NAME "attr double"
-
-static herr_t make_attributes( hid_t loc_id, const char* obj_name );
+#define ATTR5_NAME "attr long"
+#define ATTR6_NAME "attr uchar"
+#define ATTR7_NAME "attr ushort"
+#define ATTR8_NAME "attr uint"
+#define ATTR9_NAME "attr ulong"
+#define ATTR10_NAME "attr float"
+#define ATTR11_NAME "attr double"
+static herr_t make_attributes(hid_t loc_id, const char *obj_name);
/*-------------------------------------------------------------------------
-* test dataset functions
-*-------------------------------------------------------------------------
-*/
+ * test dataset functions
+ *-------------------------------------------------------------------------
+ */
-static int test_dsets( void )
+static int
+test_dsets(void)
{
- int rank = 2;
- hsize_t dims[2] = {2,3};
- hid_t file_id;
- hid_t dataset_id;
- char data_char_in[DIM] = {1,2,3,4,5,6};
- char data_char_out[DIM];
- short data_short_in[DIM] = {1,2,3,4,5,6};
- short data_short_out[DIM];
- int data_int_in[DIM] = {1,2,3,4,5,6};
- int data_int_out[DIM];
- long data_long_in[DIM] = {1,2,3,4,5,6};
- long data_long_out[DIM];
- float data_float_in[DIM] = {1,2,3,4,5,6};
- float data_float_out[DIM];
- double data_double_in[DIM] = {1,2,3,4,5,6};
- double data_double_out[DIM];
- const char *data_string_in = "This is a string";
- char data_string_out[20];
- int i;
-
+ int rank = 2;
+ hsize_t dims[2] = {2, 3};
+ hid_t file_id;
+ hid_t dataset_id;
+ char data_char_in[DIM] = {1, 2, 3, 4, 5, 6};
+ char data_char_out[DIM];
+ short data_short_in[DIM] = {1, 2, 3, 4, 5, 6};
+ short data_short_out[DIM];
+ int data_int_in[DIM] = {1, 2, 3, 4, 5, 6};
+ int data_int_out[DIM];
+ long data_long_in[DIM] = {1, 2, 3, 4, 5, 6};
+ long data_long_out[DIM];
+ float data_float_in[DIM] = {1, 2, 3, 4, 5, 6};
+ float data_float_out[DIM];
+ double data_double_in[DIM] = {1, 2, 3, 4, 5, 6};
+ double data_double_out[DIM];
+ const char *data_string_in = "This is a string";
+ char data_string_out[20];
+ int i;
/* Create a new file using default properties. */
- file_id = H5Fcreate( FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT );
+ file_id = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
/*-------------------------------------------------------------------------
- * H5LTmake_dataset test
- *-------------------------------------------------------------------------
- */
+ * H5LTmake_dataset test
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("H5LTmake_dataset");
/* Make dataset */
- if ( H5LTmake_dataset( file_id, DSET0_NAME, rank, dims, H5T_NATIVE_INT, data_int_in ) < 0 )
+ if (H5LTmake_dataset(file_id, DSET0_NAME, rank, dims, H5T_NATIVE_INT, data_int_in) < 0)
goto out;
/* Read dataset using the basic HDF5 API */
- if ( ( dataset_id = H5Dopen2(file_id, DSET0_NAME, H5P_DEFAULT) ) < 0 )
+ if ((dataset_id = H5Dopen2(file_id, DSET0_NAME, H5P_DEFAULT)) < 0)
goto out;
- if ( H5Dread ( dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data_int_out ) < 0 )
+ if (H5Dread(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data_int_out) < 0)
goto out;
- if ( H5Dclose( dataset_id ) < 0 )
+ if (H5Dclose(dataset_id) < 0)
goto out;
- for (i = 0; i < DIM; i++)
- {
- if ( data_int_in[i] != data_int_out[i] ) {
+ for (i = 0; i < DIM; i++) {
+ if (data_int_in[i] != data_int_out[i]) {
goto out;
}
}
@@ -112,18 +110,17 @@ static int test_dsets( void )
PASSED();
/*-------------------------------------------------------------------------
- * read using the LT function H5LTread_dataset
- *-------------------------------------------------------------------------
- */
+ * read using the LT function H5LTread_dataset
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("H5LTread_dataset");
- if ( H5LTread_dataset( file_id, DSET0_NAME, H5T_NATIVE_INT, data_int_out ) < 0 )
+ if (H5LTread_dataset(file_id, DSET0_NAME, H5T_NATIVE_INT, data_int_out) < 0)
goto out;
- for (i = 0; i < DIM; i++)
- {
- if ( data_int_in[i] != data_int_out[i] ) {
+ for (i = 0; i < DIM; i++) {
+ if (data_int_in[i] != data_int_out[i]) {
goto out;
}
}
@@ -131,76 +128,70 @@ static int test_dsets( void )
PASSED();
/*-------------------------------------------------------------------------
- * test the H5LTmake_dataset_ functions
- *-------------------------------------------------------------------------
- */
-
+ * test the H5LTmake_dataset_ functions
+ *-------------------------------------------------------------------------
+ */
/*-------------------------------------------------------------------------
- * H5LTmake_dataset_char
- *-------------------------------------------------------------------------
- */
+ * H5LTmake_dataset_char
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("H5LTmake_dataset_char");
/* Make dataset char */
- if ( H5LTmake_dataset_char( file_id, DSET1_NAME, rank, dims, data_char_in ) < 0 )
+ if (H5LTmake_dataset_char(file_id, DSET1_NAME, rank, dims, data_char_in) < 0)
goto out;
/* Read dataset */
- if ( H5LTread_dataset( file_id, DSET1_NAME, H5T_NATIVE_CHAR, data_char_out ) < 0 )
+ if (H5LTread_dataset(file_id, DSET1_NAME, H5T_NATIVE_CHAR, data_char_out) < 0)
goto out;
- for (i = 0; i < DIM; i++)
- {
- if ( data_char_in[i] != data_char_out[i] ) {
+ for (i = 0; i < DIM; i++) {
+ if (data_char_in[i] != data_char_out[i]) {
goto out;
}
}
/* Read dataset */
- if ( H5LTread_dataset_char( file_id, DSET1_NAME, data_char_out ) < 0 )
+ if (H5LTread_dataset_char(file_id, DSET1_NAME, data_char_out) < 0)
goto out;
- for (i = 0; i < DIM; i++)
- {
- if ( data_char_in[i] != data_char_out[i] ) {
+ for (i = 0; i < DIM; i++) {
+ if (data_char_in[i] != data_char_out[i]) {
goto out;
}
}
PASSED();
-
/*-------------------------------------------------------------------------
- * H5LTmake_dataset_short
- *-------------------------------------------------------------------------
- */
+ * H5LTmake_dataset_short
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("H5LTmake_dataset_short");
/* Make dataset short */
- if ( H5LTmake_dataset_short( file_id, DSET2_NAME, rank, dims, data_short_in ) < 0 )
+ if (H5LTmake_dataset_short(file_id, DSET2_NAME, rank, dims, data_short_in) < 0)
goto out;
/* Read dataset */
- if ( H5LTread_dataset( file_id, DSET2_NAME, H5T_NATIVE_SHORT, data_short_out ) < 0 )
+ if (H5LTread_dataset(file_id, DSET2_NAME, H5T_NATIVE_SHORT, data_short_out) < 0)
goto out;
- for (i = 0; i < DIM; i++)
- {
- if ( data_short_in[i] != data_short_out[i] ) {
+ for (i = 0; i < DIM; i++) {
+ if (data_short_in[i] != data_short_out[i]) {
goto out;
}
}
/* Read dataset */
- if ( H5LTread_dataset_short( file_id, DSET2_NAME, data_short_out ) < 0 )
+ if (H5LTread_dataset_short(file_id, DSET2_NAME, data_short_out) < 0)
goto out;
- for (i = 0; i < DIM; i++)
- {
- if ( data_short_in[i] != data_short_out[i] ) {
+ for (i = 0; i < DIM; i++) {
+ if (data_short_in[i] != data_short_out[i]) {
goto out;
}
}
@@ -208,180 +199,165 @@ static int test_dsets( void )
PASSED();
/*-------------------------------------------------------------------------
- * H5LTmake_dataset_int
- *-------------------------------------------------------------------------
- */
+ * H5LTmake_dataset_int
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("H5LTmake_dataset_int");
/* Make dataset int */
- if ( H5LTmake_dataset_int( file_id, DSET3_NAME, rank, dims, data_int_in ) < 0 )
+ if (H5LTmake_dataset_int(file_id, DSET3_NAME, rank, dims, data_int_in) < 0)
goto out;
/* Read dataset */
- if ( H5LTread_dataset( file_id, DSET3_NAME, H5T_NATIVE_INT, data_int_out ) < 0 )
+ if (H5LTread_dataset(file_id, DSET3_NAME, H5T_NATIVE_INT, data_int_out) < 0)
goto out;
- for (i = 0; i < DIM; i++)
- {
- if ( data_int_in[i] != data_int_out[i] ) {
+ for (i = 0; i < DIM; i++) {
+ if (data_int_in[i] != data_int_out[i]) {
goto out;
}
}
/* Read dataset */
- if ( H5LTread_dataset_int( file_id, DSET3_NAME, data_int_out ) < 0 )
+ if (H5LTread_dataset_int(file_id, DSET3_NAME, data_int_out) < 0)
goto out;
- for (i = 0; i < DIM; i++)
- {
- if ( data_int_in[i] != data_int_out[i] ) {
+ for (i = 0; i < DIM; i++) {
+ if (data_int_in[i] != data_int_out[i]) {
goto out;
}
}
PASSED();
-
/*-------------------------------------------------------------------------
- * H5LTmake_dataset_long
- *-------------------------------------------------------------------------
- */
+ * H5LTmake_dataset_long
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("H5LTmake_dataset_long");
/* Make dataset long */
- if ( H5LTmake_dataset_long( file_id, DSET4_NAME, rank, dims, data_long_in ) < 0 )
+ if (H5LTmake_dataset_long(file_id, DSET4_NAME, rank, dims, data_long_in) < 0)
goto out;
/* Read dataset */
- if ( H5LTread_dataset( file_id, DSET4_NAME, H5T_NATIVE_LONG, data_long_out ) < 0 )
+ if (H5LTread_dataset(file_id, DSET4_NAME, H5T_NATIVE_LONG, data_long_out) < 0)
goto out;
- for (i = 0; i < DIM; i++)
- {
- if ( data_long_in[i] != data_long_out[i] ) {
+ for (i = 0; i < DIM; i++) {
+ if (data_long_in[i] != data_long_out[i]) {
goto out;
}
}
/* Read dataset */
- if ( H5LTread_dataset_long( file_id, DSET4_NAME, data_long_out ) < 0 )
+ if (H5LTread_dataset_long(file_id, DSET4_NAME, data_long_out) < 0)
goto out;
- for (i = 0; i < DIM; i++)
- {
- if ( data_long_in[i] != data_long_out[i] ) {
+ for (i = 0; i < DIM; i++) {
+ if (data_long_in[i] != data_long_out[i]) {
goto out;
}
}
PASSED();
-
/*-------------------------------------------------------------------------
- * H5LTmake_dataset_float
- *-------------------------------------------------------------------------
- */
+ * H5LTmake_dataset_float
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("H5LTmake_dataset_float");
/* Make dataset float */
- if ( H5LTmake_dataset_float( file_id, DSET5_NAME, rank, dims, data_float_in ) < 0 )
+ if (H5LTmake_dataset_float(file_id, DSET5_NAME, rank, dims, data_float_in) < 0)
goto out;
/* Read dataset */
- if ( H5LTread_dataset( file_id, DSET5_NAME, H5T_NATIVE_FLOAT, data_float_out ) < 0 )
+ if (H5LTread_dataset(file_id, DSET5_NAME, H5T_NATIVE_FLOAT, data_float_out) < 0)
goto out;
- for (i = 0; i < DIM; i++)
- {
- if(!H5_FLT_ABS_EQUAL(data_float_in[i],data_float_out[i])) {
+ for (i = 0; i < DIM; i++) {
+ if (!H5_FLT_ABS_EQUAL(data_float_in[i], data_float_out[i])) {
goto out;
}
}
/* Read dataset */
- if ( H5LTread_dataset_float( file_id, DSET5_NAME, data_float_out ) < 0 )
+ if (H5LTread_dataset_float(file_id, DSET5_NAME, data_float_out) < 0)
goto out;
- for (i = 0; i < DIM; i++)
- {
- if(!H5_FLT_ABS_EQUAL(data_float_in[i],data_float_out[i])) {
+ for (i = 0; i < DIM; i++) {
+ if (!H5_FLT_ABS_EQUAL(data_float_in[i], data_float_out[i])) {
goto out;
}
}
PASSED();
-
/*-------------------------------------------------------------------------
- * H5LTmake_dataset_double
- *-------------------------------------------------------------------------
- */
+ * H5LTmake_dataset_double
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("H5LTmake_dataset_double");
/* Make dataset double */
- if ( H5LTmake_dataset_double( file_id, DSET6_NAME, rank, dims, data_double_in ) < 0 )
+ if (H5LTmake_dataset_double(file_id, DSET6_NAME, rank, dims, data_double_in) < 0)
goto out;
/* Read dataset */
- if ( H5LTread_dataset( file_id, DSET6_NAME, H5T_NATIVE_DOUBLE, data_double_out ) < 0 )
+ if (H5LTread_dataset(file_id, DSET6_NAME, H5T_NATIVE_DOUBLE, data_double_out) < 0)
goto out;
- for (i = 0; i < DIM; i++)
- {
- if(!H5_DBL_ABS_EQUAL(data_double_in[i],data_double_out[i])) {
+ for (i = 0; i < DIM; i++) {
+ if (!H5_DBL_ABS_EQUAL(data_double_in[i], data_double_out[i])) {
goto out;
}
}
/* Read dataset */
- if ( H5LTread_dataset_double( file_id, DSET6_NAME, data_double_out ) < 0 )
+ if (H5LTread_dataset_double(file_id, DSET6_NAME, data_double_out) < 0)
goto out;
- for (i = 0; i < DIM; i++)
- {
- if(!H5_DBL_ABS_EQUAL(data_double_in[i],data_double_out[i])) {
+ for (i = 0; i < DIM; i++) {
+ if (!H5_DBL_ABS_EQUAL(data_double_in[i], data_double_out[i])) {
goto out;
}
}
PASSED();
-
/*-------------------------------------------------------------------------
- * H5LTmake_dataset_string
- *-------------------------------------------------------------------------
- */
+ * H5LTmake_dataset_string
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("H5LTmake_dataset_string");
/* Make dataset string */
- if ( H5LTmake_dataset_string(file_id,DSET7_NAME,data_string_in) < 0 )
+ if (H5LTmake_dataset_string(file_id, DSET7_NAME, data_string_in) < 0)
goto out;
/* Read dataset */
- if ( H5LTread_dataset_string(file_id,DSET7_NAME,data_string_out) < 0 )
+ if (H5LTread_dataset_string(file_id, DSET7_NAME, data_string_out) < 0)
goto out;
- if ( HDstrcmp(data_string_in,data_string_out) != 0 )
+ if (HDstrcmp(data_string_in, data_string_out) != 0)
goto out;
-
-
/*-------------------------------------------------------------------------
- * end tests
- *-------------------------------------------------------------------------
- */
+ * end tests
+ *-------------------------------------------------------------------------
+ */
/* Close the file. */
- H5Fclose( file_id );
+ H5Fclose(file_id);
PASSED();
-
return 0;
out:
@@ -391,75 +367,83 @@ out:
}
/*-------------------------------------------------------------------------
-* test attribute functions
-*-------------------------------------------------------------------------
-*/
+ * test attribute functions
+ *-------------------------------------------------------------------------
+ */
-static int test_attr(void)
+static int
+test_attr(void)
{
hid_t file_id;
hid_t dataset_id;
hid_t group_id;
hid_t space_id;
- hsize_t dims[1] = { 5 };
+ hsize_t dims[1] = {5};
/* Create a new file using default properties. */
file_id = H5Fcreate(FILE_NAME2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
/*-------------------------------------------------------------------------
- * Create a dataset named "dset" on the root group
- *-------------------------------------------------------------------------
- */
+ * Create a dataset named "dset" on the root group
+ *-------------------------------------------------------------------------
+ */
/* Create the data space */
- if((space_id = H5Screate_simple(1, dims, NULL)) < 0) goto out;
+ if ((space_id = H5Screate_simple(1, dims, NULL)) < 0)
+ goto out;
/* Create the dataset */
- if((dataset_id = H5Dcreate2(file_id , "dset", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out;
+ if ((dataset_id = H5Dcreate2(file_id, "dset", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT,
+ H5P_DEFAULT)) < 0)
+ goto out;
/* Close */
H5Dclose(dataset_id);
/*-------------------------------------------------------------------------
- * Create a group named "grp" on the root group
- *-------------------------------------------------------------------------
- */
+ * Create a group named "grp" on the root group
+ *-------------------------------------------------------------------------
+ */
/* Create a group. */
- if((group_id = H5Gcreate2(file_id, "grp", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out;
+ if ((group_id = H5Gcreate2(file_id, "grp", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
/* Close */
H5Gclose(group_id);
/*-------------------------------------------------------------------------
- *
- * Create attributes in the root group
- * Note that we are calling the H5LTset_attribute functions with the name "."
- *
- *-------------------------------------------------------------------------
- */
- if(make_attributes(file_id, ".") < 0) goto out;
+ *
+ * Create attributes in the root group
+ * Note that we are calling the H5LTset_attribute functions with the name "."
+ *
+ *-------------------------------------------------------------------------
+ */
+ if (make_attributes(file_id, ".") < 0)
+ goto out;
/*-------------------------------------------------------------------------
- *
- * Create attributes in the dataset "dset"
- *
- *-------------------------------------------------------------------------
- */
- if(make_attributes(file_id, "dset") < 0) goto out;
+ *
+ * Create attributes in the dataset "dset"
+ *
+ *-------------------------------------------------------------------------
+ */
+ if (make_attributes(file_id, "dset") < 0)
+ goto out;
/*-------------------------------------------------------------------------
- *
- * Create attributes in the group "grp"
- *
- *-------------------------------------------------------------------------
- */
- if(make_attributes(file_id, "grp") < 0) goto out;
+ *
+ * Create attributes in the group "grp"
+ *
+ *-------------------------------------------------------------------------
+ */
+ if (make_attributes(file_id, "grp") < 0)
+ goto out;
/*-------------------------------------------------------------------------
- * end
- *-------------------------------------------------------------------------
- */
+ * end
+ *-------------------------------------------------------------------------
+ */
/* Close the file. */
H5Fclose(file_id);
@@ -474,113 +458,109 @@ out:
}
/*-------------------------------------------------------------------------
-* make_attributes
-*-------------------------------------------------------------------------
-*/
+ * make_attributes
+ *-------------------------------------------------------------------------
+ */
-static herr_t make_attributes( hid_t loc_id, const char* obj_name )
+static herr_t
+make_attributes(hid_t loc_id, const char *obj_name)
{
int rank_out;
- hsize_t *dims_out = 0;
+ hsize_t * dims_out = 0;
H5T_class_t type_class;
size_t type_size;
int i;
- char attr_str_in[] = {"My attribute"};
- char attr_str_out[20];
- char attr_char_in[5] = {1,2,3,4,5};
- char attr_char_out[5];
- short attr_short_in[5] = {1,2,3,4,5};
- short attr_short_out[5];
- int attr_int_in[5] = {1,2,3,4,5};
- int attr_int_out[5];
- long attr_long_in[5] = {1,2,3,4,5};
- long attr_long_out[5];
- float attr_float_in[5] = {1,2,3,4,5};
- float attr_float_out[5];
- double attr_double_in[5] = {1,2,3,4,5};
- double attr_double_out[5];
- unsigned char attr_uchar_in[5] = {1,2,3,4,5};
- unsigned char attr_uchar_out[5];
- unsigned short attr_ushort_in[5] = {1,2,3,4,5};
- unsigned short attr_ushort_out[5];
- unsigned int attr_uint_in[5] = {1,2,3,4,5};
- unsigned int attr_uint_out[5];
- unsigned long attr_ulong_in[5] = {1,2,3,4,5};
- unsigned long attr_ulong_out[5];
+ char attr_str_in[] = {"My attribute"};
+ char attr_str_out[20];
+ char attr_char_in[5] = {1, 2, 3, 4, 5};
+ char attr_char_out[5];
+ short attr_short_in[5] = {1, 2, 3, 4, 5};
+ short attr_short_out[5];
+ int attr_int_in[5] = {1, 2, 3, 4, 5};
+ int attr_int_out[5];
+ long attr_long_in[5] = {1, 2, 3, 4, 5};
+ long attr_long_out[5];
+ float attr_float_in[5] = {1, 2, 3, 4, 5};
+ float attr_float_out[5];
+ double attr_double_in[5] = {1, 2, 3, 4, 5};
+ double attr_double_out[5];
+ unsigned char attr_uchar_in[5] = {1, 2, 3, 4, 5};
+ unsigned char attr_uchar_out[5];
+ unsigned short attr_ushort_in[5] = {1, 2, 3, 4, 5};
+ unsigned short attr_ushort_out[5];
+ unsigned int attr_uint_in[5] = {1, 2, 3, 4, 5};
+ unsigned int attr_uint_out[5];
+ unsigned long attr_ulong_in[5] = {1, 2, 3, 4, 5};
+ unsigned long attr_ulong_out[5];
/*-------------------------------------------------------------------------
- * H5LTset_attribute_string test
- *-------------------------------------------------------------------------
- */
+ * H5LTset_attribute_string test
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("H5LTset_attribute_string");
/* Set the attribute */
- if ( H5LTset_attribute_string( loc_id, obj_name, ATTR1_NAME, attr_str_in ) < 0 )
+ if (H5LTset_attribute_string(loc_id, obj_name, ATTR1_NAME, attr_str_in) < 0)
return -1;
PASSED();
/*-------------------------------------------------------------------------
- * H5LTset_attribute_string test
- *-------------------------------------------------------------------------
- */
+ * H5LTset_attribute_string test
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("H5LTget_attribute_string");
-
/* Get the attribute */
- if ( H5LTget_attribute_string( loc_id, obj_name, ATTR1_NAME, attr_str_out ) < 0 )
+ if (H5LTget_attribute_string(loc_id, obj_name, ATTR1_NAME, attr_str_out) < 0)
return -1;
- if ( HDstrcmp( attr_str_in, attr_str_out ) != 0 )
- {
+ if (HDstrcmp(attr_str_in, attr_str_out) != 0) {
return -1;
}
PASSED();
-
/*-------------------------------------------------------------------------
- * H5LTset_attribute_char test
- *-------------------------------------------------------------------------
- */
+ * H5LTset_attribute_char test
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("H5LTset_attribute_char");
/* Set the attribute */
- if ( H5LTset_attribute_char( loc_id, obj_name, ATTR2_NAME, attr_char_in, (size_t)5 ) < 0 )
+ if (H5LTset_attribute_char(loc_id, obj_name, ATTR2_NAME, attr_char_in, (size_t)5) < 0)
return -1;
PASSED();
/*-------------------------------------------------------------------------
- * H5LTget_attribute_char test
- *-------------------------------------------------------------------------
- */
+ * H5LTget_attribute_char test
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("H5LTget_attribute_char");
/* Get the attribute */
- if ( H5LTget_attribute_char( loc_id, obj_name, ATTR2_NAME, attr_char_out ) < 0 )
+ if (H5LTget_attribute_char(loc_id, obj_name, ATTR2_NAME, attr_char_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_char_in[i] != attr_char_out[i] ) {
+ for (i = 0; i < 5; i++) {
+ if (attr_char_in[i] != attr_char_out[i]) {
return -1;
}
}
/* Get the attribute */
- if ( H5LTget_attribute( loc_id, obj_name, ATTR2_NAME, H5T_NATIVE_CHAR, attr_char_out ) < 0 )
+ if (H5LTget_attribute(loc_id, obj_name, ATTR2_NAME, H5T_NATIVE_CHAR, attr_char_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_char_in[i] != attr_char_out[i] ) {
+ for (i = 0; i < 5; i++) {
+ if (attr_char_in[i] != attr_char_out[i]) {
return -1;
}
}
@@ -588,117 +568,109 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name )
PASSED();
/*-------------------------------------------------------------------------
- * H5LTset_attribute_short test
- *-------------------------------------------------------------------------
- */
+ * H5LTset_attribute_short test
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("H5LTset_attribute_short");
/* Set the attribute */
- if ( H5LTset_attribute_short( loc_id, obj_name, ATTR3_NAME, attr_short_in, (size_t)5 ) < 0 )
+ if (H5LTset_attribute_short(loc_id, obj_name, ATTR3_NAME, attr_short_in, (size_t)5) < 0)
return -1;
PASSED();
-
/*-------------------------------------------------------------------------
- * H5LTget_attribute_short test
- *-------------------------------------------------------------------------
- */
+ * H5LTget_attribute_short test
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("H5LTget_attribute_short");
/* Get the attribute */
- if ( H5LTget_attribute_short( loc_id, obj_name, ATTR3_NAME, attr_short_out ) < 0 )
+ if (H5LTget_attribute_short(loc_id, obj_name, ATTR3_NAME, attr_short_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_short_in[i] != attr_short_out[i] ) {
+ for (i = 0; i < 5; i++) {
+ if (attr_short_in[i] != attr_short_out[i]) {
return -1;
}
}
/* Get the attribute */
- if ( H5LTget_attribute( loc_id, obj_name, ATTR3_NAME, H5T_NATIVE_SHORT, attr_short_out ) < 0 )
+ if (H5LTget_attribute(loc_id, obj_name, ATTR3_NAME, H5T_NATIVE_SHORT, attr_short_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_short_in[i] != attr_short_out[i] ) {
+ for (i = 0; i < 5; i++) {
+ if (attr_short_in[i] != attr_short_out[i]) {
return -1;
}
}
PASSED();
-
/*-------------------------------------------------------------------------
- * H5LTset_attribute_int test
- *-------------------------------------------------------------------------
- */
+ * H5LTset_attribute_int test
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("H5LTset_attribute_int");
/* Set the attribute */
- if ( H5LTset_attribute_int( loc_id, obj_name, ATTR4_NAME, attr_int_in, (size_t)5 ) < 0 )
+ if (H5LTset_attribute_int(loc_id, obj_name, ATTR4_NAME, attr_int_in, (size_t)5) < 0)
return -1;
/* Set the attribute which is a substring of an existing attribute */
- if ( H5LTset_attribute_int( loc_id, obj_name, ATTR_NAME_SUB, attr_int_in, (size_t)5 ) < 0 )
+ if (H5LTset_attribute_int(loc_id, obj_name, ATTR_NAME_SUB, attr_int_in, (size_t)5) < 0)
return -1;
/* Set the attribute which is an extension of an existing attribute */
- if ( H5LTset_attribute_int( loc_id, obj_name, ATTR_NAME_EXT, attr_int_in, (size_t)5 ) < 0 )
+ if (H5LTset_attribute_int(loc_id, obj_name, ATTR_NAME_EXT, attr_int_in, (size_t)5) < 0)
return -1;
PASSED();
/*-------------------------------------------------------------------------
- * H5LTget_attribute_int test
- *-------------------------------------------------------------------------
- */
+ * H5LTget_attribute_int test
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("H5LTget_attribute_int");
/* Get the attribute */
- if ( H5LTget_attribute_int( loc_id, obj_name, ATTR4_NAME, attr_int_out ) < 0 )
+ if (H5LTget_attribute_int(loc_id, obj_name, ATTR4_NAME, attr_int_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_int_in[i] != attr_int_out[i] ) {
+ for (i = 0; i < 5; i++) {
+ if (attr_int_in[i] != attr_int_out[i]) {
return -1;
}
}
- if ( H5LTget_attribute_int( loc_id, obj_name, ATTR_NAME_SUB, attr_int_out ) < 0 )
+ if (H5LTget_attribute_int(loc_id, obj_name, ATTR_NAME_SUB, attr_int_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_int_in[i] != attr_int_out[i] ) {
+ for (i = 0; i < 5; i++) {
+ if (attr_int_in[i] != attr_int_out[i]) {
return -1;
}
}
- if ( H5LTget_attribute_int( loc_id, obj_name, ATTR_NAME_EXT, attr_int_out ) < 0 )
+ if (H5LTget_attribute_int(loc_id, obj_name, ATTR_NAME_EXT, attr_int_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_int_in[i] != attr_int_out[i] ) {
+ for (i = 0; i < 5; i++) {
+ if (attr_int_in[i] != attr_int_out[i]) {
return -1;
}
}
/* Get the attribute */
- if ( H5LTget_attribute( loc_id, obj_name, ATTR4_NAME, H5T_NATIVE_INT, attr_int_out ) < 0 )
+ if (H5LTget_attribute(loc_id, obj_name, ATTR4_NAME, H5T_NATIVE_INT, attr_int_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_int_in[i] != attr_int_out[i] ) {
+ for (i = 0; i < 5; i++) {
+ if (attr_int_in[i] != attr_int_out[i]) {
return -1;
}
}
@@ -706,43 +678,41 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name )
PASSED();
/*-------------------------------------------------------------------------
- * H5LTset_attribute_long test
- *-------------------------------------------------------------------------
- */
+ * H5LTset_attribute_long test
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("H5LTset_attribute_long");
/* Set the attribute */
- if ( H5LTset_attribute_long( loc_id, obj_name, ATTR5_NAME, attr_long_in, (size_t)5 ) < 0 )
+ if (H5LTset_attribute_long(loc_id, obj_name, ATTR5_NAME, attr_long_in, (size_t)5) < 0)
return -1;
PASSED();
/*-------------------------------------------------------------------------
- * H5LTget_attribute_long test
- *-------------------------------------------------------------------------
- */
+ * H5LTget_attribute_long test
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("H5LTget_attribute_long");
/* Get the attribute */
- if ( H5LTget_attribute_long( loc_id, obj_name, ATTR5_NAME, attr_long_out ) < 0 )
+ if (H5LTget_attribute_long(loc_id, obj_name, ATTR5_NAME, attr_long_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_long_in[i] != attr_long_out[i] ) {
+ for (i = 0; i < 5; i++) {
+ if (attr_long_in[i] != attr_long_out[i]) {
return -1;
}
}
/* Get the attribute */
- if ( H5LTget_attribute( loc_id, obj_name, ATTR5_NAME, H5T_NATIVE_LONG, attr_long_out ) < 0 )
+ if (H5LTget_attribute(loc_id, obj_name, ATTR5_NAME, H5T_NATIVE_LONG, attr_long_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_long_in[i] != attr_long_out[i] ) {
+ for (i = 0; i < 5; i++) {
+ if (attr_long_in[i] != attr_long_out[i]) {
return -1;
}
}
@@ -750,43 +720,41 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name )
PASSED();
/*-------------------------------------------------------------------------
- * H5LTset_attribute_uchar test
- *-------------------------------------------------------------------------
- */
+ * H5LTset_attribute_uchar test
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("H5LTset_attribute_uchar");
/* Set the attribute */
- if ( H5LTset_attribute_uchar( loc_id, obj_name, ATTR6_NAME, attr_uchar_in, (size_t)5 ) < 0 )
+ if (H5LTset_attribute_uchar(loc_id, obj_name, ATTR6_NAME, attr_uchar_in, (size_t)5) < 0)
return -1;
PASSED();
/*-------------------------------------------------------------------------
- * H5LTget_attribute_uchar test
- *-------------------------------------------------------------------------
- */
+ * H5LTget_attribute_uchar test
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("H5LTget_attribute_uchar");
/* Get the attribute */
- if ( H5LTget_attribute_uchar( loc_id, obj_name, ATTR6_NAME, attr_uchar_out ) < 0 )
+ if (H5LTget_attribute_uchar(loc_id, obj_name, ATTR6_NAME, attr_uchar_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_uchar_in[i] != attr_uchar_out[i] ) {
+ for (i = 0; i < 5; i++) {
+ if (attr_uchar_in[i] != attr_uchar_out[i]) {
return -1;
}
}
/* Get the attribute */
- if ( H5LTget_attribute( loc_id, obj_name, ATTR6_NAME, H5T_NATIVE_UCHAR, attr_uchar_out ) < 0 )
+ if (H5LTget_attribute(loc_id, obj_name, ATTR6_NAME, H5T_NATIVE_UCHAR, attr_uchar_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_uchar_in[i] != attr_uchar_out[i] ) {
+ for (i = 0; i < 5; i++) {
+ if (attr_uchar_in[i] != attr_uchar_out[i]) {
return -1;
}
}
@@ -794,89 +762,83 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name )
PASSED();
/*-------------------------------------------------------------------------
- * H5LTset_attribute_ushort test
- *-------------------------------------------------------------------------
- */
+ * H5LTset_attribute_ushort test
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("H5LTset_attribute_ushort");
/* Set the attribute */
- if ( H5LTset_attribute_ushort( loc_id, obj_name, ATTR7_NAME, attr_ushort_in, (size_t)5 ) < 0 )
+ if (H5LTset_attribute_ushort(loc_id, obj_name, ATTR7_NAME, attr_ushort_in, (size_t)5) < 0)
return -1;
PASSED();
-
/*-------------------------------------------------------------------------
- * H5LTget_attribute_ushort test
- *-------------------------------------------------------------------------
- */
+ * H5LTget_attribute_ushort test
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("H5LTget_attribute_ushort");
/* Get the attribute */
- if ( H5LTget_attribute_ushort( loc_id, obj_name, ATTR7_NAME, attr_ushort_out ) < 0 )
+ if (H5LTget_attribute_ushort(loc_id, obj_name, ATTR7_NAME, attr_ushort_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_ushort_in[i] != attr_ushort_out[i] ) {
+ for (i = 0; i < 5; i++) {
+ if (attr_ushort_in[i] != attr_ushort_out[i]) {
return -1;
}
}
/* Get the attribute */
- if ( H5LTget_attribute( loc_id, obj_name, ATTR7_NAME, H5T_NATIVE_USHORT, attr_ushort_out ) < 0 )
+ if (H5LTget_attribute(loc_id, obj_name, ATTR7_NAME, H5T_NATIVE_USHORT, attr_ushort_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_ushort_in[i] != attr_ushort_out[i] ) {
+ for (i = 0; i < 5; i++) {
+ if (attr_ushort_in[i] != attr_ushort_out[i]) {
return -1;
}
}
PASSED();
-
/*-------------------------------------------------------------------------
- * H5LTset_attribute_int test
- *-------------------------------------------------------------------------
- */
+ * H5LTset_attribute_int test
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("H5LTset_attribute_uint");
/* Set the attribute */
- if ( H5LTset_attribute_uint( loc_id, obj_name, ATTR8_NAME, attr_uint_in, (size_t)5 ) < 0 )
+ if (H5LTset_attribute_uint(loc_id, obj_name, ATTR8_NAME, attr_uint_in, (size_t)5) < 0)
return -1;
PASSED();
/*-------------------------------------------------------------------------
- * H5LTget_attribute_int test
- *-------------------------------------------------------------------------
- */
+ * H5LTget_attribute_int test
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("H5LTget_attribute_uint");
/* Get the attribute */
- if ( H5LTget_attribute_uint( loc_id, obj_name, ATTR8_NAME, attr_uint_out ) < 0 )
+ if (H5LTget_attribute_uint(loc_id, obj_name, ATTR8_NAME, attr_uint_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_uint_in[i] != attr_uint_out[i] ) {
+ for (i = 0; i < 5; i++) {
+ if (attr_uint_in[i] != attr_uint_out[i]) {
return -1;
}
}
/* Get the attribute */
- if ( H5LTget_attribute( loc_id, obj_name, ATTR8_NAME, H5T_NATIVE_UINT, attr_uint_out ) < 0 )
+ if (H5LTget_attribute(loc_id, obj_name, ATTR8_NAME, H5T_NATIVE_UINT, attr_uint_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_uint_in[i] != attr_uint_out[i] ) {
+ for (i = 0; i < 5; i++) {
+ if (attr_uint_in[i] != attr_uint_out[i]) {
return -1;
}
}
@@ -884,89 +846,83 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name )
PASSED();
/*-------------------------------------------------------------------------
- * H5LTset_attribute_ulong test
- *-------------------------------------------------------------------------
- */
+ * H5LTset_attribute_ulong test
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("H5LTset_attribute_ulong");
/* Set the attribute */
- if ( H5LTset_attribute_ulong( loc_id, obj_name, ATTR9_NAME, attr_ulong_in, (size_t)5 ) < 0 )
+ if (H5LTset_attribute_ulong(loc_id, obj_name, ATTR9_NAME, attr_ulong_in, (size_t)5) < 0)
return -1;
PASSED();
/*-------------------------------------------------------------------------
- * H5LTget_attribute_long test
- *-------------------------------------------------------------------------
- */
+ * H5LTget_attribute_long test
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("H5LTget_attribute_ulong");
/* Get the attribute */
- if ( H5LTget_attribute_ulong( loc_id, obj_name, ATTR9_NAME, attr_ulong_out ) < 0 )
+ if (H5LTget_attribute_ulong(loc_id, obj_name, ATTR9_NAME, attr_ulong_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_ulong_in[i] != attr_ulong_out[i] ) {
+ for (i = 0; i < 5; i++) {
+ if (attr_ulong_in[i] != attr_ulong_out[i]) {
return -1;
}
}
/* Get the attribute */
- if ( H5LTget_attribute( loc_id, obj_name, ATTR9_NAME, H5T_NATIVE_ULONG, attr_ulong_out ) < 0 )
+ if (H5LTget_attribute(loc_id, obj_name, ATTR9_NAME, H5T_NATIVE_ULONG, attr_ulong_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if ( attr_ulong_in[i] != attr_ulong_out[i] ) {
+ for (i = 0; i < 5; i++) {
+ if (attr_ulong_in[i] != attr_ulong_out[i]) {
return -1;
}
}
PASSED();
-
/*-------------------------------------------------------------------------
- * H5LTset_attribute_float test
- *-------------------------------------------------------------------------
- */
+ * H5LTset_attribute_float test
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("H5LTset_attribute_float");
/* Set the attribute */
- if ( H5LTset_attribute_float( loc_id, obj_name, ATTR10_NAME, attr_float_in, (size_t)5 ) < 0 )
+ if (H5LTset_attribute_float(loc_id, obj_name, ATTR10_NAME, attr_float_in, (size_t)5) < 0)
return -1;
PASSED();
/*-------------------------------------------------------------------------
- * H5LTget_attribute_float test
- *-------------------------------------------------------------------------
- */
+ * H5LTget_attribute_float test
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("H5LTget_attribute_float");
-
/* Get the attribute */
- if ( H5LTget_attribute_float( loc_id, obj_name, ATTR10_NAME, attr_float_out ) < 0 )
+ if (H5LTget_attribute_float(loc_id, obj_name, ATTR10_NAME, attr_float_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if(!H5_FLT_ABS_EQUAL(attr_float_in[i],attr_float_out[i])) {
+ for (i = 0; i < 5; i++) {
+ if (!H5_FLT_ABS_EQUAL(attr_float_in[i], attr_float_out[i])) {
return -1;
}
}
/* Get the attribute */
- if ( H5LTget_attribute( loc_id, obj_name, ATTR10_NAME, H5T_NATIVE_FLOAT, attr_float_out ) < 0 )
+ if (H5LTget_attribute(loc_id, obj_name, ATTR10_NAME, H5T_NATIVE_FLOAT, attr_float_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if(!H5_FLT_ABS_EQUAL(attr_float_in[i],attr_float_out[i])) {
+ for (i = 0; i < 5; i++) {
+ if (!H5_FLT_ABS_EQUAL(attr_float_in[i], attr_float_out[i])) {
return -1;
}
}
@@ -974,93 +930,90 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name )
PASSED();
/*-------------------------------------------------------------------------
- * H5LTset_attribute_double test
- *-------------------------------------------------------------------------
- */
+ * H5LTset_attribute_double test
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("H5LTset_attribute_double");
/* Set the attribute */
- if ( H5LTset_attribute_double( loc_id, obj_name, ATTR11_NAME, attr_double_in, (size_t)5 ) < 0 )
+ if (H5LTset_attribute_double(loc_id, obj_name, ATTR11_NAME, attr_double_in, (size_t)5) < 0)
return -1;
PASSED();
/*-------------------------------------------------------------------------
- * H5LTget_attribute_double test
- *-------------------------------------------------------------------------
- */
+ * H5LTget_attribute_double test
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("H5LTget_attribute_double");
/* Get the attribute */
- if ( H5LTget_attribute_double( loc_id, obj_name, ATTR11_NAME, attr_double_out ) < 0 )
+ if (H5LTget_attribute_double(loc_id, obj_name, ATTR11_NAME, attr_double_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if(!H5_DBL_ABS_EQUAL(attr_double_in[i],attr_double_out[i])) {
+ for (i = 0; i < 5; i++) {
+ if (!H5_DBL_ABS_EQUAL(attr_double_in[i], attr_double_out[i])) {
return -1;
}
}
/* Get the attribute */
- if ( H5LTget_attribute( loc_id, obj_name, ATTR11_NAME, H5T_NATIVE_DOUBLE, attr_double_out ) < 0 )
+ if (H5LTget_attribute(loc_id, obj_name, ATTR11_NAME, H5T_NATIVE_DOUBLE, attr_double_out) < 0)
return -1;
- for (i = 0; i < 5; i++)
- {
- if(!H5_DBL_ABS_EQUAL(attr_double_in[i],attr_double_out[i])) {
+ for (i = 0; i < 5; i++) {
+ if (!H5_DBL_ABS_EQUAL(attr_double_in[i], attr_double_out[i])) {
return -1;
}
}
PASSED();
-
/*-------------------------------------------------------------------------
- * H5LTget_attribute_ndims test
- *-------------------------------------------------------------------------
- */
-
+ * H5LTget_attribute_ndims test
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("H5LTget_attribute_ndims");
- if ( H5LTget_attribute_ndims( loc_id, obj_name, ATTR2_NAME, &rank_out ) < 0 )
+ if (H5LTget_attribute_ndims(loc_id, obj_name, ATTR2_NAME, &rank_out) < 0)
return -1;
- if ( rank_out != 1 ) {
+ if (rank_out != 1) {
return -1;
}
PASSED();
/*-------------------------------------------------------------------------
- * H5LTget_attribute_info test
- *-------------------------------------------------------------------------
- */
+ * H5LTget_attribute_info test
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("H5LTget_attribute_info");
- if(NULL==(dims_out = (hsize_t*) HDmalloc( sizeof(hsize_t) * (size_t)rank_out ))) return -1;
+ if (NULL == (dims_out = (hsize_t *)HDmalloc(sizeof(hsize_t) * (size_t)rank_out)))
+ return -1;
- if ( H5LTget_attribute_info( loc_id, obj_name, ATTR2_NAME, dims_out, &type_class, &type_size) < 0 ) {
- HDfree( dims_out );
+ if (H5LTget_attribute_info(loc_id, obj_name, ATTR2_NAME, dims_out, &type_class, &type_size) < 0) {
+ HDfree(dims_out);
return -1;
}
for (i = 0; i < rank_out; i++) {
- if ( dims_out[i] != 5 ) {
- HDfree( dims_out );
+ if (dims_out[i] != 5) {
+ HDfree(dims_out);
return -1;
}
}
- if ( type_class != H5T_INTEGER ) {
- HDfree( dims_out );
+ if (type_class != H5T_INTEGER) {
+ HDfree(dims_out);
return -1;
}
- HDfree( dims_out );
+ HDfree(dims_out);
PASSED();
@@ -1068,52 +1021,53 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name )
}
/*-------------------------------------------------------------------------
-* subroutine for test_text_dtype(): test_integers().
-*-------------------------------------------------------------------------
-*/
-static int test_integers(void)
+ * subroutine for test_text_dtype(): test_integers().
+ *-------------------------------------------------------------------------
+ */
+static int
+test_integers(void)
{
- hid_t dtype;
- char* dt_str;
- size_t str_len;
+ hid_t dtype;
+ char * dt_str;
+ size_t str_len;
HL_TESTING3("\n text for integer types");
- if((dtype = H5LTtext_to_dtype("H5T_NATIVE_INT\n", H5LT_DDL))<0)
+ if ((dtype = H5LTtext_to_dtype("H5T_NATIVE_INT\n", H5LT_DDL)) < 0)
goto out;
- if(!H5Tequal(dtype, H5T_NATIVE_INT))
+ if (!H5Tequal(dtype, H5T_NATIVE_INT))
goto out;
- if(H5Tclose(dtype)<0)
+ if (H5Tclose(dtype) < 0)
goto out;
- if((dtype = H5LTtext_to_dtype("H5T_STD_I8BE\n", H5LT_DDL))<0)
+ if ((dtype = H5LTtext_to_dtype("H5T_STD_I8BE\n", H5LT_DDL)) < 0)
goto out;
- if(!H5Tequal(dtype, H5T_STD_I8BE))
+ if (!H5Tequal(dtype, H5T_STD_I8BE))
goto out;
- if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0)
+ if (H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len) < 0)
goto out;
- if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char))))
+ if (NULL == (dt_str = (char *)HDcalloc(str_len, sizeof(char))))
goto out;
- if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) {
+ if (H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len) < 0) {
HDfree(dt_str);
goto out;
}
- if(HDstrcmp(dt_str, "H5T_STD_I8BE")) {
+ if (HDstrcmp(dt_str, "H5T_STD_I8BE")) {
HDfree(dt_str);
goto out;
}
HDfree(dt_str);
- if(H5Tclose(dtype)<0)
+ if (H5Tclose(dtype) < 0)
goto out;
- if((dtype = H5LTtext_to_dtype("H5T_STD_U16LE\n", H5LT_DDL))<0)
+ if ((dtype = H5LTtext_to_dtype("H5T_STD_U16LE\n", H5LT_DDL)) < 0)
goto out;
- if(!H5Tequal(dtype, H5T_STD_U16LE))
+ if (!H5Tequal(dtype, H5T_STD_U16LE))
goto out;
- if(H5Tclose(dtype)<0)
+ if (H5Tclose(dtype) < 0)
goto out;
PASSED();
@@ -1125,52 +1079,53 @@ out:
}
/*-------------------------------------------------------------------------
-* subroutine for test_text_dtype(): test_fps().
-*-------------------------------------------------------------------------
-*/
-static int test_fps(void)
+ * subroutine for test_text_dtype(): test_fps().
+ *-------------------------------------------------------------------------
+ */
+static int
+test_fps(void)
{
- hid_t dtype;
- char* dt_str;
- size_t str_len;
+ hid_t dtype;
+ char * dt_str;
+ size_t str_len;
HL_TESTING3(" text for floating-point types");
- if((dtype = H5LTtext_to_dtype("H5T_NATIVE_LDOUBLE\n", H5LT_DDL))<0)
+ if ((dtype = H5LTtext_to_dtype("H5T_NATIVE_LDOUBLE\n", H5LT_DDL)) < 0)
goto out;
- if(!H5Tequal(dtype, H5T_NATIVE_LDOUBLE))
+ if (!H5Tequal(dtype, H5T_NATIVE_LDOUBLE))
goto out;
- if(H5Tclose(dtype)<0)
+ if (H5Tclose(dtype) < 0)
goto out;
- if((dtype = H5LTtext_to_dtype("H5T_IEEE_F32BE\n", H5LT_DDL))<0)
+ if ((dtype = H5LTtext_to_dtype("H5T_IEEE_F32BE\n", H5LT_DDL)) < 0)
goto out;
- if(!H5Tequal(dtype, H5T_IEEE_F32BE))
+ if (!H5Tequal(dtype, H5T_IEEE_F32BE))
goto out;
- if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0)
+ if (H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len) < 0)
goto out;
- if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char))))
+ if (NULL == (dt_str = (char *)HDcalloc(str_len, sizeof(char))))
goto out;
- if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) {
+ if (H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len) < 0) {
HDfree(dt_str);
goto out;
}
- if(HDstrcmp(dt_str, "H5T_IEEE_F32BE")) {
+ if (HDstrcmp(dt_str, "H5T_IEEE_F32BE")) {
HDfree(dt_str);
goto out;
}
HDfree(dt_str);
- if(H5Tclose(dtype)<0)
+ if (H5Tclose(dtype) < 0)
goto out;
- if((dtype = H5LTtext_to_dtype("H5T_IEEE_F64LE\n", H5LT_DDL))<0)
+ if ((dtype = H5LTtext_to_dtype("H5T_IEEE_F64LE\n", H5LT_DDL)) < 0)
goto out;
- if(!H5Tequal(dtype, H5T_IEEE_F64LE))
+ if (!H5Tequal(dtype, H5T_IEEE_F64LE))
goto out;
- if(H5Tclose(dtype)<0)
+ if (H5Tclose(dtype) < 0)
goto out;
PASSED();
@@ -1182,82 +1137,89 @@ out:
}
/*-------------------------------------------------------------------------
-* subroutine for test_text_dtype(): test_strings().
-*-------------------------------------------------------------------------
-*/
-static int test_strings(void)
+ * subroutine for test_text_dtype(): test_strings().
+ *-------------------------------------------------------------------------
+ */
+static int
+test_strings(void)
{
- hid_t dtype;
- size_t str_size;
+ hid_t dtype;
+ size_t str_size;
H5T_str_t str_pad;
H5T_cset_t str_cset;
H5T_class_t type_class;
- char* dt_str = NULL;
- size_t str_len;
+ char * dt_str = NULL;
+ size_t str_len;
HL_TESTING3(" text for string types");
- if((dtype = H5LTtext_to_dtype("H5T_STRING { STRSIZE 13; STRPAD H5T_STR_NULLTERM; CSET H5T_CSET_ASCII; CTYPE H5T_C_S1; }", H5LT_DDL))<0)
+ if ((dtype = H5LTtext_to_dtype(
+ "H5T_STRING { STRSIZE 13; STRPAD H5T_STR_NULLTERM; CSET H5T_CSET_ASCII; CTYPE H5T_C_S1; }",
+ H5LT_DDL)) < 0)
goto out;
- if((type_class = H5Tget_class(dtype))<0)
+ if ((type_class = H5Tget_class(dtype)) < 0)
goto out;
- if(type_class != H5T_STRING)
+ if (type_class != H5T_STRING)
goto out;
str_size = H5Tget_size(dtype);
- if(str_size != 13)
+ if (str_size != 13)
goto out;
str_pad = H5Tget_strpad(dtype);
- if(str_pad != H5T_STR_NULLTERM)
+ if (str_pad != H5T_STR_NULLTERM)
goto out;
str_cset = H5Tget_cset(dtype);
- if(str_cset != H5T_CSET_ASCII)
+ if (str_cset != H5T_CSET_ASCII)
goto out;
- if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0)
+ if (H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len) < 0)
goto out;
- if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char))))
+ if (NULL == (dt_str = (char *)HDcalloc(str_len, sizeof(char))))
goto out;
- if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) {
+ if (H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len) < 0) {
HDfree(dt_str);
goto out;
}
- if(HDstrcmp(dt_str, "H5T_STRING {\n STRSIZE 13;\n STRPAD H5T_STR_NULLTERM;\n CSET H5T_CSET_ASCII;\n CTYPE H5T_C_S1;\n }")) {
+ if (HDstrcmp(dt_str, "H5T_STRING {\n STRSIZE 13;\n STRPAD H5T_STR_NULLTERM;\n CSET "
+ "H5T_CSET_ASCII;\n CTYPE H5T_C_S1;\n }")) {
HDprintf("dt=\n%s\n", dt_str);
HDfree(dt_str);
goto out;
}
HDfree(dt_str);
- if(H5Tclose(dtype)<0)
+ if (H5Tclose(dtype) < 0)
goto out;
- if((dtype = H5LTtext_to_dtype("H5T_STRING { STRSIZE H5T_VARIABLE; STRPAD H5T_STR_NULLPAD; CSET H5T_CSET_ASCII; CTYPE H5T_C_S1; }", H5LT_DDL))<0)
+ if ((dtype = H5LTtext_to_dtype("H5T_STRING { STRSIZE H5T_VARIABLE; STRPAD H5T_STR_NULLPAD; CSET "
+ "H5T_CSET_ASCII; CTYPE H5T_C_S1; }",
+ H5LT_DDL)) < 0)
goto out;
- if(!H5Tis_variable_str(dtype))
+ if (!H5Tis_variable_str(dtype))
goto out;
str_pad = H5Tget_strpad(dtype);
- if(str_pad != H5T_STR_NULLPAD)
+ if (str_pad != H5T_STR_NULLPAD)
goto out;
str_cset = H5Tget_cset(dtype);
- if(str_cset != H5T_CSET_ASCII)
+ if (str_cset != H5T_CSET_ASCII)
goto out;
- if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0)
+ if (H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len) < 0)
goto out;
- if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char))))
+ if (NULL == (dt_str = (char *)HDcalloc(str_len, sizeof(char))))
goto out;
- if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) {
+ if (H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len) < 0) {
HDfree(dt_str);
goto out;
}
- if(HDstrcmp(dt_str, "H5T_STRING {\n STRSIZE H5T_VARIABLE;\n STRPAD H5T_STR_NULLPAD;\n CSET H5T_CSET_ASCII;\n CTYPE H5T_C_S1;\n }")) {
+ if (HDstrcmp(dt_str, "H5T_STRING {\n STRSIZE H5T_VARIABLE;\n STRPAD H5T_STR_NULLPAD;\n "
+ "CSET H5T_CSET_ASCII;\n CTYPE H5T_C_S1;\n }")) {
HDprintf("dt=\n%s\n", dt_str);
HDfree(dt_str);
goto out;
@@ -1266,97 +1228,108 @@ static int test_strings(void)
/* Length of the character buffer is larger then needed */
str_len = str_len + 10;
- if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char))))
- goto out;
+ if (NULL == (dt_str = (char *)HDcalloc(str_len, sizeof(char))))
+ goto out;
- if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) {
- HDfree(dt_str);
- goto out;
+ if (H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len) < 0) {
+ HDfree(dt_str);
+ goto out;
}
- if(HDstrncmp(dt_str, "H5T_STRING {\n STRSIZE H5T_VARIABLE;\n STRPAD H5T_STR_NULLPAD;\n CSET H5T_CSET_ASCII;\n CTYPE H5T_C_S1;\n }", str_len-1)) {
- HDprintf("dt=\n%s\n", dt_str);
- HDfree(dt_str);
- goto out;
+ if (HDstrncmp(dt_str,
+ "H5T_STRING {\n STRSIZE H5T_VARIABLE;\n STRPAD H5T_STR_NULLPAD;\n CSET "
+ "H5T_CSET_ASCII;\n CTYPE H5T_C_S1;\n }",
+ str_len - 1)) {
+ HDprintf("dt=\n%s\n", dt_str);
+ HDfree(dt_str);
+ goto out;
}
HDfree(dt_str);
/* Length of the character buffer is smaller then needed */
str_len = 21;
- if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char))))
- goto out;
+ if (NULL == (dt_str = (char *)HDcalloc(str_len, sizeof(char))))
+ goto out;
- if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) {
- HDfree(dt_str);
- goto out;
+ if (H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len) < 0) {
+ HDfree(dt_str);
+ goto out;
}
/* check the truncated string */
- if(HDstrlen(dt_str) != str_len-1) goto out;
+ if (HDstrlen(dt_str) != str_len - 1)
+ goto out;
str_len = HDstrlen(dt_str);
- if(HDstrncmp(dt_str, "H5T_STRING {\n STRSIZE H5T_VARIABLE;\n STRPAD H5T_STR_NULLPAD;\n CSET H5T_CSET_ASCII;\n CTYPE H5T_C_S1;\n }", str_len)) {
- HDprintf("dt=\n%s\n", dt_str);
- HDfree(dt_str);
- goto out;
+ if (HDstrncmp(dt_str,
+ "H5T_STRING {\n STRSIZE H5T_VARIABLE;\n STRPAD H5T_STR_NULLPAD;\n CSET "
+ "H5T_CSET_ASCII;\n CTYPE H5T_C_S1;\n }",
+ str_len)) {
+ HDprintf("dt=\n%s\n", dt_str);
+ HDfree(dt_str);
+ goto out;
}
HDfree(dt_str);
- if(H5Tclose(dtype)<0)
+ if (H5Tclose(dtype) < 0)
goto out;
PASSED();
return 0;
out:
- if(dt_str)
- HDfree(dt_str);
+ if (dt_str)
+ HDfree(dt_str);
H5_FAILED();
return -1;
}
/*-------------------------------------------------------------------------
-* subroutine for test_text_dtype(): test_opaques().
-*-------------------------------------------------------------------------
-*/
-static int test_opaques(void)
+ * subroutine for test_text_dtype(): test_opaques().
+ *-------------------------------------------------------------------------
+ */
+static int
+test_opaques(void)
{
- hid_t dtype;
- size_t opq_size;
+ hid_t dtype;
+ size_t opq_size;
H5T_class_t type_class;
- char* dt_str;
- size_t str_len;
+ char * dt_str;
+ size_t str_len;
HL_TESTING3(" text for opaque types");
- if((dtype = H5LTtext_to_dtype("H5T_OPAQUE { OPQ_SIZE 19; OPQ_TAG \"This is a tag for opaque type\"; }", H5LT_DDL))<0)
+ if ((dtype = H5LTtext_to_dtype("H5T_OPAQUE { OPQ_SIZE 19; OPQ_TAG \"This is a tag for opaque type\"; }",
+ H5LT_DDL)) < 0)
goto out;
- if((type_class = H5Tget_class(dtype))<0)
+ if ((type_class = H5Tget_class(dtype)) < 0)
goto out;
- if(type_class != H5T_OPAQUE)
+ if (type_class != H5T_OPAQUE)
goto out;
- if((opq_size = H5Tget_size(dtype)) == 0)
+ if ((opq_size = H5Tget_size(dtype)) == 0)
goto out;
- if(opq_size != 19)
+ if (opq_size != 19)
goto out;
- if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0)
+ if (H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len) < 0)
goto out;
- if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char))))
+ if (NULL == (dt_str = (char *)HDcalloc(str_len, sizeof(char))))
goto out;
- if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) {
+ if (H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len) < 0) {
HDfree(dt_str);
goto out;
}
- if(HDstrcmp(dt_str, "H5T_OPAQUE {\n OPQ_SIZE 19;\n OPQ_TAG \"This is a tag for opaque type\";\n }")) {
+ if (HDstrcmp(
+ dt_str,
+ "H5T_OPAQUE {\n OPQ_SIZE 19;\n OPQ_TAG \"This is a tag for opaque type\";\n }")) {
HDprintf("dt=\n%s\n", dt_str);
HDfree(dt_str);
goto out;
}
HDfree(dt_str);
- if(H5Tclose(dtype)<0)
+ if (H5Tclose(dtype) < 0)
goto out;
PASSED();
@@ -1368,63 +1341,66 @@ out:
}
/*-------------------------------------------------------------------------
-* subroutine for test_text_dtype(): test_enums().
-*-------------------------------------------------------------------------
-*/
-static int test_enums(void)
+ * subroutine for test_text_dtype(): test_enums().
+ *-------------------------------------------------------------------------
+ */
+static int
+test_enums(void)
{
- hid_t dtype;
- size_t size = 16;
- char name1[16];
- int value1 = 7;
- const char *name2 = "WHITE";
- int value2;
+ hid_t dtype;
+ size_t size = 16;
+ char name1[16];
+ int value1 = 7;
+ const char *name2 = "WHITE";
+ int value2;
H5T_class_t type_class;
- char* dt_str;
- size_t str_len;
+ char * dt_str;
+ size_t str_len;
HL_TESTING3(" text for enum types");
- if((dtype = H5LTtext_to_dtype("H5T_ENUM { H5T_STD_I32LE; \"RED\" 5; \"GREEN\" 6; \"BLUE\" 7; \"WHITE\" 8; }", H5LT_DDL))<0)
+ if ((dtype = H5LTtext_to_dtype(
+ "H5T_ENUM { H5T_STD_I32LE; \"RED\" 5; \"GREEN\" 6; \"BLUE\" 7; \"WHITE\" 8; }", H5LT_DDL)) < 0)
goto out;
- if((type_class = H5Tget_class(dtype))<0)
+ if ((type_class = H5Tget_class(dtype)) < 0)
goto out;
- if(type_class != H5T_ENUM)
+ if (type_class != H5T_ENUM)
goto out;
/* Convert the variable before using it */
- if(!H5Tequal(H5T_STD_I32LE, H5T_NATIVE_INT)) {
- if(H5Tconvert(H5T_NATIVE_INT, H5T_STD_I32LE, 1, &value1, NULL, H5P_DEFAULT) < 0)
+ if (!H5Tequal(H5T_STD_I32LE, H5T_NATIVE_INT)) {
+ if (H5Tconvert(H5T_NATIVE_INT, H5T_STD_I32LE, 1, &value1, NULL, H5P_DEFAULT) < 0)
goto out;
}
- if(H5Tenum_nameof(dtype, &value1, name1, size)<0)
+ if (H5Tenum_nameof(dtype, &value1, name1, size) < 0)
goto out;
- if(HDstrcmp(name1, "BLUE"))
+ if (HDstrcmp(name1, "BLUE"))
goto out;
- if(H5Tenum_valueof(dtype, name2, &value2)<0)
+ if (H5Tenum_valueof(dtype, name2, &value2) < 0)
goto out;
/* Convert the variable before comparing it */
- if(!H5Tequal(H5T_STD_I32LE, H5T_NATIVE_INT)) {
- if(H5Tconvert(H5T_NATIVE_INT, H5T_STD_I32LE, 1, &value2, NULL, H5P_DEFAULT) < 0)
+ if (!H5Tequal(H5T_STD_I32LE, H5T_NATIVE_INT)) {
+ if (H5Tconvert(H5T_NATIVE_INT, H5T_STD_I32LE, 1, &value2, NULL, H5P_DEFAULT) < 0)
goto out;
}
- if(value2 != 8)
+ if (value2 != 8)
goto out;
- if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0)
+ if (H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len) < 0)
goto out;
- if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char))))
+ if (NULL == (dt_str = (char *)HDcalloc(str_len, sizeof(char))))
goto out;
- if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) {
+ if (H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len) < 0) {
HDfree(dt_str);
goto out;
}
- if(HDstrcmp(dt_str, "H5T_ENUM {\n H5T_STD_I32LE;\n \"RED\" 5;\n \"GREEN\" 6;\n \"BLUE\" 7;\n \"WHITE\" 8;\n }")) {
+ if (HDstrcmp(dt_str, "H5T_ENUM {\n H5T_STD_I32LE;\n \"RED\" 5;\n \"GREEN\" "
+ " 6;\n \"BLUE\" 7;\n \"WHITE\" 8;\n }")) {
HDprintf("dt=\n%s\n", dt_str);
HDfree(dt_str);
@@ -1433,7 +1409,7 @@ static int test_enums(void)
HDfree(dt_str);
- if(H5Tclose(dtype)<0)
+ if (H5Tclose(dtype) < 0)
goto out;
PASSED();
@@ -1445,54 +1421,55 @@ out:
}
/*-------------------------------------------------------------------------
-* subroutine for test_text_dtype(): test_variables().
-*-------------------------------------------------------------------------
-*/
-static int test_variables(void)
+ * subroutine for test_text_dtype(): test_variables().
+ *-------------------------------------------------------------------------
+ */
+static int
+test_variables(void)
{
- hid_t dtype;
+ hid_t dtype;
H5T_class_t type_class;
- char* dt_str;
- size_t str_len;
+ char * dt_str;
+ size_t str_len;
HL_TESTING3(" text for variable types");
- if((dtype = H5LTtext_to_dtype("H5T_VLEN { H5T_NATIVE_CHAR }\n", H5LT_DDL))<0)
+ if ((dtype = H5LTtext_to_dtype("H5T_VLEN { H5T_NATIVE_CHAR }\n", H5LT_DDL)) < 0)
goto out;
- if((type_class = H5Tget_class(dtype))<0)
+ if ((type_class = H5Tget_class(dtype)) < 0)
goto out;
- if(type_class != H5T_VLEN)
+ if (type_class != H5T_VLEN)
goto out;
- if(H5Tis_variable_str(dtype))
+ if (H5Tis_variable_str(dtype))
goto out;
- if(H5Tclose(dtype)<0)
+ if (H5Tclose(dtype) < 0)
goto out;
- if((dtype = H5LTtext_to_dtype("H5T_VLEN { H5T_VLEN { H5T_STD_I32BE } }", H5LT_DDL))<0)
+ if ((dtype = H5LTtext_to_dtype("H5T_VLEN { H5T_VLEN { H5T_STD_I32BE } }", H5LT_DDL)) < 0)
goto out;
- if(H5Tis_variable_str(dtype))
+ if (H5Tis_variable_str(dtype))
goto out;
- if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0)
+ if (H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len) < 0)
goto out;
- if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char))))
+ if (NULL == (dt_str = (char *)HDcalloc(str_len, sizeof(char))))
goto out;
- if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) {
+ if (H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len) < 0) {
HDfree(dt_str);
goto out;
}
- if(HDstrcmp(dt_str, "H5T_VLEN {\n H5T_VLEN {\n H5T_STD_I32BE\n }\n }")) {
+ if (HDstrcmp(dt_str, "H5T_VLEN {\n H5T_VLEN {\n H5T_STD_I32BE\n }\n }")) {
HDprintf("dt=\n%s\n", dt_str);
HDfree(dt_str);
goto out;
}
HDfree(dt_str);
- if(H5Tclose(dtype)<0)
+ if (H5Tclose(dtype) < 0)
goto out;
PASSED();
@@ -1504,47 +1481,52 @@ out:
}
/*-------------------------------------------------------------------------
-* subroutine for test_text_dtype(): test_arrays().
-*-------------------------------------------------------------------------
-*/
-static int test_arrays(void)
+ * subroutine for test_text_dtype(): test_arrays().
+ *-------------------------------------------------------------------------
+ */
+static int
+test_arrays(void)
{
- hid_t dtype;
- int ndims;
- hsize_t dims[3];
+ hid_t dtype;
+ int ndims;
+ hsize_t dims[3];
H5T_class_t type_class;
- char* dt_str;
- size_t str_len;
+ char * dt_str;
+ size_t str_len;
HL_TESTING3(" text for array types");
- if((dtype = H5LTtext_to_dtype("H5T_ARRAY { [5][7][13] H5T_ARRAY { [17][19] H5T_COMPOUND { H5T_STD_I8BE \"arr_compound_1\"; H5T_STD_I32BE \"arr_compound_2\"; } } }", H5LT_DDL))<0)
+ if ((dtype = H5LTtext_to_dtype("H5T_ARRAY { [5][7][13] H5T_ARRAY { [17][19] H5T_COMPOUND { H5T_STD_I8BE "
+ "\"arr_compound_1\"; H5T_STD_I32BE \"arr_compound_2\"; } } }",
+ H5LT_DDL)) < 0)
goto out;
- if((type_class = H5Tget_class(dtype))<0)
+ if ((type_class = H5Tget_class(dtype)) < 0)
goto out;
- if(type_class != H5T_ARRAY)
+ if (type_class != H5T_ARRAY)
goto out;
- if((ndims = H5Tget_array_ndims(dtype))<0)
+ if ((ndims = H5Tget_array_ndims(dtype)) < 0)
goto out;
- if(ndims != 3)
+ if (ndims != 3)
goto out;
- if(H5Tget_array_dims2(dtype, dims) < 0)
+ if (H5Tget_array_dims2(dtype, dims) < 0)
goto out;
- if(dims[0] != 5 || dims[1] != 7 || dims[2] != 13)
+ if (dims[0] != 5 || dims[1] != 7 || dims[2] != 13)
goto out;
- if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0)
+ if (H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len) < 0)
goto out;
- if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char))))
+ if (NULL == (dt_str = (char *)HDcalloc(str_len, sizeof(char))))
goto out;
- if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) {
+ if (H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len) < 0) {
HDfree(dt_str);
goto out;
}
- if(HDstrcmp(dt_str, "H5T_ARRAY {\n [5][7][13] H5T_ARRAY {\n [17][19] H5T_COMPOUND {\n H5T_STD_I8BE \"arr_compound_1\" : 0;\n H5T_STD_I32BE \"arr_compound_2\" : 1;\n }\n }\n }")) {
+ if (HDstrcmp(dt_str, "H5T_ARRAY {\n [5][7][13] H5T_ARRAY {\n [17][19] H5T_COMPOUND {\n "
+ " H5T_STD_I8BE \"arr_compound_1\" : 0;\n H5T_STD_I32BE "
+ "\"arr_compound_2\" : 1;\n }\n }\n }")) {
HDprintf("dt=\n%s\n", dt_str);
HDfree(dt_str);
goto out;
@@ -1552,7 +1534,7 @@ static int test_arrays(void)
HDfree(dt_str);
- if(H5Tclose(dtype)<0)
+ if (H5Tclose(dtype) < 0)
goto out;
PASSED();
@@ -1564,66 +1546,74 @@ out:
}
/*-------------------------------------------------------------------------
-* subroutine for test_text_dtype(): test_compounds().
-*-------------------------------------------------------------------------
-*/
-static int test_compounds(void)
+ * subroutine for test_text_dtype(): test_compounds().
+ *-------------------------------------------------------------------------
+ */
+static int
+test_compounds(void)
{
- hid_t dtype;
- int nmembs;
- char *memb_name = NULL;
+ hid_t dtype;
+ int nmembs;
+ char * memb_name = NULL;
H5T_class_t memb_class;
H5T_class_t type_class;
- char* dt_str;
- size_t str_len;
+ char * dt_str;
+ size_t str_len;
HL_TESTING3(" text for compound types");
- if((dtype = H5LTtext_to_dtype("H5T_COMPOUND { H5T_STD_I16BE \"one_field\" : 2; H5T_STD_U8LE \"two_field\" : 6; }", H5LT_DDL))<0)
+ if ((dtype = H5LTtext_to_dtype(
+ "H5T_COMPOUND { H5T_STD_I16BE \"one_field\" : 2; H5T_STD_U8LE \"two_field\" : 6; }", H5LT_DDL)) <
+ 0)
goto out;
- if((type_class = H5Tget_class(dtype))<0)
+ if ((type_class = H5Tget_class(dtype)) < 0)
goto out;
- if(type_class != H5T_COMPOUND)
+ if (type_class != H5T_COMPOUND)
goto out;
- if((nmembs = H5Tget_nmembers(dtype))<0)
+ if ((nmembs = H5Tget_nmembers(dtype)) < 0)
goto out;
- if(nmembs != 2)
+ if (nmembs != 2)
goto out;
- if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0)
+ if (H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len) < 0)
goto out;
- if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char))))
+ if (NULL == (dt_str = (char *)HDcalloc(str_len, sizeof(char))))
goto out;
- if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) {
+ if (H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len) < 0) {
HDfree(dt_str);
goto out;
}
- if(HDstrcmp(dt_str, "H5T_COMPOUND {\n H5T_STD_I16BE \"one_field\" : 2;\n H5T_STD_U8LE \"two_field\" : 6;\n }")) {
+ if (HDstrcmp(dt_str, "H5T_COMPOUND {\n H5T_STD_I16BE \"one_field\" : 2;\n H5T_STD_U8LE "
+ "\"two_field\" : 6;\n }")) {
HDprintf("dt=\n%s\n", dt_str);
HDfree(dt_str);
goto out;
}
HDfree(dt_str);
- if(H5Tclose(dtype)<0)
+ if (H5Tclose(dtype) < 0)
goto out;
- if((dtype = H5LTtext_to_dtype("H5T_COMPOUND { H5T_STD_I32BE \"i32_field\"; H5T_STD_I16BE \"i16_field\"; H5T_COMPOUND { H5T_STD_I16BE \"sec_field\"; H5T_COMPOUND { H5T_STD_I32BE \"thd_field\"; } \"grandchild\"; } \"child_compound\"; H5T_STD_I8BE \"i8_field\"; }", H5LT_DDL))<0)
+ if ((dtype = H5LTtext_to_dtype(
+ "H5T_COMPOUND { H5T_STD_I32BE \"i32_field\"; H5T_STD_I16BE \"i16_field\"; H5T_COMPOUND { "
+ "H5T_STD_I16BE \"sec_field\"; H5T_COMPOUND { H5T_STD_I32BE \"thd_field\"; } \"grandchild\"; } "
+ "\"child_compound\"; H5T_STD_I8BE \"i8_field\"; }",
+ H5LT_DDL)) < 0)
goto out;
- if((memb_name = H5Tget_member_name(dtype, 1)) == NULL)
+ if ((memb_name = H5Tget_member_name(dtype, 1)) == NULL)
goto out;
- if(HDstrcmp(memb_name, "i16_field")) {
+ if (HDstrcmp(memb_name, "i16_field")) {
H5free_memory(memb_name);
goto out;
}
H5free_memory(memb_name);
- if((memb_class = H5Tget_member_class(dtype, 2))<0)
+ if ((memb_class = H5Tget_member_class(dtype, 2)) < 0)
goto out;
- if(memb_class != H5T_COMPOUND)
+ if (memb_class != H5T_COMPOUND)
goto out;
PASSED();
@@ -1635,110 +1625,120 @@ out:
}
/*-------------------------------------------------------------------------
-* subroutine for test_text_dtype(): test_compound_bug(). Test case for
-* issue 7701.
-*-------------------------------------------------------------------------
-*/
-static int test_compound_bug(void)
+ * subroutine for test_text_dtype(): test_compound_bug(). Test case for
+ * issue 7701.
+ *-------------------------------------------------------------------------
+ */
+static int
+test_compound_bug(void)
{
hid_t dtype;
H5T_class_t type_class;
int nmembs;
- char* memb_name = NULL;
- char* dt_str;
+ char * memb_name = NULL;
+ char * dt_str;
size_t str_len;
- char text[] = "H5T_COMPOUND { H5T_STD_I32LE \"state_________________________________________________________________________________\"; H5T_STD_I32LE \"desc_________________________________________________________________________________________\"; H5T_VLEN { H5T_COMPOUND { H5T_ENUM { H5T_STD_I16LE; \"ZERO\" 0; \"ONE\" 1; \"TWO\" 2; \"THREE\" 3; } \"type____\"; H5T_STD_I32LE \"sub_______________________________________________________________________________________________________________\"; H5T_STRING { STRSIZE H5T_VARIABLE; STRPAD H5T_STR_SPACEPAD; CSET H5T_CSET_ASCII; CTYPE H5T_C_S1; } \"sub_desc\"; H5T_STD_I32LE \"final___________________________________________________________________________________________________\"; } } \"sub\"; }";
- char text2[] =
- "H5T_COMPOUND {\n"
- " H5T_STD_I16LE \"state___________________________"
- "__________________________________________________"
- "____\" : 0;\n"
- " H5T_STD_I16LE \"desc____________________________"
- "__________________________________________________"
- "___________\" : 2;\n"
- " H5T_VLEN { H5T_COMPOUND {\n"
- " H5T_ENUM { H5T_STD_I16LE; \"ZERO\" 0; \"ONE\" "
- "1; \"TWO\" 2; \"THREE\" 3; } \"type____\" : 0;\n"
- " H5T_STD_I32LE \"sub___________________________"
- "__________________________________________________"
- "__________________________________1\" : 4;\n"
- " H5T_STRING { STRSIZE H5T_VARIABLE; STRPAD H5T_"
- "STR_SPACEPAD; CSET H5T_CSET_ASCII; CTYPE H5T_C_S1;"
- " } \"sub_desc\" : 8;\n"
- " H5T_STD_I32LE \"final_________________________"
- "__________________________________________________"
- "________________________\" : 16;\n"
- " } } \"sub\" : 8;\n"
- "}\n";
+ char text[] = "H5T_COMPOUND { H5T_STD_I32LE "
+ "\"state_________________________________________________________________________________"
+ "\"; H5T_STD_I32LE "
+ "\"desc____________________________________________________________________________________"
+ "_____\"; H5T_VLEN { H5T_COMPOUND { H5T_ENUM { H5T_STD_I16LE; \"ZERO\" 0; \"ONE\" 1; "
+ "\"TWO\" 2; \"THREE\" 3; } \"type____\"; H5T_STD_I32LE "
+ "\"sub_____________________________________________________________________________________"
+ "__________________________\"; H5T_STRING { STRSIZE H5T_VARIABLE; STRPAD H5T_STR_SPACEPAD; "
+ "CSET H5T_CSET_ASCII; CTYPE H5T_C_S1; } \"sub_desc\"; H5T_STD_I32LE "
+ "\"final___________________________________________________________________________________"
+ "________________\"; } } \"sub\"; }";
+ char text2[] = "H5T_COMPOUND {\n"
+ " H5T_STD_I16LE \"state___________________________"
+ "__________________________________________________"
+ "____\" : 0;\n"
+ " H5T_STD_I16LE \"desc____________________________"
+ "__________________________________________________"
+ "___________\" : 2;\n"
+ " H5T_VLEN { H5T_COMPOUND {\n"
+ " H5T_ENUM { H5T_STD_I16LE; \"ZERO\" 0; \"ONE\" "
+ "1; \"TWO\" 2; \"THREE\" 3; } \"type____\" : 0;\n"
+ " H5T_STD_I32LE \"sub___________________________"
+ "__________________________________________________"
+ "__________________________________1\" : 4;\n"
+ " H5T_STRING { STRSIZE H5T_VARIABLE; STRPAD H5T_"
+ "STR_SPACEPAD; CSET H5T_CSET_ASCII; CTYPE H5T_C_S1;"
+ " } \"sub_desc\" : 8;\n"
+ " H5T_STD_I32LE \"final_________________________"
+ "__________________________________________________"
+ "________________________\" : 16;\n"
+ " } } \"sub\" : 8;\n"
+ "}\n";
HL_TESTING3(" text for compound type of bug fix");
- if((dtype = H5LTtext_to_dtype(text, H5LT_DDL))<0)
+ if ((dtype = H5LTtext_to_dtype(text, H5LT_DDL)) < 0)
goto out;
- if((type_class = H5Tget_class(dtype))<0)
+ if ((type_class = H5Tget_class(dtype)) < 0)
goto out;
- if(type_class != H5T_COMPOUND)
+ if (type_class != H5T_COMPOUND)
goto out;
- if((memb_name = H5Tget_member_name(dtype, 2)) == NULL)
+ if ((memb_name = H5Tget_member_name(dtype, 2)) == NULL)
goto out;
- if(HDstrcmp(memb_name, "sub")) {
+ if (HDstrcmp(memb_name, "sub")) {
H5free_memory(memb_name);
goto out;
}
H5free_memory(memb_name);
- if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0)
+ if (H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len) < 0)
goto out;
- if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char))))
+ if (NULL == (dt_str = (char *)HDcalloc(str_len, sizeof(char))))
goto out;
- if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) {
+ if (H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len) < 0) {
HDfree(dt_str);
goto out;
}
HDfree(dt_str);
- if(H5Tclose(dtype)<0)
+ if (H5Tclose(dtype) < 0)
goto out;
-
/* Test similar datatype in another format */
- if((dtype = H5LTtext_to_dtype(text2, H5LT_DDL))<0)
+ if ((dtype = H5LTtext_to_dtype(text2, H5LT_DDL)) < 0)
goto out;
- if((type_class = H5Tget_class(dtype))<0)
+ if ((type_class = H5Tget_class(dtype)) < 0)
goto out;
- if(type_class != H5T_COMPOUND)
+ if (type_class != H5T_COMPOUND)
goto out;
- if((nmembs = H5Tget_nmembers(dtype))<0)
+ if ((nmembs = H5Tget_nmembers(dtype)) < 0)
goto out;
- if(nmembs != 3)
+ if (nmembs != 3)
goto out;
- if((memb_name = H5Tget_member_name(dtype, 1)) == NULL)
+ if ((memb_name = H5Tget_member_name(dtype, 1)) == NULL)
goto out;
- if(HDstrcmp(memb_name, "desc_________________________________________________________________________________________")) {
+ if (HDstrcmp(memb_name, "desc____________________________________________________________________________"
+ "_____________")) {
H5free_memory(memb_name);
goto out;
}
H5free_memory(memb_name);
- if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0)
+ if (H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len) < 0)
goto out;
- if(NULL==(dt_str = (char*)HDcalloc(str_len, sizeof(char))))
+ if (NULL == (dt_str = (char *)HDcalloc(str_len, sizeof(char))))
goto out;
- if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0) {
+ if (H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len) < 0) {
HDfree(dt_str);
goto out;
}
HDfree(dt_str);
- if(H5Tclose(dtype)<0)
+ if (H5Tclose(dtype) < 0)
goto out;
PASSED();
@@ -1750,66 +1750,67 @@ out:
}
/*-------------------------------------------------------------------------
-* subroutine for test_text_dtype(): test_complicated_compound().
-*-------------------------------------------------------------------------
-*/
-static int test_complicated_compound(void)
+ * subroutine for test_text_dtype(): test_complicated_compound().
+ *-------------------------------------------------------------------------
+ */
+static int
+test_complicated_compound(void)
{
- hid_t dtype;
- int nmembs;
+ hid_t dtype;
+ int nmembs;
H5T_class_t type_class;
- char *line = NULL;
- FILE *fp = NULL;
- size_t size = 1024;
+ char * line = NULL;
+ FILE * fp = NULL;
+ size_t size = 1024;
const char *filename = H5_get_srcdir_filename(INPUT_FILE);
HL_TESTING3(" text for complicated compound types");
/* Open input file */
fp = HDfopen(filename, "r");
- if(fp == NULL) {
- HDprintf( "Could not find file %s. Try set $srcdir \n", filename);
+ if (fp == NULL) {
+ HDprintf("Could not find file %s. Try set $srcdir \n", filename);
goto out;
}
/* This part reads in the input as a string in a slow manner. GNU C
- * Library has convenient function getline() but isn't available on
- * all machines.
- */
- if((line = (char*)HDcalloc(size, sizeof(char)))==NULL)
+ * Library has convenient function getline() but isn't available on
+ * all machines.
+ */
+ if ((line = (char *)HDcalloc(size, sizeof(char))) == NULL)
goto out;
- if(HDfgets(line, (int)size, fp)==NULL)
+ if (HDfgets(line, (int)size, fp) == NULL)
goto out;
- while(HDstrlen(line)==size-1) {
+ while (HDstrlen(line) == size - 1) {
size *= 2;
- if(line)
+ if (line)
HDfree(line);
- if((line = (char*)HDcalloc(size, sizeof(char)))==NULL)
+ if ((line = (char *)HDcalloc(size, sizeof(char))) == NULL)
goto out;
- if(HDfseek(fp, 0L, SEEK_SET)!=0)
+ if (HDfseek(fp, 0L, SEEK_SET) != 0)
goto out;
- if(HDfgets(line, (int)size, fp)==NULL)
+ if (HDfgets(line, (int)size, fp) == NULL)
goto out;
}
HDfclose(fp);
fp = NULL;
- if((dtype = H5LTtext_to_dtype(line, H5LT_DDL))<0)
+ if ((dtype = H5LTtext_to_dtype(line, H5LT_DDL)) < 0)
goto out;
- if((type_class = H5Tget_class(dtype))<0)
+ if ((type_class = H5Tget_class(dtype)) < 0)
goto out;
- if(type_class != H5T_COMPOUND)
+ if (type_class != H5T_COMPOUND)
goto out;
/* There should be 101 compound members */
- if((nmembs = H5Tget_nmembers(dtype))<0)
+ if ((nmembs = H5Tget_nmembers(dtype)) < 0)
goto out;
- if(nmembs != 101)
+ if (nmembs != 101)
goto out;
- if(line)
+ if (line)
HDfree(line);
PASSED();
@@ -1817,9 +1818,9 @@ static int test_complicated_compound(void)
out:
- if(line)
+ if (line)
HDfree(line);
- if(fp)
+ if (fp)
HDfclose(fp);
H5_FAILED();
@@ -1827,41 +1828,42 @@ out:
}
/*-------------------------------------------------------------------------
-* test H5LTtext_to_dtype function
-*-------------------------------------------------------------------------
-*/
-static int test_text_dtype(void)
+ * test H5LTtext_to_dtype function
+ *-------------------------------------------------------------------------
+ */
+static int
+test_text_dtype(void)
{
HL_TESTING2("H5LTtext_to_dtype");
- if(test_integers()<0)
+ if (test_integers() < 0)
goto out;
- if(test_fps()<0)
+ if (test_fps() < 0)
goto out;
- if(test_strings()<0)
+ if (test_strings() < 0)
goto out;
- if(test_opaques()<0)
+ if (test_opaques() < 0)
goto out;
- if(test_enums()<0)
+ if (test_enums() < 0)
goto out;
- if(test_variables()<0)
+ if (test_variables() < 0)
goto out;
- if(test_arrays()<0)
+ if (test_arrays() < 0)
goto out;
- if(test_compounds()<0)
+ if (test_compounds() < 0)
goto out;
- if(test_compound_bug()<0)
+ if (test_compound_bug() < 0)
goto out;
- if(test_complicated_compound()<0)
+ if (test_complicated_compound() < 0)
goto out;
return 0;
@@ -1874,362 +1876,364 @@ out:
* test H5LTpath_valid function
*-------------------------------------------------------------------------
*/
-static int test_valid_path(void)
+static int
+test_valid_path(void)
{
- hid_t file_id, group;
- htri_t path_valid;
- const char *data_string_in = "test";
-
- HL_TESTING2("H5LTpath_valid");
-
- /* Create a new file using default properties. */
-
- /**************************************************************
- * The file structure should look like this:
- *
- * +----------------------------------+
- * | / |
- * +----------------------------------+
- * / | \ \
- * / | \ \
- * / | \ \
- * / | \ G8 (dangled external link)
- * / DS \
- * / \
- * G1 G2
- * | --> DS1 |
- * / \--> DS3 / \
- * / / \
- * G2 DS4 G7
- * | (hard link (dangled soft link
- * | to /G1/DS3) to /G1/G20 )
- * |
- * |
- * | --- Gcyc (soft link to /G1)
- * / \
- * / \
- * G5 \
- * (soft link G6 (external link /G1 in FILENAME4)
- * to /G2)
- *
- ****************************************************************/
-
- file_id = H5Fcreate(FILE_NAME3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
-
- /*
- * Create dataset "/DS"
- */
- if(H5LTmake_dataset_string(file_id, "DS", data_string_in)<0)
- goto out;
-
- /*
- * Create an external dangled link
- */
- if(H5Lcreate_external("NonExistant_File.h5", "G8", file_id, "DangledExternalLink", H5P_DEFAULT, H5P_DEFAULT)<0)
- goto out;
-
- /*
- * Create a group named "G2" in the file.
- */
- if((group = H5Gcreate2(file_id, "G2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT))<0)
- goto out;
-
- /*
- * Create a dataset named "G2/DS4" in the file.
- */
- if(H5LTmake_dataset_string(group, "/G2/DS4", data_string_in)<0)
- goto out;
-
- /*
- * Create a soft link
- */
- if(H5Lcreate_soft("/G1/G20", file_id, "/G2/G7", H5P_DEFAULT, H5P_DEFAULT) <0)
- goto out;
-
- if(H5Gclose(group)<0)
- goto out;
-
- /*
- * Create a group named "G1" in the file.
- */
- if((group = H5Gcreate2(file_id, "G1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT))<0)
- goto out;
-
- /*
- * Create a group named "G1/DS1" in the file.
- */
- if(H5LTmake_dataset_string(group, "/G1/DS1", data_string_in)<0)
- goto out;
-
- if(H5Gclose(group)<0)
- goto out;
-
- /*
- * Create a hard link
- */
- if(H5Lcreate_hard(file_id, "/G2/DS4", file_id, "/G1/DS3",H5P_DEFAULT, H5P_DEFAULT)<0)
- goto out;
- /*
- * Create a group named "/G1/G2" in the file.
- */
- if((group = H5Gcreate2(file_id, "/G1/G2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT))<0)
- goto out;
-
- /*
- * Create a soft link
- */
- if(H5Lcreate_soft("/G2", file_id, "/G1/G2/G5", H5P_DEFAULT, H5P_DEFAULT)<0)
- goto out;
-
- /*
- * Create a cyclic soft link
- */
- if(H5Lcreate_soft("/G1", file_id, "/G1/G2/Gcyc", H5P_DEFAULT, H5P_DEFAULT)<0)
- goto out;
-
- if(H5Gclose(group)<0)
- goto out;
-
- /*
- * Create a group named "/G1/G2/G6" in the file.
- */
- if((group = H5Gcreate2(file_id, "/G1/G2/G6", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT))<0)
- goto out;
-
- /*
- * Create an external link
- */
- if(H5Lcreate_external( FILE_NAME4, "G1", group, "ExternalLink", H5P_DEFAULT, H5P_DEFAULT)<0)
- goto out;
-
- if(H5Gclose(group)<0)
- goto out;
- /*
- * Close the file.
- */
- if(H5Fclose (file_id) < 0)
- goto out;
-
- /* Create another file for checking external links */
-
- /**************************************************************
- * The file structure should look like this:
- *
- * +----+
- * | / |
- * +----+
- * |
- * |
- * |
- * G1
- * / \
- * / \
- * DS1 G2
- * (dangled soft link to /G1/G20)
- *
- ****************************************************************/
-
- /* Make external link file */
- file_id = H5Fcreate(FILE_NAME4, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
-
- /*
- * Create a group named "G1" in the file.
- */
- if((group = H5Gcreate2(file_id, "G1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT))<0)
- goto out;
- /*
- * Create a dataset named "G1/DS1" in the file.
- */
- if(H5LTmake_dataset_string(group, "/G1/DS1", data_string_in)<0)
- goto out;
-
- /*
- * Create a dangling soft link
- */
-
- if(H5Lcreate_soft("/G1/G2", file_id, "/G1/G20", H5P_DEFAULT, H5P_DEFAULT)<0)
- goto out;
-
- if(H5Gclose(group)<0)
- goto out;
-
- H5Fclose(file_id);
-
- /* Open input file */
- if((file_id = H5Fopen(FILE_NAME3,H5F_ACC_RDONLY, H5P_DEFAULT))<0)
- goto out;
-
- /**************************************
- * CHECK ABSOLUTE PATHS
- **************************************/
-
- if( (path_valid = H5LTpath_valid(file_id, "/", TRUE)) != TRUE) {
- goto out;
- }
-
- if( (path_valid = H5LTpath_valid(file_id, "/", FALSE)) != TRUE) {
- goto out;
- }
-
- if( (path_valid = H5LTpath_valid(file_id, "/G1", TRUE)) != TRUE) {
- goto out;
- }
-
- if((path_valid = H5LTpath_valid(file_id, "/G1/DS1", TRUE)) != TRUE)
- goto out;
-
- if( (path_valid = H5LTpath_valid(file_id, "/G1/DS3", TRUE)) != TRUE)
- goto out;
-
- if( (path_valid = H5LTpath_valid(file_id, "/G1/G2", TRUE)) != TRUE)
- goto out;
-
- if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/G5", TRUE)) != TRUE)
- goto out;
+ hid_t file_id, group;
+ htri_t path_valid;
+ const char *data_string_in = "test";
- if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/Gcyc/DS1", FALSE)) != TRUE)
- goto out;
+ HL_TESTING2("H5LTpath_valid");
- if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/Gcyc/DS1", TRUE)) != TRUE)
- goto out;
+ /* Create a new file using default properties. */
- if( (path_valid = H5LTpath_valid(file_id, "/G2", TRUE)) != TRUE)
- goto out;
+ /**************************************************************
+ * The file structure should look like this:
+ *
+ * +----------------------------------+
+ * | / |
+ * +----------------------------------+
+ * / | \ \
+ * / | \ \
+ * / | \ \
+ * / | \ G8 (dangled external link)
+ * / DS \
+ * / \
+ * G1 G2
+ * | --> DS1 |
+ * / \--> DS3 / \
+ * / / \
+ * G2 DS4 G7
+ * | (hard link (dangled soft link
+ * | to /G1/DS3) to /G1/G20 )
+ * |
+ * |
+ * | --- Gcyc (soft link to /G1)
+ * / \
+ * / \
+ * G5 \
+ * (soft link G6 (external link /G1 in FILENAME4)
+ * to /G2)
+ *
+ ****************************************************************/
- /* check soft link points to a valid object*/
- if( (path_valid = H5LTpath_valid(file_id, "/G2/DS4", TRUE)) != TRUE)
- goto out;
+ file_id = H5Fcreate(FILE_NAME3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- /* check if path exist, but not the object */
- if( (path_valid = H5LTpath_valid(file_id, "/G2/G7", FALSE)) != TRUE )
- goto out;
- /* check if path exist and if the object exists. It should fail
- * since it is a dangling soft link
- */
- if( (path_valid = H5LTpath_valid(file_id, "/G2/G7", TRUE)) == TRUE)
- goto out;
+ /*
+ * Create dataset "/DS"
+ */
+ if (H5LTmake_dataset_string(file_id, "DS", data_string_in) < 0)
+ goto out;
- /* check soft links */
- if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/G5/DS4", TRUE)) != TRUE)
- goto out;
+ /*
+ * Create an external dangled link
+ */
+ if (H5Lcreate_external("NonExistant_File.h5", "G8", file_id, "DangledExternalLink", H5P_DEFAULT,
+ H5P_DEFAULT) < 0)
+ goto out;
- /**************************************
- * CHECK RELATIVE PATHS
- ***************************************/
+ /*
+ * Create a group named "G2" in the file.
+ */
+ if ((group = H5Gcreate2(file_id, "G2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
- if( (group = H5Gopen2(file_id, "/", H5P_DEFAULT)) < 0)
- goto out;
+ /*
+ * Create a dataset named "G2/DS4" in the file.
+ */
+ if (H5LTmake_dataset_string(group, "/G2/DS4", data_string_in) < 0)
+ goto out;
- if( (path_valid = H5LTpath_valid(group, "/", TRUE)) != TRUE) {
- goto out;
- }
+ /*
+ * Create a soft link
+ */
+ if (H5Lcreate_soft("/G1/G20", file_id, "/G2/G7", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ goto out;
- if( (path_valid = H5LTpath_valid(group, "/", FALSE)) != TRUE) {
- goto out;
- }
+ if (H5Gclose(group) < 0)
+ goto out;
- if(H5Gclose(group)<0)
- goto out;
+ /*
+ * Create a group named "G1" in the file.
+ */
+ if ((group = H5Gcreate2(file_id, "G1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
- if( (group = H5Gopen2(file_id, "/G1", H5P_DEFAULT)) < 0)
- goto out;
+ /*
+ * Create a group named "G1/DS1" in the file.
+ */
+ if (H5LTmake_dataset_string(group, "/G1/DS1", data_string_in) < 0)
+ goto out;
- /* The identifier (file id) is the object itself, i.e. "." */
+ if (H5Gclose(group) < 0)
+ goto out;
- if((path_valid = H5LTpath_valid(file_id, ".", FALSE)) != TRUE)
- goto out;
+ /*
+ * Create a hard link
+ */
+ if (H5Lcreate_hard(file_id, "/G2/DS4", file_id, "/G1/DS3", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ goto out;
+ /*
+ * Create a group named "/G1/G2" in the file.
+ */
+ if ((group = H5Gcreate2(file_id, "/G1/G2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
- if( (path_valid = H5LTpath_valid(file_id, ".", TRUE)) != TRUE)
- goto out;
+ /*
+ * Create a soft link
+ */
+ if (H5Lcreate_soft("/G2", file_id, "/G1/G2/G5", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ goto out;
- /* The identifier (group id) is the object itself, i.e. "." */
+ /*
+ * Create a cyclic soft link
+ */
+ if (H5Lcreate_soft("/G1", file_id, "/G1/G2/Gcyc", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ goto out;
+
+ if (H5Gclose(group) < 0)
+ goto out;
+
+ /*
+ * Create a group named "/G1/G2/G6" in the file.
+ */
+ if ((group = H5Gcreate2(file_id, "/G1/G2/G6", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
+
+ /*
+ * Create an external link
+ */
+ if (H5Lcreate_external(FILE_NAME4, "G1", group, "ExternalLink", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ goto out;
+
+ if (H5Gclose(group) < 0)
+ goto out;
+ /*
+ * Close the file.
+ */
+ if (H5Fclose(file_id) < 0)
+ goto out;
+
+ /* Create another file for checking external links */
+
+ /**************************************************************
+ * The file structure should look like this:
+ *
+ * +----+
+ * | / |
+ * +----+
+ * |
+ * |
+ * |
+ * G1
+ * / \
+ * / \
+ * DS1 G2
+ * (dangled soft link to /G1/G20)
+ *
+ ****************************************************************/
+
+ /* Make external link file */
+ file_id = H5Fcreate(FILE_NAME4, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+
+ /*
+ * Create a group named "G1" in the file.
+ */
+ if ((group = H5Gcreate2(file_id, "G1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
+ /*
+ * Create a dataset named "G1/DS1" in the file.
+ */
+ if (H5LTmake_dataset_string(group, "/G1/DS1", data_string_in) < 0)
+ goto out;
+
+ /*
+ * Create a dangling soft link
+ */
+
+ if (H5Lcreate_soft("/G1/G2", file_id, "/G1/G20", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ goto out;
+
+ if (H5Gclose(group) < 0)
+ goto out;
+
+ H5Fclose(file_id);
+
+ /* Open input file */
+ if ((file_id = H5Fopen(FILE_NAME3, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
+ goto out;
+
+ /**************************************
+ * CHECK ABSOLUTE PATHS
+ **************************************/
+
+ if ((path_valid = H5LTpath_valid(file_id, "/", TRUE)) != TRUE) {
+ goto out;
+ }
+
+ if ((path_valid = H5LTpath_valid(file_id, "/", FALSE)) != TRUE) {
+ goto out;
+ }
+
+ if ((path_valid = H5LTpath_valid(file_id, "/G1", TRUE)) != TRUE) {
+ goto out;
+ }
+
+ if ((path_valid = H5LTpath_valid(file_id, "/G1/DS1", TRUE)) != TRUE)
+ goto out;
+
+ if ((path_valid = H5LTpath_valid(file_id, "/G1/DS3", TRUE)) != TRUE)
+ goto out;
+
+ if ((path_valid = H5LTpath_valid(file_id, "/G1/G2", TRUE)) != TRUE)
+ goto out;
+
+ if ((path_valid = H5LTpath_valid(file_id, "/G1/G2/G5", TRUE)) != TRUE)
+ goto out;
+
+ if ((path_valid = H5LTpath_valid(file_id, "/G1/G2/Gcyc/DS1", FALSE)) != TRUE)
+ goto out;
+
+ if ((path_valid = H5LTpath_valid(file_id, "/G1/G2/Gcyc/DS1", TRUE)) != TRUE)
+ goto out;
+
+ if ((path_valid = H5LTpath_valid(file_id, "/G2", TRUE)) != TRUE)
+ goto out;
+
+ /* check soft link points to a valid object*/
+ if ((path_valid = H5LTpath_valid(file_id, "/G2/DS4", TRUE)) != TRUE)
+ goto out;
- if( (path_valid = H5LTpath_valid(group, ".", TRUE)) != TRUE)
- goto out;
+ /* check if path exist, but not the object */
+ if ((path_valid = H5LTpath_valid(file_id, "/G2/G7", FALSE)) != TRUE)
+ goto out;
+ /* check if path exist and if the object exists. It should fail
+ * since it is a dangling soft link
+ */
+ if ((path_valid = H5LTpath_valid(file_id, "/G2/G7", TRUE)) == TRUE)
+ goto out;
- if( (path_valid = H5LTpath_valid(group, "DS3", FALSE)) != TRUE)
- goto out;
+ /* check soft links */
+ if ((path_valid = H5LTpath_valid(file_id, "/G1/G2/G5/DS4", TRUE)) != TRUE)
+ goto out;
- if( (path_valid = H5LTpath_valid(group, "DS3", TRUE)) != TRUE)
- goto out;
+ /**************************************
+ * CHECK RELATIVE PATHS
+ ***************************************/
- if( (path_valid = H5LTpath_valid(group, "G2/G5", TRUE)) != TRUE)
- goto out;
+ if ((group = H5Gopen2(file_id, "/", H5P_DEFAULT)) < 0)
+ goto out;
- /* Check the "./" case */
- if( (path_valid = H5LTpath_valid(group, "./DS3", TRUE)) != TRUE)
- goto out;
+ if ((path_valid = H5LTpath_valid(group, "/", TRUE)) != TRUE) {
+ goto out;
+ }
- if( (path_valid = H5LTpath_valid(group, "./G2/G5", TRUE)) != TRUE)
- goto out;
+ if ((path_valid = H5LTpath_valid(group, "/", FALSE)) != TRUE) {
+ goto out;
+ }
+
+ if (H5Gclose(group) < 0)
+ goto out;
- /* Should fail, does not exist */
- if( (path_valid = H5LTpath_valid(group, "./G2/G20", FALSE)) == TRUE)
- goto out;
+ if ((group = H5Gopen2(file_id, "/G1", H5P_DEFAULT)) < 0)
+ goto out;
- /* Should fail, does not exist */
- if( (path_valid = H5LTpath_valid(group, "./G2/G20", TRUE)) == TRUE)
- goto out;
+ /* The identifier (file id) is the object itself, i.e. "." */
- if(H5Gclose(group)<0)
- goto out;
+ if ((path_valid = H5LTpath_valid(file_id, ".", FALSE)) != TRUE)
+ goto out;
- /*****************************
- * Check external links
- *****************************/
+ if ((path_valid = H5LTpath_valid(file_id, ".", TRUE)) != TRUE)
+ goto out;
- /* The dangled external link path is valid */
- if( (path_valid = H5LTpath_valid(file_id, "/DangledExternalLink", FALSE)) != TRUE)
- goto out;
+ /* The identifier (group id) is the object itself, i.e. "." */
- /* The file however does not exists, so the link dangles -> should return false */
- if( (path_valid = H5LTpath_valid(file_id, "/DangledExternalLink", TRUE)) == TRUE)
- goto out;
+ if ((path_valid = H5LTpath_valid(group, ".", TRUE)) != TRUE)
+ goto out;
- if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/G6/ExternalLink", FALSE)) != TRUE)
- goto out;
+ if ((path_valid = H5LTpath_valid(group, "DS3", FALSE)) != TRUE)
+ goto out;
- if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/G6/ExternalLink", TRUE)) != TRUE)
- goto out;
+ if ((path_valid = H5LTpath_valid(group, "DS3", TRUE)) != TRUE)
+ goto out;
- if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/Gcyc/G2/G6/ExternalLink/DS1", TRUE)) != TRUE)
- goto out;
+ if ((path_valid = H5LTpath_valid(group, "G2/G5", TRUE)) != TRUE)
+ goto out;
- if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/Gcyc/G2/G6/ExternalLink/G20", FALSE)) != TRUE)
- goto out;
+ /* Check the "./" case */
+ if ((path_valid = H5LTpath_valid(group, "./DS3", TRUE)) != TRUE)
+ goto out;
- if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/G6/ExternalLink/DS1", TRUE)) != TRUE)
- goto out;
+ if ((path_valid = H5LTpath_valid(group, "./G2/G5", TRUE)) != TRUE)
+ goto out;
- if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/G6/ExternalLink/G20", FALSE)) != TRUE)
- goto out;
+ /* Should fail, does not exist */
+ if ((path_valid = H5LTpath_valid(group, "./G2/G20", FALSE)) == TRUE)
+ goto out;
- /* Should fail, does not exist */
- if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/G6/ExternalLink/G20", TRUE)) == TRUE)
- goto out;
+ /* Should fail, does not exist */
+ if ((path_valid = H5LTpath_valid(group, "./G2/G20", TRUE)) == TRUE)
+ goto out;
- if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/Gcyc/G2/G6/ExternalLink/G20", TRUE)) == TRUE)
- goto out;
+ if (H5Gclose(group) < 0)
+ goto out;
+ /*****************************
+ * Check external links
+ *****************************/
- if(H5Fclose(file_id)<0)
- goto out;
+ /* The dangled external link path is valid */
+ if ((path_valid = H5LTpath_valid(file_id, "/DangledExternalLink", FALSE)) != TRUE)
+ goto out;
- PASSED();
- return 0;
+ /* The file however does not exists, so the link dangles -> should return false */
+ if ((path_valid = H5LTpath_valid(file_id, "/DangledExternalLink", TRUE)) == TRUE)
+ goto out;
- out:
- H5_FAILED();
- return -1;
+ if ((path_valid = H5LTpath_valid(file_id, "/G1/G2/G6/ExternalLink", FALSE)) != TRUE)
+ goto out;
+
+ if ((path_valid = H5LTpath_valid(file_id, "/G1/G2/G6/ExternalLink", TRUE)) != TRUE)
+ goto out;
+
+ if ((path_valid = H5LTpath_valid(file_id, "/G1/G2/Gcyc/G2/G6/ExternalLink/DS1", TRUE)) != TRUE)
+ goto out;
+
+ if ((path_valid = H5LTpath_valid(file_id, "/G1/G2/Gcyc/G2/G6/ExternalLink/G20", FALSE)) != TRUE)
+ goto out;
+
+ if ((path_valid = H5LTpath_valid(file_id, "/G1/G2/G6/ExternalLink/DS1", TRUE)) != TRUE)
+ goto out;
+
+ if ((path_valid = H5LTpath_valid(file_id, "/G1/G2/G6/ExternalLink/G20", FALSE)) != TRUE)
+ goto out;
+
+ /* Should fail, does not exist */
+ if ((path_valid = H5LTpath_valid(file_id, "/G1/G2/G6/ExternalLink/G20", TRUE)) == TRUE)
+ goto out;
+
+ if ((path_valid = H5LTpath_valid(file_id, "/G1/G2/Gcyc/G2/G6/ExternalLink/G20", TRUE)) == TRUE)
+ goto out;
+
+ if (H5Fclose(file_id) < 0)
+ goto out;
+
+ PASSED();
+ return 0;
+
+out:
+ H5_FAILED();
+ return -1;
}
/*-------------------------------------------------------------------------
-* the main program
-*-------------------------------------------------------------------------
-*/
-int main( void )
+ * the main program
+ *-------------------------------------------------------------------------
+ */
+int
+main(void)
{
- int nerrors=0;
+ int nerrors = 0;
/* test dataset functions */
nerrors += test_dsets();
diff --git a/hl/test/test_packet.c b/hl/test/test_packet.c
index eb28e3d..1224f0f 100644
--- a/hl/test/test_packet.c
+++ b/hl/test/test_packet.c
@@ -21,41 +21,34 @@
*-------------------------------------------------------------------------
*/
-#define NRECORDS 8
-#define BIG_TABLE_SIZE 8000
-#define NFIELDS 5
-#define TEST_FILE_NAME "test_packet_table.h5"
+#define NRECORDS 8
+#define BIG_TABLE_SIZE 8000
+#define NFIELDS 5
+#define TEST_FILE_NAME "test_packet_table.h5"
#define TEST_COMPRESS_FILE "test_packet_compress.h5"
-#define PT_NAME "Test Packet Table"
-#define H5TB_TABLE_NAME "Table1"
+#define PT_NAME "Test Packet Table"
+#define H5TB_TABLE_NAME "Table1"
/*-------------------------------------------------------------------------
* structure used for some tests, a particle
*-------------------------------------------------------------------------
*/
-typedef struct particle_t
-{
- char name[16];
- int lati;
- int longi;
- float pressure;
- double temperature;
+typedef struct particle_t {
+ char name[16];
+ int lati;
+ int longi;
+ float pressure;
+ double temperature;
} particle_t;
/*-------------------------------------------------------------------------
* a static array of particles for writing and checking reads
*-------------------------------------------------------------------------
*/
-static particle_t testPart[NRECORDS] = {
- {"zero", 0,0, 0.0f, 0.0f},
- {"one", 10,10, 1.0f, 10.0f},
- {"two", 20,20, 2.0f, 20.0f},
- {"three",30,30, 3.0f, 30.0f},
- {"four", 40,40, 4.0f, 40.0f},
- {"five", 50,50, 5.0f, 50.0f},
- {"six", 60,60, 6.0f, 60.0f},
- {"seven",70,70, 7.0f, 70.0f}
- };
+static particle_t testPart[NRECORDS] = {{"zero", 0, 0, 0.0f, 0.0f}, {"one", 10, 10, 1.0f, 10.0f},
+ {"two", 20, 20, 2.0f, 20.0f}, {"three", 30, 30, 3.0f, 30.0f},
+ {"four", 40, 40, 4.0f, 40.0f}, {"five", 50, 50, 5.0f, 50.0f},
+ {"six", 60, 60, 6.0f, 60.0f}, {"seven", 70, 70, 7.0f, 70.0f}};
/*-------------------------------------------------------------------------
* function that compares one particle
@@ -63,16 +56,15 @@ static particle_t testPart[NRECORDS] = {
* fields verbatim and not lose any bits. -JML
*-------------------------------------------------------------------------
*/
-static int cmp_par(size_t i, size_t j, particle_t *rbuf, particle_t *wbuf )
+static int
+cmp_par(size_t i, size_t j, particle_t *rbuf, particle_t *wbuf)
{
- if ( ( HDstrcmp( rbuf[i].name, wbuf[j].name ) != 0 ) ||
- rbuf[i].lati != wbuf[j].lati ||
- rbuf[i].longi != wbuf[j].longi ||
- !H5_FLT_ABS_EQUAL(rbuf[i].pressure,wbuf[j].pressure) ||
- !H5_DBL_ABS_EQUAL(rbuf[i].temperature,wbuf[j].temperature) ) {
- return FAIL;
- }
- return SUCCEED;
+ if ((HDstrcmp(rbuf[i].name, wbuf[j].name) != 0) || rbuf[i].lati != wbuf[j].lati ||
+ rbuf[i].longi != wbuf[j].longi || !H5_FLT_ABS_EQUAL(rbuf[i].pressure, wbuf[j].pressure) ||
+ !H5_DBL_ABS_EQUAL(rbuf[i].temperature, wbuf[j].temperature)) {
+ return FAIL;
+ }
+ return SUCCEED;
}
/*-------------------------------------------------------------------------
@@ -82,53 +74,51 @@ static int cmp_par(size_t i, size_t j, particle_t *rbuf, particle_t *wbuf )
static hid_t
make_particle_type(void)
{
- hid_t type_id;
- hid_t string_type;
- size_t type_size = sizeof(particle_t);
-
- /* Create the memory data type. */
- if ((type_id = H5Tcreate (H5T_COMPOUND, type_size )) < 0 )
- return FAIL;
-
- /* Insert fields. */
- if ((string_type = H5Tcopy(H5T_C_S1)) < 0)
- return FAIL;
- if (H5Tset_size(string_type, (size_t)16) < 0)
- return FAIL;
-
- if ( H5Tinsert(type_id, "Name", HOFFSET(particle_t, name) , string_type ) < 0 )
- return FAIL;
- if ( H5Tinsert(type_id, "Lat", HOFFSET(particle_t, lati) , H5T_NATIVE_INT ) < 0 )
- return FAIL;
- if ( H5Tinsert(type_id, "Long", HOFFSET(particle_t, longi) , H5T_NATIVE_INT ) < 0 )
- return FAIL;
- if ( H5Tinsert(type_id, "Pressure", HOFFSET(particle_t, pressure) , H5T_NATIVE_FLOAT ) < 0 )
- return FAIL;
- if ( H5Tinsert(type_id, "Temperature", HOFFSET(particle_t, temperature) , H5T_NATIVE_DOUBLE ) < 0 )
- return FAIL;
-
- return type_id;
+ hid_t type_id;
+ hid_t string_type;
+ size_t type_size = sizeof(particle_t);
+
+ /* Create the memory data type. */
+ if ((type_id = H5Tcreate(H5T_COMPOUND, type_size)) < 0)
+ return FAIL;
+
+ /* Insert fields. */
+ if ((string_type = H5Tcopy(H5T_C_S1)) < 0)
+ return FAIL;
+ if (H5Tset_size(string_type, (size_t)16) < 0)
+ return FAIL;
+
+ if (H5Tinsert(type_id, "Name", HOFFSET(particle_t, name), string_type) < 0)
+ return FAIL;
+ if (H5Tinsert(type_id, "Lat", HOFFSET(particle_t, lati), H5T_NATIVE_INT) < 0)
+ return FAIL;
+ if (H5Tinsert(type_id, "Long", HOFFSET(particle_t, longi), H5T_NATIVE_INT) < 0)
+ return FAIL;
+ if (H5Tinsert(type_id, "Pressure", HOFFSET(particle_t, pressure), H5T_NATIVE_FLOAT) < 0)
+ return FAIL;
+ if (H5Tinsert(type_id, "Temperature", HOFFSET(particle_t, temperature), H5T_NATIVE_DOUBLE) < 0)
+ return FAIL;
+
+ return type_id;
}
- /* Create a normal HL table just like the HL examples do */
-static int create_hl_table(hid_t fid)
+/* Create a normal HL table just like the HL examples do */
+static int
+create_hl_table(hid_t fid)
{
- /* Calculate the offsets of the particle struct members in memory */
- size_t part_offset[NFIELDS] = { HOFFSET( particle_t, name ),
- HOFFSET( particle_t, lati ),
- HOFFSET( particle_t, longi ),
- HOFFSET( particle_t, pressure ),
- HOFFSET( particle_t, temperature )};
+ /* Calculate the offsets of the particle struct members in memory */
+ size_t part_offset[NFIELDS] = {HOFFSET(particle_t, name), HOFFSET(particle_t, lati),
+ HOFFSET(particle_t, longi), HOFFSET(particle_t, pressure),
+ HOFFSET(particle_t, temperature)};
/* Define field information */
- const char *field_names[NFIELDS] =
- { "Name","Latitude", "Longitude", "Pressure", "Temperature" };
- hid_t field_type[NFIELDS];
- hid_t string_type;
- hsize_t chunk_size = 10;
- int *fill_data = NULL;
- int compress = 0;
- herr_t status;
+ const char *field_names[NFIELDS] = {"Name", "Latitude", "Longitude", "Pressure", "Temperature"};
+ hid_t field_type[NFIELDS];
+ hid_t string_type;
+ hsize_t chunk_size = 10;
+ int * fill_data = NULL;
+ int compress = 0;
+ herr_t status;
/* Initialize the field field_type */
if ((string_type = H5Tcopy(H5T_C_S1)) < 0)
@@ -141,27 +131,24 @@ static int create_hl_table(hid_t fid)
field_type[3] = H5T_NATIVE_FLOAT;
field_type[4] = H5T_NATIVE_DOUBLE;
+ /*------------------------------------------------------------------------
+ * H5TBmake_table
+ *-------------------------------------------------------------------------
+ */
- /*------------------------------------------------------------------------
- * H5TBmake_table
- *-------------------------------------------------------------------------
- */
-
- status=H5TBmake_table( "Table Title", fid, H5TB_TABLE_NAME, (hsize_t)NFIELDS,
- (hsize_t)NRECORDS, sizeof(particle_t),
- field_names, part_offset, field_type,
- chunk_size, fill_data, compress, testPart );
+ status = H5TBmake_table("Table Title", fid, H5TB_TABLE_NAME, (hsize_t)NFIELDS, (hsize_t)NRECORDS,
+ sizeof(particle_t), field_names, part_offset, field_type, chunk_size, fill_data,
+ compress, testPart);
- if (H5Tclose(string_type) < 0)
- return FAIL;
+ if (H5Tclose(string_type) < 0)
+ return FAIL;
- if(status<0)
- return FAIL;
- else
- return SUCCEED;
+ if (status < 0)
+ return FAIL;
+ else
+ return SUCCEED;
}
-
/*-------------------------------------------------------------------------
* test_create_close
*
@@ -170,11 +157,12 @@ static int create_hl_table(hid_t fid)
*-------------------------------------------------------------------------
*/
-static int test_create_close(hid_t fid)
+static int
+test_create_close(hid_t fid)
{
herr_t err;
- hid_t table;
- hid_t part_t;
+ hid_t table;
+ hid_t part_t;
HL_TESTING2("H5PTcreate_fl and H5PTclose");
@@ -186,23 +174,23 @@ static int test_create_close(hid_t fid)
/* Create the table */
table = H5PTcreate_fl(fid, PT_NAME, part_t, (hsize_t)100, -1);
if (H5Tclose(part_t) < 0)
- goto error;
- if( H5PTis_valid(table) < 0)
- goto error;
- if( H5PTis_varlen(table) != 0)
- goto error;
+ goto error;
+ if (H5PTis_valid(table) < 0)
+ goto error;
+ if (H5PTis_varlen(table) != 0)
+ goto error;
/* Close the table */
err = H5PTclose(table);
- if( err < 0)
+ if (err < 0)
goto error;
PASSED();
return SUCCEED;
error:
- H5_FAILED();
- return FAIL;
+ H5_FAILED();
+ return FAIL;
}
/*-------------------------------------------------------------------------
@@ -212,32 +200,34 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int test_open(hid_t fid)
+static int
+test_open(hid_t fid)
{
herr_t err;
- hid_t table;
+ hid_t table;
HL_TESTING2("H5PTopen");
/* Open the table */
table = H5PTopen(fid, PT_NAME);
- if( H5PTis_valid(table) < 0)
+ if (H5PTis_valid(table) < 0)
goto error;
- if( H5PTis_varlen(table) != 0)
+ if (H5PTis_varlen(table) != 0)
goto error;
/* Close the table */
err = H5PTclose(table);
- if( err < 0)
+ if (err < 0)
goto error;
PASSED();
return SUCCEED;
error:
- if (table > 0) H5PTclose(table);
- H5_FAILED();
- return FAIL;
+ if (table > 0)
+ H5PTclose(table);
+ H5_FAILED();
+ return FAIL;
}
/*-------------------------------------------------------------------------
@@ -247,63 +237,64 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int test_append(hid_t fid)
+static int
+test_append(hid_t fid)
{
- herr_t err;
- hid_t table;
+ herr_t err;
+ hid_t table;
hsize_t count = 0;
HL_TESTING2("H5PTappend");
/* Open the table */
table = H5PTopen(fid, PT_NAME);
- if( H5PTis_valid(table) < 0)
+ if (H5PTis_valid(table) < 0)
goto error;
/* Count the number of packets in the table */
err = H5PTget_num_packets(table, &count);
- if( err < 0)
+ if (err < 0)
goto error;
/* There should be 0 records in the table */
- if( count != 0 )
+ if (count != 0)
goto error;
/* Append one particle */
err = H5PTappend(table, (size_t)1, &(testPart[0]));
- if( err < 0)
+ if (err < 0)
goto error;
/* Append several particles */
err = H5PTappend(table, (size_t)6, &(testPart[1]));
- if( err < 0)
+ if (err < 0)
goto error;
/* Append one more particle */
err = H5PTappend(table, (size_t)1, &(testPart[7]));
- if( err < 0)
+ if (err < 0)
goto error;
/* Count the number of packets in the table */
err = H5PTget_num_packets(table, &count);
- if( err < 0)
+ if (err < 0)
goto error;
/* There should be 8 records in the table now */
- if( count != 8 )
+ if (count != 8)
goto error;
/* Close the table */
err = H5PTclose(table);
- if( err < 0)
+ if (err < 0)
goto error;
PASSED();
return SUCCEED;
error:
- H5_FAILED();
- if( H5PTis_valid(table) > 0)
- H5PTclose(table);
- return FAIL;
+ H5_FAILED();
+ if (H5PTis_valid(table) > 0)
+ H5PTclose(table);
+ return FAIL;
}
/*-------------------------------------------------------------------------
@@ -313,45 +304,45 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int test_read(hid_t fid)
+static int
+test_read(hid_t fid)
{
- herr_t err;
- hid_t table;
+ herr_t err;
+ hid_t table;
particle_t readBuf[NRECORDS];
- size_t c;
+ size_t c;
HL_TESTING2("H5PTread_packets");
/* Open the table */
table = H5PTopen(fid, PT_NAME);
- if( H5PTis_valid(table) < 0)
+ if (H5PTis_valid(table) < 0)
goto error;
/* Read several particles */
err = H5PTread_packets(table, (hsize_t)0, 3, &(readBuf[0]));
- if( err < 0)
+ if (err < 0)
goto error;
/* Read one particle */
err = H5PTread_packets(table, (hsize_t)3, 1, &(readBuf[3]));
- if( err < 0)
+ if (err < 0)
goto error;
/* Read several particles */
- err = H5PTread_packets(table, (hsize_t)4, (NRECORDS - 4 ), &(readBuf[4]));
- if( err < 0)
+ err = H5PTread_packets(table, (hsize_t)4, (NRECORDS - 4), &(readBuf[4]));
+ if (err < 0)
goto error;
/* Ensure that particles were read correctly */
- for(c=0; c<NRECORDS; c++)
- {
- if( cmp_par(c%8, c, testPart, readBuf) != 0)
+ for (c = 0; c < NRECORDS; c++) {
+ if (cmp_par(c % 8, c, testPart, readBuf) != 0)
goto error;
}
/* Close the table */
err = H5PTclose(table);
- if( err < 0)
+ if (err < 0)
goto error;
PASSED();
@@ -359,10 +350,10 @@ static int test_read(hid_t fid)
return SUCCEED;
error:
- H5_FAILED();
- if( H5PTis_valid(table) > 0)
- H5PTclose(table);
- return FAIL;
+ H5_FAILED();
+ if (H5PTis_valid(table) > 0)
+ H5PTclose(table);
+ return FAIL;
}
/*-------------------------------------------------------------------------
@@ -373,66 +364,63 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int test_get_next(hid_t fid)
+static int
+test_get_next(hid_t fid)
{
- herr_t err;
- hid_t table;
+ herr_t err;
+ hid_t table;
particle_t readBuf[NRECORDS];
particle_t readBuf2[NRECORDS];
- size_t c;
+ size_t c;
HL_TESTING2("H5PTget_next");
/* Open the table */
table = H5PTopen(fid, PT_NAME);
- if( H5PTis_valid(table) < 0)
+ if (H5PTis_valid(table) < 0)
goto error;
/* Read several particles consecutively */
- for(c=0; c < NRECORDS; c++)
- {
+ for (c = 0; c < NRECORDS; c++) {
err = H5PTget_next(table, (size_t)1, &readBuf[c]);
- if(err < 0)
+ if (err < 0)
goto error;
}
/* Ensure that particles were read correctly */
- for(c=0; c<NRECORDS; c++)
- {
- if( cmp_par(c, c, testPart, readBuf) != 0)
+ for (c = 0; c < NRECORDS; c++) {
+ if (cmp_par(c, c, testPart, readBuf) != 0)
goto error;
}
H5PTcreate_index(table);
/* Read particles two by two */
- for(c=0; c < NRECORDS / 2; c++)
- {
+ for (c = 0; c < NRECORDS / 2; c++) {
err = H5PTget_next(table, (size_t)2, &readBuf2[c * 2]);
- if(err < 0)
+ if (err < 0)
goto error;
}
/* Ensure that particles were read correctly */
- for(c=0; c<NRECORDS; c++)
- {
- if( cmp_par(c, c, testPart, readBuf2) != 0)
+ for (c = 0; c < NRECORDS; c++) {
+ if (cmp_par(c, c, testPart, readBuf2) != 0)
goto error;
}
/* Close the table */
err = H5PTclose(table);
- if( err < 0)
+ if (err < 0)
goto error;
PASSED();
return SUCCEED;
error:
- H5_FAILED();
- if( H5PTis_valid(table) > 0)
- H5PTclose(table);
- return FAIL;
+ H5_FAILED();
+ if (H5PTis_valid(table) > 0)
+ H5PTclose(table);
+ return FAIL;
}
/*-------------------------------------------------------------------------
@@ -443,14 +431,15 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int test_big_table(hid_t fid)
+static int
+test_big_table(hid_t fid)
{
- herr_t err;
- hid_t table;
- hid_t part_t;
- size_t c;
+ herr_t err;
+ hid_t table;
+ hid_t part_t;
+ size_t c;
particle_t readPart;
- hsize_t count;
+ hsize_t count;
HL_TESTING2("large packet table");
@@ -463,52 +452,50 @@ static int test_big_table(hid_t fid)
table = H5PTcreate_fl(fid, "Packet Test Dataset2", part_t, (hsize_t)33, -1);
if (H5Tclose(part_t) < 0)
goto error;
- if( H5PTis_valid(table) < 0)
+ if (H5PTis_valid(table) < 0)
goto error;
- /* Add many particles */
- for(c = 0; c < BIG_TABLE_SIZE ; c+=8)
- {
+ /* Add many particles */
+ for (c = 0; c < BIG_TABLE_SIZE; c += 8) {
/* Append eight particles at once*/
err = H5PTappend(table, (size_t)8, &(testPart[0]));
- if( err < 0)
+ if (err < 0)
goto error;
}
/* Count the number of packets in the table */
err = H5PTget_num_packets(table, &count);
- if( err < 0)
+ if (err < 0)
goto error;
- if( count != BIG_TABLE_SIZE )
+ if (count != BIG_TABLE_SIZE)
goto error;
/* Read particles to ensure that all of them were written correctly */
/* Also, ensure that H5PTcreate_fl set the current packet to */
/* the first packet in the table */
- for(c = 0; c < BIG_TABLE_SIZE; c++)
- {
+ for (c = 0; c < BIG_TABLE_SIZE; c++) {
err = H5PTget_next(table, (size_t)1, &readPart);
- if(err < 0)
+ if (err < 0)
goto error;
/* Ensure that particles were read correctly */
- if( cmp_par(c % 8, 0, testPart, &readPart) != 0)
+ if (cmp_par(c % 8, 0, testPart, &readPart) != 0)
goto error;
}
/* Close the table */
err = H5PTclose(table);
- if( err < 0)
+ if (err < 0)
goto error;
PASSED();
return SUCCEED;
error:
- H5_FAILED();
- if( H5PTis_valid(table) > 0)
- H5PTclose(table);
- return FAIL;
+ H5_FAILED();
+ if (H5PTis_valid(table) > 0)
+ H5PTclose(table);
+ return FAIL;
}
/*-------------------------------------------------------------------------
@@ -518,63 +505,63 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int test_opaque(hid_t fid)
+static int
+test_opaque(hid_t fid)
{
- herr_t err;
- hid_t table;
- hid_t part_t;
- size_t c;
+ herr_t err;
+ hid_t table;
+ hid_t part_t;
+ size_t c;
particle_t readBuf[NRECORDS];
HL_TESTING2("opaque data");
/* Create an opaque datatype for the particle struct */
- if ((part_t = H5Tcreate (H5T_OPAQUE, sizeof(particle_t) )) < 0 )
+ if ((part_t = H5Tcreate(H5T_OPAQUE, sizeof(particle_t))) < 0)
return FAIL;
HDassert(part_t != -1);
/* Tag the opaque datatype */
- if ( H5Tset_tag(part_t, "Opaque Particle" ) < 0)
+ if (H5Tset_tag(part_t, "Opaque Particle") < 0)
return FAIL;
/* Create a new table */
table = H5PTcreate_fl(fid, "Packet Test Dataset3", part_t, (hsize_t)100, -1);
- if( H5Tclose(part_t) < 0)
+ if (H5Tclose(part_t) < 0)
goto error;
- if( H5PTis_valid(table) < 0)
+ if (H5PTis_valid(table) < 0)
goto error;
/* Append several particles, starting at particle 1 */
err = H5PTappend(table, (size_t)(NRECORDS - 1), &(testPart[1]));
- if( err < 0)
+ if (err < 0)
goto error;
/* Read the particles back */
err = H5PTread_packets(table, (hsize_t)0, 7, &(readBuf[0]));
- if( err < 0)
+ if (err < 0)
goto error;
/* Ensure that particles were read correctly */
- for(c=0; c<NRECORDS - 1; c++)
- {
- if( cmp_par(c+1, c, testPart, readBuf) != 0)
+ for (c = 0; c < NRECORDS - 1; c++) {
+ if (cmp_par(c + 1, c, testPart, readBuf) != 0)
goto error;
}
/* Close the table */
err = H5PTclose(table);
- if( err < 0)
+ if (err < 0)
goto error;
PASSED();
return SUCCEED;
error:
- H5_FAILED();
- if( H5PTis_valid(table) > 0)
- H5PTclose(table);
- return FAIL;
+ H5_FAILED();
+ if (H5PTis_valid(table) > 0)
+ H5PTclose(table);
+ return FAIL;
}
/*-------------------------------------------------------------------------
@@ -588,22 +575,23 @@ error:
static int
test_compress(void)
{
- hid_t fid1 = H5I_INVALID_HID;
- herr_t err;
- hid_t table = H5I_INVALID_HID;
- hid_t part_t = H5I_INVALID_HID;
- hid_t dset_id = H5I_INVALID_HID;
- hid_t plist_id = H5I_INVALID_HID;
- size_t c;
- size_t num_elems = 1;
- unsigned filter_vals[1];
+ hid_t fid1 = H5I_INVALID_HID;
+ herr_t err;
+ hid_t table = H5I_INVALID_HID;
+ hid_t part_t = H5I_INVALID_HID;
+ hid_t dset_id = H5I_INVALID_HID;
+ hid_t plist_id = H5I_INVALID_HID;
+ size_t c;
+ size_t num_elems = 1;
+ unsigned filter_vals[1];
particle_t readPart[1];
- hsize_t count;
+ hsize_t count;
HL_TESTING2("packet table compression");
/* Create a file. */
- if((fid1 = H5Fcreate(TEST_COMPRESS_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
+ if ((fid1 = H5Fcreate(TEST_COMPRESS_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
/* Create a datatype for the particle struct */
part_t = make_particle_type();
@@ -612,106 +600,129 @@ test_compress(void)
/* Create a new table with compression level 8 */
table = H5PTcreate_fl(fid1, "Compressed Test Dataset", part_t, (hsize_t)80, 8);
- if( H5PTis_valid(table) < 0) TEST_ERROR;
+ if (H5PTis_valid(table) < 0)
+ TEST_ERROR;
/* We can now use this table exactly the same way we use a normal uncompressed
* packet table, and it should pass the same tests. */
- /* Add many particles */
- for(c = 0; c < BIG_TABLE_SIZE ; c+=8)
- {
+ /* Add many particles */
+ for (c = 0; c < BIG_TABLE_SIZE; c += 8) {
/* Append eight particles at once*/
err = H5PTappend(table, (size_t)8, &(testPart[0]));
- if( err < 0) TEST_ERROR;
+ if (err < 0)
+ TEST_ERROR;
}
/* Count the number of packets in the table */
err = H5PTget_num_packets(table, &count);
- if( err < 0) TEST_ERROR;
- if( count != BIG_TABLE_SIZE ) TEST_ERROR;
+ if (err < 0)
+ TEST_ERROR;
+ if (count != BIG_TABLE_SIZE)
+ TEST_ERROR;
/* Read particles to ensure that all of them were written correctly */
HDmemset(readPart, 0, sizeof(readPart));
- for(c = 0; c < BIG_TABLE_SIZE; c++)
- {
+ for (c = 0; c < BIG_TABLE_SIZE; c++) {
err = H5PTget_next(table, (size_t)1, readPart);
- if(err < 0) TEST_ERROR;
+ if (err < 0)
+ TEST_ERROR;
/* Ensure that particles were read correctly */
- if( cmp_par(c % 8, 0, testPart, readPart) != 0) TEST_ERROR;
+ if (cmp_par(c % 8, 0, testPart, readPart) != 0)
+ TEST_ERROR;
}
/* Close the table */
err = H5PTclose(table);
- if( err < 0) TEST_ERROR;
+ if (err < 0)
+ TEST_ERROR;
/* Open the packet table as a regular dataset and make sure that the
* compression filter is set.
*/
dset_id = H5Dopen2(fid1, "Compressed Test Dataset", H5P_DEFAULT);
- if( dset_id < 0) TEST_ERROR;
+ if (dset_id < 0)
+ TEST_ERROR;
plist_id = H5Dget_create_plist(dset_id);
- if( plist_id < 0) TEST_ERROR;
+ if (plist_id < 0)
+ TEST_ERROR;
- err = H5Pget_filter_by_id2(plist_id, H5Z_FILTER_DEFLATE, NULL, &num_elems,
- filter_vals, 0, NULL, NULL);
- if( err < 0) TEST_ERROR;
+ err = H5Pget_filter_by_id2(plist_id, H5Z_FILTER_DEFLATE, NULL, &num_elems, filter_vals, 0, NULL, NULL);
+ if (err < 0)
+ TEST_ERROR;
/* The compression level should be 8, the value we passed in */
- if(filter_vals[0] != 8) TEST_ERROR;
+ if (filter_vals[0] != 8)
+ TEST_ERROR;
/* Clean up */
err = H5Pclose(plist_id);
- if( err < 0) TEST_ERROR;
+ if (err < 0)
+ TEST_ERROR;
err = H5Dclose(dset_id);
- if( err < 0) TEST_ERROR;
+ if (err < 0)
+ TEST_ERROR;
/* Create a new table without compression. */
table = H5PTcreate_fl(fid1, "Uncompressed Dataset", part_t, (hsize_t)80, -1);
- if(table < 0) TEST_ERROR;
+ if (table < 0)
+ TEST_ERROR;
/* Close the packet table */
err = H5PTclose(table);
- if( err < 0) TEST_ERROR;
+ if (err < 0)
+ TEST_ERROR;
/* Open the packet table as a regular dataset and make sure that the
* compression filter is not set.
*/
dset_id = H5Dopen2(fid1, "Uncompressed Dataset", H5P_DEFAULT);
- if( dset_id < 0) TEST_ERROR;
+ if (dset_id < 0)
+ TEST_ERROR;
plist_id = H5Dget_create_plist(dset_id);
- if( plist_id < 0) TEST_ERROR;
+ if (plist_id < 0)
+ TEST_ERROR;
- H5E_BEGIN_TRY {
- err = H5Pget_filter_by_id2(plist_id, H5Z_FILTER_DEFLATE, NULL, &num_elems,
- filter_vals, 0, NULL, NULL);
- if( err >= 0) TEST_ERROR;
- } H5E_END_TRY
+ H5E_BEGIN_TRY
+ {
+ err =
+ H5Pget_filter_by_id2(plist_id, H5Z_FILTER_DEFLATE, NULL, &num_elems, filter_vals, 0, NULL, NULL);
+ if (err >= 0)
+ TEST_ERROR;
+ }
+ H5E_END_TRY
/* Clean up */
err = H5Pclose(plist_id);
- if( err < 0) TEST_ERROR;
+ if (err < 0)
+ TEST_ERROR;
err = H5Dclose(dset_id);
- if( err < 0) TEST_ERROR;
+ if (err < 0)
+ TEST_ERROR;
/* Close the datatype and the file */
err = H5Tclose(part_t);
- if( err < 0) TEST_ERROR;
+ if (err < 0)
+ TEST_ERROR;
err = H5Fclose(fid1);
- if( err < 0) TEST_ERROR;
+ if (err < 0)
+ TEST_ERROR;
PASSED();
return SUCCEED;
error:
- H5E_BEGIN_TRY {
- H5Pclose(plist_id);
- H5Dclose(dset_id);
- H5Tclose(part_t);
- H5PTclose(table);
- H5Fclose(fid1);
- } H5E_END_TRY
+ H5E_BEGIN_TRY
+ {
+ H5Pclose(plist_id);
+ H5Dclose(dset_id);
+ H5Tclose(part_t);
+ H5PTclose(table);
+ H5Fclose(fid1);
+ }
+ H5E_END_TRY
H5_FAILED();
return FAIL;
}
@@ -724,83 +735,85 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int test_rw_nonnative_dt(hid_t fid)
+static int
+test_rw_nonnative_dt(hid_t fid)
{
- hid_t ptable; /* Packet table identifier */
+ hid_t ptable; /* Packet table identifier */
- herr_t err; /* Function return status */
- hsize_t count; /* Number of records in the table */
+ herr_t err; /* Function return status */
+ hsize_t count; /* Number of records in the table */
- int x; /* Loop variable */
+ int x; /* Loop variable */
- /* Buffers to hold data */
- int writeBuffer[5];
- int readBuffer[5];
+ /* Buffers to hold data */
+ int writeBuffer[5];
+ int readBuffer[5];
- HL_TESTING2("reading/writing non-native packet table");
+ HL_TESTING2("reading/writing non-native packet table");
- /* Initialize buffers */
- for(x=0; x<5; x++) {
- writeBuffer[x]=x;
- readBuffer[x] = -1;
- }
+ /* Initialize buffers */
+ for (x = 0; x < 5; x++) {
+ writeBuffer[x] = x;
+ readBuffer[x] = -1;
+ }
- /* Create a fixed-length packet table within the file */
- /* This table's "packets" will be simple integers and it will use no compression */
- if(H5Tget_order(H5T_NATIVE_INT) == H5T_ORDER_LE) {
- ptable = H5PTcreate(fid, "Packet Test Dataset, Non-native", H5T_STD_I32BE, (hsize_t)100, H5P_DEFAULT);
- } else {
- ptable = H5PTcreate(fid, "Packet Test Dataset, Non-native", H5T_STD_I32LE, (hsize_t)100, H5P_DEFAULT);
- }
- if(ptable == H5I_INVALID_HID)
+ /* Create a fixed-length packet table within the file */
+ /* This table's "packets" will be simple integers and it will use no compression */
+ if (H5Tget_order(H5T_NATIVE_INT) == H5T_ORDER_LE) {
+ ptable = H5PTcreate(fid, "Packet Test Dataset, Non-native", H5T_STD_I32BE, (hsize_t)100, H5P_DEFAULT);
+ }
+ else {
+ ptable = H5PTcreate(fid, "Packet Test Dataset, Non-native", H5T_STD_I32LE, (hsize_t)100, H5P_DEFAULT);
+ }
+ if (ptable == H5I_INVALID_HID)
goto error;
- /* Write one packet to the packet table */
- if( (err = H5PTappend(ptable, (size_t)1, &(writeBuffer[0]))) < 0 )
+ /* Write one packet to the packet table */
+ if ((err = H5PTappend(ptable, (size_t)1, &(writeBuffer[0]))) < 0)
goto error;
- /* Write several packets to the packet table */
- if( (err = H5PTappend(ptable, (size_t)4, &(writeBuffer[1]))) < 0)
+ /* Write several packets to the packet table */
+ if ((err = H5PTappend(ptable, (size_t)4, &(writeBuffer[1]))) < 0)
goto error;
- if( (err = H5PTclose(ptable)) < 0)
+ if ((err = H5PTclose(ptable)) < 0)
goto error;
- /* Open the Packet table */
- if( (ptable = H5PTopen(fid, "Packet Test Dataset, Non-native")) < 0)
+ /* Open the Packet table */
+ if ((ptable = H5PTopen(fid, "Packet Test Dataset, Non-native")) < 0)
goto error;
- /* Get the number of packets in the packet table. This should be five. */
- if( (err = H5PTget_num_packets(ptable, &count)) < 0)
+ /* Get the number of packets in the packet table. This should be five. */
+ if ((err = H5PTget_num_packets(ptable, &count)) < 0)
goto error;
- if( (int)count != 5 )
+ if ((int)count != 5)
goto error;
- /* Initialize packet table's "current record" */
- if( (err = H5PTcreate_index(ptable)) < 0)
+ /* Initialize packet table's "current record" */
+ if ((err = H5PTcreate_index(ptable)) < 0)
goto error;
- /* Iterate through packets, read each one back */
- for(x=0; x<5; x++) {
- if( (err = H5PTget_next(ptable, (size_t)1, &(readBuffer[x]))) < 0)
- goto error;
- if( x != readBuffer[x])
- goto error;
- }
+ /* Iterate through packets, read each one back */
+ for (x = 0; x < 5; x++) {
+ if ((err = H5PTget_next(ptable, (size_t)1, &(readBuffer[x]))) < 0)
+ goto error;
+ if (x != readBuffer[x])
+ goto error;
+ }
- /* Close the packet table */
- if( (err = H5PTclose(ptable)) < 0)
+ /* Close the packet table */
+ if ((err = H5PTclose(ptable)) < 0)
goto error;
- PASSED();
- return SUCCEED;
+ PASSED();
+ return SUCCEED;
error:
- H5_FAILED();
- if( H5PTis_valid(ptable) > 0)
- H5PTclose(ptable);
- return FAIL;
+ H5_FAILED();
+ if (H5PTis_valid(ptable) > 0)
+ H5PTclose(ptable);
+ return FAIL;
}
/*-------------------------------------------------------------------------
@@ -811,109 +824,110 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int test_error(hid_t fid)
+static int
+test_error(hid_t fid)
{
- hid_t id = H5I_INVALID_HID;
- int id_open=0;
- particle_t readBuf[1];
+ hid_t id = H5I_INVALID_HID;
+ int id_open = 0;
+ particle_t readBuf[1];
- HL_TESTING2("error conditions");
+ HL_TESTING2("error conditions");
- /* Create a HL table */
- if(create_hl_table(fid) < 0)
+ /* Create a HL table */
+ if (create_hl_table(fid) < 0)
goto error;
- /* Try to open things that are not packet tables */
- H5E_BEGIN_TRY
- if(H5PTopen(fid, "Bogus_name") >= 0)
+ /* Try to open things that are not packet tables */
+ H5E_BEGIN_TRY
+ if (H5PTopen(fid, "Bogus_name") >= 0)
goto error;
- if(H5PTopen(fid, "group1") >= 0)
+ if (H5PTopen(fid, "group1") >= 0)
goto error;
- H5E_END_TRY
+ H5E_END_TRY
- /* Try to execute packet table commands on an invalid ID */
- H5E_BEGIN_TRY
- if(H5PTis_valid(id) >= 0)
+ /* Try to execute packet table commands on an invalid ID */
+ H5E_BEGIN_TRY
+ if (H5PTis_valid(id) >= 0)
goto error;
- if(H5PTis_varlen(id) >= 0)
+ if (H5PTis_varlen(id) >= 0)
goto error;
- if(H5PTclose(id) >= 0)
+ if (H5PTclose(id) >= 0)
goto error;
- if(H5PTappend(id, (size_t)1, testPart) >= 0)
+ if (H5PTappend(id, (size_t)1, testPart) >= 0)
goto error;
- if(H5PTread_packets(id, (hsize_t)0, 1, readBuf) >= 0)
+ if (H5PTread_packets(id, (hsize_t)0, 1, readBuf) >= 0)
goto error;
- if(H5PTcreate_index(id) >= 0)
+ if (H5PTcreate_index(id) >= 0)
goto error;
- if(H5PTset_index(id, (hsize_t)1) >= 0)
+ if (H5PTset_index(id, (hsize_t)1) >= 0)
goto error;
- if(H5PTget_index(id, NULL) >= 0)
+ if (H5PTget_index(id, NULL) >= 0)
goto error;
- H5E_END_TRY
+ H5E_END_TRY
- /* Open a high-level non-packet (H5TB) table and try to */
- /* execute commands on it. */
- if((id=H5Dopen2(fid, H5TB_TABLE_NAME, H5P_DEFAULT)) <0)
+ /* Open a high-level non-packet (H5TB) table and try to */
+ /* execute commands on it. */
+ if ((id = H5Dopen2(fid, H5TB_TABLE_NAME, H5P_DEFAULT)) < 0)
goto error;
- id_open = 1;
+ id_open = 1;
- H5E_BEGIN_TRY
- if(H5PTis_valid(id) >= 0)
+ H5E_BEGIN_TRY
+ if (H5PTis_valid(id) >= 0)
goto error;
- if(H5PTis_varlen(id) >= 0)
+ if (H5PTis_varlen(id) >= 0)
goto error;
- if(H5PTclose(id) >= 0)
+ if (H5PTclose(id) >= 0)
goto error;
- if(H5PTappend(id, (size_t)1, testPart) >= 0)
+ if (H5PTappend(id, (size_t)1, testPart) >= 0)
goto error;
- if(H5PTread_packets(id, (hsize_t)0, 1, readBuf) >= 0)
+ if (H5PTread_packets(id, (hsize_t)0, 1, readBuf) >= 0)
goto error;
- if(H5PTcreate_index(id) >= 0)
+ if (H5PTcreate_index(id) >= 0)
goto error;
- if(H5PTset_index(id, (hsize_t)1) >= 0)
+ if (H5PTset_index(id, (hsize_t)1) >= 0)
goto error;
- if(H5PTget_index(id, NULL) >= 0)
+ if (H5PTget_index(id, NULL) >= 0)
goto error;
- H5E_END_TRY
+ H5E_END_TRY
- id_open=0;
- if(H5Dclose(id) <0)
+ id_open = 0;
+ if (H5Dclose(id) < 0)
goto error;
- /* Open and close a packet table. Try to execute */
- /* commands on the closed ID. */
- if((id=H5PTopen(fid, PT_NAME))<0)
+ /* Open and close a packet table. Try to execute */
+ /* commands on the closed ID. */
+ if ((id = H5PTopen(fid, PT_NAME)) < 0)
goto error;
- if(H5PTclose(id) <0)
+ if (H5PTclose(id) < 0)
goto error;
- H5E_BEGIN_TRY
- if(H5PTis_valid(id) >= 0)
+ H5E_BEGIN_TRY
+ if (H5PTis_valid(id) >= 0)
goto error;
- if(H5PTis_varlen(id) >= 0)
+ if (H5PTis_varlen(id) >= 0)
goto error;
- if(H5PTclose(id) >= 0)
+ if (H5PTclose(id) >= 0)
goto error;
- if(H5PTappend(id, (size_t)1, testPart) >= 0)
+ if (H5PTappend(id, (size_t)1, testPart) >= 0)
goto error;
- if(H5PTread_packets(id, (hsize_t)0, 1, readBuf) >= 0)
+ if (H5PTread_packets(id, (hsize_t)0, 1, readBuf) >= 0)
goto error;
- if(H5PTcreate_index(id) >= 0)
+ if (H5PTcreate_index(id) >= 0)
goto error;
- if(H5PTset_index(id, (hsize_t)1) >= 0)
+ if (H5PTset_index(id, (hsize_t)1) >= 0)
goto error;
- if(H5PTget_index(id, NULL) >= 0)
+ if (H5PTget_index(id, NULL) >= 0)
goto error;
- H5E_END_TRY
+ H5E_END_TRY
- PASSED();
- return SUCCEED;
+ PASSED();
+ return SUCCEED;
error:
- H5_FAILED();
- if(id_open)
- H5Dclose(id);
- return FAIL;
+ H5_FAILED();
+ if (id_open)
+ H5Dclose(id);
+ return FAIL;
}
/*-------------------------------------------------------------------------
@@ -923,18 +937,19 @@ error:
*
*-------------------------------------------------------------------------
*/
-static int test_packet_table(hid_t fid)
+static int
+test_packet_table(hid_t fid)
{
- if( test_create_close(fid) < 0 )
+ if (test_create_close(fid) < 0)
return FAIL;
- if( test_open(fid) < 0 )
+ if (test_open(fid) < 0)
return FAIL;
/* test_append must be run before test_count and test_read, as it */
/* creates the packet table they use. */
- if( test_append(fid) < 0 )
+ if (test_append(fid) < 0)
return FAIL;
/* These tests will not necessarily cause failures in each other,
@@ -952,22 +967,23 @@ static int test_packet_table(hid_t fid)
/*
*
-*/
-int main(void)
+ */
+int
+main(void)
{
/* identifier for the file that is used in FL PT tests */
- hid_t fid;
- int status = 0;
+ hid_t fid;
+ int status = 0;
-/*-------------------------------------------------------------------------
- * Packet test: test each function of the packet table library
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * Packet test: test each function of the packet table library
+ *-------------------------------------------------------------------------
+ */
- /* create a file using default properties */
- fid=H5Fcreate(TEST_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ /* create a file using default properties */
+ fid = H5Fcreate(TEST_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- HDputs("Testing packet table");
+ HDputs("Testing packet table");
/* Test packet table with fixed length */
if (test_packet_table(fid) < 0)
@@ -979,7 +995,7 @@ int main(void)
/* Close the file */
if (H5Fclose(fid) < 0)
- status = 1;
+ status = 1;
return status;
}
diff --git a/hl/test/test_packet_vlen.c b/hl/test/test_packet_vlen.c
index b41e73d..d2331d7 100644
--- a/hl/test/test_packet_vlen.c
+++ b/hl/test/test_packet_vlen.c
@@ -18,17 +18,17 @@
*-------------------------------------------------------------------------
*/
-#define NRECORDS 5
-#define TEST_FILE_NAME "test_packet_table_vlen.h5"
+#define NRECORDS 5
+#define TEST_FILE_NAME "test_packet_table_vlen.h5"
#define TESTFL_FILE_NAME "testfl_packet_table_vlen.h5"
-#define PT_VLEN_ATOMIC "Dataset with VL of Atomic types"
-#define PT_VLEN_COMP "Dataset with VL of Compound Types"
-#define PT_COMP_VLEN "Dataset with Compound Type of VL types"
-#define PT_VLEN_VLEN "Dataset with VL of VL types"
-#define PT_FIXED_LEN "Fixed-length Packet Table"
-#define L1_INCM 16
-#define L2_INCM 8
-#define NAME_BUF_SIZE 80
+#define PT_VLEN_ATOMIC "Dataset with VL of Atomic types"
+#define PT_VLEN_COMP "Dataset with VL of Compound Types"
+#define PT_COMP_VLEN "Dataset with Compound Type of VL types"
+#define PT_VLEN_VLEN "Dataset with VL of VL types"
+#define PT_FIXED_LEN "Fixed-length Packet Table"
+#define L1_INCM 16
+#define L2_INCM 8
+#define NAME_BUF_SIZE 80
/*-------------------------------------------------------------------------
* Local functions
@@ -51,17 +51,18 @@ static int verify_attribute(hid_t fid, const char *table_name, const char *attr_
* 2016/01/27 -BMR
*-------------------------------------------------------------------------
*/
-static int test_VLof_atomic(void)
+static int
+test_VLof_atomic(void)
{
- hid_t fid=H5I_INVALID_HID; /* Test file identifier */
- hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */
- hid_t vltype=H5I_INVALID_HID; /* Variable length datatype */
- hsize_t count; /* Number of records in the table */
- unsigned uu, vv; /* Loop variables */
- hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */
- hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */
- char msg[80]; /* For error message */
- herr_t ret; /* Returned status from a callee */
+ hid_t fid = H5I_INVALID_HID; /* Test file identifier */
+ hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */
+ hid_t vltype = H5I_INVALID_HID; /* Variable length datatype */
+ hsize_t count; /* Number of records in the table */
+ unsigned uu, vv; /* Loop variables */
+ hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */
+ hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */
+ char msg[80]; /* For error message */
+ herr_t ret; /* Returned status from a callee */
HL_TESTING3(" with vlen of atomic");
@@ -71,84 +72,86 @@ static int test_VLof_atomic(void)
if (writeBuf[uu].p == NULL) {
HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu);
goto error;
- }
+ }
writeBuf[uu].len = uu + 1;
for (vv = 0; vv < (uu + 1); vv++)
- ((unsigned int *)writeBuf[uu].p)[vv] = uu * 10 + vv;
+ ((unsigned int *)writeBuf[uu].p)[vv] = uu * 10 + vv;
} /* end for */
/* Open the file */
fid = H5Fopen(TEST_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT);
if (fid < 0)
- goto error;
+ goto error;
/* Create a vlen type that uses an atomic datatype as its base type */
- vltype = H5Tvlen_create (H5T_NATIVE_UINT);
+ vltype = H5Tvlen_create(H5T_NATIVE_UINT);
if (vltype < 0)
- goto error;
+ goto error;
/* Create a packet table that uses a vlen datatype of an atomic type */
ptable = H5PTcreate(fid, PT_VLEN_ATOMIC, vltype, (hsize_t)1, H5P_DEFAULT);
/* Ensure that PT is created successfully */
if (ptable == H5I_INVALID_HID)
- goto error;
+ goto error;
/* Close the vlen datatype */
if (H5Tclose(vltype) < 0)
- goto error;
+ goto error;
/* Write the entire buffer to the packet table */
ret = H5PTappend(ptable, (size_t)NRECORDS, writeBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Get the number of packets in the packet table, should be NRECORDS. */
ret = H5PTget_num_packets(ptable, &count);
if (ret < 0)
- goto error;
+ goto error;
HDsprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS);
VERIFY(count == NRECORDS, msg);
/* Read all five packets back */
- ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)NRECORDS, (void*)readBuf );
+ ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)NRECORDS, (void *)readBuf);
if (ret < 0)
- goto error;
+ goto error;
for (uu = 0; uu < NRECORDS; uu++)
- for (vv = 0; vv < (uu + 1); vv++)
- {
- if (((unsigned int *)readBuf[uu].p)[vv] != ((unsigned int *)writeBuf[uu].p)[vv]) {
- HDprintf("Packet %u's value should be %d\n", uu, ((unsigned int *)writeBuf[uu].p)[vv]);
- HDprintf("Packet %u's value in readBuf is %d\n", uu, ((unsigned int *)readBuf[uu].p)[vv]);
- }
+ for (vv = 0; vv < (uu + 1); vv++) {
+ if (((unsigned int *)readBuf[uu].p)[vv] != ((unsigned int *)writeBuf[uu].p)[vv]) {
+ HDprintf("Packet %u's value should be %d\n", uu, ((unsigned int *)writeBuf[uu].p)[vv]);
+ HDprintf("Packet %u's value in readBuf is %d\n", uu, ((unsigned int *)readBuf[uu].p)[vv]);
+ }
}
/* Free the buffers */
- ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf );
+ ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf);
if (ret < 0)
- goto error;
+ goto error;
ret = H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Close the packet table */
ret = H5PTclose(ptable);
if (ret < 0)
- goto error;
+ goto error;
/* Close the file */
if (H5Fclose(fid) < 0)
- goto error;
+ goto error;
PASSED();
return SUCCEED;
error: /* An error has occurred. Clean up and exit. */
- if (vltype > 0) H5Tclose(vltype);
- if (H5PTis_valid(ptable) > 0) H5PTclose(ptable);
- if (fid > 0) H5Fclose(fid);
+ if (vltype > 0)
+ H5Tclose(vltype);
+ if (H5PTis_valid(ptable) > 0)
+ H5PTclose(ptable);
+ if (fid > 0)
+ H5Fclose(fid);
H5PTfree_vlen_buff(ptable, NRECORDS, readBuf);
H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf);
H5_FAILED();
@@ -162,134 +165,142 @@ error: /* An error has occurred. Clean up and exit. */
* 2016/01/27 -BMR
*-------------------------------------------------------------------------
*/
-static int test_VLof_comptype(void)
+static int
+test_VLof_comptype(void)
{
/* Struct that the VL sequences are composed of */
typedef struct {
unsigned u;
- float f;
+ float f;
} VLcomp_t;
- hid_t fid=H5I_INVALID_HID; /* Test file identifier */
- hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */
- hid_t vltype=H5I_INVALID_HID; /* Variable length datatype */
- hid_t cmptype=H5I_INVALID_HID; /* Compound datatype */
- hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */
- hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */
- hsize_t count; /* Number of records in the table */
- unsigned uu, vv; /* Loop variables */
- char msg[80]; /* For error message */
- herr_t ret;
+ hid_t fid = H5I_INVALID_HID; /* Test file identifier */
+ hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */
+ hid_t vltype = H5I_INVALID_HID; /* Variable length datatype */
+ hid_t cmptype = H5I_INVALID_HID; /* Compound datatype */
+ hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */
+ hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */
+ hsize_t count; /* Number of records in the table */
+ unsigned uu, vv; /* Loop variables */
+ char msg[80]; /* For error message */
+ herr_t ret;
HL_TESTING3(" with vlen of compound datatypes");
/* Allocate and initialize VL data to write (copied from C test) */
for (uu = 0; uu < NRECORDS; uu++) {
writeBuf[uu].p = HDmalloc((uu + 1) * sizeof(VLcomp_t));
- if(writeBuf[uu].p == NULL) {
+ if (writeBuf[uu].p == NULL) {
HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu);
goto error;
- }
+ }
writeBuf[uu].len = uu + 1;
for (vv = 0; vv < (uu + 1); vv++) {
((VLcomp_t *)writeBuf[uu].p)[vv].u = uu + vv;
((VLcomp_t *)writeBuf[uu].p)[vv].f = (float)(uu + vv) / 3.0F;
- } /* end for */
- } /* end for */
+ } /* end for */
+ } /* end for */
/* Open the file */
fid = H5Fopen(TEST_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT);
if (fid < 0)
- goto error;
+ goto error;
/* Create the base compound type */
cmptype = H5Tcreate(H5T_COMPOUND, sizeof(VLcomp_t));
if (cmptype < 0)
- goto error;
+ goto error;
/* Insert fields */
ret = H5Tinsert(cmptype, "u", HOFFSET(VLcomp_t, u), H5T_NATIVE_UINT);
if (ret < 0)
- goto error;
+ goto error;
ret = H5Tinsert(cmptype, "f", HOFFSET(VLcomp_t, f), H5T_NATIVE_FLOAT);
if (ret < 0)
- goto error;
+ goto error;
/* Create a variable length type that uses the VLcomp_t as its base type */
vltype = H5Tvlen_create(cmptype);
if (vltype < 0)
- goto error;
+ goto error;
/* Create a packet table that uses a vlen datatype of compound datatype */
ptable = H5PTcreate(fid, PT_VLEN_COMP, vltype, (hsize_t)1, H5P_DEFAULT);
/* Ensure that PT is created successfully */
if (ptable == H5I_INVALID_HID)
- goto error;
+ goto error;
/* Release the datatypes */
if (H5Tclose(cmptype) < 0)
- goto error;
+ goto error;
if (H5Tclose(vltype) < 0)
- goto error;
+ goto error;
/* Write the entire buffer to the packet table */
- ret = H5PTappend(ptable, (size_t)5, writeBuf );
+ ret = H5PTappend(ptable, (size_t)5, writeBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Get the number of packets in the packet table, should be NRECORDS. */
ret = H5PTget_num_packets(ptable, &count);
if (ret < 0)
- goto error;
+ goto error;
HDsprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS);
VERIFY(count == NRECORDS, msg);
/* Read all five packets back */
- ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)5, (void*)readBuf );
+ ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)5, (void *)readBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Compare data read in */
for (uu = 0; uu < NRECORDS; uu++) {
if (writeBuf[uu].len != readBuf[uu].len) {
- HDfprintf(stderr, "%d: VL data length don't match!, writeBuf[%u].len=%d, readBuf[%u].len=%d\n", __LINE__, uu, (int)writeBuf[uu].len, uu, (int)readBuf[uu].len);
- continue;
- } /* write len != read len */
+ HDfprintf(stderr, "%d: VL data length don't match!, writeBuf[%u].len=%d, readBuf[%u].len=%d\n",
+ __LINE__, uu, (int)writeBuf[uu].len, uu, (int)readBuf[uu].len);
+ continue;
+ } /* write len != read len */
for (vv = 0; vv < (uu + 1); vv++) {
- if (((unsigned int *)writeBuf[uu].p)[vv] != ((unsigned int *)readBuf[uu].p)[vv] ) {
- HDfprintf(stderr, "VL data values don't match!, writeBuf[uu].p[%d]=%d, readBuf[uu].p[%d]=%d\n", vv, (int)((unsigned int *)writeBuf[uu].p)[vv], vv, (int)((unsigned int *)readBuf[uu].p)[vv]);
+ if (((unsigned int *)writeBuf[uu].p)[vv] != ((unsigned int *)readBuf[uu].p)[vv]) {
+ HDfprintf(
+ stderr, "VL data values don't match!, writeBuf[uu].p[%d]=%d, readBuf[uu].p[%d]=%d\n", vv,
+ (int)((unsigned int *)writeBuf[uu].p)[vv], vv, (int)((unsigned int *)readBuf[uu].p)[vv]);
continue;
- } /* write value != read value */
- }
+ } /* write value != read value */
+ }
} /* end for */
/* Free the buffers */
ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf);
if (ret < 0)
- goto error;
+ goto error;
ret = H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Close the packet table */
ret = H5PTclose(ptable);
if (ret < 0)
- goto error;
+ goto error;
/* Close the file */
if (H5Fclose(fid) < 0)
- goto error;
+ goto error;
PASSED();
return SUCCEED;
error: /* An error has occurred. Clean up and exit. */
- if (cmptype > 0) H5Tclose(cmptype);
- if (vltype > 0) H5Tclose(vltype);
- if (H5PTis_valid(ptable) > 0) H5PTclose(ptable);
- if (fid > 0) H5Fclose(fid);
+ if (cmptype > 0)
+ H5Tclose(cmptype);
+ if (vltype > 0)
+ H5Tclose(vltype);
+ if (H5PTis_valid(ptable) > 0)
+ H5PTclose(ptable);
+ if (fid > 0)
+ H5Fclose(fid);
H5PTfree_vlen_buff(ptable, NRECORDS, readBuf);
H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf);
H5_FAILED();
@@ -304,47 +315,47 @@ error: /* An error has occurred. Clean up and exit. */
* 2016/01/27 -BMR
*-------------------------------------------------------------------------
*/
-static int test_compound_VL_VLtype(void)
+static int
+test_compound_VL_VLtype(void)
{
/* Struct that the VL sequences are composed of */
typedef struct {
unsigned u;
- float f;
- hvl_t v;
+ float f;
+ hvl_t v;
} compVLVL_t;
- hid_t fid=H5I_INVALID_HID; /* Test file identifier */
- hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */
- hid_t vlatomic=H5I_INVALID_HID; /* Variable length datatype */
- hid_t vlofvl=H5I_INVALID_HID; /* Variable length datatype */
- hid_t comp_vlvl=H5I_INVALID_HID; /* ID of a compound datatype containing
- a VL of VL of atomic datatype */
- hsize_t count; /* Number of records in the table */
- compVLVL_t writeBuf[NRECORDS];/* Buffer to hold data to be written */
- compVLVL_t readBuf[NRECORDS]; /* Buffer to hold read data */
- hvl_t *t1, *t2;
- unsigned uu, vv, ww; /* Loop variables */
- char msg[80]; /* For error message */
- herr_t ret; /* Returned status from a callee */
+ hid_t fid = H5I_INVALID_HID; /* Test file identifier */
+ hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */
+ hid_t vlatomic = H5I_INVALID_HID; /* Variable length datatype */
+ hid_t vlofvl = H5I_INVALID_HID; /* Variable length datatype */
+ hid_t comp_vlvl = H5I_INVALID_HID; /* ID of a compound datatype containing
+ a VL of VL of atomic datatype */
+ hsize_t count; /* Number of records in the table */
+ compVLVL_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */
+ compVLVL_t readBuf[NRECORDS]; /* Buffer to hold read data */
+ hvl_t * t1, *t2;
+ unsigned uu, vv, ww; /* Loop variables */
+ char msg[80]; /* For error message */
+ herr_t ret; /* Returned status from a callee */
HL_TESTING3(" with compound datatype containing vlen datatype");
/* Allocate and initialize VL data to write (copied from C test) */
for (uu = 0; uu < NRECORDS; uu++) {
- writeBuf[uu].u = uu * 10;
- writeBuf[uu].f = (float)(uu * 20) / 3.0F;
+ writeBuf[uu].u = uu * 10;
+ writeBuf[uu].f = (float)(uu * 20) / 3.0F;
writeBuf[uu].v.p = HDmalloc((uu + L1_INCM) * sizeof(hvl_t));
if (writeBuf[uu].v.p == NULL) {
HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu);
goto error;
- }
+ }
writeBuf[uu].v.len = uu + L1_INCM;
- for (t1 = (hvl_t *)((writeBuf[uu].v).p), vv = 0; vv < (uu + L1_INCM); vv++, t1++)
- {
+ for (t1 = (hvl_t *)((writeBuf[uu].v).p), vv = 0; vv < (uu + L1_INCM); vv++, t1++) {
t1->p = HDmalloc((vv + L2_INCM) * sizeof(unsigned int));
- if (t1->p == NULL) {
- HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu);
- goto error;
- }
+ if (t1->p == NULL) {
+ HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu);
+ goto error;
+ }
t1->len = vv + L2_INCM;
for (ww = 0; ww < vv + L2_INCM; ww++)
((unsigned int *)t1->p)[ww] = uu * 100 + vv * 10 + ww;
@@ -354,123 +365,135 @@ static int test_compound_VL_VLtype(void)
/* Open the file */
fid = H5Fopen(TEST_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT);
if (fid < 0)
- goto error;
+ goto error;
/* Create a VL datatype of an atomic type */
- vlatomic = H5Tvlen_create (H5T_NATIVE_UINT);
+ vlatomic = H5Tvlen_create(H5T_NATIVE_UINT);
if (vlatomic < 0)
- goto error;
+ goto error;
/* Create a VL datatype of the VL of atomic datatype */
- vlofvl = H5Tvlen_create (vlatomic);
+ vlofvl = H5Tvlen_create(vlatomic);
if (vlofvl < 0)
- goto error;
+ goto error;
/* Create the base compound type */
comp_vlvl = H5Tcreate(H5T_COMPOUND, sizeof(compVLVL_t));
if (comp_vlvl < 0)
- goto error;
+ goto error;
/* Insert fields: atomic, atomic, vlen */
ret = H5Tinsert(comp_vlvl, "u", HOFFSET(compVLVL_t, u), H5T_NATIVE_UINT);
if (ret < 0)
- goto error;
+ goto error;
ret = H5Tinsert(comp_vlvl, "f", HOFFSET(compVLVL_t, f), H5T_NATIVE_FLOAT);
if (ret < 0)
- goto error;
+ goto error;
ret = H5Tinsert(comp_vlvl, "v", HOFFSET(compVLVL_t, v), vlofvl);
if (ret < 0)
- goto error;
+ goto error;
/* Create a packet table that uses a compound datatype of vlen datatype */
ptable = H5PTcreate(fid, PT_COMP_VLEN, comp_vlvl, (hsize_t)1, H5P_DEFAULT);
/* Ensure that PT is created successfully */
if (ptable == H5I_INVALID_HID)
- goto error;
+ goto error;
/* Release datatypes */
if (H5Tclose(vlatomic) < 0)
- goto error;
+ goto error;
if (H5Tclose(vlofvl) < 0)
- goto error;
+ goto error;
if (H5Tclose(comp_vlvl) < 0)
- goto error;
+ goto error;
/* Write the entire buffer to the packet table */
- ret = H5PTappend(ptable, (size_t)NRECORDS, writeBuf );
+ ret = H5PTappend(ptable, (size_t)NRECORDS, writeBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Get the number of packets in the packet table, should be NRECORDS. */
ret = H5PTget_num_packets(ptable, &count);
if (ret < 0)
- goto error;
+ goto error;
HDsprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS);
VERIFY(count == NRECORDS, msg);
/* Read all five packets back */
- ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)NRECORDS, (void*)readBuf );
+ ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)NRECORDS, (void *)readBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Compare data read in */
for (uu = 0; uu < NRECORDS; uu++) {
if (writeBuf[uu].u != readBuf[uu].u) {
- HDfprintf(stderr, "Integer components don't match!, writeBuf[%u].u=%u, readBuf[%u].u=%u\n", uu, writeBuf[uu].u, uu, readBuf[uu].u);
+ HDfprintf(stderr, "Integer components don't match!, writeBuf[%u].u=%u, readBuf[%u].u=%u\n", uu,
+ writeBuf[uu].u, uu, readBuf[uu].u);
continue;
} /* end if */
- if (!H5_FLT_ABS_EQUAL(writeBuf[uu].f,readBuf[uu].f)) {
- HDfprintf(stderr, "Float components don't match!, writeBuf[%u].f=%f, readBuf[%u].f=%f\n", uu, (double)writeBuf[uu].f, uu, (double)readBuf[uu].f);
+ if (!H5_FLT_ABS_EQUAL(writeBuf[uu].f, readBuf[uu].f)) {
+ HDfprintf(stderr, "Float components don't match!, writeBuf[%u].f=%f, readBuf[%u].f=%f\n", uu,
+ (double)writeBuf[uu].f, uu, (double)readBuf[uu].f);
continue;
} /* end if */
if (writeBuf[uu].v.len != readBuf[uu].v.len) {
- HDfprintf(stderr, "%d: VL data length don't match!, writeBuf[%d].v.len=%zu, readBuf[%d].v.len=%zu\n", __LINE__, uu, writeBuf[uu].v.len, uu, readBuf[uu].v.len);
+ HDfprintf(stderr,
+ "%d: VL data length don't match!, writeBuf[%d].v.len=%zu, readBuf[%d].v.len=%zu\n",
+ __LINE__, uu, writeBuf[uu].v.len, uu, readBuf[uu].v.len);
continue;
} /* end if */
- for (t1 = (hvl_t *)(writeBuf[uu].v.p), t2 = (hvl_t *)(readBuf[uu].v.p), vv = 0; (size_t)vv < readBuf[uu].v.len; vv++, t1++, t2++) {
+ for (t1 = (hvl_t *)(writeBuf[uu].v.p), t2 = (hvl_t *)(readBuf[uu].v.p), vv = 0;
+ (size_t)vv < readBuf[uu].v.len; vv++, t1++, t2++) {
if (t1->len != t2->len) {
- HDfprintf(stderr, "%d: VL data length don't match!, uu=%u, vv=%u, t1->len=%zu, t2->len=%zu\n", __LINE__, uu, vv, t1->len, t2->len);
+ HDfprintf(stderr, "%d: VL data length don't match!, uu=%u, vv=%u, t1->len=%zu, t2->len=%zu\n",
+ __LINE__, uu, vv, t1->len, t2->len);
continue;
} /* end if */
for (ww = 0; (size_t)ww < t2->len; ww++) {
- if (((unsigned int *)t1->p)[ww] != ((unsigned int *)t2->p)[ww] ) {
- HDfprintf(stderr, "VL data values don't match!, t1->p[%u]=%u, t2->p[%u]=%u\n", ww, ((unsigned int *)t1->p)[ww], ww, ((unsigned int *)t2->p)[ww]);
+ if (((unsigned int *)t1->p)[ww] != ((unsigned int *)t2->p)[ww]) {
+ HDfprintf(stderr, "VL data values don't match!, t1->p[%u]=%u, t2->p[%u]=%u\n", ww,
+ ((unsigned int *)t1->p)[ww], ww, ((unsigned int *)t2->p)[ww]);
continue;
} /* end if */
- } /* end for */
- } /* end for */
- } /* end for */
+ } /* end for */
+ } /* end for */
+ } /* end for */
/* Free the buffers */
ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf);
if (ret < 0)
- goto error;
+ goto error;
ret = H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Close the packet table */
ret = H5PTclose(ptable);
if (ret < 0)
- goto error;
+ goto error;
/* Close the file */
if (H5Fclose(fid) < 0)
- goto error;
+ goto error;
PASSED();
return SUCCEED;
error: /* An error has occurred. Clean up and exit. */
- if (vlatomic > 0) H5Tclose(vlatomic);
- if (vlofvl > 0) H5Tclose(vlofvl);
- if (comp_vlvl > 0) H5Tclose(comp_vlvl);
- if (H5PTis_valid(ptable) > 0) H5PTclose(ptable);
- if (fid > 0) H5Fclose(fid);
+ if (vlatomic > 0)
+ H5Tclose(vlatomic);
+ if (vlofvl > 0)
+ H5Tclose(vlofvl);
+ if (comp_vlvl > 0)
+ H5Tclose(comp_vlvl);
+ if (H5PTis_valid(ptable) > 0)
+ H5PTclose(ptable);
+ if (fid > 0)
+ H5Fclose(fid);
H5PTfree_vlen_buff(ptable, NRECORDS, readBuf);
H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf);
H5_FAILED();
@@ -485,19 +508,20 @@ error: /* An error has occurred. Clean up and exit. */
* 2016/01/27 -BMR
*-------------------------------------------------------------------------
*/
-static int test_VLof_VLtype(void)
+static int
+test_VLof_VLtype(void)
{
- hid_t fid=H5I_INVALID_HID; /* Test file identifier */
- hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */
- hid_t vlatomic=H5I_INVALID_HID; /* Variable length datatype */
- hid_t vlofvl=H5I_INVALID_HID; /* VL datatype of VL datatypes */
- hsize_t count; /* Number of records in the table */
- hvl_t *t1; /* pointer to advance */
- unsigned uu, vv, ww; /* Loop variables */
- hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */
- hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */
- char msg[80]; /* For error message */
- herr_t ret; /* Returned status from a callee */
+ hid_t fid = H5I_INVALID_HID; /* Test file identifier */
+ hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */
+ hid_t vlatomic = H5I_INVALID_HID; /* Variable length datatype */
+ hid_t vlofvl = H5I_INVALID_HID; /* VL datatype of VL datatypes */
+ hsize_t count; /* Number of records in the table */
+ hvl_t * t1; /* pointer to advance */
+ unsigned uu, vv, ww; /* Loop variables */
+ hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */
+ hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */
+ char msg[80]; /* For error message */
+ herr_t ret; /* Returned status from a callee */
HL_TESTING3(" with vlen datatype of vlen datatype");
@@ -509,89 +533,92 @@ static int test_VLof_VLtype(void)
goto error;
} /* end if */
writeBuf[uu].len = uu + 1;
- for (t1=(hvl_t *)(writeBuf[uu].p), vv = 0; vv < (uu + 1); vv++, t1++)
- {
+ for (t1 = (hvl_t *)(writeBuf[uu].p), vv = 0; vv < (uu + 1); vv++, t1++) {
t1->p = HDmalloc((vv + 1) * sizeof(unsigned int));
- if (t1->p == NULL) {
- HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu);
- goto error;
- }
+ if (t1->p == NULL) {
+ HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu);
+ goto error;
+ }
t1->len = vv * 1;
for (ww = 0; ww < (vv * 1); ww++)
((unsigned int *)t1->p)[ww] = uu * 100 + vv * 10 + ww;
} /* end for */
- } /* end for */
+ } /* end for */
/* Open the file */
fid = H5Fopen(TEST_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT);
if (fid < 0)
- goto error;
+ goto error;
/* Create a VL datatype of an atomic type */
- vlatomic = H5Tvlen_create (H5T_NATIVE_UINT);
+ vlatomic = H5Tvlen_create(H5T_NATIVE_UINT);
if (vlatomic < 0)
- goto error;
+ goto error;
- vlofvl = H5Tvlen_create (vlatomic);
+ vlofvl = H5Tvlen_create(vlatomic);
if (vlofvl < 0)
- goto error;
+ goto error;
/* Create a packet table that uses a vlen datatype of vlen datatype */
ptable = H5PTcreate(fid, PT_VLEN_VLEN, vlofvl, (hsize_t)1, H5P_DEFAULT);
/* Ensure that PT is created successfully */
if (ptable == H5I_INVALID_HID)
- goto error;
+ goto error;
/* Release datatypes */
if (H5Tclose(vlatomic) < 0)
- goto error;
+ goto error;
if (H5Tclose(vlofvl) < 0)
- goto error;
+ goto error;
/* Write the entire buffer to the packet table */
- ret = H5PTappend(ptable, (size_t)5, writeBuf );
+ ret = H5PTappend(ptable, (size_t)5, writeBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Get the number of packets in the packet table, should be NRECORDS. */
ret = H5PTget_num_packets(ptable, &count);
if (ret < 0)
- goto error;
+ goto error;
HDsprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS);
VERIFY(count == NRECORDS, msg);
/* Read all five packets back */
- ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)5, (void*)readBuf );
+ ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)5, (void *)readBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Free the buffers */
ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf);
if (ret < 0)
- goto error;
+ goto error;
ret = H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Close the packet table */
ret = H5PTclose(ptable);
if (ret < 0)
- goto error;
+ goto error;
/* Close the file */
if (H5Fclose(fid) < 0)
- goto error;
+ goto error;
PASSED();
return SUCCEED;
error: /* An error has occurred. Clean up and exit. */
- if (vlatomic > 0) H5Tclose(vlatomic);
- if (vlofvl > 0) H5Tclose(vlofvl);
- if (H5PTis_valid(ptable) > 0) H5PTclose(ptable);
- if (fid > 0) H5Fclose(fid);
+ if (vlatomic > 0)
+ H5Tclose(vlatomic);
+ if (vlofvl > 0)
+ H5Tclose(vlofvl);
+ if (H5PTis_valid(ptable) > 0)
+ H5PTclose(ptable);
+ if (fid > 0)
+ H5Fclose(fid);
H5PTfree_vlen_buff(ptable, NRECORDS, readBuf);
H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf);
H5_FAILED();
@@ -606,40 +633,41 @@ error: /* An error has occurred. Clean up and exit. */
* 2016/01/27 -BMR
*-------------------------------------------------------------------------
*/
-static int verify_ptlengthtype(hid_t fid, const char *table_name, herr_t expected_value)
+static int
+verify_ptlengthtype(hid_t fid, const char *table_name, herr_t expected_value)
{
- hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */
- herr_t is_varlen = 0;
- herr_t ret = FAIL;
+ hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */
+ herr_t is_varlen = 0;
+ herr_t ret = FAIL;
/* Open the named packet table */
- if( (ptable = H5PTopen(fid, table_name)) < 0)
- goto error;
+ if ((ptable = H5PTopen(fid, table_name)) < 0)
+ goto error;
/* Verify the value returned from H5PTis_varlen is as expected */
is_varlen = H5PTis_varlen(ptable);
if (is_varlen == FAIL)
- goto error;
+ goto error;
else if (is_varlen == expected_value)
- ret = SUCCEED;
- else
- {
- char lenthtype[20];
- HDstrcpy(lenthtype, "fixed-length");
- if (expected_value == 1)
- HDstrcpy(lenthtype, "variable-length");
- HDfprintf(stderr, "\nPacket table '%s' should be %s but is not\n", table_name, lenthtype);
- ret = FAIL;
+ ret = SUCCEED;
+ else {
+ char lenthtype[20];
+ HDstrcpy(lenthtype, "fixed-length");
+ if (expected_value == 1)
+ HDstrcpy(lenthtype, "variable-length");
+ HDfprintf(stderr, "\nPacket table '%s' should be %s but is not\n", table_name, lenthtype);
+ ret = FAIL;
}
/* Close the packet table */
if (H5PTclose(ptable) < 0)
- goto error;
+ goto error;
return ret;
error: /* An error has occurred. Clean up and exit. */
- if (H5PTis_valid(ptable) > 0) H5PTclose(ptable);
+ if (H5PTis_valid(ptable) > 0)
+ H5PTclose(ptable);
return ret;
} /* verify_ptlengthtype */
@@ -655,67 +683,69 @@ error: /* An error has occurred. Clean up and exit. */
* 2016/01/27 -BMR
*-------------------------------------------------------------------------
*/
-static int test_H5PTis_varlen(void)
+static int
+test_H5PTis_varlen(void)
{
- hid_t fid=H5I_INVALID_HID; /* Test file identifier */
- hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */
- herr_t ret; /* Returned status from a callee */
+ hid_t fid = H5I_INVALID_HID; /* Test file identifier */
+ hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */
+ herr_t ret; /* Returned status from a callee */
HL_TESTING2("H5PTis_varlen");
/* Open the file */
fid = H5Fopen(TEST_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT);
if (fid < 0)
- goto error;
+ goto error;
/* Create a new table */
ptable = H5PTcreate(fid, PT_FIXED_LEN, H5T_STD_I32BE, (hsize_t)100, H5P_DEFAULT);
/* Ensure that PT is created successfully */
if (ptable == H5I_INVALID_HID)
- goto error;
+ goto error;
/* Close the packet table */
ret = H5PTclose(ptable);
if (ret < 0)
- goto error;
+ goto error;
/* Close the file */
if (H5Fclose(fid) < 0)
- goto error;
+ goto error;
/* Open the file */
fid = H5Fopen(TEST_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT);
if (fid < 0)
- goto error;
+ goto error;
/* Open each packet table, and verify that H5PTis_varlen returns correct
type for each table */
ret = verify_ptlengthtype(fid, PT_VLEN_ATOMIC, 1); /* vlen of atomic */
if (ret < 0)
- goto error;
+ goto error;
ret = verify_ptlengthtype(fid, PT_VLEN_COMP, 1); /* vlen of compound */
if (ret < 0)
- goto error;
+ goto error;
ret = verify_ptlengthtype(fid, PT_COMP_VLEN, 0); /* compound of vlen, no vlen */
if (ret < 0)
- goto error;
+ goto error;
ret = verify_ptlengthtype(fid, PT_VLEN_VLEN, 1); /* vlen of vlen */
if (ret < 0)
- goto error;
+ goto error;
ret = verify_ptlengthtype(fid, PT_FIXED_LEN, 0); /* no vlen */
if (ret < 0)
- goto error;
+ goto error;
/* Close the file */
if (H5Fclose(fid) < 0)
- goto error;
+ goto error;
PASSED();
return SUCCEED;
error: /* An error has occurred. Clean up and exit. */
- if (fid > 0) H5Fclose(fid);
+ if (fid > 0)
+ H5Fclose(fid);
H5_FAILED();
return FAIL;
} /* test_H5PTis_varlen */
@@ -731,60 +761,64 @@ error: /* An error has occurred. Clean up and exit. */
* 2016/01/27 -BMR
*-------------------------------------------------------------------------
*/
-#define ATTR_RANK 1
-#define ATTR_DIM 3
-int attr_data[ATTR_DIM]={256,11945,-22107}; /* values to be written to attr */
+#define ATTR_RANK 1
+#define ATTR_DIM 3
+int attr_data[ATTR_DIM] = {256, 11945, -22107}; /* values to be written to attr */
-static int adding_attribute(hid_t fid, const char *table_name, const char *attr_name)
+static int
+adding_attribute(hid_t fid, const char *table_name, const char *attr_name)
{
- hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */
- hid_t space_id = H5I_INVALID_HID; /* Dataspace for the attribute */
- hid_t attr_id = H5I_INVALID_HID; /* Attribute identifier */
- hid_t dset_id = H5I_INVALID_HID; /* Dataset identifier */
- hsize_t dims[] = {ATTR_DIM}; /* Dimension for dataspace */
- int ret = FAIL; /* Returned status from a callee */
+ hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */
+ hid_t space_id = H5I_INVALID_HID; /* Dataspace for the attribute */
+ hid_t attr_id = H5I_INVALID_HID; /* Attribute identifier */
+ hid_t dset_id = H5I_INVALID_HID; /* Dataset identifier */
+ hsize_t dims[] = {ATTR_DIM}; /* Dimension for dataspace */
+ int ret = FAIL; /* Returned status from a callee */
/* Create dataspace for attribute */
space_id = H5Screate_simple(ATTR_RANK, dims, NULL);
if (space_id < 0)
- goto error;
+ goto error;
/* Open the named packet table */
- if( (ptable = H5PTopen(fid, table_name)) < 0)
- goto error;
+ if ((ptable = H5PTopen(fid, table_name)) < 0)
+ goto error;
dset_id = H5PTget_dataset(ptable);
if (dset_id < 0)
- goto error;
+ goto error;
/* Add the specified attribute to it */
attr_id = H5Acreate2(dset_id, attr_name, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT);
if (attr_id < 0)
- goto error;
+ goto error;
/* Write attribute values */
ret = H5Awrite(attr_id, H5T_NATIVE_INT, attr_data);
if (ret < 0)
- goto error;
+ goto error;
/* Close the attribute */
if (H5Aclose(attr_id) < 0)
- goto error;
+ goto error;
/* Close the dataspace */
if (H5Sclose(space_id) < 0)
- goto error;
+ goto error;
/* Close the packet table */
if (H5PTclose(ptable) < 0)
- goto error;
+ goto error;
return SUCCEED;
error: /* An error has occurred. Clean up and exit. */
- if (attr_id > 0) H5Aclose(attr_id);
- if (space_id > 0) H5Sclose(space_id);
- if (H5PTis_valid(ptable) > 0) H5PTclose(ptable);
+ if (attr_id > 0)
+ H5Aclose(attr_id);
+ if (space_id > 0)
+ H5Sclose(space_id);
+ if (H5PTis_valid(ptable) > 0)
+ H5PTclose(ptable);
return ret;
} /* adding_attribute */
@@ -795,53 +829,57 @@ error: /* An error has occurred. Clean up and exit. */
* 2016/01/27 -BMR
*-------------------------------------------------------------------------
*/
-static herr_t verify_attribute(hid_t fid, const char *table_name, const char *attr_name)
+static herr_t
+verify_attribute(hid_t fid, const char *table_name, const char *attr_name)
{
- hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */
- hid_t attr_id=H5I_INVALID_HID; /* Attribute identifier */
- hid_t dset_id=H5I_INVALID_HID; /* Dataset associated with the pt */
- int read_data[ATTR_DIM]; /* Output buffer */
- int ii;
- herr_t ret = FAIL; /* Returned status from a callee */
+ hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */
+ hid_t attr_id = H5I_INVALID_HID; /* Attribute identifier */
+ hid_t dset_id = H5I_INVALID_HID; /* Dataset associated with the pt */
+ int read_data[ATTR_DIM]; /* Output buffer */
+ int ii;
+ herr_t ret = FAIL; /* Returned status from a callee */
/* Open the named packet table */
ptable = H5PTopen(fid, table_name);
if (ptable < 0)
- goto error;
+ goto error;
/* Get the dataset id of this packet table */
dset_id = H5PTget_dataset(ptable);
if (dset_id < 0)
- goto error;
+ goto error;
/* Open first attribute for the dataset */
attr_id = H5Aopen(dset_id, attr_name, H5P_DEFAULT);
if (attr_id < 0)
- goto error;
+ goto error;
/* Read attribute values */
ret = H5Aread(attr_id, H5T_NATIVE_INT, read_data);
if (ret < 0)
- goto error;
+ goto error;
/* Verify values read in */
for (ii = 0; ii < ATTR_DIM; ii++)
if (attr_data[ii] != read_data[ii])
- TestErrPrintf("%d: attribute data different: attr_data[%d]=%d, read_data[%d]=%d\n", __LINE__, ii, attr_data[ii], ii, read_data[ii]);
+ TestErrPrintf("%d: attribute data different: attr_data[%d]=%d, read_data[%d]=%d\n", __LINE__, ii,
+ attr_data[ii], ii, read_data[ii]);
/* Close the attribute */
if (H5Aclose(attr_id) < 0)
- goto error;
+ goto error;
/* Close the packet table */
if (H5PTclose(ptable) < 0)
- goto error;
+ goto error;
return SUCCEED;
error: /* An error has occurred. Clean up and exit. */
- if (attr_id > 0) H5Aclose(attr_id);
- if (H5PTis_valid(ptable) > 0) H5PTclose(ptable);
+ if (attr_id > 0)
+ H5Aclose(attr_id);
+ if (H5PTis_valid(ptable) > 0)
+ H5PTclose(ptable);
return ret;
} /* verify_attribute */
@@ -854,59 +892,61 @@ error: /* An error has occurred. Clean up and exit. */
* 2016/01/27 -BMR
*-------------------------------------------------------------------------
*/
-static int test_attributes(void)
+static int
+test_attributes(void)
{
- hid_t fid=H5I_INVALID_HID; /* File identifier */
- hid_t attr_id=H5I_INVALID_HID; /* Attribute identifier */
- herr_t ret = FAIL; /* Returned status from a callee */
+ hid_t fid = H5I_INVALID_HID; /* File identifier */
+ hid_t attr_id = H5I_INVALID_HID; /* Attribute identifier */
+ herr_t ret = FAIL; /* Returned status from a callee */
HL_TESTING2("adding attributes to packet tables");
/* Open the file */
fid = H5Fopen(TEST_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT);
if (fid < 0)
- goto error;
+ goto error;
/* Add an arbitrary attribute to a few packet tables, using helper func */
attr_id = adding_attribute(fid, PT_VLEN_ATOMIC, "Attribute 1");
if (attr_id < 0)
- goto error;
+ goto error;
attr_id = adding_attribute(fid, PT_VLEN_COMP, "Attribute 2");
if (attr_id < 0)
- goto error;
+ goto error;
attr_id = adding_attribute(fid, PT_COMP_VLEN, "Attribute 3");
if (attr_id < 0)
- goto error;
+ goto error;
/* Close the file */
if (H5Fclose(fid) < 0)
- goto error;
+ goto error;
/* Open the file again */
fid = H5Fopen(TEST_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT);
if (fid < 0)
- goto error;
+ goto error;
/* Read each attribute and verify the values, using helper function */
ret = verify_attribute(fid, PT_VLEN_ATOMIC, "Attribute 1");
if (ret < 0)
- goto error;
+ goto error;
ret = verify_attribute(fid, PT_VLEN_COMP, "Attribute 2");
if (ret < 0)
- goto error;
+ goto error;
ret = verify_attribute(fid, PT_COMP_VLEN, "Attribute 3");
if (ret < 0)
- goto error;
+ goto error;
/* Close the file */
if (H5Fclose(fid) < 0)
- goto error;
+ goto error;
PASSED();
- return(ret);
+ return (ret);
error: /* An error has occurred. Clean up and exit. */
- if (fid > 0) H5Fclose(fid);
+ if (fid > 0)
+ H5Fclose(fid);
H5_FAILED();
return FAIL;
} /* test_attributes */
@@ -928,35 +968,36 @@ error: /* An error has occurred. Clean up and exit. */
* 2016/01/27 -BMR
*-------------------------------------------------------------------------
*/
-static herr_t verify_accessors(hid_t fid, const char *table_name, hbool_t uses_vlen_type)
+static herr_t
+verify_accessors(hid_t fid, const char *table_name, hbool_t uses_vlen_type)
{
- hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */
- hid_t dset_id = H5I_INVALID_HID; /* Dataset associated with the pt */
- hid_t dtype_id = H5I_INVALID_HID; /* Dataset identifier */
- char buf[NAME_BUF_SIZE];
+ hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */
+ hid_t dset_id = H5I_INVALID_HID; /* Dataset associated with the pt */
+ hid_t dtype_id = H5I_INVALID_HID; /* Dataset identifier */
+ char buf[NAME_BUF_SIZE];
ssize_t name_size;
- htri_t vlen_check_result = -1;
+ htri_t vlen_check_result = -1;
/* Open the named packet table. */
- if((ptable = H5PTopen(fid, table_name)) < 0)
+ if ((ptable = H5PTopen(fid, table_name)) < 0)
goto error;
/* Get the associated dataset ID. */
- if((dset_id = H5PTget_dataset(ptable)) < 0)
+ if ((dset_id = H5PTget_dataset(ptable)) < 0)
goto error;
/* Check if the packet table's name matches its associated dataset's. */
*buf = '\0';
- if((name_size = H5Iget_name(dset_id, (char*)buf, NAME_BUF_SIZE)) < 0)
+ if ((name_size = H5Iget_name(dset_id, (char *)buf, NAME_BUF_SIZE)) < 0)
goto error;
VERIFY(HDstrcmp(buf, table_name), "Names of dataset and packet table don't match");
/* Get the packet table's datatype ID */
- if((dtype_id = H5PTget_type(ptable)) < 0)
+ if ((dtype_id = H5PTget_type(ptable)) < 0)
goto error;
/* Check if the type class matches that of the packet table. */
- if((vlen_check_result = H5Tdetect_class(dtype_id, H5T_VLEN)) < 0)
+ if ((vlen_check_result = H5Tdetect_class(dtype_id, H5T_VLEN)) < 0)
goto error;
/* Check if length types match */
@@ -996,10 +1037,11 @@ error: /* An error has occurred. Clean up and exit. */
* 2016/01/27 -BMR
*-------------------------------------------------------------------------
*/
-static int test_accessors(void)
+static int
+test_accessors(void)
{
- hid_t fid=H5I_INVALID_HID; /* File identifier */
- herr_t ret = FAIL; /* Returned status from a callee */
+ hid_t fid = H5I_INVALID_HID; /* File identifier */
+ herr_t ret = FAIL; /* Returned status from a callee */
HL_TESTING2("accessor functions");
@@ -1044,17 +1086,18 @@ error: /* An error has occurred. Clean up and exit. */
* 2016/01/27 -BMR
*-------------------------------------------------------------------------
*/
-static int testfl_VLof_atomic(void)
+static int
+testfl_VLof_atomic(void)
{
- hid_t fid=H5I_INVALID_HID; /* Test file identifier */
- hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */
- hid_t vltype=H5I_INVALID_HID; /* Variable length datatype */
- hsize_t count; /* Number of records in the table */
- unsigned uu, vv; /* Loop variables */
- hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */
- hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */
- char msg[80]; /* For error message */
- herr_t ret; /* Returned status from a callee */
+ hid_t fid = H5I_INVALID_HID; /* Test file identifier */
+ hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */
+ hid_t vltype = H5I_INVALID_HID; /* Variable length datatype */
+ hsize_t count; /* Number of records in the table */
+ unsigned uu, vv; /* Loop variables */
+ hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */
+ hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */
+ char msg[80]; /* For error message */
+ herr_t ret; /* Returned status from a callee */
HL_TESTING3(" with vlen of atomic");
@@ -1064,84 +1107,86 @@ static int testfl_VLof_atomic(void)
if (writeBuf[uu].p == NULL) {
HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu);
goto error;
- }
+ }
writeBuf[uu].len = uu + 1;
for (vv = 0; vv < (uu + 1); vv++)
- ((unsigned int *)writeBuf[uu].p)[vv] = uu * 10 + vv;
+ ((unsigned int *)writeBuf[uu].p)[vv] = uu * 10 + vv;
} /* end for */
/* Open the file */
fid = H5Fopen(TESTFL_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT);
if (fid < 0)
- goto error;
+ goto error;
/* Create a vlen type that uses an atomic datatype as its base type */
- vltype = H5Tvlen_create (H5T_NATIVE_UINT);
+ vltype = H5Tvlen_create(H5T_NATIVE_UINT);
if (vltype < 0)
- goto error;
+ goto error;
/* Create a packet table that uses a vlen datatype of an atomic type */
ptable = H5PTcreate_fl(fid, PT_VLEN_ATOMIC, vltype, (hsize_t)1, 0);
/* Ensure that PT is created successfully */
if (ptable == H5I_INVALID_HID)
- goto error;
+ goto error;
/* Close the vlen datatype */
if (H5Tclose(vltype) < 0)
- goto error;
+ goto error;
/* Write the entire buffer to the packet table */
ret = H5PTappend(ptable, (size_t)NRECORDS, writeBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Get the number of packets in the packet table, should be NRECORDS. */
ret = H5PTget_num_packets(ptable, &count);
if (ret < 0)
- goto error;
+ goto error;
HDsprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS);
VERIFY(count == NRECORDS, msg);
/* Read all five packets back */
- ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)NRECORDS, (void*)readBuf );
+ ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)NRECORDS, (void *)readBuf);
if (ret < 0)
- goto error;
+ goto error;
for (uu = 0; uu < NRECORDS; uu++)
- for (vv = 0; vv < (uu + 1); vv++)
- {
- if (((unsigned int *)readBuf[uu].p)[vv] != ((unsigned int *)writeBuf[uu].p)[vv]) {
- HDprintf("Packet %d's value should be %d\n", uu, ((unsigned int *)writeBuf[uu].p)[vv]);
- HDprintf("Packet %d's value in readBuf is %d\n", uu, ((unsigned int *)readBuf[uu].p)[vv]);
- }
+ for (vv = 0; vv < (uu + 1); vv++) {
+ if (((unsigned int *)readBuf[uu].p)[vv] != ((unsigned int *)writeBuf[uu].p)[vv]) {
+ HDprintf("Packet %d's value should be %d\n", uu, ((unsigned int *)writeBuf[uu].p)[vv]);
+ HDprintf("Packet %d's value in readBuf is %d\n", uu, ((unsigned int *)readBuf[uu].p)[vv]);
+ }
}
/* Free the buffers */
- ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf );
+ ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf);
if (ret < 0)
- goto error;
+ goto error;
ret = H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Close the packet table */
ret = H5PTclose(ptable);
if (ret < 0)
- goto error;
+ goto error;
/* Close the file */
if (H5Fclose(fid) < 0)
- goto error;
+ goto error;
PASSED();
return SUCCEED;
error: /* An error has occurred. Clean up and exit. */
- if (vltype > 0) H5Tclose(vltype);
- if (H5PTis_valid(ptable) > 0) H5PTclose(ptable);
- if (fid > 0) H5Fclose(fid);
+ if (vltype > 0)
+ H5Tclose(vltype);
+ if (H5PTis_valid(ptable) > 0)
+ H5PTclose(ptable);
+ if (fid > 0)
+ H5Fclose(fid);
H5PTfree_vlen_buff(ptable, NRECORDS, readBuf);
H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf);
H5_FAILED();
@@ -1155,134 +1200,142 @@ error: /* An error has occurred. Clean up and exit. */
* 2016/01/27 -BMR
*-------------------------------------------------------------------------
*/
-static int testfl_VLof_comptype(void)
+static int
+testfl_VLof_comptype(void)
{
/* Struct that the VL sequences are composed of */
typedef struct {
unsigned u;
- float f;
+ float f;
} VLcomp_t;
- hid_t fid=H5I_INVALID_HID; /* Test file identifier */
- hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */
- hid_t vltype=H5I_INVALID_HID; /* Variable length datatype */
- hid_t cmptype=H5I_INVALID_HID; /* Compound datatype */
- hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */
- hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */
- hsize_t count; /* Number of records in the table */
- unsigned uu, vv; /* Loop variables */
- char msg[80]; /* For error message */
- herr_t ret;
+ hid_t fid = H5I_INVALID_HID; /* Test file identifier */
+ hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */
+ hid_t vltype = H5I_INVALID_HID; /* Variable length datatype */
+ hid_t cmptype = H5I_INVALID_HID; /* Compound datatype */
+ hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */
+ hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */
+ hsize_t count; /* Number of records in the table */
+ unsigned uu, vv; /* Loop variables */
+ char msg[80]; /* For error message */
+ herr_t ret;
HL_TESTING3(" with vlen of compound datatypes");
/* Allocate and initialize VL data to write (copied from C test) */
for (uu = 0; uu < NRECORDS; uu++) {
writeBuf[uu].p = HDmalloc((uu + 1) * sizeof(VLcomp_t));
- if(writeBuf[uu].p == NULL) {
+ if (writeBuf[uu].p == NULL) {
HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu);
goto error;
- }
+ }
writeBuf[uu].len = uu + 1;
for (vv = 0; vv < (uu + 1); vv++) {
((VLcomp_t *)writeBuf[uu].p)[vv].u = uu + vv;
((VLcomp_t *)writeBuf[uu].p)[vv].f = (float)(uu + vv) / 3.0F;
- } /* end for */
- } /* end for */
+ } /* end for */
+ } /* end for */
/* Open the file */
fid = H5Fopen(TESTFL_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT);
if (fid < 0)
- goto error;
+ goto error;
/* Create the base compound type */
cmptype = H5Tcreate(H5T_COMPOUND, sizeof(VLcomp_t));
if (cmptype < 0)
- goto error;
+ goto error;
/* Insert fields */
ret = H5Tinsert(cmptype, "u", HOFFSET(VLcomp_t, u), H5T_NATIVE_UINT);
if (ret < 0)
- goto error;
+ goto error;
ret = H5Tinsert(cmptype, "f", HOFFSET(VLcomp_t, f), H5T_NATIVE_FLOAT);
if (ret < 0)
- goto error;
+ goto error;
/* Create a variable length type that uses the VLcomp_t as its base type */
vltype = H5Tvlen_create(cmptype);
if (vltype < 0)
- goto error;
+ goto error;
/* Create a packet table that uses a vlen datatype of compound datatype */
ptable = H5PTcreate_fl(fid, PT_VLEN_COMP, vltype, (hsize_t)1, 0);
/* Ensure that PT is created successfully */
if (ptable == H5I_INVALID_HID)
- goto error;
+ goto error;
/* Release the datatypes */
if (H5Tclose(cmptype) < 0)
- goto error;
+ goto error;
if (H5Tclose(vltype) < 0)
- goto error;
+ goto error;
/* Write the entire buffer to the packet table */
- ret = H5PTappend(ptable, (size_t)5, writeBuf );
+ ret = H5PTappend(ptable, (size_t)5, writeBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Get the number of packets in the packet table, should be NRECORDS. */
ret = H5PTget_num_packets(ptable, &count);
if (ret < 0)
- goto error;
+ goto error;
HDsprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS);
VERIFY(count == NRECORDS, msg);
/* Read all five packets back */
- ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)5, (void*)readBuf );
+ ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)5, (void *)readBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Compare data read in */
for (uu = 0; uu < NRECORDS; uu++) {
if (writeBuf[uu].len != readBuf[uu].len) {
- HDfprintf(stderr, "%d: VL data length don't match!, writeBuf[%u].len=%zu, readBuf[%u].len=%zu\n",__LINE__, uu, writeBuf[uu].len, uu, readBuf[uu].len);
- continue;
- } /* write len != read len */
+ HDfprintf(stderr, "%d: VL data length don't match!, writeBuf[%u].len=%zu, readBuf[%u].len=%zu\n",
+ __LINE__, uu, writeBuf[uu].len, uu, readBuf[uu].len);
+ continue;
+ } /* write len != read len */
for (vv = 0; vv < (uu + 1); vv++) {
- if (((unsigned int *)writeBuf[uu].p)[vv] != ((unsigned int *)readBuf[uu].p)[vv] ) {
- HDfprintf(stderr, "VL data values don't match!, writeBuf[uu].p[%u]=%u, readBuf[uu].p[%u]=%u\n", vv, ((unsigned int *)writeBuf[uu].p)[vv], vv, ((unsigned int *)readBuf[uu].p)[vv]);
+ if (((unsigned int *)writeBuf[uu].p)[vv] != ((unsigned int *)readBuf[uu].p)[vv]) {
+ HDfprintf(stderr,
+ "VL data values don't match!, writeBuf[uu].p[%u]=%u, readBuf[uu].p[%u]=%u\n", vv,
+ ((unsigned int *)writeBuf[uu].p)[vv], vv, ((unsigned int *)readBuf[uu].p)[vv]);
continue;
- } /* write value != read value */
- }
+ } /* write value != read value */
+ }
} /* end for */
/* Free the buffers */
ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf);
if (ret < 0)
- goto error;
+ goto error;
ret = H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Close the packet table */
ret = H5PTclose(ptable);
if (ret < 0)
- goto error;
+ goto error;
/* Close the file */
if (H5Fclose(fid) < 0)
- goto error;
+ goto error;
PASSED();
return SUCCEED;
error: /* An error has occurred. Clean up and exit. */
- if (cmptype > 0) H5Tclose(cmptype);
- if (vltype > 0) H5Tclose(vltype);
- if (H5PTis_valid(ptable) > 0) H5PTclose(ptable);
- if (fid > 0) H5Fclose(fid);
+ if (cmptype > 0)
+ H5Tclose(cmptype);
+ if (vltype > 0)
+ H5Tclose(vltype);
+ if (H5PTis_valid(ptable) > 0)
+ H5PTclose(ptable);
+ if (fid > 0)
+ H5Fclose(fid);
H5PTfree_vlen_buff(ptable, NRECORDS, readBuf);
H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf);
H5_FAILED();
@@ -1297,173 +1350,185 @@ error: /* An error has occurred. Clean up and exit. */
* 2016/01/27 -BMR
*-------------------------------------------------------------------------
*/
-static int testfl_compound_VL_VLtype(void)
+static int
+testfl_compound_VL_VLtype(void)
{
/* Struct that the VL sequences are composed of */
typedef struct {
unsigned u;
- float f;
- hvl_t v;
+ float f;
+ hvl_t v;
} compVLVL_t;
- hid_t fid=H5I_INVALID_HID; /* Test file identifier */
- hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */
- hid_t vlatomic=H5I_INVALID_HID; /* Variable length datatype */
- hid_t vlofvl=H5I_INVALID_HID; /* Variable length datatype */
- hid_t comp_vlvl=H5I_INVALID_HID; /* ID of a compound datatype containing
- a VL of VL of atomic datatype */
- hsize_t count; /* Number of records in the table */
- compVLVL_t writeBuf[NRECORDS];/* Buffer to hold data to be written */
- compVLVL_t readBuf[NRECORDS]; /* Buffer to hold read data */
- hvl_t *t1, *t2;
- unsigned uu, vv, ww; /* Loop variables */
- char msg[80]; /* For error message */
- herr_t ret; /* Returned status from a callee */
+ hid_t fid = H5I_INVALID_HID; /* Test file identifier */
+ hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */
+ hid_t vlatomic = H5I_INVALID_HID; /* Variable length datatype */
+ hid_t vlofvl = H5I_INVALID_HID; /* Variable length datatype */
+ hid_t comp_vlvl = H5I_INVALID_HID; /* ID of a compound datatype containing
+ a VL of VL of atomic datatype */
+ hsize_t count; /* Number of records in the table */
+ compVLVL_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */
+ compVLVL_t readBuf[NRECORDS]; /* Buffer to hold read data */
+ hvl_t * t1, *t2;
+ unsigned uu, vv, ww; /* Loop variables */
+ char msg[80]; /* For error message */
+ herr_t ret; /* Returned status from a callee */
HL_TESTING3(" with compound datatype containing vlen datatype");
/* Allocate and initialize VL data to write (copied from C test) */
for (uu = 0; uu < NRECORDS; uu++) {
- writeBuf[uu].u = uu * 10;
- writeBuf[uu].f = (float)(uu * 20) / 3.0F;
+ writeBuf[uu].u = uu * 10;
+ writeBuf[uu].f = (float)(uu * 20) / 3.0F;
writeBuf[uu].v.p = HDmalloc((uu + L1_INCM) * sizeof(hvl_t));
if (writeBuf[uu].v.p == NULL) {
HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu);
goto error;
- }
+ }
writeBuf[uu].v.len = uu + L1_INCM;
- for (t1 = (hvl_t *)((writeBuf[uu].v).p), vv = 0; vv < (uu + L1_INCM); vv++, t1++)
- {
+ for (t1 = (hvl_t *)((writeBuf[uu].v).p), vv = 0; vv < (uu + L1_INCM); vv++, t1++) {
t1->p = HDmalloc((vv + L2_INCM) * sizeof(unsigned int));
- if (t1->p == NULL) {
- HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu);
- goto error;
- }
+ if (t1->p == NULL) {
+ HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu);
+ goto error;
+ }
t1->len = vv + L2_INCM;
for (ww = 0; ww < vv + L2_INCM; ww++)
- ((unsigned int*)t1->p)[ww] = uu * 100 + vv * 10 + ww;
+ ((unsigned int *)t1->p)[ww] = uu * 100 + vv * 10 + ww;
}
} /* end for */
/* Open the file */
fid = H5Fopen(TESTFL_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT);
if (fid < 0)
- goto error;
+ goto error;
/* Create a VL datatype of an atomic type */
- vlatomic = H5Tvlen_create (H5T_NATIVE_UINT);
+ vlatomic = H5Tvlen_create(H5T_NATIVE_UINT);
if (vlatomic < 0)
- goto error;
+ goto error;
/* Create a VL datatype of the VL of atomic datatype */
- vlofvl = H5Tvlen_create (vlatomic);
+ vlofvl = H5Tvlen_create(vlatomic);
if (vlofvl < 0)
- goto error;
+ goto error;
/* Create the base compound type */
comp_vlvl = H5Tcreate(H5T_COMPOUND, sizeof(compVLVL_t));
if (comp_vlvl < 0)
- goto error;
+ goto error;
/* Insert fields: atomic, atomic, vlen */
ret = H5Tinsert(comp_vlvl, "u", HOFFSET(compVLVL_t, u), H5T_NATIVE_UINT);
if (ret < 0)
- goto error;
+ goto error;
ret = H5Tinsert(comp_vlvl, "f", HOFFSET(compVLVL_t, f), H5T_NATIVE_FLOAT);
if (ret < 0)
- goto error;
+ goto error;
ret = H5Tinsert(comp_vlvl, "v", HOFFSET(compVLVL_t, v), vlofvl);
if (ret < 0)
- goto error;
+ goto error;
/* Create a packet table that uses a compound datatype of vlen datatype */
ptable = H5PTcreate_fl(fid, PT_COMP_VLEN, comp_vlvl, (hsize_t)1, 0);
/* Ensure that PT is created successfully */
if (ptable == H5I_INVALID_HID)
- goto error;
+ goto error;
/* Release datatypes */
if (H5Tclose(vlatomic) < 0)
- goto error;
+ goto error;
if (H5Tclose(vlofvl) < 0)
- goto error;
+ goto error;
if (H5Tclose(comp_vlvl) < 0)
- goto error;
+ goto error;
/* Write the entire buffer to the packet table */
- ret = H5PTappend(ptable, (size_t)NRECORDS, writeBuf );
+ ret = H5PTappend(ptable, (size_t)NRECORDS, writeBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Get the number of packets in the packet table, should be NRECORDS. */
ret = H5PTget_num_packets(ptable, &count);
if (ret < 0)
- goto error;
+ goto error;
HDsprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS);
VERIFY(count == NRECORDS, msg);
/* Read all five packets back */
- ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)NRECORDS, (void*)readBuf );
+ ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)NRECORDS, (void *)readBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Compare data read in */
for (uu = 0; uu < NRECORDS; uu++) {
if (writeBuf[uu].u != readBuf[uu].u) {
- HDfprintf(stderr, "Integer components don't match!, writeBuf[%u].u=%u, readBuf[%u].u=%u\n", uu, writeBuf[uu].u, uu, readBuf[uu].u);
+ HDfprintf(stderr, "Integer components don't match!, writeBuf[%u].u=%u, readBuf[%u].u=%u\n", uu,
+ writeBuf[uu].u, uu, readBuf[uu].u);
continue;
} /* end if */
if (!H5_FLT_ABS_EQUAL(writeBuf[uu].f, readBuf[uu].f)) {
- HDfprintf(stderr, "Float components don't match!, writeBuf[%u].f=%f, readBuf[%u].f=%f\n", uu, (double)writeBuf[uu].f, uu, (double)readBuf[uu].f);
+ HDfprintf(stderr, "Float components don't match!, writeBuf[%u].f=%f, readBuf[%u].f=%f\n", uu,
+ (double)writeBuf[uu].f, uu, (double)readBuf[uu].f);
continue;
} /* end if */
if (writeBuf[uu].v.len != readBuf[uu].v.len) {
- HDfprintf(stderr, "%d: VL data length don't match!, writeBuf[%u].v.len=%zu, readBuf[%u].v.len=%zu\n", __LINE__, uu, writeBuf[uu].v.len, uu, readBuf[uu].v.len);
+ HDfprintf(stderr,
+ "%d: VL data length don't match!, writeBuf[%u].v.len=%zu, readBuf[%u].v.len=%zu\n",
+ __LINE__, uu, writeBuf[uu].v.len, uu, readBuf[uu].v.len);
continue;
} /* end if */
- for (t1 = (hvl_t *)(writeBuf[uu].v.p), t2 = (hvl_t *)(readBuf[uu].v.p), vv = 0; (size_t)vv < readBuf[uu].v.len; vv++, t1++, t2++) {
+ for (t1 = (hvl_t *)(writeBuf[uu].v.p), t2 = (hvl_t *)(readBuf[uu].v.p), vv = 0;
+ (size_t)vv < readBuf[uu].v.len; vv++, t1++, t2++) {
if (t1->len != t2->len) {
- HDfprintf(stderr, "%d: VL data length don't match!, uu=%u, vv=%u, t1->len=%zu, t2->len=%zu\n", __LINE__, uu, vv, t1->len, t2->len);
+ HDfprintf(stderr, "%d: VL data length don't match!, uu=%u, vv=%u, t1->len=%zu, t2->len=%zu\n",
+ __LINE__, uu, vv, t1->len, t2->len);
continue;
} /* end if */
for (ww = 0; (size_t)ww < t2->len; ww++) {
- if (((unsigned int *)t1->p)[ww] != ((unsigned int *)t2->p)[ww] ) {
- HDfprintf(stderr, "VL data values don't match!, t1->p[%u]=%u, t2->p[%u]=%u\n", ww, ((unsigned int *)t1->p)[ww], ww, ((unsigned int *)t2->p)[ww]);
+ if (((unsigned int *)t1->p)[ww] != ((unsigned int *)t2->p)[ww]) {
+ HDfprintf(stderr, "VL data values don't match!, t1->p[%u]=%u, t2->p[%u]=%u\n", ww,
+ ((unsigned int *)t1->p)[ww], ww, ((unsigned int *)t2->p)[ww]);
continue;
} /* end if */
- } /* end for */
- } /* end for */
- } /* end for */
+ } /* end for */
+ } /* end for */
+ } /* end for */
/* Free the buffers */
ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf);
if (ret < 0)
- goto error;
+ goto error;
ret = H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Close the packet table */
ret = H5PTclose(ptable);
if (ret < 0)
- goto error;
+ goto error;
/* Close the file */
if (H5Fclose(fid) < 0)
- goto error;
+ goto error;
PASSED();
return SUCCEED;
error: /* An error has occurred. Clean up and exit. */
- if (vlatomic > 0) H5Tclose(vlatomic);
- if (vlofvl > 0) H5Tclose(vlofvl);
- if (comp_vlvl > 0) H5Tclose(comp_vlvl);
- if (H5PTis_valid(ptable) > 0) H5PTclose(ptable);
- if (fid > 0) H5Fclose(fid);
+ if (vlatomic > 0)
+ H5Tclose(vlatomic);
+ if (vlofvl > 0)
+ H5Tclose(vlofvl);
+ if (comp_vlvl > 0)
+ H5Tclose(comp_vlvl);
+ if (H5PTis_valid(ptable) > 0)
+ H5PTclose(ptable);
+ if (fid > 0)
+ H5Fclose(fid);
H5PTfree_vlen_buff(ptable, NRECORDS, readBuf);
H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf);
H5_FAILED();
@@ -1478,19 +1543,20 @@ error: /* An error has occurred. Clean up and exit. */
* 2016/01/27 -BMR
*-------------------------------------------------------------------------
*/
-static int testfl_VLof_VLtype(void)
+static int
+testfl_VLof_VLtype(void)
{
- hid_t fid=H5I_INVALID_HID; /* Test file identifier */
- hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */
- hid_t vlatomic=H5I_INVALID_HID; /* Variable length datatype */
- hid_t vlofvl=H5I_INVALID_HID; /* VL datatype of VL datatypes */
- hsize_t count; /* Number of records in the table */
- hvl_t *t1; /* pointer to advance */
- unsigned uu, vv, ww; /* Loop variables */
- hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */
- hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */
- char msg[80]; /* For error message */
- herr_t ret; /* Returned status from a callee */
+ hid_t fid = H5I_INVALID_HID; /* Test file identifier */
+ hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */
+ hid_t vlatomic = H5I_INVALID_HID; /* Variable length datatype */
+ hid_t vlofvl = H5I_INVALID_HID; /* VL datatype of VL datatypes */
+ hsize_t count; /* Number of records in the table */
+ hvl_t * t1; /* pointer to advance */
+ unsigned uu, vv, ww; /* Loop variables */
+ hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */
+ hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */
+ char msg[80]; /* For error message */
+ herr_t ret; /* Returned status from a callee */
HL_TESTING3(" with vlen datatype of vlen datatype");
@@ -1502,89 +1568,92 @@ static int testfl_VLof_VLtype(void)
goto error;
} /* end if */
writeBuf[uu].len = uu + 1;
- for (t1 = (hvl_t *)(writeBuf[uu].p), vv = 0; vv < (uu + 1); vv++, t1++)
- {
+ for (t1 = (hvl_t *)(writeBuf[uu].p), vv = 0; vv < (uu + 1); vv++, t1++) {
t1->p = HDmalloc((vv + 1) * sizeof(unsigned int));
- if (t1->p == NULL) {
- HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu);
- goto error;
- }
+ if (t1->p == NULL) {
+ HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu);
+ goto error;
+ }
t1->len = vv + 1;
for (ww = 0; ww < (vv + 1); ww++)
((unsigned int *)t1->p)[ww] = uu * 100 + vv * 10 + ww;
} /* end for */
- } /* end for */
+ } /* end for */
/* Open the file */
fid = H5Fopen(TESTFL_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT);
if (fid < 0)
- goto error;
+ goto error;
/* Create a VL datatype of an atomic type */
- vlatomic = H5Tvlen_create (H5T_NATIVE_UINT);
+ vlatomic = H5Tvlen_create(H5T_NATIVE_UINT);
if (vlatomic < 0)
- goto error;
+ goto error;
- vlofvl = H5Tvlen_create (vlatomic);
+ vlofvl = H5Tvlen_create(vlatomic);
if (vlofvl < 0)
- goto error;
+ goto error;
/* Create a packet table that uses a vlen datatype of vlen datatype */
ptable = H5PTcreate_fl(fid, PT_VLEN_VLEN, vlofvl, (hsize_t)1, 0);
/* Ensure that PT is created successfully */
if (ptable == H5I_INVALID_HID)
- goto error;
+ goto error;
/* Release datatypes */
if (H5Tclose(vlatomic) < 0)
- goto error;
+ goto error;
if (H5Tclose(vlofvl) < 0)
- goto error;
+ goto error;
/* Write the entire buffer to the packet table */
- ret = H5PTappend(ptable, (size_t)5, writeBuf );
+ ret = H5PTappend(ptable, (size_t)5, writeBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Get the number of packets in the packet table, should be NRECORDS. */
ret = H5PTget_num_packets(ptable, &count);
if (ret < 0)
- goto error;
+ goto error;
HDsprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS);
VERIFY(count == NRECORDS, msg);
/* Read all five packets back */
- ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)5, (void*)readBuf );
+ ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)5, (void *)readBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Free the buffers */
ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf);
if (ret < 0)
- goto error;
+ goto error;
ret = H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf);
if (ret < 0)
- goto error;
+ goto error;
/* Close the packet table */
ret = H5PTclose(ptable);
if (ret < 0)
- goto error;
+ goto error;
/* Close the file */
if (H5Fclose(fid) < 0)
- goto error;
+ goto error;
PASSED();
return SUCCEED;
error: /* An error has occurred. Clean up and exit. */
- if (vlatomic > 0) H5Tclose(vlatomic);
- if (vlofvl > 0) H5Tclose(vlofvl);
- if (H5PTis_valid(ptable) > 0) H5PTclose(ptable);
- if (fid > 0) H5Fclose(fid);
+ if (vlatomic > 0)
+ H5Tclose(vlatomic);
+ if (vlofvl > 0)
+ H5Tclose(vlofvl);
+ if (H5PTis_valid(ptable) > 0)
+ H5PTclose(ptable);
+ if (fid > 0)
+ H5Fclose(fid);
H5PTfree_vlen_buff(ptable, NRECORDS, readBuf);
H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf);
H5_FAILED();
@@ -1599,19 +1668,20 @@ error: /* An error has occurred. Clean up and exit. */
* 2016/01/27 -BMR
*-------------------------------------------------------------------------
*/
-int test_packet_table_with_varlen(void)
+int
+test_packet_table_with_varlen(void)
{
- hid_t fid=H5I_INVALID_HID; /* File identifier */
- int status = SUCCEED;
+ hid_t fid = H5I_INVALID_HID; /* File identifier */
+ int status = SUCCEED;
/* Create a file using default properties */
fid = H5Fcreate(TEST_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
if (fid < 0)
- return FAIL;
+ return FAIL;
/* Close the file. The file will be opened by each test function below */
if (H5Fclose(fid) < 0)
- return FAIL;
+ return FAIL;
HDputs("Testing packet table with various variable-length datatypes");
@@ -1620,46 +1690,46 @@ int test_packet_table_with_varlen(void)
/* Test variable length of a simple type */
if (test_VLof_atomic() < 0)
- status = FAIL;
+ status = FAIL;
/* Test variable length of a compound type */
if (test_VLof_comptype() < 0)
- status = FAIL;
+ status = FAIL;
/* Test compound type with variable length */
if (test_compound_VL_VLtype() < 0)
- status = FAIL;
+ status = FAIL;
/* Test variable length of a variable length */
if (test_VLof_VLtype() < 0)
- status = FAIL;
+ status = FAIL;
/* Test variable length of a variable length */
if (test_H5PTis_varlen() < 0)
- status = FAIL;
+ status = FAIL;
/* Test adding attributes to packet table */
if (test_attributes() < 0)
- status = FAIL;
+ status = FAIL;
/* Test accessor functions */
if (test_accessors() < 0)
- status = FAIL;
+ status = FAIL;
-/**************************************************************************
- Calling test functions for deprecated function H5PTcreate_fl
- Mar 2016, -BMR
+ /**************************************************************************
+ Calling test functions for deprecated function H5PTcreate_fl
+ Mar 2016, -BMR
-**************************************************************************/
+ **************************************************************************/
/* Create a file using default properties */
fid = H5Fcreate(TESTFL_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
if (fid < 0)
- return FAIL;
+ return FAIL;
/* Close the file. The file will be opened by each test function below */
if (H5Fclose(fid) < 0)
- return FAIL;
+ return FAIL;
HDputs("Testing packet table with various variable-length datatypes - H5PTcreate_fl");
@@ -1668,19 +1738,19 @@ int test_packet_table_with_varlen(void)
/* Test variable length of a simple type */
if (testfl_VLof_atomic() < 0)
- status = FAIL;
+ status = FAIL;
/* Test variable length of a compound type */
if (testfl_VLof_comptype() < 0)
- status = FAIL;
+ status = FAIL;
/* Test compound type with variable length */
if (testfl_compound_VL_VLtype() < 0)
- status = FAIL;
+ status = FAIL;
/* Test variable length of a variable length */
if (testfl_VLof_VLtype() < 0)
- status = FAIL;
+ status = FAIL;
- return(status);
+ return (status);
}
diff --git a/hl/test/test_table.c b/hl/test/test_table.c
index cd2e2a4..2f98f4a 100644
--- a/hl/test/test_table.c
+++ b/hl/test/test_table.c
@@ -1,60 +1,58 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-* Copyright by The HDF Group. *
-* Copyright by the Board of Trustees of the University of Illinois. *
-* All rights reserved. *
-* *
-* This file is part of HDF5. The full HDF5 copyright notice, including *
-* terms governing use, modification, and redistribution, is contained in *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
* distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "h5hltest.h"
#include "H5srcdir.h"
#include "H5TBpublic.h"
-#define TEST_FILE_BE "test_table_be.h5"
-#define TEST_FILE_LE "test_table_le.h5"
+#define TEST_FILE_BE "test_table_be.h5"
+#define TEST_FILE_LE "test_table_le.h5"
#define TEST_FILE_CRAY "test_table_cray.h5"
-
/*-------------------------------------------------------------------------
-* Table API test
-*
-* Functions tested:
-*
-* H5TBmake_table
-* H5TBread_table
-* H5TBwrite_records
-* H5TBread_records
-* H5TBappend_records
-* H5TBinsert_record
-* H5TBdelete_record
-* H5TBcombine_tables
-* H5TBwrite_fields_name
-* H5TBread_fields_name
-* H5TBwrite_fields_index
-* H5TBinsert_field
-* H5TBdelete_field
-* H5TBget_table_info
-* H5TBget_field_info
-*
-*-------------------------------------------------------------------------
-*/
-
-#define TITLE "Title"
-#define NFIELDS 5
-#define NRECORDS 8
-#define NRECORDS_ADD 3
+ * Table API test
+ *
+ * Functions tested:
+ *
+ * H5TBmake_table
+ * H5TBread_table
+ * H5TBwrite_records
+ * H5TBread_records
+ * H5TBappend_records
+ * H5TBinsert_record
+ * H5TBdelete_record
+ * H5TBcombine_tables
+ * H5TBwrite_fields_name
+ * H5TBread_fields_name
+ * H5TBwrite_fields_index
+ * H5TBinsert_field
+ * H5TBdelete_field
+ * H5TBget_table_info
+ * H5TBget_field_info
+ *
+ *-------------------------------------------------------------------------
+ */
+
+#define TITLE "Title"
+#define NFIELDS 5
+#define NRECORDS 8
+#define NRECORDS_ADD 3
/*-------------------------------------------------------------------------
-* structure used for all tests, a particle with properties
-*-------------------------------------------------------------------------
-*/
-typedef struct particle_t
-{
+ * structure used for all tests, a particle with properties
+ *-------------------------------------------------------------------------
+ */
+typedef struct particle_t {
char name[16];
long longi;
float pressure;
@@ -63,31 +61,28 @@ typedef struct particle_t
} particle_t;
/*-------------------------------------------------------------------------
-* a subset of particle_t, with latitude and longitude fields
-*-------------------------------------------------------------------------
-*/
-typedef struct position_t
-{
- long longi;
- int lati;
+ * a subset of particle_t, with latitude and longitude fields
+ *-------------------------------------------------------------------------
+ */
+typedef struct position_t {
+ long longi;
+ int lati;
} position_t;
/*-------------------------------------------------------------------------
-* a subset of particle_t, with name and pressure fields
-*-------------------------------------------------------------------------
-*/
-typedef struct namepressure_t
-{
- char name[16];
- float pressure;
+ * a subset of particle_t, with name and pressure fields
+ *-------------------------------------------------------------------------
+ */
+typedef struct namepressure_t {
+ char name[16];
+ float pressure;
} namepressure_t;
/*-------------------------------------------------------------------------
-* an extended particle, used in the insert field test
-*-------------------------------------------------------------------------
-*/
-typedef struct particle2_t
-{
+ * an extended particle, used in the insert field test
+ *-------------------------------------------------------------------------
+ */
+typedef struct particle2_t {
char name[16];
long longi;
float pressure;
@@ -97,11 +92,10 @@ typedef struct particle2_t
} particle2_t;
/*-------------------------------------------------------------------------
-* a particle with one field less, used in the delete field test
-*-------------------------------------------------------------------------
-*/
-typedef struct particle3_t
-{
+ * a particle with one field less, used in the delete field test
+ *-------------------------------------------------------------------------
+ */
+typedef struct particle3_t {
char name[16];
long longi;
double temperature;
@@ -116,35 +110,34 @@ typedef struct particle3_t
/* Push current alignment rule forcing 4-byte alignment boundary
* to the internal stack ...
*/
-#pragma pack(push,4)
- typedef struct particle4_t {
- uint32_t state;
- double posx;
- double posy;
- float atx[3];
- float aty[3];
- float rro[2];
- } particle4_t;
+#pragma pack(push, 4)
+typedef struct particle4_t {
+ uint32_t state;
+ double posx;
+ double posy;
+ float atx[3];
+ float aty[3];
+ float rro[2];
+} particle4_t;
/*
* ... and restore original alignment rules from stack
*/
#pragma pack(pop)
-
/*-------------------------------------------------------------------------
-* function to open an HDF5 file and return its file identifier
-*-------------------------------------------------------------------------
-*/
-static hid_t h5file_open(const char *fname, unsigned flags)
+ * function to open an HDF5 file and return its file identifier
+ *-------------------------------------------------------------------------
+ */
+static hid_t
+h5file_open(const char *fname, unsigned flags)
{
- hid_t fid; /* identifier for the file */
+ hid_t fid; /* identifier for the file */
const char *data_file = H5_get_srcdir_filename(fname);
/* open */
- if ((fid = H5Fopen(data_file,flags,H5P_DEFAULT))<0)
- {
- HDfprintf(stderr,"Error: Cannot open file <%s>\n",data_file );
+ if ((fid = H5Fopen(data_file, flags, H5P_DEFAULT)) < 0) {
+ HDfprintf(stderr, "Error: Cannot open file <%s>\n", data_file);
HDexit(1);
}
@@ -152,74 +145,68 @@ static hid_t h5file_open(const char *fname, unsigned flags)
}
/*-------------------------------------------------------------------------
-* function that compares one particle
-*-------------------------------------------------------------------------
-*/
-static int cmp_par(hsize_t i, hsize_t j, particle_t *rbuf, particle_t *wbuf )
+ * function that compares one particle
+ *-------------------------------------------------------------------------
+ */
+static int
+cmp_par(hsize_t i, hsize_t j, particle_t *rbuf, particle_t *wbuf)
{
- if ( ( HDstrcmp( rbuf[i].name, wbuf[j].name ) != 0 ) ||
- rbuf[i].lati != wbuf[j].lati ||
- rbuf[i].longi != wbuf[j].longi ||
- !H5_FLT_ABS_EQUAL(rbuf[i].pressure,wbuf[j].pressure) ||
- !H5_DBL_ABS_EQUAL(rbuf[i].temperature,wbuf[j].temperature) )
- {
- HDfprintf(stderr,"read and write buffers have differences\n");
- HDfprintf(stderr,"%s %ld %f %f %d\n",
- rbuf[i].name,rbuf[i].longi,(double)rbuf[i].pressure,rbuf[i].temperature,rbuf[i].lati);
- HDfprintf(stderr,"%s %ld %f %f %d\n",
- wbuf[j].name,wbuf[j].longi,(double)wbuf[j].pressure,wbuf[j].temperature,wbuf[j].lati);
+ if ((HDstrcmp(rbuf[i].name, wbuf[j].name) != 0) || rbuf[i].lati != wbuf[j].lati ||
+ rbuf[i].longi != wbuf[j].longi || !H5_FLT_ABS_EQUAL(rbuf[i].pressure, wbuf[j].pressure) ||
+ !H5_DBL_ABS_EQUAL(rbuf[i].temperature, wbuf[j].temperature)) {
+ HDfprintf(stderr, "read and write buffers have differences\n");
+ HDfprintf(stderr, "%s %ld %f %f %d\n", rbuf[i].name, rbuf[i].longi, (double)rbuf[i].pressure,
+ rbuf[i].temperature, rbuf[i].lati);
+ HDfprintf(stderr, "%s %ld %f %f %d\n", wbuf[j].name, wbuf[j].longi, (double)wbuf[j].pressure,
+ wbuf[j].temperature, wbuf[j].lati);
return -1;
}
return 0;
}
/*-------------------------------------------------------------------------
-* function to compare deleted records
-*-------------------------------------------------------------------------
-*/
-static int compare_deleted(hsize_t rrecords, hsize_t dstart, hsize_t drecords,
- particle_t *rbuf, particle_t *wbuf)
+ * function to compare deleted records
+ *-------------------------------------------------------------------------
+ */
+static int
+compare_deleted(hsize_t rrecords, hsize_t dstart, hsize_t drecords, particle_t *rbuf, particle_t *wbuf)
{
- hsize_t i,j;
- for( i=0; i<rrecords; i++)
- {
- if (i<dstart)
- {
- if (cmp_par(i,i,rbuf,wbuf)<0)
+ hsize_t i, j;
+ for (i = 0; i < rrecords; i++) {
+ if (i < dstart) {
+ if (cmp_par(i, i, rbuf, wbuf) < 0)
return -1;
}
- else
- {
- j=i+drecords;
- if (cmp_par(i,j,rbuf,wbuf)<0)
+ else {
+ j = i + drecords;
+ if (cmp_par(i, j, rbuf, wbuf) < 0)
return -1;
}
}
return 0;
}
-
-
/*-------------------------------------------------------------------------
-* the test program
-*-------------------------------------------------------------------------
-*/
+ * the test program
+ *-------------------------------------------------------------------------
+ */
-static int test_table(hid_t fid, int do_write)
+static int
+test_table(hid_t fid, int do_write)
{
- hid_t fid1;
- hid_t fid2;
- hsize_t chunk_size=10;
- int compress=0;
- int *fill=NULL;
- particle_t fill1[1] = { {"no data",-1, -99.0f, -99.0f, -1} };
- int fill1_new[1] = { -100 };
- hsize_t position;
- char tname[20];
- hsize_t i, j;
+ hid_t fid1;
+ hid_t fid2;
+ hsize_t chunk_size = 10;
+ int compress = 0;
+ int * fill = NULL;
+ particle_t fill1[1] = {{"no data", -1, -99.0f, -99.0f, -1}};
+ int fill1_new[1] = {-100};
+ hsize_t position;
+ char tname[20];
+ hsize_t i, j;
/* write, read, append, delete, insert some records and fields */
- hsize_t FIELDS = NFIELDS;
- hsize_t RECORDS = NRECORDS;
+ hsize_t FIELDS = NFIELDS;
+ hsize_t RECORDS = NRECORDS;
hsize_t start;
hsize_t wstart;
hsize_t rstart;
@@ -233,210 +220,157 @@ static int test_table(hid_t fid, int do_write)
hsize_t drecords;
hsize_t nfields;
hsize_t rfields;
- hsize_t start1; /* record to start reading from 1st table */
- hsize_t start2; /* record to start writing in 2nd table */
+ hsize_t start1; /* record to start reading from 1st table */
+ hsize_t start2; /* record to start writing in 2nd table */
/* read, write, insert, append buffers */
- particle_t rbuf[NRECORDS+4];
+ particle_t rbuf[NRECORDS + 4];
particle2_t rbuf2[NRECORDS];
particle3_t rbuf3[NRECORDS];
- particle_t rbufc[NRECORDS*2];
- particle_t abuf[2]={{"eight",80,8.0f,80.0f,80},{"nine",90,9.0f,90.0f,90}};
- particle_t ibuf[2]={{"zero", 0, 0.0f, 0.0f, 0},{"zero", 0, 0.0f, 0.0f, 0}};
+ particle_t rbufc[NRECORDS * 2];
+ particle_t abuf[2] = {{"eight", 80, 8.0f, 80.0f, 80}, {"nine", 90, 9.0f, 90.0f, 90}};
+ particle_t ibuf[2] = {{"zero", 0, 0.0f, 0.0f, 0}, {"zero", 0, 0.0f, 0.0f, 0}};
particle_t wbufd[NRECORDS];
- particle_t wbuf[NRECORDS] = {
- {"zero", 0, 0.0f, 0.0f, 0,},
- {"one", 10, 1.0f, 10.0f, 10},
- {"two", 20, 2.0f, 20.0f, 20},
- {"three",30, 3.0f, 30.0f, 30},
- {"four", 40, 4.0f, 40.0f, 40},
- {"five", 50, 5.0f, 50.0f, 50},
- {"six", 60, 6.0f, 60.0f, 60},
- {"seven",70, 7.0f, 70.0f, 70}
- };
+ particle_t wbuf[NRECORDS] = {{
+ "zero",
+ 0,
+ 0.0f,
+ 0.0f,
+ 0,
+ },
+ {"one", 10, 1.0f, 10.0f, 10},
+ {"two", 20, 2.0f, 20.0f, 20},
+ {"three", 30, 3.0f, 30.0f, 30},
+ {"four", 40, 4.0f, 40.0f, 40},
+ {"five", 50, 5.0f, 50.0f, 50},
+ {"six", 60, 6.0f, 60.0f, 60},
+ {"seven", 70, 7.0f, 70.0f, 70}};
/* buffers for the field "Pressure" and "New_field" */
- float pressure_in [NRECORDS] = { 0.0f,1.0f,2.0f,3.0f,4.0f,5.0f,6.0f,7.0f };
- float pressure_out [NRECORDS];
- int buf_new[NRECORDS] = { 0,1,2,3,4,5,6,7 };
+ float pressure_in[NRECORDS] = {0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f};
+ float pressure_out[NRECORDS];
+ int buf_new[NRECORDS] = {0, 1, 2, 3, 4, 5, 6, 7};
/* buffers for the fields "Latitude,Longitude" */
- position_t position_out[NRECORDS_ADD];
- position_t position_in[NRECORDS_ADD] = { {0,0},
- {10,10},
- {20,20}};
+ position_t position_out[NRECORDS_ADD];
+ position_t position_in[NRECORDS_ADD] = {{0, 0}, {10, 10}, {20, 20}};
/* buffers for the fields "Name,Pressure" */
- namepressure_t namepre_out[NRECORDS];
- namepressure_t namepre_in[NRECORDS] =
- { {"zero",0.0f},
- {"one", 1.0f},
- {"two", 2.0f},
- {"three", 3.0f},
- {"four", 4.0f},
- {"five", 5.0f},
- {"six", 6.0f},
- {"seven", 7.0f},
+ namepressure_t namepre_out[NRECORDS];
+ namepressure_t namepre_in[NRECORDS] = {
+ {"zero", 0.0f}, {"one", 1.0f}, {"two", 2.0f}, {"three", 3.0f},
+ {"four", 4.0f}, {"five", 5.0f}, {"six", 6.0f}, {"seven", 7.0f},
};
-
/*-------------------------------------------------------------------------
- * initialize table parameters
- * field offsets and sizes used in the fields functions
- *-------------------------------------------------------------------------
- */
-
- size_t field_offset_pos[2]=
- {
- HOFFSET( position_t, longi ),
- HOFFSET( position_t, lati )
- };
- size_t field_offset_namepre[2]=
- {
- HOFFSET( namepressure_t, name ),
- HOFFSET( namepressure_t, pressure )
- };
- size_t field_sizes_pos[2]=
- {
- sizeof(position_in[0].longi),
- sizeof(position_in[0].lati)
- };
- size_t field_sizes_namepre[2]=
- {
- sizeof(namepre_in[0].name),
- sizeof(namepre_in[0].pressure)
- };
- size_t field_sizes_pre[1]=
- {
- sizeof(namepre_in[0].pressure)
- };
+ * initialize table parameters
+ * field offsets and sizes used in the fields functions
+ *-------------------------------------------------------------------------
+ */
+
+ size_t field_offset_pos[2] = {HOFFSET(position_t, longi), HOFFSET(position_t, lati)};
+ size_t field_offset_namepre[2] = {HOFFSET(namepressure_t, name), HOFFSET(namepressure_t, pressure)};
+ size_t field_sizes_pos[2] = {sizeof(position_in[0].longi), sizeof(position_in[0].lati)};
+ size_t field_sizes_namepre[2] = {sizeof(namepre_in[0].name), sizeof(namepre_in[0].pressure)};
+ size_t field_sizes_pre[1] = {sizeof(namepre_in[0].pressure)};
/*-------------------------------------------------------------------------
- * query table test
- *-------------------------------------------------------------------------
- */
- char **names_out;
- size_t sizes_out[NFIELDS];
- size_t offset_out[NFIELDS];
- size_t size_out;
+ * query table test
+ *-------------------------------------------------------------------------
+ */
+ char **names_out;
+ size_t sizes_out[NFIELDS];
+ size_t offset_out[NFIELDS];
+ size_t size_out;
/*-------------------------------------------------------------------------
- * initialize table parameters
- * field indexes (zero based) used in the fields functions
- * "Name 0","Longitude 1","Pressure 2","Temperature 3","Latitude 4"
- *-------------------------------------------------------------------------
- */
- int field_index_pre[1] = { 2 };
- int field_index_pos[2] = { 1,4 };
- int field_index_namepre[2] = { 0,2 };
- int field_index[NFIELDS] = { 0,1,2,3,4 };
+ * initialize table parameters
+ * field indexes (zero based) used in the fields functions
+ * "Name 0","Longitude 1","Pressure 2","Temperature 3","Latitude 4"
+ *-------------------------------------------------------------------------
+ */
+ int field_index_pre[1] = {2};
+ int field_index_pos[2] = {1, 4};
+ int field_index_namepre[2] = {0, 2};
+ int field_index[NFIELDS] = {0, 1, 2, 3, 4};
/*-------------------------------------------------------------------------
- * initialize table parameters
- * size and the offsets of struct members in memory
- * define the inserted field HDF5 type and buffers
- * these are used for the insert field test
- *-------------------------------------------------------------------------
- */
- hid_t field_type_new = H5T_NATIVE_INT;
- size_t dst_size2 = sizeof( particle2_t );
- size_t dst_offset2[NFIELDS+1] = { HOFFSET( particle2_t, name ),
- HOFFSET( particle2_t, longi ),
- HOFFSET( particle2_t, pressure ),
- HOFFSET( particle2_t, temperature ),
- HOFFSET( particle2_t, lati ),
- HOFFSET( particle2_t, new_field )};
- size_t dst_sizes2[NFIELDS+1] = { sizeof( rbuf2[0].name),
- sizeof( rbuf2[0].longi),
- sizeof( rbuf2[0].pressure),
- sizeof( rbuf2[0].temperature),
- sizeof( rbuf2[0].lati),
- sizeof( rbuf2[0].new_field)};
+ * initialize table parameters
+ * size and the offsets of struct members in memory
+ * define the inserted field HDF5 type and buffers
+ * these are used for the insert field test
+ *-------------------------------------------------------------------------
+ */
+ hid_t field_type_new = H5T_NATIVE_INT;
+ size_t dst_size2 = sizeof(particle2_t);
+ size_t dst_offset2[NFIELDS + 1] = {HOFFSET(particle2_t, name), HOFFSET(particle2_t, longi),
+ HOFFSET(particle2_t, pressure), HOFFSET(particle2_t, temperature),
+ HOFFSET(particle2_t, lati), HOFFSET(particle2_t, new_field)};
+ size_t dst_sizes2[NFIELDS + 1] = {sizeof(rbuf2[0].name), sizeof(rbuf2[0].longi),
+ sizeof(rbuf2[0].pressure), sizeof(rbuf2[0].temperature),
+ sizeof(rbuf2[0].lati), sizeof(rbuf2[0].new_field)};
/*-------------------------------------------------------------------------
- * initialize table parameters
- * size and the offsets of struct members in memory
- * these are used for the delete field test
- *-------------------------------------------------------------------------
- */
- size_t dst_size3 = sizeof( particle3_t );
- size_t dst_offset3[NFIELDS-1] = { HOFFSET( particle3_t, name ),
- HOFFSET( particle3_t, longi ),
- HOFFSET( particle3_t, temperature ),
- HOFFSET( particle3_t, lati )};
-
- size_t dst_sizes3[NFIELDS-1] = { sizeof( rbuf3[0].name),
- sizeof( rbuf3[0].longi),
- sizeof( rbuf3[0].temperature),
- sizeof( rbuf3[0].lati)};
+ * initialize table parameters
+ * size and the offsets of struct members in memory
+ * these are used for the delete field test
+ *-------------------------------------------------------------------------
+ */
+ size_t dst_size3 = sizeof(particle3_t);
+ size_t dst_offset3[NFIELDS - 1] = {HOFFSET(particle3_t, name), HOFFSET(particle3_t, longi),
+ HOFFSET(particle3_t, temperature), HOFFSET(particle3_t, lati)};
+
+ size_t dst_sizes3[NFIELDS - 1] = {sizeof(rbuf3[0].name), sizeof(rbuf3[0].longi),
+ sizeof(rbuf3[0].temperature), sizeof(rbuf3[0].lati)};
/*-------------------------------------------------------------------------
- * initialize table parameters
- * size and the offsets of struct members in memory
- * these are used for the delete field test with differing memory layout
- *-------------------------------------------------------------------------
- */
+ * initialize table parameters
+ * size and the offsets of struct members in memory
+ * these are used for the delete field test with differing memory layout
+ *-------------------------------------------------------------------------
+ */
/* Calculate the size and the offsets of our struct members in memory */
- size_t tbl_size = sizeof(particle4_t);
- size_t tbl_offset[NFIELDS+1] = { HOFFSET(particle4_t, state),
- HOFFSET(particle4_t, posx),
- HOFFSET(particle4_t, posy),
- HOFFSET(particle4_t, atx),
- HOFFSET(particle4_t, aty),
- HOFFSET(particle4_t, rro)
- };
+ size_t tbl_size = sizeof(particle4_t);
+ size_t tbl_offset[NFIELDS + 1] = {HOFFSET(particle4_t, state), HOFFSET(particle4_t, posx),
+ HOFFSET(particle4_t, posy), HOFFSET(particle4_t, atx),
+ HOFFSET(particle4_t, aty), HOFFSET(particle4_t, rro)};
/* Define an array of Particles */
- particle4_t p_data[NRECORDS] = {
- {12112, 1.4f, 2.5f, {1,2,3},{4,5,6}, {99,100}},
- {12113, 1.4f, 2.5f, {1,2,3},{4,5,6}, {99,100}},
- {12114, 1.4f, 2.5f, {1,2,3},{4,5,6}, {99,100}},
- {12115, 1.4f, 2.5f, {1,2,3},{4,5,6}, {99,100}},
- {12116, 1.4f, 2.5f, {1,2,3},{4,5,6}, {99,100}},
- {12117, 1.4f, 2.5f, {1,2,3},{4,5,6}, {99,100}},
- {12118, 1.4f, 2.5f, {1,2,3},{4,5,6}, {99,100}},
- {12119, 1.4f, 2.5f, {1,2,3},{4,5,6}, {99,100}}
- };
+ particle4_t p_data[NRECORDS] = {{12112, 1.4f, 2.5f, {1, 2, 3}, {4, 5, 6}, {99, 100}},
+ {12113, 1.4f, 2.5f, {1, 2, 3}, {4, 5, 6}, {99, 100}},
+ {12114, 1.4f, 2.5f, {1, 2, 3}, {4, 5, 6}, {99, 100}},
+ {12115, 1.4f, 2.5f, {1, 2, 3}, {4, 5, 6}, {99, 100}},
+ {12116, 1.4f, 2.5f, {1, 2, 3}, {4, 5, 6}, {99, 100}},
+ {12117, 1.4f, 2.5f, {1, 2, 3}, {4, 5, 6}, {99, 100}},
+ {12118, 1.4f, 2.5f, {1, 2, 3}, {4, 5, 6}, {99, 100}},
+ {12119, 1.4f, 2.5f, {1, 2, 3}, {4, 5, 6}, {99, 100}}};
/*-------------------------------------------------------------------------
- * initialize table parameters
- * 1) size and the offsets of struct members in memory
- * 2) field names
- * 3) define a HDF5 type for the fields
- *-------------------------------------------------------------------------
- */
-
- size_t type_size_mem = sizeof( particle_t );
- size_t field_offset[NFIELDS]=
- {
- HOFFSET( particle_t, name ),
- HOFFSET( particle_t, longi ),
- HOFFSET( particle_t, pressure ),
- HOFFSET( particle_t, temperature ),
- HOFFSET( particle_t, lati )
- };
- size_t field_size[NFIELDS] =
- {
- sizeof( rbuf[0].name),
- sizeof( rbuf[0].longi),
- sizeof( rbuf[0].pressure),
- sizeof( rbuf[0].temperature),
- sizeof( rbuf[0].lati)
- };
+ * initialize table parameters
+ * 1) size and the offsets of struct members in memory
+ * 2) field names
+ * 3) define a HDF5 type for the fields
+ *-------------------------------------------------------------------------
+ */
+
+ size_t type_size_mem = sizeof(particle_t);
+ size_t field_offset[NFIELDS] = {HOFFSET(particle_t, name), HOFFSET(particle_t, longi),
+ HOFFSET(particle_t, pressure), HOFFSET(particle_t, temperature),
+ HOFFSET(particle_t, lati)};
+ size_t field_size[NFIELDS] = {sizeof(rbuf[0].name), sizeof(rbuf[0].longi), sizeof(rbuf[0].pressure),
+ sizeof(rbuf[0].temperature), sizeof(rbuf[0].lati)};
- const char *field_names4[NFIELDS+1] =
- { "F1", "F2", "F3", "F4", "F5", "F6"};
- hid_t field_type4[NFIELDS+1];
- particle4_t fill_data[1] = { {9999999, -9999999, 999999, {999,999,999},{999,999,999}, {999,999}} };
+ const char *field_names4[NFIELDS + 1] = {"F1", "F2", "F3", "F4", "F5", "F6"};
+ hid_t field_type4[NFIELDS + 1];
+ particle4_t fill_data[1] = {{9999999, -9999999, 999999, {999, 999, 999}, {999, 999, 999}, {999, 999}}};
- hsize_t nfields_out;
- hsize_t nrecords_out;
- hid_t arry3_32f;
- hid_t arry2_32f;
- hsize_t dims;
+ hsize_t nfields_out;
+ hsize_t nrecords_out;
+ hid_t arry3_32f;
+ hid_t arry2_32f;
+ hsize_t dims;
- const char *field_names[NFIELDS] =
- { "Name","Longitude","Pressure","Temperature","Latitude" };
- hid_t field_type[NFIELDS];
- hid_t string_type = H5Tcopy( H5T_C_S1 );
+ const char *field_names[NFIELDS] = {"Name", "Longitude", "Pressure", "Temperature", "Latitude"};
+ hid_t field_type[NFIELDS];
+ hid_t string_type = H5Tcopy(H5T_C_S1);
- H5Tset_size( string_type, 16 );
+ H5Tset_size(string_type, 16);
field_type[0] = string_type;
field_type[1] = H5T_NATIVE_LONG;
field_type[2] = H5T_NATIVE_FLOAT;
@@ -444,21 +378,19 @@ static int test_table(hid_t fid, int do_write)
field_type[4] = H5T_NATIVE_INT;
/*-------------------------------------------------------------------------
- *
- * Functions tested:
- *
- * H5TBmake_table
- * H5TBread_table
- *
- *-------------------------------------------------------------------------
- */
- if (do_write)
- {
+ *
+ * Functions tested:
+ *
+ * H5TBmake_table
+ * H5TBread_table
+ *
+ *-------------------------------------------------------------------------
+ */
+ if (do_write) {
HL_TESTING2("making table");
- if (H5TBmake_table(TITLE,fid,"table1",FIELDS,RECORDS,type_size_mem,
- field_names,field_offset,field_type,
- chunk_size,fill,compress,wbuf)<0)
+ if (H5TBmake_table(TITLE, fid, "table1", FIELDS, RECORDS, type_size_mem, field_names, field_offset,
+ field_type, chunk_size, fill, compress, wbuf) < 0)
goto out;
PASSED();
}
@@ -466,61 +398,56 @@ static int test_table(hid_t fid, int do_write)
HL_TESTING2("reading table");
/*-------------------------------------------------------------------------
- * read the table
- *-------------------------------------------------------------------------
- */
+ * read the table
+ *-------------------------------------------------------------------------
+ */
- if (H5TBread_table(fid,"table1",type_size_mem,field_offset,field_size,rbuf)<0)
+ if (H5TBread_table(fid, "table1", type_size_mem, field_offset, field_size, rbuf) < 0)
goto out;
/* compare the extracted table with the original array */
- for( i = 0; i < NRECORDS; i++ )
- {
- if (cmp_par(i,i,rbuf,wbuf)<0)
+ for (i = 0; i < NRECORDS; i++) {
+ if (cmp_par(i, i, rbuf, wbuf) < 0)
goto out;
}
PASSED();
-
/*-------------------------------------------------------------------------
- *
- * Functions tested:
- *
- * H5TBwrite_records
- *
- *-------------------------------------------------------------------------
- */
- if (do_write)
- {
+ *
+ * Functions tested:
+ *
+ * H5TBwrite_records
+ *
+ *-------------------------------------------------------------------------
+ */
+ if (do_write) {
HL_TESTING2("writing records");
/* create an empty table */
- if (H5TBmake_table(TITLE,fid,"table2",FIELDS,RECORDS,type_size_mem,
- field_names,field_offset,field_type,
- chunk_size,fill,compress,0)<0)
+ if (H5TBmake_table(TITLE, fid, "table2", FIELDS, RECORDS, type_size_mem, field_names, field_offset,
+ field_type, chunk_size, fill, compress, 0) < 0)
goto out;
/*-------------------------------------------------------------------------
- * write records, start at 0, write 8
- * pos = 0 1 2 3 4 5 6 7
- * data= 0 1 2 3 4 5 6 7
- *-------------------------------------------------------------------------
- */
- wstart=0;
- wrecords=8;
- if (H5TBwrite_records(fid,"table2",wstart,wrecords,type_size_mem,field_offset,
- field_size,wbuf)<0)
+ * write records, start at 0, write 8
+ * pos = 0 1 2 3 4 5 6 7
+ * data= 0 1 2 3 4 5 6 7
+ *-------------------------------------------------------------------------
+ */
+ wstart = 0;
+ wrecords = 8;
+ if (H5TBwrite_records(fid, "table2", wstart, wrecords, type_size_mem, field_offset, field_size,
+ wbuf) < 0)
goto out;
/* read it back */
- if (H5TBread_table(fid,"table2",type_size_mem,field_offset,field_size,rbuf)<0)
+ if (H5TBread_table(fid, "table2", type_size_mem, field_offset, field_size, rbuf) < 0)
goto out;
/* compare */
- for( i = 0; i < NRECORDS; i++ )
- {
- if (cmp_par(i,i,rbuf,wbuf)<0)
+ for (i = 0; i < NRECORDS; i++) {
+ if (cmp_par(i, i, rbuf, wbuf) < 0)
goto out;
}
@@ -528,147 +455,139 @@ static int test_table(hid_t fid, int do_write)
}
/*-------------------------------------------------------------------------
- *
- * Functions tested:
- *
- * H5TBread_records
- *
- *-------------------------------------------------------------------------
- */
+ *
+ * Functions tested:
+ *
+ * H5TBread_records
+ *
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("reading records");
/*-------------------------------------------------------------------------
- * read records, start at 0, read 8
- * pos = 0 1 2 3 4 5 6 7
- * data= 0 1 2 3 4 5 6 7
- *-------------------------------------------------------------------------
- */
+ * read records, start at 0, read 8
+ * pos = 0 1 2 3 4 5 6 7
+ * data= 0 1 2 3 4 5 6 7
+ *-------------------------------------------------------------------------
+ */
/*-------------------------------------------------------------------------
- * for the read test we cannot use "table2" because it has been appended
- * we use the original "table1" instead
- *-------------------------------------------------------------------------
- */
- if(do_write)
- HDstrcpy(tname,"table2");
+ * for the read test we cannot use "table2" because it has been appended
+ * we use the original "table1" instead
+ *-------------------------------------------------------------------------
+ */
+ if (do_write)
+ HDstrcpy(tname, "table2");
else
- HDstrcpy(tname,"table1");
+ HDstrcpy(tname, "table1");
- rstart=0;
- rrecords=8;
- if (H5TBread_records(fid,tname,rstart,rrecords,type_size_mem,field_offset,
- field_size,rbuf)<0)
+ rstart = 0;
+ rrecords = 8;
+ if (H5TBread_records(fid, tname, rstart, rrecords, type_size_mem, field_offset, field_size, rbuf) < 0)
goto out;
/* compare */
- for( i = rstart; i < rrecords; i++)
- {
- if (cmp_par(i,i,rbuf,wbuf)<0)
+ for (i = rstart; i < rrecords; i++) {
+ if (cmp_par(i, i, rbuf, wbuf) < 0)
goto out;
}
PASSED();
/*-------------------------------------------------------------------------
- *
- * Functions tested:
- *
- * H5TBappend_records
- * H5TBread_records
- *
- *-------------------------------------------------------------------------
- */
- if (do_write)
- {
+ *
+ * Functions tested:
+ *
+ * H5TBappend_records
+ * H5TBread_records
+ *
+ *-------------------------------------------------------------------------
+ */
+ if (do_write) {
HL_TESTING2("appending records");
/*-------------------------------------------------------------------------
- * append 2 records
- * pos = 0 1 2 3 4 5 6 7 8 9
- * data= 0 1 2 3 4 5 6 7 8 9
- *-------------------------------------------------------------------------
- */
- arecords=2;
- if (H5TBappend_records(fid,"table2",arecords,type_size_mem,field_offset,field_size,abuf)<0)
+ * append 2 records
+ * pos = 0 1 2 3 4 5 6 7 8 9
+ * data= 0 1 2 3 4 5 6 7 8 9
+ *-------------------------------------------------------------------------
+ */
+ arecords = 2;
+ if (H5TBappend_records(fid, "table2", arecords, type_size_mem, field_offset, field_size, abuf) < 0)
return 1;
- if (H5TBget_table_info(fid,"table2",&rfields,&rrecords)<0)
+ if (H5TBget_table_info(fid, "table2", &rfields, &rrecords) < 0)
return 1;
- rstart=0; rrecords=NRECORDS+arecords;
- if (H5TBread_records(fid,"table2",rstart,rrecords,type_size_mem,field_offset,
- field_size,rbuf)<0)
+ rstart = 0;
+ rrecords = NRECORDS + arecords;
+ if (H5TBread_records(fid, "table2", rstart, rrecords, type_size_mem, field_offset, field_size, rbuf) <
+ 0)
return 1;
/* compare */
- wrecords=8;
- for( i = rstart; i< wrecords; i++)
- {
- if (cmp_par(i,i,rbuf,wbuf)<0)
+ wrecords = 8;
+ for (i = rstart; i < wrecords; i++) {
+ if (cmp_par(i, i, rbuf, wbuf) < 0)
goto out;
}
- for( i = wrecords, j = 0; i < rrecords; i++,j++)
- {
- if (cmp_par(i,j,rbuf,abuf)<0)
+ for (i = wrecords, j = 0; i < rrecords; i++, j++) {
+ if (cmp_par(i, j, rbuf, abuf) < 0)
goto out;
}
PASSED();
}
/*-------------------------------------------------------------------------
- *
- * Functions tested:
- *
- * H5TBinsert_record
- * H5TBread_records
- *
- *-------------------------------------------------------------------------
- */
- if (do_write)
- {
+ *
+ * Functions tested:
+ *
+ * H5TBinsert_record
+ * H5TBread_records
+ *
+ *-------------------------------------------------------------------------
+ */
+ if (do_write) {
HL_TESTING2("inserting records");
/*-------------------------------------------------------------------------
- * insert 2 records
- * pos = 0 1 2 3 4 5 6 7 8 9 10 11
- * data= 0 0 0 1 2 3 4 5 6 7 8 9
- *-------------------------------------------------------------------------
- */
- istart=1; irecords=2;
- if (H5TBinsert_record(fid,"table2",istart,irecords,type_size_mem,field_offset,field_size,ibuf)<0)
+ * insert 2 records
+ * pos = 0 1 2 3 4 5 6 7 8 9 10 11
+ * data= 0 0 0 1 2 3 4 5 6 7 8 9
+ *-------------------------------------------------------------------------
+ */
+ istart = 1;
+ irecords = 2;
+ if (H5TBinsert_record(fid, "table2", istart, irecords, type_size_mem, field_offset, field_size,
+ ibuf) < 0)
return 1;
- if (H5TBget_table_info(fid,"table2",&rfields,&rrecords)<0)
+ if (H5TBget_table_info(fid, "table2", &rfields, &rrecords) < 0)
return 1;
- if (H5TBread_records(fid,"table2",rstart,rrecords,type_size_mem,field_offset,
- field_size,rbuf)<0)
+ if (H5TBread_records(fid, "table2", rstart, rrecords, type_size_mem, field_offset, field_size, rbuf) <
+ 0)
return 1;
/* compare */
- for( i = 0; i < 12; i++)
- {
- if (i < istart)
- {
- if (cmp_par(i,i,rbuf,wbuf)<0)
+ for (i = 0; i < 12; i++) {
+ if (i < istart) {
+ if (cmp_par(i, i, rbuf, wbuf) < 0)
goto out;
}
- else if (i >= istart && i < istart + irecords)
- {
+ else if (i >= istart && i < istart + irecords) {
j = i - istart;
- if (cmp_par(i,j,rbuf,ibuf)<0)
+ if (cmp_par(i, j, rbuf, ibuf) < 0)
goto out;
}
- else if ( i >= istart + irecords && i < 10 )
- {
+ else if (i >= istart + irecords && i < 10) {
j = i - irecords;
- if (cmp_par(i,j,rbuf,wbuf)<0)
+ if (cmp_par(i, j, rbuf, wbuf) < 0)
goto out;
}
- else
- {
+ else {
j = i - 10;
- if (cmp_par(i,j,rbuf,abuf)<0)
+ if (cmp_par(i, j, rbuf, abuf) < 0)
goto out;
}
}
@@ -676,198 +595,192 @@ static int test_table(hid_t fid, int do_write)
}
/*-------------------------------------------------------------------------
- *
- * Functions tested:
- *
- * H5TBdelete_record
- * H5TBread_records
- *
- *-------------------------------------------------------------------------
- */
- if (do_write)
- {
+ *
+ * Functions tested:
+ *
+ * H5TBdelete_record
+ * H5TBread_records
+ *
+ *-------------------------------------------------------------------------
+ */
+ if (do_write) {
HL_TESTING2("deleting records");
/*-------------------------------------------------------------------------
- * Create a table
- * pos = 0 1 2 3 4 5 6 7
- * data= 0 1 2 3 4 5 6 7
- *-------------------------------------------------------------------------
- */
-
- for( i=0; i<NRECORDS; i++)
- {
- wbufd[i].lati = wbuf[i].lati;
- wbufd[i].longi = wbuf[i].longi;
- wbufd[i].pressure = wbuf[i].pressure;
+ * Create a table
+ * pos = 0 1 2 3 4 5 6 7
+ * data= 0 1 2 3 4 5 6 7
+ *-------------------------------------------------------------------------
+ */
+
+ for (i = 0; i < NRECORDS; i++) {
+ wbufd[i].lati = wbuf[i].lati;
+ wbufd[i].longi = wbuf[i].longi;
+ wbufd[i].pressure = wbuf[i].pressure;
wbufd[i].temperature = wbuf[i].temperature;
- HDstrcpy(wbufd[i].name, wbuf[i].name );
-
+ HDstrcpy(wbufd[i].name, wbuf[i].name);
}
-
- if (H5TBmake_table(TITLE,fid,"table3",FIELDS,RECORDS,type_size_mem,
- field_names,field_offset,field_type,
- chunk_size,fill,compress,wbufd)<0)
+ if (H5TBmake_table(TITLE, fid, "table3", FIELDS, RECORDS, type_size_mem, field_names, field_offset,
+ field_type, chunk_size, fill, compress, wbufd) < 0)
goto out;
/*-------------------------------------------------------------------------
- * Delete records, start at 2, delete 3
- * pos = 0 1 2 3 4
- * data= 0 1 5 6 7
- *-------------------------------------------------------------------------
- */
- dstart=2; drecords=3;
- if (H5TBdelete_record(fid,"table3",dstart,drecords)<0)
+ * Delete records, start at 2, delete 3
+ * pos = 0 1 2 3 4
+ * data= 0 1 5 6 7
+ *-------------------------------------------------------------------------
+ */
+ dstart = 2;
+ drecords = 3;
+ if (H5TBdelete_record(fid, "table3", dstart, drecords) < 0)
goto out;
- if (H5TBget_table_info(fid,"table3",&rfields,&rrecords)<0)
+ if (H5TBget_table_info(fid, "table3", &rfields, &rrecords) < 0)
goto out;
- rstart=0;
- if (H5TBread_records(fid,"table3",rstart,rrecords,type_size_mem,field_offset,
- field_size,rbuf)<0)
+ rstart = 0;
+ if (H5TBread_records(fid, "table3", rstart, rrecords, type_size_mem, field_offset, field_size, rbuf) <
+ 0)
goto out;
/* compare */
- nrecords=NRECORDS;
- assert(rrecords == nrecords-drecords);
- if (compare_deleted(rrecords,dstart,drecords,rbuf,wbufd)<0)
+ nrecords = NRECORDS;
+ assert(rrecords == nrecords - drecords);
+ if (compare_deleted(rrecords, dstart, drecords, rbuf, wbufd) < 0)
goto out;
/*-------------------------------------------------------------------------
- * reset compare buffer
- *-------------------------------------------------------------------------
- */
- nrecords=rrecords;
- for( i=0; i<nrecords; i++)
- {
+ * reset compare buffer
+ *-------------------------------------------------------------------------
+ */
+ nrecords = rrecords;
+ for (i = 0; i < nrecords; i++) {
wbufd[i] = rbuf[i];
}
/*-------------------------------------------------------------------------
- * Delete records, start at 0, delete 2
- * pos = 0 1 2
- * data= 5 6 7
- *-------------------------------------------------------------------------
- */
- dstart=0; drecords=2;
- if (H5TBdelete_record(fid,"table3",dstart,drecords)<0)
+ * Delete records, start at 0, delete 2
+ * pos = 0 1 2
+ * data= 5 6 7
+ *-------------------------------------------------------------------------
+ */
+ dstart = 0;
+ drecords = 2;
+ if (H5TBdelete_record(fid, "table3", dstart, drecords) < 0)
goto out;
- if (H5TBget_table_info(fid,"table3",&rfields,&rrecords)<0)
+ if (H5TBget_table_info(fid, "table3", &rfields, &rrecords) < 0)
goto out;
- rstart=0;
- if (H5TBread_records(fid,"table3",rstart,rrecords,type_size_mem,field_offset,
- field_size,rbuf)<0)
+ rstart = 0;
+ if (H5TBread_records(fid, "table3", rstart, rrecords, type_size_mem, field_offset, field_size, rbuf) <
+ 0)
goto out;
/* Compare */
- assert(rrecords == nrecords-drecords);
- if (compare_deleted(rrecords,dstart,drecords,rbuf,wbufd)<0)
+ assert(rrecords == nrecords - drecords);
+ if (compare_deleted(rrecords, dstart, drecords, rbuf, wbufd) < 0)
goto out;
/*-------------------------------------------------------------------------
- * reset compare buffer
- *-------------------------------------------------------------------------
- */
- nrecords=rrecords;
- for( i=0; i<nrecords; i++)
- {
+ * reset compare buffer
+ *-------------------------------------------------------------------------
+ */
+ nrecords = rrecords;
+ for (i = 0; i < nrecords; i++) {
wbufd[i] = rbuf[i];
}
/*-------------------------------------------------------------------------
- * Delete records, start at 1, delete 1
- * pos = 0 1
- * data= 5 7
- *-------------------------------------------------------------------------
- */
- dstart=1; drecords=1;
- if (H5TBdelete_record(fid,"table3",dstart,drecords)<0)
+ * Delete records, start at 1, delete 1
+ * pos = 0 1
+ * data= 5 7
+ *-------------------------------------------------------------------------
+ */
+ dstart = 1;
+ drecords = 1;
+ if (H5TBdelete_record(fid, "table3", dstart, drecords) < 0)
goto out;
- if (H5TBget_table_info(fid,"table3",&rfields,&rrecords)<0)
+ if (H5TBget_table_info(fid, "table3", &rfields, &rrecords) < 0)
goto out;
- rstart=0;
- if (H5TBread_records(fid,"table3",rstart,rrecords,type_size_mem,field_offset,
- field_size,rbuf)<0)
+ rstart = 0;
+ if (H5TBread_records(fid, "table3", rstart, rrecords, type_size_mem, field_offset, field_size, rbuf) <
+ 0)
goto out;
/* Compare */
- assert(rrecords == nrecords-drecords);
- if (compare_deleted(rrecords,dstart,drecords,rbuf,wbufd)<0)
+ assert(rrecords == nrecords - drecords);
+ if (compare_deleted(rrecords, dstart, drecords, rbuf, wbufd) < 0)
goto out;
/*-------------------------------------------------------------------------
- * reset compare buffer
- *-------------------------------------------------------------------------
- */
- nrecords=rrecords;
- for( i=0; i<nrecords; i++)
- {
+ * reset compare buffer
+ *-------------------------------------------------------------------------
+ */
+ nrecords = rrecords;
+ for (i = 0; i < nrecords; i++) {
wbufd[i] = rbuf[i];
}
/*-------------------------------------------------------------------------
- * Delete records, start at 0, delete 1
- * pos = 0
- * data= 7
- *-------------------------------------------------------------------------
- */
- dstart=0; drecords=1;
- if (H5TBdelete_record(fid,"table3",dstart,drecords)<0)
+ * Delete records, start at 0, delete 1
+ * pos = 0
+ * data= 7
+ *-------------------------------------------------------------------------
+ */
+ dstart = 0;
+ drecords = 1;
+ if (H5TBdelete_record(fid, "table3", dstart, drecords) < 0)
goto out;
- if (H5TBget_table_info(fid,"table3",&rfields,&rrecords)<0)
+ if (H5TBget_table_info(fid, "table3", &rfields, &rrecords) < 0)
goto out;
- rstart=0;
- if (H5TBread_records(fid,"table3",rstart,rrecords,type_size_mem,field_offset,
- field_size,rbuf)<0)
+ rstart = 0;
+ if (H5TBread_records(fid, "table3", rstart, rrecords, type_size_mem, field_offset, field_size, rbuf) <
+ 0)
goto out;
/* Compare */
- assert(rrecords == nrecords-drecords);
- if (compare_deleted(rrecords,dstart,drecords,rbuf,wbufd)<0)
+ assert(rrecords == nrecords - drecords);
+ if (compare_deleted(rrecords, dstart, drecords, rbuf, wbufd) < 0)
goto out;
/*-------------------------------------------------------------------------
- * reset compare buffer
- *-------------------------------------------------------------------------
- */
- nrecords=rrecords;
- for( i=0; i<nrecords; i++)
- {
+ * reset compare buffer
+ *-------------------------------------------------------------------------
+ */
+ nrecords = rrecords;
+ for (i = 0; i < nrecords; i++) {
wbufd[i] = rbuf[i];
}
/* Read complete table */
- if (H5TBread_table(fid,"table3",type_size_mem,field_offset,field_size,rbuf)<0)
+ if (H5TBread_table(fid, "table3", type_size_mem, field_offset, field_size, rbuf) < 0)
goto out;
/* Compare */
- for( i=0; i<rrecords; i++)
- {
- if (cmp_par(i,i,rbuf,wbufd)<0)
- {
+ for (i = 0; i < rrecords; i++) {
+ if (cmp_par(i, i, rbuf, wbufd) < 0) {
goto out;
}
}
/*-------------------------------------------------------------------------
- * Delete records, start at 0, delete 1
- * pos = 0
- * data= empty
- *-------------------------------------------------------------------------
- */
- dstart=0; drecords=1;
- if (H5TBdelete_record(fid,"table3",dstart,drecords)<0)
+ * Delete records, start at 0, delete 1
+ * pos = 0
+ * data= empty
+ *-------------------------------------------------------------------------
+ */
+ dstart = 0;
+ drecords = 1;
+ if (H5TBdelete_record(fid, "table3", dstart, drecords) < 0)
goto out;
- if (H5TBget_table_info(fid,"table3",&rfields,&rrecords)<0)
+ if (H5TBget_table_info(fid, "table3", &rfields, &rrecords) < 0)
goto out;
if (rrecords)
@@ -884,104 +797,97 @@ static int test_table(hid_t fid, int do_write)
*
*-------------------------------------------------------------------------
*/
- if (do_write)
- {
+ if (do_write) {
HL_TESTING2("deleting records (differing memory layout)");
- dims = 3;
- arry3_32f = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, &dims);
-
- dims = 2;
- arry2_32f = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, &dims);
-
- /* Initialize the field field_type */
- field_type4[0] = H5T_NATIVE_UINT32;
- field_type4[1] = H5T_NATIVE_DOUBLE;
- field_type4[2] = H5T_NATIVE_DOUBLE;
- field_type4[3] = arry3_32f;
- field_type4[4] = arry3_32f;
- field_type4[5] = arry2_32f;
-
- /* Make the table */
- if (H5TBmake_table("Table Title",fid,"table",NFIELDS+1,(hsize_t)NRECORDS,
- tbl_size, field_names4, tbl_offset, field_type4,
- chunk_size, fill_data, compress, p_data)<0)
- goto out;
- /* Delete records */
- start = 3;
- nrecords = 3;
- if (H5TBdelete_record(fid, "table", start, nrecords)<0)
- goto out;;
- /* Get table info */
- if (H5TBget_table_info(fid,"table", &nfields_out, &nrecords_out)<0)
- goto out;
- /* check */
- if( (int)nfields_out != (int)NFIELDS+1)
- goto out;
-
- if( (int)nrecords_out != (int)NRECORDS-3)
- goto out;
-
- /* close type */
- H5Tclose(arry3_32f);
- H5Tclose(arry2_32f);
+ dims = 3;
+ arry3_32f = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, &dims);
- PASSED();
+ dims = 2;
+ arry2_32f = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, &dims);
+
+ /* Initialize the field field_type */
+ field_type4[0] = H5T_NATIVE_UINT32;
+ field_type4[1] = H5T_NATIVE_DOUBLE;
+ field_type4[2] = H5T_NATIVE_DOUBLE;
+ field_type4[3] = arry3_32f;
+ field_type4[4] = arry3_32f;
+ field_type4[5] = arry2_32f;
+
+ /* Make the table */
+ if (H5TBmake_table("Table Title", fid, "table", NFIELDS + 1, (hsize_t)NRECORDS, tbl_size,
+ field_names4, tbl_offset, field_type4, chunk_size, fill_data, compress,
+ p_data) < 0)
+ goto out;
+ /* Delete records */
+ start = 3;
+ nrecords = 3;
+ if (H5TBdelete_record(fid, "table", start, nrecords) < 0)
+ goto out;
+ ;
+ /* Get table info */
+ if (H5TBget_table_info(fid, "table", &nfields_out, &nrecords_out) < 0)
+ goto out;
+ /* check */
+ if ((int)nfields_out != (int)NFIELDS + 1)
+ goto out;
+
+ if ((int)nrecords_out != (int)NRECORDS - 3)
+ goto out;
+
+ /* close type */
+ H5Tclose(arry3_32f);
+ H5Tclose(arry2_32f);
+
+ PASSED();
}
/*-------------------------------------------------------------------------
- *
- * Functions tested:
- *
- * H5TBadd_records_from
- * H5TBread_records
- *
- *-------------------------------------------------------------------------
- */
+ *
+ * Functions tested:
+ *
+ * H5TBadd_records_from
+ * H5TBread_records
+ *
+ *-------------------------------------------------------------------------
+ */
- if (do_write)
- {
+ if (do_write) {
HL_TESTING2("adding records");
/* create 2 tables */
- if (H5TBmake_table(TITLE,fid,"table4",FIELDS,RECORDS,type_size_mem,
- field_names,field_offset,field_type,
- chunk_size,fill,compress,wbuf)<0)
+ if (H5TBmake_table(TITLE, fid, "table4", FIELDS, RECORDS, type_size_mem, field_names, field_offset,
+ field_type, chunk_size, fill, compress, wbuf) < 0)
goto out;
- if (H5TBmake_table(TITLE,fid,"table5",FIELDS,RECORDS,type_size_mem,
- field_names,field_offset,field_type,
- chunk_size,fill,compress,wbuf)<0)
+ if (H5TBmake_table(TITLE, fid, "table5", FIELDS, RECORDS, type_size_mem, field_names, field_offset,
+ field_type, chunk_size, fill, compress, wbuf) < 0)
goto out;
/* add the records from "table4" to "table5" */
- start1 = 3;
- nrecords = 2;
- start2 = 6;
- if ( H5TBadd_records_from(fid,"table4",start1,nrecords,"table5",start2)<0)
+ start1 = 3;
+ nrecords = 2;
+ start2 = 6;
+ if (H5TBadd_records_from(fid, "table4", start1, nrecords, "table5", start2) < 0)
goto out;
/* read final table */
- if (H5TBread_table(fid,"table5",type_size_mem,field_offset,field_size,rbuf)<0)
+ if (H5TBread_table(fid, "table5", type_size_mem, field_offset, field_size, rbuf) < 0)
goto out;
/* compare */
- for( i = 0; i < NRECORDS+2; i++ )
- {
- if ( i < start2 )
- {
- if (cmp_par(i,i,rbuf,wbuf)<0)
+ for (i = 0; i < NRECORDS + 2; i++) {
+ if (i < start2) {
+ if (cmp_par(i, i, rbuf, wbuf) < 0)
goto out;
}
- else if ( i < start2 + nrecords )
- {
+ else if (i < start2 + nrecords) {
j = i - start1;
- if (cmp_par(i,j,rbuf,wbuf)<0)
+ if (cmp_par(i, j, rbuf, wbuf) < 0)
goto out;
}
- else
- {
+ else {
j = i - nrecords;
- if (cmp_par(i,j,rbuf,wbuf)<0)
+ if (cmp_par(i, j, rbuf, wbuf) < 0)
goto out;
}
}
@@ -990,90 +896,79 @@ static int test_table(hid_t fid, int do_write)
}
/*-------------------------------------------------------------------------
- *
- * Functions tested:
- *
- * H5TBcombine_tables
- * H5TBread_table
- *
- *-------------------------------------------------------------------------
- */
+ *
+ * Functions tested:
+ *
+ * H5TBcombine_tables
+ * H5TBread_table
+ *
+ *-------------------------------------------------------------------------
+ */
- if (do_write)
- {
+ if (do_write) {
HL_TESTING2("combining tables");
/* create 2 tables */
- if (H5TBmake_table(TITLE,fid,"table6",FIELDS,RECORDS,type_size_mem,
- field_names,field_offset,field_type,
- chunk_size,fill,compress,wbuf)<0)
+ if (H5TBmake_table(TITLE, fid, "table6", FIELDS, RECORDS, type_size_mem, field_names, field_offset,
+ field_type, chunk_size, fill, compress, wbuf) < 0)
goto out;
- if (H5TBmake_table(TITLE,fid,"table7",FIELDS,RECORDS,type_size_mem,
- field_names,field_offset,field_type,
- chunk_size,fill,compress,wbuf)<0)
+ if (H5TBmake_table(TITLE, fid, "table7", FIELDS, RECORDS, type_size_mem, field_names, field_offset,
+ field_type, chunk_size, fill, compress, wbuf) < 0)
goto out;
/* combine the two tables into a third */
- if ( H5TBcombine_tables(fid,"table6",fid,"table7","table8")<0)
+ if (H5TBcombine_tables(fid, "table6", fid, "table7", "table8") < 0)
goto out;
/* read merged table */
- if (H5TBread_table(fid,"table8",type_size_mem,field_offset,field_size,rbufc)<0)
+ if (H5TBread_table(fid, "table8", type_size_mem, field_offset, field_size, rbufc) < 0)
goto out;
/* compare */
- for( i = 0; i < NRECORDS*2; i++ )
- {
- if ( i < NRECORDS )
- {
- if (cmp_par(i,i,rbufc,wbuf)<0)
+ for (i = 0; i < NRECORDS * 2; i++) {
+ if (i < NRECORDS) {
+ if (cmp_par(i, i, rbufc, wbuf) < 0)
goto out;
}
- else
- {
- if (cmp_par(i,i-NRECORDS,rbufc,wbuf)<0)
+ else {
+ if (cmp_par(i, i - NRECORDS, rbufc, wbuf) < 0)
goto out;
}
}
/*-------------------------------------------------------------------------
- * multi file test
- *-------------------------------------------------------------------------
- */
+ * multi file test
+ *-------------------------------------------------------------------------
+ */
/* create 2 files using default properties. */
- fid1 = H5Fcreate("combine_tables1.h5",H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT);
- fid2 = H5Fcreate("combine_tables2.h5",H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT);
+ fid1 = H5Fcreate("combine_tables1.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ fid2 = H5Fcreate("combine_tables2.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
/* create 2 tables, one in each file */
- if (H5TBmake_table(TITLE,fid1,"table1",FIELDS,RECORDS,type_size_mem,
- field_names,field_offset,field_type,
- chunk_size,fill,compress,wbuf)<0)
+ if (H5TBmake_table(TITLE, fid1, "table1", FIELDS, RECORDS, type_size_mem, field_names, field_offset,
+ field_type, chunk_size, fill, compress, wbuf) < 0)
goto out;
- if (H5TBmake_table(TITLE,fid2,"table2",FIELDS,RECORDS,type_size_mem,
- field_names,field_offset,field_type,
- chunk_size,fill,compress,wbuf)<0)
+ if (H5TBmake_table(TITLE, fid2, "table2", FIELDS, RECORDS, type_size_mem, field_names, field_offset,
+ field_type, chunk_size, fill, compress, wbuf) < 0)
goto out;
/* combine the two tables into a third */
- if ( H5TBcombine_tables(fid1,"table1",fid2,"table2","table3")<0)
+ if (H5TBcombine_tables(fid1, "table1", fid2, "table2", "table3") < 0)
goto out;
/* read merged table */
- if (H5TBread_table(fid1,"table3",type_size_mem,field_offset,field_size,rbufc)<0)
+ if (H5TBread_table(fid1, "table3", type_size_mem, field_offset, field_size, rbufc) < 0)
goto out;
/* compare */
- for( i = 0; i < NRECORDS*2; i++ )
- {
- if ( i < NRECORDS )
- {
- if (cmp_par(i,i,rbufc,wbuf)<0)
+ for (i = 0; i < NRECORDS * 2; i++) {
+ if (i < NRECORDS) {
+ if (cmp_par(i, i, rbufc, wbuf) < 0)
goto out;
}
- else
- {
- if (cmp_par(i,i-NRECORDS,rbufc,wbuf)<0)
+ else {
+ if (cmp_par(i, i - NRECORDS, rbufc, wbuf) < 0)
goto out;
}
}
@@ -1085,98 +980,87 @@ static int test_table(hid_t fid, int do_write)
PASSED();
}
-
/*-------------------------------------------------------------------------
- *
- * Functions tested:
- *
- * H5TBwrite_fields_name
- *
- *-------------------------------------------------------------------------
- */
- if (do_write)
- {
+ *
+ * Functions tested:
+ *
+ * H5TBwrite_fields_name
+ *
+ *-------------------------------------------------------------------------
+ */
+ if (do_write) {
HL_TESTING2("writing fields by name");
/* make an empty table with fill values */
- if (H5TBmake_table(TITLE,fid,"table9",FIELDS,RECORDS,type_size_mem,
- field_names,field_offset,field_type,
- chunk_size,fill1,compress,0)<0)
+ if (H5TBmake_table(TITLE, fid, "table9", FIELDS, RECORDS, type_size_mem, field_names, field_offset,
+ field_type, chunk_size, fill1, compress, 0) < 0)
goto out;
/* write the pressure field starting at record 2 */
start = 2;
nrecords = NRECORDS_ADD;
- if (H5TBwrite_fields_name(fid,"table9","Pressure",start,nrecords,sizeof(float),
- 0,field_sizes_pre,pressure_in)<0)
+ if (H5TBwrite_fields_name(fid, "table9", "Pressure", start, nrecords, sizeof(float), 0,
+ field_sizes_pre, pressure_in) < 0)
goto out;
/* write the new longitude and latitude information starting at record 2 */
start = 2;
nrecords = 3;
- if (H5TBwrite_fields_name(fid,"table9","Latitude,Longitude",start,nrecords,sizeof(position_t),
- field_offset_pos,field_sizes_pos,position_in)<0)
+ if (H5TBwrite_fields_name(fid, "table9", "Latitude,Longitude", start, nrecords, sizeof(position_t),
+ field_offset_pos, field_sizes_pos, position_in) < 0)
goto out;
/* read back the all table */
start = 0;
nrecords = NRECORDS;
- if (H5TBread_table(fid,"table9",type_size_mem,field_offset,field_size,rbuf)<0)
+ if (H5TBread_table(fid, "table9", type_size_mem, field_offset, field_size, rbuf) < 0)
goto out;
{
-
/* compare the read values with the initial values */
- for( i = 0; i < NRECORDS; i++ )
- {
- if ( i >= 2 && i <= 4 )
- {
- if ( rbuf[i].lati != position_in[i-NRECORDS_ADD+1].lati ||
- rbuf[i].longi != position_in[i-NRECORDS_ADD+1].longi ||
- !H5_FLT_ABS_EQUAL(rbuf[i].pressure,pressure_in[i-NRECORDS_ADD+1]) )
- {
- HDfprintf(stderr,"%ld %f %d\n",
- rbuf[i].longi,(double)rbuf[i].pressure,rbuf[i].lati);
- HDfprintf(stderr,"%ld %f %d\n",
- position_in[i].longi,(double)pressure_in[i],position_in[i].lati);
+ for (i = 0; i < NRECORDS; i++) {
+ if (i >= 2 && i <= 4) {
+ if (rbuf[i].lati != position_in[i - NRECORDS_ADD + 1].lati ||
+ rbuf[i].longi != position_in[i - NRECORDS_ADD + 1].longi ||
+ !H5_FLT_ABS_EQUAL(rbuf[i].pressure, pressure_in[i - NRECORDS_ADD + 1])) {
+ HDfprintf(stderr, "%ld %f %d\n", rbuf[i].longi, (double)rbuf[i].pressure,
+ rbuf[i].lati);
+ HDfprintf(stderr, "%ld %f %d\n", position_in[i].longi, (double)pressure_in[i],
+ position_in[i].lati);
goto out;
}
}
}
}
-
-
PASSED();
} /*write*/
/*-------------------------------------------------------------------------
- *
- * Functions tested:
- *
- * H5TBread_fields_name
- *
- *-------------------------------------------------------------------------
- */
+ *
+ * Functions tested:
+ *
+ * H5TBread_fields_name
+ *
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("reading fields by name");
/*-------------------------------------------------------------------------
- * write and read the "Pressure" field
- *-------------------------------------------------------------------------
- */
- if (do_write)
- {
- if (H5TBmake_table(TITLE,fid,"table10",FIELDS,RECORDS,type_size_mem,
- field_names,field_offset,field_type,
- chunk_size,fill1,compress,0)<0)
+ * write and read the "Pressure" field
+ *-------------------------------------------------------------------------
+ */
+ if (do_write) {
+ if (H5TBmake_table(TITLE, fid, "table10", FIELDS, RECORDS, type_size_mem, field_names, field_offset,
+ field_type, chunk_size, fill1, compress, 0) < 0)
goto out;
/* write the pressure field to all the records */
start = 0;
nrecords = NRECORDS;
- if ( H5TBwrite_fields_name(fid,"table10","Pressure",start,nrecords,
- sizeof( float ),0,field_sizes_pre,pressure_in)<0)
+ if (H5TBwrite_fields_name(fid, "table10", "Pressure", start, nrecords, sizeof(float), 0,
+ field_sizes_pre, pressure_in) < 0)
goto out;
}
@@ -1184,170 +1068,149 @@ static int test_table(hid_t fid, int do_write)
nrecords = NRECORDS;
/* read an invalid field, should fail */
- if ( H5TBread_fields_name(fid,"table10","DoesNotExist",start,nrecords,
- sizeof(float),0,field_sizes_pre,pressure_out) >=0)
- goto out;
+ if (H5TBread_fields_name(fid, "table10", "DoesNotExist", start, nrecords, sizeof(float), 0,
+ field_sizes_pre, pressure_out) >= 0)
+ goto out;
/* read the "Pressure" field */
- if ( H5TBread_fields_name(fid,"table10","Pressure",start,nrecords,
- sizeof(float),0,field_sizes_pre,pressure_out)<0)
+ if (H5TBread_fields_name(fid, "table10", "Pressure", start, nrecords, sizeof(float), 0, field_sizes_pre,
+ pressure_out) < 0)
goto out;
/* Compare the extracted table with the initial values */
- for ( i = 0; i < NRECORDS; i++ )
- {
- if ( !H5_FLT_ABS_EQUAL(pressure_out[i], pressure_in[i]) ) {
+ for (i = 0; i < NRECORDS; i++) {
+ if (!H5_FLT_ABS_EQUAL(pressure_out[i], pressure_in[i])) {
goto out;
}
}
/*-------------------------------------------------------------------------
- * Write and read the "Latitude,Longitude" fields
- *-------------------------------------------------------------------------
- */
- if (do_write)
- {
+ * Write and read the "Latitude,Longitude" fields
+ *-------------------------------------------------------------------------
+ */
+ if (do_write) {
/* Write the new longitude and latitude information to all the records */
start = 0;
nrecords = NRECORDS_ADD;
- if ( H5TBwrite_fields_name(fid,"table10", "Latitude,Longitude", start, nrecords,
- sizeof( position_t ), field_offset_pos, field_sizes_pos, position_in ) < 0 )
+ if (H5TBwrite_fields_name(fid, "table10", "Latitude,Longitude", start, nrecords, sizeof(position_t),
+ field_offset_pos, field_sizes_pos, position_in) < 0)
goto out;
- }/*write*/
+ } /*write*/
/* Read the "Latitude,Longitude" fields */
start = 0;
nrecords = NRECORDS_ADD;
- if ( H5TBread_fields_name( fid, "table10", "Latitude,Longitude",
- start, nrecords, sizeof(position_t), field_offset_pos, field_sizes_pos, position_out ) < 0 )
+ if (H5TBread_fields_name(fid, "table10", "Latitude,Longitude", start, nrecords, sizeof(position_t),
+ field_offset_pos, field_sizes_pos, position_out) < 0)
goto out;
-
/* Compare the extracted table with the initial values */
- for( i = 0; i < NRECORDS_ADD; i++ )
- {
- if ( position_out[i].lati != position_in[i].lati ||
- position_out[i].longi != position_in[i].longi )
+ for (i = 0; i < NRECORDS_ADD; i++) {
+ if (position_out[i].lati != position_in[i].lati || position_out[i].longi != position_in[i].longi)
goto out;
}
-
/*-------------------------------------------------------------------------
- * Write and read the "Name,Pressure" fields
- *-------------------------------------------------------------------------
- */
- if (do_write)
- {
+ * Write and read the "Name,Pressure" fields
+ *-------------------------------------------------------------------------
+ */
+ if (do_write) {
/* Write the new name and pressure information to all the records */
start = 0;
nrecords = NRECORDS;
- if ( H5TBwrite_fields_name( fid, "table10", "Name,Pressure", start, nrecords,
- sizeof( namepressure_t ), field_offset_namepre, field_sizes_namepre, namepre_in ) < 0 )
+ if (H5TBwrite_fields_name(fid, "table10", "Name,Pressure", start, nrecords, sizeof(namepressure_t),
+ field_offset_namepre, field_sizes_namepre, namepre_in) < 0)
goto out;
- }/*write*/
+ } /*write*/
/* Read the "Name,Pressure" fields */
start = 0;
nrecords = NRECORDS;
- if ( H5TBread_fields_name( fid, "table10", "Name,Pressure",
- start, nrecords, sizeof(namepressure_t), field_offset_namepre, field_sizes_namepre,
- namepre_out ) < 0 )
+ if (H5TBread_fields_name(fid, "table10", "Name,Pressure", start, nrecords, sizeof(namepressure_t),
+ field_offset_namepre, field_sizes_namepre, namepre_out) < 0)
goto out;
-
/* Compare the extracted table with the initial values */
- for( i = 0; i < NRECORDS; i++ )
- {
- if ( ( HDstrcmp( namepre_out[i].name, namepre_in[i].name ) != 0 ) ||
- !H5_FLT_ABS_EQUAL(namepre_out[i].pressure,namepre_in[i].pressure) ) {
- goto out;
+ for (i = 0; i < NRECORDS; i++) {
+ if ((HDstrcmp(namepre_out[i].name, namepre_in[i].name) != 0) ||
+ !H5_FLT_ABS_EQUAL(namepre_out[i].pressure, namepre_in[i].pressure)) {
+ goto out;
}
}
/* reset buffer */
- for( i = 0; i < NRECORDS; i++ )
- {
- HDstrcpy( namepre_out[i].name, "\0" );
+ for (i = 0; i < NRECORDS; i++) {
+ HDstrcpy(namepre_out[i].name, "\0");
namepre_out[i].pressure = -1;
}
/*-------------------------------------------------------------------------
- * read only 3 records of the "Name,Pressure" fields, starting at record 2
- *-------------------------------------------------------------------------
- */
+ * read only 3 records of the "Name,Pressure" fields, starting at record 2
+ *-------------------------------------------------------------------------
+ */
start = 2;
nrecords = 3;
- if ( H5TBread_fields_name( fid, "table10", "Name,Pressure",
- start, nrecords, sizeof(namepressure_t), field_offset_namepre,
- field_sizes_namepre, namepre_out ) < 0 )
+ if (H5TBread_fields_name(fid, "table10", "Name,Pressure", start, nrecords, sizeof(namepressure_t),
+ field_offset_namepre, field_sizes_namepre, namepre_out) < 0)
goto out;
-
/* Compare the extracted table with the initial values */
- for( i = 0; i < 3; i++ )
- {
+ for (i = 0; i < 3; i++) {
hsize_t iistart = start;
- if ( ( HDstrcmp( namepre_out[i].name, namepre_in[iistart+i].name ) != 0 ) ||
- !H5_FLT_ABS_EQUAL(namepre_out[i].pressure, namepre_in[iistart+i].pressure) ) {
- goto out;
+ if ((HDstrcmp(namepre_out[i].name, namepre_in[iistart + i].name) != 0) ||
+ !H5_FLT_ABS_EQUAL(namepre_out[i].pressure, namepre_in[iistart + i].pressure)) {
+ goto out;
}
}
-
-
PASSED();
/*-------------------------------------------------------------------------
- *
- * Functions tested:
- *
- * H5TBwrite_fields_index
- *
- *-------------------------------------------------------------------------
- */
- if (do_write)
- {
+ *
+ * Functions tested:
+ *
+ * H5TBwrite_fields_index
+ *
+ *-------------------------------------------------------------------------
+ */
+ if (do_write) {
HL_TESTING2("writing fields by index");
/* make an empty table */
- if (H5TBmake_table(TITLE,fid,"table11",FIELDS,RECORDS,type_size_mem,
- field_names,field_offset,field_type,
- chunk_size,fill,compress,NULL)<0)
+ if (H5TBmake_table(TITLE, fid, "table11", FIELDS, RECORDS, type_size_mem, field_names, field_offset,
+ field_type, chunk_size, fill, compress, NULL) < 0)
goto out;
/* write the pressure field starting at record 2 */
nfields = 1;
start = 2;
nrecords = NRECORDS_ADD;
- if ( H5TBwrite_fields_index(fid, "table11", nfields, field_index_pre, start, nrecords,
- sizeof( float ), 0, field_sizes_pre, pressure_in ) < 0 )
+ if (H5TBwrite_fields_index(fid, "table11", nfields, field_index_pre, start, nrecords, sizeof(float),
+ 0, field_sizes_pre, pressure_in) < 0)
goto out;
-
/* write the new longitude and latitude information starting at record 2 */
nfields = 2;
start = 2;
nrecords = NRECORDS_ADD;
- if ( H5TBwrite_fields_index(fid, "table11", nfields, field_index_pos, start, nrecords,
- sizeof( position_t ), field_offset_pos, field_sizes_pos, position_in ) < 0 )
+ if (H5TBwrite_fields_index(fid, "table11", nfields, field_index_pos, start, nrecords,
+ sizeof(position_t), field_offset_pos, field_sizes_pos, position_in) < 0)
goto out;
/* read back the all table */
nfields = 5;
start = 0;
nrecords = NRECORDS;
- if ( H5TBread_fields_index(fid, "table11", nfields, field_index,
- start, nrecords, type_size_mem, field_offset, field_size, rbuf ) < 0 )
+ if (H5TBread_fields_index(fid, "table11", nfields, field_index, start, nrecords, type_size_mem,
+ field_offset, field_size, rbuf) < 0)
goto out;
/* Compare the extracted table with the initial values */
- for( i = 0; i < NRECORDS; i++ )
- {
- if ( i >= 2 && i <= 4 )
- {
- if ( rbuf[i].lati != position_in[i-NRECORDS_ADD+1].lati ||
- rbuf[i].longi != position_in[i-NRECORDS_ADD+1].longi ||
- !H5_FLT_ABS_EQUAL(rbuf[i].pressure,pressure_in[i-NRECORDS_ADD+1]) )
+ for (i = 0; i < NRECORDS; i++) {
+ if (i >= 2 && i <= 4) {
+ if (rbuf[i].lati != position_in[i - NRECORDS_ADD + 1].lati ||
+ rbuf[i].longi != position_in[i - NRECORDS_ADD + 1].longi ||
+ !H5_FLT_ABS_EQUAL(rbuf[i].pressure, pressure_in[i - NRECORDS_ADD + 1]))
goto out;
}
}
@@ -1355,37 +1218,34 @@ static int test_table(hid_t fid, int do_write)
PASSED();
}
-
/*-------------------------------------------------------------------------
- *
- * Functions tested:
- *
- * H5TBread_fields_index
- *
- *-------------------------------------------------------------------------
- */
+ *
+ * Functions tested:
+ *
+ * H5TBread_fields_index
+ *
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("reading fields by index");
- if (do_write)
- {
+ if (do_write) {
/* make an empty table */
- if (H5TBmake_table(TITLE,fid,"table12",FIELDS,RECORDS,type_size_mem,
- field_names,field_offset,field_type,
- chunk_size,fill,compress,NULL)<0)
+ if (H5TBmake_table(TITLE, fid, "table12", FIELDS, RECORDS, type_size_mem, field_names, field_offset,
+ field_type, chunk_size, fill, compress, NULL) < 0)
goto out;
/*-------------------------------------------------------------------------
- * write and read the "Pressure" field
- *-------------------------------------------------------------------------
- */
+ * write and read the "Pressure" field
+ *-------------------------------------------------------------------------
+ */
/* write the pressure field to all the records */
nfields = 1;
start = 0;
nrecords = NRECORDS;
- if ( H5TBwrite_fields_index(fid, "table12", nfields, field_index_pre, start, nrecords,
- sizeof( float ), 0, field_sizes_pre, pressure_in ) < 0 )
+ if (H5TBwrite_fields_index(fid, "table12", nfields, field_index_pre, start, nrecords, sizeof(float),
+ 0, field_sizes_pre, pressure_in) < 0)
goto out;
}
@@ -1393,196 +1253,178 @@ static int test_table(hid_t fid, int do_write)
nfields = 1;
start = 0;
nrecords = NRECORDS;
- if ( H5TBread_fields_index(fid, "table12", nfields, field_index_pre,
- start, nrecords, sizeof(float), 0, field_sizes_pre, pressure_out ) < 0 )
+ if (H5TBread_fields_index(fid, "table12", nfields, field_index_pre, start, nrecords, sizeof(float), 0,
+ field_sizes_pre, pressure_out) < 0)
goto out;
/* compare the extracted table with the initial values */
- for( i = 0; i < NRECORDS; i++ )
- {
- if ( !H5_FLT_ABS_EQUAL(pressure_out[i], pressure_in[i]) ) {
+ for (i = 0; i < NRECORDS; i++) {
+ if (!H5_FLT_ABS_EQUAL(pressure_out[i], pressure_in[i])) {
goto out;
}
}
/*-------------------------------------------------------------------------
- * write and read the "Latitude,Longitude" fields
- *-------------------------------------------------------------------------
- */
- if (do_write)
- {
+ * write and read the "Latitude,Longitude" fields
+ *-------------------------------------------------------------------------
+ */
+ if (do_write) {
/* write the new longitude and latitude information to all the records */
- nfields = 2;
+ nfields = 2;
start = 0;
nrecords = NRECORDS;
- if ( H5TBwrite_fields_index(fid, "table12", nfields, field_index_pos, start, nrecords,
- sizeof( position_t ), field_offset_pos, field_sizes_pos, position_in ) < 0 )
+ if (H5TBwrite_fields_index(fid, "table12", nfields, field_index_pos, start, nrecords,
+ sizeof(position_t), field_offset_pos, field_sizes_pos, position_in) < 0)
goto out;
} /*write*/
/* read the "Latitude,Longitude" fields */
- nfields = 2;
+ nfields = 2;
start = 0;
nrecords = NRECORDS_ADD;
- if ( H5TBread_fields_index(fid, "table12", nfields, field_index_pos,
- start, nrecords, sizeof(position_t), field_offset_pos, field_sizes_pos, position_out ) < 0 )
+ if (H5TBread_fields_index(fid, "table12", nfields, field_index_pos, start, nrecords, sizeof(position_t),
+ field_offset_pos, field_sizes_pos, position_out) < 0)
goto out;
/* compare the extracted table with the initial values */
- for( i = 0; i < NRECORDS_ADD; i++ )
- {
- if ( position_out[i].lati != position_in[i].lati ||
- position_out[i].longi != position_in[i].longi ) {
- goto out;
+ for (i = 0; i < NRECORDS_ADD; i++) {
+ if (position_out[i].lati != position_in[i].lati || position_out[i].longi != position_in[i].longi) {
+ goto out;
}
}
/*-------------------------------------------------------------------------
- * write and read the "Name,Pressure" fields
- *-------------------------------------------------------------------------
- */
+ * write and read the "Name,Pressure" fields
+ *-------------------------------------------------------------------------
+ */
- if (do_write)
- {
+ if (do_write) {
/* write the new name and pressure information to all the records */
- nfields = 2;
+ nfields = 2;
start = 0;
nrecords = NRECORDS;
- if ( H5TBwrite_fields_index(fid, "table12", nfields, field_index_namepre, start, nrecords,
- sizeof( namepressure_t ), field_offset_namepre, field_sizes_namepre, namepre_in ) < 0 )
+ if (H5TBwrite_fields_index(fid, "table12", nfields, field_index_namepre, start, nrecords,
+ sizeof(namepressure_t), field_offset_namepre, field_sizes_namepre,
+ namepre_in) < 0)
goto out;
}
/* read the "Name,Pressure" fields */
- nfields = 2;
+ nfields = 2;
start = 0;
nrecords = NRECORDS;
- if ( H5TBread_fields_index(fid, "table12", nfields, field_index_namepre,
- start, nrecords, sizeof(namepressure_t), field_offset_namepre,
- field_sizes_namepre, namepre_out ) < 0 )
+ if (H5TBread_fields_index(fid, "table12", nfields, field_index_namepre, start, nrecords,
+ sizeof(namepressure_t), field_offset_namepre, field_sizes_namepre,
+ namepre_out) < 0)
goto out;
/* compare the extracted table with the initial values */
- for( i = 0; i < NRECORDS; i++ )
- {
- if ( ( HDstrcmp( namepre_out[i].name, namepre_in[i].name ) != 0 ) ||
- !H5_FLT_ABS_EQUAL(namepre_out[i].pressure,namepre_in[i].pressure) ) {
- goto out;
- }
+ for (i = 0; i < NRECORDS; i++) {
+ if ((HDstrcmp(namepre_out[i].name, namepre_in[i].name) != 0) ||
+ !H5_FLT_ABS_EQUAL(namepre_out[i].pressure, namepre_in[i].pressure)) {
+ goto out;
+ }
}
/* reset buffer */
- for( i = 0; i < NRECORDS; i++ )
- {
- HDstrcpy( namepre_out[i].name, "\0" );
+ for (i = 0; i < NRECORDS; i++) {
+ HDstrcpy(namepre_out[i].name, "\0");
namepre_out[i].pressure = -1;
}
/*-------------------------------------------------------------------------
- * read only 3 records of the "Name,Pressure" fields, starting at record 2
- *-------------------------------------------------------------------------
- */
+ * read only 3 records of the "Name,Pressure" fields, starting at record 2
+ *-------------------------------------------------------------------------
+ */
/* write the new name and pressure information to all the records */
nfields = 2;
start = 2;
nrecords = 3;
- if ( H5TBread_fields_index(fid, "table12", nfields, field_index_namepre,
- start, nrecords, sizeof(namepressure_t), field_offset_namepre,
- field_sizes_namepre, namepre_out ) < 0 )
+ if (H5TBread_fields_index(fid, "table12", nfields, field_index_namepre, start, nrecords,
+ sizeof(namepressure_t), field_offset_namepre, field_sizes_namepre,
+ namepre_out) < 0)
goto out;
/* compare the extracted table with the initial values */
- for( i = 0; i < 3; i++ )
- {
- int iistart = (int) start;
- if ( ( HDstrcmp( namepre_out[i].name, wbuf[iistart+(int)i].name ) != 0 ) ||
- !H5_FLT_ABS_EQUAL(namepre_out[i].pressure, wbuf[iistart+(int)i].pressure) ) {
- goto out;
+ for (i = 0; i < 3; i++) {
+ int iistart = (int)start;
+ if ((HDstrcmp(namepre_out[i].name, wbuf[iistart + (int)i].name) != 0) ||
+ !H5_FLT_ABS_EQUAL(namepre_out[i].pressure, wbuf[iistart + (int)i].pressure)) {
+ goto out;
}
}
PASSED();
-
/*-------------------------------------------------------------------------
- *
- * Functions tested:
- *
- * H5TBinsert_field
- *
- *-------------------------------------------------------------------------
- */
+ *
+ * Functions tested:
+ *
+ * H5TBinsert_field
+ *
+ *-------------------------------------------------------------------------
+ */
- if (do_write)
- {
+ if (do_write) {
HL_TESTING2("inserting fields");
/* make a table */
- if (H5TBmake_table(TITLE,fid,"table13",FIELDS,RECORDS,type_size_mem,
- field_names,field_offset,field_type,
- chunk_size,fill1,compress,wbuf)<0)
+ if (H5TBmake_table(TITLE, fid, "table13", FIELDS, RECORDS, type_size_mem, field_names, field_offset,
+ field_type, chunk_size, fill1, compress, wbuf) < 0)
goto out;
/* insert the new field at the end of the field list */
position = NFIELDS;
- if ( H5TBinsert_field( fid, "table13", "New Field", field_type_new, position,
- fill1_new, buf_new ) < 0 )
+ if (H5TBinsert_field(fid, "table13", "New Field", field_type_new, position, fill1_new, buf_new) < 0)
goto out;
/* read the table */
- if ( H5TBread_table( fid, "table13", dst_size2, dst_offset2, dst_sizes2, rbuf2 ) < 0 )
+ if (H5TBread_table(fid, "table13", dst_size2, dst_offset2, dst_sizes2, rbuf2) < 0)
goto out;
/* compare the extracted table with the original array */
- for( i = 0; i < NRECORDS; i++ )
- {
- if ( ( HDstrcmp( rbuf2[i].name, wbuf[i].name ) != 0 ) ||
- rbuf2[i].lati != wbuf[i].lati ||
- rbuf2[i].longi != wbuf[i].longi ||
- !H5_FLT_ABS_EQUAL(rbuf2[i].pressure,wbuf[i].pressure) ||
- !H5_DBL_ABS_EQUAL(rbuf2[i].temperature,wbuf[i].temperature) ||
- rbuf2[i].new_field != buf_new[i] ) {
- goto out;
+ for (i = 0; i < NRECORDS; i++) {
+ if ((HDstrcmp(rbuf2[i].name, wbuf[i].name) != 0) || rbuf2[i].lati != wbuf[i].lati ||
+ rbuf2[i].longi != wbuf[i].longi || !H5_FLT_ABS_EQUAL(rbuf2[i].pressure, wbuf[i].pressure) ||
+ !H5_DBL_ABS_EQUAL(rbuf2[i].temperature, wbuf[i].temperature) ||
+ rbuf2[i].new_field != buf_new[i]) {
+ goto out;
}
}
PASSED();
}
/*-------------------------------------------------------------------------
- *
- * Functions tested:
- *
- * H5TBdelete_field
- *
- *-------------------------------------------------------------------------
- */
- if (do_write)
- {
+ *
+ * Functions tested:
+ *
+ * H5TBdelete_field
+ *
+ *-------------------------------------------------------------------------
+ */
+ if (do_write) {
HL_TESTING2("deleting fields");
/* make a table */
- if (H5TBmake_table(TITLE,fid,"table14",FIELDS,RECORDS,type_size_mem,
- field_names,field_offset,field_type,
- chunk_size,fill,compress,wbuf)<0)
+ if (H5TBmake_table(TITLE, fid, "table14", FIELDS, RECORDS, type_size_mem, field_names, field_offset,
+ field_type, chunk_size, fill, compress, wbuf) < 0)
goto out;
/* delete the field */
- if ( H5TBdelete_field(fid, "table14", "Pressure" ) < 0 )
+ if (H5TBdelete_field(fid, "table14", "Pressure") < 0)
goto out;
/* read the table */
- if ( H5TBread_table(fid, "table14", dst_size3, dst_offset3, dst_sizes3, rbuf3 ) < 0 )
+ if (H5TBread_table(fid, "table14", dst_size3, dst_offset3, dst_sizes3, rbuf3) < 0)
goto out;
/* compare the extracted table with the original array */
- for( i = 0; i < NRECORDS; i++ )
- {
- if ( ( HDstrcmp( rbuf3[i].name, wbuf[i].name ) != 0 ) ||
- rbuf3[i].lati != wbuf[i].lati ||
+ for (i = 0; i < NRECORDS; i++) {
+ if ((HDstrcmp(rbuf3[i].name, wbuf[i].name) != 0) || rbuf3[i].lati != wbuf[i].lati ||
rbuf3[i].longi != wbuf[i].longi ||
- !H5_DBL_ABS_EQUAL(rbuf3[i].temperature,wbuf[i].temperature) ) {
- goto out;
+ !H5_DBL_ABS_EQUAL(rbuf3[i].temperature, wbuf[i].temperature)) {
+ goto out;
}
}
@@ -1590,143 +1432,140 @@ static int test_table(hid_t fid, int do_write)
}
/*-------------------------------------------------------------------------
- *
- * Functions tested:
- *
- * H5TBget_table_info
- * H5TBget_field_info
- *
- *-------------------------------------------------------------------------
- */
+ *
+ * Functions tested:
+ *
+ * H5TBget_table_info
+ * H5TBget_field_info
+ *
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("getting table info");
/* get table info */
- if ( H5TBget_table_info (fid, "table1", &rfields, &rrecords ) < 0 )
+ if (H5TBget_table_info(fid, "table1", &rfields, &rrecords) < 0)
goto out;
- if ( NFIELDS != rfields || rrecords != NRECORDS ) {
+ if (NFIELDS != rfields || rrecords != NRECORDS) {
goto out;
}
PASSED();
/*-------------------------------------------------------------------------
- *
- * Functions tested:
- *
- * H5TBget_field_info
- *
- *-------------------------------------------------------------------------
- */
+ *
+ * Functions tested:
+ *
+ * H5TBget_field_info
+ *
+ *-------------------------------------------------------------------------
+ */
HL_TESTING2("getting field info");
/* alocate */
- names_out = (char**) HDmalloc( sizeof(char*) * (size_t)NFIELDS );
- for ( i = 0; i < NFIELDS; i++)
- {
- names_out[i] = (char*) HDmalloc( sizeof(char) * 255 );
+ names_out = (char **)HDmalloc(sizeof(char *) * (size_t)NFIELDS);
+ for (i = 0; i < NFIELDS; i++) {
+ names_out[i] = (char *)HDmalloc(sizeof(char) * 255);
}
/* Get field info */
- if ( H5TBget_field_info(fid, "table1", names_out, sizes_out, offset_out, &size_out ) < 0 )
+ if (H5TBget_field_info(fid, "table1", names_out, sizes_out, offset_out, &size_out) < 0)
goto out;
- for ( i = 0; i < NFIELDS; i++)
- {
- if ( (HDstrcmp( field_names[i], names_out[i] ) != 0)) {
+ for (i = 0; i < NFIELDS; i++) {
+ if ((HDstrcmp(field_names[i], names_out[i]) != 0)) {
goto out;
}
}
/* release */
- for ( i = 0; i < NFIELDS; i++)
- {
- HDfree ( names_out[i] );
+ for (i = 0; i < NFIELDS; i++) {
+ HDfree(names_out[i]);
}
- HDfree ( names_out );
+ HDfree(names_out);
PASSED();
/*-------------------------------------------------------------------------
- * end
- *-------------------------------------------------------------------------
- */
+ * end
+ *-------------------------------------------------------------------------
+ */
return 0;
out:
H5_FAILED();
return -1;
}
-
/*-------------------------------------------------------------------------
-* the main program
-*-------------------------------------------------------------------------
-*/
+ * the main program
+ *-------------------------------------------------------------------------
+ */
-int main(void)
+int
+main(void)
{
- hid_t fid; /* identifier for the file */
- unsigned flags=H5F_ACC_RDONLY;
+ hid_t fid; /* identifier for the file */
+ unsigned flags = H5F_ACC_RDONLY;
/*-------------------------------------------------------------------------
- * test1: create a file for the write/read test
- *-------------------------------------------------------------------------
- */
+ * test1: create a file for the write/read test
+ *-------------------------------------------------------------------------
+ */
/* create a file using default properties */
- fid=H5Fcreate("test_table.h5",H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT);
+ fid = H5Fcreate("test_table.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
HDputs("Testing table with file creation mode (read/write in native architecture):");
/* test, do write */
- if (test_table(fid,1)<0)
+ if (test_table(fid, 1) < 0)
goto out;
/* close */
H5Fclose(fid);
/*-------------------------------------------------------------------------
- * test2: open a file written in test1 on a big-endian machine
- *-------------------------------------------------------------------------
- */
+ * test2: open a file written in test1 on a big-endian machine
+ *-------------------------------------------------------------------------
+ */
HDputs("Testing table with file open mode (read big-endian data):");
- fid=h5file_open(TEST_FILE_BE,flags);
+ fid = h5file_open(TEST_FILE_BE, flags);
/* test, do not write */
- if (test_table(fid,0)<0)
+ if (test_table(fid, 0) < 0)
goto out;
/* close */
H5Fclose(fid);
/*-------------------------------------------------------------------------
- * test3: open a file written in test1 on a little-endian machine
- *-------------------------------------------------------------------------
- */
+ * test3: open a file written in test1 on a little-endian machine
+ *-------------------------------------------------------------------------
+ */
HDputs("Testing table with file open mode (read little-endian data):");
- fid=h5file_open(TEST_FILE_LE,flags);
+ fid = h5file_open(TEST_FILE_LE, flags);
/* test, do not write */
- if (test_table(fid,0)<0)
+ if (test_table(fid, 0) < 0)
goto out;
/* close */
H5Fclose(fid);
/*-------------------------------------------------------------------------
- * test4: open a file written in test1 on the Cray T3 machine
- *-------------------------------------------------------------------------
- */
+ * test4: open a file written in test1 on the Cray T3 machine
+ *-------------------------------------------------------------------------
+ */
HDputs("Testing table with file open mode (read Cray data):");
- fid=h5file_open(TEST_FILE_CRAY,flags);
+ fid = h5file_open(TEST_FILE_CRAY, flags);
/* test, do not write */
- if (test_table(fid,0)<0)
+ if (test_table(fid, 0) < 0)
goto out;
/* close */
@@ -1737,5 +1576,3 @@ out:
H5Fclose(fid);
return 1;
}
-
-