summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/objcopy.c1129
1 files changed, 1058 insertions, 71 deletions
diff --git a/test/objcopy.c b/test/objcopy.c
index 9d05ead..9a74cef 100755
--- a/test/objcopy.c
+++ b/test/objcopy.c
@@ -31,6 +31,9 @@ const char *FILENAME[] = {
#define FILE_EXT "objcopy_ext.dat"
#define NAME_DATATYPE_SIMPLE "H5T_NATIVE_INT"
+#define NAME_DATATYPE_SIMPLE2 "H5T_NATIVE_INT-2"
+#define NAME_DATATYPE_VL "vlen of int"
+#define NAME_DATATYPE_VL_VL "vlen of vlen of int"
#define NAME_DATASET_SIMPLE "dataset_simple"
#define NAME_DATASET_COMPOUND "dataset_compound"
#define NAME_DATASET_CHUNKED "dataset_chunked"
@@ -41,18 +44,23 @@ const char *FILENAME[] = {
#define NAME_DATASET_MULTI_OHDR "dataset_multi_ohdr"
#define NAME_DATASET_MULTI_OHDR2 "dataset_multi_ohdr2"
#define NAME_DATASET_VL "dataset_vl"
+#define NAME_DATASET_SUB_SUB "/g0/g00/g000/dataset_simple"
#define NAME_GROUP_UNCOPIED "/uncopied"
#define NAME_GROUP_EMPTY "/empty"
#define NAME_GROUP_TOP "/g0"
#define NAME_GROUP_SUB "/g0/g00"
#define NAME_GROUP_SUB_2 "/g0/g01"
#define NAME_GROUP_SUB_SUB "/g0/g00/g000"
+#define NAME_GROUP_SUB_SUB2 "g000"
#define NAME_GROUP_DATASET "/g0/dataset_simple"
#define NAME_GROUP_LINK "/g_links"
#define NAME_GROUP_LOOP "g_loop"
+#define NAME_GROUP_LOOP2 "g_loop2"
+#define NAME_GROUP_LOOP3 "g_loop3"
#define NAME_LINK_DATASET "/g_links/dataset_simple"
#define NAME_LINK_HARD "/g_links/hard_link_to_dataset_simple"
-#define NAME_LINK_SOFT "/g_links/soft_link_to_nowhere"
+#define NAME_LINK_SOFT "/g_links/soft_link_to_dataset_simple"
+#define NAME_LINK_SOFT_DANGLE "/g_links/soft_link_to_nowhere"
#define NAME_BUF_SIZE 1024
#define NUM_ATTRIBUTES 8
@@ -60,6 +68,7 @@ const char *FILENAME[] = {
#define DIM_SIZE_1 12
#define DIM_SIZE_2 6
#define NUM_SUB_GROUPS 20
+#define NUM_WIDE_LOOP_GROUPS 10
#define NUM_DATASETS 10
/* Table containing object id and object name */
@@ -390,6 +399,62 @@ error:
/*-------------------------------------------------------------------------
+ * Function: compare_data
+ *
+ * Purpose: Compare two buffers of data to check that they are equal
+ *
+ * Return: TRUE if buffer are equal/FALSE if they are different
+ *
+ * Programmer: Quincey Koziol
+ * Monday, November 21, 2005
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+compare_data(hid_t tid, size_t elmt_size, size_t nelmts, void *buf1, void *buf2)
+{
+ /* Check for references, which aren't handled */
+ if(H5Tdetect_class(tid, H5T_REFERENCE) == TRUE) TEST_ERROR
+
+ /* Check for vlen datatype */
+ if(H5Tdetect_class(tid, H5T_VLEN) == TRUE) {
+ hvl_t *vl_buf1, *vl_buf2; /* Aliases for buffers to compare */
+ hid_t base_tid; /* Base type of vlen datatype */
+ size_t base_size; /* Size of base type */
+ size_t u; /* Local index variable */
+
+ /* Check for "simple" vlen datatype */
+ if(H5Tget_class(tid) != H5T_VLEN) TEST_ERROR;
+
+ /* Get base type of vlen datatype */
+ if ( (base_tid = H5Tget_super(tid)) < 0) TEST_ERROR
+ if ( (base_size = H5Tget_size(base_tid)) == 0) TEST_ERROR
+
+ /* Loop over elements in buffers */
+ vl_buf1 = buf1;
+ vl_buf2 = buf2;
+ for(u = 0; u < nelmts; u++, vl_buf1++, vl_buf2++) {
+ /* Check vlen lengths */
+ if(vl_buf1->len != vl_buf2->len) TEST_ERROR
+
+ /* Check vlen data */
+ if(!compare_data(base_tid, base_size, vl_buf1->len, vl_buf1->p, vl_buf2->p)) TEST_ERROR
+ } /* end for */
+
+ if(H5Tclose(base_tid) < 0) TEST_ERROR
+ } /* end if */
+ else
+ if ( HDmemcmp(buf1, buf2, (size_t)(elmt_size * nelmts))) TEST_ERROR
+
+ /* Data should be the same. :-) */
+ return TRUE;
+
+error:
+ return FALSE;
+} /* end compare_data() */
+
+
+/*-------------------------------------------------------------------------
* Function: compare_datasets
*
* Purpose: Compare two datasets to check that they are equal
@@ -406,12 +471,11 @@ compare_datasets(hid_t did, hid_t did2, void *wbuf)
{
hid_t sid = -1, sid2 = -1; /* Dataspace IDs */
hid_t tid = -1, tid2 = -1; /* Datatype IDs */
- hid_t tmp_tid = -1; /* Temporary datatype ID for reading data */
hid_t dcpl = -1, dcpl2 = -1; /* Dataset creation property list IDs */
- size_t elem_size; /* Size of datatype */
+ size_t elmt_size; /* Size of datatype */
htri_t is_committed; /* If the datatype is committed */
htri_t is_committed2; /* If the datatype is committed */
- hssize_t nelem; /* # of elements in dataspace */
+ hssize_t nelmts; /* # of elements in dataspace */
void *rbuf = NULL; /* Buffer for reading raw data */
void *rbuf2 = NULL; /* Buffer for reading raw data */
H5D_space_status_t space_status; /* Dataset's raw data space status */
@@ -436,16 +500,7 @@ compare_datasets(hid_t did, hid_t did2, void *wbuf)
if ( H5Tequal(tid, tid2) != TRUE) TEST_ERROR;
/* Determine the size of datatype (for later) */
- if ( (elem_size = H5Tget_size(tid)) == 0) TEST_ERROR;
-
- /* Make copy of the datatype (for later) */
- if ( (tmp_tid = H5Tcopy(tid)) < 0) TEST_ERROR;
-
- /* close the source datatype */
- if ( H5Tclose(tid) < 0) TEST_ERROR;
-
- /* close the destination datatype */
- if ( H5Tclose(tid2) < 0) TEST_ERROR;
+ if ( (elmt_size = H5Tget_size(tid)) == 0) TEST_ERROR
/* Check the dataspaces are equal */
@@ -460,13 +515,7 @@ compare_datasets(hid_t did, hid_t did2, void *wbuf)
if ( H5Sextent_equal(sid, sid2) != TRUE) TEST_ERROR;
/* Determine the number of elements in dataspace (for later) */
- if ( (nelem = H5Sget_simple_extent_npoints(sid)) < 0) TEST_ERROR
-
- /* close the source dataspace */
- if ( H5Sclose(sid) < 0) TEST_ERROR;
-
- /* close the destination dataspace */
- if ( H5Sclose(sid2) < 0) TEST_ERROR;
+ if ( (nelmts = H5Sget_simple_extent_npoints(sid)) < 0) TEST_ERROR
/* Check the dataset creation property lists are equal */
@@ -503,28 +552,43 @@ compare_datasets(hid_t did, hid_t did2, void *wbuf)
/* Check the raw data is equal */
/* Allocate & initialize space for the raw data buffers */
- if ( (rbuf = HDcalloc( elem_size, (size_t)nelem)) == NULL) TEST_ERROR;
- if ( (rbuf2 = HDcalloc( elem_size, (size_t)nelem)) == NULL) TEST_ERROR;
+ if ( (rbuf = HDcalloc( elmt_size, (size_t)nelmts)) == NULL) TEST_ERROR;
+ if ( (rbuf2 = HDcalloc( elmt_size, (size_t)nelmts)) == NULL) TEST_ERROR;
/* Read data from datasets */
- if ( H5Dread(did, tmp_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) TEST_ERROR;
- if ( H5Dread(did2, tmp_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf2) < 0) TEST_ERROR;
+ if ( H5Dread(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) TEST_ERROR;
+ if ( H5Dread(did2, tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf2) < 0) TEST_ERROR;
/* Check raw data read in against data written out */
if(wbuf) {
- if ( HDmemcmp(wbuf, rbuf, (size_t)(elem_size * nelem))) TEST_ERROR
- if ( HDmemcmp(wbuf, rbuf2, (size_t)(elem_size * nelem))) TEST_ERROR
+ if ( !compare_data(tid, elmt_size, (size_t)nelmts, wbuf, rbuf)) TEST_ERROR
+ if ( !compare_data(tid2, elmt_size, (size_t)nelmts, wbuf, rbuf2)) TEST_ERROR
} /* end if */
/* Don't have written data, just compare data between the two datasets */
else
- if ( HDmemcmp(rbuf, rbuf2, (size_t)(elem_size * nelem))) TEST_ERROR
+ if ( !compare_data(tid, elmt_size, (size_t)nelmts, rbuf, rbuf2)) TEST_ERROR
+
+ /* Reclaim vlen data, if necessary */
+ if(H5Tdetect_class(tid, H5T_VLEN) == TRUE)
+ if(H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, rbuf) < 0) TEST_ERROR
+ if(H5Tdetect_class(tid2, H5T_VLEN) == TRUE)
+ if(H5Dvlen_reclaim(tid2, sid2, H5P_DEFAULT, rbuf2) < 0) TEST_ERROR
/* Release raw data buffers */
HDfree(rbuf);
HDfree(rbuf2);
- /* Release temporary datatype */
- if ( H5Tclose(tmp_tid) < 0) TEST_ERROR;
+ /* close the source dataspace */
+ if ( H5Sclose(sid) < 0) TEST_ERROR;
+
+ /* close the destination dataspace */
+ if ( H5Sclose(sid2) < 0) TEST_ERROR;
+
+ /* close the source datatype */
+ if ( H5Tclose(tid) < 0) TEST_ERROR;
+
+ /* close the destination datatype */
+ if ( H5Tclose(tid2) < 0) TEST_ERROR;
/* Check if the attributes are equal */
@@ -544,7 +608,6 @@ error:
H5Pclose(dcpl);
H5Sclose(sid2);
H5Sclose(sid);
- H5Tclose(tmp_tid);
H5Tclose(tid2);
H5Tclose(tid);
} H5E_END_TRY;
@@ -783,6 +846,198 @@ error:
/*-------------------------------------------------------------------------
+ * Function: test_copy_named_datatype_vl
+ *
+ * Purpose: Create name vlen datatype in SRC file and copy it to DST file
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, November 22, 2005
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_copy_named_datatype_vl(hid_t fapl)
+{
+ hid_t fid_src = -1, fid_dst = -1; /* File IDs */
+ hid_t tid = -1, tid2 = -1; /* Datatype IDs */
+ char src_filename[NAME_BUF_SIZE];
+ char dst_filename[NAME_BUF_SIZE];
+
+ TESTING("H5Gcopy(): named vlen datatype");
+
+ /* Initialize the filenames */
+ h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename);
+ h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename);
+
+ /* Reset file address checking info */
+ addr_reset();
+
+ /* create source file */
+ if ( (fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR;
+
+ /* create datatype */
+ if ( (tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) TEST_ERROR;
+
+ /* create named datatype */
+ if ( (H5Tcommit(fid_src, NAME_DATATYPE_VL, tid)) < 0) TEST_ERROR;
+
+ /* close the datatype */
+ if ( H5Tclose(tid) < 0) TEST_ERROR;
+
+ /* close the SRC file */
+ if ( H5Fclose(fid_src) < 0) TEST_ERROR;
+
+
+ /* open the source file with read-only */
+ if ( (fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR;
+
+ /* create destination file */
+ if ( (fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR;
+
+ /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
+ if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+
+ /* open the datatype for copy */
+ if ( (tid = H5Topen(fid_src, NAME_DATATYPE_VL)) < 0) TEST_ERROR;
+
+ /* copy the datatype from SRC to DST */
+ if ( H5Gcopy(tid, fid_dst, NAME_DATATYPE_VL, H5P_DEFAULT) < 0) TEST_ERROR;
+
+ /* open the copied datatype */
+ if ( (tid2 = H5Topen(fid_dst, NAME_DATATYPE_VL)) < 0) TEST_ERROR;
+
+ /* Compare the datatypes */
+ if ( H5Tequal(tid, tid2) != TRUE) TEST_ERROR;
+
+ /* close the destination datatype */
+ if ( H5Tclose(tid2) < 0) TEST_ERROR;
+
+ /* close the source datatype */
+ if ( H5Tclose(tid) < 0) TEST_ERROR;
+
+ /* close the SRC file */
+ if ( H5Fclose(fid_src) < 0) TEST_ERROR;
+
+ /* close the DST file */
+ if ( H5Fclose(fid_dst) < 0) TEST_ERROR;
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Tclose(tid2);
+ H5Tclose(tid);
+ H5Fclose(fid_dst);
+ H5Fclose(fid_src);
+ } H5E_END_TRY;
+ return 1;
+} /* end test_copy_named_datatype_vl */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_copy_named_datatype_vl_vl
+ *
+ * Purpose: Create named vlen of vlen datatype in SRC file and copy it to DST file
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, November 22, 2005
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_copy_named_datatype_vl_vl(hid_t fapl)
+{
+ hid_t fid_src = -1, fid_dst = -1; /* File IDs */
+ hid_t tid = -1, tid2 = -1; /* Datatype IDs */
+ char src_filename[NAME_BUF_SIZE];
+ char dst_filename[NAME_BUF_SIZE];
+
+ TESTING("H5Gcopy(): named nested vlen datatype");
+
+ /* Initialize the filenames */
+ h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename);
+ h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename);
+
+ /* Reset file address checking info */
+ addr_reset();
+
+ /* create source file */
+ if ( (fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR;
+
+ /* create first vlen datatype */
+ if ( (tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) TEST_ERROR;
+
+ /* create second (nested) vlen datatype */
+ if ( (tid2 = H5Tvlen_create(tid)) < 0) TEST_ERROR;
+
+ /* create named datatype */
+ if ( (H5Tcommit(fid_src, NAME_DATATYPE_VL_VL, tid2)) < 0) TEST_ERROR;
+
+ /* close the first datatype */
+ if ( H5Tclose(tid) < 0) TEST_ERROR;
+
+ /* close the second datatype */
+ if ( H5Tclose(tid2) < 0) TEST_ERROR;
+
+ /* close the SRC file */
+ if ( H5Fclose(fid_src) < 0) TEST_ERROR;
+
+
+ /* open the source file with read-only */
+ if ( (fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR;
+
+ /* create destination file */
+ if ( (fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR;
+
+ /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
+ if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+
+ /* open the datatype for copy */
+ if ( (tid = H5Topen(fid_src, NAME_DATATYPE_VL_VL)) < 0) TEST_ERROR;
+
+ /* copy the datatype from SRC to DST */
+ if ( H5Gcopy(tid, fid_dst, NAME_DATATYPE_VL_VL, H5P_DEFAULT) < 0) TEST_ERROR;
+
+ /* open the copied datatype */
+ if ( (tid2 = H5Topen(fid_dst, NAME_DATATYPE_VL_VL)) < 0) TEST_ERROR;
+
+ /* Compare the datatypes */
+ if ( H5Tequal(tid, tid2) != TRUE) TEST_ERROR;
+
+ /* close the destination datatype */
+ if ( H5Tclose(tid2) < 0) TEST_ERROR;
+
+ /* close the source datatype */
+ if ( H5Tclose(tid) < 0) TEST_ERROR;
+
+ /* close the SRC file */
+ if ( H5Fclose(fid_src) < 0) TEST_ERROR;
+
+ /* close the DST file */
+ if ( H5Fclose(fid_dst) < 0) TEST_ERROR;
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Tclose(tid2);
+ H5Tclose(tid);
+ H5Fclose(fid_dst);
+ H5Fclose(fid_src);
+ } H5E_END_TRY;
+ return 1;
+} /* end test_copy_named_datatype_vl */
+
+
+/*-------------------------------------------------------------------------
* Function: test_copy_dataset_simple
*
* Purpose: Create a simple dataset in SRC file and copy it to DST file
@@ -1158,7 +1413,7 @@ test_copy_dataset_chunked(hid_t fapl)
{
hid_t fid_src = -1, fid_dst = -1; /* File IDs */
hid_t sid = -1; /* Dataspace ID */
- hid_t pid = -1; /* Datasset creation property list ID */
+ hid_t pid = -1; /* Dataset creation property list ID */
hid_t did = -1, did2 = -1; /* Dataset IDs */
hsize_t dim2d[2]; /* Dataset dimensions */
hsize_t chunk_dim2d[2] ={2, 3}; /* Chunk dimensions */
@@ -1285,7 +1540,7 @@ test_copy_dataset_chunked_empty(hid_t fapl)
{
hid_t fid_src = -1, fid_dst = -1; /* File IDs */
hid_t sid = -1; /* Dataspace ID */
- hid_t pid = -1; /* Datasset creation property list ID */
+ hid_t pid = -1; /* Dataset creation property list ID */
hid_t did = -1, did2 = -1; /* Dataset IDs */
hsize_t dim2d[2]; /* Dataset dimensions */
hsize_t chunk_dim2d[2] ={2, 3}; /* Chunk dimensions */
@@ -1380,7 +1635,7 @@ error:
H5Fclose(fid_src);
} H5E_END_TRY;
return 1;
-} /* end test_copy_dataset_chunked */
+} /* end test_copy_dataset_chunked_empty */
/*-------------------------------------------------------------------------
@@ -1402,7 +1657,7 @@ test_copy_dataset_chunked_sparse(hid_t fapl)
{
hid_t fid_src = -1, fid_dst = -1; /* File IDs */
hid_t sid = -1; /* Dataspace ID */
- hid_t pid = -1; /* Datasset creation property list ID */
+ hid_t pid = -1; /* Dataset creation property list ID */
hid_t did = -1, did2 = -1; /* Dataset IDs */
hsize_t dim2d[2]; /* Dataset dimensions */
hsize_t new_dim2d[2]; /* Dataset dimensions */
@@ -1520,7 +1775,6 @@ error:
return 1;
} /* end test_copy_dataset_chunked_sparse */
-#ifdef H5_HAVE_FILTER_DEFLATE
/*-------------------------------------------------------------------------
* Function: test_copy_dataset_compressed
@@ -1538,9 +1792,10 @@ error:
static int
test_copy_dataset_compressed(hid_t fapl)
{
+#ifdef H5_HAVE_FILTER_DEFLATE
hid_t fid_src = -1, fid_dst = -1; /* File IDs */
hid_t sid = -1; /* Dataspace ID */
- hid_t pid = -1; /* Datasset creation property list ID */
+ hid_t pid = -1; /* Dataset creation property list ID */
hid_t did = -1, did2 = -1; /* Dataset IDs */
hsize_t dim2d[2]; /* Dataset dimensions */
hsize_t chunk_dim2d[2] ={2, 3}; /* Chunk dimensions */
@@ -1548,9 +1803,14 @@ test_copy_dataset_compressed(hid_t fapl)
int i, j; /* Local index variables */
char src_filename[NAME_BUF_SIZE];
char dst_filename[NAME_BUF_SIZE];
+#endif /* H5_HAVE_FILTER_DEFLATE */
TESTING("H5Gcopy(): compressed dataset");
+#ifndef H5_HAVE_FILTER_DEFLATE
+ SKIPPED();
+ puts(" Deflation filter not available");
+#else /* H5_HAVE_FILTER_DEFLATE */
/* set initial data values */
for (i=0; i<DIM_SIZE_1; i++)
for (j=0; j<DIM_SIZE_2; j++)
@@ -1634,8 +1894,10 @@ test_copy_dataset_compressed(hid_t fapl)
if ( H5Fclose(fid_dst) < 0) TEST_ERROR;
PASSED();
+#endif /* H5_HAVE_FILTER_DEFLATE */
return 0;
+#ifdef H5_HAVE_FILTER_DEFLATE
error:
H5E_BEGIN_TRY {
H5Dclose(did2);
@@ -1646,8 +1908,8 @@ error:
H5Fclose(fid_src);
} H5E_END_TRY;
return 1;
-} /* end test_copy_dataset_compressed */
#endif /* H5_HAVE_FILTER_DEFLATE */
+} /* end test_copy_dataset_compressed */
/*-------------------------------------------------------------------------
@@ -1668,7 +1930,7 @@ test_copy_dataset_compact(hid_t fapl)
{
hid_t fid_src = -1, fid_dst = -1; /* File IDs */
hid_t sid = -1; /* Dataspace ID */
- hid_t pid = -1; /* Datasset creation property list ID */
+ hid_t pid = -1; /* Dataset creation property list ID */
hid_t did = -1, did2 = -1; /* Dataset IDs */
hsize_t dim2d[2]; /* Dataset dimensions */
float buf[DIM_SIZE_1][DIM_SIZE_2]; /* Buffer for writing data */
@@ -1795,7 +2057,7 @@ test_copy_dataset_external(hid_t fapl)
{
hid_t fid_src = -1, fid_dst = -1; /* File IDs */
hid_t sid = -1; /* Dataspace ID */
- hid_t pid = -1; /* Datasset creation property list ID */
+ hid_t pid = -1; /* Dataset creation property list ID */
hid_t did = -1, did2 = -1; /* Dataset IDs */
int i;
hsize_t size;
@@ -2584,9 +2846,10 @@ error:
/*-------------------------------------------------------------------------
- * Function: test_copy_dataset_vl
+ * Function: test_copy_dataset_contig_vl
*
- * Purpose: Create a variable-length dataset in SRC file and copy it to DST file
+ * Purpose: Create a contiguous dataset w/variable-length datatype in SRC
+ * file and copy it to DST file
*
* Return: Success: 0
* Failure: number of errors
@@ -2594,39 +2857,167 @@ error:
* Programmer: Peter Cao
* Friday, September 30, 2005
*
- * Modifications:
+ *-------------------------------------------------------------------------
+ */
+static int
+test_copy_dataset_contig_vl(hid_t fapl)
+{
+ hid_t fid_src = -1, fid_dst = -1; /* File IDs */
+ hid_t tid = -1; /* Datatype ID */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t did = -1, did2 = -1; /* Dataset IDs */
+ unsigned int i, j; /* Local index variables */
+ hsize_t dim1d[1]; /* Dataset dimensions */
+ hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */
+ char src_filename[NAME_BUF_SIZE];
+ char dst_filename[NAME_BUF_SIZE];
+
+ TESTING("H5Gcopy(): contiguous dataset with variable-length datatype");
+
+ /* set initial data values */
+ for(i = 0; i < DIM_SIZE_1; i++) {
+ buf[i].len = i+1;
+ buf[i].p = (int *)HDmalloc(buf[i].len * sizeof(int));
+ for(j = 0; j < buf[i].len; j++)
+ ((int *)buf[i].p)[j] = i*10+j;
+ } /* end for */
+
+ /* Initialize the filenames */
+ h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename);
+ h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename);
+
+ /* Reset file address checking info */
+ addr_reset();
+
+ /* create source file */
+ if ( (fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR;
+
+ /* Set dataspace dimensions */
+ dim1d[0]=DIM_SIZE_1;
+
+ /* create dataspace */
+ if ( (sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR;
+
+ /* create datatype */
+ if ( (tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) TEST_ERROR;
+
+ /* create dataset at SRC file */
+ if ( (did = H5Dcreate(fid_src, NAME_DATASET_VL, tid, sid, H5P_DEFAULT)) < 0) TEST_ERROR;
+
+ /* write data into file */
+ if ( H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR;
+
+ /* close the dataset */
+ if ( H5Dclose(did) < 0) TEST_ERROR;
+
+ /* close the SRC file */
+ if ( H5Fclose(fid_src) < 0) TEST_ERROR;
+
+
+ /* open the source file with read-only */
+ if ( (fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR;
+
+ /* create destination file */
+ if ( (fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR;
+
+ /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
+ if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+
+ /* open the dataset for copy */
+ if ( (did = H5Dopen(fid_src, NAME_DATASET_VL)) < 0) TEST_ERROR;
+
+ /* copy the dataset from SRC to DST */
+ if ( H5Gcopy(did, fid_dst, NAME_DATASET_VL, H5P_DEFAULT) < 0) TEST_ERROR;
+
+ /* open the destination dataset */
+ if ( (did2 = H5Dopen(fid_dst, NAME_DATASET_VL)) < 0) TEST_ERROR;
+
+ /* Check if the datasets are equal */
+ if ( compare_datasets(did, did2, buf) != TRUE) TEST_ERROR;
+
+ /* close the destination dataset */
+ if ( H5Dclose(did2) < 0) TEST_ERROR;
+
+ /* close the source dataset */
+ if ( H5Dclose(did) < 0) TEST_ERROR;
+
+ /* close the SRC file */
+ if ( H5Fclose(fid_src) < 0) TEST_ERROR;
+
+ /* close the DST file */
+ if ( H5Fclose(fid_dst) < 0) TEST_ERROR;
+
+
+ /* Reclaim vlen buffer */
+ if ( H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR;
+
+ /* close datatype */
+ if ( H5Tclose(tid) < 0) TEST_ERROR;
+
+ /* close dataspace */
+ if ( H5Sclose(sid) < 0) TEST_ERROR;
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Dclose(did2);
+ H5Dclose(did);
+ H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf);
+ H5Tclose(tid);
+ H5Sclose(sid);
+ H5Fclose(fid_dst);
+ H5Fclose(fid_src);
+ } H5E_END_TRY;
+ return 1;
+} /* end test_copy_dataset_contig_vl */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_copy_dataset_chunked_vl
+ *
+ * Purpose: Create a chunked dataset w/variable-length datatype in SRC
+ * file and copy it to DST file
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ * Programmer: Peter Cao
+ * Friday, September 30, 2005
*
*-------------------------------------------------------------------------
*/
static int
-test_copy_dataset_vl(hid_t fapl)
+test_copy_dataset_chunked_vl(hid_t fapl)
{
#ifdef NOT_YET
hid_t fid_src = -1, fid_dst = -1; /* File IDs */
hid_t tid = -1; /* Datatype ID */
hid_t sid = -1; /* Dataspace ID */
+ hid_t pid = -1; /* Dataset creation property list ID */
hid_t did = -1, did2 = -1; /* Dataset IDs */
- unsigned int i, j;
- hsize_t dim1d[1];
- hvl_t buf[DIM_SIZE_1];
+ unsigned int i, j; /* Local index variables */
+ hsize_t dim1d[1]; /* Dataset dimensions */
+ hsize_t chunk_dim1d[1] = {3}; /* Chunk dimensions */
+ hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */
char src_filename[NAME_BUF_SIZE];
char dst_filename[NAME_BUF_SIZE];
#endif /* NOT_YET */
- TESTING("H5Gcopy(): dataset with variable-length datatype");
+ TESTING("H5Gcopy(): chunked dataset with variable-length datatype");
#ifndef NOT_YET
SKIPPED();
- puts(" Not implemented yet -- needs data copying functionality");
+ puts(" Not supported yet!!");
#else /* NOT_YET */
-
/* set initial data values */
- for (i=0; i<DIM_SIZE_1; i++) {
+ for(i = 0; i < DIM_SIZE_1; i++) {
buf[i].len = i+1;
- buf[i].p = (int *)malloc( buf[i].len*sizeof(int));
- for (j=0; j<buf[i].len; j++)
+ buf[i].p = (int *)HDmalloc(buf[i].len * sizeof(int));
+ for(j = 0; j < buf[i].len; j++)
((int *)buf[i].p)[j] = i*10+j;
- }
+ } /* end for */
/* Initialize the filenames */
h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename);
@@ -2647,20 +3038,21 @@ test_copy_dataset_vl(hid_t fapl)
/* create datatype */
if ( (tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) TEST_ERROR;
+ /* create and set chunk plist */
+ if ( (pid = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR;
+ if ( H5Pset_chunk(pid, 1, chunk_dim1d) < 0) TEST_ERROR;
+
/* create dataset at SRC file */
- if ( (did = H5Dcreate(fid_src, NAME_DATASET_VL, tid, sid, H5P_DEFAULT)) < 0) TEST_ERROR;
+ if ( (did = H5Dcreate(fid_src, NAME_DATASET_VL, tid, sid, pid)) < 0) TEST_ERROR;
+
+ /* close chunk plist */
+ if ( H5Pclose(pid) < 0) TEST_ERROR;
/* write data into file */
if ( H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR;
- /* close dataspace */
- if ( H5Sclose(sid) < 0) TEST_ERROR;
-
- /* close datatype */
- if ( H5Tclose(tid) < 0) TEST_ERROR;
-
/* close the dataset */
- if (H5Dclose(did) < 0) TEST_ERROR;
+ if ( H5Dclose(did) < 0) TEST_ERROR;
/* close the SRC file */
if ( H5Fclose(fid_src) < 0) TEST_ERROR;
@@ -2699,6 +3091,16 @@ test_copy_dataset_vl(hid_t fapl)
/* close the DST file */
if ( H5Fclose(fid_dst) < 0) TEST_ERROR;
+
+ /* Reclaim vlen buffer */
+ if ( H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR;
+
+ /* close datatype */
+ if ( H5Tclose(tid) < 0) TEST_ERROR;
+
+ /* close dataspace */
+ if ( H5Sclose(sid) < 0) TEST_ERROR;
+
PASSED();
#endif /* NOT_YET */
return 0;
@@ -2708,6 +3110,7 @@ error:
H5E_BEGIN_TRY {
H5Dclose(did2);
H5Dclose(did);
+ H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf);
H5Tclose(tid);
H5Sclose(sid);
H5Fclose(fid_dst);
@@ -2715,7 +3118,7 @@ error:
} H5E_END_TRY;
return 1;
#endif /* NOT_YET */
-} /* end test_copy_dataset_vl */
+} /* end test_copy_dataset_chunked_vl */
/*-------------------------------------------------------------------------
@@ -3200,7 +3603,136 @@ error:
/*-------------------------------------------------------------------------
- * Function: test_copy_link
+ * Function: test_copy_group_wide_loop
+ *
+ * Purpose: Create a group hier. with loops in SRC file and copy it to DST file
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, November 1, 2005
+ *
+ * Note: Create groups w/lots of entries in each level, so that "dense"
+ * group form is used.
+ *
+ * Note: Also tests multiple links to a locked group during copy.
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_copy_group_wide_loop(hid_t fapl)
+{
+ hid_t fid_src = -1, fid_dst = -1; /* File IDs */
+ hid_t gid = -1, gid2 = -1; /* Group IDs */
+ hid_t gid_sub = -1, gid_sub2; /* Sub-group IDs */
+ unsigned u, v; /* Local index variables */
+ char objname[NAME_BUF_SIZE]; /* Object name buffer */
+ char src_filename[NAME_BUF_SIZE];
+ char dst_filename[NAME_BUF_SIZE];
+
+ TESTING("H5Gcopy(): wide nested groups with loop");
+
+ /* Initialize the filenames */
+ h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename);
+ h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename);
+
+ /* Reset file address checking info */
+ addr_reset();
+
+ /* create source file */
+ if ( (fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR;
+
+ /* create group at the SRC file */
+ if ( (gid = H5Gcreate(fid_src, NAME_GROUP_TOP, (size_t)0)) < 0) TEST_ERROR;
+
+ /* attach attributes to the group */
+ if ( test_copy_attach_attributes(gid, H5T_NATIVE_INT) < 0) TEST_ERROR;
+
+ /* create wide sub-group hierarchy, with multiple links to higher groups */
+ for(u = 0; u < NUM_WIDE_LOOP_GROUPS; u++) {
+ sprintf(objname, "%s-%u", NAME_GROUP_SUB, u);
+ if ( (gid_sub = H5Gcreate(gid, objname, (size_t)0)) < 0) TEST_ERROR;
+
+ for(v = 0; v < NUM_WIDE_LOOP_GROUPS; v++) {
+ sprintf(objname, "%s-%u", NAME_GROUP_SUB_SUB2, v);
+ if ( (gid_sub2 = H5Gcreate(gid_sub, objname, (size_t)0)) < 0) TEST_ERROR;
+
+ /* Create link to top group */
+ if ( H5Glink2(gid, ".", H5G_LINK_HARD, gid_sub2, NAME_GROUP_LOOP) < 0) TEST_ERROR;
+
+ /* Create link to sub-group */
+ if ( H5Glink2(gid_sub, ".", H5G_LINK_HARD, gid_sub2, NAME_GROUP_LOOP2) < 0) TEST_ERROR;
+
+ /* Create link to self :-) */
+ if ( H5Glink2(gid_sub2, ".", H5G_LINK_HARD, gid_sub2, NAME_GROUP_LOOP3) < 0) TEST_ERROR;
+
+ /* close sub sub group */
+ if( H5Gclose(gid_sub2) < 0) TEST_ERROR;
+ } /* end for */
+
+ /* close sub group */
+ if( H5Gclose(gid_sub) < 0) TEST_ERROR;
+ } /* end for */
+
+ /* close the group */
+ if ( H5Gclose(gid) < 0) TEST_ERROR;
+
+ /* close the SRC file */
+ if ( H5Fclose(fid_src) < 0) TEST_ERROR;
+
+
+ /* open the source file with read-only */
+ if ( (fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR;
+
+ /* create destination file */
+ if ( (fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR;
+
+ /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
+ if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+
+ /* open the group for copy */
+ if ( (gid = H5Gopen(fid_src, NAME_GROUP_TOP)) < 0) TEST_ERROR;
+
+ /* copy the group from SRC to DST */
+ if ( H5Gcopy(gid, fid_dst, NAME_GROUP_TOP, H5P_DEFAULT) < 0) TEST_ERROR;
+
+ /* open the destination group */
+ if ( (gid2 = H5Gopen(fid_dst, NAME_GROUP_TOP)) < 0) TEST_ERROR;
+
+ /* Check if the groups are equal */
+ if ( compare_groups(gid, gid2) != TRUE) TEST_ERROR;
+
+ /* close the destination group */
+ if ( H5Gclose(gid2) < 0) TEST_ERROR;
+
+ /* close the source group */
+ if ( H5Gclose(gid) < 0) TEST_ERROR;
+
+ /* close the SRC file */
+ if ( H5Fclose(fid_src) < 0) TEST_ERROR;
+
+ /* close the DST file */
+ if ( H5Fclose(fid_dst) < 0) TEST_ERROR;
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Gclose(gid_sub2);
+ H5Gclose(gid_sub);
+ H5Gclose(gid2);
+ H5Gclose(gid);
+ H5Fclose(fid_dst);
+ H5Fclose(fid_src);
+ } H5E_END_TRY;
+ return 1;
+} /* end test_copy_group_wide_loop */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_copy_group_links
*
* Purpose: Create a group and links in SRC file and copy it to DST file
*
@@ -3215,7 +3747,7 @@ error:
*-------------------------------------------------------------------------
*/
static int
-test_copy_link(hid_t fapl)
+test_copy_group_links(hid_t fapl)
{
hid_t fid_src = -1, fid_dst = -1; /* File IDs */
hid_t sid = -1; /* Dataspace ID */
@@ -3270,8 +3802,11 @@ test_copy_link(hid_t fapl)
/* make a hard link to the dataset */
if (H5Glink(fid_src, H5G_LINK_HARD, NAME_LINK_DATASET, NAME_LINK_HARD) < 0) TEST_ERROR;
+ /* make a soft link to the dataset */
+ if (H5Glink(fid_src, H5G_LINK_SOFT, NAME_LINK_DATASET, NAME_LINK_SOFT) < 0) TEST_ERROR;
+
/* make a soft link to nowhere */
- if (H5Glink(fid_src, H5G_LINK_SOFT, "nowhere", NAME_LINK_SOFT) < 0) TEST_ERROR;
+ if (H5Glink(fid_src, H5G_LINK_SOFT, "nowhere", NAME_LINK_SOFT_DANGLE) < 0) TEST_ERROR;
/* close the group */
if ( H5Gclose(gid) < 0) TEST_ERROR;
@@ -3326,7 +3861,451 @@ error:
H5Fclose(fid_src);
} H5E_END_TRY;
return 1;
-} /* end test_copy_link */
+} /* end test_copy_group_links */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_copy_soft_link
+ *
+ * Purpose: Create a soft link in SRC file and copy it to DST file
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, September 30, 2005
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_copy_soft_link(hid_t fapl)
+{
+ hid_t fid_src = -1, fid_dst = -1; /* File IDs */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t did = -1, did2 = -1; /* Dataset IDs */
+ hid_t gid = -1; /* Group ID */
+ hsize_t dim2d[2];
+ int buf[DIM_SIZE_1][DIM_SIZE_2];
+ int i, j;
+ char src_filename[NAME_BUF_SIZE];
+ char dst_filename[NAME_BUF_SIZE];
+
+ TESTING("H5Gcopy(): object through soft link");
+
+ /* set initial data values */
+ for (i=0; i<DIM_SIZE_1; i++)
+ for (j=0; j<DIM_SIZE_2; j++)
+ buf[i][j] = 10000 + 100*i+j;
+
+ /* Initialize the filenames */
+ h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename);
+ h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename);
+
+ /* Reset file address checking info */
+ addr_reset();
+
+ /* create source file */
+ if ( (fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR;
+
+ /* create group at the SRC file */
+ if ( (gid = H5Gcreate(fid_src, NAME_GROUP_LINK, (size_t)0)) < 0) TEST_ERROR;
+
+ /* attach attributes to the group */
+ if ( test_copy_attach_attributes(gid, H5T_NATIVE_INT) < 0) TEST_ERROR;
+
+ /* Set dataspace dimensions */
+ dim2d[0]=DIM_SIZE_1;
+ dim2d[1]=DIM_SIZE_2;
+
+ /* create dataspace */
+ if ( (sid = H5Screate_simple(2, dim2d, NULL)) < 0) TEST_ERROR;
+
+ /* add a dataset to the group */
+ if ( (did = H5Dcreate(fid_src, NAME_LINK_DATASET, H5T_NATIVE_INT, sid, H5P_DEFAULT) ) < 0) TEST_ERROR;
+ if ( H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR;
+
+ /* close dataspace */
+ if ( H5Sclose(sid) < 0) TEST_ERROR;
+
+ /* close the dataset */
+ if (H5Dclose(did) < 0) TEST_ERROR;
+
+ /* make a soft link to the dataset */
+ if (H5Glink(fid_src, H5G_LINK_SOFT, NAME_LINK_DATASET, NAME_LINK_SOFT) < 0) TEST_ERROR;
+
+ /* close the group */
+ if ( H5Gclose(gid) < 0) TEST_ERROR;
+
+ /* close the SRC file */
+ if ( H5Fclose(fid_src) < 0) TEST_ERROR;
+
+
+ /* open the source file with read-only */
+ if ( (fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR;
+
+ /* create destination file */
+ if ( (fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR;
+
+ /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
+ if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+
+ /* open the dataset through the soft link for copy */
+ if ( (did = H5Dopen(fid_src, NAME_LINK_SOFT)) < 0) TEST_ERROR;
+
+ /* copy the dataset from SRC to DST */
+ if ( H5Gcopy(did, fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT) < 0) TEST_ERROR;
+
+ /* open the destination dataset */
+ if ( (did2 = H5Dopen(fid_dst, NAME_DATASET_SIMPLE)) < 0) TEST_ERROR;
+
+ /* Check if the datasets are equal */
+ if ( compare_datasets(did, did2, buf) != TRUE) TEST_ERROR;
+
+ /* close the destination dataset */
+ if ( H5Dclose(did2) < 0) TEST_ERROR;
+
+ /* close the source dataset */
+ if ( H5Dclose(did) < 0) TEST_ERROR;
+
+ /* close the SRC file */
+ if ( H5Fclose(fid_src) < 0) TEST_ERROR;
+
+ /* close the DST file */
+ if ( H5Fclose(fid_dst) < 0) TEST_ERROR;
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Sclose(sid);
+ H5Dclose(did2);
+ H5Dclose(did);
+ H5Gclose(gid);
+ H5Fclose(fid_dst);
+ H5Fclose(fid_src);
+ } H5E_END_TRY;
+ return 1;
+} /* end test_copy_soft_link */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_copy_exist
+ *
+ * Purpose: Create a simple dataset in SRC file and copy it onto an
+ * existing object in DST file
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, November 8, 2005
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_copy_exist(hid_t fapl)
+{
+ hid_t fid_src = -1, fid_dst = -1; /* File IDs */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t did = -1; /* Dataset IDs */
+ int buf[DIM_SIZE_1][DIM_SIZE_2]; /* Buffer for writing data */
+ hsize_t dim2d[2]; /* Dataset dimensions */
+ int i, j; /* local index variables */
+ herr_t ret; /* Generic return value */
+ char src_filename[NAME_BUF_SIZE];
+ char dst_filename[NAME_BUF_SIZE];
+
+ TESTING("H5Gcopy(): existing object");
+
+ /* Initialize write buffer */
+ for (i=0; i<DIM_SIZE_1; i++)
+ for (j=0; j<DIM_SIZE_2; j++)
+ buf[i][j] = 10000 + 100*i+j;
+
+ /* Initialize the filenames */
+ h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename);
+ h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename);
+
+ /* Reset file address checking info */
+ addr_reset();
+
+ /* create source file */
+ if ( (fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR;
+
+ /* Set dataspace dimensions */
+ dim2d[0] = DIM_SIZE_1;
+ dim2d[1] = DIM_SIZE_2;
+
+ /* create 2D dataspace */
+ if ( (sid = H5Screate_simple(2, dim2d, NULL)) < 0) TEST_ERROR;
+
+ /* create 2D int dataset at SRC file */
+ if ( (did = H5Dcreate(fid_src, NAME_DATASET_SIMPLE, H5T_NATIVE_INT, sid, H5P_DEFAULT)) < 0) TEST_ERROR;
+
+ /* write data into file */
+ if ( H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR;
+
+ /* close dataspace */
+ if ( H5Sclose(sid) < 0) TEST_ERROR;
+
+ /* attach attributes to the dataset */
+ if ( test_copy_attach_attributes(did, H5T_NATIVE_INT) < 0) TEST_ERROR;
+
+ /* close the dataset */
+ if ( H5Dclose(did) < 0) TEST_ERROR;
+
+ /* close the SRC file */
+ if ( H5Fclose(fid_src) < 0) TEST_ERROR;
+
+
+ /* open the source file with read-only */
+ if ( (fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR;
+
+ /* create destination file */
+ if ( (fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR;
+
+ /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
+ if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+
+ /* open the dataset for copy */
+ if ( (did = H5Dopen(fid_src, NAME_DATASET_SIMPLE)) < 0) TEST_ERROR;
+
+ /* copy the dataset from SRC to DST */
+ if ( H5Gcopy(did, fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT) < 0) TEST_ERROR;
+
+ /* try to copy the dataset from SRC to DST again (should fail) */
+ H5E_BEGIN_TRY {
+ ret = H5Gcopy(did, fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT);
+ } H5E_END_TRY;
+ if( ret >= 0) TEST_ERROR;
+
+ /* close the source dataset */
+ if ( H5Dclose(did) < 0) TEST_ERROR;
+
+ /* close the SRC file */
+ if ( H5Fclose(fid_src) < 0) TEST_ERROR;
+
+ /* close the DST file */
+ if ( H5Fclose(fid_dst) < 0) TEST_ERROR;
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Dclose(did);
+ H5Sclose(sid);
+ H5Fclose(fid_dst);
+ H5Fclose(fid_src);
+ } H5E_END_TRY;
+ return 1;
+} /* end test_copy_exist */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_copy_path
+ *
+ * Purpose: Create a simple dataset in SRC file and copy it to DST file
+ * using a full path name
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, November 8, 2005
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_copy_path(hid_t fapl)
+{
+ hid_t fid_src = -1, fid_dst = -1; /* File IDs */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t did = -1, did2 = -1; /* Dataset IDs */
+ hid_t gid = -1; /* Group ID */
+ int buf[DIM_SIZE_1][DIM_SIZE_2]; /* Buffer for writing data */
+ hsize_t dim2d[2]; /* Dataset dimensions */
+ int i, j; /* local index variables */
+ herr_t ret; /* Generic return value */
+ char src_filename[NAME_BUF_SIZE];
+ char dst_filename[NAME_BUF_SIZE];
+
+ TESTING("H5Gcopy(): full path");
+
+ /* Initialize write buffer */
+ for (i=0; i<DIM_SIZE_1; i++)
+ for (j=0; j<DIM_SIZE_2; j++)
+ buf[i][j] = 10000 + 100*i+j;
+
+ /* Initialize the filenames */
+ h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename);
+ h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename);
+
+ /* Reset file address checking info */
+ addr_reset();
+
+ /* create source file */
+ if ( (fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR;
+
+ /* Set dataspace dimensions */
+ dim2d[0] = DIM_SIZE_1;
+ dim2d[1] = DIM_SIZE_2;
+
+ /* create 2D dataspace */
+ if ( (sid = H5Screate_simple(2, dim2d, NULL)) < 0) TEST_ERROR;
+
+ /* create 2D int dataset at SRC file */
+ if ( (did = H5Dcreate(fid_src, NAME_DATASET_SIMPLE, H5T_NATIVE_INT, sid, H5P_DEFAULT)) < 0) TEST_ERROR;
+
+ /* write data into file */
+ if ( H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR;
+
+ /* close dataspace */
+ if ( H5Sclose(sid) < 0) TEST_ERROR;
+
+ /* attach attributes to the dataset */
+ if ( test_copy_attach_attributes(did, H5T_NATIVE_INT) < 0) TEST_ERROR;
+
+ /* close the dataset */
+ if ( H5Dclose(did) < 0) TEST_ERROR;
+
+ /* close the SRC file */
+ if ( H5Fclose(fid_src) < 0) TEST_ERROR;
+
+
+ /* open the source file with read-only */
+ if ( (fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR;
+
+ /* create destination file */
+ if ( (fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR;
+
+ /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
+ if ( H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR;
+
+ /* open the dataset for copy */
+ if ( (did = H5Dopen(fid_src, NAME_DATASET_SIMPLE)) < 0) TEST_ERROR;
+
+ /* copy the dataset from SRC to DST (should fail - intermediate groups not there) */
+ H5E_BEGIN_TRY {
+ ret = H5Gcopy(did, fid_dst, NAME_DATASET_SUB_SUB, H5P_DEFAULT);
+ } H5E_END_TRY;
+ if( ret >= 0) TEST_ERROR;
+
+ /* Create the intermediate groups in destination file */
+ if ( (gid = H5Gcreate(fid_dst, NAME_GROUP_TOP, (size_t)0)) < 0) TEST_ERROR;
+ if ( H5Gclose(gid) < 0) TEST_ERROR;
+
+ if ( (gid = H5Gcreate(fid_dst, NAME_GROUP_SUB, (size_t)0)) < 0) TEST_ERROR;
+ if ( H5Gclose(gid) < 0) TEST_ERROR;
+
+ if ( (gid = H5Gcreate(fid_dst, NAME_GROUP_SUB_SUB, (size_t)0)) < 0) TEST_ERROR;
+ if ( H5Gclose(gid) < 0) TEST_ERROR;
+
+ /* copy the dataset from SRC to DST, using full path */
+ if ( H5Gcopy(did, fid_dst, NAME_DATASET_SUB_SUB, H5P_DEFAULT) < 0) TEST_ERROR;
+
+ /* open the destination dataset */
+ if ( (did2 = H5Dopen(fid_dst, NAME_DATASET_SUB_SUB)) < 0) TEST_ERROR;
+
+ /* Check if the datasets are equal */
+ if ( compare_datasets(did, did2, buf) != TRUE) TEST_ERROR;
+
+ /* close the destination dataset */
+ if ( H5Dclose(did2) < 0) TEST_ERROR;
+
+ /* close the source dataset */
+ if ( H5Dclose(did) < 0) TEST_ERROR;
+
+ /* close the SRC file */
+ if ( H5Fclose(fid_src) < 0) TEST_ERROR;
+
+ /* close the DST file */
+ if ( H5Fclose(fid_dst) < 0) TEST_ERROR;
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Dclose(did2);
+ H5Dclose(did);
+ H5Sclose(sid);
+ H5Gclose(gid);
+ H5Fclose(fid_dst);
+ H5Fclose(fid_src);
+ } H5E_END_TRY;
+ return 1;
+} /* end test_copy_path */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_copy_same_file_named_datatype
+ *
+ * Purpose: Create name datatype in SRC file and copy it to same file
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, November 8, 2005
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_copy_same_file_named_datatype(hid_t fapl)
+{
+ hid_t fid = -1; /* File ID */
+ hid_t tid = -1, tid2 = -1; /* Datatype IDs */
+ char filename[NAME_BUF_SIZE];
+
+ TESTING("H5Gcopy(): named datatype in same file");
+
+ /* Initialize the filenames */
+ h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
+
+ /* Reset file address checking info */
+ addr_reset();
+
+ /* create source file */
+ if ( (fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR;
+
+ /* create datatype */
+ if ( (tid = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR;
+
+ /* create named datatype */
+ if ( (H5Tcommit(fid, NAME_DATATYPE_SIMPLE, tid)) < 0) TEST_ERROR;
+
+
+ /* copy the datatype from SRC to DST */
+ if ( H5Gcopy(tid, fid, NAME_DATATYPE_SIMPLE2, H5P_DEFAULT) < 0) TEST_ERROR;
+
+ /* open the copied datatype */
+ if ( (tid2 = H5Topen(fid, NAME_DATATYPE_SIMPLE2)) < 0) TEST_ERROR;
+
+ /* Compare the datatypes */
+ if ( H5Tequal(tid, tid2) != TRUE) TEST_ERROR;
+
+ /* close the destination datatype */
+ if ( H5Tclose(tid2) < 0) TEST_ERROR;
+
+ /* close the source datatype */
+ if ( H5Tclose(tid) < 0) TEST_ERROR;
+
+ /* close the file */
+ if ( H5Fclose(fid) < 0) TEST_ERROR;
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Tclose(tid2);
+ H5Tclose(tid);
+ H5Fclose(fid);
+ } H5E_END_TRY;
+ return 1;
+} /* end test_copy_same_file_named_datatype */
/*-------------------------------------------------------------------------
@@ -3379,15 +4358,15 @@ main(void)
/* The tests... */
nerrors += test_copy_named_datatype(fapl);
+ nerrors += test_copy_named_datatype_vl(fapl);
+ nerrors += test_copy_named_datatype_vl_vl(fapl);
nerrors += test_copy_dataset_simple(fapl);
nerrors += test_copy_dataset_simple_empty(fapl);
nerrors += test_copy_dataset_compound(fapl);
nerrors += test_copy_dataset_chunked(fapl);
nerrors += test_copy_dataset_chunked_empty(fapl);
nerrors += test_copy_dataset_chunked_sparse(fapl);
-#ifdef H5_HAVE_FILTER_DEFLATE
nerrors += test_copy_dataset_compressed(fapl);
-#endif /* H5_HAVE_FILTER_DEFLATE */
nerrors += test_copy_dataset_compact(fapl);
nerrors += test_copy_dataset_external(fapl);
nerrors += test_copy_dataset_named_dtype(fapl);
@@ -3395,12 +4374,20 @@ main(void)
nerrors += test_copy_dataset_named_dtype_hier_outside(fapl);
nerrors += test_copy_dataset_multi_ohdr_chunks(fapl);
nerrors += test_copy_dataset_attr_named_dtype(fapl);
- nerrors += test_copy_dataset_vl(fapl); /* TODO */
+ nerrors += test_copy_dataset_contig_vl(fapl);
+ nerrors += test_copy_dataset_chunked_vl(fapl); /* TODO */
+/* TODO: Add more tests for copying vlen data */
nerrors += test_copy_group_empty(fapl);
nerrors += test_copy_group(fapl);
nerrors += test_copy_group_deep(fapl);
nerrors += test_copy_group_loop(fapl);
- nerrors += test_copy_link(fapl);
+ nerrors += test_copy_group_wide_loop(fapl);
+ nerrors += test_copy_group_links(fapl);
+ nerrors += test_copy_soft_link(fapl);
+ nerrors += test_copy_exist(fapl);
+ nerrors += test_copy_path(fapl);
+ nerrors += test_copy_same_file_named_datatype(fapl);
+/* TODO: Add more tests for copying objects in same file */
nerrors += test_copy_mount(fapl); /* TODO */
/* TODO: Add more tests for copying objects in mounted files */