summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/objcopy.c189
1 files changed, 161 insertions, 28 deletions
diff --git a/test/objcopy.c b/test/objcopy.c
index aca041f..61963b5 100755
--- a/test/objcopy.c
+++ b/test/objcopy.c
@@ -55,7 +55,8 @@ const char *FILENAME[] = {
#define CONFIG_SHARE_SRC 1
#define CONFIG_SHARE_DST 2
#define CONFIG_NEW_FORMAT 4
-#define MAX_CONFIGURATION 7
+#define CONFIG_DENSE 8
+#define MAX_CONFIGURATION 15
#define FILE_EXT "objcopy_ext.dat"
/* The fill_old.h5 is generated from gen_old_fill.c in HDF5 'test' directory
@@ -69,6 +70,7 @@ const char *FILENAME[] = {
#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_SIMPLE2 "dataset_simple_copy"
#define NAME_DATASET_COMPOUND "dataset_compound"
#define NAME_DATASET_CHUNKED "dataset_chunked"
#define NAME_DATASET_COMPACT "dataset_compact"
@@ -104,7 +106,6 @@ const char *FILENAME[] = {
#define NAME_OLD_FORMAT "/dset1"
#define NAME_BUF_SIZE 1024
-#define NUM_ATTRIBUTES 4
#define ATTR_NAME_LEN 80
#define DIM_SIZE_1 12
#define DIM_SIZE_2 6
@@ -116,6 +117,8 @@ const char *FILENAME[] = {
char src_obj_full_name[215]; /* the full path + name of the object to be copied */
+int num_attributes_g; /* Number of attributes created */
+
/* Table containing object id and object name */
/* (Used for detecting duplicate objects when comparing groups */
static struct {
@@ -535,7 +538,7 @@ test_copy_attach_attributes(hid_t loc_id, hid_t type_id)
if((sid = H5Screate_simple(1, &dim1, NULL)) < 0 )
goto done;
- for (i=0; i<NUM_ATTRIBUTES; i++) {
+ for (i=0; i<num_attributes_g; i++) {
sprintf(attr_name, "%d attr", i);
/* Set attribute data */
@@ -588,7 +591,7 @@ test_copy_attach_paired_attributes(hid_t loc_id, hid_t loc_id2, hid_t type_id)
if((sid = H5Screate_simple(1, &dim1, NULL)) < 0 ) goto done;
- for (i=0; i<NUM_ATTRIBUTES; i++) {
+ for (i=0; i<num_attributes_g; i++) {
sprintf(attr_name, "%d attr", i);
/* Set attribute data */
@@ -1779,6 +1782,112 @@ error:
/*-------------------------------------------------------------------------
+ * Function: test_copy_dataset_simple_samefile
+ *
+ * Purpose: Create a simple dataset in SRC file and copy it to SRC file
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ * Programmer: Neil Fortner
+ * Thursday, January 15, 2009
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_copy_dataset_simple_samefile(hid_t fcpl, hid_t fapl, int config)
+{
+ hid_t fid = -1; /* File ID */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t did = -1, did2 = -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 */
+ char filename[NAME_BUF_SIZE];
+
+ TESTING("H5Ocopy(): simple dataset within the same file");
+
+ /* 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, filename, sizeof filename);
+
+ /* Reset file address checking info */
+ addr_reset();
+
+ /* create source file */
+ if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, 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 = H5Dcreate2(fid, NAME_DATASET_SIMPLE, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, 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) < 0) TEST_ERROR
+
+
+ /* open the source file with read-write */
+ if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR
+
+ /* copy the dataset from SRC to DST */
+ if(H5Ocopy(fid, NAME_DATASET_SIMPLE, fid, NAME_DATASET_SIMPLE2, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* open the dataset for copy */
+ if((did = H5Dopen2(fid, NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* open the destination dataset */
+ if((did2 = H5Dopen2(fid, NAME_DATASET_SIMPLE2, H5P_DEFAULT)) < 0) TEST_ERROR
+
+ /* Check if the datasets are equal */
+ if(compare_datasets(did, did2, H5P_DEFAULT, 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) < 0) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Dclose(did2);
+ H5Dclose(did);
+ H5Sclose(sid);
+ H5Fclose(fid);
+ } H5E_END_TRY;
+ return 1;
+} /* end test_copy_dataset_simple_samefile */
+
+
+/*-------------------------------------------------------------------------
* Function: test_copy_dataset_simple_empty
*
* Purpose: Create a simple dataset in SRC file and copy it to DST file
@@ -7150,7 +7259,8 @@ main(void)
{
int nerrors = 0;
hid_t fapl, fapl2;
- hid_t fcpl_shared;
+ hid_t fcpl_shared, ocpl;
+ unsigned max_compact, min_dense;
int configuration; /* Configuration of tests. */
int ExpressMode;
@@ -7173,6 +7283,11 @@ main(void)
if(H5Pset_shared_mesg_nindexes(fcpl_shared, 1) < 0) TEST_ERROR
if(H5Pset_shared_mesg_index(fcpl_shared, 0, H5O_SHMESG_ALL_FLAG, (size_t) 10) < 0) TEST_ERROR
+ /* Obtain the default attribute storage phase change values */
+ if((ocpl = H5Pcreate(H5P_OBJECT_CREATE)) < 0) TEST_ERROR
+ if(H5Pget_attr_phase_change(ocpl, &max_compact, &min_dense) < 0) TEST_ERROR
+ if(H5Pclose(ocpl) < 0) TEST_ERROR
+
/* Test in all configurations */
for(configuration = 0; configuration <= MAX_CONFIGURATION; configuration++) {
hid_t my_fapl;
@@ -7207,40 +7322,29 @@ main(void)
my_fapl = fapl;
} /* end else */
+ /* Test with and without dense attributes */
+ if(configuration & CONFIG_DENSE) {
+ puts("Testing with dense attributes:");
+ num_attributes_g = max_compact + 1;
+ }
+ else {
+ puts("Testing without dense attributes:");
+ num_attributes_g = MAX(min_dense, 2) - 1;
+ }
/* The tests... */
- nerrors += test_copy_named_datatype(fcpl_src, fcpl_dst, my_fapl);
- nerrors += test_copy_named_datatype_vl(fcpl_src, fcpl_dst, my_fapl);
- nerrors += test_copy_named_datatype_vl_vl(fcpl_src, fcpl_dst, my_fapl);
nerrors += test_copy_dataset_simple(fcpl_src, fcpl_dst, my_fapl);
+ nerrors += test_copy_dataset_simple_samefile(fcpl_src, my_fapl, configuration);
nerrors += test_copy_dataset_simple_empty(fcpl_src, fcpl_dst, my_fapl);
nerrors += test_copy_dataset_compound(fcpl_src, fcpl_dst, my_fapl);
nerrors += test_copy_dataset_chunked(fcpl_src, fcpl_dst, my_fapl);
-
nerrors += test_copy_dataset_chunked_empty(fcpl_src, fcpl_dst, my_fapl);
nerrors += test_copy_dataset_chunked_sparse(fcpl_src, fcpl_dst, my_fapl);
nerrors += test_copy_dataset_compressed(fcpl_src, fcpl_dst, my_fapl);
nerrors += test_copy_dataset_compact(fcpl_src, fcpl_dst, my_fapl);
- nerrors += test_copy_dataset_external(fcpl_src, fcpl_dst, my_fapl);
- nerrors += test_copy_dataset_named_dtype(fcpl_src, fcpl_dst, my_fapl);
- nerrors += test_copy_dataset_named_dtype_hier(fcpl_src, fcpl_dst, my_fapl);
- nerrors += test_copy_dataset_named_dtype_hier_outside(fcpl_src, fcpl_dst, my_fapl);
nerrors += test_copy_dataset_multi_ohdr_chunks(fcpl_src, fcpl_dst, my_fapl);
nerrors += test_copy_dataset_attr_named_dtype(fcpl_src, fcpl_dst, my_fapl);
- nerrors += test_copy_dataset_contig_vl(fcpl_src, fcpl_dst, my_fapl);
- nerrors += test_copy_dataset_chunked_vl(fcpl_src, fcpl_dst, my_fapl);
- nerrors += test_copy_dataset_compact_vl(fcpl_src, fcpl_dst, my_fapl);
- nerrors += test_copy_dataset_compressed_vl(fcpl_src, fcpl_dst, my_fapl);
- nerrors += test_copy_attribute_vl(fcpl_src, fcpl_dst, my_fapl);
- nerrors += test_copy_dataset_compact_named_vl(fcpl_src, fcpl_dst, my_fapl);
- nerrors += test_copy_dataset_contig_named_vl(fcpl_src, fcpl_dst, my_fapl);
- nerrors += test_copy_dataset_chunked_named_vl(fcpl_src, fcpl_dst, my_fapl);
- nerrors += test_copy_dataset_compressed_named_vl(fcpl_src, fcpl_dst, my_fapl);
- nerrors += test_copy_dataset_compact_vl_vl(fcpl_src, fcpl_dst, my_fapl);
- nerrors += test_copy_dataset_contig_vl_vl(fcpl_src, fcpl_dst, my_fapl);
- nerrors += test_copy_dataset_chunked_vl_vl(fcpl_src, fcpl_dst, my_fapl);
- nerrors += test_copy_dataset_compressed_vl_vl(fcpl_src, fcpl_dst, my_fapl);
nerrors += test_copy_group_empty(fcpl_src, fcpl_dst, my_fapl);
nerrors += test_copy_root_group(fcpl_src, fcpl_dst, my_fapl);
nerrors += test_copy_group(fcpl_src, fcpl_dst, my_fapl);
@@ -7254,8 +7358,7 @@ main(void)
#endif /* H5_CANNOT_OPEN_TWICE */
nerrors += test_copy_exist(fcpl_src, fcpl_dst, my_fapl);
nerrors += test_copy_path(fcpl_src, fcpl_dst, my_fapl);
- nerrors += test_copy_same_file_named_datatype(fcpl_src, my_fapl);
- nerrors += test_copy_old_layout(fcpl_dst, my_fapl);
+
nerrors += test_copy_option(fcpl_src, fcpl_dst, my_fapl, H5O_COPY_WITHOUT_ATTR_FLAG,
FALSE, "H5Ocopy(): without attributes");
nerrors += test_copy_option(fcpl_src, fcpl_dst, my_fapl, 0, TRUE,
@@ -7271,6 +7374,36 @@ main(void)
nerrors += test_copy_option(fcpl_src, fcpl_dst, my_fapl, H5O_COPY_WITHOUT_ATTR_FLAG |
H5O_COPY_PRESERVE_NULL_FLAG, TRUE, "H5Ocopy(): preserve NULL messages");
+ /* Tests that do not use attributes and do not need to be tested
+ * multiple times for different attribute configurations */
+ if(configuration < CONFIG_DENSE) {
+ nerrors += test_copy_named_datatype(fcpl_src, fcpl_dst, my_fapl);
+ nerrors += test_copy_named_datatype_vl(fcpl_src, fcpl_dst, my_fapl);
+ nerrors += test_copy_named_datatype_vl_vl(fcpl_src, fcpl_dst, my_fapl);
+
+ nerrors += test_copy_dataset_external(fcpl_src, fcpl_dst, my_fapl);
+ nerrors += test_copy_dataset_named_dtype(fcpl_src, fcpl_dst, my_fapl);
+ nerrors += test_copy_dataset_named_dtype_hier(fcpl_src, fcpl_dst, my_fapl);
+ nerrors += test_copy_dataset_named_dtype_hier_outside(fcpl_src, fcpl_dst, my_fapl);
+
+ nerrors += test_copy_dataset_contig_vl(fcpl_src, fcpl_dst, my_fapl);
+ nerrors += test_copy_dataset_chunked_vl(fcpl_src, fcpl_dst, my_fapl);
+ nerrors += test_copy_dataset_compact_vl(fcpl_src, fcpl_dst, my_fapl);
+ nerrors += test_copy_dataset_compressed_vl(fcpl_src, fcpl_dst, my_fapl);
+ nerrors += test_copy_attribute_vl(fcpl_src, fcpl_dst, my_fapl);
+ nerrors += test_copy_dataset_compact_named_vl(fcpl_src, fcpl_dst, my_fapl);
+ nerrors += test_copy_dataset_contig_named_vl(fcpl_src, fcpl_dst, my_fapl);
+ nerrors += test_copy_dataset_chunked_named_vl(fcpl_src, fcpl_dst, my_fapl);
+ nerrors += test_copy_dataset_compressed_named_vl(fcpl_src, fcpl_dst, my_fapl);
+ nerrors += test_copy_dataset_compact_vl_vl(fcpl_src, fcpl_dst, my_fapl);
+ nerrors += test_copy_dataset_contig_vl_vl(fcpl_src, fcpl_dst, my_fapl);
+ nerrors += test_copy_dataset_chunked_vl_vl(fcpl_src, fcpl_dst, my_fapl);
+ nerrors += test_copy_dataset_compressed_vl_vl(fcpl_src, fcpl_dst, my_fapl);
+
+ nerrors += test_copy_same_file_named_datatype(fcpl_src, my_fapl);
+ nerrors += test_copy_old_layout(fcpl_dst, my_fapl);
+ }
+
/* TODO: not implemented
nerrors += test_copy_option(my_fapl, H5O_COPY_EXPAND_EXT_LINK_FLAG, FALSE, "H5Ocopy: expand external link");
nerrors += test_copy_mount(my_fapl);