diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2007-11-01 17:32:49 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2007-11-01 17:32:49 (GMT) |
commit | ecaf22fa0450205a508c961b59dbe616d0449b0a (patch) | |
tree | 8639af89b517b320d8ce09aa5e958f54fc2ad481 /test | |
parent | 88cf7ce60bd0784835d66ff79945baeaa0ddd678 (diff) | |
download | hdf5-ecaf22fa0450205a508c961b59dbe616d0449b0a.zip hdf5-ecaf22fa0450205a508c961b59dbe616d0449b0a.tar.gz hdf5-ecaf22fa0450205a508c961b59dbe616d0449b0a.tar.bz2 |
[svn-r14228] Description:
Change H5Llink to H5Olink, which makes more sense.
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
Diffstat (limited to 'test')
-rw-r--r-- | test/links.c | 133 | ||||
-rw-r--r-- | test/th5o.c | 165 |
2 files changed, 155 insertions, 143 deletions
diff --git a/test/links.c b/test/links.c index bee4f07..8a8ab3a 100644 --- a/test/links.c +++ b/test/links.c @@ -690,134 +690,6 @@ toomany(hid_t fapl, hbool_t new_format) /*------------------------------------------------------------------------- - * Function: test_h5l_create - * - * Purpose: Tests H5Lcreate - * - * Return: Success: 0 - * Failure: number of errors - * - * Programmer: James Laird - * Monday, January 30, 2006 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static int -test_h5l_create(hid_t fapl, hbool_t new_format) -{ - hid_t file_id=-1; - hid_t group_id=-1; - hid_t space_id=-1; - hid_t dset_id=-1; - hid_t type_id=-1; - hid_t lcpl_id=-1; - char filename[1024]; - hsize_t dims[2]; - int i, n, j; - int wdata[H5L_DIM1][H5L_DIM2]; - int rdata[H5L_DIM1][H5L_DIM2]; - - if(new_format) - TESTING("H5Llink (w/new group format)") - else - TESTING("H5Llink") - - /* Create file */ - h5_fixname(FILENAME[3], fapl, filename, sizeof filename); - - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - - /* Create and commit a datatype with no name */ - if((type_id = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR - if(H5Tcommit_anon(file_id, type_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(!H5Tcommitted(type_id)) TEST_ERROR - - /* Create the dataspace */ - dims[0] = H5L_DIM1; - dims[1] = H5L_DIM2; - if((space_id = H5Screate_simple(2 ,dims, NULL)) < 0) TEST_ERROR - - /* Create a dataset with no name using the committed datatype*/ - if ((dset_id = H5Dcreate_anon(file_id, type_id, space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - - /* Verify that we can write to and read from the dataset */ - /* Initialize the dataset */ - for (i = n = 0; i < H5L_DIM1; i++) - for (j = 0; j < H5L_DIM2; j++) - wdata[i][j] = n++; - - /* Write the data to the dataset */ - if (H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata) < 0) TEST_ERROR - - /* Read the data back */ - if (H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata) < 0) TEST_ERROR - - /* Verify the data */ - for (i = 0; i < H5L_DIM1; i++) - for (j = 0; j < H5L_DIM2; j++) - if (wdata[i][j] != rdata[i][j]) - TEST_ERROR - - /* Create a group with no name*/ - if((group_id = H5Gcreate_anon(file_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - - /* Link nameless datatype into nameless group */ - if(H5Llink(group_id, "datatype", type_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - - /* Create LCPL with intermediate group creation flag set */ - if((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) TEST_ERROR - if(H5Pset_create_intermediate_group(lcpl_id, TRUE) < 0) TEST_ERROR - - /* Link nameless dataset into nameless group with intermediate group */ - if(H5Llink(group_id, "inter_group/dataset", dset_id, lcpl_id, H5P_DEFAULT) < 0) TEST_ERROR - - /* Close IDs for dataset and datatype */ - if(H5Dclose(dset_id) < 0) TEST_ERROR - if(H5Tclose(type_id) < 0) TEST_ERROR - - /* Re-open datatype using new link */ - if((type_id = H5Topen2(group_id, "datatype", H5P_DEFAULT)) < 0) TEST_ERROR - - /* Link nameless group to root group and close the group ID*/ - if(H5Llink(file_id, "/group", group_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Gclose(group_id) < 0) TEST_ERROR - - /* Open dataset through root group and verify its data */ - if((dset_id = H5Dopen2(file_id, "/group/inter_group/dataset", H5P_DEFAULT)) < 0) TEST_ERROR - - /* Read data from dataset */ - if (H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata) < 0) TEST_ERROR - for (i = 0; i < H5L_DIM1; i++) - for (j = 0; j < H5L_DIM2; j++) - if (wdata[i][j] != rdata[i][j]) - TEST_ERROR - - /* Close open IDs */ - if(H5Dclose(dset_id) < 0) TEST_ERROR - if(H5Tclose(type_id) < 0) TEST_ERROR - if(H5Pclose(lcpl_id) < 0) TEST_ERROR - if(H5Sclose(space_id) < 0) TEST_ERROR - if(H5Fclose(file_id) < 0) TEST_ERROR - - PASSED(); - return 0; - -error: - H5E_BEGIN_TRY { - H5Gclose(group_id); - H5Dclose(dset_id); - H5Tclose(type_id); - H5Pclose(lcpl_id); - H5Sclose(space_id); - H5Fclose(file_id); - } H5E_END_TRY; - return 1; -} /* end test_h5l_create() */ - - -/*------------------------------------------------------------------------- * Function: test_lcpl * * Purpose: Tests Link Creation Property Lists @@ -5052,8 +4924,8 @@ lapl_nlinks(hid_t fapl, hbool_t new_format) if(H5Lcopy(fid, "soft17", fid, "soft17/newer_soft", H5P_DEFAULT, plist) < 0) TEST_ERROR if(H5Lmove(fid, "soft17/newer_soft", fid, "soft17/newest_soft", H5P_DEFAULT, plist) < 0) TEST_ERROR - /* H5Llink */ - if(H5Llink(fid, "soft17/link_to_group", gid, H5P_DEFAULT, plist) < 0) TEST_ERROR + /* H5Olink */ + if(H5Olink(gid, fid, "soft17/link_to_group", H5P_DEFAULT, plist) < 0) TEST_ERROR /* H5Lcreate_hard and H5Lcreate_soft */ if(H5Lcreate_hard(fid, "soft17", fid, "soft17/link2_to_group", H5P_DEFAULT, plist) < 0) TEST_ERROR @@ -9732,7 +9604,6 @@ main(void) nerrors += toomany((new_format ? fapl2 : fapl), new_format) < 0 ? 1 : 0; /* Test new H5L link creation routine */ - nerrors += test_h5l_create((new_format ? fapl2 : fapl), new_format); nerrors += test_lcpl((new_format ? fapl2 : fapl), new_format); nerrors += test_move((new_format ? fapl2 : fapl), new_format); nerrors += test_copy((new_format ? fapl2 : fapl), new_format); diff --git a/test/th5o.c b/test/th5o.c index cd1fc77..d913e47 100644 --- a/test/th5o.c +++ b/test/th5o.c @@ -23,17 +23,15 @@ #include "testhdf5.h" -/*#include "H5private.h" -#include "H5Bprivate.h" -#include "H5Sprivate.h" -#include "H5Pprivate.h" -*/ - #define TEST_FILENAME "th5o_file" #define RANK 2 #define DIM0 5 #define DIM1 10 + +#define TEST6_DIM1 100 +#define TEST6_DIM2 100 + /**************************************************************** ** @@ -632,16 +630,16 @@ test_h5o_plist(void) /* Create the group anonymously and link it in */ grp = H5Gcreate_anon(fid, gcpl, H5P_DEFAULT); CHECK(grp, FAIL, "H5Gcreate_anon"); - ret = H5Llink(fid, "group", grp, H5P_DEFAULT, H5P_DEFAULT); - CHECK(ret, FAIL, "H5Llink"); + ret = H5Olink(grp, fid, "group", H5P_DEFAULT, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Olink"); /* Commit the type inside the group anonymously and link it in */ dtype = H5Tcopy(H5T_NATIVE_INT); CHECK(dtype, FAIL, "H5Tcopy"); ret = H5Tcommit_anon(fid, dtype, tcpl, H5P_DEFAULT); CHECK(ret, FAIL, "H5Tcommit_anon"); - ret = H5Llink(fid, "datatype", dtype, H5P_DEFAULT, H5P_DEFAULT); - CHECK(ret, FAIL, "H5Llink"); + ret = H5Olink(dtype, fid, "datatype", H5P_DEFAULT, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Olink"); /* Create the dataspace for the dataset. */ dspace = H5Screate(H5S_SCALAR); @@ -650,8 +648,8 @@ test_h5o_plist(void) /* Create the dataset anonymously and link it in */ dset = H5Dcreate_anon(fid, H5T_NATIVE_INT, dspace, dcpl, H5P_DEFAULT); CHECK(dset, FAIL, "H5Dcreate_anon"); - ret = H5Llink(fid, "dataset", dset, H5P_DEFAULT, H5P_DEFAULT); - CHECK(ret, FAIL, "H5Llink"); + ret = H5Olink(dset, fid, "dataset", H5P_DEFAULT, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Olink"); ret = H5Sclose(dspace); CHECK(ret, FAIL, "H5Sclose"); @@ -759,6 +757,147 @@ test_h5o_plist(void) /**************************************************************** ** +** test_h5o_link(): Test creating link to object +** +****************************************************************/ +static void +test_h5o_link(void) +{ + hid_t file_id=-1; + hid_t group_id=-1; + hid_t space_id=-1; + hid_t dset_id=-1; + hid_t type_id=-1; + hid_t fapl_id=-1; + hid_t lcpl_id=-1; + hsize_t dims[2] = {TEST6_DIM1, TEST6_DIM2}; + htri_t committed; /* Whether the named datatype is committed */ + hbool_t new_format; /* Whether to use the new format or not */ + int wdata[TEST6_DIM1][TEST6_DIM2]; + int rdata[TEST6_DIM1][TEST6_DIM2]; + int i, n, j; + herr_t ret; /* Value returned from API calls */ + + /* Initialize the raw data */ + for(i = n = 0; i < TEST6_DIM1; i++) + for(j = 0; j < TEST6_DIM2; j++) + wdata[i][j] = n++; + + /* Create the dataspace */ + space_id = H5Screate_simple(2 ,dims, NULL); + CHECK(space_id, FAIL, "H5Screate_simple"); + + /* Create LCPL with intermediate group creation flag set */ + lcpl_id = H5Pcreate(H5P_LINK_CREATE); + CHECK(lcpl_id, FAIL, "H5Pcreate"); + ret = H5Pset_create_intermediate_group(lcpl_id, TRUE); + CHECK(ret, FAIL, "H5Pset_create_intermediate_group"); + + /* Loop over using new group format */ + for(new_format = FALSE; new_format <= TRUE; new_format++) { + + /* Make a FAPL that uses the "use the latest version of the format" flag */ + fapl_id = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl_id, FAIL, "H5Pcreate"); + + /* Set the "use the latest version of the format" flag for creating objects in the file */ + ret = H5Pset_latest_format(fapl_id, new_format); + CHECK(ret, FAIL, "H5Pset_latest_format"); + + /* Create a new HDF5 file */ + file_id = H5Fcreate(TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); + CHECK(file_id, FAIL, "H5Fcreate"); + + /* Close the FAPL */ + ret = H5Pclose(fapl_id); + CHECK(ret, FAIL, "H5Pclose"); + + + /* Create and commit a datatype with no name */ + type_id = H5Tcopy(H5T_NATIVE_INT); + CHECK(type_id, FAIL, "H5Fcreate"); + ret = H5Tcommit_anon(file_id, type_id, H5P_DEFAULT, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Tcommit_anon"); + committed = H5Tcommitted(type_id); + VERIFY(committed, TRUE, "H5Tcommitted"); + + /* Create a dataset with no name using the committed datatype*/ + dset_id = H5Dcreate_anon(file_id, type_id, space_id, H5P_DEFAULT, H5P_DEFAULT); + CHECK(dset_id, FAIL, "H5Dcreate_anon"); + + /* Verify that we can write to and read from the dataset */ + + /* Write the data to the dataset */ + ret = H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); + CHECK(ret, FAIL, "H5Dwrite"); + + /* Read the data back */ + ret = H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata); + CHECK(ret, FAIL, "H5Dread"); + + /* Verify the data */ + for(i = 0; i < TEST6_DIM1; i++) + for(j = 0; j < TEST6_DIM2; j++) + VERIFY(wdata[i][j], rdata[i][j], "H5Dread"); + + /* Create a group with no name*/ + group_id = H5Gcreate_anon(file_id, H5P_DEFAULT, H5P_DEFAULT); + CHECK(group_id, FAIL, "H5Gcreate_anon"); + + /* Link nameless datatype into nameless group */ + ret = H5Olink(type_id, group_id, "datatype", H5P_DEFAULT, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Olink"); + + /* Link nameless dataset into nameless group with intermediate group */ + ret = H5Olink(dset_id, group_id, "inter_group/dataset", lcpl_id, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Olink"); + + /* Close IDs for dataset and datatype */ + ret = H5Dclose(dset_id); + CHECK(ret, FAIL, "H5Dclose"); + ret = H5Tclose(type_id); + CHECK(ret, FAIL, "H5Tclose"); + + /* Re-open datatype using new link */ + type_id = H5Topen2(group_id, "datatype", H5P_DEFAULT); + CHECK(type_id, FAIL, "H5Topen2"); + + /* Link nameless group to root group and close the group ID*/ + ret = H5Olink(group_id, file_id, "/group", H5P_DEFAULT, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Olink"); + ret = H5Gclose(group_id); + CHECK(ret, FAIL, "H5Gclose"); + + /* Open dataset through root group and verify its data */ + dset_id = H5Dopen2(file_id, "/group/inter_group/dataset", H5P_DEFAULT); + CHECK(dset_id, FAIL, "H5Dopen2"); + + /* Read data from dataset */ + ret = H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata); + CHECK(ret, FAIL, "H5Dread"); + for(i = 0; i < TEST6_DIM1; i++) + for(j = 0; j < TEST6_DIM2; j++) + VERIFY(wdata[i][j], rdata[i][j], "H5Dread"); + + /* Close open IDs */ + ret = H5Dclose(dset_id); + CHECK(ret, FAIL, "H5Dclose"); + ret = H5Tclose(type_id); + CHECK(ret, FAIL, "H5Tclose"); + ret = H5Fclose(file_id); + CHECK(ret, FAIL, "H5Fclose"); + } /* end for */ + + /* Close remaining IDs */ + ret = H5Sclose(space_id); + CHECK(ret, FAIL, "H5Sclose"); + ret = H5Pclose(lcpl_id); + CHECK(ret, FAIL, "H5Pclose"); +} /* end test_h5o_link() */ + + +/**************************************************************** +** ** test_h5o(): Main H5O (generic object) testing routine. ** ****************************************************************/ @@ -773,6 +912,7 @@ test_h5o(void) test_h5o_close(); /* Test generic close function */ test_h5o_refcount(); /* Test incrementing and decrementing reference count */ test_h5o_plist(); /* Test object creation properties */ + test_h5o_link(); /* Test object link routine */ } /* test_h5o() */ @@ -793,3 +933,4 @@ cleanup_h5o(void) { remove(TEST_FILENAME); } + |