From b742150e4c2bc115c531bc285a86dc38153594ca Mon Sep 17 00:00:00 2001 From: John Mainzer Date: Thu, 9 Aug 2007 23:19:43 -0500 Subject: [svn-r14064] Implemented function allowing the user to cork the metadata cache. Also implemented associated test code. --- src/H5AC.c | 126 +- src/H5ACprivate.h | 2 + src/H5ACpublic.h | 33 + src/H5C.c | 140 +- src/H5Cpkg.h | 14 + src/H5Cprivate.h | 10 +- test/cache.c | 4248 +++++++++++++++++++++++++++++++++++------------------ test/cache_api.c | 155 +- testpar/t_cache.c | 32 +- 9 files changed, 3264 insertions(+), 1496 deletions(-) diff --git a/src/H5AC.c b/src/H5AC.c index 31f757f..3389dc6 100644 --- a/src/H5AC.c +++ b/src/H5AC.c @@ -2537,6 +2537,15 @@ done: * JRM - 6/8/06 * Added support for the new trace file related fields. * + * JRM - 7/28/07 + * Added support for the new evictions enabled related fields. + * + * Observe that H5AC_get_cache_auto_resize_config() and + * H5AC_set_cache_auto_resize_config() are becoming generic + * metadata cache configuration routines as they gain + * switches for functions that are only tenuously related + * to auto resize configuration. + * *------------------------------------------------------------------------- */ @@ -2546,6 +2555,7 @@ H5AC_get_cache_auto_resize_config(H5AC_t * cache_ptr, { herr_t result; herr_t ret_value = SUCCEED; /* Return value */ + hbool_t evictions_enabled; H5C_auto_size_ctl_t internal_config; FUNC_ENTER_NOAPI(H5AC_get_cache_auto_resize_config, FAIL) @@ -2581,6 +2591,14 @@ H5AC_get_cache_auto_resize_config(H5AC_t * cache_ptr, "H5C_get_cache_auto_resize_config() failed.") } + result = H5C_get_evictions_enabled((H5C_t *)cache_ptr, &evictions_enabled); + + if ( result < 0 ) { + + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ + "H5C_get_resize_enabled() failed.") + } + if ( internal_config.rpt_fcn == NULL ) { config_ptr->rpt_fcn_enabled = FALSE; @@ -2593,6 +2611,8 @@ H5AC_get_cache_auto_resize_config(H5AC_t * cache_ptr, config_ptr->open_trace_file = FALSE; config_ptr->close_trace_file = FALSE; config_ptr->trace_file_name[0] = '\0'; + config_ptr->set_evictions_enabled = FALSE; + config_ptr->evictions_enabled = evictions_enabled; config_ptr->set_initial_size = internal_config.set_initial_size; config_ptr->initial_size = internal_config.initial_size; config_ptr->min_clean_fraction = internal_config.min_clean_fraction; @@ -2788,6 +2808,15 @@ done: * John Mainzer -- 6/7/06 * Added trace file support. * + * John Mainzer -- 7/28/07 + * Added support for the new evictions enabled related fields. + * + * Observe that H5AC_get_cache_auto_resize_config() and + * H5AC_set_cache_auto_resize_config() are becoming generic + * metadata cache configuration routines as they gain + * switches for functions that are only tenuously related + * to auto resize configuration. + * *------------------------------------------------------------------------- */ @@ -2835,56 +2864,11 @@ H5AC_set_cache_auto_resize_config(H5AC_t * cache_ptr, HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "bad cache_ptr on entry.") } - if ( config_ptr == NULL ) { - - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL config_ptr on entry.") - } - - if ( config_ptr->version != H5AC__CURR_CACHE_CONFIG_VERSION ) { - - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Unknown config version.") - } - - if ( ( config_ptr->rpt_fcn_enabled != TRUE ) && - ( config_ptr->rpt_fcn_enabled != FALSE ) ) { - - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ - "config_ptr->rpt_fcn_enabled must be either TRUE or FALSE.") - } - - if ( ( config_ptr->open_trace_file != TRUE ) && - ( config_ptr->open_trace_file != FALSE ) ) { - - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ - "config_ptr->open_trace_file must be either TRUE or FALSE.") - } - - if ( ( config_ptr->close_trace_file != TRUE ) && - ( config_ptr->close_trace_file != FALSE ) ) { - - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ - "config_ptr->close_trace_file must be either TRUE or FALSE.") - } - - /* don't bother to test trace_file_name unless open_trace_file is TRUE */ - if ( config_ptr->open_trace_file ) { - - /* Can't really test the trace_file_name field without trying to - * open the file, so we will content ourselves with a couple of - * sanity checks on the length of the file name. - */ - name_len = HDstrlen(config_ptr->trace_file_name); - - if ( name_len <= 0 ) { - - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ - "config_ptr->trace_file_name is empty.") + result = H5AC_validate_config(config_ptr); - } else if ( name_len > H5AC__MAX_TRACE_FILE_NAME_LEN ) { + if ( result != SUCCEED ) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ - "config_ptr->trace_file_name too long.") - } + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Bad cache configuration"); } if ( config_ptr->open_trace_file ) { @@ -2957,6 +2941,18 @@ H5AC_set_cache_auto_resize_config(H5AC_t * cache_ptr, "H5C_set_cache_auto_resize_config() failed.") } + if ( config_ptr->set_evictions_enabled ) { + + result = H5C_set_evictions_enabled((H5C_t *)cache_ptr, + config_ptr->evictions_enabled); + + if ( result < 0 ) { + + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ + "H5C_set_evictions_enabled() failed.") + } + } + #ifdef H5_HAVE_PARALLEL if ( cache_ptr->aux_ptr != NULL ) { @@ -2977,13 +2973,15 @@ done: ( trace_file_ptr != NULL ) ) { HDfprintf(trace_file_ptr, - "%s %d %d %d %d \"%s\" %d %d %f %d %d %ld %d %f %f %d %d %d %f %f %d %d %d %d %f %d %d\n", + "%s %d %d %d %d \"%s\" %d %d %d %d %f %d %d %ld %d %f %f %d %d %d %f %f %d %d %d %d %f %d %d\n", "H5AC_set_cache_auto_resize_config", trace_config.version, (int)(trace_config.rpt_fcn_enabled), (int)(trace_config.open_trace_file), (int)(trace_config.close_trace_file), trace_config.trace_file_name, + (int)(trace_config.set_evictions_enabled), + (int)(trace_config.evictions_enabled), (int)(trace_config.set_initial_size), (int)(trace_config.initial_size), trace_config.min_clean_fraction, @@ -3041,6 +3039,13 @@ done: * are applied. * JRM - 5/15/06 * + * - Added code testing the evictions enabled field. At + * present this consists of verifying that if + * set_evictions_enabled is TRUE and evictions_enabled + * is FALSE, then automatic cache resizing in disabled. + * + * JRM - 7/28/07 + * *------------------------------------------------------------------------- */ @@ -3107,6 +3112,29 @@ H5AC_validate_config(H5AC_cache_config_t * config_ptr) } } + if ( ( config_ptr->set_evictions_enabled != TRUE ) && + ( config_ptr->set_evictions_enabled != FALSE ) ) { + + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ + "config_ptr->set_evictions_enabled must be either TRUE or FALSE.") + } + + if ( ( config_ptr->evictions_enabled != TRUE ) && + ( config_ptr->evictions_enabled != FALSE ) ) { + + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ + "config_ptr->evictions_enabled must be either TRUE or FALSE.") + } + + if ( ( config_ptr->set_evictions_enabled == TRUE ) && + ( config_ptr->evictions_enabled == FALSE ) && + ( ( config_ptr->incr_mode != H5C_incr__off ) || + ( config_ptr->incr_mode != H5C_decr__off ) ) ) { + + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ + "Can't disable evictions while auto-resize is enabled.") + } + if ( config_ptr->dirty_bytes_threshold < H5AC__MIN_DIRTY_BYTES_THRESHOLD ) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, diff --git a/src/H5ACprivate.h b/src/H5ACprivate.h index 34ca4ef..0d10c88 100644 --- a/src/H5ACprivate.h +++ b/src/H5ACprivate.h @@ -201,6 +201,8 @@ extern hid_t H5AC_ind_dxpl_id; /* hbool_t open_trace_file = */ FALSE, \ /* hbool_t close_trace_file = */ FALSE, \ /* char trace_file_name[] = */ "", \ + /* hbool_t set_evictions_enabled = */ FALSE, \ + /* hbool_t evictions_enabled = */ TRUE, \ /* hbool_t set_initial_size = */ TRUE, \ /* size_t initial_size = */ ( 1 * 1024 * 1024), \ /* double min_clean_fraction = */ 0.5, \ diff --git a/src/H5ACpublic.h b/src/H5ACpublic.h index 362b14f..76e5530 100644 --- a/src/H5ACpublic.h +++ b/src/H5ACpublic.h @@ -107,6 +107,30 @@ extern "C" { * The length of the path must not exceed H5AC__MAX_TRACE_FILE_NAME_LEN * characters. * + * set_evictions_enabled: Boolean flag indicating whether the cache + * evictions_enabled flag is to be set to the value specified + * in the evictions_enabled field below. + * + * evictions_enabled: Boolean field used to either report the current + * evictions enabled status of the cache, or, when + * set_evictions_enabled is TRUE, to set the cache's evictions + * enabled status. + * + * In general, the metadata cache should always be allowed to + * evict entries. However, in some cases it is advantageous to + * disable evictions briefly, and thereby postpone metadata + * writes. However, this must be done with care, as the cache + * can grow quickly. If you do this, re-enable evictions as + * soon as possible and monitor cache size. + * + * At present, evictions can only be disabled if automatic + * cache resizing is also disabled (that is, ( incr_mode == + * H5C_incr__off ) && ( decr_mode == H5C_decr__off )). There + * is no logical reason why this should be so, but it simplifies + * implementation and testing, and I can't think of any reason + * why it would be desireable. If you can think of one, I'll + * revisit the issue. + * * set_initial_size: Boolean flag indicating whether the size of the * initial size of the cache is to be set to the value given in * the initial_size field. If set_initial_size is FALSE, the @@ -160,6 +184,9 @@ extern "C" { * at its maximum size, or if the cache is not already using * all available space. * + * Note that you must set decr_mode to H5C_incr__off if you + * disable metadata cache entry evictions. + * * lower_hr_threshold: Lower hit rate threshold. If the increment mode * (incr_mode) is H5C_incr__threshold and the hit rate drops below the * value supplied in this field in an epoch, increment the cache size by @@ -217,6 +244,9 @@ extern "C" { * over the last epoch exceeds the value provided in the * upper_hr_threshold field. * + * Note that you must set decr_mode to H5C_decr__off if you + * disable metadata cache entry evictions. + * * upper_hr_threshold: Upper hit rate threshold. The use of this field * varies according to the current decr_mode: * @@ -316,6 +346,9 @@ typedef struct H5AC_cache_config_t hbool_t close_trace_file; char trace_file_name[H5AC__MAX_TRACE_FILE_NAME_LEN + 1]; + hbool_t set_evictions_enabled; + hbool_t evictions_enabled; + hbool_t set_initial_size; size_t initial_size; diff --git a/src/H5C.c b/src/H5C.c index d9951fe..8ac9929 100644 --- a/src/H5C.c +++ b/src/H5C.c @@ -2835,6 +2835,10 @@ done: * Added initialization for the new is_read_only and * ro_ref_count fields. * + * JRM -- 7/27/07 +* Added initialization for the new evictions_enabled +* field of H5C_t. + * *------------------------------------------------------------------------- */ @@ -2906,6 +2910,8 @@ H5C_create(size_t max_cache_size, cache_ptr->log_flush = log_flush; + cache_ptr->evictions_enabled = TRUE; + cache_ptr->index_len = 0; cache_ptr->index_size = (size_t)0; @@ -4260,6 +4266,52 @@ done: /*------------------------------------------------------------------------- + * Function: H5C_get_evictions_enabled() + * + * Purpose: Copy the current value of cache_ptr->evictions_enabled into + * *evictions_enabled_ptr. + * + * Return: SUCCEED on success, and FAIL on failure. + * + * Programmer: John Mainzer + * 7/27/07 + * + * Modifications: + * + * None. + * + *------------------------------------------------------------------------- + */ + +herr_t +H5C_get_evictions_enabled(H5C_t * cache_ptr, + hbool_t * evictions_enabled_ptr) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5C_get_evictions_enabled, FAIL) + + if ( ( cache_ptr == NULL ) || ( cache_ptr->magic != H5C__H5C_T_MAGIC ) ) { + + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr on entry.") + } + + if ( evictions_enabled_ptr == NULL ) { + + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ + "Bad evictions_enabled_ptr on entry.") + } + + *evictions_enabled_ptr = cache_ptr->evictions_enabled; + +done: + + FUNC_LEAVE_NOAPI(ret_value) + +} /* H5C_get_evictions_enabled() */ + + +/*------------------------------------------------------------------------- * Function: H5C_get_trace_file_ptr * * Purpose: Get the trace_file_ptr field from the cache. @@ -4378,6 +4430,10 @@ done: * Added initialization for the new is_read_only and * ro_ref_count fields. * + * JRM -- 8/1/07 + * Added code to disable evictions when the new + * evictions_enabled field is FALSE. + * *------------------------------------------------------------------------- */ @@ -4468,7 +4524,9 @@ H5C_insert_entry(H5F_t * f, H5C__RESET_CACHE_ENTRY_STATS(entry_ptr) - if ((cache_ptr->index_size + entry_ptr->size) > cache_ptr->max_cache_size) { + if ( ( cache_ptr->evictions_enabled ) && + ( (cache_ptr->index_size + entry_ptr->size) > + cache_ptr->max_cache_size ) ) { size_t space_needed; @@ -5545,6 +5603,10 @@ done: * Also added code to allow multiple read only protects * of cache entries. * + * JRM -- 7/27/07 + * Added code supporting the new evictions_enabled fieled + * in H5C_t. + * *------------------------------------------------------------------------- */ @@ -5616,9 +5678,10 @@ H5C_protect(H5F_t * f, entry_ptr = (H5C_cache_entry_t *)thing; - /* try to free up some space if necessary */ - if ( (cache_ptr->index_size + entry_ptr->size) > - cache_ptr->max_cache_size ) { + /* try to free up some space if necessary and if evictions are permitted */ + if ( ( cache_ptr->evictions_enabled ) && + ( (cache_ptr->index_size + entry_ptr->size) > + cache_ptr->max_cache_size ) ) { size_t space_needed; @@ -5754,10 +5817,11 @@ H5C_protect(H5F_t * f, ret_value = thing; - if ( ( cache_ptr->size_decreased ) || - ( ( cache_ptr->resize_enabled ) && - ( cache_ptr->cache_accesses >= - (cache_ptr->resize_ctl).epoch_length ) ) ) { + if ( ( cache_ptr->evictions_enabled ) && + ( ( cache_ptr->size_decreased ) || + ( ( cache_ptr->resize_enabled ) && + ( cache_ptr->cache_accesses >= + (cache_ptr->resize_ctl).epoch_length ) ) ) ) { if ( ! have_write_permitted ) { @@ -6140,6 +6204,66 @@ done: /*------------------------------------------------------------------------- + * Function: H5C_set_evictions_enabled() + * + * Purpose: Set cache_ptr->evictions_enabled to the value of the + * evictions enabled parameter. + * + * Return: SUCCEED on success, and FAIL on failure. + * + * Programmer: John Mainzer + * 7/27/07 + * + * Modifications: + * + * None. + * + *------------------------------------------------------------------------- + */ + +herr_t +H5C_set_evictions_enabled(H5C_t * cache_ptr, + hbool_t evictions_enabled) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5C_set_evictions_enabled, FAIL) + + if ( ( cache_ptr == NULL ) || ( cache_ptr->magic != H5C__H5C_T_MAGIC ) ) { + + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr on entry.") + } + + if ( ( evictions_enabled != TRUE ) && ( evictions_enabled != FALSE ) ) { + + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ + "Bad evictions_enabled on entry.") + } + + /* There is no fundamental reason why we should not permit + * evictions to be disabled while automatic resize is enabled. + * However, I can't think of any good reason why one would + * want to, and allowing it would greatly complicate testing + * the feature. Hence the following: + */ + if ( ( evictions_enabled != TRUE ) && + ( ( cache_ptr->resize_ctl.incr_mode != H5C_incr__off ) || + ( cache_ptr->resize_ctl.decr_mode != H5C_decr__off ) ) ) { + + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ + "Can't disable evictions when auto resize enabled.") + } + + cache_ptr->evictions_enabled = evictions_enabled; + +done: + + FUNC_LEAVE_NOAPI(ret_value) + +} /* H5C_set_evictions_enabled() */ + + +/*------------------------------------------------------------------------- * Function: H5C_set_prefix * * Purpose: Set the values of the prefix field of H5C_t. This diff --git a/src/H5Cpkg.h b/src/H5Cpkg.h index 3b8d650..949f923 100644 --- a/src/H5Cpkg.h +++ b/src/H5Cpkg.h @@ -176,6 +176,18 @@ * entry is flushed to disk. * * + * In cases where memory is plentiful, and performance is an issue, it + * is useful to disable all cache evictions, and thereby postpone metadata + * writes. The following field is used to implement this. + * + * evictions_enabled: Boolean flag that is initialized to TRUE. When + * this flag is set to FALSE, the metadata cache will not + * attempt to evict entries to make space for newly protected + * entries, and instead the will grow without limit. + * + * Needless to say, this feature must be used with care. + * + * * The cache requires an index to facilitate searching for entries. The * following fields support that index. * @@ -802,6 +814,8 @@ struct H5C_t H5C_log_flush_func_t log_flush; + hbool_t evictions_enabled; + int32_t index_len; size_t index_size; H5C_cache_entry_t * (index[H5C__HASH_TABLE_LEN]); diff --git a/src/H5Cprivate.h b/src/H5Cprivate.h index d3fcbeb..e169bd6 100644 --- a/src/H5Cprivate.h +++ b/src/H5Cprivate.h @@ -37,7 +37,7 @@ #include "H5Fprivate.h" /* File access */ -#define H5C_DO_SANITY_CHECKS 0 +#define H5C_DO_SANITY_CHECKS 1 #define H5C_DO_EXTREME_SANITY_CHECKS 0 /* This sanity checking constant was picked out of the air. Increase @@ -51,7 +51,7 @@ /* H5C_COLLECT_CACHE_STATS controls overall collection of statistics * on cache activity. In general, this #define should be set to 0. */ -#define H5C_COLLECT_CACHE_STATS 0 +#define H5C_COLLECT_CACHE_STATS 1 /* H5C_COLLECT_CACHE_ENTRY_STATS controls collection of statistics * in individual cache entries. @@ -901,6 +901,9 @@ H5_DLL herr_t H5C_get_entry_status(H5C_t * cache_ptr, hbool_t * is_protected_ptr, hbool_t * is_pinned_ptr); +H5_DLL herr_t H5C_get_evictions_enabled(H5C_t * cache_ptr, + hbool_t * evictions_enabled_ptr); + H5_DLL herr_t H5C_get_trace_file_ptr(H5C_t * cache_ptr, FILE ** trace_file_ptr_ptr); @@ -955,6 +958,9 @@ H5_DLL herr_t H5C_resize_pinned_entry(H5C_t * cache_ptr, H5_DLL herr_t H5C_set_cache_auto_resize_config(H5C_t * cache_ptr, H5C_auto_size_ctl_t *config_ptr); +H5_DLL herr_t H5C_set_evictions_enabled(H5C_t * cache_ptr, + hbool_t evictions_enabled); + H5_DLL herr_t H5C_set_prefix(H5C_t * cache_ptr, char * prefix); H5_DLL herr_t H5C_set_skip_flags(H5C_t * cache_ptr, diff --git a/test/cache.c b/test/cache.c index b4caa68..a0bc5b1 100644 --- a/test/cache.c +++ b/test/cache.c @@ -34,6 +34,8 @@ static void smoke_check_5(void); static void smoke_check_6(void); static void smoke_check_7(void); static void smoke_check_8(void); +static void smoke_check_9(void); +static void smoke_check_10(void); static void write_permitted_check(void); static void check_insert_entry(void); static void check_flush_cache(void); @@ -98,6 +100,7 @@ static void check_rename_entry__run_test(H5C_t * cache_ptr, int test_num, struct rename_entry_test_spec * spec_ptr); static void check_pin_protected_entry(void); static void check_resize_entry(void); +static void check_evictions_enabled(void); static void check_destroy_pinned_err(void); static void check_destroy_protected_err(void); static void check_duplicate_insert_err(void); @@ -112,6 +115,7 @@ static void check_expunge_entry_errs(void); static void check_resize_entry_errs(void); static void check_unprotect_ro_dirty_err(void); static void check_protect_ro_rw_err(void); +static void check_check_evictions_enabled_err(void); static void check_auto_cache_resize(void); static void check_auto_cache_resize_disable(void); static void check_auto_cache_resize_epoch_markers(void); @@ -1842,42 +1846,53 @@ smoke_check_8(void) /*------------------------------------------------------------------------- - * Function: write_permitted_check() + * Function: smoke_check_9() * - * Purpose: A basic test of the write permitted function. In essence, - * we load the cache up with dirty entryies, set - * write_permitted to FALSE, and then protect a bunch of - * entries. If there are any writes while write_permitted is - * FALSE, the test will fail. + * Purpose: A repeat of smoke check 1, only with the cache corked + * part of the time. + * + * Recall that smoke check 1 is a basic functional test, + * with inserts, destroys, and renames in the mix, along + * with repeated protects and unprotects. All entries are + * marked as clean. * * Return: void * * Programmer: John Mainzer - * 6/24/04 + * 8/1/07 * * Modifications: * + * None. + * *------------------------------------------------------------------------- */ static void -write_permitted_check(void) +smoke_check_9(void) { - -#if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS - - const char * fcn_name = "write_permitted_check"; + const char * fcn_name = "smoke_check_9"; + herr_t result; hbool_t show_progress = FALSE; + hbool_t dirty_inserts = FALSE; + int dirty_unprotects = FALSE; + int dirty_destroys = FALSE; hbool_t display_stats = FALSE; + hbool_t display_detailed_stats = FALSE; int32_t lag = 10; int mile_stone = 1; H5C_t * cache_ptr = NULL; -#endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ + TESTING("smoke check #9 -- all clean, ins, dest, ren, 4/2 MB, corked"); - TESTING("write permitted check -- 1/0 MB cache"); + if ( skip_long_tests ) { -#if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS + SKIPPED(); + + HDfprintf(stdout, " Long tests disabled.\n"); + + return; + } pass = TRUE; @@ -1891,74 +1906,134 @@ write_permitted_check(void) HDfprintf(stdout, "%s() - %0d -- pass = %d\n", fcn_name, mile_stone++, (int)pass); - cache_ptr = setup_cache((size_t)(1 * 1024 * 1024), - (size_t)(0)); + cache_ptr = setup_cache((size_t)(4 * 1024 * 1024), + (size_t)(2 * 1024 * 1024)); + + /* disable evictions */ if ( show_progress ) /* 3 */ HDfprintf(stdout, "%s() - %0d -- pass = %d\n", fcn_name, mile_stone++, (int)pass); + if ( pass ) { + + result = H5C_set_evictions_enabled(cache_ptr, FALSE); + + if ( result < 0 ) { + + pass = FALSE; + failure_mssg = "can't disable evictions 1.\n"; + } + } + + if ( show_progress ) /* 4 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions disabled\n", + fcn_name, mile_stone++, (int)pass); + row_major_scan_forward(/* cache_ptr */ cache_ptr, /* lag */ lag, /* verbose */ FALSE, /* reset_stats */ TRUE, /* display_stats */ display_stats, - /* display_detailed_stats */ TRUE, + /* display_detailed_stats */ display_detailed_stats, /* do_inserts */ TRUE, - /* dirty_inserts */ TRUE, + /* dirty_inserts */ dirty_inserts, /* do_renames */ TRUE, /* rename_to_main_addr */ FALSE, /* do_destroys */ TRUE, /* do_mult_ro_protects */ TRUE, - /* dirty_destroys */ TRUE, - /* dirty_unprotects */ TRUE); + /* dirty_destroys */ dirty_destroys, + /* dirty_unprotects */ dirty_unprotects); - if ( show_progress ) /* 4 */ + /* enable evictions */ + + if ( show_progress ) /* 5 */ HDfprintf(stdout, "%s() - %0d -- pass = %d\n", fcn_name, mile_stone++, (int)pass); - write_permitted = FALSE; + if ( pass ) { + + result = H5C_set_evictions_enabled(cache_ptr, TRUE); + + if ( result < 0 ) { + + pass = FALSE; + failure_mssg = "can't enable evictions 1.\n"; + } + } + + if ( show_progress ) /* 6 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions enabled \n", + fcn_name, mile_stone++, (int)pass); row_major_scan_backward(/* cache_ptr */ cache_ptr, /* lag */ lag, /* verbose */ FALSE, /* reset_stats */ TRUE, /* display_stats */ display_stats, - /* display_detailed_stats */ TRUE, + /* display_detailed_stats */ display_detailed_stats, /* do_inserts */ FALSE, - /* dirty_inserts */ FALSE, + /* dirty_inserts */ dirty_inserts, /* do_renames */ TRUE, /* rename_to_main_addr */ TRUE, /* do_destroys */ FALSE, /* do_mult_ro_protects */ TRUE, - /* dirty_destroys */ FALSE, - /* dirty_unprotects */ NO_CHANGE); + /* dirty_destroys */ dirty_destroys, + /* dirty_unprotects */ dirty_unprotects); - if ( show_progress ) /* 5 */ + if ( show_progress ) /* 7 */ HDfprintf(stdout, "%s() - %0d -- pass = %d\n", fcn_name, mile_stone++, (int)pass); - write_permitted = TRUE; + if ( pass ) { + + result = H5C_set_evictions_enabled(cache_ptr, FALSE); + + if ( result < 0 ) { + + pass = FALSE; + failure_mssg = "can't disable evictions 2.\n"; + } + } + + if ( show_progress ) /* 8 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions disabled \n", + fcn_name, mile_stone++, (int)pass); row_major_scan_forward(/* cache_ptr */ cache_ptr, /* lag */ lag, /* verbose */ FALSE, /* reset_stats */ TRUE, /* display_stats */ display_stats, - /* display_detailed_stats */ TRUE, + /* display_detailed_stats */ display_detailed_stats, /* do_inserts */ TRUE, - /* dirty_inserts */ TRUE, + /* dirty_inserts */ dirty_inserts, /* do_renames */ TRUE, /* rename_to_main_addr */ FALSE, /* do_destroys */ FALSE, /* do_mult_ro_protects */ TRUE, - /* dirty_destroys */ TRUE, - /* dirty_unprotects */ TRUE); + /* dirty_destroys */ dirty_destroys, + /* dirty_unprotects */ dirty_unprotects); - if ( show_progress ) /* 6 */ + if ( show_progress ) /* 9 */ HDfprintf(stdout, "%s() - %0d -- pass = %d\n", fcn_name, mile_stone++, (int)pass); + if ( pass ) { + + result = H5C_set_evictions_enabled(cache_ptr, TRUE); + + if ( result < 0 ) { + + pass = FALSE; + failure_mssg = "can't enable evictions 2.\n"; + } + } + + if ( show_progress ) /* 10 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions enabled \n", + fcn_name, mile_stone++, (int)pass); + /* flush and destroy all entries in the cache: */ flush_cache(/* cache_ptr */ cache_ptr, @@ -1966,45 +2041,98 @@ write_permitted_check(void) /* dump_stats */ FALSE, /* dump_detailed_stats */ FALSE); - if ( show_progress ) /* 7 */ + if ( show_progress ) /* 11 */ HDfprintf(stdout, "%s() - %0d -- pass = %d\n", fcn_name, mile_stone++, (int)pass); + if ( pass ) { + + result = H5C_set_evictions_enabled(cache_ptr, FALSE); + + if ( result < 0 ) { + + pass = FALSE; + failure_mssg = "can't disable evictions 3.\n"; + } + } + + if ( show_progress ) /* 12 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions disabled\n", + fcn_name, mile_stone++, (int)pass); + col_major_scan_forward(/* cache_ptr */ cache_ptr, /* lag */ lag, /* verbose */ FALSE, /* reset_stats */ TRUE, /* display_stats */ display_stats, - /* display_detailed_stats */ TRUE, + /* display_detailed_stats */ display_detailed_stats, /* do_inserts */ TRUE, - /* dirty_inserts */ TRUE, - /* dirty_unprotects */ TRUE); + /* dirty_inserts */ dirty_inserts, + /* dirty_unprotects */ dirty_unprotects); - if ( show_progress ) /* 8 */ + if ( show_progress ) /* 13 */ HDfprintf(stdout, "%s() - %0d -- pass = %d\n", fcn_name, mile_stone++, (int)pass); - write_permitted = FALSE; + /* flush all entries in the cache: */ + + flush_cache(/* cache_ptr */ cache_ptr, + /* destroy_entries */ FALSE, + /* dump_stats */ FALSE, + /* dump_detailed_stats */ FALSE); + + if ( show_progress ) /* 14 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); + + if ( pass ) { + + result = H5C_set_evictions_enabled(cache_ptr, TRUE); + + if ( result < 0 ) { + + pass = FALSE; + failure_mssg = "can't enable evictions 3.\n"; + } + } + + if ( show_progress ) /* 15 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions enabled\n", + fcn_name, mile_stone++, (int)pass); col_major_scan_backward(/* cache_ptr */ cache_ptr, /* lag */ lag, /* verbose */ FALSE, /* reset_stats */ TRUE, /* display_stats */ display_stats, - /* display_detailed_stats */ TRUE, - /* do_inserts */ FALSE, - /* dirty_inserts */ FALSE, - /* dirty_unprotects */ NO_CHANGE); - - write_permitted = TRUE; + /* display_detailed_stats */ display_detailed_stats, + /* do_inserts */ TRUE, + /* dirty_inserts */ dirty_inserts, + /* dirty_unprotects */ dirty_unprotects); - if ( show_progress ) /* 9 */ + if ( show_progress ) /* 16 */ HDfprintf(stdout, "%s() - %0d -- pass = %d\n", fcn_name, mile_stone++, (int)pass); + if ( pass ) { + + result = H5C_set_evictions_enabled(cache_ptr, FALSE); + + if ( result < 0 ) { + + pass = FALSE; + failure_mssg = "can't disable evictions 4.\n"; + } + } + + + if ( show_progress ) /* 17 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions disabled\n", + fcn_name, mile_stone++, (int)pass); + takedown_cache(cache_ptr, display_stats, TRUE); - if ( show_progress ) /* 10 */ + if ( show_progress ) /* 18 */ HDfprintf(stdout, "%s() - %0d -- pass = %d\n", fcn_name, mile_stone++, (int)pass); @@ -2019,307 +2147,299 @@ write_permitted_check(void) fcn_name, failure_mssg); } -#else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - - SKIPPED(); - - HDfprintf(stdout, " Clean and dirty LRU lists disabled.\n"); - -#endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - return; -} /* write_permitted_check() */ +} /* smoke_check_9() */ /*------------------------------------------------------------------------- - * Function: check_insert_entry() + * Function: smoke_check_10() * - * Purpose: Verify that H5C_insert_entry behaves as expected. - * Test the behaviour with different flags. + * Purpose: A repeat of smoke check 2, only with the cache corked + * part of the time. * - * This test was added primarily to test basic insert - * pinned entry functionallity, but I through in explicit - * tests for other functionallity that is tested implicitly - * elsewhere. + * Recall that smoke check 2 is a basic functional test, + * with inserts, destroys, and renames in the mix, along + * with some repeated protects and unprotects. About half + * the entries are marked as dirty. * * Return: void * * Programmer: John Mainzer - * 8/10/06 + * 8/1/07 * * Modifications: * + * None. + * *------------------------------------------------------------------------- */ static void -check_insert_entry(void) +smoke_check_10(void) { - const char * fcn_name = "check_insert_entry"; - int entry_type = PICO_ENTRY_TYPE; - int i; - herr_t result; - hbool_t in_cache; - hbool_t is_dirty; - hbool_t is_protected; - hbool_t is_pinned; - size_t entry_size; - H5C_t * cache_ptr = NULL; - test_entry_t * base_addr; - test_entry_t * entry_ptr; - struct H5C_cache_entry_t * search_ptr; - - - TESTING("H5C_insert_entry() functionality"); + const char * fcn_name = "smoke_check_10"; + herr_t result; + hbool_t show_progress = FALSE; + hbool_t dirty_inserts = TRUE; + int dirty_unprotects = TRUE; + int dirty_destroys = TRUE; + hbool_t display_stats = FALSE; + hbool_t display_detailed_stats = FALSE; + int32_t lag = 10; + int mile_stone = 1; + H5C_t * cache_ptr = NULL; - pass = TRUE; + TESTING("smoke check #10 -- ~1/2 dirty, ins, dest, ren, 4/2 MB, corked"); - /* Allocate a cache, and insert entries into it using all - * combinations of flags. Verify that the entries are inserted, - * and that the flags have the desired effects. - * - * Note that the dirty parameter in insert_entry is no longer - * used, as we have decided that all inserted entries are - * dirty by definition. (Which sounds very reasonable, but didn't - * used to be the case.) - */ + if ( skip_long_tests ) { - if ( pass ) { + SKIPPED(); - reset_entries(); + HDfprintf(stdout, " Long tests disabled.\n"); - cache_ptr = setup_cache((size_t)(2 * 1024 * 1024), - (size_t)(1 * 1024 * 1024)); + return; } - if ( pass ) { + pass = TRUE; - insert_entry(cache_ptr, entry_type, 0, TRUE, H5C__NO_FLAGS_SET); - insert_entry(cache_ptr, entry_type, 1, TRUE, - H5C__SET_FLUSH_MARKER_FLAG); - insert_entry(cache_ptr, entry_type, 2, TRUE, H5C__PIN_ENTRY_FLAG); - insert_entry(cache_ptr, entry_type, 3, TRUE, - (H5C__SET_FLUSH_MARKER_FLAG | H5C__PIN_ENTRY_FLAG)); - } + if ( show_progress ) /* 1 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); + reset_entries(); - /* Verify that the entries are inserted as desired. */ + if ( show_progress ) /* 2 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); - i = 0; - base_addr = entries[0]; - while ( ( pass ) && ( i < 4 ) ) - { - entry_ptr = &(base_addr[i]); + cache_ptr = setup_cache((size_t)(4 * 1024 * 1024), + (size_t)(2 * 1024 * 1024)); - /* Start by checking everything we can via H5C_get_entry_status() */ + if ( show_progress ) /* 3 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions enabled\n", + fcn_name, mile_stone++, (int)pass); - result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size, - &in_cache, &is_dirty, &is_protected, - &is_pinned); + row_major_scan_forward(/* cache_ptr */ cache_ptr, + /* lag */ lag, + /* verbose */ FALSE, + /* reset_stats */ TRUE, + /* display_stats */ display_stats, + /* display_detailed_stats */ display_detailed_stats, + /* do_inserts */ TRUE, + /* dirty_inserts */ dirty_inserts, + /* do_renames */ TRUE, + /* rename_to_main_addr */ FALSE, + /* do_destroys */ TRUE, + /* do_mult_ro_protects */ TRUE, + /* dirty_destroys */ dirty_destroys, + /* dirty_unprotects */ dirty_unprotects); - if ( result < 0 ) { + if ( show_progress ) /* 4 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); - pass = FALSE; - failure_mssg = "H5AC_get_entry_status() reports failure."; - } + if ( pass ) { - if ( pass ) { + result = H5C_set_evictions_enabled(cache_ptr, FALSE); - /* check the universals */ - if ( ( ! in_cache ) || ( ! is_dirty ) || ( is_protected ) || - ( entry_size != entry_sizes[entry_type] ) ) { + if ( result < 0 ) { - pass = FALSE; - failure_mssg = "Unexpected insert results 1."; - } + pass = FALSE; + failure_mssg = "can't disable evictions 1.\n"; } + } - if ( pass ) { + if ( show_progress ) /* 5 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions disabled\n", + fcn_name, mile_stone++, (int)pass); - /* verify that the pinned flag got set correctly */ - if ( ( i == 2 ) || ( i == 3 ) ) { + row_major_scan_backward(/* cache_ptr */ cache_ptr, + /* lag */ lag, + /* verbose */ FALSE, + /* reset_stats */ TRUE, + /* display_stats */ display_stats, + /* display_detailed_stats */ display_detailed_stats, + /* do_inserts */ FALSE, + /* dirty_inserts */ dirty_inserts, + /* do_renames */ TRUE, + /* rename_to_main_addr */ TRUE, + /* do_destroys */ FALSE, + /* do_mult_ro_protects */ TRUE, + /* dirty_destroys */ dirty_destroys, + /* dirty_unprotects */ dirty_unprotects); - if ( ! is_pinned ) { + if ( show_progress ) /* 6 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); - pass = FALSE; - failure_mssg = "Unexpected insert results 2."; - } - } else if ( is_pinned ) { + if ( pass ) { - pass = FALSE; - failure_mssg = "Unexpected insert results 3."; + result = H5C_set_evictions_enabled(cache_ptr, TRUE); - } else if ( is_pinned != ((entry_ptr->header).is_pinned) ) { + if ( result < 0 ) { - pass = FALSE; - failure_mssg = "Unexpected insert results 4."; - } + pass = FALSE; + failure_mssg = "can't enable evictions 1.\n"; } + } - /* Thats all we can get from H5AC_get_entry_status(). - * Now start looking at the cache data structures directly. - */ - - if ( pass ) { - - /* Verify that the flush marker got set correctly */ - if ( ( i == 1 ) || ( i == 3 ) ) { - - if ( ! ((entry_ptr->header).flush_marker) ) { + if ( show_progress ) /* 7 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions enabled\n", + fcn_name, mile_stone++, (int)pass); - pass = FALSE; - failure_mssg = "Unexpected insert results 5."; - } - } else if ( (entry_ptr->header).flush_marker ) { + row_major_scan_forward(/* cache_ptr */ cache_ptr, + /* lag */ lag, + /* verbose */ FALSE, + /* reset_stats */ TRUE, + /* display_stats */ display_stats, + /* display_detailed_stats */ display_detailed_stats, + /* do_inserts */ TRUE, + /* dirty_inserts */ dirty_inserts, + /* do_renames */ TRUE, + /* rename_to_main_addr */ FALSE, + /* do_destroys */ FALSE, + /* do_mult_ro_protects */ TRUE, + /* dirty_destroys */ dirty_destroys, + /* dirty_unprotects */ dirty_unprotects); - pass = FALSE; - failure_mssg = "Unexpected insert results 6."; - } - } + if ( show_progress ) /* 8 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); - if ( pass ) { + if ( pass ) { - /* Verify that pinned entries are in the pinned entry list */ - if ( (entry_ptr->header).is_pinned ) { + result = H5C_set_evictions_enabled(cache_ptr, FALSE); - search_ptr = cache_ptr->pel_head_ptr; + if ( result < 0 ) { - while ( ( search_ptr != NULL ) && - ( search_ptr != - (struct H5C_cache_entry_t *)entry_ptr ) ) - { - search_ptr = search_ptr->next; - } + pass = FALSE; + failure_mssg = "can't disable evictions 2.\n"; + } + } - if ( search_ptr == NULL ) { + if ( show_progress ) /* 9 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions disabled\n", + fcn_name, mile_stone++, (int)pass); - pass = FALSE; - failure_mssg = "Unexpected insert results 7."; - } - } - } + /* flush and destroy all entries in the cache: */ - if ( pass ) { + flush_cache(/* cache_ptr */ cache_ptr, + /* destroy_entries */ TRUE, + /* dump_stats */ FALSE, + /* dump_detailed_stats */ FALSE); - /* Verify that unpinned entries are in the LRU list */ - if ( ! ((entry_ptr->header).is_pinned) ) { + if ( show_progress ) /* 10 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); - search_ptr = cache_ptr->LRU_head_ptr; + if ( pass ) { - while ( ( search_ptr != NULL ) && - ( search_ptr != - (struct H5C_cache_entry_t *)entry_ptr ) ) - { - search_ptr = search_ptr->next; - } + result = H5C_set_evictions_enabled(cache_ptr, TRUE); - if ( search_ptr == NULL ) { + if ( result < 0 ) { - pass = FALSE; - failure_mssg = "Unexpected insert results 8."; - } - } + pass = FALSE; + failure_mssg = "can't enable evictions 2.\n"; } + } -#if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS - if ( pass ) { + if ( show_progress ) /* 11 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions enabled\n", + fcn_name, mile_stone++, (int)pass); - /* Verify that unpinned entries are in the dirty LRU list */ - if ( ! ((entry_ptr->header).is_pinned) ) { + col_major_scan_forward(/* cache_ptr */ cache_ptr, + /* lag */ lag, + /* verbose */ FALSE, + /* reset_stats */ TRUE, + /* display_stats */ display_stats, + /* display_detailed_stats */ display_detailed_stats, + /* do_inserts */ TRUE, + /* dirty_inserts */ dirty_inserts, + /* dirty_unprotects */ dirty_unprotects); - search_ptr = cache_ptr->dLRU_head_ptr; + if ( show_progress ) /* 12 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); - while ( ( search_ptr != NULL ) && - ( search_ptr != - (struct H5C_cache_entry_t *)entry_ptr ) ) - { - search_ptr = search_ptr->aux_next; - } + if ( pass ) { - if ( search_ptr == NULL ) { + result = H5C_set_evictions_enabled(cache_ptr, FALSE); - pass = FALSE; - failure_mssg = "Unexpected insert results 9."; - } - } + if ( result < 0 ) { + + pass = FALSE; + failure_mssg = "can't disable evictions 3.\n"; } -#endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ + } - i++; + if ( show_progress ) /* 13 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions disabled\n", + fcn_name, mile_stone++, (int)pass); - } /* while */ + /* flush all entries in the cache: */ + flush_cache(/* cache_ptr */ cache_ptr, + /* destroy_entries */ FALSE, + /* dump_stats */ FALSE, + /* dump_detailed_stats */ FALSE); - /* So much for looking at the individual entries. Now verify - * that the various counts and sized in the cache header are - * as expected. - */ + if ( show_progress ) /* 14 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); if ( pass ) { - if ( ( cache_ptr->index_len != 4 ) || - ( cache_ptr->index_size != 4 * entry_sizes[entry_type] ) || - ( cache_ptr->slist_len != 4 ) || - ( cache_ptr->slist_size != 4 * entry_sizes[entry_type] ) || - ( cache_ptr->pl_len != 0 ) || - ( cache_ptr->pl_size != (size_t)0 ) || - ( cache_ptr->pel_len != 2 ) || - ( cache_ptr->pel_size != 2 * entry_sizes[entry_type] ) || - ( cache_ptr->LRU_list_len != 2 ) || - ( cache_ptr->LRU_list_size != 2 * entry_sizes[entry_type] ) || -#if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS - ( cache_ptr->dLRU_list_len != 2 ) || - ( cache_ptr->dLRU_list_size != 2 * entry_sizes[entry_type] ) || -#endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ - ( cache_ptr->cLRU_list_len != 0 ) || - ( cache_ptr->cLRU_list_size != (size_t)0 ) ) { + result = H5C_set_evictions_enabled(cache_ptr, TRUE); - pass = FALSE; - failure_mssg = "Unexpected insert results 10."; + if ( result < 0 ) { + + pass = FALSE; + failure_mssg = "can't enable evictions 3.\n"; } } + if ( show_progress ) /* 15 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions enabled\n", + fcn_name, mile_stone++, (int)pass); + + col_major_scan_backward(/* cache_ptr */ cache_ptr, + /* lag */ lag, + /* verbose */ FALSE, + /* reset_stats */ TRUE, + /* display_stats */ display_stats, + /* display_detailed_stats */ display_detailed_stats, + /* do_inserts */ TRUE, + /* dirty_inserts */ dirty_inserts, + /* dirty_unprotects */ dirty_unprotects); + + if ( show_progress ) /* 16 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); - /* Finally, if stats collection is enabled, verify that the expected - * stats are collected. - */ -#if H5C_COLLECT_CACHE_STATS if ( pass ) { - if ( ( cache_ptr->insertions[entry_type] != 4 ) || - ( cache_ptr->pinned_insertions[entry_type] != 2 ) || - ( cache_ptr->pins[entry_type] != 2 ) || - ( cache_ptr->unpins[entry_type] != 0 ) || - ( cache_ptr->dirty_pins[entry_type] != 0 ) || - ( cache_ptr->max_index_len != 4 ) || - ( cache_ptr->max_index_size != 4 * entry_sizes[entry_type] ) || - ( cache_ptr->max_slist_len != 4 ) || - ( cache_ptr->max_slist_size != 4 * entry_sizes[entry_type] ) || - ( cache_ptr->max_pl_len != 0 ) || - ( cache_ptr->max_pl_size != (size_t)0 ) || - ( cache_ptr->max_pel_len != 2 ) || - ( cache_ptr->max_pel_size != 2 * entry_sizes[entry_type] ) ) { + result = H5C_set_evictions_enabled(cache_ptr, FALSE); - pass = FALSE; - failure_mssg = "Unexpected insert results 11."; + if ( result < 0 ) { + + pass = FALSE; + failure_mssg = "can't disable evictions 4.\n"; } } -#endif /* H5C_COLLECT_CACHE_STATS */ + if ( show_progress ) /* 17 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d -- evictions disabled\n", + fcn_name, mile_stone++, (int)pass); - /* Unpin the pinned entries so we can take down the cache cleanly. */ - - if ( pass ) { - - unpin_entry(cache_ptr, entry_type, 2); - unpin_entry(cache_ptr, entry_type, 3); - } + takedown_cache(cache_ptr, display_stats, TRUE); - if ( pass ) { + if ( show_progress ) /* 18 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); - takedown_cache(cache_ptr, FALSE, FALSE); - } + verify_clean(); + verify_unprotected(); if ( pass ) { PASSED(); } else { H5_FAILED(); } @@ -2331,19 +2451,22 @@ check_insert_entry(void) return; -} /* check_insert_entry() */ +} /* smoke_check_10() */ /*------------------------------------------------------------------------- - * Function: check_flush_cache() + * Function: write_permitted_check() * - * Purpose: Verify that flush_cache behaves as expected. In particular, - * test the behaviour with different flags. + * Purpose: A basic test of the write permitted function. In essence, + * we load the cache up with dirty entryies, set + * write_permitted to FALSE, and then protect a bunch of + * entries. If there are any writes while write_permitted is + * FALSE, the test will fail. * * Return: void * * Programmer: John Mainzer - * 1/10/05 + * 6/24/04 * * Modifications: * @@ -2351,60 +2474,155 @@ check_insert_entry(void) */ static void -check_flush_cache(void) +write_permitted_check(void) { - const char * fcn_name = "check_flush_cache"; - H5C_t * cache_ptr = NULL; - TESTING("H5C_flush_cache() functionality"); +#if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS + + const char * fcn_name = "write_permitted_check"; + hbool_t show_progress = FALSE; + hbool_t display_stats = FALSE; + int32_t lag = 10; + int mile_stone = 1; + H5C_t * cache_ptr = NULL; + +#endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ + + TESTING("write permitted check -- 1/0 MB cache"); + +#if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS pass = TRUE; - /* allocate a cache, and flush it under various circumstances. - * To the extent possible, verify that the desired actions took - * place. - */ + if ( show_progress ) /* 1 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); - if ( pass ) { + reset_entries(); - reset_entries(); + if ( show_progress ) /* 2 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); - cache_ptr = setup_cache((size_t)(2 * 1024 * 1024), - (size_t)(1 * 1024 * 1024)); - } + cache_ptr = setup_cache((size_t)(1 * 1024 * 1024), + (size_t)(0)); - /* first test behaviour on an empty cache. Can't do much sanity - * checking in this case, so simply check the return values. - */ + if ( show_progress ) /* 3 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); - if ( pass ) { + row_major_scan_forward(/* cache_ptr */ cache_ptr, + /* lag */ lag, + /* verbose */ FALSE, + /* reset_stats */ TRUE, + /* display_stats */ display_stats, + /* display_detailed_stats */ TRUE, + /* do_inserts */ TRUE, + /* dirty_inserts */ TRUE, + /* do_renames */ TRUE, + /* rename_to_main_addr */ FALSE, + /* do_destroys */ TRUE, + /* do_mult_ro_protects */ TRUE, + /* dirty_destroys */ TRUE, + /* dirty_unprotects */ TRUE); - check_flush_cache__empty_cache(cache_ptr); - } + if ( show_progress ) /* 4 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); - /* now do a series of similar tests with a cache with a single entry. - * Start with a clean entry, with no flags set. - */ + write_permitted = FALSE; - if ( pass ) { + row_major_scan_backward(/* cache_ptr */ cache_ptr, + /* lag */ lag, + /* verbose */ FALSE, + /* reset_stats */ TRUE, + /* display_stats */ display_stats, + /* display_detailed_stats */ TRUE, + /* do_inserts */ FALSE, + /* dirty_inserts */ FALSE, + /* do_renames */ TRUE, + /* rename_to_main_addr */ TRUE, + /* do_destroys */ FALSE, + /* do_mult_ro_protects */ TRUE, + /* dirty_destroys */ FALSE, + /* dirty_unprotects */ NO_CHANGE); - check_flush_cache__single_entry(cache_ptr); - } + if ( show_progress ) /* 5 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); - if ( pass ) { + write_permitted = TRUE; - check_flush_cache__multi_entry(cache_ptr); - } + row_major_scan_forward(/* cache_ptr */ cache_ptr, + /* lag */ lag, + /* verbose */ FALSE, + /* reset_stats */ TRUE, + /* display_stats */ display_stats, + /* display_detailed_stats */ TRUE, + /* do_inserts */ TRUE, + /* dirty_inserts */ TRUE, + /* do_renames */ TRUE, + /* rename_to_main_addr */ FALSE, + /* do_destroys */ FALSE, + /* do_mult_ro_protects */ TRUE, + /* dirty_destroys */ TRUE, + /* dirty_unprotects */ TRUE); - if ( pass ) { + if ( show_progress ) /* 6 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); - check_flush_cache__flush_ops(cache_ptr); - } + /* flush and destroy all entries in the cache: */ - if ( pass ) { + flush_cache(/* cache_ptr */ cache_ptr, + /* destroy_entries */ TRUE, + /* dump_stats */ FALSE, + /* dump_detailed_stats */ FALSE); - takedown_cache(cache_ptr, FALSE, FALSE); - } + if ( show_progress ) /* 7 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); + + col_major_scan_forward(/* cache_ptr */ cache_ptr, + /* lag */ lag, + /* verbose */ FALSE, + /* reset_stats */ TRUE, + /* display_stats */ display_stats, + /* display_detailed_stats */ TRUE, + /* do_inserts */ TRUE, + /* dirty_inserts */ TRUE, + /* dirty_unprotects */ TRUE); + + if ( show_progress ) /* 8 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); + + write_permitted = FALSE; + + col_major_scan_backward(/* cache_ptr */ cache_ptr, + /* lag */ lag, + /* verbose */ FALSE, + /* reset_stats */ TRUE, + /* display_stats */ display_stats, + /* display_detailed_stats */ TRUE, + /* do_inserts */ FALSE, + /* dirty_inserts */ FALSE, + /* dirty_unprotects */ NO_CHANGE); + + write_permitted = TRUE; + + if ( show_progress ) /* 9 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); + + takedown_cache(cache_ptr, display_stats, TRUE); + + if ( show_progress ) /* 10 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); + + verify_clean(); + verify_unprotected(); if ( pass ) { PASSED(); } else { H5_FAILED(); } @@ -2414,21 +2632,34 @@ check_flush_cache(void) fcn_name, failure_mssg); } +#else /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ + + SKIPPED(); + + HDfprintf(stdout, " Clean and dirty LRU lists disabled.\n"); + +#endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ + return; -} /* check_flush_cache() */ +} /* write_permitted_check() */ /*------------------------------------------------------------------------- - * Function: check_flush_cache__empty_cache() + * Function: check_insert_entry() * - * Purpose: Verify that flush_cache behaves as expected with an empty - * cache. + * Purpose: Verify that H5C_insert_entry behaves as expected. + * Test the behaviour with different flags. + * + * This test was added primarily to test basic insert + * pinned entry functionallity, but I through in explicit + * tests for other functionallity that is tested implicitly + * elsewhere. * * Return: void * * Programmer: John Mainzer - * 1/12/05 + * 8/10/06 * * Modifications: * @@ -2436,35 +2667,417 @@ check_flush_cache(void) */ static void -check_flush_cache__empty_cache(H5C_t * cache_ptr) +check_insert_entry(void) { - /* const char * fcn_name = "check_flush_cache__empty_cache"; */ - herr_t result; - - if ( cache_ptr == NULL ) { + const char * fcn_name = "check_insert_entry"; + int entry_type = PICO_ENTRY_TYPE; + int i; + herr_t result; + hbool_t in_cache; + hbool_t is_dirty; + hbool_t is_protected; + hbool_t is_pinned; + size_t entry_size; + H5C_t * cache_ptr = NULL; + test_entry_t * base_addr; + test_entry_t * entry_ptr; + struct H5C_cache_entry_t * search_ptr; - pass = FALSE; - failure_mssg = "cache_ptr NULL on entry to empty cache case."; - } - else if ( ( cache_ptr->index_len != 0 ) || - ( cache_ptr->index_size != 0 ) ) { - pass = FALSE; - failure_mssg = "cache not empty at beginning of empty cache case."; - } + TESTING("H5C_insert_entry() functionality"); + pass = TRUE; - /* Test behaviour on an empty cache. Can't do much sanity - * checking in this case, so simply check the return values. + /* Allocate a cache, and insert entries into it using all + * combinations of flags. Verify that the entries are inserted, + * and that the flags have the desired effects. + * + * Note that the dirty parameter in insert_entry is no longer + * used, as we have decided that all inserted entries are + * dirty by definition. (Which sounds very reasonable, but didn't + * used to be the case.) */ if ( pass ) { - result = H5C_flush_cache(NULL, -1, -1, cache_ptr, H5C__NO_FLAGS_SET); - - if ( result < 0 ) { + reset_entries(); - pass = FALSE; + cache_ptr = setup_cache((size_t)(2 * 1024 * 1024), + (size_t)(1 * 1024 * 1024)); + } + + if ( pass ) { + + insert_entry(cache_ptr, entry_type, 0, TRUE, H5C__NO_FLAGS_SET); + insert_entry(cache_ptr, entry_type, 1, TRUE, + H5C__SET_FLUSH_MARKER_FLAG); + insert_entry(cache_ptr, entry_type, 2, TRUE, H5C__PIN_ENTRY_FLAG); + insert_entry(cache_ptr, entry_type, 3, TRUE, + (H5C__SET_FLUSH_MARKER_FLAG | H5C__PIN_ENTRY_FLAG)); + } + + + /* Verify that the entries are inserted as desired. */ + + i = 0; + base_addr = entries[0]; + while ( ( pass ) && ( i < 4 ) ) + { + entry_ptr = &(base_addr[i]); + + /* Start by checking everything we can via H5C_get_entry_status() */ + + result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size, + &in_cache, &is_dirty, &is_protected, + &is_pinned); + + if ( result < 0 ) { + + pass = FALSE; + failure_mssg = "H5AC_get_entry_status() reports failure."; + } + + if ( pass ) { + + /* check the universals */ + if ( ( ! in_cache ) || ( ! is_dirty ) || ( is_protected ) || + ( entry_size != entry_sizes[entry_type] ) ) { + + pass = FALSE; + failure_mssg = "Unexpected insert results 1."; + } + } + + if ( pass ) { + + /* verify that the pinned flag got set correctly */ + if ( ( i == 2 ) || ( i == 3 ) ) { + + if ( ! is_pinned ) { + + pass = FALSE; + failure_mssg = "Unexpected insert results 2."; + } + } else if ( is_pinned ) { + + pass = FALSE; + failure_mssg = "Unexpected insert results 3."; + + } else if ( is_pinned != ((entry_ptr->header).is_pinned) ) { + + pass = FALSE; + failure_mssg = "Unexpected insert results 4."; + } + } + + /* Thats all we can get from H5AC_get_entry_status(). + * Now start looking at the cache data structures directly. + */ + + if ( pass ) { + + /* Verify that the flush marker got set correctly */ + if ( ( i == 1 ) || ( i == 3 ) ) { + + if ( ! ((entry_ptr->header).flush_marker) ) { + + pass = FALSE; + failure_mssg = "Unexpected insert results 5."; + } + } else if ( (entry_ptr->header).flush_marker ) { + + pass = FALSE; + failure_mssg = "Unexpected insert results 6."; + } + } + + if ( pass ) { + + /* Verify that pinned entries are in the pinned entry list */ + if ( (entry_ptr->header).is_pinned ) { + + search_ptr = cache_ptr->pel_head_ptr; + + while ( ( search_ptr != NULL ) && + ( search_ptr != + (struct H5C_cache_entry_t *)entry_ptr ) ) + { + search_ptr = search_ptr->next; + } + + if ( search_ptr == NULL ) { + + pass = FALSE; + failure_mssg = "Unexpected insert results 7."; + } + } + } + + if ( pass ) { + + /* Verify that unpinned entries are in the LRU list */ + if ( ! ((entry_ptr->header).is_pinned) ) { + + search_ptr = cache_ptr->LRU_head_ptr; + + while ( ( search_ptr != NULL ) && + ( search_ptr != + (struct H5C_cache_entry_t *)entry_ptr ) ) + { + search_ptr = search_ptr->next; + } + + if ( search_ptr == NULL ) { + + pass = FALSE; + failure_mssg = "Unexpected insert results 8."; + } + } + } + +#if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS + if ( pass ) { + + /* Verify that unpinned entries are in the dirty LRU list */ + if ( ! ((entry_ptr->header).is_pinned) ) { + + search_ptr = cache_ptr->dLRU_head_ptr; + + while ( ( search_ptr != NULL ) && + ( search_ptr != + (struct H5C_cache_entry_t *)entry_ptr ) ) + { + search_ptr = search_ptr->aux_next; + } + + if ( search_ptr == NULL ) { + + pass = FALSE; + failure_mssg = "Unexpected insert results 9."; + } + } + } +#endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ + + i++; + + } /* while */ + + + /* So much for looking at the individual entries. Now verify + * that the various counts and sized in the cache header are + * as expected. + */ + + if ( pass ) { + + if ( ( cache_ptr->index_len != 4 ) || + ( cache_ptr->index_size != 4 * entry_sizes[entry_type] ) || + ( cache_ptr->slist_len != 4 ) || + ( cache_ptr->slist_size != 4 * entry_sizes[entry_type] ) || + ( cache_ptr->pl_len != 0 ) || + ( cache_ptr->pl_size != (size_t)0 ) || + ( cache_ptr->pel_len != 2 ) || + ( cache_ptr->pel_size != 2 * entry_sizes[entry_type] ) || + ( cache_ptr->LRU_list_len != 2 ) || + ( cache_ptr->LRU_list_size != 2 * entry_sizes[entry_type] ) || +#if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS + ( cache_ptr->dLRU_list_len != 2 ) || + ( cache_ptr->dLRU_list_size != 2 * entry_sizes[entry_type] ) || +#endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ + ( cache_ptr->cLRU_list_len != 0 ) || + ( cache_ptr->cLRU_list_size != (size_t)0 ) ) { + + pass = FALSE; + failure_mssg = "Unexpected insert results 10."; + } + } + + + /* Finally, if stats collection is enabled, verify that the expected + * stats are collected. + */ +#if H5C_COLLECT_CACHE_STATS + if ( pass ) { + + if ( ( cache_ptr->insertions[entry_type] != 4 ) || + ( cache_ptr->pinned_insertions[entry_type] != 2 ) || + ( cache_ptr->pins[entry_type] != 2 ) || + ( cache_ptr->unpins[entry_type] != 0 ) || + ( cache_ptr->dirty_pins[entry_type] != 0 ) || + ( cache_ptr->max_index_len != 4 ) || + ( cache_ptr->max_index_size != 4 * entry_sizes[entry_type] ) || + ( cache_ptr->max_slist_len != 4 ) || + ( cache_ptr->max_slist_size != 4 * entry_sizes[entry_type] ) || + ( cache_ptr->max_pl_len != 0 ) || + ( cache_ptr->max_pl_size != (size_t)0 ) || + ( cache_ptr->max_pel_len != 2 ) || + ( cache_ptr->max_pel_size != 2 * entry_sizes[entry_type] ) ) { + + pass = FALSE; + failure_mssg = "Unexpected insert results 11."; + } + } +#endif /* H5C_COLLECT_CACHE_STATS */ + + + /* Unpin the pinned entries so we can take down the cache cleanly. */ + + if ( pass ) { + + unpin_entry(cache_ptr, entry_type, 2); + unpin_entry(cache_ptr, entry_type, 3); + } + + if ( pass ) { + + takedown_cache(cache_ptr, FALSE, FALSE); + } + + if ( pass ) { PASSED(); } else { H5_FAILED(); } + + if ( ! pass ) { + + HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", + fcn_name, failure_mssg); + } + + return; + +} /* check_insert_entry() */ + + +/*------------------------------------------------------------------------- + * Function: check_flush_cache() + * + * Purpose: Verify that flush_cache behaves as expected. In particular, + * test the behaviour with different flags. + * + * Return: void + * + * Programmer: John Mainzer + * 1/10/05 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +static void +check_flush_cache(void) +{ + const char * fcn_name = "check_flush_cache"; + H5C_t * cache_ptr = NULL; + + TESTING("H5C_flush_cache() functionality"); + + pass = TRUE; + + /* allocate a cache, and flush it under various circumstances. + * To the extent possible, verify that the desired actions took + * place. + */ + + if ( pass ) { + + reset_entries(); + + cache_ptr = setup_cache((size_t)(2 * 1024 * 1024), + (size_t)(1 * 1024 * 1024)); + } + + /* first test behaviour on an empty cache. Can't do much sanity + * checking in this case, so simply check the return values. + */ + + if ( pass ) { + + check_flush_cache__empty_cache(cache_ptr); + } + + /* now do a series of similar tests with a cache with a single entry. + * Start with a clean entry, with no flags set. + */ + + if ( pass ) { + + check_flush_cache__single_entry(cache_ptr); + } + + if ( pass ) { + + check_flush_cache__multi_entry(cache_ptr); + } + + if ( pass ) { + + check_flush_cache__flush_ops(cache_ptr); + } + + if ( pass ) { + + takedown_cache(cache_ptr, FALSE, FALSE); + } + + if ( pass ) { PASSED(); } else { H5_FAILED(); } + + if ( ! pass ) { + + HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", + fcn_name, failure_mssg); + } + + return; + +} /* check_flush_cache() */ + + +/*------------------------------------------------------------------------- + * Function: check_flush_cache__empty_cache() + * + * Purpose: Verify that flush_cache behaves as expected with an empty + * cache. + * + * Return: void + * + * Programmer: John Mainzer + * 1/12/05 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +static void +check_flush_cache__empty_cache(H5C_t * cache_ptr) +{ + /* const char * fcn_name = "check_flush_cache__empty_cache"; */ + herr_t result; + + if ( cache_ptr == NULL ) { + + pass = FALSE; + failure_mssg = "cache_ptr NULL on entry to empty cache case."; + } + else if ( ( cache_ptr->index_len != 0 ) || + ( cache_ptr->index_size != 0 ) ) { + + pass = FALSE; + failure_mssg = "cache not empty at beginning of empty cache case."; + } + + + /* Test behaviour on an empty cache. Can't do much sanity + * checking in this case, so simply check the return values. + */ + + if ( pass ) { + + result = H5C_flush_cache(NULL, -1, -1, cache_ptr, H5C__NO_FLAGS_SET); + + if ( result < 0 ) { + + pass = FALSE; failure_mssg = "flush with flags = 0x00 failed on empty cache.\n"; } } @@ -12262,11 +12875,227 @@ check_get_entry_status(void) } else if ( in_cache ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected status 1."); + HDsnprintf(msg, (size_t)128, "Unexpected status 1."); + failure_mssg = msg; + } + } + + protect_entry(cache_ptr, 0, 0); + + unprotect_entry(cache_ptr, 0, 0, FALSE, H5C__NO_FLAGS_SET); + + if ( pass ) { + + result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size, + &in_cache, &is_dirty, &is_protected, &is_pinned); + + if ( result < 0 ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, + "H5AC_get_entry_status() reports failure 2."); + failure_mssg = msg; + + } else if ( !in_cache || is_dirty || is_protected || is_pinned ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected status 2."); + failure_mssg = msg; + } + } + + protect_entry(cache_ptr, 0, 0); + + if ( pass ) { + + result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size, + &in_cache, &is_dirty, &is_protected, &is_pinned); + + if ( result < 0 ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, + "H5AC_get_entry_status() reports failure 3."); + failure_mssg = msg; + + } else if ( !in_cache || is_dirty || !is_protected || is_pinned ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected status 3."); + failure_mssg = msg; + } + } + + unprotect_entry(cache_ptr, 0, 0, FALSE, H5C__PIN_ENTRY_FLAG); + + if ( pass ) { + + result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size, + &in_cache, &is_dirty, &is_protected, &is_pinned); + + if ( result < 0 ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, + "H5AC_get_entry_status() reports failure 4."); + failure_mssg = msg; + + } else if ( !in_cache || is_dirty || is_protected || !is_pinned ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected status 4."); + failure_mssg = msg; + } + } + + mark_pinned_entry_dirty(cache_ptr, 0, 0, FALSE, (size_t)0); + + if ( pass ) { + + result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size, + &in_cache, &is_dirty, &is_protected, &is_pinned); + + if ( result < 0 ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, + "H5AC_get_entry_status() reports failure 5."); + failure_mssg = msg; + + } else if ( !in_cache || !is_dirty || is_protected || !is_pinned ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected status 5."); + failure_mssg = msg; + } + } + + unpin_entry(cache_ptr, 0, 0); + + if ( pass ) { + + result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size, + &in_cache, &is_dirty, &is_protected, &is_pinned); + + if ( result < 0 ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, + "H5AC_get_entry_status() reports failure 6."); + failure_mssg = msg; + + } else if ( !in_cache || !is_dirty || is_protected || is_pinned ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected status 6."); + failure_mssg = msg; + } + } + + if ( pass ) { + + takedown_cache(cache_ptr, FALSE, FALSE); + } + + if ( pass ) { PASSED(); } else { H5_FAILED(); } + + if ( ! pass ) { + + HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", + fcn_name, failure_mssg); + } + + return; + +} /* check_get_entry_status() */ + + +/*------------------------------------------------------------------------- + * Function: check_expunge_entry() + * + * Purpose: Verify that H5C_expunge_entry() behaves as expected. + * + * Return: void + * + * Programmer: John Mainzer + * 7/5/06 + * + * Modifications: + * + * None. + * + *------------------------------------------------------------------------- + */ + +static void +check_expunge_entry(void) +{ + const char * fcn_name = "check_expunge_entry"; + static char msg[128]; + herr_t result; + hbool_t in_cache; + hbool_t is_dirty; + hbool_t is_protected; + hbool_t is_pinned; + size_t entry_size; + H5C_t * cache_ptr = NULL; + test_entry_t * base_addr; + test_entry_t * entry_ptr; + + TESTING("H5C_expunge_entry() functionality"); + + pass = TRUE; + + if ( pass ) { + + reset_entries(); + + cache_ptr = setup_cache((size_t)(2 * 1024 * 1024), + (size_t)(1 * 1024 * 1024)); + + base_addr = entries[0]; + entry_ptr = &(base_addr[0]); + } + + if ( pass ) { + + /* entry not in cache -- only in_cache should be touched by + * the status call. Thus, only check that boolean. + */ + + result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size, + &in_cache, &is_dirty, &is_protected, + &is_pinned); + + if ( result < 0 ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, + "H5AC_get_entry_status() reports failure 1."); + failure_mssg = msg; + + } else if ( in_cache ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected status 1."); + failure_mssg = msg; + + } else if ( ( entry_ptr->loaded ) || + ( entry_ptr->cleared ) || + ( entry_ptr->flushed ) || + ( entry_ptr->destroyed ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected entry history 1."); failure_mssg = msg; - } + + } } + /* protect an entry to force the cache to load it, and then unprotect + * it without marking it dirty. + */ + protect_entry(cache_ptr, 0, 0); unprotect_entry(cache_ptr, 0, 0, FALSE, H5C__NO_FLAGS_SET); @@ -12288,13 +13117,31 @@ check_get_entry_status(void) pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected status 2."); failure_mssg = msg; - } + + } else if ( ( ! entry_ptr->loaded ) || + ( entry_ptr->cleared ) || + ( entry_ptr->flushed ) || + ( entry_ptr->destroyed ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected entry history 2."); + failure_mssg = msg; + + } } - protect_entry(cache_ptr, 0, 0); + /* Expunge the entry and then verify that it is no longer in the cache. + * Also verify that the entry was loaded, cleared, and destroyed, but + * not flushed. + */ + expunge_entry(cache_ptr, 0, 0); if ( pass ) { + /* entry shouldn't be in cache -- only in_cache should be touched + * by the status call. Thus, only check that boolean. + */ + result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size, &in_cache, &is_dirty, &is_protected, &is_pinned); @@ -12305,20 +13152,40 @@ check_get_entry_status(void) "H5AC_get_entry_status() reports failure 3."); failure_mssg = msg; - } else if ( !in_cache || is_dirty || !is_protected || is_pinned ) { + } else if ( in_cache ) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected status 3."); failure_mssg = msg; - } + + } else if ( ( ! entry_ptr->loaded ) || + ( ! entry_ptr->cleared ) || + ( entry_ptr->flushed ) || + ( ! entry_ptr->destroyed ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected entry history 3."); + failure_mssg = msg; + + } } - unprotect_entry(cache_ptr, 0, 0, FALSE, H5C__PIN_ENTRY_FLAG); + /* now repeat the process with a different entry. On unprotect + * mark the entry as dirty. Verify that it is not flushed. + */ + + base_addr = entries[0]; + entry_ptr = &(base_addr[1]); if ( pass ) { + /* entry not in cache -- only in_cache should be touched by + * the status call. Thus, only check that boolean. + */ + result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size, - &in_cache, &is_dirty, &is_protected, &is_pinned); + &in_cache, &is_dirty, &is_protected, + &is_pinned); if ( result < 0 ) { @@ -12327,20 +13194,37 @@ check_get_entry_status(void) "H5AC_get_entry_status() reports failure 4."); failure_mssg = msg; - } else if ( !in_cache || is_dirty || is_protected || !is_pinned ) { + } else if ( in_cache ) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected status 4."); failure_mssg = msg; - } + + } else if ( ( entry_ptr->loaded ) || + ( entry_ptr->cleared ) || + ( entry_ptr->flushed ) || + ( entry_ptr->destroyed ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected entry history 4."); + failure_mssg = msg; + + } } - mark_pinned_entry_dirty(cache_ptr, 0, 0, FALSE, (size_t)0); + /* protect the entry to force the cache to load it, and then unprotect + * it with the dirty flag set. + */ + + protect_entry(cache_ptr, 0, 1); + + unprotect_entry(cache_ptr, 0, 1, TRUE, H5C__NO_FLAGS_SET); if ( pass ) { result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size, - &in_cache, &is_dirty, &is_protected, &is_pinned); + &in_cache, &is_dirty, &is_protected, + &is_pinned); if ( result < 0 ) { @@ -12349,20 +13233,39 @@ check_get_entry_status(void) "H5AC_get_entry_status() reports failure 5."); failure_mssg = msg; - } else if ( !in_cache || !is_dirty || is_protected || !is_pinned ) { + } else if ( !in_cache || !is_dirty || is_protected || is_pinned ) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected status 5."); failure_mssg = msg; - } + + } else if ( ( ! entry_ptr->loaded ) || + ( entry_ptr->cleared ) || + ( entry_ptr->flushed ) || + ( entry_ptr->destroyed ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected entry history 5."); + failure_mssg = msg; + + } } - unpin_entry(cache_ptr, 0, 0); + /* Expunge the entry and then verify that it is no longer in the cache. + * Also verify that the entry was loaded, cleared and destroyed, but not + * flushed. + */ + expunge_entry(cache_ptr, 0, 1); if ( pass ) { + /* entry shouldn't be in cache -- only in_cache should be touched + * by the status call. Thus, only check that boolean. + */ + result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size, - &in_cache, &is_dirty, &is_protected, &is_pinned); + &in_cache, &is_dirty, &is_protected, + &is_pinned); if ( result < 0 ) { @@ -12371,12 +13274,22 @@ check_get_entry_status(void) "H5AC_get_entry_status() reports failure 6."); failure_mssg = msg; - } else if ( !in_cache || !is_dirty || is_protected || is_pinned ) { + } else if ( in_cache ) { pass = FALSE; HDsnprintf(msg, (size_t)128, "Unexpected status 6."); failure_mssg = msg; - } + + } else if ( ( ! entry_ptr->loaded ) || + ( ! entry_ptr->cleared ) || + ( entry_ptr->flushed ) || + ( ! entry_ptr->destroyed ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected entry history 6."); + failure_mssg = msg; + + } } if ( pass ) { @@ -12394,18 +13307,19 @@ check_get_entry_status(void) return; -} /* check_get_entry_status() */ +} /* check_expunge_entry() */ /*------------------------------------------------------------------------- - * Function: check_expunge_entry() + * Function: check_multiple_read_protect() * - * Purpose: Verify that H5C_expunge_entry() behaves as expected. + * Purpose: Verify that multiple, simultaneous read protects of a + * single entry perform as expectd. * * Return: void * * Programmer: John Mainzer - * 7/5/06 + * 4/1/07 * * Modifications: * @@ -12414,270 +13328,390 @@ check_get_entry_status(void) *------------------------------------------------------------------------- */ + static void -check_expunge_entry(void) +check_multiple_read_protect(void) { - const char * fcn_name = "check_expunge_entry"; - static char msg[128]; - herr_t result; - hbool_t in_cache; - hbool_t is_dirty; - hbool_t is_protected; - hbool_t is_pinned; - size_t entry_size; - H5C_t * cache_ptr = NULL; - test_entry_t * base_addr; + const char * fcn_name = "check_multiple_read_protect()"; + H5C_t * cache_ptr = NULL; test_entry_t * entry_ptr; - TESTING("H5C_expunge_entry() functionality"); + TESTING("multiple read only protects on a single entry"); pass = TRUE; + /* allocate a cache. Should succeed. + * + * Then to start with, proceed as follows: + * + * Read protect an entry. + * + * Then read protect the entry again. Should succeed. + * + * Read protect yet again. Should succeed. + * + * Unprotect with no changes, and then read protect twice again. + * Should succeed. + * + * Now unprotect three times. Should succeed. + * + * If stats are enabled, verify that correct stats are collected at + * every step. + * + * Also, verify internal state of read protects at every step. + */ + if ( pass ) { reset_entries(); - cache_ptr = setup_cache((size_t)(2 * 1024 * 1024), - (size_t)(1 * 1024 * 1024)); + cache_ptr = setup_cache((size_t)(2 * 1024), + (size_t)(1 * 1024)); - base_addr = entries[0]; - entry_ptr = &(base_addr[0]); + entry_ptr = &((entries[0])[0]); + + if ( ( entry_ptr->header.is_protected ) || + ( entry_ptr->header.is_read_only ) || + ( entry_ptr->header.ro_ref_count != 0 ) ) { + + pass = FALSE; + failure_mssg = "Unexpected ro protected status 1.\n"; + } } - if ( pass ) { +#if H5C_COLLECT_CACHE_STATS + if ( ( cache_ptr->write_protects[0] != 0 ) || + ( cache_ptr->read_protects[0] != 0 ) || + ( cache_ptr->max_read_protects[0] != 0 ) ) { - /* entry not in cache -- only in_cache should be touched by - * the status call. Thus, only check that boolean. - */ + pass = FALSE; + failure_mssg = "Unexpected protect stats 1.\n"; + } +#endif /* H5C_COLLECT_CACHE_STATS */ - result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size, - &in_cache, &is_dirty, &is_protected, - &is_pinned); + if ( pass ) + { + protect_entry_ro(cache_ptr, 0, 0); - if ( result < 0 ) { + if ( ( ! ( entry_ptr->header.is_protected ) ) || + ( ! ( entry_ptr->header.is_read_only ) ) || + ( entry_ptr->header.ro_ref_count != 1 ) ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5AC_get_entry_status() reports failure 1."); - failure_mssg = msg; + failure_mssg = "Unexpected ro protected status 2.\n"; + } + } - } else if ( in_cache ) { +#if H5C_COLLECT_CACHE_STATS + if ( ( cache_ptr->write_protects[0] != 0 ) || + ( cache_ptr->read_protects[0] != 1 ) || + ( cache_ptr->max_read_protects[0] != 1 ) ) { + + pass = FALSE; + failure_mssg = "Unexpected protect stats 2.\n"; + } +#endif /* H5C_COLLECT_CACHE_STATS */ + + if ( pass ) + { + protect_entry_ro(cache_ptr, 0, 0); + + if ( ( ! ( entry_ptr->header.is_protected ) ) || + ( ! ( entry_ptr->header.is_read_only ) ) || + ( entry_ptr->header.ro_ref_count != 2 ) ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected status 1."); - failure_mssg = msg; + failure_mssg = "Unexpected ro protected status 3.\n"; + } + } + +#if H5C_COLLECT_CACHE_STATS + if ( ( cache_ptr->write_protects[0] != 0 ) || + ( cache_ptr->read_protects[0] != 2 ) || + ( cache_ptr->max_read_protects[0] != 2 ) ) { + + pass = FALSE; + failure_mssg = "Unexpected protect stats 3.\n"; + } +#endif /* H5C_COLLECT_CACHE_STATS */ + + if ( pass ) + { + unprotect_entry(cache_ptr, 0, 0, FALSE, H5C__NO_FLAGS_SET); - } else if ( ( entry_ptr->loaded ) || - ( entry_ptr->cleared ) || - ( entry_ptr->flushed ) || - ( entry_ptr->destroyed ) ) { + if ( ( ! ( entry_ptr->header.is_protected ) ) || + ( ! ( entry_ptr->header.is_read_only ) ) || + ( entry_ptr->header.ro_ref_count != 1 ) ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected entry history 1."); - failure_mssg = msg; + failure_mssg = "Unexpected ro protected status 4.\n"; + } + } - } +#if H5C_COLLECT_CACHE_STATS + if ( ( cache_ptr->write_protects[0] != 0 ) || + ( cache_ptr->read_protects[0] != 2 ) || + ( cache_ptr->max_read_protects[0] != 2 ) ) { + + pass = FALSE; + failure_mssg = "Unexpected protect stats 4.\n"; } +#endif /* H5C_COLLECT_CACHE_STATS */ - /* protect an entry to force the cache to load it, and then unprotect - * it without marking it dirty. - */ + if ( pass ) + { + protect_entry_ro(cache_ptr, 0, 0); - protect_entry(cache_ptr, 0, 0); + if ( ( ! ( entry_ptr->header.is_protected ) ) || + ( ! ( entry_ptr->header.is_read_only ) ) || + ( entry_ptr->header.ro_ref_count != 2 ) ) { - unprotect_entry(cache_ptr, 0, 0, FALSE, H5C__NO_FLAGS_SET); + pass = FALSE; + failure_mssg = "Unexpected ro protected status 5.\n"; + } + } - if ( pass ) { +#if H5C_COLLECT_CACHE_STATS + if ( ( cache_ptr->write_protects[0] != 0 ) || + ( cache_ptr->read_protects[0] != 3 ) || + ( cache_ptr->max_read_protects[0] != 2 ) ) { - result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size, - &in_cache, &is_dirty, &is_protected, &is_pinned); + pass = FALSE; + failure_mssg = "Unexpected protect stats 5.\n"; + } +#endif /* H5C_COLLECT_CACHE_STATS */ - if ( result < 0 ) { + if ( pass ) + { + protect_entry_ro(cache_ptr, 0, 0); + + if ( ( ! ( entry_ptr->header.is_protected ) ) || + ( ! ( entry_ptr->header.is_read_only ) ) || + ( entry_ptr->header.ro_ref_count != 3 ) ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5AC_get_entry_status() reports failure 2."); - failure_mssg = msg; + failure_mssg = "Unexpected ro protected status 6.\n"; + } + } - } else if ( !in_cache || is_dirty || is_protected || is_pinned ) { +#if H5C_COLLECT_CACHE_STATS + if ( ( cache_ptr->write_protects[0] != 0 ) || + ( cache_ptr->read_protects[0] != 4 ) || + ( cache_ptr->max_read_protects[0] != 3 ) ) { - pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected status 2."); - failure_mssg = msg; + pass = FALSE; + failure_mssg = "Unexpected protect stats 6.\n"; + } +#endif /* H5C_COLLECT_CACHE_STATS */ - } else if ( ( ! entry_ptr->loaded ) || - ( entry_ptr->cleared ) || - ( entry_ptr->flushed ) || - ( entry_ptr->destroyed ) ) { + if ( pass ) + { + unprotect_entry(cache_ptr, 0, 0, FALSE, H5C__NO_FLAGS_SET); - pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected entry history 2."); - failure_mssg = msg; + if ( ( ! ( entry_ptr->header.is_protected ) ) || + ( ! ( entry_ptr->header.is_read_only ) ) || + ( entry_ptr->header.ro_ref_count != 2 ) ) { - } + pass = FALSE; + failure_mssg = "Unexpected ro protected status 7.\n"; + } } - /* Expunge the entry and then verify that it is no longer in the cache. - * Also verify that the entry was loaded, cleared, and destroyed, but - * not flushed. - */ - expunge_entry(cache_ptr, 0, 0); - - if ( pass ) { +#if H5C_COLLECT_CACHE_STATS + if ( ( cache_ptr->write_protects[0] != 0 ) || + ( cache_ptr->read_protects[0] != 4 ) || + ( cache_ptr->max_read_protects[0] != 3 ) ) { - /* entry shouldn't be in cache -- only in_cache should be touched - * by the status call. Thus, only check that boolean. - */ + pass = FALSE; + failure_mssg = "Unexpected protect stats 7.\n"; + } +#endif /* H5C_COLLECT_CACHE_STATS */ - result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size, - &in_cache, &is_dirty, &is_protected, &is_pinned); + if ( pass ) + { + unprotect_entry(cache_ptr, 0, 0, FALSE, H5C__NO_FLAGS_SET); - if ( result < 0 ) { + if ( ( ! ( entry_ptr->header.is_protected ) ) || + ( ! ( entry_ptr->header.is_read_only ) ) || + ( entry_ptr->header.ro_ref_count != 1 ) ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5AC_get_entry_status() reports failure 3."); - failure_mssg = msg; + failure_mssg = "Unexpected ro protected status 8.\n"; + } + } - } else if ( in_cache ) { +#if H5C_COLLECT_CACHE_STATS + if ( ( cache_ptr->write_protects[0] != 0 ) || + ( cache_ptr->read_protects[0] != 4 ) || + ( cache_ptr->max_read_protects[0] != 3 ) ) { - pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected status 3."); - failure_mssg = msg; + pass = FALSE; + failure_mssg = "Unexpected protect stats 8.\n"; + } +#endif /* H5C_COLLECT_CACHE_STATS */ - } else if ( ( ! entry_ptr->loaded ) || - ( ! entry_ptr->cleared ) || - ( entry_ptr->flushed ) || - ( ! entry_ptr->destroyed ) ) { + if ( pass ) + { + unprotect_entry(cache_ptr, 0, 0, FALSE, H5C__NO_FLAGS_SET); - pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected entry history 3."); - failure_mssg = msg; + if ( ( entry_ptr->header.is_protected ) || + ( entry_ptr->header.is_read_only ) || + ( entry_ptr->header.ro_ref_count != 0 ) ) { - } + pass = FALSE; + failure_mssg = "Unexpected ro protected status 9.\n"; + } } - /* now repeat the process with a different entry. On unprotect - * mark the entry as dirty. Verify that it is not flushed. - */ - - base_addr = entries[0]; - entry_ptr = &(base_addr[1]); +#if H5C_COLLECT_CACHE_STATS + if ( ( cache_ptr->write_protects[0] != 0 ) || + ( cache_ptr->read_protects[0] != 4 ) || + ( cache_ptr->max_read_protects[0] != 3 ) ) { - if ( pass ) { + pass = FALSE; + failure_mssg = "Unexpected protect stats 9.\n"; + } +#endif /* H5C_COLLECT_CACHE_STATS */ - /* entry not in cache -- only in_cache should be touched by - * the status call. Thus, only check that boolean. - */ - result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size, - &in_cache, &is_dirty, &is_protected, - &is_pinned); + /* If we get this far, do a write protect and unprotect to verify + * that the stats are getting collected properly here as well. + */ - if ( result < 0 ) { + if ( pass ) + { + protect_entry(cache_ptr, 0, 0); + + if ( ( ! ( entry_ptr->header.is_protected ) ) || + ( entry_ptr->header.is_read_only ) || + ( entry_ptr->header.ro_ref_count != 0 ) ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5AC_get_entry_status() reports failure 4."); - failure_mssg = msg; + failure_mssg = "Unexpected ro protected status 10.\n"; + } + } - } else if ( in_cache ) { +#if H5C_COLLECT_CACHE_STATS + if ( ( cache_ptr->write_protects[0] != 1 ) || + ( cache_ptr->read_protects[0] != 4 ) || + ( cache_ptr->max_read_protects[0] != 3 ) ) { - pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected status 4."); - failure_mssg = msg; + pass = FALSE; + failure_mssg = "Unexpected protect stats 10.\n"; + } +#endif /* H5C_COLLECT_CACHE_STATS */ - } else if ( ( entry_ptr->loaded ) || - ( entry_ptr->cleared ) || - ( entry_ptr->flushed ) || - ( entry_ptr->destroyed ) ) { + if ( pass ) + { + unprotect_entry(cache_ptr, 0, 0, FALSE, H5C__NO_FLAGS_SET); + + if ( ( entry_ptr->header.is_protected ) || + ( entry_ptr->header.is_read_only ) || + ( entry_ptr->header.ro_ref_count != 0 ) ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected entry history 4."); - failure_mssg = msg; + failure_mssg = "Unexpected ro protected status 11.\n"; + } + } - } +#if H5C_COLLECT_CACHE_STATS + if ( ( cache_ptr->write_protects[0] != 1 ) || + ( cache_ptr->read_protects[0] != 4 ) || + ( cache_ptr->max_read_protects[0] != 3 ) ) { + + pass = FALSE; + failure_mssg = "Unexpected protect stats 11.\n"; } +#endif /* H5C_COLLECT_CACHE_STATS */ - /* protect the entry to force the cache to load it, and then unprotect - * it with the dirty flag set. + + /* Finally, mix things up a little, using a mix of reads and + * and writes on different entries. Also include a pin to verify + * that it works as well. + * + * Stats are looking OK, so we will only test them one more time + * at the end to ensure that all is at it should be. */ - protect_entry(cache_ptr, 0, 1); + if ( pass ) { - unprotect_entry(cache_ptr, 0, 1, TRUE, H5C__NO_FLAGS_SET); + protect_entry(cache_ptr, 0, 2); /* (0,2) write */ + protect_entry_ro(cache_ptr, 0, 4); /* (0,4) read only (1) */ + protect_entry(cache_ptr, 0, 6); /* (0,6) write */ - if ( pass ) { + unprotect_entry(cache_ptr, 0, 2, FALSE, /* (0,2) unprotect */ + H5C__NO_FLAGS_SET); + + protect_entry_ro(cache_ptr, 0, 2); /* (0,2) read only (1) */ + protect_entry(cache_ptr, 0, 1); /* (0,1) write */ + protect_entry_ro(cache_ptr, 0, 4); /* (0,4) read only (2) */ + protect_entry(cache_ptr, 0, 0); /* (0,0) write */ + protect_entry_ro(cache_ptr, 0, 2); /* (0,2) read only (2) */ + + unprotect_entry(cache_ptr, 0, 2, FALSE, /* (0,2) read only (1) pin */ + H5C__PIN_ENTRY_FLAG); + unprotect_entry(cache_ptr, 0, 6, FALSE, /* (0,6) unprotect */ + H5C__NO_FLAGS_SET); - result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size, - &in_cache, &is_dirty, &is_protected, - &is_pinned); + protect_entry_ro(cache_ptr, 0, 4); /* (0,4) read only (3) */ - if ( result < 0 ) { + unprotect_entry(cache_ptr, 0, 2, FALSE, /* (0,2) unprotect */ + H5C__NO_FLAGS_SET); + unprotect_entry(cache_ptr, 0, 1, FALSE, /* (0,1) unprotect */ + H5C__NO_FLAGS_SET); - pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5AC_get_entry_status() reports failure 5."); - failure_mssg = msg; + if ( pass ) { - } else if ( !in_cache || !is_dirty || is_protected || is_pinned ) { + entry_ptr = &((entries[0])[4]); - pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected status 5."); - failure_mssg = msg; + if ( H5C_pin_protected_entry(cache_ptr, (void *)entry_ptr) < 0 ) { - } else if ( ( ! entry_ptr->loaded ) || - ( entry_ptr->cleared ) || - ( entry_ptr->flushed ) || - ( entry_ptr->destroyed ) ) { + pass = FALSE; + failure_mssg = "H5C_pin_protected_entry() failed.\n"; - pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected entry history 5."); - failure_mssg = msg; + } else if ( ! (entry_ptr->header.is_pinned) ) { - } - } + pass = FALSE; + failure_mssg = "entry (0,4) not pinned.\n"; - /* Expunge the entry and then verify that it is no longer in the cache. - * Also verify that the entry was loaded, cleared and destroyed, but not - * flushed. - */ - expunge_entry(cache_ptr, 0, 1); + } else { - if ( pass ) { + /* keep test bed sanity checks happy */ + entry_ptr->is_pinned = TRUE; - /* entry shouldn't be in cache -- only in_cache should be touched - * by the status call. Thus, only check that boolean. - */ + } + } - result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size, - &in_cache, &is_dirty, &is_protected, - &is_pinned); + unprotect_entry(cache_ptr, 0, 4, FALSE, /* (0,4) read only (2) */ + H5C__NO_FLAGS_SET); + unprotect_entry(cache_ptr, 0, 4, FALSE, /* (0,4) read only (1) */ + H5C__UNPIN_ENTRY_FLAG); - if ( result < 0 ) { + if ( ( pass ) && ( entry_ptr->header.is_pinned ) ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5AC_get_entry_status() reports failure 6."); - failure_mssg = msg; + failure_mssg = "enty (0,4) still pinned.\n"; - } else if ( in_cache ) { + } - pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected status 6."); - failure_mssg = msg; + unprotect_entry(cache_ptr, 0, 4, FALSE, /* (0,4) unprotect */ + H5C__NO_FLAGS_SET); + unprotect_entry(cache_ptr, 0, 0, FALSE, /* (0,0) unprotect */ + H5C__NO_FLAGS_SET); - } else if ( ( ! entry_ptr->loaded ) || - ( ! entry_ptr->cleared ) || - ( entry_ptr->flushed ) || - ( ! entry_ptr->destroyed ) ) { + unpin_entry(cache_ptr, 0, 2); + } - pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected entry history 6."); - failure_mssg = msg; +#if H5C_COLLECT_CACHE_STATS + if ( ( cache_ptr->write_protects[0] != 5 ) || + ( cache_ptr->read_protects[0] != 9 ) || + ( cache_ptr->max_read_protects[0] != 3 ) ) { - } + pass = FALSE; + failure_mssg = "Unexpected protect stats 11.\n"; } +#endif /* H5C_COLLECT_CACHE_STATS */ + if ( pass ) { @@ -12688,417 +13722,349 @@ check_expunge_entry(void) if ( ! pass ) { - HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", fcn_name, failure_mssg); } return; -} /* check_expunge_entry() */ +} /* check_multiple_read_protect() */ /*------------------------------------------------------------------------- - * Function: check_multiple_read_protect() + * Function: check_rename_entry() * - * Purpose: Verify that multiple, simultaneous read protects of a - * single entry perform as expectd. + * Purpose: Verify that H5C_rename_entry behaves as expected. In + * particular, verify that it works correctly with pinned + * entries. * * Return: void * * Programmer: John Mainzer - * 4/1/07 + * 4/26/06 * * Modifications: * - * None. - * *------------------------------------------------------------------------- */ - static void -check_multiple_read_protect(void) +check_rename_entry(void) { - const char * fcn_name = "check_multiple_read_protect()"; - H5C_t * cache_ptr = NULL; - test_entry_t * entry_ptr; + const char * fcn_name = "check_rename_entry"; + int i; + H5C_t * cache_ptr = NULL; + struct rename_entry_test_spec test_specs[4] = + { + { + /* int entry_type = */ PICO_ENTRY_TYPE, + /* int entry_index = */ 10, + /* hbool_t is_dirty = */ FALSE, + /* hbool_t is_pinned = */ FALSE + }, + { + /* int entry_type = */ PICO_ENTRY_TYPE, + /* int entry_index = */ 20, + /* hbool_t is_dirty = */ TRUE, + /* hbool_t is_pinned = */ FALSE + }, + { + /* int entry_type = */ PICO_ENTRY_TYPE, + /* int entry_index = */ 30, + /* hbool_t is_dirty = */ FALSE, + /* hbool_t is_pinned = */ TRUE + }, + { + /* int entry_type = */ PICO_ENTRY_TYPE, + /* int entry_index = */ 40, + /* hbool_t is_dirty = */ TRUE, + /* hbool_t is_pinned = */ TRUE + } + }; - TESTING("multiple read only protects on a single entry"); + TESTING("H5C_rename_entry() functionality"); pass = TRUE; - /* allocate a cache. Should succeed. + /* allocate a cache, load entries into it, and then rename + * them. To the extent possible, verify that the desired + * actions took place. * - * Then to start with, proceed as follows: + * At present, we should do the following tests: * - * Read protect an entry. + * 1) Rename a clean, unprotected, unpinned entry. * - * Then read protect the entry again. Should succeed. + * 2) Rename a dirty, unprotected, unpinned entry. * - * Read protect yet again. Should succeed. + * 3) Rename a clean, unprotected, pinned entry. * - * Unprotect with no changes, and then read protect twice again. - * Should succeed. + * 4) Rename a dirty, unprotected, pinned entry. * - * Now unprotect three times. Should succeed. + * In all cases, the entry should have moved to its + * new location, and have been marked dirty if it wasn't + * already. * - * If stats are enabled, verify that correct stats are collected at - * every step. + * Unpinned entries should have been moved to the head + * of the LRU list. * - * Also, verify internal state of read protects at every step. + * Pinned entries should remain untouched on the pinned entry + * list. */ if ( pass ) { - reset_entries(); - - cache_ptr = setup_cache((size_t)(2 * 1024), - (size_t)(1 * 1024)); - - entry_ptr = &((entries[0])[0]); - - if ( ( entry_ptr->header.is_protected ) || - ( entry_ptr->header.is_read_only ) || - ( entry_ptr->header.ro_ref_count != 0 ) ) { - - pass = FALSE; - failure_mssg = "Unexpected ro protected status 1.\n"; - } - } - -#if H5C_COLLECT_CACHE_STATS - if ( ( cache_ptr->write_protects[0] != 0 ) || - ( cache_ptr->read_protects[0] != 0 ) || - ( cache_ptr->max_read_protects[0] != 0 ) ) { - - pass = FALSE; - failure_mssg = "Unexpected protect stats 1.\n"; - } -#endif /* H5C_COLLECT_CACHE_STATS */ - - if ( pass ) - { - protect_entry_ro(cache_ptr, 0, 0); - - if ( ( ! ( entry_ptr->header.is_protected ) ) || - ( ! ( entry_ptr->header.is_read_only ) ) || - ( entry_ptr->header.ro_ref_count != 1 ) ) { - - pass = FALSE; - failure_mssg = "Unexpected ro protected status 2.\n"; - } - } - -#if H5C_COLLECT_CACHE_STATS - if ( ( cache_ptr->write_protects[0] != 0 ) || - ( cache_ptr->read_protects[0] != 1 ) || - ( cache_ptr->max_read_protects[0] != 1 ) ) { - - pass = FALSE; - failure_mssg = "Unexpected protect stats 2.\n"; - } -#endif /* H5C_COLLECT_CACHE_STATS */ - - if ( pass ) - { - protect_entry_ro(cache_ptr, 0, 0); - - if ( ( ! ( entry_ptr->header.is_protected ) ) || - ( ! ( entry_ptr->header.is_read_only ) ) || - ( entry_ptr->header.ro_ref_count != 2 ) ) { - - pass = FALSE; - failure_mssg = "Unexpected ro protected status 3.\n"; - } - } - -#if H5C_COLLECT_CACHE_STATS - if ( ( cache_ptr->write_protects[0] != 0 ) || - ( cache_ptr->read_protects[0] != 2 ) || - ( cache_ptr->max_read_protects[0] != 2 ) ) { - - pass = FALSE; - failure_mssg = "Unexpected protect stats 3.\n"; - } -#endif /* H5C_COLLECT_CACHE_STATS */ - - if ( pass ) - { - unprotect_entry(cache_ptr, 0, 0, FALSE, H5C__NO_FLAGS_SET); - - if ( ( ! ( entry_ptr->header.is_protected ) ) || - ( ! ( entry_ptr->header.is_read_only ) ) || - ( entry_ptr->header.ro_ref_count != 1 ) ) { - - pass = FALSE; - failure_mssg = "Unexpected ro protected status 4.\n"; - } - } - -#if H5C_COLLECT_CACHE_STATS - if ( ( cache_ptr->write_protects[0] != 0 ) || - ( cache_ptr->read_protects[0] != 2 ) || - ( cache_ptr->max_read_protects[0] != 2 ) ) { + reset_entries(); - pass = FALSE; - failure_mssg = "Unexpected protect stats 4.\n"; + cache_ptr = setup_cache((size_t)(2 * 1024 * 1024), + (size_t)(1 * 1024 * 1024)); } -#endif /* H5C_COLLECT_CACHE_STATS */ - if ( pass ) + i = 0; + while ( ( pass ) && ( i < 4 ) ) { - protect_entry_ro(cache_ptr, 0, 0); - - if ( ( ! ( entry_ptr->header.is_protected ) ) || - ( ! ( entry_ptr->header.is_read_only ) ) || - ( entry_ptr->header.ro_ref_count != 2 ) ) { - - pass = FALSE; - failure_mssg = "Unexpected ro protected status 5.\n"; - } + check_rename_entry__run_test(cache_ptr, i, &(test_specs[i])); + i++; } -#if H5C_COLLECT_CACHE_STATS - if ( ( cache_ptr->write_protects[0] != 0 ) || - ( cache_ptr->read_protects[0] != 3 ) || - ( cache_ptr->max_read_protects[0] != 2 ) ) { + if ( pass ) { - pass = FALSE; - failure_mssg = "Unexpected protect stats 5.\n"; + takedown_cache(cache_ptr, FALSE, FALSE); } -#endif /* H5C_COLLECT_CACHE_STATS */ - if ( pass ) - { - protect_entry_ro(cache_ptr, 0, 0); + if ( pass ) { PASSED(); } else { H5_FAILED(); } - if ( ( ! ( entry_ptr->header.is_protected ) ) || - ( ! ( entry_ptr->header.is_read_only ) ) || - ( entry_ptr->header.ro_ref_count != 3 ) ) { + if ( ! pass ) { - pass = FALSE; - failure_mssg = "Unexpected ro protected status 6.\n"; - } + HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", + fcn_name, failure_mssg); } -#if H5C_COLLECT_CACHE_STATS - if ( ( cache_ptr->write_protects[0] != 0 ) || - ( cache_ptr->read_protects[0] != 4 ) || - ( cache_ptr->max_read_protects[0] != 3 ) ) { - - pass = FALSE; - failure_mssg = "Unexpected protect stats 6.\n"; - } -#endif /* H5C_COLLECT_CACHE_STATS */ + return; - if ( pass ) - { - unprotect_entry(cache_ptr, 0, 0, FALSE, H5C__NO_FLAGS_SET); +} /* check_rename_entry() */ - if ( ( ! ( entry_ptr->header.is_protected ) ) || - ( ! ( entry_ptr->header.is_read_only ) ) || - ( entry_ptr->header.ro_ref_count != 2 ) ) { + +/*------------------------------------------------------------------------- + * Function: check_rename_entry__run_test() + * + * Purpose: Run a rename entry test. + * + * Do nothing if pass is FALSE on entry. + * + * Return: void + * + * Programmer: John Mainzer + * 4/27/06 + * + * Modifications: + * + * None. + * + *------------------------------------------------------------------------- + */ - pass = FALSE; - failure_mssg = "Unexpected ro protected status 7.\n"; - } - } +static void +check_rename_entry__run_test(H5C_t * cache_ptr, + int test_num, + struct rename_entry_test_spec * spec_ptr) +{ + /* const char * fcn_name = "check_rename_entry__run_test"; */ + static char msg[128]; + unsigned int flags = H5C__NO_FLAGS_SET; + test_entry_t * base_addr; + test_entry_t * entry_ptr = NULL; + H5C_cache_entry_t * test_ptr = NULL; -#if H5C_COLLECT_CACHE_STATS - if ( ( cache_ptr->write_protects[0] != 0 ) || - ( cache_ptr->read_protects[0] != 4 ) || - ( cache_ptr->max_read_protects[0] != 3 ) ) { + if ( cache_ptr == NULL ) { - pass = FALSE; - failure_mssg = "Unexpected protect stats 7.\n"; - } -#endif /* H5C_COLLECT_CACHE_STATS */ + pass = FALSE; + HDsnprintf(msg, (size_t)128, + "cache_ptr NULL on entry to rename test #%d.", + test_num); + failure_mssg = msg; - if ( pass ) - { - unprotect_entry(cache_ptr, 0, 0, FALSE, H5C__NO_FLAGS_SET); + } else if ( spec_ptr == NULL ) { - if ( ( ! ( entry_ptr->header.is_protected ) ) || - ( ! ( entry_ptr->header.is_read_only ) ) || - ( entry_ptr->header.ro_ref_count != 1 ) ) { + pass = FALSE; + HDsnprintf(msg, (size_t)128, + "spec_ptr NULL on entry to rename test #%d.", + test_num); + failure_mssg = msg; - pass = FALSE; - failure_mssg = "Unexpected ro protected status 8.\n"; - } } -#if H5C_COLLECT_CACHE_STATS - if ( ( cache_ptr->write_protects[0] != 0 ) || - ( cache_ptr->read_protects[0] != 4 ) || - ( cache_ptr->max_read_protects[0] != 3 ) ) { - - pass = FALSE; - failure_mssg = "Unexpected protect stats 8.\n"; - } -#endif /* H5C_COLLECT_CACHE_STATS */ + if ( pass ) { - if ( pass ) - { - unprotect_entry(cache_ptr, 0, 0, FALSE, H5C__NO_FLAGS_SET); + base_addr = entries[spec_ptr->entry_type]; + entry_ptr = &(base_addr[spec_ptr->entry_index]); - if ( ( entry_ptr->header.is_protected ) || - ( entry_ptr->header.is_read_only ) || - ( entry_ptr->header.ro_ref_count != 0 ) ) { + if ( ( entry_ptr->self != entry_ptr ) || + ( ( entry_ptr->cache_ptr != cache_ptr ) && + ( entry_ptr->cache_ptr != NULL ) ) || + ( ! ( entry_ptr->at_main_addr ) ) || + ( entry_ptr->addr != entry_ptr->main_addr ) ) { pass = FALSE; - failure_mssg = "Unexpected ro protected status 9.\n"; + HDsnprintf(msg, (size_t)128, + "bad entry_ptr in rename test #%d.", + test_num); + failure_mssg = msg; + + } else if ( spec_ptr->is_pinned ) { + + flags |= H5C__PIN_ENTRY_FLAG; } } -#if H5C_COLLECT_CACHE_STATS - if ( ( cache_ptr->write_protects[0] != 0 ) || - ( cache_ptr->read_protects[0] != 4 ) || - ( cache_ptr->max_read_protects[0] != 3 ) ) { + protect_entry(cache_ptr, spec_ptr->entry_type, spec_ptr->entry_index); - pass = FALSE; - failure_mssg = "Unexpected protect stats 9.\n"; - } -#endif /* H5C_COLLECT_CACHE_STATS */ + unprotect_entry(cache_ptr, spec_ptr->entry_type, spec_ptr->entry_index, + (int)(spec_ptr->is_dirty), flags); + rename_entry(cache_ptr, spec_ptr->entry_type, spec_ptr->entry_index, FALSE); - /* If we get this far, do a write protect and unprotect to verify - * that the stats are getting collected properly here as well. - */ + if ( pass ) { - if ( pass ) - { - protect_entry(cache_ptr, 0, 0); + /* verify that the rename took place, and that the cache's internal + * structures are as expected. Note that some sanity checking is + * done by rename_entry(), so we don't have to repeat it here. + */ - if ( ( ! ( entry_ptr->header.is_protected ) ) || - ( entry_ptr->header.is_read_only ) || - ( entry_ptr->header.ro_ref_count != 0 ) ) { + if ( spec_ptr->is_pinned ) { - pass = FALSE; - failure_mssg = "Unexpected ro protected status 10.\n"; - } - } + if ( ! ( entry_ptr->header.is_pinned ) ) { -#if H5C_COLLECT_CACHE_STATS - if ( ( cache_ptr->write_protects[0] != 1 ) || - ( cache_ptr->read_protects[0] != 4 ) || - ( cache_ptr->max_read_protects[0] != 3 ) ) { + pass = FALSE; + HDsnprintf(msg, (size_t)128, + "Pinned entry not pinned after rename in test #%d.", + test_num); + failure_mssg = msg; + } - pass = FALSE; - failure_mssg = "Unexpected protect stats 10.\n"; - } -#endif /* H5C_COLLECT_CACHE_STATS */ + if ( pass ) { - if ( pass ) - { - unprotect_entry(cache_ptr, 0, 0, FALSE, H5C__NO_FLAGS_SET); + test_ptr = cache_ptr->pel_head_ptr; - if ( ( entry_ptr->header.is_protected ) || - ( entry_ptr->header.is_read_only ) || - ( entry_ptr->header.ro_ref_count != 0 ) ) { + while ( ( test_ptr != NULL ) && + ( test_ptr != (H5C_cache_entry_t *)entry_ptr ) ) + { + test_ptr = test_ptr->next; + } - pass = FALSE; - failure_mssg = "Unexpected ro protected status 11.\n"; - } - } + if ( test_ptr == NULL ) { -#if H5C_COLLECT_CACHE_STATS - if ( ( cache_ptr->write_protects[0] != 1 ) || - ( cache_ptr->read_protects[0] != 4 ) || - ( cache_ptr->max_read_protects[0] != 3 ) ) { + pass = FALSE; + HDsnprintf(msg, (size_t)128, + "Pinned entry not in pel after rename in test #%d.", + test_num); + failure_mssg = msg; + } + } - pass = FALSE; - failure_mssg = "Unexpected protect stats 11.\n"; - } -#endif /* H5C_COLLECT_CACHE_STATS */ + unpin_entry(cache_ptr, spec_ptr->entry_type, spec_ptr->entry_index); + } else { - /* Finally, mix things up a little, using a mix of reads and - * and writes on different entries. Also include a pin to verify - * that it works as well. - * - * Stats are looking OK, so we will only test them one more time - * at the end to ensure that all is at it should be. - */ + if ( entry_ptr->header.is_pinned ) { - if ( pass ) { + pass = FALSE; + HDsnprintf(msg, (size_t)128, + "Unpinned entry pinned after rename in test #%d.", + test_num); + failure_mssg = msg; + } - protect_entry(cache_ptr, 0, 2); /* (0,2) write */ - protect_entry_ro(cache_ptr, 0, 4); /* (0,4) read only (1) */ - protect_entry(cache_ptr, 0, 6); /* (0,6) write */ + if ( ( entry_ptr->header.prev != NULL ) || + ( cache_ptr->LRU_head_ptr != (H5C_cache_entry_t *)entry_ptr ) ) + { + pass = FALSE; + HDsnprintf(msg, (size_t)128, + "Entry not at head of LRU after rename in test #%d.", + test_num); + failure_mssg = msg; + } + } + } - unprotect_entry(cache_ptr, 0, 2, FALSE, /* (0,2) unprotect */ - H5C__NO_FLAGS_SET); + /* put the entry back where it started from */ + rename_entry(cache_ptr, spec_ptr->entry_type, spec_ptr->entry_index, TRUE); - protect_entry_ro(cache_ptr, 0, 2); /* (0,2) read only (1) */ - protect_entry(cache_ptr, 0, 1); /* (0,1) write */ - protect_entry_ro(cache_ptr, 0, 4); /* (0,4) read only (2) */ - protect_entry(cache_ptr, 0, 0); /* (0,0) write */ - protect_entry_ro(cache_ptr, 0, 2); /* (0,2) read only (2) */ + return; - unprotect_entry(cache_ptr, 0, 2, FALSE, /* (0,2) read only (1) pin */ - H5C__PIN_ENTRY_FLAG); - unprotect_entry(cache_ptr, 0, 6, FALSE, /* (0,6) unprotect */ - H5C__NO_FLAGS_SET); +} /* check_rename_entry__run_test() */ - protect_entry_ro(cache_ptr, 0, 4); /* (0,4) read only (3) */ + +/*------------------------------------------------------------------------- + * Function: check_pin_protected_entry() + * + * Purpose: Verify that H5C_pin_protected_entry behaves as expected. + * + * Return: void + * + * Programmer: John Mainzer + * 4/28/06 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ - unprotect_entry(cache_ptr, 0, 2, FALSE, /* (0,2) unprotect */ - H5C__NO_FLAGS_SET); - unprotect_entry(cache_ptr, 0, 1, FALSE, /* (0,1) unprotect */ - H5C__NO_FLAGS_SET); +static void +check_pin_protected_entry(void) +{ + const char * fcn_name = "check_pin_protected_entry"; + static char msg[128]; + herr_t result; + H5C_t * cache_ptr = NULL; + test_entry_t * base_addr; + test_entry_t * entry_ptr; - if ( pass ) { + TESTING("H5C_pin_protected_entry() functionality"); - entry_ptr = &((entries[0])[4]); + pass = TRUE; - if ( H5C_pin_protected_entry(cache_ptr, (void *)entry_ptr) < 0 ) { + /* Create a cache, protect an entry, and then use H5C_pin_protected_entry() + * to pin it. Verify that the entry is in fact pined. Unprotect the entry + * to unpin it, and then destroy the cache. + */ - pass = FALSE; - failure_mssg = "H5C_pin_protected_entry() failed.\n"; + if ( pass ) { - } else if ( ! (entry_ptr->header.is_pinned) ) { + reset_entries(); - pass = FALSE; - failure_mssg = "entry (0,4) not pinned.\n"; + cache_ptr = setup_cache((size_t)(2 * 1024 * 1024), + (size_t)(1 * 1024 * 1024)); + } - } else { + protect_entry(cache_ptr, 0, 0); - /* keep test bed sanity checks happy */ - entry_ptr->is_pinned = TRUE; + if ( pass ) { - } - } + base_addr = entries[0]; + entry_ptr = &(base_addr[0]); - unprotect_entry(cache_ptr, 0, 4, FALSE, /* (0,4) read only (2) */ - H5C__NO_FLAGS_SET); - unprotect_entry(cache_ptr, 0, 4, FALSE, /* (0,4) read only (1) */ - H5C__UNPIN_ENTRY_FLAG); + result = H5C_pin_protected_entry(cache_ptr, (void *)entry_ptr); - if ( ( pass ) && ( entry_ptr->header.is_pinned ) ) { + if ( result < 0 ) { pass = FALSE; - failure_mssg = "enty (0,4) still pinned.\n"; - - } + HDsnprintf(msg, (size_t)128, + "H5C_pin_protected_entry() reports failure."); + failure_mssg = msg; - unprotect_entry(cache_ptr, 0, 4, FALSE, /* (0,4) unprotect */ - H5C__NO_FLAGS_SET); - unprotect_entry(cache_ptr, 0, 0, FALSE, /* (0,0) unprotect */ - H5C__NO_FLAGS_SET); + } else if ( ! ( entry_ptr->header.is_pinned ) ) { - unpin_entry(cache_ptr, 0, 2); - } + pass = FALSE; + HDsnprintf(msg, (size_t)128, "entry not pinned when it should be."); + failure_mssg = msg; -#if H5C_COLLECT_CACHE_STATS - if ( ( cache_ptr->write_protects[0] != 5 ) || - ( cache_ptr->read_protects[0] != 9 ) || - ( cache_ptr->max_read_protects[0] != 3 ) ) { + } else { - pass = FALSE; - failure_mssg = "Unexpected protect stats 11.\n"; + entry_ptr->is_pinned = TRUE; + } } -#endif /* H5C_COLLECT_CACHE_STATS */ + unprotect_entry(cache_ptr, 0, 0, FALSE, H5C__UNPIN_ENTRY_FLAG); if ( pass ) { @@ -13109,475 +14075,534 @@ check_multiple_read_protect(void) if ( ! pass ) { - HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", + HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", fcn_name, failure_mssg); } return; -} /* check_multiple_read_protect() */ +} /* check_pin_protected_entry() */ /*------------------------------------------------------------------------- - * Function: check_rename_entry() + * Function: check_resize_entry() * - * Purpose: Verify that H5C_rename_entry behaves as expected. In - * particular, verify that it works correctly with pinned - * entries. + * Purpose: Verify that H5C_resize_entry() and H5C_unprotect() resize + * entries as expected. * * Return: void * * Programmer: John Mainzer - * 4/26/06 + * 7/7/06 * * Modifications: * + * None. + * *------------------------------------------------------------------------- */ static void -check_rename_entry(void) +check_resize_entry(void) { - const char * fcn_name = "check_rename_entry"; - int i; - H5C_t * cache_ptr = NULL; - struct rename_entry_test_spec test_specs[4] = - { - { - /* int entry_type = */ PICO_ENTRY_TYPE, - /* int entry_index = */ 10, - /* hbool_t is_dirty = */ FALSE, - /* hbool_t is_pinned = */ FALSE - }, - { - /* int entry_type = */ PICO_ENTRY_TYPE, - /* int entry_index = */ 20, - /* hbool_t is_dirty = */ TRUE, - /* hbool_t is_pinned = */ FALSE - }, - { - /* int entry_type = */ PICO_ENTRY_TYPE, - /* int entry_index = */ 30, - /* hbool_t is_dirty = */ FALSE, - /* hbool_t is_pinned = */ TRUE - }, - { - /* int entry_type = */ PICO_ENTRY_TYPE, - /* int entry_index = */ 40, - /* hbool_t is_dirty = */ TRUE, - /* hbool_t is_pinned = */ TRUE - } - }; + const char * fcn_name = "check_resize_entry"; + static char msg[128]; + herr_t result; + hbool_t in_cache; + hbool_t is_dirty; + hbool_t is_protected; + hbool_t is_pinned; + size_t entry_size; + size_t reported_entry_size; + H5C_t * cache_ptr = NULL; + test_entry_t * base_addr; + test_entry_t * entry_ptr; + + TESTING("entry resize functionality"); + + /* Setup a cache and verify that it is empty. + * + * Then force the load of an entry by protecting it, and verify that + * the entry and cache have the expected sizes. + * + * Then unprotect the entry with the size changed flag and a reduced + * size. Verify that the entry and cache have the expected expected + * sizes. + * + * Use a second protect/unprotect cycle to restore the entry to + * its original size. Verify that the entry and cache have the + * expected sizes. + * + * Protect and unprotect the entry again to pin it. Use + * H5C_resize_entry to reduce its size. Verify that the entry + * and cache have the expected sizes. + * + * Use H5C_resize_entry again to restore the entry to its original + * size. Verify that the entry and cache have the expected sizes. + * + * Use a protect / unprotect cycle to unpin and destroy the entry. + * Verify that the entry and cache have the expected sizes. + * + * + * Obesrve that all the above tests have been done with only one + * entry in the cache. Repeat the tests with several entries in + * the cache. + */ + + pass = TRUE; + + /* tests with only one entry in the cache: */ + + if ( pass ) { + + reset_entries(); + + cache_ptr = setup_cache((size_t)(2 * 1024 * 1024), + (size_t)(1 * 1024 * 1024)); + + base_addr = entries[LARGE_ENTRY_TYPE]; + entry_ptr = &(base_addr[0]); + entry_size = LARGE_ENTRY_SIZE; + } + + if ( pass ) { + + if ( ( cache_ptr->index_len != 0 ) || + ( cache_ptr->index_size != 0 ) || + ( cache_ptr->slist_len != 0 ) || + ( cache_ptr->slist_size != 0 ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected cache status 1."); + failure_mssg = msg; + + } + } + + protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 0); + + if ( pass ) { + + if ( ( cache_ptr->index_len != 1 ) || + ( cache_ptr->index_size != LARGE_ENTRY_SIZE ) || + ( cache_ptr->slist_len != 0 ) || + ( cache_ptr->slist_size != 0 ) ) { + + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected cache status 2."); + failure_mssg = msg; + + } + } + + if ( pass ) { + + result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, + &reported_entry_size, &in_cache, + &is_dirty, &is_protected, &is_pinned); - TESTING("H5C_rename_entry() functionality"); + if ( result < 0 ) { - pass = TRUE; + pass = FALSE; + HDsnprintf(msg, (size_t)128, + "H5AC_get_entry_status() reports failure 1."); + failure_mssg = msg; - /* allocate a cache, load entries into it, and then rename - * them. To the extent possible, verify that the desired - * actions took place. - * - * At present, we should do the following tests: - * - * 1) Rename a clean, unprotected, unpinned entry. - * - * 2) Rename a dirty, unprotected, unpinned entry. - * - * 3) Rename a clean, unprotected, pinned entry. - * - * 4) Rename a dirty, unprotected, pinned entry. - * - * In all cases, the entry should have moved to its - * new location, and have been marked dirty if it wasn't - * already. - * - * Unpinned entries should have been moved to the head - * of the LRU list. - * - * Pinned entries should remain untouched on the pinned entry - * list. - */ + } else if ( !in_cache || is_dirty || !is_protected || is_pinned ) { - if ( pass ) { + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected status 1."); + failure_mssg = msg; - reset_entries(); + } else if ( ( ! entry_ptr->loaded ) || + ( entry_ptr->cleared ) || + ( entry_ptr->flushed ) || + ( entry_ptr->destroyed ) ) { - cache_ptr = setup_cache((size_t)(2 * 1024 * 1024), - (size_t)(1 * 1024 * 1024)); + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected entry history 1."); + failure_mssg = msg; + + } } - i = 0; - while ( ( pass ) && ( i < 4 ) ) - { - check_rename_entry__run_test(cache_ptr, i, &(test_specs[i])); - i++; + if ( pass ) { + + result = H5C_unprotect(NULL, -1, -1, cache_ptr, + &(types[LARGE_ENTRY_TYPE]), entry_ptr->addr, + (void *)entry_ptr, + H5C__SIZE_CHANGED_FLAG | H5C__DIRTIED_FLAG, + (LARGE_ENTRY_SIZE / 2)); + + if ( result < 0 ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "H5C_unprotect() reports failure 1."); + failure_mssg = msg; + + } else { + + /* tidy up so we play nice with the standard protect / unprotect + * calls. + */ + entry_ptr->is_protected = FALSE; + entry_ptr->is_dirty = TRUE; + entry_ptr->size = LARGE_ENTRY_SIZE / 2; + } } if ( pass ) { - takedown_cache(cache_ptr, FALSE, FALSE); + if ( ( cache_ptr->index_len != 1 ) || + ( cache_ptr->index_size != (LARGE_ENTRY_SIZE / 2) ) || + ( cache_ptr->slist_len != 1 ) || + ( cache_ptr->slist_size != (LARGE_ENTRY_SIZE / 2) ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected cache status 3."); + failure_mssg = msg; + + } } - if ( pass ) { PASSED(); } else { H5_FAILED(); } + if ( pass ) { - if ( ! pass ) { + result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, + &reported_entry_size, &in_cache, + &is_dirty, &is_protected, &is_pinned); - HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", - fcn_name, failure_mssg); + if ( result < 0 ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, + "H5AC_get_entry_status() reports failure 2."); + failure_mssg = msg; + + } else if ( !in_cache || !is_dirty || is_protected || is_pinned || + ( reported_entry_size != (LARGE_ENTRY_SIZE / 2) ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected status 2."); + failure_mssg = msg; + + } else if ( ( ! entry_ptr->loaded ) || + ( entry_ptr->cleared ) || + ( entry_ptr->flushed ) || + ( entry_ptr->destroyed ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected entry history 2."); + failure_mssg = msg; + + } } - return; + protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 0); -} /* check_rename_entry() */ + if ( pass ) { - -/*------------------------------------------------------------------------- - * Function: check_rename_entry__run_test() - * - * Purpose: Run a rename entry test. - * - * Do nothing if pass is FALSE on entry. - * - * Return: void - * - * Programmer: John Mainzer - * 4/27/06 - * - * Modifications: - * - * None. - * - *------------------------------------------------------------------------- - */ + result = H5C_unprotect(NULL, -1, -1, cache_ptr, + &(types[LARGE_ENTRY_TYPE]), entry_ptr->addr, + (void *)entry_ptr, + (H5C__DIRTIED_FLAG | H5C__SIZE_CHANGED_FLAG), + LARGE_ENTRY_SIZE); -static void -check_rename_entry__run_test(H5C_t * cache_ptr, - int test_num, - struct rename_entry_test_spec * spec_ptr) -{ - /* const char * fcn_name = "check_rename_entry__run_test"; */ - static char msg[128]; - unsigned int flags = H5C__NO_FLAGS_SET; - test_entry_t * base_addr; - test_entry_t * entry_ptr = NULL; - H5C_cache_entry_t * test_ptr = NULL; + if ( result < 0 ) { - if ( cache_ptr == NULL ) { + pass = FALSE; + HDsnprintf(msg, (size_t)128, "H5C_unprotect() reports failure 2."); + failure_mssg = msg; - pass = FALSE; - HDsnprintf(msg, (size_t)128, - "cache_ptr NULL on entry to rename test #%d.", - test_num); - failure_mssg = msg; + } else { - } else if ( spec_ptr == NULL ) { + /* tidy up so we play nice with the standard protect / unprotect + * calls. + */ + entry_ptr->is_protected = FALSE; + entry_ptr->is_dirty = TRUE; + entry_ptr->size = LARGE_ENTRY_SIZE; + } + } - pass = FALSE; - HDsnprintf(msg, (size_t)128, - "spec_ptr NULL on entry to rename test #%d.", - test_num); - failure_mssg = msg; + if ( pass ) { + + if ( ( cache_ptr->index_len != 1 ) || + ( cache_ptr->index_size != LARGE_ENTRY_SIZE ) || + ( cache_ptr->slist_len != 1 ) || + ( cache_ptr->slist_size != LARGE_ENTRY_SIZE ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected cache status 4."); + failure_mssg = msg; + } } if ( pass ) { - base_addr = entries[spec_ptr->entry_type]; - entry_ptr = &(base_addr[spec_ptr->entry_index]); + result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, + &reported_entry_size, &in_cache, + &is_dirty, &is_protected, &is_pinned); - if ( ( entry_ptr->self != entry_ptr ) || - ( ( entry_ptr->cache_ptr != cache_ptr ) && - ( entry_ptr->cache_ptr != NULL ) ) || - ( ! ( entry_ptr->at_main_addr ) ) || - ( entry_ptr->addr != entry_ptr->main_addr ) ) { + if ( result < 0 ) { pass = FALSE; HDsnprintf(msg, (size_t)128, - "bad entry_ptr in rename test #%d.", - test_num); + "H5AC_get_entry_status() reports failure 3."); failure_mssg = msg; - } else if ( spec_ptr->is_pinned ) { + } else if ( !in_cache || !is_dirty || is_protected || is_pinned || + ( reported_entry_size != LARGE_ENTRY_SIZE ) ) { - flags |= H5C__PIN_ENTRY_FLAG; - } - } + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected status 3."); + failure_mssg = msg; - protect_entry(cache_ptr, spec_ptr->entry_type, spec_ptr->entry_index); + } else if ( ( ! entry_ptr->loaded ) || + ( entry_ptr->cleared ) || + ( entry_ptr->flushed ) || + ( entry_ptr->destroyed ) ) { - unprotect_entry(cache_ptr, spec_ptr->entry_type, spec_ptr->entry_index, - (int)(spec_ptr->is_dirty), flags); + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected entry history 3."); + failure_mssg = msg; - rename_entry(cache_ptr, spec_ptr->entry_type, spec_ptr->entry_index, FALSE); + } + } + + protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 0); + + unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 0, FALSE, H5C__PIN_ENTRY_FLAG); if ( pass ) { - /* verify that the rename took place, and that the cache's internal - * structures are as expected. Note that some sanity checking is - * done by rename_entry(), so we don't have to repeat it here. - */ + result = H5C_resize_pinned_entry(cache_ptr, (void *)entry_ptr, + (LARGE_ENTRY_SIZE / 4)); - if ( spec_ptr->is_pinned ) { + if ( result < 0 ) { - if ( ! ( entry_ptr->header.is_pinned ) ) { + pass = FALSE; + HDsnprintf(msg, (size_t)128, + "H5C_resize_pinned_entry() reports failure 1."); + failure_mssg = msg; - pass = FALSE; - HDsnprintf(msg, (size_t)128, - "Pinned entry not pinned after rename in test #%d.", - test_num); - failure_mssg = msg; - } + } + } - if ( pass ) { + if ( pass ) { - test_ptr = cache_ptr->pel_head_ptr; + if ( ( cache_ptr->index_len != 1 ) || + ( cache_ptr->index_size != (LARGE_ENTRY_SIZE / 4) ) || + ( cache_ptr->slist_len != 1 ) || + ( cache_ptr->slist_size != (LARGE_ENTRY_SIZE / 4) ) ) { - while ( ( test_ptr != NULL ) && - ( test_ptr != (H5C_cache_entry_t *)entry_ptr ) ) - { - test_ptr = test_ptr->next; - } + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected cache status 5."); + failure_mssg = msg; - if ( test_ptr == NULL ) { + } + } - pass = FALSE; - HDsnprintf(msg, (size_t)128, - "Pinned entry not in pel after rename in test #%d.", - test_num); - failure_mssg = msg; - } - } + if ( pass ) { - unpin_entry(cache_ptr, spec_ptr->entry_type, spec_ptr->entry_index); + result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, + &reported_entry_size, &in_cache, + &is_dirty, &is_protected, &is_pinned); - } else { + if ( result < 0 ) { - if ( entry_ptr->header.is_pinned ) { + pass = FALSE; + HDsnprintf(msg, (size_t)128, + "H5AC_get_entry_status() reports failure 4."); + failure_mssg = msg; - pass = FALSE; - HDsnprintf(msg, (size_t)128, - "Unpinned entry pinned after rename in test #%d.", - test_num); - failure_mssg = msg; - } + } else if ( !in_cache || !is_dirty || is_protected || ! is_pinned || + ( reported_entry_size != (LARGE_ENTRY_SIZE / 4) ) ) { - if ( ( entry_ptr->header.prev != NULL ) || - ( cache_ptr->LRU_head_ptr != (H5C_cache_entry_t *)entry_ptr ) ) - { - pass = FALSE; - HDsnprintf(msg, (size_t)128, - "Entry not at head of LRU after rename in test #%d.", - test_num); - failure_mssg = msg; - } - } - } + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected status 4."); + failure_mssg = msg; - /* put the entry back where it started from */ - rename_entry(cache_ptr, spec_ptr->entry_type, spec_ptr->entry_index, TRUE); + } else if ( ( ! entry_ptr->loaded ) || + ( entry_ptr->cleared ) || + ( entry_ptr->flushed ) || + ( entry_ptr->destroyed ) ) { - return; + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected entry history 4."); + failure_mssg = msg; -} /* check_rename_entry__run_test() */ + } + } - -/*------------------------------------------------------------------------- - * Function: check_pin_protected_entry() - * - * Purpose: Verify that H5C_pin_protected_entry behaves as expected. - * - * Return: void - * - * Programmer: John Mainzer - * 4/28/06 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ + if ( pass ) { -static void -check_pin_protected_entry(void) -{ - const char * fcn_name = "check_pin_protected_entry"; - static char msg[128]; - herr_t result; - H5C_t * cache_ptr = NULL; - test_entry_t * base_addr; - test_entry_t * entry_ptr; + result = H5C_resize_pinned_entry(cache_ptr, (void *)entry_ptr, + LARGE_ENTRY_SIZE); - TESTING("H5C_pin_protected_entry() functionality"); + if ( result < 0 ) { - pass = TRUE; + pass = FALSE; + HDsnprintf(msg, (size_t)128, + "H5C_resize_pinned_entry() reports failure 2."); + failure_mssg = msg; - /* Create a cache, protect an entry, and then use H5C_pin_protected_entry() - * to pin it. Verify that the entry is in fact pined. Unprotect the entry - * to unpin it, and then destroy the cache. - */ + } + } if ( pass ) { - reset_entries(); + if ( ( cache_ptr->index_len != 1 ) || + ( cache_ptr->index_size != LARGE_ENTRY_SIZE ) || + ( cache_ptr->slist_len != 1 ) || + ( cache_ptr->slist_size != LARGE_ENTRY_SIZE ) ) { - cache_ptr = setup_cache((size_t)(2 * 1024 * 1024), - (size_t)(1 * 1024 * 1024)); - } + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected cache status 6."); + failure_mssg = msg; - protect_entry(cache_ptr, 0, 0); + } + } if ( pass ) { - base_addr = entries[0]; - entry_ptr = &(base_addr[0]); - - result = H5C_pin_protected_entry(cache_ptr, (void *)entry_ptr); + result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, + &reported_entry_size, &in_cache, + &is_dirty, &is_protected, &is_pinned); if ( result < 0 ) { pass = FALSE; HDsnprintf(msg, (size_t)128, - "H5C_pin_protected_entry() reports failure."); + "H5AC_get_entry_status() reports failure 5."); failure_mssg = msg; - } else if ( ! ( entry_ptr->header.is_pinned ) ) { + } else if ( !in_cache || !is_dirty || is_protected || ! is_pinned || + ( reported_entry_size != LARGE_ENTRY_SIZE ) ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "entry not pinned when it should be."); + HDsnprintf(msg, (size_t)128, "Unexpected status 5."); failure_mssg = msg; - } else { + } else if ( ( ! entry_ptr->loaded ) || + ( entry_ptr->cleared ) || + ( entry_ptr->flushed ) || + ( entry_ptr->destroyed ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected entry history 5."); + failure_mssg = msg; - entry_ptr->is_pinned = TRUE; } } - unprotect_entry(cache_ptr, 0, 0, FALSE, H5C__UNPIN_ENTRY_FLAG); + protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 0); + + unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 0, FALSE, + H5C__UNPIN_ENTRY_FLAG | H5C__DELETED_FLAG); if ( pass ) { - takedown_cache(cache_ptr, FALSE, FALSE); - } + result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size, + &in_cache, &is_dirty, &is_protected, + &is_pinned); - if ( pass ) { PASSED(); } else { H5_FAILED(); } + if ( result < 0 ) { - if ( ! pass ) { + pass = FALSE; + HDsnprintf(msg, (size_t)128, + "H5AC_get_entry_status() reports failure 6."); + failure_mssg = msg; - HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", - fcn_name, failure_mssg); - } + } else if ( in_cache ) { - return; + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected status 6."); + failure_mssg = msg; -} /* check_pin_protected_entry() */ + } else if ( ( ! entry_ptr->loaded ) || + ( ! entry_ptr->cleared ) || + ( entry_ptr->flushed ) || + ( ! entry_ptr->destroyed ) ) { - -/*------------------------------------------------------------------------- - * Function: check_resize_entry() - * - * Purpose: Verify that H5C_resize_entry() and H5C_unprotect() resize - * entries as expected. - * - * Return: void - * - * Programmer: John Mainzer - * 7/7/06 - * - * Modifications: - * - * None. - * - *------------------------------------------------------------------------- - */ + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected entry history 6."); + failure_mssg = msg; -static void -check_resize_entry(void) -{ - const char * fcn_name = "check_resize_entry"; - static char msg[128]; - herr_t result; - hbool_t in_cache; - hbool_t is_dirty; - hbool_t is_protected; - hbool_t is_pinned; - size_t entry_size; - size_t reported_entry_size; - H5C_t * cache_ptr = NULL; - test_entry_t * base_addr; - test_entry_t * entry_ptr; + } + } - TESTING("entry resize functionality"); + if ( pass ) { - /* Setup a cache and verify that it is empty. - * - * Then force the load of an entry by protecting it, and verify that - * the entry and cache have the expected sizes. - * - * Then unprotect the entry with the size changed flag and a reduced - * size. Verify that the entry and cache have the expected expected - * sizes. - * - * Use a second protect/unprotect cycle to restore the entry to - * its original size. Verify that the entry and cache have the - * expected sizes. - * - * Protect and unprotect the entry again to pin it. Use - * H5C_resize_entry to reduce its size. Verify that the entry - * and cache have the expected sizes. - * - * Use H5C_resize_entry again to restore the entry to its original - * size. Verify that the entry and cache have the expected sizes. - * - * Use a protect / unprotect cycle to unpin and destroy the entry. - * Verify that the entry and cache have the expected sizes. - * - * - * Obesrve that all the above tests have been done with only one - * entry in the cache. Repeat the tests with several entries in - * the cache. - */ + if ( ( cache_ptr->index_len != 0 ) || + ( cache_ptr->index_size != 0 ) || + ( cache_ptr->slist_len != 0 ) || + ( cache_ptr->slist_size != 0 ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected cache status 7."); + failure_mssg = msg; - pass = TRUE; + } + } - /* tests with only one entry in the cache: */ + + /* now repreat the above tests with several entries in the cache: */ if ( pass ) { - reset_entries(); + if ( ( cache_ptr->index_len != 0 ) || + ( cache_ptr->index_size != 0 ) || + ( cache_ptr->slist_len != 0 ) || + ( cache_ptr->slist_size != 0 ) ) { - cache_ptr = setup_cache((size_t)(2 * 1024 * 1024), - (size_t)(1 * 1024 * 1024)); + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected cache status 8."); + failure_mssg = msg; + } base_addr = entries[LARGE_ENTRY_TYPE]; - entry_ptr = &(base_addr[0]); + entry_ptr = &(base_addr[3]); entry_size = LARGE_ENTRY_SIZE; } + protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 0); + unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 0, FALSE, H5C__NO_FLAGS_SET); + + protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 1); + unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 1, TRUE, H5C__NO_FLAGS_SET); + + protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 2); + unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 2, FALSE, H5C__NO_FLAGS_SET); + if ( pass ) { - if ( ( cache_ptr->index_len != 0 ) || - ( cache_ptr->index_size != 0 ) || - ( cache_ptr->slist_len != 0 ) || - ( cache_ptr->slist_size != 0 ) ) { + if ( ( cache_ptr->index_len != 3 ) || + ( cache_ptr->index_size != 3 * LARGE_ENTRY_SIZE ) || + ( cache_ptr->slist_len != 1 ) || + ( cache_ptr->slist_size != LARGE_ENTRY_SIZE ) ) { + pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected cache status 1."); + HDsnprintf(msg, (size_t)128, "Unexpected cache status 9."); failure_mssg = msg; } } - protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 0); + protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 3); if ( pass ) { - if ( ( cache_ptr->index_len != 1 ) || - ( cache_ptr->index_size != LARGE_ENTRY_SIZE ) || - ( cache_ptr->slist_len != 0 ) || - ( cache_ptr->slist_size != 0 ) ) { + if ( ( cache_ptr->index_len != 4 ) || + ( cache_ptr->index_size != 4 * LARGE_ENTRY_SIZE ) || + ( cache_ptr->slist_len != 1 ) || + ( cache_ptr->slist_size != LARGE_ENTRY_SIZE ) ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected cache status 2."); + HDsnprintf(msg, (size_t)128, "Unexpected cache status 10."); failure_mssg = msg; } @@ -13593,13 +14618,13 @@ check_resize_entry(void) pass = FALSE; HDsnprintf(msg, (size_t)128, - "H5AC_get_entry_status() reports failure 1."); + "H5AC_get_entry_status() reports failure 7."); failure_mssg = msg; } else if ( !in_cache || is_dirty || !is_protected || is_pinned ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected status 1."); + HDsnprintf(msg, (size_t)128, "Unexpected status 7."); failure_mssg = msg; } else if ( ( ! entry_ptr->loaded ) || @@ -13608,7 +14633,7 @@ check_resize_entry(void) ( entry_ptr->destroyed ) ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected entry history 1."); + HDsnprintf(msg, (size_t)128, "Unexpected entry history 7."); failure_mssg = msg; } @@ -13625,7 +14650,7 @@ check_resize_entry(void) if ( result < 0 ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "H5C_unprotect() reports failure 1."); + HDsnprintf(msg, (size_t)128, "H5C_unprotect() reports failure 3."); failure_mssg = msg; } else { @@ -13641,13 +14666,15 @@ check_resize_entry(void) if ( pass ) { - if ( ( cache_ptr->index_len != 1 ) || - ( cache_ptr->index_size != (LARGE_ENTRY_SIZE / 2) ) || - ( cache_ptr->slist_len != 1 ) || - ( cache_ptr->slist_size != (LARGE_ENTRY_SIZE / 2) ) ) { + if ( ( cache_ptr->index_len != 4 ) || + ( cache_ptr->index_size != + ((3 * LARGE_ENTRY_SIZE) + (LARGE_ENTRY_SIZE / 2)) ) || + ( cache_ptr->slist_len != 2 ) || + ( cache_ptr->slist_size != + (LARGE_ENTRY_SIZE + (LARGE_ENTRY_SIZE / 2)) ) ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected cache status 3."); + HDsnprintf(msg, (size_t)128, "Unexpected cache status 11."); failure_mssg = msg; } @@ -13663,14 +14690,14 @@ check_resize_entry(void) pass = FALSE; HDsnprintf(msg, (size_t)128, - "H5AC_get_entry_status() reports failure 2."); + "H5AC_get_entry_status() reports failure 8."); failure_mssg = msg; } else if ( !in_cache || !is_dirty || is_protected || is_pinned || ( reported_entry_size != (LARGE_ENTRY_SIZE / 2) ) ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected status 2."); + HDsnprintf(msg, (size_t)128, "Unexpected status 8."); failure_mssg = msg; } else if ( ( ! entry_ptr->loaded ) || @@ -13679,13 +14706,13 @@ check_resize_entry(void) ( entry_ptr->destroyed ) ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected entry history 2."); + HDsnprintf(msg, (size_t)128, "Unexpected entry history 8."); failure_mssg = msg; } } - protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 0); + protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 3); if ( pass ) { @@ -13698,7 +14725,7 @@ check_resize_entry(void) if ( result < 0 ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "H5C_unprotect() reports failure 2."); + HDsnprintf(msg, (size_t)128, "H5C_unprotect() reports failure 4."); failure_mssg = msg; } else { @@ -13714,13 +14741,13 @@ check_resize_entry(void) if ( pass ) { - if ( ( cache_ptr->index_len != 1 ) || - ( cache_ptr->index_size != LARGE_ENTRY_SIZE ) || - ( cache_ptr->slist_len != 1 ) || - ( cache_ptr->slist_size != LARGE_ENTRY_SIZE ) ) { + if ( ( cache_ptr->index_len != 4 ) || + ( cache_ptr->index_size != 4 * LARGE_ENTRY_SIZE ) || + ( cache_ptr->slist_len != 2 ) || + ( cache_ptr->slist_size != 2 * LARGE_ENTRY_SIZE ) ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected cache status 4."); + HDsnprintf(msg, (size_t)128, "Unexpected cache status 12."); failure_mssg = msg; } @@ -13736,14 +14763,14 @@ check_resize_entry(void) pass = FALSE; HDsnprintf(msg, (size_t)128, - "H5AC_get_entry_status() reports failure 3."); + "H5AC_get_entry_status() reports failure 9."); failure_mssg = msg; } else if ( !in_cache || !is_dirty || is_protected || is_pinned || ( reported_entry_size != LARGE_ENTRY_SIZE ) ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected status 3."); + HDsnprintf(msg, (size_t)128, "Unexpected status 9."); failure_mssg = msg; } else if ( ( ! entry_ptr->loaded ) || @@ -13752,15 +14779,15 @@ check_resize_entry(void) ( entry_ptr->destroyed ) ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected entry history 3."); + HDsnprintf(msg, (size_t)128, "Unexpected entry history 9."); failure_mssg = msg; } } - protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 0); + protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 3); - unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 0, FALSE, H5C__PIN_ENTRY_FLAG); + unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 3, FALSE, H5C__PIN_ENTRY_FLAG); if ( pass ) { @@ -13771,7 +14798,7 @@ check_resize_entry(void) pass = FALSE; HDsnprintf(msg, (size_t)128, - "H5C_resize_pinned_entry() reports failure 1."); + "H5C_resize_pinned_entry() reports failure 3."); failure_mssg = msg; } @@ -13779,13 +14806,15 @@ check_resize_entry(void) if ( pass ) { - if ( ( cache_ptr->index_len != 1 ) || - ( cache_ptr->index_size != (LARGE_ENTRY_SIZE / 4) ) || - ( cache_ptr->slist_len != 1 ) || - ( cache_ptr->slist_size != (LARGE_ENTRY_SIZE / 4) ) ) { + if ( ( cache_ptr->index_len != 4 ) || + ( cache_ptr->index_size != + ((3 * LARGE_ENTRY_SIZE) + (LARGE_ENTRY_SIZE / 4)) ) || + ( cache_ptr->slist_len != 2 ) || + ( cache_ptr->slist_size != + (LARGE_ENTRY_SIZE + (LARGE_ENTRY_SIZE / 4)) ) ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected cache status 5."); + HDsnprintf(msg, (size_t)128, "Unexpected cache status 13."); failure_mssg = msg; } @@ -13801,14 +14830,14 @@ check_resize_entry(void) pass = FALSE; HDsnprintf(msg, (size_t)128, - "H5AC_get_entry_status() reports failure 4."); + "H5AC_get_entry_status() reports failure 10."); failure_mssg = msg; } else if ( !in_cache || !is_dirty || is_protected || ! is_pinned || ( reported_entry_size != (LARGE_ENTRY_SIZE / 4) ) ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected status 4."); + HDsnprintf(msg, (size_t)128, "Unexpected status 10."); failure_mssg = msg; } else if ( ( ! entry_ptr->loaded ) || @@ -13817,7 +14846,7 @@ check_resize_entry(void) ( entry_ptr->destroyed ) ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected entry history 4."); + HDsnprintf(msg, (size_t)128, "Unexpected entry history 10."); failure_mssg = msg; } @@ -13832,7 +14861,7 @@ check_resize_entry(void) pass = FALSE; HDsnprintf(msg, (size_t)128, - "H5C_resize_pinned_entry() reports failure 2."); + "H5C_resize_pinned_entry() reports failure 4."); failure_mssg = msg; } @@ -13840,13 +14869,13 @@ check_resize_entry(void) if ( pass ) { - if ( ( cache_ptr->index_len != 1 ) || - ( cache_ptr->index_size != LARGE_ENTRY_SIZE ) || - ( cache_ptr->slist_len != 1 ) || - ( cache_ptr->slist_size != LARGE_ENTRY_SIZE ) ) { + if ( ( cache_ptr->index_len != 4 ) || + ( cache_ptr->index_size != (4 * LARGE_ENTRY_SIZE) ) || + ( cache_ptr->slist_len != 2 ) || + ( cache_ptr->slist_size != (2 * LARGE_ENTRY_SIZE) ) ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected cache status 6."); + HDsnprintf(msg, (size_t)128, "Unexpected cache status 14."); failure_mssg = msg; } @@ -13862,14 +14891,14 @@ check_resize_entry(void) pass = FALSE; HDsnprintf(msg, (size_t)128, - "H5AC_get_entry_status() reports failure 5."); + "H5AC_get_entry_status() reports failure 11."); failure_mssg = msg; } else if ( !in_cache || !is_dirty || is_protected || ! is_pinned || ( reported_entry_size != LARGE_ENTRY_SIZE ) ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected status 5."); + HDsnprintf(msg, (size_t)128, "Unexpected status 11."); failure_mssg = msg; } else if ( ( ! entry_ptr->loaded ) || @@ -13878,15 +14907,15 @@ check_resize_entry(void) ( entry_ptr->destroyed ) ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected entry history 5."); + HDsnprintf(msg, (size_t)128, "Unexpected entry history 11."); failure_mssg = msg; } } - protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 0); + protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 3); - unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 0, FALSE, + unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 3, FALSE, H5C__UNPIN_ENTRY_FLAG | H5C__DELETED_FLAG); if ( pass ) { @@ -13899,13 +14928,13 @@ check_resize_entry(void) pass = FALSE; HDsnprintf(msg, (size_t)128, - "H5AC_get_entry_status() reports failure 6."); + "H5AC_get_entry_status() reports failure 12."); failure_mssg = msg; } else if ( in_cache ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected status 6."); + HDsnprintf(msg, (size_t)128, "Unexpected status 12."); failure_mssg = msg; } else if ( ( ! entry_ptr->loaded ) || @@ -13913,472 +14942,758 @@ check_resize_entry(void) ( entry_ptr->flushed ) || ( ! entry_ptr->destroyed ) ) { - pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected entry history 6."); - failure_mssg = msg; + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected entry history 12."); + failure_mssg = msg; + + } + } + + if ( pass ) { + + if ( ( cache_ptr->index_len != 3 ) || + ( cache_ptr->index_size != (3 * LARGE_ENTRY_SIZE) ) || + ( cache_ptr->slist_len != 1 ) || + ( cache_ptr->slist_size != LARGE_ENTRY_SIZE ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected cache status 15."); + failure_mssg = msg; + + } + } + + protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 2); + unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 2, FALSE, H5C__DELETED_FLAG); + + protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 1); + unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 1, FALSE, H5C__DELETED_FLAG); + + protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 0); + unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 0, FALSE, H5C__DELETED_FLAG); + + + if ( pass ) { + + if ( ( cache_ptr->index_len != 0 ) || + ( cache_ptr->index_size != 0 ) || + ( cache_ptr->slist_len != 0 ) || + ( cache_ptr->slist_size != 0 ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected cache status 16."); + failure_mssg = msg; + + } + } + + if ( pass ) { + + takedown_cache(cache_ptr, FALSE, FALSE); + } + + if ( pass ) { PASSED(); } else { H5_FAILED(); } + + if ( ! pass ) { + + HDfprintf(stdout, "%s(): failure_mssg = \"%s\".\n", + fcn_name, failure_mssg); + } + + return; + +} /* check_resize_entry() */ + + +/*------------------------------------------------------------------------- + * Function: check_evictions_enabled() + * + * Purpose: Verify that H5C_get_evictions_enabled() and + * H5C_set_evictions_enabled() functions perform as expected. + * + * Return: void + * + * Programmer: John Mainzer + * 8/2/07 + * + * Modifications: + * + * None. + * + *------------------------------------------------------------------------- + */ + +static void +check_evictions_enabled(void) +{ + const char * fcn_name = "check_evictions_enabled"; + static char msg[128]; + herr_t result; + hbool_t show_progress = FALSE; + hbool_t evictions_enabled; + hbool_t in_cache; + int i; + int mile_stone = 1; + size_t entry_size; + H5C_t * cache_ptr = NULL; + test_entry_t * base_addr; + test_entry_t * entry_ptr; + + TESTING("evictions enabled/disabled functionality"); + + /* Setup a cache and verify that it is empty. + * + * Use H5C_get_evictions_enabled() to determine if evictions are + * currently enabled -- they should be. + * + * Load entries until the cache is full. Load one more. Verify that + * this caused an entry to be evicted. + * + * Insert an entry. Verify that this cases and entry to be evicted. + * + * Used H5C_set_evictions_enabled() to disable evictions. Verify + * with a call to H5C_get_evictions_enabled(). + * + * Load another entry -- verify that this does not cause an entry + * to be evicted. + * + * Insert an entry -- verify that this does not cause an entry to + * be evicted. + * + * Use H5C_set_evictions_enabled() to re-enable evictions. Verify + * with a call to H5C_get_evictions_enabled(). + * + * Protect and unprotect some of the entries in the cache. Verify + * that there are no evictions (since we only try to make space + * when we either insert or load a new entry). + * + * Protect an entry not in the cache. Verify that this causes + * two evictions. + * + * Used H5C_set_evictions_enabled() to disable evictions again. + * Verify with a call to H5C_get_evictions_enabled(). + * + * Now flush and discard the cache -- should succeed. + */ + + pass = TRUE; + + if ( show_progress ) /* 1 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); + + /* create the cache */ + if ( pass ) { + + reset_entries(); - } + cache_ptr = setup_cache((size_t)(1 * 1024 * 1024), + (size_t)( 512 * 1024)); + + base_addr = entries[MONSTER_ENTRY_TYPE]; + entry_size = MONSTER_ENTRY_SIZE; } + if ( show_progress ) /* 2 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); + + /* verivy that it is empty */ if ( pass ) { if ( ( cache_ptr->index_len != 0 ) || ( cache_ptr->index_size != 0 ) || ( cache_ptr->slist_len != 0 ) || - ( cache_ptr->slist_size != 0 ) ) { + ( cache_ptr->slist_size != 0 ) || + ( cache_ptr->evictions_enabled != TRUE ) ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected cache status 7."); + HDsnprintf(msg, (size_t)128, "Unexpected cache status 1."); failure_mssg = msg; } } + if ( show_progress ) /* 3 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); - /* now repreat the above tests with several entries in the cache: */ - + /* verify that H5C_get_evictions_enabled() returns the expected value */ if ( pass ) { - if ( ( cache_ptr->index_len != 0 ) || - ( cache_ptr->index_size != 0 ) || - ( cache_ptr->slist_len != 0 ) || - ( cache_ptr->slist_size != 0 ) ) { + result = H5C_get_evictions_enabled(cache_ptr, &evictions_enabled); + + if ( ( result != SUCCEED ) || ( evictions_enabled != TRUE ) ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected cache status 8."); + HDsnprintf(msg, (size_t)128, "Unexpected evictions enabled 1."); failure_mssg = msg; - } - base_addr = entries[LARGE_ENTRY_TYPE]; - entry_ptr = &(base_addr[3]); - entry_size = LARGE_ENTRY_SIZE; } - protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 0); - unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 0, FALSE, H5C__NO_FLAGS_SET); + if ( show_progress ) /* 4 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); - protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 1); - unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 1, TRUE, H5C__NO_FLAGS_SET); + /* fill the cache */ + for ( i = 0; i < 16 ; i++ ) + { + protect_entry(cache_ptr, MONSTER_ENTRY_TYPE, i); + unprotect_entry(cache_ptr, MONSTER_ENTRY_TYPE, i, + FALSE, H5C__NO_FLAGS_SET); + } - protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 2); - unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 2, FALSE, H5C__NO_FLAGS_SET); + if ( show_progress ) /* 5 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); + /* verify that the cache is full */ if ( pass ) { - if ( ( cache_ptr->index_len != 3 ) || - ( cache_ptr->index_size != 3 * LARGE_ENTRY_SIZE ) || - ( cache_ptr->slist_len != 1 ) || - ( cache_ptr->slist_size != LARGE_ENTRY_SIZE ) ) { + if ( ( cache_ptr->index_len != 16 ) || + ( cache_ptr->index_size != 16 * MONSTER_ENTRY_SIZE ) || + ( cache_ptr->slist_len != 0 ) || + ( cache_ptr->slist_size != 0 ) || + ( cache_ptr->evictions_enabled != TRUE ) ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected cache status 9."); + HDsnprintf(msg, (size_t)128, "Unexpected cache status 2."); failure_mssg = msg; } } - protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 3); + if ( show_progress ) /* 6 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); - if ( pass ) { + /* protect and unprotect another entry */ + protect_entry(cache_ptr, MONSTER_ENTRY_TYPE, 16); + unprotect_entry(cache_ptr, MONSTER_ENTRY_TYPE, 16, + FALSE, H5C__NO_FLAGS_SET); - if ( ( cache_ptr->index_len != 4 ) || - ( cache_ptr->index_size != 4 * LARGE_ENTRY_SIZE ) || - ( cache_ptr->slist_len != 1 ) || - ( cache_ptr->slist_size != LARGE_ENTRY_SIZE ) ) { + if ( show_progress ) /* 7 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); + + /* verify that the an entry has been evicted */ + if ( pass ) { + if ( ( cache_ptr->index_len != 16 ) || + ( cache_ptr->index_size != 16 * MONSTER_ENTRY_SIZE ) || + ( cache_ptr->slist_len != 0 ) || + ( cache_ptr->slist_size != 0 ) || + ( cache_ptr->evictions_enabled != TRUE ) ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected cache status 10."); + HDsnprintf(msg, (size_t)128, "Unexpected cache status 3."); failure_mssg = msg; } } + if ( show_progress ) /* 8 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); + if ( pass ) { + entry_ptr = &(base_addr[0]); + result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, - &reported_entry_size, &in_cache, - &is_dirty, &is_protected, &is_pinned); + NULL, &in_cache, NULL, NULL, NULL); if ( result < 0 ) { pass = FALSE; HDsnprintf(msg, (size_t)128, - "H5AC_get_entry_status() reports failure 7."); + "H5AC_get_entry_status() reports failure 1."); failure_mssg = msg; - } else if ( !in_cache || is_dirty || !is_protected || is_pinned ) { + } else if ( in_cache ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected status 7."); + HDsnprintf(msg, (size_t)128, "Unexpected status 1."); failure_mssg = msg; } else if ( ( ! entry_ptr->loaded ) || ( entry_ptr->cleared ) || - ( entry_ptr->flushed ) || - ( entry_ptr->destroyed ) ) { + ( ! entry_ptr->flushed ) || + ( ! entry_ptr->destroyed ) ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected entry history 7."); + HDsnprintf(msg, (size_t)128, "Unexpected entry history 1."); failure_mssg = msg; } } - if ( pass ) { - - result = H5C_unprotect(NULL, -1, -1, cache_ptr, - &(types[LARGE_ENTRY_TYPE]), entry_ptr->addr, - (void *)entry_ptr, - H5C__SIZE_CHANGED_FLAG | H5C__DIRTIED_FLAG, - (LARGE_ENTRY_SIZE / 2)); - - if ( result < 0 ) { - - pass = FALSE; - HDsnprintf(msg, (size_t)128, "H5C_unprotect() reports failure 3."); - failure_mssg = msg; + if ( show_progress ) /* 9 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); - } else { + /* insert an entry */ + insert_entry(cache_ptr, MONSTER_ENTRY_TYPE, 17, TRUE, H5C__NO_FLAGS_SET); - /* tidy up so we play nice with the standard protect / unprotect - * calls. - */ - entry_ptr->is_protected = FALSE; - entry_ptr->is_dirty = TRUE; - entry_ptr->size = LARGE_ENTRY_SIZE / 2; - } - } + if ( show_progress ) /* 10 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); + /* verify that another entry has been evicted */ if ( pass ) { - if ( ( cache_ptr->index_len != 4 ) || - ( cache_ptr->index_size != - ((3 * LARGE_ENTRY_SIZE) + (LARGE_ENTRY_SIZE / 2)) ) || - ( cache_ptr->slist_len != 2 ) || - ( cache_ptr->slist_size != - (LARGE_ENTRY_SIZE + (LARGE_ENTRY_SIZE / 2)) ) ) { + if ( ( cache_ptr->index_len != 16 ) || + ( cache_ptr->index_size != 16 * MONSTER_ENTRY_SIZE ) || + ( cache_ptr->slist_len != 1 ) || + ( cache_ptr->slist_size != MONSTER_ENTRY_SIZE ) || + ( cache_ptr->evictions_enabled != TRUE ) ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected cache status 11."); + HDsnprintf(msg, (size_t)128, "Unexpected cache status 4."); failure_mssg = msg; } } + if ( show_progress ) /* 11 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); + if ( pass ) { + entry_ptr = &(base_addr[1]); + result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, - &reported_entry_size, &in_cache, - &is_dirty, &is_protected, &is_pinned); + NULL, &in_cache, NULL, NULL, NULL); if ( result < 0 ) { pass = FALSE; HDsnprintf(msg, (size_t)128, - "H5AC_get_entry_status() reports failure 8."); + "H5AC_get_entry_status() reports failure 2."); failure_mssg = msg; - } else if ( !in_cache || !is_dirty || is_protected || is_pinned || - ( reported_entry_size != (LARGE_ENTRY_SIZE / 2) ) ) { + } else if ( in_cache ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected status 8."); + HDsnprintf(msg, (size_t)128, "Unexpected status 2."); failure_mssg = msg; } else if ( ( ! entry_ptr->loaded ) || ( entry_ptr->cleared ) || - ( entry_ptr->flushed ) || - ( entry_ptr->destroyed ) ) { + ( ! entry_ptr->flushed ) || + ( ! entry_ptr->destroyed ) ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected entry history 8."); + HDsnprintf(msg, (size_t)128, "Unexpected entry history 2."); failure_mssg = msg; } } - protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 3); + if ( show_progress ) /* 12 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); + /* disable evictions */ if ( pass ) { - result = H5C_unprotect(NULL, -1, -1, cache_ptr, - &(types[LARGE_ENTRY_TYPE]), entry_ptr->addr, - (void *)entry_ptr, - (H5C__DIRTIED_FLAG | H5C__SIZE_CHANGED_FLAG), - LARGE_ENTRY_SIZE); + result = H5C_set_evictions_enabled(cache_ptr, FALSE); - if ( result < 0 ) { + if ( result != SUCCEED ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "H5C_unprotect() reports failure 4."); + HDsnprintf(msg, (size_t)128, "can't disable evictions 1."); failure_mssg = msg; + } + } - } else { + if ( show_progress ) /* 13 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); + + /* verify that evictions are disabled */ + if ( pass ) { + + if ( ( cache_ptr->index_len != 16 ) || + ( cache_ptr->index_size != 16 * MONSTER_ENTRY_SIZE ) || + ( cache_ptr->slist_len != 1 ) || + ( cache_ptr->slist_size != MONSTER_ENTRY_SIZE ) || + ( cache_ptr->evictions_enabled != FALSE ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected cache status 5."); + failure_mssg = msg; - /* tidy up so we play nice with the standard protect / unprotect - * calls. - */ - entry_ptr->is_protected = FALSE; - entry_ptr->is_dirty = TRUE; - entry_ptr->size = LARGE_ENTRY_SIZE; } } + if ( show_progress ) /* 14 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); + + /* protect and unprotect another entry */ + protect_entry(cache_ptr, MONSTER_ENTRY_TYPE, 18); + unprotect_entry(cache_ptr, MONSTER_ENTRY_TYPE, 18, + FALSE, H5C__NO_FLAGS_SET); + + if ( show_progress ) /* 15 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); + + /* verify that no entry has been evicted */ if ( pass ) { - if ( ( cache_ptr->index_len != 4 ) || - ( cache_ptr->index_size != 4 * LARGE_ENTRY_SIZE ) || + if ( ( cache_ptr->index_len != 17 ) || + ( cache_ptr->index_size != 17 * MONSTER_ENTRY_SIZE ) || + ( cache_ptr->slist_len != 1 ) || + ( cache_ptr->slist_size != MONSTER_ENTRY_SIZE ) || + ( cache_ptr->evictions_enabled != FALSE ) ) { + + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected cache status 6."); + failure_mssg = msg; + + } + } + + if ( show_progress ) /* 16 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); + + /* insert another entry */ + insert_entry(cache_ptr, MONSTER_ENTRY_TYPE, 19, TRUE, H5C__NO_FLAGS_SET); + + if ( show_progress ) /* 17 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); + + /* verify that no entry has been evicted */ + if ( pass ) { + + if ( ( cache_ptr->index_len != 18 ) || + ( cache_ptr->index_size != 18 * MONSTER_ENTRY_SIZE ) || ( cache_ptr->slist_len != 2 ) || - ( cache_ptr->slist_size != 2 * LARGE_ENTRY_SIZE ) ) { + ( cache_ptr->slist_size != 2 * MONSTER_ENTRY_SIZE ) || + ( cache_ptr->evictions_enabled != FALSE ) ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected cache status 12."); + HDsnprintf(msg, (size_t)128, "Unexpected cache status 7."); failure_mssg = msg; } } + if ( show_progress ) /* 18 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); + + /* re-enable evictions */ if ( pass ) { - result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, - &reported_entry_size, &in_cache, - &is_dirty, &is_protected, &is_pinned); + result = H5C_set_evictions_enabled(cache_ptr, TRUE); - if ( result < 0 ) { + if ( result != SUCCEED ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5AC_get_entry_status() reports failure 9."); + HDsnprintf(msg, (size_t)128, "can't enable evictions 1."); failure_mssg = msg; + } + } - } else if ( !in_cache || !is_dirty || is_protected || is_pinned || - ( reported_entry_size != LARGE_ENTRY_SIZE ) ) { + if ( show_progress ) /* 19 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); + + /* protect and unprotect an entry that is in the cache */ + protect_entry(cache_ptr, MONSTER_ENTRY_TYPE, 19); + unprotect_entry(cache_ptr, MONSTER_ENTRY_TYPE, 19, + FALSE, H5C__NO_FLAGS_SET); + + if ( show_progress ) /* 20 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); + + /* verify that no entries have been evicted */ + if ( pass ) { + + if ( ( cache_ptr->index_len != 18 ) || + ( cache_ptr->index_size != 18 * MONSTER_ENTRY_SIZE ) || + ( cache_ptr->slist_len != 2 ) || + ( cache_ptr->slist_size != 2 * MONSTER_ENTRY_SIZE ) || + ( cache_ptr->evictions_enabled != TRUE ) ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected status 9."); + HDsnprintf(msg, (size_t)128, "Unexpected cache status 8."); failure_mssg = msg; - } else if ( ( ! entry_ptr->loaded ) || - ( entry_ptr->cleared ) || - ( entry_ptr->flushed ) || - ( entry_ptr->destroyed ) ) { + } + } + + if ( show_progress ) /* 21 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); + + /* protect and unprotect an entry that isn't in the cache */ + protect_entry(cache_ptr, MONSTER_ENTRY_TYPE, 20); + unprotect_entry(cache_ptr, MONSTER_ENTRY_TYPE, 20, + FALSE, H5C__NO_FLAGS_SET); + + if ( show_progress ) /* 22 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); + + /* verify that the entries have been evicted to bring the + * cache back down to its normal size. + */ + + if ( pass ) { + + if ( ( cache_ptr->index_len != 16 ) || + ( cache_ptr->index_size != 16 * MONSTER_ENTRY_SIZE ) || + ( cache_ptr->slist_len != 2 ) || + ( cache_ptr->slist_size != 2 * MONSTER_ENTRY_SIZE ) || + ( cache_ptr->evictions_enabled != TRUE ) ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected entry history 9."); + HDsnprintf(msg, (size_t)128, "Unexpected cache status 9."); failure_mssg = msg; } } - protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 3); - - unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 3, FALSE, H5C__PIN_ENTRY_FLAG); + if ( show_progress ) /* 23 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); if ( pass ) { - result = H5C_resize_pinned_entry(cache_ptr, (void *)entry_ptr, - (LARGE_ENTRY_SIZE / 4)); + entry_ptr = &(base_addr[2]); + + result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, + NULL, &in_cache, NULL, NULL, NULL); if ( result < 0 ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5C_resize_pinned_entry() reports failure 3."); + HDsnprintf(msg, (size_t)128, + "H5AC_get_entry_status() reports failure 3."); failure_mssg = msg; - } - } + } else if ( in_cache ) { - if ( pass ) { + pass = FALSE; + HDsnprintf(msg, (size_t)128, "Unexpected status 3."); + failure_mssg = msg; - if ( ( cache_ptr->index_len != 4 ) || - ( cache_ptr->index_size != - ((3 * LARGE_ENTRY_SIZE) + (LARGE_ENTRY_SIZE / 4)) ) || - ( cache_ptr->slist_len != 2 ) || - ( cache_ptr->slist_size != - (LARGE_ENTRY_SIZE + (LARGE_ENTRY_SIZE / 4)) ) ) { + } else if ( ( ! entry_ptr->loaded ) || + ( entry_ptr->cleared ) || + ( ! entry_ptr->flushed ) || + ( ! entry_ptr->destroyed ) ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected cache status 13."); + HDsnprintf(msg, (size_t)128, "Unexpected entry history 3."); failure_mssg = msg; } } + if ( show_progress ) /* 24 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); + if ( pass ) { + entry_ptr = &(base_addr[3]); + result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, - &reported_entry_size, &in_cache, - &is_dirty, &is_protected, &is_pinned); + NULL, &in_cache, NULL, NULL, NULL); if ( result < 0 ) { pass = FALSE; HDsnprintf(msg, (size_t)128, - "H5AC_get_entry_status() reports failure 10."); + "H5AC_get_entry_status() reports failure 4."); failure_mssg = msg; - } else if ( !in_cache || !is_dirty || is_protected || ! is_pinned || - ( reported_entry_size != (LARGE_ENTRY_SIZE / 4) ) ) { + } else if ( in_cache ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected status 10."); + HDsnprintf(msg, (size_t)128, "Unexpected status 4."); failure_mssg = msg; } else if ( ( ! entry_ptr->loaded ) || ( entry_ptr->cleared ) || - ( entry_ptr->flushed ) || - ( entry_ptr->destroyed ) ) { + ( ! entry_ptr->flushed ) || + ( ! entry_ptr->destroyed ) ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected entry history 10."); + HDsnprintf(msg, (size_t)128, "Unexpected entry history 4."); failure_mssg = msg; } } + if ( show_progress ) /* 25 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); + + /* disable evictions again */ if ( pass ) { - result = H5C_resize_pinned_entry(cache_ptr, (void *)entry_ptr, - LARGE_ENTRY_SIZE); + result = H5C_set_evictions_enabled(cache_ptr, FALSE); - if ( result < 0 ) { + if ( result != SUCCEED ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5C_resize_pinned_entry() reports failure 4."); + HDsnprintf(msg, (size_t)128, "can't disable evictions 2."); failure_mssg = msg; - - } + } } + if ( show_progress ) /* 26 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); + + /* protect and unprotect an entry that isn't in the cache, forcing + * the cache to grow. + */ + protect_entry(cache_ptr, MONSTER_ENTRY_TYPE, 21); + unprotect_entry(cache_ptr, MONSTER_ENTRY_TYPE, 21, + FALSE, H5C__NO_FLAGS_SET); + + + if ( show_progress ) /* 27 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); + + /* verify that the cache has grown */ if ( pass ) { - if ( ( cache_ptr->index_len != 4 ) || - ( cache_ptr->index_size != (4 * LARGE_ENTRY_SIZE) ) || + if ( ( cache_ptr->index_len != 17 ) || + ( cache_ptr->index_size != 17 * MONSTER_ENTRY_SIZE ) || ( cache_ptr->slist_len != 2 ) || - ( cache_ptr->slist_size != (2 * LARGE_ENTRY_SIZE) ) ) { + ( cache_ptr->slist_size != 2 * MONSTER_ENTRY_SIZE ) || + ( cache_ptr->evictions_enabled != FALSE ) ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected cache status 14."); + HDsnprintf(msg, (size_t)128, "Unexpected cache status 10."); failure_mssg = msg; } } + if ( show_progress ) /* 28 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); + + /* re-enable evictions again */ if ( pass ) { - result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, - &reported_entry_size, &in_cache, - &is_dirty, &is_protected, &is_pinned); + result = H5C_set_evictions_enabled(cache_ptr, TRUE); - if ( result < 0 ) { + if ( result != SUCCEED ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, - "H5AC_get_entry_status() reports failure 11."); + HDsnprintf(msg, (size_t)128, "can't enable evictions 2."); failure_mssg = msg; + } + } - } else if ( !in_cache || !is_dirty || is_protected || ! is_pinned || - ( reported_entry_size != LARGE_ENTRY_SIZE ) ) { + if ( show_progress ) /* 29 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); - pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected status 11."); - failure_mssg = msg; + /* insert an entry */ + insert_entry(cache_ptr, MONSTER_ENTRY_TYPE, 22, TRUE, H5C__NO_FLAGS_SET); - } else if ( ( ! entry_ptr->loaded ) || - ( entry_ptr->cleared ) || - ( entry_ptr->flushed ) || - ( entry_ptr->destroyed ) ) { + if ( show_progress ) /* 30 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); + + /* verify that the cache has returned to its maximum size */ + if ( pass ) { + + if ( ( cache_ptr->index_len != 16 ) || + ( cache_ptr->index_size != 16 * MONSTER_ENTRY_SIZE ) || + ( cache_ptr->slist_len != 3 ) || + ( cache_ptr->slist_size != 3 * MONSTER_ENTRY_SIZE ) || + ( cache_ptr->evictions_enabled != TRUE ) ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected entry history 11."); + HDsnprintf(msg, (size_t)128, "Unexpected cache status 11."); failure_mssg = msg; } } - protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 3); - - unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 3, FALSE, - H5C__UNPIN_ENTRY_FLAG | H5C__DELETED_FLAG); + if ( show_progress ) /* 31 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); if ( pass ) { - result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, &entry_size, - &in_cache, &is_dirty, &is_protected, - &is_pinned); + entry_ptr = &(base_addr[4]); + + result = H5C_get_entry_status(cache_ptr, entry_ptr->addr, + NULL, &in_cache, NULL, NULL, NULL); if ( result < 0 ) { pass = FALSE; HDsnprintf(msg, (size_t)128, - "H5AC_get_entry_status() reports failure 12."); + "H5AC_get_entry_status() reports failure 5."); failure_mssg = msg; } else if ( in_cache ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected status 12."); + HDsnprintf(msg, (size_t)128, "Unexpected status 5."); failure_mssg = msg; } else if ( ( ! entry_ptr->loaded ) || - ( ! entry_ptr->cleared ) || - ( entry_ptr->flushed ) || + ( entry_ptr->cleared ) || + ( ! entry_ptr->flushed ) || ( ! entry_ptr->destroyed ) ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected entry history 12."); - failure_mssg = msg; - - } - } - - if ( pass ) { - - if ( ( cache_ptr->index_len != 3 ) || - ( cache_ptr->index_size != (3 * LARGE_ENTRY_SIZE) ) || - ( cache_ptr->slist_len != 1 ) || - ( cache_ptr->slist_size != LARGE_ENTRY_SIZE ) ) { - - pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected cache status 15."); + HDsnprintf(msg, (size_t)128, "Unexpected entry history 5."); failure_mssg = msg; } } - protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 2); - unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 2, FALSE, H5C__DELETED_FLAG); - - protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 1); - unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 1, FALSE, H5C__DELETED_FLAG); - - protect_entry(cache_ptr, LARGE_ENTRY_TYPE, 0); - unprotect_entry(cache_ptr, LARGE_ENTRY_TYPE, 0, FALSE, H5C__DELETED_FLAG); - + if ( show_progress ) /* 32 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); + /* disable evictions one last time before we shut down */ if ( pass ) { - if ( ( cache_ptr->index_len != 0 ) || - ( cache_ptr->index_size != 0 ) || - ( cache_ptr->slist_len != 0 ) || - ( cache_ptr->slist_size != 0 ) ) { + result = H5C_set_evictions_enabled(cache_ptr, FALSE); + + if ( result != SUCCEED ) { pass = FALSE; - HDsnprintf(msg, (size_t)128, "Unexpected cache status 16."); + HDsnprintf(msg, (size_t)128, "can't disable evictions 3."); failure_mssg = msg; - } } + if ( show_progress ) /* 33 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); + if ( pass ) { takedown_cache(cache_ptr, FALSE, FALSE); } + if ( show_progress ) /* 34 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + fcn_name, mile_stone++, (int)pass); + if ( pass ) { PASSED(); } else { H5_FAILED(); } if ( ! pass ) { @@ -14389,7 +15704,7 @@ check_resize_entry(void) return; -} /* check_resize_entry() */ +} /* check_evictions_enabled() */ /*------------------------------------------------------------------------- @@ -15829,6 +17144,143 @@ check_protect_ro_rw_err(void) /*------------------------------------------------------------------------- + * Function: check_evictions_enabled_err() + * + * Purpose: Verify that H5C_get_evictions_enabled() and + * H5C_set_evictions_enabled() generate errors as expected. + * + * Return: void + * + * Programmer: John Mainzer + * 8/3/07 + * + * Modifications: + * + * None. + * + *------------------------------------------------------------------------- + */ + +static void +check_check_evictions_enabled_err(void) +{ + const char * fcn_name = "check_evictions_enabled_err()"; + herr_t result; + hbool_t evictions_enabled; + H5C_t * cache_ptr = NULL; + + TESTING("get/set evictions enabled errors"); + + pass = TRUE; + + /* allocate a cache. + * + * Call H5C_get_evictions_enabled(), passing it a NULL cache_ptr, + * should fail. + * + * Repeat with a NULL evictions_enabled_ptr, should fail as well. + * + * Configure the cache to use auto cache resize. Call + * H5C_set_evictions_enabled() to disable evictions. Should fail. + * + * Unprotect the entry and destroy the cache -- should succeed. + */ + + if ( pass ) { + + reset_entries(); + + cache_ptr = setup_cache((size_t)(2 * 1024), + (size_t)(1 * 1024)); + } + + if ( pass ) { + + result = H5C_get_evictions_enabled(NULL, &evictions_enabled); + + if ( result == SUCCEED ) { + + pass = FALSE; + failure_mssg = "H5C_get_evictions_enabled succeeded() 1.\n"; + } + } + + if ( pass ) { + + result = H5C_get_evictions_enabled(cache_ptr, NULL); + + if ( result == SUCCEED ) { + + pass = FALSE; + failure_mssg = "H5C_get_evictions_enabled succeeded() 2.\n"; + } + } + + if ( pass ) { + + result = H5C_set_evictions_enabled(cache_ptr, TRUE); + + if ( result != SUCCEED ) { + + pass = FALSE; + failure_mssg = "H5C_set_evictions_enabled failed().\n"; + + } + } + + if ( pass ) { + + (cache_ptr->resize_ctl).incr_mode = H5C_incr__threshold; + + result = H5C_get_evictions_enabled(cache_ptr, FALSE); + + if ( result == SUCCEED ) { + + pass = FALSE; + failure_mssg = "H5C_set_evictions_enabled succeeded() 1.\n"; + + } else if ( cache_ptr->evictions_enabled == TRUE ) { + + } + + (cache_ptr->resize_ctl).incr_mode = H5C_incr__off; + } + + if ( pass ) { + + (cache_ptr->resize_ctl).decr_mode = H5C_decr__threshold; + + result = H5C_get_evictions_enabled(cache_ptr, FALSE); + + if ( result == SUCCEED ) { + + pass = FALSE; + failure_mssg = "H5C_set_evictions_enabled succeeded() 2.\n"; + } + + (cache_ptr->resize_ctl).decr_mode = H5C_decr__off; + } + + + if ( pass ) { + + takedown_cache(cache_ptr, FALSE, FALSE); + } + + if ( pass ) { PASSED(); } else { H5_FAILED(); } + + if ( ! pass ) { + + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", + fcn_name, failure_mssg); + } + + return; + +} /* check_evictions_enabled_err() */ + + +/*------------------------------------------------------------------------- * Function: check_auto_cache_resize() * * Purpose: Exercise the automatic cache resizing functionality. @@ -24823,6 +26275,8 @@ main(void) smoke_check_6(); smoke_check_7(); smoke_check_8(); + smoke_check_9(); + smoke_check_10(); #endif write_permitted_check(); @@ -24834,6 +26288,7 @@ main(void) check_rename_entry(); check_pin_protected_entry(); check_resize_entry(); + check_evictions_enabled(); check_flush_protected_err(); check_destroy_pinned_err(); check_destroy_protected_err(); @@ -24849,6 +26304,7 @@ main(void) check_resize_entry_errs(); check_unprotect_ro_dirty_err(); check_protect_ro_rw_err(); + check_check_evictions_enabled_err(); check_auto_cache_resize(); check_auto_cache_resize_disable(); check_auto_cache_resize_epoch_markers(); diff --git a/test/cache_api.c b/test/cache_api.c index fe42d0d..1b9a37e 100644 --- a/test/cache_api.c +++ b/test/cache_api.c @@ -118,29 +118,34 @@ static void check_file_mdc_api_errs(void); *------------------------------------------------------------------------- */ -#define CACHE_CONFIGS_EQUAL(a, b, cmp_set_init, cmp_init_size) \ - ( ( (a).version == (b).version ) && \ - ( (a).rpt_fcn_enabled == (b).rpt_fcn_enabled ) && \ - ( ( ! cmp_set_init ) || \ - ( (a).set_initial_size == (b).set_initial_size ) ) && \ - ( ( ! cmp_init_size ) || \ - ( (a).initial_size == (b).initial_size ) ) && \ - ( (a).min_clean_fraction == (b).min_clean_fraction ) && \ - ( (a).max_size == (b).max_size ) && \ - ( (a).min_size == (b).min_size ) && \ - ( (a).epoch_length == (b).epoch_length ) && \ - ( (a).incr_mode == (b).incr_mode ) && \ - ( (a).lower_hr_threshold == (b).lower_hr_threshold ) && \ - ( (a).increment == (b).increment ) && \ - ( (a).apply_max_increment == (b).apply_max_increment ) && \ - ( (a).max_increment == (b).max_increment ) && \ - ( (a).decr_mode == (b).decr_mode ) && \ - ( (a).upper_hr_threshold == (b).upper_hr_threshold ) && \ - ( (a).decrement == (b).decrement ) && \ - ( (a).apply_max_decrement == (b).apply_max_decrement ) && \ - ( (a).max_decrement == (b).max_decrement ) && \ - ( (a).epochs_before_eviction == (b).epochs_before_eviction ) && \ - ( (a).apply_empty_reserve == (b).apply_empty_reserve ) && \ +#define CACHE_CONFIGS_EQUAL(a, b, cmp_set_init, cmp_init_size) \ + ( ( (a).version == (b).version ) && \ + ( (a).rpt_fcn_enabled == (b).rpt_fcn_enabled ) && \ + ( (a).open_trace_file == (b).open_trace_file ) && \ + ( (a).close_trace_file == (b).close_trace_file ) && \ + ( ( (a).open_trace_file == FALSE ) || \ + ( strcmp((a).trace_file_name, (b).trace_file_name) == 0 ) ) && \ + ( (a).evictions_enabled == (b).evictions_enabled ) && \ + ( ( ! cmp_set_init ) || \ + ( (a).set_initial_size == (b).set_initial_size ) ) && \ + ( ( ! cmp_init_size ) || \ + ( (a).initial_size == (b).initial_size ) ) && \ + ( (a).min_clean_fraction == (b).min_clean_fraction ) && \ + ( (a).max_size == (b).max_size ) && \ + ( (a).min_size == (b).min_size ) && \ + ( (a).epoch_length == (b).epoch_length ) && \ + ( (a).incr_mode == (b).incr_mode ) && \ + ( (a).lower_hr_threshold == (b).lower_hr_threshold ) && \ + ( (a).increment == (b).increment ) && \ + ( (a).apply_max_increment == (b).apply_max_increment ) && \ + ( (a).max_increment == (b).max_increment ) && \ + ( (a).decr_mode == (b).decr_mode ) && \ + ( (a).upper_hr_threshold == (b).upper_hr_threshold ) && \ + ( (a).decrement == (b).decrement ) && \ + ( (a).apply_max_decrement == (b).apply_max_decrement ) && \ + ( (a).max_decrement == (b).max_decrement ) && \ + ( (a).epochs_before_eviction == (b).epochs_before_eviction ) && \ + ( (a).apply_empty_reserve == (b).apply_empty_reserve ) && \ ( (a).empty_reserve == (b).empty_reserve ) ) #define XLATE_EXT_TO_INT_MDC_CONFIG(i, e) \ @@ -191,6 +196,7 @@ check_fapl_mdc_api_calls(void) /* hbool_t open_trace_file = */ FALSE, /* hbool_t close_trace_file = */ FALSE, /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024 + 1), /* double min_clean_fraction = */ 0.2, @@ -755,6 +761,7 @@ check_file_mdc_api_calls(void) /* hbool_t open_trace_file = */ FALSE, /* hbool_t close_trace_file = */ FALSE, /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024 + 1), /* double min_clean_fraction = */ 0.2, @@ -783,6 +790,7 @@ check_file_mdc_api_calls(void) /* hbool_t open_trace_file = */ FALSE, /* hbool_t close_trace_file = */ FALSE, /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (512 * 1024), /* double min_clean_fraction = */ 0.1, @@ -811,6 +819,7 @@ check_file_mdc_api_calls(void) /* hbool_t open_trace_file = */ FALSE, /* hbool_t close_trace_file = */ FALSE, /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.2, @@ -839,6 +848,7 @@ check_file_mdc_api_calls(void) /* hbool_t open_trace_file = */ FALSE, /* hbool_t close_trace_file = */ FALSE, /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.15, @@ -1367,6 +1377,7 @@ mdc_api_call_smoke_check(void) /* hbool_t open_trace_file = */ FALSE, /* hbool_t close_trace_file = */ FALSE, /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ 500000, /* double min_clean_fraction = */ 0.1, @@ -1395,6 +1406,7 @@ mdc_api_call_smoke_check(void) /* hbool_t open_trace_file = */ FALSE, /* hbool_t close_trace_file = */ FALSE, /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ 12000000, /* double min_clean_fraction = */ 0.1, @@ -1423,6 +1435,7 @@ mdc_api_call_smoke_check(void) /* hbool_t open_trace_file = */ FALSE, /* hbool_t close_trace_file = */ FALSE, /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ 2000000, /* double min_clean_fraction = */ 0.1, @@ -2079,7 +2092,7 @@ mdc_api_call_smoke_check(void) * used to test error rejection in the MDC related API calls. */ -#define NUM_INVALID_CONFIGS 34 +#define NUM_INVALID_CONFIGS 36 H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = { @@ -2090,6 +2103,7 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* hbool_t open_trace_file = */ FALSE, /* hbool_t close_trace_file = */ FALSE, /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2118,6 +2132,7 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* hbool_t open_trace_file = */ FALSE, /* hbool_t close_trace_file = */ FALSE, /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2146,6 +2161,7 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* hbool_t open_trace_file = */ (hbool_t)-1, /* hbool_t close_trace_file = */ FALSE, /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2174,6 +2190,7 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* hbool_t open_trace_file = */ FALSE, /* hbool_t close_trace_file = */ (hbool_t)-1, /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2202,6 +2219,7 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* hbool_t open_trace_file = */ TRUE, /* hbool_t close_trace_file = */ FALSE, /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2230,6 +2248,7 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* hbool_t open_trace_file = */ FALSE, /* hbool_t close_trace_file = */ FALSE, /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ 2, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2258,6 +2277,7 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* hbool_t open_trace_file = */ FALSE, /* hbool_t close_trace_file = */ FALSE, /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2286,6 +2306,7 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* hbool_t open_trace_file = */ FALSE, /* hbool_t close_trace_file = */ FALSE, /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2314,6 +2335,7 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* hbool_t open_trace_file = */ FALSE, /* hbool_t close_trace_file = */ FALSE, /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ FALSE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2342,6 +2364,7 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* hbool_t open_trace_file = */ FALSE, /* hbool_t close_trace_file = */ FALSE, /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (16 * 1024 * 1024 + 1), /* double min_clean_fraction = */ 0.25, @@ -2370,6 +2393,7 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* hbool_t open_trace_file = */ FALSE, /* hbool_t close_trace_file = */ FALSE, /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024 - 1), /* double min_clean_fraction = */ 0.25, @@ -2398,6 +2422,7 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* hbool_t open_trace_file = */ FALSE, /* hbool_t close_trace_file = */ FALSE, /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 1.000001, @@ -2426,6 +2451,7 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* hbool_t open_trace_file = */ FALSE, /* hbool_t close_trace_file = */ FALSE, /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ -0.00000001, @@ -2454,6 +2480,7 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* hbool_t open_trace_file = */ FALSE, /* hbool_t close_trace_file = */ FALSE, /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2482,6 +2509,7 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* hbool_t open_trace_file = */ FALSE, /* hbool_t close_trace_file = */ FALSE, /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2510,6 +2538,7 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* hbool_t open_trace_file = */ FALSE, /* hbool_t close_trace_file = */ FALSE, /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2538,6 +2567,7 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* hbool_t open_trace_file = */ FALSE, /* hbool_t close_trace_file = */ FALSE, /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2566,6 +2596,7 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* hbool_t open_trace_file = */ FALSE, /* hbool_t close_trace_file = */ FALSE, /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2594,6 +2625,7 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* hbool_t open_trace_file = */ FALSE, /* hbool_t close_trace_file = */ FALSE, /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2622,6 +2654,7 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* hbool_t open_trace_file = */ FALSE, /* hbool_t close_trace_file = */ FALSE, /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2650,6 +2683,7 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* hbool_t open_trace_file = */ FALSE, /* hbool_t close_trace_file = */ FALSE, /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2678,6 +2712,7 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* hbool_t open_trace_file = */ FALSE, /* hbool_t close_trace_file = */ FALSE, /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2706,6 +2741,7 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* hbool_t open_trace_file = */ FALSE, /* hbool_t close_trace_file = */ FALSE, /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2734,6 +2770,7 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* hbool_t open_trace_file = */ FALSE, /* hbool_t close_trace_file = */ FALSE, /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2762,6 +2799,7 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* hbool_t open_trace_file = */ FALSE, /* hbool_t close_trace_file = */ FALSE, /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2790,6 +2828,7 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* hbool_t open_trace_file = */ FALSE, /* hbool_t close_trace_file = */ FALSE, /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2818,6 +2857,7 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* hbool_t open_trace_file = */ FALSE, /* hbool_t close_trace_file = */ FALSE, /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2846,6 +2886,7 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* hbool_t open_trace_file = */ FALSE, /* hbool_t close_trace_file = */ FALSE, /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2874,6 +2915,7 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* hbool_t open_trace_file = */ FALSE, /* hbool_t close_trace_file = */ FALSE, /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2902,6 +2944,7 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* hbool_t open_trace_file = */ FALSE, /* hbool_t close_trace_file = */ FALSE, /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2930,6 +2973,7 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* hbool_t open_trace_file = */ FALSE, /* hbool_t close_trace_file = */ FALSE, /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2958,6 +3002,7 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* hbool_t open_trace_file = */ FALSE, /* hbool_t close_trace_file = */ FALSE, /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -2986,6 +3031,7 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* hbool_t open_trace_file = */ FALSE, /* hbool_t close_trace_file = */ FALSE, /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -3014,6 +3060,7 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* hbool_t open_trace_file = */ FALSE, /* hbool_t close_trace_file = */ FALSE, /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ TRUE, /* hbool_t set_initial_size = */ TRUE, /* size_t initial_size = */ (1 * 1024 * 1024), /* double min_clean_fraction = */ 0.25, @@ -3034,6 +3081,64 @@ H5AC_cache_config_t invalid_configs[NUM_INVALID_CONFIGS] = /* hbool_t apply_empty_reserve = */ TRUE, /* double empty_reserve = */ 0.1, /* int dirty_bytes_threshold = */ (H5C__MAX_MAX_CACHE_SIZE / 4) + 1 + }, + { + /* 34 -- attempt to disable evictions when auto incr enabled */ + /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, + /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ FALSE, + /* hbool_t set_initial_size = */ TRUE, + /* size_t initial_size = */ (1 * 1024 * 1024), + /* double min_clean_fraction = */ 0.25, + /* size_t max_size = */ (16 * 1024 * 1024), + /* size_t min_size = */ ( 1 * 1024 * 1024), + /* long int epoch_length = */ 50000, + /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__threshold, + /* double lower_hr_threshold = */ 0.9, + /* double increment = */ 2.0, + /* hbool_t apply_max_increment = */ TRUE, + /* size_t max_increment = */ (4 * 1024 * 1024), + /* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__off, + /* double upper_hr_threshold = */ 0.9, + /* double decrement = */ 0.9, + /* hbool_t apply_max_decrement = */ TRUE, + /* size_t max_decrement = */ (1 * 1024 * 1024), + /* int epochs_before_eviction = */ 3, + /* hbool_t apply_empty_reserve = */ TRUE, + /* double empty_reserve = */ 0.1, + /* int dirty_bytes_threshold = */ (256 * 1024) + }, + { + /* 35 -- attempt to disable evictions when auto decr enabled */ + /* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER, + /* hbool_t rpt_fcn_enabled = */ FALSE, + /* hbool_t open_trace_file = */ FALSE, + /* hbool_t close_trace_file = */ FALSE, + /* char trace_file_name[] = */ "", + /* hbool_t evictions_enabled = */ FALSE, + /* hbool_t set_initial_size = */ TRUE, + /* size_t initial_size = */ (1 * 1024 * 1024), + /* double min_clean_fraction = */ 0.25, + /* size_t max_size = */ (16 * 1024 * 1024), + /* size_t min_size = */ ( 1 * 1024 * 1024), + /* long int epoch_length = */ 50000, + /* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__threshold, + /* double lower_hr_threshold = */ 0.9, + /* double increment = */ 2.0, + /* hbool_t apply_max_increment = */ TRUE, + /* size_t max_increment = */ (4 * 1024 * 1024), + /* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__age_out, + /* double upper_hr_threshold = */ 0.9, + /* double decrement = */ 0.9, + /* hbool_t apply_max_decrement = */ TRUE, + /* size_t max_decrement = */ (1 * 1024 * 1024), + /* int epochs_before_eviction = */ 3, + /* hbool_t apply_empty_reserve = */ TRUE, + /* double empty_reserve = */ 0.1, + /* int dirty_bytes_threshold = */ (256 * 1024) } }; @@ -3580,7 +3685,7 @@ main(void) #if 1 check_file_mdc_api_calls(); #endif -#if 1 +#if 0 mdc_api_call_smoke_check(); #endif #if 1 diff --git a/testpar/t_cache.c b/testpar/t_cache.c index b659e79..243caa1 100644 --- a/testpar/t_cache.c +++ b/testpar/t_cache.c @@ -5281,28 +5281,28 @@ trace_file_check(void) const char * expected_output[] = { "### HDF5 metadata cache trace file version 1 ###\n", - "H5AC_set_cache_auto_resize_config 1 0 1 0 \"t_cache_trace.txt\" 0 1048576 0.500000 16777216 1048576 50000 1 0.900000 2.000000 1 4194304 3 0.999000 0.900000 1 1048576 3 1 0.100000 262144 0\n", - "H5AC_set 0x0 13 0x0 2 0\n", - "H5AC_set 0x2 13 0x0 2 0\n", - "H5AC_set 0x4 13 0x0 4 0\n", - "H5AC_set 0x8 13 0x0 6 0\n", - "H5AC_protect 0 13 2 1\n", + "H5AC_set_cache_auto_resize_config 1 0 1 0 \"t_cache_trace.txt\" 1 0 1048576 0.500000 16777216 1048576 50000 1 0.900000 2.000000 1 4194304 3 0.999000 0.900000 1 1048576 3 1 0.100000 262144 0\n", + "H5AC_set 0x0 15 0x0 2 0\n", + "H5AC_set 0x2 15 0x0 2 0\n", + "H5AC_set 0x4 15 0x0 4 0\n", + "H5AC_set 0x8 15 0x0 6 0\n", + "H5AC_protect 0 15 H5AC_WRITE 2 1\n", "H5AC_mark_pinned_or_protected_entry_dirty 0 0\n", - "H5AC_protect 0 13 0 0 0\n", - "H5AC_protect 2 13 2 1\n", + "H5AC_unprotect 0 15 0 0 0\n", + "H5AC_protect 2 15 H5AC_WRITE 2 1\n", "H5AC_pin_protected_entry 2 0\n", - "H5AC_protect 2 13 0 0 0\n", + "H5AC_unprotect 2 15 0 0 0\n", "H5AC_unpin_entry 2 0\n", - "H5AC_expunge_entry 2 13 0\n", - "H5AC_protect 4 13 4 1\n", + "H5AC_expunge_entry 2 15 0\n", + "H5AC_protect 4 15 H5AC_WRITE 4 1\n", "H5AC_pin_protected_entry 4 0\n", - "H5AC_protect 4 13 0 0 0\n", + "H5AC_unprotect 4 15 0 0 0\n", "H5AC_mark_pinned_entry_dirty 0x4 0 0 0\n", - "H5AC_resize_pinned_entry 0x4 2 0 0\n", - "H5AC_resize_pinned_entry 0x4 4 0 0\n", + "H5AC_resize_pinned_entry 0x4 2 0\n", + "H5AC_resize_pinned_entry 0x4 4 0\n", "H5AC_unpin_entry 4 0\n", - "H5AC_rename 0 8a65 13 0\n", - "H5AC_rename 8a65 0 13 0\n", + "H5AC_rename 0 8a65 15 0\n", + "H5AC_rename 8a65 0 15 0\n", "H5AC_flush 0x0 0\n", NULL }; -- cgit v0.12