summaryrefslogtreecommitdiffstats
path: root/test/tattr.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/tattr.c')
-rw-r--r--test/tattr.c189
1 files changed, 63 insertions, 126 deletions
diff --git a/test/tattr.c b/test/tattr.c
index a8e604b..ded9a79 100644
--- a/test/tattr.c
+++ b/test/tattr.c
@@ -169,10 +169,8 @@ test_attr_basic_write(void)
/* Verify values read in */
for(i=0; i<ATTR1_DIM1; i++)
- if(attr_data1[i]!=read_data1[i]) {
- printf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n",__LINE__,i,attr_data1[i],i,read_data1[i]);
- num_errs++;
- } /* end if */
+ if(attr_data1[i]!=read_data1[i])
+ TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n",__LINE__,i,attr_data1[i],i,read_data1[i]);
/* Close attribute */
ret=H5Aclose(attr);
@@ -211,10 +209,8 @@ test_attr_basic_write(void)
/* Verify values read in */
for(i=0; i<ATTR1_DIM1; i++)
- if(attr_data1[i]!=read_data1[i]) {
- printf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n",__LINE__,i,attr_data1[i],i,read_data1[i]);
- num_errs++;
- } /* end if */
+ if(attr_data1[i]!=read_data1[i])
+ TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n",__LINE__,i,attr_data1[i],i,read_data1[i]);
/* Close attribute */
ret=H5Aclose(attr);
@@ -246,10 +242,8 @@ test_attr_basic_write(void)
/* Verify values read in */
for(i=0; i<ATTR1_DIM1; i++)
- if(attr_data1a[i]!=read_data1[i]) {
- printf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n",__LINE__,i,attr_data1[i],i,read_data1[i]);
- num_errs++;
- } /* end if */
+ if(attr_data1a[i]!=read_data1[i])
+ TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n",__LINE__,i,attr_data1[i],i,read_data1[i]);
/* Close attribute */
ret=H5Aclose(attr2);
@@ -355,10 +349,8 @@ test_attr_basic_read(void)
/* Verify values read in */
for(i=0; i<ATTR1_DIM1; i++)
- if(attr_data1[i]!=read_data1[i]) {
- printf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n",__LINE__,i,attr_data1[i],i,read_data1[i]);
- num_errs++;
- } /* end if */
+ if(attr_data1[i]!=read_data1[i])
+ TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n",__LINE__,i,attr_data1[i],i,read_data1[i]);
/* Close attribute */
ret=H5Aclose(attr);
@@ -385,10 +377,8 @@ test_attr_basic_read(void)
/* Verify values read in */
for(i=0; i<ATTR2_DIM1; i++)
for(j=0; j<ATTR2_DIM2; j++)
- if(attr_data2[i][j]!=read_data2[i][j]) {
- printf("%d: attribute data different: attr_data2[%d][%d]=%d, read_data2[%d][%d]=%d\n",__LINE__, i,j,attr_data2[i][j],i,j,read_data1[i]);
- num_errs++;
- } /* end if */
+ if(attr_data2[i][j]!=read_data2[i][j])
+ TestErrPrintf("%d: attribute data different: attr_data2[%d][%d]=%d, read_data2[%d][%d]=%d\n",__LINE__, i,j,attr_data2[i][j],i,j,read_data1[i]);
/* Close attribute */
ret=H5Aclose(attr);
@@ -545,14 +535,10 @@ test_attr_compound_read(void)
VERIFY(rank, ATTR4_RANK, "H5Sget_simple_extent_ndims");
ret=H5Sget_simple_extent_dims(space,dims, NULL);
CHECK(ret, FAIL, "H5Sget_simple_extent_dims");
- if(dims[0]!=ATTR4_DIM1) {
- printf("attribute dimensions different: dims[0]=%d, should be %d\n",(int)dims[0],ATTR4_DIM1);
- num_errs++;
- } /* end if */
- if(dims[1]!=ATTR4_DIM2) {
- printf("attribute dimensions different: dims[1]=%d, should be %d\n",(int)dims[1],ATTR4_DIM2);
- num_errs++;
- } /* end if */
+ if(dims[0]!=ATTR4_DIM1)
+ TestErrPrintf("attribute dimensions different: dims[0]=%d, should be %d\n",(int)dims[0],ATTR4_DIM1);
+ if(dims[1]!=ATTR4_DIM2)
+ TestErrPrintf("attribute dimensions different: dims[1]=%d, should be %d\n",(int)dims[1],ATTR4_DIM2);
H5Sclose(space);
/* Verify Datatype */
@@ -566,10 +552,8 @@ test_attr_compound_read(void)
fieldname=H5Tget_member_name(type,(unsigned)i);
if(!(HDstrcmp(fieldname,ATTR4_FIELDNAME1) ||
HDstrcmp(fieldname,ATTR4_FIELDNAME2) ||
- HDstrcmp(fieldname,ATTR4_FIELDNAME3))) {
- printf("invalid field name for field #%d: %s\n",i,fieldname);
- num_errs++;
- } /* end if */
+ HDstrcmp(fieldname,ATTR4_FIELDNAME3)))
+ TestErrPrintf("invalid field name for field #%d: %s\n",i,fieldname);
free(fieldname);
} /* end for */
offset=H5Tget_member_offset(type,0);
@@ -618,17 +602,14 @@ test_attr_compound_read(void)
if(HDmemcmp(&attr_data4[i][j],&read_data4[i][j],sizeof(struct attr4_struct))) {
printf("%d: attribute data different: attr_data4[%d][%d].i=%d, read_data4[%d][%d].i=%d\n",__LINE__,i,j,attr_data4[i][j].i,i,j,read_data4[i][j].i);
printf("%d: attribute data different: attr_data4[%d][%d].d=%f, read_data4[%d][%d].d=%f\n",__LINE__,i,j,attr_data4[i][j].d,i,j,read_data4[i][j].d);
- printf("%d: attribute data different: attr_data4[%d][%d].c=%c, read_data4[%d][%d].c=%c\n",__LINE__,i,j,attr_data4[i][j].c,i,j,read_data4[i][j].c);
- num_errs++;
+ TestErrPrintf("%d: attribute data different: attr_data4[%d][%d].c=%c, read_data4[%d][%d].c=%c\n",__LINE__,i,j,attr_data4[i][j].c,i,j,read_data4[i][j].c);
} /* end if */
/* Verify Name */
name_len=H5Aget_name(attr,ATTR_NAME_LEN, attr_name);
VERIFY(name_len, HDstrlen(ATTR4_NAME), "H5Aget_name");
- if(HDstrcmp(attr_name,ATTR4_NAME)) {
- printf("attribute name different: attr_name=%s, should be %s\n",attr_name,ATTR4_NAME);
- num_errs++;
- } /* end if */
+ if(HDstrcmp(attr_name,ATTR4_NAME))
+ TestErrPrintf("attribute name different: attr_name=%s, should be %s\n",attr_name,ATTR4_NAME);
/* Close attribute datatype */
ret=H5Tclose(type);
@@ -947,10 +928,8 @@ test_attr_mult_read(void)
VERIFY(rank, ATTR1_RANK, "H5Sget_simple_extent_ndims");
ret=H5Sget_simple_extent_dims(space,dims, NULL);
CHECK(ret, FAIL, "H5Sget_simple_extent_dims");
- if(dims[0]!=ATTR1_DIM1) {
- printf("attribute dimensions different: dims[0]=%d, should be %d\n",(int)dims[0],ATTR1_DIM1);
- num_errs++;
- } /* end if */
+ if(dims[0]!=ATTR1_DIM1)
+ TestErrPrintf("attribute dimensions different: dims[0]=%d, should be %d\n",(int)dims[0],ATTR1_DIM1);
H5Sclose(space);
/* Verify Datatype */
@@ -970,28 +949,22 @@ test_attr_mult_read(void)
/* Verify values read in */
for(i=0; i<ATTR1_DIM1; i++)
- if(attr_data1[i]!=read_data1[i]) {
- printf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n",__LINE__,i,attr_data1[i],i,read_data1[i]);
- num_errs++;
- } /* end if */
+ if(attr_data1[i]!=read_data1[i])
+ TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n",__LINE__,i,attr_data1[i],i,read_data1[i]);
/* Verify Name */
name_len=H5Aget_name(attr, ATTR_NAME_LEN, attr_name);
VERIFY(name_len, HDstrlen(ATTR1_NAME), "H5Aget_name");
- if(HDstrcmp(attr_name,ATTR1_NAME)) {
- printf("attribute name different: attr_name=%s, should be %s\n",attr_name,ATTR1_NAME);
- num_errs++;
- } /* end if */
+ if(HDstrcmp(attr_name,ATTR1_NAME))
+ TestErrPrintf("attribute name different: attr_name=%s, should be %s\n",attr_name,ATTR1_NAME);
/* Verify Name with too small of a buffer */
name_len=H5Aget_name(attr,HDstrlen(ATTR1_NAME), attr_name);
VERIFY(name_len, HDstrlen(ATTR1_NAME), "H5Aget_name");
HDstrcpy(temp_name,ATTR1_NAME); /* make a copy of the name */
temp_name[HDstrlen(ATTR1_NAME)-1]='\0'; /* truncate it to match the one retrieved */
- if(HDstrcmp(attr_name,temp_name)) {
- printf("attribute name different: attr_name=%s, should be %s\n",attr_name,temp_name);
- num_errs++;
- } /* end if */
+ if(HDstrcmp(attr_name,temp_name))
+ TestErrPrintf("attribute name different: attr_name=%s, should be %s\n",attr_name,temp_name);
/* Close attribute */
ret=H5Aclose(attr);
@@ -1008,14 +981,10 @@ test_attr_mult_read(void)
VERIFY(rank, ATTR2_RANK, "H5Sget_simple_extent_ndims");
ret=H5Sget_simple_extent_dims(space,dims, NULL);
CHECK(ret, FAIL, "H5Sget_simple_extent_dims");
- if(dims[0]!=ATTR2_DIM1) {
- printf("attribute dimensions different: dims[0]=%d, should be %d\n",(int)dims[0],ATTR2_DIM1);
- num_errs++;
- } /* end if */
- if(dims[1]!=ATTR2_DIM2) {
- printf("attribute dimensions different: dims[1]=%d, should be %d\n",(int)dims[1],ATTR2_DIM2);
- num_errs++;
- } /* end if */
+ if(dims[0]!=ATTR2_DIM1)
+ TestErrPrintf("attribute dimensions different: dims[0]=%d, should be %d\n",(int)dims[0],ATTR2_DIM1);
+ if(dims[1]!=ATTR2_DIM2)
+ TestErrPrintf("attribute dimensions different: dims[1]=%d, should be %d\n",(int)dims[1],ATTR2_DIM2);
H5Sclose(space);
/* Verify Datatype */
@@ -1036,28 +1005,22 @@ test_attr_mult_read(void)
/* Verify values read in */
for(i=0; i<ATTR2_DIM1; i++)
for(j=0; j<ATTR2_DIM2; j++)
- if(attr_data2[i][j]!=read_data2[i][j]) {
- printf("%d: attribute data different: attr_data2[%d][%d]=%d, read_data2[%d][%d]=%d\n",__LINE__,i,j,attr_data2[i][j],i,j,read_data2[i][j]);
- num_errs++;
- } /* end if */
+ if(attr_data2[i][j]!=read_data2[i][j])
+ TestErrPrintf("%d: attribute data different: attr_data2[%d][%d]=%d, read_data2[%d][%d]=%d\n",__LINE__,i,j,attr_data2[i][j],i,j,read_data2[i][j]);
/* Verify Name */
name_len=H5Aget_name(attr,ATTR_NAME_LEN, attr_name);
VERIFY(name_len, HDstrlen(ATTR2_NAME), "H5Aget_name");
- if(HDstrcmp(attr_name,ATTR2_NAME)) {
- printf("attribute name different: attr_name=%s, should be %s\n",attr_name,ATTR2_NAME);
- num_errs++;
- } /* end if */
+ if(HDstrcmp(attr_name,ATTR2_NAME))
+ TestErrPrintf("attribute name different: attr_name=%s, should be %s\n",attr_name,ATTR2_NAME);
/* Verify Name with too small of a buffer */
name_len=H5Aget_name(attr,HDstrlen(ATTR2_NAME), attr_name);
VERIFY(name_len, HDstrlen(ATTR2_NAME), "H5Aget_name");
HDstrcpy(temp_name,ATTR2_NAME); /* make a copy of the name */
temp_name[HDstrlen(ATTR2_NAME)-1]='\0'; /* truncate it to match the one retrieved */
- if(HDstrcmp(attr_name,temp_name)) {
- printf("attribute name different: attr_name=%s, should be %s\n",attr_name,temp_name);
- num_errs++;
- } /* end if */
+ if(HDstrcmp(attr_name,temp_name))
+ TestErrPrintf("attribute name different: attr_name=%s, should be %s\n",attr_name,temp_name);
/* Close attribute */
ret=H5Aclose(attr);
@@ -1074,18 +1037,12 @@ test_attr_mult_read(void)
VERIFY(rank, ATTR3_RANK, "H5Sget_simple_extent_ndims");
ret=H5Sget_simple_extent_dims(space,dims, NULL);
CHECK(ret, FAIL, "H5Sget_simple_extent_dims");
- if(dims[0]!=ATTR3_DIM1) {
- printf("attribute dimensions different: dims[0]=%d, should be %d\n",(int)dims[0],ATTR3_DIM1);
- num_errs++;
- } /* end if */
- if(dims[1]!=ATTR3_DIM2) {
- printf("attribute dimensions different: dims[1]=%d, should be %d\n",(int)dims[1],ATTR3_DIM2);
- num_errs++;
- } /* end if */
- if(dims[2]!=ATTR3_DIM3) {
- printf("attribute dimensions different: dims[2]=%d, should be %d\n",(int)dims[2],ATTR3_DIM3);
- num_errs++;
- } /* end if */
+ if(dims[0]!=ATTR3_DIM1)
+ TestErrPrintf("attribute dimensions different: dims[0]=%d, should be %d\n",(int)dims[0],ATTR3_DIM1);
+ if(dims[1]!=ATTR3_DIM2)
+ TestErrPrintf("attribute dimensions different: dims[1]=%d, should be %d\n",(int)dims[1],ATTR3_DIM2);
+ if(dims[2]!=ATTR3_DIM3)
+ TestErrPrintf("attribute dimensions different: dims[2]=%d, should be %d\n",(int)dims[2],ATTR3_DIM3);
H5Sclose(space);
/* Verify Datatype */
@@ -1107,28 +1064,22 @@ test_attr_mult_read(void)
for(i=0; i<ATTR3_DIM1; i++)
for(j=0; j<ATTR3_DIM2; j++)
for(k=0; k<ATTR3_DIM3; k++)
- if(attr_data3[i][j][k]!=read_data3[i][j][k]) {
- printf("%d: attribute data different: attr_data3[%d][%d][%d]=%f, read_data3[%d][%d][%d]=%f\n",__LINE__,i,j,k,attr_data3[i][j][k],i,j,k,read_data3[i][j][k]);
- num_errs++;
- } /* end if */
+ if(attr_data3[i][j][k]!=read_data3[i][j][k])
+ TestErrPrintf("%d: attribute data different: attr_data3[%d][%d][%d]=%f, read_data3[%d][%d][%d]=%f\n",__LINE__,i,j,k,attr_data3[i][j][k],i,j,k,read_data3[i][j][k]);
/* Verify Name */
name_len=H5Aget_name(attr,ATTR_NAME_LEN, attr_name);
VERIFY(name_len, HDstrlen(ATTR3_NAME), "H5Aget_name");
- if(HDstrcmp(attr_name,ATTR3_NAME)) {
- printf("attribute name different: attr_name=%s, should be %s\n",attr_name,ATTR3_NAME);
- num_errs++;
- } /* end if */
+ if(HDstrcmp(attr_name,ATTR3_NAME))
+ TestErrPrintf("attribute name different: attr_name=%s, should be %s\n",attr_name,ATTR3_NAME);
/* Verify Name with too small of a buffer */
name_len=H5Aget_name(attr,HDstrlen(ATTR3_NAME), attr_name);
VERIFY(name_len, HDstrlen(ATTR3_NAME), "H5Aget_name");
HDstrcpy(temp_name,ATTR3_NAME); /* make a copy of the name */
temp_name[HDstrlen(ATTR3_NAME)-1]='\0'; /* truncate it to match the one retrieved */
- if(HDstrcmp(attr_name,temp_name)) {
- printf("attribute name different: attr_name=%s, should be %s\n",attr_name,temp_name);
- num_errs++;
- } /* end if */
+ if(HDstrcmp(attr_name,temp_name))
+ TestErrPrintf("attribute name different: attr_name=%s, should be %s\n",attr_name,temp_name);
/* Close attribute */
ret=H5Aclose(attr);
@@ -1155,26 +1106,20 @@ herr_t attr_op1(hid_t UNUSED loc_id, const char *name, void *op_data)
switch(*count) {
case 0:
- if(HDstrcmp(name,ATTR1_NAME)) {
- printf("attribute name different: name=%s, should be %s\n",name,ATTR1_NAME);
- num_errs++;
- } /* end if */
+ if(HDstrcmp(name,ATTR1_NAME))
+ TestErrPrintf("attribute name different: name=%s, should be %s\n",name,ATTR1_NAME);
(*count)++;
break;
case 1:
- if(HDstrcmp(name,ATTR2_NAME)) {
- printf("attribute name different: name=%s, should be %s\n",name,ATTR2_NAME);
- num_errs++;
- } /* end if */
+ if(HDstrcmp(name,ATTR2_NAME))
+ TestErrPrintf("attribute name different: name=%s, should be %s\n",name,ATTR2_NAME);
(*count)++;
break;
case 2:
- if(HDstrcmp(name,ATTR3_NAME)) {
- printf("attribute name different: name=%s, should be %s\n",name,ATTR3_NAME);
- num_errs++;
- } /* end if */
+ if(HDstrcmp(name,ATTR3_NAME))
+ TestErrPrintf("attribute name different: name=%s, should be %s\n",name,ATTR3_NAME);
(*count)++;
break;
@@ -1310,10 +1255,8 @@ test_attr_delete(void)
/* Verify Name */
name_len=H5Aget_name(attr,ATTR_NAME_LEN,attr_name);
VERIFY(name_len, HDstrlen(ATTR1_NAME), "H5Aget_name");
- if(HDstrcmp(attr_name,ATTR1_NAME)) {
- printf("attribute name different: attr_name=%s, should be %s\n",attr_name,ATTR1_NAME);
- num_errs++;
- } /* end if */
+ if(HDstrcmp(attr_name,ATTR1_NAME))
+ TestErrPrintf("attribute name different: attr_name=%s, should be %s\n",attr_name,ATTR1_NAME);
/* Close attribute */
ret=H5Aclose(attr);
@@ -1326,10 +1269,8 @@ test_attr_delete(void)
/* Verify Name */
name_len=H5Aget_name(attr,ATTR_NAME_LEN, attr_name);
VERIFY(name_len, HDstrlen(ATTR3_NAME), "H5Aget_name");
- if(HDstrcmp(attr_name,ATTR3_NAME)) {
- printf("attribute name different: attr_name=%s, should be %s\n",attr_name,ATTR3_NAME);
- num_errs++;
- } /* end if */
+ if(HDstrcmp(attr_name,ATTR3_NAME))
+ TestErrPrintf("attribute name different: attr_name=%s, should be %s\n",attr_name,ATTR3_NAME);
/* Close attribute */
ret=H5Aclose(attr);
@@ -1350,10 +1291,8 @@ test_attr_delete(void)
/* Verify Name */
name_len=H5Aget_name(attr,ATTR_NAME_LEN, attr_name);
VERIFY(name_len, HDstrlen(ATTR3_NAME), "H5Aget_name");
- if(HDstrcmp(attr_name,ATTR3_NAME)) {
- printf("attribute name different: attr_name=%s, should be %s\n",attr_name,ATTR3_NAME);
- num_errs++;
- } /* end if */
+ if(HDstrcmp(attr_name,ATTR3_NAME))
+ TestErrPrintf("attribute name different: attr_name=%s, should be %s\n",attr_name,ATTR3_NAME);
/* Close attribute */
ret=H5Aclose(attr);
@@ -1410,10 +1349,8 @@ test_attr_dtype_shared(void)
/* Get size of file */
empty_filesize=h5_get_file_size(FILENAME);
- if(empty_filesize==0) {
- printf("Line %d: file size wrong!\n",__LINE__);
- num_errs++;
- } /* end if */
+ if(empty_filesize==0)
+ TestErrPrintf("Line %d: file size wrong!\n",__LINE__);
/* Re-open file */
file_id=H5Fopen(FILENAME,H5F_ACC_RDWR,H5P_DEFAULT);