summaryrefslogtreecommitdiffstats
path: root/test/tattr.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/tattr.c')
-rw-r--r--test/tattr.c6488
1 files changed, 3615 insertions, 2873 deletions
diff --git a/test/tattr.c b/test/tattr.c
index 31a3844..f77f793 100644
--- a/test/tattr.c
+++ b/test/tattr.c
@@ -1,72 +1,68 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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 files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/***********************************************************
-*
-* Test program: tattr
-*
-* Test the attribute functionality
-*
-*************************************************************/
+ *
+ * Test program: tattr
+ *
+ * Test the attribute functionality
+ *
+ *************************************************************/
#include "testhdf5.h"
-#include "h5test.h"
-#include "hdf5.h"
+#include "H5VLnative_private.h"
/*
* This file needs to access private information from the H5O package.
* This file also needs to access the object header testing code.
*/
-#define H5O_PACKAGE
+#define H5O_FRIEND /*suppress error about including H5Opkg */
#define H5O_TESTING
-#include "H5Opkg.h" /* Object headers */
+#include "H5Opkg.h" /* Object headers */
/*
* This file needs to access private information from the H5A package.
* This file also needs to access the attribute testing code.
*/
-#define H5A_PACKAGE
+#define H5A_FRIEND /*suppress error about including H5Apkg */
#define H5A_TESTING
-#include "H5Apkg.h" /* Attributes */
+#include "H5Apkg.h" /* Attributes */
/*
* This file needs to access private information from the H5F package.
* This file also needs to access the file testing code.
*/
-#define H5F_PACKAGE
+#define H5F_FRIEND /*suppress error about including H5Fpkg */
#define H5F_TESTING
-#include "H5Fpkg.h" /* File access */
+#include "H5Fpkg.h" /* File access */
-#define FILENAME "tattr.h5"
-#define NAME_BUF_SIZE 1024
-#define ATTR_NAME_LEN 16
-#define ATTR_MAX_DIMS 7
-#define ATTR_TMP_NAME "a really long temp_name"
-#define CORDER_ITER_STOP 3
+#define FILENAME "tattr.h5"
+#define NAME_BUF_SIZE 1024
+#define ATTR_NAME_LEN 16
+#define ATTR_MAX_DIMS 7
+#define ATTR_TMP_NAME "a really long temp_name"
+#define CORDER_ITER_STOP 3
/* 3-D dataset with fixed dimensions */
-#define SPACE1_RANK 3
-#define SPACE1_DIM1 3
-#define SPACE1_DIM2 15
-#define SPACE1_DIM3 13
+#define SPACE1_RANK 3
+#define SPACE1_DIM1 3
+#define SPACE1_DIM2 15
+#define SPACE1_DIM3 13
/* Dataset Information */
#define DSET1_NAME "Dataset1"
#define DSET2_NAME "Dataset2"
#define DSET3_NAME "Dataset3"
-#define NUM_DSETS 3
+#define NUM_DSETS 3
/* Group Information */
#define GROUP1_NAME "/Group1"
@@ -77,85 +73,107 @@
#define TYPE1_NAME "/Type"
/* Attribute Rank & Dimensions */
-#define ATTR1_NAME "Attr1"
-#define ATTR1_RANK 1
-#define ATTR1_DIM1 3
-int attr_data1[ATTR1_DIM1]={512,-234,98123}; /* Test data for 1st attribute */
+#define ATTR1_NAME "Attr1"
+#define ATTR1_RANK 1
+#define ATTR1_DIM1 3
+int attr_data1[ATTR1_DIM1] = {512, -234, 98123}; /* Test data for 1st attribute */
/* rank & dimensions for another attribute */
-#define ATTR1A_NAME "Attr1_a"
-int attr_data1a[ATTR1_DIM1]={256,11945,-22107};
-
-#define ATTR2_NAME "Attr2"
-#define ATTR2_RANK 2
-#define ATTR2_DIM1 2
-#define ATTR2_DIM2 2
-int attr_data2[ATTR2_DIM1][ATTR2_DIM2]={{7614,-416},{197814,-3}}; /* Test data for 2nd attribute */
-
-#define ATTR3_NAME "Attr3"
-#define ATTR3_RANK 3
-#define ATTR3_DIM1 2
-#define ATTR3_DIM2 2
-#define ATTR3_DIM3 2
-double attr_data3[ATTR3_DIM1][ATTR3_DIM2][ATTR3_DIM3]={{{2.3F,-26.1F}, {0.123F,-10.0F}},{{973.23F,-0.91827F},{2.0F,23.0F}}}; /* Test data for 3rd attribute */
-
-#define ATTR4_NAME "Attr4"
-#define ATTR4_RANK 2
-#define ATTR4_DIM1 2
-#define ATTR4_DIM2 2
-#define ATTR4_FIELDNAME1 "i"
-#define ATTR4_FIELDNAME2 "d"
-#define ATTR4_FIELDNAME3 "c"
-size_t attr4_field1_off=0;
-size_t attr4_field2_off=0;
-size_t attr4_field3_off=0;
+#define ATTR1A_NAME "Attr1_a"
+int attr_data1a[ATTR1_DIM1] = {256, 11945, -22107};
+
+#define ATTR2_NAME "Attr2"
+#define ATTR2_RANK 2
+#define ATTR2_DIM1 2
+#define ATTR2_DIM2 2
+int attr_data2[ATTR2_DIM1][ATTR2_DIM2] = {{7614, -416}, {197814, -3}}; /* Test data for 2nd attribute */
+
+#define ATTR3_NAME "Attr3"
+#define ATTR3_RANK 3
+#define ATTR3_DIM1 2
+#define ATTR3_DIM2 2
+#define ATTR3_DIM3 2
+double attr_data3[ATTR3_DIM1][ATTR3_DIM2][ATTR3_DIM3] = {
+ {{2.3, -26.1}, {0.123, -10.0}}, {{973.23, -0.91827}, {2.0, 23.0}}}; /* Test data for 3rd attribute */
+
+#define ATTR4_NAME "Attr4"
+#define ATTR4_RANK 2
+#define ATTR4_DIM1 2
+#define ATTR4_DIM2 2
+#define ATTR4_FIELDNAME1 "i"
+#define ATTR4_FIELDNAME2 "d"
+#define ATTR4_FIELDNAME3 "c"
+size_t attr4_field1_off = 0;
+size_t attr4_field2_off = 0;
+size_t attr4_field3_off = 0;
struct attr4_struct {
- int i;
+ int i;
double d;
- char c;
- } attr_data4[ATTR4_DIM1][ATTR4_DIM2]={{{3,-26.1F,'d'},{-100000, 0.123F,'3'}},
- {{-23,981724.2F,'Q'},{0,2.0F,'\n'}}}; /* Test data for 4th attribute */
+ char c;
+} attr_data4[ATTR4_DIM1][ATTR4_DIM2] = {
+ {{3, -26.1, 'd'}, {-100000, 0.123, '3'}},
+ {{-23, 981724.2, 'Q'}, {0, 2.0, '\n'}}}; /* Test data for 4th attribute */
-#define ATTR5_NAME "Attr5"
-#define ATTR5_RANK 0
-float attr_data5=-5.123F; /* Test data for 5th attribute */
+#define ATTR5_NAME "Attr5"
+#define ATTR5_RANK 0
+float attr_data5 = -5.123F; /* Test data for 5th attribute */
-#define ATTR6_RANK 3
-#define ATTR6_DIM1 100
-#define ATTR6_DIM2 100
-#define ATTR6_DIM3 100
+#define ATTR6_RANK 3
+#define ATTR6_DIM1 100
+#define ATTR6_DIM2 100
+#define ATTR6_DIM3 100
-#define ATTR7_NAME "attr 1 - 000000"
-#define ATTR8_NAME "attr 2"
+#define ATTR7_NAME "attr 1 - 000000"
+#define ATTR8_NAME "attr 2"
-#define LINK1_NAME "Link1"
+#define LINK1_NAME "Link1"
-#define NATTR_MANY_OLD 350
-#define NATTR_MANY_NEW 35000
+#define NATTR_MANY_OLD 350
+#define NATTR_MANY_NEW 35000
#define BUG2_NATTR 100
#define BUG2_NATTR2 16
-#define BUG3_DSET_NAME "dset"
-#define BUG3_DT_NAME "dt"
-#define BUG3_ATTR_NAME "attr"
+#define BUG3_DSET_NAME "dset"
+#define BUG3_DT_NAME "dt"
+#define BUG3_ATTR_NAME "attr"
+
+/* Used by test_attr_delete_last_dense() */
+#define GRPNAME "grp"
+#define ATTRNAME "attr"
+#define DIM0 100
+#define DIM1 100
+#define RANK 2
+
+/* Used by test_attr_info_null_info_pointer() */
+#define GET_INFO_NULL_POINTER_ATTR_NAME "NullInfoPointerAttr"
+
+/* Used by test_attr_rename_invalid_name() */
+#define INVALID_RENAME_TEST_ATTR_NAME "InvalidRenameTestAttr"
+#define INVALID_RENAME_TEST_NEW_ATTR_NAME "InvalidRenameTestNewAttr"
+
+/* Used by test_attr_get_name_invalid_buf() */
+#define GET_NAME_INVALID_BUF_TEST_ATTR_NAME "InvalidNameBufferTestAttr"
/* Attribute iteration struct */
typedef struct {
- H5_iter_order_t order; /* Direction of iteration */
- unsigned ncalled; /* # of times callback is entered */
- unsigned nskipped; /* # of attributes skipped */
- int stop; /* # of iterations to stop after */
- int64_t curr; /* Current creation order value */
- size_t max_visit; /* Size of "visited attribute" flag array */
- hbool_t *visited; /* Pointer to array of "visited attribute" flags */
+ H5_iter_order_t order; /* Direction of iteration */
+ unsigned ncalled; /* # of times callback is entered */
+ unsigned nskipped; /* # of attributes skipped */
+ int stop; /* # of iterations to stop after */
+ hsize_t curr; /* Current creation order value */
+ size_t max_visit; /* Size of "visited attribute" flag array */
+ hbool_t *visited; /* Pointer to array of "visited attribute" flags */
} attr_iter_info_t;
-static herr_t attr_op1(hid_t loc_id, const char *name, const H5A_info_t *ainfo,
- void *op_data);
+static herr_t attr_op1(hid_t loc_id, const char *name, const H5A_info_t *ainfo, void *op_data);
+/* Global dcpl ID, can be re-set as a generated dcpl for various operations
+ * across multiple tests.
+ * e.g., minimized dataset object headers
+ */
+static hid_t dcpl_g = H5P_DEFAULT;
-
/****************************************************************
**
** test_attr_basic_write(): Test basic H5A (attribute) code.
@@ -165,21 +183,21 @@ static herr_t attr_op1(hid_t loc_id, const char *name, const H5A_info_t *ainfo,
static void
test_attr_basic_write(hid_t fapl)
{
- hid_t fid1; /* HDF5 File IDs */
- hid_t dataset; /* Dataset ID */
- hid_t group; /* Group ID */
- hid_t sid1,sid2; /* Dataspace ID */
- hid_t attr, attr2; /* Attribute ID */
- hsize_t attr_size; /* storage size for attribute */
- ssize_t attr_name_size; /* size of attribute name */
- char *attr_name=NULL; /* name of attribute */
- hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3};
- hsize_t dims2[] = {ATTR1_DIM1};
- hsize_t dims3[] = {ATTR2_DIM1,ATTR2_DIM2};
- int read_data1[ATTR1_DIM1]={0}; /* Buffer for reading 1st attribute */
- int i;
- hid_t ret_id; /* Generic hid_t return value */
- herr_t ret; /* Generic return value */
+ hid_t fid1; /* HDF5 File IDs */
+ hid_t dataset; /* Dataset ID */
+ hid_t group; /* Group ID */
+ hid_t sid1, sid2; /* Dataspace ID */
+ hid_t attr, attr2; /* Attribute ID */
+ hsize_t attr_size; /* storage size for attribute */
+ ssize_t attr_name_size; /* size of attribute name */
+ char *attr_name = NULL; /* name of attribute */
+ hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3};
+ hsize_t dims2[] = {ATTR1_DIM1};
+ hsize_t dims3[] = {ATTR2_DIM1, ATTR2_DIM2};
+ int read_data1[ATTR1_DIM1] = {0}; /* Buffer for reading 1st attribute */
+ int i;
+ hid_t ret_id; /* Generic hid_t return value */
+ herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Basic Scalar Attribute Writing Functions\n"));
@@ -193,7 +211,7 @@ test_attr_basic_write(hid_t fapl)
CHECK(sid1, FAIL, "H5Screate_simple");
/* Create a dataset */
- dataset = H5Dcreate2(fid1, DSET1_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ dataset = H5Dcreate2(fid1, DSET1_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, dcpl_g, H5P_DEFAULT);
CHECK(dataset, FAIL, "H5Dcreate2");
/* Create dataspace for attribute */
@@ -253,9 +271,10 @@ test_attr_basic_write(hid_t fapl)
CHECK(ret, FAIL, "H5Aread");
/* Verify values read in */
- for(i = 0; i < ATTR1_DIM1; i++)
- if(attr_data1[i] != read_data1[i])
- TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n", __LINE__, i, attr_data1[i], i, read_data1[i]);
+ for (i = 0; i < ATTR1_DIM1; i++)
+ if (attr_data1[i] != read_data1[i])
+ TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n", __LINE__, i,
+ attr_data1[i], i, read_data1[i]);
/* Close attribute */
ret = H5Aclose(attr);
@@ -277,11 +296,11 @@ test_attr_basic_write(hid_t fapl)
attr_name_size = H5Aget_name(attr, (size_t)0, NULL);
CHECK(attr_name_size, FAIL, "H5Aget_name");
- if(attr_name_size > 0) {
- attr_name = (char*)HDcalloc((size_t)(attr_name_size + 1), sizeof(char));
- CHECK(attr_name, NULL, "HDcalloc");
-
- if(attr_name) {
+ if (attr_name_size > 0) {
+ attr_name = (char *)HDcalloc((size_t)(attr_name_size + 1), sizeof(char));
+ CHECK_PTR(attr_name, "HDcalloc");
+
+ if (attr_name) {
ret = (herr_t)H5Aget_name(attr, (size_t)(attr_name_size + 1), attr_name);
CHECK(ret, FAIL, "H5Aget_name");
ret = HDstrcmp(attr_name, ATTR_TMP_NAME);
@@ -290,16 +309,17 @@ test_attr_basic_write(hid_t fapl)
HDfree(attr_name);
attr_name = NULL;
} /* end if */
- } /* end if */
+ } /* end if */
/* Read attribute information immediately, without closing attribute */
ret = H5Aread(attr, H5T_NATIVE_INT, read_data1);
CHECK(ret, FAIL, "H5Aread");
/* Verify values read in */
- for(i = 0; i < ATTR1_DIM1; i++)
- if(attr_data1[i] != read_data1[i])
- TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n", __LINE__, i, attr_data1[i], i, read_data1[i]);
+ for (i = 0; i < ATTR1_DIM1; i++)
+ if (attr_data1[i] != read_data1[i])
+ TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n", __LINE__, i,
+ attr_data1[i], i, read_data1[i]);
/* Close attribute */
ret = H5Aclose(attr);
@@ -313,11 +333,11 @@ test_attr_basic_write(hid_t fapl)
attr_name_size = H5Aget_name(attr2, (size_t)0, NULL);
CHECK(attr_name_size, FAIL, "H5Aget_name");
- if(attr_name_size > 0) {
- attr_name = (char*)HDcalloc((size_t)(attr_name_size+1), sizeof(char));
- CHECK(attr_name, NULL, "HDcalloc");
-
- if(attr_name) {
+ if (attr_name_size > 0) {
+ attr_name = (char *)HDcalloc((size_t)(attr_name_size + 1), sizeof(char));
+ CHECK_PTR(attr_name, "HDcalloc");
+
+ if (attr_name) {
ret = (herr_t)H5Aget_name(attr2, (size_t)(attr_name_size + 1), attr_name);
CHECK(ret, FAIL, "H5Aget_name");
ret = HDstrcmp(attr_name, ATTR1A_NAME);
@@ -326,16 +346,17 @@ test_attr_basic_write(hid_t fapl)
HDfree(attr_name);
attr_name = NULL;
} /* end if */
- } /* end if */
+ } /* end if */
/* Read attribute information immediately, without closing attribute */
ret = H5Aread(attr2, H5T_NATIVE_INT, read_data1);
CHECK(ret, FAIL, "H5Aread");
/* Verify values read in */
- for(i = 0; i < ATTR1_DIM1; i++)
- if(attr_data1a[i] != read_data1[i])
- TestErrPrintf("%d: attribute data different: attr_data1a[%d]=%d, read_data1[%d]=%d\n", __LINE__, i, attr_data1a[i], i, read_data1[i]);
+ for (i = 0; i < ATTR1_DIM1; i++)
+ if (attr_data1a[i] != read_data1[i])
+ TestErrPrintf("%d: attribute data different: attr_data1a[%d]=%d, read_data1[%d]=%d\n", __LINE__,
+ i, attr_data1a[i], i, read_data1[i]);
/* Close attribute */
ret = H5Aclose(attr2);
@@ -393,9 +414,8 @@ test_attr_basic_write(hid_t fapl)
/* Close file */
ret = H5Fclose(fid1);
CHECK(ret, FAIL, "H5Fclose");
-} /* test_attr_basic_write() */
+} /* test_attr_basic_write() */
-
/****************************************************************
**
** test_attr_basic_read(): Test basic H5A (attribute) code.
@@ -404,15 +424,15 @@ test_attr_basic_write(hid_t fapl)
static void
test_attr_basic_read(hid_t fapl)
{
- hid_t fid1; /* HDF5 File IDs */
- hid_t dataset; /* Dataset ID */
- hid_t group; /* Group ID */
- hid_t attr; /* Attribute ID */
- H5O_info_t oinfo; /* Object info */
- int read_data1[ATTR1_DIM1] = {0}; /* Buffer for reading 1st attribute */
+ hid_t fid1; /* HDF5 File IDs */
+ hid_t dataset; /* Dataset ID */
+ hid_t group; /* Group ID */
+ hid_t attr; /* Attribute ID */
+ H5O_info2_t oinfo; /* Object info */
+ int read_data1[ATTR1_DIM1] = {0}; /* Buffer for reading 1st attribute */
int read_data2[ATTR2_DIM1][ATTR2_DIM2] = {{0}}; /* Buffer for reading 2nd attribute */
- int i, j; /* Local index variables */
- herr_t ret; /* Generic return value */
+ int i, j; /* Local index variables */
+ herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Basic Attribute Functions\n"));
@@ -426,9 +446,9 @@ test_attr_basic_read(hid_t fapl)
CHECK(dataset, FAIL, "H5Dopen2");
/* Verify the correct number of attributes */
- ret = H5Oget_info(dataset, &oinfo);
- CHECK(ret, FAIL, "H5Oget_info");
- VERIFY(oinfo.num_attrs, 2, "H5Oget_info");
+ ret = H5Oget_info3(dataset, &oinfo, H5O_INFO_NUM_ATTRS);
+ CHECK(ret, FAIL, "H5Oget_info3");
+ VERIFY(oinfo.num_attrs, 2, "H5Oget_info3");
/* Open first attribute for the dataset */
attr = H5Aopen(dataset, ATTR_TMP_NAME, H5P_DEFAULT);
@@ -439,9 +459,10 @@ test_attr_basic_read(hid_t fapl)
CHECK(ret, FAIL, "H5Aread");
/* Verify values read in */
- for(i = 0; i < ATTR1_DIM1; i++)
- if(attr_data1[i] != read_data1[i])
- TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n", __LINE__, i, attr_data1[i], i, read_data1[i]);
+ for (i = 0; i < ATTR1_DIM1; i++)
+ if (attr_data1[i] != read_data1[i])
+ TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n", __LINE__, i,
+ attr_data1[i], i, read_data1[i]);
/* Close attribute */
ret = H5Aclose(attr);
@@ -455,9 +476,9 @@ test_attr_basic_read(hid_t fapl)
CHECK(group, FAIL, "H5Gopen2");
/* Verify the correct number of attributes */
- ret = H5Oget_info(group, &oinfo);
- CHECK(ret, FAIL, "H5Oget_info");
- VERIFY(oinfo.num_attrs, 1, "H5Oget_info");
+ ret = H5Oget_info3(group, &oinfo, H5O_INFO_NUM_ATTRS);
+ CHECK(ret, FAIL, "H5Oget_info3");
+ VERIFY(oinfo.num_attrs, 1, "H5Oget_info3");
/* Open the attribute for the group */
attr = H5Aopen(group, ATTR2_NAME, H5P_DEFAULT);
@@ -468,10 +489,11 @@ test_attr_basic_read(hid_t fapl)
CHECK(ret, FAIL, "H5Aread");
/* Verify values read in */
- for(i = 0; i < ATTR2_DIM1; i++)
- for(j = 0; j < ATTR2_DIM2; j++)
- if(attr_data2[i][j] != read_data2[i][j])
- TestErrPrintf("%d: attribute data different: attr_data2[%d][%d]=%d, read_data2[%d][%d]=%d\n", __LINE__, i, j, attr_data2[i][j], i, j, read_data1[i]);
+ for (i = 0; i < ATTR2_DIM1; i++)
+ for (j = 0; j < ATTR2_DIM2; j++)
+ if (attr_data2[i][j] != read_data2[i][j])
+ TestErrPrintf("%d: attribute data different: attr_data2[%d][%d]=%d, read_data2[%d][%d]=%d\n",
+ __LINE__, i, j, attr_data2[i][j], i, j, read_data1[i]);
/* Close attribute */
ret = H5Aclose(attr);
@@ -484,9 +506,8 @@ test_attr_basic_read(hid_t fapl)
/* Close file */
ret = H5Fclose(fid1);
CHECK(ret, FAIL, "H5Fclose");
-} /* test_attr_basic_read() */
+} /* test_attr_basic_read() */
-
/****************************************************************
**
** test_attr_flush(): Test H5A (attribute) code for performing
@@ -496,13 +517,13 @@ test_attr_basic_read(hid_t fapl)
static void
test_attr_flush(hid_t fapl)
{
- hid_t fil, /* File ID */
- att, /* Attribute ID */
- spc, /* Dataspace ID */
- set; /* Dataset ID */
- double wdata=3.14159F; /* Data to write */
- double rdata; /* Data read in */
- herr_t ret; /* Generic return value */
+ hid_t fil, /* File ID */
+ att, /* Attribute ID */
+ spc, /* Dataspace ID */
+ set; /* Dataset ID */
+ double wdata = 3.14159; /* Data to write */
+ double rdata; /* Data read in */
+ herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Attribute Flushing\n"));
@@ -513,47 +534,46 @@ test_attr_flush(hid_t fapl)
spc = H5Screate(H5S_SCALAR);
CHECK(spc, FAIL, "H5Screate");
- set = H5Dcreate2(fil, DSET1_NAME, H5T_NATIVE_DOUBLE, spc, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ set = H5Dcreate2(fil, DSET1_NAME, H5T_NATIVE_DOUBLE, spc, H5P_DEFAULT, dcpl_g, H5P_DEFAULT);
CHECK(set, FAIL, "H5Dcreate2");
att = H5Acreate2(set, ATTR1_NAME, H5T_NATIVE_DOUBLE, spc, H5P_DEFAULT, H5P_DEFAULT);
CHECK(att, FAIL, "H5Acreate2");
- ret=H5Aread(att, H5T_NATIVE_DOUBLE, &rdata);
+ ret = H5Aread(att, H5T_NATIVE_DOUBLE, &rdata);
CHECK(ret, FAIL, "H5Awrite");
- if(!DBL_ABS_EQUAL(rdata,0.0F))
- TestErrPrintf("attribute value wrong: rdata=%f, should be %f\n",rdata,(double)0.0F);
+ if (!H5_DBL_ABS_EQUAL(rdata, 0.0))
+ TestErrPrintf("attribute value wrong: rdata=%f, should be %f\n", rdata, 0.0);
- ret=H5Fflush(fil, H5F_SCOPE_GLOBAL);
+ ret = H5Fflush(fil, H5F_SCOPE_GLOBAL);
CHECK(ret, FAIL, "H5Fflush");
- ret=H5Aread(att, H5T_NATIVE_DOUBLE, &rdata);
+ ret = H5Aread(att, H5T_NATIVE_DOUBLE, &rdata);
CHECK(ret, FAIL, "H5Awrite");
- if(!DBL_ABS_EQUAL(rdata,0.0F))
- TestErrPrintf("attribute value wrong: rdata=%f, should be %f\n",rdata,(double)0.0F);
+ if (!H5_DBL_ABS_EQUAL(rdata, 0.0))
+ TestErrPrintf("attribute value wrong: rdata=%f, should be %f\n", rdata, 0.0);
- ret=H5Awrite(att, H5T_NATIVE_DOUBLE, &wdata);
+ ret = H5Awrite(att, H5T_NATIVE_DOUBLE, &wdata);
CHECK(ret, FAIL, "H5Awrite");
- ret=H5Aread(att, H5T_NATIVE_DOUBLE, &rdata);
+ ret = H5Aread(att, H5T_NATIVE_DOUBLE, &rdata);
CHECK(ret, FAIL, "H5Awrite");
- if(!DBL_ABS_EQUAL(rdata,wdata))
- TestErrPrintf("attribute value wrong: rdata=%f, should be %f\n",rdata,wdata);
+ if (!H5_DBL_ABS_EQUAL(rdata, wdata))
+ TestErrPrintf("attribute value wrong: rdata=%f, should be %f\n", rdata, wdata);
- ret=H5Sclose(spc);
+ ret = H5Sclose(spc);
CHECK(ret, FAIL, "H5Sclose");
- ret=H5Aclose(att);
+ ret = H5Aclose(att);
CHECK(ret, FAIL, "H5Aclose");
- ret=H5Dclose(set);
+ ret = H5Dclose(set);
CHECK(ret, FAIL, "H5Dclose");
- ret=H5Fclose(fil);
+ ret = H5Fclose(fil);
CHECK(ret, FAIL, "H5Fclose");
-} /* test_attr_flush() */
+} /* test_attr_flush() */
-
/****************************************************************
**
** test_attr_plist(): Test Attribute Creation Property Lists
@@ -562,111 +582,121 @@ test_attr_flush(hid_t fapl)
static void
test_attr_plist(hid_t fapl)
{
- hid_t fid1; /* HDF5 File IDs */
- hid_t dataset; /* Dataset ID */
- hid_t sid1,sid2; /* Dataspace ID */
- hid_t attr; /* Attribute ID */
- hid_t plist; /* Property list ID */
- hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3};
- hsize_t dims2[] = {ATTR1_DIM1};
- H5T_cset_t cset; /* Character set for attributes */
- herr_t ret; /* Generic return value */
+ hid_t fid = H5I_INVALID_HID; /* File ID */
+ hid_t did = H5I_INVALID_HID; /* Dataset ID */
+ hid_t dsid = H5I_INVALID_HID; /* Dataspace ID (for dataset) */
+ hid_t asid = H5I_INVALID_HID; /* Dataspace ID (for attribute) */
+ hid_t aid = H5I_INVALID_HID; /* Attribute ID */
+ hid_t acpl_id = H5I_INVALID_HID; /* Attribute creation property list ID */
+ hid_t aapl_id = H5I_INVALID_HID; /* Attribute access property list ID */
+ hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3};
+ hsize_t dims2[] = {ATTR1_DIM1};
+ H5T_cset_t cset; /* Character set for attributes */
+ herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Attribute Property Lists\n"));
/* Create file */
- fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
- CHECK(fid1, FAIL, "H5Fcreate");
+ fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
+ CHECK(fid, H5I_INVALID_HID, "H5Fcreate");
/* Create dataspace for dataset */
- sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL);
- CHECK(sid1, FAIL, "H5Screate_simple");
+ dsid = H5Screate_simple(SPACE1_RANK, dims1, NULL);
+ CHECK(dsid, H5I_INVALID_HID, "H5Screate_simple");
/* Create a dataset */
- dataset = H5Dcreate2(fid1, DSET1_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- CHECK(dataset, FAIL, "H5Dcreate2");
+ did = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, dsid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT);
+ CHECK(did, H5I_INVALID_HID, "H5Dcreate2");
/* Create dataspace for attribute */
- sid2 = H5Screate_simple(ATTR1_RANK, dims2, NULL);
- CHECK(sid2, FAIL, "H5Screate_simple");
+ asid = H5Screate_simple(ATTR1_RANK, dims2, NULL);
+ CHECK(asid, H5I_INVALID_HID, "H5Screate_simple");
- /* Create default property list for attribute */
- plist = H5Pcreate(H5P_ATTRIBUTE_CREATE);
- CHECK(plist, FAIL, "H5Pcreate");
+ /* Create default creation property list for attribute */
+ acpl_id = H5Pcreate(H5P_ATTRIBUTE_CREATE);
+ CHECK(acpl_id, H5I_INVALID_HID, "H5Pcreate");
+
+ /* Create default access property list for attribute
+ * This currently has no properties, but we need to test its creation
+ * and use.
+ */
+ aapl_id = H5Pcreate(H5P_ATTRIBUTE_ACCESS);
+ CHECK(aapl_id, H5I_INVALID_HID, "H5Pcreate");
/* Get the character encoding and ensure that it is the default (ASCII) */
- ret = H5Pget_char_encoding(plist, &cset);
+ ret = H5Pget_char_encoding(acpl_id, &cset);
CHECK(ret, FAIL, "H5Pget_char_encoding");
VERIFY(cset, H5T_CSET_ASCII, "H5Pget_char_encoding");
/* Create an attribute for the dataset using the property list */
- attr = H5Acreate2(dataset, ATTR1_NAME, H5T_NATIVE_INT, sid2, plist, H5P_DEFAULT);
- CHECK(attr, FAIL, "H5Acreate2");
+ aid = H5Acreate2(did, ATTR1_NAME, H5T_NATIVE_INT, asid, acpl_id, aapl_id);
+ CHECK(aid, H5I_INVALID_HID, "H5Acreate2");
- /* Close the property list, and get the attribute's property list */
- ret = H5Pclose(plist);
+ /* Close the property list, and get the attribute's creation property list */
+ ret = H5Pclose(acpl_id);
CHECK(ret, FAIL, "H5Pclose");
- plist = H5Aget_create_plist(attr);
- CHECK(plist, FAIL, "H5Aget_create_plist");
+ acpl_id = H5Aget_create_plist(aid);
+ CHECK(acpl_id, H5I_INVALID_HID, "H5Aget_create_plist");
/* Get the character encoding and ensure that it is the default (ASCII) */
- ret = H5Pget_char_encoding(plist, &cset);
+ ret = H5Pget_char_encoding(acpl_id, &cset);
CHECK(ret, FAIL, "H5Pget_char_encoding");
VERIFY(cset, H5T_CSET_ASCII, "H5Pget_char_encoding");
/* Close the property list and attribute */
- ret = H5Pclose(plist);
+ ret = H5Pclose(acpl_id);
CHECK(ret, FAIL, "H5Pclose");
- ret = H5Aclose(attr);
+ ret = H5Aclose(aid);
CHECK(ret, FAIL, "H5Aclose");
/* Create a new property list and modify it to use a different encoding */
- plist = H5Pcreate(H5P_ATTRIBUTE_CREATE);
- CHECK(plist, FAIL, "H5Pcreate");
- ret = H5Pset_char_encoding(plist, H5T_CSET_UTF8);
+ acpl_id = H5Pcreate(H5P_ATTRIBUTE_CREATE);
+ CHECK(acpl_id, H5I_INVALID_HID, "H5Pcreate");
+ ret = H5Pset_char_encoding(acpl_id, H5T_CSET_UTF8);
CHECK(ret, FAIL, "H5Pset_char_encoding");
/* Get the character encoding and ensure that it has been changed */
- ret = H5Pget_char_encoding(plist, &cset);
+ ret = H5Pget_char_encoding(acpl_id, &cset);
CHECK(ret, FAIL, "H5Pget_char_encoding");
VERIFY(cset, H5T_CSET_UTF8, "H5Pget_char_encoding");
/* Create an attribute for the dataset using the modified property list */
- attr = H5Acreate2(dataset, ATTR2_NAME, H5T_NATIVE_INT, sid2, plist, H5P_DEFAULT);
- CHECK(attr, FAIL, "H5Acreate2");
+ aid = H5Acreate2(did, ATTR2_NAME, H5T_NATIVE_INT, asid, acpl_id, aapl_id);
+ CHECK(aid, H5I_INVALID_HID, "H5Acreate2");
/* Close the property list and attribute */
- ret = H5Pclose(plist);
+ ret = H5Pclose(acpl_id);
CHECK(ret, FAIL, "H5Pclose");
- ret = H5Aclose(attr);
+ ret = H5Aclose(aid);
CHECK(ret, FAIL, "H5Aclose");
/* Re-open the second attribute and ensure that its character encoding is correct */
- attr = H5Aopen(dataset, ATTR2_NAME, H5P_DEFAULT);
- CHECK(attr, FAIL, "H5Aopen");
- plist = H5Aget_create_plist(attr);
- CHECK(plist, FAIL, "H5Aget_create_plist");
- ret = H5Pget_char_encoding(plist, &cset);
+ aid = H5Aopen(did, ATTR2_NAME, H5P_DEFAULT);
+ CHECK(aid, H5I_INVALID_HID, "H5Aopen");
+ acpl_id = H5Aget_create_plist(aid);
+ CHECK(acpl_id, H5I_INVALID_HID, "H5Aget_create_plist");
+ ret = H5Pget_char_encoding(acpl_id, &cset);
CHECK(ret, FAIL, "H5Pget_char_encoding");
VERIFY(cset, H5T_CSET_UTF8, "H5Pget_char_encoding");
/* Close everything */
- ret=H5Sclose(sid1);
+ ret = H5Sclose(dsid);
CHECK(ret, FAIL, "H5Sclose");
- ret=H5Sclose(sid2);
+ ret = H5Sclose(asid);
CHECK(ret, FAIL, "H5Sclose");
- ret = H5Pclose(plist);
+ ret = H5Pclose(aapl_id);
CHECK(ret, FAIL, "H5Pclose");
- ret=H5Aclose(attr);
+ ret = H5Pclose(acpl_id);
+ CHECK(ret, FAIL, "H5Pclose");
+ ret = H5Aclose(aid);
CHECK(ret, FAIL, "H5Aclose");
- ret=H5Dclose(dataset);
+ ret = H5Dclose(did);
CHECK(ret, FAIL, "H5Dclose");
- ret=H5Fclose(fid1);
+ ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
-} /* test_attr_plist() */
+} /* test_attr_plist() */
-
/****************************************************************
**
** test_attr_compound_write(): Test H5A (attribute) code.
@@ -676,15 +706,15 @@ test_attr_plist(hid_t fapl)
static void
test_attr_compound_write(hid_t fapl)
{
- hid_t fid1; /* HDF5 File IDs */
- hid_t dataset; /* Dataset ID */
- hid_t tid1; /* Attribute datatype ID */
- hid_t sid1,sid2; /* Dataspace ID */
- hid_t attr; /* Attribute ID */
- hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3};
- hsize_t dims2[] = {ATTR4_DIM1,ATTR4_DIM2};
- hid_t ret_id; /* Generic hid_t return value */
- herr_t ret; /* Generic return value */
+ hid_t fid1; /* HDF5 File IDs */
+ hid_t dataset; /* Dataset ID */
+ hid_t tid1; /* Attribute datatype ID */
+ hid_t sid1, sid2; /* Dataspace ID */
+ hid_t attr; /* Attribute ID */
+ hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3};
+ hsize_t dims2[] = {ATTR4_DIM1, ATTR4_DIM2};
+ hid_t ret_id; /* Generic hid_t return value */
+ herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Multiple Attribute Functions\n"));
@@ -698,7 +728,7 @@ test_attr_compound_write(hid_t fapl)
CHECK(sid1, FAIL, "H5Screate_simple");
/* Create a dataset */
- dataset = H5Dcreate2(fid1, DSET1_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ dataset = H5Dcreate2(fid1, DSET1_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, dcpl_g, H5P_DEFAULT);
CHECK(dataset, FAIL, "H5Dcreate2");
/* Close dataset's dataspace */
@@ -709,13 +739,13 @@ test_attr_compound_write(hid_t fapl)
tid1 = H5Tcreate(H5T_COMPOUND, sizeof(struct attr4_struct));
CHECK(tid1, FAIL, "H5Tcreate");
attr4_field1_off = HOFFSET(struct attr4_struct, i);
- ret = H5Tinsert(tid1, ATTR4_FIELDNAME1, attr4_field1_off, H5T_NATIVE_INT);
+ ret = H5Tinsert(tid1, ATTR4_FIELDNAME1, attr4_field1_off, H5T_NATIVE_INT);
CHECK(ret, FAIL, "H5Tinsert");
attr4_field2_off = HOFFSET(struct attr4_struct, d);
- ret = H5Tinsert(tid1, ATTR4_FIELDNAME2, attr4_field2_off, H5T_NATIVE_DOUBLE);
+ ret = H5Tinsert(tid1, ATTR4_FIELDNAME2, attr4_field2_off, H5T_NATIVE_DOUBLE);
CHECK(ret, FAIL, "H5Tinsert");
attr4_field3_off = HOFFSET(struct attr4_struct, c);
- ret = H5Tinsert(tid1, ATTR4_FIELDNAME3, attr4_field3_off, H5T_NATIVE_SCHAR);
+ ret = H5Tinsert(tid1, ATTR4_FIELDNAME3, attr4_field3_off, H5T_NATIVE_SCHAR);
CHECK(ret, FAIL, "H5Tinsert");
/* Create dataspace for 1st attribute */
@@ -753,9 +783,8 @@ test_attr_compound_write(hid_t fapl)
/* Close file */
ret = H5Fclose(fid1);
CHECK(ret, FAIL, "H5Fclose");
-} /* test_attr_compound_write() */
+} /* test_attr_compound_write() */
-
/****************************************************************
**
** test_attr_compound_read(): Test basic H5A (attribute) code.
@@ -764,26 +793,26 @@ test_attr_compound_write(hid_t fapl)
static void
test_attr_compound_read(hid_t fapl)
{
- hid_t fid1; /* HDF5 File ID */
- hid_t dataset; /* Dataset ID */
- hid_t space; /* Attribute dataspace */
- hid_t type; /* Attribute datatype */
- hid_t attr; /* Attribute ID */
- char attr_name[ATTR_NAME_LEN]; /* Buffer for attribute names */
- int rank; /* Attribute rank */
- hsize_t dims[ATTR_MAX_DIMS]; /* Attribute dimensions */
- H5T_class_t t_class; /* Attribute datatype class */
- H5T_order_t order; /* Attribute datatype order */
- size_t size; /* Attribute datatype size as stored in file */
- int fields; /* # of Attribute datatype fields */
- char *fieldname; /* Name of a field */
- size_t offset; /* Attribute datatype field offset */
- hid_t field; /* Attribute field datatype */
+ hid_t fid1; /* HDF5 File ID */
+ hid_t dataset; /* Dataset ID */
+ hid_t space; /* Attribute dataspace */
+ hid_t type; /* Attribute datatype */
+ hid_t attr; /* Attribute ID */
+ char attr_name[ATTR_NAME_LEN]; /* Buffer for attribute names */
+ int rank; /* Attribute rank */
+ hsize_t dims[ATTR_MAX_DIMS]; /* Attribute dimensions */
+ H5T_class_t t_class; /* Attribute datatype class */
+ H5T_order_t order; /* Attribute datatype order */
+ size_t size; /* Attribute datatype size as stored in file */
+ int fields; /* # of Attribute datatype fields */
+ char *fieldname; /* Name of a field */
+ size_t offset; /* Attribute datatype field offset */
+ hid_t field; /* Attribute field datatype */
struct attr4_struct read_data4[ATTR4_DIM1][ATTR4_DIM2]; /* Buffer for reading 4th attribute */
- size_t name_len; /* Length of attribute name */
- H5O_info_t oinfo; /* Object info */
- int i, j; /* Local index variables */
- herr_t ret; /* Generic return value */
+ ssize_t name_len; /* Length of attribute name */
+ H5O_info2_t oinfo; /* Object info */
+ int i, j; /* Local index variables */
+ herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Basic Attribute Functions\n"));
@@ -797,12 +826,13 @@ test_attr_compound_read(hid_t fapl)
CHECK(dataset, FAIL, "H5Dopen2");
/* Verify the correct number of attributes */
- ret = H5Oget_info(dataset, &oinfo);
- CHECK(ret, FAIL, "H5Oget_info");
- VERIFY(oinfo.num_attrs, 1, "H5Oget_info");
+ ret = H5Oget_info3(dataset, &oinfo, H5O_INFO_NUM_ATTRS);
+ CHECK(ret, FAIL, "H5Oget_info3");
+ VERIFY(oinfo.num_attrs, 1, "H5Oget_info3");
/* Open 1st attribute for the dataset */
- attr = H5Aopen_by_idx(dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, H5P_DEFAULT, H5P_DEFAULT);
+ attr =
+ H5Aopen_by_idx(dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Aopen_by_idx");
/* Verify Dataspace */
@@ -812,9 +842,9 @@ test_attr_compound_read(hid_t fapl)
VERIFY(rank, ATTR4_RANK, "H5Sget_simple_extent_ndims");
ret = H5Sget_simple_extent_dims(space, dims, NULL);
CHECK(ret, FAIL, "H5Sget_simple_extent_dims");
- if(dims[0] != ATTR4_DIM1)
+ if (dims[0] != ATTR4_DIM1)
TestErrPrintf("attribute dimensions different: dims[0]=%d, should be %d\n", (int)dims[0], ATTR4_DIM1);
- if(dims[1] != ATTR4_DIM2)
+ if (dims[1] != ATTR4_DIM2)
TestErrPrintf("attribute dimensions different: dims[1]=%d, should be %d\n", (int)dims[1], ATTR4_DIM2);
H5Sclose(space);
@@ -825,14 +855,13 @@ test_attr_compound_read(hid_t fapl)
VERIFY(t_class, H5T_COMPOUND, "H5Tget_class");
fields = H5Tget_nmembers(type);
VERIFY(fields, 3, "H5Tget_nmembers");
- for(i = 0; i < fields; i++) {
+ for (i = 0; i < fields; i++) {
fieldname = H5Tget_member_name(type, (unsigned)i);
- if(!(HDstrcmp(fieldname, ATTR4_FIELDNAME1) ||
- HDstrcmp(fieldname, ATTR4_FIELDNAME2) ||
- HDstrcmp(fieldname, ATTR4_FIELDNAME3)))
+ if (!(HDstrcmp(fieldname, ATTR4_FIELDNAME1) != 0 || HDstrcmp(fieldname, ATTR4_FIELDNAME2) != 0 ||
+ HDstrcmp(fieldname, ATTR4_FIELDNAME3) != 0))
TestErrPrintf("invalid field name for field #%d: %s\n", i, fieldname);
H5free_memory(fieldname);
- } /* end for */
+ } /* end for */
offset = H5Tget_member_offset(type, 0);
VERIFY(offset, attr4_field1_off, "H5Tget_member_offset");
offset = H5Tget_member_offset(type, 1);
@@ -846,7 +875,7 @@ test_attr_compound_read(hid_t fapl)
t_class = H5Tget_class(field);
VERIFY(t_class, H5T_INTEGER, "H5Tget_class");
order = H5Tget_order(field);
- VERIFY(order, H5Tget_order(H5T_NATIVE_INT), "H5Tget_order");
+ VERIFY_TYPE(order, H5Tget_order(H5T_NATIVE_INT), H5T_order_t, "%d", "H5Tget_order");
size = H5Tget_size(field);
VERIFY(size, H5Tget_size(H5T_NATIVE_INT), "H5Tget_size");
H5Tclose(field);
@@ -855,7 +884,7 @@ test_attr_compound_read(hid_t fapl)
t_class = H5Tget_class(field);
VERIFY(t_class, H5T_FLOAT, "H5Tget_class");
order = H5Tget_order(field);
- VERIFY(order, H5Tget_order(H5T_NATIVE_DOUBLE), "H5Tget_order");
+ VERIFY_TYPE(order, H5Tget_order(H5T_NATIVE_DOUBLE), H5T_order_t, "%d", "H5Tget_order");
size = H5Tget_size(field);
VERIFY(size, H5Tget_size(H5T_NATIVE_DOUBLE), "H5Tget_size");
H5Tclose(field);
@@ -864,7 +893,7 @@ test_attr_compound_read(hid_t fapl)
t_class = H5Tget_class(field);
VERIFY(t_class, H5T_INTEGER, "H5Tget_class");
order = H5Tget_order(field);
- VERIFY(order, H5Tget_order(H5T_NATIVE_SCHAR), "H5Tget_order");
+ VERIFY_TYPE(order, H5Tget_order(H5T_NATIVE_SCHAR), H5T_order_t, "%d", "H5Tget_order");
size = H5Tget_size(field);
VERIFY(size, H5Tget_size(H5T_NATIVE_SCHAR), "H5Tget_size");
H5Tclose(field);
@@ -874,18 +903,22 @@ test_attr_compound_read(hid_t fapl)
CHECK(ret, FAIL, "H5Aread");
/* Verify values read in */
- for(i = 0; i < ATTR4_DIM1; i++)
- for(j = 0; j < ATTR4_DIM2; j++)
- if(HDmemcmp(&attr_data4[i][j], &read_data4[i][j], sizeof(struct attr4_struct))) {
- printf("%d: attribute data different: attr_data4[%d][%d].i=%d, read_data4[%d][%d].i=%d\n", __LINE__, i, j, attr_data4[i][j].i, i, j, read_data4[i][j].i);
- printf("%d: attribute data different: attr_data4[%d][%d].d=%f, read_data4[%d][%d].d=%f\n", __LINE__, i, j, attr_data4[i][j].d, i, j, read_data4[i][j].d);
- TestErrPrintf("%d: attribute data different: attr_data4[%d][%d].c=%c, read_data4[%d][%d].c=%c\n", __LINE__, i, j, attr_data4[i][j].c, i, j, read_data4[i][j].c);
- } /* end if */
+ for (i = 0; i < ATTR4_DIM1; i++)
+ for (j = 0; j < ATTR4_DIM2; j++)
+ if (HDmemcmp(&attr_data4[i][j], &read_data4[i][j], sizeof(struct attr4_struct)) != 0) {
+ HDprintf("%d: attribute data different: attr_data4[%d][%d].i=%d, read_data4[%d][%d].i=%d\n",
+ __LINE__, i, j, attr_data4[i][j].i, i, j, read_data4[i][j].i);
+ HDprintf("%d: attribute data different: attr_data4[%d][%d].d=%f, read_data4[%d][%d].d=%f\n",
+ __LINE__, i, j, attr_data4[i][j].d, i, j, read_data4[i][j].d);
+ TestErrPrintf(
+ "%d: attribute data different: attr_data4[%d][%d].c=%c, read_data4[%d][%d].c=%c\n",
+ __LINE__, i, j, attr_data4[i][j].c, i, j, read_data4[i][j].c);
+ } /* end if */
/* Verify Name */
name_len = H5Aget_name(attr, (size_t)ATTR_NAME_LEN, attr_name);
VERIFY(name_len, HDstrlen(ATTR4_NAME), "H5Aget_name");
- if(HDstrcmp(attr_name, ATTR4_NAME))
+ if (HDstrcmp(attr_name, ATTR4_NAME) != 0)
TestErrPrintf("attribute name different: attr_name=%s, should be %s\n", attr_name, ATTR4_NAME);
/* Close attribute datatype */
@@ -903,9 +936,8 @@ test_attr_compound_read(hid_t fapl)
/* Close file */
ret = H5Fclose(fid1);
CHECK(ret, FAIL, "H5Fclose");
-} /* test_attr_compound_read() */
+} /* test_attr_compound_read() */
-
/****************************************************************
**
** test_attr_scalar_write(): Test scalar H5A (attribute) writing code.
@@ -914,13 +946,13 @@ test_attr_compound_read(hid_t fapl)
static void
test_attr_scalar_write(hid_t fapl)
{
- hid_t fid1; /* HDF5 File IDs */
- hid_t dataset; /* Dataset ID */
- hid_t sid1,sid2; /* Dataspace ID */
- hid_t attr; /* Attribute ID */
- hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3};
- hid_t ret_id; /* Generic hid_t return value */
- herr_t ret; /* Generic return value */
+ hid_t fid1; /* HDF5 File IDs */
+ hid_t dataset; /* Dataset ID */
+ hid_t sid1, sid2; /* Dataspace ID */
+ hid_t attr; /* Attribute ID */
+ hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3};
+ hid_t ret_id; /* Generic hid_t return value */
+ herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Basic Attribute Functions\n"));
@@ -934,7 +966,7 @@ test_attr_scalar_write(hid_t fapl)
CHECK(sid1, FAIL, "H5Screate_simple");
/* Create a dataset */
- dataset = H5Dcreate2(fid1, DSET1_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ dataset = H5Dcreate2(fid1, DSET1_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, dcpl_g, H5P_DEFAULT);
CHECK(dataset, FAIL, "H5Dcreate2");
/* Create dataspace for attribute */
@@ -969,9 +1001,8 @@ test_attr_scalar_write(hid_t fapl)
/* Close file */
ret = H5Fclose(fid1);
CHECK(ret, FAIL, "H5Fclose");
-} /* test_attr_scalar_write() */
+} /* test_attr_scalar_write() */
-
/****************************************************************
**
** test_attr_scalar_read(): Test scalar H5A (attribute) reading code.
@@ -980,14 +1011,14 @@ test_attr_scalar_write(hid_t fapl)
static void
test_attr_scalar_read(hid_t fapl)
{
- hid_t fid1; /* HDF5 File IDs */
- hid_t dataset; /* Dataset ID */
- hid_t sid; /* Dataspace ID */
- hid_t attr; /* Attribute ID */
- H5S_class_t stype; /* Dataspace class */
- float rdata = 0.0F; /* Buffer for reading 1st attribute */
- H5O_info_t oinfo; /* Object info */
- herr_t ret; /* Generic return value */
+ hid_t fid1; /* HDF5 File IDs */
+ hid_t dataset; /* Dataset ID */
+ hid_t sid; /* Dataspace ID */
+ hid_t attr; /* Attribute ID */
+ H5S_class_t stype; /* Dataspace class */
+ float rdata = 0.0F; /* Buffer for reading 1st attribute */
+ H5O_info2_t oinfo; /* Object info */
+ herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Basic Scalar Attribute Reading Functions\n"));
@@ -1001,9 +1032,9 @@ test_attr_scalar_read(hid_t fapl)
CHECK(dataset, FAIL, "H5Dopen2");
/* Verify the correct number of attributes */
- ret = H5Oget_info(dataset, &oinfo);
- CHECK(ret, FAIL, "H5Oget_info");
- VERIFY(oinfo.num_attrs, 1, "H5Oget_info");
+ ret = H5Oget_info3(dataset, &oinfo, H5O_INFO_NUM_ATTRS);
+ CHECK(ret, FAIL, "H5Oget_info3");
+ VERIFY(oinfo.num_attrs, 1, "H5Oget_info3");
/* Open an attribute for the dataset */
attr = H5Aopen(dataset, ATTR5_NAME, H5P_DEFAULT);
@@ -1014,9 +1045,9 @@ test_attr_scalar_read(hid_t fapl)
CHECK(ret, FAIL, "H5Aread");
/* Verify the floating-poing value in this way to avoid compiler warning. */
- if(!FLT_ABS_EQUAL(rdata, attr_data5))
- printf("*** UNEXPECTED VALUE from %s should be %f, but is %f at line %4d in %s\n",
- "H5Aread", (double)attr_data5, (double)rdata, (int)__LINE__, __FILE__);
+ if (!H5_FLT_ABS_EQUAL(rdata, attr_data5))
+ HDprintf("*** UNEXPECTED VALUE from %s should be %f, but is %f at line %4d in %s\n", "H5Aread",
+ (double)attr_data5, (double)rdata, (int)__LINE__, __FILE__);
/* Get the attribute's dataspace */
sid = H5Aget_space(attr);
@@ -1040,9 +1071,8 @@ test_attr_scalar_read(hid_t fapl)
/* Close file */
ret = H5Fclose(fid1);
CHECK(ret, FAIL, "H5Fclose");
-} /* test_attr_scalar_read() */
+} /* test_attr_scalar_read() */
-
/****************************************************************
**
** test_attr_mult_write(): Test basic H5A (attribute) code.
@@ -1052,16 +1082,16 @@ test_attr_scalar_read(hid_t fapl)
static void
test_attr_mult_write(hid_t fapl)
{
- hid_t fid1; /* HDF5 File IDs */
- hid_t dataset; /* Dataset ID */
- hid_t sid1,sid2; /* Dataspace ID */
- hid_t attr; /* Attribute ID */
- hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3};
- hsize_t dims2[] = {ATTR1_DIM1};
- hsize_t dims3[] = {ATTR2_DIM1,ATTR2_DIM2};
- hsize_t dims4[] = {ATTR3_DIM1,ATTR3_DIM2,ATTR3_DIM3};
- hid_t ret_id; /* Generic hid_t return value */
- herr_t ret; /* Generic return value */
+ hid_t fid1; /* HDF5 File IDs */
+ hid_t dataset; /* Dataset ID */
+ hid_t sid1, sid2; /* Dataspace ID */
+ hid_t attr; /* Attribute ID */
+ hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3};
+ hsize_t dims2[] = {ATTR1_DIM1};
+ hsize_t dims3[] = {ATTR2_DIM1, ATTR2_DIM2};
+ hsize_t dims4[] = {ATTR3_DIM1, ATTR3_DIM2, ATTR3_DIM3};
+ hid_t ret_id; /* Generic hid_t return value */
+ herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Multiple Attribute Functions\n"));
@@ -1075,7 +1105,7 @@ test_attr_mult_write(hid_t fapl)
CHECK(sid1, FAIL, "H5Screate_simple");
/* Create a dataset */
- dataset = H5Dcreate2(fid1, DSET1_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ dataset = H5Dcreate2(fid1, DSET1_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, dcpl_g, H5P_DEFAULT);
CHECK(dataset, FAIL, "H5Dcreate2");
/* Close dataset's dataspace */
@@ -1161,9 +1191,8 @@ test_attr_mult_write(hid_t fapl)
/* Close file */
ret = H5Fclose(fid1);
CHECK(ret, FAIL, "H5Fclose");
-} /* test_attr_mult_write() */
+} /* test_attr_mult_write() */
-
/****************************************************************
**
** test_attr_mult_read(): Test basic H5A (attribute) code.
@@ -1172,25 +1201,25 @@ test_attr_mult_write(hid_t fapl)
static void
test_attr_mult_read(hid_t fapl)
{
- hid_t fid1; /* HDF5 File ID */
- hid_t dataset; /* Dataset ID */
- hid_t space; /* Attribute dataspace */
- hid_t type; /* Attribute datatype */
- hid_t attr; /* Attribute ID */
- char attr_name[ATTR_NAME_LEN]; /* Buffer for attribute names */
- char temp_name[ATTR_NAME_LEN]; /* Buffer for mangling attribute names */
- int rank; /* Attribute rank */
- hsize_t dims[ATTR_MAX_DIMS]; /* Attribute dimensions */
- H5T_class_t t_class; /* Attribute datatype class */
- H5T_order_t order; /* Attribute datatype order */
- size_t size; /* Attribute datatype size as stored in file */
- int read_data1[ATTR1_DIM1] = {0}; /* Buffer for reading 1st attribute */
- int read_data2[ATTR2_DIM1][ATTR2_DIM2] = {{0}}; /* Buffer for reading 2nd attribute */
+ hid_t fid1; /* HDF5 File ID */
+ hid_t dataset; /* Dataset ID */
+ hid_t space; /* Attribute dataspace */
+ hid_t type; /* Attribute datatype */
+ hid_t attr; /* Attribute ID */
+ char attr_name[ATTR_NAME_LEN]; /* Buffer for attribute names */
+ char temp_name[ATTR_NAME_LEN]; /* Buffer for mangling attribute names */
+ int rank; /* Attribute rank */
+ hsize_t dims[ATTR_MAX_DIMS]; /* Attribute dimensions */
+ H5T_class_t t_class; /* Attribute datatype class */
+ H5T_order_t order; /* Attribute datatype order */
+ size_t size; /* Attribute datatype size as stored in file */
+ int read_data1[ATTR1_DIM1] = {0}; /* Buffer for reading 1st attribute */
+ int read_data2[ATTR2_DIM1][ATTR2_DIM2] = {{0}}; /* Buffer for reading 2nd attribute */
double read_data3[ATTR3_DIM1][ATTR3_DIM2][ATTR3_DIM3] = {{{0}}}; /* Buffer for reading 3rd attribute */
- size_t name_len; /* Length of attribute name */
- H5O_info_t oinfo; /* Object info */
- int i, j, k; /* Local index values */
- herr_t ret; /* Generic return value */
+ ssize_t name_len; /* Length of attribute name */
+ H5O_info2_t oinfo; /* Object info */
+ int i, j, k; /* Local index values */
+ herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Basic Attribute Functions\n"));
@@ -1204,12 +1233,13 @@ test_attr_mult_read(hid_t fapl)
CHECK(dataset, FAIL, "H5Dopen2");
/* Verify the correct number of attributes */
- ret = H5Oget_info(dataset, &oinfo);
- CHECK(ret, FAIL, "H5Oget_info");
- VERIFY(oinfo.num_attrs, 3, "H5Oget_info");
+ ret = H5Oget_info3(dataset, &oinfo, H5O_INFO_NUM_ATTRS);
+ CHECK(ret, FAIL, "H5Oget_info3");
+ VERIFY(oinfo.num_attrs, 3, "H5Oget_info3");
/* Open 1st attribute for the dataset */
- attr = H5Aopen_by_idx(dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, H5P_DEFAULT, H5P_DEFAULT);
+ attr =
+ H5Aopen_by_idx(dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Aopen_by_idx");
/* Verify Dataspace */
@@ -1219,7 +1249,7 @@ test_attr_mult_read(hid_t fapl)
VERIFY(rank, ATTR1_RANK, "H5Sget_simple_extent_ndims");
ret = H5Sget_simple_extent_dims(space, dims, NULL);
CHECK(ret, FAIL, "H5Sget_simple_extent_dims");
- if(dims[0] != ATTR1_DIM1)
+ if (dims[0] != ATTR1_DIM1)
TestErrPrintf("attribute dimensions different: dims[0]=%d, should be %d\n", (int)dims[0], ATTR1_DIM1);
H5Sclose(space);
@@ -1229,7 +1259,7 @@ test_attr_mult_read(hid_t fapl)
t_class = H5Tget_class(type);
VERIFY(t_class, H5T_INTEGER, "H5Tget_class");
order = H5Tget_order(type);
- VERIFY(order, H5Tget_order(H5T_NATIVE_INT), "H5Tget_order");
+ VERIFY_TYPE(order, H5Tget_order(H5T_NATIVE_INT), H5T_order_t, "%d", "H5Tget_order");
size = H5Tget_size(type);
VERIFY(size, H5Tget_size(H5T_NATIVE_INT), "H5Tget_size");
H5Tclose(type);
@@ -1239,22 +1269,23 @@ test_attr_mult_read(hid_t fapl)
CHECK(ret, FAIL, "H5Aread");
/* Verify values read in */
- for(i = 0; i < ATTR1_DIM1; i++)
- if(attr_data1[i] != read_data1[i])
- TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n", __LINE__, i, attr_data1[i], i, read_data1[i]);
+ for (i = 0; i < ATTR1_DIM1; i++)
+ if (attr_data1[i] != read_data1[i])
+ TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n", __LINE__, i,
+ attr_data1[i], i, read_data1[i]);
/* Verify Name */
name_len = H5Aget_name(attr, (size_t)ATTR_NAME_LEN, attr_name);
VERIFY(name_len, HDstrlen(ATTR1_NAME), "H5Aget_name");
- if(HDstrcmp(attr_name, ATTR1_NAME))
+ if (HDstrcmp(attr_name, ATTR1_NAME) != 0)
TestErrPrintf("attribute name different: attr_name=%s, should be %s\n", attr_name, ATTR1_NAME);
/* Verify Name with too small of a buffer */
- name_len = H5Aget_name(attr,HDstrlen(ATTR1_NAME), attr_name);
+ name_len = H5Aget_name(attr, HDstrlen(ATTR1_NAME), attr_name);
VERIFY(name_len, HDstrlen(ATTR1_NAME), "H5Aget_name");
- HDstrcpy(temp_name, ATTR1_NAME); /* make a copy of the name */
- temp_name[HDstrlen(ATTR1_NAME) - 1] = '\0'; /* truncate it to match the one retrieved */
- if(HDstrcmp(attr_name, temp_name))
+ HDstrcpy(temp_name, ATTR1_NAME); /* make a copy of the name */
+ temp_name[HDstrlen(ATTR1_NAME) - 1] = '\0'; /* truncate it to match the one retrieved */
+ if (HDstrcmp(attr_name, temp_name) != 0)
TestErrPrintf("attribute name different: attr_name=%s, should be %s\n", attr_name, temp_name);
/* Close attribute */
@@ -1262,7 +1293,8 @@ test_attr_mult_read(hid_t fapl)
CHECK(ret, FAIL, "H5Aclose");
/* Open 2nd attribute for the dataset */
- attr = H5Aopen_by_idx(dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)1, H5P_DEFAULT, H5P_DEFAULT);
+ attr =
+ H5Aopen_by_idx(dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)1, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Aopen_by_idx");
/* Verify Dataspace */
@@ -1272,9 +1304,9 @@ test_attr_mult_read(hid_t fapl)
VERIFY(rank, ATTR2_RANK, "H5Sget_simple_extent_ndims");
ret = H5Sget_simple_extent_dims(space, dims, NULL);
CHECK(ret, FAIL, "H5Sget_simple_extent_dims");
- if(dims[0] != ATTR2_DIM1)
+ if (dims[0] != ATTR2_DIM1)
TestErrPrintf("attribute dimensions different: dims[0]=%d, should be %d\n", (int)dims[0], ATTR2_DIM1);
- if(dims[1] != ATTR2_DIM2)
+ if (dims[1] != ATTR2_DIM2)
TestErrPrintf("attribute dimensions different: dims[1]=%d, should be %d\n", (int)dims[1], ATTR2_DIM2);
H5Sclose(space);
@@ -1284,7 +1316,7 @@ test_attr_mult_read(hid_t fapl)
t_class = H5Tget_class(type);
VERIFY(t_class, H5T_INTEGER, "H5Tget_class");
order = H5Tget_order(type);
- VERIFY(order, H5Tget_order(H5T_NATIVE_INT), "H5Tget_order");
+ VERIFY_TYPE(order, H5Tget_order(H5T_NATIVE_INT), H5T_order_t, "%d", "H5Tget_order");
size = H5Tget_size(type);
VERIFY(size, H5Tget_size(H5T_NATIVE_INT), "H5Tget_size");
H5Tclose(type);
@@ -1294,23 +1326,24 @@ test_attr_mult_read(hid_t fapl)
CHECK(ret, FAIL, "H5Aread");
/* Verify values read in */
- for(i = 0; i < ATTR2_DIM1; i++)
- for(j = 0; j < ATTR2_DIM2; j++)
- if(attr_data2[i][j] != read_data2[i][j])
- TestErrPrintf("%d: attribute data different: attr_data2[%d][%d]=%d, read_data2[%d][%d]=%d\n", __LINE__, i, j, attr_data2[i][j], i, j, read_data2[i][j]);
+ for (i = 0; i < ATTR2_DIM1; i++)
+ for (j = 0; j < ATTR2_DIM2; j++)
+ if (attr_data2[i][j] != read_data2[i][j])
+ TestErrPrintf("%d: attribute data different: attr_data2[%d][%d]=%d, read_data2[%d][%d]=%d\n",
+ __LINE__, i, j, attr_data2[i][j], i, j, read_data2[i][j]);
/* Verify Name */
name_len = H5Aget_name(attr, (size_t)ATTR_NAME_LEN, attr_name);
VERIFY(name_len, HDstrlen(ATTR2_NAME), "H5Aget_name");
- if(HDstrcmp(attr_name, ATTR2_NAME))
+ if (HDstrcmp(attr_name, ATTR2_NAME) != 0)
TestErrPrintf("attribute name different: attr_name=%s, should be %s\n", attr_name, ATTR2_NAME);
/* Verify Name with too small of a buffer */
name_len = H5Aget_name(attr, HDstrlen(ATTR2_NAME), attr_name);
VERIFY(name_len, HDstrlen(ATTR2_NAME), "H5Aget_name");
- HDstrcpy(temp_name, ATTR2_NAME); /* make a copy of the name */
- temp_name[HDstrlen(ATTR2_NAME) - 1] = '\0'; /* truncate it to match the one retrieved */
- if(HDstrcmp(attr_name, temp_name))
+ HDstrcpy(temp_name, ATTR2_NAME); /* make a copy of the name */
+ temp_name[HDstrlen(ATTR2_NAME) - 1] = '\0'; /* truncate it to match the one retrieved */
+ if (HDstrcmp(attr_name, temp_name) != 0)
TestErrPrintf("attribute name different: attr_name=%s, should be %s\n", attr_name, temp_name);
/* Close attribute */
@@ -1318,7 +1351,8 @@ test_attr_mult_read(hid_t fapl)
CHECK(ret, FAIL, "H5Aclose");
/* Open 2nd attribute for the dataset */
- attr = H5Aopen_by_idx(dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)2, H5P_DEFAULT, H5P_DEFAULT);
+ attr =
+ H5Aopen_by_idx(dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)2, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Aopen_by_idx");
/* Verify Dataspace */
@@ -1328,11 +1362,11 @@ test_attr_mult_read(hid_t fapl)
VERIFY(rank, ATTR3_RANK, "H5Sget_simple_extent_ndims");
ret = H5Sget_simple_extent_dims(space, dims, NULL);
CHECK(ret, FAIL, "H5Sget_simple_extent_dims");
- if(dims[0] != ATTR3_DIM1)
+ if (dims[0] != ATTR3_DIM1)
TestErrPrintf("attribute dimensions different: dims[0]=%d, should be %d\n", (int)dims[0], ATTR3_DIM1);
- if(dims[1] != ATTR3_DIM2)
+ if (dims[1] != ATTR3_DIM2)
TestErrPrintf("attribute dimensions different: dims[1]=%d, should be %d\n", (int)dims[1], ATTR3_DIM2);
- if(dims[2] != ATTR3_DIM3)
+ if (dims[2] != ATTR3_DIM3)
TestErrPrintf("attribute dimensions different: dims[2]=%d, should be %d\n", (int)dims[2], ATTR3_DIM3);
H5Sclose(space);
@@ -1342,7 +1376,7 @@ test_attr_mult_read(hid_t fapl)
t_class = H5Tget_class(type);
VERIFY(t_class, H5T_FLOAT, "H5Tget_class");
order = H5Tget_order(type);
- VERIFY(order, H5Tget_order(H5T_NATIVE_DOUBLE), "H5Tget_order");
+ VERIFY_TYPE(order, H5Tget_order(H5T_NATIVE_DOUBLE), H5T_order_t, "%d", "H5Tget_order");
size = H5Tget_size(type);
VERIFY(size, H5Tget_size(H5T_NATIVE_DOUBLE), "H5Tget_size");
H5Tclose(type);
@@ -1352,24 +1386,26 @@ test_attr_mult_read(hid_t fapl)
CHECK(ret, FAIL, "H5Aread");
/* Verify values read in */
- for(i = 0; i < ATTR3_DIM1; i++)
- for(j = 0; j < ATTR3_DIM2; j++)
- for(k = 0; k < ATTR3_DIM3; k++)
- if(!DBL_ABS_EQUAL(attr_data3[i][j][k], read_data3[i][j][k]))
- TestErrPrintf("%d: attribute data different: attr_data3[%d][%d][%d]=%f, read_data3[%d][%d][%d]=%f\n", __LINE__, i, j, k, attr_data3[i][j][k], i, j, k, read_data3[i][j][k]);
+ for (i = 0; i < ATTR3_DIM1; i++)
+ for (j = 0; j < ATTR3_DIM2; j++)
+ for (k = 0; k < ATTR3_DIM3; k++)
+ if (!H5_DBL_ABS_EQUAL(attr_data3[i][j][k], read_data3[i][j][k]))
+ TestErrPrintf("%d: attribute data different: attr_data3[%d][%d][%d]=%f, "
+ "read_data3[%d][%d][%d]=%f\n",
+ __LINE__, i, j, k, attr_data3[i][j][k], i, j, k, read_data3[i][j][k]);
/* Verify Name */
name_len = H5Aget_name(attr, (size_t)ATTR_NAME_LEN, attr_name);
VERIFY(name_len, HDstrlen(ATTR3_NAME), "H5Aget_name");
- if(HDstrcmp(attr_name, ATTR3_NAME))
+ if (HDstrcmp(attr_name, ATTR3_NAME) != 0)
TestErrPrintf("attribute name different: attr_name=%s, should be %s\n", attr_name, ATTR3_NAME);
/* Verify Name with too small of a buffer */
name_len = H5Aget_name(attr, HDstrlen(ATTR3_NAME), attr_name);
VERIFY(name_len, HDstrlen(ATTR3_NAME), "H5Aget_name");
- HDstrcpy(temp_name, ATTR3_NAME); /* make a copy of the name */
- temp_name[HDstrlen(ATTR3_NAME) - 1] = '\0'; /* truncate it to match the one retrieved */
- if(HDstrcmp(attr_name, temp_name))
+ HDstrcpy(temp_name, ATTR3_NAME); /* make a copy of the name */
+ temp_name[HDstrlen(ATTR3_NAME) - 1] = '\0'; /* truncate it to match the one retrieved */
+ if (HDstrcmp(attr_name, temp_name) != 0)
TestErrPrintf("attribute name different: attr_name=%s, should be %s\n", attr_name, temp_name);
/* Close attribute */
@@ -1383,49 +1419,46 @@ test_attr_mult_read(hid_t fapl)
/* Close file */
ret = H5Fclose(fid1);
CHECK(ret, FAIL, "H5Fclose");
-} /* test_attr_mult_read() */
+} /* test_attr_mult_read() */
-
/****************************************************************
**
** attr_op1(): Attribute operator
**
****************************************************************/
static herr_t
-attr_op1(hid_t UNUSED loc_id, const char *name, const H5A_info_t UNUSED *ainfo,
- void *op_data)
+attr_op1(hid_t H5_ATTR_UNUSED loc_id, const char *name, const H5A_info_t H5_ATTR_UNUSED *ainfo, void *op_data)
{
- int *count = (int *)op_data;
- herr_t ret = 0;
+ int *count = (int *)op_data;
+ herr_t ret = 0;
- switch(*count) {
+ switch (*count) {
case 0:
- if(HDstrcmp(name, ATTR1_NAME))
+ if (HDstrcmp(name, ATTR1_NAME) != 0)
TestErrPrintf("attribute name different: name=%s, should be %s\n", name, ATTR1_NAME);
- (*count)++;
- break;
+ (*count)++;
+ break;
case 1:
- if(HDstrcmp(name, ATTR2_NAME))
+ if (HDstrcmp(name, ATTR2_NAME) != 0)
TestErrPrintf("attribute name different: name=%s, should be %s\n", name, ATTR2_NAME);
- (*count)++;
- break;
+ (*count)++;
+ break;
case 2:
- if(HDstrcmp(name, ATTR3_NAME))
+ if (HDstrcmp(name, ATTR3_NAME) != 0)
TestErrPrintf("attribute name different: name=%s, should be %s\n", name, ATTR3_NAME);
- (*count)++;
- break;
+ (*count)++;
+ break;
default:
ret = -1;
break;
- } /* end switch() */
+ } /* end switch() */
- return(ret);
+ return (ret);
} /* end attr_op1() */
-
/****************************************************************
**
** test_attr_iterate(): Test H5A (attribute) iterator code.
@@ -1434,12 +1467,12 @@ attr_op1(hid_t UNUSED loc_id, const char *name, const H5A_info_t UNUSED *ainfo,
static void
test_attr_iterate(hid_t fapl)
{
- hid_t file; /* HDF5 File ID */
- hid_t dataset; /* Dataset ID */
- hid_t sid; /* Dataspace ID */
- int count; /* operator data for the iterator */
- H5O_info_t oinfo; /* Object info */
- herr_t ret; /* Generic return value */
+ hid_t file; /* HDF5 File ID */
+ hid_t dataset; /* Dataset ID */
+ hid_t sid; /* Dataspace ID */
+ int count; /* operator data for the iterator */
+ H5O_info2_t oinfo; /* Object info */
+ herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Basic Attribute Functions\n"));
@@ -1453,7 +1486,7 @@ test_attr_iterate(hid_t fapl)
CHECK(sid, FAIL, "H5Screate");
/* Create a new dataset */
- dataset = H5Dcreate2(file, DSET2_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ dataset = H5Dcreate2(file, DSET2_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT);
CHECK(dataset, FAIL, "H5Dcreate2");
/* Close dataspace */
@@ -1461,13 +1494,13 @@ test_attr_iterate(hid_t fapl)
CHECK(ret, FAIL, "H5Sclose");
/* Verify the correct number of attributes */
- ret = H5Oget_info(dataset, &oinfo);
- CHECK(ret, FAIL, "H5Oget_info");
- VERIFY(oinfo.num_attrs, 0, "H5Oget_info");
+ ret = H5Oget_info3(dataset, &oinfo, H5O_INFO_NUM_ATTRS);
+ CHECK(ret, FAIL, "H5Oget_info3");
+ VERIFY(oinfo.num_attrs, 0, "H5Oget_info3");
/* Iterate over attributes on dataset */
count = 0;
- ret = H5Aiterate2(dataset, H5_INDEX_NAME, H5_ITER_INC, NULL, attr_op1, &count);
+ ret = H5Aiterate2(dataset, H5_INDEX_NAME, H5_ITER_INC, NULL, attr_op1, &count);
VERIFY(ret, 0, "H5Aiterate2");
/* Close dataset */
@@ -1479,13 +1512,13 @@ test_attr_iterate(hid_t fapl)
CHECK(dataset, FAIL, "H5Dopen2");
/* Verify the correct number of attributes */
- ret = H5Oget_info(dataset, &oinfo);
- CHECK(ret, FAIL, "H5Oget_info");
- VERIFY(oinfo.num_attrs, 3, "H5Oget_info");
+ ret = H5Oget_info3(dataset, &oinfo, H5O_INFO_NUM_ATTRS);
+ CHECK(ret, FAIL, "H5Oget_info3");
+ VERIFY(oinfo.num_attrs, 3, "H5Oget_info3");
/* Iterate over attributes on dataset */
count = 0;
- ret = H5Aiterate2(dataset, H5_INDEX_NAME, H5_ITER_INC, NULL, attr_op1, &count);
+ ret = H5Aiterate2(dataset, H5_INDEX_NAME, H5_ITER_INC, NULL, attr_op1, &count);
VERIFY(ret, 0, "H5Aiterate2");
/* Close dataset */
@@ -1495,9 +1528,8 @@ test_attr_iterate(hid_t fapl)
/* Close file */
ret = H5Fclose(file);
CHECK(ret, FAIL, "H5Fclose");
-} /* test_attr_iterate() */
+} /* test_attr_iterate() */
-
/****************************************************************
**
** test_attr_delete(): Test H5A (attribute) code for deleting objects.
@@ -1506,13 +1538,13 @@ test_attr_iterate(hid_t fapl)
static void
test_attr_delete(hid_t fapl)
{
- hid_t fid1; /* HDF5 File ID */
- hid_t dataset; /* Dataset ID */
- hid_t attr; /* Attribute ID */
- char attr_name[ATTR_NAME_LEN]; /* Buffer for attribute names */
- size_t name_len; /* Length of attribute name */
- H5O_info_t oinfo; /* Object info */
- herr_t ret; /* Generic return value */
+ hid_t fid1; /* HDF5 File ID */
+ hid_t dataset; /* Dataset ID */
+ hid_t attr; /* Attribute ID */
+ char attr_name[ATTR_NAME_LEN]; /* Buffer for attribute names */
+ ssize_t name_len; /* Length of attribute name */
+ H5O_info2_t oinfo; /* Object info */
+ herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Basic Attribute Functions\n"));
@@ -1526,51 +1558,53 @@ test_attr_delete(hid_t fapl)
CHECK(dataset, FAIL, "H5Dopen2");
/* Verify the correct number of attributes */
- ret = H5Oget_info(dataset, &oinfo);
- CHECK(ret, FAIL, "H5Oget_info");
- VERIFY(oinfo.num_attrs, 3, "H5Oget_info");
+ ret = H5Oget_info3(dataset, &oinfo, H5O_INFO_NUM_ATTRS);
+ CHECK(ret, FAIL, "H5Oget_info3");
+ VERIFY(oinfo.num_attrs, 3, "H5Oget_info3");
/* Try to delete bogus attribute */
ret = H5Adelete(dataset, "Bogus");
VERIFY(ret, FAIL, "H5Adelete");
/* Verify the correct number of attributes */
- ret = H5Oget_info(dataset, &oinfo);
- CHECK(ret, FAIL, "H5Oget_info");
- VERIFY(oinfo.num_attrs, 3, "H5Oget_info");
+ ret = H5Oget_info3(dataset, &oinfo, H5O_INFO_NUM_ATTRS);
+ CHECK(ret, FAIL, "H5Oget_info3");
+ VERIFY(oinfo.num_attrs, 3, "H5Oget_info3");
/* Delete middle (2nd) attribute */
ret = H5Adelete(dataset, ATTR2_NAME);
CHECK(ret, FAIL, "H5Adelete");
/* Verify the correct number of attributes */
- ret = H5Oget_info(dataset, &oinfo);
- CHECK(ret, FAIL, "H5Oget_info");
- VERIFY(oinfo.num_attrs, 2, "H5Oget_info");
+ ret = H5Oget_info3(dataset, &oinfo, H5O_INFO_NUM_ATTRS);
+ CHECK(ret, FAIL, "H5Oget_info3");
+ VERIFY(oinfo.num_attrs, 2, "H5Oget_info3");
/* Open 1st attribute for the dataset */
- attr = H5Aopen_by_idx(dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, H5P_DEFAULT, H5P_DEFAULT);
+ attr =
+ H5Aopen_by_idx(dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Aopen_by_idx");
/* Verify Name */
name_len = H5Aget_name(attr, (size_t)ATTR_NAME_LEN, attr_name);
VERIFY(name_len, HDstrlen(ATTR1_NAME), "H5Aget_name");
- if(HDstrcmp(attr_name, ATTR1_NAME))
- TestErrPrintf("attribute name different: attr_name=%s, should be %s\n",attr_name,ATTR1_NAME);
+ if (HDstrcmp(attr_name, ATTR1_NAME) != 0)
+ TestErrPrintf("attribute name different: attr_name=%s, should be %s\n", attr_name, ATTR1_NAME);
/* Close attribute */
ret = H5Aclose(attr);
CHECK(ret, FAIL, "H5Aclose");
/* Open last (formally 3rd) attribute for the dataset */
- attr = H5Aopen_by_idx(dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)1, H5P_DEFAULT, H5P_DEFAULT);
+ attr =
+ H5Aopen_by_idx(dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)1, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Aopen_by_idx");
/* Verify Name */
name_len = H5Aget_name(attr, (size_t)ATTR_NAME_LEN, attr_name);
VERIFY(name_len, HDstrlen(ATTR3_NAME), "H5Aget_name");
- if(HDstrcmp(attr_name, ATTR3_NAME))
- TestErrPrintf("attribute name different: attr_name=%s, should be %s\n",attr_name,ATTR3_NAME);
+ if (HDstrcmp(attr_name, ATTR3_NAME) != 0)
+ TestErrPrintf("attribute name different: attr_name=%s, should be %s\n", attr_name, ATTR3_NAME);
/* Close attribute */
ret = H5Aclose(attr);
@@ -1581,19 +1615,20 @@ test_attr_delete(hid_t fapl)
CHECK(ret, FAIL, "H5Adelete");
/* Verify the correct number of attributes */
- ret = H5Oget_info(dataset, &oinfo);
- CHECK(ret, FAIL, "H5Oget_info");
- VERIFY(oinfo.num_attrs, 1, "H5Oget_info");
+ ret = H5Oget_info3(dataset, &oinfo, H5O_INFO_NUM_ATTRS);
+ CHECK(ret, FAIL, "H5Oget_info3");
+ VERIFY(oinfo.num_attrs, 1, "H5Oget_info3");
/* Open last (formally 3rd) attribute for the dataset */
- attr = H5Aopen_by_idx(dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, H5P_DEFAULT, H5P_DEFAULT);
+ attr =
+ H5Aopen_by_idx(dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Aopen_by_idx");
/* Verify Name */
name_len = H5Aget_name(attr, (size_t)ATTR_NAME_LEN, attr_name);
VERIFY(name_len, HDstrlen(ATTR3_NAME), "H5Aget_name");
- if(HDstrcmp(attr_name, ATTR3_NAME))
- TestErrPrintf("attribute name different: attr_name=%s, should be %s\n",attr_name,ATTR3_NAME);
+ if (HDstrcmp(attr_name, ATTR3_NAME) != 0)
+ TestErrPrintf("attribute name different: attr_name=%s, should be %s\n", attr_name, ATTR3_NAME);
/* Close attribute */
ret = H5Aclose(attr);
@@ -1604,9 +1639,9 @@ test_attr_delete(hid_t fapl)
CHECK(ret, FAIL, "H5Adelete");
/* Verify the correct number of attributes */
- ret = H5Oget_info(dataset, &oinfo);
- CHECK(ret, FAIL, "H5Oget_info");
- VERIFY(oinfo.num_attrs, 0, "H5Oget_info");
+ ret = H5Oget_info3(dataset, &oinfo, H5O_INFO_NUM_ATTRS);
+ CHECK(ret, FAIL, "H5Oget_info3");
+ VERIFY(oinfo.num_attrs, 0, "H5Oget_info3");
/* Close dataset */
ret = H5Dclose(dataset);
@@ -1615,9 +1650,8 @@ test_attr_delete(hid_t fapl)
/* Close file */
ret = H5Fclose(fid1);
CHECK(ret, FAIL, "H5Fclose");
-} /* test_attr_delete() */
+} /* test_attr_delete() */
-
/****************************************************************
**
** test_attr_dtype_shared(): Test H5A (attribute) code for using
@@ -1627,17 +1661,17 @@ test_attr_delete(hid_t fapl)
static void
test_attr_dtype_shared(hid_t fapl)
{
- hid_t file_id; /* File ID */
- hid_t dset_id; /* Dataset ID */
- hid_t space_id; /* Dataspace ID for dataset & attribute */
- hid_t type_id; /* Datatype ID for named datatype */
- hid_t attr_id; /* Attribute ID */
- int data = 8; /* Data to write */
- int rdata = 0; /* Read read in */
- H5O_info_t oinfo; /* Object's information */
- h5_stat_size_t empty_filesize; /* Size of empty file */
- h5_stat_size_t filesize; /* Size of file after modifications */
- herr_t ret; /* Generic return value */
+ hid_t file_id; /* File ID */
+ hid_t dset_id; /* Dataset ID */
+ hid_t space_id; /* Dataspace ID for dataset & attribute */
+ hid_t type_id; /* Datatype ID for named datatype */
+ hid_t attr_id; /* Attribute ID */
+ int data = 8; /* Data to write */
+ int rdata = 0; /* Read read in */
+ H5O_info2_t oinfo; /* Object's information */
+ h5_stat_size_t empty_filesize; /* Size of empty file */
+ h5_stat_size_t filesize; /* Size of file after modifications */
+ herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Shared Datatypes with Attributes\n"));
@@ -1652,10 +1686,9 @@ test_attr_dtype_shared(hid_t fapl)
/* Get size of file */
empty_filesize = h5_get_file_size(FILENAME, fapl);
- if(empty_filesize < 0)
+ if (empty_filesize < 0)
TestErrPrintf("Line %d: file size wrong!\n", __LINE__);
-
/* Re-open file */
file_id = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
CHECK(file_id, FAIL, "H5Fopen");
@@ -1669,31 +1702,31 @@ test_attr_dtype_shared(hid_t fapl)
CHECK(ret, FAIL, "H5Tcommit2");
/* Check reference count on named datatype */
- ret = H5Oget_info_by_name(file_id, TYPE1_NAME, &oinfo, H5P_DEFAULT);
- CHECK(ret, FAIL, "H5Oget_info_by_name");
- VERIFY(oinfo.rc, 1, "H5Oget_info_by_name");
+ ret = H5Oget_info_by_name3(file_id, TYPE1_NAME, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Oget_info_by_name3");
+ VERIFY(oinfo.rc, 1, "H5Oget_info_by_name3");
/* Create dataspace for dataset */
space_id = H5Screate(H5S_SCALAR);
CHECK(space_id, FAIL, "H5Screate");
/* Create dataset */
- dset_id = H5Dcreate2(file_id, DSET1_NAME, type_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ dset_id = H5Dcreate2(file_id, DSET1_NAME, type_id, space_id, H5P_DEFAULT, dcpl_g, H5P_DEFAULT);
CHECK(dset_id, FAIL, "H5Dcreate2");
/* Check reference count on named datatype */
- ret = H5Oget_info_by_name(file_id, TYPE1_NAME, &oinfo, H5P_DEFAULT);
- CHECK(ret, FAIL, "H5Oget_info_by_name");
- VERIFY(oinfo.rc, 2, "H5Oget_info_by_name");
+ ret = H5Oget_info_by_name3(file_id, TYPE1_NAME, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Oget_info_by_name3");
+ VERIFY(oinfo.rc, 2, "H5Oget_info_by_name3");
/* Create attribute on dataset */
attr_id = H5Acreate2(dset_id, ATTR1_NAME, type_id, space_id, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr_id, FAIL, "H5Acreate2");
/* Check reference count on named datatype */
- ret = H5Oget_info_by_name(file_id, TYPE1_NAME, &oinfo, H5P_DEFAULT);
- CHECK(ret, FAIL, "H5Oget_info_by_name");
- VERIFY(oinfo.rc, 3, "H5Oget_info_by_name");
+ ret = H5Oget_info_by_name3(file_id, TYPE1_NAME, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Oget_info_by_name3");
+ VERIFY(oinfo.rc, 3, "H5Oget_info_by_name3");
/* Close attribute */
ret = H5Aclose(attr_id);
@@ -1704,18 +1737,18 @@ test_attr_dtype_shared(hid_t fapl)
CHECK(ret, FAIL, "H5Adelete");
/* Check reference count on named datatype */
- ret = H5Oget_info_by_name(file_id, TYPE1_NAME, &oinfo, H5P_DEFAULT);
- CHECK(ret, FAIL, "H5Oget_info_by_name");
- VERIFY(oinfo.rc, 2, "H5Oget_info_by_name");
+ ret = H5Oget_info_by_name3(file_id, TYPE1_NAME, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Oget_info_by_name3");
+ VERIFY(oinfo.rc, 2, "H5Oget_info_by_name3");
/* Create attribute on dataset */
attr_id = H5Acreate2(dset_id, ATTR1_NAME, type_id, space_id, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr_id, FAIL, "H5Acreate2");
/* Check reference count on named datatype */
- ret = H5Oget_info_by_name(file_id, TYPE1_NAME, &oinfo, H5P_DEFAULT);
- CHECK(ret, FAIL, "H5Oget_info_by_name");
- VERIFY(oinfo.rc, 3, "H5Oget_info_by_name");
+ ret = H5Oget_info_by_name3(file_id, TYPE1_NAME, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Oget_info_by_name3");
+ VERIFY(oinfo.rc, 3, "H5Oget_info_by_name3");
/* Write data into the attribute */
ret = H5Awrite(attr_id, H5T_NATIVE_INT, &data);
@@ -1741,7 +1774,6 @@ test_attr_dtype_shared(hid_t fapl)
ret = H5Fclose(file_id);
CHECK(ret, FAIL, "H5Fclose");
-
/* Re-open file */
file_id = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
CHECK(file_id, FAIL, "H5Fopen");
@@ -1768,18 +1800,18 @@ test_attr_dtype_shared(hid_t fapl)
CHECK(ret, FAIL, "H5Dclose");
/* Check reference count on named datatype */
- ret = H5Oget_info_by_name(file_id, TYPE1_NAME, &oinfo, H5P_DEFAULT);
- CHECK(ret, FAIL, "H5Oget_info_by_name");
- VERIFY(oinfo.rc, 3, "H5Oget_info_by_name");
+ ret = H5Oget_info_by_name3(file_id, TYPE1_NAME, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Oget_info_by_name3");
+ VERIFY(oinfo.rc, 3, "H5Oget_info_by_name3");
/* Unlink the dataset */
ret = H5Ldelete(file_id, DSET1_NAME, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Ldelete");
/* Check reference count on named datatype */
- ret = H5Oget_info_by_name(file_id, TYPE1_NAME, &oinfo, H5P_DEFAULT);
- CHECK(ret, FAIL, "H5Oget_info_by_name");
- VERIFY(oinfo.rc, 1, "H5Oget_info_by_name");
+ ret = H5Oget_info_by_name3(file_id, TYPE1_NAME, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Oget_info_by_name3");
+ VERIFY(oinfo.rc, 1, "H5Oget_info_by_name3");
/* Unlink the named datatype */
ret = H5Ldelete(file_id, TYPE1_NAME, H5P_DEFAULT);
@@ -1792,9 +1824,8 @@ test_attr_dtype_shared(hid_t fapl)
/* Check size of file */
filesize = h5_get_file_size(FILENAME, fapl);
VERIFY(filesize, empty_filesize, "h5_get_file_size");
-} /* test_attr_dtype_shared() */
+} /* test_attr_dtype_shared() */
-
/****************************************************************
**
** test_attr_duplicate_ids(): Test operations with more than
@@ -1804,17 +1835,17 @@ test_attr_dtype_shared(hid_t fapl)
static void
test_attr_duplicate_ids(hid_t fapl)
{
- hid_t fid1; /* HDF5 File IDs */
- hid_t dataset; /* Dataset ID */
- hid_t gid1, gid2; /* Group ID */
- hid_t sid1,sid2; /* Dataspace ID */
- hid_t attr, attr2; /* Attribute ID */
- hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3};
- hsize_t dims2[] = {ATTR1_DIM1};
- int read_data1[ATTR1_DIM1]={0}; /* Buffer for reading 1st attribute */
- int rewrite_data[ATTR1_DIM1]={1234, -423, 9907256}; /* Test data for rewrite */
- int i;
- herr_t ret; /* Generic return value */
+ hid_t fid1; /* HDF5 File IDs */
+ hid_t dataset; /* Dataset ID */
+ hid_t gid1, gid2; /* Group ID */
+ hid_t sid1, sid2; /* Dataspace ID */
+ hid_t attr, attr2; /* Attribute ID */
+ hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3};
+ hsize_t dims2[] = {ATTR1_DIM1};
+ int read_data1[ATTR1_DIM1] = {0}; /* Buffer for reading 1st attribute */
+ int rewrite_data[ATTR1_DIM1] = {1234, -423, 9907256}; /* Test data for rewrite */
+ int i;
+ herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing operations with two ID handles\n"));
@@ -1831,8 +1862,7 @@ test_attr_duplicate_ids(hid_t fapl)
CHECK(sid1, FAIL, "H5Screate_simple");
/* Create a dataset */
- dataset = H5Dcreate2(fid1, DSET1_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT,
- H5P_DEFAULT, H5P_DEFAULT);
+ dataset = H5Dcreate2(fid1, DSET1_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, dcpl_g, H5P_DEFAULT);
CHECK(dataset, FAIL, "H5Dcreate2");
/* Create dataspace for attribute */
@@ -1885,8 +1915,8 @@ test_attr_duplicate_ids(hid_t fapl)
CHECK(ret, FAIL, "H5Aread");
/* Verify values read in */
- for(i = 0; i < ATTR1_DIM1; i++)
- if(0 != read_data1[i])
+ for (i = 0; i < ATTR1_DIM1; i++)
+ if (0 != read_data1[i])
TestErrPrintf("%d: attribute data different: read_data1[%d]=%d\n", __LINE__, i, read_data1[i]);
/* Open attribute for the second time */
@@ -1934,9 +1964,10 @@ test_attr_duplicate_ids(hid_t fapl)
CHECK(ret, FAIL, "H5Aread");
/* Verify values read in */
- for(i = 0; i < ATTR1_DIM1; i++)
- if(attr_data1[i] != read_data1[i])
- TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n", __LINE__, i, attr_data1[i], i, read_data1[i]);
+ for (i = 0; i < ATTR1_DIM1; i++)
+ if (attr_data1[i] != read_data1[i])
+ TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n", __LINE__, i,
+ attr_data1[i], i, read_data1[i]);
/* Open attribute for the second time */
attr2 = H5Aopen(dataset, ATTR1_NAME, H5P_DEFAULT);
@@ -1951,9 +1982,10 @@ test_attr_duplicate_ids(hid_t fapl)
CHECK(ret, FAIL, "H5Aread");
/* Verify values read in */
- for(i = 0; i < ATTR1_DIM1; i++)
- if(read_data1[i] != rewrite_data[i])
- TestErrPrintf("%d: attribute data different: read_data1[%d]=%d, rewrite_data[%d]=%d\n", __LINE__, i, read_data1[i], i, rewrite_data[i]);
+ for (i = 0; i < ATTR1_DIM1; i++)
+ if (read_data1[i] != rewrite_data[i])
+ TestErrPrintf("%d: attribute data different: read_data1[%d]=%d, rewrite_data[%d]=%d\n", __LINE__,
+ i, read_data1[i], i, rewrite_data[i]);
/* Close attribute */
ret = H5Aclose(attr);
@@ -1983,8 +2015,7 @@ test_attr_duplicate_ids(hid_t fapl)
CHECK(gid1, FAIL, "H5Gcreate2");
/* Create hard link to the first group */
- ret = H5Lcreate_hard(gid1, GROUP1_NAME, H5L_SAME_LOC, GROUP2_NAME, H5P_DEFAULT,
- H5P_DEFAULT);
+ ret = H5Lcreate_hard(gid1, GROUP1_NAME, H5L_SAME_LOC, GROUP2_NAME, H5P_DEFAULT, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Lcreate_hard");
/* Try to create an attribute on the group */
@@ -2008,9 +2039,10 @@ test_attr_duplicate_ids(hid_t fapl)
CHECK(ret, FAIL, "H5Aread");
/* Verify values read in */
- for(i = 0; i < ATTR1_DIM1; i++)
- if(attr_data1[i] != read_data1[i])
- TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n", __LINE__, i, attr_data1[i], i, read_data1[i]);
+ for (i = 0; i < ATTR1_DIM1; i++)
+ if (attr_data1[i] != read_data1[i])
+ TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n", __LINE__, i,
+ attr_data1[i], i, read_data1[i]);
/* Close attribute */
ret = H5Aclose(attr);
@@ -2037,9 +2069,8 @@ test_attr_duplicate_ids(hid_t fapl)
/* Close file */
ret = H5Fclose(fid1);
CHECK(ret, FAIL, "H5Fclose");
-} /* test_attr_duplicate_ids() */
+} /* test_attr_duplicate_ids() */
-
/****************************************************************
**
** test_attr_dense_verify(): Test basic H5A (attribute) code.
@@ -2049,20 +2080,20 @@ test_attr_duplicate_ids(hid_t fapl)
static int
test_attr_dense_verify(hid_t loc_id, unsigned max_attr)
{
- char attrname[NAME_BUF_SIZE]; /* Name of attribute */
- hid_t attr; /* Attribute ID */
- unsigned value; /* Attribute value */
- unsigned u; /* Local index variable */
- int old_nerrs; /* Number of errors when entering this check */
- herr_t ret; /* Generic return value */
+ char attrname[NAME_BUF_SIZE]; /* Name of attribute */
+ hid_t attr; /* Attribute ID */
+ unsigned value; /* Attribute value */
+ unsigned u; /* Local index variable */
+ int old_nerrs; /* Number of errors when entering this check */
+ herr_t ret; /* Generic return value */
/* Retrieve the current # of reported errors */
old_nerrs = GetTestNumErrs();
/* Re-open all the attributes by name and verify the data */
- for(u = 0; u < max_attr; u++) {
+ for (u = 0; u < max_attr; u++) {
/* Open attribute */
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Aopen(loc_id, attrname, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Aopen");
@@ -2077,20 +2108,22 @@ test_attr_dense_verify(hid_t loc_id, unsigned max_attr)
} /* end for */
/* Re-open all the attributes by index and verify the data */
- for(u = 0; u < max_attr; u++) {
- size_t name_len; /* Length of attribute name */
- char check_name[ATTR_NAME_LEN]; /* Buffer for checking attribute names */
+ for (u = 0; u < max_attr; u++) {
+ ssize_t name_len; /* Length of attribute name */
+ char check_name[ATTR_NAME_LEN]; /* Buffer for checking attribute names */
/* Open attribute */
- attr = H5Aopen_by_idx(loc_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, H5P_DEFAULT, H5P_DEFAULT);
+ attr = H5Aopen_by_idx(loc_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, H5P_DEFAULT,
+ H5P_DEFAULT);
CHECK(attr, FAIL, "H5Aopen_by_idx");
/* Verify Name */
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
name_len = H5Aget_name(attr, (size_t)ATTR_NAME_LEN, check_name);
VERIFY(name_len, HDstrlen(attrname), "H5Aget_name");
- if(HDstrcmp(check_name, attrname))
- TestErrPrintf("attribute name different: attrname = '%s', should be '%s'\n", check_name, attrname);
+ if (HDstrcmp(check_name, attrname) != 0)
+ TestErrPrintf("attribute name different: attrname = '%s', should be '%s'\n", check_name,
+ attrname);
/* Read data from the attribute */
ret = H5Aread(attr, H5T_NATIVE_UINT, &value);
@@ -2103,13 +2136,12 @@ test_attr_dense_verify(hid_t loc_id, unsigned max_attr)
} /* end for */
/* Retrieve current # of errors */
- if(old_nerrs == GetTestNumErrs())
- return(0);
+ if (old_nerrs == GetTestNumErrs())
+ return (0);
else
- return(-1);
-} /* test_attr_dense_verify() */
+ return (-1);
+} /* test_attr_dense_verify() */
-
/****************************************************************
**
** test_attr_dense_create(): Test basic H5A (attribute) code.
@@ -2119,19 +2151,19 @@ test_attr_dense_verify(hid_t loc_id, unsigned max_attr)
static void
test_attr_dense_create(hid_t fcpl, hid_t fapl)
{
- hid_t fid; /* HDF5 File ID */
- hid_t dataset; /* Dataset ID */
- hid_t sid; /* Dataspace ID */
- hid_t attr; /* Attribute ID */
- hid_t dcpl; /* Dataset creation property list ID */
- char attrname[NAME_BUF_SIZE]; /* Name of attribute */
- unsigned max_compact; /* Maximum # of attributes to store compactly */
- unsigned min_dense; /* Minimum # of attributes to store "densely" */
- htri_t is_dense; /* Are attributes stored densely? */
- unsigned u; /* Local index variable */
- h5_stat_size_t empty_filesize; /* Size of empty file */
- h5_stat_size_t filesize; /* Size of file after modifications */
- herr_t ret; /* Generic return value */
+ hid_t fid; /* HDF5 File ID */
+ hid_t dataset; /* Dataset ID */
+ hid_t sid; /* Dataspace ID */
+ hid_t attr; /* Attribute ID */
+ hid_t dcpl; /* Dataset creation property list ID */
+ char attrname[NAME_BUF_SIZE]; /* Name of attribute */
+ unsigned max_compact; /* Maximum # of attributes to store compactly */
+ unsigned min_dense; /* Minimum # of attributes to store "densely" */
+ htri_t is_dense; /* Are attributes stored densely? */
+ unsigned u; /* Local index variable */
+ h5_stat_size_t empty_filesize; /* Size of empty file */
+ h5_stat_size_t filesize; /* Size of file after modifications */
+ herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Dense Attribute Storage Creation\n"));
@@ -2146,7 +2178,7 @@ test_attr_dense_create(hid_t fcpl, hid_t fapl)
/* Get size of file */
empty_filesize = h5_get_file_size(FILENAME, fapl);
- if(empty_filesize < 0)
+ if (empty_filesize < 0)
TestErrPrintf("Line %d: file size wrong!\n", __LINE__);
/* Re-open file */
@@ -2157,9 +2189,15 @@ test_attr_dense_create(hid_t fcpl, hid_t fapl)
sid = H5Screate(H5S_SCALAR);
CHECK(sid, FAIL, "H5Screate");
- /* Query the group creation properties */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ /* need DCPL to query the group creation properties */
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ }
+ else {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
/* Create a dataset */
dataset = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT);
@@ -2174,13 +2212,13 @@ test_attr_dense_create(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Pclose");
/* Check on dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
/* Add attributes, until just before converting to dense storage */
- for(u = 0; u < max_compact; u++) {
+ for (u = 0; u < max_compact; u++) {
/* Create attribute */
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -2194,18 +2232,18 @@ test_attr_dense_create(hid_t fcpl, hid_t fapl)
} /* end for */
/* Check on dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
/* Add one more attribute, to push into "dense" storage */
/* Create attribute */
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
/* Check on dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test");
/* Write data into the attribute */
ret = H5Awrite(attr, H5T_NATIVE_UINT, &u);
@@ -2235,12 +2273,13 @@ test_attr_dense_create(hid_t fcpl, hid_t fapl)
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
- /* Check size of file */
- filesize = h5_get_file_size(FILENAME, fapl);
- VERIFY(filesize, empty_filesize, "h5_get_file_size");
-} /* test_attr_dense_create() */
+ if (h5_using_default_driver(NULL)) {
+ /* Check size of file */
+ filesize = h5_get_file_size(FILENAME, fapl);
+ VERIFY(filesize, empty_filesize, "h5_get_file_size");
+ }
+} /* test_attr_dense_create() */
-
/****************************************************************
**
** test_attr_dense_open(): Test basic H5A (attribute) code.
@@ -2250,19 +2289,19 @@ test_attr_dense_create(hid_t fcpl, hid_t fapl)
static void
test_attr_dense_open(hid_t fcpl, hid_t fapl)
{
- hid_t fid; /* HDF5 File ID */
- hid_t dataset; /* Dataset ID */
- hid_t sid; /* Dataspace ID */
- hid_t attr; /* Attribute ID */
- hid_t dcpl; /* Dataset creation property list ID */
- char attrname[NAME_BUF_SIZE]; /* Name of attribute */
- unsigned max_compact; /* Maximum # of attributes to store compactly */
- unsigned min_dense; /* Minimum # of attributes to store "densely" */
- htri_t is_dense; /* Are attributes stored densely? */
- unsigned u; /* Local index variable */
- h5_stat_size_t empty_filesize; /* Size of empty file */
- h5_stat_size_t filesize; /* Size of file after modifications */
- herr_t ret; /* Generic return value */
+ hid_t fid; /* HDF5 File ID */
+ hid_t dataset; /* Dataset ID */
+ hid_t sid; /* Dataspace ID */
+ hid_t attr; /* Attribute ID */
+ hid_t dcpl; /* Dataset creation property list ID */
+ char attrname[NAME_BUF_SIZE]; /* Name of attribute */
+ unsigned max_compact; /* Maximum # of attributes to store compactly */
+ unsigned min_dense; /* Minimum # of attributes to store "densely" */
+ htri_t is_dense; /* Are attributes stored densely? */
+ unsigned u; /* Local index variable */
+ h5_stat_size_t empty_filesize; /* Size of empty file */
+ h5_stat_size_t filesize; /* Size of file after modifications */
+ herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Opening Attributes in Dense Storage\n"));
@@ -2277,7 +2316,7 @@ test_attr_dense_open(hid_t fcpl, hid_t fapl)
/* Get size of file */
empty_filesize = h5_get_file_size(FILENAME, fapl);
- if(empty_filesize < 0)
+ if (empty_filesize < 0)
TestErrPrintf("Line %d: file size wrong!\n", __LINE__);
/* Re-open file */
@@ -2288,9 +2327,15 @@ test_attr_dense_open(hid_t fcpl, hid_t fapl)
sid = H5Screate(H5S_SCALAR);
CHECK(sid, FAIL, "H5Screate");
- /* Query the group creation properties */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ /* need DCPL to query the group creation properties */
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ }
+ else {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
/* Enable creation order tracking on attributes, so creation order tests work */
ret = H5Pset_attr_creation_order(dcpl, H5P_CRT_ORDER_TRACKED);
@@ -2309,13 +2354,13 @@ test_attr_dense_open(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Pclose");
/* Check on dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
/* Add attributes, until just before converting to dense storage */
- for(u = 0; u < max_compact; u++) {
+ for (u = 0; u < max_compact; u++) {
/* Create attribute */
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -2333,18 +2378,18 @@ test_attr_dense_open(hid_t fcpl, hid_t fapl)
} /* end for */
/* Check on dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
/* Add one more attribute, to push into "dense" storage */
/* Create attribute */
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
/* Check on dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test");
/* Write data into the attribute */
ret = H5Awrite(attr, H5T_NATIVE_UINT, &u);
@@ -2374,12 +2419,13 @@ test_attr_dense_open(hid_t fcpl, hid_t fapl)
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
- /* Check size of file */
- filesize = h5_get_file_size(FILENAME, fapl);
- VERIFY(filesize, empty_filesize, "h5_get_file_size");
-} /* test_attr_dense_open() */
+ if (h5_using_default_driver(NULL)) {
+ /* Check size of file */
+ filesize = h5_get_file_size(FILENAME, fapl);
+ VERIFY(filesize, empty_filesize, "h5_get_file_size");
+ }
+} /* test_attr_dense_open() */
-
/****************************************************************
**
** test_attr_dense_delete(): Test basic H5A (attribute) code.
@@ -2389,27 +2435,42 @@ test_attr_dense_open(hid_t fcpl, hid_t fapl)
static void
test_attr_dense_delete(hid_t fcpl, hid_t fapl)
{
- hid_t fid; /* HDF5 File ID */
- hid_t dataset; /* Dataset ID */
- hid_t sid; /* Dataspace ID */
- hid_t attr; /* Attribute ID */
- hid_t dcpl; /* Dataset creation property list ID */
- char attrname[NAME_BUF_SIZE]; /* Name of attribute */
- unsigned max_compact; /* Maximum # of attributes to store compactly */
- unsigned min_dense; /* Minimum # of attributes to store "densely" */
- htri_t is_dense; /* Are attributes stored densely? */
- unsigned u; /* Local index variable */
- h5_stat_size_t empty_filesize; /* Size of empty file */
- h5_stat_size_t filesize; /* Size of file after modifications */
- H5O_info_t oinfo; /* Object info */
- herr_t ret; /* Generic return value */
+ hid_t fid; /* HDF5 File ID */
+ hid_t dataset; /* Dataset ID */
+ hid_t sid; /* Dataspace ID */
+ hid_t attr; /* Attribute ID */
+ hid_t dcpl; /* Dataset creation property list ID */
+ char attrname[NAME_BUF_SIZE]; /* Name of attribute */
+ unsigned max_compact; /* Maximum # of attributes to store compactly */
+ unsigned min_dense; /* Minimum # of attributes to store "densely" */
+ htri_t is_dense; /* Are attributes stored densely? */
+ unsigned u; /* Local index variable */
+ h5_stat_size_t empty_filesize; /* Size of empty file */
+ h5_stat_size_t filesize; /* Size of file after modifications */
+ H5O_info2_t oinfo; /* Object info */
+ int use_min_dset_oh = (dcpl_g != H5P_DEFAULT);
+ herr_t ret; /* Generic return value */
+
+ /* Only run this test for sec2/default driver */
+ if (!h5_using_default_driver(NULL))
+ return;
/* Output message about test being performed */
MESSAGE(5, ("Testing Deleting Attributes in Dense Storage\n"));
- /* Create file */
+ if (use_min_dset_oh) { /* using minimized dataset headers */
+ /* modify fcpl...
+ * sidestep "bug" where file space is lost with minimized dset ohdrs
+ */
+ fcpl = H5Pcopy(fcpl);
+ CHECK(fcpl, FAIL, "H5Pcopy");
+ ret = H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, 1);
+ CHECK(ret, FAIL, "H5Pset_file_space_strategy");
+ }
fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl);
CHECK(fid, FAIL, "H5Fcreate");
+ if (use_min_dset_oh)
+ CHECK(H5Pclose(fcpl), FAIL, "H5Pclose");
/* Close file */
ret = H5Fclose(fid);
@@ -2417,7 +2478,7 @@ test_attr_dense_delete(hid_t fcpl, hid_t fapl)
/* Get size of file */
empty_filesize = h5_get_file_size(FILENAME, fapl);
- if(empty_filesize < 0)
+ if (empty_filesize < 0)
TestErrPrintf("Line %d: file size wrong!\n", __LINE__);
/* Re-open file */
@@ -2428,9 +2489,15 @@ test_attr_dense_delete(hid_t fcpl, hid_t fapl)
sid = H5Screate(H5S_SCALAR);
CHECK(sid, FAIL, "H5Screate");
- /* Query the group creation properties */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ /* need DCPL to query the group creation properties */
+ if (use_min_dset_oh) {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
+ else {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ }
/* Enable creation order tracking on attributes, so creation order tests work */
ret = H5Pset_attr_creation_order(dcpl, H5P_CRT_ORDER_TRACKED);
@@ -2449,13 +2516,13 @@ test_attr_dense_delete(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Pclose");
/* Check on dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
/* Add attributes, until well into dense storage */
- for(u = 0; u < (max_compact * 2); u++) {
+ for (u = 0; u < (max_compact * 2); u++) {
/* Create attribute */
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -2468,14 +2535,14 @@ test_attr_dense_delete(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Aclose");
/* Check # of attributes */
- ret = H5Oget_info(dataset, &oinfo);
- CHECK(ret, FAIL, "H5Oget_info");
- VERIFY(oinfo.num_attrs, (u + 1), "H5Oget_info");
+ ret = H5Oget_info3(dataset, &oinfo, H5O_INFO_NUM_ATTRS);
+ CHECK(ret, FAIL, "H5Oget_info3");
+ VERIFY(oinfo.num_attrs, (u + 1), "H5Oget_info3");
} /* end for */
/* Check on dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test");
/* Close dataspace */
ret = H5Sclose(sid);
@@ -2489,7 +2556,6 @@ test_attr_dense_delete(hid_t fcpl, hid_t fapl)
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
-
/* Re-open file */
fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
CHECK(fid, FAIL, "H5Fopen");
@@ -2499,9 +2565,9 @@ test_attr_dense_delete(hid_t fcpl, hid_t fapl)
CHECK(dataset, FAIL, "H5Dopen2");
/* Delete attributes until the attributes revert to compact storage again */
- for(u--; u >= min_dense; u--) {
+ for (u--; u >= min_dense; u--) {
/* Delete attribute */
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
ret = H5Adelete(dataset, attrname);
CHECK(ret, FAIL, "H5Adelete");
@@ -2511,30 +2577,30 @@ test_attr_dense_delete(hid_t fcpl, hid_t fapl)
} /* end for */
/* Check on dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test");
/* Delete one more attribute, which should cause reversion to compact storage */
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
ret = H5Adelete(dataset, attrname);
CHECK(ret, FAIL, "H5Adelete");
/* Check on dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
/* Verify attributes still left */
ret = test_attr_dense_verify(dataset, (u - 1));
CHECK(ret, FAIL, "test_attr_dense_verify");
/* Delete another attribute, to verify deletion in compact storage */
- sprintf(attrname, "attr %02u", (u - 1));
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", (u - 1));
ret = H5Adelete(dataset, attrname);
CHECK(ret, FAIL, "H5Adelete");
/* Check on dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
/* Verify attributes still left */
ret = test_attr_dense_verify(dataset, (u - 2));
@@ -2552,12 +2618,13 @@ test_attr_dense_delete(hid_t fcpl, hid_t fapl)
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
- /* Check size of file */
- filesize = h5_get_file_size(FILENAME, fapl);
- VERIFY(filesize, empty_filesize, "h5_get_file_size");
-} /* test_attr_dense_delete() */
+ if (h5_using_default_driver(NULL)) {
+ /* Check size of file */
+ filesize = h5_get_file_size(FILENAME, fapl);
+ VERIFY(filesize, empty_filesize, "h5_get_file_size");
+ }
+} /* test_attr_dense_delete() */
-
/****************************************************************
**
** test_attr_dense_rename(): Test basic H5A (attribute) code.
@@ -2567,28 +2634,44 @@ test_attr_dense_delete(hid_t fcpl, hid_t fapl)
static void
test_attr_dense_rename(hid_t fcpl, hid_t fapl)
{
- hid_t fid; /* HDF5 File ID */
- hid_t dataset; /* Dataset ID */
- hid_t sid; /* Dataspace ID */
- hid_t attr; /* Attribute ID */
- hid_t dcpl; /* Dataset creation property list ID */
- char attrname[NAME_BUF_SIZE]; /* Name of attribute */
- char new_attrname[NAME_BUF_SIZE]; /* New name of attribute */
- unsigned max_compact; /* Maximum # of attributes to store compactly */
- unsigned min_dense; /* Minimum # of attributes to store "densely" */
- htri_t is_dense; /* Are attributes stored densely? */
- h5_stat_size_t empty_filesize; /* Size of empty file */
- h5_stat_size_t filesize; /* Size of file after modifications */
- H5O_info_t oinfo; /* Object info */
- unsigned u; /* Local index variable */
- herr_t ret; /* Generic return value */
+ hid_t fid; /* HDF5 File ID */
+ hid_t dataset; /* Dataset ID */
+ hid_t sid; /* Dataspace ID */
+ hid_t attr; /* Attribute ID */
+ hid_t dcpl; /* Dataset creation property list ID */
+ char attrname[NAME_BUF_SIZE]; /* Name of attribute */
+ char new_attrname[NAME_BUF_SIZE]; /* New name of attribute */
+ unsigned max_compact; /* Maximum # of attributes to store compactly */
+ unsigned min_dense; /* Minimum # of attributes to store "densely" */
+ htri_t is_dense; /* Are attributes stored densely? */
+ h5_stat_size_t empty_filesize; /* Size of empty file */
+ h5_stat_size_t filesize; /* Size of file after modifications */
+ H5O_info2_t oinfo; /* Object info */
+ unsigned u; /* Local index variable */
+ int use_min_dset_oh = (dcpl_g != H5P_DEFAULT);
+ unsigned use_corder; /* Track creation order or not */
+ herr_t ret; /* Generic return value */
+
+ /* Only run this test for sec2/default driver */
+ if (!h5_using_default_driver(NULL))
+ return;
/* Output message about test being performed */
MESSAGE(5, ("Testing Renaming Attributes in Dense Storage\n"));
- /* Create file */
+ if (use_min_dset_oh) { /* using minimized dataset headers */
+ /* modify fcpl...
+ * sidestep "bug" where file space is lost with minimized dset ohdrs
+ */
+ fcpl = H5Pcopy(fcpl);
+ CHECK(fcpl, FAIL, "H5Pcopy");
+ ret = H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, 1);
+ CHECK(ret, FAIL, "H5Pset_file_space_strategy");
+ }
fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl);
- CHECK(fid, FAIL, "H5Fcreate");
+ CHECK(fid, H5I_INVALID_HID, "H5Fcreate");
+ if (use_min_dset_oh)
+ CHECK(H5Pclose(fcpl), FAIL, "H5Pclose");
/* Close file */
ret = H5Fclose(fid);
@@ -2596,98 +2679,119 @@ test_attr_dense_rename(hid_t fcpl, hid_t fapl)
/* Get size of file */
empty_filesize = h5_get_file_size(FILENAME, fapl);
- if(empty_filesize < 0)
+ if (empty_filesize < 0)
TestErrPrintf("Line %d: file size wrong!\n", __LINE__);
/* Re-open file */
fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
- CHECK(fid, FAIL, "H5Fopen");
+ CHECK(fid, H5I_INVALID_HID, "H5Fopen");
/* Create dataspace for dataset */
sid = H5Screate(H5S_SCALAR);
- CHECK(sid, FAIL, "H5Screate");
+ CHECK(sid, H5I_INVALID_HID, "H5Screate");
- /* Query the group creation properties */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
-
- /* Create a dataset */
- dataset = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT);
- CHECK(dataset, FAIL, "H5Dcreate2");
+ /* need DCPL to query the group creation properties */
+ if (use_min_dset_oh) {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, H5I_INVALID_HID, "H5Pcopy");
+ }
+ else {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, H5I_INVALID_HID, "H5Pcreate");
+ }
/* Retrieve limits for compact/dense attribute storage */
ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense);
CHECK(ret, FAIL, "H5Pget_attr_phase_change");
- /* Close property list */
- ret = H5Pclose(dcpl);
- CHECK(ret, FAIL, "H5Pclose");
+ /* Using creation order or not */
+ for (use_corder = FALSE; use_corder <= TRUE; use_corder++) {
- /* Check on dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ if (use_corder) {
+ ret = H5Pset_attr_creation_order(dcpl, H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED);
+ CHECK(ret, FAIL, "H5Pset_attr_creation_order");
+ }
- /* Add attributes, until well into dense storage */
- for(u = 0; u < (max_compact * 2); u++) {
- /* Create attribute */
- sprintf(attrname, "attr %02u", u);
- attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
- CHECK(attr, FAIL, "H5Acreate2");
+ /* Create a dataset */
+ dataset = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT);
+ CHECK(dataset, H5I_INVALID_HID, "H5Dcreate2");
- /* Write data into the attribute */
- ret = H5Awrite(attr, H5T_NATIVE_UINT, &u);
- CHECK(ret, FAIL, "H5Awrite");
+ /* Check on dataset's attribute storage status */
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
- /* Close attribute */
- ret = H5Aclose(attr);
- CHECK(ret, FAIL, "H5Aclose");
+ /* Add attributes, until well into dense storage */
+ for (u = 0; u < (max_compact * 2); u++) {
+ /* Create attribute */
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
+ attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(attr, H5I_INVALID_HID, "H5Acreate2");
- /* Rename attribute */
- sprintf(new_attrname, "new attr %02u", u);
+ /* Write data into the attribute */
+ ret = H5Awrite(attr, H5T_NATIVE_UINT, &u);
+ CHECK(ret, FAIL, "H5Awrite");
- /* Rename attribute */
- ret = H5Arename_by_name(fid, DSET1_NAME, attrname, new_attrname, H5P_DEFAULT);
- CHECK(ret, FAIL, "H5Arename_by_name");
+ /* Close attribute */
+ ret = H5Aclose(attr);
+ CHECK(ret, FAIL, "H5Aclose");
- /* Check # of attributes */
- ret = H5Oget_info(dataset, &oinfo);
- CHECK(ret, FAIL, "H5Oget_info");
- VERIFY(oinfo.num_attrs, (u + 1), "H5Oget_info");
- } /* end for */
+ /* Rename attribute */
+ HDsnprintf(new_attrname, sizeof(new_attrname), "new attr %02u", u);
- /* Check on dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
+ /* Rename attribute */
+ ret = H5Arename_by_name(fid, DSET1_NAME, attrname, new_attrname, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Arename_by_name");
+
+ /* Check # of attributes */
+ ret = H5Oget_info3(dataset, &oinfo, H5O_INFO_NUM_ATTRS);
+ CHECK(ret, FAIL, "H5Oget_info3");
+ VERIFY(oinfo.num_attrs, (u + 1), "H5Oget_info3");
+ } /* end for */
+
+ /* Check on dataset's attribute storage status */
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test");
+
+ /* Close Dataset */
+ ret = H5Dclose(dataset);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ if (!use_corder) {
+ /* Unlink dataset with attributes */
+ ret = H5Ldelete(fid, DSET1_NAME, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Ldelete");
+ }
+
+ } /* end for use_corder */
/* Close dataspace */
ret = H5Sclose(sid);
CHECK(ret, FAIL, "H5Sclose");
- /* Close Dataset */
- ret = H5Dclose(dataset);
- CHECK(ret, FAIL, "H5Dclose");
+ /* Close property list */
+ ret = H5Pclose(dcpl);
+ CHECK(ret, FAIL, "H5Pclose");
/* Close file */
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
-
/* Re-open file */
fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
- CHECK(fid, FAIL, "H5Fopen");
+ CHECK(fid, H5I_INVALID_HID, "H5Fopen");
/* Open dataset */
dataset = H5Dopen2(fid, DSET1_NAME, H5P_DEFAULT);
- CHECK(dataset, FAIL, "H5Dopen2");
+ CHECK(dataset, H5I_INVALID_HID, "H5Dopen2");
/* Verify renamed attributes */
- for(u = 0; u < (max_compact * 2); u++) {
- unsigned value; /* Attribute value */
+ for (u = 0; u < (max_compact * 2); u++) {
+ unsigned value; /* Attribute value */
/* Open attribute */
- sprintf(attrname, "new attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "new attr %02u", u);
attr = H5Aopen(dataset, attrname, H5P_DEFAULT);
- CHECK(attr, FAIL, "H5Aopen");
+ CHECK(attr, H5I_INVALID_HID, "H5Aopen");
/* Read data from the attribute */
ret = H5Aread(attr, H5T_NATIVE_UINT, &value);
@@ -2711,12 +2815,13 @@ test_attr_dense_rename(hid_t fcpl, hid_t fapl)
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
- /* Check size of file */
- filesize = h5_get_file_size(FILENAME, fapl);
- VERIFY(filesize, empty_filesize, "h5_get_file_size");
-} /* test_attr_dense_rename() */
+ if (h5_using_default_driver(NULL)) {
+ /* Check size of file */
+ filesize = h5_get_file_size(FILENAME, fapl);
+ VERIFY(filesize, empty_filesize, "h5_get_file_size");
+ }
+} /* test_attr_dense_rename() */
-
/****************************************************************
**
** test_attr_dense_unlink(): Test basic H5A (attribute) code.
@@ -2726,36 +2831,49 @@ test_attr_dense_rename(hid_t fcpl, hid_t fapl)
static void
test_attr_dense_unlink(hid_t fcpl, hid_t fapl)
{
- hid_t fid; /* HDF5 File ID */
- hid_t dataset; /* Dataset ID */
- hid_t sid; /* Dataspace ID */
- hid_t attr; /* Attribute ID */
- hid_t dcpl; /* Dataset creation property list ID */
- char attrname[NAME_BUF_SIZE]; /* Name of attribute */
- unsigned max_compact; /* Maximum # of attributes to store compactly */
- unsigned min_dense; /* Minimum # of attributes to store "densely" */
- htri_t is_dense; /* Are attributes stored densely? */
- size_t mesg_count; /* # of shared messages */
- h5_stat_size_t empty_filesize; /* Size of empty file */
- h5_stat_size_t filesize; /* Size of file after modifications */
- H5O_info_t oinfo; /* Object info */
- unsigned u; /* Local index variable */
- herr_t ret; /* Generic return value */
+ hid_t fid; /* HDF5 File ID */
+ hid_t dataset; /* Dataset ID */
+ hid_t sid; /* Dataspace ID */
+ hid_t attr; /* Attribute ID */
+ hid_t dcpl; /* Dataset creation property list ID */
+ char attrname[NAME_BUF_SIZE]; /* Name of attribute */
+ unsigned max_compact; /* Maximum # of attributes to store compactly */
+ unsigned min_dense; /* Minimum # of attributes to store "densely" */
+ htri_t is_dense; /* Are attributes stored densely? */
+ size_t mesg_count; /* # of shared messages */
+ h5_stat_size_t empty_filesize; /* Size of empty file */
+ h5_stat_size_t filesize; /* Size of file after modifications */
+ H5O_info2_t oinfo; /* Object info */
+ unsigned u; /* Local index variable */
+ int use_min_dset_oh = (dcpl_g != H5P_DEFAULT);
+ herr_t ret; /* Generic return value */
+
+ /* Only run this test for sec2/default driver */
+ if (!h5_using_default_driver(NULL))
+ return;
/* Output message about test being performed */
MESSAGE(5, ("Testing Unlinking Object with Attributes in Dense Storage\n"));
- /* Create file */
+ if (use_min_dset_oh) { /* using minimized dataset headers */
+ /* modify fcpl...
+ * sidestep "bug" where file space is lost with minimized dset ohdrs
+ */
+ fcpl = H5Pcopy(fcpl);
+ CHECK(fcpl, FAIL, "H5Pcopy");
+ ret = H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, 1);
+ CHECK(ret, FAIL, "H5Pset_file_space_strategy");
+ }
fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl);
CHECK(fid, FAIL, "H5Fcreate");
+ if (use_min_dset_oh)
+ CHECK(H5Pclose(fcpl), FAIL, "H5Pclose");
- /* Close file */
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
- /* Get size of file */
empty_filesize = h5_get_file_size(FILENAME, fapl);
- if(empty_filesize < 0)
+ if (empty_filesize < 0)
TestErrPrintf("Line %d: file size wrong!\n", __LINE__);
/* Re-open file */
@@ -2766,9 +2884,15 @@ test_attr_dense_unlink(hid_t fcpl, hid_t fapl)
sid = H5Screate(H5S_SCALAR);
CHECK(sid, FAIL, "H5Screate");
- /* Query the group creation properties */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ /* need DCPL to query the group creation properties */
+ if (use_min_dset_oh) {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
+ else {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ }
/* Create a dataset */
dataset = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT);
@@ -2783,13 +2907,13 @@ test_attr_dense_unlink(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Pclose");
/* Check on dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
/* Add attributes, until well into dense storage */
- for(u = 0; u < (max_compact * 2); u++) {
+ for (u = 0; u < (max_compact * 2); u++) {
/* Create attribute */
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -2802,14 +2926,14 @@ test_attr_dense_unlink(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Aclose");
/* Check # of attributes */
- ret = H5Oget_info(dataset, &oinfo);
- CHECK(ret, FAIL, "H5Oget_info");
- VERIFY(oinfo.num_attrs, (u + 1), "H5Oget_info");
+ ret = H5Oget_info3(dataset, &oinfo, H5O_INFO_NUM_ATTRS);
+ CHECK(ret, FAIL, "H5Oget_info3");
+ VERIFY(oinfo.num_attrs, (u + 1), "H5Oget_info3");
} /* end for */
/* Check on dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test");
/* Close dataspace */
ret = H5Sclose(sid);
@@ -2823,7 +2947,6 @@ test_attr_dense_unlink(hid_t fcpl, hid_t fapl)
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
-
/* Re-open file */
fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
CHECK(fid, FAIL, "H5Fopen");
@@ -2833,20 +2956,21 @@ test_attr_dense_unlink(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Ldelete");
/* Check on dataset's attribute storage status */
- ret = H5F_get_sohm_mesg_count_test(fid, H5O_ATTR_ID, &mesg_count);
- CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test");
- VERIFY(mesg_count, 0, "H5F_get_sohm_mesg_count_test");
+ ret = H5F__get_sohm_mesg_count_test(fid, H5O_ATTR_ID, &mesg_count);
+ CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test");
+ VERIFY(mesg_count, 0, "H5F__get_sohm_mesg_count_test");
/* Close file */
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
- /* Check size of file */
- filesize = h5_get_file_size(FILENAME, fapl);
- VERIFY(filesize, empty_filesize, "h5_get_file_size");
-} /* test_attr_dense_unlink() */
+ if (h5_using_default_driver(NULL)) {
+ /* Check size of file */
+ filesize = h5_get_file_size(FILENAME, fapl);
+ VERIFY(filesize, empty_filesize, "h5_get_file_size");
+ }
+} /* test_attr_dense_unlink() */
-
/****************************************************************
**
** test_attr_dense_limits(): Test basic H5A (attribute) code.
@@ -2856,19 +2980,19 @@ test_attr_dense_unlink(hid_t fcpl, hid_t fapl)
static void
test_attr_dense_limits(hid_t fcpl, hid_t fapl)
{
- hid_t fid; /* HDF5 File ID */
- hid_t dataset; /* Dataset ID */
- hid_t sid; /* Dataspace ID */
- hid_t attr; /* Attribute ID */
- hid_t dcpl; /* Dataset creation property list ID */
- char attrname[NAME_BUF_SIZE]; /* Name of attribute */
- unsigned max_compact, rmax_compact; /* Maximum # of attributes to store compactly */
- unsigned min_dense, rmin_dense; /* Minimum # of attributes to store "densely" */
- htri_t is_dense; /* Are attributes stored densely? */
- unsigned u; /* Local index variable */
- h5_stat_size_t empty_filesize; /* Size of empty file */
- h5_stat_size_t filesize; /* Size of file after modifications */
- herr_t ret; /* Generic return value */
+ hid_t fid; /* HDF5 File ID */
+ hid_t dataset; /* Dataset ID */
+ hid_t sid; /* Dataspace ID */
+ hid_t attr; /* Attribute ID */
+ hid_t dcpl; /* Dataset creation property list ID */
+ char attrname[NAME_BUF_SIZE]; /* Name of attribute */
+ unsigned max_compact, rmax_compact; /* Maximum # of attributes to store compactly */
+ unsigned min_dense, rmin_dense; /* Minimum # of attributes to store "densely" */
+ htri_t is_dense; /* Are attributes stored densely? */
+ unsigned u; /* Local index variable */
+ h5_stat_size_t empty_filesize; /* Size of empty file */
+ h5_stat_size_t filesize; /* Size of file after modifications */
+ herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Phase Change Limits For Attributes in Dense Storage\n"));
@@ -2883,7 +3007,7 @@ test_attr_dense_limits(hid_t fcpl, hid_t fapl)
/* Get size of file */
empty_filesize = h5_get_file_size(FILENAME, fapl);
- if(empty_filesize < 0)
+ if (empty_filesize < 0)
TestErrPrintf("Line %d: file size wrong!\n", __LINE__);
/* Re-open file */
@@ -2894,14 +3018,20 @@ test_attr_dense_limits(hid_t fcpl, hid_t fapl)
sid = H5Screate(H5S_SCALAR);
CHECK(sid, FAIL, "H5Screate");
- /* Query the group creation properties */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ /* need DCPL to query the group creation properties */
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ }
+ else {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
/* Change limits on compact/dense attribute storage */
max_compact = 0;
- min_dense = 0;
- ret = H5Pset_attr_phase_change(dcpl, max_compact, min_dense);
+ min_dense = 0;
+ ret = H5Pset_attr_phase_change(dcpl, max_compact, min_dense);
CHECK(ret, FAIL, "H5Pget_attr_phase_change");
/* Create a dataset */
@@ -2918,17 +3048,15 @@ test_attr_dense_limits(hid_t fcpl, hid_t fapl)
ret = H5Pclose(dcpl);
CHECK(ret, FAIL, "H5Pclose");
-
/* Check on dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
-
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
/* Add first attribute, which should be immediately in dense storage */
/* Create attribute */
u = 0;
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -2941,15 +3069,14 @@ test_attr_dense_limits(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Aclose");
/* Check on dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
-
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test");
/* Add second attribute, to allow deletions to be checked easily */
/* Create attribute */
u = 1;
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -2962,9 +3089,8 @@ test_attr_dense_limits(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Aclose");
/* Check on dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
-
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test");
/* Delete second attribute, attributes should still be stored densely */
@@ -2973,22 +3099,20 @@ test_attr_dense_limits(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Adelete");
/* Check on dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
-
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test");
/* Delete first attribute, attributes should not be stored densely */
/* Delete attribute */
u = 0;
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
ret = H5Adelete(dataset, attrname);
CHECK(ret, FAIL, "H5Adelete");
/* Check on dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
-
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
/* Close dataspace */
ret = H5Sclose(sid);
@@ -3006,12 +3130,13 @@ test_attr_dense_limits(hid_t fcpl, hid_t fapl)
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
- /* Check size of file */
- filesize = h5_get_file_size(FILENAME, fapl);
- VERIFY(filesize, empty_filesize, "h5_get_file_size");
-} /* test_attr_dense_limits() */
+ if (h5_using_default_driver(NULL)) {
+ /* Check size of file */
+ filesize = h5_get_file_size(FILENAME, fapl);
+ VERIFY(filesize, empty_filesize, "h5_get_file_size");
+ }
+} /* test_attr_dense_limits() */
-
/****************************************************************
**
** test_attr_dense_dup_ids(): Test operations with multiple ID
@@ -3021,23 +3146,23 @@ test_attr_dense_limits(hid_t fcpl, hid_t fapl)
static void
test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
{
- hid_t fid; /* HDF5 File ID */
- hid_t dataset; /* Dataset ID */
- hid_t gid1, gid2; /* Group ID */
- hid_t sid, sid2; /* Dataspace ID */
- hid_t attr, attr2, add_attr; /* Attribute ID */
- hid_t dcpl; /* Dataset creation property list ID */
- char attrname[NAME_BUF_SIZE]; /* Name of attribute */
- hsize_t dims[] = {ATTR1_DIM1};
- int read_data1[ATTR1_DIM1]={0}; /* Buffer for reading attribute */
- int rewrite_data[ATTR1_DIM1]={1234, -423, 9907256}; /* Test data for rewrite */
- unsigned scalar_data = 1317; /* scalar data for attribute */
- unsigned read_scalar; /* variable for reading attribute*/
- unsigned max_compact; /* Maximum # of attributes to store compactly */
- unsigned min_dense; /* Minimum # of attributes to store "densely" */
- htri_t is_dense; /* Are attributes stored densely? */
- unsigned u, i; /* Local index variable */
- herr_t ret; /* Generic return value */
+ hid_t fid; /* HDF5 File ID */
+ hid_t dataset; /* Dataset ID */
+ hid_t gid1, gid2; /* Group ID */
+ hid_t sid, sid2; /* Dataspace ID */
+ hid_t attr, attr2, add_attr; /* Attribute ID */
+ hid_t dcpl; /* Dataset creation property list ID */
+ char attrname[NAME_BUF_SIZE]; /* Name of attribute */
+ hsize_t dims[] = {ATTR1_DIM1};
+ int read_data1[ATTR1_DIM1] = {0}; /* Buffer for reading attribute */
+ int rewrite_data[ATTR1_DIM1] = {1234, -423, 9907256}; /* Test data for rewrite */
+ unsigned scalar_data = 1317; /* scalar data for attribute */
+ unsigned read_scalar; /* variable for reading attribute*/
+ unsigned max_compact; /* Maximum # of attributes to store compactly */
+ unsigned min_dense; /* Minimum # of attributes to store "densely" */
+ htri_t is_dense; /* Are attributes stored densely? */
+ unsigned u, i; /* Local index variable */
+ herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing operations with two IDs for Dense Storage\n"));
@@ -3061,9 +3186,15 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
sid = H5Screate(H5S_SCALAR);
CHECK(sid, FAIL, "H5Screate");
- /* Query the group creation properties */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ /* need DCPL to query the group creation properties */
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ }
+ else {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
/* Create a dataset */
dataset = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT);
@@ -3078,13 +3209,13 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Pclose");
/* Check on dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
/* Add attributes, until just before converting to dense storage */
- for(u = 0; u < max_compact; u++) {
+ for (u = 0; u < max_compact; u++) {
/* Create attribute */
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -3098,8 +3229,8 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
} /* end for */
/* Check on dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
/* Add one more attribute, to push into "dense" storage */
/* Create dataspace for attribute */
@@ -3107,13 +3238,13 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
CHECK(sid2, FAIL, "H5Screate_simple");
/* Create attribute */
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(dataset, attrname, H5T_NATIVE_INT, sid2, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
/* Check on dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test");
/* Open the attribute just created and get a second ID */
attr2 = H5Aopen(dataset, attrname, H5P_DEFAULT);
@@ -3147,8 +3278,8 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
CHECK(dataset, FAIL, "H5Dopen2");
/* Check on dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test");
/* Open first attribute for the dataset */
attr = H5Aopen(dataset, attrname, H5P_DEFAULT);
@@ -3159,10 +3290,9 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Aread");
/* Verify values read in */
- for(i = 0; i < ATTR1_DIM1; i++)
- if(0 != read_data1[i])
- TestErrPrintf("%d: attribute data different: read_data1[%d]=%d\n", __LINE__,
- i, read_data1[i]);
+ for (i = 0; i < ATTR1_DIM1; i++)
+ if (0 != read_data1[i])
+ TestErrPrintf("%d: attribute data different: read_data1[%d]=%d\n", __LINE__, i, read_data1[i]);
/* Open attribute for the second time */
attr2 = H5Aopen(dataset, attrname, H5P_DEFAULT);
@@ -3200,8 +3330,8 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
CHECK(dataset, FAIL, "H5Dopen2");
/* Check on dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test");
/* Open first attribute for the dataset */
attr = H5Aopen(dataset, attrname, H5P_DEFAULT);
@@ -3212,9 +3342,10 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Aread");
/* Verify values read in */
- for(i = 0; i < ATTR1_DIM1; i++)
- if(attr_data1[i] != read_data1[i])
- TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n", __LINE__, i, attr_data1[i], i, read_data1[i]);
+ for (i = 0; i < ATTR1_DIM1; i++)
+ if (attr_data1[i] != read_data1[i])
+ TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n", __LINE__, i,
+ attr_data1[i], i, read_data1[i]);
/* Open attribute for the second time */
attr2 = H5Aopen(dataset, attrname, H5P_DEFAULT);
@@ -3229,9 +3360,10 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Aread");
/* Verify values read in */
- for(i = 0; i < ATTR1_DIM1; i++)
- if(read_data1[i] != rewrite_data[i])
- TestErrPrintf("%d: attribute data different: read_data1[%d]=%d, rewrite_data[%d]=%d\n", __LINE__, i, read_data1[i], i, rewrite_data[i]);
+ for (i = 0; i < ATTR1_DIM1; i++)
+ if (read_data1[i] != rewrite_data[i])
+ TestErrPrintf("%d: attribute data different: read_data1[%d]=%d, rewrite_data[%d]=%d\n", __LINE__,
+ i, read_data1[i], i, rewrite_data[i]);
/* Close attribute */
ret = H5Aclose(attr);
@@ -3261,17 +3393,15 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
CHECK(dataset, FAIL, "H5Dopen2");
/* Check on dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test");
/* Open first attribute for the dataset */
- attr = H5Aopen_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)4,
- H5P_DEFAULT, H5P_DEFAULT);
+ attr = H5Aopen_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)4, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Aopen");
/* Open attribute for the second time */
- attr2 = H5Aopen_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)4,
- H5P_DEFAULT, H5P_DEFAULT);
+ attr2 = H5Aopen_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)4, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Aopen");
/* Write attribute information with the second ID */
@@ -3283,9 +3413,9 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Aread");
/* Verify values read in */
- if(read_scalar != scalar_data)
- TestErrPrintf("%d: attribute data different: read_scalar=%d, scalar_data=%d\n",
- __LINE__, read_scalar, scalar_data);
+ if (read_scalar != scalar_data)
+ TestErrPrintf("%d: attribute data different: read_scalar=%d, scalar_data=%d\n", __LINE__, read_scalar,
+ scalar_data);
/* Close attribute */
ret = H5Aclose(attr);
@@ -3317,28 +3447,25 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
CHECK(dataset, FAIL, "H5Dopen2");
/* Check on dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test");
/* Open attribute of the dataset for the first time */
- attr = H5Aopen_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)2,
- H5P_DEFAULT, H5P_DEFAULT);
+ attr = H5Aopen_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)2, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Aopen");
/* Delete a few attributes until the storage switches to compact */
- for(u = max_compact; u >= min_dense - 1; u--) {
- ret = H5Adelete_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)u,
- H5P_DEFAULT);
+ for (u = max_compact; u >= min_dense - 1; u--) {
+ ret = H5Adelete_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)u, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Adelete_by_idx");
}
/* Check on dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
/* Open attribute for the second time */
- attr2 = H5Aopen_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)2,
- H5P_DEFAULT, H5P_DEFAULT);
+ attr2 = H5Aopen_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)2, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Aopen");
/* Write attribute information with the second ID */
@@ -3350,9 +3477,9 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Aread");
/* Verify values read in */
- if(read_scalar != scalar_data)
- TestErrPrintf("%d: attribute data different: read_scalar=%d, scalar_data=%d\n",
- __LINE__, read_scalar, scalar_data);
+ if (read_scalar != scalar_data)
+ TestErrPrintf("%d: attribute data different: read_scalar=%d, scalar_data=%d\n", __LINE__, read_scalar,
+ scalar_data);
/* Close attribute */
ret = H5Aclose(attr);
@@ -3384,18 +3511,17 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
CHECK(dataset, FAIL, "H5Dopen2");
/* Check on dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
/* Open attribute of the dataset for the first time */
- attr = H5Aopen_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)3,
- H5P_DEFAULT, H5P_DEFAULT);
+ attr = H5Aopen_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)3, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Aopen");
/* Delete a few attributes until the storage switches to compact */
- for(u = min_dense-1; u <= max_compact; u++) {
+ for (u = min_dense - 1; u <= max_compact; u++) {
/* Create attribute */
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
add_attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(add_attr, FAIL, "H5Acreate2");
@@ -3409,12 +3535,11 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
}
/* Check on dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test");
/* Open attribute for the second time */
- attr2 = H5Aopen_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)3,
- H5P_DEFAULT, H5P_DEFAULT);
+ attr2 = H5Aopen_by_idx(dataset, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)3, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Aopen");
/* Write attribute information with the second ID */
@@ -3426,9 +3551,9 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Aread");
/* Verify values read in */
- if(read_scalar != scalar_data)
- TestErrPrintf("%d: attribute data different: read_scalar=%d, scalar_data=%d\n",
- __LINE__, read_scalar, scalar_data);
+ if (read_scalar != scalar_data)
+ TestErrPrintf("%d: attribute data different: read_scalar=%d, scalar_data=%d\n", __LINE__, read_scalar,
+ scalar_data);
/* Close attribute */
ret = H5Aclose(attr);
@@ -3458,14 +3583,13 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
CHECK(gid1, FAIL, "H5Gcreate2");
/* Create hard link to the first group */
- ret = H5Lcreate_hard(gid1, GROUP1_NAME, H5L_SAME_LOC, GROUP2_NAME, H5P_DEFAULT,
- H5P_DEFAULT);
+ ret = H5Lcreate_hard(gid1, GROUP1_NAME, H5L_SAME_LOC, GROUP2_NAME, H5P_DEFAULT, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Lcreate_hard");
/* Add attributes, until just before converting to dense storage */
- for(u = 0; u < max_compact; u++) {
+ for (u = 0; u < max_compact; u++) {
/* Create attribute */
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(gid1, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -3483,8 +3607,8 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
CHECK(attr, FAIL, "H5Acreate2");
/* Check on group's attribute storage status */
- is_dense = H5O_is_attr_dense_test(gid1);
- VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
+ is_dense = H5O__is_attr_dense_test(gid1);
+ VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test");
/* Open the hard link just created */
gid2 = H5Gopen2(fid, GROUP2_NAME, H5P_DEFAULT);
@@ -3503,9 +3627,10 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Aread");
/* Verify values read in */
- for(i = 0; i < ATTR1_DIM1; i++)
- if(attr_data1[i] != read_data1[i])
- TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n", __LINE__, i, attr_data1[i], i, read_data1[i]);
+ for (i = 0; i < ATTR1_DIM1; i++)
+ if (attr_data1[i] != read_data1[i])
+ TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n", __LINE__, i,
+ attr_data1[i], i, read_data1[i]);
/* Close attribute */
ret = H5Aclose(attr);
@@ -3532,9 +3657,8 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
/* Close file */
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
-} /* test_attr_dense_dup_ids() */
+} /* test_attr_dense_dup_ids() */
-
/****************************************************************
**
** test_attr_big(): Test basic H5A (attribute) code.
@@ -3544,24 +3668,24 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
static void
test_attr_big(hid_t fcpl, hid_t fapl)
{
- hid_t fid; /* HDF5 File ID */
- hid_t dataset; /* Dataset ID */
- hid_t sid; /* Dataspace ID */
- hid_t big_sid; /* "Big" dataspace ID */
- hsize_t dims[ATTR6_RANK] = {ATTR6_DIM1, ATTR6_DIM2, ATTR6_DIM3}; /* Attribute dimensions */
- hid_t attr; /* Attribute ID */
- hid_t dcpl; /* Dataset creation property list ID */
- char attrname[NAME_BUF_SIZE]; /* Name of attribute */
- unsigned max_compact; /* Maximum # of attributes to store compactly */
- unsigned min_dense; /* Minimum # of attributes to store "densely" */
- unsigned nshared_indices; /* # of shared message indices */
- H5F_libver_t low, high; /* File format bounds */
- htri_t is_empty; /* Are there any attributes? */
- htri_t is_dense; /* Are attributes stored densely? */
- unsigned u; /* Local index variable */
- h5_stat_size_t empty_filesize; /* Size of empty file */
- h5_stat_size_t filesize; /* Size of file after modifications */
- herr_t ret; /* Generic return value */
+ hid_t fid; /* HDF5 File ID */
+ hid_t dataset; /* Dataset ID */
+ hid_t sid; /* Dataspace ID */
+ hid_t big_sid; /* "Big" dataspace ID */
+ hsize_t dims[ATTR6_RANK] = {ATTR6_DIM1, ATTR6_DIM2, ATTR6_DIM3}; /* Attribute dimensions */
+ hid_t attr; /* Attribute ID */
+ hid_t dcpl; /* Dataset creation property list ID */
+ char attrname[NAME_BUF_SIZE]; /* Name of attribute */
+ unsigned max_compact; /* Maximum # of attributes to store compactly */
+ unsigned min_dense; /* Minimum # of attributes to store "densely" */
+ unsigned nshared_indices; /* # of shared message indices */
+ H5F_libver_t low, high; /* File format bounds */
+ htri_t is_empty; /* Are there any attributes? */
+ htri_t is_dense; /* Are attributes stored densely? */
+ unsigned u; /* Local index variable */
+ h5_stat_size_t empty_filesize; /* Size of empty file */
+ h5_stat_size_t filesize; /* Size of file after modifications */
+ herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Storing 'Big' Attributes in Dense Storage\n"));
@@ -3576,7 +3700,7 @@ test_attr_big(hid_t fcpl, hid_t fapl)
/* Get size of file */
empty_filesize = h5_get_file_size(FILENAME, fapl);
- if(empty_filesize < 0)
+ if (empty_filesize < 0)
TestErrPrintf("Line %d: file size wrong!\n", __LINE__);
/* Re-open file */
@@ -3591,9 +3715,15 @@ test_attr_big(hid_t fcpl, hid_t fapl)
big_sid = H5Screate_simple(ATTR6_RANK, dims, NULL);
CHECK(big_sid, FAIL, "H5Screate_simple");
- /* Query the group creation properties */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ /* need DCPL to query the group creation properties */
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ }
+ else {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
/* Retrieve limits for compact/dense attribute storage */
ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense);
@@ -3615,19 +3745,17 @@ test_attr_big(hid_t fcpl, hid_t fapl)
ret = H5Pclose(dcpl);
CHECK(ret, FAIL, "H5Pclose");
-
/* Check on dataset's attribute storage status */
- is_empty = H5O_is_attr_empty_test(dataset);
- VERIFY(is_empty, TRUE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
-
+ is_empty = H5O__is_attr_empty_test(dataset);
+ VERIFY(is_empty, TRUE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
/* Add first "small" attribute, which should be in compact storage */
/* Create attribute */
u = 0;
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -3636,17 +3764,16 @@ test_attr_big(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Aclose");
/* Check on dataset's attribute storage status */
- is_empty = H5O_is_attr_empty_test(dataset);
- VERIFY(is_empty, FALSE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
-
+ is_empty = H5O__is_attr_empty_test(dataset);
+ VERIFY(is_empty, FALSE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
/* Add second "small" attribute, which should stay in compact storage */
/* Create attribute */
u = 1;
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -3655,19 +3782,18 @@ test_attr_big(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Aclose");
/* Check on dataset's attribute storage status */
- is_empty = H5O_is_attr_empty_test(dataset);
- VERIFY(is_empty, FALSE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
-
+ is_empty = H5O__is_attr_empty_test(dataset);
+ VERIFY(is_empty, FALSE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
/* Add first "big" attribute, which should push storage into dense form */
/* Create attribute */
u = 2;
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, big_sid, H5P_DEFAULT, H5P_DEFAULT);
- if(low == H5F_LIBVER_LATEST) {
+ if (low == H5F_LIBVER_LATEST) {
CHECK(attr, FAIL, "H5Acreate2");
/* Close attribute */
@@ -3679,17 +3805,16 @@ test_attr_big(hid_t fcpl, hid_t fapl)
* message heap instead of forcing the attribute storage into the dense
* form - QAK)
*/
- is_empty = H5O_is_attr_empty_test(dataset);
- VERIFY(is_empty, FALSE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, (nshared_indices ? FALSE : TRUE), "H5O_is_attr_dense_test");
-
+ is_empty = H5O__is_attr_empty_test(dataset);
+ VERIFY(is_empty, FALSE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, (nshared_indices ? FALSE : TRUE), "H5O__is_attr_dense_test");
/* Add second "big" attribute, which should leave storage in dense form */
/* Create attribute */
u = 3;
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, big_sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -3702,68 +3827,64 @@ test_attr_big(hid_t fcpl, hid_t fapl)
* message heap instead of forcing the attribute storage into the dense
* form - QAK)
*/
- is_empty = H5O_is_attr_empty_test(dataset);
- VERIFY(is_empty, FALSE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, (nshared_indices ? FALSE : TRUE), "H5O_is_attr_dense_test");
-
+ is_empty = H5O__is_attr_empty_test(dataset);
+ VERIFY(is_empty, FALSE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, (nshared_indices ? FALSE : TRUE), "H5O__is_attr_dense_test");
/* Delete second "small" attribute, attributes should still be stored densely */
/* Delete attribute */
u = 1;
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
ret = H5Adelete(dataset, attrname);
CHECK(ret, FAIL, "H5Adelete");
/* Check on dataset's attribute storage status */
- is_empty = H5O_is_attr_empty_test(dataset);
- VERIFY(is_empty, FALSE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, (nshared_indices ? FALSE : TRUE), "H5O_is_attr_dense_test");
-
+ is_empty = H5O__is_attr_empty_test(dataset);
+ VERIFY(is_empty, FALSE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, (nshared_indices ? FALSE : TRUE), "H5O__is_attr_dense_test");
/* Delete second "big" attribute, attributes should still be stored densely */
/* Delete attribute */
u = 3;
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
ret = H5Adelete(dataset, attrname);
CHECK(ret, FAIL, "H5Adelete");
/* Check on dataset's attribute storage status */
- is_empty = H5O_is_attr_empty_test(dataset);
- VERIFY(is_empty, FALSE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, (nshared_indices ? FALSE : TRUE), "H5O_is_attr_dense_test");
-
+ is_empty = H5O__is_attr_empty_test(dataset);
+ VERIFY(is_empty, FALSE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, (nshared_indices ? FALSE : TRUE), "H5O__is_attr_dense_test");
/* Delete first "big" attribute, attributes should _not_ be stored densely */
/* Delete attribute */
u = 2;
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
ret = H5Adelete(dataset, attrname);
CHECK(ret, FAIL, "H5Adelete");
/* Check on dataset's attribute storage status */
- is_empty = H5O_is_attr_empty_test(dataset);
- VERIFY(is_empty, FALSE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
-
+ is_empty = H5O__is_attr_empty_test(dataset);
+ VERIFY(is_empty, FALSE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
/* Delete first "small" attribute, should be no attributes now */
/* Delete attribute */
u = 0;
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
ret = H5Adelete(dataset, attrname);
CHECK(ret, FAIL, "H5Adelete");
/* Check on dataset's attribute storage status */
- is_empty = H5O_is_attr_empty_test(dataset);
- VERIFY(is_empty, TRUE, "H5O_is_attr_empty_test");
+ is_empty = H5O__is_attr_empty_test(dataset);
+ VERIFY(is_empty, TRUE, "H5O__is_attr_empty_test");
} /* end if */
else {
/* Shouldn't be able to create "big" attributes with older version of format */
@@ -3774,13 +3895,12 @@ test_attr_big(hid_t fcpl, hid_t fapl)
* message heap instead of forcing the attribute storage into the dense
* form - QAK)
*/
- is_empty = H5O_is_attr_empty_test(dataset);
- VERIFY(is_empty, FALSE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ is_empty = H5O__is_attr_empty_test(dataset);
+ VERIFY(is_empty, FALSE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
} /* end else */
-
/* Close dataspaces */
ret = H5Sclose(sid);
CHECK(ret, FAIL, "H5Sclose");
@@ -3799,12 +3919,13 @@ test_attr_big(hid_t fcpl, hid_t fapl)
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
- /* Check size of file */
- filesize = h5_get_file_size(FILENAME, fapl);
- VERIFY(filesize, empty_filesize, "h5_get_file_size");
-} /* test_attr_big() */
+ if (h5_using_default_driver(NULL)) {
+ /* Check size of file */
+ filesize = h5_get_file_size(FILENAME, fapl);
+ VERIFY(filesize, empty_filesize, "h5_get_file_size");
+ }
+} /* test_attr_big() */
-
/****************************************************************
**
** test_attr_null_space(): Test basic H5A (attribute) code.
@@ -3814,20 +3935,20 @@ test_attr_big(hid_t fcpl, hid_t fapl)
static void
test_attr_null_space(hid_t fcpl, hid_t fapl)
{
- hid_t fid; /* HDF5 File ID */
- hid_t dataset; /* Dataset ID */
- hid_t sid; /* Dataspace ID */
- hid_t null_sid; /* "null" dataspace ID */
- hid_t attr_sid; /* Attribute's dataspace ID */
- hid_t attr; /* Attribute ID */
- char attrname[NAME_BUF_SIZE]; /* Name of attribute */
- unsigned value; /* Attribute value */
- htri_t cmp; /* Results of comparison */
- hsize_t storage_size; /* Size of storage for attribute */
- H5A_info_t ainfo; /* Attribute info */
- h5_stat_size_t empty_filesize; /* Size of empty file */
- h5_stat_size_t filesize; /* Size of file after modifications */
- herr_t ret; /* Generic return value */
+ hid_t fid; /* HDF5 File ID */
+ hid_t dataset; /* Dataset ID */
+ hid_t sid; /* Dataspace ID */
+ hid_t null_sid; /* "null" dataspace ID */
+ hid_t attr_sid; /* Attribute's dataspace ID */
+ hid_t attr; /* Attribute ID */
+ char attrname[NAME_BUF_SIZE]; /* Name of attribute */
+ unsigned value; /* Attribute value */
+ htri_t cmp; /* Results of comparison */
+ hsize_t storage_size; /* Size of storage for attribute */
+ H5A_info_t ainfo; /* Attribute info */
+ h5_stat_size_t empty_filesize; /* Size of empty file */
+ h5_stat_size_t filesize; /* Size of file after modifications */
+ herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Storing Attributes with 'null' dataspace\n"));
@@ -3842,7 +3963,7 @@ test_attr_null_space(hid_t fcpl, hid_t fapl)
/* Get size of file */
empty_filesize = h5_get_file_size(FILENAME, fapl);
- if(empty_filesize < 0)
+ if (empty_filesize < 0)
TestErrPrintf("Line %d: file size wrong!\n", __LINE__);
/* Re-open file */
@@ -3858,10 +3979,9 @@ test_attr_null_space(hid_t fcpl, hid_t fapl)
CHECK(null_sid, FAIL, "H5Screate");
/* Create a dataset */
- dataset = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ dataset = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT);
CHECK(dataset, FAIL, "H5Dcreate2");
-
/* Add attribute with 'null' dataspace */
/* Create attribute */
@@ -3872,7 +3992,7 @@ test_attr_null_space(hid_t fcpl, hid_t fapl)
/* Try to read data from the attribute */
/* (shouldn't fail, but should leave buffer alone) */
value = 23;
- ret = H5Aread(attr, H5T_NATIVE_UINT, &value);
+ ret = H5Aread(attr, H5T_NATIVE_UINT, &value);
CHECK(ret, FAIL, "H5Aread");
VERIFY(value, 23, "H5Aread");
@@ -3902,7 +4022,6 @@ test_attr_null_space(hid_t fcpl, hid_t fapl)
ret = H5Aclose(attr);
CHECK(ret, FAIL, "H5Aclose");
-
/* Add another attribute with 'null' dataspace */
/* Create attribute */
@@ -3913,7 +4032,7 @@ test_attr_null_space(hid_t fcpl, hid_t fapl)
/* Try to write data to the attribute */
/* (shouldn't fail, but should leave buffer alone) */
value = 23;
- ret = H5Awrite(attr, H5T_NATIVE_UINT, &value);
+ ret = H5Awrite(attr, H5T_NATIVE_UINT, &value);
CHECK(ret, FAIL, "H5Awrite");
VERIFY(value, 23, "H5Awrite");
@@ -3929,7 +4048,6 @@ test_attr_null_space(hid_t fcpl, hid_t fapl)
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
-
/* Re-open the file and check on the attributes */
/* Re-open file */
@@ -3940,7 +4058,6 @@ test_attr_null_space(hid_t fcpl, hid_t fapl)
dataset = H5Dopen2(fid, DSET1_NAME, H5P_DEFAULT);
CHECK(dataset, FAIL, "H5Dopen2");
-
/* Open first attribute */
HDstrcpy(attrname, "null attr #2");
attr = H5Aopen(dataset, attrname, H5P_DEFAULT);
@@ -3949,7 +4066,7 @@ test_attr_null_space(hid_t fcpl, hid_t fapl)
/* Try to read data from the attribute */
/* (shouldn't fail, but should leave buffer alone) */
value = 23;
- ret = H5Aread(attr, H5T_NATIVE_UINT, &value);
+ ret = H5Aread(attr, H5T_NATIVE_UINT, &value);
CHECK(ret, FAIL, "H5Aread");
VERIFY(value, 23, "H5Aread");
@@ -3979,7 +4096,6 @@ test_attr_null_space(hid_t fcpl, hid_t fapl)
ret = H5Aclose(attr);
CHECK(ret, FAIL, "H5Aclose");
-
/* Open second attribute */
HDstrcpy(attrname, "null attr");
attr = H5Aopen(dataset, attrname, H5P_DEFAULT);
@@ -3988,7 +4104,7 @@ test_attr_null_space(hid_t fcpl, hid_t fapl)
/* Try to write data to the attribute */
/* (shouldn't fail, but should leave buffer alone) */
value = 23;
- ret = H5Awrite(attr, H5T_NATIVE_UINT, &value);
+ ret = H5Awrite(attr, H5T_NATIVE_UINT, &value);
CHECK(ret, FAIL, "H5Awrite");
VERIFY(value, 23, "H5Awrite");
@@ -3996,7 +4112,6 @@ test_attr_null_space(hid_t fcpl, hid_t fapl)
ret = H5Aclose(attr);
CHECK(ret, FAIL, "H5Aclose");
-
/* Close Dataset */
ret = H5Dclose(dataset);
CHECK(ret, FAIL, "H5Dclose");
@@ -4009,20 +4124,19 @@ test_attr_null_space(hid_t fcpl, hid_t fapl)
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
-
/* Close dataspaces */
ret = H5Sclose(sid);
CHECK(ret, FAIL, "H5Sclose");
ret = H5Sclose(null_sid);
CHECK(ret, FAIL, "H5Sclose");
+ if (h5_using_default_driver(NULL)) {
+ /* Check size of file */
+ filesize = h5_get_file_size(FILENAME, fapl);
+ VERIFY(filesize, empty_filesize, "h5_get_file_size");
+ }
+} /* test_attr_null_space() */
- /* Check size of file */
- filesize = h5_get_file_size(FILENAME, fapl);
- VERIFY(filesize, empty_filesize, "h5_get_file_size");
-} /* test_attr_null_space() */
-
-
/****************************************************************
**
** test_attr_deprec(): Test basic H5A (attribute) code.
@@ -4033,11 +4147,11 @@ static void
test_attr_deprec(hid_t fcpl, hid_t fapl)
{
#ifndef H5_NO_DEPRECATED_SYMBOLS
- hid_t fid; /* HDF5 File ID */
- hid_t dataset; /* Dataset ID */
- hid_t sid; /* Dataspace ID */
- hid_t attr; /* Attribute ID */
- herr_t ret; /* Generic return value */
+ hid_t fid; /* HDF5 File ID */
+ hid_t dataset; /* Dataset ID */
+ hid_t sid; /* Dataspace ID */
+ hid_t attr; /* Attribute ID */
+ herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Deprecated Attribute Routines\n"));
@@ -4051,10 +4165,9 @@ test_attr_deprec(hid_t fcpl, hid_t fapl)
CHECK(sid, FAIL, "H5Screate");
/* Create a dataset */
- dataset = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ dataset = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT);
CHECK(dataset, FAIL, "H5Dcreate2");
-
/* Add attribute to dataset */
/* Create attribute */
@@ -4065,7 +4178,6 @@ test_attr_deprec(hid_t fcpl, hid_t fapl)
ret = H5Aclose(attr);
CHECK(ret, FAIL, "H5Aclose");
-
/* Close dataspaces */
ret = H5Sclose(sid);
@@ -4077,7 +4189,6 @@ test_attr_deprec(hid_t fcpl, hid_t fapl)
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
-
/* Re-open the file and operate on the attribute */
/* Re-open file */
@@ -4088,7 +4199,6 @@ test_attr_deprec(hid_t fcpl, hid_t fapl)
dataset = H5Dopen2(fid, DSET1_NAME, H5P_DEFAULT);
CHECK(dataset, FAIL, "H5Dopen2");
-
/* Get number of attributes with bad ID */
ret = H5Aget_num_attrs((hid_t)-1);
VERIFY(ret, FAIL, "H5Aget_num_attrs");
@@ -4113,7 +4223,6 @@ test_attr_deprec(hid_t fcpl, hid_t fapl)
ret = H5Aclose(attr);
CHECK(ret, FAIL, "H5Aclose");
-
/* Close Dataset */
ret = H5Dclose(dataset);
CHECK(ret, FAIL, "H5Dclose");
@@ -4123,15 +4232,15 @@ test_attr_deprec(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Fclose");
#else /* H5_NO_DEPRECATED_SYMBOLS */
/* Shut compiler up */
- fcpl = fcpl; fapl = fapl;
+ (void)fcpl;
+ (void)fapl;
/* Output message about test being skipped */
MESSAGE(5, ("Skipping Test On Deprecated Attribute Routines\n"));
#endif /* H5_NO_DEPRECATED_SYMBOLS */
-} /* test_attr_deprec() */
+} /* test_attr_deprec() */
-
/****************************************************************
**
** test_attr_many(): Test basic H5A (attribute) code.
@@ -4141,15 +4250,15 @@ test_attr_deprec(hid_t fcpl, hid_t fapl)
static void
test_attr_many(hbool_t new_format, hid_t fcpl, hid_t fapl)
{
- hid_t fid; /* HDF5 File ID */
- hid_t gid; /* Group ID */
- hid_t sid; /* Dataspace ID */
- hid_t aid; /* Attribute ID */
- char attrname[NAME_BUF_SIZE]; /* Name of attribute */
- unsigned nattr = (new_format ? NATTR_MANY_NEW : NATTR_MANY_OLD); /* Number of attributes */
- htri_t exists; /* Whether the attribute exists or not */
- unsigned u; /* Local index variable */
- herr_t ret; /* Generic return value */
+ hid_t fid; /* HDF5 File ID */
+ hid_t gid; /* Group ID */
+ hid_t sid; /* Dataspace ID */
+ hid_t aid; /* Attribute ID */
+ char attrname[NAME_BUF_SIZE]; /* Name of attribute */
+ unsigned nattr = (new_format ? NATTR_MANY_NEW : NATTR_MANY_OLD); /* Number of attributes */
+ htri_t exists; /* Whether the attribute exists or not */
+ unsigned u; /* Local index variable */
+ herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Storing Many Attributes\n"));
@@ -4167,8 +4276,8 @@ test_attr_many(hbool_t new_format, hid_t fcpl, hid_t fapl)
CHECK(gid, FAIL, "H5Gcreate2");
/* Create many attributes */
- for(u = 0; u < nattr; u++) {
- sprintf(attrname, "a-%06u", u);
+ for (u = 0; u < nattr; u++) {
+ HDsnprintf(attrname, sizeof(attrname), "a-%06u", u);
exists = H5Aexists(gid, attrname);
VERIFY(exists, FALSE, "H5Aexists");
@@ -4206,7 +4315,6 @@ test_attr_many(hbool_t new_format, hid_t fcpl, hid_t fapl)
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
-
/* Re-open the file and check on the attributes */
/* Re-open file */
@@ -4218,10 +4326,10 @@ test_attr_many(hbool_t new_format, hid_t fcpl, hid_t fapl)
CHECK(gid, FAIL, "H5Gopen2");
/* Verify attributes */
- for(u = 0; u < nattr; u++) {
- unsigned value; /* Attribute value */
+ for (u = 0; u < nattr; u++) {
+ unsigned value; /* Attribute value */
- sprintf(attrname, "a-%06u", u);
+ HDsnprintf(attrname, sizeof(attrname), "a-%06u", u);
exists = H5Aexists(gid, attrname);
VERIFY(exists, TRUE, "H5Aexists");
@@ -4254,13 +4362,11 @@ test_attr_many(hbool_t new_format, hid_t fcpl, hid_t fapl)
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
-
/* Close dataspaces */
ret = H5Sclose(sid);
CHECK(ret, FAIL, "H5Sclose");
-} /* test_attr_many() */
+} /* test_attr_many() */
-
/****************************************************************
**
** test_attr_corder_create_empty(): Test basic H5A (attribute) code.
@@ -4270,14 +4376,14 @@ test_attr_many(hbool_t new_format, hid_t fcpl, hid_t fapl)
static void
test_attr_corder_create_basic(hid_t fcpl, hid_t fapl)
{
- hid_t fid; /* HDF5 File ID */
- hid_t dataset; /* Dataset ID */
- hid_t sid; /* Dataspace ID */
- hid_t dcpl; /* Dataset creation property list ID */
- unsigned crt_order_flags;/* Creation order flags */
- htri_t is_empty; /* Are there any attributes? */
- htri_t is_dense; /* Are attributes stored densely? */
- herr_t ret; /* Generic return value */
+ hid_t fid; /* HDF5 File ID */
+ hid_t dataset; /* Dataset ID */
+ hid_t sid; /* Dataspace ID */
+ hid_t dcpl; /* Dataset creation property list ID */
+ unsigned crt_order_flags; /* Creation order flags */
+ htri_t is_empty; /* Are there any attributes? */
+ htri_t is_dense; /* Are attributes stored densely? */
+ herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Basic Code for Attributes with Creation Order Info\n"));
@@ -4287,8 +4393,14 @@ test_attr_corder_create_basic(hid_t fcpl, hid_t fapl)
CHECK(fid, FAIL, "H5Fcreate");
/* Create dataset creation property list */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ }
+ else {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
/* Get creation order indexing on object */
ret = H5Pget_attr_creation_order(dcpl, &crt_order_flags);
@@ -4307,7 +4419,7 @@ test_attr_corder_create_basic(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Pset_attr_creation_order");
ret = H5Pget_attr_creation_order(dcpl, &crt_order_flags);
CHECK(ret, FAIL, "H5Pget_attr_creation_order");
- VERIFY(crt_order_flags, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED) , "H5Pget_attr_creation_order");
+ VERIFY(crt_order_flags, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED), "H5Pget_attr_creation_order");
/* Create dataspace for dataset */
sid = H5Screate(H5S_SCALAR);
@@ -4322,10 +4434,10 @@ test_attr_corder_create_basic(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Sclose");
/* Check on dataset's attribute storage status */
- is_empty = H5O_is_attr_empty_test(dataset);
- VERIFY(is_empty, TRUE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ is_empty = H5O__is_attr_empty_test(dataset);
+ VERIFY(is_empty, TRUE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
/* Close Dataset */
ret = H5Dclose(dataset);
@@ -4339,7 +4451,6 @@ test_attr_corder_create_basic(hid_t fcpl, hid_t fapl)
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
-
/* Re-open file */
fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
CHECK(fid, FAIL, "H5Fopen");
@@ -4349,10 +4460,10 @@ test_attr_corder_create_basic(hid_t fcpl, hid_t fapl)
CHECK(dataset, FAIL, "H5Dopen2");
/* Check on dataset's attribute storage status */
- is_empty = H5O_is_attr_empty_test(dataset);
- VERIFY(is_empty, TRUE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ is_empty = H5O__is_attr_empty_test(dataset);
+ VERIFY(is_empty, TRUE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
/* Retrieve dataset creation property list for group */
dcpl = H5Dget_create_plist(dataset);
@@ -4361,7 +4472,7 @@ test_attr_corder_create_basic(hid_t fcpl, hid_t fapl)
/* Query the attribute creation properties */
ret = H5Pget_attr_creation_order(dcpl, &crt_order_flags);
CHECK(ret, FAIL, "H5Pget_attr_creation_order");
- VERIFY(crt_order_flags, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED) , "H5Pget_attr_creation_order");
+ VERIFY(crt_order_flags, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED), "H5Pget_attr_creation_order");
/* Close property list */
ret = H5Pclose(dcpl);
@@ -4374,9 +4485,8 @@ test_attr_corder_create_basic(hid_t fcpl, hid_t fapl)
/* Close file */
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
-} /* test_attr_corder_create_basic() */
+} /* test_attr_corder_create_basic() */
-
/****************************************************************
**
** test_attr_corder_create_compact(): Test basic H5A (attribute) code.
@@ -4386,21 +4496,21 @@ test_attr_corder_create_basic(hid_t fcpl, hid_t fapl)
static void
test_attr_corder_create_compact(hid_t fcpl, hid_t fapl)
{
- hid_t fid; /* HDF5 File ID */
- hid_t dset1, dset2, dset3; /* Dataset IDs */
- hid_t my_dataset; /* Current dataset ID */
- hid_t sid; /* Dataspace ID */
- hid_t attr; /* Attribute ID */
- hid_t dcpl; /* Dataset creation property list ID */
- unsigned max_compact; /* Maximum # of links to store in group compactly */
- unsigned min_dense; /* Minimum # of links to store in group "densely" */
- htri_t is_empty; /* Are there any attributes? */
- htri_t is_dense; /* Are attributes stored densely? */
- hsize_t nattrs; /* Number of attributes on object */
- char attrname[NAME_BUF_SIZE]; /* Name of attribute */
- unsigned curr_dset; /* Current dataset to work on */
- unsigned u; /* Local index variable */
- herr_t ret; /* Generic return value */
+ hid_t fid; /* HDF5 File ID */
+ hid_t dset1, dset2, dset3; /* Dataset IDs */
+ hid_t my_dataset; /* Current dataset ID */
+ hid_t sid; /* Dataspace ID */
+ hid_t attr; /* Attribute ID */
+ hid_t dcpl; /* Dataset creation property list ID */
+ unsigned max_compact; /* Maximum # of links to store in group compactly */
+ unsigned min_dense; /* Minimum # of links to store in group "densely" */
+ htri_t is_empty; /* Are there any attributes? */
+ htri_t is_dense; /* Are attributes stored densely? */
+ hsize_t nattrs; /* Number of attributes on object */
+ char attrname[NAME_BUF_SIZE]; /* Name of attribute */
+ unsigned curr_dset; /* Current dataset to work on */
+ unsigned u; /* Local index variable */
+ herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Compact Storage of Attributes with Creation Order Info\n"));
@@ -4410,8 +4520,14 @@ test_attr_corder_create_compact(hid_t fcpl, hid_t fapl)
CHECK(fid, FAIL, "H5Fcreate");
/* Create dataset creation property list */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ }
+ else {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
/* Set attribute creation order tracking & indexing for object */
ret = H5Pset_attr_creation_order(dcpl, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED));
@@ -4434,8 +4550,8 @@ test_attr_corder_create_compact(hid_t fcpl, hid_t fapl)
CHECK(dset3, FAIL, "H5Dcreate2");
/* Work on all the datasets */
- for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
- switch(curr_dset) {
+ for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
+ switch (curr_dset) {
case 0:
my_dataset = dset1;
break;
@@ -4453,15 +4569,15 @@ test_attr_corder_create_compact(hid_t fcpl, hid_t fapl)
} /* end switch */
/* Check on dataset's attribute storage status */
- is_empty = H5O_is_attr_empty_test(my_dataset);
- VERIFY(is_empty, TRUE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ is_empty = H5O__is_attr_empty_test(my_dataset);
+ VERIFY(is_empty, TRUE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
/* Create several attributes, but keep storage in compact form */
- for(u = 0; u < max_compact; u++) {
+ for (u = 0; u < max_compact; u++) {
/* Create attribute */
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -4474,15 +4590,15 @@ test_attr_corder_create_compact(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Aclose");
/* Verify state of object */
- ret = H5O_num_attrs_test(my_dataset, &nattrs);
- CHECK(ret, FAIL, "H5O_num_attrs_test");
- VERIFY(nattrs, (u + 1), "H5O_num_attrs_test");
- is_empty = H5O_is_attr_empty_test(my_dataset);
- VERIFY(is_empty, FALSE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ ret = H5O__num_attrs_test(my_dataset, &nattrs);
+ CHECK(ret, FAIL, "H5O__num_attrs_test");
+ VERIFY(nattrs, (u + 1), "H5O__num_attrs_test");
+ is_empty = H5O__is_attr_empty_test(my_dataset);
+ VERIFY(is_empty, FALSE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
} /* end for */
- } /* end for */
+ } /* end for */
/* Close Datasets */
ret = H5Dclose(dset1);
@@ -4504,7 +4620,6 @@ test_attr_corder_create_compact(hid_t fcpl, hid_t fapl)
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
-
/* Re-open file */
fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
CHECK(fid, FAIL, "H5Fopen");
@@ -4518,8 +4633,8 @@ test_attr_corder_create_compact(hid_t fcpl, hid_t fapl)
CHECK(dset3, FAIL, "H5Dopen2");
/* Work on all the datasets */
- for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
- switch(curr_dset) {
+ for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
+ switch (curr_dset) {
case 0:
my_dataset = dset1;
break;
@@ -4537,21 +4652,21 @@ test_attr_corder_create_compact(hid_t fcpl, hid_t fapl)
} /* end switch */
/* Check on dataset's attribute storage status */
- ret = H5O_num_attrs_test(my_dataset, &nattrs);
- CHECK(ret, FAIL, "H5O_num_attrs_test");
- VERIFY(nattrs, max_compact, "H5O_num_attrs_test");
- is_empty = H5O_is_attr_empty_test(my_dataset);
- VERIFY(is_empty, FALSE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ ret = H5O__num_attrs_test(my_dataset, &nattrs);
+ CHECK(ret, FAIL, "H5O__num_attrs_test");
+ VERIFY(nattrs, max_compact, "H5O__num_attrs_test");
+ is_empty = H5O__is_attr_empty_test(my_dataset);
+ VERIFY(is_empty, FALSE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
/* Loop through attributes, checking their creation order values */
/* (the name index is used, but the creation order value is in the same order) */
- for(u = 0; u < max_compact; u++) {
- H5A_info_t ainfo; /* Attribute information */
+ for (u = 0; u < max_compact; u++) {
+ H5A_info_t ainfo; /* Attribute information */
/* Retrieve information for attribute */
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
ret = H5Aget_info_by_name(my_dataset, ".", attrname, &ainfo, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Aget_info_by_name");
@@ -4559,7 +4674,7 @@ test_attr_corder_create_compact(hid_t fcpl, hid_t fapl)
VERIFY(ainfo.corder_valid, TRUE, "H5Aget_info_by_name");
VERIFY(ainfo.corder, u, "H5Aget_info_by_name");
} /* end for */
- } /* end for */
+ } /* end for */
/* Close Datasets */
ret = H5Dclose(dset1);
@@ -4572,9 +4687,8 @@ test_attr_corder_create_compact(hid_t fcpl, hid_t fapl)
/* Close file */
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
-} /* test_attr_corder_create_compact() */
+} /* test_attr_corder_create_compact() */
-
/****************************************************************
**
** test_attr_corder_create_dense(): Test basic H5A (attribute) code.
@@ -4584,23 +4698,23 @@ test_attr_corder_create_compact(hid_t fcpl, hid_t fapl)
static void
test_attr_corder_create_dense(hid_t fcpl, hid_t fapl)
{
- hid_t fid; /* HDF5 File ID */
- hid_t dset1, dset2, dset3; /* Dataset IDs */
- hid_t my_dataset; /* Current dataset ID */
- hid_t sid; /* Dataspace ID */
- hid_t attr; /* Attribute ID */
- hid_t dcpl; /* Dataset creation property list ID */
- unsigned max_compact; /* Maximum # of links to store in group compactly */
- unsigned min_dense; /* Minimum # of links to store in group "densely" */
- htri_t is_empty; /* Are there any attributes? */
- htri_t is_dense; /* Are attributes stored densely? */
- hsize_t nattrs; /* Number of attributes on object */
- hsize_t name_count; /* # of records in name index */
- hsize_t corder_count; /* # of records in creation order index */
- char attrname[NAME_BUF_SIZE]; /* Name of attribute */
- unsigned curr_dset; /* Current dataset to work on */
- unsigned u; /* Local index variable */
- herr_t ret; /* Generic return value */
+ hid_t fid; /* HDF5 File ID */
+ hid_t dset1, dset2, dset3; /* Dataset IDs */
+ hid_t my_dataset; /* Current dataset ID */
+ hid_t sid; /* Dataspace ID */
+ hid_t attr; /* Attribute ID */
+ hid_t dcpl; /* Dataset creation property list ID */
+ unsigned max_compact; /* Maximum # of links to store in group compactly */
+ unsigned min_dense; /* Minimum # of links to store in group "densely" */
+ htri_t is_empty; /* Are there any attributes? */
+ htri_t is_dense; /* Are attributes stored densely? */
+ hsize_t nattrs; /* Number of attributes on object */
+ hsize_t name_count; /* # of records in name index */
+ hsize_t corder_count; /* # of records in creation order index */
+ char attrname[NAME_BUF_SIZE]; /* Name of attribute */
+ unsigned curr_dset; /* Current dataset to work on */
+ unsigned u; /* Local index variable */
+ herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Dense Storage of Attributes with Creation Order Info\n"));
@@ -4610,8 +4724,14 @@ test_attr_corder_create_dense(hid_t fcpl, hid_t fapl)
CHECK(fid, FAIL, "H5Fcreate");
/* Create dataset creation property list */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ }
+ else {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
/* Set attribute creation order tracking & indexing for object */
ret = H5Pset_attr_creation_order(dcpl, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED));
@@ -4634,8 +4754,8 @@ test_attr_corder_create_dense(hid_t fcpl, hid_t fapl)
CHECK(dset3, FAIL, "H5Dcreate2");
/* Work on all the datasets */
- for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
- switch(curr_dset) {
+ for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
+ switch (curr_dset) {
case 0:
my_dataset = dset1;
break;
@@ -4653,15 +4773,15 @@ test_attr_corder_create_dense(hid_t fcpl, hid_t fapl)
} /* end switch */
/* Check on dataset's attribute storage status */
- is_empty = H5O_is_attr_empty_test(my_dataset);
- VERIFY(is_empty, TRUE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ is_empty = H5O__is_attr_empty_test(my_dataset);
+ VERIFY(is_empty, TRUE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
/* Create several attributes, but keep storage in compact form */
- for(u = 0; u < max_compact; u++) {
+ for (u = 0; u < max_compact; u++) {
/* Create attribute */
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -4674,17 +4794,17 @@ test_attr_corder_create_dense(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Aclose");
/* Verify state of object */
- ret = H5O_num_attrs_test(my_dataset, &nattrs);
- CHECK(ret, FAIL, "H5O_num_attrs_test");
- VERIFY(nattrs, (u + 1), "H5O_num_attrs_test");
- is_empty = H5O_is_attr_empty_test(my_dataset);
- VERIFY(is_empty, FALSE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ ret = H5O__num_attrs_test(my_dataset, &nattrs);
+ CHECK(ret, FAIL, "H5O__num_attrs_test");
+ VERIFY(nattrs, (u + 1), "H5O__num_attrs_test");
+ is_empty = H5O__is_attr_empty_test(my_dataset);
+ VERIFY(is_empty, FALSE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
} /* end for */
/* Create another attribute, to push into dense storage */
- sprintf(attrname, "attr %02u", max_compact);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", max_compact);
attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -4697,18 +4817,18 @@ test_attr_corder_create_dense(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Aclose");
/* Verify state of object */
- ret = H5O_num_attrs_test(my_dataset, &nattrs);
- CHECK(ret, FAIL, "H5O_num_attrs_test");
- VERIFY(nattrs, (max_compact + 1), "H5O_num_attrs_test");
- is_empty = H5O_is_attr_empty_test(my_dataset);
- VERIFY(is_empty, FALSE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
+ ret = H5O__num_attrs_test(my_dataset, &nattrs);
+ CHECK(ret, FAIL, "H5O__num_attrs_test");
+ VERIFY(nattrs, (max_compact + 1), "H5O__num_attrs_test");
+ is_empty = H5O__is_attr_empty_test(my_dataset);
+ VERIFY(is_empty, FALSE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test");
/* Retrieve & verify # of records in the name & creation order indices */
- ret = H5O_attr_dense_info_test(my_dataset, &name_count, &corder_count);
- CHECK(ret, FAIL, "H5O_attr_dense_info_test");
- VERIFY(name_count, corder_count, "H5O_attr_dense_info_test");
+ ret = H5O__attr_dense_info_test(my_dataset, &name_count, &corder_count);
+ CHECK(ret, FAIL, "H5O__attr_dense_info_test");
+ VERIFY(name_count, corder_count, "H5O__attr_dense_info_test");
} /* end for */
/* Close Datasets */
@@ -4731,7 +4851,6 @@ test_attr_corder_create_dense(hid_t fcpl, hid_t fapl)
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
-
/* Re-open file */
fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
CHECK(fid, FAIL, "H5Fopen");
@@ -4745,8 +4864,8 @@ test_attr_corder_create_dense(hid_t fcpl, hid_t fapl)
CHECK(dset3, FAIL, "H5Dopen2");
/* Work on all the datasets */
- for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
- switch(curr_dset) {
+ for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
+ switch (curr_dset) {
case 0:
my_dataset = dset1;
break;
@@ -4764,21 +4883,21 @@ test_attr_corder_create_dense(hid_t fcpl, hid_t fapl)
} /* end switch */
/* Check on dataset's attribute storage status */
- ret = H5O_num_attrs_test(my_dataset, &nattrs);
- CHECK(ret, FAIL, "H5O_num_attrs_test");
- VERIFY(nattrs, (max_compact + 1), "H5O_num_attrs_test");
- is_empty = H5O_is_attr_empty_test(my_dataset);
- VERIFY(is_empty, FALSE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
+ ret = H5O__num_attrs_test(my_dataset, &nattrs);
+ CHECK(ret, FAIL, "H5O__num_attrs_test");
+ VERIFY(nattrs, (max_compact + 1), "H5O__num_attrs_test");
+ is_empty = H5O__is_attr_empty_test(my_dataset);
+ VERIFY(is_empty, FALSE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test");
/* Loop through attributes, checking their creation order values */
/* (the name index is used, but the creation order value is in the same order) */
- for(u = 0; u < (max_compact + 1); u++) {
- H5A_info_t ainfo; /* Attribute information */
+ for (u = 0; u < (max_compact + 1); u++) {
+ H5A_info_t ainfo; /* Attribute information */
/* Retrieve information for attribute */
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
ret = H5Aget_info_by_name(my_dataset, ".", attrname, &ainfo, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Aget_info_by_name");
@@ -4786,7 +4905,7 @@ test_attr_corder_create_dense(hid_t fcpl, hid_t fapl)
VERIFY(ainfo.corder_valid, TRUE, "H5Aget_info_by_name");
VERIFY(ainfo.corder, u, "H5Aget_info_by_name");
} /* end for */
- } /* end for */
+ } /* end for */
/* Close Datasets */
ret = H5Dclose(dset1);
@@ -4799,9 +4918,8 @@ test_attr_corder_create_dense(hid_t fcpl, hid_t fapl)
/* Close file */
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
-} /* test_attr_corder_create_dense() */
+} /* test_attr_corder_create_dense() */
-
/****************************************************************
**
** test_attr_corder_create_reopen(): Test basic H5A (attribute) code.
@@ -4812,13 +4930,13 @@ test_attr_corder_create_dense(hid_t fcpl, hid_t fapl)
static void
test_attr_corder_create_reopen(hid_t fcpl, hid_t fapl)
{
- hid_t fid = -1; /* File ID */
- hid_t gcpl_id = -1; /* Group creation property list ID */
- hid_t gid = -1; /* Group ID */
- hid_t sid = -1; /* Dataspace ID */
- hid_t aid = -1; /* Attribute ID */
- int buf; /* Attribute data */
- herr_t ret; /* Generic return value */
+ hid_t fid = -1; /* File ID */
+ hid_t gcpl_id = -1; /* Group creation property list ID */
+ hid_t gid = -1; /* Group ID */
+ hid_t sid = -1; /* Dataspace ID */
+ hid_t aid = -1; /* Attribute ID */
+ int buf; /* Attribute data */
+ herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Creating Attributes w/New & Old Format\n"));
@@ -4866,7 +4984,6 @@ test_attr_corder_create_reopen(hid_t fcpl, hid_t fapl)
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
-
/* Re-open file, without "use the latest format" flag */
fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT);
CHECK(fid, FAIL, "H5Fopen");
@@ -4907,9 +5024,8 @@ test_attr_corder_create_reopen(hid_t fcpl, hid_t fapl)
/* Close attribute dataspace */
ret = H5Sclose(sid);
CHECK(ret, FAIL, "H5Sclose");
-} /* test_attr_corder_create_reopen() */
+} /* test_attr_corder_create_reopen() */
-
/****************************************************************
**
** test_attr_corder_transition(): Test basic H5A (attribute) code.
@@ -4919,23 +5035,23 @@ test_attr_corder_create_reopen(hid_t fcpl, hid_t fapl)
static void
test_attr_corder_transition(hid_t fcpl, hid_t fapl)
{
- hid_t fid; /* HDF5 File ID */
- hid_t dset1, dset2, dset3; /* Dataset IDs */
- hid_t my_dataset; /* Current dataset ID */
- hid_t sid; /* Dataspace ID */
- hid_t attr; /* Attribute ID */
- hid_t dcpl; /* Dataset creation property list ID */
- unsigned max_compact; /* Maximum # of links to store in group compactly */
- unsigned min_dense; /* Minimum # of links to store in group "densely" */
- htri_t is_empty; /* Are there any attributes? */
- htri_t is_dense; /* Are attributes stored densely? */
- hsize_t nattrs; /* Number of attributes on object */
- hsize_t name_count; /* # of records in name index */
- hsize_t corder_count; /* # of records in creation order index */
- char attrname[NAME_BUF_SIZE]; /* Name of attribute */
- unsigned curr_dset; /* Current dataset to work on */
- unsigned u; /* Local index variable */
- herr_t ret; /* Generic return value */
+ hid_t fid; /* HDF5 File ID */
+ hid_t dset1, dset2, dset3; /* Dataset IDs */
+ hid_t my_dataset; /* Current dataset ID */
+ hid_t sid; /* Dataspace ID */
+ hid_t attr; /* Attribute ID */
+ hid_t dcpl; /* Dataset creation property list ID */
+ unsigned max_compact; /* Maximum # of links to store in group compactly */
+ unsigned min_dense; /* Minimum # of links to store in group "densely" */
+ htri_t is_empty; /* Are there any attributes? */
+ htri_t is_dense; /* Are attributes stored densely? */
+ hsize_t nattrs; /* Number of attributes on object */
+ hsize_t name_count; /* # of records in name index */
+ hsize_t corder_count; /* # of records in creation order index */
+ char attrname[NAME_BUF_SIZE]; /* Name of attribute */
+ unsigned curr_dset; /* Current dataset to work on */
+ unsigned u; /* Local index variable */
+ herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Storage Transitions of Attributes with Creation Order Info\n"));
@@ -4945,8 +5061,14 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl)
CHECK(fid, FAIL, "H5Fcreate");
/* Create dataset creation property list */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ }
+ else {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
/* Set attribute creation order tracking & indexing for object */
ret = H5Pset_attr_creation_order(dcpl, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED));
@@ -4960,10 +5082,10 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl)
sid = H5Screate(H5S_SCALAR);
CHECK(sid, FAIL, "H5Screate");
-/* XXX: Try to find a way to resize dataset's object header so that the object
- * header can have one chunk, then retrieve "empty" file size and check
- * that size after everything is deleted -QAK
- */
+ /* XXX: Try to find a way to resize dataset's object header so that the object
+ * header can have one chunk, then retrieve "empty" file size and check
+ * that size after everything is deleted -QAK
+ */
/* Create datasets */
dset1 = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT);
CHECK(dset1, FAIL, "H5Dcreate2");
@@ -4973,8 +5095,8 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl)
CHECK(dset3, FAIL, "H5Dcreate2");
/* Work on all the datasets */
- for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
- switch(curr_dset) {
+ for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
+ switch (curr_dset) {
case 0:
my_dataset = dset1;
break;
@@ -4992,10 +5114,10 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl)
} /* end switch */
/* Check on dataset's attribute storage status */
- is_empty = H5O_is_attr_empty_test(my_dataset);
- VERIFY(is_empty, TRUE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ is_empty = H5O__is_attr_empty_test(my_dataset);
+ VERIFY(is_empty, TRUE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
} /* end for */
/* Close Datasets */
@@ -5014,7 +5136,6 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl)
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
-
/* Re-open file */
fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
CHECK(fid, FAIL, "H5Fopen");
@@ -5028,8 +5149,8 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl)
CHECK(dset3, FAIL, "H5Dopen2");
/* Work on all the datasets */
- for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
- switch(curr_dset) {
+ for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
+ switch (curr_dset) {
case 0:
my_dataset = dset1;
break;
@@ -5047,9 +5168,9 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl)
} /* end switch */
/* Create several attributes, but keep storage in compact form */
- for(u = 0; u < max_compact; u++) {
+ for (u = 0; u < max_compact; u++) {
/* Create attribute */
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -5062,17 +5183,17 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Aclose");
/* Verify state of object */
- ret = H5O_num_attrs_test(my_dataset, &nattrs);
- CHECK(ret, FAIL, "H5O_num_attrs_test");
- VERIFY(nattrs, (u + 1), "H5O_num_attrs_test");
- is_empty = H5O_is_attr_empty_test(my_dataset);
- VERIFY(is_empty, FALSE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ ret = H5O__num_attrs_test(my_dataset, &nattrs);
+ CHECK(ret, FAIL, "H5O__num_attrs_test");
+ VERIFY(nattrs, (u + 1), "H5O__num_attrs_test");
+ is_empty = H5O__is_attr_empty_test(my_dataset);
+ VERIFY(is_empty, FALSE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
} /* end for */
/* Create another attribute, to push into dense storage */
- sprintf(attrname, "attr %02u", max_compact);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", max_compact);
attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -5085,58 +5206,58 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Aclose");
/* Verify state of object */
- ret = H5O_num_attrs_test(my_dataset, &nattrs);
- CHECK(ret, FAIL, "H5O_num_attrs_test");
- VERIFY(nattrs, (max_compact + 1), "H5O_num_attrs_test");
- is_empty = H5O_is_attr_empty_test(my_dataset);
- VERIFY(is_empty, FALSE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
+ ret = H5O__num_attrs_test(my_dataset, &nattrs);
+ CHECK(ret, FAIL, "H5O__num_attrs_test");
+ VERIFY(nattrs, (max_compact + 1), "H5O__num_attrs_test");
+ is_empty = H5O__is_attr_empty_test(my_dataset);
+ VERIFY(is_empty, FALSE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test");
/* Retrieve & verify # of records in the name & creation order indices */
- ret = H5O_attr_dense_info_test(my_dataset, &name_count, &corder_count);
- CHECK(ret, FAIL, "H5O_attr_dense_info_test");
- VERIFY(name_count, corder_count, "H5O_attr_dense_info_test");
+ ret = H5O__attr_dense_info_test(my_dataset, &name_count, &corder_count);
+ CHECK(ret, FAIL, "H5O__attr_dense_info_test");
+ VERIFY(name_count, corder_count, "H5O__attr_dense_info_test");
/* Delete several attributes from object, until attribute storage resumes compact form */
- for(u = max_compact; u >= min_dense; u--) {
- sprintf(attrname, "attr %02u", u);
+ for (u = max_compact; u >= min_dense; u--) {
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
ret = H5Adelete(my_dataset, attrname);
CHECK(ret, FAIL, "H5Adelete");
/* Verify state of object */
- ret = H5O_num_attrs_test(my_dataset, &nattrs);
- CHECK(ret, FAIL, "H5O_num_attrs_test");
- VERIFY(nattrs, u, "H5O_num_attrs_test");
- is_empty = H5O_is_attr_empty_test(my_dataset);
- VERIFY(is_empty, FALSE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
+ ret = H5O__num_attrs_test(my_dataset, &nattrs);
+ CHECK(ret, FAIL, "H5O__num_attrs_test");
+ VERIFY(nattrs, u, "H5O__num_attrs_test");
+ is_empty = H5O__is_attr_empty_test(my_dataset);
+ VERIFY(is_empty, FALSE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test");
/* Retrieve & verify # of records in the name & creation order indices */
- ret = H5O_attr_dense_info_test(my_dataset, &name_count, &corder_count);
- CHECK(ret, FAIL, "H5O_attr_dense_info_test");
- VERIFY(name_count, corder_count, "H5O_attr_dense_info_test");
+ ret = H5O__attr_dense_info_test(my_dataset, &name_count, &corder_count);
+ CHECK(ret, FAIL, "H5O__attr_dense_info_test");
+ VERIFY(name_count, corder_count, "H5O__attr_dense_info_test");
} /* end for */
/* Delete another attribute, to push attribute storage into compact form */
- sprintf(attrname, "attr %02u", (min_dense - 1));
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", (min_dense - 1));
ret = H5Adelete(my_dataset, attrname);
CHECK(ret, FAIL, "H5Adelete");
/* Verify state of object */
- ret = H5O_num_attrs_test(my_dataset, &nattrs);
- CHECK(ret, FAIL, "H5O_num_attrs_test");
- VERIFY(nattrs, (min_dense - 1), "H5O_num_attrs_test");
- is_empty = H5O_is_attr_empty_test(my_dataset);
- VERIFY(is_empty, FALSE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ ret = H5O__num_attrs_test(my_dataset, &nattrs);
+ CHECK(ret, FAIL, "H5O__num_attrs_test");
+ VERIFY(nattrs, (min_dense - 1), "H5O__num_attrs_test");
+ is_empty = H5O__is_attr_empty_test(my_dataset);
+ VERIFY(is_empty, FALSE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
/* Re-add attributes to get back into dense form */
- for(u = (min_dense - 1); u < (max_compact + 1); u++) {
+ for (u = (min_dense - 1); u < (max_compact + 1); u++) {
/* Create attribute */
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -5150,18 +5271,18 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl)
} /* end for */
/* Verify state of object */
- ret = H5O_num_attrs_test(my_dataset, &nattrs);
- CHECK(ret, FAIL, "H5O_num_attrs_test");
- VERIFY(nattrs, (max_compact + 1), "H5O_num_attrs_test");
- is_empty = H5O_is_attr_empty_test(my_dataset);
- VERIFY(is_empty, FALSE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
+ ret = H5O__num_attrs_test(my_dataset, &nattrs);
+ CHECK(ret, FAIL, "H5O__num_attrs_test");
+ VERIFY(nattrs, (max_compact + 1), "H5O__num_attrs_test");
+ is_empty = H5O__is_attr_empty_test(my_dataset);
+ VERIFY(is_empty, FALSE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test");
/* Retrieve & verify # of records in the name & creation order indices */
- ret = H5O_attr_dense_info_test(my_dataset, &name_count, &corder_count);
- CHECK(ret, FAIL, "H5O_attr_dense_info_test");
- VERIFY(name_count, corder_count, "H5O_attr_dense_info_test");
+ ret = H5O__attr_dense_info_test(my_dataset, &name_count, &corder_count);
+ CHECK(ret, FAIL, "H5O__attr_dense_info_test");
+ VERIFY(name_count, corder_count, "H5O__attr_dense_info_test");
} /* end for */
/* Close Datasets */
@@ -5176,7 +5297,6 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl)
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
-
/* Re-open file */
fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
CHECK(fid, FAIL, "H5Fopen");
@@ -5190,8 +5310,8 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl)
CHECK(dset3, FAIL, "H5Dopen2");
/* Work on all the datasets */
- for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
- switch(curr_dset) {
+ for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
+ switch (curr_dset) {
case 0:
my_dataset = dset1;
break;
@@ -5209,58 +5329,58 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl)
} /* end switch */
/* Check on dataset's attribute storage status */
- ret = H5O_num_attrs_test(my_dataset, &nattrs);
- CHECK(ret, FAIL, "H5O_num_attrs_test");
- VERIFY(nattrs, (max_compact + 1), "H5O_num_attrs_test");
- is_empty = H5O_is_attr_empty_test(my_dataset);
- VERIFY(is_empty, FALSE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
+ ret = H5O__num_attrs_test(my_dataset, &nattrs);
+ CHECK(ret, FAIL, "H5O__num_attrs_test");
+ VERIFY(nattrs, (max_compact + 1), "H5O__num_attrs_test");
+ is_empty = H5O__is_attr_empty_test(my_dataset);
+ VERIFY(is_empty, FALSE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test");
/* Retrieve & verify # of records in the name & creation order indices */
- ret = H5O_attr_dense_info_test(my_dataset, &name_count, &corder_count);
- CHECK(ret, FAIL, "H5O_attr_dense_info_test");
- VERIFY(name_count, corder_count, "H5O_attr_dense_info_test");
+ ret = H5O__attr_dense_info_test(my_dataset, &name_count, &corder_count);
+ CHECK(ret, FAIL, "H5O__attr_dense_info_test");
+ VERIFY(name_count, corder_count, "H5O__attr_dense_info_test");
/* Delete several attributes from object, until attribute storage resumes compact form */
- for(u = max_compact; u >= min_dense; u--) {
- sprintf(attrname, "attr %02u", u);
+ for (u = max_compact; u >= min_dense; u--) {
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
ret = H5Adelete(my_dataset, attrname);
CHECK(ret, FAIL, "H5Adelete");
/* Verify state of object */
- ret = H5O_num_attrs_test(my_dataset, &nattrs);
- CHECK(ret, FAIL, "H5O_num_attrs_test");
- VERIFY(nattrs, u, "H5O_num_attrs_test");
- is_empty = H5O_is_attr_empty_test(my_dataset);
- VERIFY(is_empty, FALSE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
+ ret = H5O__num_attrs_test(my_dataset, &nattrs);
+ CHECK(ret, FAIL, "H5O__num_attrs_test");
+ VERIFY(nattrs, u, "H5O__num_attrs_test");
+ is_empty = H5O__is_attr_empty_test(my_dataset);
+ VERIFY(is_empty, FALSE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test");
/* Retrieve & verify # of records in the name & creation order indices */
- ret = H5O_attr_dense_info_test(my_dataset, &name_count, &corder_count);
- CHECK(ret, FAIL, "H5O_attr_dense_info_test");
- VERIFY(name_count, corder_count, "H5O_attr_dense_info_test");
+ ret = H5O__attr_dense_info_test(my_dataset, &name_count, &corder_count);
+ CHECK(ret, FAIL, "H5O__attr_dense_info_test");
+ VERIFY(name_count, corder_count, "H5O__attr_dense_info_test");
} /* end for */
/* Delete another attribute, to push attribute storage into compact form */
- sprintf(attrname, "attr %02u", (min_dense - 1));
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", (min_dense - 1));
ret = H5Adelete(my_dataset, attrname);
CHECK(ret, FAIL, "H5Adelete");
/* Verify state of object */
- ret = H5O_num_attrs_test(my_dataset, &nattrs);
- CHECK(ret, FAIL, "H5O_num_attrs_test");
- VERIFY(nattrs, (min_dense - 1), "H5O_num_attrs_test");
- is_empty = H5O_is_attr_empty_test(my_dataset);
- VERIFY(is_empty, FALSE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ ret = H5O__num_attrs_test(my_dataset, &nattrs);
+ CHECK(ret, FAIL, "H5O__num_attrs_test");
+ VERIFY(nattrs, (min_dense - 1), "H5O__num_attrs_test");
+ is_empty = H5O__is_attr_empty_test(my_dataset);
+ VERIFY(is_empty, FALSE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
/* Re-add attributes to get back into dense form */
- for(u = (min_dense - 1); u < (max_compact + 1); u++) {
+ for (u = (min_dense - 1); u < (max_compact + 1); u++) {
/* Create attribute */
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -5274,26 +5394,26 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl)
} /* end for */
/* Verify state of object */
- ret = H5O_num_attrs_test(my_dataset, &nattrs);
- CHECK(ret, FAIL, "H5O_num_attrs_test");
- VERIFY(nattrs, (max_compact + 1), "H5O_num_attrs_test");
- is_empty = H5O_is_attr_empty_test(my_dataset);
- VERIFY(is_empty, FALSE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
+ ret = H5O__num_attrs_test(my_dataset, &nattrs);
+ CHECK(ret, FAIL, "H5O__num_attrs_test");
+ VERIFY(nattrs, (max_compact + 1), "H5O__num_attrs_test");
+ is_empty = H5O__is_attr_empty_test(my_dataset);
+ VERIFY(is_empty, FALSE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test");
/* Retrieve & verify # of records in the name & creation order indices */
- ret = H5O_attr_dense_info_test(my_dataset, &name_count, &corder_count);
- CHECK(ret, FAIL, "H5O_attr_dense_info_test");
- VERIFY(name_count, corder_count, "H5O_attr_dense_info_test");
+ ret = H5O__attr_dense_info_test(my_dataset, &name_count, &corder_count);
+ CHECK(ret, FAIL, "H5O__attr_dense_info_test");
+ VERIFY(name_count, corder_count, "H5O__attr_dense_info_test");
/* Delete all attributes */
- for(u = max_compact; u > 0; u--) {
- sprintf(attrname, "attr %02u", u);
+ for (u = max_compact; u > 0; u--) {
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
ret = H5Adelete(my_dataset, attrname);
CHECK(ret, FAIL, "H5Adelete");
} /* end for */
- sprintf(attrname, "attr %02u", 0);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", 0);
ret = H5Adelete(my_dataset, attrname);
CHECK(ret, FAIL, "H5Adelete");
} /* end for */
@@ -5313,9 +5433,8 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl)
/* Close dataspace */
ret = H5Sclose(sid);
CHECK(ret, FAIL, "H5Sclose");
-} /* test_attr_corder_transition() */
+} /* test_attr_corder_transition() */
-
/****************************************************************
**
** test_attr_corder_delete(): Test basic H5A (attribute) code.
@@ -5325,28 +5444,28 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl)
static void
test_attr_corder_delete(hid_t fcpl, hid_t fapl)
{
- hid_t fid; /* HDF5 File ID */
- hid_t dset1, dset2, dset3; /* Dataset IDs */
- hid_t my_dataset; /* Current dataset ID */
- hid_t sid; /* Dataspace ID */
- hid_t attr; /* Attribute ID */
- hid_t dcpl; /* Dataset creation property list ID */
- unsigned max_compact; /* Maximum # of links to store in group compactly */
- unsigned min_dense; /* Minimum # of links to store in group "densely" */
- htri_t is_empty; /* Are there any attributes? */
- htri_t is_dense; /* Are attributes stored densely? */
- hsize_t nattrs; /* Number of attributes on object */
- hsize_t name_count; /* # of records in name index */
- hsize_t corder_count; /* # of records in creation order index */
- hbool_t reopen_file; /* Whether to re-open the file before deleting group */
- char attrname[NAME_BUF_SIZE]; /* Name of attribute */
+ hid_t fid; /* HDF5 File ID */
+ hid_t dset1, dset2, dset3; /* Dataset IDs */
+ hid_t my_dataset; /* Current dataset ID */
+ hid_t sid; /* Dataspace ID */
+ hid_t attr; /* Attribute ID */
+ hid_t dcpl; /* Dataset creation property list ID */
+ unsigned max_compact; /* Maximum # of links to store in group compactly */
+ unsigned min_dense; /* Minimum # of links to store in group "densely" */
+ htri_t is_empty; /* Are there any attributes? */
+ htri_t is_dense; /* Are attributes stored densely? */
+ hsize_t nattrs; /* Number of attributes on object */
+ hsize_t name_count; /* # of records in name index */
+ hsize_t corder_count; /* # of records in creation order index */
+ unsigned reopen_file; /* Whether to re-open the file before deleting group */
+ char attrname[NAME_BUF_SIZE]; /* Name of attribute */
#ifdef LATER
- h5_stat_size_t empty_size; /* Size of empty file */
- h5_stat_size_t file_size; /* Size of file after operating on it */
-#endif /* LATER */
- unsigned curr_dset; /* Current dataset to work on */
- unsigned u; /* Local index variable */
- herr_t ret; /* Generic return value */
+ h5_stat_size_t empty_size; /* Size of empty file */
+ h5_stat_size_t file_size; /* Size of file after operating on it */
+#endif /* LATER */
+ unsigned curr_dset; /* Current dataset to work on */
+ unsigned u; /* Local index variable */
+ herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Deleting Object w/Dense Attribute Storage and Creation Order Info\n"));
@@ -5356,8 +5475,14 @@ test_attr_corder_delete(hid_t fcpl, hid_t fapl)
CHECK(sid, FAIL, "H5Screate");
/* Create dataset creation property list */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ }
+ else {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
/* Set attribute creation order tracking & indexing for object */
ret = H5Pset_attr_creation_order(dcpl, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED));
@@ -5367,7 +5492,6 @@ test_attr_corder_delete(hid_t fcpl, hid_t fapl)
ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense);
CHECK(ret, FAIL, "H5Pget_attr_phase_change");
-
/* XXX: Try to find a way to resize dataset's object header so that the object
* header can have one chunk, then retrieve "empty" file size and check
* that size after everything is deleted -QAK
@@ -5386,10 +5510,9 @@ test_attr_corder_delete(hid_t fcpl, hid_t fapl)
CHECK(empty_size, FAIL, "h5_get_file_size");
#endif /* LATER */
-
/* Loop to leave file open when deleting dataset, or to close & re-open file
* before deleting dataset */
- for(reopen_file = FALSE; reopen_file <= TRUE; reopen_file++) {
+ for (reopen_file = FALSE; reopen_file <= TRUE; reopen_file++) {
/* Create test file */
fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl);
CHECK(fid, FAIL, "H5Fopen");
@@ -5403,8 +5526,8 @@ test_attr_corder_delete(hid_t fcpl, hid_t fapl)
CHECK(dset3, FAIL, "H5Dcreate2");
/* Work on all the datasets */
- for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
- switch(curr_dset) {
+ for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
+ switch (curr_dset) {
case 0:
my_dataset = dset1;
break;
@@ -5422,15 +5545,15 @@ test_attr_corder_delete(hid_t fcpl, hid_t fapl)
} /* end switch */
/* Check on dataset's attribute storage status */
- is_empty = H5O_is_attr_empty_test(my_dataset);
- VERIFY(is_empty, TRUE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ is_empty = H5O__is_attr_empty_test(my_dataset);
+ VERIFY(is_empty, TRUE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
/* Create attributes, until attribute storage is in dense form */
- for(u = 0; u < max_compact * 2; u++) {
+ for (u = 0; u < max_compact * 2; u++) {
/* Create attribute */
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -5444,18 +5567,18 @@ test_attr_corder_delete(hid_t fcpl, hid_t fapl)
} /* end for */
/* Verify state of object */
- ret = H5O_num_attrs_test(my_dataset, &nattrs);
- CHECK(ret, FAIL, "H5O_num_attrs_test");
- VERIFY(nattrs, (max_compact * 2), "H5O_num_attrs_test");
- is_empty = H5O_is_attr_empty_test(my_dataset);
- VERIFY(is_empty, FALSE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
+ ret = H5O__num_attrs_test(my_dataset, &nattrs);
+ CHECK(ret, FAIL, "H5O__num_attrs_test");
+ VERIFY(nattrs, (max_compact * 2), "H5O__num_attrs_test");
+ is_empty = H5O__is_attr_empty_test(my_dataset);
+ VERIFY(is_empty, FALSE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test");
/* Retrieve & verify # of records in the name & creation order indices */
- ret = H5O_attr_dense_info_test(my_dataset, &name_count, &corder_count);
- CHECK(ret, FAIL, "H5O_attr_dense_info_test");
- VERIFY(name_count, corder_count, "H5O_attr_dense_info_test");
+ ret = H5O__attr_dense_info_test(my_dataset, &name_count, &corder_count);
+ CHECK(ret, FAIL, "H5O__attr_dense_info_test");
+ VERIFY(name_count, corder_count, "H5O__attr_dense_info_test");
} /* end for */
/* Close Datasets */
@@ -5467,7 +5590,7 @@ test_attr_corder_delete(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Dclose");
/* Check for deleting datasets without re-opening file */
- if(!reopen_file) {
+ if (!reopen_file) {
ret = H5Ldelete(fid, DSET1_NAME, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Ldelete");
ret = H5Ldelete(fid, DSET2_NAME, H5P_DEFAULT);
@@ -5481,7 +5604,7 @@ test_attr_corder_delete(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Fclose");
/* Check for deleting dataset after re-opening file */
- if(reopen_file) {
+ if (reopen_file) {
/* Re-open file */
fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
CHECK(fid, FAIL, "H5Fopen");
@@ -5505,7 +5628,7 @@ test_attr_corder_delete(hid_t fcpl, hid_t fapl)
CHECK(file_size, FAIL, "h5_get_file_size");
VERIFY(file_size, empty_size, "h5_get_file_size");
#endif /* LATER */
- } /* end for */
+ } /* end for */
/* Close property list */
ret = H5Pclose(dcpl);
@@ -5514,16 +5637,15 @@ test_attr_corder_delete(hid_t fcpl, hid_t fapl)
/* Close dataspace */
ret = H5Sclose(sid);
CHECK(ret, FAIL, "H5Sclose");
-} /* test_attr_corder_delete() */
+} /* test_attr_corder_delete() */
-
/*-------------------------------------------------------------------------
* Function: attr_info_by_idx_check
*
* Purpose: Support routine for attr_info_by_idx, to verify the attribute
* info is correct for a attribute
*
- * Note: This routine assumes that the attributes have been added to the
+ * Note: This routine assumes that the attributes have been added to the
* object in alphabetical order.
*
* Return: Success: 0
@@ -5535,13 +5657,12 @@ test_attr_corder_delete(hid_t fcpl, hid_t fapl)
*-------------------------------------------------------------------------
*/
static int
-attr_info_by_idx_check(hid_t obj_id, const char *attrname, hsize_t n,
- hbool_t use_index)
+attr_info_by_idx_check(hid_t obj_id, const char *attrname, hsize_t n, hbool_t use_index)
{
- char tmpname[NAME_BUF_SIZE]; /* Temporary attribute name */
- H5A_info_t ainfo; /* Attribute info struct */
- int old_nerrs; /* Number of errors when entering this check */
- herr_t ret; /* Generic return value */
+ char tmpname[NAME_BUF_SIZE]; /* Temporary attribute name */
+ H5A_info_t ainfo; /* Attribute info struct */
+ int old_nerrs; /* Number of errors when entering this check */
+ herr_t ret; /* Generic return value */
/* Retrieve the current # of reported errors */
old_nerrs = GetTestNumErrs();
@@ -5560,20 +5681,21 @@ attr_info_by_idx_check(hid_t obj_id, const char *attrname, hsize_t n,
/* Verify the name for new link, in increasing creation order */
HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE);
- ret = H5Aget_name_by_idx(obj_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, n, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
+ ret = (herr_t)H5Aget_name_by_idx(obj_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, n, tmpname,
+ (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Aget_name_by_idx");
- if(HDstrcmp(attrname, tmpname))
+ if (HDstrcmp(attrname, tmpname) != 0)
TestErrPrintf("Line %d: attribute name size wrong!\n", __LINE__);
-
/* Don't test "native" order if there is no creation order index, since
* there's not a good way to easily predict the attribute's order in the name
* index.
*/
- if(use_index) {
+ if (use_index) {
/* Verify the information for first attribute, in native creation order */
HDmemset(&ainfo, 0, sizeof(ainfo));
- ret = H5Aget_info_by_idx(obj_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, (hsize_t)0, &ainfo, H5P_DEFAULT);
+ ret = H5Aget_info_by_idx(obj_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, (hsize_t)0, &ainfo,
+ H5P_DEFAULT);
CHECK(ret, FAIL, "H5Aget_info_by_idx");
VERIFY(ainfo.corder, 0, "H5Aget_info_by_idx");
@@ -5585,13 +5707,13 @@ attr_info_by_idx_check(hid_t obj_id, const char *attrname, hsize_t n,
/* Verify the name for new link, in increasing native order */
HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE);
- ret = H5Aget_name_by_idx(obj_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, n, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
+ ret = (herr_t)H5Aget_name_by_idx(obj_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, n, tmpname,
+ (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Aget_name_by_idx");
- if(HDstrcmp(attrname, tmpname))
+ if (HDstrcmp(attrname, tmpname) != 0)
TestErrPrintf("Line %d: attribute name size wrong!\n", __LINE__);
} /* end if */
-
/* Verify the information for first attribute, in decreasing creation order */
HDmemset(&ainfo, 0, sizeof(ainfo));
ret = H5Aget_info_by_idx(obj_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, n, &ainfo, H5P_DEFAULT);
@@ -5606,12 +5728,12 @@ attr_info_by_idx_check(hid_t obj_id, const char *attrname, hsize_t n,
/* Verify the name for new link, in increasing creation order */
HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE);
- ret = H5Aget_name_by_idx(obj_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
+ ret = (herr_t)H5Aget_name_by_idx(obj_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, (hsize_t)0, tmpname,
+ (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Aget_name_by_idx");
- if(HDstrcmp(attrname, tmpname))
+ if (HDstrcmp(attrname, tmpname) != 0)
TestErrPrintf("Line %d: attribute name size wrong!\n", __LINE__);
-
/* Verify the information for first attribute, in increasing name order */
HDmemset(&ainfo, 0, sizeof(ainfo));
ret = H5Aget_info_by_idx(obj_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)0, &ainfo, H5P_DEFAULT);
@@ -5626,17 +5748,16 @@ attr_info_by_idx_check(hid_t obj_id, const char *attrname, hsize_t n,
/* Verify the name for new link, in increasing name order */
HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE);
- ret = H5Aget_name_by_idx(obj_id, ".", H5_INDEX_NAME, H5_ITER_INC, n, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
+ ret = (herr_t)H5Aget_name_by_idx(obj_id, ".", H5_INDEX_NAME, H5_ITER_INC, n, tmpname,
+ (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Aget_name_by_idx");
- if(HDstrcmp(attrname, tmpname))
+ if (HDstrcmp(attrname, tmpname) != 0)
TestErrPrintf("Line %d: attribute name size wrong!\n", __LINE__);
-
/* Don't test "native" order queries on link name order, since there's not
* a good way to easily predict the order of the links in the name index.
*/
-
/* Verify the information for first attribute, in decreasing name order */
HDmemset(&ainfo, 0, sizeof(ainfo));
ret = H5Aget_info_by_idx(obj_id, ".", H5_INDEX_NAME, H5_ITER_DEC, n, &ainfo, H5P_DEFAULT);
@@ -5651,19 +5772,19 @@ attr_info_by_idx_check(hid_t obj_id, const char *attrname, hsize_t n,
/* Verify the name for new link, in increasing name order */
HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE);
- ret = H5Aget_name_by_idx(obj_id, ".", H5_INDEX_NAME, H5_ITER_DEC, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
+ ret = (herr_t)H5Aget_name_by_idx(obj_id, ".", H5_INDEX_NAME, H5_ITER_DEC, (hsize_t)0, tmpname,
+ (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Aget_name_by_idx");
- if(HDstrcmp(attrname, tmpname))
+ if (HDstrcmp(attrname, tmpname) != 0)
TestErrPrintf("Line %d: attribute name size wrong!\n", __LINE__);
/* Retrieve current # of errors */
- if(old_nerrs == GetTestNumErrs())
- return(0);
+ if (old_nerrs == GetTestNumErrs())
+ return (0);
else
- return(-1);
+ return (-1);
} /* end attr_info_by_idx_check() */
-
/****************************************************************
**
** test_attr_info_by_idx(): Test basic H5A (attribute) code.
@@ -5673,43 +5794,49 @@ attr_info_by_idx_check(hid_t obj_id, const char *attrname, hsize_t n,
static void
test_attr_info_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
{
- hid_t fid; /* HDF5 File ID */
- hid_t dset1, dset2, dset3; /* Dataset IDs */
- hid_t my_dataset; /* Current dataset ID */
- hid_t sid; /* Dataspace ID */
- hid_t attr; /* Attribute ID */
- hid_t dcpl; /* Dataset creation property list ID */
- H5A_info_t ainfo; /* Attribute information */
- unsigned max_compact; /* Maximum # of links to store in group compactly */
- unsigned min_dense; /* Minimum # of links to store in group "densely" */
- htri_t is_empty; /* Are there any attributes? */
- htri_t is_dense; /* Are attributes stored densely? */
- hsize_t nattrs; /* Number of attributes on object */
- hsize_t name_count; /* # of records in name index */
- hsize_t corder_count; /* # of records in creation order index */
- hbool_t use_index; /* Use index on creation order values */
- char attrname[NAME_BUF_SIZE]; /* Name of attribute */
- char tmpname[NAME_BUF_SIZE]; /* Temporary attribute name */
- unsigned curr_dset; /* Current dataset to work on */
- unsigned u; /* Local index variable */
- herr_t ret; /* Generic return value */
+ hid_t fid; /* HDF5 File ID */
+ hid_t dset1, dset2, dset3; /* Dataset IDs */
+ hid_t my_dataset; /* Current dataset ID */
+ hid_t sid; /* Dataspace ID */
+ hid_t attr; /* Attribute ID */
+ hid_t dcpl; /* Dataset creation property list ID */
+ H5A_info_t ainfo; /* Attribute information */
+ unsigned max_compact; /* Maximum # of links to store in group compactly */
+ unsigned min_dense; /* Minimum # of links to store in group "densely" */
+ htri_t is_empty; /* Are there any attributes? */
+ htri_t is_dense; /* Are attributes stored densely? */
+ hsize_t nattrs; /* Number of attributes on object */
+ hsize_t name_count; /* # of records in name index */
+ hsize_t corder_count; /* # of records in creation order index */
+ unsigned use_index; /* Use index on creation order values */
+ char attrname[NAME_BUF_SIZE]; /* Name of attribute */
+ char tmpname[NAME_BUF_SIZE]; /* Temporary attribute name */
+ unsigned curr_dset; /* Current dataset to work on */
+ unsigned u; /* Local index variable */
+ herr_t ret; /* Generic return value */
/* Create dataspace for dataset & attributes */
sid = H5Screate(H5S_SCALAR);
CHECK(sid, FAIL, "H5Screate");
/* Create dataset creation property list */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ }
+ else {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
/* Query the attribute creation properties */
ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense);
CHECK(ret, FAIL, "H5Pget_attr_phase_change");
/* Loop over using index for creation order value */
- for(use_index = FALSE; use_index <= TRUE; use_index++) {
+ for (use_index = FALSE; use_index <= TRUE; use_index++) {
/* Output message about test being performed */
- if(use_index)
+ if (use_index)
MESSAGE(5, ("Testing Querying Attribute Info By Index w/Creation Order Index\n"))
else
MESSAGE(5, ("Testing Querying Attribute Info By Index w/o Creation Order Index\n"))
@@ -5719,8 +5846,9 @@ test_attr_info_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
CHECK(fid, FAIL, "H5Fcreate");
/* Set attribute creation order tracking & indexing for object */
- if(new_format == TRUE) {
- ret = H5Pset_attr_creation_order(dcpl, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0)));
+ if (new_format == TRUE) {
+ ret = H5Pset_attr_creation_order(
+ dcpl, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0)));
CHECK(ret, FAIL, "H5Pset_attr_creation_order");
} /* end if */
@@ -5733,8 +5861,8 @@ test_attr_info_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
CHECK(dset3, FAIL, "H5Dcreate2");
/* Work on all the datasets */
- for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
- switch(curr_dset) {
+ for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
+ switch (curr_dset) {
case 0:
my_dataset = dset1;
break;
@@ -5752,21 +5880,23 @@ test_attr_info_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
} /* end switch */
/* Check on dataset's attribute storage status */
- is_empty = H5O_is_attr_empty_test(my_dataset);
- VERIFY(is_empty, TRUE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
-
- /* Check for query on non-existant attribute */
- ret = H5Aget_info_by_idx(my_dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, &ainfo, H5P_DEFAULT);
+ is_empty = H5O__is_attr_empty_test(my_dataset);
+ VERIFY(is_empty, TRUE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
+
+ /* Check for query on non-existent attribute */
+ ret = H5Aget_info_by_idx(my_dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, &ainfo,
+ H5P_DEFAULT);
VERIFY(ret, FAIL, "H5Aget_info_by_idx");
- ret = H5Aget_name_by_idx(my_dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
+ ret = (herr_t)H5Aget_name_by_idx(my_dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0,
+ tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
VERIFY(ret, FAIL, "H5Aget_name_by_idx");
/* Create attributes, up to limit of compact form */
- for(u = 0; u < max_compact; u++) {
+ for (u = 0; u < max_compact; u++) {
/* Create attribute */
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -5784,26 +5914,29 @@ test_attr_info_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
} /* end for */
/* Verify state of object */
- ret = H5O_num_attrs_test(my_dataset, &nattrs);
- CHECK(ret, FAIL, "H5O_num_attrs_test");
- VERIFY(nattrs, max_compact, "H5O_num_attrs_test");
- is_empty = H5O_is_attr_empty_test(my_dataset);
- VERIFY(is_empty, FALSE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ ret = H5O__num_attrs_test(my_dataset, &nattrs);
+ CHECK(ret, FAIL, "H5O__num_attrs_test");
+ VERIFY(nattrs, max_compact, "H5O__num_attrs_test");
+ is_empty = H5O__is_attr_empty_test(my_dataset);
+ VERIFY(is_empty, FALSE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
/* Check for out of bound offset queries */
- ret = H5Aget_info_by_idx(my_dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, &ainfo, H5P_DEFAULT);
+ ret = H5Aget_info_by_idx(my_dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, &ainfo,
+ H5P_DEFAULT);
VERIFY(ret, FAIL, "H5Aget_info_by_idx");
- ret = H5Aget_info_by_idx(my_dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, (hsize_t)u, &ainfo, H5P_DEFAULT);
+ ret = H5Aget_info_by_idx(my_dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, (hsize_t)u, &ainfo,
+ H5P_DEFAULT);
VERIFY(ret, FAIL, "H5Aget_info_by_idx");
- ret = H5Aget_name_by_idx(my_dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
+ ret = (herr_t)H5Aget_name_by_idx(my_dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u,
+ tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
VERIFY(ret, FAIL, "H5Aget_name_by_idx");
/* Create more attributes, to push into dense form */
- for(; u < (max_compact * 2); u++) {
+ for (; u < (max_compact * 2); u++) {
/* Create attribute */
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -5816,8 +5949,8 @@ test_attr_info_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Aclose");
/* Verify state of object */
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, (new_format ? TRUE : FALSE), "H5O_is_attr_dense_test");
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, (new_format ? TRUE : FALSE), "H5O__is_attr_dense_test");
/* Verify information for new attribute */
ret = attr_info_by_idx_check(my_dataset, attrname, (hsize_t)u, use_index);
@@ -5825,29 +5958,32 @@ test_attr_info_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
} /* end for */
/* Verify state of object */
- ret = H5O_num_attrs_test(my_dataset, &nattrs);
- CHECK(ret, FAIL, "H5O_num_attrs_test");
- VERIFY(nattrs, (max_compact * 2), "H5O_num_attrs_test");
- is_empty = H5O_is_attr_empty_test(my_dataset);
- VERIFY(is_empty, FALSE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, (new_format ? TRUE : FALSE), "H5O_is_attr_dense_test");
-
- if(new_format) {
+ ret = H5O__num_attrs_test(my_dataset, &nattrs);
+ CHECK(ret, FAIL, "H5O__num_attrs_test");
+ VERIFY(nattrs, (max_compact * 2), "H5O__num_attrs_test");
+ is_empty = H5O__is_attr_empty_test(my_dataset);
+ VERIFY(is_empty, FALSE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, (new_format ? TRUE : FALSE), "H5O__is_attr_dense_test");
+
+ if (new_format) {
/* Retrieve & verify # of records in the name & creation order indices */
- ret = H5O_attr_dense_info_test(my_dataset, &name_count, &corder_count);
- CHECK(ret, FAIL, "H5O_attr_dense_info_test");
- if(use_index)
- VERIFY(name_count, corder_count, "H5O_attr_dense_info_test");
- VERIFY(name_count, (max_compact * 2), "H5O_attr_dense_info_test");
+ ret = H5O__attr_dense_info_test(my_dataset, &name_count, &corder_count);
+ CHECK(ret, FAIL, "H5O__attr_dense_info_test");
+ if (use_index)
+ VERIFY(name_count, corder_count, "H5O__attr_dense_info_test");
+ VERIFY(name_count, (max_compact * 2), "H5O__attr_dense_info_test");
} /* end if */
/* Check for out of bound offset queries */
- ret = H5Aget_info_by_idx(my_dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, &ainfo, H5P_DEFAULT);
+ ret = H5Aget_info_by_idx(my_dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, &ainfo,
+ H5P_DEFAULT);
VERIFY(ret, FAIL, "H5Aget_info_by_idx");
- ret = H5Aget_info_by_idx(my_dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, (hsize_t)u, &ainfo, H5P_DEFAULT);
+ ret = H5Aget_info_by_idx(my_dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, (hsize_t)u, &ainfo,
+ H5P_DEFAULT);
VERIFY(ret, FAIL, "H5Aget_info_by_idx");
- ret = H5Aget_name_by_idx(my_dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
+ ret = (herr_t)H5Aget_name_by_idx(my_dataset, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u,
+ tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
VERIFY(ret, FAIL, "H5Aget_name_by_idx");
} /* end for */
@@ -5871,9 +6007,234 @@ test_attr_info_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
/* Close dataspace */
ret = H5Sclose(sid);
CHECK(ret, FAIL, "H5Sclose");
-} /* test_attr_info_by_idx() */
+} /* test_attr_info_by_idx() */
+
+/***************************************************************
+**
+** test_attr_info_null_info_pointer(): A test to ensure that
+** passing a NULL attribute info pointer to H5Aget_info
+** (_by_name/_by_idx) doesn't cause bad behavior.
+**
+****************************************************************/
+static void
+test_attr_info_null_info_pointer(hid_t fcpl, hid_t fapl)
+{
+ herr_t err_ret = -1;
+ hid_t fid;
+ hid_t attr;
+ hid_t sid;
+
+ /* Create dataspace for attribute */
+ sid = H5Screate(H5S_SCALAR);
+ CHECK(sid, FAIL, "H5Screate");
+
+ /* Create file */
+ fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl);
+ CHECK(fid, FAIL, "H5Fcreate");
+
+ /* Create attribute */
+ attr = H5Acreate2(fid, GET_INFO_NULL_POINTER_ATTR_NAME, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(attr, FAIL, "H5Acreate2");
+
+ H5E_BEGIN_TRY
+ {
+ err_ret = H5Aget_info(attr, NULL);
+ }
+ H5E_END_TRY;
+
+ CHECK(err_ret, SUCCEED, "H5Aget_info");
+
+ H5E_BEGIN_TRY
+ {
+ err_ret = H5Aget_info_by_name(fid, ".", GET_INFO_NULL_POINTER_ATTR_NAME, NULL, H5P_DEFAULT);
+ }
+ H5E_END_TRY;
+
+ CHECK(err_ret, SUCCEED, "H5Aget_info_by_name");
+
+ H5E_BEGIN_TRY
+ {
+ err_ret = H5Aget_info_by_idx(fid, ".", H5_INDEX_NAME, H5_ITER_INC, 0, NULL, H5P_DEFAULT);
+ }
+ H5E_END_TRY;
+
+ CHECK(err_ret, SUCCEED, "H5Aget_info_by_idx");
+
+ /* Close dataspace */
+ err_ret = H5Sclose(sid);
+ CHECK(err_ret, FAIL, "H5Sclose");
+
+ /* Close attribute */
+ err_ret = H5Aclose(attr);
+ CHECK(err_ret, FAIL, "H5Aclose");
+
+ /* Close file */
+ err_ret = H5Fclose(fid);
+ CHECK(err_ret, FAIL, "H5Fclose");
+}
+
+/***************************************************************
+**
+** test_attr_rename_invalid_name(): A test to ensure that
+** passing a NULL or empty attribute name to
+** H5Arename(_by_name) doesn't cause bad behavior.
+**
+****************************************************************/
+static void
+test_attr_rename_invalid_name(hid_t fcpl, hid_t fapl)
+{
+ herr_t err_ret = -1;
+ hid_t fid;
+ hid_t attr;
+ hid_t sid;
+
+ /* Create dataspace for attribute */
+ sid = H5Screate(H5S_SCALAR);
+ CHECK(sid, FAIL, "H5Screate");
+
+ /* Create file */
+ fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl);
+ CHECK(fid, FAIL, "H5Fcreate");
+
+ /* Create attribute */
+ attr = H5Acreate2(fid, INVALID_RENAME_TEST_ATTR_NAME, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(attr, FAIL, "H5Acreate2");
+
+ H5E_BEGIN_TRY
+ {
+ err_ret = H5Arename(fid, NULL, INVALID_RENAME_TEST_NEW_ATTR_NAME);
+ }
+ H5E_END_TRY;
+
+ CHECK(err_ret, SUCCEED, "H5Arename");
+
+ H5E_BEGIN_TRY
+ {
+ err_ret = H5Arename(fid, "", INVALID_RENAME_TEST_NEW_ATTR_NAME);
+ }
+ H5E_END_TRY;
+
+ CHECK(err_ret, SUCCEED, "H5Arename");
+
+ H5E_BEGIN_TRY
+ {
+ err_ret = H5Arename(fid, INVALID_RENAME_TEST_ATTR_NAME, NULL);
+ }
+ H5E_END_TRY;
+
+ CHECK(err_ret, SUCCEED, "H5Arename");
+
+ H5E_BEGIN_TRY
+ {
+ err_ret = H5Arename(fid, INVALID_RENAME_TEST_ATTR_NAME, "");
+ }
+ H5E_END_TRY;
+
+ CHECK(err_ret, SUCCEED, "H5Arename");
+
+ H5E_BEGIN_TRY
+ {
+ err_ret = H5Arename_by_name(fid, ".", NULL, INVALID_RENAME_TEST_NEW_ATTR_NAME, H5P_DEFAULT);
+ }
+ H5E_END_TRY;
+
+ CHECK(err_ret, SUCCEED, "H5Arename_by_name");
+
+ H5E_BEGIN_TRY
+ {
+ err_ret = H5Arename_by_name(fid, ".", "", INVALID_RENAME_TEST_NEW_ATTR_NAME, H5P_DEFAULT);
+ }
+ H5E_END_TRY;
+
+ CHECK(err_ret, SUCCEED, "H5Arename_by_name");
+
+ H5E_BEGIN_TRY
+ {
+ err_ret = H5Arename_by_name(fid, ".", INVALID_RENAME_TEST_ATTR_NAME, NULL, H5P_DEFAULT);
+ }
+ H5E_END_TRY;
+
+ CHECK(err_ret, SUCCEED, "H5Arename_by_name");
+
+ H5E_BEGIN_TRY
+ {
+ err_ret = H5Arename_by_name(fid, ".", INVALID_RENAME_TEST_ATTR_NAME, "", H5P_DEFAULT);
+ }
+ H5E_END_TRY;
+
+ CHECK(err_ret, SUCCEED, "H5Arename_by_name");
+
+ /* Close dataspace */
+ err_ret = H5Sclose(sid);
+ CHECK(err_ret, FAIL, "H5Sclose");
+
+ /* Close attribute */
+ err_ret = H5Aclose(attr);
+ CHECK(err_ret, FAIL, "H5Aclose");
+
+ /* Close file */
+ err_ret = H5Fclose(fid);
+ CHECK(err_ret, FAIL, "H5Fclose");
+}
+
+/***************************************************************
+**
+** test_attr_get_name_invalid_buf(): A test to ensure that
+** passing a NULL buffer to H5Aget_name(_by_idx) when
+** the 'size' parameter is non-zero doesn't cause bad
+** behavior.
+**
+****************************************************************/
+static void
+test_attr_get_name_invalid_buf(hid_t fcpl, hid_t fapl)
+{
+ ssize_t err_ret = -1;
+ hid_t fid;
+ hid_t attr;
+ hid_t sid;
+
+ /* Create dataspace for attribute */
+ sid = H5Screate(H5S_SCALAR);
+ CHECK(sid, FAIL, "H5Screate");
+
+ /* Create file */
+ fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl);
+ CHECK(fid, FAIL, "H5Fcreate");
+
+ /* Create attribute */
+ attr =
+ H5Acreate2(fid, GET_NAME_INVALID_BUF_TEST_ATTR_NAME, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(attr, FAIL, "H5Acreate2");
+
+ H5E_BEGIN_TRY
+ {
+ err_ret = H5Aget_name(attr, 1, NULL);
+ }
+ H5E_END_TRY;
+
+ VERIFY(err_ret, FAIL, "H5Aget_name");
+
+ H5E_BEGIN_TRY
+ {
+ err_ret = H5Aget_name_by_idx(fid, ".", H5_INDEX_NAME, H5_ITER_INC, 0, NULL, 1, H5P_DEFAULT);
+ }
+ H5E_END_TRY;
+
+ VERIFY(err_ret, FAIL, "H5Aget_name_by_idx");
+
+ /* Close dataspace */
+ err_ret = H5Sclose(sid);
+ CHECK(err_ret, FAIL, "H5Sclose");
+
+ /* Close attribute */
+ err_ret = H5Aclose(attr);
+ CHECK(err_ret, FAIL, "H5Aclose");
+
+ /* Close file */
+ err_ret = H5Fclose(fid);
+ CHECK(err_ret, FAIL, "H5Fclose");
+}
-
/****************************************************************
**
** test_attr_delete_by_idx(): Test basic H5A (attribute) code.
@@ -5883,84 +6244,99 @@ test_attr_info_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
static void
test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
{
- hid_t fid; /* HDF5 File ID */
- hid_t dset1, dset2, dset3; /* Dataset IDs */
- hid_t my_dataset; /* Current dataset ID */
- hid_t sid; /* Dataspace ID */
- hid_t attr; /* Attribute ID */
- hid_t dcpl; /* Dataset creation property list ID */
- H5A_info_t ainfo; /* Attribute information */
- unsigned max_compact; /* Maximum # of links to store in group compactly */
- unsigned min_dense; /* Minimum # of links to store in group "densely" */
- htri_t is_empty; /* Are there any attributes? */
- htri_t is_dense; /* Are attributes stored densely? */
- hsize_t nattrs; /* Number of attributes on object */
- hsize_t name_count; /* # of records in name index */
- hsize_t corder_count; /* # of records in creation order index */
- H5_index_t idx_type; /* Type of index to operate on */
- H5_iter_order_t order; /* Order within in the index */
- hbool_t use_index; /* Use index on creation order values */
- char attrname[NAME_BUF_SIZE]; /* Name of attribute */
- char tmpname[NAME_BUF_SIZE]; /* Temporary attribute name */
- unsigned curr_dset; /* Current dataset to work on */
- unsigned u; /* Local index variable */
- herr_t ret; /* Generic return value */
+ hid_t fid; /* HDF5 File ID */
+ hid_t dset1, dset2, dset3; /* Dataset IDs */
+ hid_t my_dataset; /* Current dataset ID */
+ hid_t sid; /* Dataspace ID */
+ hid_t attr; /* Attribute ID */
+ hid_t dcpl; /* Dataset creation property list ID */
+ H5A_info_t ainfo; /* Attribute information */
+ unsigned max_compact; /* Maximum # of links to store in group compactly */
+ unsigned min_dense; /* Minimum # of links to store in group "densely" */
+ htri_t is_empty; /* Are there any attributes? */
+ htri_t is_dense; /* Are attributes stored densely? */
+ hsize_t nattrs; /* Number of attributes on object */
+ hsize_t name_count; /* # of records in name index */
+ hsize_t corder_count; /* # of records in creation order index */
+ H5_index_t idx_type; /* Type of index to operate on */
+ H5_iter_order_t order; /* Order within in the index */
+ unsigned use_index; /* Use index on creation order values */
+ char attrname[NAME_BUF_SIZE]; /* Name of attribute */
+ char tmpname[NAME_BUF_SIZE]; /* Temporary attribute name */
+ unsigned curr_dset; /* Current dataset to work on */
+ unsigned u; /* Local index variable */
+ herr_t ret; /* Generic return value */
/* Create dataspace for dataset & attributes */
sid = H5Screate(H5S_SCALAR);
CHECK(sid, FAIL, "H5Screate");
/* Create dataset creation property list */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ }
+ else {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
/* Query the attribute creation properties */
ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense);
CHECK(ret, FAIL, "H5Pget_attr_phase_change");
/* Loop over operating on different indices on link fields */
- for(idx_type = H5_INDEX_NAME; idx_type <=H5_INDEX_CRT_ORDER; idx_type++) {
+ for (idx_type = H5_INDEX_NAME; idx_type <= H5_INDEX_CRT_ORDER; idx_type++) {
/* Loop over operating in different orders */
- for(order = H5_ITER_INC; order <=H5_ITER_DEC; order++) {
+ for (order = H5_ITER_INC; order <= H5_ITER_DEC; order++) {
/* Loop over using index for creation order value */
- for(use_index = FALSE; use_index <= TRUE; use_index++) {
+ for (use_index = FALSE; use_index <= TRUE; use_index++) {
/* Print appropriate test message */
- if(idx_type == H5_INDEX_CRT_ORDER) {
- if(order == H5_ITER_INC) {
- if(use_index)
- MESSAGE(5, ("Testing Deleting Attribute By Creation Order Index in Increasing Order w/Creation Order Index\n"))
+ if (idx_type == H5_INDEX_CRT_ORDER) {
+ if (order == H5_ITER_INC) {
+ if (use_index)
+ MESSAGE(5, ("Testing Deleting Attribute By Creation Order Index in Increasing "
+ "Order w/Creation Order Index\n"))
else
- MESSAGE(5, ("Testing Deleting Attribute By Creation Order Index in Increasing Order w/o Creation Order Index\n"))
+ MESSAGE(5, ("Testing Deleting Attribute By Creation Order Index in Increasing "
+ "Order w/o Creation Order Index\n"))
} /* end if */
else {
- if(use_index)
- MESSAGE(5, ("Testing Deleting Attribute By Creation Order Index in Decreasing Order w/Creation Order Index\n"))
+ if (use_index)
+ MESSAGE(5, ("Testing Deleting Attribute By Creation Order Index in Decreasing "
+ "Order w/Creation Order Index\n"))
else
- MESSAGE(5, ("Testing Deleting Attribute By Creation Order Index in Decreasing Order w/o Creation Order Index\n"))
+ MESSAGE(5, ("Testing Deleting Attribute By Creation Order Index in Decreasing "
+ "Order w/o Creation Order Index\n"))
} /* end else */
- } /* end if */
+ } /* end if */
else {
- if(order == H5_ITER_INC) {
- if(use_index)
- MESSAGE(5, ("Testing Deleting Attribute By Name Index in Increasing Order w/Creation Order Index\n"))
+ if (order == H5_ITER_INC) {
+ if (use_index)
+ MESSAGE(5, ("Testing Deleting Attribute By Name Index in Increasing Order "
+ "w/Creation Order Index\n"))
else
- MESSAGE(5, ("Testing Deleting Attribute By Name Index in Increasing Order w/o Creation Order Index\n"))
+ MESSAGE(5, ("Testing Deleting Attribute By Name Index in Increasing Order w/o "
+ "Creation Order Index\n"))
} /* end if */
else {
- if(use_index)
- MESSAGE(5, ("Testing Deleting Attribute By Name Index in Decreasing Order w/Creation Order Index\n"))
+ if (use_index)
+ MESSAGE(5, ("Testing Deleting Attribute By Name Index in Decreasing Order "
+ "w/Creation Order Index\n"))
else
- MESSAGE(5, ("Testing Deleting Attribute By Name Index in Decreasing Order w/o Creation Order Index\n"))
+ MESSAGE(5, ("Testing Deleting Attribute By Name Index in Decreasing Order w/o "
+ "Creation Order Index\n"))
} /* end else */
- } /* end else */
+ } /* end else */
/* Create file */
fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl);
CHECK(fid, FAIL, "H5Fcreate");
/* Set attribute creation order tracking & indexing for object */
- if(new_format == TRUE) {
- ret = H5Pset_attr_creation_order(dcpl, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0)));
+ if (new_format == TRUE) {
+ ret = H5Pset_attr_creation_order(
+ dcpl, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0)));
CHECK(ret, FAIL, "H5Pset_attr_creation_order");
} /* end if */
@@ -5973,8 +6349,8 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
CHECK(dset3, FAIL, "H5Dcreate2");
/* Work on all the datasets */
- for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
- switch(curr_dset) {
+ for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
+ switch (curr_dset) {
case 0:
my_dataset = dset1;
break;
@@ -5992,20 +6368,21 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
} /* end switch */
/* Check on dataset's attribute storage status */
- is_empty = H5O_is_attr_empty_test(my_dataset);
- VERIFY(is_empty, TRUE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ is_empty = H5O__is_attr_empty_test(my_dataset);
+ VERIFY(is_empty, TRUE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
- /* Check for deleting non-existant attribute */
+ /* Check for deleting non-existent attribute */
ret = H5Adelete_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT);
VERIFY(ret, FAIL, "H5Adelete_by_idx");
/* Create attributes, up to limit of compact form */
- for(u = 0; u < max_compact; u++) {
+ for (u = 0; u < max_compact; u++) {
/* Create attribute */
- sprintf(attrname, "attr %02u", u);
- attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
+ attr =
+ H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
/* Write data into the attribute */
@@ -6022,13 +6399,13 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
} /* end for */
/* Verify state of object */
- ret = H5O_num_attrs_test(my_dataset, &nattrs);
- CHECK(ret, FAIL, "H5O_num_attrs_test");
- VERIFY(nattrs, max_compact, "H5O_num_attrs_test");
- is_empty = H5O_is_attr_empty_test(my_dataset);
- VERIFY(is_empty, FALSE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ ret = H5O__num_attrs_test(my_dataset, &nattrs);
+ CHECK(ret, FAIL, "H5O__num_attrs_test");
+ VERIFY(nattrs, max_compact, "H5O__num_attrs_test");
+ is_empty = H5O__is_attr_empty_test(my_dataset);
+ VERIFY(is_empty, FALSE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
/* Check for out of bound deletions */
ret = H5Adelete_by_idx(my_dataset, ".", idx_type, order, (hsize_t)u, H5P_DEFAULT);
@@ -6036,8 +6413,8 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
} /* end for */
/* Work on all the datasets */
- for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
- switch(curr_dset) {
+ for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
+ switch (curr_dset) {
case 0:
my_dataset = dset1;
break;
@@ -6055,30 +6432,32 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
} /* end switch */
/* Delete attributes from compact storage */
- for(u = 0; u < (max_compact - 1); u++) {
+ for (u = 0; u < (max_compact - 1); u++) {
/* Delete first attribute in appropriate order */
ret = H5Adelete_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Adelete_by_idx");
/* Verify the attribute information for first attribute in appropriate order */
HDmemset(&ainfo, 0, sizeof(ainfo));
- ret = H5Aget_info_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0, &ainfo, H5P_DEFAULT);
- if(new_format) {
- if(order == H5_ITER_INC) {
+ ret = H5Aget_info_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0, &ainfo,
+ H5P_DEFAULT);
+ if (new_format) {
+ if (order == H5_ITER_INC) {
VERIFY(ainfo.corder, (u + 1), "H5Aget_info_by_idx");
} /* end if */
else {
VERIFY(ainfo.corder, (max_compact - (u + 2)), "H5Aget_info_by_idx");
} /* end else */
- } /* end if */
+ } /* end if */
/* Verify the name for first attribute in appropriate order */
HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE);
- ret = H5Aget_name_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
- if(order == H5_ITER_INC)
- sprintf(attrname, "attr %02u", (u + 1));
+ ret = (herr_t)H5Aget_name_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0,
+ tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
+ if (order == H5_ITER_INC)
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", (u + 1));
else
- sprintf(attrname, "attr %02u", (max_compact - (u + 2)));
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", (max_compact - (u + 2)));
ret = HDstrcmp(attrname, tmpname);
VERIFY(ret, 0, "H5Aget_name_by_idx");
} /* end for */
@@ -6088,13 +6467,13 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Adelete_by_idx");
/* Verify state of attribute storage (empty) */
- is_empty = H5O_is_attr_empty_test(my_dataset);
- VERIFY(is_empty, TRUE, "H5O_is_attr_empty_test");
+ is_empty = H5O__is_attr_empty_test(my_dataset);
+ VERIFY(is_empty, TRUE, "H5O__is_attr_empty_test");
} /* end for */
/* Work on all the datasets */
- for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
- switch(curr_dset) {
+ for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
+ switch (curr_dset) {
case 0:
my_dataset = dset1;
break;
@@ -6112,10 +6491,11 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
} /* end switch */
/* Create more attributes, to push into dense form */
- for(u = 0; u < (max_compact * 2); u++) {
+ for (u = 0; u < (max_compact * 2); u++) {
/* Create attribute */
- sprintf(attrname, "attr %02u", u);
- attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
+ attr =
+ H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
/* Write data into the attribute */
@@ -6127,9 +6507,9 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Aclose");
/* Verify state of object */
- if(u >= max_compact) {
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, (new_format ? TRUE : FALSE), "H5O_is_attr_dense_test");
+ if (u >= max_compact) {
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, (new_format ? TRUE : FALSE), "H5O__is_attr_dense_test");
} /* end if */
/* Verify information for new attribute */
@@ -6138,21 +6518,21 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
} /* end for */
/* Verify state of object */
- ret = H5O_num_attrs_test(my_dataset, &nattrs);
- CHECK(ret, FAIL, "H5O_num_attrs_test");
- VERIFY(nattrs, (max_compact * 2), "H5O_num_attrs_test");
- is_empty = H5O_is_attr_empty_test(my_dataset);
- VERIFY(is_empty, FALSE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, (new_format ? TRUE : FALSE), "H5O_is_attr_dense_test");
-
- if(new_format) {
+ ret = H5O__num_attrs_test(my_dataset, &nattrs);
+ CHECK(ret, FAIL, "H5O__num_attrs_test");
+ VERIFY(nattrs, (max_compact * 2), "H5O__num_attrs_test");
+ is_empty = H5O__is_attr_empty_test(my_dataset);
+ VERIFY(is_empty, FALSE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, (new_format ? TRUE : FALSE), "H5O__is_attr_dense_test");
+
+ if (new_format) {
/* Retrieve & verify # of records in the name & creation order indices */
- ret = H5O_attr_dense_info_test(my_dataset, &name_count, &corder_count);
- CHECK(ret, FAIL, "H5O_attr_dense_info_test");
- if(use_index)
- VERIFY(name_count, corder_count, "H5O_attr_dense_info_test");
- VERIFY(name_count, (max_compact * 2), "H5O_attr_dense_info_test");
+ ret = H5O__attr_dense_info_test(my_dataset, &name_count, &corder_count);
+ CHECK(ret, FAIL, "H5O__attr_dense_info_test");
+ if (use_index)
+ VERIFY(name_count, corder_count, "H5O__attr_dense_info_test");
+ VERIFY(name_count, (max_compact * 2), "H5O__attr_dense_info_test");
} /* end if */
/* Check for out of bound deletion */
@@ -6161,8 +6541,8 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
} /* end for */
/* Work on all the datasets */
- for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
- switch(curr_dset) {
+ for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
+ switch (curr_dset) {
case 0:
my_dataset = dset1;
break;
@@ -6180,30 +6560,33 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
} /* end switch */
/* Delete attributes from dense storage */
- for(u = 0; u < ((max_compact * 2) - 1); u++) {
+ for (u = 0; u < ((max_compact * 2) - 1); u++) {
/* Delete first attribute in appropriate order */
ret = H5Adelete_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Adelete_by_idx");
/* Verify the attribute information for first attribute in appropriate order */
HDmemset(&ainfo, 0, sizeof(ainfo));
- ret = H5Aget_info_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0, &ainfo, H5P_DEFAULT);
- if(new_format) {
- if(order == H5_ITER_INC) {
+ ret = H5Aget_info_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0, &ainfo,
+ H5P_DEFAULT);
+ if (new_format) {
+ if (order == H5_ITER_INC) {
VERIFY(ainfo.corder, (u + 1), "H5Aget_info_by_idx");
} /* end if */
else {
VERIFY(ainfo.corder, ((max_compact * 2) - (u + 2)), "H5Aget_info_by_idx");
} /* end else */
- } /* end if */
+ } /* end if */
/* Verify the name for first attribute in appropriate order */
HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE);
- ret = H5Aget_name_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
- if(order == H5_ITER_INC)
- sprintf(attrname, "attr %02u", (u + 1));
+ ret = (herr_t)H5Aget_name_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0,
+ tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
+ if (order == H5_ITER_INC)
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", (u + 1));
else
- sprintf(attrname, "attr %02u", ((max_compact * 2) - (u + 2)));
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u",
+ ((max_compact * 2) - (u + 2)));
ret = HDstrcmp(attrname, tmpname);
VERIFY(ret, 0, "H5Aget_name_by_idx");
} /* end for */
@@ -6213,21 +6596,19 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Adelete_by_idx");
/* Verify state of attribute storage (empty) */
- is_empty = H5O_is_attr_empty_test(my_dataset);
- VERIFY(is_empty, TRUE, "H5O_is_attr_empty_test");
+ is_empty = H5O__is_attr_empty_test(my_dataset);
+ VERIFY(is_empty, TRUE, "H5O__is_attr_empty_test");
/* Check for deletion on empty attribute storage again */
ret = H5Adelete_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT);
VERIFY(ret, FAIL, "H5Adelete_by_idx");
} /* end for */
-
- /* Delete attributes in middle */
-
+ /* Delete attributes in middle */
/* Work on all the datasets */
- for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
- switch(curr_dset) {
+ for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
+ switch (curr_dset) {
case 0:
my_dataset = dset1;
break;
@@ -6245,10 +6626,11 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
} /* end switch */
/* Create attributes, to push into dense form */
- for(u = 0; u < (max_compact * 2); u++) {
+ for (u = 0; u < (max_compact * 2); u++) {
/* Create attribute */
- sprintf(attrname, "attr %02u", u);
- attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
+ attr =
+ H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
/* Write data into the attribute */
@@ -6260,20 +6642,20 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Aclose");
/* Verify state of object */
- if(u >= max_compact) {
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, (new_format ? TRUE : FALSE), "H5O_is_attr_dense_test");
+ if (u >= max_compact) {
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, (new_format ? TRUE : FALSE), "H5O__is_attr_dense_test");
} /* end if */
/* Verify information for new attribute */
ret = attr_info_by_idx_check(my_dataset, attrname, (hsize_t)u, use_index);
CHECK(ret, FAIL, "attr_info_by_idx_check");
} /* end for */
- } /* end for */
+ } /* end for */
/* Work on all the datasets */
- for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
- switch(curr_dset) {
+ for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
+ switch (curr_dset) {
case 0:
my_dataset = dset1;
break;
@@ -6291,38 +6673,42 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
} /* end switch */
/* Delete every other attribute from dense storage, in appropriate order */
- for(u = 0; u < max_compact; u++) {
+ for (u = 0; u < max_compact; u++) {
/* Delete attribute */
ret = H5Adelete_by_idx(my_dataset, ".", idx_type, order, (hsize_t)u, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Adelete_by_idx");
/* Verify the attribute information for first attribute in appropriate order */
HDmemset(&ainfo, 0, sizeof(ainfo));
- ret = H5Aget_info_by_idx(my_dataset, ".", idx_type, order, (hsize_t)u, &ainfo, H5P_DEFAULT);
- if(new_format) {
- if(order == H5_ITER_INC) {
+ ret = H5Aget_info_by_idx(my_dataset, ".", idx_type, order, (hsize_t)u, &ainfo,
+ H5P_DEFAULT);
+ if (new_format) {
+ if (order == H5_ITER_INC) {
VERIFY(ainfo.corder, ((u * 2) + 1), "H5Aget_info_by_idx");
} /* end if */
else {
- VERIFY(ainfo.corder, ((max_compact * 2) - ((u * 2) + 2)), "H5Aget_info_by_idx");
+ VERIFY(ainfo.corder, ((max_compact * 2) - ((u * 2) + 2)),
+ "H5Aget_info_by_idx");
} /* end else */
- } /* end if */
+ } /* end if */
/* Verify the name for first attribute in appropriate order */
HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE);
- ret = H5Aget_name_by_idx(my_dataset, ".", idx_type, order, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
- if(order == H5_ITER_INC)
- sprintf(attrname, "attr %02u", ((u * 2) + 1));
+ ret = (herr_t)H5Aget_name_by_idx(my_dataset, ".", idx_type, order, (hsize_t)u,
+ tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
+ if (order == H5_ITER_INC)
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", ((u * 2) + 1));
else
- sprintf(attrname, "attr %02u", ((max_compact * 2) - ((u * 2) + 2)));
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u",
+ ((max_compact * 2) - ((u * 2) + 2)));
ret = HDstrcmp(attrname, tmpname);
VERIFY(ret, 0, "H5Aget_name_by_idx");
} /* end for */
- } /* end for */
+ } /* end for */
/* Work on all the datasets */
- for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
- switch(curr_dset) {
+ for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
+ switch (curr_dset) {
case 0:
my_dataset = dset1;
break;
@@ -6340,30 +6726,34 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
} /* end switch */
/* Delete remaining attributes from dense storage, in appropriate order */
- for(u = 0; u < (max_compact - 1); u++) {
+ for (u = 0; u < (max_compact - 1); u++) {
/* Delete attribute */
ret = H5Adelete_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Adelete_by_idx");
/* Verify the attribute information for first attribute in appropriate order */
HDmemset(&ainfo, 0, sizeof(ainfo));
- ret = H5Aget_info_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0, &ainfo, H5P_DEFAULT);
- if(new_format) {
- if(order == H5_ITER_INC) {
+ ret = H5Aget_info_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0, &ainfo,
+ H5P_DEFAULT);
+ if (new_format) {
+ if (order == H5_ITER_INC) {
VERIFY(ainfo.corder, ((u * 2) + 3), "H5Aget_info_by_idx");
} /* end if */
else {
- VERIFY(ainfo.corder, ((max_compact * 2) - ((u * 2) + 4)), "H5Aget_info_by_idx");
+ VERIFY(ainfo.corder, ((max_compact * 2) - ((u * 2) + 4)),
+ "H5Aget_info_by_idx");
} /* end else */
- } /* end if */
+ } /* end if */
/* Verify the name for first attribute in appropriate order */
HDmemset(tmpname, 0, (size_t)NAME_BUF_SIZE);
- ret = H5Aget_name_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
- if(order == H5_ITER_INC)
- sprintf(attrname, "attr %02u", ((u * 2) + 3));
+ ret = (herr_t)H5Aget_name_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0,
+ tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
+ if (order == H5_ITER_INC)
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", ((u * 2) + 3));
else
- sprintf(attrname, "attr %02u", ((max_compact * 2) - ((u * 2) + 4)));
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u",
+ ((max_compact * 2) - ((u * 2) + 4)));
ret = HDstrcmp(attrname, tmpname);
VERIFY(ret, 0, "H5Aget_name_by_idx");
} /* end for */
@@ -6373,8 +6763,8 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Adelete_by_idx");
/* Verify state of attribute storage (empty) */
- is_empty = H5O_is_attr_empty_test(my_dataset);
- VERIFY(is_empty, TRUE, "H5O_is_attr_empty_test");
+ is_empty = H5O__is_attr_empty_test(my_dataset);
+ VERIFY(is_empty, TRUE, "H5O__is_attr_empty_test");
/* Check for deletion on empty attribute storage again */
ret = H5Adelete_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT);
@@ -6393,8 +6783,8 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
} /* end for */
- } /* end for */
- } /* end for */
+ } /* end for */
+ } /* end for */
/* Close property list */
ret = H5Pclose(dcpl);
@@ -6403,83 +6793,74 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
/* Close dataspace */
ret = H5Sclose(sid);
CHECK(ret, FAIL, "H5Sclose");
-} /* test_attr_delete_by_idx() */
+} /* test_attr_delete_by_idx() */
-
/****************************************************************
**
** attr_iterate2_cb(): Revised attribute operator
**
****************************************************************/
static herr_t
-attr_iterate2_cb(hid_t loc_id, const char *attr_name, const H5A_info_t *info,
- void *_op_data)
+attr_iterate2_cb(hid_t loc_id, const char *attr_name, const H5A_info_t *info, void *_op_data)
{
- attr_iter_info_t *op_data = (attr_iter_info_t *)_op_data; /* User data */
- char attrname[NAME_BUF_SIZE]; /* Object name */
- H5A_info_t my_info; /* Local attribute info */
-
-#ifdef QAK
-HDfprintf(stderr, "attr_name = '%s'\n", attr_name);
-if(info)
- HDfprintf(stderr, "info->corder = %u\n", (unsigned)info->corder);
-HDfprintf(stderr, "op_data->curr = %Hd\n", op_data->curr);
-#endif /* QAK */
+ attr_iter_info_t *op_data = (attr_iter_info_t *)_op_data; /* User data */
+ char attrname[NAME_BUF_SIZE]; /* Object name */
+ H5A_info_t my_info; /* Local attribute info */
/* Increment # of times the callback was called */
op_data->ncalled++;
/* Get the attribute information directly to compare */
- if(H5Aget_info_by_name(loc_id, ".", attr_name, &my_info, H5P_DEFAULT) < 0)
- return(H5_ITER_ERROR);
+ if (H5Aget_info_by_name(loc_id, ".", attr_name, &my_info, H5P_DEFAULT) < 0)
+ return (H5_ITER_ERROR);
/* Check more things for revised attribute iteration (vs. older attribute iteration) */
- if(info) {
+ if (info) {
/* Check for correct order of iteration */
/* (if we are operating in increasing or decreasing order) */
- if(op_data->order != H5_ITER_NATIVE)
- if(info->corder != op_data->curr)
- return(H5_ITER_ERROR);
+ if (op_data->order != H5_ITER_NATIVE)
+ if (info->corder != op_data->curr)
+ return (H5_ITER_ERROR);
/* Compare attribute info structs */
- if(info->corder_valid != my_info.corder_valid)
- return(H5_ITER_ERROR);
- if(info->corder != my_info.corder)
- return(H5_ITER_ERROR);
- if(info->cset != my_info.cset)
- return(H5_ITER_ERROR);
- if(info->data_size != my_info.data_size)
- return(H5_ITER_ERROR);
+ if (info->corder_valid != my_info.corder_valid)
+ return (H5_ITER_ERROR);
+ if (info->corder != my_info.corder)
+ return (H5_ITER_ERROR);
+ if (info->cset != my_info.cset)
+ return (H5_ITER_ERROR);
+ if (info->data_size != my_info.data_size)
+ return (H5_ITER_ERROR);
} /* end if */
/* Verify name of link */
- sprintf(attrname, "attr %02u", (unsigned)my_info.corder);
- if(HDstrcmp(attr_name, attrname))
- return(H5_ITER_ERROR);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", (unsigned)my_info.corder);
+ if (HDstrcmp(attr_name, attrname) != 0)
+ return (H5_ITER_ERROR);
/* Check if we've visited this link before */
- if((size_t)op_data->curr >= op_data->max_visit)
- return(H5_ITER_ERROR);
- if(op_data->visited[op_data->curr])
- return(H5_ITER_ERROR);
+ if ((size_t)op_data->curr >= op_data->max_visit)
+ return (H5_ITER_ERROR);
+ if (op_data->visited[op_data->curr])
+ return (H5_ITER_ERROR);
op_data->visited[op_data->curr] = TRUE;
/* Advance to next value, in correct direction */
- if(op_data->order != H5_ITER_DEC)
+ if (op_data->order != H5_ITER_DEC)
op_data->curr++;
else
op_data->curr--;
/* Check for stopping in the middle of iterating */
- if(op_data->stop > 0)
- if(--op_data->stop == 0)
- return(CORDER_ITER_STOP);
+ if (op_data->stop > 0)
+ if (--op_data->stop == 0)
+ return (CORDER_ITER_STOP);
- return(H5_ITER_CONT);
+ return (H5_ITER_CONT);
} /* end attr_iterate2_cb() */
#ifndef H5_NO_DEPRECATED_SYMBOLS
-
+
/****************************************************************
**
** attr_iterate1_cb(): Attribute operator
@@ -6488,11 +6869,10 @@ HDfprintf(stderr, "op_data->curr = %Hd\n", op_data->curr);
static herr_t
attr_iterate1_cb(hid_t loc_id, const char *attr_name, void *_op_data)
{
- return(attr_iterate2_cb(loc_id, attr_name, NULL, _op_data));
+ return (attr_iterate2_cb(loc_id, attr_name, NULL, _op_data));
} /* end attr_iterate1_cb() */
#endif /* H5_NO_DEPRECATED_SYMBOLS */
-
/*-------------------------------------------------------------------------
* Function: attr_iterate2_fail_cb
*
@@ -6508,13 +6888,12 @@ attr_iterate1_cb(hid_t loc_id, const char *attr_name, void *_op_data)
*-------------------------------------------------------------------------
*/
static int
-attr_iterate2_fail_cb(hid_t UNUSED group_id, const char UNUSED *attr_name,
- const H5A_info_t UNUSED *info, void UNUSED *_op_data)
+attr_iterate2_fail_cb(hid_t H5_ATTR_UNUSED group_id, const char H5_ATTR_UNUSED *attr_name,
+ const H5A_info_t H5_ATTR_UNUSED *info, void H5_ATTR_UNUSED *_op_data)
{
- return(H5_ITER_ERROR);
+ return (H5_ITER_ERROR);
} /* end attr_iterate2_fail_cb() */
-
/*-------------------------------------------------------------------------
* Function: attr_iterate_check
*
@@ -6529,263 +6908,251 @@ attr_iterate2_fail_cb(hid_t UNUSED group_id, const char UNUSED *attr_name,
*-------------------------------------------------------------------------
*/
static int
-attr_iterate_check(hid_t fid, const char *dsetname, hid_t obj_id,
- H5_index_t idx_type, H5_iter_order_t order, unsigned max_attrs,
- attr_iter_info_t *iter_info)
+attr_iterate_check(hid_t fid, const char *dsetname, hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order,
+ unsigned max_attrs, attr_iter_info_t *iter_info)
{
- unsigned v; /* Local index variable */
- hsize_t skip; /* # of attributes to skip on object */
+ unsigned v; /* Local index variable */
+ hsize_t skip; /* # of attributes to skip on object */
#ifndef H5_NO_DEPRECATED_SYMBOLS
- unsigned oskip; /* # of attributes to skip on object, with H5Aiterate1 */
-#endif /* H5_NO_DEPRECATED_SYMBOLS */
- int old_nerrs; /* Number of errors when entering this check */
- herr_t ret; /* Generic return value */
+ unsigned oskip; /* # of attributes to skip on object, with H5Aiterate1 */
+#endif /* H5_NO_DEPRECATED_SYMBOLS */
+ int old_nerrs; /* Number of errors when entering this check */
+ herr_t ret; /* Generic return value */
/* Retrieve the current # of reported errors */
old_nerrs = GetTestNumErrs();
/* Iterate over attributes on object */
iter_info->nskipped = (unsigned)(skip = 0);
- iter_info->order = order;
- iter_info->stop = -1;
- iter_info->ncalled = 0;
- iter_info->curr = order != H5_ITER_DEC ? 0 : (max_attrs - 1);
+ iter_info->order = order;
+ iter_info->stop = -1;
+ iter_info->ncalled = 0;
+ iter_info->curr = order != H5_ITER_DEC ? 0 : (max_attrs - 1);
HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit);
ret = H5Aiterate2(obj_id, idx_type, order, &skip, attr_iterate2_cb, iter_info);
CHECK(ret, FAIL, "H5Aiterate2");
/* Verify that we visited all the attributes */
VERIFY(skip, max_attrs, "H5Aiterate2");
- for(v = 0; v < max_attrs; v++)
+ for (v = 0; v < max_attrs; v++)
VERIFY(iter_info->visited[v], TRUE, "H5Aiterate2");
-
/* Iterate over attributes on object */
iter_info->nskipped = (unsigned)(skip = 0);
- iter_info->order = order;
- iter_info->stop = -1;
- iter_info->ncalled = 0;
- iter_info->curr = order != H5_ITER_DEC ? 0 : (max_attrs - 1);
+ iter_info->order = order;
+ iter_info->stop = -1;
+ iter_info->ncalled = 0;
+ iter_info->curr = order != H5_ITER_DEC ? 0 : (max_attrs - 1);
HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit);
ret = H5Aiterate_by_name(fid, dsetname, idx_type, order, &skip, attr_iterate2_cb, iter_info, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Aiterate_by_name");
/* Verify that we visited all the attributes */
VERIFY(skip, max_attrs, "H5Aiterate_by_name");
- for(v = 0; v < max_attrs; v++)
+ for (v = 0; v < max_attrs; v++)
VERIFY(iter_info->visited[v], TRUE, "H5Aiterate_by_name");
-
/* Iterate over attributes on object */
iter_info->nskipped = (unsigned)(skip = 0);
- iter_info->order = order;
- iter_info->stop = -1;
- iter_info->ncalled = 0;
- iter_info->curr = order != H5_ITER_DEC ? 0 : (max_attrs - 1);
+ iter_info->order = order;
+ iter_info->stop = -1;
+ iter_info->ncalled = 0;
+ iter_info->curr = order != H5_ITER_DEC ? 0 : (max_attrs - 1);
HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit);
ret = H5Aiterate_by_name(obj_id, ".", idx_type, order, &skip, attr_iterate2_cb, iter_info, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Aiterate_by_name");
/* Verify that we visited all the attributes */
VERIFY(skip, max_attrs, "H5Aiterate_by_name");
- for(v = 0; v < max_attrs; v++)
+ for (v = 0; v < max_attrs; v++)
VERIFY(iter_info->visited[v], TRUE, "H5Aiterate_by_name");
-
#ifndef H5_NO_DEPRECATED_SYMBOLS
/* Iterate over attributes on object, with H5Aiterate1 */
iter_info->nskipped = oskip = 0;
- iter_info->order = order;
- iter_info->stop = -1;
- iter_info->ncalled = 0;
- iter_info->curr = order != H5_ITER_DEC ? 0 : (max_attrs - 1);
+ iter_info->order = order;
+ iter_info->stop = -1;
+ iter_info->ncalled = 0;
+ iter_info->curr = order != H5_ITER_DEC ? 0 : (max_attrs - 1);
HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit);
ret = H5Aiterate1(obj_id, &oskip, attr_iterate1_cb, iter_info);
CHECK(ret, FAIL, "H5Aiterate1");
/* Verify that we visited all the attributes */
VERIFY(skip, max_attrs, "H5Aiterate1");
- for(v = 0; v < max_attrs; v++)
+ for (v = 0; v < max_attrs; v++)
VERIFY(iter_info->visited[v], TRUE, "H5Aiterate1");
#endif /* H5_NO_DEPRECATED_SYMBOLS */
-
/* Skip over some attributes on object */
iter_info->nskipped = (unsigned)(skip = max_attrs / 2);
- iter_info->order = order;
- iter_info->stop = -1;
- iter_info->ncalled = 0;
- iter_info->curr = order != H5_ITER_DEC ? skip : ((max_attrs - 1) - skip);
+ iter_info->order = order;
+ iter_info->stop = -1;
+ iter_info->ncalled = 0;
+ iter_info->curr = order != H5_ITER_DEC ? skip : ((max_attrs - 1) - skip);
HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit);
ret = H5Aiterate2(obj_id, idx_type, order, &skip, attr_iterate2_cb, iter_info);
CHECK(ret, FAIL, "H5Aiterate2");
/* Verify that we visited all the attributes */
VERIFY(skip, max_attrs, "H5Aiterate2");
- if(order == H5_ITER_INC) {
- for(v = 0; v < (max_attrs / 2); v++)
+ if (order == H5_ITER_INC) {
+ for (v = 0; v < (max_attrs / 2); v++)
VERIFY(iter_info->visited[v + (max_attrs / 2)], TRUE, "H5Aiterate2");
} /* end if */
- else if(order == H5_ITER_DEC) {
- for(v = 0; v < (max_attrs / 2); v++)
+ else if (order == H5_ITER_DEC) {
+ for (v = 0; v < (max_attrs / 2); v++)
VERIFY(iter_info->visited[v], TRUE, "H5Aiterate2");
} /* end if */
else {
- unsigned nvisit = 0; /* # of links visited */
+ unsigned nvisit = 0; /* # of links visited */
HDassert(order == H5_ITER_NATIVE);
- for(v = 0; v < max_attrs; v++)
- if(iter_info->visited[v] == TRUE)
+ for (v = 0; v < max_attrs; v++)
+ if (iter_info->visited[v] == TRUE)
nvisit++;
VERIFY(skip, (max_attrs / 2), "H5Aiterate2");
} /* end else */
-
/* Skip over some attributes on object */
iter_info->nskipped = (unsigned)(skip = max_attrs / 2);
- iter_info->order = order;
- iter_info->stop = -1;
- iter_info->ncalled = 0;
- iter_info->curr = order != H5_ITER_DEC ? skip : ((max_attrs - 1) - skip);
+ iter_info->order = order;
+ iter_info->stop = -1;
+ iter_info->ncalled = 0;
+ iter_info->curr = order != H5_ITER_DEC ? skip : ((max_attrs - 1) - skip);
HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit);
ret = H5Aiterate_by_name(fid, dsetname, idx_type, order, &skip, attr_iterate2_cb, iter_info, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Aiterate_by_name");
/* Verify that we visited all the attributes */
VERIFY(skip, max_attrs, "H5Aiterate_by_name");
- if(order == H5_ITER_INC) {
- for(v = 0; v < (max_attrs / 2); v++)
+ if (order == H5_ITER_INC) {
+ for (v = 0; v < (max_attrs / 2); v++)
VERIFY(iter_info->visited[v + (max_attrs / 2)], TRUE, "H5Aiterate_by_name");
} /* end if */
- else if(order == H5_ITER_DEC) {
- for(v = 0; v < (max_attrs / 2); v++)
+ else if (order == H5_ITER_DEC) {
+ for (v = 0; v < (max_attrs / 2); v++)
VERIFY(iter_info->visited[v], TRUE, "H5Aiterate_by_name");
} /* end if */
else {
- unsigned nvisit = 0; /* # of links visited */
+ unsigned nvisit = 0; /* # of links visited */
HDassert(order == H5_ITER_NATIVE);
- for(v = 0; v < max_attrs; v++)
- if(iter_info->visited[v] == TRUE)
+ for (v = 0; v < max_attrs; v++)
+ if (iter_info->visited[v] == TRUE)
nvisit++;
VERIFY(skip, (max_attrs / 2), "H5Aiterate_by_name");
} /* end else */
-
/* Skip over some attributes on object */
iter_info->nskipped = (unsigned)(skip = max_attrs / 2);
- iter_info->order = order;
- iter_info->stop = -1;
- iter_info->ncalled = 0;
- iter_info->curr = order != H5_ITER_DEC ? skip : ((max_attrs - 1) - skip);
+ iter_info->order = order;
+ iter_info->stop = -1;
+ iter_info->ncalled = 0;
+ iter_info->curr = order != H5_ITER_DEC ? skip : ((max_attrs - 1) - skip);
HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit);
ret = H5Aiterate_by_name(obj_id, ".", idx_type, order, &skip, attr_iterate2_cb, iter_info, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Aiterate_by_name");
/* Verify that we visited all the attributes */
VERIFY(skip, max_attrs, "H5Aiterate_by_name");
- if(order == H5_ITER_INC) {
- for(v = 0; v < (max_attrs / 2); v++)
+ if (order == H5_ITER_INC) {
+ for (v = 0; v < (max_attrs / 2); v++)
VERIFY(iter_info->visited[v + (max_attrs / 2)], TRUE, "H5Aiterate_by_name");
} /* end if */
- else if(order == H5_ITER_DEC) {
- for(v = 0; v < (max_attrs / 2); v++)
+ else if (order == H5_ITER_DEC) {
+ for (v = 0; v < (max_attrs / 2); v++)
VERIFY(iter_info->visited[v], TRUE, "H5Aiterate_by_name");
} /* end if */
else {
- unsigned nvisit = 0; /* # of links visited */
+ unsigned nvisit = 0; /* # of links visited */
HDassert(order == H5_ITER_NATIVE);
- for(v = 0; v < max_attrs; v++)
- if(iter_info->visited[v] == TRUE)
+ for (v = 0; v < max_attrs; v++)
+ if (iter_info->visited[v] == TRUE)
nvisit++;
VERIFY(skip, (max_attrs / 2), "H5Aiterate_by_name");
} /* end else */
-
#ifndef H5_NO_DEPRECATED_SYMBOLS
/* Skip over some attributes on object, with H5Aiterate1 */
iter_info->nskipped = oskip = max_attrs / 2;
- iter_info->order = order;
- iter_info->stop = -1;
- iter_info->ncalled = 0;
- iter_info->curr = order != H5_ITER_DEC ? (unsigned)oskip : ((max_attrs - 1) - oskip);
+ iter_info->order = order;
+ iter_info->stop = -1;
+ iter_info->ncalled = 0;
+ iter_info->curr = order != H5_ITER_DEC ? (unsigned)oskip : ((max_attrs - 1) - oskip);
HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit);
ret = H5Aiterate1(obj_id, &oskip, attr_iterate1_cb, iter_info);
CHECK(ret, FAIL, "H5Aiterate1");
/* Verify that we visited all the links */
VERIFY(oskip, max_attrs, "H5Aiterate1");
- if(order == H5_ITER_INC) {
- for(v = 0; v < (max_attrs / 2); v++)
+ if (order == H5_ITER_INC) {
+ for (v = 0; v < (max_attrs / 2); v++)
VERIFY(iter_info->visited[v + (max_attrs / 2)], TRUE, "H5Aiterate1");
} /* end if */
- else if(order == H5_ITER_DEC) {
- for(v = 0; v < (max_attrs / 2); v++)
+ else if (order == H5_ITER_DEC) {
+ for (v = 0; v < (max_attrs / 2); v++)
VERIFY(iter_info->visited[v], TRUE, "H5Aiterate1");
} /* end if */
else {
- unsigned nvisit = 0; /* # of links visited */
+ unsigned nvisit = 0; /* # of links visited */
HDassert(order == H5_ITER_NATIVE);
- for(v = 0; v < max_attrs; v++)
- if(iter_info->visited[v] == TRUE)
+ for (v = 0; v < max_attrs; v++)
+ if (iter_info->visited[v] == TRUE)
nvisit++;
VERIFY(skip, (max_attrs / 2), "H5Aiterate1");
- } /* end else */
+ } /* end else */
#endif /* H5_NO_DEPRECATED_SYMBOLS */
-
/* Iterate over attributes on object, stopping in the middle */
iter_info->nskipped = (unsigned)(skip = 0);
- iter_info->order = order;
- iter_info->stop = 3;
- iter_info->ncalled = 0;
- iter_info->curr = order != H5_ITER_DEC ? 0 : (max_attrs - 1);
+ iter_info->order = order;
+ iter_info->stop = 3;
+ iter_info->ncalled = 0;
+ iter_info->curr = order != H5_ITER_DEC ? 0 : (max_attrs - 1);
HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit);
ret = H5Aiterate2(obj_id, idx_type, order, &skip, attr_iterate2_cb, iter_info);
CHECK(ret, FAIL, "H5Aiterate2");
VERIFY(ret, CORDER_ITER_STOP, "H5Aiterate2");
VERIFY(iter_info->ncalled, 3, "H5Aiterate2");
-
/* Iterate over attributes on object, stopping in the middle */
iter_info->nskipped = (unsigned)(skip = 0);
- iter_info->order = order;
- iter_info->stop = 3;
- iter_info->ncalled = 0;
- iter_info->curr = order != H5_ITER_DEC ? 0 : (max_attrs - 1);
+ iter_info->order = order;
+ iter_info->stop = 3;
+ iter_info->ncalled = 0;
+ iter_info->curr = order != H5_ITER_DEC ? 0 : (max_attrs - 1);
HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit);
ret = H5Aiterate_by_name(fid, dsetname, idx_type, order, &skip, attr_iterate2_cb, iter_info, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Aiterate_by_name");
VERIFY(ret, CORDER_ITER_STOP, "H5Aiterate_by_name");
VERIFY(iter_info->ncalled, 3, "H5Aiterate_by_name");
-
/* Iterate over attributes on object, stopping in the middle */
iter_info->nskipped = (unsigned)(skip = 0);
- iter_info->order = order;
- iter_info->stop = 3;
- iter_info->ncalled = 0;
- iter_info->curr = order != H5_ITER_DEC ? 0 : (max_attrs - 1);
+ iter_info->order = order;
+ iter_info->stop = 3;
+ iter_info->ncalled = 0;
+ iter_info->curr = order != H5_ITER_DEC ? 0 : (max_attrs - 1);
HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit);
ret = H5Aiterate_by_name(obj_id, ".", idx_type, order, &skip, attr_iterate2_cb, iter_info, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Aiterate_by_name");
VERIFY(ret, CORDER_ITER_STOP, "H5Aiterate_by_name");
VERIFY(iter_info->ncalled, 3, "H5Aiterate_by_name");
-
#ifndef H5_NO_DEPRECATED_SYMBOLS
/* Iterate over attributes on object, stopping in the middle, with H5Aiterate1() */
iter_info->nskipped = oskip = 0;
- iter_info->order = order;
- iter_info->stop = 3;
- iter_info->ncalled = 0;
- iter_info->curr = order != H5_ITER_DEC ? 0 : (max_attrs - 1);
+ iter_info->order = order;
+ iter_info->stop = 3;
+ iter_info->ncalled = 0;
+ iter_info->curr = order != H5_ITER_DEC ? 0 : (max_attrs - 1);
HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit);
ret = H5Aiterate1(obj_id, &oskip, attr_iterate1_cb, iter_info);
CHECK(ret, FAIL, "H5Aiterate1");
@@ -6793,10 +7160,9 @@ attr_iterate_check(hid_t fid, const char *dsetname, hid_t obj_id,
VERIFY(iter_info->ncalled, 3, "H5Aiterate1");
#endif /* H5_NO_DEPRECATED_SYMBOLS */
-
/* Check for iteration routine indicating failure */
skip = 0;
- ret = H5Aiterate2(obj_id, idx_type, order, &skip, attr_iterate2_fail_cb, NULL);
+ ret = H5Aiterate2(obj_id, idx_type, order, &skip, attr_iterate2_fail_cb, NULL);
VERIFY(ret, FAIL, "H5Aiterate2");
skip = 0;
@@ -6804,17 +7170,16 @@ attr_iterate_check(hid_t fid, const char *dsetname, hid_t obj_id,
VERIFY(ret, FAIL, "H5Aiterate_by_name");
skip = 0;
- ret = H5Aiterate_by_name(obj_id, ".", idx_type, order, &skip, attr_iterate2_fail_cb, NULL, H5P_DEFAULT);
+ ret = H5Aiterate_by_name(obj_id, ".", idx_type, order, &skip, attr_iterate2_fail_cb, NULL, H5P_DEFAULT);
VERIFY(ret, FAIL, "H5Aiterate_by_name");
/* Retrieve current # of errors */
- if(old_nerrs == GetTestNumErrs())
- return(0);
+ if (old_nerrs == GetTestNumErrs())
+ return (0);
else
- return(-1);
+ return (-1);
} /* end attr_iterate_check() */
-
/****************************************************************
**
** test_attr_iterate2(): Test basic H5A (attribute) code.
@@ -6824,38 +7189,44 @@ attr_iterate_check(hid_t fid, const char *dsetname, hid_t obj_id,
static void
test_attr_iterate2(hbool_t new_format, hid_t fcpl, hid_t fapl)
{
- hid_t fid; /* HDF5 File ID */
- hid_t dset1, dset2, dset3; /* Dataset IDs */
- hid_t my_dataset; /* Current dataset ID */
- hid_t sid; /* Dataspace ID */
- hid_t attr; /* Attribute ID */
- hid_t dcpl; /* Dataset creation property list ID */
- unsigned max_compact; /* Maximum # of links to store in group compactly */
- unsigned min_dense; /* Minimum # of links to store in group "densely" */
- htri_t is_empty; /* Are there any attributes? */
- htri_t is_dense; /* Are attributes stored densely? */
- hsize_t nattrs; /* Number of attributes on object */
- hsize_t name_count; /* # of records in name index */
- hsize_t corder_count; /* # of records in creation order index */
- H5_index_t idx_type; /* Type of index to operate on */
- H5_iter_order_t order; /* Order within in the index */
- attr_iter_info_t iter_info; /* Iterator info */
- hbool_t *visited = NULL; /* Array of flags for visiting links */
- hsize_t idx; /* Start index for iteration */
- hbool_t use_index; /* Use index on creation order values */
- const char *dsetname; /* Name of dataset for attributes */
- char attrname[NAME_BUF_SIZE]; /* Name of attribute */
- unsigned curr_dset; /* Current dataset to work on */
- unsigned u; /* Local index variable */
- herr_t ret; /* Generic return value */
+ hid_t fid; /* HDF5 File ID */
+ hid_t dset1, dset2, dset3; /* Dataset IDs */
+ hid_t my_dataset; /* Current dataset ID */
+ hid_t sid; /* Dataspace ID */
+ hid_t attr; /* Attribute ID */
+ hid_t dcpl; /* Dataset creation property list ID */
+ unsigned max_compact; /* Maximum # of links to store in group compactly */
+ unsigned min_dense; /* Minimum # of links to store in group "densely" */
+ htri_t is_empty; /* Are there any attributes? */
+ htri_t is_dense; /* Are attributes stored densely? */
+ hsize_t nattrs; /* Number of attributes on object */
+ hsize_t name_count; /* # of records in name index */
+ hsize_t corder_count; /* # of records in creation order index */
+ H5_index_t idx_type; /* Type of index to operate on */
+ H5_iter_order_t order; /* Order within in the index */
+ attr_iter_info_t iter_info; /* Iterator info */
+ hbool_t *visited = NULL; /* Array of flags for visiting links */
+ hsize_t idx; /* Start index for iteration */
+ unsigned use_index; /* Use index on creation order values */
+ const char *dsetname; /* Name of dataset for attributes */
+ char attrname[NAME_BUF_SIZE]; /* Name of attribute */
+ unsigned curr_dset; /* Current dataset to work on */
+ unsigned u; /* Local index variable */
+ herr_t ret; /* Generic return value */
/* Create dataspace for dataset & attributes */
sid = H5Screate(H5S_SCALAR);
CHECK(sid, FAIL, "H5Screate");
/* Create dataset creation property list */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ }
+ else {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
/* Query the attribute creation properties */
ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense);
@@ -6863,53 +7234,62 @@ test_attr_iterate2(hbool_t new_format, hid_t fcpl, hid_t fapl)
/* Allocate the "visited link" array */
iter_info.max_visit = max_compact * 2;
- visited = (hbool_t*)HDmalloc(sizeof(hbool_t) * iter_info.max_visit);
- CHECK(visited, NULL, "HDmalloc");
+ visited = (hbool_t *)HDmalloc(sizeof(hbool_t) * iter_info.max_visit);
+ CHECK_PTR(visited, "HDmalloc");
iter_info.visited = visited;
/* Loop over operating on different indices on link fields */
- for(idx_type = H5_INDEX_NAME; idx_type <=H5_INDEX_CRT_ORDER; idx_type++) {
+ for (idx_type = H5_INDEX_NAME; idx_type <= H5_INDEX_CRT_ORDER; idx_type++) {
/* Loop over operating in different orders */
- for(order = H5_ITER_INC; order <=H5_ITER_DEC; order++) {
+ for (order = H5_ITER_INC; order <= H5_ITER_DEC; order++) {
/* Loop over using index for creation order value */
- for(use_index = FALSE; use_index <= TRUE; use_index++) {
+ for (use_index = FALSE; use_index <= TRUE; use_index++) {
/* Print appropriate test message */
- if(idx_type == H5_INDEX_CRT_ORDER) {
- if(order == H5_ITER_INC) {
- if(use_index)
- MESSAGE(5, ("Testing Iterating over Attributes By Creation Order Index in Increasing Order w/Creation Order Index\n"))
+ if (idx_type == H5_INDEX_CRT_ORDER) {
+ if (order == H5_ITER_INC) {
+ if (use_index)
+ MESSAGE(5, ("Testing Iterating over Attributes By Creation Order Index in "
+ "Increasing Order w/Creation Order Index\n"))
else
- MESSAGE(5, ("Testing Iterating over Attributes By Creation Order Index in Increasing Order w/o Creation Order Index\n"))
+ MESSAGE(5, ("Testing Iterating over Attributes By Creation Order Index in "
+ "Increasing Order w/o Creation Order Index\n"))
} /* end if */
else {
- if(use_index)
- MESSAGE(5, ("Testing Iterating over Attributes By Creation Order Index in Decreasing Order w/Creation Order Index\n"))
+ if (use_index)
+ MESSAGE(5, ("Testing Iterating over Attributes By Creation Order Index in "
+ "Decreasing Order w/Creation Order Index\n"))
else
- MESSAGE(5, ("Testing Iterating over Attributes By Creation Order Index in Decreasing Order w/o Creation Order Index\n"))
+ MESSAGE(5, ("Testing Iterating over Attributes By Creation Order Index in "
+ "Decreasing Order w/o Creation Order Index\n"))
} /* end else */
- } /* end if */
+ } /* end if */
else {
- if(order == H5_ITER_INC) {
- if(use_index)
- MESSAGE(5, ("Testing Iterating over Attributes By Name Index in Increasing Order w/Creation Order Index\n"))
+ if (order == H5_ITER_INC) {
+ if (use_index)
+ MESSAGE(5, ("Testing Iterating over Attributes By Name Index in Increasing Order "
+ "w/Creation Order Index\n"))
else
- MESSAGE(5, ("Testing Iterating over Attributes By Name Index in Increasing Order w/o Creation Order Index\n"))
+ MESSAGE(5, ("Testing Iterating over Attributes By Name Index in Increasing Order "
+ "w/o Creation Order Index\n"))
} /* end if */
else {
- if(use_index)
- MESSAGE(5, ("Testing Iterating over Attributes By Name Index in Decreasing Order w/Creation Order Index\n"))
+ if (use_index)
+ MESSAGE(5, ("Testing Iterating over Attributes By Name Index in Decreasing Order "
+ "w/Creation Order Index\n"))
else
- MESSAGE(5, ("Testing Iterating over Attributes By Name Index in Decreasing Order w/o Creation Order Index\n"))
+ MESSAGE(5, ("Testing Iterating over Attributes By Name Index in Decreasing Order "
+ "w/o Creation Order Index\n"))
} /* end else */
- } /* end else */
+ } /* end else */
/* Create file */
fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl);
CHECK(fid, FAIL, "H5Fcreate");
/* Set attribute creation order tracking & indexing for object */
- if(new_format == TRUE) {
- ret = H5Pset_attr_creation_order(dcpl, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0)));
+ if (new_format == TRUE) {
+ ret = H5Pset_attr_creation_order(
+ dcpl, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0)));
CHECK(ret, FAIL, "H5Pset_attr_creation_order");
} /* end if */
@@ -6922,21 +7302,21 @@ test_attr_iterate2(hbool_t new_format, hid_t fcpl, hid_t fapl)
CHECK(dset3, FAIL, "H5Dcreate2");
/* Work on all the datasets */
- for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
- switch(curr_dset) {
+ for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
+ switch (curr_dset) {
case 0:
my_dataset = dset1;
- dsetname = DSET1_NAME;
+ dsetname = DSET1_NAME;
break;
case 1:
my_dataset = dset2;
- dsetname = DSET2_NAME;
+ dsetname = DSET2_NAME;
break;
case 2:
my_dataset = dset3;
- dsetname = DSET3_NAME;
+ dsetname = DSET3_NAME;
break;
default:
@@ -6944,26 +7324,29 @@ test_attr_iterate2(hbool_t new_format, hid_t fcpl, hid_t fapl)
} /* end switch */
/* Check on dataset's attribute storage status */
- is_empty = H5O_is_attr_empty_test(my_dataset);
- VERIFY(is_empty, TRUE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ is_empty = H5O__is_attr_empty_test(my_dataset);
+ VERIFY(is_empty, TRUE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
/* Check for iterating over object with no attributes (should be OK) */
ret = H5Aiterate2(my_dataset, idx_type, order, NULL, attr_iterate2_cb, NULL);
CHECK(ret, FAIL, "H5Aiterate2");
- ret = H5Aiterate_by_name(fid, dsetname, idx_type, order, NULL, attr_iterate2_cb, NULL, H5P_DEFAULT);
+ ret = H5Aiterate_by_name(fid, dsetname, idx_type, order, NULL, attr_iterate2_cb, NULL,
+ H5P_DEFAULT);
CHECK(ret, FAIL, "H5Aiterate_by_name");
- ret = H5Aiterate_by_name(my_dataset, ".", idx_type, order, NULL, attr_iterate2_cb, NULL, H5P_DEFAULT);
+ ret = H5Aiterate_by_name(my_dataset, ".", idx_type, order, NULL, attr_iterate2_cb, NULL,
+ H5P_DEFAULT);
CHECK(ret, FAIL, "H5Aiterate_by_name");
/* Create attributes, up to limit of compact form */
- for(u = 0; u < max_compact; u++) {
+ for (u = 0; u < max_compact; u++) {
/* Create attribute */
- sprintf(attrname, "attr %02u", u);
- attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
+ attr =
+ H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
/* Write data into the attribute */
@@ -6980,13 +7363,13 @@ test_attr_iterate2(hbool_t new_format, hid_t fcpl, hid_t fapl)
} /* end for */
/* Verify state of object */
- ret = H5O_num_attrs_test(my_dataset, &nattrs);
- CHECK(ret, FAIL, "H5O_num_attrs_test");
- VERIFY(nattrs, max_compact, "H5O_num_attrs_test");
- is_empty = H5O_is_attr_empty_test(my_dataset);
- VERIFY(is_empty, FALSE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ ret = H5O__num_attrs_test(my_dataset, &nattrs);
+ CHECK(ret, FAIL, "H5O__num_attrs_test");
+ VERIFY(nattrs, max_compact, "H5O__num_attrs_test");
+ is_empty = H5O__is_attr_empty_test(my_dataset);
+ VERIFY(is_empty, FALSE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
/* Check for out of bound iteration */
idx = u;
@@ -6994,11 +7377,13 @@ test_attr_iterate2(hbool_t new_format, hid_t fcpl, hid_t fapl)
VERIFY(ret, FAIL, "H5Aiterate2");
idx = u;
- ret = H5Aiterate_by_name(fid, dsetname, idx_type, order, &idx, attr_iterate2_cb, NULL, H5P_DEFAULT);
+ ret = H5Aiterate_by_name(fid, dsetname, idx_type, order, &idx, attr_iterate2_cb, NULL,
+ H5P_DEFAULT);
VERIFY(ret, FAIL, "H5Aiterate_by_name");
idx = u;
- ret = H5Aiterate_by_name(my_dataset, ".", idx_type, order, &idx, attr_iterate2_cb, NULL, H5P_DEFAULT);
+ ret = H5Aiterate_by_name(my_dataset, ".", idx_type, order, &idx, attr_iterate2_cb, NULL,
+ H5P_DEFAULT);
VERIFY(ret, FAIL, "H5Aiterate_by_name");
/* Test iteration over attributes stored compactly */
@@ -7006,23 +7391,22 @@ test_attr_iterate2(hbool_t new_format, hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "attr_iterate_check");
} /* end for */
-
/* Work on all the datasets */
- for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
- switch(curr_dset) {
+ for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
+ switch (curr_dset) {
case 0:
my_dataset = dset1;
- dsetname = DSET1_NAME;
+ dsetname = DSET1_NAME;
break;
case 1:
my_dataset = dset2;
- dsetname = DSET2_NAME;
+ dsetname = DSET2_NAME;
break;
case 2:
my_dataset = dset3;
- dsetname = DSET3_NAME;
+ dsetname = DSET3_NAME;
break;
default:
@@ -7030,10 +7414,11 @@ test_attr_iterate2(hbool_t new_format, hid_t fcpl, hid_t fapl)
} /* end switch */
/* Create more attributes, to push into dense form */
- for(u = max_compact; u < (max_compact * 2); u++) {
+ for (u = max_compact; u < (max_compact * 2); u++) {
/* Create attribute */
- sprintf(attrname, "attr %02u", u);
- attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
+ attr =
+ H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
/* Write data into the attribute */
@@ -7045,9 +7430,9 @@ test_attr_iterate2(hbool_t new_format, hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Aclose");
/* Verify state of object */
- if(u >= max_compact) {
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, (new_format ? TRUE : FALSE), "H5O_is_attr_dense_test");
+ if (u >= max_compact) {
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, (new_format ? TRUE : FALSE), "H5O__is_attr_dense_test");
} /* end if */
/* Verify information for new attribute */
@@ -7056,21 +7441,21 @@ test_attr_iterate2(hbool_t new_format, hid_t fcpl, hid_t fapl)
} /* end for */
/* Verify state of object */
- ret = H5O_num_attrs_test(my_dataset, &nattrs);
- CHECK(ret, FAIL, "H5O_num_attrs_test");
- VERIFY(nattrs, (max_compact * 2), "H5O_num_attrs_test");
- is_empty = H5O_is_attr_empty_test(my_dataset);
- VERIFY(is_empty, FALSE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, (new_format ? TRUE : FALSE), "H5O_is_attr_dense_test");
-
- if(new_format) {
+ ret = H5O__num_attrs_test(my_dataset, &nattrs);
+ CHECK(ret, FAIL, "H5O__num_attrs_test");
+ VERIFY(nattrs, (max_compact * 2), "H5O__num_attrs_test");
+ is_empty = H5O__is_attr_empty_test(my_dataset);
+ VERIFY(is_empty, FALSE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, (new_format ? TRUE : FALSE), "H5O__is_attr_dense_test");
+
+ if (new_format) {
/* Retrieve & verify # of records in the name & creation order indices */
- ret = H5O_attr_dense_info_test(my_dataset, &name_count, &corder_count);
- CHECK(ret, FAIL, "H5O_attr_dense_info_test");
- if(use_index)
- VERIFY(name_count, corder_count, "H5O_attr_dense_info_test");
- VERIFY(name_count, (max_compact * 2), "H5O_attr_dense_info_test");
+ ret = H5O__attr_dense_info_test(my_dataset, &name_count, &corder_count);
+ CHECK(ret, FAIL, "H5O__attr_dense_info_test");
+ if (use_index)
+ VERIFY(name_count, corder_count, "H5O__attr_dense_info_test");
+ VERIFY(name_count, (max_compact * 2), "H5O__attr_dense_info_test");
} /* end if */
/* Check for out of bound iteration */
@@ -7079,11 +7464,13 @@ test_attr_iterate2(hbool_t new_format, hid_t fcpl, hid_t fapl)
VERIFY(ret, FAIL, "H5Aiterate2");
idx = u;
- ret = H5Aiterate_by_name(fid, dsetname, idx_type, order, &idx, attr_iterate2_cb, NULL, H5P_DEFAULT);
+ ret = H5Aiterate_by_name(fid, dsetname, idx_type, order, &idx, attr_iterate2_cb, NULL,
+ H5P_DEFAULT);
VERIFY(ret, FAIL, "H5Aiterate_by_name");
idx = u;
- ret = H5Aiterate_by_name(my_dataset, ".", idx_type, order, &idx, attr_iterate2_cb, NULL, H5P_DEFAULT);
+ ret = H5Aiterate_by_name(my_dataset, ".", idx_type, order, &idx, attr_iterate2_cb, NULL,
+ H5P_DEFAULT);
VERIFY(ret, FAIL, "H5Aiterate_by_name");
/* Test iteration over attributes stored densely */
@@ -7103,8 +7490,8 @@ test_attr_iterate2(hbool_t new_format, hid_t fcpl, hid_t fapl)
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
} /* end for */
- } /* end for */
- } /* end for */
+ } /* end for */
+ } /* end for */
/* Close property list */
ret = H5Pclose(dcpl);
@@ -7116,9 +7503,8 @@ test_attr_iterate2(hbool_t new_format, hid_t fcpl, hid_t fapl)
/* Free the "visited link" array */
HDfree(visited);
-} /* test_attr_iterate2() */
+} /* test_attr_iterate2() */
-
/*-------------------------------------------------------------------------
* Function: attr_open_by_idx_check
*
@@ -7133,20 +7519,19 @@ test_attr_iterate2(hbool_t new_format, hid_t fcpl, hid_t fapl)
*-------------------------------------------------------------------------
*/
static int
-attr_open_by_idx_check(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order,
- unsigned max_attrs)
+attr_open_by_idx_check(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, unsigned max_attrs)
{
- hid_t attr_id; /* ID of attribute to test */
- H5A_info_t ainfo; /* Attribute info */
- int old_nerrs; /* Number of errors when entering this check */
- unsigned u; /* Local index variable */
- herr_t ret; /* Generic return value */
+ hid_t attr_id; /* ID of attribute to test */
+ H5A_info_t ainfo; /* Attribute info */
+ int old_nerrs; /* Number of errors when entering this check */
+ unsigned u; /* Local index variable */
+ herr_t ret; /* Generic return value */
/* Retrieve the current # of reported errors */
old_nerrs = GetTestNumErrs();
/* Open each attribute on object by index and check that it's the correct one */
- for(u = 0; u < max_attrs; u++) {
+ for (u = 0; u < max_attrs; u++) {
/* Open the attribute */
attr_id = H5Aopen_by_idx(obj_id, ".", idx_type, order, (hsize_t)u, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr_id, FAIL, "H5Aopen_by_idx");
@@ -7156,10 +7541,10 @@ attr_open_by_idx_check(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order,
CHECK(ret, FAIL, "H5Aget_info");
/* Check that the object is the correct one */
- if(order == H5_ITER_INC) {
+ if (order == H5_ITER_INC) {
VERIFY(ainfo.corder, u, "H5Aget_info");
} /* end if */
- else if(order == H5_ITER_DEC) {
+ else if (order == H5_ITER_DEC) {
VERIFY(ainfo.corder, (max_attrs - (u + 1)), "H5Aget_info");
} /* end if */
else {
@@ -7172,13 +7557,12 @@ attr_open_by_idx_check(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order,
} /* end for */
/* Retrieve current # of errors */
- if(old_nerrs == GetTestNumErrs())
- return(0);
+ if (old_nerrs == GetTestNumErrs())
+ return (0);
else
- return(-1);
+ return (-1);
} /* end attr_open_by_idx_check() */
-
/****************************************************************
**
** test_attr_open_by_idx(): Test basic H5A (attribute) code.
@@ -7188,83 +7572,98 @@ attr_open_by_idx_check(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order,
static void
test_attr_open_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
{
- hid_t fid; /* HDF5 File ID */
- hid_t dset1, dset2, dset3; /* Dataset IDs */
- hid_t my_dataset; /* Current dataset ID */
- hid_t sid; /* Dataspace ID */
- hid_t attr; /* Attribute ID */
- hid_t dcpl; /* Dataset creation property list ID */
- unsigned max_compact; /* Maximum # of links to store in group compactly */
- unsigned min_dense; /* Minimum # of links to store in group "densely" */
- htri_t is_empty; /* Are there any attributes? */
- htri_t is_dense; /* Are attributes stored densely? */
- hsize_t nattrs; /* Number of attributes on object */
- hsize_t name_count; /* # of records in name index */
- hsize_t corder_count; /* # of records in creation order index */
- H5_index_t idx_type; /* Type of index to operate on */
- H5_iter_order_t order; /* Order within in the index */
- hbool_t use_index; /* Use index on creation order values */
- char attrname[NAME_BUF_SIZE]; /* Name of attribute */
- unsigned curr_dset; /* Current dataset to work on */
- unsigned u; /* Local index variable */
- hid_t ret_id; /* Generic hid_t return value */
- herr_t ret; /* Generic return value */
+ hid_t fid; /* HDF5 File ID */
+ hid_t dset1, dset2, dset3; /* Dataset IDs */
+ hid_t my_dataset; /* Current dataset ID */
+ hid_t sid; /* Dataspace ID */
+ hid_t attr; /* Attribute ID */
+ hid_t dcpl; /* Dataset creation property list ID */
+ unsigned max_compact; /* Maximum # of links to store in group compactly */
+ unsigned min_dense; /* Minimum # of links to store in group "densely" */
+ htri_t is_empty; /* Are there any attributes? */
+ htri_t is_dense; /* Are attributes stored densely? */
+ hsize_t nattrs; /* Number of attributes on object */
+ hsize_t name_count; /* # of records in name index */
+ hsize_t corder_count; /* # of records in creation order index */
+ H5_index_t idx_type; /* Type of index to operate on */
+ H5_iter_order_t order; /* Order within in the index */
+ unsigned use_index; /* Use index on creation order values */
+ char attrname[NAME_BUF_SIZE]; /* Name of attribute */
+ unsigned curr_dset; /* Current dataset to work on */
+ unsigned u; /* Local index variable */
+ hid_t ret_id; /* Generic hid_t return value */
+ herr_t ret; /* Generic return value */
/* Create dataspace for dataset & attributes */
sid = H5Screate(H5S_SCALAR);
CHECK(sid, FAIL, "H5Screate");
/* Create dataset creation property list */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ }
+ else {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
/* Query the attribute creation properties */
ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense);
CHECK(ret, FAIL, "H5Pget_attr_phase_change");
/* Loop over operating on different indices on link fields */
- for(idx_type = H5_INDEX_NAME; idx_type <=H5_INDEX_CRT_ORDER; idx_type++) {
+ for (idx_type = H5_INDEX_NAME; idx_type <= H5_INDEX_CRT_ORDER; idx_type++) {
/* Loop over operating in different orders */
- for(order = H5_ITER_INC; order <=H5_ITER_DEC; order++) {
+ for (order = H5_ITER_INC; order <= H5_ITER_DEC; order++) {
/* Loop over using index for creation order value */
- for(use_index = FALSE; use_index <= TRUE; use_index++) {
+ for (use_index = FALSE; use_index <= TRUE; use_index++) {
/* Print appropriate test message */
- if(idx_type == H5_INDEX_CRT_ORDER) {
- if(order == H5_ITER_INC) {
- if(use_index)
- MESSAGE(5, ("Testing Opening Attributes By Creation Order Index in Increasing Order w/Creation Order Index\n"))
+ if (idx_type == H5_INDEX_CRT_ORDER) {
+ if (order == H5_ITER_INC) {
+ if (use_index)
+ MESSAGE(5, ("Testing Opening Attributes By Creation Order Index in Increasing "
+ "Order w/Creation Order Index\n"))
else
- MESSAGE(5, ("Testing Opening Attributes By Creation Order Index in Increasing Order w/o Creation Order Index\n"))
+ MESSAGE(5, ("Testing Opening Attributes By Creation Order Index in Increasing "
+ "Order w/o Creation Order Index\n"))
} /* end if */
else {
- if(use_index)
- MESSAGE(5, ("Testing Opening Attributes By Creation Order Index in Decreasing Order w/Creation Order Index\n"))
+ if (use_index)
+ MESSAGE(5, ("Testing Opening Attributes By Creation Order Index in Decreasing "
+ "Order w/Creation Order Index\n"))
else
- MESSAGE(5, ("Testing Opening Attributes By Creation Order Index in Decreasing Order w/o Creation Order Index\n"))
+ MESSAGE(5, ("Testing Opening Attributes By Creation Order Index in Decreasing "
+ "Order w/o Creation Order Index\n"))
} /* end else */
- } /* end if */
+ } /* end if */
else {
- if(order == H5_ITER_INC) {
- if(use_index)
- MESSAGE(5, ("Testing Opening Attributes By Name Index in Increasing Order w/Creation Order Index\n"))
+ if (order == H5_ITER_INC) {
+ if (use_index)
+ MESSAGE(5, ("Testing Opening Attributes By Name Index in Increasing Order "
+ "w/Creation Order Index\n"))
else
- MESSAGE(5, ("Testing Opening Attributes By Name Index in Increasing Order w/o Creation Order Index\n"))
+ MESSAGE(5, ("Testing Opening Attributes By Name Index in Increasing Order w/o "
+ "Creation Order Index\n"))
} /* end if */
else {
- if(use_index)
- MESSAGE(5, ("Testing Opening Attributes By Name Index in Decreasing Order w/Creation Order Index\n"))
+ if (use_index)
+ MESSAGE(5, ("Testing Opening Attributes By Name Index in Decreasing Order "
+ "w/Creation Order Index\n"))
else
- MESSAGE(5, ("Testing Opening Attributes By Name Index in Decreasing Order w/o Creation Order Index\n"))
+ MESSAGE(5, ("Testing Opening Attributes By Name Index in Decreasing Order w/o "
+ "Creation Order Index\n"))
} /* end else */
- } /* end else */
+ } /* end else */
/* Create file */
fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl);
CHECK(fid, FAIL, "H5Fcreate");
/* Set attribute creation order tracking & indexing for object */
- if(new_format == TRUE) {
- ret = H5Pset_attr_creation_order(dcpl, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0)));
+ if (new_format == TRUE) {
+ ret = H5Pset_attr_creation_order(
+ dcpl, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0)));
CHECK(ret, FAIL, "H5Pset_attr_creation_order");
} /* end if */
@@ -7277,8 +7676,8 @@ test_attr_open_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
CHECK(dset3, FAIL, "H5Dcreate2");
/* Work on all the datasets */
- for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
- switch(curr_dset) {
+ for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
+ switch (curr_dset) {
case 0:
my_dataset = dset1;
break;
@@ -7296,20 +7695,22 @@ test_attr_open_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
} /* end switch */
/* Check on dataset's attribute storage status */
- is_empty = H5O_is_attr_empty_test(my_dataset);
- VERIFY(is_empty, TRUE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ is_empty = H5O__is_attr_empty_test(my_dataset);
+ VERIFY(is_empty, TRUE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
/* Check for opening an attribute on an object with no attributes */
- ret_id = H5Aopen_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT, H5P_DEFAULT);
+ ret_id = H5Aopen_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT,
+ H5P_DEFAULT);
VERIFY(ret_id, FAIL, "H5Aopen_by_idx");
/* Create attributes, up to limit of compact form */
- for(u = 0; u < max_compact; u++) {
+ for (u = 0; u < max_compact; u++) {
/* Create attribute */
- sprintf(attrname, "attr %02u", u);
- attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
+ attr =
+ H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
/* Write data into the attribute */
@@ -7326,16 +7727,17 @@ test_attr_open_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
} /* end for */
/* Verify state of object */
- ret = H5O_num_attrs_test(my_dataset, &nattrs);
- CHECK(ret, FAIL, "H5O_num_attrs_test");
- VERIFY(nattrs, max_compact, "H5O_num_attrs_test");
- is_empty = H5O_is_attr_empty_test(my_dataset);
- VERIFY(is_empty, FALSE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ ret = H5O__num_attrs_test(my_dataset, &nattrs);
+ CHECK(ret, FAIL, "H5O__num_attrs_test");
+ VERIFY(nattrs, max_compact, "H5O__num_attrs_test");
+ is_empty = H5O__is_attr_empty_test(my_dataset);
+ VERIFY(is_empty, FALSE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
/* Check for out of bound opening an attribute on an object */
- ret_id = H5Aopen_by_idx(my_dataset, ".", idx_type, order, (hsize_t)u, H5P_DEFAULT, H5P_DEFAULT);
+ ret_id = H5Aopen_by_idx(my_dataset, ".", idx_type, order, (hsize_t)u, H5P_DEFAULT,
+ H5P_DEFAULT);
VERIFY(ret_id, FAIL, "H5Aopen_by_idx");
/* Test opening attributes by index stored compactly */
@@ -7343,10 +7745,9 @@ test_attr_open_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "attr_open_by_idx_check");
} /* end for */
-
/* Work on all the datasets */
- for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
- switch(curr_dset) {
+ for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
+ switch (curr_dset) {
case 0:
my_dataset = dset1;
break;
@@ -7364,10 +7765,11 @@ test_attr_open_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
} /* end switch */
/* Create more attributes, to push into dense form */
- for(u = max_compact; u < (max_compact * 2); u++) {
+ for (u = max_compact; u < (max_compact * 2); u++) {
/* Create attribute */
- sprintf(attrname, "attr %02u", u);
- attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
+ attr =
+ H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
/* Write data into the attribute */
@@ -7379,9 +7781,9 @@ test_attr_open_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Aclose");
/* Verify state of object */
- if(u >= max_compact) {
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, (new_format ? TRUE : FALSE), "H5O_is_attr_dense_test");
+ if (u >= max_compact) {
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, (new_format ? TRUE : FALSE), "H5O__is_attr_dense_test");
} /* end if */
/* Verify information for new attribute */
@@ -7390,25 +7792,26 @@ test_attr_open_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
} /* end for */
/* Verify state of object */
- ret = H5O_num_attrs_test(my_dataset, &nattrs);
- CHECK(ret, FAIL, "H5O_num_attrs_test");
- VERIFY(nattrs, (max_compact * 2), "H5O_num_attrs_test");
- is_empty = H5O_is_attr_empty_test(my_dataset);
- VERIFY(is_empty, FALSE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, (new_format ? TRUE : FALSE), "H5O_is_attr_dense_test");
-
- if(new_format) {
+ ret = H5O__num_attrs_test(my_dataset, &nattrs);
+ CHECK(ret, FAIL, "H5O__num_attrs_test");
+ VERIFY(nattrs, (max_compact * 2), "H5O__num_attrs_test");
+ is_empty = H5O__is_attr_empty_test(my_dataset);
+ VERIFY(is_empty, FALSE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, (new_format ? TRUE : FALSE), "H5O__is_attr_dense_test");
+
+ if (new_format) {
/* Retrieve & verify # of records in the name & creation order indices */
- ret = H5O_attr_dense_info_test(my_dataset, &name_count, &corder_count);
- CHECK(ret, FAIL, "H5O_attr_dense_info_test");
- if(use_index)
- VERIFY(name_count, corder_count, "H5O_attr_dense_info_test");
- VERIFY(name_count, (max_compact * 2), "H5O_attr_dense_info_test");
+ ret = H5O__attr_dense_info_test(my_dataset, &name_count, &corder_count);
+ CHECK(ret, FAIL, "H5O__attr_dense_info_test");
+ if (use_index)
+ VERIFY(name_count, corder_count, "H5O__attr_dense_info_test");
+ VERIFY(name_count, (max_compact * 2), "H5O__attr_dense_info_test");
} /* end if */
/* Check for out of bound opening an attribute on an object */
- ret_id = H5Aopen_by_idx(my_dataset, ".", idx_type, order, (hsize_t)u, H5P_DEFAULT, H5P_DEFAULT);
+ ret_id = H5Aopen_by_idx(my_dataset, ".", idx_type, order, (hsize_t)u, H5P_DEFAULT,
+ H5P_DEFAULT);
VERIFY(ret_id, FAIL, "H5Aopen_by_idx");
/* Test opening attributes by index stored compactly */
@@ -7428,8 +7831,8 @@ test_attr_open_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
} /* end for */
- } /* end for */
- } /* end for */
+ } /* end for */
+ } /* end for */
/* Close property list */
ret = H5Pclose(dcpl);
@@ -7438,9 +7841,8 @@ test_attr_open_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
/* Close dataspace */
ret = H5Sclose(sid);
CHECK(ret, FAIL, "H5Sclose");
-} /* test_attr_open_by_idx() */
+} /* test_attr_open_by_idx() */
-
/*-------------------------------------------------------------------------
* Function: attr_open_check
*
@@ -7455,23 +7857,22 @@ test_attr_open_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
*-------------------------------------------------------------------------
*/
static int
-attr_open_check(hid_t fid, const char *dsetname, hid_t obj_id,
- unsigned max_attrs)
+attr_open_check(hid_t fid, const char *dsetname, hid_t obj_id, unsigned max_attrs)
{
- hid_t attr_id; /* ID of attribute to test */
- H5A_info_t ainfo; /* Attribute info */
- char attrname[NAME_BUF_SIZE]; /* Name of attribute */
- int old_nerrs; /* Number of errors when entering this check */
- unsigned u; /* Local index variable */
- herr_t ret; /* Generic return value */
+ hid_t attr_id; /* ID of attribute to test */
+ H5A_info_t ainfo; /* Attribute info */
+ char attrname[NAME_BUF_SIZE]; /* Name of attribute */
+ int old_nerrs; /* Number of errors when entering this check */
+ unsigned u; /* Local index variable */
+ herr_t ret; /* Generic return value */
/* Retrieve the current # of reported errors */
old_nerrs = GetTestNumErrs();
/* Open each attribute on object by index and check that it's the correct one */
- for(u = 0; u < max_attrs; u++) {
+ for (u = 0; u < max_attrs; u++) {
/* Open the attribute */
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr_id = H5Aopen(obj_id, attrname, H5P_DEFAULT);
CHECK(attr_id, FAIL, "H5Aopen");
@@ -7486,7 +7887,6 @@ attr_open_check(hid_t fid, const char *dsetname, hid_t obj_id,
ret = H5Aclose(attr_id);
CHECK(ret, FAIL, "H5Aclose");
-
/* Open the attribute */
attr_id = H5Aopen_by_name(obj_id, ".", attrname, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr_id, FAIL, "H5Aopen_by_name");
@@ -7502,7 +7902,6 @@ attr_open_check(hid_t fid, const char *dsetname, hid_t obj_id,
ret = H5Aclose(attr_id);
CHECK(ret, FAIL, "H5Aclose");
-
/* Open the attribute */
attr_id = H5Aopen_by_name(fid, dsetname, attrname, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr_id, FAIL, "H5Aopen_by_name");
@@ -7520,13 +7919,12 @@ attr_open_check(hid_t fid, const char *dsetname, hid_t obj_id,
} /* end for */
/* Retrieve current # of errors */
- if(old_nerrs == GetTestNumErrs())
- return(0);
+ if (old_nerrs == GetTestNumErrs())
+ return (0);
else
- return(-1);
+ return (-1);
} /* end attr_open_check() */
-
/****************************************************************
**
** test_attr_open_by_name(): Test basic H5A (attribute) code.
@@ -7536,43 +7934,49 @@ attr_open_check(hid_t fid, const char *dsetname, hid_t obj_id,
static void
test_attr_open_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl)
{
- hid_t fid; /* HDF5 File ID */
- hid_t dset1, dset2, dset3; /* Dataset IDs */
- hid_t my_dataset; /* Current dataset ID */
- hid_t sid; /* Dataspace ID */
- hid_t attr; /* Attribute ID */
- hid_t dcpl; /* Dataset creation property list ID */
- unsigned max_compact; /* Maximum # of links to store in group compactly */
- unsigned min_dense; /* Minimum # of links to store in group "densely" */
- htri_t is_empty; /* Are there any attributes? */
- htri_t is_dense; /* Are attributes stored densely? */
- hsize_t nattrs; /* Number of attributes on object */
- hsize_t name_count; /* # of records in name index */
- hsize_t corder_count; /* # of records in creation order index */
- hbool_t use_index; /* Use index on creation order values */
- const char *dsetname; /* Name of dataset for attributes */
- char attrname[NAME_BUF_SIZE]; /* Name of attribute */
- unsigned curr_dset; /* Current dataset to work on */
- unsigned u; /* Local index variable */
- hid_t ret_id; /* Generic hid_t return value */
- herr_t ret; /* Generic return value */
+ hid_t fid; /* HDF5 File ID */
+ hid_t dset1, dset2, dset3; /* Dataset IDs */
+ hid_t my_dataset; /* Current dataset ID */
+ hid_t sid; /* Dataspace ID */
+ hid_t attr; /* Attribute ID */
+ hid_t dcpl; /* Dataset creation property list ID */
+ unsigned max_compact; /* Maximum # of links to store in group compactly */
+ unsigned min_dense; /* Minimum # of links to store in group "densely" */
+ htri_t is_empty; /* Are there any attributes? */
+ htri_t is_dense; /* Are attributes stored densely? */
+ hsize_t nattrs; /* Number of attributes on object */
+ hsize_t name_count; /* # of records in name index */
+ hsize_t corder_count; /* # of records in creation order index */
+ unsigned use_index; /* Use index on creation order values */
+ const char *dsetname; /* Name of dataset for attributes */
+ char attrname[NAME_BUF_SIZE]; /* Name of attribute */
+ unsigned curr_dset; /* Current dataset to work on */
+ unsigned u; /* Local index variable */
+ hid_t ret_id; /* Generic hid_t return value */
+ herr_t ret; /* Generic return value */
/* Create dataspace for dataset & attributes */
sid = H5Screate(H5S_SCALAR);
CHECK(sid, FAIL, "H5Screate");
/* Create dataset creation property list */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ }
+ else {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
/* Query the attribute creation properties */
ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense);
CHECK(ret, FAIL, "H5Pget_attr_phase_change");
/* Loop over using index for creation order value */
- for(use_index = FALSE; use_index <= TRUE; use_index++) {
+ for (use_index = FALSE; use_index <= TRUE; use_index++) {
/* Print appropriate test message */
- if(use_index)
+ if (use_index)
MESSAGE(5, ("Testing Opening Attributes By Name w/Creation Order Index\n"))
else
MESSAGE(5, ("Testing Opening Attributes By Name w/o Creation Order Index\n"))
@@ -7582,8 +7986,9 @@ test_attr_open_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl)
CHECK(fid, FAIL, "H5Fcreate");
/* Set attribute creation order tracking & indexing for object */
- if(new_format == TRUE) {
- ret = H5Pset_attr_creation_order(dcpl, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0)));
+ if (new_format == TRUE) {
+ ret = H5Pset_attr_creation_order(
+ dcpl, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0)));
CHECK(ret, FAIL, "H5Pset_attr_creation_order");
} /* end if */
@@ -7596,21 +8001,21 @@ test_attr_open_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl)
CHECK(dset3, FAIL, "H5Dcreate2");
/* Work on all the datasets */
- for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
- switch(curr_dset) {
+ for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
+ switch (curr_dset) {
case 0:
my_dataset = dset1;
- dsetname = DSET1_NAME;
+ dsetname = DSET1_NAME;
break;
case 1:
my_dataset = dset2;
- dsetname = DSET2_NAME;
+ dsetname = DSET2_NAME;
break;
case 2:
my_dataset = dset3;
- dsetname = DSET3_NAME;
+ dsetname = DSET3_NAME;
break;
default:
@@ -7618,12 +8023,12 @@ test_attr_open_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl)
} /* end switch */
/* Check on dataset's attribute storage status */
- is_empty = H5O_is_attr_empty_test(my_dataset);
- VERIFY(is_empty, TRUE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ is_empty = H5O__is_attr_empty_test(my_dataset);
+ VERIFY(is_empty, TRUE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
- /* Check for opening a non-existant attribute on an object with no attributes */
+ /* Check for opening a non-existent attribute on an object with no attributes */
ret_id = H5Aopen(my_dataset, "foo", H5P_DEFAULT);
VERIFY(ret_id, FAIL, "H5Aopen");
@@ -7634,9 +8039,9 @@ test_attr_open_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl)
VERIFY(ret_id, FAIL, "H5Aopen_by_name");
/* Create attributes, up to limit of compact form */
- for(u = 0; u < max_compact; u++) {
+ for (u = 0; u < max_compact; u++) {
/* Create attribute */
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -7654,15 +8059,15 @@ test_attr_open_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl)
} /* end for */
/* Verify state of object */
- ret = H5O_num_attrs_test(my_dataset, &nattrs);
- CHECK(ret, FAIL, "H5O_num_attrs_test");
- VERIFY(nattrs, max_compact, "H5O_num_attrs_test");
- is_empty = H5O_is_attr_empty_test(my_dataset);
- VERIFY(is_empty, FALSE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
-
- /* Check for opening a non-existant attribute on an object with compact attribute storage */
+ ret = H5O__num_attrs_test(my_dataset, &nattrs);
+ CHECK(ret, FAIL, "H5O__num_attrs_test");
+ VERIFY(nattrs, max_compact, "H5O__num_attrs_test");
+ is_empty = H5O__is_attr_empty_test(my_dataset);
+ VERIFY(is_empty, FALSE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
+
+ /* Check for opening a non-existent attribute on an object with compact attribute storage */
ret_id = H5Aopen(my_dataset, "foo", H5P_DEFAULT);
VERIFY(ret_id, FAIL, "H5Aopen");
@@ -7677,23 +8082,22 @@ test_attr_open_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "attr_open_check");
} /* end for */
-
/* Work on all the datasets */
- for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
- switch(curr_dset) {
+ for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
+ switch (curr_dset) {
case 0:
my_dataset = dset1;
- dsetname = DSET1_NAME;
+ dsetname = DSET1_NAME;
break;
case 1:
my_dataset = dset2;
- dsetname = DSET2_NAME;
+ dsetname = DSET2_NAME;
break;
case 2:
my_dataset = dset3;
- dsetname = DSET3_NAME;
+ dsetname = DSET3_NAME;
break;
default:
@@ -7701,9 +8105,9 @@ test_attr_open_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl)
} /* end switch */
/* Create more attributes, to push into dense form */
- for(u = max_compact; u < (max_compact * 2); u++) {
+ for (u = max_compact; u < (max_compact * 2); u++) {
/* Create attribute */
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -7716,9 +8120,9 @@ test_attr_open_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Aclose");
/* Verify state of object */
- if(u >= max_compact) {
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, (new_format ? TRUE : FALSE), "H5O_is_attr_dense_test");
+ if (u >= max_compact) {
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, (new_format ? TRUE : FALSE), "H5O__is_attr_dense_test");
} /* end if */
/* Verify information for new attribute */
@@ -7727,24 +8131,24 @@ test_attr_open_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl)
} /* end for */
/* Verify state of object */
- ret = H5O_num_attrs_test(my_dataset, &nattrs);
- CHECK(ret, FAIL, "H5O_num_attrs_test");
- VERIFY(nattrs, (max_compact * 2), "H5O_num_attrs_test");
- is_empty = H5O_is_attr_empty_test(my_dataset);
- VERIFY(is_empty, FALSE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, (new_format ? TRUE : FALSE), "H5O_is_attr_dense_test");
-
- if(new_format) {
+ ret = H5O__num_attrs_test(my_dataset, &nattrs);
+ CHECK(ret, FAIL, "H5O__num_attrs_test");
+ VERIFY(nattrs, (max_compact * 2), "H5O__num_attrs_test");
+ is_empty = H5O__is_attr_empty_test(my_dataset);
+ VERIFY(is_empty, FALSE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, (new_format ? TRUE : FALSE), "H5O__is_attr_dense_test");
+
+ if (new_format) {
/* Retrieve & verify # of records in the name & creation order indices */
- ret = H5O_attr_dense_info_test(my_dataset, &name_count, &corder_count);
- CHECK(ret, FAIL, "H5O_attr_dense_info_test");
- if(use_index)
- VERIFY(name_count, corder_count, "H5O_attr_dense_info_test");
- VERIFY(name_count, (max_compact * 2), "H5O_attr_dense_info_test");
+ ret = H5O__attr_dense_info_test(my_dataset, &name_count, &corder_count);
+ CHECK(ret, FAIL, "H5O__attr_dense_info_test");
+ if (use_index)
+ VERIFY(name_count, corder_count, "H5O__attr_dense_info_test");
+ VERIFY(name_count, (max_compact * 2), "H5O__attr_dense_info_test");
} /* end if */
- /* Check for opening a non-existant attribute on an object with dense attribute storage */
+ /* Check for opening a non-existent attribute on an object with dense attribute storage */
ret_id = H5Aopen(my_dataset, "foo", H5P_DEFAULT);
VERIFY(ret_id, FAIL, "H5Aopen");
@@ -7779,9 +8183,8 @@ test_attr_open_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl)
/* Close dataspace */
ret = H5Sclose(sid);
CHECK(ret, FAIL, "H5Sclose");
-} /* test_attr_open_by_name() */
+} /* test_attr_open_by_name() */
-
/****************************************************************
**
** test_attr_create_by_name(): Test basic H5A (attribute) code.
@@ -7791,42 +8194,48 @@ test_attr_open_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl)
static void
test_attr_create_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl)
{
- hid_t fid; /* HDF5 File ID */
- hid_t dset1, dset2, dset3; /* Dataset IDs */
- hid_t my_dataset; /* Current dataset ID */
- hid_t sid; /* Dataspace ID */
- hid_t attr; /* Attribute ID */
- hid_t dcpl; /* Dataset creation property list ID */
- unsigned max_compact; /* Maximum # of links to store in group compactly */
- unsigned min_dense; /* Minimum # of links to store in group "densely" */
- htri_t is_empty; /* Are there any attributes? */
- htri_t is_dense; /* Are attributes stored densely? */
- hsize_t nattrs; /* Number of attributes on object */
- hsize_t name_count; /* # of records in name index */
- hsize_t corder_count; /* # of records in creation order index */
- hbool_t use_index; /* Use index on creation order values */
- const char *dsetname; /* Name of dataset for attributes */
- char attrname[NAME_BUF_SIZE]; /* Name of attribute */
- unsigned curr_dset; /* Current dataset to work on */
- unsigned u; /* Local index variable */
- herr_t ret; /* Generic return value */
+ hid_t fid; /* HDF5 File ID */
+ hid_t dset1, dset2, dset3; /* Dataset IDs */
+ hid_t my_dataset; /* Current dataset ID */
+ hid_t sid; /* Dataspace ID */
+ hid_t attr; /* Attribute ID */
+ hid_t dcpl; /* Dataset creation property list ID */
+ unsigned max_compact; /* Maximum # of links to store in group compactly */
+ unsigned min_dense; /* Minimum # of links to store in group "densely" */
+ htri_t is_empty; /* Are there any attributes? */
+ htri_t is_dense; /* Are attributes stored densely? */
+ hsize_t nattrs; /* Number of attributes on object */
+ hsize_t name_count; /* # of records in name index */
+ hsize_t corder_count; /* # of records in creation order index */
+ unsigned use_index; /* Use index on creation order values */
+ const char *dsetname; /* Name of dataset for attributes */
+ char attrname[NAME_BUF_SIZE]; /* Name of attribute */
+ unsigned curr_dset; /* Current dataset to work on */
+ unsigned u; /* Local index variable */
+ herr_t ret; /* Generic return value */
/* Create dataspace for dataset & attributes */
sid = H5Screate(H5S_SCALAR);
CHECK(sid, FAIL, "H5Screate");
/* Create dataset creation property list */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ }
+ else {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
/* Query the attribute creation properties */
ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense);
CHECK(ret, FAIL, "H5Pget_attr_phase_change");
/* Loop over using index for creation order value */
- for(use_index = FALSE; use_index <= TRUE; use_index++) {
+ for (use_index = FALSE; use_index <= TRUE; use_index++) {
/* Print appropriate test message */
- if(use_index)
+ if (use_index)
MESSAGE(5, ("Testing Creating Attributes By Name w/Creation Order Index\n"))
else
MESSAGE(5, ("Testing Creating Attributes By Name w/o Creation Order Index\n"))
@@ -7836,8 +8245,9 @@ test_attr_create_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl)
CHECK(fid, FAIL, "H5Fcreate");
/* Set attribute creation order tracking & indexing for object */
- if(new_format == TRUE) {
- ret = H5Pset_attr_creation_order(dcpl, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0)));
+ if (new_format == TRUE) {
+ ret = H5Pset_attr_creation_order(
+ dcpl, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0)));
CHECK(ret, FAIL, "H5Pset_attr_creation_order");
} /* end if */
@@ -7850,21 +8260,21 @@ test_attr_create_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl)
CHECK(dset3, FAIL, "H5Dcreate2");
/* Work on all the datasets */
- for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
- switch(curr_dset) {
+ for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
+ switch (curr_dset) {
case 0:
my_dataset = dset1;
- dsetname = DSET1_NAME;
+ dsetname = DSET1_NAME;
break;
case 1:
my_dataset = dset2;
- dsetname = DSET2_NAME;
+ dsetname = DSET2_NAME;
break;
case 2:
my_dataset = dset3;
- dsetname = DSET3_NAME;
+ dsetname = DSET3_NAME;
break;
default:
@@ -7872,16 +8282,17 @@ test_attr_create_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl)
} /* end switch */
/* Check on dataset's attribute storage status */
- is_empty = H5O_is_attr_empty_test(my_dataset);
- VERIFY(is_empty, TRUE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ is_empty = H5O__is_attr_empty_test(my_dataset);
+ VERIFY(is_empty, TRUE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
/* Create attributes, up to limit of compact form */
- for(u = 0; u < max_compact; u++) {
+ for (u = 0; u < max_compact; u++) {
/* Create attribute */
- sprintf(attrname, "attr %02u", u);
- attr = H5Acreate_by_name(fid, dsetname, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
+ attr = H5Acreate_by_name(fid, dsetname, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT,
+ H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate_by_name");
/* Write data into the attribute */
@@ -7898,36 +8309,35 @@ test_attr_create_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl)
} /* end for */
/* Verify state of object */
- ret = H5O_num_attrs_test(my_dataset, &nattrs);
- CHECK(ret, FAIL, "H5O_num_attrs_test");
- VERIFY(nattrs, max_compact, "H5O_num_attrs_test");
- is_empty = H5O_is_attr_empty_test(my_dataset);
- VERIFY(is_empty, FALSE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ ret = H5O__num_attrs_test(my_dataset, &nattrs);
+ CHECK(ret, FAIL, "H5O__num_attrs_test");
+ VERIFY(nattrs, max_compact, "H5O__num_attrs_test");
+ is_empty = H5O__is_attr_empty_test(my_dataset);
+ VERIFY(is_empty, FALSE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
/* Test opening attributes stored compactly */
ret = attr_open_check(fid, dsetname, my_dataset, u);
CHECK(ret, FAIL, "attr_open_check");
} /* end for */
-
/* Work on all the datasets */
- for(curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
- switch(curr_dset) {
+ for (curr_dset = 0; curr_dset < NUM_DSETS; curr_dset++) {
+ switch (curr_dset) {
case 0:
my_dataset = dset1;
- dsetname = DSET1_NAME;
+ dsetname = DSET1_NAME;
break;
case 1:
my_dataset = dset2;
- dsetname = DSET2_NAME;
+ dsetname = DSET2_NAME;
break;
case 2:
my_dataset = dset3;
- dsetname = DSET3_NAME;
+ dsetname = DSET3_NAME;
break;
default:
@@ -7935,10 +8345,11 @@ test_attr_create_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl)
} /* end switch */
/* Create more attributes, to push into dense form */
- for(u = max_compact; u < (max_compact * 2); u++) {
+ for (u = max_compact; u < (max_compact * 2); u++) {
/* Create attribute */
- sprintf(attrname, "attr %02u", u);
- attr = H5Acreate_by_name(fid, dsetname, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
+ attr = H5Acreate_by_name(fid, dsetname, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT,
+ H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate_by_name");
/* Write data into the attribute */
@@ -7950,9 +8361,9 @@ test_attr_create_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Aclose");
/* Verify state of object */
- if(u >= max_compact) {
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, (new_format ? TRUE : FALSE), "H5O_is_attr_dense_test");
+ if (u >= max_compact) {
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, (new_format ? TRUE : FALSE), "H5O__is_attr_dense_test");
} /* end if */
/* Verify information for new attribute */
@@ -7961,21 +8372,21 @@ test_attr_create_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl)
} /* end for */
/* Verify state of object */
- ret = H5O_num_attrs_test(my_dataset, &nattrs);
- CHECK(ret, FAIL, "H5O_num_attrs_test");
- VERIFY(nattrs, (max_compact * 2), "H5O_num_attrs_test");
- is_empty = H5O_is_attr_empty_test(my_dataset);
- VERIFY(is_empty, FALSE, "H5O_is_attr_empty_test");
- is_dense = H5O_is_attr_dense_test(my_dataset);
- VERIFY(is_dense, (new_format ? TRUE : FALSE), "H5O_is_attr_dense_test");
-
- if(new_format) {
+ ret = H5O__num_attrs_test(my_dataset, &nattrs);
+ CHECK(ret, FAIL, "H5O__num_attrs_test");
+ VERIFY(nattrs, (max_compact * 2), "H5O__num_attrs_test");
+ is_empty = H5O__is_attr_empty_test(my_dataset);
+ VERIFY(is_empty, FALSE, "H5O__is_attr_empty_test");
+ is_dense = H5O__is_attr_dense_test(my_dataset);
+ VERIFY(is_dense, (new_format ? TRUE : FALSE), "H5O__is_attr_dense_test");
+
+ if (new_format) {
/* Retrieve & verify # of records in the name & creation order indices */
- ret = H5O_attr_dense_info_test(my_dataset, &name_count, &corder_count);
- CHECK(ret, FAIL, "H5O_attr_dense_info_test");
- if(use_index)
- VERIFY(name_count, corder_count, "H5O_attr_dense_info_test");
- VERIFY(name_count, (max_compact * 2), "H5O_attr_dense_info_test");
+ ret = H5O__attr_dense_info_test(my_dataset, &name_count, &corder_count);
+ CHECK(ret, FAIL, "H5O__attr_dense_info_test");
+ if (use_index)
+ VERIFY(name_count, corder_count, "H5O__attr_dense_info_test");
+ VERIFY(name_count, (max_compact * 2), "H5O__attr_dense_info_test");
} /* end if */
/* Test opening attributes stored compactly */
@@ -8003,7 +8414,7 @@ test_attr_create_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl)
/* Close dataspace */
ret = H5Sclose(sid);
CHECK(ret, FAIL, "H5Sclose");
-} /* test_attr_create_by_name() */
+} /* test_attr_create_by_name() */
/****************************************************************
**
@@ -8014,34 +8425,36 @@ test_attr_create_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl)
static void
test_attr_shared_write(hid_t fcpl, hid_t fapl)
{
- hid_t fid; /* File ID */
- hid_t my_fcpl; /* File creation property list ID */
- hid_t dataset, dataset2; /* Dataset IDs */
- hid_t attr_tid; /* Attribute's datatype ID */
- hid_t sid, big_sid; /* Dataspace IDs */
- hsize_t big_dims[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; /* Dimensions for "big" attribute */
- hid_t attr; /* Attribute ID */
- hid_t dcpl; /* Dataset creation property list ID */
- char attrname[NAME_BUF_SIZE]; /* Name of attribute */
- unsigned max_compact; /* Maximum # of attributes to store compactly */
- unsigned min_dense; /* Minimum # of attributes to store "densely" */
- htri_t is_dense; /* Are attributes stored densely? */
- htri_t is_shared; /* Is attributes shared? */
- hsize_t shared_refcount; /* Reference count of shared attribute */
- unsigned attr_value; /* Attribute value */
- unsigned big_value[SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3]; /* Data for "big" attribute */
- size_t mesg_count; /* # of shared messages */
- unsigned test_shared; /* Index over shared component type */
- unsigned u; /* Local index variable */
- h5_stat_size_t empty_filesize; /* Size of empty file */
- h5_stat_size_t filesize; /* Size of file after modifications */
- herr_t ret; /* Generic return value */
+ hid_t fid; /* File ID */
+ hid_t my_fcpl; /* File creation property list ID */
+ hid_t dataset, dataset2; /* Dataset IDs */
+ hid_t attr_tid; /* Attribute's datatype ID */
+ hid_t sid, big_sid; /* Dataspace IDs */
+ hsize_t big_dims[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; /* Dimensions for "big" attribute */
+ hid_t attr; /* Attribute ID */
+ hid_t dcpl; /* Dataset creation property list ID */
+ char attrname[NAME_BUF_SIZE]; /* Name of attribute */
+ unsigned max_compact; /* Maximum # of attributes to store compactly */
+ unsigned min_dense; /* Minimum # of attributes to store "densely" */
+ htri_t is_dense; /* Are attributes stored densely? */
+ htri_t is_shared; /* Is attributes shared? */
+ hsize_t shared_refcount; /* Reference count of shared attribute */
+ unsigned attr_value; /* Attribute value */
+ unsigned *big_value; /* Data for "big" attribute */
+ size_t mesg_count; /* # of shared messages */
+ unsigned test_shared; /* Index over shared component type */
+ unsigned u; /* Local index variable */
+ h5_stat_size_t empty_filesize; /* Size of empty file */
+ h5_stat_size_t filesize; /* Size of file after modifications */
+ herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Writing Shared & Unshared Attributes in Compact & Dense Storage\n"));
- /* Initialize "big" attribute data */
- HDmemset(big_value, 1, sizeof(big_value));
+ /* Allocate & initialize "big" attribute data */
+ big_value = (unsigned *)HDmalloc((size_t)(SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3) * sizeof(unsigned));
+ CHECK_PTR(big_value, "HDmalloc");
+ HDmemset(big_value, 1, sizeof(unsigned) * (size_t)(SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3));
/* Create dataspace for dataset */
sid = H5Screate(H5S_SCALAR);
@@ -8052,7 +8465,7 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl)
CHECK(big_sid, FAIL, "H5Screate_simple");
/* Loop over type of shared components */
- for(test_shared = 0; test_shared < 3; test_shared++) {
+ for (test_shared = 0; test_shared < 3; test_shared++) {
/* Make copy of file creation property list */
my_fcpl = H5Pcopy(fcpl);
CHECK(my_fcpl, FAIL, "H5Pcopy");
@@ -8062,7 +8475,7 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl)
CHECK(attr_tid, FAIL, "H5Tcopy");
/* Special setup for each type of shared components */
- if(test_shared == 0) {
+ if (test_shared == 0) {
/* Make attributes > 500 bytes shared */
ret = H5Pset_shared_mesg_nindexes(my_fcpl, (unsigned)1);
CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
@@ -8100,23 +8513,28 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl)
/* Get size of file */
empty_filesize = h5_get_file_size(FILENAME, fapl);
- if(empty_filesize < 0)
+ if (empty_filesize < 0)
TestErrPrintf("Line %d: file size wrong!\n", __LINE__);
-
/* Re-open file */
fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
CHECK(fid, FAIL, "H5Fopen");
/* Commit datatype to file */
- if(test_shared == 2) {
+ if (test_shared == 2) {
ret = H5Tcommit2(fid, TYPE1_NAME, attr_tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Tcommit2");
} /* end if */
/* Set up to query the object creation properties */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ }
+ else {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
/* Create datasets */
dataset = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT);
@@ -8125,16 +8543,16 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl)
CHECK(dataset2, FAIL, "H5Dcreate2");
/* Check on dataset's message storage status */
- if(test_shared != 0) {
+ if (test_shared != 0) {
/* Datasets' datatypes can be shared */
- ret = H5F_get_sohm_mesg_count_test(fid, H5O_DTYPE_ID, &mesg_count);
- CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test");
- VERIFY(mesg_count, 1, "H5F_get_sohm_mesg_count_test");
+ ret = H5F__get_sohm_mesg_count_test(fid, H5O_DTYPE_ID, &mesg_count);
+ CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test");
+ VERIFY(mesg_count, 1, "H5F__get_sohm_mesg_count_test");
/* Datasets' dataspace can be shared */
- ret = H5F_get_sohm_mesg_count_test(fid, H5O_SDSPACE_ID, &mesg_count);
- CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test");
- VERIFY(mesg_count, 1, "H5F_get_sohm_mesg_count_test");
+ ret = H5F__get_sohm_mesg_count_test(fid, H5O_SDSPACE_ID, &mesg_count);
+ CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test");
+ VERIFY(mesg_count, 1, "H5F__get_sohm_mesg_count_test");
} /* end if */
/* Retrieve limits for compact/dense attribute storage */
@@ -8146,29 +8564,29 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Pclose");
/* Check on datasets' attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
- is_dense = H5O_is_attr_dense_test(dataset2);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
+ is_dense = H5O__is_attr_dense_test(dataset2);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
/* Add attributes to each dataset, until after converting to dense storage */
- for(u = 0; u < max_compact * 2; u++) {
+ for (u = 0; u < max_compact * 2; u++) {
/* Create attribute name */
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
/* Alternate between creating "small" & "big" attributes */
- if(u % 2) {
+ if (u % 2) {
/* Create "small" attribute on first dataset */
attr = H5Acreate2(dataset, attrname, attr_tid, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
/* Check that attribute is not shared */
- is_shared = H5A_is_shared_test(attr);
- VERIFY(is_shared, FALSE, "H5A_is_shared_test");
+ is_shared = H5A__is_shared_test(attr);
+ VERIFY(is_shared, FALSE, "H5A__is_shared_test");
/* Write data into the attribute */
attr_value = u + 1;
- ret = H5Awrite(attr, attr_tid, &attr_value);
+ ret = H5Awrite(attr, attr_tid, &attr_value);
CHECK(ret, FAIL, "H5Awrite");
} /* end if */
else {
@@ -8177,23 +8595,23 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl)
CHECK(attr, FAIL, "H5Acreate2");
/* Check that attribute is shared */
- is_shared = H5A_is_shared_test(attr);
- VERIFY(is_shared, TRUE, "H5A_is_shared_test");
+ is_shared = H5A__is_shared_test(attr);
+ VERIFY(is_shared, TRUE, "H5A__is_shared_test");
/* Check refcount for attribute */
- ret = H5A_get_shared_rc_test(attr, &shared_refcount);
- CHECK(ret, FAIL, "H5A_get_shared_rc_test");
- VERIFY(shared_refcount, 1, "H5A_get_shared_rc_test");
+ ret = H5A__get_shared_rc_test(attr, &shared_refcount);
+ CHECK(ret, FAIL, "H5A__get_shared_rc_test");
+ VERIFY(shared_refcount, 1, "H5A__get_shared_rc_test");
/* Write data into the attribute */
big_value[0] = u + 1;
- ret = H5Awrite(attr, attr_tid, big_value);
+ ret = H5Awrite(attr, attr_tid, big_value);
CHECK(ret, FAIL, "H5Awrite");
/* Check refcount for attribute */
- ret = H5A_get_shared_rc_test(attr, &shared_refcount);
- CHECK(ret, FAIL, "H5A_get_shared_rc_test");
- VERIFY(shared_refcount, 1, "H5A_get_shared_rc_test");
+ ret = H5A__get_shared_rc_test(attr, &shared_refcount);
+ CHECK(ret, FAIL, "H5A__get_shared_rc_test");
+ VERIFY(shared_refcount, 1, "H5A__get_shared_rc_test");
} /* end else */
/* Close attribute */
@@ -8201,26 +8619,25 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Aclose");
/* Check on dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset);
- if(u < max_compact)
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ is_dense = H5O__is_attr_dense_test(dataset);
+ if (u < max_compact)
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
else
- VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
-
+ VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test");
/* Alternate between creating "small" & "big" attributes */
- if(u % 2) {
+ if (u % 2) {
/* Create "small" attribute on second dataset */
attr = H5Acreate2(dataset2, attrname, attr_tid, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
/* Check that attribute is not shared */
- is_shared = H5A_is_shared_test(attr);
- VERIFY(is_shared, FALSE, "H5A_is_shared_test");
+ is_shared = H5A__is_shared_test(attr);
+ VERIFY(is_shared, FALSE, "H5A__is_shared_test");
/* Write data into the attribute */
attr_value = u + 1;
- ret = H5Awrite(attr, attr_tid, &attr_value);
+ ret = H5Awrite(attr, attr_tid, &attr_value);
CHECK(ret, FAIL, "H5Awrite");
} /* end if */
else {
@@ -8229,23 +8646,23 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl)
CHECK(attr, FAIL, "H5Acreate2");
/* Check that attribute is shared */
- is_shared = H5A_is_shared_test(attr);
- VERIFY(is_shared, TRUE, "H5A_is_shared_test");
+ is_shared = H5A__is_shared_test(attr);
+ VERIFY(is_shared, TRUE, "H5A__is_shared_test");
/* Check refcount for attribute */
- ret = H5A_get_shared_rc_test(attr, &shared_refcount);
- CHECK(ret, FAIL, "H5A_get_shared_rc_test");
- VERIFY(shared_refcount, 1, "H5A_get_shared_rc_test");
+ ret = H5A__get_shared_rc_test(attr, &shared_refcount);
+ CHECK(ret, FAIL, "H5A__get_shared_rc_test");
+ VERIFY(shared_refcount, 1, "H5A__get_shared_rc_test");
/* Write data into the attribute */
big_value[0] = u + 1;
- ret = H5Awrite(attr, attr_tid, big_value);
+ ret = H5Awrite(attr, attr_tid, big_value);
CHECK(ret, FAIL, "H5Awrite");
/* Check refcount for attribute */
- ret = H5A_get_shared_rc_test(attr, &shared_refcount);
- CHECK(ret, FAIL, "H5A_get_shared_rc_test");
- VERIFY(shared_refcount, 2, "H5A_get_shared_rc_test");
+ ret = H5A__get_shared_rc_test(attr, &shared_refcount);
+ CHECK(ret, FAIL, "H5A__get_shared_rc_test");
+ VERIFY(shared_refcount, 2, "H5A__get_shared_rc_test");
} /* end else */
/* Close attribute */
@@ -8253,11 +8670,11 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Aclose");
/* Check on dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset2);
- if(u < max_compact)
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ is_dense = H5O__is_attr_dense_test(dataset2);
+ if (u < max_compact)
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
else
- VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
+ VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test");
} /* end for */
/* Close attribute's datatype */
@@ -8271,18 +8688,18 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Dclose");
/* Check on shared message status now */
- if(test_shared != 0) {
- if(test_shared == 1) {
+ if (test_shared != 0) {
+ if (test_shared == 1) {
/* Check on datatype storage status */
- ret = H5F_get_sohm_mesg_count_test(fid, H5O_DTYPE_ID, &mesg_count);
- CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test");
- VERIFY(mesg_count, 2, "H5F_get_sohm_mesg_count_test");
+ ret = H5F__get_sohm_mesg_count_test(fid, H5O_DTYPE_ID, &mesg_count);
+ CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test");
+ VERIFY(mesg_count, 2, "H5F__get_sohm_mesg_count_test");
} /* end if */
/* Check on dataspace storage status */
- ret = H5F_get_sohm_mesg_count_test(fid, H5O_SDSPACE_ID, &mesg_count);
- CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test");
- VERIFY(mesg_count, 2, "H5F_get_sohm_mesg_count_test");
+ ret = H5F__get_sohm_mesg_count_test(fid, H5O_SDSPACE_ID, &mesg_count);
+ CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test");
+ VERIFY(mesg_count, 2, "H5F__get_sohm_mesg_count_test");
} /* end if */
/* Unlink datasets with attributes */
@@ -8292,35 +8709,37 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Ldelete");
/* Unlink committed datatype */
- if(test_shared == 2) {
+ if (test_shared == 2) {
ret = H5Ldelete(fid, TYPE1_NAME, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Ldelete");
} /* end if */
/* Check on attribute storage status */
- ret = H5F_get_sohm_mesg_count_test(fid, H5O_ATTR_ID, &mesg_count);
- CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test");
- VERIFY(mesg_count, 0, "H5F_get_sohm_mesg_count_test");
+ ret = H5F__get_sohm_mesg_count_test(fid, H5O_ATTR_ID, &mesg_count);
+ CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test");
+ VERIFY(mesg_count, 0, "H5F__get_sohm_mesg_count_test");
- if(test_shared != 0) {
+ if (test_shared != 0) {
/* Check on datatype storage status */
- ret = H5F_get_sohm_mesg_count_test(fid, H5O_DTYPE_ID, &mesg_count);
- CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test");
- VERIFY(mesg_count, 0, "H5F_get_sohm_mesg_count_test");
+ ret = H5F__get_sohm_mesg_count_test(fid, H5O_DTYPE_ID, &mesg_count);
+ CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test");
+ VERIFY(mesg_count, 0, "H5F__get_sohm_mesg_count_test");
/* Check on dataspace storage status */
- ret = H5F_get_sohm_mesg_count_test(fid, H5O_SDSPACE_ID, &mesg_count);
- CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test");
- VERIFY(mesg_count, 0, "H5F_get_sohm_mesg_count_test");
+ ret = H5F__get_sohm_mesg_count_test(fid, H5O_SDSPACE_ID, &mesg_count);
+ CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test");
+ VERIFY(mesg_count, 0, "H5F__get_sohm_mesg_count_test");
} /* end if */
/* Close file */
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
- /* Check size of file */
- filesize = h5_get_file_size(FILENAME, fapl);
- VERIFY(filesize, empty_filesize, "h5_get_file_size");
+ if (h5_using_default_driver(NULL)) {
+ /* Check size of file */
+ filesize = h5_get_file_size(FILENAME, fapl);
+ VERIFY(filesize, empty_filesize, "h5_get_file_size");
+ }
} /* end for */
/* Close dataspaces */
@@ -8328,7 +8747,10 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Sclose");
ret = H5Sclose(big_sid);
CHECK(ret, FAIL, "H5Sclose");
-} /* test_attr_shared_write() */
+
+ /* Release memory */
+ HDfree(big_value);
+} /* test_attr_shared_write() */
/****************************************************************
**
@@ -8339,35 +8761,37 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl)
static void
test_attr_shared_rename(hid_t fcpl, hid_t fapl)
{
- hid_t fid; /* HDF5 File ID */
- hid_t my_fcpl; /* File creation property list ID */
- hid_t dataset, dataset2; /* Dataset ID2 */
- hid_t attr_tid; /* Attribute's datatype ID */
- hid_t sid, big_sid; /* Dataspace IDs */
- hsize_t big_dims[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; /* Dimensions for "big" attribute */
- hid_t attr; /* Attribute ID */
- hid_t dcpl; /* Dataset creation property list ID */
- char attrname[NAME_BUF_SIZE]; /* Name of attribute on first dataset */
- char attrname2[NAME_BUF_SIZE]; /* Name of attribute on second dataset */
- unsigned max_compact; /* Maximum # of attributes to store compactly */
- unsigned min_dense; /* Minimum # of attributes to store "densely" */
- htri_t is_dense; /* Are attributes stored densely? */
- htri_t is_shared; /* Is attributes shared? */
- hsize_t shared_refcount; /* Reference count of shared attribute */
- unsigned attr_value; /* Attribute value */
- unsigned big_value[SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3]; /* Data for "big" attribute */
- size_t mesg_count; /* # of shared messages */
- unsigned test_shared; /* Index over shared component type */
- unsigned u; /* Local index variable */
- h5_stat_size_t empty_filesize; /* Size of empty file */
- h5_stat_size_t filesize; /* Size of file after modifications */
- herr_t ret; /* Generic return value */
+ hid_t fid; /* HDF5 File ID */
+ hid_t my_fcpl; /* File creation property list ID */
+ hid_t dataset, dataset2; /* Dataset ID2 */
+ hid_t attr_tid; /* Attribute's datatype ID */
+ hid_t sid, big_sid; /* Dataspace IDs */
+ hsize_t big_dims[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; /* Dimensions for "big" attribute */
+ hid_t attr; /* Attribute ID */
+ hid_t dcpl; /* Dataset creation property list ID */
+ char attrname[NAME_BUF_SIZE]; /* Name of attribute on first dataset */
+ char attrname2[NAME_BUF_SIZE]; /* Name of attribute on second dataset */
+ unsigned max_compact; /* Maximum # of attributes to store compactly */
+ unsigned min_dense; /* Minimum # of attributes to store "densely" */
+ htri_t is_dense; /* Are attributes stored densely? */
+ htri_t is_shared; /* Is attributes shared? */
+ hsize_t shared_refcount; /* Reference count of shared attribute */
+ unsigned attr_value; /* Attribute value */
+ unsigned *big_value; /* Data for "big" attribute */
+ size_t mesg_count; /* # of shared messages */
+ unsigned test_shared; /* Index over shared component type */
+ unsigned u; /* Local index variable */
+ h5_stat_size_t empty_filesize; /* Size of empty file */
+ h5_stat_size_t filesize; /* Size of file after modifications */
+ herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Renaming Shared & Unshared Attributes in Compact & Dense Storage\n"));
- /* Initialize "big" attribute data */
- HDmemset(big_value, 1, sizeof(big_value));
+ /* Allocate & initialize "big" attribute data */
+ big_value = (unsigned *)HDmalloc((size_t)(SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3) * sizeof(unsigned));
+ CHECK_PTR(big_value, "HDmalloc");
+ HDmemset(big_value, 1, sizeof(unsigned) * (size_t)(SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3));
/* Create dataspace for dataset */
sid = H5Screate(H5S_SCALAR);
@@ -8378,7 +8802,7 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl)
CHECK(big_sid, FAIL, "H5Screate_simple");
/* Loop over type of shared components */
- for(test_shared = 0; test_shared < 3; test_shared++) {
+ for (test_shared = 0; test_shared < 3; test_shared++) {
/* Make copy of file creation property list */
my_fcpl = H5Pcopy(fcpl);
CHECK(my_fcpl, FAIL, "H5Pcopy");
@@ -8388,7 +8812,7 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl)
CHECK(attr_tid, FAIL, "H5Tcopy");
/* Special setup for each type of shared components */
- if(test_shared == 0) {
+ if (test_shared == 0) {
/* Make attributes > 500 bytes shared */
ret = H5Pset_shared_mesg_nindexes(my_fcpl, (unsigned)1);
CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
@@ -8426,23 +8850,28 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl)
/* Get size of file */
empty_filesize = h5_get_file_size(FILENAME, fapl);
- if(empty_filesize < 0)
+ if (empty_filesize < 0)
TestErrPrintf("Line %d: file size wrong!\n", __LINE__);
-
/* Re-open file */
fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
CHECK(fid, FAIL, "H5Fopen");
/* Commit datatype to file */
- if(test_shared == 2) {
+ if (test_shared == 2) {
ret = H5Tcommit2(fid, TYPE1_NAME, attr_tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Tcommit2");
} /* end if */
/* Set up to query the object creation properties */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ }
+ else {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
/* Create datasets */
dataset = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT);
@@ -8451,16 +8880,16 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl)
CHECK(dataset2, FAIL, "H5Dcreate2");
/* Check on dataset's message storage status */
- if(test_shared != 0) {
+ if (test_shared != 0) {
/* Datasets' datatypes can be shared */
- ret = H5F_get_sohm_mesg_count_test(fid, H5O_DTYPE_ID, &mesg_count);
- CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test");
- VERIFY(mesg_count, 1, "H5F_get_sohm_mesg_count_test");
+ ret = H5F__get_sohm_mesg_count_test(fid, H5O_DTYPE_ID, &mesg_count);
+ CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test");
+ VERIFY(mesg_count, 1, "H5F__get_sohm_mesg_count_test");
/* Datasets' dataspace can be shared */
- ret = H5F_get_sohm_mesg_count_test(fid, H5O_SDSPACE_ID, &mesg_count);
- CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test");
- VERIFY(mesg_count, 1, "H5F_get_sohm_mesg_count_test");
+ ret = H5F__get_sohm_mesg_count_test(fid, H5O_SDSPACE_ID, &mesg_count);
+ CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test");
+ VERIFY(mesg_count, 1, "H5F__get_sohm_mesg_count_test");
} /* end if */
/* Retrieve limits for compact/dense attribute storage */
@@ -8472,29 +8901,29 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Pclose");
/* Check on datasets' attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
- is_dense = H5O_is_attr_dense_test(dataset2);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
+ is_dense = H5O__is_attr_dense_test(dataset2);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
/* Add attributes to each dataset, until after converting to dense storage */
- for(u = 0; u < max_compact * 2; u++) {
+ for (u = 0; u < max_compact * 2; u++) {
/* Create attribute name */
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
/* Alternate between creating "small" & "big" attributes */
- if(u % 2) {
+ if (u % 2) {
/* Create "small" attribute on first dataset */
attr = H5Acreate2(dataset, attrname, attr_tid, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
/* Check that attribute is not shared */
- is_shared = H5A_is_shared_test(attr);
- VERIFY(is_shared, FALSE, "H5A_is_shared_test");
+ is_shared = H5A__is_shared_test(attr);
+ VERIFY(is_shared, FALSE, "H5A__is_shared_test");
/* Write data into the attribute */
attr_value = u + 1;
- ret = H5Awrite(attr, attr_tid, &attr_value);
+ ret = H5Awrite(attr, attr_tid, &attr_value);
CHECK(ret, FAIL, "H5Awrite");
} /* end if */
else {
@@ -8503,23 +8932,23 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl)
CHECK(attr, FAIL, "H5Acreate2");
/* Check that attribute is shared */
- is_shared = H5A_is_shared_test(attr);
- VERIFY(is_shared, TRUE, "H5A_is_shared_test");
+ is_shared = H5A__is_shared_test(attr);
+ VERIFY(is_shared, TRUE, "H5A__is_shared_test");
/* Check refcount for attribute */
- ret = H5A_get_shared_rc_test(attr, &shared_refcount);
- CHECK(ret, FAIL, "H5A_get_shared_rc_test");
- VERIFY(shared_refcount, 1, "H5A_get_shared_rc_test");
+ ret = H5A__get_shared_rc_test(attr, &shared_refcount);
+ CHECK(ret, FAIL, "H5A__get_shared_rc_test");
+ VERIFY(shared_refcount, 1, "H5A__get_shared_rc_test");
/* Write data into the attribute */
big_value[0] = u + 1;
- ret = H5Awrite(attr, attr_tid, big_value);
+ ret = H5Awrite(attr, attr_tid, big_value);
CHECK(ret, FAIL, "H5Awrite");
/* Check refcount for attribute */
- ret = H5A_get_shared_rc_test(attr, &shared_refcount);
- CHECK(ret, FAIL, "H5A_get_shared_rc_test");
- VERIFY(shared_refcount, 1, "H5A_get_shared_rc_test");
+ ret = H5A__get_shared_rc_test(attr, &shared_refcount);
+ CHECK(ret, FAIL, "H5A__get_shared_rc_test");
+ VERIFY(shared_refcount, 1, "H5A__get_shared_rc_test");
} /* end else */
/* Close attribute */
@@ -8527,26 +8956,25 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Aclose");
/* Check on dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset);
- if(u < max_compact)
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ is_dense = H5O__is_attr_dense_test(dataset);
+ if (u < max_compact)
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
else
- VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
-
+ VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test");
/* Alternate between creating "small" & "big" attributes */
- if(u % 2) {
+ if (u % 2) {
/* Create "small" attribute on second dataset */
attr = H5Acreate2(dataset2, attrname, attr_tid, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
/* Check that attribute is not shared */
- is_shared = H5A_is_shared_test(attr);
- VERIFY(is_shared, FALSE, "H5A_is_shared_test");
+ is_shared = H5A__is_shared_test(attr);
+ VERIFY(is_shared, FALSE, "H5A__is_shared_test");
/* Write data into the attribute */
attr_value = u + 1;
- ret = H5Awrite(attr, attr_tid, &attr_value);
+ ret = H5Awrite(attr, attr_tid, &attr_value);
CHECK(ret, FAIL, "H5Awrite");
} /* end if */
else {
@@ -8555,23 +8983,23 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl)
CHECK(attr, FAIL, "H5Acreate2");
/* Check that attribute is shared */
- is_shared = H5A_is_shared_test(attr);
- VERIFY(is_shared, TRUE, "H5A_is_shared_test");
+ is_shared = H5A__is_shared_test(attr);
+ VERIFY(is_shared, TRUE, "H5A__is_shared_test");
/* Check refcount for attribute */
- ret = H5A_get_shared_rc_test(attr, &shared_refcount);
- CHECK(ret, FAIL, "H5A_get_shared_rc_test");
- VERIFY(shared_refcount, 1, "H5A_get_shared_rc_test");
+ ret = H5A__get_shared_rc_test(attr, &shared_refcount);
+ CHECK(ret, FAIL, "H5A__get_shared_rc_test");
+ VERIFY(shared_refcount, 1, "H5A__get_shared_rc_test");
/* Write data into the attribute */
big_value[0] = u + 1;
- ret = H5Awrite(attr, attr_tid, big_value);
+ ret = H5Awrite(attr, attr_tid, big_value);
CHECK(ret, FAIL, "H5Awrite");
/* Check refcount for attribute */
- ret = H5A_get_shared_rc_test(attr, &shared_refcount);
- CHECK(ret, FAIL, "H5A_get_shared_rc_test");
- VERIFY(shared_refcount, 2, "H5A_get_shared_rc_test");
+ ret = H5A__get_shared_rc_test(attr, &shared_refcount);
+ CHECK(ret, FAIL, "H5A__get_shared_rc_test");
+ VERIFY(shared_refcount, 2, "H5A__get_shared_rc_test");
} /* end else */
/* Close attribute */
@@ -8579,41 +9007,39 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Aclose");
/* Check on dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset2);
- if(u < max_compact)
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ is_dense = H5O__is_attr_dense_test(dataset2);
+ if (u < max_compact)
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
else
- VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
-
+ VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test");
/* Create new attribute name */
- sprintf(attrname2, "new attr %02u", u);
+ HDsnprintf(attrname2, sizeof(attrname2), "new attr %02u", u);
/* Change second dataset's attribute's name */
ret = H5Arename_by_name(fid, DSET2_NAME, attrname, attrname2, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Arename_by_name");
-
/* Check refcount on attributes now */
/* Check refcount on renamed attribute */
attr = H5Aopen(dataset2, attrname2, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Aopen");
- if(u % 2) {
+ if (u % 2) {
/* Check that attribute is not shared */
- is_shared = H5A_is_shared_test(attr);
- VERIFY(is_shared, FALSE, "H5A_is_shared_test");
+ is_shared = H5A__is_shared_test(attr);
+ VERIFY(is_shared, FALSE, "H5A__is_shared_test");
} /* end if */
else {
/* Check that attribute is shared */
- is_shared = H5A_is_shared_test(attr);
- VERIFY(is_shared, TRUE, "H5A_is_shared_test");
+ is_shared = H5A__is_shared_test(attr);
+ VERIFY(is_shared, TRUE, "H5A__is_shared_test");
/* Check refcount for attribute */
- ret = H5A_get_shared_rc_test(attr, &shared_refcount);
- CHECK(ret, FAIL, "H5A_get_shared_rc_test");
- VERIFY(shared_refcount, 1, "H5A_get_shared_rc_test");
+ ret = H5A__get_shared_rc_test(attr, &shared_refcount);
+ CHECK(ret, FAIL, "H5A__get_shared_rc_test");
+ VERIFY(shared_refcount, 1, "H5A__get_shared_rc_test");
} /* end else */
/* Close attribute */
@@ -8624,52 +9050,50 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl)
attr = H5Aopen(dataset, attrname, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Aopen");
- if(u % 2) {
+ if (u % 2) {
/* Check that attribute is not shared */
- is_shared = H5A_is_shared_test(attr);
- VERIFY(is_shared, FALSE, "H5A_is_shared_test");
+ is_shared = H5A__is_shared_test(attr);
+ VERIFY(is_shared, FALSE, "H5A__is_shared_test");
} /* end if */
else {
/* Check that attribute is shared */
- is_shared = H5A_is_shared_test(attr);
- VERIFY(is_shared, TRUE, "H5A_is_shared_test");
+ is_shared = H5A__is_shared_test(attr);
+ VERIFY(is_shared, TRUE, "H5A__is_shared_test");
/* Check refcount for attribute */
- ret = H5A_get_shared_rc_test(attr, &shared_refcount);
- CHECK(ret, FAIL, "H5A_get_shared_rc_test");
- VERIFY(shared_refcount, 1, "H5A_get_shared_rc_test");
+ ret = H5A__get_shared_rc_test(attr, &shared_refcount);
+ CHECK(ret, FAIL, "H5A__get_shared_rc_test");
+ VERIFY(shared_refcount, 1, "H5A__get_shared_rc_test");
} /* end else */
/* Close attribute */
ret = H5Aclose(attr);
CHECK(ret, FAIL, "H5Aclose");
-
/* Change second dataset's attribute's name back to original */
ret = H5Arename_by_name(fid, DSET2_NAME, attrname2, attrname, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Arename_by_name");
-
/* Check refcount on attributes now */
/* Check refcount on renamed attribute */
attr = H5Aopen(dataset2, attrname, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Aopen");
- if(u % 2) {
+ if (u % 2) {
/* Check that attribute is not shared */
- is_shared = H5A_is_shared_test(attr);
- VERIFY(is_shared, FALSE, "H5A_is_shared_test");
+ is_shared = H5A__is_shared_test(attr);
+ VERIFY(is_shared, FALSE, "H5A__is_shared_test");
} /* end if */
else {
/* Check that attribute is shared */
- is_shared = H5A_is_shared_test(attr);
- VERIFY(is_shared, TRUE, "H5A_is_shared_test");
+ is_shared = H5A__is_shared_test(attr);
+ VERIFY(is_shared, TRUE, "H5A__is_shared_test");
/* Check refcount for attribute */
- ret = H5A_get_shared_rc_test(attr, &shared_refcount);
- CHECK(ret, FAIL, "H5A_get_shared_rc_test");
- VERIFY(shared_refcount, 2, "H5A_get_shared_rc_test");
+ ret = H5A__get_shared_rc_test(attr, &shared_refcount);
+ CHECK(ret, FAIL, "H5A__get_shared_rc_test");
+ VERIFY(shared_refcount, 2, "H5A__get_shared_rc_test");
} /* end else */
/* Close attribute */
@@ -8680,20 +9104,20 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl)
attr = H5Aopen(dataset, attrname, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Aopen");
- if(u % 2) {
+ if (u % 2) {
/* Check that attribute is not shared */
- is_shared = H5A_is_shared_test(attr);
- VERIFY(is_shared, FALSE, "H5A_is_shared_test");
+ is_shared = H5A__is_shared_test(attr);
+ VERIFY(is_shared, FALSE, "H5A__is_shared_test");
} /* end if */
else {
/* Check that attribute is shared */
- is_shared = H5A_is_shared_test(attr);
- VERIFY(is_shared, TRUE, "H5A_is_shared_test");
+ is_shared = H5A__is_shared_test(attr);
+ VERIFY(is_shared, TRUE, "H5A__is_shared_test");
/* Check refcount for attribute */
- ret = H5A_get_shared_rc_test(attr, &shared_refcount);
- CHECK(ret, FAIL, "H5A_get_shared_rc_test");
- VERIFY(shared_refcount, 2, "H5A_get_shared_rc_test");
+ ret = H5A__get_shared_rc_test(attr, &shared_refcount);
+ CHECK(ret, FAIL, "H5A__get_shared_rc_test");
+ VERIFY(shared_refcount, 2, "H5A__get_shared_rc_test");
} /* end else */
/* Close attribute */
@@ -8701,7 +9125,6 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Aclose");
} /* end for */
-
/* Close attribute's datatype */
ret = H5Tclose(attr_tid);
CHECK(ret, FAIL, "H5Tclose");
@@ -8713,18 +9136,18 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Dclose");
/* Check on shared message status now */
- if(test_shared != 0) {
- if(test_shared == 1) {
+ if (test_shared != 0) {
+ if (test_shared == 1) {
/* Check on datatype storage status */
- ret = H5F_get_sohm_mesg_count_test(fid, H5O_DTYPE_ID, &mesg_count);
- CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test");
- VERIFY(mesg_count, 2, "H5F_get_sohm_mesg_count_test");
+ ret = H5F__get_sohm_mesg_count_test(fid, H5O_DTYPE_ID, &mesg_count);
+ CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test");
+ VERIFY(mesg_count, 2, "H5F__get_sohm_mesg_count_test");
} /* end if */
/* Check on dataspace storage status */
- ret = H5F_get_sohm_mesg_count_test(fid, H5O_SDSPACE_ID, &mesg_count);
- CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test");
- VERIFY(mesg_count, 2, "H5F_get_sohm_mesg_count_test");
+ ret = H5F__get_sohm_mesg_count_test(fid, H5O_SDSPACE_ID, &mesg_count);
+ CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test");
+ VERIFY(mesg_count, 2, "H5F__get_sohm_mesg_count_test");
} /* end if */
/* Unlink datasets with attributes */
@@ -8734,35 +9157,37 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Ldelete");
/* Unlink committed datatype */
- if(test_shared == 2) {
+ if (test_shared == 2) {
ret = H5Ldelete(fid, TYPE1_NAME, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Ldelete");
} /* end if */
/* Check on attribute storage status */
- ret = H5F_get_sohm_mesg_count_test(fid, H5O_ATTR_ID, &mesg_count);
- CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test");
- VERIFY(mesg_count, 0, "H5F_get_sohm_mesg_count_test");
+ ret = H5F__get_sohm_mesg_count_test(fid, H5O_ATTR_ID, &mesg_count);
+ CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test");
+ VERIFY(mesg_count, 0, "H5F__get_sohm_mesg_count_test");
- if(test_shared != 0) {
+ if (test_shared != 0) {
/* Check on datatype storage status */
- ret = H5F_get_sohm_mesg_count_test(fid, H5O_DTYPE_ID, &mesg_count);
- CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test");
- VERIFY(mesg_count, 0, "H5F_get_sohm_mesg_count_test");
+ ret = H5F__get_sohm_mesg_count_test(fid, H5O_DTYPE_ID, &mesg_count);
+ CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test");
+ VERIFY(mesg_count, 0, "H5F__get_sohm_mesg_count_test");
/* Check on dataspace storage status */
- ret = H5F_get_sohm_mesg_count_test(fid, H5O_SDSPACE_ID, &mesg_count);
- CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test");
- VERIFY(mesg_count, 0, "H5F_get_sohm_mesg_count_test");
+ ret = H5F__get_sohm_mesg_count_test(fid, H5O_SDSPACE_ID, &mesg_count);
+ CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test");
+ VERIFY(mesg_count, 0, "H5F__get_sohm_mesg_count_test");
} /* end if */
/* Close file */
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
- /* Check size of file */
- filesize = h5_get_file_size(FILENAME, fapl);
- VERIFY(filesize, empty_filesize, "h5_get_file_size");
+ if (h5_using_default_driver(NULL)) {
+ /* Check size of file */
+ filesize = h5_get_file_size(FILENAME, fapl);
+ VERIFY(filesize, empty_filesize, "h5_get_file_size");
+ }
} /* end for */
/* Close dataspaces */
@@ -8770,7 +9195,10 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Sclose");
ret = H5Sclose(big_sid);
CHECK(ret, FAIL, "H5Sclose");
-} /* test_attr_shared_rename() */
+
+ /* Release memory */
+ HDfree(big_value);
+} /* test_attr_shared_rename() */
/****************************************************************
**
@@ -8781,34 +9209,36 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl)
static void
test_attr_shared_delete(hid_t fcpl, hid_t fapl)
{
- hid_t fid; /* File ID */
- hid_t my_fcpl; /* File creation property list ID */
- hid_t dataset, dataset2; /* Dataset IDs */
- hid_t attr_tid; /* Attribute's datatype ID */
- hid_t sid, big_sid; /* Dataspace IDs */
- hsize_t big_dims[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; /* Dimensions for "big" attribute */
- hid_t attr; /* Attribute ID */
- hid_t dcpl; /* Dataset creation property list ID */
- char attrname[NAME_BUF_SIZE]; /* Name of attribute on first dataset */
- unsigned max_compact; /* Maximum # of attributes to store compactly */
- unsigned min_dense; /* Minimum # of attributes to store "densely" */
- htri_t is_dense; /* Are attributes stored densely? */
- htri_t is_shared; /* Is attributes shared? */
- hsize_t shared_refcount; /* Reference count of shared attribute */
- unsigned attr_value; /* Attribute value */
- unsigned big_value[SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3]; /* Data for "big" attribute */
- size_t mesg_count; /* # of shared messages */
- unsigned test_shared; /* Index over shared component type */
- unsigned u; /* Local index variable */
- h5_stat_size_t empty_filesize; /* Size of empty file */
- h5_stat_size_t filesize; /* Size of file after modifications */
- herr_t ret; /* Generic return value */
+ hid_t fid; /* File ID */
+ hid_t my_fcpl; /* File creation property list ID */
+ hid_t dataset, dataset2; /* Dataset IDs */
+ hid_t attr_tid; /* Attribute's datatype ID */
+ hid_t sid, big_sid; /* Dataspace IDs */
+ hsize_t big_dims[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; /* Dimensions for "big" attribute */
+ hid_t attr; /* Attribute ID */
+ hid_t dcpl; /* Dataset creation property list ID */
+ char attrname[NAME_BUF_SIZE]; /* Name of attribute on first dataset */
+ unsigned max_compact; /* Maximum # of attributes to store compactly */
+ unsigned min_dense; /* Minimum # of attributes to store "densely" */
+ htri_t is_dense; /* Are attributes stored densely? */
+ htri_t is_shared; /* Is attributes shared? */
+ hsize_t shared_refcount; /* Reference count of shared attribute */
+ unsigned attr_value; /* Attribute value */
+ unsigned *big_value; /* Data for "big" attribute */
+ size_t mesg_count; /* # of shared messages */
+ unsigned test_shared; /* Index over shared component type */
+ unsigned u; /* Local index variable */
+ h5_stat_size_t empty_filesize; /* Size of empty file */
+ h5_stat_size_t filesize; /* Size of file after modifications */
+ herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Deleting Shared & Unshared Attributes in Compact & Dense Storage\n"));
- /* Initialize "big" attribute data */
- HDmemset(big_value, 1, sizeof(big_value));
+ /* Allocate & initialize "big" attribute data */
+ big_value = (unsigned *)HDmalloc((size_t)(SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3) * sizeof(unsigned));
+ CHECK_PTR(big_value, "HDmalloc");
+ HDmemset(big_value, 1, sizeof(unsigned) * (size_t)(SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3));
/* Create dataspace for dataset */
sid = H5Screate(H5S_SCALAR);
@@ -8819,7 +9249,7 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl)
CHECK(big_sid, FAIL, "H5Screate_simple");
/* Loop over type of shared components */
- for(test_shared = 0; test_shared < 3; test_shared++) {
+ for (test_shared = 0; test_shared < 3; test_shared++) {
/* Make copy of file creation property list */
my_fcpl = H5Pcopy(fcpl);
CHECK(my_fcpl, FAIL, "H5Pcopy");
@@ -8829,7 +9259,7 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl)
CHECK(attr_tid, FAIL, "H5Tcopy");
/* Special setup for each type of shared components */
- if(test_shared == 0) {
+ if (test_shared == 0) {
/* Make attributes > 500 bytes shared */
ret = H5Pset_shared_mesg_nindexes(my_fcpl, (unsigned)1);
CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
@@ -8867,23 +9297,28 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl)
/* Get size of file */
empty_filesize = h5_get_file_size(FILENAME, fapl);
- if(empty_filesize < 0)
+ if (empty_filesize < 0)
TestErrPrintf("Line %d: file size wrong!\n", __LINE__);
-
/* Re-open file */
fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
CHECK(fid, FAIL, "H5Fopen");
/* Commit datatype to file */
- if(test_shared == 2) {
+ if (test_shared == 2) {
ret = H5Tcommit2(fid, TYPE1_NAME, attr_tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Tcommit2");
} /* end if */
/* Set up to query the object creation properties */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ }
+ else {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
/* Create datasets */
dataset = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT);
@@ -8892,16 +9327,16 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl)
CHECK(dataset2, FAIL, "H5Dcreate2");
/* Check on dataset's message storage status */
- if(test_shared != 0) {
+ if (test_shared != 0) {
/* Datasets' datatypes can be shared */
- ret = H5F_get_sohm_mesg_count_test(fid, H5O_DTYPE_ID, &mesg_count);
- CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test");
- VERIFY(mesg_count, 1, "H5F_get_sohm_mesg_count_test");
+ ret = H5F__get_sohm_mesg_count_test(fid, H5O_DTYPE_ID, &mesg_count);
+ CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test");
+ VERIFY(mesg_count, 1, "H5F__get_sohm_mesg_count_test");
/* Datasets' dataspace can be shared */
- ret = H5F_get_sohm_mesg_count_test(fid, H5O_SDSPACE_ID, &mesg_count);
- CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test");
- VERIFY(mesg_count, 1, "H5F_get_sohm_mesg_count_test");
+ ret = H5F__get_sohm_mesg_count_test(fid, H5O_SDSPACE_ID, &mesg_count);
+ CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test");
+ VERIFY(mesg_count, 1, "H5F__get_sohm_mesg_count_test");
} /* end if */
/* Retrieve limits for compact/dense attribute storage */
@@ -8913,29 +9348,29 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Pclose");
/* Check on datasets' attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
- is_dense = H5O_is_attr_dense_test(dataset2);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
+ is_dense = H5O__is_attr_dense_test(dataset2);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
/* Add attributes to each dataset, until after converting to dense storage */
- for(u = 0; u < max_compact * 2; u++) {
+ for (u = 0; u < max_compact * 2; u++) {
/* Create attribute name */
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
/* Alternate between creating "small" & "big" attributes */
- if(u % 2) {
+ if (u % 2) {
/* Create "small" attribute on first dataset */
attr = H5Acreate2(dataset, attrname, attr_tid, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
/* Check that attribute is not shared */
- is_shared = H5A_is_shared_test(attr);
- VERIFY(is_shared, FALSE, "H5A_is_shared_test");
+ is_shared = H5A__is_shared_test(attr);
+ VERIFY(is_shared, FALSE, "H5A__is_shared_test");
/* Write data into the attribute */
attr_value = u + 1;
- ret = H5Awrite(attr, attr_tid, &attr_value);
+ ret = H5Awrite(attr, attr_tid, &attr_value);
CHECK(ret, FAIL, "H5Awrite");
} /* end if */
else {
@@ -8944,23 +9379,23 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl)
CHECK(attr, FAIL, "H5Acreate2");
/* Check that attribute is shared */
- is_shared = H5A_is_shared_test(attr);
- VERIFY(is_shared, TRUE, "H5A_is_shared_test");
+ is_shared = H5A__is_shared_test(attr);
+ VERIFY(is_shared, TRUE, "H5A__is_shared_test");
/* Check refcount for attribute */
- ret = H5A_get_shared_rc_test(attr, &shared_refcount);
- CHECK(ret, FAIL, "H5A_get_shared_rc_test");
- VERIFY(shared_refcount, 1, "H5A_get_shared_rc_test");
+ ret = H5A__get_shared_rc_test(attr, &shared_refcount);
+ CHECK(ret, FAIL, "H5A__get_shared_rc_test");
+ VERIFY(shared_refcount, 1, "H5A__get_shared_rc_test");
/* Write data into the attribute */
big_value[0] = u + 1;
- ret = H5Awrite(attr, attr_tid, big_value);
+ ret = H5Awrite(attr, attr_tid, big_value);
CHECK(ret, FAIL, "H5Awrite");
/* Check refcount for attribute */
- ret = H5A_get_shared_rc_test(attr, &shared_refcount);
- CHECK(ret, FAIL, "H5A_get_shared_rc_test");
- VERIFY(shared_refcount, 1, "H5A_get_shared_rc_test");
+ ret = H5A__get_shared_rc_test(attr, &shared_refcount);
+ CHECK(ret, FAIL, "H5A__get_shared_rc_test");
+ VERIFY(shared_refcount, 1, "H5A__get_shared_rc_test");
} /* end else */
/* Close attribute */
@@ -8968,26 +9403,25 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Aclose");
/* Check on dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset);
- if(u < max_compact)
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ is_dense = H5O__is_attr_dense_test(dataset);
+ if (u < max_compact)
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
else
- VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
-
+ VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test");
/* Alternate between creating "small" & "big" attributes */
- if(u % 2) {
+ if (u % 2) {
/* Create "small" attribute on second dataset */
attr = H5Acreate2(dataset2, attrname, attr_tid, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
/* Check that attribute is not shared */
- is_shared = H5A_is_shared_test(attr);
- VERIFY(is_shared, FALSE, "H5A_is_shared_test");
+ is_shared = H5A__is_shared_test(attr);
+ VERIFY(is_shared, FALSE, "H5A__is_shared_test");
/* Write data into the attribute */
attr_value = u + 1;
- ret = H5Awrite(attr, attr_tid, &attr_value);
+ ret = H5Awrite(attr, attr_tid, &attr_value);
CHECK(ret, FAIL, "H5Awrite");
} /* end if */
else {
@@ -8996,23 +9430,23 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl)
CHECK(attr, FAIL, "H5Acreate2");
/* Check that attribute is shared */
- is_shared = H5A_is_shared_test(attr);
- VERIFY(is_shared, TRUE, "H5A_is_shared_test");
+ is_shared = H5A__is_shared_test(attr);
+ VERIFY(is_shared, TRUE, "H5A__is_shared_test");
/* Check refcount for attribute */
- ret = H5A_get_shared_rc_test(attr, &shared_refcount);
- CHECK(ret, FAIL, "H5A_get_shared_rc_test");
- VERIFY(shared_refcount, 1, "H5A_get_shared_rc_test");
+ ret = H5A__get_shared_rc_test(attr, &shared_refcount);
+ CHECK(ret, FAIL, "H5A__get_shared_rc_test");
+ VERIFY(shared_refcount, 1, "H5A__get_shared_rc_test");
/* Write data into the attribute */
big_value[0] = u + 1;
- ret = H5Awrite(attr, attr_tid, big_value);
+ ret = H5Awrite(attr, attr_tid, big_value);
CHECK(ret, FAIL, "H5Awrite");
/* Check refcount for attribute */
- ret = H5A_get_shared_rc_test(attr, &shared_refcount);
- CHECK(ret, FAIL, "H5A_get_shared_rc_test");
- VERIFY(shared_refcount, 2, "H5A_get_shared_rc_test");
+ ret = H5A__get_shared_rc_test(attr, &shared_refcount);
+ CHECK(ret, FAIL, "H5A__get_shared_rc_test");
+ VERIFY(shared_refcount, 2, "H5A__get_shared_rc_test");
} /* end else */
/* Close attribute */
@@ -9020,44 +9454,42 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Aclose");
/* Check on dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset2);
- if(u < max_compact)
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ is_dense = H5O__is_attr_dense_test(dataset2);
+ if (u < max_compact)
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
else
- VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
+ VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test");
} /* end for */
-
/* Delete attributes from second dataset */
- for(u = 0; u < max_compact * 2; u++) {
+ for (u = 0; u < max_compact * 2; u++) {
/* Create attribute name */
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
/* Delete second dataset's attribute */
ret = H5Adelete_by_name(fid, DSET2_NAME, attrname, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Adelete_by_name");
-
/* Check refcount on attributes now */
/* Check refcount on first dataset's attribute */
attr = H5Aopen(dataset, attrname, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Aopen");
- if(u % 2) {
+ if (u % 2) {
/* Check that attribute is not shared */
- is_shared = H5A_is_shared_test(attr);
- VERIFY(is_shared, FALSE, "H5A_is_shared_test");
+ is_shared = H5A__is_shared_test(attr);
+ VERIFY(is_shared, FALSE, "H5A__is_shared_test");
} /* end if */
else {
/* Check that attribute is shared */
- is_shared = H5A_is_shared_test(attr);
- VERIFY(is_shared, TRUE, "H5A_is_shared_test");
+ is_shared = H5A__is_shared_test(attr);
+ VERIFY(is_shared, TRUE, "H5A__is_shared_test");
/* Check refcount for attribute */
- ret = H5A_get_shared_rc_test(attr, &shared_refcount);
- CHECK(ret, FAIL, "H5A_get_shared_rc_test");
- VERIFY(shared_refcount, 1, "H5A_get_shared_rc_test");
+ ret = H5A__get_shared_rc_test(attr, &shared_refcount);
+ CHECK(ret, FAIL, "H5A__get_shared_rc_test");
+ VERIFY(shared_refcount, 1, "H5A__get_shared_rc_test");
} /* end else */
/* Close attribute */
@@ -9065,7 +9497,6 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Aclose");
} /* end for */
-
/* Close attribute's datatype */
ret = H5Tclose(attr_tid);
CHECK(ret, FAIL, "H5Tclose");
@@ -9077,18 +9508,18 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Dclose");
/* Check on shared message status now */
- if(test_shared != 0) {
- if(test_shared == 1) {
+ if (test_shared != 0) {
+ if (test_shared == 1) {
/* Check on datatype storage status */
- ret = H5F_get_sohm_mesg_count_test(fid, H5O_DTYPE_ID, &mesg_count);
- CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test");
- VERIFY(mesg_count, 2, "H5F_get_sohm_mesg_count_test");
+ ret = H5F__get_sohm_mesg_count_test(fid, H5O_DTYPE_ID, &mesg_count);
+ CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test");
+ VERIFY(mesg_count, 2, "H5F__get_sohm_mesg_count_test");
} /* end if */
/* Check on dataspace storage status */
- ret = H5F_get_sohm_mesg_count_test(fid, H5O_SDSPACE_ID, &mesg_count);
- CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test");
- VERIFY(mesg_count, 2, "H5F_get_sohm_mesg_count_test");
+ ret = H5F__get_sohm_mesg_count_test(fid, H5O_SDSPACE_ID, &mesg_count);
+ CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test");
+ VERIFY(mesg_count, 2, "H5F__get_sohm_mesg_count_test");
} /* end if */
/* Unlink datasets with attributes */
@@ -9098,35 +9529,37 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Ldelete");
/* Unlink committed datatype */
- if(test_shared == 2) {
+ if (test_shared == 2) {
ret = H5Ldelete(fid, TYPE1_NAME, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Ldelete");
} /* end if */
/* Check on attribute storage status */
- ret = H5F_get_sohm_mesg_count_test(fid, H5O_ATTR_ID, &mesg_count);
- CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test");
- VERIFY(mesg_count, 0, "H5F_get_sohm_mesg_count_test");
+ ret = H5F__get_sohm_mesg_count_test(fid, H5O_ATTR_ID, &mesg_count);
+ CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test");
+ VERIFY(mesg_count, 0, "H5F__get_sohm_mesg_count_test");
- if(test_shared != 0) {
+ if (test_shared != 0) {
/* Check on datatype storage status */
- ret = H5F_get_sohm_mesg_count_test(fid, H5O_DTYPE_ID, &mesg_count);
- CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test");
- VERIFY(mesg_count, 0, "H5F_get_sohm_mesg_count_test");
+ ret = H5F__get_sohm_mesg_count_test(fid, H5O_DTYPE_ID, &mesg_count);
+ CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test");
+ VERIFY(mesg_count, 0, "H5F__get_sohm_mesg_count_test");
/* Check on dataspace storage status */
- ret = H5F_get_sohm_mesg_count_test(fid, H5O_SDSPACE_ID, &mesg_count);
- CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test");
- VERIFY(mesg_count, 0, "H5F_get_sohm_mesg_count_test");
+ ret = H5F__get_sohm_mesg_count_test(fid, H5O_SDSPACE_ID, &mesg_count);
+ CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test");
+ VERIFY(mesg_count, 0, "H5F__get_sohm_mesg_count_test");
} /* end if */
/* Close file */
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
- /* Check size of file */
- filesize = h5_get_file_size(FILENAME, fapl);
- VERIFY(filesize, empty_filesize, "h5_get_file_size");
+ if (h5_using_default_driver(NULL)) {
+ /* Check size of file */
+ filesize = h5_get_file_size(FILENAME, fapl);
+ VERIFY(filesize, empty_filesize, "h5_get_file_size");
+ }
} /* end for */
/* Close dataspaces */
@@ -9134,7 +9567,10 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Sclose");
ret = H5Sclose(big_sid);
CHECK(ret, FAIL, "H5Sclose");
-} /* test_attr_shared_delete() */
+
+ /* Release memory */
+ HDfree(big_value);
+} /* test_attr_shared_delete() */
/****************************************************************
**
@@ -9145,34 +9581,36 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl)
static void
test_attr_shared_unlink(hid_t fcpl, hid_t fapl)
{
- hid_t fid; /* File ID */
- hid_t my_fcpl; /* File creation property list ID */
- hid_t dataset, dataset2; /* Dataset IDs */
- hid_t attr_tid; /* Attribute's datatype ID */
- hid_t sid, big_sid; /* Dataspace IDs */
- hsize_t big_dims[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; /* Dimensions for "big" attribute */
- hid_t attr; /* Attribute ID */
- hid_t dcpl; /* Dataset creation property list ID */
- char attrname[NAME_BUF_SIZE]; /* Name of attribute on first dataset */
- unsigned max_compact; /* Maximum # of attributes to store compactly */
- unsigned min_dense; /* Minimum # of attributes to store "densely" */
- htri_t is_dense; /* Are attributes stored densely? */
- htri_t is_shared; /* Is attributes shared? */
- hsize_t shared_refcount; /* Reference count of shared attribute */
- unsigned attr_value; /* Attribute value */
- unsigned big_value[SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3]; /* Data for "big" attribute */
- size_t mesg_count; /* # of shared messages */
- unsigned test_shared; /* Index over shared component type */
- unsigned u; /* Local index variable */
- h5_stat_size_t empty_filesize; /* Size of empty file */
- h5_stat_size_t filesize; /* Size of file after modifications */
- herr_t ret; /* Generic return value */
+ hid_t fid; /* File ID */
+ hid_t my_fcpl; /* File creation property list ID */
+ hid_t dataset, dataset2; /* Dataset IDs */
+ hid_t attr_tid; /* Attribute's datatype ID */
+ hid_t sid, big_sid; /* Dataspace IDs */
+ hsize_t big_dims[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; /* Dimensions for "big" attribute */
+ hid_t attr; /* Attribute ID */
+ hid_t dcpl; /* Dataset creation property list ID */
+ char attrname[NAME_BUF_SIZE]; /* Name of attribute on first dataset */
+ unsigned max_compact; /* Maximum # of attributes to store compactly */
+ unsigned min_dense; /* Minimum # of attributes to store "densely" */
+ htri_t is_dense; /* Are attributes stored densely? */
+ htri_t is_shared; /* Is attributes shared? */
+ hsize_t shared_refcount; /* Reference count of shared attribute */
+ unsigned attr_value; /* Attribute value */
+ unsigned *big_value; /* Data for "big" attribute */
+ size_t mesg_count; /* # of shared messages */
+ unsigned test_shared; /* Index over shared component type */
+ unsigned u; /* Local index variable */
+ h5_stat_size_t empty_filesize; /* Size of empty file */
+ h5_stat_size_t filesize; /* Size of file after modifications */
+ herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Unlinking Object with Shared Attributes in Compact & Dense Storage\n"));
- /* Initialize "big" attribute data */
- HDmemset(big_value, 1, sizeof(big_value));
+ /* Allocate & initialize "big" attribute data */
+ big_value = (unsigned *)HDmalloc((size_t)(SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3) * sizeof(unsigned));
+ CHECK_PTR(big_value, "HDmalloc");
+ HDmemset(big_value, 1, sizeof(unsigned) * (size_t)(SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3));
/* Create dataspace for dataset */
sid = H5Screate(H5S_SCALAR);
@@ -9183,7 +9621,7 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl)
CHECK(big_sid, FAIL, "H5Screate_simple");
/* Loop over type of shared components */
- for(test_shared = 0; test_shared < 3; test_shared++) {
+ for (test_shared = 0; test_shared < 3; test_shared++) {
/* Make copy of file creation property list */
my_fcpl = H5Pcopy(fcpl);
CHECK(my_fcpl, FAIL, "H5Pcopy");
@@ -9193,7 +9631,7 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl)
CHECK(attr_tid, FAIL, "H5Tcopy");
/* Special setup for each type of shared components */
- if(test_shared == 0) {
+ if (test_shared == 0) {
/* Make attributes > 500 bytes shared */
ret = H5Pset_shared_mesg_nindexes(my_fcpl, (unsigned)1);
CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
@@ -9231,23 +9669,28 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl)
/* Get size of file */
empty_filesize = h5_get_file_size(FILENAME, fapl);
- if(empty_filesize < 0)
+ if (empty_filesize < 0)
TestErrPrintf("Line %d: file size wrong!\n", __LINE__);
-
/* Re-open file */
fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
CHECK(fid, FAIL, "H5Fopen");
/* Commit datatype to file */
- if(test_shared == 2) {
+ if (test_shared == 2) {
ret = H5Tcommit2(fid, TYPE1_NAME, attr_tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Tcommit2");
} /* end if */
/* Set up to query the object creation properties */
- dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ if (dcpl_g == H5P_DEFAULT) {
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ }
+ else {
+ dcpl = H5Pcopy(dcpl_g);
+ CHECK(dcpl, FAIL, "H5Pcopy");
+ }
/* Create datasets */
dataset = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT);
@@ -9256,16 +9699,16 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl)
CHECK(dataset2, FAIL, "H5Dcreate2");
/* Check on dataset's message storage status */
- if(test_shared != 0) {
+ if (test_shared != 0) {
/* Datasets' datatypes can be shared */
- ret = H5F_get_sohm_mesg_count_test(fid, H5O_DTYPE_ID, &mesg_count);
- CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test");
- VERIFY(mesg_count, 1, "H5F_get_sohm_mesg_count_test");
+ ret = H5F__get_sohm_mesg_count_test(fid, H5O_DTYPE_ID, &mesg_count);
+ CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test");
+ VERIFY(mesg_count, 1, "H5F__get_sohm_mesg_count_test");
/* Datasets' dataspace can be shared */
- ret = H5F_get_sohm_mesg_count_test(fid, H5O_SDSPACE_ID, &mesg_count);
- CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test");
- VERIFY(mesg_count, 1, "H5F_get_sohm_mesg_count_test");
+ ret = H5F__get_sohm_mesg_count_test(fid, H5O_SDSPACE_ID, &mesg_count);
+ CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test");
+ VERIFY(mesg_count, 1, "H5F__get_sohm_mesg_count_test");
} /* end if */
/* Retrieve limits for compact/dense attribute storage */
@@ -9277,29 +9720,29 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Pclose");
/* Check on datasets' attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
- is_dense = H5O_is_attr_dense_test(dataset2);
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
+ is_dense = H5O__is_attr_dense_test(dataset2);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
/* Add attributes to each dataset, until after converting to dense storage */
- for(u = 0; u < max_compact * 2; u++) {
+ for (u = 0; u < max_compact * 2; u++) {
/* Create attribute name */
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
/* Alternate between creating "small" & "big" attributes */
- if(u % 2) {
+ if (u % 2) {
/* Create "small" attribute on first dataset */
attr = H5Acreate2(dataset, attrname, attr_tid, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
/* Check that attribute is not shared */
- is_shared = H5A_is_shared_test(attr);
- VERIFY(is_shared, FALSE, "H5A_is_shared_test");
+ is_shared = H5A__is_shared_test(attr);
+ VERIFY(is_shared, FALSE, "H5A__is_shared_test");
/* Write data into the attribute */
attr_value = u + 1;
- ret = H5Awrite(attr, attr_tid, &attr_value);
+ ret = H5Awrite(attr, attr_tid, &attr_value);
CHECK(ret, FAIL, "H5Awrite");
} /* end if */
else {
@@ -9308,23 +9751,23 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl)
CHECK(attr, FAIL, "H5Acreate2");
/* ChecFk that attribute is shared */
- is_shared = H5A_is_shared_test(attr);
- VERIFY(is_shared, TRUE, "H5A_is_shared_test");
+ is_shared = H5A__is_shared_test(attr);
+ VERIFY(is_shared, TRUE, "H5A__is_shared_test");
/* Check refcount for attribute */
- ret = H5A_get_shared_rc_test(attr, &shared_refcount);
- CHECK(ret, FAIL, "H5A_get_shared_rc_test");
- VERIFY(shared_refcount, 1, "H5A_get_shared_rc_test");
+ ret = H5A__get_shared_rc_test(attr, &shared_refcount);
+ CHECK(ret, FAIL, "H5A__get_shared_rc_test");
+ VERIFY(shared_refcount, 1, "H5A__get_shared_rc_test");
/* Write data into the attribute */
big_value[0] = u + 1;
- ret = H5Awrite(attr, attr_tid, big_value);
+ ret = H5Awrite(attr, attr_tid, big_value);
CHECK(ret, FAIL, "H5Awrite");
/* Check refcount for attribute */
- ret = H5A_get_shared_rc_test(attr, &shared_refcount);
- CHECK(ret, FAIL, "H5A_get_shared_rc_test");
- VERIFY(shared_refcount, 1, "H5A_get_shared_rc_test");
+ ret = H5A__get_shared_rc_test(attr, &shared_refcount);
+ CHECK(ret, FAIL, "H5A__get_shared_rc_test");
+ VERIFY(shared_refcount, 1, "H5A__get_shared_rc_test");
} /* end else */
/* Close attribute */
@@ -9332,26 +9775,25 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Aclose");
/* Check on dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset);
- if(u < max_compact)
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ is_dense = H5O__is_attr_dense_test(dataset);
+ if (u < max_compact)
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
else
- VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
-
+ VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test");
/* Alternate between creating "small" & "big" attributes */
- if(u % 2) {
+ if (u % 2) {
/* Create "small" attribute on second dataset */
attr = H5Acreate2(dataset2, attrname, attr_tid, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
/* Check that attribute is not shared */
- is_shared = H5A_is_shared_test(attr);
- VERIFY(is_shared, FALSE, "H5A_is_shared_test");
+ is_shared = H5A__is_shared_test(attr);
+ VERIFY(is_shared, FALSE, "H5A__is_shared_test");
/* Write data into the attribute */
attr_value = u + 1;
- ret = H5Awrite(attr, attr_tid, &attr_value);
+ ret = H5Awrite(attr, attr_tid, &attr_value);
CHECK(ret, FAIL, "H5Awrite");
} /* end if */
else {
@@ -9360,23 +9802,23 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl)
CHECK(attr, FAIL, "H5Acreate2");
/* Check that attribute is shared */
- is_shared = H5A_is_shared_test(attr);
- VERIFY(is_shared, TRUE, "H5A_is_shared_test");
+ is_shared = H5A__is_shared_test(attr);
+ VERIFY(is_shared, TRUE, "H5A__is_shared_test");
/* Check refcount for attribute */
- ret = H5A_get_shared_rc_test(attr, &shared_refcount);
- CHECK(ret, FAIL, "H5A_get_shared_rc_test");
- VERIFY(shared_refcount, 1, "H5A_get_shared_rc_test");
+ ret = H5A__get_shared_rc_test(attr, &shared_refcount);
+ CHECK(ret, FAIL, "H5A__get_shared_rc_test");
+ VERIFY(shared_refcount, 1, "H5A__get_shared_rc_test");
/* Write data into the attribute */
big_value[0] = u + 1;
- ret = H5Awrite(attr, attr_tid, big_value);
+ ret = H5Awrite(attr, attr_tid, big_value);
CHECK(ret, FAIL, "H5Awrite");
/* Check refcount for attribute */
- ret = H5A_get_shared_rc_test(attr, &shared_refcount);
- CHECK(ret, FAIL, "H5A_get_shared_rc_test");
- VERIFY(shared_refcount, 2, "H5A_get_shared_rc_test");
+ ret = H5A__get_shared_rc_test(attr, &shared_refcount);
+ CHECK(ret, FAIL, "H5A__get_shared_rc_test");
+ VERIFY(shared_refcount, 2, "H5A__get_shared_rc_test");
} /* end else */
/* Close attribute */
@@ -9384,14 +9826,13 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Aclose");
/* Check on dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset2);
- if(u < max_compact)
- VERIFY(is_dense, FALSE, "H5O_is_attr_dense_test");
+ is_dense = H5O__is_attr_dense_test(dataset2);
+ if (u < max_compact)
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
else
- VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
+ VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test");
} /* end for */
-
/* Close attribute's datatype */
ret = H5Tclose(attr_tid);
CHECK(ret, FAIL, "H5Tclose");
@@ -9404,34 +9845,33 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl)
ret = H5Ldelete(fid, DSET2_NAME, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Ldelete");
-
/* Check on first dataset's attribute storage status */
- is_dense = H5O_is_attr_dense_test(dataset);
- VERIFY(is_dense, TRUE, "H5O_is_attr_dense_test");
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test");
/* Check ref count on attributes of first dataset */
- for(u = 0; u < max_compact * 2; u++) {
+ for (u = 0; u < max_compact * 2; u++) {
/* Create attribute name */
- sprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
/* Open attribute on first dataset */
attr = H5Aopen(dataset, attrname, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Aopen");
- if(u % 2) {
+ if (u % 2) {
/* Check that attribute is not shared */
- is_shared = H5A_is_shared_test(attr);
- VERIFY(is_shared, FALSE, "H5A_is_shared_test");
+ is_shared = H5A__is_shared_test(attr);
+ VERIFY(is_shared, FALSE, "H5A__is_shared_test");
} /* end if */
else {
/* Check that attribute is shared */
- is_shared = H5A_is_shared_test(attr);
- VERIFY(is_shared, TRUE, "H5A_is_shared_test");
+ is_shared = H5A__is_shared_test(attr);
+ VERIFY(is_shared, TRUE, "H5A__is_shared_test");
/* Check refcount for attribute */
- ret = H5A_get_shared_rc_test(attr, &shared_refcount);
- CHECK(ret, FAIL, "H5A_get_shared_rc_test");
- VERIFY(shared_refcount, 1, "H5A_get_shared_rc_test");
+ ret = H5A__get_shared_rc_test(attr, &shared_refcount);
+ CHECK(ret, FAIL, "H5A__get_shared_rc_test");
+ VERIFY(shared_refcount, 1, "H5A__get_shared_rc_test");
} /* end else */
/* Close attribute */
@@ -9448,35 +9888,37 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Ldelete");
/* Unlink committed datatype */
- if(test_shared == 2) {
+ if (test_shared == 2) {
ret = H5Ldelete(fid, TYPE1_NAME, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Ldelete");
} /* end if */
/* Check on attribute storage status */
- ret = H5F_get_sohm_mesg_count_test(fid, H5O_ATTR_ID, &mesg_count);
- CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test");
- VERIFY(mesg_count, 0, "H5F_get_sohm_mesg_count_test");
+ ret = H5F__get_sohm_mesg_count_test(fid, H5O_ATTR_ID, &mesg_count);
+ CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test");
+ VERIFY(mesg_count, 0, "H5F__get_sohm_mesg_count_test");
- if(test_shared != 0) {
+ if (test_shared != 0) {
/* Check on datatype storage status */
- ret = H5F_get_sohm_mesg_count_test(fid, H5O_DTYPE_ID, &mesg_count);
- CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test");
- VERIFY(mesg_count, 0, "H5F_get_sohm_mesg_count_test");
+ ret = H5F__get_sohm_mesg_count_test(fid, H5O_DTYPE_ID, &mesg_count);
+ CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test");
+ VERIFY(mesg_count, 0, "H5F__get_sohm_mesg_count_test");
/* Check on dataspace storage status */
- ret = H5F_get_sohm_mesg_count_test(fid, H5O_SDSPACE_ID, &mesg_count);
- CHECK(ret, FAIL, "H5F_get_sohm_mesg_count_test");
- VERIFY(mesg_count, 0, "H5F_get_sohm_mesg_count_test");
+ ret = H5F__get_sohm_mesg_count_test(fid, H5O_SDSPACE_ID, &mesg_count);
+ CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test");
+ VERIFY(mesg_count, 0, "H5F__get_sohm_mesg_count_test");
} /* end if */
/* Close file */
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
- /* Check size of file */
- filesize = h5_get_file_size(FILENAME, fapl);
- VERIFY(filesize, empty_filesize, "h5_get_file_size");
+ if (h5_using_default_driver(NULL)) {
+ /* Check size of file */
+ filesize = h5_get_file_size(FILENAME, fapl);
+ VERIFY(filesize, empty_filesize, "h5_get_file_size");
+ }
} /* end for */
/* Close dataspaces */
@@ -9484,7 +9926,10 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Sclose");
ret = H5Sclose(big_sid);
CHECK(ret, FAIL, "H5Sclose");
-} /* test_attr_shared_unlink() */
+
+ /* Release memory */
+ HDfree(big_value);
+} /* test_attr_shared_unlink() */
/****************************************************************
**
@@ -9500,11 +9945,11 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl)
static void
test_attr_bug1(hid_t fcpl, hid_t fapl)
{
- hid_t fid; /* File ID */
- hid_t gid; /* Group ID */
- hid_t aid; /* Attribute ID */
- hid_t sid; /* Dataspace ID */
- herr_t ret; /* Generic return status */
+ hid_t fid; /* File ID */
+ hid_t gid; /* Group ID */
+ hid_t aid; /* Attribute ID */
+ hid_t sid; /* Dataspace ID */
+ herr_t ret; /* Generic return status */
/* Output message about test being performed */
MESSAGE(5, ("Testing Allocating and De-allocating Attributes in Unusual Way\n"));
@@ -9526,7 +9971,6 @@ test_attr_bug1(hid_t fcpl, hid_t fapl)
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
-
/* Re-open file and create another group, then attribute on first group */
fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
CHECK(fid, FAIL, "H5Fopen");
@@ -9555,7 +9999,6 @@ test_attr_bug1(hid_t fcpl, hid_t fapl)
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
-
/* Re-open file and create another group, then another attribute on first group */
fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
CHECK(fid, FAIL, "H5Fopen");
@@ -9588,7 +10031,6 @@ test_attr_bug1(hid_t fcpl, hid_t fapl)
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
-
/* Re-open file and re-create attributes on first group */
fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
CHECK(fid, FAIL, "H5Fopen");
@@ -9625,11 +10067,10 @@ test_attr_bug1(hid_t fcpl, hid_t fapl)
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
-
/* Close dataspace ID */
ret = H5Sclose(sid);
CHECK(ret, FAIL, "H5Gclose");
-} /* test_attr_bug1() */
+} /* test_attr_bug1() */
/****************************************************************
**
@@ -9645,17 +10086,17 @@ test_attr_bug1(hid_t fcpl, hid_t fapl)
static void
test_attr_bug2(hid_t fcpl, hid_t fapl)
{
- hid_t fid; /* File ID */
- hid_t gid; /* Group ID */
- hid_t aid; /* Attribute ID */
- hid_t sid; /* Dataspace ID */
- hid_t tid; /* Datatype ID */
- hid_t gcpl; /* Group creation property list */
- hsize_t dims[2] = {10, 100}; /* Attribute dimensions */
- char aname[4]; /* Attribute name */
- unsigned i; /* index */
- herr_t ret; /* Generic return status */
- htri_t tri_ret; /* htri_t return status */
+ hid_t fid; /* File ID */
+ hid_t gid; /* Group ID */
+ hid_t aid; /* Attribute ID */
+ hid_t sid; /* Dataspace ID */
+ hid_t tid; /* Datatype ID */
+ hid_t gcpl; /* Group creation property list */
+ hsize_t dims[2] = {10, 100}; /* Attribute dimensions */
+ char aname[16]; /* Attribute name */
+ unsigned i; /* index */
+ herr_t ret; /* Generic return status */
+ htri_t tri_ret; /* htri_t return status */
/* Output message about test being performed */
MESSAGE(5, ("Testing Allocating and De-allocating Attributes in Unusual Way\n"));
@@ -9668,7 +10109,7 @@ test_attr_bug2(hid_t fcpl, hid_t fapl)
/* Not doing this with the latest format actually triggers a different bug.
* This will be tested here as soon as it is fixed. -NAF
*/
- ret = H5Pset_attr_phase_change (gcpl, BUG2_NATTR+10, BUG2_NATTR+5);
+ ret = H5Pset_attr_phase_change(gcpl, BUG2_NATTR + 10, BUG2_NATTR + 5);
CHECK(ret, FAIL, "H5Pset_attr_phase_change");
/* Create dataspace ID for attributes */
@@ -9683,8 +10124,8 @@ test_attr_bug2(hid_t fcpl, hid_t fapl)
CHECK(gid, FAIL, "H5Gcreate2");
/* Create attributes on group */
- for (i=0; i<BUG2_NATTR; i++) {
- sprintf(aname, "%03u", i);
+ for (i = 0; i < BUG2_NATTR; i++) {
+ HDsnprintf(aname, sizeof(aname), "%03u", i);
aid = H5Acreate2(gid, aname, H5T_STD_I32LE, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(aid, FAIL, "H5Acreate2");
@@ -9693,8 +10134,8 @@ test_attr_bug2(hid_t fcpl, hid_t fapl)
}
/* Delete every other attribute */
- for (i=1; i<BUG2_NATTR; i+=2) {
- sprintf(aname, "%03u", i);
+ for (i = 1; i < BUG2_NATTR; i += 2) {
+ HDsnprintf(aname, sizeof(aname), "%03u", i);
ret = H5Adelete(gid, aname);
CHECK(ret, FAIL, "H5Adelete");
}
@@ -9718,7 +10159,7 @@ test_attr_bug2(hid_t fcpl, hid_t fapl)
/* Open an attribute in the middle */
i = (BUG2_NATTR / 4) * 2;
- sprintf(aname, "%03u", i);
+ HDsnprintf(aname, sizeof(aname), "%03u", i);
aid = H5Aopen(gid, aname, H5P_DEFAULT);
CHECK(aid, FAIL, "H5Aopen");
@@ -9760,8 +10201,8 @@ test_attr_bug2(hid_t fcpl, hid_t fapl)
CHECK(gid, FAIL, "H5Gcreate2");
/* Create attributes on group */
- for (i=0; i<BUG2_NATTR2; i++) {
- sprintf(aname, "%03u", i);
+ for (i = 0; i < BUG2_NATTR2; i++) {
+ HDsnprintf(aname, sizeof(aname), "%03u", i);
aid = H5Acreate2(gid, aname, H5T_STD_I32LE, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(aid, FAIL, "H5Acreate2");
@@ -9770,8 +10211,8 @@ test_attr_bug2(hid_t fcpl, hid_t fapl)
}
/* Delete every other attribute */
- for (i=0; i<BUG2_NATTR2; i++) {
- sprintf(aname, "%03u", i);
+ for (i = 0; i < BUG2_NATTR2; i++) {
+ HDsnprintf(aname, sizeof(aname), "%03u", i);
ret = H5Adelete(gid, aname);
CHECK(ret, FAIL, "H5Adelete");
}
@@ -9788,7 +10229,7 @@ test_attr_bug2(hid_t fcpl, hid_t fapl)
ret = H5Pclose(gcpl);
CHECK(ret, FAIL, "H5Pclose");
-} /* test_attr_bug2() */
+} /* test_attr_bug2() */
/****************************************************************
**
@@ -9801,17 +10242,16 @@ test_attr_bug2(hid_t fcpl, hid_t fapl)
static void
test_attr_bug3(hid_t fcpl, hid_t fapl)
{
- hid_t fid; /* File ID */
- hid_t aid1, aid2; /* Attribute IDs */
- hid_t sid1, sid2; /* Dataspace ID */
- hid_t tid1, tid2; /* Datatype IDs */
- hid_t did; /* Dataset ID */
- hsize_t dims1[2] = {2, 2},
- dims2[2] = {3, 3}; /* Dimensions */
- int wdata1[2][2];
- unsigned wdata2[3][3]; /* Write buffers */
- unsigned u, v; /* Local index variables */
- herr_t ret; /* Generic return status */
+ hid_t fid; /* File ID */
+ hid_t aid1, aid2; /* Attribute IDs */
+ hid_t sid1, sid2; /* Dataspace ID */
+ hid_t tid1, tid2; /* Datatype IDs */
+ hid_t did; /* Dataset ID */
+ hsize_t dims1[2] = {2, 2}, dims2[2] = {3, 3}; /* Dimensions */
+ int wdata1[2][2];
+ unsigned wdata2[3][3]; /* Write buffers */
+ unsigned u, v; /* Local index variables */
+ herr_t ret; /* Generic return status */
/* Output message about test being performed */
MESSAGE(5, ("Testing Attributes in the Same Header as their Datatypes\n"));
@@ -9835,7 +10275,7 @@ test_attr_bug3(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Tcommit2");
/* Create dataset */
- did = H5Dcreate2(fid, "dset", tid2, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ did = H5Dcreate2(fid, "dset", tid2, sid2, H5P_DEFAULT, dcpl_g, H5P_DEFAULT);
CHECK(did, FAIL, "H5Dcreate2");
/* Create attribute on datatype, using that datatype as its datatype */
@@ -9859,12 +10299,12 @@ test_attr_bug3(hid_t fcpl, hid_t fapl)
CHECK(aid2, FAIL, "H5Aopen");
/* Initialize the write buffers */
- for(u = 0; u < dims1[0]; u++)
- for(v = 0; v < dims1[1]; v++)
+ for (u = 0; u < dims1[0]; u++)
+ for (v = 0; v < dims1[1]; v++)
wdata1[u][v] = (int)((u * dims1[1]) + v);
- for(u = 0; u < dims2[0]; u++)
- for(v = 0; v < dims2[1]; v++)
- wdata2[u][v] = (int)((u * dims2[1]) + v);
+ for (u = 0; u < dims2[0]; u++)
+ for (v = 0; v < dims2[1]; v++)
+ wdata2[u][v] = (unsigned)((u * dims2[1]) + v);
/* Write data to the attributes */
ret = H5Awrite(aid1, H5T_NATIVE_INT, wdata1);
@@ -9925,7 +10365,7 @@ test_attr_bug3(hid_t fcpl, hid_t fapl)
/* Close file */
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
-} /* test_attr_bug3() */
+} /* test_attr_bug3() */
/****************************************************************
**
@@ -9939,14 +10379,14 @@ test_attr_bug3(hid_t fcpl, hid_t fapl)
static void
test_attr_bug4(hid_t fcpl, hid_t fapl)
{
- hid_t fid; /* File ID */
- hid_t gid; /* Group ID */
+ hid_t fid; /* File ID */
+ hid_t gid; /* Group ID */
hid_t aid1, aid2, aid3; /* Attribute IDs */
- hid_t sid; /* Dataspace ID */
- hid_t tid; /* Datatype ID */
- hid_t did; /* Dataset ID */
- hsize_t dims[1] = {5}; /* Attribute dimensions */
- herr_t ret; /* Generic return status */
+ hid_t sid; /* Dataspace ID */
+ hid_t tid; /* Datatype ID */
+ hid_t did; /* Dataset ID */
+ hsize_t dims[1] = {5}; /* Attribute dimensions */
+ herr_t ret; /* Generic return status */
/* Output message about test being performed */
MESSAGE(5, ("Testing that attributes can always be added to named datatypes\n"));
@@ -9970,7 +10410,7 @@ test_attr_bug4(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Tcommit2");
/* Create dataset */
- did = H5Dcreate2(fid, "dset", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ did = H5Dcreate2(fid, "dset", tid, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT);
CHECK(did, FAIL, "H5Dcreate2");
/* Create attributes on group and dataset */
@@ -10007,7 +10447,7 @@ test_attr_bug4(hid_t fcpl, hid_t fapl)
ret = H5Sclose(sid);
CHECK(ret, FAIL, "H5Sclose");
-} /* test_attr_bug4() */
+} /* test_attr_bug4() */
/****************************************************************
**
@@ -10019,16 +10459,14 @@ test_attr_bug4(hid_t fcpl, hid_t fapl)
static void
test_attr_bug5(hid_t fcpl, hid_t fapl)
{
- hid_t fid1, fid2; /* File IDs */
- hid_t gid1, gid2; /* Group IDs */
- hid_t did1, did2; /* Dataset IDs */
- hid_t tid1, tid2; /* Datatype IDs */
- hid_t aidg1, aidg2,
- aidd1, aidd2,
- aidt1, aidt2; /* Attribute IDs */
- hid_t sid; /* Dataspace ID */
- hsize_t dims[1] = {5}; /* Attribute dimensions */
- herr_t ret; /* Generic return status */
+ hid_t fid1, fid2; /* File IDs */
+ hid_t gid1, gid2; /* Group IDs */
+ hid_t did1, did2; /* Dataset IDs */
+ hid_t tid1, tid2; /* Datatype IDs */
+ hid_t aidg1, aidg2, aidd1, aidd2, aidt1, aidt2; /* Attribute IDs */
+ hid_t sid; /* Dataspace ID */
+ hsize_t dims[1] = {5}; /* Attribute dimensions */
+ herr_t ret; /* Generic return status */
/* Output message about test being performed */
MESSAGE(5, ("Testing Opening an Attribute Through Multiple Files Concurrently\n"));
@@ -10052,7 +10490,7 @@ test_attr_bug5(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Tcommit2");
/* Create dataset */
- did1 = H5Dcreate2(fid1, BUG3_DSET_NAME, tid1, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ did1 = H5Dcreate2(fid1, BUG3_DSET_NAME, tid1, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT);
CHECK(did1, FAIL, "H5Dcreate2");
/* Create attribute on root group */
@@ -10164,7 +10602,7 @@ test_attr_bug5(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Fclose");
ret = H5Fclose(fid2);
CHECK(ret, FAIL, "H5Fclose");
-} /* test_attr_bug5() */
+} /* test_attr_bug5() */
/****************************************************************
**
@@ -10175,13 +10613,13 @@ test_attr_bug5(hid_t fcpl, hid_t fapl)
static void
test_attr_bug6(hid_t fcpl, hid_t fapl)
{
- hid_t fid; /* File ID */
- hid_t gid; /* Group ID */
- hid_t aid1, aid2; /* Attribute IDs */
- hid_t sid; /* Dataspace ID */
- hsize_t dims[ATTR1_RANK] = {ATTR1_DIM1}; /* Attribute dimensions */
- int intar[ATTR1_DIM1]; /* Data reading buffer */
- herr_t ret; /* Generic return status */
+ hid_t fid; /* File ID */
+ hid_t gid; /* Group ID */
+ hid_t aid1, aid2; /* Attribute IDs */
+ hid_t sid; /* Dataspace ID */
+ hsize_t dims[ATTR1_RANK] = {ATTR1_DIM1}; /* Attribute dimensions */
+ int intar[ATTR1_DIM1]; /* Data reading buffer */
+ herr_t ret; /* Generic return status */
/* Output message about test being performed */
MESSAGE(5, ("Testing that empty attribute can be read\n"));
@@ -10224,7 +10662,7 @@ test_attr_bug6(hid_t fcpl, hid_t fapl)
ret = H5Sclose(sid);
CHECK(ret, FAIL, "H5Sclose");
-} /* test_attr_bug6() */
+} /* test_attr_bug6() */
/****************************************************************
**
@@ -10239,19 +10677,18 @@ test_attr_bug6(hid_t fcpl, hid_t fapl)
static void
test_attr_bug7(hid_t fcpl, hid_t fapl)
{
- hid_t fid; /* File ID */
- hid_t aid; /* Attribute ID */
- hid_t sid; /* Dataspace ID */
- hid_t tid; /* Datatype ID */
- hsize_t dims_s = 140; /* Small attribute dimensions */
- hsize_t dims_l = 65480; /* Large attribute dimensions */
- H5A_info_t ainfo; /* Attribute info */
- herr_t ret; /* Generic return status */
+ hid_t fid; /* File ID */
+ hid_t aid; /* Attribute ID */
+ hid_t sid; /* Dataspace ID */
+ hid_t tid; /* Datatype ID */
+ hsize_t dims_s = 140; /* Small attribute dimensions */
+ hsize_t dims_l = 65480; /* Large attribute dimensions */
+ H5A_info_t ainfo; /* Attribute info */
+ herr_t ret; /* Generic return status */
/* Output message about test being performed */
MESSAGE(5, ("Testing adding and deleting large attributes\n"));
-
/* Create committed datatype to operate on. Use a committed datatype so that
* there is nothing after the object header and the first chunk can expand and
* contract as necessary. */
@@ -10287,8 +10724,9 @@ test_attr_bug7(hid_t fcpl, hid_t fapl)
CHECK(tid, FAIL, "H5Topen2");
ret = H5Aget_info_by_name(tid, ".", ATTR1_NAME, &ainfo, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Aget_info_by_name");
- if(ainfo.data_size != dims_s)
- TestErrPrintf("attribute data size different: data_size=%llu, should be %llu\n", (long long unsigned)ainfo.data_size, (long long unsigned)dims_s);
+ if (ainfo.data_size != dims_s)
+ TestErrPrintf("attribute data size different: data_size=%llu, should be %llu\n",
+ (long long unsigned)ainfo.data_size, (long long unsigned)dims_s);
/*
* Create another small attribute. Should cause chunk size field to expand by
@@ -10314,12 +10752,14 @@ test_attr_bug7(hid_t fcpl, hid_t fapl)
CHECK(tid, FAIL, "H5Topen2");
ret = H5Aget_info_by_name(tid, ".", ATTR1_NAME, &ainfo, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Aget_info_by_name");
- if(ainfo.data_size != dims_s)
- TestErrPrintf("attribute data size different: data_size=%llu, should be %llu\n", (long long unsigned)ainfo.data_size, (long long unsigned)dims_s);
+ if (ainfo.data_size != dims_s)
+ TestErrPrintf("attribute data size different: data_size=%llu, should be %llu\n",
+ (long long unsigned)ainfo.data_size, (long long unsigned)dims_s);
ret = H5Aget_info_by_name(tid, ".", ATTR2_NAME, &ainfo, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Aget_info_by_name");
- if(ainfo.data_size != dims_s)
- TestErrPrintf("attribute data size different: data_size=%llu, should be %llu\n", (long long unsigned)ainfo.data_size, (long long unsigned)dims_s);
+ if (ainfo.data_size != dims_s)
+ TestErrPrintf("attribute data size different: data_size=%llu, should be %llu\n",
+ (long long unsigned)ainfo.data_size, (long long unsigned)dims_s);
/*
* Create large attribute. Should cause chunk size field to expand by 2 bytes
@@ -10347,16 +10787,19 @@ test_attr_bug7(hid_t fcpl, hid_t fapl)
CHECK(tid, FAIL, "H5Topen2");
ret = H5Aget_info_by_name(tid, ".", ATTR1_NAME, &ainfo, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Aget_info_by_name");
- if(ainfo.data_size != dims_s)
- TestErrPrintf("attribute data size different: data_size=%llu, should be %llu\n", (long long unsigned)ainfo.data_size, (long long unsigned)dims_s);
+ if (ainfo.data_size != dims_s)
+ TestErrPrintf("attribute data size different: data_size=%llu, should be %llu\n",
+ (long long unsigned)ainfo.data_size, (long long unsigned)dims_s);
ret = H5Aget_info_by_name(tid, ".", ATTR2_NAME, &ainfo, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Aget_info_by_name");
- if(ainfo.data_size != dims_s)
- TestErrPrintf("attribute data size different: data_size=%llu, should be %llu\n", (long long unsigned)ainfo.data_size, (long long unsigned)dims_s);
+ if (ainfo.data_size != dims_s)
+ TestErrPrintf("attribute data size different: data_size=%llu, should be %llu\n",
+ (long long unsigned)ainfo.data_size, (long long unsigned)dims_s);
ret = H5Aget_info_by_name(tid, ".", ATTR3_NAME, &ainfo, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Aget_info_by_name");
- if(ainfo.data_size != dims_l)
- TestErrPrintf("attribute data size different: data_size=%llu, should be %llu\n", (long long unsigned)ainfo.data_size, (long long unsigned)dims_l);
+ if (ainfo.data_size != dims_l)
+ TestErrPrintf("attribute data size different: data_size=%llu, should be %llu\n",
+ (long long unsigned)ainfo.data_size, (long long unsigned)dims_l);
/*
* Delete last two attributes - should merge into a null message that is too
@@ -10384,8 +10827,9 @@ test_attr_bug7(hid_t fcpl, hid_t fapl)
CHECK(tid, FAIL, "H5Topen2");
ret = H5Aget_info_by_name(tid, ".", ATTR1_NAME, &ainfo, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Aget_info_by_name");
- if(ainfo.data_size != dims_s)
- TestErrPrintf("attribute data size different: data_size=%llu, should be %llu\n", (long long unsigned)ainfo.data_size, (long long unsigned)dims_s);
+ if (ainfo.data_size != dims_s)
+ TestErrPrintf("attribute data size different: data_size=%llu, should be %llu\n",
+ (long long unsigned)ainfo.data_size, (long long unsigned)dims_s);
/*
* Create large attribute. Should cause chunk size field to expand by 3 bytes
@@ -10411,12 +10855,14 @@ test_attr_bug7(hid_t fcpl, hid_t fapl)
CHECK(tid, FAIL, "H5Topen2");
ret = H5Aget_info_by_name(tid, ".", ATTR1_NAME, &ainfo, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Aget_info_by_name");
- if(ainfo.data_size != dims_s)
- TestErrPrintf("attribute data size different: data_size=%llu, should be %llu\n", (long long unsigned)ainfo.data_size, (long long unsigned)dims_s);
+ if (ainfo.data_size != dims_s)
+ TestErrPrintf("attribute data size different: data_size=%llu, should be %llu\n",
+ (long long unsigned)ainfo.data_size, (long long unsigned)dims_s);
ret = H5Aget_info_by_name(tid, ".", ATTR2_NAME, &ainfo, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Aget_info_by_name");
- if(ainfo.data_size != dims_l)
- TestErrPrintf("attribute data size different: data_size=%llu, should be %llu\n", (long long unsigned)ainfo.data_size, (long long unsigned)dims_l);
+ if (ainfo.data_size != dims_l)
+ TestErrPrintf("attribute data size different: data_size=%llu, should be %llu\n",
+ (long long unsigned)ainfo.data_size, (long long unsigned)dims_l);
/* Close IDs */
ret = H5Tclose(tid);
@@ -10425,7 +10871,7 @@ test_attr_bug7(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Sclose");
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
-} /* test_attr_bug7() */
+} /* test_attr_bug7() */
/****************************************************************
**
@@ -10444,21 +10890,21 @@ test_attr_bug7(hid_t fcpl, hid_t fapl)
static void
test_attr_bug8(hid_t fcpl, hid_t fapl)
{
- hid_t fid; /* File ID */
- hid_t aid; /* Attribute ID */
- hid_t sid; /* Dataspace ID */
- hid_t gid; /* Group ID */
- hid_t oid; /* Object ID */
- hsize_t dims = 256; /* Attribute dimensions */
- H5O_info_t oinfo; /* Object info */
- H5A_info_t ainfo; /* Attribute info */
- haddr_t root_addr; /* Root group address */
- herr_t ret; /* Generic return status */
+ hid_t fid; /* File ID */
+ hid_t aid; /* Attribute ID */
+ hid_t sid; /* Dataspace ID */
+ hid_t gid; /* Group ID */
+ hid_t oid; /* Object ID */
+ hsize_t dims = 256; /* Attribute dimensions */
+ H5O_info2_t oinfo; /* Object info */
+ H5A_info_t ainfo; /* Attribute info */
+ haddr_t root_addr; /* Root group address */
+ haddr_t link_addr; /* Link (to root group) address */
+ herr_t ret; /* Generic return status */
/* Output message about test being performed */
MESSAGE(5, ("Testing attribute expanding object header with undecoded messages\n"));
-
/* Create committed datatype to operate on. Use a committed datatype so that
* there is nothing after the object header and the first chunk can expand and
* contract as necessary. */
@@ -10468,9 +10914,10 @@ test_attr_bug8(hid_t fcpl, hid_t fapl)
CHECK(gid, FAIL, "H5Gcreate2");
/* Get root group address */
- ret = H5Oget_info(fid, &oinfo);
+ ret = H5Oget_info3(fid, &oinfo, H5O_INFO_BASIC);
CHECK(ret, FAIL, "H5Oget_info");
- root_addr = oinfo.addr;
+ ret = H5VLnative_token_to_addr(fid, oinfo.token, &root_addr);
+ CHECK(ret, FAIL, "H5VLnative_token_to_addr");
/*
* Create link to root group
@@ -10493,10 +10940,13 @@ test_attr_bug8(hid_t fcpl, hid_t fapl)
CHECK(gid, FAIL, "H5Gopen2");
oid = H5Oopen(gid, LINK1_NAME, H5P_DEFAULT);
CHECK(oid, FAIL, "H5Oopen");
- ret = H5Oget_info(oid, &oinfo);
+ ret = H5Oget_info3(oid, &oinfo, H5O_INFO_BASIC);
CHECK(ret, FAIL, "H5Oget_info");
- if(oinfo.addr != root_addr)
- TestErrPrintf("incorrect link target address: addr: %llu, expected: %llu\n", (long long unsigned)oinfo.addr, (long long unsigned)root_addr);
+ ret = H5VLnative_token_to_addr(fid, oinfo.token, &link_addr);
+ CHECK(ret, FAIL, "H5VLnative_token_to_addr");
+ if (link_addr != root_addr)
+ TestErrPrintf("incorrect link target address: addr: %llu, expected: %llu\n",
+ (long long unsigned)link_addr, (long long unsigned)root_addr);
/* Close file */
ret = H5Fclose(fid);
@@ -10538,14 +10988,18 @@ test_attr_bug8(hid_t fcpl, hid_t fapl)
CHECK(gid, FAIL, "H5Gopen2");
oid = H5Oopen(gid, LINK1_NAME, H5P_DEFAULT);
CHECK(oid, FAIL, "H5Oopen");
- ret = H5Oget_info(oid, &oinfo);
+ ret = H5Oget_info3(oid, &oinfo, H5O_INFO_BASIC);
CHECK(ret, FAIL, "H5Oget_info");
- if(oinfo.addr != root_addr)
- TestErrPrintf("incorrect link target address: addr: %llu, expected: %llu\n", (long long unsigned)oinfo.addr, (long long unsigned)root_addr);
+ ret = H5VLnative_token_to_addr(fid, oinfo.token, &link_addr);
+ CHECK(ret, FAIL, "H5VLnative_token_to_addr");
+ if (link_addr != root_addr)
+ TestErrPrintf("incorrect link target address: addr: %llu, expected: %llu\n",
+ (long long unsigned)link_addr, (long long unsigned)root_addr);
ret = H5Aget_info_by_name(gid, ".", ATTR1_NAME, &ainfo, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Aget_info_by_name");
- if(ainfo.data_size != dims)
- TestErrPrintf("attribute data size different: data_size=%llu, should be %llu\n", (long long unsigned)ainfo.data_size, (long long unsigned)dims);
+ if (ainfo.data_size != dims)
+ TestErrPrintf("attribute data size different: data_size=%llu, should be %llu\n",
+ (long long unsigned)ainfo.data_size, (long long unsigned)dims);
/* Close IDs */
ret = H5Oclose(oid);
@@ -10556,7 +11010,264 @@ test_attr_bug8(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Sclose");
ret = H5Fclose(fid);
CHECK(ret, FAIL, "H5Fclose");
-} /* test_attr_bug8() */
+} /* test_attr_bug8() */
+
+/****************************************************************
+**
+** test_attr_bug9(): Test basic H5A (attribute) code.
+** (Really tests object header code).
+** Tests adding several large attributes to an object until
+** they convert to dense storage. The total size of all
+** attributes is larger than 64K, causing the internal
+** object header code to, after merging the deleted
+** messages in to a NULL message, shrink the object header
+** chunk. Do this twice: once with only attributes in the
+** object header chunk and once with a (small) soft link in
+** the chunk as well. In both cases, the shrunk chunk will
+** initially be too small and a new NULL message must be
+** created.
+**
+****************************************************************/
+static void
+test_attr_bug9(hid_t fcpl, hid_t fapl)
+{
+ hid_t fid = -1; /* File ID */
+ hid_t gid = -1; /* Group ID */
+ hid_t aid = -1; /* Attribute ID */
+ hid_t sid = -1; /* Dataspace ID */
+ hsize_t dims[1] = {32768}; /* Attribute dimensions */
+ int create_link; /* Whether to create a soft link */
+ unsigned max_compact; /* Setting from fcpl */
+ unsigned min_dense; /* Setting from fcpl */
+ char aname[11]; /* Attribute name */
+ unsigned i; /* Local index variable */
+ herr_t ret; /* Generic return status */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing that attributes can always be added to named datatypes\n"));
+
+ /* Create dataspace */
+ sid = H5Screate_simple(1, dims, NULL);
+ CHECK(sid, FAIL, "H5Screate_simple");
+
+ /* Obtain attribute phase change settings */
+ ret = H5Pget_attr_phase_change(fcpl, &max_compact, &min_dense);
+ CHECK(ret, FAIL, "H5Pget_attr_phase_change");
+
+ /* Run with and without the soft link */
+ for (create_link = 0; create_link < 2; create_link++) {
+ /* Create file */
+ fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl);
+ CHECK(fid, FAIL, "H5Fcreate");
+
+ /* Create second group */
+ gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(gid, FAIL, "H5Gcreate2");
+
+ /* Close second group */
+ ret = H5Gclose(gid);
+ CHECK(ret, FAIL, "H5Gclose");
+
+ /* Open root group */
+ gid = H5Gopen2(fid, "/", H5P_DEFAULT);
+ CHECK(gid, FAIL, "H5Gopen2");
+
+ /* Create enough attributes to cause a change to dense storage */
+ for (i = 0; i < max_compact + 1; i++) {
+ /* Create attribute */
+ HDsnprintf(aname, sizeof(aname), "%u", i);
+ aid = H5Acreate2(gid, aname, H5T_NATIVE_CHAR, sid, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(aid, FAIL, "H5Acreate2");
+
+ /* Close attribute */
+ ret = H5Aclose(aid);
+ CHECK(ret, FAIL, "H5Aclose");
+
+ /* Create enough soft links that exactly one goes into chunk 1 if
+ * requested */
+ if (i == 0 && create_link) {
+ ret = H5Lcreate_soft("b", gid, "a", H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Lcreate_soft");
+ ret = H5Lcreate_soft("d", gid, "c", H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Lcreate_soft");
+ ret = H5Lcreate_soft("f", gid, "e", H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Lcreate_soft");
+ } /* end if */
+ } /* end for */
+
+ /* Close IDs */
+ ret = H5Gclose(gid);
+ CHECK(ret, FAIL, "H5Gclose");
+
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+ } /* end for */
+
+ /* Close dataspace */
+ ret = H5Sclose(sid);
+ CHECK(ret, FAIL, "H5Sclose");
+} /* test_attr_bug9() */
+
+/****************************************************************
+**
+** test_attr_bug10(): Test basic H5A (attribute) code.
+** Attempts to trigger a bug which would result in a
+** segfault. Create a vlen attribute through a file
+** handle, then open the same file through a different
+** handle, open the same attribute through the second file
+** handle, then close the second file and attribute
+** handles, then write to the attribute through the first
+** handle.
+**
+****************************************************************/
+static void
+test_attr_bug10(hid_t fcpl, hid_t fapl)
+{
+ hid_t fid1, fid2; /* File IDs */
+ hid_t aid1, aid2; /* Attribute IDs */
+ hid_t sid; /* Dataspace ID */
+ hid_t tid; /* Datatype ID */
+ hsize_t dims[1] = {1}; /* Attribute dimensions */
+ const char *wbuf[1] = {"foo"}; /* Write buffer */
+ herr_t ret; /* Generic return status */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing that vlen attributes can be written to after a second file handle is closed\n"));
+
+ /* Create dataspace */
+ sid = H5Screate_simple(1, dims, NULL);
+ CHECK(sid, FAIL, "H5Screate_simple");
+
+ /* Create VL string datatype */
+ tid = H5Tcopy(H5T_C_S1);
+ CHECK(tid, FAIL, "H5Tcreate");
+ ret = H5Tset_size(tid, H5T_VARIABLE);
+ CHECK(ret, FAIL, "H5Tset_size");
+
+ /* Create file */
+ fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl);
+ CHECK(fid1, FAIL, "H5Fcreate");
+
+ /* Create attribute on root group */
+ aid1 = H5Acreate2(fid1, "attr", tid, sid, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(aid1, FAIL, "H5Acreate2");
+
+ /* Open the same file again */
+ fid2 = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
+ CHECK(fid2, FAIL, "H5Fcreate");
+
+ /* Open the same attribute through the second file handle */
+ aid2 = H5Aopen(fid2, "attr", H5P_DEFAULT);
+ CHECK(aid2, FAIL, "H5Aopen");
+
+ /* Close the second attribute and file handles */
+ ret = H5Aclose(aid2);
+ CHECK(ret, FAIL, "H5Aclose");
+ ret = H5Fclose(fid2);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Write to the attribute through the first handle */
+ ret = H5Awrite(aid1, tid, wbuf);
+
+ /* Close IDs */
+ ret = H5Aclose(aid1);
+ CHECK(ret, FAIL, "H5Aclose");
+
+ ret = H5Fclose(fid1);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ ret = H5Tclose(tid);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ ret = H5Sclose(sid);
+ CHECK(ret, FAIL, "H5Sclose");
+} /* test_attr_bug10() */
+
+/****************************************************************
+**
+** test_attr_delete_dense():
+** This is to verify the error as described in HDFFV-9277
+** is fixed when deleting the last "large" attribute that
+** is stored densely.
+**
+****************************************************************/
+static void
+test_attr_delete_last_dense(hid_t fcpl, hid_t fapl)
+{
+ hid_t fid; /* File ID */
+ hid_t gid; /* Group ID */
+ hid_t aid; /* Attribute ID */
+ hid_t sid; /* Dataspace ID */
+ hsize_t dim2[2] = {DIM0, DIM1}; /* Dimension sizes */
+ int i, j; /* Local index variables */
+ double *data = NULL; /* Pointer to the data buffer */
+ herr_t ret; /* Generic return status */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing Deleting the last large attribute stored densely\n"));
+
+ /* Create the file */
+ fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl);
+ CHECK(fid, FAIL, "H5Fcreate");
+
+ /* Create the group */
+ gid = H5Gcreate2(fid, GRPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(gid, FAIL, "H5Gcreate");
+
+ /* Create the dataspace */
+ sid = H5Screate_simple(RANK, dim2, NULL);
+ CHECK(sid, FAIL, "H5Screate_simple");
+
+ /* Attach the attribute to the group */
+ aid = H5Acreate2(gid, ATTRNAME, H5T_IEEE_F64LE, sid, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(aid, FAIL, "H5Acreate2");
+
+ /* Allocate the data buffer */
+ data = (double *)HDmalloc((size_t)(DIM0 * DIM1) * sizeof(double));
+ CHECK_PTR(data, "HDmalloc");
+
+ /* Initialize the data */
+ for (i = 0; i < DIM0; i++)
+ for (j = 0; j < DIM1; j++)
+ *(data + i * DIM1 + j) = i + j;
+
+ /* Write to the attribute */
+ ret = H5Awrite(aid, H5T_NATIVE_DOUBLE, data);
+ CHECK(ret, FAIL, "H5Awrite");
+
+ /* Closing */
+ ret = H5Aclose(aid);
+ CHECK(ret, FAIL, "H5Aclose");
+ ret = H5Sclose(sid);
+ CHECK(ret, FAIL, "H5Sclose");
+ ret = H5Gclose(gid);
+ CHECK(ret, FAIL, "H5Gclose");
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Re-open the file */
+ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
+ CHECK(fid, FAIL, "H5Fopen");
+
+ /* Open the group */
+ gid = H5Gopen2(fid, GRPNAME, H5P_DEFAULT);
+ CHECK(gid, FAIL, "H5Gopen");
+
+ /* Delete the attribute */
+ ret = H5Adelete(gid, ATTRNAME);
+ CHECK(ret, FAIL, "H5Adelete");
+
+ /* Closing */
+ ret = H5Gclose(gid);
+ CHECK(ret, FAIL, "H5Gclose");
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Free the data buffer */
+ if (data)
+ HDfree(data);
+
+} /* test_attr_delete_last_dense() */
/****************************************************************
**
@@ -10566,176 +11277,209 @@ test_attr_bug8(hid_t fcpl, hid_t fapl)
void
test_attr(void)
{
- hid_t fapl = (-1), fapl2 = (-1); /* File access property lists */
- hid_t fcpl = (-1), fcpl2 = (-1); /* File creation property lists */
- hbool_t new_format; /* Whether to use the new format or not */
- hbool_t use_shared; /* Whether to use shared attributes or not */
- herr_t ret; /* Generic return value */
+ hid_t fapl = (-1), fapl2 = (-1); /* File access property lists */
+ hid_t fcpl = (-1), fcpl2 = (-1); /* File creation property lists */
+ hid_t dcpl = -1; /* Dataset creation property list */
+ unsigned new_format; /* Whether to use the new format or not */
+ unsigned use_shared; /* Whether to use shared attributes or not */
+ unsigned minimize_dset_oh; /* Whether to use minimized dataset object headers */
+ herr_t ret; /* Generic return value */
- /* Output message about test being performed */
MESSAGE(5, ("Testing Attributes\n"));
- /* Create a default file access property list */
fapl = H5Pcreate(H5P_FILE_ACCESS);
CHECK(fapl, FAIL, "H5Pcreate");
- /* Copy the file access property list */
+ /* fapl2 uses "latest version of the format" for creating objects in the file */
fapl2 = H5Pcopy(fapl);
CHECK(fapl2, FAIL, "H5Pcopy");
-
- /* Set the "use the latest version of the format" bounds for creating objects in the file */
ret = H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST);
CHECK(ret, FAIL, "H5Pset_libver_bounds");
- /* Create a default file creation property list */
fcpl = H5Pcreate(H5P_FILE_CREATE);
CHECK(fcpl, FAIL, "H5Pcreate");
- /* Copy the file creation property list */
+ /* files with fcpl2 make all attributes ( > 1 byte) shared
+ * (i.e. all of them :-) */
fcpl2 = H5Pcopy(fcpl);
CHECK(fcpl2, FAIL, "H5Pcopy");
-
- /* Make attributes > 1 byte shared (i.e. all of them :-) */
ret = H5Pset_shared_mesg_nindexes(fcpl2, (unsigned)1);
CHECK_I(ret, "H5Pset_shared_mesg_nindexes");
ret = H5Pset_shared_mesg_index(fcpl2, (unsigned)0, H5O_SHMESG_ATTR_FLAG, (unsigned)1);
CHECK_I(ret, "H5Pset_shared_mesg_index");
- /* Loop over using new group format */
- for(new_format = FALSE; new_format <= TRUE; new_format++) {
- hid_t my_fapl;
-
- /* Set the FAPL for the type of format */
- if(new_format) {
- MESSAGE(7, ("testing with new file format\n"));
- my_fapl = fapl2;
- } /* end if */
+ for (minimize_dset_oh = 0; minimize_dset_oh <= 1; minimize_dset_oh++) {
+ if (minimize_dset_oh == 0) {
+ MESSAGE(7, ("testing with default dataset object headers\n"));
+ dcpl_g = H5P_DEFAULT;
+ }
else {
- MESSAGE(7, ("testing with old file format\n"));
- my_fapl = fapl;
- } /* end else */
+ MESSAGE(7, ("testing with minimzied dataset object headers\n"));
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ ret = H5Pset_dset_no_attrs_hint(dcpl, TRUE);
+ CHECK_I(ret, "H5Pset_dset_no_attrs_hint");
+ dcpl_g = dcpl;
+ }
+
+ for (new_format = FALSE; new_format <= TRUE; new_format++) {
+ hid_t my_fapl;
+
+ /* Set the FAPL for the type of format */
+ if (new_format) {
+ MESSAGE(7, ("testing with new file format\n"));
+ my_fapl = fapl2;
+ }
+ else {
+ MESSAGE(7, ("testing with old file format\n"));
+ my_fapl = fapl;
+ }
- /* These next two tests use the same file information */
- test_attr_basic_write(my_fapl); /* Test basic H5A writing code */
- test_attr_basic_read(my_fapl); /* Test basic H5A reading code */
+ /* These next two tests use the same file information */
+ test_attr_basic_write(my_fapl); /* Test basic H5A writing code */
+ test_attr_basic_read(my_fapl); /* Test basic H5A reading code */
- /* These next two tests use their own file information */
- test_attr_flush(my_fapl); /* Test H5A I/O in the presence of H5Fflush calls */
- test_attr_plist(my_fapl); /* Test attribute property lists */
+ /* These next two tests use their own file information */
+ test_attr_flush(my_fapl); /* Test H5A I/O in the presence of H5Fflush calls */
+ test_attr_plist(my_fapl); /* Test attribute property lists */
- /* These next two tests use the same file information */
- test_attr_compound_write(my_fapl); /* Test complex datatype H5A writing code */
- test_attr_compound_read(my_fapl); /* Test complex datatype H5A reading code */
+ /* These next two tests use the same file information */
+ test_attr_compound_write(my_fapl); /* Test complex datatype H5A writing code */
+ test_attr_compound_read(my_fapl); /* Test complex datatype H5A reading code */
- /* These next two tests use the same file information */
- test_attr_scalar_write(my_fapl); /* Test scalar dataspace H5A writing code */
- test_attr_scalar_read(my_fapl); /* Test scalar dataspace H5A reading code */
+ /* These next two tests use the same file information */
+ test_attr_scalar_write(my_fapl); /* Test scalar dataspace H5A writing code */
+ test_attr_scalar_read(my_fapl); /* Test scalar dataspace H5A reading code */
- /* These next four tests use the same file information */
- test_attr_mult_write(my_fapl); /* Test H5A writing code for multiple attributes */
- test_attr_mult_read(my_fapl); /* Test H5A reading code for multiple attributes */
- test_attr_iterate(my_fapl); /* Test H5A iterator code */
- test_attr_delete(my_fapl); /* Test H5A code for deleting attributes */
+ /* These next four tests use the same file information */
+ test_attr_mult_write(my_fapl); /* Test H5A writing code for multiple attributes */
+ test_attr_mult_read(my_fapl); /* Test H5A reading code for multiple attributes */
+ test_attr_iterate(my_fapl); /* Test H5A iterator code */
+ test_attr_delete(my_fapl); /* Test H5A code for deleting attributes */
- /* This next test uses its own file information */
- test_attr_dtype_shared(my_fapl); /* Test using shared dataypes in attributes */
+ /* This next test uses its own file information */
+ test_attr_dtype_shared(my_fapl); /* Test using shared dataypes in attributes */
- /* This next test uses its own file information */
- test_attr_duplicate_ids(my_fapl);
+ /* This next test uses its own file information */
+ test_attr_duplicate_ids(my_fapl);
- /* Tests on "new format" attribute storage */
- if(new_format == TRUE) {
- /* Loop over using shared attributes */
- for(use_shared = FALSE; use_shared <= TRUE; use_shared++) {
+ for (use_shared = FALSE; use_shared <= TRUE; use_shared++) {
hid_t my_fcpl;
- /* Set the FCPL for shared or not */
- if(use_shared) {
+ if (new_format == TRUE && use_shared) {
MESSAGE(7, ("testing with shared attributes\n"));
my_fcpl = fcpl2;
- } /* end if */
+ }
else {
MESSAGE(7, ("testing without shared attributes\n"));
my_fcpl = fcpl;
- } /* end else */
-
- /* General attribute tests */
- test_attr_dense_create(my_fcpl, my_fapl); /* Test dense attribute storage creation */
- test_attr_dense_open(my_fcpl, my_fapl); /* Test opening attributes in dense storage */
- test_attr_dense_delete(my_fcpl, my_fapl); /* Test deleting attributes in dense storage */
- test_attr_dense_rename(my_fcpl, my_fapl); /* Test renaming attributes in dense storage */
- test_attr_dense_unlink(my_fcpl, my_fapl); /* Test unlinking object with attributes in dense storage */
- test_attr_dense_limits(my_fcpl, my_fapl); /* Test dense attribute storage limits */
- test_attr_dense_dup_ids(my_fcpl, my_fapl); /* Test duplicated IDs for dense attribute storage */
-
- test_attr_big(my_fcpl, my_fapl); /* Test storing big attribute */
- test_attr_null_space(my_fcpl, my_fapl); /* Test storing attribute with NULL dataspace */
- test_attr_deprec(fcpl, my_fapl); /* Test deprecated API routines */
- test_attr_many(new_format, my_fcpl, my_fapl); /* Test storing lots of attributes */
-
- /* Attribute creation order tests */
- test_attr_corder_create_basic(my_fcpl, my_fapl);/* Test creating an object w/attribute creation order info */
- test_attr_corder_create_compact(my_fcpl, my_fapl); /* Test compact attribute storage on an object w/attribute creation order info */
- test_attr_corder_create_dense(my_fcpl, my_fapl);/* Test dense attribute storage on an object w/attribute creation order info */
- test_attr_corder_create_reopen(my_fcpl, my_fapl);/* Test creating attributes w/reopening file from using new format to using old format */
- test_attr_corder_transition(my_fcpl, my_fapl); /* Test attribute storage transitions on an object w/attribute creation order info */
- test_attr_corder_delete(my_fcpl, my_fapl); /* Test deleting object using dense storage w/attribute creation order info */
+ }
+
+ test_attr_big(my_fcpl, my_fapl); /* Test storing big attribute */
+ test_attr_null_space(my_fcpl, my_fapl); /* Test storing attribute with NULL dataspace */
+ test_attr_deprec(fcpl, my_fapl); /* Test deprecated API routines */
+ test_attr_many(new_format, my_fcpl, my_fapl); /* Test storing lots of attributes */
+ test_attr_info_null_info_pointer(my_fcpl,
+ my_fapl); /* Test passing a NULL attribute info pointer to
+ H5Aget_info(_by_name/_by_idx) */
+ test_attr_rename_invalid_name(
+ my_fcpl,
+ my_fapl); /* Test passing a NULL or empty attribute name to H5Arename(_by_name) */
+ test_attr_get_name_invalid_buf(
+ my_fcpl, my_fapl); /* Test passing NULL buffer to H5Aget_name(_by_idx) */
/* New attribute API routine tests */
- test_attr_info_by_idx(new_format, my_fcpl, my_fapl); /* Test querying attribute info by index */
- test_attr_delete_by_idx(new_format, my_fcpl, my_fapl); /* Test deleting attribute by index */
- test_attr_iterate2(new_format, my_fcpl, my_fapl); /* Test iterating over attributes by index */
+ test_attr_info_by_idx(new_format, my_fcpl,
+ my_fapl); /* Test querying attribute info by index */
+ test_attr_delete_by_idx(new_format, my_fcpl, my_fapl); /* Test deleting attribute by index */
+ test_attr_iterate2(new_format, my_fcpl,
+ my_fapl); /* Test iterating over attributes by index */
test_attr_open_by_idx(new_format, my_fcpl, my_fapl); /* Test opening attributes by index */
test_attr_open_by_name(new_format, my_fcpl, my_fapl); /* Test opening attributes by name */
test_attr_create_by_name(new_format, my_fcpl, my_fapl); /* Test creating attributes by name */
- /* More complex tests with both "new format" and "shared" attributes */
- if(use_shared == TRUE) {
- test_attr_shared_write(my_fcpl, my_fapl); /* Test writing to shared attributes in compact & dense storage */
- test_attr_shared_rename(my_fcpl, my_fapl); /* Test renaming shared attributes in compact & dense storage */
- test_attr_shared_delete(my_fcpl, my_fapl); /* Test deleting shared attributes in compact & dense storage */
- test_attr_shared_unlink(my_fcpl, my_fapl); /* Test unlinking object with shared attributes in compact & dense storage */
- } /* end if */
-
/* Tests that address specific bugs */
- test_attr_bug1(my_fcpl, my_fapl); /* Test odd allocation operations */
- test_attr_bug2(my_fcpl, my_fapl); /* Test many deleted attributes */
- test_attr_bug3(my_fcpl, my_fapl); /* Test "self referential" attributes */
- test_attr_bug4(my_fcpl, my_fapl); /* Test attributes on named datatypes */
- test_attr_bug5(my_fcpl, my_fapl); /* Test opening/closing attributes through different file handles */
- test_attr_bug6(my_fcpl, my_fapl); /* Test reading empty attribute */
- test_attr_bug7(my_fcpl, my_fapl); /* Test creating and deleting large attributes in ohdr chunk 0 */
- test_attr_bug8(my_fcpl, my_fapl); /* Test attribute expanding object header with undecoded messages */
- } /* end for */
- } /* end if */
- else {
- /* General attribute tests */
- test_attr_big(fcpl, my_fapl); /* Test storing big attribute */
- test_attr_null_space(fcpl, my_fapl); /* Test storing attribute with NULL dataspace */
- test_attr_deprec(fcpl, my_fapl); /* Test deprecated API routines */
- test_attr_many(new_format, fcpl, my_fapl); /* Test storing lots of attributes */
-
- /* New attribute API routine tests, on old-format storage */
- test_attr_info_by_idx(new_format, fcpl, my_fapl); /* Test querying attribute info by index */
- test_attr_delete_by_idx(new_format, fcpl, my_fapl); /* Test deleting attribute by index */
- test_attr_iterate2(new_format, fcpl, my_fapl); /* Test iterating over attributes by index */
- test_attr_open_by_idx(new_format, fcpl, my_fapl); /* Test opening attributes by index */
- test_attr_open_by_name(new_format, fcpl, my_fapl); /* Test opening attributes by name */
- test_attr_create_by_name(new_format, fcpl, my_fapl); /* Test creating attributes by name */
-
- /* Tests that address specific bugs */
- test_attr_bug1(fcpl, my_fapl); /* Test odd allocation operations */
- test_attr_bug2(fcpl, my_fapl); /* Test many deleted attributes */
- test_attr_bug3(fcpl, my_fapl); /* Test "self referential" attributes */
- test_attr_bug4(fcpl, my_fapl); /* Test attributes on named datatypes */
- test_attr_bug5(fcpl, my_fapl); /* Test opening/closing attributes through different file handles */
- test_attr_bug6(fcpl, my_fapl); /* Test reading empty attribute */
- /* Skip test_attr_bug7 because it is specific to the new object
- * header format and in fact fails if used with the old format, due
- * to the attributes being larger than 64K */
- test_attr_bug8(fcpl, my_fapl); /* Test attribute expanding object header with undecoded messages */
- } /* end else */
- } /* end for */
+ test_attr_bug1(my_fcpl, my_fapl); /* Test odd allocation operations */
+ test_attr_bug2(my_fcpl, my_fapl); /* Test many deleted attributes */
+ test_attr_bug3(my_fcpl, my_fapl); /* Test "self referential" attributes */
+ test_attr_bug4(my_fcpl, my_fapl); /* Test attributes on named datatypes */
+ test_attr_bug5(my_fcpl,
+ my_fapl); /* Test opening/closing attributes through different file handles */
+ test_attr_bug6(my_fcpl, my_fapl); /* Test reading empty attribute */
+ /* test_attr_bug7 is specific to the "new" object header format,
+ * and in fact fails if used with the old format due to the
+ * attributes being larger than 64K */
+ test_attr_bug8(my_fcpl,
+ my_fapl); /* Test attribute expanding object header with undecoded messages */
+ test_attr_bug9(my_fcpl, my_fapl); /* Test large attributes converting to dense storage */
+ test_attr_bug10(my_fcpl, my_fapl); /* Test writing an attribute after opening and closing
+ through a different file handle */
+
+ /* tests specific to the "new format" */
+ if (new_format == TRUE) {
+ /* General attribute tests */
+ test_attr_dense_create(my_fcpl, my_fapl); /* Test dense attribute storage creation */
+ test_attr_dense_open(my_fcpl, my_fapl); /* Test opening attributes in dense storage */
+ test_attr_dense_delete(my_fcpl, my_fapl); /* Test deleting attributes in dense storage */
+ test_attr_dense_rename(my_fcpl, my_fapl); /* Test renaming attributes in dense storage */
+ test_attr_dense_unlink(
+ my_fcpl, my_fapl); /* Test unlinking object with attributes in dense storage */
+ test_attr_dense_limits(my_fcpl, my_fapl); /* Test dense attribute storage limits */
+ test_attr_dense_dup_ids(my_fcpl,
+ my_fapl); /* Test duplicated IDs for dense attribute storage */
+
+ /* Attribute creation order tests */
+ test_attr_corder_create_basic(
+ my_fcpl, my_fapl); /* Test creating an object w/attribute creation order info */
+ test_attr_corder_create_compact(my_fcpl,
+ my_fapl); /* Test compact attribute storage on an object
+ w/attribute creation order info */
+ test_attr_corder_create_dense(my_fcpl,
+ my_fapl); /* Test dense attribute storage on an object
+ w/attribute creation order info */
+ test_attr_corder_create_reopen(my_fcpl,
+ my_fapl); /* Test creating attributes w/reopening file from
+ using new format to using old format */
+ test_attr_corder_transition(my_fcpl,
+ my_fapl); /* Test attribute storage transitions on an object
+ w/attribute creation order info */
+ test_attr_corder_delete(my_fcpl, my_fapl); /* Test deleting object using dense storage
+ w/attribute creation order info */
+
+ /* More complex tests with exclusively both "new format" and "shared" attributes */
+ if (use_shared == TRUE) {
+ test_attr_shared_write(
+ my_fcpl,
+ my_fapl); /* Test writing to shared attributes in compact & dense storage */
+ test_attr_shared_rename(
+ my_fcpl,
+ my_fapl); /* Test renaming shared attributes in compact & dense storage */
+ test_attr_shared_delete(
+ my_fcpl,
+ my_fapl); /* Test deleting shared attributes in compact & dense storage */
+ test_attr_shared_unlink(my_fcpl, my_fapl); /* Test unlinking object with shared
+ attributes in compact & dense storage */
+ } /* if using shared attributes */
+
+ test_attr_delete_last_dense(my_fcpl, my_fapl);
+
+ /* test_attr_bug7 is specific to the "new" object header format,
+ * and in fact fails if used with the old format due to the
+ * attributes being larger than 64K */
+ test_attr_bug7(my_fcpl,
+ my_fapl); /* Test creating and deleting large attributes in ohdr chunk 0 */
+
+ } /* if using "new format" */
+ } /* for unshared/shared attributes */
+ } /* for old/new format */
+
+ if (minimize_dset_oh != 0) {
+ ret = H5Pclose(dcpl);
+ CHECK(ret, FAIL, "H5Pclose");
+ dcpl_g = H5P_DEFAULT;
+ }
+
+ } /* for default/minimized dataset object headers */
/* Close FCPLs */
ret = H5Pclose(fcpl);
@@ -10748,17 +11492,16 @@ test_attr(void)
CHECK(ret, FAIL, "H5Pclose");
ret = H5Pclose(fapl2);
CHECK(ret, FAIL, "H5Pclose");
-} /* test_attr() */
+} /* test_attr() */
-
/*-------------------------------------------------------------------------
- * Function: cleanup_attr
+ * Function: cleanup_attr
*
- * Purpose: Cleanup temporary test files
+ * Purpose: Cleanup temporary test files
*
- * Return: none
+ * Return: none
*
- * Programmer: Albert Cheng
+ * Programmer: Albert Cheng
* July 2, 1998
*
* Modifications:
@@ -10768,6 +11511,5 @@ test_attr(void)
void
cleanup_attr(void)
{
- remove(FILENAME);
+ HDremove(FILENAME);
}
-