summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2004-09-27 18:06:14 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2004-09-27 18:06:14 (GMT)
commitdde6dbe652e4cf64278cf2881e9d8634a8568f70 (patch)
tree6fcc4e40426b3229dadaa0ba1c0120d9671cecab /test
parent68b13b11477aec16974d831ae3abcb6526a9b156 (diff)
downloadhdf5-dde6dbe652e4cf64278cf2881e9d8634a8568f70.zip
hdf5-dde6dbe652e4cf64278cf2881e9d8634a8568f70.tar.gz
hdf5-dde6dbe652e4cf64278cf2881e9d8634a8568f70.tar.bz2
[svn-r9323] Purpose:
Bug fix Description: Fix situation where deleting a chunked datasets with B-tree nodes that weren't in the metadata cache would die with a core dump. Platforms tested: FreeBSD 4.10 (sleipnir) Linux 2.4 (heping) Solaris 2.7 (arabica)
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.in2
-rw-r--r--test/unlink.c97
2 files changed, 98 insertions, 1 deletions
diff --git a/test/Makefile.in b/test/Makefile.in
index e4bb65c..b55cd28 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -61,7 +61,7 @@ MOSTLYCLEAN=cmpd_dset.h5 compact_dataset.h5 dataset.h5 extend.h5 istore.h5 \
getname.h5 getname1.h5 getname2.h5 getname3.h5 sec2_file.h5 \
family_file000[0-3][0-9].h5 multi_file-[rs].h5 core_file \
new_move_[ab].h5 ntypes.h5 dangle.h5 test_filters.h5 \
- get_file_name.h5 tstint[1-2].h5
+ get_file_name.h5 tstint[1-2].h5 unlink_chunked.h5
CLEAN=$(TIMINGS)
diff --git a/test/unlink.c b/test/unlink.c
index f87b6fb..a2cd391 100644
--- a/test/unlink.c
+++ b/test/unlink.c
@@ -30,6 +30,7 @@ const char *FILENAME[] = {
"filespace",
"slashes",
"resurrect",
+ "unlink_chunked",
NULL
};
@@ -1857,6 +1858,7 @@ test_resurrect_dataset(void)
/* Close things */
if(H5Dclose(d)<0) TEST_ERROR;
if(H5Fclose(f)<0) TEST_ERROR;
+ if(H5Pclose(fapl)<0) TEST_ERROR;
PASSED();
return 0;
@@ -1866,12 +1868,104 @@ error:
H5Sclose(s);
H5Dclose(d);
H5Fclose(f);
+ H5Pclose(fapl);
} H5E_END_TRY;
return 1;
} /* end test_resurrect_dataset() */
/*-------------------------------------------------------------------------
+ * Function: test_unlink_chunked_dataset
+ *
+ * Purpose: Tests deleting a chunked dataset
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ * Programmer: Quincey Koziol
+ * Monday, September 27, 2004
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_unlink_chunked_dataset(void)
+{
+ hid_t fapl_id=-1;
+ hid_t file_id=-1;
+ hid_t dset_id=-1;
+ hid_t space_id=-1;
+ hid_t dcpl_id=-1;
+ hsize_t dims[FILESPACE_NDIMS]={FILESPACE_DIM0,FILESPACE_DIM1,FILESPACE_DIM2};
+ hsize_t max_dims[FILESPACE_NDIMS]={H5S_UNLIMITED,H5S_UNLIMITED,H5S_UNLIMITED};
+ hsize_t chunk_dims[FILESPACE_NDIMS]={FILESPACE_CHUNK0,FILESPACE_CHUNK1,FILESPACE_CHUNK2};
+ char filename[1024];
+
+ TESTING("Unlinking chunked dataset");
+
+ /* Create file */
+ fapl_id = h5_fileaccess();
+ h5_fixname(FILENAME[7], fapl_id, filename, sizeof filename);
+
+ /* Create the file */
+ if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id))<0) TEST_ERROR;
+
+ /* Create the dataspace */
+ if((space_id=H5Screate_simple(FILESPACE_NDIMS,dims,max_dims))<0) TEST_ERROR;
+
+ /* Create the dataset creation filter */
+ if((dcpl_id=H5Pcreate(H5P_DATASET_CREATE))<0) TEST_ERROR;
+
+ /* Set to chunked storage */
+ if(H5Pset_chunk(dcpl_id,FILESPACE_NDIMS,chunk_dims)<0) TEST_ERROR;
+
+ /* Set to early space allocation */
+ if(H5Pset_alloc_time(dcpl_id,H5D_ALLOC_TIME_EARLY)<0) TEST_ERROR;
+
+ /* Create the dataset */
+ if((dset_id = H5Dcreate(file_id,DATASETNAME,H5T_NATIVE_INT,space_id,dcpl_id))<0) TEST_ERROR;
+
+ /* Close the dataspace */
+ if(H5Sclose(space_id)<0) TEST_ERROR;
+
+ /* Close the dataset creation property list */
+ if(H5Pclose(dcpl_id)<0) TEST_ERROR;
+
+ /* Close the dataset */
+ if(H5Dclose(dset_id)<0) TEST_ERROR;
+
+ /* Close the file */
+ if(H5Fclose(file_id)<0) TEST_ERROR;
+
+ /* Re-open the file */
+ if((file_id = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT))<0) TEST_ERROR;
+
+ /* Delete the dataset */
+ if(H5Gunlink(file_id, DATASETNAME)<0) TEST_ERROR;
+
+ /* Close the file */
+ if(H5Fclose(file_id)<0) TEST_ERROR;
+
+ /* Close the file access property list */
+ if(H5Pclose(fapl_id)<0) TEST_ERROR;
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Pclose(dcpl_id);
+ H5Sclose(space_id);
+ H5Dclose(dset_id);
+ H5Fclose(file_id);
+ H5Pclose(fapl_id);
+ } H5E_END_TRY;
+ return 1;
+} /* end test_unlink_chunked_dataset() */
+
+
+/*-------------------------------------------------------------------------
* Function: main
*
* Purpose: Test H5Gunlink()
@@ -1951,6 +2045,9 @@ main(void)
/* Test "resurrecting" objects */
nerrors += test_resurrect_dataset();
+ /* Test unlinking chunked datasets */
+ nerrors += test_unlink_chunked_dataset();
+
/* Close */
if (H5Fclose(file)<0) TEST_ERROR;
if (nerrors) {