Skip to content

Commit

Permalink
Add test H5Aget_name against H5Rget_attr_name
Browse files Browse the repository at this point in the history
  • Loading branch information
bmribler committed Aug 11, 2024
1 parent 92e5af3 commit 9d57f6a
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/trefer.c
Original file line number Diff line number Diff line change
Expand Up @@ -2470,6 +2470,8 @@ test_reference_attr(void)
unsigned i; /* Local index variables */
ssize_t namelen; /* String buffer size return value */
char *namebuf; /* Buffer for attribute's or dataset's name */
char *attr_name = NULL; /* name of attribute, from H5A */
ssize_t attr_name_size; /* size of attribute name */
H5O_type_t obj_type; /* Object type */
herr_t ret; /* Generic return value */

Expand Down Expand Up @@ -2684,6 +2686,27 @@ test_reference_attr(void)
ret = (int)H5Sget_simple_extent_npoints(sid);
VERIFY(ret, SPACE1_DIM1, "H5Sget_simple_extent_npoints");

/* Verify attribute name */
attr_name_size = H5Aget_name(attr1_from_name, (size_t)0, NULL);
CHECK(attr_name_size, FAIL, "H5Aget_name");

if (attr_name_size > 0) {
attr_name = (char *)calloc((size_t)(attr_name_size + 1), sizeof(char));
CHECK_PTR(attr_name, "calloc");

if (attr_name) {
ret = (herr_t)H5Aget_name(attr1_from_name, (size_t)(attr_name_size + 1), attr_name);
CHECK(ret, FAIL, "H5Aget_name");

/* Verify the name info between the H5A and H5R APIs */
ret = strcmp(attr_name, namebuf);
VERIFY(ret, 0, "H5Aget_name vs H5Rget_attr_name");
VERIFY(attr_name_size, namelen, "H5Aget_name vs H5Rget_attr_name");

free(attr_name);
} /* end if */
} /* end if */

/* Read attribute data from disk */
ret = H5Aread(attr1_from_name, H5T_NATIVE_UINT, rbuf);
CHECK(ret, FAIL, "H5Aread");
Expand Down

0 comments on commit 9d57f6a

Please sign in to comment.