summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVailin Choi <vchoi@hdfgroup.org>2016-08-05 20:13:54 (GMT)
committerVailin Choi <vchoi@hdfgroup.org>2016-08-05 20:13:54 (GMT)
commit4d358ef0afa1e9ffef8351031242710080389eff (patch)
tree8b38f574b7b55b38c5033459dfb9d3ab3c3ed342
parenta4e4094c766348c296d0dd8e1af38e28492528bf (diff)
downloadhdf5-4d358ef0afa1e9ffef8351031242710080389eff.zip
hdf5-4d358ef0afa1e9ffef8351031242710080389eff.tar.gz
hdf5-4d358ef0afa1e9ffef8351031242710080389eff.tar.bz2
[svn-r30262] Fix for HDFFV-9960: H5DOappend will not fail if a dataset has no append callback registered.
Tested on mayll, platypus, osx1010test, emu, moohan, kituo, ostrich, kite, quail.
-rw-r--r--hl/src/H5DO.c9
-rw-r--r--hl/test/test_dset_append.c100
2 files changed, 106 insertions, 3 deletions
diff --git a/hl/src/H5DO.c b/hl/src/H5DO.c
index bfadfaa..f59f2ca 100644
--- a/hl/src/H5DO.c
+++ b/hl/src/H5DO.c
@@ -165,7 +165,7 @@ H5DOappend(hid_t dset_id, hid_t dxpl_id, unsigned axis, size_t extension,
created_dxpl = TRUE;
} /* end if */
else if(TRUE != H5Pisa_class(dxpl_id, H5P_DATASET_XFER))
- goto done;
+ goto done;
/* Get the dataspace of the dataset */
if(FAIL == (space_id = H5Dget_space(dset_id)))
@@ -219,7 +219,8 @@ H5DOappend(hid_t dset_id, hid_t dxpl_id, unsigned axis, size_t extension,
nelmts = (hsize_t)snelmts;
/* create a memory space */
- mem_space_id = H5Screate_simple(1, &nelmts, NULL);
+ if(FAIL == (mem_space_id = H5Screate_simple(1, &nelmts, NULL)))
+ goto done;
/* Write the data */
if(H5Dwrite(dset_id, memtype, mem_space_id, new_space_id, dxpl_id, buf) < 0)
@@ -237,8 +238,10 @@ H5DOappend(hid_t dset_id, hid_t dxpl_id, unsigned axis, size_t extension,
goto done;
/* No boundary for this axis */
- if(boundary[axis] == 0)
+ if(boundary[axis] == 0) {
+ ret_value = SUCCEED;
goto done;
+ }
/* Determine whether a boundary is hit or not */
for(k = start[axis]; k < size[axis]; k++)
diff --git a/hl/test/test_dset_append.c b/hl/test/test_dset_append.c
index 57dab81..62e86cb 100644
--- a/hl/test/test_dset_append.c
+++ b/hl/test/test_dset_append.c
@@ -27,6 +27,7 @@
#endif
#define FILE "test_append.h5"
+#define DNAME_NOTSET "dataset_notset"
#define DNAME_UNLIM "dataset_unlim"
#define DNAME_LESS "dataset_less"
#define DNAME_VARY "dataset_vary"
@@ -35,6 +36,103 @@
#define DBUGNAME1 "dataset_bug1"
#define DBUGNAME2 "dataset_bug2"
+/*-------------------------------------------------------------------------
+ * Function: test_dataset_append_notset
+ *
+ * Purpose: Verify that H5DOappend works properly with default dapl.
+ * That is, H5Pset_append_flush() is not used to set boundary
+ * and callback in dapl.
+ *
+ * Return: Success: 0
+ * Failure: 1
+ *
+ * Programmer: Vailin Choi; Aug 2016
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_dataset_append_notset(hid_t fid)
+{
+ hid_t did = -1; /* Dataset ID */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t dcpl = -1; /* A copy of dataset creation property */
+ hid_t dapl = -1; /* A copy of dataset access property */
+ hid_t ffapl = -1; /* The file's file access property list */
+
+ hsize_t dims[2] = {0, 10}; /* Current dimension sizes */
+ hsize_t maxdims[2] = {H5S_UNLIMITED, 20}; /* Maximum dimension sizes */
+ hsize_t chunk_dims[2] = {2,5}; /* Chunk dimension sizes */
+ int lbuf[10]; /* The data buffers */
+ hsize_t file_size; /* File size */
+ int i, j; /* Local index variables */
+ h5_stat_t sb1, sb2; /* File info */
+
+ TESTING("Append flush with H5DOappend()--append rows with default dapl");
+
+ /* Get the file's file access property list */
+ if((ffapl = H5Fget_access_plist(fid)) < 0)
+ FAIL_STACK_ERROR;
+
+ /* Set to create a chunked dataset with extendible dimensions */
+ if((sid = H5Screate_simple(2, dims, maxdims)) < 0)
+ FAIL_STACK_ERROR;
+ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ FAIL_STACK_ERROR;
+ if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0)
+ FAIL_STACK_ERROR;
+
+ /* Create the dataset */
+ if((did = H5Dcreate2(fid, DNAME_NOTSET, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR;
+
+ /* Append 6 rows to the dataset */
+ for(i = 0; i < 6; i++) {
+ for(j = 0; j < 10; j++)
+ lbuf[j] = (i * 10) + (j + 1);
+ /* Append without boundary, callback and flush */
+ if(H5DOappend(did, H5P_DEFAULT, 0, (size_t)1, H5T_NATIVE_INT, lbuf) < 0)
+ FAIL_STACK_ERROR;
+ } /* end for */
+
+ /* File size when not flushed */
+ if(HDstat(FILE, &sb1) < 0)
+ TEST_ERROR;
+
+ /* Close the dataset */
+ if(H5Dclose(did) < 0)
+ FAIL_STACK_ERROR;
+
+ /* File size after flushing */
+ if(HDstat(FILE, &sb2) < 0)
+ TEST_ERROR;
+
+ /* File size before flushing should be less */
+ if(sb1.st_size > sb2.st_size)
+ TEST_ERROR;
+
+ /* Closing */
+ if(H5Sclose(sid) < 0)
+ FAIL_STACK_ERROR;
+ if(H5Pclose(dcpl) < 0)
+ FAIL_STACK_ERROR;
+ if(H5Pclose(ffapl) < 0)
+ FAIL_STACK_ERROR;
+
+ PASSED();
+
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Pclose(dcpl);
+ H5Pclose(sid);
+ H5Dclose(did);
+ H5Pclose(ffapl);
+ } H5E_END_TRY;
+
+ return 1;
+} /* test_dataset_append_notset() */
+
/* The callback function for the object flush property */
static herr_t
flush_func(hid_t H5_ATTR_UNUSED obj_id, void *_udata)
@@ -1150,6 +1248,8 @@ int main(void)
if((fid = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
FAIL_STACK_ERROR;
+ nerrors += test_dataset_append_notset(fid);
+
nerrors += test_dataset_append_rows(fid);
flush_ct = 0; /* Reset flush counter */