summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2011-04-17 19:16:38 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2011-04-17 19:16:38 (GMT)
commit0badac6423ddfeb881345838e3879ad413e52ad1 (patch)
tree0ad085535930a65392a00ee911579574d24008a0 /test
parenta99c68f3f9ac16df25d68a06947d92fcd0da220c (diff)
downloadhdf5-0badac6423ddfeb881345838e3879ad413e52ad1.zip
hdf5-0badac6423ddfeb881345838e3879ad413e52ad1.tar.gz
hdf5-0badac6423ddfeb881345838e3879ad413e52ad1.tar.bz2
[svn-r20537] Description:
Bring r20535 & r20536 from trunk to 1.8 branch: Add explicit test that checks that the 'fileno' field in H5O_info_t is the same for objects in the same file, whether the file was opened twice or not. Clean up various warnings & code formatting issues. Bring changes from Coverity branch to trunk: r20085: Purpose: Fix coverity issue 793 Description: Modified H5S_hyper_project_simple_higher() to free the entire span list in new_space on failure. r20091: This is a fix for coverity bug #1683. Changed the two printfs to use %lu (unsigned long) for printing "dset_size". r20162: Purpose: Fix coverity issue 785 Description: Modified H5T_enum_nameof() to free "name" on failure if it was allocated. Also clarified some code in H5S_hyper_rebuild_helper(). r20189: Addressed coverity defect 783. H5SL_new_node() in H5SL.c was failing to free space allocated in its first alloc if the second alloc failed. Added a call to H5FL_FREE to address this issue. This is purely to keep coverity happy -- if this code is ever triggered, we have much larger problems. Note that this fix will trigger an unused return value complaint from coverity next week. r20190: Fixed Coverity issues 1561 1565 and 1678 (UNUSED_VALUES) by moving checks of return values to after the function call. r20191: Fixed coverity issues 643 644 and 1678 (CHECKED_RETURN). r20232: Addressed coverity issues 923-925. Replaced calls to sprintf with calls to HDsnprintf. r20233: Fix coverity issue 662. Don't try to sort 0 attributes in H5Aint.c. r20234: Fix coverity issue 664. Check for NULL before dereferencing in H5Gdeprec.c. r20271: Purpose: Fix coverity issue 784 Description: Modified H5_debug_mask() to keep a list of files opened for use as a debugging output stream, and modified H5_term_library to close these files on exit. r20272: addressed coverity issues 838 & 955. Issue was use of strcpy() -- existing code was safe, but modified to use strncpy() to keep coverity happy. r20273: Addresed coverity issues 1388 and 1389. Initialized sel_iter->type to NULL in H5S_select_iter_init. r20275: Purpose: Fix valgrind issue in mf.c Description: Fixed bug (incomplete if statement) in test_mf_fs_alloc_free() so the retrieved node gets freed. Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, w/threadsafe, in production mode Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
Diffstat (limited to 'test')
-rw-r--r--test/links.c46
-rw-r--r--test/mf.c3
-rw-r--r--test/th5o.c106
-rw-r--r--test/tvlstr.c6
4 files changed, 142 insertions, 19 deletions
diff --git a/test/links.c b/test/links.c
index f9c6b6a..7daa090 100644
--- a/test/links.c
+++ b/test/links.c
@@ -1627,7 +1627,7 @@ test_deprec(hid_t fapl, hbool_t new_format)
hid_t file_id = -1;
hid_t group1_id = -1;
hid_t group2_id = -1;
- H5G_stat_t sb_hard1, sb_hard2, sb_soft1;
+ H5G_stat_t sb_hard1, sb_hard2, sb_soft1, sb_soft2;
H5G_obj_t obj_type; /* Object type */
hsize_t num_objs; /* Number of objects in a group */
char filename[1024];
@@ -1656,6 +1656,7 @@ test_deprec(hid_t fapl, hbool_t new_format)
if(H5Glink(file_id, H5G_LINK_HARD, "group2", "group1/link_to_group2") < 0) FAIL_STACK_ERROR
if(H5Glink2(file_id, "group1", H5G_LINK_HARD, group2_id, "link_to_group1") < 0) FAIL_STACK_ERROR
if(H5Glink2(file_id, "link_to_group1", H5G_LINK_SOFT, H5G_SAME_LOC, "group2/soft_link_to_group1") < 0) FAIL_STACK_ERROR
+ if(H5Glink2(file_id, "dangle", H5G_LINK_SOFT, H5G_SAME_LOC, "group2/dangle_soft_link") < 0) FAIL_STACK_ERROR
/* Test getting the names for objects */
if(H5Gget_objname_by_idx(group1_id, (hsize_t)0, tmpstr, sizeof(tmpstr)) < 0) FAIL_STACK_ERROR
@@ -1708,6 +1709,15 @@ test_deprec(hid_t fapl, hbool_t new_format)
if(HDstrcmp("link_to_group1", tmpstr)) TEST_ERROR
+ /* Test the dangling soft link */
+ if(H5Gget_objinfo(file_id, "/group2/dangle_soft_link", FALSE, &sb_soft2) < 0) FAIL_STACK_ERROR
+ if(sb_soft2.type != H5G_LINK) TEST_ERROR
+ if(sb_soft2.linklen != HDstrlen("dangle") + 1) TEST_ERROR
+
+ if(H5Gget_linkval(group2_id, "dangle_soft_link", sb_soft2.linklen, tmpstr) < 0) FAIL_STACK_ERROR
+ if(HDstrcmp("dangle", tmpstr)) TEST_ERROR
+
+
/* Test H5Gmove and H5Gmove2 */
if(H5Gmove(file_id, "group1", "moved_group1") < 0) FAIL_STACK_ERROR
if(H5Gmove2(file_id, "group2", group1_id, "moved_group2") < 0) FAIL_STACK_ERROR
@@ -3538,7 +3548,7 @@ external_set_elink_fapl1(hid_t fapl, hbool_t new_format)
HDmemset(memb_addr, 0, sizeof memb_addr);
HDmemset(sv, 0, sizeof sv);
- for(mt = 0; mt < H5FD_MEM_NTYPES; mt++) {
+ for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, mt)) {
memb_map[mt] = H5FD_MEM_SUPER;
memb_fapl[mt] = H5P_DEFAULT;
} /* end for */
@@ -9593,7 +9603,7 @@ link_filters(hid_t fapl, hbool_t new_format)
/* Check that the file size is smaller with the filter */
if((double)filesize_filtered
- > (filesize_unfiltered * FILTER_FILESIZE_MAX_FRACTION))
+ > ((double)filesize_unfiltered * FILTER_FILESIZE_MAX_FRACTION))
TEST_ERROR
/* Close */
@@ -11161,9 +11171,9 @@ delete_by_idx(hid_t fapl)
herr_t ret; /* Generic return value */
/* Loop over operating on different indices on link fields */
- for(idx_type = H5_INDEX_NAME; idx_type <=H5_INDEX_CRT_ORDER; idx_type++) {
+ for(idx_type = H5_INDEX_NAME; idx_type <= H5_INDEX_CRT_ORDER; H5_INC_ENUM(H5_index_t, idx_type)) {
/* Loop over operating in different orders */
- for(order = H5_ITER_INC; order <=H5_ITER_DEC; order++) {
+ for(order = H5_ITER_INC; order <=H5_ITER_DEC; H5_INC_ENUM(H5_iter_order_t, order)) {
/* Loop over using index for creation order value */
for(use_index = FALSE; use_index <= TRUE; use_index++) {
/* Print appropriate test message */
@@ -11477,7 +11487,7 @@ delete_by_idx_old(hid_t fapl)
herr_t ret; /* Generic return value */
/* Loop over operating in different orders */
- for(order = H5_ITER_INC; order <=H5_ITER_DEC; order++) {
+ for(order = H5_ITER_INC; order <=H5_ITER_DEC; H5_INC_ENUM(H5_iter_order_t, order)) {
/* Print test banner */
if(order == H5_ITER_INC)
TESTING("deleting links by index in increasing order in old-style group")
@@ -12000,9 +12010,9 @@ link_iterate(hid_t fapl)
iter_info.visited = visited;
/* Loop over operating on different indices on link fields */
- for(idx_type = H5_INDEX_NAME; idx_type <=H5_INDEX_CRT_ORDER; idx_type++) {
+ for(idx_type = H5_INDEX_NAME; idx_type <= H5_INDEX_CRT_ORDER; H5_INC_ENUM(H5_index_t, idx_type)) {
/* Loop over operating in different orders */
- for(order = H5_ITER_INC; order <=H5_ITER_NATIVE; order++) {
+ for(order = H5_ITER_INC; order <=H5_ITER_NATIVE; H5_INC_ENUM(H5_iter_order_t, order)) {
/* Loop over using index for creation order value */
for(use_index = FALSE; use_index <= TRUE; use_index++) {
/* Print appropriate test message */
@@ -12452,7 +12462,7 @@ link_iterate_old(hid_t fapl)
iter_info.visited = visited;
/* Loop over operating in different orders */
- for(order = H5_ITER_INC; order <=H5_ITER_NATIVE; order++) {
+ for(order = H5_ITER_INC; order <=H5_ITER_NATIVE; H5_INC_ENUM(H5_iter_order_t, order)) {
/* Print appropriate test message */
if(order == H5_ITER_INC) {
TESTING("iterating over links by name index in increasing order in old-style group")
@@ -12688,9 +12698,9 @@ open_by_idx(hid_t fapl)
if((mount_file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
/* Loop over operating on different indices on link fields */
- for(idx_type = H5_INDEX_NAME; idx_type <=H5_INDEX_CRT_ORDER; idx_type++) {
+ for(idx_type = H5_INDEX_NAME; idx_type <= H5_INDEX_CRT_ORDER; H5_INC_ENUM(H5_index_t, idx_type)) {
/* Loop over operating in different orders */
- for(order = H5_ITER_INC; order <=H5_ITER_NATIVE; order++) {
+ for(order = H5_ITER_INC; order <= H5_ITER_NATIVE; H5_INC_ENUM(H5_iter_order_t, order)) {
/* Loop over using index for creation order value */
for(use_index = FALSE; use_index <= TRUE; use_index++) {
/* Print appropriate test message */
@@ -12904,7 +12914,7 @@ open_by_idx_old(hid_t fapl)
if((mount_file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
/* Loop over operating in different orders */
- for(order = H5_ITER_INC; order <=H5_ITER_NATIVE; order++) {
+ for(order = H5_ITER_INC; order <=H5_ITER_NATIVE; H5_INC_ENUM(H5_iter_order_t, order)) {
/* Print appropriate test message */
if(order == H5_ITER_INC) {
TESTING("open object by name index in increasing order in old-style group")
@@ -13124,9 +13134,9 @@ object_info(hid_t fapl)
if((space_id = H5Screate(H5S_SCALAR)) < 0) TEST_ERROR
/* Loop over operating on different indices on link fields */
- for(idx_type = H5_INDEX_NAME; idx_type <=H5_INDEX_CRT_ORDER; idx_type++) {
+ for(idx_type = H5_INDEX_NAME; idx_type <= H5_INDEX_CRT_ORDER; H5_INC_ENUM(H5_index_t, idx_type)) {
/* Loop over operating in different orders */
- for(order = H5_ITER_INC; order <=H5_ITER_NATIVE; order++) {
+ for(order = H5_ITER_INC; order <=H5_ITER_NATIVE; H5_INC_ENUM(H5_iter_order_t, order)) {
/* Loop over using index for creation order value */
for(use_index = FALSE; use_index <= TRUE; use_index++) {
/* Print appropriate test message */
@@ -13360,7 +13370,7 @@ object_info_old(hid_t fapl)
if((space_id = H5Screate(H5S_SCALAR)) < 0) TEST_ERROR
/* Loop over operating in different orders */
- for(order = H5_ITER_INC; order <=H5_ITER_NATIVE; order++) {
+ for(order = H5_ITER_INC; order <=H5_ITER_NATIVE; H5_INC_ENUM(H5_iter_order_t, order)) {
/* Print appropriate test message */
if(order == H5_ITER_INC) {
TESTING("query object info by name index in increasing order in old-style group")
@@ -13513,9 +13523,9 @@ group_info(hid_t fapl)
if(H5Pget_link_phase_change(gcpl_id, &max_compact, &min_dense) < 0) TEST_ERROR
/* Loop over operating on different indices on link fields */
- for(idx_type = H5_INDEX_NAME; idx_type <=H5_INDEX_CRT_ORDER; idx_type++) {
+ for(idx_type = H5_INDEX_NAME; idx_type <= H5_INDEX_CRT_ORDER; H5_INC_ENUM(H5_index_t, idx_type)) {
/* Loop over operating in different orders */
- for(order = H5_ITER_INC; order <=H5_ITER_NATIVE; order++) {
+ for(order = H5_ITER_INC; order <=H5_ITER_NATIVE; H5_INC_ENUM(H5_iter_order_t, order)) {
/* Loop over using index for creation order value */
for(use_index = FALSE; use_index <= TRUE; use_index++) {
/* Print appropriate test message */
@@ -13924,7 +13934,7 @@ group_info_old(hid_t fapl)
unsigned u, v; /* Local index variables */
/* Loop over operating in different orders */
- for(order = H5_ITER_INC; order <=H5_ITER_NATIVE; order++) {
+ for(order = H5_ITER_INC; order <=H5_ITER_NATIVE; H5_INC_ENUM(H5_iter_order_t, order)) {
if(order == H5_ITER_INC) {
TESTING("query group info by name index in increasing order in old-style group")
} /* end if */
diff --git a/test/mf.c b/test/mf.c
index 6361adc..005e5a0 100644
--- a/test/mf.c
+++ b/test/mf.c
@@ -1155,7 +1155,8 @@ test_mf_fs_alloc_free(hid_t fapl)
/* Remove section A from free-space */
if(H5FS_sect_find(f, H5P_DATASET_XFER_DEFAULT, f->shared->fs_man[type],
- (hsize_t)TEST_BLOCK_SIZE30, (H5FS_section_info_t **)&node) < 0)
+ (hsize_t)TEST_BLOCK_SIZE30, (H5FS_section_info_t **)&node) < 0)
+ TEST_ERROR
/* Free the free-space section node */
if(H5MF_sect_simple_free((H5FS_section_info_t *)node) < 0)
diff --git a/test/th5o.c b/test/th5o.c
index 17619ee..70f8067 100644
--- a/test/th5o.c
+++ b/test/th5o.c
@@ -1225,6 +1225,111 @@ test_h5o_comment_by_name(void)
} /* test_h5o_comment_by_name() */
+
+/****************************************************************
+**
+** test_h5o_getinfo_same_file(): Test that querying the object info for
+** objects in the same file will return the same file "number"
+**
+****************************************************************/
+static void
+test_h5o_getinfo_same_file(void)
+{
+ hid_t fid1, fid2; /* HDF5 File ID */
+ hid_t gid1, gid2; /* Group IDs */
+ H5O_info_t oinfo1, oinfo2; /* Object info structs */
+ herr_t ret; /* Value returned from API calls */
+
+ /* Create a new HDF5 file */
+ fid1 = H5Fcreate(TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(fid1, FAIL, "H5Fcreate");
+
+ /* Create two groups in the file */
+ gid1 = H5Gcreate2(fid1, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(gid1, FAIL, "H5Gcreate2");
+ gid2 = H5Gcreate2(fid1, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(gid2, FAIL, "H5Gcreate2");
+
+ /* Reset object info */
+ HDmemset(&oinfo1, 0, sizeof(oinfo1));
+ HDmemset(&oinfo2, 0, sizeof(oinfo2));
+
+ /* Query the object info for each object, through group IDs */
+ ret = H5Oget_info(gid1, &oinfo1);
+ CHECK(ret, FAIL, "H5Oget_info");
+ ret = H5Oget_info(gid2, &oinfo2);
+ CHECK(ret, FAIL, "H5Oget_info");
+
+ VERIFY(oinfo1.fileno, oinfo2.fileno, "file number from H5Oget_info");
+
+ /* Reset object info */
+ HDmemset(&oinfo1, 0, sizeof(oinfo1));
+ HDmemset(&oinfo2, 0, sizeof(oinfo2));
+
+ /* Query the object info for each object, by name */
+ ret = H5Oget_info_by_name(fid1, "group1", &oinfo1, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Oget_info_by_name");
+ ret = H5Oget_info_by_name(fid1, "group2", &oinfo2, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Oget_info_by_name");
+
+ VERIFY(oinfo1.fileno, oinfo2.fileno, "file number from H5Oget_info");
+
+ /* Close everything */
+ ret = H5Gclose(gid1);
+ CHECK(ret, FAIL, "H5Gclose");
+ ret = H5Gclose(gid2);
+ CHECK(ret, FAIL, "H5Gclose");
+ ret = H5Fclose(fid1);
+ CHECK(ret, FAIL, "H5Fclose");
+
+
+ /* Open file twice */
+ fid1 = H5Fopen(TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT);
+ CHECK(fid1, FAIL, "H5Fopen");
+ fid2 = H5Fopen(TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT);
+ CHECK(fid2, FAIL, "H5Fopen");
+
+ /* Open the two groups in the file */
+ gid1 = H5Gopen2(fid1, "group1", H5P_DEFAULT);
+ CHECK(gid1, FAIL, "H5Gopen2");
+ gid2 = H5Gopen2(fid2, "group2", H5P_DEFAULT);
+ CHECK(gid2, FAIL, "H5Gopen2");
+
+ /* Reset object info */
+ HDmemset(&oinfo1, 0, sizeof(oinfo1));
+ HDmemset(&oinfo2, 0, sizeof(oinfo2));
+
+ /* Query the object info for each object, through group IDs */
+ ret = H5Oget_info(gid1, &oinfo1);
+ CHECK(ret, FAIL, "H5Oget_info");
+ ret = H5Oget_info(gid2, &oinfo2);
+ CHECK(ret, FAIL, "H5Oget_info");
+
+ VERIFY(oinfo1.fileno, oinfo2.fileno, "file number from H5Oget_info");
+
+ /* Reset object info */
+ HDmemset(&oinfo1, 0, sizeof(oinfo1));
+ HDmemset(&oinfo2, 0, sizeof(oinfo2));
+
+ /* Query the object info for each object, by name */
+ ret = H5Oget_info_by_name(fid1, "group1", &oinfo1, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Oget_info_by_name");
+ ret = H5Oget_info_by_name(fid1, "group2", &oinfo2, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Oget_info_by_name");
+
+ VERIFY(oinfo1.fileno, oinfo2.fileno, "file number from H5Oget_info");
+
+ /* Close everything */
+ ret = H5Gclose(gid1);
+ CHECK(ret, FAIL, "H5Gclose");
+ ret = H5Gclose(gid2);
+ CHECK(ret, FAIL, "H5Gclose");
+ ret = H5Fclose(fid1);
+ CHECK(ret, FAIL, "H5Fclose");
+ ret = H5Fclose(fid2);
+ CHECK(ret, FAIL, "H5Fclose");
+
+} /* test_h5o_getinfo_same_file() */
/****************************************************************
@@ -1246,6 +1351,7 @@ test_h5o(void)
test_h5o_link(); /* Test object link routine */
test_h5o_comment(); /* Test routines for comment */
test_h5o_comment_by_name(); /* Test routines for comment by name */
+ test_h5o_getinfo_same_file(); /* Test info for objects in the same file */
} /* test_h5o() */
diff --git a/test/tvlstr.c b/test/tvlstr.c
index 87008aa..02bd59d 100644
--- a/test/tvlstr.c
+++ b/test/tvlstr.c
@@ -388,6 +388,7 @@ static void test_vlstring_type(void)
hid_t tid_vlstr;
H5T_cset_t cset;
H5T_str_t pad;
+ htri_t vl_str; /* Whether string is VL */
herr_t ret;
/* Output message about test being performed */
@@ -417,6 +418,11 @@ static void test_vlstring_type(void)
ret = H5Tis_variable_str(tid_vlstr);
VERIFY(ret, TRUE, "H5Tis_variable_str");
+ /* Verify that the class detects as a string */
+ vl_str = H5Tdetect_class(tid_vlstr, H5T_STRING);
+ CHECK(vl_str, FAIL, "H5Tdetect_class");
+ VERIFY(vl_str, TRUE, "H5Tdetect_class");
+
/* Check default character set and padding */
cset = H5Tget_cset(tid_vlstr);
VERIFY(cset, H5T_CSET_ASCII, "H5Tget_cset");