summaryrefslogtreecommitdiffstats
path: root/hl/test/test_ld.c
diff options
context:
space:
mode:
Diffstat (limited to 'hl/test/test_ld.c')
-rw-r--r--hl/test/test_ld.c1268
1 files changed, 636 insertions, 632 deletions
diff --git a/hl/test/test_ld.c b/hl/test/test_ld.c
index 7de409f..cc98fc9 100644
--- a/hl/test/test_ld.c
+++ b/hl/test/test_ld.c
@@ -1,15 +1,15 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-* Copyright by The HDF Group. *
-* Copyright by the Board of Trustees of the University of Illinois. *
-* All rights reserved. *
-* *
-* This file is part of HDF5. The full HDF5 copyright notice, including *
-* terms governing use, modification, and redistribution, is contained in *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
* distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
-* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "h5hltest.h"
#include "H5srcdir.h"
@@ -21,17 +21,17 @@
#define COPY_FILENAME "COPY_test_ld.h5"
/* Dataset names */
-#define DSET_ONE "DSET_ONE"
-#define DSET_ALLOC_LATE "DSET_ALLOC_LATE"
+#define DSET_ONE "DSET_ONE"
+#define DSET_ALLOC_LATE "DSET_ALLOC_LATE"
#define DSET_ALLOC_EARLY "DSET_ALLOC_EARLY"
-#define DSET_TWO "DSET_TWO"
-#define TWO_DIM_1 4
-#define TWO_DIM_2 10
-#define DSET_CMPD "DSET_CMPD"
-#define DSET_CMPD_ESC "DSET_CMPD_ESC"
-#define DSET_CMPD_TWO "DSET_CMPD_TWO"
-#define DSET_NULL "DSET_NULL"
-#define DSET_SCALAR "DSET_SCALAR"
+#define DSET_TWO "DSET_TWO"
+#define TWO_DIM_1 4
+#define TWO_DIM_2 10
+#define DSET_CMPD "DSET_CMPD"
+#define DSET_CMPD_ESC "DSET_CMPD_ESC"
+#define DSET_CMPD_TWO "DSET_CMPD_TWO"
+#define DSET_NULL "DSET_NULL"
+#define DSET_SCALAR "DSET_SCALAR"
/* Selected compound field members for testing */
#define VALID_FIELDS1 "field1,field2.a,field3,field4" /* TEMPORORAY */
@@ -52,7 +52,7 @@
* Test variations (retained original) for one-dimensional dataset:
* Varies from 10->13; 10->9, 10->10, 10->1, 10->11
*/
-#define ONE_NTESTS 5
+#define ONE_NTESTS 5
int one_tests[ONE_NTESTS] = {3, -1, 0, -9, 1};
/*
@@ -61,88 +61,92 @@ int one_tests[ONE_NTESTS] = {3, -1, 0, -9, 1};
* {4,10}->{3,12}; {4,10}->{3,9}; {4,10}->{3,10};
* {4,10}->{4,12}; {4,10}->{4,9}; {4,10}->{4,10}
*/
-#define TWO_NTESTS 9
-int two_tests[TWO_NTESTS][2] = { {2,2}, {2,-1}, {2,0},
- {-1,2}, {-1,-1}, {-1,0},
- {0,2}, {0,-1}, {0,0} };
-
+#define TWO_NTESTS 9
+int two_tests[TWO_NTESTS][2] = {{2, 2}, {2, -1}, {2, 0}, {-1, 2}, {-1, -1}, {-1, 0}, {0, 2}, {0, -1}, {0, 0}};
/* Verify that the two input values are the same */
-#define VERIFY_EQUAL(_x, _y) \
-{ \
- long __x = (long)_x, __y = (long)_y; \
- if(__x != __y) TEST_ERROR \
-}
+#define VERIFY_EQUAL(_x, _y) \
+ { \
+ long __x = (long)_x, __y = (long)_y; \
+ if (__x != __y) \
+ TEST_ERROR \
+ }
/* Temporary buffer for reading in the test file */
-#define TMP_BUF_SIZE 2048
-char g_tmp_buf[TMP_BUF_SIZE];
+#define TMP_BUF_SIZE 2048
+char g_tmp_buf[TMP_BUF_SIZE];
/* Macros for verifying compound fields */
/* Verify all fields */
-#define VERIFY_ELMTS_ALL(ent1, ent2) { \
- VERIFY_EQUAL(ent1.field1, ent2.field1); \
- VERIFY_EQUAL(ent1.field2.a, ent2.field2.a); \
- VERIFY_EQUAL(ent1.field2.b.a, ent2.field2.b.a); \
- VERIFY_EQUAL(ent1.field2.b.b, ent2.field2.b.b); \
- VERIFY_EQUAL(ent1.field2.b.c, ent2.field2.b.c); \
- VERIFY_EQUAL(ent1.field2.c, ent2.field2.c); \
- VERIFY_EQUAL(ent1.field3, ent2.field3); \
- VERIFY_EQUAL(ent1.field4.a, ent2.field4.a); \
-}
+#define VERIFY_ELMTS_ALL(ent1, ent2) \
+ { \
+ VERIFY_EQUAL(ent1.field1, ent2.field1); \
+ VERIFY_EQUAL(ent1.field2.a, ent2.field2.a); \
+ VERIFY_EQUAL(ent1.field2.b.a, ent2.field2.b.a); \
+ VERIFY_EQUAL(ent1.field2.b.b, ent2.field2.b.b); \
+ VERIFY_EQUAL(ent1.field2.b.c, ent2.field2.b.c); \
+ VERIFY_EQUAL(ent1.field2.c, ent2.field2.c); \
+ VERIFY_EQUAL(ent1.field3, ent2.field3); \
+ VERIFY_EQUAL(ent1.field4.a, ent2.field4.a); \
+ }
/* Verify fields selected in VALID_FIELDS1 */
-#define VERIFY_ELMTS_VALID1(ent1, ent2) { \
- VERIFY_EQUAL(ent1.field1, ent2.field1); \
- VERIFY_EQUAL(ent1.field2_a, ent2.field2.a); \
- VERIFY_EQUAL(ent1.field3, ent2.field3); \
- VERIFY_EQUAL(ent1.field4.a, ent2.field4.a); \
- VERIFY_EQUAL(ent1.field4.b, ent2.field4.b); \
-}
+#define VERIFY_ELMTS_VALID1(ent1, ent2) \
+ { \
+ VERIFY_EQUAL(ent1.field1, ent2.field1); \
+ VERIFY_EQUAL(ent1.field2_a, ent2.field2.a); \
+ VERIFY_EQUAL(ent1.field3, ent2.field3); \
+ VERIFY_EQUAL(ent1.field4.a, ent2.field4.a); \
+ VERIFY_EQUAL(ent1.field4.b, ent2.field4.b); \
+ }
/* Verify fields selected in VALID_FIELDS2 */
-#define VERIFY_ELMTS_VALID2(ent1, ent2) { \
- VERIFY_EQUAL(ent1.field2_b_a, ent2.field2.b.a); \
- VERIFY_EQUAL(ent1.field2_c, ent2.field2.c); \
- VERIFY_EQUAL(ent1.field4_b, ent2.field4.b); \
-}
+#define VERIFY_ELMTS_VALID2(ent1, ent2) \
+ { \
+ VERIFY_EQUAL(ent1.field2_b_a, ent2.field2.b.a); \
+ VERIFY_EQUAL(ent1.field2_c, ent2.field2.c); \
+ VERIFY_EQUAL(ent1.field4_b, ent2.field4.b); \
+ }
/* The types of 2-dimensional dataset: DSET_TWO or DSET_CMPD_TWO */
-#define TWO_NONE 0 /* DSET_TWO */
-#define TWO_CMPD_NULL 1 /* DSET_CMPD_TWO with NULL fields */
-#define TWO_CMPD_VALID1 2 /* DSET_CMPD_TWO with VALID_FIELDS1 or VALID_ESC_FIELDS1 */
-#define TWO_CMPD_VALID2 3 /* DSET_CMPD_TWO with VALID_FIELDS2 or VALID_ESC_FIELDS2 */
-
-#define VERIFY_ELMTS(type, k, ind, _ldbuf, _buf) { \
- if(type == TWO_NONE) { \
- int *iib = (int *)_ldbuf; \
- int *ib = (int *)_buf; \
- \
- VERIFY_EQUAL(iib[k], ib[ind + n]) \
- } else if(type == TWO_CMPD_NULL) { \
- set_t *ccb = (set_t *)_ldbuf; \
- set_t *cb = (set_t *)_buf; \
- \
- VERIFY_ELMTS_ALL(ccb[k], cb[ind + n]) \
- } else if(type == TWO_CMPD_VALID1) { \
- test_valid_fields1 *vb1 = (test_valid_fields1 *)_ldbuf; \
- set_t *cb = (set_t *)_buf; \
- \
- VERIFY_ELMTS_VALID1(vb1[k], cb[ind + n]) \
- } else if(type == TWO_CMPD_VALID2) { \
- test_valid_fields2 *vb2 = (test_valid_fields2 *)_ldbuf; \
- set_t *cb = (set_t *)_buf; \
- \
- VERIFY_ELMTS_VALID2(vb2[k], cb[ind + n]) \
- } \
-}
+#define TWO_NONE 0 /* DSET_TWO */
+#define TWO_CMPD_NULL 1 /* DSET_CMPD_TWO with NULL fields */
+#define TWO_CMPD_VALID1 2 /* DSET_CMPD_TWO with VALID_FIELDS1 or VALID_ESC_FIELDS1 */
+#define TWO_CMPD_VALID2 3 /* DSET_CMPD_TWO with VALID_FIELDS2 or VALID_ESC_FIELDS2 */
+
+#define VERIFY_ELMTS(type, k, ind, _ldbuf, _buf) \
+ { \
+ if (type == TWO_NONE) { \
+ int *iib = (int *)_ldbuf; \
+ int *ib = (int *)_buf; \
+ \
+ VERIFY_EQUAL(iib[k], ib[ind + n]) \
+ } \
+ else if (type == TWO_CMPD_NULL) { \
+ set_t *ccb = (set_t *)_ldbuf; \
+ set_t *cb = (set_t *)_buf; \
+ \
+ VERIFY_ELMTS_ALL(ccb[k], cb[ind + n]) \
+ } \
+ else if (type == TWO_CMPD_VALID1) { \
+ test_valid_fields1 *vb1 = (test_valid_fields1 *)_ldbuf; \
+ set_t * cb = (set_t *)_buf; \
+ \
+ VERIFY_ELMTS_VALID1(vb1[k], cb[ind + n]) \
+ } \
+ else if (type == TWO_CMPD_VALID2) { \
+ test_valid_fields2 *vb2 = (test_valid_fields2 *)_ldbuf; \
+ set_t * cb = (set_t *)_buf; \
+ \
+ VERIFY_ELMTS_VALID2(vb2[k], cb[ind + n]) \
+ } \
+ }
/* Tests for test_LD_elmts_pipe() */
-#define ONE_TESTS 3
-int onetests[ONE_TESTS] = {3, 9, 1};
-#define TWO_TESTS 5
-int twotests[TWO_TESTS][2] = { {2,2}, {2,-1}, {2,0}, {-1,2}, {0,2} };
-
+#define ONE_TESTS 3
+int onetests[ONE_TESTS] = {3, 9, 1};
+#define TWO_TESTS 5
+int twotests[TWO_TESTS][2] = {{2, 2}, {2, -1}, {2, 0}, {-1, 2}, {0, 2}};
static herr_t test_LD_dims_params(const char *file);
static herr_t test_LD_dims(const char *file);
@@ -153,7 +157,7 @@ static herr_t test_LD_elmts_invalid(const char *file);
static herr_t test_LD_elmts_one(const char *file, const char *dname, const char *fields);
static herr_t test_LD_elmts_two(const char *file, const char *dname, const char *fields);
-static herr_t verify_elmts_two(int type, hsize_t *ext_dims, hsize_t *prev_dims, void *_ldbuf, void *_buf);
+static herr_t verify_elmts_two(int type, hsize_t *ext_dims, hsize_t *prev_dims, void *_ldbuf, void *_buf);
/* data structures for compound data type */
typedef struct sub22_t {
@@ -163,9 +167,9 @@ typedef struct sub22_t {
} sub22_t;
typedef struct sub2_t {
- int a;
+ int a;
sub22_t b;
- int c;
+ int c;
} sub2_t;
typedef struct sub4_t {
@@ -174,7 +178,7 @@ typedef struct sub4_t {
} sub4_t;
typedef struct set_t {
- int field1;
+ int field1;
sub2_t field2;
double field3;
sub4_t field4;
@@ -190,8 +194,8 @@ typedef struct set_t {
/* VALID_FIELDS1 "field1,field2.a,field3,field4" */
/* VALID_ESC_FIELDS1 "field\\,1,field2\\..\\.a,field\\\\3,field4\\," */
typedef struct test_valid_fields1 {
- int field1;
- int field2_a;
+ int field1;
+ int field2_a;
double field3;
sub4_t field4;
} test_valid_fields1;
@@ -204,16 +208,14 @@ typedef struct test_valid_fields2 {
int field4_b;
} test_valid_fields2;
-
/* Temporary buffers for tests: test_LD_elmts_one() & test_LD_elmts_two() */
-#define TEST_BUF_SIZE 100
-int *iibuf; /* buffer for storing retrieved elements */
-int *ibuf; /* buffer for storing retrieved elements (integer) */
-set_t *cbuf; /* buffer for storing retrieved elemnets (compound) */
-set_t *ccbuf; /* buffer for storing retrieved elemnets (compound) */
-test_valid_fields1 *vbuf1; /* buffer for storing retrieved elements (FIELDS1) */
-test_valid_fields2 *vbuf2; /* buffer for storing retrieved elements (FIELDS2) */
-
+#define TEST_BUF_SIZE 100
+int * iibuf; /* buffer for storing retrieved elements */
+int * ibuf; /* buffer for storing retrieved elements (integer) */
+set_t * cbuf; /* buffer for storing retrieved elemnets (compound) */
+set_t * ccbuf; /* buffer for storing retrieved elemnets (compound) */
+test_valid_fields1 *vbuf1; /* buffer for storing retrieved elements (FIELDS1) */
+test_valid_fields2 *vbuf2; /* buffer for storing retrieved elements (FIELDS2) */
/*
*********************************************************************************
@@ -231,109 +233,108 @@ test_valid_fields2 *vbuf2; /* buffer for storing retrieved elements (FIELDS2)
static herr_t
test_LD_dims_params(const char *file)
{
- hid_t fid=-1; /* file identifier */
- hid_t did=-1; /* dataset identifier */
- hsize_t one_cur_dims[1]; /* current dimension sizes for 1-dimensonal dataset */
- hsize_t two_cur_dims[2]; /* current dimension sizes for 2-dimensional dataset */
- hid_t invalid_id = -1;
- herr_t ret; /* return value */
+ hid_t fid = -1; /* file identifier */
+ hid_t did = -1; /* dataset identifier */
+ hsize_t one_cur_dims[1]; /* current dimension sizes for 1-dimensonal dataset */
+ hsize_t two_cur_dims[2]; /* current dimension sizes for 2-dimensional dataset */
+ hid_t invalid_id = -1;
+ herr_t ret; /* return value */
const char *filename = H5_get_srcdir_filename(file);
HL_TESTING2("H5LDget_dset_dims");
/* Open the copied file */
- if((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
- FAIL_STACK_ERROR
+ if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
/*
* 1. Verify failure with negative dataset id
*/
- H5E_BEGIN_TRY {
- ret = H5LDget_dset_dims(invalid_id, one_cur_dims);
- } H5E_END_TRY;
+ H5E_BEGIN_TRY { ret = H5LDget_dset_dims(invalid_id, one_cur_dims); }
+ H5E_END_TRY;
VERIFY_EQUAL(ret, FAIL)
/*
* 2. Verify failure for NULL cur_dims
*/
- if((did = H5Dopen2(fid, DSET_ALLOC_EARLY, H5P_DEFAULT)) < 0)
- FAIL_STACK_ERROR
- H5E_BEGIN_TRY {
- ret = H5LDget_dset_dims(did, NULL);
- } H5E_END_TRY;
+ if ((did = H5Dopen2(fid, DSET_ALLOC_EARLY, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+ H5E_BEGIN_TRY { ret = H5LDget_dset_dims(did, NULL); }
+ H5E_END_TRY;
VERIFY_EQUAL(ret, FAIL)
- if(H5Dclose(did) < 0)
- FAIL_STACK_ERROR
+ if (H5Dclose(did) < 0)
+ FAIL_STACK_ERROR
/*
* 3. Verify for nonNULL cur_dims
*/
- if((did = H5Dopen2(fid, DSET_ALLOC_LATE, H5P_DEFAULT)) < 0)
- FAIL_STACK_ERROR
- if(H5LDget_dset_dims(did, one_cur_dims) < 0)
- FAIL_STACK_ERROR
+ if ((did = H5Dopen2(fid, DSET_ALLOC_LATE, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+ if (H5LDget_dset_dims(did, one_cur_dims) < 0)
+ FAIL_STACK_ERROR
VERIFY_EQUAL(one_cur_dims[0], 10)
- if(H5Dclose(did) < 0)
- FAIL_STACK_ERROR
+ if (H5Dclose(did) < 0)
+ FAIL_STACK_ERROR
/*
* 4. Verify nonNULL cur_dims for a 2-dimensional dataset
*/
- if((did = H5Dopen2(fid, DSET_CMPD_TWO, H5P_DEFAULT)) < 0)
- FAIL_STACK_ERROR
- if(H5LDget_dset_dims(did, two_cur_dims) < 0)
- FAIL_STACK_ERROR
+ if ((did = H5Dopen2(fid, DSET_CMPD_TWO, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+ if (H5LDget_dset_dims(did, two_cur_dims) < 0)
+ FAIL_STACK_ERROR
VERIFY_EQUAL(two_cur_dims[0], TWO_DIM_1)
VERIFY_EQUAL(two_cur_dims[1], TWO_DIM_2)
- if(H5Dclose(did) < 0)
- FAIL_STACK_ERROR
+ if (H5Dclose(did) < 0)
+ FAIL_STACK_ERROR
/*
* 5. Verify nonNULL cur_dims for dataset with H5S_NULL dataspace
*/
one_cur_dims[0] = 0;
- if((did = H5Dopen2(fid, DSET_NULL, H5P_DEFAULT)) < 0)
- FAIL_STACK_ERROR
+ if ((did = H5Dopen2(fid, DSET_NULL, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
- if(H5LDget_dset_dims(did, one_cur_dims) < 0)
- FAIL_STACK_ERROR
+ if (H5LDget_dset_dims(did, one_cur_dims) < 0)
+ FAIL_STACK_ERROR
VERIFY_EQUAL(one_cur_dims[0], 0)
- if(H5Dclose(did) < 0)
- FAIL_STACK_ERROR
+ if (H5Dclose(did) < 0)
+ FAIL_STACK_ERROR
/*
* 6. Verify nonNULL cur_dims for dataset with H5S_SCALAR dataspace
*/
one_cur_dims[0] = 0;
- if((did = H5Dopen2(fid, DSET_SCALAR, H5P_DEFAULT)) < 0)
- FAIL_STACK_ERROR
+ if ((did = H5Dopen2(fid, DSET_SCALAR, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
- if(H5LDget_dset_dims(did, one_cur_dims) < 0)
- FAIL_STACK_ERROR
+ if (H5LDget_dset_dims(did, one_cur_dims) < 0)
+ FAIL_STACK_ERROR
VERIFY_EQUAL(one_cur_dims[0], 0)
- if(H5Dclose(did) < 0)
- FAIL_STACK_ERROR
+ if (H5Dclose(did) < 0)
+ FAIL_STACK_ERROR
/* Close the file */
- if(H5Fclose(fid) < 0)
- FAIL_STACK_ERROR
+ if (H5Fclose(fid) < 0)
+ FAIL_STACK_ERROR
PASSED();
return 0;
error:
- H5E_BEGIN_TRY {
- H5Dclose(did);
- H5Fclose(fid);
- } H5E_END_TRY;
+ H5E_BEGIN_TRY
+ {
+ H5Dclose(did);
+ H5Fclose(fid);
+ }
+ H5E_END_TRY;
- return(-1);
+ return (-1);
} /* test_LD_dims_params() */
-
/*
*********************************************************************************
*
@@ -374,93 +375,93 @@ error:
static herr_t
test_LD_dims(const char *file)
{
- hid_t fid=-1; /* file identifier */
- hid_t did=-1; /* dataset identifier */
- hsize_t one_prev_dims[1]; /* original dimension sizes for 1-dimensonal dataset */
- hsize_t one_cur_dims[1]; /* current dimension sizes for 1-dimensonal dataset */
- hsize_t one_ext_dims[1]; /* extended dimension sizes for 1-dimensonal dataset */
- hsize_t two_prev_dims[2]; /* original dimension sizes for 2-dimensional dataset */
- hsize_t two_cur_dims[2]; /* current dimension sizes for 2-dimensional dataset */
- hsize_t two_ext_dims[2]; /* extended dimension sizes for 2-dimensional dataset*/
- int i; /* local index variable */
+ hid_t fid = -1; /* file identifier */
+ hid_t did = -1; /* dataset identifier */
+ hsize_t one_prev_dims[1]; /* original dimension sizes for 1-dimensonal dataset */
+ hsize_t one_cur_dims[1]; /* current dimension sizes for 1-dimensonal dataset */
+ hsize_t one_ext_dims[1]; /* extended dimension sizes for 1-dimensonal dataset */
+ hsize_t two_prev_dims[2]; /* original dimension sizes for 2-dimensional dataset */
+ hsize_t two_cur_dims[2]; /* current dimension sizes for 2-dimensional dataset */
+ hsize_t two_ext_dims[2]; /* extended dimension sizes for 2-dimensional dataset*/
+ int i; /* local index variable */
HL_TESTING2("H5LDget_dset_dims with H5Dset_extent");
/* Make a copy of the test file */
- if(h5_make_local_copy(file, COPY_FILENAME) < 0)
+ if (h5_make_local_copy(file, COPY_FILENAME) < 0)
TEST_ERROR
/* Open the copied file */
- if((fid = H5Fopen(COPY_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
- FAIL_STACK_ERROR
+ if ((fid = H5Fopen(COPY_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
/*
* Testing with one-dimensional dataset: DSET_ONE
*/
- if((did = H5Dopen2(fid, DSET_ONE, H5P_DEFAULT)) < 0)
- FAIL_STACK_ERROR
+ if ((did = H5Dopen2(fid, DSET_ONE, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
/* Retrieve dimension sizes */
- if(H5LDget_dset_dims(did, one_prev_dims) < 0)
- FAIL_STACK_ERROR
+ if (H5LDget_dset_dims(did, one_prev_dims) < 0)
+ FAIL_STACK_ERROR
- for(i = 0; i < ONE_NTESTS; i++) {
+ for (i = 0; i < ONE_NTESTS; i++) {
- /* Set up the extended dimension sizes */
- one_ext_dims[0] = (hsize_t)((int)one_prev_dims[0] + one_tests[i]);
+ /* Set up the extended dimension sizes */
+ one_ext_dims[0] = (hsize_t)((int)one_prev_dims[0] + one_tests[i]);
- /* Change the dimension size */
- if(H5Dset_extent(did, one_ext_dims) < 0)
- FAIL_STACK_ERROR
+ /* Change the dimension size */
+ if (H5Dset_extent(did, one_ext_dims) < 0)
+ FAIL_STACK_ERROR
- /* Retrieve the dimension size */
- if(H5LDget_dset_dims(did, one_cur_dims) < 0)
- FAIL_STACK_ERROR
+ /* Retrieve the dimension size */
+ if (H5LDget_dset_dims(did, one_cur_dims) < 0)
+ FAIL_STACK_ERROR
- /* Verify that the retrieved dimension size is correct as expected */
- VERIFY_EQUAL(one_cur_dims[0], one_ext_dims[0])
+ /* Verify that the retrieved dimension size is correct as expected */
+ VERIFY_EQUAL(one_cur_dims[0], one_ext_dims[0])
}
/* Close the dataset */
- if(H5Dclose(did) < 0)
- FAIL_STACK_ERROR
+ if (H5Dclose(did) < 0)
+ FAIL_STACK_ERROR
/*
* Testing with two-dimensional dataset: DSET_TWO
*/
- if((did = H5Dopen2(fid, DSET_TWO, H5P_DEFAULT)) < 0)
- FAIL_STACK_ERROR
+ if ((did = H5Dopen2(fid, DSET_TWO, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
/* Retrieve the dimension sizes */
- if(H5LDget_dset_dims(did, two_prev_dims) < 0)
- FAIL_STACK_ERROR
+ if (H5LDget_dset_dims(did, two_prev_dims) < 0)
+ FAIL_STACK_ERROR
- for(i = 0; i < TWO_NTESTS; i++) {
+ for (i = 0; i < TWO_NTESTS; i++) {
- /* Set up the extended dimension sizes */
- two_ext_dims[0] = (hsize_t)((int)two_prev_dims[0] + two_tests[i][0]);
- two_ext_dims[1] = (hsize_t) ((int)two_prev_dims[1] + two_tests[i][1]);
+ /* Set up the extended dimension sizes */
+ two_ext_dims[0] = (hsize_t)((int)two_prev_dims[0] + two_tests[i][0]);
+ two_ext_dims[1] = (hsize_t)((int)two_prev_dims[1] + two_tests[i][1]);
- /* Change the dimension sizes */
- if(H5Dset_extent(did, two_ext_dims) < 0)
- FAIL_STACK_ERROR
+ /* Change the dimension sizes */
+ if (H5Dset_extent(did, two_ext_dims) < 0)
+ FAIL_STACK_ERROR
- /* Retrieve the dimension sizes */
- if(H5LDget_dset_dims(did, two_cur_dims) < 0)
- FAIL_STACK_ERROR
+ /* Retrieve the dimension sizes */
+ if (H5LDget_dset_dims(did, two_cur_dims) < 0)
+ FAIL_STACK_ERROR
- /* Verify that the retrieved dimension sizes are correct as expected */
- VERIFY_EQUAL(two_cur_dims[0], two_ext_dims[0])
- VERIFY_EQUAL(two_cur_dims[1], two_ext_dims[1])
+ /* Verify that the retrieved dimension sizes are correct as expected */
+ VERIFY_EQUAL(two_cur_dims[0], two_ext_dims[0])
+ VERIFY_EQUAL(two_cur_dims[1], two_ext_dims[1])
} /* end TWO_NTESTS */
/* Close the dataset */
- if(H5Dclose(did) < 0)
- FAIL_STACK_ERROR
+ if (H5Dclose(did) < 0)
+ FAIL_STACK_ERROR
/* Close the file */
- if(H5Fclose(fid) < 0)
- FAIL_STACK_ERROR
+ if (H5Fclose(fid) < 0)
+ FAIL_STACK_ERROR
/* Remove the copied file */
HDremove(COPY_FILENAME);
@@ -469,15 +470,16 @@ test_LD_dims(const char *file)
return 0;
error:
- H5E_BEGIN_TRY {
- H5Dclose(did);
- H5Fclose(fid);
- } H5E_END_TRY;
- return(-1);
+ H5E_BEGIN_TRY
+ {
+ H5Dclose(did);
+ H5Fclose(fid);
+ }
+ H5E_END_TRY;
+ return (-1);
} /* test_LD_dims() */
-
/*
**********************************************************************************
*
@@ -509,33 +511,32 @@ error:
static int
test_LD_size(const char *file)
{
- hid_t fid=-1; /* file identifier */
- hid_t did=-1; /* dataset identifier */
- hid_t dtid=-1; /* dataset's datatype identifier */
- hid_t invalid_id=-1;
- hid_t memb0_tid=-1; /* type identifier for a member in the compound type */
- hid_t memb1_tid=-1; /* type identifier for a member in the compound type */
- hid_t memb2_tid=-1; /* type identifier for a member in the compound type */
- hid_t memb3_tid=-1; /* type identifier for a member in the compound type */
- hid_t memb_tid=-1; /* type identifier for a member in the compound type */
- hid_t memb_tid2=-1; /* type identifier for a member in the compound type */
- size_t dsize; /* size of the dataset's datatype */
- size_t ck_dsize; /* size of the dataset's datatype to be checked against */
+ hid_t fid = -1; /* file identifier */
+ hid_t did = -1; /* dataset identifier */
+ hid_t dtid = -1; /* dataset's datatype identifier */
+ hid_t invalid_id = -1;
+ hid_t memb0_tid = -1; /* type identifier for a member in the compound type */
+ hid_t memb1_tid = -1; /* type identifier for a member in the compound type */
+ hid_t memb2_tid = -1; /* type identifier for a member in the compound type */
+ hid_t memb3_tid = -1; /* type identifier for a member in the compound type */
+ hid_t memb_tid = -1; /* type identifier for a member in the compound type */
+ hid_t memb_tid2 = -1; /* type identifier for a member in the compound type */
+ size_t dsize; /* size of the dataset's datatype */
+ size_t ck_dsize; /* size of the dataset's datatype to be checked against */
const char *filename = H5_get_srcdir_filename(file);
HL_TESTING2("H5LDget_dset_type_size");
/* Open the file */
- if((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
- FAIL_STACK_ERROR
+ if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
/*
* Verify failure with an invalid dataset id
*/
- H5E_BEGIN_TRY {
- dsize = H5LDget_dset_type_size(invalid_id, NULL);
- } H5E_END_TRY;
+ H5E_BEGIN_TRY { dsize = H5LDget_dset_type_size(invalid_id, NULL); }
+ H5E_END_TRY;
VERIFY_EQUAL(dsize, 0)
/*
@@ -544,91 +545,91 @@ test_LD_size(const char *file)
*/
/* Open dataset DSET_CMPD */
- if((did = H5Dopen2(fid, DSET_CMPD, H5P_DEFAULT)) < 0)
- FAIL_STACK_ERROR
+ if ((did = H5Dopen2(fid, DSET_CMPD, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
/* Return size of the whole element */
- if((dsize = H5LDget_dset_type_size(did, NULL)) == 0)
- FAIL_STACK_ERROR
+ if ((dsize = H5LDget_dset_type_size(did, NULL)) == 0)
+ FAIL_STACK_ERROR
/* Get the dataset's datatype and then its datatype size */
- if((dtid = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0)
+ if ((dtid = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0)
FAIL_STACK_ERROR
- if((ck_dsize = H5Tget_size(dtid)) == 0)
- FAIL_STACK_ERROR
+ if ((ck_dsize = H5Tget_size(dtid)) == 0)
+ FAIL_STACK_ERROR
/* Verify case #1 */
VERIFY_EQUAL(dsize, ck_dsize)
/* Get datatype id for each member */
- if((memb0_tid = H5Tget_member_type(dtid, 0)) < 0) /* "field1" */
- FAIL_STACK_ERROR
- if((memb1_tid = H5Tget_member_type(dtid, 1)) < 0) /* "field2" */
- FAIL_STACK_ERROR
- if((memb2_tid = H5Tget_member_type(dtid, 2)) < 0) /* "field3" */
- FAIL_STACK_ERROR
- if((memb3_tid = H5Tget_member_type(dtid, 3)) < 0) /* "field4" */
- FAIL_STACK_ERROR
+ if ((memb0_tid = H5Tget_member_type(dtid, 0)) < 0) /* "field1" */
+ FAIL_STACK_ERROR
+ if ((memb1_tid = H5Tget_member_type(dtid, 1)) < 0) /* "field2" */
+ FAIL_STACK_ERROR
+ if ((memb2_tid = H5Tget_member_type(dtid, 2)) < 0) /* "field3" */
+ FAIL_STACK_ERROR
+ if ((memb3_tid = H5Tget_member_type(dtid, 3)) < 0) /* "field4" */
+ FAIL_STACK_ERROR
/* Obtain size for VALID_FIELDS1: "field1,field2.a,field3,field4" */
- if((dsize = H5LDget_dset_type_size(did, VALID_FIELDS1)) == 0)
- FAIL_STACK_ERROR
+ if ((dsize = H5LDget_dset_type_size(did, VALID_FIELDS1)) == 0)
+ FAIL_STACK_ERROR
/* Get the datatype size for "field1" */
- if((ck_dsize = H5Tget_size(memb0_tid)) == 0)
- FAIL_STACK_ERROR
+ if ((ck_dsize = H5Tget_size(memb0_tid)) == 0)
+ FAIL_STACK_ERROR
/* Add the datatype size for "field2.a" */
- if((memb_tid = H5Tget_member_type(memb1_tid, 0)) < 0)
- FAIL_STACK_ERROR
- if((ck_dsize += H5Tget_size(memb_tid)) == 0)
- FAIL_STACK_ERROR
- if(H5Tclose(memb_tid) < 0)
- FAIL_STACK_ERROR
+ if ((memb_tid = H5Tget_member_type(memb1_tid, 0)) < 0)
+ FAIL_STACK_ERROR
+ if ((ck_dsize += H5Tget_size(memb_tid)) == 0)
+ FAIL_STACK_ERROR
+ if (H5Tclose(memb_tid) < 0)
+ FAIL_STACK_ERROR
/* Add the datatype size for "field3" */
- if((ck_dsize += H5Tget_size(memb2_tid)) == 0)
- FAIL_STACK_ERROR
+ if ((ck_dsize += H5Tget_size(memb2_tid)) == 0)
+ FAIL_STACK_ERROR
/* Add the datatype size for "field4" */
- if((ck_dsize += H5Tget_size(memb3_tid)) == 0)
- FAIL_STACK_ERROR
+ if ((ck_dsize += H5Tget_size(memb3_tid)) == 0)
+ FAIL_STACK_ERROR
/* Verify case #2 */
VERIFY_EQUAL(dsize, ck_dsize)
/* Obtain datatype size for VALID_FIELDS2: "field2.b.a,field2.c,field4.b" */
- if((dsize = H5LDget_dset_type_size(did, VALID_FIELDS2)) == 0)
- FAIL_STACK_ERROR
+ if ((dsize = H5LDget_dset_type_size(did, VALID_FIELDS2)) == 0)
+ FAIL_STACK_ERROR
/* Get the datatype size for "field2.b.a" */
- if((memb_tid = H5Tget_member_type(memb1_tid, 1)) < 0)
- FAIL_STACK_ERROR
- if((memb_tid2 = H5Tget_member_type(memb_tid, 0)) < 0)
- FAIL_STACK_ERROR
- if((ck_dsize = H5Tget_size(memb_tid2)) == 0)
- FAIL_STACK_ERROR
- if(H5Tclose(memb_tid) < 0)
- FAIL_STACK_ERROR
- if(H5Tclose(memb_tid2) < 0)
- FAIL_STACK_ERROR
+ if ((memb_tid = H5Tget_member_type(memb1_tid, 1)) < 0)
+ FAIL_STACK_ERROR
+ if ((memb_tid2 = H5Tget_member_type(memb_tid, 0)) < 0)
+ FAIL_STACK_ERROR
+ if ((ck_dsize = H5Tget_size(memb_tid2)) == 0)
+ FAIL_STACK_ERROR
+ if (H5Tclose(memb_tid) < 0)
+ FAIL_STACK_ERROR
+ if (H5Tclose(memb_tid2) < 0)
+ FAIL_STACK_ERROR
/* Add the datatype size for "field2.c" */
- if((memb_tid = H5Tget_member_type(memb1_tid, 2)) < 0)
- FAIL_STACK_ERROR
- if((ck_dsize += H5Tget_size(memb_tid)) == 0)
- FAIL_STACK_ERROR
- if(H5Tclose(memb_tid) < 0)
- FAIL_STACK_ERROR
+ if ((memb_tid = H5Tget_member_type(memb1_tid, 2)) < 0)
+ FAIL_STACK_ERROR
+ if ((ck_dsize += H5Tget_size(memb_tid)) == 0)
+ FAIL_STACK_ERROR
+ if (H5Tclose(memb_tid) < 0)
+ FAIL_STACK_ERROR
/* Add the datatype size for "field4.b" */
- if((memb_tid = H5Tget_member_type(memb3_tid, 1)) < 0)
- FAIL_STACK_ERROR
- if((ck_dsize += H5Tget_size(memb_tid)) == 0)
- FAIL_STACK_ERROR
- if(H5Tclose(memb_tid) < 0)
- FAIL_STACK_ERROR
+ if ((memb_tid = H5Tget_member_type(memb3_tid, 1)) < 0)
+ FAIL_STACK_ERROR
+ if ((ck_dsize += H5Tget_size(memb_tid)) == 0)
+ FAIL_STACK_ERROR
+ if (H5Tclose(memb_tid) < 0)
+ FAIL_STACK_ERROR
/* Verify case #3 */
VERIFY_EQUAL(dsize, ck_dsize)
@@ -652,18 +653,18 @@ test_LD_size(const char *file)
VERIFY_EQUAL(dsize, 0)
/* Closing */
- if(H5Tclose(memb0_tid) < 0)
- FAIL_STACK_ERROR
- if(H5Tclose(memb1_tid) < 0)
- FAIL_STACK_ERROR
- if(H5Tclose(memb2_tid) < 0)
- FAIL_STACK_ERROR
- if(H5Tclose(memb3_tid) < 0)
- FAIL_STACK_ERROR
- if(H5Tclose(dtid) < 0)
- FAIL_STACK_ERROR
- if(H5Dclose(did) < 0)
- FAIL_STACK_ERROR
+ if (H5Tclose(memb0_tid) < 0)
+ FAIL_STACK_ERROR
+ if (H5Tclose(memb1_tid) < 0)
+ FAIL_STACK_ERROR
+ if (H5Tclose(memb2_tid) < 0)
+ FAIL_STACK_ERROR
+ if (H5Tclose(memb3_tid) < 0)
+ FAIL_STACK_ERROR
+ if (H5Tclose(dtid) < 0)
+ FAIL_STACK_ERROR
+ if (H5Dclose(did) < 0)
+ FAIL_STACK_ERROR
/*
* Testing one-dimensional dataset with compound datatype and
@@ -672,91 +673,91 @@ test_LD_size(const char *file)
*/
/* Open dataset DSET_CMPD_ESC */
- if((did = H5Dopen2(fid, DSET_CMPD_ESC, H5P_DEFAULT)) < 0)
- FAIL_STACK_ERROR
+ if ((did = H5Dopen2(fid, DSET_CMPD_ESC, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
/* Return size of the whole element */
- if((dsize = H5LDget_dset_type_size(did, NULL)) == 0)
- FAIL_STACK_ERROR
+ if ((dsize = H5LDget_dset_type_size(did, NULL)) == 0)
+ FAIL_STACK_ERROR
/* Get the dataset's datatype and then its datatype size */
- if((dtid = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0)
+ if ((dtid = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+ if ((ck_dsize = H5Tget_size(dtid)) == 0)
FAIL_STACK_ERROR
- if((ck_dsize = H5Tget_size(dtid)) == 0)
- FAIL_STACK_ERROR
/* Verify case #1 */
VERIFY_EQUAL(dsize, ck_dsize)
/* Get datatype id for each member */
- if((memb0_tid = H5Tget_member_type(dtid, 0)) < 0) /* "field,1" */
- FAIL_STACK_ERROR
- if((memb1_tid = H5Tget_member_type(dtid, 1)) < 0) /* "field2." */
- FAIL_STACK_ERROR
- if((memb2_tid = H5Tget_member_type(dtid, 2)) < 0) /* "field\3" */
- FAIL_STACK_ERROR
- if((memb3_tid = H5Tget_member_type(dtid, 3)) < 0) /* "field4," */
- FAIL_STACK_ERROR
+ if ((memb0_tid = H5Tget_member_type(dtid, 0)) < 0) /* "field,1" */
+ FAIL_STACK_ERROR
+ if ((memb1_tid = H5Tget_member_type(dtid, 1)) < 0) /* "field2." */
+ FAIL_STACK_ERROR
+ if ((memb2_tid = H5Tget_member_type(dtid, 2)) < 0) /* "field\3" */
+ FAIL_STACK_ERROR
+ if ((memb3_tid = H5Tget_member_type(dtid, 3)) < 0) /* "field4," */
+ FAIL_STACK_ERROR
/* Obtain size for VALID_ESC_FIELDS1: "field\\,1,field2\\..\\.a,field\\\\3,field4\\," */
- if((dsize = H5LDget_dset_type_size(did, VALID_ESC_FIELDS1)) == 0)
- FAIL_STACK_ERROR
+ if ((dsize = H5LDget_dset_type_size(did, VALID_ESC_FIELDS1)) == 0)
+ FAIL_STACK_ERROR
/* Get the datatype size for "field\\,1" */
- if((ck_dsize = H5Tget_size(memb0_tid)) == 0)
- FAIL_STACK_ERROR
+ if ((ck_dsize = H5Tget_size(memb0_tid)) == 0)
+ FAIL_STACK_ERROR
/* Add the datatype size for "field2\\..\\.a" */
- if((memb_tid = H5Tget_member_type(memb1_tid, 0)) < 0)
- FAIL_STACK_ERROR
- if((ck_dsize += H5Tget_size(memb_tid)) == 0)
- FAIL_STACK_ERROR
- if(H5Tclose(memb_tid) < 0)
- FAIL_STACK_ERROR
+ if ((memb_tid = H5Tget_member_type(memb1_tid, 0)) < 0)
+ FAIL_STACK_ERROR
+ if ((ck_dsize += H5Tget_size(memb_tid)) == 0)
+ FAIL_STACK_ERROR
+ if (H5Tclose(memb_tid) < 0)
+ FAIL_STACK_ERROR
/* Add the datatype size for "field\\\\3" */
- if((ck_dsize += H5Tget_size(memb2_tid)) == 0)
- FAIL_STACK_ERROR
+ if ((ck_dsize += H5Tget_size(memb2_tid)) == 0)
+ FAIL_STACK_ERROR
/* Add the datatype size for "field4\\," */
- if((ck_dsize += H5Tget_size(memb3_tid)) == 0)
- FAIL_STACK_ERROR
+ if ((ck_dsize += H5Tget_size(memb3_tid)) == 0)
+ FAIL_STACK_ERROR
/* Verify case #2 */
VERIFY_EQUAL(dsize, ck_dsize)
/* Obtain datatype size for VALID_ESC_FIELDS2:
"field2\\..\\,b.a,field2\\..\\\\c,field4\\,.b\\," */
- if((dsize = H5LDget_dset_type_size(did, VALID_ESC_FIELDS2)) == 0)
- FAIL_STACK_ERROR
+ if ((dsize = H5LDget_dset_type_size(did, VALID_ESC_FIELDS2)) == 0)
+ FAIL_STACK_ERROR
/* Get the datatype size for "field2\..,b.a" */
- if((memb_tid = H5Tget_member_type(memb1_tid, 1)) < 0)
- FAIL_STACK_ERROR
- if((memb_tid2 = H5Tget_member_type(memb_tid, 0)) < 0)
- FAIL_STACK_ERROR
- if((ck_dsize = H5Tget_size(memb_tid2)) == 0)
- FAIL_STACK_ERROR
- if(H5Tclose(memb_tid) < 0)
- FAIL_STACK_ERROR
- if(H5Tclose(memb_tid2) < 0)
- FAIL_STACK_ERROR
+ if ((memb_tid = H5Tget_member_type(memb1_tid, 1)) < 0)
+ FAIL_STACK_ERROR
+ if ((memb_tid2 = H5Tget_member_type(memb_tid, 0)) < 0)
+ FAIL_STACK_ERROR
+ if ((ck_dsize = H5Tget_size(memb_tid2)) == 0)
+ FAIL_STACK_ERROR
+ if (H5Tclose(memb_tid) < 0)
+ FAIL_STACK_ERROR
+ if (H5Tclose(memb_tid2) < 0)
+ FAIL_STACK_ERROR
/* Add the datatype size for "field2\..\\c" */
- if((memb_tid = H5Tget_member_type(memb1_tid, 2)) < 0)
- FAIL_STACK_ERROR
- if((ck_dsize += H5Tget_size(memb_tid)) == 0)
- FAIL_STACK_ERROR
- if(H5Tclose(memb_tid) < 0)
- FAIL_STACK_ERROR
+ if ((memb_tid = H5Tget_member_type(memb1_tid, 2)) < 0)
+ FAIL_STACK_ERROR
+ if ((ck_dsize += H5Tget_size(memb_tid)) == 0)
+ FAIL_STACK_ERROR
+ if (H5Tclose(memb_tid) < 0)
+ FAIL_STACK_ERROR
/* Add the datatype size for "field4\,.b\," */
- if((memb_tid = H5Tget_member_type(memb3_tid, 1)) < 0)
- FAIL_STACK_ERROR
- if((ck_dsize += H5Tget_size(memb_tid)) == 0)
- FAIL_STACK_ERROR
- if(H5Tclose(memb_tid) < 0)
- FAIL_STACK_ERROR
+ if ((memb_tid = H5Tget_member_type(memb3_tid, 1)) < 0)
+ FAIL_STACK_ERROR
+ if ((ck_dsize += H5Tget_size(memb_tid)) == 0)
+ FAIL_STACK_ERROR
+ if (H5Tclose(memb_tid) < 0)
+ FAIL_STACK_ERROR
/* Verify case #3 */
VERIFY_EQUAL(dsize, ck_dsize)
@@ -780,42 +781,43 @@ test_LD_size(const char *file)
VERIFY_EQUAL(dsize, 0)
/* Closing */
- if(H5Tclose(memb0_tid) < 0)
- FAIL_STACK_ERROR
- if(H5Tclose(memb1_tid) < 0)
- FAIL_STACK_ERROR
- if(H5Tclose(memb2_tid) < 0)
- FAIL_STACK_ERROR
- if(H5Tclose(memb3_tid) < 0)
- FAIL_STACK_ERROR
- if(H5Tclose(dtid) < 0)
- FAIL_STACK_ERROR
- if(H5Dclose(did) < 0)
- FAIL_STACK_ERROR
-
- if(H5Fclose(fid) < 0)
- FAIL_STACK_ERROR
+ if (H5Tclose(memb0_tid) < 0)
+ FAIL_STACK_ERROR
+ if (H5Tclose(memb1_tid) < 0)
+ FAIL_STACK_ERROR
+ if (H5Tclose(memb2_tid) < 0)
+ FAIL_STACK_ERROR
+ if (H5Tclose(memb3_tid) < 0)
+ FAIL_STACK_ERROR
+ if (H5Tclose(dtid) < 0)
+ FAIL_STACK_ERROR
+ if (H5Dclose(did) < 0)
+ FAIL_STACK_ERROR
+
+ if (H5Fclose(fid) < 0)
+ FAIL_STACK_ERROR
PASSED();
return 0;
error:
- H5E_BEGIN_TRY {
- H5Tclose(memb0_tid);
- H5Tclose(memb1_tid);
- H5Tclose(memb2_tid);
- H5Tclose(memb3_tid);
- H5Tclose(memb_tid);
- H5Tclose(memb_tid2);
- H5Tclose(dtid);
- H5Dclose(did);
- H5Fclose(fid);
- } H5E_END_TRY;
- return(-1);
+ H5E_BEGIN_TRY
+ {
+ H5Tclose(memb0_tid);
+ H5Tclose(memb1_tid);
+ H5Tclose(memb2_tid);
+ H5Tclose(memb3_tid);
+ H5Tclose(memb_tid);
+ H5Tclose(memb_tid2);
+ H5Tclose(dtid);
+ H5Dclose(did);
+ H5Fclose(fid);
+ }
+ H5E_END_TRY;
+ return (-1);
} /* test_LD_size() */
-
/*
**************************************************************************************
* Testing for the High Level public routine: H5LDget_dset_elmts()
@@ -839,32 +841,32 @@ error:
static int
test_LD_elmts_invalid(const char *file)
{
- hid_t fid=-1; /* file identifier */
- hid_t did=-1; /* dataset identifier */
- hid_t sid=-1; /* dataspace identifier */
- hid_t invalid_id=-1;
- int ret; /* return value */
- hsize_t cur_dims[2]; /* current dimension sizes of the dataset */
- hsize_t prev_dims[2]; /* previous dimension sizes of the dataset */
- char tbuf[2]; /* temporary buffer for testing */
- int ndims; /* # of dimension sizes */
- int i; /* local index variable */
+ hid_t fid = -1; /* file identifier */
+ hid_t did = -1; /* dataset identifier */
+ hid_t sid = -1; /* dataspace identifier */
+ hid_t invalid_id = -1;
+ int ret; /* return value */
+ hsize_t cur_dims[2]; /* current dimension sizes of the dataset */
+ hsize_t prev_dims[2]; /* previous dimension sizes of the dataset */
+ char tbuf[2]; /* temporary buffer for testing */
+ int ndims; /* # of dimension sizes */
+ int i; /* local index variable */
const char *filename = H5_get_srcdir_filename(file);
HL_TESTING2("H5LDget_dset_elmts on invalid conditions");
/* Open the copied file */
- if((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
- FAIL_STACK_ERROR
+ if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
/*
* Testing two-dimensional dataset: DSET_TWO
*/
/* Open dataset: DSET_TWO */
- if((did = H5Dopen2(fid, DSET_TWO, H5P_DEFAULT)) < 0)
- FAIL_STACK_ERROR
+ if ((did = H5Dopen2(fid, DSET_TWO, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
/* Verify failure from case #1: cur_dims and prev_dims are NULL */
ret = H5LDget_dset_elmts(did, NULL, NULL, NULL, NULL);
@@ -878,16 +880,16 @@ test_LD_elmts_invalid(const char *file)
ret = H5LDget_dset_elmts(did, NULL, prev_dims, NULL, NULL);
VERIFY_EQUAL(ret, FAIL)
- if((sid = H5Dget_space(did)) < 0)
- FAIL_STACK_ERROR
+ if ((sid = H5Dget_space(did)) < 0)
+ FAIL_STACK_ERROR
/* Get the # of dimensions and current dimension sizes */
- if((ndims = H5Sget_simple_extent_dims(sid, cur_dims, NULL)) < 0)
- FAIL_STACK_ERROR
+ if ((ndims = H5Sget_simple_extent_dims(sid, cur_dims, NULL)) < 0)
+ FAIL_STACK_ERROR
/* Set up valid cur_dims and prev_dims */
- for(i = 0; i < ndims; i++)
- prev_dims[i] = cur_dims[i] - 1;
+ for (i = 0; i < ndims; i++)
+ prev_dims[i] = cur_dims[i] - 1;
/* Verify failure from case #4: FIELDS is nonNULL but the dataset is not compound datatype */
ret = H5LDget_dset_elmts(did, prev_dims, cur_dims, "field1", tbuf);
@@ -900,12 +902,12 @@ test_LD_elmts_invalid(const char *file)
/* Verify failure from case #6: cur_dims is not > than prev_dims */
cur_dims[0] = prev_dims[0] - 1;
cur_dims[1] = prev_dims[1] - 1;
- ret = H5LDget_dset_elmts(did, prev_dims, cur_dims, NULL, tbuf);
+ ret = H5LDget_dset_elmts(did, prev_dims, cur_dims, NULL, tbuf);
VERIFY_EQUAL(ret, FAIL)
/* Close DSET_TWO */
- if(H5Dclose(did) < 0)
- FAIL_STACK_ERROR
+ if (H5Dclose(did) < 0)
+ FAIL_STACK_ERROR
/*
* Testing one-dimensional dataset with compound datatype:
@@ -913,18 +915,17 @@ test_LD_elmts_invalid(const char *file)
*/
/* Verify failure from case #1: an invalid dataset id */
- H5E_BEGIN_TRY {
- ret = H5LDget_dset_elmts(invalid_id, prev_dims, cur_dims, NULL, tbuf);
- } H5E_END_TRY;
+ H5E_BEGIN_TRY { ret = H5LDget_dset_elmts(invalid_id, prev_dims, cur_dims, NULL, tbuf); }
+ H5E_END_TRY;
VERIFY_EQUAL(ret, FAIL)
/* Open dataset: DSET_CMPD */
- if((did = H5Dopen2(fid, DSET_CMPD, H5P_DEFAULT)) < 0)
- FAIL_STACK_ERROR
+ if ((did = H5Dopen2(fid, DSET_CMPD, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
/* Retrieve the current dimension sizes */
- if(H5LDget_dset_dims(did, cur_dims) < 0)
- FAIL_STACK_ERROR
+ if (H5LDget_dset_dims(did, cur_dims) < 0)
+ FAIL_STACK_ERROR
/* Set up valid cur_dims, prev_dims */
prev_dims[0] = cur_dims[0] - 1;
@@ -934,27 +935,28 @@ test_LD_elmts_invalid(const char *file)
VERIFY_EQUAL(ret, FAIL)
/* Close DSET_CMPD */
- if(H5Dclose(did) < 0)
- FAIL_STACK_ERROR
+ if (H5Dclose(did) < 0)
+ FAIL_STACK_ERROR
/* Close the file */
- if(H5Fclose(fid) < 0)
- FAIL_STACK_ERROR
+ if (H5Fclose(fid) < 0)
+ FAIL_STACK_ERROR
PASSED();
return 0;
error:
- H5E_BEGIN_TRY {
- H5Sclose(sid);
- H5Dclose(did);
- H5Fclose(fid);
- } H5E_END_TRY;
- return(-1);
+ H5E_BEGIN_TRY
+ {
+ H5Sclose(sid);
+ H5Dclose(did);
+ H5Fclose(fid);
+ }
+ H5E_END_TRY;
+ return (-1);
} /* test_LD_elmts_invalid() */
-
/*
**************************************************************************************
* Testing for the High Level public routine: H5LDget_dset_elmts()
@@ -977,122 +979,122 @@ error:
static herr_t
test_LD_elmts_one(const char *file, const char *dname, const char *fields)
{
- hid_t fid=-1; /* file identifier */
- hid_t did=-1; /* dataset identifier */
- hid_t dtype=-1; /* dataset's data type */
- hsize_t ext_dims[1]; /* extended dimension sizes of the dataset */
- hsize_t prev_dims[1]; /* previous dimension sizes of the dataset */
- int i, j; /* local index variable */
- int ret = 0; /* return value */
+ hid_t fid = -1; /* file identifier */
+ hid_t did = -1; /* dataset identifier */
+ hid_t dtype = -1; /* dataset's data type */
+ hsize_t ext_dims[1]; /* extended dimension sizes of the dataset */
+ hsize_t prev_dims[1]; /* previous dimension sizes of the dataset */
+ int i, j; /* local index variable */
+ int ret = 0; /* return value */
HL_TESTING2("H5LDget_dset_elmts: one-dimensional dataset");
/* Copy the test file */
- if(h5_make_local_copy(file, COPY_FILENAME) < 0)
+ if (h5_make_local_copy(file, COPY_FILENAME) < 0)
TEST_ERROR
- for(i = 0; i < TEST_BUF_SIZE; i++) {
- cbuf[i].field1 = i;
- cbuf[i].field2.a = i;
- cbuf[i].field2.b.a = i;
- cbuf[i].field2.b.b = i;
- cbuf[i].field2.b.c = i;
- cbuf[i].field2.c = i;
- cbuf[i].field3 = (double)i;
- cbuf[i].field4.a = i;
- cbuf[i].field4.b = i;
- ibuf[i] = i;
+ for (i = 0; i < TEST_BUF_SIZE; i++) {
+ cbuf[i].field1 = i;
+ cbuf[i].field2.a = i;
+ cbuf[i].field2.b.a = i;
+ cbuf[i].field2.b.b = i;
+ cbuf[i].field2.b.c = i;
+ cbuf[i].field2.c = i;
+ cbuf[i].field3 = (double)i;
+ cbuf[i].field4.a = i;
+ cbuf[i].field4.b = i;
+ ibuf[i] = i;
} /* end for */
/* Open the copied file */
- if((fid = H5Fopen(COPY_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
- FAIL_STACK_ERROR
+ if ((fid = H5Fopen(COPY_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
/* Open the dataset */
- if((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0)
- FAIL_STACK_ERROR
+ if ((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
/* Get the dataset's data type */
- if((dtype = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0)
- FAIL_STACK_ERROR
+ if ((dtype = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
/* Get current dimension sizes before extending the dataset's dimension sizes */
- if(H5LDget_dset_dims(did, prev_dims) < 0)
- FAIL_STACK_ERROR
-
- /* Loop through different variations of extending the dataset */
- for(i = 0; i < ONE_NTESTS; i++) {
- HDmemset(vbuf1, 0, TEST_BUF_SIZE * sizeof(test_valid_fields1));
- HDmemset(vbuf2, 0, TEST_BUF_SIZE * sizeof(test_valid_fields2));
- HDmemset(ccbuf, 0, TEST_BUF_SIZE * sizeof(set_t));
- HDmemset(iibuf, 0, TEST_BUF_SIZE * sizeof(int));
-
- ext_dims[0] = (hsize_t)((int)prev_dims[0] + one_tests[i]);
-
- /* Change the dimension sizes of the dataset */
- if(H5Dset_extent(did, ext_dims) < 0)
+ if (H5LDget_dset_dims(did, prev_dims) < 0)
FAIL_STACK_ERROR
- /* Initialize data */
- if(!HDstrcmp(dname, DSET_CMPD) || !HDstrcmp(dname, DSET_CMPD_ESC)) {
- if(H5Dwrite(did, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, cbuf) < 0)
- FAIL_STACK_ERROR
- } /* end if */
- else if(!HDstrcmp(dname, DSET_ONE)) {
- if(H5Dwrite(did, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, ibuf) < 0)
- FAIL_STACK_ERROR
- } /* end if */
+ /* Loop through different variations of extending the dataset */
+ for (i = 0; i < ONE_NTESTS; i++) {
+ HDmemset(vbuf1, 0, TEST_BUF_SIZE * sizeof(test_valid_fields1));
+ HDmemset(vbuf2, 0, TEST_BUF_SIZE * sizeof(test_valid_fields2));
+ HDmemset(ccbuf, 0, TEST_BUF_SIZE * sizeof(set_t));
+ HDmemset(iibuf, 0, TEST_BUF_SIZE * sizeof(int));
+
+ ext_dims[0] = (hsize_t)((int)prev_dims[0] + one_tests[i]);
+
+ /* Change the dimension sizes of the dataset */
+ if (H5Dset_extent(did, ext_dims) < 0)
+ FAIL_STACK_ERROR
+
+ /* Initialize data */
+ if (!HDstrcmp(dname, DSET_CMPD) || !HDstrcmp(dname, DSET_CMPD_ESC)) {
+ if (H5Dwrite(did, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, cbuf) < 0)
+ FAIL_STACK_ERROR
+ } /* end if */
+ else if (!HDstrcmp(dname, DSET_ONE)) {
+ if (H5Dwrite(did, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, ibuf) < 0)
+ FAIL_STACK_ERROR
+ } /* end if */
- /* There are changes in dimension sizes */
- if(one_tests[i] > 0) {
- if(!HDstrcmp(dname, DSET_CMPD) || !HDstrcmp(dname, DSET_CMPD_ESC)) {
- if(fields) {
- if(!HDstrcmp(fields, VALID_FIELDS1) || !HDstrcmp(fields, VALID_ESC_FIELDS1)) {
+ /* There are changes in dimension sizes */
+ if (one_tests[i] > 0) {
+ if (!HDstrcmp(dname, DSET_CMPD) || !HDstrcmp(dname, DSET_CMPD_ESC)) {
+ if (fields) {
+ if (!HDstrcmp(fields, VALID_FIELDS1) || !HDstrcmp(fields, VALID_ESC_FIELDS1)) {
/* Retrieve the elmemts in BUF */
- if(H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, vbuf1) < 0)
+ if (H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, vbuf1) < 0)
TEST_ERROR
- for(j = 0; j < one_tests[i]; j++)
+ for (j = 0; j < one_tests[i]; j++)
VERIFY_ELMTS_VALID1(vbuf1[j], cbuf[prev_dims[0] + (hsize_t)j])
} /* end if */
- else if(!HDstrcmp(fields, VALID_FIELDS2) || !HDstrcmp(fields, VALID_ESC_FIELDS2)) {
+ else if (!HDstrcmp(fields, VALID_FIELDS2) || !HDstrcmp(fields, VALID_ESC_FIELDS2)) {
/* Retrieve the elmemts in BUF */
- if(H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, vbuf2) < 0)
+ if (H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, vbuf2) < 0)
TEST_ERROR
- for(j = 0; j < one_tests[i]; j++)
+ for (j = 0; j < one_tests[i]; j++)
VERIFY_ELMTS_VALID2(vbuf2[j], cbuf[prev_dims[0] + (hsize_t)j])
} /* end else-if */
else
- TEST_ERROR
- } /* end if */
+ TEST_ERROR
+ } /* end if */
else {
- /* Retrieve the elmemts in BUF */
- if(H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, ccbuf) < 0)
- TEST_ERROR
- for(j = 0; j < one_tests[i]; j++)
- VERIFY_ELMTS_ALL(ccbuf[j], cbuf[prev_dims[0] + (hsize_t)j])
- } /* end else-if */
- } /* end if */
+ /* Retrieve the elmemts in BUF */
+ if (H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, ccbuf) < 0)
+ TEST_ERROR
+ for (j = 0; j < one_tests[i]; j++)
+ VERIFY_ELMTS_ALL(ccbuf[j], cbuf[prev_dims[0] + (hsize_t)j])
+ } /* end else-if */
+ } /* end if */
else {
- /* Retrieve the elmemts in BUF */
- if(H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, iibuf) < 0)
- TEST_ERROR
- for(j = 0; j < one_tests[i]; j++)
- VERIFY_EQUAL(iibuf[j], ibuf[prev_dims[0] + (hsize_t)j])
- } /* end else */
- } /* end if */
+ /* Retrieve the elmemts in BUF */
+ if (H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, iibuf) < 0)
+ TEST_ERROR
+ for (j = 0; j < one_tests[i]; j++)
+ VERIFY_EQUAL(iibuf[j], ibuf[prev_dims[0] + (hsize_t)j])
+ } /* end else */
+ } /* end if */
else {
/* Verify failure when changes between prev_dims and ext_dims are same/decrease */
ret = H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, iibuf);
VERIFY_EQUAL(ret, FAIL)
} /* end else */
- } /* end for */
+ } /* end for */
/* Closing */
- if(H5Tclose(dtype) < 0)
+ if (H5Tclose(dtype) < 0)
FAIL_STACK_ERROR
- if(H5Dclose(did) < 0)
+ if (H5Dclose(did) < 0)
FAIL_STACK_ERROR
- if(H5Fclose(fid) < 0)
+ if (H5Fclose(fid) < 0)
FAIL_STACK_ERROR
/* Remove the copied file */
@@ -1102,15 +1104,16 @@ test_LD_elmts_one(const char *file, const char *dname, const char *fields)
return 0;
error:
- H5E_BEGIN_TRY {
- H5Tclose(dtype);
- H5Dclose(did);
- H5Fclose(fid);
- } H5E_END_TRY;
- return(-1);
+ H5E_BEGIN_TRY
+ {
+ H5Tclose(dtype);
+ H5Dclose(did);
+ H5Fclose(fid);
+ }
+ H5E_END_TRY;
+ return (-1);
} /* test_LD_elmts_one() */
-
/*
**************************************************************************************
*
@@ -1132,36 +1135,35 @@ error:
**************************************************************************************
*/
static herr_t
-verify_elmts_two(int type, hsize_t *ext_dims, hsize_t *prev_dims, void *_ldbuf, void *_buf)
+verify_elmts_two(int type, hsize_t *ext_dims, hsize_t *prev_dims, void *_ldbuf, void *_buf)
{
- int k, m; /* Local index variable */
+ int k, m; /* Local index variable */
k = 0;
- for(m = 0; m < (int)ext_dims[0]; m++) {
- int n, ind; /* Local index variable */
-
- ind = m * (int)ext_dims[1];
- if(m < (int)prev_dims[0]) {
- for(n = (int)prev_dims[1]; n < (int)ext_dims[1]; n++) {
- VERIFY_ELMTS(type, k, ind, _ldbuf, _buf)
- ++k;
- } /* end for */
- } /* end if */
+ for (m = 0; m < (int)ext_dims[0]; m++) {
+ int n, ind; /* Local index variable */
+
+ ind = m * (int)ext_dims[1];
+ if (m < (int)prev_dims[0]) {
+ for (n = (int)prev_dims[1]; n < (int)ext_dims[1]; n++) {
+ VERIFY_ELMTS(type, k, ind, _ldbuf, _buf)
+ ++k;
+ } /* end for */
+ } /* end if */
else {
- for(n = 0; n < (int)ext_dims[1]; n++) {
- VERIFY_ELMTS(type, k, ind, _ldbuf, _buf)
- ++k;
- } /* end for */
- } /* end else */
- } /* end for */
+ for (n = 0; n < (int)ext_dims[1]; n++) {
+ VERIFY_ELMTS(type, k, ind, _ldbuf, _buf)
+ ++k;
+ } /* end for */
+ } /* end else */
+ } /* end for */
- return(0);
+ return (0);
error:
- return(-1);
+ return (-1);
} /* verify_elmts_two() */
-
/*
**************************************************************************************
* Testing for the High Level public routine: H5LDget_dset_elmts()
@@ -1188,126 +1190,126 @@ error:
static herr_t
test_LD_elmts_two(const char *file, const char *dname, const char *fields)
{
- hid_t fid=-1; /* file identifier */
- hid_t did=-1; /* dataset identifier */
- hid_t dtype=-1; /* dataset's data type */
- hsize_t ext_dims[2]; /* extended dimension sizes of the dataset */
- hsize_t prev_dims[2]; /* previous dimension sizes of the dataset */
- int i; /* local index variable */
- int ret = 0; /* return value */
+ hid_t fid = -1; /* file identifier */
+ hid_t did = -1; /* dataset identifier */
+ hid_t dtype = -1; /* dataset's data type */
+ hsize_t ext_dims[2]; /* extended dimension sizes of the dataset */
+ hsize_t prev_dims[2]; /* previous dimension sizes of the dataset */
+ int i; /* local index variable */
+ int ret = 0; /* return value */
HL_TESTING2("H5LDget_dset_elmts: two-dimensional dataset");
/* Copy the test file */
- if(h5_make_local_copy(file, COPY_FILENAME) < 0)
+ if (h5_make_local_copy(file, COPY_FILENAME) < 0)
TEST_ERROR
- for(i = 0; i < TEST_BUF_SIZE; i++) {
- cbuf[i].field1 = i;
- cbuf[i].field2.a = i;
- cbuf[i].field2.b.a = i;
- cbuf[i].field2.b.b = i;
- cbuf[i].field2.b.c = i;
- cbuf[i].field2.c = i;
- cbuf[i].field3 = (double)i;
- cbuf[i].field4.a = i;
- cbuf[i].field4.b = i;
- ibuf[i] = i;
+ for (i = 0; i < TEST_BUF_SIZE; i++) {
+ cbuf[i].field1 = i;
+ cbuf[i].field2.a = i;
+ cbuf[i].field2.b.a = i;
+ cbuf[i].field2.b.b = i;
+ cbuf[i].field2.b.c = i;
+ cbuf[i].field2.c = i;
+ cbuf[i].field3 = (double)i;
+ cbuf[i].field4.a = i;
+ cbuf[i].field4.b = i;
+ ibuf[i] = i;
} /* end for */
/* Open the copied file */
- if((fid = H5Fopen(COPY_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
- FAIL_STACK_ERROR
+ if ((fid = H5Fopen(COPY_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
/* Open the dataset */
- if((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0)
- FAIL_STACK_ERROR
+ if ((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
/* Get the dataset's data type */
- if((dtype = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0)
- FAIL_STACK_ERROR
+ if ((dtype = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
/* Get current dimension sizes before extending the dataset's dimension sizes */
- if(H5LDget_dset_dims(did, prev_dims) < 0)
- FAIL_STACK_ERROR
-
- /* Loop through different variations of extending the dataset */
- for(i = 0; i < TWO_NTESTS; i++) {
- HDmemset(vbuf1, 0, TEST_BUF_SIZE * sizeof(test_valid_fields1));
- HDmemset(vbuf2, 0, TEST_BUF_SIZE * sizeof(test_valid_fields2));
- HDmemset(ccbuf, 0, TEST_BUF_SIZE * sizeof(set_t));
- HDmemset(iibuf, 0, TEST_BUF_SIZE * sizeof(int));
-
- ext_dims[0] = (hsize_t)((int)prev_dims[0] + two_tests[i][0]);
- ext_dims[1] = (hsize_t)((int)prev_dims[1] + two_tests[i][1]);
-
- /* Change the dimension sizes of the dataset */
- if(H5Dset_extent(did, ext_dims) < 0)
+ if (H5LDget_dset_dims(did, prev_dims) < 0)
FAIL_STACK_ERROR
- /* Initialize data */
- if(!HDstrcmp(dname, DSET_CMPD_TWO)) {
- if(H5Dwrite(did, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, cbuf) < 0)
- FAIL_STACK_ERROR
- } /* end if */
- else if(!HDstrcmp(dname, DSET_TWO)) {
- if(H5Dwrite(did, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, ibuf) < 0)
- FAIL_STACK_ERROR
- } /* end else-if */
+ /* Loop through different variations of extending the dataset */
+ for (i = 0; i < TWO_NTESTS; i++) {
+ HDmemset(vbuf1, 0, TEST_BUF_SIZE * sizeof(test_valid_fields1));
+ HDmemset(vbuf2, 0, TEST_BUF_SIZE * sizeof(test_valid_fields2));
+ HDmemset(ccbuf, 0, TEST_BUF_SIZE * sizeof(set_t));
+ HDmemset(iibuf, 0, TEST_BUF_SIZE * sizeof(int));
+
+ ext_dims[0] = (hsize_t)((int)prev_dims[0] + two_tests[i][0]);
+ ext_dims[1] = (hsize_t)((int)prev_dims[1] + two_tests[i][1]);
+
+ /* Change the dimension sizes of the dataset */
+ if (H5Dset_extent(did, ext_dims) < 0)
+ FAIL_STACK_ERROR
+
+ /* Initialize data */
+ if (!HDstrcmp(dname, DSET_CMPD_TWO)) {
+ if (H5Dwrite(did, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, cbuf) < 0)
+ FAIL_STACK_ERROR
+ } /* end if */
+ else if (!HDstrcmp(dname, DSET_TWO)) {
+ if (H5Dwrite(did, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, ibuf) < 0)
+ FAIL_STACK_ERROR
+ } /* end else-if */
else
TEST_ERROR
- /* There are changes in dimension sizes */
- if(two_tests[i][0] > 0 || two_tests[i][1] > 0) {
- if(!HDstrcmp(dname, DSET_CMPD_TWO)) {
- if(fields) {
- if(!HDstrcmp(fields, VALID_FIELDS1) || !HDstrcmp(fields, VALID_ESC_FIELDS1)) {
+ /* There are changes in dimension sizes */
+ if (two_tests[i][0] > 0 || two_tests[i][1] > 0) {
+ if (!HDstrcmp(dname, DSET_CMPD_TWO)) {
+ if (fields) {
+ if (!HDstrcmp(fields, VALID_FIELDS1) || !HDstrcmp(fields, VALID_ESC_FIELDS1)) {
/* Retrieve the elmemts in BUF */
- if(H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, vbuf1) < 0)
+ if (H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, vbuf1) < 0)
TEST_ERROR
- if(verify_elmts_two(TWO_CMPD_VALID1, ext_dims, prev_dims, vbuf1, cbuf) < 0)
+ if (verify_elmts_two(TWO_CMPD_VALID1, ext_dims, prev_dims, vbuf1, cbuf) < 0)
TEST_ERROR
} /* end if */
- else if(!HDstrcmp(fields, VALID_FIELDS2) || !HDstrcmp(fields, VALID_ESC_FIELDS2)) {
+ else if (!HDstrcmp(fields, VALID_FIELDS2) || !HDstrcmp(fields, VALID_ESC_FIELDS2)) {
/* Retrieve the elmemts in BUF */
- if(H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, vbuf2) < 0)
+ if (H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, vbuf2) < 0)
TEST_ERROR
- if(verify_elmts_two(TWO_CMPD_VALID2, ext_dims, prev_dims, vbuf2, cbuf) < 0)
+ if (verify_elmts_two(TWO_CMPD_VALID2, ext_dims, prev_dims, vbuf2, cbuf) < 0)
TEST_ERROR
} /* end else-if */
else
TEST_ERROR
- } /* end if */
+ } /* end if */
else {
- /* Retrieve the elmemts in BUF */
- if(H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, ccbuf) < 0)
- TEST_ERROR
- if(verify_elmts_two(TWO_CMPD_NULL, ext_dims, prev_dims, ccbuf, cbuf) < 0)
- TEST_ERROR
- } /* end else */
- } /* end if */
+ /* Retrieve the elmemts in BUF */
+ if (H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, ccbuf) < 0)
+ TEST_ERROR
+ if (verify_elmts_two(TWO_CMPD_NULL, ext_dims, prev_dims, ccbuf, cbuf) < 0)
+ TEST_ERROR
+ } /* end else */
+ } /* end if */
else { /* DSET_TWO */
- /* Retrieve the elmemts in BUF */
- if(H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, iibuf) < 0)
- TEST_ERROR
- if(verify_elmts_two(TWO_NONE, ext_dims, prev_dims, iibuf, ibuf) < 0)
- TEST_ERROR
- } /* end else */
- } /* end if */
+ /* Retrieve the elmemts in BUF */
+ if (H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, iibuf) < 0)
+ TEST_ERROR
+ if (verify_elmts_two(TWO_NONE, ext_dims, prev_dims, iibuf, ibuf) < 0)
+ TEST_ERROR
+ } /* end else */
+ } /* end if */
else {
- /* Verify failure when changes between prev_dims and ext_dims are same/decrease */
- ret = H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, iibuf);
- VERIFY_EQUAL(ret, FAIL)
- } /* end else */
- } /* end for */
+ /* Verify failure when changes between prev_dims and ext_dims are same/decrease */
+ ret = H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, iibuf);
+ VERIFY_EQUAL(ret, FAIL)
+ } /* end else */
+ } /* end for */
/* Closing */
- if(H5Tclose(dtype) < 0)
- FAIL_STACK_ERROR;
- if(H5Dclose(did) < 0)
- FAIL_STACK_ERROR;
- if(H5Fclose(fid) < 0)
- FAIL_STACK_ERROR;
+ if (H5Tclose(dtype) < 0)
+ FAIL_STACK_ERROR;
+ if (H5Dclose(did) < 0)
+ FAIL_STACK_ERROR;
+ if (H5Fclose(fid) < 0)
+ FAIL_STACK_ERROR;
/* Remove the copied file */
HDremove(COPY_FILENAME);
@@ -1316,37 +1318,40 @@ test_LD_elmts_two(const char *file, const char *dname, const char *fields)
return 0;
error:
- H5E_BEGIN_TRY {
- H5Tclose(dtype);
- H5Dclose(did);
- H5Fclose(fid);
- } H5E_END_TRY;
- return(-1);
+ H5E_BEGIN_TRY
+ {
+ H5Tclose(dtype);
+ H5Dclose(did);
+ H5Fclose(fid);
+ }
+ H5E_END_TRY;
+ return (-1);
} /* test_LD_elmts_two() */
/*
* Tests for High Level routines:
* H5LDget_dset_dims(), H5LDget_dset_elmts, H5LDget_dset_type_size()
*/
-int main(void)
+int
+main(void)
{
- int nerrors = 0;
+ int nerrors = 0;
/* Set up temporary buffers for tests: test_LD_elmts_one() & test_LD_elmts_two() */
- if(NULL == (ibuf = (int *)HDmalloc(sizeof(int) * TEST_BUF_SIZE)))
- FAIL_STACK_ERROR;
- if(NULL == (iibuf = (int *)HDmalloc(sizeof(int) * TEST_BUF_SIZE)))
- FAIL_STACK_ERROR;
+ if (NULL == (ibuf = (int *)HDmalloc(sizeof(int) * TEST_BUF_SIZE)))
+ FAIL_STACK_ERROR;
+ if (NULL == (iibuf = (int *)HDmalloc(sizeof(int) * TEST_BUF_SIZE)))
+ FAIL_STACK_ERROR;
- if(NULL == (cbuf = (set_t *)HDmalloc(sizeof(set_t) * TEST_BUF_SIZE)))
- FAIL_STACK_ERROR;
- if(NULL == (ccbuf = (set_t *)HDmalloc(sizeof(set_t) * TEST_BUF_SIZE)))
- FAIL_STACK_ERROR;
+ if (NULL == (cbuf = (set_t *)HDmalloc(sizeof(set_t) * TEST_BUF_SIZE)))
+ FAIL_STACK_ERROR;
+ if (NULL == (ccbuf = (set_t *)HDmalloc(sizeof(set_t) * TEST_BUF_SIZE)))
+ FAIL_STACK_ERROR;
- if(NULL == (vbuf1 = (test_valid_fields1 *)HDmalloc(sizeof(test_valid_fields1) * TEST_BUF_SIZE)))
- FAIL_STACK_ERROR;
- if(NULL == (vbuf2 = (test_valid_fields2 *)HDmalloc(sizeof(test_valid_fields2) * TEST_BUF_SIZE)))
- FAIL_STACK_ERROR;
+ if (NULL == (vbuf1 = (test_valid_fields1 *)HDmalloc(sizeof(test_valid_fields1) * TEST_BUF_SIZE)))
+ FAIL_STACK_ERROR;
+ if (NULL == (vbuf2 = (test_valid_fields2 *)HDmalloc(sizeof(test_valid_fields2) * TEST_BUF_SIZE)))
+ FAIL_STACK_ERROR;
/*
* Testing H5LDget_dset_dims()
@@ -1396,28 +1401,27 @@ int main(void)
nerrors += test_LD_elmts_two(FILE, DSET_CMPD_TWO, VALID_FIELDS2);
/* Free temporary buffers */
- if(ibuf)
+ if (ibuf)
HDfree(ibuf);
- if(iibuf)
+ if (iibuf)
HDfree(iibuf);
- if(cbuf)
+ if (cbuf)
HDfree(cbuf);
- if(ccbuf)
+ if (ccbuf)
HDfree(ccbuf);
- if(vbuf1)
+ if (vbuf1)
HDfree(vbuf1);
- if(vbuf2)
+ if (vbuf2)
HDfree(vbuf2);
/* check for errors */
- if(nerrors)
- goto error;
+ if (nerrors)
+ goto error;
puts("All tests for H5LD high level routines passed.");
- return(0);
+ return (0);
error:
- return(1);
+ return (1);
} /* main() */
-