summaryrefslogtreecommitdiffstats
path: root/c++/test/tlinks.cpp
diff options
context:
space:
mode:
authorLarry Knox <lrknox@hdfgroup.org>2017-07-06 19:16:57 (GMT)
committerLarry Knox <lrknox@hdfgroup.org>2017-07-06 19:16:57 (GMT)
commit23a702e7bad93fc4f14eab07678c75d276e2d0ad (patch)
treeafb57ddaeca17021342fa09b8999c15569630e71 /c++/test/tlinks.cpp
parent03dbcb75918b2cbf39800d9edf5665d3471a1fee (diff)
parentc15238a38fdb3692466bc1218de4c5aeb420fdcc (diff)
downloadhdf5-23a702e7bad93fc4f14eab07678c75d276e2d0ad.zip
hdf5-23a702e7bad93fc4f14eab07678c75d276e2d0ad.tar.gz
hdf5-23a702e7bad93fc4f14eab07678c75d276e2d0ad.tar.bz2
Merge pull request #593 in HDFFV/hdf5 from hdf5_1_8_19 to 1.8/masterhdf5-1_8_19
* commit 'c15238a38fdb3692466bc1218de4c5aeb420fdcc': (153 commits) Commit changes to release version strings in README.txt and RELEASE.txt from release. Put back link targets for dynamically loaded libraries in Makefile.ams that avoid linking with libhdf5 dependencies. Some configurations failed unnecessarily to find and link with lz and lsz when these targets were removed. Update URL for obtaining source inINSTALL file. Disable building of libdynlib* dynamically loaded plugin test libraries on CYGWIN. Added known problem entry to RELEASE.txt. Set version for 1.8.19 release. Barbara updated contents of README.txt file. Moved libdynlib* plugin test libraries to noist_LT_LIBRARIES with added flag '-rpath /nowhere' to stop them being installed while keeping them from linking with libhdf5, etc. Incremented version to 1.8.19-pre1 and ran bin/release to create tar and zip files for testing. HDF5 1.8.19-pre1 released. Add RELEASE.txt entry for H5Dget_chunk_size. Remove test entries Ran bin/reconfigure after so number change. Update hl lib .so numbers: new function was added. Update RELEASE.txt: move H5DOread_chunks entry to new features, clarify entry for HDFFV-10051. Updated notes for test fixes and added bug fix for h5diff help text. Update h5vers and release scripts for 1.8.19 branch, set version to 1.8.19-pre1. Make script name consistent across product versions Update version to 1.8.19-pre1. Propagate .so number changes to Makefile.ins with bin/reconfigure. Add toolset option Update so version numbers according to the interface compatibility report. Update supported Platforms section. Remove empty sub-sections of New Features and Bugs Fixed sections. Add entries for HDFFV-10051 and HDFFV-9934 to RELEASE.txt. Correct spelling ...
Diffstat (limited to 'c++/test/tlinks.cpp')
-rw-r--r--c++/test/tlinks.cpp369
1 files changed, 208 insertions, 161 deletions
diff --git a/c++/test/tlinks.cpp b/c++/test/tlinks.cpp
index 2b05764..1328a19 100644
--- a/c++/test/tlinks.cpp
+++ b/c++/test/tlinks.cpp
@@ -4,12 +4,10 @@
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
- * the files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*****************************************************************************
@@ -46,8 +44,8 @@ using namespace H5;
//#define H5G_TESTING
//#include "h5test.h"
-//#include "H5Gpkg.h" /* Groups */
-//#include "H5Iprivate.h" /* IDs */
+//#include "H5Gpkg.h" /* Groups */
+//#include "H5Iprivate.h" /* IDs */
//#include "H5Lprivate.h" /* Links */
/* File for external link test. Created with gen_udlinks.c */
@@ -67,39 +65,39 @@ const char *FILENAME[] = {
"links6", /* 9 */
"links7", /* 10 */
"links8", /* 11 */
- "extlinks0", /* 12: main files */
- "tmp/extlinks0", /* 13: */
- "extlinks1", /* 14: target files */
- "tmp/extlinks1", /* 15: */
- "extlinks2", /* 16: */
- "tmp/extlinks2", /* 17: */
- "extlinks3", /* 18: */
- "tmp/extlinks3", /* 19: */
- "extlinks4", /* 20: */
- "tmp/extlinks4", /* 21: */
- "extlinks5", /* 22: */
- "tmp/extlinks6", /* 23: */
- "extlinks7", /* 24: */
- "tmp/extlinks7", /* 25: */
- "tmp/extlinks8", /* 26: */
- "extlinks9", /* 27: */
- "tmp/extlinks9", /* 28: */
- "extlinks10", /* 29: */ /* TESTS for windows */
- "tmp/extlinks10", /* 30: */
- "tmp/extlinks11", /* 31: */
- "tmp/extlinks12", /* 32: */
- "extlinks13", /* 33: */
- "tmp/extlinks13", /* 34: */
- "tmp/extlinks14", /* 35: */
- "tmp/extlinks15", /* 36: */
- "extlinks16A", /* 37: */ /* TESTS for H5P_set_elink_fapl */
- "extlinks16B", /* 38: */
- "extlinks17", /* 39: */
- "extlinks18A", /* 40: */
- "extlinks18B", /* 41: */
- "extlinks19A", /* 42: */
- "extlinks19B", /* 43: */
- "extlinks20", /* 44: */
+ "extlinks0", /* 12: main files */
+ "tmp/extlinks0", /* 13: */
+ "extlinks1", /* 14: target files */
+ "tmp/extlinks1", /* 15: */
+ "extlinks2", /* 16: */
+ "tmp/extlinks2", /* 17: */
+ "extlinks3", /* 18: */
+ "tmp/extlinks3", /* 19: */
+ "extlinks4", /* 20: */
+ "tmp/extlinks4", /* 21: */
+ "extlinks5", /* 22: */
+ "tmp/extlinks6", /* 23: */
+ "extlinks7", /* 24: */
+ "tmp/extlinks7", /* 25: */
+ "tmp/extlinks8", /* 26: */
+ "extlinks9", /* 27: */
+ "tmp/extlinks9", /* 28: */
+ "extlinks10", /* 29: */ /* TESTS for windows */
+ "tmp/extlinks10", /* 30: */
+ "tmp/extlinks11", /* 31: */
+ "tmp/extlinks12", /* 32: */
+ "extlinks13", /* 33: */
+ "tmp/extlinks13", /* 34: */
+ "tmp/extlinks14", /* 35: */
+ "tmp/extlinks15", /* 36: */
+ "extlinks16A", /* 37: */ /* TESTS for H5P_set_elink_fapl */
+ "extlinks16B", /* 38: */
+ "extlinks17", /* 39: */
+ "extlinks18A", /* 40: */
+ "extlinks18B", /* 41: */
+ "extlinks19A", /* 42: */
+ "extlinks19B", /* 43: */
+ "extlinks20", /* 44: */
NULL
};
@@ -107,12 +105,12 @@ const char *FILENAME[] = {
#define TMPDIR "tmp"
-#define FAMILY_SIZE 1024
+#define FAMILY_SIZE 1024
#define CORE_INCREMENT 1024
-#define NUM400 400
+#define NUM400 400
/* do not do check_all_closed() for "ext*" files and "tmp/ext*" */
-#define EXTSTOP 12
+#define EXTSTOP 12
#define LINK_BUF_SIZE 1024
#define NAME_BUF_SIZE 1024
@@ -326,16 +324,16 @@ static const char *FILENAME[] = {
/*-------------------------------------------------------------------------
- * Function: test_basic_links
+ * Function: test_basic_links
*
- * Purpose: Test building a file with assorted links.
+ * Purpose: Test building a file with assorted links.
*
- * Return: Success: 0
+ * Return: Success: 0
*
- * Failure: -1
+ * Failure: -1
*
- * Programmer: Binh-Minh Ribler
- * October 16, 2009
+ * Programmer: Binh-Minh Ribler
+ * October 16, 2009
*
* Modifications:
*
@@ -343,114 +341,162 @@ static const char *FILENAME[] = {
*/
static void test_basic_links(hid_t fapl_id, hbool_t new_format)
{
- hsize_t size[1] = {1};
- char filename[NAME_BUF_SIZE];
+ hsize_t size[1] = {1};
+ char filename[NAME_BUF_SIZE];
// Use the file access template id to create a file access prop. list.
FileAccPropList fapl(fapl_id);
try
{
- if(new_format)
- SUBTEST("Link creation (w/new group format)")
- else
- SUBTEST("Link creation")
+ if(new_format)
+ SUBTEST("Link creation (w/new group format)")
+ else
+ SUBTEST("Link creation")
- h5_fixname(FILENAME[0], fapl_id, filename, sizeof filename);
- H5File file(filename, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl);
+ h5_fixname(FILENAME[0], fapl_id, filename, sizeof filename);
+ H5File file(filename, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl);
- // Create simple dataspace
- DataSpace scalar (1, size, size);
+ // Create simple dataspace
+ DataSpace scalar (1, size, size);
- // Create a group then close it by letting the object go out of scope
- {
- Group group(file.createGroup("grp1", 0));
- }
+ // Create a group then close it by letting the object go out of scope
+ {
+ Group group(file.createGroup("grp1", 0));
+ }
- // Create a dataset then close it by letting the object go out of scope
- {
- DataSet dset1(file.createDataSet("dset1", PredType::NATIVE_INT, scalar));
- }
+ // Create a dataset then close it by letting the object go out of scope
+ {
+ DataSet dset1(file.createDataSet("dset1", PredType::NATIVE_INT, scalar));
+ }
- hid_t file_id = file.getId();
+ hid_t file_id = file.getId();
- // Because these are not implemented in the C++ API yet, they are
- // used so CommonFG::getLinkval can be tested.
- // Create a hard link
- if(H5Lcreate_hard(
- file_id, "dset1", H5L_SAME_LOC, "grp1/hard1",
- H5P_DEFAULT, H5P_DEFAULT) < 0)
- throw Exception("test_basic_links", "H5Lcreate_hard failed");
+ // Because these are not implemented in the C++ API yet, they are
+ // used so CommonFG::getLinkval can be tested.
+ // Create a hard link
+ if(H5Lcreate_hard(
+ file_id, "dset1", H5L_SAME_LOC, "grp1/hard1",
+ H5P_DEFAULT, H5P_DEFAULT) < 0)
+ throw Exception("test_basic_links", "H5Lcreate_hard failed");
- // Create a symbolic link
- if(H5Lcreate_soft(
- "/dset1", file_id, "grp1/soft", H5P_DEFAULT, H5P_DEFAULT) < 0)
- throw Exception("test_basic_links", "H5Lcreate_soft failed");
+ // Create a symbolic link
+ if(H5Lcreate_soft(
+ "/dset1", file_id, "grp1/soft", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ throw Exception("test_basic_links", "H5Lcreate_soft failed");
- // Create a symbolic link to something that doesn't exist
- if(H5Lcreate_soft(
- "foobar", file_id, "grp1/dangle", H5P_DEFAULT, H5P_DEFAULT) < 0)
- throw Exception("test_basic_links", "H5Lcreate_soft failed");
+ // Create a symbolic link to something that doesn't exist
+ if(H5Lcreate_soft(
+ "foobar", file_id, "grp1/dangle", H5P_DEFAULT, H5P_DEFAULT) < 0)
+ throw Exception("test_basic_links", "H5Lcreate_soft failed");
- // Create a recursive symbolic link
- if(H5Lcreate_soft(
- "/grp1/recursive", file_id, "/grp1/recursive",
- H5P_DEFAULT, H5P_DEFAULT) < 0)
- throw Exception("test_basic_links", "H5Lcreate_soft failed");
+ // Create a recursive symbolic link
+ if(H5Lcreate_soft(
+ "/grp1/recursive", file_id, "/grp1/recursive",
+ H5P_DEFAULT, H5P_DEFAULT) < 0)
+ throw Exception("test_basic_links", "H5Lcreate_soft failed");
- // Verify link values before closing the file
+ // Verify link values before closing the file
- H5std_string softlink_val = file.getLinkval("grp1/soft");
- verify_val(softlink_val, "/dset1", "H5File::getLinkval grp1/soft", __LINE__, __FILE__);
+ H5std_string softlink_val = file.getLinkval("grp1/soft");
+ verify_val(softlink_val, "/dset1", "H5File::getLinkval grp1/soft", __LINE__, __FILE__);
- H5std_string dngllink_val = file.getLinkval("grp1/dangle");
- verify_val(dngllink_val, "foobar", "H5File::getLinkval grp1/dangle", __LINE__, __FILE__);
+ H5std_string dngllink_val = file.getLinkval("grp1/dangle");
+ verify_val(dngllink_val, "foobar", "H5File::getLinkval grp1/dangle", __LINE__, __FILE__);
- H5std_string reclink_val = file.getLinkval("grp1/recursive");
- verify_val(reclink_val, "/grp1/recursive", "H5File::getLinkval grp1/recursive", __LINE__, __FILE__);
+ H5std_string reclink_val = file.getLinkval("grp1/recursive");
+ verify_val(reclink_val, "/grp1/recursive", "H5File::getLinkval grp1/recursive", __LINE__, __FILE__);
} // end of try block
catch (Exception& E)
{
- issue_fail_msg("test_basic_links()", __LINE__, __FILE__, E.getCDetailMsg());
+ issue_fail_msg("test_basic_links()", __LINE__, __FILE__, E.getCDetailMsg());
}
// Open the file and check on the links in it
try
{
- // Open the file above
- H5File file(filename, H5F_ACC_RDWR, FileCreatPropList::DEFAULT, fapl);
+ // Open the file above
+ H5File file(filename, H5F_ACC_RDWR, FileCreatPropList::DEFAULT, fapl);
- // Verify link existence
- if(H5Lexists(file.getId(), "dset1", H5P_DEFAULT) != TRUE)
- throw InvalidActionException("H5Lexists", "dset1 doesn't exist");
- if(H5Lexists(file.getId(), "grp1/soft", H5P_DEFAULT) != TRUE)
- throw InvalidActionException("H5Lexists", "grp1/soft doesn't exist");
+ // Verify link existence
+ if(file.nameExists("dset1", LinkAccPropList::DEFAULT) != TRUE)
+ throw InvalidActionException("H5File::nameExists", "dset1 doesn't exist");
+ if(file.nameExists("grp1/soft", LinkAccPropList::DEFAULT) != TRUE)
+ throw InvalidActionException("H5File::nameExists", "grp1/soft doesn't exist");
- // Verify link values
- H5std_string softlink_val = file.getLinkval("grp1/soft");
- verify_val(softlink_val, "/dset1", "H5File::getLinkval grp1/soft", __LINE__, __FILE__);
+ // Verify link values
+ H5std_string softlink_val = file.getLinkval("grp1/soft");
+ verify_val(softlink_val, "/dset1", "H5File::getLinkval grp1/soft", __LINE__, __FILE__);
- H5std_string reclink_val = file.getLinkval("grp1/recursive");
- verify_val(reclink_val, "/grp1/recursive", "H5File::getLinkval grp1/recursive", __LINE__, __FILE__);
+ H5std_string reclink_val = file.getLinkval("grp1/recursive");
+ verify_val(reclink_val, "/grp1/recursive", "H5File::getLinkval grp1/recursive", __LINE__, __FILE__);
- PASSED();
+ PASSED();
} // end of try block
catch (Exception& E)
{
- issue_fail_msg("test_basic_links()", __LINE__, __FILE__, E.getCDetailMsg());
+ issue_fail_msg("test_basic_links()", __LINE__, __FILE__, E.getCDetailMsg());
}
}
+
+/*-------------------------------------------------------------------------
+ * Function: test_num_links
+ *
+ * Purpose Test setting and getting limit of number of links
+ *
+ * Return Success: 0
+ *
+ * Failure: -1
+ *
+ * Programmer Binh-Minh Ribler
+ * Mar, 2017
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static void test_num_links(hid_t fapl_id, hbool_t new_format)
+{
+ char filename[NAME_BUF_SIZE];
+ if(new_format)
+ SUBTEST("Setting number of links (w/new group format)")
+ else
+ SUBTEST("Setting number of links")
+
+ try
+ {
+ // Use the file access template id to create a file access prop. list.
+ FileAccPropList fapl(fapl_id);
+
+ h5_fixname(FILENAME[0], fapl_id, filename, sizeof filename);
+ H5File file(filename, H5F_ACC_RDWR, FileCreatPropList::DEFAULT, fapl);
+
+ LinkAccPropList lapl;
+ size_t nlinks = 5;
+ lapl.setNumLinks(nlinks);
+
+ // Read it back and verify
+ size_t read_nlinks = lapl.getNumLinks();
+ verify_val(read_nlinks, nlinks, "LinkAccPropList::setNumLinks", __LINE__, __FILE__);
+
+ PASSED();
+ } // end of try block
+ catch (Exception& E)
+ {
+ issue_fail_msg("test_num_links()", __LINE__, __FILE__, E.getCDetailMsg());
+ }
+} // test_num_links
/*-------------------------------------------------------------------------
- * Function: test_links
+ * Function: test_links
*
- * Purpose: Test links
+ * Purpose: Test links
*
- * Return: None
+ * Return: None
*
- * Programmer: Binh-Minh Ribler
+ * Programmer: Binh-Minh Ribler
* October 16, 2009
*
*-------------------------------------------------------------------------
@@ -458,7 +504,7 @@ static void test_basic_links(hid_t fapl_id, hbool_t new_format)
extern "C"
void test_links()
{
- hid_t fapl_id, fapl2_id; /* File access property lists */
+ hid_t fapl_id, fapl2_id; /* File access property lists */
hbool_t new_format; /* Whether to use the new format or not */
const char *envval;
@@ -472,40 +518,41 @@ void test_links()
MESSAGE(5, ("Testing Various Links\n"));
try
{
- /* Copy the file access property list */
- if((fapl2_id = H5Pcopy(fapl_id)) < 0)
- throw Exception("test_links", "H5Pcopy failed");
-
- /* Set the "use the latest version of the format" bounds for creating objects in the file */
- if(H5Pset_libver_bounds(fapl2_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
- throw Exception("test_links", "H5Pset_libver_bounds failed");
-
- /* Loop over using new group format */
- for(new_format = FALSE; new_format <= TRUE; new_format++)
- {
- hid_t my_fapl_id;
-
- /* Check for FAPL to use */
- if(new_format)
- my_fapl_id = fapl2_id;
- else
- my_fapl_id = fapl_id;
-
- /* General tests... (on both old & new format groups */
- // FileAccPropList may be passed in instead of fapl id
- test_basic_links(my_fapl_id, new_format);
+ /* Copy the file access property list */
+ if((fapl2_id = H5Pcopy(fapl_id)) < 0)
+ throw Exception("test_links", "H5Pcopy failed");
+
+ /* Set the "use the latest version of the format" bounds for creating objects in the file */
+ if(H5Pset_libver_bounds(fapl2_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ throw Exception("test_links", "H5Pset_libver_bounds failed");
+
+ /* Loop over using new group format */
+ for(new_format = FALSE; new_format <= TRUE; new_format++)
+ {
+ hid_t my_fapl_id;
+
+ /* Check for FAPL to use */
+ if(new_format)
+ my_fapl_id = fapl2_id;
+ else
+ my_fapl_id = fapl_id;
+
+ /* General tests... (on both old & new format groups */
+ // FileAccPropList may be passed in instead of fapl id
+ test_basic_links(my_fapl_id, new_format);
+ test_num_links(my_fapl_id, new_format);
#if 0
// these tests are from the C test links.c and left here for future
// implementation of H5L API
- nerrors += test_basic_links(fapl_id, new_format) < 0 ? 1 : 0;
- nerrors += cklinks(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += new_links(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += ck_new_links(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += long_links(my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += toomany(my_fapl, new_format) < 0 ? 1 : 0;
-
- /* Test new H5L link creation routine */
- nerrors += test_lcpl(my_fapl, new_format);
+ nerrors += test_basic_links(fapl_id, new_format) < 0 ? 1 : 0;
+ nerrors += cklinks(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += new_links(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += ck_new_links(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += long_links(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += toomany(my_fapl, new_format) < 0 ? 1 : 0;
+
+ /* Test new H5L link creation routine */
+ nerrors += test_lcpl(my_fapl, new_format);
nerrors += test_move(my_fapl, new_format);
nerrors += test_copy(my_fapl, new_format);
nerrors += test_move_preserves(my_fapl, new_format);
@@ -582,7 +629,7 @@ void test_links()
/* do not do this for files used by external link tests */
nerrors += check_all_closed(my_fapl, new_format, EXTSTOP) < 0 ? 1 : 0;
#endif // 0
- } /* end for */
+ } /* end for */
#if 0
/* New group revision feature tests */
@@ -612,33 +659,33 @@ void test_links()
nerrors += group_info_old(fapl) < 0 ? 1 : 0;
#endif
- /* Close 2nd FAPL */
- H5Pclose(fapl2_id);
+ /* Close 2nd FAPL */
+ H5Pclose(fapl2_id);
- h5_cleanup(FILENAME, fapl_id);
+ h5_clean_files(FILENAME, fapl_id);
- /* Test that external links can be used after a library reset. MUST be
- * called last so the reset doesn't interfere with the property lists. This
- * routine will delete its own file. */
- /* nerrors += external_reset_register() < 0 ? 1 : 0;
+ /* Test that external links can be used after a library reset. MUST be
+ * called last so the reset doesn't interfere with the property lists. This
+ * routine will delete its own file. */
+ /* nerrors += external_reset_register() < 0 ? 1 : 0;
*/
}
catch (Exception& E)
{
- issue_fail_msg("test_links()", __LINE__, __FILE__, E.getCDetailMsg());
+ issue_fail_msg("test_links()", __LINE__, __FILE__, E.getCDetailMsg());
}
}
/*-------------------------------------------------------------------------
- * Function: cleanup_links
+ * Function: cleanup_links
*
- * Purpose: Cleanup temporary test files
+ * Purpose: Cleanup temporary test files
*
- * Return: none
+ * Return: none
*
- * Programmer: Binh-Minh Ribler
- * October 16, 2009
+ * Programmer: Binh-Minh Ribler
+ * October 16, 2009
*
* Modifications:
*