summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2011-07-18 22:43:30 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2011-07-18 22:43:30 (GMT)
commitde106315771c4c227c4e73d9194494a240b92fd2 (patch)
tree16aa02432eba532a89f5421e29f492a2801685be /test
parent69d7f7312a6664d1f0ce4d617f08fee7f0154442 (diff)
downloadhdf5-de106315771c4c227c4e73d9194494a240b92fd2.zip
hdf5-de106315771c4c227c4e73d9194494a240b92fd2.tar.gz
hdf5-de106315771c4c227c4e73d9194494a240b92fd2.tar.bz2
[svn-r21120] Description:
Check in ugly version of fix for Jira #7638. I'm going to leave the issue open in Jira and when the library has been refactored to use shared file pointers (instead of top file pointers) for file operations, I'll uncomment the check in src/H5Oshared.c Tested on: Mac OS X/32 10.6.8 (amazon) w/debug (too small for h5committest)
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.am2
-rw-r--r--test/Makefile.in2
-rw-r--r--test/dtypes.c199
3 files changed, 201 insertions, 2 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index 26b527c..afc1b37 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -112,7 +112,7 @@ CHECK_CLEANFILES+=accum.h5 cmpd_dset.h5 compact_dataset.h5 dataset.h5 dset_offse
stab.h5 extern_[1-3].h5 extern_[1-4][ab].raw gheap[0-4].h5 \
dt_arith[1-2] links.h5 links[0-6]*.h5 extlinks[0-15].h5 tmp \
big.data big[0-9][0-9][0-9][0-9][0-9].h5 \
- stdio.h5 sec2.h5 dtypes[1-8].h5 dt_arith[1-2].h5 tattr.h5 \
+ stdio.h5 sec2.h5 dtypes[0-9].h5 dt_arith[1-2].h5 tattr.h5 \
tselect.h5 mtime.h5 unlink.h5 unicode.h5 coord.h5 \
fillval_[0-9].h5 fillval.raw mount_[0-9].h5 testmeta.h5 ttime.h5 \
trefer[1-3].h5 tvltypes.h5 tvlstr.h5 tvlstr2.h5 flush.h5 \
diff --git a/test/Makefile.in b/test/Makefile.in
index 6a5bf6a..c5b6f81 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -741,7 +741,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog accum.h5 cmpd_dset.h5 \
extern_[1-4][ab].raw gheap[0-4].h5 dt_arith[1-2] links.h5 \
links[0-6]*.h5 extlinks[0-15].h5 tmp big.data \
big[0-9][0-9][0-9][0-9][0-9].h5 stdio.h5 sec2.h5 \
- dtypes[1-8].h5 dt_arith[1-2].h5 tattr.h5 tselect.h5 mtime.h5 \
+ dtypes[0-9].h5 dt_arith[1-2].h5 tattr.h5 tselect.h5 mtime.h5 \
unlink.h5 unicode.h5 coord.h5 fillval_[0-9].h5 fillval.raw \
mount_[0-9].h5 testmeta.h5 ttime.h5 trefer[1-3].h5 tvltypes.h5 \
tvlstr.h5 tvlstr2.h5 flush.h5 enum1.h5 titerate.h5 ttsafe.h5 \
diff --git a/test/dtypes.c b/test/dtypes.c
index fbb552d..601b46a 100644
--- a/test/dtypes.c
+++ b/test/dtypes.c
@@ -71,6 +71,7 @@
}
const char *FILENAME[] = {
+ "dtypes0",
"dtypes1",
"dtypes2",
"dtypes3",
@@ -79,6 +80,7 @@ const char *FILENAME[] = {
"dtypes6",
"dtypes7",
"dtypes8",
+ "dtypes9",
NULL
};
@@ -102,6 +104,11 @@ typedef enum dtype_t {
#define COMPOUND13_ARRAY_SIZE 256
#define COMPOUND13_ATTR_NAME "attr"
+/* Constants for delete_obj_named test */
+#define DEL_OBJ_NAMED_DATASET "/Dataset"
+#define DEL_OBJ_NAMED_NAMED_DTYPE "/Dtype"
+#define DEL_OBJ_NAMED_ATTRIBUTE "Attr"
+
/* Count opaque conversions */
static int num_opaque_conversions_g = 0;
@@ -6611,6 +6618,197 @@ error:
return 1;
} /* end test_named_indirect_reopen() */
+static void create_del_obj_named_test_file(const char *filename, hid_t fapl,
+ hbool_t new_format)
+{
+ hid_t file; /* File ID */
+ hid_t type; /* Datatype ID */
+ hid_t space; /* Dataspace ID */
+ hid_t attr; /* Attribute ID */
+ hid_t dset; /* Dataset ID */
+ hid_t fcpl; /* File creation property list ID */
+ hid_t my_fapl; /* Copy of file access property list ID */
+ hid_t dcpl; /* Dataset creation property list ID */
+ herr_t status; /* Generic return value */
+
+ /* Make copy of FAPL */
+ my_fapl = H5Pcopy(fapl);
+ assert(my_fapl > 0);
+
+ if(new_format) {
+ /* Use latest version of file format */
+ status = H5Pset_libver_bounds(my_fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST);
+ assert(status >= 0);
+ } /* end if */
+
+ /* Create a file creation property list (used for the root group's creation property list) */
+ fcpl = H5Pcreate(H5P_FILE_CREATE);
+ assert(fcpl > 0);
+
+ if(new_format) {
+ /* Use dense link storage for all links in root group */
+ status = H5Pset_link_phase_change(fcpl, 0, 0);
+ assert(status >= 0);
+ } /* end if */
+
+ /* Create file with attribute that uses committed datatype */
+ file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, my_fapl);
+ assert(file > 0);
+
+ /* Close FCPL */
+ status = H5Pclose(fcpl);
+ assert(status >= 0);
+
+ /* Close FAPL */
+ status = H5Pclose(my_fapl);
+ assert(status >= 0);
+
+ /* Create datatype to commit */
+ type = H5Tvlen_create(H5T_NATIVE_INT);
+ assert(type > 0);
+
+ /* Commit datatype */
+ status = H5Tcommit2(file, DEL_OBJ_NAMED_NAMED_DTYPE, type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ assert(status >= 0);
+
+ /* Create scalar dataspace */
+ space = H5Screate(H5S_SCALAR);
+ assert(space > 0);
+
+ /* Create a dataset creation property list */
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ assert(dcpl > 0);
+
+ if(new_format) {
+ /* Use dense attribute storage for all attributes on dataset */
+ status = H5Pset_attr_phase_change(dcpl, 0, 0);
+ assert(status >= 0);
+ } /* end if */
+
+ /* Create dataset */
+ dset = H5Dcreate2(file, DEL_OBJ_NAMED_DATASET, type, space, H5P_DEFAULT, dcpl, H5P_DEFAULT);
+ assert(dset > 0);
+
+ /* Close DCPL */
+ status = H5Pclose(dcpl);
+ assert(status >= 0);
+
+ /* Close dataset */
+ status = H5Dclose(dset);
+ assert(status >= 0);
+
+ /* Create attribute */
+ attr = H5Acreate_by_name(file, DEL_OBJ_NAMED_DATASET, DEL_OBJ_NAMED_ATTRIBUTE, type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ assert(attr > 0);
+
+ /* Close dataspace */
+ status = H5Sclose(space);
+ assert(status >= 0);
+
+ /* Close datatype */
+ status = H5Tclose(type);
+ assert(status >= 0);
+
+ /* Close attribute */
+ status = H5Aclose(attr);
+ assert(status >= 0);
+
+ /* Close file */
+ status = H5Fclose(file);
+ assert(status >= 0);
+} /* end create_del_obj_named_test_file() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_delete_obj_named
+ *
+ * Purpose: Tests that delete objects that use named datatypes through
+ * different file IDs
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ * Programmer: Quincey Koziol
+ * Monday, July 18, 2011
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_delete_obj_named(hid_t fapl)
+{
+ hid_t filea1 = -1, filea2 = -1, fileb = -1; /* File IDs */
+ hid_t attr = -1; /* Attribute ID */
+ hid_t dset = -1; /* Dataset ID */
+ hid_t fapl2 = -1; /* File access property list ID */
+ hbool_t new_format; /* Whether to use old or new format */
+ char filename[1024], filename2[1024];
+
+ TESTING("deleting objects that use named datatypes");
+
+ /* Set up filenames & FAPLs */
+ if((fapl2 = H5Pcopy(fapl)) < 0) FAIL_STACK_ERROR
+ h5_fixname(FILENAME[8], fapl, filename, sizeof filename);
+ h5_fixname(FILENAME[9], fapl2, filename2, sizeof filename2);
+
+ /* Loop over old & new format files */
+ for(new_format = FALSE; new_format <= TRUE; new_format++) {
+ /* Create test file, with attribute that uses committed datatype */
+ create_del_obj_named_test_file(filename, fapl, new_format);
+
+/* Test deleting dataset opened through different file ID */
+ if((filea1 = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+ if((filea2 = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+
+ if((dset = H5Dopen2(filea1, DEL_OBJ_NAMED_DATASET, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+ if(H5Dclose(dset) < 0) FAIL_STACK_ERROR
+
+ if(H5Fclose(filea1) < 0) FAIL_STACK_ERROR
+
+ if((fileb = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl2)) < 0) FAIL_STACK_ERROR
+
+ if(H5Ldelete(filea2, DEL_OBJ_NAMED_DATASET, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
+
+ if(H5Fclose(filea2) < 0) FAIL_STACK_ERROR
+ if(H5Fclose(fileb) < 0) FAIL_STACK_ERROR
+
+
+ /* Create test file, with attribute that uses committed datatype */
+ create_del_obj_named_test_file(filename, fapl, new_format);
+
+/* Test deleting attribute opened through different file ID */
+ if((filea1 = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+ if((filea2 = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+
+ if((attr = H5Aopen_by_name(filea1, DEL_OBJ_NAMED_DATASET, DEL_OBJ_NAMED_ATTRIBUTE, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+ if(H5Aclose(attr) < 0) FAIL_STACK_ERROR
+
+ if(H5Fclose(filea1) < 0) FAIL_STACK_ERROR
+
+ if((fileb = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl2)) < 0) FAIL_STACK_ERROR
+
+ if(H5Adelete_by_name(filea2, DEL_OBJ_NAMED_DATASET, DEL_OBJ_NAMED_ATTRIBUTE, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
+
+ if(H5Fclose(filea2) < 0) FAIL_STACK_ERROR
+ if(H5Fclose(fileb) < 0) FAIL_STACK_ERROR
+ } /* end for */
+
+ if(H5Pclose(fapl2) < 0) FAIL_STACK_ERROR
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Tclose(attr);
+ H5Dclose(dset);
+ H5Pclose(fapl2);
+ H5Fclose(filea1);
+ H5Fclose(filea2);
+ H5Fclose(fileb);
+ } H5E_END_TRY;
+ return 1;
+} /* end test_delete_obj_named() */
+
/*-------------------------------------------------------------------------
* Function: test_deprec
@@ -6805,6 +7003,7 @@ main(void)
nerrors += test_latest();
nerrors += test_int_float_except();
nerrors += test_named_indirect_reopen(fapl);
+ nerrors += test_delete_obj_named(fapl);
nerrors += test_set_order_compound(fapl);
nerrors += test_str_create();
#ifndef H5_NO_DEPRECATED_SYMBOLS