From 9c167bcfa76e4f8a7116a5b061546dfbb5dd27fe Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Mon, 11 Dec 2006 21:10:05 -0500 Subject: [svn-r13048] Description: Set up tests for next phase of testing dense attribute operations, with shared attributes. Other minor code cleanups... Tested on: Linux/32 2.6 (chicago) Linux/64 2.6 (chicago2) --- src/H5Pfcpl.c | 66 +++++++++++++++++++++++++++++------------------------------ test/tattr.c | 53 +++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 78 insertions(+), 41 deletions(-) diff --git a/src/H5Pfcpl.c b/src/H5Pfcpl.c index d487f29..51daa38 100644 --- a/src/H5Pfcpl.c +++ b/src/H5Pfcpl.c @@ -660,10 +660,10 @@ herr_t H5Pget_istore_k(hid_t plist_id, unsigned *ik /*out */ ) { unsigned btree_k[H5B_NUM_BTREE_ID]; - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value=SUCCEED; /* return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API(H5Pget_istore_k, FAIL); + FUNC_ENTER_API(H5Pget_istore_k, FAIL) H5TRACE2("e","ix",plist_id,ik); /* Get the plist structure */ @@ -671,15 +671,15 @@ H5Pget_istore_k(hid_t plist_id, unsigned *ik /*out */ ) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Get value */ - if (ik) { + if(ik) { if(H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get rank for btree interanl nodes"); *ik = btree_k[H5B_ISTORE_ID]; - } + } /* end if */ done: - FUNC_LEAVE_API(ret_value); -} + FUNC_LEAVE_API(ret_value) +} /* end H5Pget_istore_k() */ /*------------------------------------------------------------------------- @@ -716,15 +716,15 @@ H5Pset_shared_mesgs(hid_t plist_id, unsigned nindexes, const unsigned mesg_type_ unsigned flags_used; /* type flags already specified. * Used to make sure a flag isn't used twice. */ - herr_t ret_value=SUCCEED; /* return value */ + herr_t ret_value = SUCCEED; /* return value */ - FUNC_ENTER_API(H5Pset_shared_mesgs, FAIL); + FUNC_ENTER_API(H5Pset_shared_mesgs, FAIL) H5TRACE3("e","iIu*Iu",plist_id,nindexes,mesg_type_flags); /* Check arguments */ - if (nindexes > H5SM_MAX_NUM_INDEXES) + if(nindexes > H5SM_MAX_NUM_INDEXES) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "number of indexes is too large"); - if (nindexes > 0 && !mesg_type_flags) + if(nindexes > 0 && !mesg_type_flags) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no type flags specified"); /* Get the plist structure */ @@ -732,26 +732,26 @@ H5Pset_shared_mesgs(hid_t plist_id, unsigned nindexes, const unsigned mesg_type_ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); flags_used = H5O_MESG_NONE_FLAG; - - for (i=0; i nindexes) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "index_num is greater than number of indexes in property list"); @@ -890,11 +891,10 @@ H5Pset_shared_mesg_index(hid_t plist_id, unsigned index_num, unsigned mesg_type_ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set min mesg sizes"); done: - FUNC_LEAVE_API(ret_value); -} + FUNC_LEAVE_API(ret_value) +} /* end H5Pset_shared_mesg_index() */ - /*------------------------------------------------------------------------- * Function: H5Pget_shared_mesg_index * diff --git a/test/tattr.c b/test/tattr.c index 12eebec..04350a8 100644 --- a/test/tattr.c +++ b/test/tattr.c @@ -1688,7 +1688,7 @@ test_attr_dtype_shared(hid_t fapl) ** ****************************************************************/ static void -test_attr_dense_create(hid_t fapl) +test_attr_dense_create(hid_t fcpl, hid_t fapl) { hid_t fid; /* HDF5 File ID */ hid_t dataset; /* Dataset ID */ @@ -1794,7 +1794,7 @@ HDfprintf(stderr, "max_compact = %u, min_dense = %u\n", max_compact, min_dense); ** ****************************************************************/ static void -test_attr_dense_open(hid_t fapl) +test_attr_dense_open(hid_t fcpl, hid_t fapl) { hid_t fid; /* HDF5 File ID */ hid_t dataset; /* Dataset ID */ @@ -1915,7 +1915,7 @@ HDfprintf(stderr, "max_compact = %u, min_dense = %u\n", max_compact, min_dense); ** ****************************************************************/ static void -test_attr_dense_delete(hid_t fapl) +test_attr_dense_delete(hid_t fcpl, hid_t fapl) { hid_t fid; /* HDF5 File ID */ hid_t dataset; /* Dataset ID */ @@ -2018,7 +2018,9 @@ void test_attr(void) { hid_t fapl = (-1), fapl2 = (-1); /* File access property lists */ - hbool_t new_format; /* Whether to use the new format or not */ + 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 */ /* Output message about test being performed */ @@ -2043,7 +2045,7 @@ test_attr(void) /* Set the FAPL for the type of format */ if(new_format) { - MESSAGE(7, ("testing with new file format\n")); + MESSAGE(7, ("testing with new file format\n")); my_fapl = fapl2; } /* end if */ else { @@ -2077,14 +2079,49 @@ test_attr(void) test_attr_dtype_shared(my_fapl); /* Test using shared dataypes in attributes */ } /* end for */ + /* Create a default file creation property list */ + fcpl = H5Pcreate(H5P_FILE_CREATE); + CHECK(fcpl, FAIL, "H5Pcreate"); + + /* Copy the file creation property list */ + 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)1, H5O_MESG_ATTR_FLAG, (unsigned)1); + CHECK_I(ret, "H5Pset_shared_mesg_index"); + /* Tests on "new format" attribute storage */ - test_attr_dense_create(fapl2); /* Test dense attribute storage creation */ - test_attr_dense_open(fapl2); /* Test opening attributes in dense storage */ - test_attr_dense_delete(fapl2); /* Test deleting attributes in dense storage */ + /* Loop over using shared attributes */ + for(use_shared = FALSE; use_shared <= TRUE; use_shared++) { + hid_t my_fcpl; + + /* Set the FCPL for shared or not */ + if(new_format) { + MESSAGE(7, ("testing with shared attributes\n")); + my_fcpl = fcpl2; + } /* end if */ + else { + MESSAGE(7, ("testing with shared attributes\n")); + my_fcpl = fcpl; + } /* end else */ + + test_attr_dense_create(my_fcpl, fapl2); /* Test dense attribute storage creation */ + test_attr_dense_open(my_fcpl, fapl2); /* Test opening attributes in dense storage */ + test_attr_dense_delete(my_fcpl, fapl2); /* Test deleting attributes in dense storage */ + } /* end for */ #else /* QAK */ HDfprintf(stderr, "Uncomment tests!\n"); #endif /* QAK */ + /* Close FCPLs */ + ret = H5Pclose(fcpl); + CHECK(ret, FAIL, "H5Pclose"); + ret = H5Pclose(fcpl2); + CHECK(ret, FAIL, "H5Pclose"); + /* Close FAPLs */ ret = H5Pclose(fapl); CHECK(ret, FAIL, "H5Pclose"); -- cgit v0.12