diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2005-11-16 00:52:42 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2005-11-16 00:52:42 (GMT) |
commit | e70783203ab603627147c565d0fe08ddbe103981 (patch) | |
tree | c9b996abe51516c398e16da488b226234e1a6d3b | |
parent | da16ec38eb79823243f5bcc6d70905ddfed31c53 (diff) | |
download | hdf5-e70783203ab603627147c565d0fe08ddbe103981.zip hdf5-e70783203ab603627147c565d0fe08ddbe103981.tar.gz hdf5-e70783203ab603627147c565d0fe08ddbe103981.tar.bz2 |
[svn-r11732] Purpose:
More tests
Description:
Add more tests for proper behavior of groups with different group
creation property settings.
Platforms tested:
FreeBSD 4.11 (sleipnir)
Linux 2.4
Solaris 2.8
-rw-r--r-- | src/H5Gpkg.h | 1 | ||||
-rw-r--r-- | src/H5Gtest.c | 46 | ||||
-rw-r--r-- | src/H5Pgcpl.c | 16 | ||||
-rw-r--r-- | test/stab.c | 51 |
4 files changed, 97 insertions, 17 deletions
diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h index ad65fc1..80a3413 100644 --- a/src/H5Gpkg.h +++ b/src/H5Gpkg.h @@ -404,6 +404,7 @@ H5_DLL herr_t H5G_loc_remove(H5G_loc_t *grp_loc, const char *name, H5_DLL htri_t H5G_is_empty_test(hid_t gid); H5_DLL htri_t H5G_has_links_test(hid_t gid, unsigned *nmsgs); H5_DLL htri_t H5G_has_stab_test(hid_t gid); +H5_DLL herr_t H5G_lheap_size_test(hid_t gid, size_t *lheap_size); #endif /* H5G_TESTING */ #endif diff --git a/src/H5Gtest.c b/src/H5Gtest.c index 6c7d3ee..73511a2 100644 --- a/src/H5Gtest.c +++ b/src/H5Gtest.c @@ -25,6 +25,7 @@ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Gpkg.h" /* Groups */ +#include "H5HLprivate.h" /* Local Heaps */ #include "H5Iprivate.h" /* IDs */ @@ -183,3 +184,48 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5G_has_stab_test() */ + +/*-------------------------------------------------------------------------- + NAME + H5G_lheap_size_test + PURPOSE + Determine the size of a local heap for a group + USAGE + herr_t H5G_lheap_size_test(gid, lheap_size) + hid_t gid; IN: group to check + size_t *lheap_size; OUT: Size of local heap + RETURNS + Non-negative on success, negative on failure + DESCRIPTION + Checks the size of the local heap for a group + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + DO NOT USE THIS FUNCTION FOR ANYTHING EXCEPT TESTING + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +herr_t +H5G_lheap_size_test(hid_t gid, size_t *lheap_size) +{ + H5G_t *grp = NULL; /* Pointer to group */ + H5O_stab_t stab; /* Symbol table message */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5G_lheap_size_test, FAIL) + + /* Get group structure */ + if(NULL == (grp = H5I_object_verify(gid, H5I_GROUP))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") + + /* Make certain the group has a symbol table message */ + if(NULL == H5O_read(&(grp->oloc), H5O_STAB_ID, 0, &stab, H5AC_dxpl_id)) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read symbol table message") + + /* Check the size of the local heap for the group */ + if(H5HL_get_size(grp->oloc.file, H5AC_dxpl_id, stab.heap_addr, lheap_size) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGETSIZE, FAIL, "can't query local heap size") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5G_lheap_size_test() */ + diff --git a/src/H5Pgcpl.c b/src/H5Pgcpl.c index 388d453..c2a5688 100644 --- a/src/H5Pgcpl.c +++ b/src/H5Pgcpl.c @@ -30,8 +30,6 @@ * * Purpose: Set the "size hint" for creating local heaps for a group. * - * Note: XXX: Add [meaningful] tests for this routine! -QAK - * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol @@ -73,8 +71,6 @@ done: * Purpose: Returns the local heap size hint, which is used for creating * groups * - * Note: XXX: Add [meaningful] tests for this routine! -QAK - * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol @@ -118,8 +114,6 @@ done: * * Note: Currently both of these must be updated at the same time. * - * Note: XXX: Add [meaningful] tests for this routine! -QAK - * * Note: Come up with better name & description! -QAK * * Return: Non-negative on success/Negative on failure @@ -164,8 +158,6 @@ done: * Purpose: Returns the max. # of compact links & the min. # of dense * links, which are used for storing groups * - * Note: XXX: Add [meaningful] tests for this routine! -QAK - * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol @@ -211,10 +203,8 @@ done: * * Note: Currently both of these must be updated at the same time. * - * Note: EST_NUM_ENTRIES applies only when the number of entries than - * the MAX_COMPACT # of entries (from H5Pset_link_phase_change). - * - * Note: XXX: Add [meaningful] tests for this routine! -QAK + * Note: EST_NUM_ENTRIES applies only when the number of entries is less + * than the MAX_COMPACT # of entries (from H5Pset_link_phase_change). * * Note: Come up with better name & description? -QAK * @@ -260,8 +250,6 @@ done: * Purpose: Returns the est. # of links in a group & the est. length of * the name of each link. * - * Note: XXX: Add [meaningful] tests for this routine! -QAK - * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol diff --git a/test/stab.c b/test/stab.c index 33c0fce..47f4966 100644 --- a/test/stab.c +++ b/test/stab.c @@ -24,6 +24,7 @@ #include "h5test.h" #include "H5Gpkg.h" /* Groups */ +#include "H5HLprivate.h" /* Local Heaps */ const char *FILENAME[] = { "stab1", @@ -36,10 +37,11 @@ const char *FILENAME[] = { /* Definitions for 'lifecycle' test */ #define LIFECYCLE_TOP_GROUP "top" #define LIFECYCLE_BOTTOM_GROUP "bottom %u" +#define LIFECYCLE_LOCAL_HEAP_SIZE_HINT 256 #define LIFECYCLE_MAX_COMPACT 4 #define LIFECYCLE_MIN_DENSE 3 -#define LIFECYCLE_EST_NUM_ENTRIES 3 -#define LIFECYCLE_EST_NAME_LEN 10 +#define LIFECYCLE_EST_NUM_ENTRIES 4 +#define LIFECYCLE_EST_NAME_LEN 8 /* Definitions for 'long_compact' test */ #define LONG_COMPACT_LENGTH ((64 * 1024) + 1024) @@ -285,6 +287,7 @@ lifecycle(hid_t fapl) unsigned est_num_entries; /* Estimated # of entries in group */ unsigned est_name_len; /* Estimated length of entry name */ unsigned nmsgs; /* Number of messages in group's header */ + H5G_stat_t obj_stat; /* Object info */ char objname[NAME_BUF_SIZE]; /* Object name */ char filename[NAME_BUF_SIZE]; off_t empty_size; /* Size of an empty file */ @@ -320,13 +323,16 @@ lifecycle(hid_t fapl) if(est_name_len != H5G_CRT_GINFO_EST_NAME_LEN) TEST_ERROR; /* Set GCPL parameters */ + if(H5Pset_local_heap_size_hint(gcpl, LIFECYCLE_LOCAL_HEAP_SIZE_HINT) < 0) TEST_ERROR; if(H5Pset_link_phase_change(gcpl, LIFECYCLE_MAX_COMPACT, LIFECYCLE_MIN_DENSE) < 0) TEST_ERROR; if(H5Pset_est_link_info(gcpl, LIFECYCLE_EST_NUM_ENTRIES, LIFECYCLE_EST_NAME_LEN) < 0) TEST_ERROR; /* Create group for testing lifecycle */ if((gid = H5Gcreate_expand(fid, LIFECYCLE_TOP_GROUP, gcpl, H5P_DEFAULT)) < 0) TEST_ERROR - /* Query default group creation property settings */ + /* Query group creation property settings */ + if(H5Pget_local_heap_size_hint(gcpl, &lheap_size_hint) < 0) TEST_ERROR; + if(lheap_size_hint != LIFECYCLE_LOCAL_HEAP_SIZE_HINT) TEST_ERROR; if(H5Pget_link_phase_change(gcpl, &max_compact, &min_dense) < 0) TEST_ERROR; if(max_compact != LIFECYCLE_MAX_COMPACT) TEST_ERROR; if(min_dense != LIFECYCLE_MIN_DENSE) TEST_ERROR; @@ -370,6 +376,17 @@ lifecycle(hid_t fapl) if(H5G_has_links_test(gid, &nmsgs) != TRUE) TEST_ERROR; if(nmsgs != LIFECYCLE_MAX_COMPACT) TEST_ERROR; + /* Check that the object header is only one chunk and the space has been allocated correctly */ + if(H5Gget_objinfo(gid, ".", FALSE, &obj_stat) < 0) TEST_ERROR; +#ifdef H5_HAVE_LARGE_HSIZET + if(obj_stat.u.obj.ohdr.size != 232) TEST_ERROR; +#else /* H5_HAVE_LARGE_HSIZET */ + if(obj_stat.u.obj.ohdr.size != 224) TEST_ERROR; +#endif /* H5_HAVE_LARGE_HSIZET */ + if(obj_stat.u.obj.ohdr.free != 0) TEST_ERROR; + if(obj_stat.u.obj.ohdr.nmesgs != 6) TEST_ERROR; + if(obj_stat.u.obj.ohdr.nchunks != 1) TEST_ERROR; + /* Create one more "bottom" group, which should push top group into using a symbol table */ sprintf(objname, LIFECYCLE_BOTTOM_GROUP, u); if((gid2 = H5Gcreate(gid, objname, (size_t)0)) < 0) TEST_ERROR @@ -384,6 +401,19 @@ lifecycle(hid_t fapl) if(H5G_is_empty_test(gid) == TRUE) TEST_ERROR; if(H5G_has_links_test(gid, NULL) == TRUE) TEST_ERROR; if(H5G_has_stab_test(gid) != TRUE) TEST_ERROR; + if(H5G_lheap_size_test(gid, &lheap_size_hint) < 0) TEST_ERROR; + if(lheap_size_hint != LIFECYCLE_LOCAL_HEAP_SIZE_HINT) TEST_ERROR; + + /* Check that the object header is still one chunk and the space has been allocated correctly */ + if(H5Gget_objinfo(gid, ".", FALSE, &obj_stat) < 0) TEST_ERROR; +#ifdef H5_HAVE_LARGE_HSIZET + if(obj_stat.u.obj.ohdr.size != 232) TEST_ERROR; +#else /* H5_HAVE_LARGE_HSIZET */ + if(obj_stat.u.obj.ohdr.size != 224) TEST_ERROR; +#endif /* H5_HAVE_LARGE_HSIZET */ + if(obj_stat.u.obj.ohdr.free != 136) TEST_ERROR; + if(obj_stat.u.obj.ohdr.nmesgs != 4) TEST_ERROR; + if(obj_stat.u.obj.ohdr.nchunks != 1) TEST_ERROR; /* Unlink objects from top group */ while(u >= LIFECYCLE_MIN_DENSE) { @@ -722,6 +752,10 @@ no_compact(hid_t fapl) char filename[NAME_BUF_SIZE]; off_t empty_size; /* Size of an empty file */ off_t file_size; /* Size of each file created */ + size_t lheap_size_hint; /* Local heap size */ + size_t def_lheap_size; /* Default local heap size */ + unsigned est_num_entries; /* Estimated # of entries in group */ + unsigned est_name_len; /* Estimated length of entry name */ TESTING("group without compact form"); @@ -744,6 +778,13 @@ no_compact(hid_t fapl) /* Set GCPL parameters */ if(H5Pset_link_phase_change(gcpl, NO_COMPACT_MAX_COMPACT, NO_COMPACT_MIN_DENSE) < 0) TEST_ERROR; + /* Check information for default local heap creation */ + if(H5Pget_local_heap_size_hint(gcpl, &lheap_size_hint) < 0) TEST_ERROR; + if(lheap_size_hint != H5G_CRT_GINFO_LHEAP_SIZE_HINT) TEST_ERROR; + if(H5Pget_est_link_info(gcpl, &est_num_entries, &est_name_len) < 0) TEST_ERROR; + if(est_num_entries != H5G_CRT_GINFO_EST_NUM_ENTRIES) TEST_ERROR; + if(est_name_len != H5G_CRT_GINFO_EST_NAME_LEN) TEST_ERROR; + /* Create group for testing lifecycle */ if((gid = H5Gcreate_expand(fid, NO_COMPACT_TOP_GROUP, gcpl, H5P_DEFAULT)) < 0) TEST_ERROR @@ -767,6 +808,10 @@ no_compact(hid_t fapl) if(H5G_is_empty_test(gid) == TRUE) TEST_ERROR; if(H5G_has_links_test(gid, NULL) == TRUE) TEST_ERROR; if(H5G_has_stab_test(gid) != TRUE) TEST_ERROR; + if(H5G_lheap_size_test(gid, &lheap_size_hint) < 0) TEST_ERROR; + def_lheap_size = est_num_entries * (est_name_len + 1); + def_lheap_size = H5HL_ALIGN(def_lheap_size); + if(lheap_size_hint != def_lheap_size) TEST_ERROR; /* Unlink object from top group */ sprintf(objname, NO_COMPACT_BOTTOM_GROUP, (unsigned)0); |