diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/Makefile.in | 2 | ||||
-rw-r--r-- | test/links.c | 1026 | ||||
-rw-r--r-- | test/mount.c | 12 | ||||
-rwxr-xr-x | test/objcopy.c | 123 | ||||
-rw-r--r-- | test/stab.c | 19 | ||||
-rw-r--r-- | test/tmisc.c | 89 | ||||
-rw-r--r-- | test/tunicode.c | 7 |
7 files changed, 1076 insertions, 202 deletions
diff --git a/test/Makefile.in b/test/Makefile.in index ad5677a..7247af0 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -588,7 +588,7 @@ TRACE = perl $(top_srcdir)/bin/trace # Temporary files. These files are the ones created by setting the # HDF5_NOCLEANUP environment variable and running `make test' without # specifying a file prefix or low-level driver. Changing the file -# prefix or low-level driver with environment variables will influence +# prefix or low-level driver with environment variables will influence # the temporary file name in ways that the makefile is not aware of. CHECK_CLEANFILES = *.chkexe *.chklog *.clog cmpd_dset.h5 \ compact_dataset.h5 dataset.h5 extend.h5 istore.h5 \ diff --git a/test/links.c b/test/links.c index 0d3388c..1ad35af 100644 --- a/test/links.c +++ b/test/links.c @@ -28,9 +28,22 @@ #include "H5Gpkg.h" /* Groups */ const char *FILENAME[] = { + "links0", "links1", "links2", "links3", + "links4", + "links5", + "links6", + "links7", + "links8", + "links9", + "links10", + "links11", + "links12", + "links13", + "links14", + "links15", NULL }; @@ -38,6 +51,9 @@ const char *FILENAME[] = { #define NAME_BUF_SIZE 1024 #define MAX_NAME_LEN ((64*1024)+1024) +#define H5L_DIM1 100 +#define H5L_DIM2 100 + /*------------------------------------------------------------------------- * Function: mklinks @@ -65,7 +81,7 @@ mklinks(hid_t fapl) TESTING("link creation"); /* Create a file */ - h5_fixname(FILENAME[0], fapl, filename, sizeof filename); + h5_fixname(FILENAME[1], fapl, filename, sizeof filename); if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) TEST_ERROR; if ((scalar=H5Screate_simple (1, size, size))<0) TEST_ERROR; @@ -78,16 +94,16 @@ mklinks(hid_t fapl) if (H5Dclose (d1)<0) TEST_ERROR; /* Create a hard link */ - if (H5Glink (file, H5G_LINK_HARD, "d1", "grp1/hard")<0) TEST_ERROR; + if (H5Lcreate_hard (file, "d1", H5L_SAME_LOC, "grp1/hard", H5P_DEFAULT)<0) TEST_ERROR; /* Create a symbolic link */ - if (H5Glink (file, H5G_LINK_SOFT, "/d1", "grp1/soft")<0) TEST_ERROR; + if (H5Lcreate_soft ("/d1", file, "grp1/soft", H5P_DEFAULT)<0) TEST_ERROR; /* Create a symbolic link to something that doesn't exist */ - if (H5Glink (file, H5G_LINK_SOFT, "foobar", "grp1/dangle")<0) TEST_ERROR; + if (H5Lcreate_soft ("foobar", file, "grp1/dangle", H5P_DEFAULT)<0) TEST_ERROR; /* Create a recursive symbolic link */ - if (H5Glink (file, H5G_LINK_SOFT, "/grp1/recursive", "/grp1/recursive")<0) TEST_ERROR; + if (H5Lcreate_soft ("/grp1/recursive", file, "/grp1/recursive", H5P_DEFAULT)<0) TEST_ERROR; /* Close */ if (H5Sclose (scalar)<0) TEST_ERROR; @@ -127,7 +143,7 @@ new_links(hid_t fapl) char filename[NAME_BUF_SIZE]; hsize_t size[1] = {1}; - TESTING("H5Glink2 function"); + TESTING("H5Lcreate functions"); /* Create two files */ h5_fixname(FILENAME[1], fapl, filename, sizeof filename); @@ -149,30 +165,24 @@ new_links(hid_t fapl) if((dset2=H5Dcreate(grp1_a, "dataset2", H5T_NATIVE_INT, scalar, H5P_DEFAULT))<0) TEST_ERROR; /* Create links within a file. Both of source and destination use - * H5G_SAME_LOC. Both hard and soft links should fail. */ + * H5L_SAME_LOC. Both hard and soft links should fail. */ H5E_BEGIN_TRY { - if(H5Glink2(H5G_SAME_LOC, "dataset1", H5G_LINK_HARD , H5G_SAME_LOC, "hard")!=FAIL) TEST_ERROR; + if(H5Lcreate_hard(H5L_SAME_LOC, "dataset1", H5L_SAME_LOC, "hard", H5P_DEFAULT)!=FAIL) TEST_ERROR; } H5E_END_TRY; H5E_BEGIN_TRY { - if(H5Glink2(H5G_SAME_LOC, "dataset1", H5G_LINK_SOFT , H5G_SAME_LOC, "soft")!=FAIL) TEST_ERROR; + if(H5Lcreate_soft("dataset1", H5L_SAME_LOC, "soft", H5P_DEFAULT)!=FAIL) TEST_ERROR; } H5E_END_TRY; - /* Create links across files. Both hard and soft links should fail. */ + /* Create links across files with hard link. Should fail. */ H5E_BEGIN_TRY { - if(H5Glink2(file_a, "dataset1", H5G_LINK_HARD , file_b, "hard")!=FAIL) TEST_ERROR; - } H5E_END_TRY; - H5E_BEGIN_TRY { - if(H5Glink2(file_a, "dataset1", H5G_LINK_SOFT, file_b, "soft")!=FAIL) TEST_ERROR; + if(H5Lcreate_hard(file_a, "dataset1", file_b, "hard", H5P_DEFAULT)!=FAIL) TEST_ERROR; } H5E_END_TRY; - /* Create links to test H5G_SAME_LOC, H5G_LINK_HARD, H5G_LINK_SOFT. */ - if(H5Glink2(grp1_a, "dataset2", H5G_LINK_HARD , H5G_SAME_LOC, "hard1")<0) TEST_ERROR; - if(H5Glink2(H5G_SAME_LOC, "dataset2", H5G_LINK_SOFT , grp1_a, "soft1")<0) TEST_ERROR; + /* Create hard link to test H5L_SAME_LOC */ + if(H5Lcreate_hard(grp1_a, "dataset2", H5L_SAME_LOC, "hard1", H5P_DEFAULT)<0) TEST_ERROR; - /* Create links to test H5G_LINK_HARD, H5G_LINK_SOFT across different - * locations. */ - if(H5Glink2(grp1_a, "dataset2", H5G_LINK_HARD, grp2_a, "hard2")<0) TEST_ERROR; - if(H5Glink2(grp1_a, "/grp1/dataset2", H5G_LINK_SOFT , grp2_a, "soft2")<0) TEST_ERROR; + /* Create links to test hard links across different locations */ + if(H5Lcreate_hard(grp1_a, "dataset2", grp2_a, "hard2", H5P_DEFAULT)<0) TEST_ERROR; /* Close dataspace and files */ if (H5Sclose (scalar)<0) TEST_ERROR; @@ -233,7 +243,7 @@ cklinks(hid_t fapl) TESTING("link queries"); /* Open the file */ - h5_fixname(FILENAME[0], fapl, filename, sizeof filename); + h5_fixname(FILENAME[1], fapl, filename, sizeof filename); if ((file=H5Fopen(filename, H5F_ACC_RDONLY, fapl))<0) TEST_ERROR; /* Hard link */ @@ -242,13 +252,13 @@ cklinks(hid_t fapl) if (H5G_DATASET!=sb2.type) { H5_FAILED(); printf(" %d: Unexpected object type should have been a dataset\n", __LINE__); - goto error; + TEST_ERROR; } if (HDmemcmp(&sb1.objno, &sb2.objno, sizeof(sb1.objno))) { H5_FAILED(); puts(" Hard link test failed. Link seems not to point to the "); puts(" expected file location."); - goto error; + TEST_ERROR; } /* Symbolic link */ @@ -256,19 +266,19 @@ cklinks(hid_t fapl) if (H5G_DATASET!=sb2.type) { H5_FAILED(); printf(" %d: Unexpected object type should have been a dataset\n", __LINE__); - goto error; + TEST_ERROR; } if (HDmemcmp(&sb1.objno, &sb2.objno, sizeof(sb1.objno))) { H5_FAILED(); puts(" Soft link test failed. Link seems not to point to the "); puts(" expected file location."); - goto error; + TEST_ERROR; } if (H5Gget_linkval(file, "grp1/soft", sizeof linkval, linkval)<0) TEST_ERROR; if (HDstrcmp(linkval, "/d1")) { H5_FAILED(); puts(" Soft link test failed. Wrong link value"); - goto error; + TEST_ERROR; } /* Dangling link */ @@ -278,23 +288,23 @@ cklinks(hid_t fapl) if (status>=0) { H5_FAILED(); puts(" H5Gget_objinfo() should have failed for a dangling link."); - goto error; + TEST_ERROR; } if (H5Gget_objinfo(file, "grp1/dangle", FALSE, &sb2)<0) TEST_ERROR; if (H5G_LINK!=sb2.type) { H5_FAILED(); printf(" %d: Unexpected object type should have been a symbolic link\n", __LINE__); - goto error; + TEST_ERROR; } if (H5Gget_linkval(file, "grp1/dangle", sizeof linkval, linkval)<0) { H5_FAILED(); printf(" %d: Can't retrieve link value\n", __LINE__); - goto error; + TEST_ERROR; } if (HDstrcmp(linkval, "foobar")) { H5_FAILED(); puts(" Dangling link test failed. Wrong link value"); - goto error; + TEST_ERROR; } /* Recursive link */ @@ -304,23 +314,23 @@ cklinks(hid_t fapl) if (status>=0) { H5_FAILED(); puts(" H5Gget_objinfo() should have failed for a recursive link."); - goto error; + TEST_ERROR; } if (H5Gget_objinfo(file, "grp1/recursive", FALSE, &sb2)<0) TEST_ERROR; if (H5G_LINK!=sb2.type) { H5_FAILED(); printf(" %d: Unexpected object type should have been a symbolic link\n", __LINE__); - goto error; + TEST_ERROR; } if (H5Gget_linkval(file, "grp1/recursive", sizeof linkval, linkval)<0) { H5_FAILED(); printf(" %d: Can't retrieve link value\n", __LINE__); - goto error; + TEST_ERROR; } if (HDstrcmp(linkval, "/grp1/recursive")) { H5_FAILED(); puts(" Recursive link test failed. Wrong link value"); - goto error; + TEST_ERROR; } /* Cleanup */ @@ -352,9 +362,8 @@ static int ck_new_links(hid_t fapl) { hid_t file; - H5G_stat_t sb_dset, sb_hard1, sb_hard2, sb_soft1, sb_soft2; + H5G_stat_t sb_dset, sb_hard1, sb_hard2; char filename[NAME_BUF_SIZE]; - char linkval[LINK_BUF_SIZE]; TESTING("new link queries"); @@ -374,39 +383,13 @@ ck_new_links(hid_t fapl) if(H5G_DATASET!=sb_hard1.type || H5G_DATASET!=sb_hard2.type) { H5_FAILED(); printf(" %d: Unexpected object type should have been a dataset\n", __LINE__); - goto error; + TEST_ERROR; } if(HDmemcmp(&sb_dset.objno, &sb_hard1.objno, sizeof(sb_dset.objno)) || HDmemcmp(&sb_dset.objno, &sb_hard2.objno, sizeof(sb_dset.objno))) { H5_FAILED(); puts(" Hard link test failed. Link seems not to point to the "); puts(" expected file location."); - goto error; - } - - /* Get soft link info */ - if(H5Gget_objinfo(file, "/grp1/soft1", TRUE, &sb_soft1)<0) TEST_ERROR; - if(H5Gget_objinfo(file, "/grp2/soft2", TRUE, &sb_soft2)<0) TEST_ERROR; - - /* Check soft links */ - if(H5G_DATASET!=sb_soft1.type || H5G_DATASET!=sb_soft2.type) { - H5_FAILED(); - printf(" %d: Unexpected object type should have been a dataset\n", __LINE__); - TEST_ERROR; - } - - if(HDmemcmp(&sb_dset.objno, &sb_soft1.objno, sizeof(sb_dset.objno)) || HDmemcmp(&sb_dset.objno, &sb_soft2.objno, sizeof(sb_dset.objno))) { - H5_FAILED(); - puts(" Soft link test failed. Link seems not to point to the "); - puts(" expected file location."); - TEST_ERROR; - } - - if (H5Gget_linkval(file, "grp2/soft2", sizeof linkval, linkval)<0) - TEST_ERROR; - if (HDstrcmp(linkval, "/grp1/dataset2")) { - H5_FAILED(); - puts(" Soft link test failed. Wrong link value"); - TEST_ERROR; + TEST_ERROR; } /* Cleanup */ @@ -448,7 +431,7 @@ long_links(hid_t fapl) TESTING("long names for objects & links"); /* Create files */ - h5_fixname(FILENAME[1], fapl, filename, sizeof filename); + h5_fixname(FILENAME[13], fapl, filename, sizeof filename); if((fid=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) TEST_ERROR; /* Create group with short name in file (used as target for hard links) */ @@ -461,11 +444,11 @@ long_links(hid_t fapl) objname[MAX_NAME_LEN] = '\0'; /* Create hard link to existing object */ - if(H5Glink2(fid, "grp1", H5G_LINK_HARD, fid, objname) < 0) TEST_ERROR; + if(H5Lcreate_hard(fid, "grp1", fid, objname, H5P_DEFAULT) < 0) TEST_ERROR; /* Create soft link to existing object */ objname[0] = 'b'; - if(H5Glink2(fid, "grp1", H5G_LINK_SOFT, fid, objname) < 0) TEST_ERROR; + if(H5Lcreate_soft("grp1", fid, objname, H5P_DEFAULT) < 0) TEST_ERROR; /* Create group with long name in existing group */ if((gid2=H5Gcreate(gid, objname, (size_t)0))<0) TEST_ERROR; @@ -527,53 +510,53 @@ toomany(hid_t fapl) HDassert(H5G_NLINKS == 16); /* Create files */ - h5_fixname(FILENAME[1], fapl, filename, sizeof filename); + h5_fixname(FILENAME[14], fapl, filename, sizeof filename); if((fid=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) TEST_ERROR; /* Create group with short name in file (used as target for hard links) */ if((gid=H5Gcreate (fid, "final", (size_t)0))<0) TEST_ERROR; /* Create chain of hard links to existing object (no limit on #) */ - if(H5Glink2(fid, "final", H5G_LINK_HARD, fid, "hard1") < 0) TEST_ERROR; - if(H5Glink2(fid, "hard1", H5G_LINK_HARD, fid, "hard2") < 0) TEST_ERROR; - if(H5Glink2(fid, "hard2", H5G_LINK_HARD, fid, "hard3") < 0) TEST_ERROR; - if(H5Glink2(fid, "hard3", H5G_LINK_HARD, fid, "hard4") < 0) TEST_ERROR; - if(H5Glink2(fid, "hard4", H5G_LINK_HARD, fid, "hard5") < 0) TEST_ERROR; - if(H5Glink2(fid, "hard5", H5G_LINK_HARD, fid, "hard6") < 0) TEST_ERROR; - if(H5Glink2(fid, "hard6", H5G_LINK_HARD, fid, "hard7") < 0) TEST_ERROR; - if(H5Glink2(fid, "hard7", H5G_LINK_HARD, fid, "hard8") < 0) TEST_ERROR; - if(H5Glink2(fid, "hard8", H5G_LINK_HARD, fid, "hard9") < 0) TEST_ERROR; - if(H5Glink2(fid, "hard9", H5G_LINK_HARD, fid, "hard10") < 0) TEST_ERROR; - if(H5Glink2(fid, "hard10", H5G_LINK_HARD, fid, "hard11") < 0) TEST_ERROR; - if(H5Glink2(fid, "hard11", H5G_LINK_HARD, fid, "hard12") < 0) TEST_ERROR; - if(H5Glink2(fid, "hard12", H5G_LINK_HARD, fid, "hard13") < 0) TEST_ERROR; - if(H5Glink2(fid, "hard13", H5G_LINK_HARD, fid, "hard14") < 0) TEST_ERROR; - if(H5Glink2(fid, "hard14", H5G_LINK_HARD, fid, "hard15") < 0) TEST_ERROR; - if(H5Glink2(fid, "hard15", H5G_LINK_HARD, fid, "hard16") < 0) TEST_ERROR; - if(H5Glink2(fid, "hard16", H5G_LINK_HARD, fid, "hard17") < 0) TEST_ERROR; - if(H5Glink2(fid, "hard17", H5G_LINK_HARD, fid, "hard18") < 0) TEST_ERROR; - if(H5Glink2(fid, "hard18", H5G_LINK_HARD, fid, "hard19") < 0) TEST_ERROR; - if(H5Glink2(fid, "hard19", H5G_LINK_HARD, fid, "hard20") < 0) TEST_ERROR; - if(H5Glink2(fid, "hard20", H5G_LINK_HARD, fid, "hard21") < 0) TEST_ERROR; + if(H5Lcreate_hard(fid, "final", fid, "hard1", H5P_DEFAULT) < 0) TEST_ERROR; + if(H5Lcreate_hard(fid, "hard1", fid, "hard2", H5P_DEFAULT) < 0) TEST_ERROR; + if(H5Lcreate_hard(fid, "hard2", fid, "hard3", H5P_DEFAULT) < 0) TEST_ERROR; + if(H5Lcreate_hard(fid, "hard3", fid, "hard4", H5P_DEFAULT) < 0) TEST_ERROR; + if(H5Lcreate_hard(fid, "hard4", fid, "hard5", H5P_DEFAULT) < 0) TEST_ERROR; + if(H5Lcreate_hard(fid, "hard5", fid, "hard6", H5P_DEFAULT) < 0) TEST_ERROR; + if(H5Lcreate_hard(fid, "hard6", fid, "hard7", H5P_DEFAULT) < 0) TEST_ERROR; + if(H5Lcreate_hard(fid, "hard7", fid, "hard8", H5P_DEFAULT) < 0) TEST_ERROR; + if(H5Lcreate_hard(fid, "hard8", fid, "hard9", H5P_DEFAULT) < 0) TEST_ERROR; + if(H5Lcreate_hard(fid, "hard9", fid, "hard10", H5P_DEFAULT) < 0) TEST_ERROR; + if(H5Lcreate_hard(fid, "hard10", fid, "hard11", H5P_DEFAULT) < 0) TEST_ERROR; + if(H5Lcreate_hard(fid, "hard11", fid, "hard12", H5P_DEFAULT) < 0) TEST_ERROR; + if(H5Lcreate_hard(fid, "hard12", fid, "hard13", H5P_DEFAULT) < 0) TEST_ERROR; + if(H5Lcreate_hard(fid, "hard13", fid, "hard14", H5P_DEFAULT) < 0) TEST_ERROR; + if(H5Lcreate_hard(fid, "hard14", fid, "hard15", H5P_DEFAULT) < 0) TEST_ERROR; + if(H5Lcreate_hard(fid, "hard15", fid, "hard16", H5P_DEFAULT) < 0) TEST_ERROR; + if(H5Lcreate_hard(fid, "hard16", fid, "hard17", H5P_DEFAULT) < 0) TEST_ERROR; + if(H5Lcreate_hard(fid, "hard17", fid, "hard18", H5P_DEFAULT) < 0) TEST_ERROR; + if(H5Lcreate_hard(fid, "hard18", fid, "hard19", H5P_DEFAULT) < 0) TEST_ERROR; + if(H5Lcreate_hard(fid, "hard19", fid, "hard20", H5P_DEFAULT) < 0) TEST_ERROR; + if(H5Lcreate_hard(fid, "hard20", fid, "hard21", H5P_DEFAULT) < 0) TEST_ERROR; /* Create chain of soft links to existing object (limited) */ - if(H5Glink2(fid, "final", H5G_LINK_SOFT, fid, "soft1") < 0) TEST_ERROR; - if(H5Glink2(fid, "soft1", H5G_LINK_SOFT, fid, "soft2") < 0) TEST_ERROR; - if(H5Glink2(fid, "soft2", H5G_LINK_SOFT, fid, "soft3") < 0) TEST_ERROR; - if(H5Glink2(fid, "soft3", H5G_LINK_SOFT, fid, "soft4") < 0) TEST_ERROR; - if(H5Glink2(fid, "soft4", H5G_LINK_SOFT, fid, "soft5") < 0) TEST_ERROR; - if(H5Glink2(fid, "soft5", H5G_LINK_SOFT, fid, "soft6") < 0) TEST_ERROR; - if(H5Glink2(fid, "soft6", H5G_LINK_SOFT, fid, "soft7") < 0) TEST_ERROR; - if(H5Glink2(fid, "soft7", H5G_LINK_SOFT, fid, "soft8") < 0) TEST_ERROR; - if(H5Glink2(fid, "soft8", H5G_LINK_SOFT, fid, "soft9") < 0) TEST_ERROR; - if(H5Glink2(fid, "soft9", H5G_LINK_SOFT, fid, "soft10") < 0) TEST_ERROR; - if(H5Glink2(fid, "soft10", H5G_LINK_SOFT, fid, "soft11") < 0) TEST_ERROR; - if(H5Glink2(fid, "soft11", H5G_LINK_SOFT, fid, "soft12") < 0) TEST_ERROR; - if(H5Glink2(fid, "soft12", H5G_LINK_SOFT, fid, "soft13") < 0) TEST_ERROR; - if(H5Glink2(fid, "soft13", H5G_LINK_SOFT, fid, "soft14") < 0) TEST_ERROR; - if(H5Glink2(fid, "soft14", H5G_LINK_SOFT, fid, "soft15") < 0) TEST_ERROR; - if(H5Glink2(fid, "soft15", H5G_LINK_SOFT, fid, "soft16") < 0) TEST_ERROR; - if(H5Glink2(fid, "soft16", H5G_LINK_SOFT, fid, "soft17") < 0) TEST_ERROR; + if(H5Lcreate_soft("final", fid, "soft1", H5P_DEFAULT) < 0) TEST_ERROR; + if(H5Lcreate_soft("soft1", fid, "soft2", H5P_DEFAULT) < 0) TEST_ERROR; + if(H5Lcreate_soft("soft2", fid, "soft3", H5P_DEFAULT) < 0) TEST_ERROR; + if(H5Lcreate_soft("soft3", fid, "soft4", H5P_DEFAULT) < 0) TEST_ERROR; + if(H5Lcreate_soft("soft4", fid, "soft5", H5P_DEFAULT) < 0) TEST_ERROR; + if(H5Lcreate_soft("soft5", fid, "soft6", H5P_DEFAULT) < 0) TEST_ERROR; + if(H5Lcreate_soft("soft6", fid, "soft7", H5P_DEFAULT) < 0) TEST_ERROR; + if(H5Lcreate_soft("soft7", fid, "soft8", H5P_DEFAULT) < 0) TEST_ERROR; + if(H5Lcreate_soft("soft8", fid, "soft9", H5P_DEFAULT) < 0) TEST_ERROR; + if(H5Lcreate_soft("soft9", fid, "soft10", H5P_DEFAULT) < 0) TEST_ERROR; + if(H5Lcreate_soft("soft10", fid, "soft11", H5P_DEFAULT) < 0) TEST_ERROR; + if(H5Lcreate_soft("soft11", fid, "soft12", H5P_DEFAULT) < 0) TEST_ERROR; + if(H5Lcreate_soft("soft12", fid, "soft13", H5P_DEFAULT) < 0) TEST_ERROR; + if(H5Lcreate_soft("soft13", fid, "soft14", H5P_DEFAULT) < 0) TEST_ERROR; + if(H5Lcreate_soft("soft14", fid, "soft15", H5P_DEFAULT) < 0) TEST_ERROR; + if(H5Lcreate_soft("soft15", fid, "soft16", H5P_DEFAULT) < 0) TEST_ERROR; + if(H5Lcreate_soft("soft16", fid, "soft17", H5P_DEFAULT) < 0) TEST_ERROR; /* Close objects */ if(H5Gclose(gid)<0) TEST_ERROR; @@ -605,7 +588,7 @@ toomany(hid_t fapl) if (gid >= 0) { H5_FAILED(); puts(" Should have failed for sequence of too many nested links."); - goto error; + TEST_ERROR; } /* Open object through lesser soft link */ @@ -640,6 +623,821 @@ toomany(hid_t fapl) } /* end toomany() */ +#ifdef H5_GROUP_REVISION +/*------------------------------------------------------------------------- + * 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) +{ + hid_t fapl_id=-1; + 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]; + TESTING("H5Lcreate"); + + /* Create file */ + fapl_id = h5_fileaccess(); + h5_fixname(FILENAME[3], fapl_id, filename, sizeof filename); + + if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id))<0) TEST_ERROR; + + /* Create and commit a datatype with no name */ + if((type_id =H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR; + if(H5Tcommit_expand(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_expand(file_id, type_id, space_id, 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_expand(file_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; + + /* Link nameless datatype into nameless group */ + if(H5Lcreate(group_id, "datatype", type_id, 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(H5Lcreate(group_id, "inter_group/dataset", dset_id, lcpl_id)<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 = H5Topen(group_id, "datatype"))<0) TEST_ERROR; + + /* Link nameless group to root group and close the group ID*/ + if(H5Lcreate(file_id, "/group", group_id, H5P_DEFAULT)<0) TEST_ERROR; + if(H5Gclose(group_id)<0) TEST_ERROR; + + /* Open dataset through root group and verify its data */ + if((dset_id = H5Dopen(file_id, "/group/inter_group/dataset"))<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; + if(H5Pclose(fapl_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); + H5Pclose(fapl_id); + } H5E_END_TRY; + return 1; +} /* end test_h5l_create() */ + + +/*------------------------------------------------------------------------- + * Function: test_lcpl + * + * Purpose: Tests Link Creation Property Lists + * + * Return: Success: 0 + * Failure: number of errors + * + * Programmer: James Laird + * Monday, January 30, 2006 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static int +test_lcpl(hid_t fapl) +{ + hid_t fapl_id=-1; + 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; + H5L_linkinfo_t linfo; + char filename[1024]; + hsize_t dims[2]; + + TESTING("link creation property lists"); + /* Actually, intermediate group creation is tested elsewhere (tmisc). + * Here we only need to test the character encoding property */ + + /* Create file */ + fapl_id = h5_fileaccess(); + h5_fixname(FILENAME[12], fapl_id, filename, sizeof filename); + + if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id))<0) TEST_ERROR; + + /* Create and link a group with the default LCPL */ + if((group_id = H5Gcreate_expand(file_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; + if(H5Lcreate(file_id, "/group", group_id, H5P_DEFAULT)<0) TEST_ERROR; + if(H5Gclose(group_id)<0) TEST_ERROR; + + /* Check that its character encoding is the default */ + if(H5Lget_linkinfo(file_id, "group", &linfo) < 0) TEST_ERROR; + if(linfo.cset != H5F_CRT_DEFAULT_CSET) TEST_ERROR; + + /* Create and commit a datatype with the default LCPL */ + if((type_id =H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR; + if(H5Tcommit_expand(file_id, type_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; + if(H5Lcreate(file_id, "/type", type_id, H5P_DEFAULT)<0) TEST_ERROR; + if(H5Tclose(type_id)<0) TEST_ERROR; + + /* Check that its character encoding is the default */ + if(H5Lget_linkinfo(file_id, "type", &linfo) < 0) TEST_ERROR; + if(linfo.cset != H5F_CRT_DEFAULT_CSET) TEST_ERROR; + + /* Create a dataspace */ + dims[0] = H5L_DIM1; + dims[1] = H5L_DIM2; + if((space_id=H5Screate_simple(2 ,dims, NULL))<0) TEST_ERROR; + + /* Create a dataset using the default LCPL */ + if ((dset_id = H5Dcreate_expand(file_id, H5T_NATIVE_INT, space_id, H5P_DEFAULT)) <0) TEST_ERROR; + if(H5Lcreate(file_id, "/dataset", dset_id, H5P_DEFAULT)<0) TEST_ERROR; + if(H5Dclose(dset_id)<0) TEST_ERROR; + + /* Check that its character encoding is the default */ + if(H5Lget_linkinfo(file_id, "dataset", &linfo) < 0) TEST_ERROR; + if(linfo.cset != H5F_CRT_DEFAULT_CSET) TEST_ERROR; + + /* Create a link creation property list with the UTF-8 character encoding */ + if((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) <0) TEST_ERROR; + if(H5Pset_char_encoding(lcpl_id, H5T_CSET_UTF8) < 0) TEST_ERROR; + + /* Create and link a group with the new LCPL */ + if((group_id = H5Gcreate_expand(file_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; + if(H5Lcreate(file_id, "/group2", group_id, lcpl_id)<0) TEST_ERROR; + if(H5Gclose(group_id)<0) TEST_ERROR; + + /* Check that its character encoding is UTF-8 */ + if(H5Lget_linkinfo(file_id, "group2", &linfo) < 0) TEST_ERROR; + if(linfo.cset != H5T_CSET_UTF8) TEST_ERROR; + + /* Create and commit a datatype with the new LCPL */ + if((type_id =H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR; + if(H5Tcommit_expand(file_id, type_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; + if(H5Lcreate(file_id, "/type2", type_id, lcpl_id)<0) TEST_ERROR; + if(H5Tclose(type_id)<0) TEST_ERROR; + + /* Check that its character encoding is UTF-8 */ + if(H5Lget_linkinfo(file_id, "type2", &linfo) < 0) TEST_ERROR; + if(linfo.cset != H5T_CSET_UTF8) TEST_ERROR; + + /* Create a dataset using the new LCPL */ + if ((dset_id = H5Dcreate_expand(file_id, H5T_NATIVE_INT, space_id, H5P_DEFAULT)) <0) TEST_ERROR; + if(H5Lcreate(file_id, "/dataset2", dset_id, lcpl_id)<0) TEST_ERROR; + if(H5Dclose(dset_id)<0) TEST_ERROR; + + /* Check that its character encoding is UTF-8 */ + if(H5Lget_linkinfo(file_id, "dataset2", &linfo) < 0) TEST_ERROR; + if(linfo.cset != H5T_CSET_UTF8) TEST_ERROR; + + /* Create a new link to the dataset with a different character encoding. */ + if(H5Pclose(lcpl_id)<0) TEST_ERROR; + if((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) <0) TEST_ERROR; + if(H5Pset_char_encoding(lcpl_id, H5T_CSET_ASCII) < 0) TEST_ERROR; + + if(H5Lcreate_hard(file_id, "/dataset2", file_id, "/dataset2_link", lcpl_id) < 0) TEST_ERROR; + + /* Check that its character encoding is ASCII */ + if(H5Lget_linkinfo(file_id, "/dataset2_link", &linfo) < 0) TEST_ERROR; + if(linfo.cset != H5T_CSET_ASCII) TEST_ERROR; + + /* Check that the first link's encoding hasn't changed */ + if(H5Lget_linkinfo(file_id, "/dataset2", &linfo) < 0) TEST_ERROR; + if(linfo.cset != H5T_CSET_UTF8) TEST_ERROR; + + /* Close open IDs */ + if(H5Pclose(lcpl_id)<0) TEST_ERROR; + if(H5Sclose(space_id)<0) TEST_ERROR; + if(H5Fclose(file_id)<0) TEST_ERROR; + if(H5Pclose(fapl_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); + H5Pclose(fapl_id); + } H5E_END_TRY; + return 1; +} /* end test_lcpl() */ +#endif /* H5_GROUP_REVISION */ + + +/*------------------------------------------------------------------------- + * Function: test_move + * + * Purpose: Tests H5Lmove() + * + * Return: Success: 0 + * + * Failure: number of errors + * + * Programmer: James Laird + * Friday, March 30, 2006 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static int +test_move(hid_t fapl) +{ + hid_t file_a, file_b=(-1); + hid_t grp_1=(-1), grp_2=(-1), grp_move=(-1), moved_grp=(-1); + char filename[1024]; + + TESTING("H5Lmove"); + + /* Create two new files */ + h5_fixname(FILENAME[8], fapl, filename, sizeof filename); + if ((file_a=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) + TEST_ERROR; + h5_fixname(FILENAME[9], fapl, filename, sizeof filename); + if ((file_b=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) + TEST_ERROR; + + /* Create groups in first file */ + if((grp_1=H5Gcreate(file_a, "group1", 0))<0) TEST_ERROR; + if((grp_2=H5Gcreate(file_a, "group2", 0))<0) TEST_ERROR; + if((grp_move=H5Gcreate(grp_1, "group_move", 0))<0) TEST_ERROR; + + /* Create hard and soft links. */ + if(H5Lcreate_hard(grp_1, "group_move", H5L_SAME_LOC, "hard", H5P_DEFAULT)<0) + TEST_ERROR; + if(H5Lcreate_soft("/group1/group_move", grp_2, "soft", H5P_DEFAULT)<0) + TEST_ERROR; + + /* Move a group within the file. Both of source and destination use + * H5L_SAME_LOC. Should fail. */ + H5E_BEGIN_TRY { + if(H5Lmove(H5L_SAME_LOC, "group_move", H5L_SAME_LOC, "group_new_name", H5P_DEFAULT) + !=FAIL) TEST_ERROR; + } H5E_END_TRY; + + /* Move a group across files. Should fail. */ + H5E_BEGIN_TRY { + if(H5Lmove(grp_1, "group_move", file_b, "group_new_name", H5P_DEFAULT) + !=FAIL) TEST_ERROR; + } H5E_END_TRY; + + /* Move a group across groups in the same file while renaming it. */ + if(H5Lmove(grp_1, "group_move", grp_2, "group_new_name", H5P_DEFAULT)<0) + TEST_ERROR; + + /* Open the group just moved to the new location. */ + if((moved_grp = H5Gopen(grp_2, "group_new_name"))<0) + TEST_ERROR; + if( H5Gclose(moved_grp) < 0) + TEST_ERROR; + + /* Verify that the group is no longer in the original location */ + H5E_BEGIN_TRY { + if((moved_grp = H5Gopen(grp_1, "group_move"))>=0) + TEST_ERROR; + } H5E_END_TRY; + + /* Use H5Lmove to rename a group without moving it. */ + if(H5Lmove(grp_2, "group_new_name", H5L_SAME_LOC, "group_newer_name", H5P_DEFAULT)<0) + TEST_ERROR; + + /* Open the group. */ + if((moved_grp = H5Gopen(grp_2, "group_newer_name"))<0) + TEST_ERROR; + if( H5Gclose(moved_grp) < 0) + TEST_ERROR; + + /* Use H5Lmove to move a group without renaming it. */ + if(H5Lmove(grp_2, "group_newer_name", grp_1, "group_newer_name", H5P_DEFAULT)<0) + TEST_ERROR; + + /* Open the group . */ + if((moved_grp = H5Gopen(grp_1, "group_newer_name"))<0) + TEST_ERROR; + if( H5Gclose(moved_grp) < 0) + TEST_ERROR; + + /* Move the group while giving long paths. */ + if(H5Lmove(file_a, "/group1/group_newer_name", grp_2, "/group2/group_newest_name", H5P_DEFAULT)<0) + TEST_ERROR; + + /* Open the group just moved to the new location. */ + if((moved_grp = H5Gopen(grp_2, "group_newest_name"))<0) + TEST_ERROR; + + if( H5Gclose(moved_grp) < 0) + TEST_ERROR; + + /* Verify that the group is in no previous locations */ + H5E_BEGIN_TRY { + if((moved_grp = H5Gopen(grp_1, "group_newer_name"))>=0) + TEST_ERROR; + if((moved_grp = H5Gopen(grp_2, "group_newer_name"))>=0) + TEST_ERROR; + if((moved_grp = H5Gopen(grp_2, "group_new_name"))>=0) + TEST_ERROR; + if((moved_grp = H5Gopen(grp_1, "group_copy"))>=0) + TEST_ERROR; + } H5E_END_TRY; + + H5Gclose(grp_1); + H5Gclose(grp_2); + H5Gclose(grp_move); + H5Fclose(file_a); + H5Fclose(file_b); + + PASSED(); + return 0; + + error: + H5_FAILED(); + H5E_BEGIN_TRY { + H5Gclose(grp_1); + H5Gclose(grp_2); + H5Gclose(grp_move); + H5Gclose(moved_grp); + H5Fclose(file_a); + H5Fclose(file_b); + } H5E_END_TRY; + return 1; +} + + +/*------------------------------------------------------------------------- + * Function: test_copy + * + * Purpose: Tests H5Lcopy() + * + * Return: Success: 0 + * + * Failure: number of errors + * + * Programmer: James Laird + * Friday, March 30, 2006 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static int +test_copy(hid_t fapl) +{ + hid_t file_a, file_b=(-1); + hid_t grp_1=(-1), grp_2=(-1), grp_move=(-1), moved_grp=(-1); + char filename[1024]; + + TESTING("H5Lcopy"); + + /* Create two new files */ + h5_fixname(FILENAME[8], fapl, filename, sizeof filename); + if ((file_a=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) + TEST_ERROR; + h5_fixname(FILENAME[9], fapl, filename, sizeof filename); + if ((file_b=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) + TEST_ERROR; + + /* Create groups in first file */ + if((grp_1=H5Gcreate(file_a, "group1", 0))<0) TEST_ERROR; + if((grp_2=H5Gcreate(file_a, "group2", 0))<0) TEST_ERROR; + if((grp_move=H5Gcreate(grp_1, "group_copy", 0))<0) TEST_ERROR; + + /* Create hard and soft links. */ + if(H5Lcreate_hard(grp_1, "group_copy", H5L_SAME_LOC, "hard", H5P_DEFAULT)<0) + TEST_ERROR; + if(H5Lcreate_soft("/group1/group_copy", grp_2, "soft", H5P_DEFAULT)<0) + TEST_ERROR; + + /* Copy a group within the file. Both of source and destination use + * H5L_SAME_LOC. Should fail. */ + H5E_BEGIN_TRY { + if(H5Lcopy(H5L_SAME_LOC, "group_copy", H5L_SAME_LOC, "group_new_name", H5P_DEFAULT) + !=FAIL) TEST_ERROR; + } H5E_END_TRY; + + /* Copy a group across files. Should fail. */ + H5E_BEGIN_TRY { + if(H5Lcopy(grp_1, "group_copy", file_b, "group_new_name", H5P_DEFAULT) + !=FAIL) TEST_ERROR; + } H5E_END_TRY; + + /* Move a group across groups in the same file while renaming it. */ + if(H5Lcopy(grp_1, "group_copy", grp_2, "group_new_name", H5P_DEFAULT)<0) + TEST_ERROR; + + /* Open the group just moved to the new location. */ + if((moved_grp = H5Gopen(grp_2, "group_new_name"))<0) + TEST_ERROR; + if( H5Gclose(moved_grp) < 0) + TEST_ERROR; + + /* Verify that the group is also in the original location */ + if((moved_grp = H5Gopen(grp_1, "group_copy"))<0) + TEST_ERROR; + if( H5Gclose(moved_grp) < 0) + TEST_ERROR; + + /* Use H5Lcopy to create a group in the same location with a different name. */ + if(H5Lcopy(grp_2, "group_new_name", H5L_SAME_LOC, "group_newer_name", H5P_DEFAULT)<0) + TEST_ERROR; + + /* Open the group. */ + if((moved_grp = H5Gopen(grp_2, "group_newer_name"))<0) + TEST_ERROR; + if( H5Gclose(moved_grp) < 0) + TEST_ERROR; + /* Verify that the group is also in the original location */ + if((moved_grp = H5Gopen(grp_2, "group_new_name"))<0) + TEST_ERROR; + if( H5Gclose(moved_grp) < 0) + TEST_ERROR; + + /* Use H5Lcopy to copy to a different location with the same name. */ + if(H5Lcopy(grp_2, "group_newer_name", grp_1, "group_newer_name", H5P_DEFAULT)<0) + TEST_ERROR; + + /* Open the group . */ + if((moved_grp = H5Gopen(grp_1, "group_newer_name"))<0) + TEST_ERROR; + if( H5Gclose(moved_grp) < 0) + TEST_ERROR; + /* Verify that the group is still in the previous location */ + if((moved_grp = H5Gopen(grp_2, "group_new_name"))<0) + TEST_ERROR; + if( H5Gclose(moved_grp) < 0) + TEST_ERROR; + + /* Copy the group while giving long paths. */ + if(H5Lcopy(file_a, "/group1/group_newer_name", grp_2, "/group2/group_newest_name", H5P_DEFAULT)<0) + TEST_ERROR; + + /* Open the group just moved to the new location. */ + if((moved_grp = H5Gopen(grp_2, "group_newest_name"))<0) + TEST_ERROR; + if( H5Gclose(moved_grp) < 0) + TEST_ERROR; + + /* Verify that the group is still in all previous original locations */ + if((moved_grp = H5Gopen(grp_1, "group_newer_name"))<0) + TEST_ERROR; + if( H5Gclose(moved_grp) < 0) + TEST_ERROR; + if((moved_grp = H5Gopen(grp_2, "group_newer_name"))<0) + TEST_ERROR; + if( H5Gclose(moved_grp) < 0) + TEST_ERROR; + if((moved_grp = H5Gopen(grp_2, "group_new_name"))<0) + TEST_ERROR; + if( H5Gclose(moved_grp) < 0) + TEST_ERROR; + if((moved_grp = H5Gopen(grp_1, "group_copy"))<0) + TEST_ERROR; + if( H5Gclose(moved_grp) < 0) + TEST_ERROR; + + H5Gclose(grp_1); + H5Gclose(grp_2); + H5Gclose(grp_move); + H5Fclose(file_a); + H5Fclose(file_b); + + PASSED(); + return 0; + + error: + H5_FAILED(); + H5E_BEGIN_TRY { + H5Gclose(grp_1); + H5Gclose(grp_2); + H5Gclose(grp_move); + H5Gclose(moved_grp); + H5Fclose(file_a); + H5Fclose(file_b); + } H5E_END_TRY; + return 1; +} + +#ifdef H5_GROUP_REVISION +/*------------------------------------------------------------------------- + * Function: test_move_preserves + * + * Purpose: Tests that moving and renaming links preserves their + * properties. + * + * Return: Success: 0 + * Failure: number of errors + * + * Programmer: James Laird + * Monday, January 30, 2006 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static int +test_move_preserves(hid_t fapl_id) +{ + hid_t file_id=-1; + hid_t group_id=-1; + hid_t lcpl_id=-1; + hid_t lcpl2_id=-1; + H5G_stat_t statbuf; + H5L_linkinfo_t linfo; + time_t old_create_time; + time_t old_modification_time; + time_t curr_time; + char filename[1024]; + + TESTING("moving and copying links preserves their properties"); + + /* Create file */ + h5_fixname(FILENAME[11], fapl_id, filename, sizeof filename); + + if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id))<0) TEST_ERROR; + + /* Create a link creation property list with the UTF-8 character encoding */ + if((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) <0) TEST_ERROR; + if(H5Pset_char_encoding(lcpl_id, H5T_CSET_UTF8) < 0) TEST_ERROR; + /* Create a group with that lcpl */ + if((group_id = H5Gcreate_expand(file_id, H5P_DEFAULT, H5P_DEFAULT)) <0) TEST_ERROR; + if(H5Lcreate(file_id, "group", group_id, lcpl_id) < 0) TEST_ERROR; + if(H5Gclose(group_id) < 0) TEST_ERROR; + + /* Get the group's link's creation time */ + if(H5Lget_linkinfo(file_id, "group", &linfo) < 0) TEST_ERROR; + if(H5Gget_objinfo(file_id, "group", TRUE, &statbuf) <0) TEST_ERROR; + old_create_time = linfo.ctime; + old_modification_time = statbuf.mtime; + + /* If this test happens too quickly, the creation times will all be the same. Make sure the time changes. */ + curr_time=time(NULL); + while(time(NULL) <= curr_time ); + + /* Close the file and reopen it */ + if(H5Fclose(file_id)<0) TEST_ERROR; + if((file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) <0) TEST_ERROR; + + /* Get the group's link's creation time. The times should be unchanged */ + if(H5Lget_linkinfo(file_id, "group", &linfo) < 0) TEST_ERROR; + if(H5Gget_objinfo(file_id, "group", TRUE, &statbuf) <0) TEST_ERROR; + if(old_modification_time != statbuf.mtime) TEST_ERROR; + if(old_create_time != linfo.ctime) TEST_ERROR; + + /* Create a new link to the group. It should have a different creation time but the same modification time */ + if(H5Lcreate_hard(file_id, "group", file_id, "group2", H5P_DEFAULT) < 0) TEST_ERROR; + if(H5Gget_objinfo(file_id, "group2", TRUE, &statbuf) <0) TEST_ERROR; + if(old_modification_time != statbuf.mtime) TEST_ERROR; + if(H5Lget_linkinfo(file_id, "group2", &linfo) <0) TEST_ERROR; + if(old_create_time == linfo.ctime) TEST_ERROR; + + /* Copy the first link to a UTF-8 name. Its creation time and modification time should not change. */ + if(H5Lcopy(file_id, "group", file_id, "group_copied", lcpl_id) <0) TEST_ERROR; + if(H5Gget_objinfo(file_id, "group_copied", TRUE, &statbuf) <0) TEST_ERROR; + if(old_modification_time != statbuf.mtime) TEST_ERROR; + if(H5Lget_linkinfo(file_id, "group_copied", &linfo) <0) TEST_ERROR; + if(old_create_time != linfo.ctime) TEST_ERROR; + + /* Check that its character encoding is UTF-8 */ + if(linfo.cset != H5T_CSET_UTF8) TEST_ERROR; + + /* Move the link with the default property list. */ + if(H5Lmove(file_id, "group_copied", file_id, "group_copied2", H5P_DEFAULT) <0) TEST_ERROR; + if(H5Gget_objinfo(file_id, "group_copied2", TRUE, &statbuf) <0) TEST_ERROR; + if(old_modification_time != statbuf.mtime) TEST_ERROR; + if(H5Lget_linkinfo(file_id, "group_copied2", &linfo) <0) TEST_ERROR; + if(old_create_time != linfo.ctime) TEST_ERROR; + + /* Check that its character encoding is not UTF-8 */ + if(linfo.cset == H5T_CSET_UTF8) TEST_ERROR; + + /* Check that the original link is unchanged */ + if(H5Gget_objinfo(file_id, "group", TRUE, &statbuf) <0) TEST_ERROR; + if(old_modification_time != statbuf.mtime) TEST_ERROR; + if(H5Lget_linkinfo(file_id, "group", &linfo) <0) TEST_ERROR; + if(old_create_time != linfo.ctime) TEST_ERROR; + if(linfo.cset != H5T_CSET_UTF8) TEST_ERROR; + + /* Move the first link to a UTF-8 name. Its creation time and modification time should not change. */ + if(H5Lmove(file_id, "group", file_id, "group_moved", lcpl_id) <0) TEST_ERROR; + if(H5Gget_objinfo(file_id, "group_moved", TRUE, &statbuf) <0) TEST_ERROR; + if(old_modification_time != statbuf.mtime) TEST_ERROR; + if(H5Lget_linkinfo(file_id, "group_moved", &linfo) <0) TEST_ERROR; + if(old_create_time != linfo.ctime) TEST_ERROR; + + /* Check that its character encoding is UTF-8 */ + if(linfo.cset != H5T_CSET_UTF8) TEST_ERROR; + + /* Move the link again using the default property list. */ + if(H5Lmove(file_id, "group_moved", file_id, "group_moved_again", H5P_DEFAULT) <0) TEST_ERROR; + if(H5Gget_objinfo(file_id, "group_moved_again", TRUE, &statbuf) <0) TEST_ERROR; + if(old_modification_time != statbuf.mtime) TEST_ERROR; + if(H5Lget_linkinfo(file_id, "group_moved_again", &linfo) <0) TEST_ERROR; + if(old_create_time != linfo.ctime) TEST_ERROR; + + /* Check that its character encoding is not UTF-8 */ + if(linfo.cset == H5T_CSET_UTF8) TEST_ERROR; + + /* Close open IDs */ + if(H5Pclose(lcpl_id) < 0) TEST_ERROR; + if(H5Fclose(file_id)<0) TEST_ERROR; + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + H5Pclose(lcpl_id); + H5Pclose(lcpl2_id); + H5Gclose(group_id); + H5Fclose(file_id); + } H5E_END_TRY; + return 1; +} /* end test_move_preserves() */ +#endif /* H5_GROUP_REVISION */ + + +/*------------------------------------------------------------------------- + * Function: test_compat + * + * Purpose: Tests deprecated functions for backward compatibility. + * + * Return: Success: 0 + * Failure: number of errors + * + * Programmer: James Laird + * Wednesday, April 26 2006 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static int +test_compat(hid_t fapl) +{ + hid_t file_id=-1; + hid_t group1_id=-1; + hid_t group2_id=-1; + H5G_stat_t sb_hard1, sb_hard2, sb_soft1; + char filename[1024]; + char linkval[1024]; + + TESTING("backwards compatibility"); + + /* Create file */ + h5_fixname(FILENAME[15], fapl, filename, sizeof filename); + + if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) TEST_ERROR; + + /* Create two groups in the file */ + if((group1_id = H5Gcreate(file_id, "group1", 1)) < 0) TEST_ERROR; + if((group2_id = H5Gcreate(file_id, "group2", 1)) < 0) TEST_ERROR; + + /* Create links using H5Glink and H5Glink2 */ + if(H5Glink(file_id, H5G_LINK_HARD, "group2", "group1/link_to_group2") < 0) TEST_ERROR; + if(H5Glink2(file_id, "group1", H5G_LINK_HARD, group2_id, "link_to_group1") < 0) TEST_ERROR; + if(H5Glink2(file_id, "link_to_group1", H5G_LINK_SOFT, H5G_SAME_LOC, "group2/soft_link_to_group1") < 0) TEST_ERROR; + + /* Test that H5Glink created hard links properly */ + if(H5Gget_objinfo(file_id, "/group2", TRUE, &sb_hard1)<0) TEST_ERROR; + if(H5Gget_objinfo(file_id, "/group1/link_to_group2", TRUE, &sb_hard2)<0) TEST_ERROR; + + if (HDmemcmp(&sb_hard1.objno, sb_hard2.objno, sizeof(sb_hard1.objno))) { + H5_FAILED(); + puts(" Hard link test failed. Link seems not to point to the "); + puts(" expected file location."); + TEST_ERROR; + } + + /* Test for the other hard link created */ + if(H5Gget_objinfo(file_id, "/group1", TRUE, &sb_hard1)<0) TEST_ERROR; + if(H5Gget_objinfo(file_id, "/group2/link_to_group1", TRUE, &sb_hard2)<0) TEST_ERROR; + + if (HDmemcmp(&sb_hard1.objno, sb_hard2.objno, sizeof(sb_hard1.objno))) { + H5_FAILED(); + puts(" Hard link test failed. Link seems not to point to the "); + puts(" expected file location."); + TEST_ERROR; + } + + /* Test the soft link */ + if(H5Gget_objinfo(file_id, "/group2/soft_link_to_group1", FALSE, &sb_soft1)<0) TEST_ERROR; + if(sb_soft1.type != H5G_LINK) TEST_ERROR; + if(sb_soft1.linklen != HDstrlen("link_to_group1") + 1) TEST_ERROR; + + if(H5Gget_linkval(group2_id, "soft_link_to_group1", sb_soft1.linklen, linkval) < 0) TEST_ERROR; + if(HDstrcmp("link_to_group1", linkval)) TEST_ERROR; + + + /* Test H5Gmove and H5Gmove2 */ + if(H5Gmove(file_id, "group1", "moved_group1") < 0) TEST_ERROR; + if(H5Gmove2(file_id, "group2", group1_id, "moved_group2") < 0) TEST_ERROR; + + /* Ensure that both groups can be opened */ + if(H5Gclose(group2_id)<0) TEST_ERROR; + if(H5Gclose(group1_id)<0) TEST_ERROR; + + if((group1_id = H5Gopen(file_id, "moved_group1")) < 0) TEST_ERROR; + if((group2_id = H5Gopen(file_id, "moved_group1/moved_group2")) < 0) TEST_ERROR; + + /* Close open IDs */ + if(H5Gclose(group2_id)<0) TEST_ERROR; + if(H5Gclose(group1_id)<0) TEST_ERROR; + + /* Test H5Gunlink */ + if(H5Gunlink(file_id, "moved_group1/moved_group2") < 0) TEST_ERROR; + + H5E_BEGIN_TRY { + if(H5Gopen(file_id, "moved_group1/moved_group2") >=0) TEST_ERROR; + } H5E_END_TRY; + + if(H5Fclose(file_id)<0) TEST_ERROR; + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + H5Gclose(group2_id); + H5Gclose(group1_id); + H5Fclose(file_id); + } H5E_END_TRY; + return 1; +} /* end test_compat() */ + + /*------------------------------------------------------------------------- * Function: main * @@ -673,6 +1471,18 @@ main(void) nerrors += long_links(fapl) < 0 ? 1 : 0; nerrors += toomany(fapl) < 0 ? 1 : 0; + /* Test new H5L link creation routine */ +#ifdef H5_GROUP_REVISION + nerrors += test_h5l_create(fapl); + nerrors += test_lcpl(fapl); +#endif + nerrors += test_move(fapl); + nerrors += test_copy(fapl); +#ifdef H5_GROUP_REVISION + nerrors += test_move_preserves(fapl); +#endif + nerrors += test_compat(fapl); + /* Results */ if (nerrors) { printf("***** %d LINK TEST%s FAILED! *****\n", diff --git a/test/mount.c b/test/mount.c index 0f748a8..a456c7c 100644 --- a/test/mount.c +++ b/test/mount.c @@ -453,7 +453,7 @@ test_mntlnk(hid_t fapl) /*------------------------------------------------------------------------- * Function: test_move * - * Purpose: An object cannot be moved or renamed with H5Gmove() in such a + * Purpose: An object cannot be moved or renamed with in such a * way that the new location would be in a different file than * the original location. * @@ -486,9 +486,9 @@ test_move(hid_t fapl) if (H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT)<0) goto error; /* First rename an object in the mounted file, then try it across files */ - if (H5Gmove(file1, "/mnt1/rename_a/x", "/mnt1/rename_b/y")<0) goto error; + if (H5Lmove(file1, "/mnt1/rename_a/x", H5L_SAME_LOC, "/mnt1/rename_b/y", H5P_DEFAULT)<0) goto error; H5E_BEGIN_TRY { - status = H5Gmove(file1, "/mnt1/rename_b/y", "/y"); + status = H5Lmove(file1, "/mnt1/rename_b/y", H5L_SAME_LOC, "/y", H5P_DEFAULT); } H5E_END_TRY; if (status>=0) { H5_FAILED(); @@ -796,7 +796,7 @@ test_mvmpt(hid_t fapl) if (H5Fmount(file1, "/mnt_move_a", file2, H5P_DEFAULT)<0) TEST_ERROR /* Rename the mount point */ - if (H5Gmove(file1, "/mnt_move_a", "/mnt_move_b")<0) TEST_ERROR + if (H5Lmove(file1, "/mnt_move_a", H5L_SAME_LOC, "/mnt_move_b", H5P_DEFAULT)<0) TEST_ERROR /* Access something under the new name */ if (H5Gget_objinfo(file1, "/mnt_move_b/file2", TRUE, NULL)<0) TEST_ERROR @@ -864,7 +864,7 @@ test_interlink(hid_t fapl) /* Try an interfile hard link by renaming something */ H5E_BEGIN_TRY { - status = H5Gmove(file1, "/mnt1/file2", "/file2"); + status = H5Lmove(file1, "/mnt1/file2", H5L_SAME_LOC, "/file2", H5P_DEFAULT); } H5E_END_TRY; if (status>=0) { H5_FAILED(); @@ -1450,7 +1450,7 @@ test_mount_after_unmount(hid_t fapl) /* Rename object in file #3 that is "disconnected" from name hiearchy */ /* (It is "disconnected" because it's parent file has been unmounted) */ - if(H5Gmove2(gidAMX,"M/Y",gidAMX,"M/Z") < 0) + if(H5Lmove(gidAMX,"M/Y",gidAMX,"M/Z", H5P_DEFAULT) < 0) TEST_ERROR /* Close group in file #3 */ diff --git a/test/objcopy.c b/test/objcopy.c index daf382e..9b2c5bf 100755 --- a/test/objcopy.c +++ b/test/objcopy.c @@ -978,7 +978,7 @@ test_copy_named_datatype(hid_t fapl) if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR; /* copy the datatype from SRC to DST */ - if ( H5Gcopy(fid_src, NAME_DATATYPE_SIMPLE, fid_dst, NAME_DATATYPE_SIMPLE, H5P_DEFAULT) < 0) TEST_ERROR; + if ( H5Gcopy(fid_src, NAME_DATATYPE_SIMPLE, fid_dst, NAME_DATATYPE_SIMPLE, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; /* open the datatype for copy */ if ( (tid = H5Topen(fid_src, NAME_DATATYPE_SIMPLE)) < 0) TEST_ERROR; @@ -1071,7 +1071,7 @@ test_copy_named_datatype_vl(hid_t fapl) if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR; /* copy the datatype from SRC to DST */ - if ( H5Gcopy(fid_src, NAME_DATATYPE_VL, fid_dst, NAME_DATATYPE_VL, H5P_DEFAULT) < 0) TEST_ERROR; + if ( H5Gcopy(fid_src, NAME_DATATYPE_VL, fid_dst, NAME_DATATYPE_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; /* open the datatype for copy */ if ( (tid = H5Topen(fid_src, NAME_DATATYPE_VL)) < 0) TEST_ERROR; @@ -1170,7 +1170,7 @@ test_copy_named_datatype_vl_vl(hid_t fapl) if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR; /* copy the datatype from SRC to DST */ - if ( H5Gcopy(fid_src, NAME_DATATYPE_VL_VL, fid_dst, NAME_DATATYPE_VL_VL, H5P_DEFAULT) < 0) TEST_ERROR; + if ( H5Gcopy(fid_src, NAME_DATATYPE_VL_VL, fid_dst, NAME_DATATYPE_VL_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; /* open the datatype for copy */ if ( (tid = H5Topen(fid_src, NAME_DATATYPE_VL_VL)) < 0) TEST_ERROR; @@ -1287,7 +1287,7 @@ test_copy_dataset_simple(hid_t fapl) if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR; /* copy the dataset from SRC to DST */ - if ( H5Gcopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT) < 0) TEST_ERROR; + if ( H5Gcopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; /* open the dataset for copy */ if ( (did = H5Dopen(fid_src, NAME_DATASET_SIMPLE)) < 0) TEST_ERROR; @@ -1394,7 +1394,7 @@ test_copy_dataset_simple_empty(hid_t fapl) if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR; /* copy the dataset from SRC to DST */ - if ( H5Gcopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT) < 0) TEST_ERROR; + if ( H5Gcopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; /* open the dataset for copy */ if ( (did = H5Dopen(fid_src, NAME_DATASET_SIMPLE)) < 0) TEST_ERROR; @@ -1524,7 +1524,7 @@ test_copy_dataset_compound(hid_t fapl) if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR; /* copy the dataset from SRC to DST */ - if ( H5Gcopy(fid_src, NAME_DATASET_COMPOUND, fid_dst, NAME_DATASET_COMPOUND, H5P_DEFAULT) < 0) TEST_ERROR; + if ( H5Gcopy(fid_src, NAME_DATASET_COMPOUND, fid_dst, NAME_DATASET_COMPOUND, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; /* open the dataset for copy */ if ( (did = H5Dopen(fid_src, NAME_DATASET_COMPOUND)) < 0) TEST_ERROR; @@ -1652,7 +1652,7 @@ test_copy_dataset_chunked(hid_t fapl) if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR; /* copy the dataset from SRC to DST */ - if ( H5Gcopy(fid_src, NAME_DATASET_CHUNKED, fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT) < 0) TEST_ERROR; + if ( H5Gcopy(fid_src, NAME_DATASET_CHUNKED, fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; /* open the dataset for copy */ if ( (did = H5Dopen(fid_src, NAME_DATASET_CHUNKED)) < 0) TEST_ERROR; @@ -1769,7 +1769,7 @@ test_copy_dataset_chunked_empty(hid_t fapl) if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR; /* copy the dataset from SRC to DST */ - if ( H5Gcopy(fid_src, NAME_DATASET_CHUNKED, fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT) < 0) TEST_ERROR; + if ( H5Gcopy(fid_src, NAME_DATASET_CHUNKED, fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; /* open the dataset for copy */ if ( (did = H5Dopen(fid_src, NAME_DATASET_CHUNKED)) < 0) TEST_ERROR; @@ -1907,7 +1907,7 @@ test_copy_dataset_chunked_sparse(hid_t fapl) if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR; /* copy the dataset from SRC to DST */ - if ( H5Gcopy(fid_src, NAME_DATASET_CHUNKED, fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT) < 0) TEST_ERROR; + if ( H5Gcopy(fid_src, NAME_DATASET_CHUNKED, fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; /* open the dataset for copy */ if ( (did = H5Dopen(fid_src, NAME_DATASET_CHUNKED)) < 0) TEST_ERROR; @@ -2040,7 +2040,7 @@ test_copy_dataset_compressed(hid_t fapl) if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR; /* copy the dataset from SRC to DST */ - if ( H5Gcopy(fid_src, NAME_DATASET_CHUNKED, fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT) < 0) TEST_ERROR; + if ( H5Gcopy(fid_src, NAME_DATASET_CHUNKED, fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; /* open the dataset for copy */ if ( (did = H5Dopen(fid_src, NAME_DATASET_CHUNKED)) < 0) TEST_ERROR; @@ -2168,7 +2168,7 @@ test_copy_dataset_compact(hid_t fapl) if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR; /* copy the dataset from SRC to DST */ - if ( H5Gcopy(fid_src, NAME_DATASET_COMPACT, fid_dst, NAME_DATASET_COMPACT, H5P_DEFAULT) < 0) TEST_ERROR; + if ( H5Gcopy(fid_src, NAME_DATASET_COMPACT, fid_dst, NAME_DATASET_COMPACT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; /* open the dataset for copy */ if ( (did = H5Dopen(fid_src, NAME_DATASET_COMPACT)) < 0) TEST_ERROR; @@ -2302,7 +2302,7 @@ test_copy_dataset_external(hid_t fapl) #endif /* 0 */ /* copy the dataset from SRC to DST */ - if ( H5Gcopy(fid_src, NAME_DATASET_EXTERNAL, fid_dst, NAME_DATASET_EXTERNAL, H5P_DEFAULT) < 0) TEST_ERROR; + if ( H5Gcopy(fid_src, NAME_DATASET_EXTERNAL, fid_dst, NAME_DATASET_EXTERNAL, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; /* open the dataset for copy */ if ( (did = H5Dopen(fid_src, NAME_DATASET_EXTERNAL)) < 0) TEST_ERROR; @@ -2423,7 +2423,7 @@ test_copy_dataset_named_dtype(hid_t fapl) if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR; /* copy the dataset from SRC to DST */ - if ( H5Gcopy(fid_src, NAME_DATASET_NAMED_DTYPE, fid_dst, NAME_DATASET_NAMED_DTYPE, H5P_DEFAULT) < 0) TEST_ERROR; + if ( H5Gcopy(fid_src, NAME_DATASET_NAMED_DTYPE, fid_dst, NAME_DATASET_NAMED_DTYPE, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; /* open the dataset for copy */ if ( (did = H5Dopen(fid_src, NAME_DATASET_NAMED_DTYPE)) < 0) TEST_ERROR; @@ -2560,7 +2560,7 @@ test_copy_dataset_named_dtype_hier(hid_t fapl) if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR; /* copy the dataset from SRC to DST */ - if ( H5Gcopy(fid_src, NAME_GROUP_TOP, fid_dst, NAME_GROUP_TOP, H5P_DEFAULT) < 0) TEST_ERROR; + if ( H5Gcopy(fid_src, NAME_GROUP_TOP, fid_dst, NAME_GROUP_TOP, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; /* open the group for copy */ if ( (gid = H5Gopen(fid_src, NAME_GROUP_TOP)) < 0) TEST_ERROR; @@ -2699,7 +2699,7 @@ test_copy_dataset_named_dtype_hier_outside(hid_t fapl) if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR; /* copy the dataset from SRC to DST */ - if ( H5Gcopy(fid_src, NAME_GROUP_TOP, fid_dst, NAME_GROUP_TOP, H5P_DEFAULT) < 0) TEST_ERROR; + if ( H5Gcopy(fid_src, NAME_GROUP_TOP, fid_dst, NAME_GROUP_TOP, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; /* open the group for copy */ if ( (gid = H5Gopen(fid_src, NAME_GROUP_TOP)) < 0) TEST_ERROR; @@ -2833,7 +2833,7 @@ test_copy_dataset_multi_ohdr_chunks(hid_t fapl) if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR; /* copy the dataset from SRC to DST */ - if ( H5Gcopy(fid_src, NAME_GROUP_TOP, fid_dst, NAME_GROUP_TOP, H5P_DEFAULT) < 0) TEST_ERROR; + if ( H5Gcopy(fid_src, NAME_GROUP_TOP, fid_dst, NAME_GROUP_TOP, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; /* open the group for copy */ if ( (gid = H5Gopen(fid_src, NAME_GROUP_TOP)) < 0) TEST_ERROR; @@ -2974,7 +2974,7 @@ test_copy_dataset_attr_named_dtype(hid_t fapl) if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR; /* copy the dataset from SRC to DST */ - if ( H5Gcopy(fid_src, NAME_GROUP_TOP, fid_dst, NAME_GROUP_TOP, H5P_DEFAULT) < 0) TEST_ERROR; + if ( H5Gcopy(fid_src, NAME_GROUP_TOP, fid_dst, NAME_GROUP_TOP, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; /* open the group for copy */ if ( (gid = H5Gopen(fid_src, NAME_GROUP_TOP)) < 0) TEST_ERROR; @@ -3094,7 +3094,7 @@ test_copy_dataset_contig_vl(hid_t fapl) if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR; /* copy the dataset from SRC to DST */ - if ( H5Gcopy(fid_src, NAME_DATASET_VL, fid_dst, NAME_DATASET_VL, H5P_DEFAULT) < 0) TEST_ERROR; + if ( H5Gcopy(fid_src, NAME_DATASET_VL, fid_dst, NAME_DATASET_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; /* open the dataset for copy */ if ( (did = H5Dopen(fid_src, NAME_DATASET_VL)) < 0) TEST_ERROR; @@ -3232,7 +3232,7 @@ test_copy_dataset_chunked_vl(hid_t fapl) if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR; /* copy the dataset from SRC to DST */ - if ( H5Gcopy(fid_src, NAME_DATASET_VL, fid_dst, NAME_DATASET_VL, H5P_DEFAULT) < 0) TEST_ERROR; + if ( H5Gcopy(fid_src, NAME_DATASET_VL, fid_dst, NAME_DATASET_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; /* open the dataset for copy */ if ( (did = H5Dopen(fid_src, NAME_DATASET_VL)) < 0) TEST_ERROR; @@ -3369,7 +3369,7 @@ test_copy_dataset_compact_vl(hid_t fapl) if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR; /* copy the dataset from SRC to DST */ - if ( H5Gcopy(fid_src, NAME_DATASET_VL, fid_dst, NAME_DATASET_VL, H5P_DEFAULT) < 0) TEST_ERROR; + if ( H5Gcopy(fid_src, NAME_DATASET_VL, fid_dst, NAME_DATASET_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; /* open the dataset for copy */ if ( (did = H5Dopen(fid_src, NAME_DATASET_VL)) < 0) TEST_ERROR; @@ -3489,7 +3489,7 @@ test_copy_attribute_vl(hid_t fapl) if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR; /* copy the dataset from SRC to DST */ - if ( H5Gcopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT) < 0) TEST_ERROR; + if ( H5Gcopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; /* open the dataset for copy */ if ( (did = H5Dopen(fid_src, NAME_DATASET_SIMPLE)) < 0) TEST_ERROR; @@ -3632,7 +3632,7 @@ test_copy_dataset_compressed_vl(hid_t fapl) if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR; /* copy the dataset from SRC to DST */ - if ( H5Gcopy(fid_src, NAME_DATASET_CHUNKED, fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT) < 0) TEST_ERROR; + if ( H5Gcopy(fid_src, NAME_DATASET_CHUNKED, fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; /* open the dataset for copy */ if ( (did = H5Dopen(fid_src, NAME_DATASET_CHUNKED)) < 0) TEST_ERROR; @@ -3743,7 +3743,7 @@ test_copy_group_empty(hid_t fapl) if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR; /* copy the group from SRC to DST */ - if ( H5Gcopy(fid_src, NAME_GROUP_EMPTY, fid_dst, NAME_GROUP_EMPTY, H5P_DEFAULT) < 0) TEST_ERROR; + if ( H5Gcopy(fid_src, NAME_GROUP_EMPTY, fid_dst, NAME_GROUP_EMPTY, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; /* open the group for copy */ if ( (gid = H5Gopen(fid_src, NAME_GROUP_EMPTY)) < 0) TEST_ERROR; @@ -3874,7 +3874,7 @@ test_copy_group(hid_t fapl) if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR; /* copy the group from SRC to DST */ - if ( H5Gcopy(fid_src, NAME_GROUP_TOP, fid_dst, NAME_GROUP_TOP, H5P_DEFAULT) < 0) TEST_ERROR; + if ( H5Gcopy(fid_src, NAME_GROUP_TOP, fid_dst, NAME_GROUP_TOP, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; /* open the group for copy */ if ( (gid = H5Gopen(fid_src, NAME_GROUP_TOP)) < 0) TEST_ERROR; @@ -4016,7 +4016,7 @@ test_copy_group_deep(hid_t fapl) if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR; /* copy the group from SRC to DST */ - if ( H5Gcopy(fid_src, NAME_GROUP_TOP, fid_dst, NAME_GROUP_TOP, H5P_DEFAULT) < 0) TEST_ERROR; + if ( H5Gcopy(fid_src, NAME_GROUP_TOP, fid_dst, NAME_GROUP_TOP, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; /* open the group for copy */ if ( (gid = H5Gopen(fid_src, NAME_GROUP_TOP)) < 0) TEST_ERROR; @@ -4127,7 +4127,7 @@ test_copy_group_loop(hid_t fapl) if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR; /* copy the group from SRC to DST */ - if ( H5Gcopy(fid_src, NAME_GROUP_TOP, fid_dst, NAME_GROUP_TOP, H5P_DEFAULT) < 0) TEST_ERROR; + if ( H5Gcopy(fid_src, NAME_GROUP_TOP, fid_dst, NAME_GROUP_TOP, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; /* open the group for copy */ if ( (gid = H5Gopen(fid_src, NAME_GROUP_TOP)) < 0) TEST_ERROR; @@ -4256,7 +4256,7 @@ test_copy_group_wide_loop(hid_t fapl) if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR; /* copy the group from SRC to DST */ - if ( H5Gcopy(fid_src, NAME_GROUP_TOP, fid_dst, NAME_GROUP_TOP, H5P_DEFAULT) < 0) TEST_ERROR; + if ( H5Gcopy(fid_src, NAME_GROUP_TOP, fid_dst, NAME_GROUP_TOP, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; /* open the group for copy */ if ( (gid = H5Gopen(fid_src, NAME_GROUP_TOP)) < 0) TEST_ERROR; @@ -4389,7 +4389,7 @@ test_copy_group_links(hid_t fapl) if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR; /* copy the group from SRC to DST */ - if ( H5Gcopy(fid_src, NAME_GROUP_LINK, fid_dst, NAME_GROUP_LINK, H5P_DEFAULT) < 0) TEST_ERROR; + if ( H5Gcopy(fid_src, NAME_GROUP_LINK, fid_dst, NAME_GROUP_LINK, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; /* open the group for copy */ if ( (gid = H5Gopen(fid_src, NAME_GROUP_LINK)) < 0) TEST_ERROR; @@ -4515,7 +4515,7 @@ test_copy_soft_link(hid_t fapl) if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR; /* copy the dataset from SRC to DST */ - if ( H5Gcopy(fid_src, NAME_LINK_SOFT, fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT) < 0) TEST_ERROR; + if ( H5Gcopy(fid_src, NAME_LINK_SOFT, fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; /* open the dataset through the soft link for copy */ if ( (did = H5Dopen(fid_src, NAME_LINK_SOFT)) < 0) TEST_ERROR; @@ -4634,11 +4634,11 @@ test_copy_exist(hid_t fapl) if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR; /* copy the dataset from SRC to DST */ - if ( H5Gcopy(fid_src, NAME_DATASET_SIMPLE,fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT) < 0) TEST_ERROR; + if ( H5Gcopy(fid_src, NAME_DATASET_SIMPLE,fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; /* try to copy the dataset from SRC to DST again (should fail) */ H5E_BEGIN_TRY { - ret = H5Gcopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT); + ret = H5Gcopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT, H5P_DEFAULT); } H5E_END_TRY; if( ret >= 0) TEST_ERROR; @@ -4744,7 +4744,7 @@ test_copy_path(hid_t fapl) /* copy the dataset from SRC to DST (should fail - intermediate groups not there) */ H5E_BEGIN_TRY { - ret = H5Gcopy(fid_src, NAME_DATASET_SUB_SUB, fid_dst, NAME_DATASET_SUB_SUB, H5P_DEFAULT); + ret = H5Gcopy(fid_src, NAME_DATASET_SUB_SUB, fid_dst, NAME_DATASET_SUB_SUB, H5P_DEFAULT, H5P_DEFAULT); } H5E_END_TRY; if( ret >= 0) TEST_ERROR; @@ -4759,7 +4759,7 @@ test_copy_path(hid_t fapl) if ( H5Gclose(gid) < 0) TEST_ERROR; /* copy the dataset from SRC to DST, using full path */ - if ( H5Gcopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SUB_SUB, H5P_DEFAULT) < 0) TEST_ERROR; + if ( H5Gcopy(fid_src, NAME_DATASET_SIMPLE, fid_dst, NAME_DATASET_SUB_SUB, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; /* open the dataset for copy */ if ( (did = H5Dopen(fid_src, NAME_DATASET_SIMPLE)) < 0) TEST_ERROR; @@ -4837,7 +4837,7 @@ test_copy_same_file_named_datatype(hid_t fapl) /* copy the datatype from SRC to DST */ - if ( H5Gcopy(fid, NAME_DATATYPE_SIMPLE, fid, NAME_DATATYPE_SIMPLE2, H5P_DEFAULT) < 0) TEST_ERROR; + if ( H5Gcopy(fid, NAME_DATATYPE_SIMPLE, fid, NAME_DATATYPE_SIMPLE2, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; /* open the copied datatype */ if ( (tid2 = H5Topen(fid, NAME_DATATYPE_SIMPLE2)) < 0) TEST_ERROR; @@ -4987,7 +4987,7 @@ test_copy_dataset_compact_named_vl(hid_t fapl) if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR; /* copy the dataset from SRC to DST */ - if ( H5Gcopy(fid_src, NAME_DATASET_VL, fid_dst, NAME_DATASET_VL, H5P_DEFAULT) < 0) TEST_ERROR; + if ( H5Gcopy(fid_src, NAME_DATASET_VL, fid_dst, NAME_DATASET_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; /* open the dataset for copy */ if ( (did = H5Dopen(fid_src, NAME_DATASET_VL)) < 0) TEST_ERROR; @@ -5127,7 +5127,7 @@ test_copy_dataset_contig_named_vl(hid_t fapl) if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR; /* copy the dataset from SRC to DST */ - if ( H5Gcopy(fid_src, NAME_DATASET_VL, fid_dst, NAME_DATASET_VL, H5P_DEFAULT) < 0) TEST_ERROR; + if ( H5Gcopy(fid_src, NAME_DATASET_VL, fid_dst, NAME_DATASET_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; /* open the dataset for copy */ if ( (did = H5Dopen(fid_src, NAME_DATASET_VL)) < 0) TEST_ERROR; @@ -5275,7 +5275,7 @@ test_copy_dataset_chunked_named_vl(hid_t fapl) if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR; /* copy the dataset from SRC to DST */ - if ( H5Gcopy(fid_src, NAME_DATASET_VL, fid_dst, NAME_DATASET_VL, H5P_DEFAULT) < 0) TEST_ERROR; + if ( H5Gcopy(fid_src, NAME_DATASET_VL, fid_dst, NAME_DATASET_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; /* open the dataset for copy */ if ( (did = H5Dopen(fid_src, NAME_DATASET_VL)) < 0) TEST_ERROR; @@ -5425,7 +5425,7 @@ test_copy_dataset_compressed_named_vl(hid_t fapl) if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR; /* copy the dataset from SRC to DST */ - if ( H5Gcopy(fid_src, NAME_DATASET_VL, fid_dst, NAME_DATASET_VL, H5P_DEFAULT) < 0) TEST_ERROR; + if ( H5Gcopy(fid_src, NAME_DATASET_VL, fid_dst, NAME_DATASET_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; /* open the dataset for copy */ if ( (did = H5Dopen(fid_src, NAME_DATASET_VL)) < 0) TEST_ERROR; @@ -5581,7 +5581,7 @@ test_copy_dataset_compact_vl_vl(hid_t fapl) if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR; /* copy the dataset from SRC to DST */ - if ( H5Gcopy(fid_src, NAME_DATASET_VL_VL, fid_dst, NAME_DATASET_VL_VL, H5P_DEFAULT) < 0) TEST_ERROR; + if ( H5Gcopy(fid_src, NAME_DATASET_VL_VL, fid_dst, NAME_DATASET_VL_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; /* open the dataset for copy */ if ( (did = H5Dopen(fid_src, NAME_DATASET_VL_VL)) < 0) TEST_ERROR; @@ -5735,7 +5735,7 @@ test_copy_dataset_contig_vl_vl(hid_t fapl) if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR; /* copy the dataset from SRC to DST */ - if ( H5Gcopy(fid_src, NAME_DATASET_VL_VL, fid_dst, NAME_DATASET_VL_VL, H5P_DEFAULT) < 0) TEST_ERROR; + if ( H5Gcopy(fid_src, NAME_DATASET_VL_VL, fid_dst, NAME_DATASET_VL_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; /* open the dataset for copy */ if ( (did = H5Dopen(fid_src, NAME_DATASET_VL_VL)) < 0) TEST_ERROR; @@ -5889,7 +5889,7 @@ test_copy_dataset_chunked_vl_vl(hid_t fapl) if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR; /* copy the dataset from SRC to DST */ - if ( H5Gcopy(fid_src, NAME_DATASET_VL_VL, fid_dst, NAME_DATASET_VL_VL, H5P_DEFAULT) < 0) TEST_ERROR; + if ( H5Gcopy(fid_src, NAME_DATASET_VL_VL, fid_dst, NAME_DATASET_VL_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; /* open the dataset for copy */ if ( (did = H5Dopen(fid_src, NAME_DATASET_VL_VL)) < 0) TEST_ERROR; @@ -6046,7 +6046,7 @@ test_copy_dataset_compressed_vl_vl(hid_t fapl) if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR; /* copy the dataset from SRC to DST */ - if ( H5Gcopy(fid_src, NAME_DATASET_VL_VL, fid_dst, NAME_DATASET_VL_VL, H5P_DEFAULT) < 0) TEST_ERROR; + if ( H5Gcopy(fid_src, NAME_DATASET_VL_VL, fid_dst, NAME_DATASET_VL_VL, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; /* open the dataset for copy */ if ( (did = H5Dopen(fid_src, NAME_DATASET_VL_VL)) < 0) TEST_ERROR; @@ -6115,14 +6115,14 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_option(hid_t fapl, unsigned flag, const char* test_desciption) +test_copy_option(hid_t fapl, unsigned flag, hbool_t crt_intermediate_grp, const char* test_desciption) { hid_t fid_src = -1, fid_dst = -1; /* File IDs */ hid_t sid = -1; /* Dataspace ID */ hid_t did = -1; /* Dataset ID */ hid_t gid = -1, gid2 = -1; /* Group IDs */ hid_t gid_sub=-1, gid_sub_sub=-1; /* Sub-group ID */ - hid_t pid=-1; /* Property ID */ + hid_t pid=-1, lcpl_id=-1; /* Property IDs */ unsigned cpy_flags; /* Object copy flags */ int depth = -1; /* Copy depth */ hsize_t dim2d[2]; @@ -6237,8 +6237,16 @@ test_copy_option(hid_t fapl, unsigned flag, const char* test_desciption) if ( cpy_flags != flag) TEST_ERROR; /* copy the group from SRC to DST */ - if ((flag & H5G_COPY_CREATE_INTERMEDIATE_GROUP_FLAG) > 0) { - if ( H5Gcopy(fid_src, NAME_GROUP_TOP, fid_dst, "/new_g0/new_g00", pid) < 0) TEST_ERROR; + if (crt_intermediate_grp) { + /* Create link creation plist to pass in intermediate group creation */ + if ( (lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) TEST_ERROR; +#ifdef H5_GROUP_REVISION + if ( H5Pset_create_intermediate_group(lcpl_id, TRUE) < 0) TEST_ERROR; +#endif /* H5_GROUP_REVISION */ + + if ( H5Gcopy(fid_src, NAME_GROUP_TOP, fid_dst, "/new_g0/new_g00", pid, lcpl_id) < 0) TEST_ERROR; + + if ( H5Pclose(lcpl_id) < 0) TEST_ERROR; /* open the group for copy */ if ( (gid = H5Gopen(fid_src, NAME_GROUP_TOP)) < 0) TEST_ERROR; @@ -6247,7 +6255,7 @@ test_copy_option(hid_t fapl, unsigned flag, const char* test_desciption) if ( (gid2 = H5Gopen(fid_dst, "/new_g0/new_g00")) < 0) TEST_ERROR; } else if ((flag & H5G_COPY_EXPAND_SOFT_LINK_FLAG) > 0) { - if ( H5Gcopy(fid_src, NAME_GROUP_LINK, fid_dst, NAME_GROUP_LINK, pid) < 0) TEST_ERROR; + if ( H5Gcopy(fid_src, NAME_GROUP_LINK, fid_dst, NAME_GROUP_LINK, pid, H5P_DEFAULT) < 0) TEST_ERROR; /* Unlink dataset to copy from original location */ /* (So group comparison works properly) */ @@ -6260,7 +6268,7 @@ test_copy_option(hid_t fapl, unsigned flag, const char* test_desciption) if ( (gid2 = H5Gopen(fid_dst, NAME_GROUP_LINK)) < 0) TEST_ERROR; } else if(flag & H5G_COPY_WITHOUT_ATTR_FLAG) { - if ( H5Gcopy(fid_src, NAME_GROUP_TOP, fid_dst, NAME_GROUP_TOP, pid) < 0) TEST_ERROR; + if ( H5Gcopy(fid_src, NAME_GROUP_TOP, fid_dst, NAME_GROUP_TOP, pid, H5P_DEFAULT) < 0) TEST_ERROR; /* open the group for copy */ if ( (gid = H5Gopen(fid_src, NAME_GROUP_TOP)) < 0) TEST_ERROR; @@ -6268,7 +6276,7 @@ test_copy_option(hid_t fapl, unsigned flag, const char* test_desciption) /* open the destination group */ if ( (gid2 = H5Gopen(fid_dst, NAME_GROUP_TOP)) < 0) TEST_ERROR; } else if(flag & H5G_COPY_SHALLOW_HIERARCHY_FLAG) { - if ( H5Gcopy(fid_src, NAME_GROUP_TOP, fid_dst, NAME_GROUP_TOP, pid) < 0) TEST_ERROR; + if ( H5Gcopy(fid_src, NAME_GROUP_TOP, fid_dst, NAME_GROUP_TOP, pid, H5P_DEFAULT) < 0) TEST_ERROR; /* open the group for copy */ if ( (gid = H5Gopen(fid_src, NAME_GROUP_TOP)) < 0) TEST_ERROR; @@ -6298,7 +6306,7 @@ test_copy_option(hid_t fapl, unsigned flag, const char* test_desciption) /* close the DST file */ if ( H5Fclose(fid_dst) < 0) TEST_ERROR; - /* close property */ + /* close properties */ if ( H5Pclose(pid) < 0) TEST_ERROR; PASSED(); @@ -6306,6 +6314,7 @@ test_copy_option(hid_t fapl, unsigned flag, const char* test_desciption) error: H5E_BEGIN_TRY { + H5Pclose(lcpl_id); H5Pclose(pid); H5Sclose(sid); H5Dclose(did); @@ -6384,14 +6393,16 @@ main(void) nerrors += test_copy_exist(fapl); nerrors += test_copy_path(fapl); nerrors += test_copy_same_file_named_datatype(fapl); - nerrors += test_copy_option(fapl, H5G_COPY_WITHOUT_ATTR_FLAG, "H5Gcopy(): without attributes"); - nerrors += test_copy_option(fapl, H5G_COPY_CREATE_INTERMEDIATE_GROUP_FLAG, "H5Gcopy(): with missing groups"); - nerrors += test_copy_option(fapl, H5G_COPY_EXPAND_SOFT_LINK_FLAG, "H5Gcopy(): expand soft link"); - nerrors += test_copy_option(fapl, H5G_COPY_SHALLOW_HIERARCHY_FLAG, "H5Gcopy(): shallow group copy"); + nerrors += test_copy_option(fapl, H5G_COPY_WITHOUT_ATTR_FLAG, FALSE, "H5Gcopy(): without attributes"); +#ifdef H5_GROUP_REVISION + nerrors += test_copy_option(fapl, 0, TRUE, "H5Gcopy(): with missing groups"); +#endif /* H5_GROUP_REVISION */ + nerrors += test_copy_option(fapl, H5G_COPY_EXPAND_SOFT_LINK_FLAG, FALSE, "H5Gcopy(): expand soft link"); + nerrors += test_copy_option(fapl, H5G_COPY_SHALLOW_HIERARCHY_FLAG, FALSE, "H5Gcopy(): shallow group copy"); /* TODO: not implemented - nerrors += test_copy_option(fapl, H5G_COPY_EXPAND_EXT_LINK_FLAG, "H5Gcopy: expand external link"); - nerrors += test_copy_option(fapl, H5G_COPY_EXPAND_EXPAND_OBJ_REFERENCE_FLAG, "H5Gcopy: expand object reference"); + nerrors += test_copy_option(fapl, H5G_COPY_EXPAND_EXT_LINK_FLAG, FALSE, "H5Gcopy: expand external link"); + nerrors += test_copy_option(fapl, H5G_COPY_EXPAND_EXPAND_OBJ_REFERENCE_FLAG, FALSE, "H5Gcopy: expand object reference"); */ /* TODO: Add more tests for copying objects in same file */ diff --git a/test/stab.c b/test/stab.c index 945dca6..ec6343d 100644 --- a/test/stab.c +++ b/test/stab.c @@ -329,7 +329,8 @@ lifecycle(hid_t fapl) if(H5Pset_est_link_info(gcpl, LIFECYCLE_EST_NUM_ENTRIES, LIFECYCLE_EST_NAME_LEN) < 0) TEST_ERROR; /* Create group for testing lifecycle */ - if((gid = H5Gcreate_expand(fid, LIFECYCLE_TOP_GROUP, gcpl, H5P_DEFAULT)) < 0) TEST_ERROR + if((gid = H5Gcreate_expand(fid, gcpl, H5P_DEFAULT)) < 0) TEST_ERROR + if((H5Lcreate(fid, LIFECYCLE_TOP_GROUP, gid, H5P_DEFAULT)) < 0) TEST_ERROR /* Query group creation property settings */ if(H5Pget_local_heap_size_hint(gcpl, &lheap_size_hint) < 0) TEST_ERROR; @@ -787,7 +788,8 @@ no_compact(hid_t fapl) if(est_name_len != H5G_CRT_GINFO_EST_NAME_LEN) TEST_ERROR; /* Create group for testing lifecycle */ - if((gid = H5Gcreate_expand(fid, NO_COMPACT_TOP_GROUP, gcpl, H5P_DEFAULT)) < 0) TEST_ERROR + if((gid = H5Gcreate_expand(fid, gcpl, H5P_DEFAULT)) < 0) TEST_ERROR + if((H5Lcreate(fid, NO_COMPACT_TOP_GROUP, gid, H5P_DEFAULT)) < 0) TEST_ERROR /* Close GCPL */ if(H5Pclose(gcpl) < 0) TEST_ERROR; @@ -873,6 +875,7 @@ gcpl_on_root(hid_t fapl) hid_t gid2 = (-1); /* Datatype ID */ hid_t fcpl = (-1); /* File creation property list ID */ hid_t gcpl = (-1); /* Group creation property list ID */ + hid_t lcpl = (-1); /* Link creation property list ID */ unsigned max_compact; /* Maximum # of links to store in group compactly */ unsigned min_dense; /* Minimum # of links to store in group "densely" */ char filename[NAME_BUF_SIZE]; @@ -912,14 +915,15 @@ gcpl_on_root(hid_t fapl) if(H5Pclose(gcpl) < 0) TEST_ERROR; /* Create a group creation property list, with intermediate group creation set */ - if((gcpl = H5Pcreate(H5P_GROUP_CREATE)) < 0) TEST_ERROR; - if(H5Pset_create_intermediate_group(gcpl, TRUE) < 0) TEST_ERROR + if((lcpl = H5Pcreate(H5P_LINK_CREATE)) < 0) TEST_ERROR; + if(H5Pset_create_intermediate_group(lcpl, TRUE) < 0) TEST_ERROR /* Create a group and intermediate groups, to check if root group settings are inherited */ - if((gid2 = H5Gcreate_expand(gid, GCPL_ON_ROOT_BOTTOM_GROUP, gcpl, H5P_DEFAULT)) < 0) TEST_ERROR + if((gid2 = H5Gcreate_expand(gid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if((H5Lcreate(gid, GCPL_ON_ROOT_BOTTOM_GROUP, gid2, lcpl)) < 0) TEST_ERROR - /* Close GCPL */ - if(H5Pclose(gcpl) < 0) TEST_ERROR; + /* Close LCPL */ + if(H5Pclose(lcpl) < 0) TEST_ERROR; /* Query the group creation properties */ if((gcpl = H5Gget_create_plist(gid2)) < 0) TEST_ERROR; @@ -1022,6 +1026,7 @@ main(void) nerrors += read_old(fapl); nerrors += no_compact(fapl); nerrors += gcpl_on_root(fapl); + #endif /* H5_GROUP_REVISION */ if (nerrors) goto error; diff --git a/test/tmisc.c b/test/tmisc.c index ca405c7..7f39cf3 100644 --- a/test/tmisc.c +++ b/test/tmisc.c @@ -3830,8 +3830,8 @@ test_misc23(void) * test H5Gcreate_expand() **********************************************************************/ - /* Create group creation property list */ - create_id = H5Pcreate(H5P_GROUP_CREATE); + /* Create link creation property list */ + create_id = H5Pcreate(H5P_LINK_CREATE); CHECK(create_id, FAIL, "H5Pcreate"); /* Set flag for intermediate group creation */ @@ -3839,9 +3839,12 @@ test_misc23(void) CHECK(status, FAIL, "H5Pset_create_intermediate_group"); - tmp_id = H5Gcreate_expand(file_id, "/A/B01/grp", create_id, access_id); + tmp_id = H5Gcreate_expand(file_id, H5P_DEFAULT, access_id); CHECK(tmp_id, FAIL, "H5Gcreate_expand"); + status = H5Llink(file_id, "/A/B01/grp", tmp_id, create_id); + CHECK(status, FAIL, "H5Llink"); + /* Query that the name of the new group is correct */ status = H5Iget_name( tmp_id, objname, (size_t)MISC23_NAME_BUF_SIZE ); CHECK(status, FAIL, "H5Iget_name"); @@ -3862,30 +3865,42 @@ test_misc23(void) CHECK(status, FAIL, "H5Gclose"); - tmp_id = H5Gcreate_expand(file_id, "/A/B02/C02/grp", create_id, access_id); + tmp_id = H5Gcreate_expand(file_id, H5P_DEFAULT, access_id); CHECK(tmp_id, FAIL, "H5Gcreate_expand"); + status = H5Llink(file_id, "/A/B02/C02/grp", tmp_id, create_id); + CHECK(status, FAIL, "H5Llink"); + status = H5Gclose(tmp_id); CHECK(status, FAIL, "H5Gclose"); - tmp_id = H5Gcreate_expand(group_id, "B03/grp/", create_id, access_id); + tmp_id = H5Gcreate_expand(group_id, H5P_DEFAULT, access_id); CHECK(tmp_id, FAIL, "H5Gcreate_expand"); + status = H5Llink(group_id, "B03/grp/", tmp_id, create_id); + CHECK(status, FAIL, "H5Llink"); + status = H5Gclose(tmp_id); CHECK(status, FAIL, "H5Gclose"); - if ( (tmp_id = H5Gcreate_expand(group_id, "/A/B04/grp/", create_id, access_id)) < 0) + if ( (tmp_id = H5Gcreate_expand(group_id, H5P_DEFAULT, access_id)) < 0) CHECK(tmp_id, FAIL, "H5Gcreate_expand"); + status = H5Llink(group_id, "/A/B04/grp/", tmp_id, create_id); + CHECK(status, FAIL, "H5Llink"); + status = H5Gclose(tmp_id); CHECK(status, FAIL, "H5Gclose"); - if ( (tmp_id = H5Gcreate_expand(file_id, "/A/B05/C05/A", create_id, access_id)) < 0) + if ( (tmp_id = H5Gcreate_expand(file_id, H5P_DEFAULT, access_id)) < 0) CHECK(tmp_id, FAIL, "H5Gcreate_expand"); + status = H5Llink(file_id, "/A/B05/C05/A", tmp_id, create_id); + CHECK(status, FAIL, "H5Llink"); + status = H5Gclose(tmp_id); CHECK(status, FAIL, "H5Gclose"); @@ -3898,8 +3913,8 @@ test_misc23(void) * test new H5Dcreate **********************************************************************/ - /* Create dataset creation property list */ - create_id = H5Pcreate(H5P_DATASET_CREATE); + /* Create link creation property list */ + create_id = H5Pcreate(H5P_LINK_CREATE); CHECK(create_id, FAIL, "H5Pcreate"); /* Set flag for intermediate group creation */ @@ -3907,37 +3922,52 @@ test_misc23(void) CHECK(status, FAIL, "H5Pset_create_intermediate_group"); - tmp_id = H5Dcreate(file_id, "/A/B06/dset", type_id, space_id, create_id); + tmp_id = H5Dcreate_expand(file_id, type_id, space_id, H5P_DEFAULT); CHECK(tmp_id, FAIL, "H5Dcreate"); + status = H5Llink(file_id, "/A/B06/dset", tmp_id, create_id); + CHECK(status, FAIL, "H5Llink"); + status = H5Dclose(tmp_id); CHECK(status, FAIL, "H5Dclose"); - tmp_id = H5Dcreate(file_id, "/A/B07/B07/dset", type_id, space_id, create_id); + tmp_id = H5Dcreate_expand(file_id, type_id, space_id, H5P_DEFAULT); CHECK(tmp_id, FAIL, "H5Dcreate"); + status = H5Llink(file_id, "/A/B07/B07/dset", tmp_id, create_id); + CHECK(status, FAIL, "H5Llink"); + status = H5Dclose(tmp_id); CHECK(status, FAIL, "H5Dclose"); - tmp_id = H5Dcreate(group_id, "B08/dset", type_id, space_id, create_id); + tmp_id = H5Dcreate_expand(group_id, type_id, space_id, H5P_DEFAULT); CHECK(tmp_id, FAIL, "H5Dcreate"); + status = H5Llink(group_id, "B08/dset", tmp_id, create_id); + CHECK(status, FAIL, "H5Llink"); + status = H5Dclose(tmp_id); CHECK(status, FAIL, "H5Dclose"); - tmp_id = H5Dcreate(group_id, "/A/B09/dset", type_id, space_id, create_id); + tmp_id = H5Dcreate_expand(group_id, type_id, space_id, H5P_DEFAULT); CHECK(tmp_id, FAIL, "H5Dcreate"); + status = H5Llink(group_id, "/A/B09/dset", tmp_id, create_id); + CHECK(status, FAIL, "H5Llink"); + status = H5Dclose(tmp_id); CHECK(status, FAIL, "H5Dclose"); - tmp_id = H5Dcreate(file_id, "/A/B10/C10/A/dset", type_id, space_id, create_id); + tmp_id = H5Dcreate_expand(file_id, type_id, space_id, H5P_DEFAULT); CHECK(tmp_id, FAIL, "H5Dcreate"); + status = H5Llink(file_id, "/A/B10/C10/A/dset", tmp_id, create_id); + CHECK(status, FAIL, "H5Llink"); + status = H5Dclose(tmp_id); CHECK(status, FAIL, "H5Dclose"); @@ -3948,7 +3978,6 @@ test_misc23(void) status = H5Sclose(space_id); CHECK(status, FAIL, "H5Sclose"); - status = H5Pclose(create_id); CHECK(status, FAIL, "H5Pclose"); @@ -3957,21 +3986,23 @@ test_misc23(void) * test new H5Tcommit **********************************************************************/ - /* Create datatype creation property list */ - create_id = H5Pcreate(H5P_DATATYPE_CREATE); + /* Create link creation property list */ + create_id = H5Pcreate(H5P_LINK_CREATE); CHECK(create_id, FAIL, "H5Pcreate"); /* Set flag for intermediate group creation */ status = H5Pset_create_intermediate_group(create_id, TRUE); CHECK(status, FAIL, "H5Pset_create_intermediate_group"); - tmp_id = H5Tcopy(H5T_NATIVE_INT16); CHECK(tmp_id, FAIL, "H5Tcopy"); - status = H5Tcommit_expand(file_id, "/A/B11/dtype", tmp_id, create_id, access_id); + status = H5Tcommit_expand(file_id, tmp_id, H5P_DEFAULT, access_id); CHECK(status, FAIL, "H5Tcommit_expand"); + status = H5Llink(file_id, "/A/B11/dtype", tmp_id, create_id); + CHECK(status, FAIL, "H5Llink"); + status = H5Tclose(tmp_id); CHECK(status, FAIL, "H5Tclose"); @@ -3979,9 +4010,12 @@ test_misc23(void) tmp_id = H5Tcopy(H5T_NATIVE_INT32); CHECK(tmp_id, FAIL, "H5Tcopy"); - status = H5Tcommit_expand(file_id, "/A/B12/C12/dtype", tmp_id, create_id, access_id); + status = H5Tcommit_expand(file_id, tmp_id, H5P_DEFAULT, access_id); CHECK(status, FAIL, "H5Tcommit_expand"); + status = H5Llink(file_id, "/A/B12/C12/dtype", tmp_id, create_id); + CHECK(status, FAIL, "H5Llink"); + status = H5Tclose(tmp_id); CHECK(status, FAIL, "H5Tclose"); @@ -3989,8 +4023,11 @@ test_misc23(void) tmp_id = H5Tcopy(H5T_NATIVE_INT64); CHECK(tmp_id, FAIL, "H5Tcopy"); - status = H5Tcommit_expand(group_id, "B13/dtype", tmp_id, create_id, access_id); + status = H5Tcommit_expand(group_id, tmp_id, H5P_DEFAULT, access_id); CHECK(status, FAIL, "H5Tcommit_expand"); + + status = H5Llink(group_id, "B13/C12/dtype", tmp_id, create_id); + CHECK(status, FAIL, "H5Llink"); status = H5Tclose(tmp_id); CHECK(status, FAIL, "H5Tclose"); @@ -3999,9 +4036,12 @@ test_misc23(void) tmp_id = H5Tcopy(H5T_NATIVE_FLOAT); CHECK(tmp_id, FAIL, "H5Tcopy"); - status = H5Tcommit_expand(group_id, "/A/B14/dtype", tmp_id, create_id, access_id); + status = H5Tcommit_expand(group_id, tmp_id, H5P_DEFAULT, access_id); CHECK(status, FAIL, "H5Tcommit_expand"); + status = H5Llink(group_id, "/A/B14/dtype", tmp_id, create_id); + CHECK(status, FAIL, "H5Llink"); + status = H5Tclose(tmp_id); CHECK(status, FAIL, "H5Tclose"); @@ -4009,9 +4049,12 @@ test_misc23(void) tmp_id = H5Tcopy(H5T_NATIVE_DOUBLE); CHECK(tmp_id, FAIL, "H5Tcopy"); - status = H5Tcommit_expand(file_id, "/A/B15/C15/A/dtype", tmp_id, create_id, access_id); + status = H5Tcommit_expand(file_id, tmp_id, H5P_DEFAULT, access_id); CHECK(status, FAIL, "H5Tcommit_expand"); + status = H5Llink(file_id, "/A/B15/C15/A/dtype", tmp_id, create_id); + CHECK(status, FAIL, "H5Llink"); + status = H5Tclose(tmp_id); CHECK(status, FAIL, "H5Tclose"); diff --git a/test/tunicode.c b/test/tunicode.c index f4c4cda..16d3764 100644 --- a/test/tunicode.c +++ b/test/tunicode.c @@ -373,6 +373,11 @@ void test_vl_string(hid_t fid, const char *string) * test_objnames * Tests that UTF-8 can be used for object names in the file. * Tests groups, datasets, named datatypes, and soft links. + * Note that this test doesn't actually mark the names as being + * in UTF-8. At the time this test was written, that feature + * didn't exist in HDF5, and when the character encoding property + * was added to links it didn't change how they were stored in the file, + * -JML 2/2/2006 */ void test_objnames(hid_t fid, const char* string) { @@ -552,7 +557,7 @@ void test_attrname(hid_t fid, const char * string) } /* - * test_attrname + * test_compound * Test that compound datatypes can have UTF-8 field names. */ void test_compound(hid_t fid, const char * string) |