summaryrefslogtreecommitdiffstats
path: root/tools/h5dump
diff options
context:
space:
mode:
Diffstat (limited to 'tools/h5dump')
-rw-r--r--tools/h5dump/h5dumpgentest.c93
-rw-r--r--tools/h5dump/testh5dump.sh.in1
2 files changed, 57 insertions, 37 deletions
diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c
index 75d9b60..2d4a620 100644
--- a/tools/h5dump/h5dumpgentest.c
+++ b/tools/h5dump/h5dumpgentest.c
@@ -236,6 +236,13 @@ typedef struct s1_t {
/* "File 51" macros */
#define F51_MAX_NAME_LEN ((64*1024)+1024)
+/* "File 64" macros */
+#define F64_FILE "tarray8.h5"
+#define F64_DATASET "DS1"
+#define F64_DIM0 1
+#define F64_ARRAY_BUF_LEN (4*1024)
+#define F64_DIM1 (F64_ARRAY_BUF_LEN / sizeof(int) + 1)
+
static void
gent_group(void)
{
@@ -2813,48 +2820,59 @@ static void gent_array7(void)
assert(ret >= 0);
}
+/* Test the boundary of the display output buffer at the reallocation event */
static void gent_array8(void)
{
- int *buf; /* information to write */
- hid_t fid; /* HDF5 File ID */
- hid_t did; /* dataset ID */
- hid_t sid; /* dataspace ID */
- hid_t tid; /* datatype ID */
- size_t size;
- hsize_t sdims[] = {1};
- hsize_t tdims[] = {H5TOOLS_BUFSIZE / sizeof(int) + 1};
- int i;
- herr_t ret;
-
- size = ( H5TOOLS_BUFSIZE / sizeof(int) + 1 ) * sizeof(int);
- buf = malloc( size );
-
- for( i = 0; i < H5TOOLS_BUFSIZE / sizeof(int) + 1; i++)
- buf[i] = i;
-
- /* create file */
- fid = H5Fcreate(FILE64, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
-
- /* create a type larger than H5TOOLS_BUFSIZE */
- tid = H5Tarray_create2(H5T_NATIVE_INT, 1, tdims);
- size = H5Tget_size(tid);
- sid = H5Screate_simple(1, sdims, NULL);
- did = H5Dcreate2(fid, "dset", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- ret = H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf);
- assert(ret >= 0);
+ hid_t file = -1; /* Handles */
+ hid_t filetype = -1; /* Handles */
+ hid_t space = -1; /* Handles */
+ hid_t dset = -1; /* Handles */
+ herr_t status = -1;
+ hsize_t sdims[] = {F64_DIM0};
+ hsize_t tdims[] = {F64_DIM1};
+ int wdata[(F64_DIM1) * sizeof(int)]; /* Write buffer */
+ int ndims;
+ int i;
+ /*
+ * Initialize data. i is the element in the dataspace, j and k the
+ * elements within the array datatype.
+ */
+ for (i=0; i<F64_DIM1; i++)
+ wdata[i] = i;
- /* close */
- ret = H5Dclose(did);
- assert(ret >= 0);
- ret = H5Tclose(tid);
- assert(ret >= 0);
- ret = H5Sclose(sid);
- assert(ret >= 0);
+ /*
+ * Create a new file using the default properties.
+ */
+ file = H5Fcreate (F64_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- ret = H5Fclose(fid);
- assert(ret >= 0);
- free( buf );
+ /*
+ * Create array datatypes for file and memory.
+ */
+ filetype = H5Tarray_create (H5T_NATIVE_INT, 1, tdims);
+
+ /*
+ * Create dataspace. Setting maximum size to NULL sets the maximum
+ * size to be the current size.
+ */
+ space = H5Screate_simple (1, sdims, NULL);
+
+ /*
+ * Create the dataset and write the array data to it.
+ */
+ if(file>=0 && filetype>=0 && space>=0) {
+ dset = H5Dcreate (file, F64_DATASET, filetype, space, H5P_DEFAULT, H5P_DEFAULT,
+ H5P_DEFAULT);
+ if(dset>=0)
+ status = H5Dwrite (dset, filetype, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata);
+ }
+ /*
+ * Close and release resources.
+ */
+ status = H5Dclose (dset);
+ status = H5Sclose (space);
+ status = H5Tclose (filetype);
+ status = H5Fclose (file);
}
static void gent_empty(void)
@@ -6348,6 +6366,7 @@ int main(void)
gent_array5();
gent_array6();
gent_array7();
+ gent_array8();
gent_empty();
gent_group_comments();
gent_split_file();
diff --git a/tools/h5dump/testh5dump.sh.in b/tools/h5dump/testh5dump.sh.in
index 748b165..5bf7f75 100644
--- a/tools/h5dump/testh5dump.sh.in
+++ b/tools/h5dump/testh5dump.sh.in
@@ -300,6 +300,7 @@ TOOLTEST tarray4.ddl tarray4.h5
TOOLTEST tarray5.ddl tarray5.h5
TOOLTEST tarray6.ddl tarray6.h5
TOOLTEST tarray7.ddl tarray7.h5
+TOOLTEST tarray8.ddl tarray8.h5
# test for files with empty data
TOOLTEST tempty.ddl tempty.h5