diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2019-12-12 18:42:58 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2019-12-12 18:42:58 (GMT) |
commit | f159fb5fd54a89e66ceacf73f550c2dc4344c477 (patch) | |
tree | cf8f3e0ab208be7fb6b05adf666de58a2f645fcb | |
parent | 2ca5f237cbde3689ce368a538f3b4c17e43aafc4 (diff) | |
download | hdf5-f159fb5fd54a89e66ceacf73f550c2dc4344c477.zip hdf5-f159fb5fd54a89e66ceacf73f550c2dc4344c477.tar.gz hdf5-f159fb5fd54a89e66ceacf73f550c2dc4344c477.tar.bz2 |
HDFFV-10979 fix issue with global name conflict
-rw-r--r-- | test/cache.c | 464 | ||||
-rw-r--r-- | test/cache_api.c | 15 | ||||
-rw-r--r-- | test/cache_common.c | 454 | ||||
-rw-r--r-- | test/cache_common.h | 520 |
4 files changed, 730 insertions, 723 deletions
diff --git a/test/cache.c b/test/cache.c index 1a726fa..ca2cf13 100644 --- a/test/cache.c +++ b/test/cache.c @@ -20,6 +20,33 @@ #include "cache_common.h" +hid_t saved_fapl_id = H5P_DEFAULT; /* store the fapl id here between + * cache setup and takedown. Note + * that if saved_fapl_id == H5P_DEFAULT, + * we assume that there is no fapl to + * close. + */ + +hid_t saved_fcpl_id = H5P_DEFAULT; /* store the fcpl id here between + * cache setup and takedown. Note + * that if saved_fcpl_id == H5P_DEFAULT, + * we assume that there is no fcpl to + * close. + */ +hid_t saved_fid = -1; /* store the file id here between cache setup + * and takedown. + */ +hbool_t try_core_file_driver = FALSE; +hbool_t core_file_driver_failed = FALSE; + + +/* global variable declarations: */ + +const char *FILENAME[] = { + "cache_test", + NULL +}; + /* private typedef declarations: */ struct flush_cache_test_spec @@ -205,6 +232,12 @@ static void check_stats__smoke_check_1(H5F_t * file_ptr); #endif /* H5C_COLLECT_CACHE_STATS */ +static H5F_t *setup_cache(size_t max_cache_size, size_t min_clean_size, unsigned paged); + +static void takedown_cache(H5F_t * file_ptr, + hbool_t dump_stats, + hbool_t dump_detailed_stats); + /**************************************************************************/ /**************************************************************************/ /********************************* tests: *********************************/ @@ -36417,6 +36450,437 @@ check_stats__smoke_check_1(H5F_t * file_ptr) #endif /* H5C_COLLECT_CACHE_STATS */ +/* Call back functions: */ + + +/*------------------------------------------------------------------------- + * + * Function: check_if_write_permitted + * + * Purpose: Determine if a write is permitted under the current + * circumstances, and set *write_permitted_ptr accordingly. + * As a general rule it is, but when we are running in parallel + * mode with collective I/O, we must ensure that a read cannot + * cause a write. + * + * In the event of failure, the value of *write_permitted_ptr + * is undefined. + * + * Return: Non-negative on success/Negative on failure. + * + * Programmer: John Mainzer, 5/15/04 + * + *------------------------------------------------------------------------- + */ +static herr_t +check_write_permitted(const H5F_t H5_ATTR_UNUSED *f, hbool_t *write_permitted_ptr) +{ + HDassert( write_permitted_ptr ); + + *write_permitted_ptr = write_permitted; + + return(SUCCEED); +} /* check_write_permitted() */ + + +/***************************************************************************** + * + * Function: setup_cache() + * + * Purpose: Open an HDF file. This will allocate an instance and + * initialize an associated instance of H5C_t. However, + * we want to test an instance of H5C_t, so allocate and + * initialize one with the file ID returned by the call to + * H5Fcreate(). Return a pointer to this instance of H5C_t. + * + * Observe that we open a HDF file because the cache now + * writes directly to file, and we need the file I/O facilities + * associated with the file. + * + * To avoid tripping on error check code, must allocate enough + * space in the file to hold all the test entries and their + * alternates. This is a little sticky, as the addresses of + * all the test entries are determined at compile time. + * + * Deal with this by choosing BASE_ADDR large enough that + * the base address of the allocate space will be less than + * or equal to BASE_ADDR, and then requesting an extra BASE_ADDR + * bytes, so we don't have to wory about exceeding the allocation. + * + * Return: Success: Ptr to H5C_t + * + * Failure: NULL + * + * Programmer: JRM -- 9/13/07 + * + *****************************************************************************/ + +H5F_t * +setup_cache(size_t max_cache_size, + size_t min_clean_size, + unsigned paged) +{ + char filename[512]; + hbool_t show_progress = FALSE; + hbool_t verbose = TRUE; + int mile_stone = 1; + hid_t fid = -1; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + H5F_t * ret_val = NULL; + haddr_t actual_base_addr; + hid_t fapl_id = H5P_DEFAULT; + hid_t fcpl_id = H5P_DEFAULT; + + if(show_progress) /* 1 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + FUNC, mile_stone++, (int)pass); + + saved_fid = -1; + + if(pass) { + if((fcpl_id = H5Pcreate(H5P_FILE_CREATE)) == FAIL) { + pass = FALSE; + failure_mssg = "H5Pcreate(H5P_FILE_CREATE) failed.\n"; + } + } + + if(pass && paged) { + /* Set up paged aggregation strategy */ + if(H5Pset_file_space_strategy(fcpl_id, H5F_FSPACE_STRATEGY_PAGE, 1, (hsize_t)1) == FAIL) { + pass = FALSE; + failure_mssg = "H5Pset_file_space_strategy() failed.\n"; + H5Pclose(fcpl_id); + fcpl_id = H5P_DEFAULT; + } + } + + if(pass && paged) { + /* Set up file space page size to BASE_ADDR */ + if(H5Pset_file_space_page_size(fcpl_id, (hsize_t)BASE_ADDR) == FAIL) { + pass = FALSE; + failure_mssg = "H5Pset_file_space_page_size() failed.\n"; + H5Pclose(fcpl_id); + fcpl_id = H5P_DEFAULT; + } + } + + if(pass) + saved_fcpl_id = fcpl_id; + + /* setup the file name */ + if(pass) { + if(NULL == h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof(filename))) { + pass = FALSE; + failure_mssg = "h5_fixname() failed.\n"; + } + } + + if(show_progress) /* 2 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + FUNC, mile_stone++, (int)pass); + + if(pass && try_core_file_driver) { + if((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) == FAIL) { + pass = FALSE; + failure_mssg = "H5Pcreate(H5P_FILE_ACCESS) failed.\n"; + } + else if(H5Pset_fapl_core(fapl_id, MAX_ADDR, FALSE) < 0) { + H5Pclose(fapl_id); + fapl_id = H5P_DEFAULT; + pass = FALSE; + failure_mssg = "H5P_set_fapl_core() failed.\n"; + } + else if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_id, fapl_id)) < 0) { + core_file_driver_failed = TRUE; + + if(verbose) + HDfprintf(stdout, "%s: H5Fcreate() with CFD failed.\n", FUNC); + } else { + saved_fapl_id = fapl_id; + } + } + + if(show_progress) /* 3 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + FUNC, mile_stone++, (int)pass); + + /* if we either aren't using the core file driver, or a create + * with the core file driver failed, try again with a regular file. + * If this fails, we are cooked. + */ + if(pass && fid < 0) { + fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_id, fapl_id); + saved_fid = fid; + + if(fid < 0) { + pass = FALSE; + failure_mssg = "H5Fcreate() failed."; + + if(verbose) + HDfprintf(stdout, "%s: H5Fcreate() failed.\n", FUNC); + } /* end if */ + } /* end if */ + + /* Push API context */ + H5CX_push(); + + if(show_progress) /* 4 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + FUNC, mile_stone++, (int)pass); + + if(pass) { + HDassert(fid >= 0); + saved_fid = fid; + if(H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) { + pass = FALSE; + failure_mssg = "H5Fflush() failed."; + + if(verbose) + HDfprintf(stdout, "%s: H5Fflush() failed.\n", FUNC); + } + else { + file_ptr = (H5F_t *)H5VL_object_verify(fid, H5I_FILE); + if(file_ptr == NULL) { + pass = FALSE; + failure_mssg = "Can't get file_ptr."; + + if(verbose) + HDfprintf(stdout, "%s: H5Fflush() failed.\n", FUNC); + } + } + } + + if(show_progress) /* 5 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + FUNC, mile_stone++, (int)pass); + + if(pass) { + + /* A bit of fancy footwork here: + * + * The call to H5Fcreate() allocates an instance of H5C_t, + * initializes it, and stores its address in f->shared->cache. + * + * We don't want to use this cache, as it has a bunch of extra + * initialization that may change over time, and in any case + * it will not in general be configured the way we want it. + * + * We used to deal with this problem by storing the file pointer + * in another instance of H5C_t, and then ignoring the original + * version. However, this strategy doesn't work any more, as + * we can't store the file pointer in the instance of H5C_t, + * and we have modified many cache routines to use a file + * pointer to look up the target cache. + * + * Thus we now make note of the address of the instance of + * H5C_t created by the call to H5Fcreate(), set + * file_ptr->shared->cache to NULL, call H5C_create() + * to allocate a new instance of H5C_t for test purposes, + * and store than new instance's address in + * file_ptr->shared->cache. + * + * On shut down, we call H5C_dest on our instance of H5C_t, + * set file_ptr->shared->cache to point to the original + * instance, and then close the file normally. + */ + + HDassert(saved_cache == NULL); + saved_cache = file_ptr->shared->cache; + file_ptr->shared->cache = NULL; + + cache_ptr = H5C_create(max_cache_size, + min_clean_size, + (NUMBER_OF_ENTRY_TYPES - 1), + types, + check_write_permitted, + TRUE, + NULL, + NULL); + + file_ptr->shared->cache = cache_ptr; + } + + if(show_progress) /* 6 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + FUNC, mile_stone++, (int)pass); + + if(pass) { + if(cache_ptr == NULL) { + pass = FALSE; + failure_mssg = "H5C_create() failed."; + + if(verbose) + HDfprintf(stdout, "%s: H5C_create() failed.\n", FUNC); + } + else if(cache_ptr->magic != H5C__H5C_T_MAGIC) { + pass = FALSE; + failure_mssg = "Bad cache_ptr magic."; + + if(verbose) + HDfprintf(stdout, "%s: Bad cache_ptr magic.\n", FUNC); + } + } + + if(show_progress) /* 7 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + FUNC, mile_stone++, (int)pass); + + if(pass) { /* allocate space for test entries */ + actual_base_addr = H5MF_alloc(file_ptr, H5FD_MEM_DEFAULT, (hsize_t)(ADDR_SPACE_SIZE + BASE_ADDR)); + + if(actual_base_addr == HADDR_UNDEF) { + pass = FALSE; + failure_mssg = "H5MF_alloc() failed."; + + if(verbose) + HDfprintf(stdout, "%s: H5MF_alloc() failed.\n", FUNC); + } else if(actual_base_addr > BASE_ADDR) { + /* If this happens, must increase BASE_ADDR so that the + * actual_base_addr is <= BASE_ADDR. This should only happen + * if the size of the superblock is increase. + */ + pass = FALSE; + failure_mssg = "actual_base_addr > BASE_ADDR"; + + if(verbose) + HDfprintf(stdout, "%s: actual_base_addr > BASE_ADDR.\n", FUNC); + } + + saved_actual_base_addr = actual_base_addr; + } + + if(show_progress) /* 8 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + FUNC, mile_stone++, (int)pass); + + if(pass) { + /* Need to set this else all cache tests will fail */ + cache_ptr->ignore_tags = TRUE; + + H5C_stats__reset(cache_ptr); + ret_val = file_ptr; + } + + if(show_progress) /* 9 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + FUNC, mile_stone++, (int)pass); + + return(ret_val); +} /* setup_cache() */ + + +/*------------------------------------------------------------------------- + * Function: takedown_cache() + * + * Purpose: Flush the specified cache and destroy it. If requested, + * dump stats first. Then close and delete the associate + * file. + * + * If pass is FALSE, do nothing. + * + * Return: void + * + * Programmer: John Mainzer + * 9/14/07 + * + *------------------------------------------------------------------------- + */ + +void +takedown_cache(H5F_t * file_ptr, + hbool_t dump_stats, + hbool_t dump_detailed_stats) +{ + char filename[512]; + + if ( file_ptr != NULL ) { + H5C_t * cache_ptr = file_ptr->shared->cache; + + if ( dump_stats ) { + + H5C_stats(cache_ptr, "test cache", dump_detailed_stats); + } + + if ( H5C_prep_for_file_close(file_ptr) < 0 ) { + + pass = FALSE; + failure_mssg = "unexpected failure of prep for file close.\n"; + } + + flush_cache(file_ptr, TRUE, FALSE, FALSE); + + H5C_dest(file_ptr); + + if ( saved_cache != NULL ) { + + file_ptr->shared->cache = saved_cache; + saved_cache = NULL; + } + + } + + if ( saved_fapl_id != H5P_DEFAULT ) { + + H5Pclose(saved_fapl_id); + saved_fapl_id = H5P_DEFAULT; + } + + if ( saved_fcpl_id != H5P_DEFAULT ) { + H5Pclose(saved_fcpl_id); + saved_fcpl_id = H5P_DEFAULT; + } + + if ( saved_fid != -1 ) { + + if ( H5F_addr_defined(saved_actual_base_addr) ) { + + if ( NULL == file_ptr ) { + file_ptr = (H5F_t *)H5VL_object_verify(saved_fid, H5I_FILE); + HDassert ( file_ptr ); + } + + H5MF_xfree(file_ptr, H5FD_MEM_DEFAULT, saved_actual_base_addr, + (hsize_t)(ADDR_SPACE_SIZE + BASE_ADDR)); + saved_actual_base_addr = HADDR_UNDEF; + } + + if ( H5Fclose(saved_fid) < 0 ) { + + pass = FALSE; + failure_mssg = "couldn't close test file."; + + } else { + + saved_fid = -1; + + } + + /* Pop API context */ + H5CX_pop(); + + if ( ( ! try_core_file_driver ) || ( core_file_driver_failed ) ) { + + if ( h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof(filename)) + == NULL ) { + + pass = FALSE; + failure_mssg = "h5_fixname() failed.\n"; + } + + if ( HDremove(filename) < 0 ) { + + pass = FALSE; + failure_mssg = "couldn't delete test file."; + + } + } + } + + return; + +} /* takedown_cache() */ + /*------------------------------------------------------------------------- * Function: main * diff --git a/test/cache_api.c b/test/cache_api.c index c0b84c1..1e1a2c9 100644 --- a/test/cache_api.c +++ b/test/cache_api.c @@ -24,6 +24,11 @@ /* global variable declarations: */ +const char *FILENAME[] = { + "cache_api_test", + NULL +}; + /* macro definitions */ /* private function declarations: */ @@ -207,7 +212,7 @@ check_fapl_mdc_api_calls(unsigned paged, hid_t fcpl_id) /* setup the file name */ if ( pass ) { - if ( h5_fixname(FILENAME[1], H5P_DEFAULT, filename, sizeof(filename)) + if ( h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof(filename)) == NULL ) { pass = FALSE; @@ -355,7 +360,7 @@ check_fapl_mdc_api_calls(unsigned paged, hid_t fcpl_id) /* setup the file name */ if ( pass ) { - if ( h5_fixname(FILENAME[1], H5P_DEFAULT, filename, sizeof(filename)) + if ( h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof(filename)) == NULL ) { pass = FALSE; @@ -688,7 +693,7 @@ check_file_mdc_api_calls(unsigned paged, hid_t fcpl_id) /* setup the file name */ if ( pass ) { - if ( h5_fixname(FILENAME[1], H5P_DEFAULT, filename, sizeof(filename)) + if ( h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof(filename)) == NULL ) { pass = FALSE; @@ -1034,7 +1039,7 @@ mdc_api_call_smoke_check(int express_test, unsigned paged, hid_t fcpl_id) /* setup the file name */ if ( pass ) { - if ( h5_fixname(FILENAME[1], H5P_DEFAULT, filename, sizeof(filename)) + if ( h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof(filename)) == NULL ) { pass = FALSE; @@ -1963,7 +1968,7 @@ check_file_mdc_api_errs(unsigned paged, hid_t fcpl_id) HDfprintf(stdout, "%s: calling h5_fixname().\n", FUNC); } - if ( h5_fixname(FILENAME[1], H5P_DEFAULT, filename, sizeof(filename)) + if ( h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof(filename)) == NULL ) { pass = FALSE; diff --git a/test/cache_common.c b/test/cache_common.c index f8d630d..819d073 100644 --- a/test/cache_common.c +++ b/test/cache_common.c @@ -24,31 +24,6 @@ #include "cache_common.h" -/* global variable declarations: */ - -const char *FILENAME[] = { - "cache_test", - "cache_api_test", - NULL -}; - -hid_t saved_fapl_id = H5P_DEFAULT; /* store the fapl id here between - * cache setup and takedown. Note - * that if saved_fapl_id == H5P_DEFAULT, - * we assume that there is no fapl to - * close. - */ - -hid_t saved_fcpl_id = H5P_DEFAULT; /* store the fcpl id here between - * cache setup and takedown. Note - * that if saved_fcpl_id == H5P_DEFAULT, - * we assume that there is no fcpl to - * close. - */ -hid_t saved_fid = -1; /* store the file id here between cache setup - * and takedown. - */ - H5C_t * saved_cache = NULL; /* store the pointer to the instance of * of H5C_t created by H5Fcreate() * here between test cache setup and @@ -61,8 +36,6 @@ haddr_t saved_actual_base_addr = HADDR_UNDEF; /* Store the address of the hbool_t write_permitted = TRUE; hbool_t pass = TRUE; /* set to false on error */ -hbool_t try_core_file_driver = FALSE; -hbool_t core_file_driver_failed = FALSE; const char *failure_mssg = NULL; static test_entry_t *pico_entries = NULL, *orig_pico_entries = NULL; @@ -578,35 +551,6 @@ addr_to_type_and_index(haddr_t addr, /* Call back functions: */ -/*------------------------------------------------------------------------- - * - * Function: check_if_write_permitted - * - * Purpose: Determine if a write is permitted under the current - * circumstances, and set *write_permitted_ptr accordingly. - * As a general rule it is, but when we are running in parallel - * mode with collective I/O, we must ensure that a read cannot - * cause a write. - * - * In the event of failure, the value of *write_permitted_ptr - * is undefined. - * - * Return: Non-negative on success/Negative on failure. - * - * Programmer: John Mainzer, 5/15/04 - * - *------------------------------------------------------------------------- - */ -static herr_t -check_write_permitted(const H5F_t H5_ATTR_UNUSED *f, hbool_t *write_permitted_ptr) -{ - HDassert( write_permitted_ptr ); - - *write_permitted_ptr = write_permitted; - - return(SUCCEED); -} /* check_write_permitted() */ - /*------------------------------------------------------------------------- * Function: get_initial_load_size & friends @@ -3130,404 +3074,6 @@ verify_unprotected(void) } /* verify_unprotected() */ -/***************************************************************************** - * - * Function: setup_cache() - * - * Purpose: Open an HDF file. This will allocate an instance and - * initialize an associated instance of H5C_t. However, - * we want to test an instance of H5C_t, so allocate and - * initialize one with the file ID returned by the call to - * H5Fcreate(). Return a pointer to this instance of H5C_t. - * - * Observe that we open a HDF file because the cache now - * writes directly to file, and we need the file I/O facilities - * associated with the file. - * - * To avoid tripping on error check code, must allocate enough - * space in the file to hold all the test entries and their - * alternates. This is a little sticky, as the addresses of - * all the test entries are determined at compile time. - * - * Deal with this by choosing BASE_ADDR large enough that - * the base address of the allocate space will be less than - * or equal to BASE_ADDR, and then requesting an extra BASE_ADDR - * bytes, so we don't have to wory about exceeding the allocation. - * - * Return: Success: Ptr to H5C_t - * - * Failure: NULL - * - * Programmer: JRM -- 9/13/07 - * - *****************************************************************************/ - -H5F_t * -setup_cache(size_t max_cache_size, - size_t min_clean_size, - unsigned paged) -{ - char filename[512]; - hbool_t show_progress = FALSE; - hbool_t verbose = TRUE; - int mile_stone = 1; - hid_t fid = -1; - H5F_t * file_ptr = NULL; - H5C_t * cache_ptr = NULL; - H5F_t * ret_val = NULL; - haddr_t actual_base_addr; - hid_t fapl_id = H5P_DEFAULT; - hid_t fcpl_id = H5P_DEFAULT; - - if(show_progress) /* 1 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); - - saved_fid = -1; - - if(pass) { - if((fcpl_id = H5Pcreate(H5P_FILE_CREATE)) == FAIL) { - pass = FALSE; - failure_mssg = "H5Pcreate(H5P_FILE_CREATE) failed.\n"; - } - } - - if(pass && paged) { - /* Set up paged aggregation strategy */ - if(H5Pset_file_space_strategy(fcpl_id, H5F_FSPACE_STRATEGY_PAGE, 1, (hsize_t)1) == FAIL) { - pass = FALSE; - failure_mssg = "H5Pset_file_space_strategy() failed.\n"; - H5Pclose(fcpl_id); - fcpl_id = H5P_DEFAULT; - } - } - - if(pass && paged) { - /* Set up file space page size to BASE_ADDR */ - if(H5Pset_file_space_page_size(fcpl_id, (hsize_t)BASE_ADDR) == FAIL) { - pass = FALSE; - failure_mssg = "H5Pset_file_space_page_size() failed.\n"; - H5Pclose(fcpl_id); - fcpl_id = H5P_DEFAULT; - } - } - - if(pass) - saved_fcpl_id = fcpl_id; - - /* setup the file name */ - if(pass) { - if(NULL == h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof(filename))) { - pass = FALSE; - failure_mssg = "h5_fixname() failed.\n"; - } - } - - if(show_progress) /* 2 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); - - if(pass && try_core_file_driver) { - if((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) == FAIL) { - pass = FALSE; - failure_mssg = "H5Pcreate(H5P_FILE_ACCESS) failed.\n"; - } - else if(H5Pset_fapl_core(fapl_id, MAX_ADDR, FALSE) < 0) { - H5Pclose(fapl_id); - fapl_id = H5P_DEFAULT; - pass = FALSE; - failure_mssg = "H5P_set_fapl_core() failed.\n"; - } - else if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_id, fapl_id)) < 0) { - core_file_driver_failed = TRUE; - - if(verbose) - HDfprintf(stdout, "%s: H5Fcreate() with CFD failed.\n", FUNC); - } else { - saved_fapl_id = fapl_id; - } - } - - if(show_progress) /* 3 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); - - /* if we either aren't using the core file driver, or a create - * with the core file driver failed, try again with a regular file. - * If this fails, we are cooked. - */ - if(pass && fid < 0) { - fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_id, fapl_id); - saved_fid = fid; - - if(fid < 0) { - pass = FALSE; - failure_mssg = "H5Fcreate() failed."; - - if(verbose) - HDfprintf(stdout, "%s: H5Fcreate() failed.\n", FUNC); - } /* end if */ - } /* end if */ - - /* Push API context */ - H5CX_push(); - - if(show_progress) /* 4 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); - - if(pass) { - HDassert(fid >= 0); - saved_fid = fid; - if(H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) { - pass = FALSE; - failure_mssg = "H5Fflush() failed."; - - if(verbose) - HDfprintf(stdout, "%s: H5Fflush() failed.\n", FUNC); - } - else { - file_ptr = (H5F_t *)H5I_object_verify(fid, H5I_FILE); - if(file_ptr == NULL) { - pass = FALSE; - failure_mssg = "Can't get file_ptr."; - - if(verbose) - HDfprintf(stdout, "%s: H5Fflush() failed.\n", FUNC); - } - } - } - - if(show_progress) /* 5 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); - - if(pass) { - - /* A bit of fancy footwork here: - * - * The call to H5Fcreate() allocates an instance of H5C_t, - * initializes it, and stores its address in f->shared->cache. - * - * We don't want to use this cache, as it has a bunch of extra - * initialization that may change over time, and in any case - * it will not in general be configured the way we want it. - * - * We used to deal with this problem by storing the file pointer - * in another instance of H5C_t, and then ignoring the original - * version. However, this strategy doesn't work any more, as - * we can't store the file pointer in the instance of H5C_t, - * and we have modified many cache routines to use a file - * pointer to look up the target cache. - * - * Thus we now make note of the address of the instance of - * H5C_t created by the call to H5Fcreate(), set - * file_ptr->shared->cache to NULL, call H5C_create() - * to allocate a new instance of H5C_t for test purposes, - * and store than new instance's address in - * file_ptr->shared->cache. - * - * On shut down, we call H5C_dest on our instance of H5C_t, - * set file_ptr->shared->cache to point to the original - * instance, and then close the file normally. - */ - - HDassert(saved_cache == NULL); - saved_cache = file_ptr->shared->cache; - file_ptr->shared->cache = NULL; - - cache_ptr = H5C_create(max_cache_size, - min_clean_size, - (NUMBER_OF_ENTRY_TYPES - 1), - types, - check_write_permitted, - TRUE, - NULL, - NULL); - - file_ptr->shared->cache = cache_ptr; - } - - if(show_progress) /* 6 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); - - if(pass) { - if(cache_ptr == NULL) { - pass = FALSE; - failure_mssg = "H5C_create() failed."; - - if(verbose) - HDfprintf(stdout, "%s: H5C_create() failed.\n", FUNC); - } - else if(cache_ptr->magic != H5C__H5C_T_MAGIC) { - pass = FALSE; - failure_mssg = "Bad cache_ptr magic."; - - if(verbose) - HDfprintf(stdout, "%s: Bad cache_ptr magic.\n", FUNC); - } - } - - if(show_progress) /* 7 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); - - if(pass) { /* allocate space for test entries */ - actual_base_addr = H5MF_alloc(file_ptr, H5FD_MEM_DEFAULT, (hsize_t)(ADDR_SPACE_SIZE + BASE_ADDR)); - - if(actual_base_addr == HADDR_UNDEF) { - pass = FALSE; - failure_mssg = "H5MF_alloc() failed."; - - if(verbose) - HDfprintf(stdout, "%s: H5MF_alloc() failed.\n", FUNC); - } else if(actual_base_addr > BASE_ADDR) { - /* If this happens, must increase BASE_ADDR so that the - * actual_base_addr is <= BASE_ADDR. This should only happen - * if the size of the superblock is increase. - */ - pass = FALSE; - failure_mssg = "actual_base_addr > BASE_ADDR"; - - if(verbose) - HDfprintf(stdout, "%s: actual_base_addr > BASE_ADDR.\n", FUNC); - } - - saved_actual_base_addr = actual_base_addr; - } - - if(show_progress) /* 8 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); - - if(pass) { - /* Need to set this else all cache tests will fail */ - cache_ptr->ignore_tags = TRUE; - - H5C_stats__reset(cache_ptr); - ret_val = file_ptr; - } - - if(show_progress) /* 9 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); - - return(ret_val); -} /* setup_cache() */ - - -/*------------------------------------------------------------------------- - * Function: takedown_cache() - * - * Purpose: Flush the specified cache and destroy it. If requested, - * dump stats first. Then close and delete the associate - * file. - * - * If pass is FALSE, do nothing. - * - * Return: void - * - * Programmer: John Mainzer - * 9/14/07 - * - *------------------------------------------------------------------------- - */ - -void -takedown_cache(H5F_t * file_ptr, - hbool_t dump_stats, - hbool_t dump_detailed_stats) -{ - char filename[512]; - - if ( file_ptr != NULL ) { - H5C_t * cache_ptr = file_ptr->shared->cache; - - if ( dump_stats ) { - - H5C_stats(cache_ptr, "test cache", dump_detailed_stats); - } - - if ( H5C_prep_for_file_close(file_ptr) < 0 ) { - - pass = FALSE; - failure_mssg = "unexpected failure of prep for file close.\n"; - } - - flush_cache(file_ptr, TRUE, FALSE, FALSE); - - H5C_dest(file_ptr); - - if ( saved_cache != NULL ) { - - file_ptr->shared->cache = saved_cache; - saved_cache = NULL; - } - - } - - if ( saved_fapl_id != H5P_DEFAULT ) { - - H5Pclose(saved_fapl_id); - saved_fapl_id = H5P_DEFAULT; - } - - if ( saved_fcpl_id != H5P_DEFAULT ) { - H5Pclose(saved_fcpl_id); - saved_fcpl_id = H5P_DEFAULT; - } - - if ( saved_fid != -1 ) { - - if ( H5F_addr_defined(saved_actual_base_addr) ) { - - if ( NULL == file_ptr ) { - file_ptr = (H5F_t *)H5I_object_verify(saved_fid, H5I_FILE); - HDassert ( file_ptr ); - } - - H5MF_xfree(file_ptr, H5FD_MEM_DEFAULT, saved_actual_base_addr, - (hsize_t)(ADDR_SPACE_SIZE + BASE_ADDR)); - saved_actual_base_addr = HADDR_UNDEF; - } - - if ( H5Fclose(saved_fid) < 0 ) { - - pass = FALSE; - failure_mssg = "couldn't close test file."; - - } else { - - saved_fid = -1; - - } - - /* Pop API context */ - H5CX_pop(); - - if ( ( ! try_core_file_driver ) || ( core_file_driver_failed ) ) { - - if ( h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof(filename)) - == NULL ) { - - pass = FALSE; - failure_mssg = "h5_fixname() failed.\n"; - } - - if ( HDremove(filename) < 0 ) { - - pass = FALSE; - failure_mssg = "couldn't delete test file."; - - } - } - } - - return; - -} /* takedown_cache() */ - /*------------------------------------------------------------------------- * Function: expunge_entry() diff --git a/test/cache_common.h b/test/cache_common.h index 9c66357..8f2aee2 100644 --- a/test/cache_common.h +++ b/test/cache_common.h @@ -14,14 +14,14 @@ /* Programmer: John Mainzer * 10/27/05 * - * This file contains common #defines, type definitions, and - * externs for tests of the cache implemented in H5C.c + * This file contains common #defines, type definitions, and + * externs for tests of the cache implemented in H5C.c */ #ifndef _CACHE_COMMON_H #define _CACHE_COMMON_H -#define H5C_FRIEND /*suppress error about including H5Cpkg */ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5C_FRIEND /*suppress error about including H5Cpkg */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ /* Include library header files */ #include "H5ACprivate.h" @@ -35,174 +35,174 @@ /* Macro to make error reporting easier */ #define CACHE_ERROR(s) {failure_mssg = "Line #" H5_TOSTRING(__LINE__) ": " s ; pass = FALSE; goto done;} -#define NO_CHANGE -1 +#define NO_CHANGE -1 /* with apologies for the abuse of terminology... */ -#define PICO_ENTRY_TYPE 0 -#define NANO_ENTRY_TYPE 1 -#define MICRO_ENTRY_TYPE 2 -#define TINY_ENTRY_TYPE 3 -#define SMALL_ENTRY_TYPE 4 -#define MEDIUM_ENTRY_TYPE 5 -#define LARGE_ENTRY_TYPE 6 -#define HUGE_ENTRY_TYPE 7 -#define MONSTER_ENTRY_TYPE 8 -#define VARIABLE_ENTRY_TYPE 9 -#define NOTIFY_ENTRY_TYPE 10 +#define PICO_ENTRY_TYPE 0 +#define NANO_ENTRY_TYPE 1 +#define MICRO_ENTRY_TYPE 2 +#define TINY_ENTRY_TYPE 3 +#define SMALL_ENTRY_TYPE 4 +#define MEDIUM_ENTRY_TYPE 5 +#define LARGE_ENTRY_TYPE 6 +#define HUGE_ENTRY_TYPE 7 +#define MONSTER_ENTRY_TYPE 8 +#define VARIABLE_ENTRY_TYPE 9 +#define NOTIFY_ENTRY_TYPE 10 #define NUMBER_OF_ENTRY_TYPES 11 -#define PICO_ENTRY_SIZE (size_t)1 -#define NANO_ENTRY_SIZE (size_t)4 -#define MICRO_ENTRY_SIZE (size_t)16 -#define TINY_ENTRY_SIZE (size_t)64 -#define SMALL_ENTRY_SIZE (size_t)256 -#define MEDIUM_ENTRY_SIZE (size_t)1024 -#define LARGE_ENTRY_SIZE (size_t)(4 * 1024) -#define HUGE_ENTRY_SIZE (size_t)(16 * 1024) -#define MONSTER_ENTRY_SIZE (size_t)(64 * 1024) -#define VARIABLE_ENTRY_SIZE (size_t)(10 * 1024) -#define NOTIFY_ENTRY_SIZE (size_t)1 - -#define NUM_PICO_ENTRIES (10 * 1024) -#define NUM_NANO_ENTRIES (10 * 1024) -#define NUM_MICRO_ENTRIES (10 * 1024) -#define NUM_TINY_ENTRIES (10 * 1024) -#define NUM_SMALL_ENTRIES (10 * 1024) -#define NUM_MEDIUM_ENTRIES (10 * 1024) -#define NUM_LARGE_ENTRIES (10 * 1024) -#define NUM_HUGE_ENTRIES (10 * 1024) -#define NUM_MONSTER_ENTRIES (10 * 1024) -#define NUM_VARIABLE_ENTRIES (10 * 1024) -#define NUM_NOTIFY_ENTRIES (10 * 1024) - -#define MAX_ENTRIES (10 * 1024) +#define PICO_ENTRY_SIZE (size_t)1 +#define NANO_ENTRY_SIZE (size_t)4 +#define MICRO_ENTRY_SIZE (size_t)16 +#define TINY_ENTRY_SIZE (size_t)64 +#define SMALL_ENTRY_SIZE (size_t)256 +#define MEDIUM_ENTRY_SIZE (size_t)1024 +#define LARGE_ENTRY_SIZE (size_t)(4 * 1024) +#define HUGE_ENTRY_SIZE (size_t)(16 * 1024) +#define MONSTER_ENTRY_SIZE (size_t)(64 * 1024) +#define VARIABLE_ENTRY_SIZE (size_t)(10 * 1024) +#define NOTIFY_ENTRY_SIZE (size_t)1 + +#define NUM_PICO_ENTRIES (10 * 1024) +#define NUM_NANO_ENTRIES (10 * 1024) +#define NUM_MICRO_ENTRIES (10 * 1024) +#define NUM_TINY_ENTRIES (10 * 1024) +#define NUM_SMALL_ENTRIES (10 * 1024) +#define NUM_MEDIUM_ENTRIES (10 * 1024) +#define NUM_LARGE_ENTRIES (10 * 1024) +#define NUM_HUGE_ENTRIES (10 * 1024) +#define NUM_MONSTER_ENTRIES (10 * 1024) +#define NUM_VARIABLE_ENTRIES (10 * 1024) +#define NUM_NOTIFY_ENTRIES (10 * 1024) + +#define MAX_ENTRIES (10 * 1024) /* The choice of the BASE_ADDR below is arbitrary -- it just has to be * larger than the superblock. */ -#define BASE_ADDR (haddr_t)1024 -#define PICO_BASE_ADDR BASE_ADDR -#define NANO_BASE_ADDR (haddr_t)(PICO_BASE_ADDR + \ +#define BASE_ADDR (haddr_t)1024 +#define PICO_BASE_ADDR BASE_ADDR +#define NANO_BASE_ADDR (haddr_t)(PICO_BASE_ADDR + \ (PICO_ENTRY_SIZE * NUM_PICO_ENTRIES)) -#define MICRO_BASE_ADDR (haddr_t)(NANO_BASE_ADDR + \ +#define MICRO_BASE_ADDR (haddr_t)(NANO_BASE_ADDR + \ (NANO_ENTRY_SIZE * NUM_NANO_ENTRIES)) -#define TINY_BASE_ADDR (haddr_t)(MICRO_BASE_ADDR + \ - (MICRO_ENTRY_SIZE * NUM_MICRO_ENTRIES)) -#define SMALL_BASE_ADDR (haddr_t)(TINY_BASE_ADDR + \ +#define TINY_BASE_ADDR (haddr_t)(MICRO_BASE_ADDR + \ + (MICRO_ENTRY_SIZE * NUM_MICRO_ENTRIES)) +#define SMALL_BASE_ADDR (haddr_t)(TINY_BASE_ADDR + \ (TINY_ENTRY_SIZE * NUM_TINY_ENTRIES)) -#define MEDIUM_BASE_ADDR (haddr_t)(SMALL_BASE_ADDR + \ +#define MEDIUM_BASE_ADDR (haddr_t)(SMALL_BASE_ADDR + \ (SMALL_ENTRY_SIZE * NUM_SMALL_ENTRIES)) -#define LARGE_BASE_ADDR (haddr_t)(MEDIUM_BASE_ADDR + \ +#define LARGE_BASE_ADDR (haddr_t)(MEDIUM_BASE_ADDR + \ (MEDIUM_ENTRY_SIZE * NUM_MEDIUM_ENTRIES)) -#define HUGE_BASE_ADDR (haddr_t)(LARGE_BASE_ADDR + \ +#define HUGE_BASE_ADDR (haddr_t)(LARGE_BASE_ADDR + \ (LARGE_ENTRY_SIZE * NUM_LARGE_ENTRIES)) -#define MONSTER_BASE_ADDR (haddr_t)(HUGE_BASE_ADDR + \ +#define MONSTER_BASE_ADDR (haddr_t)(HUGE_BASE_ADDR + \ (HUGE_ENTRY_SIZE * NUM_HUGE_ENTRIES)) -#define VARIABLE_BASE_ADDR (haddr_t)(MONSTER_BASE_ADDR + \ - (MONSTER_ENTRY_SIZE * NUM_MONSTER_ENTRIES)) -#define NOTIFY_BASE_ADDR (haddr_t)(VARIABLE_BASE_ADDR + \ - (VARIABLE_ENTRY_SIZE * NUM_VARIABLE_ENTRIES)) - -#define PICO_ALT_BASE_ADDR (haddr_t)(NOTIFY_BASE_ADDR + \ - (NOTIFY_ENTRY_SIZE * NUM_NOTIFY_ENTRIES)) -#define NANO_ALT_BASE_ADDR (haddr_t)(PICO_ALT_BASE_ADDR + \ +#define VARIABLE_BASE_ADDR (haddr_t)(MONSTER_BASE_ADDR + \ + (MONSTER_ENTRY_SIZE * NUM_MONSTER_ENTRIES)) +#define NOTIFY_BASE_ADDR (haddr_t)(VARIABLE_BASE_ADDR + \ + (VARIABLE_ENTRY_SIZE * NUM_VARIABLE_ENTRIES)) + +#define PICO_ALT_BASE_ADDR (haddr_t)(NOTIFY_BASE_ADDR + \ + (NOTIFY_ENTRY_SIZE * NUM_NOTIFY_ENTRIES)) +#define NANO_ALT_BASE_ADDR (haddr_t)(PICO_ALT_BASE_ADDR + \ (PICO_ENTRY_SIZE * NUM_PICO_ENTRIES)) -#define MICRO_ALT_BASE_ADDR (haddr_t)(NANO_ALT_BASE_ADDR + \ +#define MICRO_ALT_BASE_ADDR (haddr_t)(NANO_ALT_BASE_ADDR + \ (NANO_ENTRY_SIZE * NUM_NANO_ENTRIES)) -#define TINY_ALT_BASE_ADDR (haddr_t)(MICRO_ALT_BASE_ADDR + \ - (MICRO_ENTRY_SIZE * NUM_MICRO_ENTRIES)) -#define SMALL_ALT_BASE_ADDR (haddr_t)(TINY_ALT_BASE_ADDR + \ +#define TINY_ALT_BASE_ADDR (haddr_t)(MICRO_ALT_BASE_ADDR + \ + (MICRO_ENTRY_SIZE * NUM_MICRO_ENTRIES)) +#define SMALL_ALT_BASE_ADDR (haddr_t)(TINY_ALT_BASE_ADDR + \ (TINY_ENTRY_SIZE * NUM_TINY_ENTRIES)) -#define MEDIUM_ALT_BASE_ADDR (haddr_t)(SMALL_ALT_BASE_ADDR + \ +#define MEDIUM_ALT_BASE_ADDR (haddr_t)(SMALL_ALT_BASE_ADDR + \ (SMALL_ENTRY_SIZE * NUM_SMALL_ENTRIES)) -#define LARGE_ALT_BASE_ADDR (haddr_t)(MEDIUM_ALT_BASE_ADDR + \ +#define LARGE_ALT_BASE_ADDR (haddr_t)(MEDIUM_ALT_BASE_ADDR + \ (MEDIUM_ENTRY_SIZE * NUM_MEDIUM_ENTRIES)) -#define HUGE_ALT_BASE_ADDR (haddr_t)(LARGE_ALT_BASE_ADDR + \ +#define HUGE_ALT_BASE_ADDR (haddr_t)(LARGE_ALT_BASE_ADDR + \ (LARGE_ENTRY_SIZE * NUM_LARGE_ENTRIES)) -#define MONSTER_ALT_BASE_ADDR (haddr_t)(HUGE_ALT_BASE_ADDR + \ +#define MONSTER_ALT_BASE_ADDR (haddr_t)(HUGE_ALT_BASE_ADDR + \ (HUGE_ENTRY_SIZE * NUM_HUGE_ENTRIES)) -#define VARIABLE_ALT_BASE_ADDR (haddr_t)(MONSTER_ALT_BASE_ADDR + \ +#define VARIABLE_ALT_BASE_ADDR (haddr_t)(MONSTER_ALT_BASE_ADDR + \ (MONSTER_ENTRY_SIZE * NUM_MONSTER_ENTRIES)) -#define NOTIFY_ALT_BASE_ADDR (haddr_t)(VARIABLE_ALT_BASE_ADDR + \ +#define NOTIFY_ALT_BASE_ADDR (haddr_t)(VARIABLE_ALT_BASE_ADDR + \ (VARIABLE_ENTRY_SIZE * NUM_VARIABLE_ENTRIES)) -#define MAX_ADDR (haddr_t)(NOTIFY_ALT_BASE_ADDR + \ - (NOTIFY_ENTRY_SIZE * NUM_NOTIFY_ENTRIES)) -#define ADDR_SPACE_SIZE (haddr_t)(MAX_ADDR - BASE_ADDR) - -#define MAX_PINS 8 /* Maximum number of entries that can be - * directly pinned by a single entry. - */ - -#define FLUSH_OP__NO_OP 0 -#define FLUSH_OP__DIRTY 1 -#define FLUSH_OP__RESIZE 2 -#define FLUSH_OP__MOVE 3 -#define FLUSH_OP__ORDER 4 -#define FLUSH_OP__EXPUNGE 5 -#define FLUSH_OP__DEST_FLUSH_DEP 6 -#define FLUSH_OP__MAX_OP 6 - -#define MAX_FLUSH_OPS 10 /* Maximum number of flush operations - * that can be associated with a - * cache entry. - */ +#define MAX_ADDR (haddr_t)(NOTIFY_ALT_BASE_ADDR + \ + (NOTIFY_ENTRY_SIZE * NUM_NOTIFY_ENTRIES)) +#define ADDR_SPACE_SIZE (haddr_t)(MAX_ADDR - BASE_ADDR) + +#define MAX_PINS 8 /* Maximum number of entries that can be + * directly pinned by a single entry. + */ + +#define FLUSH_OP__NO_OP 0 +#define FLUSH_OP__DIRTY 1 +#define FLUSH_OP__RESIZE 2 +#define FLUSH_OP__MOVE 3 +#define FLUSH_OP__ORDER 4 +#define FLUSH_OP__EXPUNGE 5 +#define FLUSH_OP__DEST_FLUSH_DEP 6 +#define FLUSH_OP__MAX_OP 6 + +#define MAX_FLUSH_OPS 10 /* Maximum number of flush operations + * that can be associated with a + * cache entry. + */ #define MAX_FLUSH_DEP_PARS 8 /* Maximum number of flush dependency * parents in the test */ typedef struct flush_op { - int op_code; /* integer op code indicating the - * operation to be performed. At - * present it must be one of: - * - * FLUSH_OP__NO_OP - * FLUSH_OP__DIRTY - * FLUSH_OP__RESIZE - * FLUSH_OP__MOVE - * FLUSH_OP__ORDER - */ - int type; /* type code of the cache entry that - * is the target of the operation. - * This value is passed into the - * function implementing the flush - * operation. - */ - int idx; /* index of the cache entry that - * is the target of the operation. - * This value is passed into the + int op_code; /* integer op code indicating the + * operation to be performed. At + * present it must be one of: + * + * FLUSH_OP__NO_OP + * FLUSH_OP__DIRTY + * FLUSH_OP__RESIZE + * FLUSH_OP__MOVE + * FLUSH_OP__ORDER + */ + int type; /* type code of the cache entry that + * is the target of the operation. + * This value is passed into the + * function implementing the flush + * operation. + */ + int idx; /* index of the cache entry that + * is the target of the operation. + * This value is passed into the * function implementing the flush * operation. - */ - hbool_t flag; /* boolean flag passed into the - * function implementing the flush - * operation. The meaning of the - * flag is dependent upon the flush - * operation: - * - * FLUSH_OP__DIRTY: TRUE iff the - * target is pinned, and is to - * be dirtied via the - * H5C_mark_entry_dirty() - * call. - * - * FLUSH_OP__RESIZE: TRUE iff the - * target is pinned, and is to - * be resized via the - * H5C_resize_entry() - * call. - * - * FLUSH_OP__MOVE: TRUE iff the - * target is to be moved to - * its main address. - */ - size_t size; /* New target size in the - * FLUSH_OP__MOVE operation. - * Unused elsewhere. - */ + */ + hbool_t flag; /* boolean flag passed into the + * function implementing the flush + * operation. The meaning of the + * flag is dependent upon the flush + * operation: + * + * FLUSH_OP__DIRTY: TRUE iff the + * target is pinned, and is to + * be dirtied via the + * H5C_mark_entry_dirty() + * call. + * + * FLUSH_OP__RESIZE: TRUE iff the + * target is pinned, and is to + * be resized via the + * H5C_resize_entry() + * call. + * + * FLUSH_OP__MOVE: TRUE iff the + * target is to be moved to + * its main address. + */ + size_t size; /* New target size in the + * FLUSH_OP__MOVE operation. + * Unused elsewhere. + */ unsigned * order_ptr; /* Pointer to outside counter for * recording the order of entries * flushed. @@ -216,135 +216,135 @@ typedef enum test_entry_action_t { typedef struct test_entry_t { - H5C_cache_entry_t header; /* entry data used by the cache - * -- must be first - */ - struct test_entry_t * self; /* pointer to this entry -- used for - * sanity checking. + H5C_cache_entry_t header; /* entry data used by the cache + * -- must be first + */ + struct test_entry_t * self; /* pointer to this entry -- used for + * sanity checking. */ test_entry_action_t action; /* Action being performed on a test entry */ H5F_t * file_ptr; /* pointer to the file in which the * entry resides, or NULL if the entry * is not in a file. */ - H5C_t * cache_ptr; /* pointer to the cache in which - * the entry resides, or NULL if the - * entry is not in cache. - */ - hbool_t written_to_main_addr; - /* Flag indicating whether an image - * of the entry has been written to - * its main address. Since we no - * longer have a flush callback, we - * set this field to true whenever the - * entry is serialized while at its - * main address. - */ - hbool_t written_to_alt_addr; + H5C_t * cache_ptr; /* pointer to the cache in which + * the entry resides, or NULL if the + * entry is not in cache. + */ + hbool_t written_to_main_addr; + /* Flag indicating whether an image + * of the entry has been written to + * its main address. Since we no + * longer have a flush callback, we + * set this field to true whenever the + * entry is serialized while at its + * main address. + */ + hbool_t written_to_alt_addr; /* Flag indicating whether an image - * of the entry has been written to - * its alternate address. Since we no - * longer have a flush callback, we - * set this field to true whenever the - * entry is serialized while at its - * alternate address. - */ - haddr_t addr; /* where the cache thinks this entry + * of the entry has been written to + * its alternate address. Since we no + * longer have a flush callback, we + * set this field to true whenever the + * entry is serialized while at its + * alternate address. + */ + haddr_t addr; /* where the cache thinks this entry * is located */ - hbool_t at_main_addr; /* boolean flag indicating whether - * the entry is supposed to be at - * either its main or alternate - * address. - */ - haddr_t main_addr; /* initial location of the entry + hbool_t at_main_addr; /* boolean flag indicating whether + * the entry is supposed to be at + * either its main or alternate + * address. + */ + haddr_t main_addr; /* initial location of the entry */ - haddr_t alt_addr; /* location to which the entry - * can be relocated or "moved" + haddr_t alt_addr; /* location to which the entry + * can be relocated or "moved" */ - size_t size; /* how big the cache thinks this + size_t size; /* how big the cache thinks this * entry is */ - int32_t type; /* indicates which entry array this - * entry is in + int32_t type; /* indicates which entry array this + * entry is in */ - int32_t index; /* index in its entry array + int32_t index; /* index in its entry array */ - int32_t serializes; /* number of times this entry has - * been serialized. + int32_t serializes; /* number of times this entry has + * been serialized. */ - int32_t deserializes; /* number of times this entry has + int32_t deserializes; /* number of times this entry has * been deserialized */ - hbool_t is_dirty; /* entry has been modified since + hbool_t is_dirty; /* entry has been modified since * last write */ - hbool_t is_protected; /* entry should currently be on - * the cache's protected list. + hbool_t is_protected; /* entry should currently be on + * the cache's protected list. */ - hbool_t is_read_only; /* TRUE iff the entry should be - * protected read only. - */ - int ro_ref_count; /* Number of outstanding read only - * protects on the entry. - */ - hbool_t is_pinned; /* entry is currently pinned in - * the cache. + hbool_t is_read_only; /* TRUE iff the entry should be + * protected read only. + */ + int ro_ref_count; /* Number of outstanding read only + * protects on the entry. + */ + hbool_t is_pinned; /* entry is currently pinned in + * the cache. */ - haddr_t tag; /* the base_addr as tag for corking entries */ - hbool_t is_corked; /* entry is currently corked or not */ - int pinning_ref_count; /* Number of entries that - * pin this entry in the cache. - * When this count drops to zero, - * this entry should be unpinned. - */ - int num_pins; /* Number of entries that this - * entry pins in the cache. This - * value must be in the range - * [0, MAX_PINS]. - */ - int pin_type[MAX_PINS]; /* array of the types of entries - * pinned by this entry. - */ - int pin_idx[MAX_PINS]; /* array of the indicies of - * entries pinned by this entry. - */ - int num_flush_ops; /* integer field containing the - * number of flush operations to - * be executed when the entry is - * flushed. This value must lie in - * the closed interval - * [0, MAX_FLUSH_OPS]. - */ - struct flush_op flush_ops[MAX_FLUSH_OPS]; /* Array of instances - * of struct flush_op detailing the - * flush operations (if any) that - * are to be executed when the entry - * is flushed from the cache. - * - * num_flush_ops contains the number - * of valid entries in this array. - */ - hbool_t flush_op_self_resize_in_progress; /* Boolean flag - * that is set to TRUE iff this - * entry is being flushed, it has - * been resized by a resize flush - * op, and the flush function has - * not yet returned, This field is - * used to turn off overactive santity - * checking code that would otherwise - * cause a false test failure. - */ - hbool_t deserialized; /* entry has been deserialized since - * the last time it was reset. + haddr_t tag; /* the base_addr as tag for corking entries */ + hbool_t is_corked; /* entry is currently corked or not */ + int pinning_ref_count; /* Number of entries that + * pin this entry in the cache. + * When this count drops to zero, + * this entry should be unpinned. + */ + int num_pins; /* Number of entries that this + * entry pins in the cache. This + * value must be in the range + * [0, MAX_PINS]. + */ + int pin_type[MAX_PINS]; /* array of the types of entries + * pinned by this entry. + */ + int pin_idx[MAX_PINS]; /* array of the indicies of + * entries pinned by this entry. + */ + int num_flush_ops; /* integer field containing the + * number of flush operations to + * be executed when the entry is + * flushed. This value must lie in + * the closed interval + * [0, MAX_FLUSH_OPS]. + */ + struct flush_op flush_ops[MAX_FLUSH_OPS]; /* Array of instances + * of struct flush_op detailing the + * flush operations (if any) that + * are to be executed when the entry + * is flushed from the cache. + * + * num_flush_ops contains the number + * of valid entries in this array. + */ + hbool_t flush_op_self_resize_in_progress; /* Boolean flag + * that is set to TRUE iff this + * entry is being flushed, it has + * been resized by a resize flush + * op, and the flush function has + * not yet returned, This field is + * used to turn off overactive santity + * checking code that would otherwise + * cause a false test failure. + */ + hbool_t deserialized; /* entry has been deserialized since + * the last time it was reset. */ - hbool_t serialized; /* entry has been serialized since the + hbool_t serialized; /* entry has been serialized since the * last time it was reset. */ hbool_t destroyed; /* entry has been destroyed since the * last time it was reset. */ - hbool_t expunged; /* entry has been expunged since the + hbool_t expunged; /* entry has been expunged since the * last time it was reset. */ int flush_dep_par_type[MAX_FLUSH_DEP_PARS]; /* Entry types of flush dependency parents */ @@ -352,15 +352,15 @@ typedef struct test_entry_t unsigned flush_dep_npar; /* Number of flush dependency parents */ unsigned flush_dep_nchd; /* Number of flush dependency children */ unsigned flush_dep_ndirty_chd; /* Number of dirty flush dependency children (including granchildren, etc.) */ - hbool_t pinned_from_client; /* entry was pinned by client call */ - hbool_t pinned_from_cache; /* entry was pinned by cache internally */ + hbool_t pinned_from_client; /* entry was pinned by client call */ + hbool_t pinned_from_cache; /* entry was pinned by cache internally */ unsigned flush_order; /* Order that entry was flushed in */ unsigned notify_after_insert_count; /* Count of times that entry was inserted in cache */ unsigned notify_before_evict_count; /* Count of times that entry was removed in cache */ - size_t actual_len; /* Simulate the entry's actual size for a speculative load */ - unsigned max_verify_ct; /* Maximum # of times to verify an entry's checksum */ - unsigned verify_ct; /* Count the # of checksum verification for an entry */ + size_t actual_len; /* Simulate the entry's actual size for a speculative load */ + unsigned max_verify_ct; /* Maximum # of times to verify an entry's checksum */ + unsigned verify_ct; /* Count the # of checksum verification for an entry */ } test_entry_t; /* The following are cut down test versions of the hash table manipulation @@ -508,39 +508,37 @@ if ( ( (cache_ptr) == NULL ) || \ (i).empty_reserve = (e).empty_reserve; \ } - + /* misc type definitions */ struct expected_entry_status { - int entry_type; + int entry_type; int entry_index; size_t size; - hbool_t in_cache; + hbool_t in_cache; hbool_t at_main_addr; - hbool_t is_dirty; - hbool_t is_protected; - hbool_t is_pinned; - hbool_t deserialized; - hbool_t serialized; - hbool_t destroyed; + hbool_t is_dirty; + hbool_t is_protected; + hbool_t is_pinned; + hbool_t deserialized; + hbool_t serialized; + hbool_t destroyed; int flush_dep_par_type[MAX_FLUSH_DEP_PARS]; /* Entry types of flush dependency parents */ int flush_dep_par_idx[MAX_FLUSH_DEP_PARS]; /* Indices of flush dependency parents */ unsigned flush_dep_npar; /* Number of flush dependency parents */ unsigned flush_dep_nchd; /* Number of flush dependency children */ unsigned flush_dep_ndirty_chd; /* Number of dirty flush dependency children */ int flush_order; /* flush order of entry */ - unsigned char is_corked; /* cork status of entry */ + unsigned char is_corked; /* cork status of entry */ }; - + /* global variable externs: */ H5TEST_DLLVAR H5C_t * saved_cache; -H5TEST_DLLVAR const char *FILENAME[]; - H5TEST_DLLVAR haddr_t saved_actual_base_addr; H5TEST_DLLVAR hbool_t write_permitted; H5TEST_DLLVAR hbool_t pass; /* set to false on error */ @@ -556,7 +554,7 @@ H5TEST_DLLVAR const haddr_t alt_base_addrs[NUMBER_OF_ENTRY_TYPES]; H5TEST_DLLVAR const H5C_class_t *types[NUMBER_OF_ENTRY_TYPES]; - + #ifdef __cplusplus extern "C" { #endif @@ -641,8 +639,6 @@ H5TEST_DLL void resize_entry(H5F_t * file_ptr, size_t new_size, hbool_t in_cache); -H5TEST_DLL H5F_t *setup_cache(size_t max_cache_size, size_t min_clean_size, unsigned paged); - H5TEST_DLL void row_major_scan_forward(H5F_t * file_ptr, int32_t max_index, int32_t lag, @@ -727,10 +723,6 @@ H5TEST_DLL void hl_col_major_scan_backward(H5F_t * file_ptr, hbool_t do_inserts, int dirty_unprotects); -H5TEST_DLL void takedown_cache(H5F_t * file_ptr, - hbool_t dump_stats, - hbool_t dump_detailed_stats); - H5TEST_DLL void flush_cache(H5F_t * file_ptr, hbool_t destroy_entries, hbool_t dump_stats, @@ -747,7 +739,7 @@ H5TEST_DLL void unprotect_entry(H5F_t * file_ptr, H5TEST_DLL void verify_clean(void); H5TEST_DLL void verify_entry_status(H5C_t * cache_ptr, - int tag, + int tag, int num_entries, struct expected_entry_status expected[]); |