diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/cache.c | 480 | ||||
-rw-r--r-- | test/cache_api.c | 15 | ||||
-rw-r--r-- | test/cache_common.c | 467 | ||||
-rw-r--r-- | test/cache_common.h | 524 | ||||
-rw-r--r-- | test/cork.c | 86 | ||||
-rw-r--r-- | test/dsets.c | 30 | ||||
-rw-r--r-- | test/dtypes.c | 4 | ||||
-rw-r--r-- | test/external_env.c | 3 | ||||
-rw-r--r-- | test/getname.c | 8 | ||||
-rw-r--r-- | test/h5test.c | 3 | ||||
-rw-r--r-- | test/links.c | 385 | ||||
-rw-r--r-- | test/mount.c | 48 | ||||
-rw-r--r-- | test/mtime.c | 10 | ||||
-rw-r--r-- | test/ntypes.c | 2 | ||||
-rw-r--r-- | test/null_vol_connector.c | 148 | ||||
-rw-r--r-- | test/objcopy.c | 47 | ||||
-rw-r--r-- | test/objcopy_ref.c | 15 | ||||
-rw-r--r-- | test/ohdr.c | 11 | ||||
-rw-r--r-- | test/th5s.c | 13 | ||||
-rw-r--r-- | test/titerate.c | 6 | ||||
-rw-r--r-- | test/trefer.c | 40 | ||||
-rw-r--r-- | test/trefer_deprec.c | 2 | ||||
-rw-r--r-- | test/tsohm.c | 8 | ||||
-rw-r--r-- | test/tvltypes.c | 6 | ||||
-rw-r--r-- | test/unlink.c | 4 | ||||
-rw-r--r-- | test/vol.c | 4 |
26 files changed, 1278 insertions, 1091 deletions
diff --git a/test/cache.c b/test/cache.c index 1a726fa..a90f12b 100644 --- a/test/cache.c +++ b/test/cache.c @@ -18,7 +18,48 @@ * H5C.c */ #include "cache_common.h" - +#include "H5MFprivate.h" + + +H5C_t * saved_cache = NULL; /* store the pointer to the instance of + * of H5C_t created by H5Fcreate() + * here between test cache setup and + * shutdown. + */ + +haddr_t saved_actual_base_addr = HADDR_UNDEF; /* Store the address of the + * space allocated for cache items in the file between + * cache setup & takedown + */ + +hid_t saved_fapl_id = H5P_DEFAULT; /* store the fapl id here between + * cache setup and takedown. Note + * that if saved_fapl_id == H5P_DEFAULT, + * we assume that there is no fapl to + * close. + */ + +hid_t saved_fcpl_id = H5P_DEFAULT; /* store the fcpl id here between + * cache setup and takedown. Note + * that if saved_fcpl_id == H5P_DEFAULT, + * we assume that there is no fcpl to + * close. + */ + +hid_t saved_fid = -1; /* store the file id here between cache setup + * and takedown. + */ +hbool_t write_permitted = TRUE; +hbool_t try_core_file_driver = FALSE; +hbool_t core_file_driver_failed = FALSE; + + +/* global variable declarations: */ + +const char *FILENAME[] = { + "cache_test", + NULL +}; /* private typedef declarations: */ @@ -205,6 +246,12 @@ static void check_stats__smoke_check_1(H5F_t * file_ptr); #endif /* H5C_COLLECT_CACHE_STATS */ +static H5F_t *setup_cache(size_t max_cache_size, size_t min_clean_size, unsigned paged); + +static void takedown_cache(H5F_t * file_ptr, + hbool_t dump_stats, + hbool_t dump_detailed_stats); + /**************************************************************************/ /**************************************************************************/ /********************************* tests: *********************************/ @@ -36417,6 +36464,437 @@ check_stats__smoke_check_1(H5F_t * file_ptr) #endif /* H5C_COLLECT_CACHE_STATS */ +/* Call back functions: */ + + +/*------------------------------------------------------------------------- + * + * Function: check_if_write_permitted + * + * Purpose: Determine if a write is permitted under the current + * circumstances, and set *write_permitted_ptr accordingly. + * As a general rule it is, but when we are running in parallel + * mode with collective I/O, we must ensure that a read cannot + * cause a write. + * + * In the event of failure, the value of *write_permitted_ptr + * is undefined. + * + * Return: Non-negative on success/Negative on failure. + * + * Programmer: John Mainzer, 5/15/04 + * + *------------------------------------------------------------------------- + */ +static herr_t +check_write_permitted(const H5F_t H5_ATTR_UNUSED *f, hbool_t *write_permitted_ptr) +{ + HDassert( write_permitted_ptr ); + + *write_permitted_ptr = write_permitted; + + return(SUCCEED); +} /* check_write_permitted() */ + + +/***************************************************************************** + * + * Function: setup_cache() + * + * Purpose: Open an HDF file. This will allocate an instance and + * initialize an associated instance of H5C_t. However, + * we want to test an instance of H5C_t, so allocate and + * initialize one with the file ID returned by the call to + * H5Fcreate(). Return a pointer to this instance of H5C_t. + * + * Observe that we open a HDF file because the cache now + * writes directly to file, and we need the file I/O facilities + * associated with the file. + * + * To avoid tripping on error check code, must allocate enough + * space in the file to hold all the test entries and their + * alternates. This is a little sticky, as the addresses of + * all the test entries are determined at compile time. + * + * Deal with this by choosing BASE_ADDR large enough that + * the base address of the allocate space will be less than + * or equal to BASE_ADDR, and then requesting an extra BASE_ADDR + * bytes, so we don't have to wory about exceeding the allocation. + * + * Return: Success: Ptr to H5C_t + * + * Failure: NULL + * + * Programmer: JRM -- 9/13/07 + * + *****************************************************************************/ + +H5F_t * +setup_cache(size_t max_cache_size, + size_t min_clean_size, + unsigned paged) +{ + char filename[512]; + hbool_t show_progress = FALSE; + hbool_t verbose = TRUE; + int mile_stone = 1; + hid_t fid = -1; + H5F_t * file_ptr = NULL; + H5C_t * cache_ptr = NULL; + H5F_t * ret_val = NULL; + haddr_t actual_base_addr; + hid_t fapl_id = H5P_DEFAULT; + hid_t fcpl_id = H5P_DEFAULT; + + if(show_progress) /* 1 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + FUNC, mile_stone++, (int)pass); + + saved_fid = -1; + + if(pass) { + if((fcpl_id = H5Pcreate(H5P_FILE_CREATE)) == FAIL) { + pass = FALSE; + failure_mssg = "H5Pcreate(H5P_FILE_CREATE) failed.\n"; + } + } + + if(pass && paged) { + /* Set up paged aggregation strategy */ + if(H5Pset_file_space_strategy(fcpl_id, H5F_FSPACE_STRATEGY_PAGE, 1, (hsize_t)1) == FAIL) { + pass = FALSE; + failure_mssg = "H5Pset_file_space_strategy() failed.\n"; + H5Pclose(fcpl_id); + fcpl_id = H5P_DEFAULT; + } + } + + if(pass && paged) { + /* Set up file space page size to BASE_ADDR */ + if(H5Pset_file_space_page_size(fcpl_id, (hsize_t)BASE_ADDR) == FAIL) { + pass = FALSE; + failure_mssg = "H5Pset_file_space_page_size() failed.\n"; + H5Pclose(fcpl_id); + fcpl_id = H5P_DEFAULT; + } + } + + if(pass) + saved_fcpl_id = fcpl_id; + + /* setup the file name */ + if(pass) { + if(NULL == h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof(filename))) { + pass = FALSE; + failure_mssg = "h5_fixname() failed.\n"; + } + } + + if(show_progress) /* 2 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + FUNC, mile_stone++, (int)pass); + + if(pass && try_core_file_driver) { + if((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) == FAIL) { + pass = FALSE; + failure_mssg = "H5Pcreate(H5P_FILE_ACCESS) failed.\n"; + } + else if(H5Pset_fapl_core(fapl_id, MAX_ADDR, FALSE) < 0) { + H5Pclose(fapl_id); + fapl_id = H5P_DEFAULT; + pass = FALSE; + failure_mssg = "H5P_set_fapl_core() failed.\n"; + } + else if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_id, fapl_id)) < 0) { + core_file_driver_failed = TRUE; + + if(verbose) + HDfprintf(stdout, "%s: H5Fcreate() with CFD failed.\n", FUNC); + } else { + saved_fapl_id = fapl_id; + } + } + + if(show_progress) /* 3 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + FUNC, mile_stone++, (int)pass); + + /* if we either aren't using the core file driver, or a create + * with the core file driver failed, try again with a regular file. + * If this fails, we are cooked. + */ + if(pass && fid < 0) { + fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_id, fapl_id); + saved_fid = fid; + + if(fid < 0) { + pass = FALSE; + failure_mssg = "H5Fcreate() failed."; + + if(verbose) + HDfprintf(stdout, "%s: H5Fcreate() failed.\n", FUNC); + } /* end if */ + } /* end if */ + + /* Push API context */ + H5CX_push(); + + if(show_progress) /* 4 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + FUNC, mile_stone++, (int)pass); + + if(pass) { + HDassert(fid >= 0); + saved_fid = fid; + if(H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) { + pass = FALSE; + failure_mssg = "H5Fflush() failed."; + + if(verbose) + HDfprintf(stdout, "%s: H5Fflush() failed.\n", FUNC); + } + else { + file_ptr = (H5F_t *)H5VL_object_verify(fid, H5I_FILE); + if(file_ptr == NULL) { + pass = FALSE; + failure_mssg = "Can't get file_ptr."; + + if(verbose) + HDfprintf(stdout, "%s: H5Fflush() failed.\n", FUNC); + } + } + } + + if(show_progress) /* 5 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + FUNC, mile_stone++, (int)pass); + + if(pass) { + + /* A bit of fancy footwork here: + * + * The call to H5Fcreate() allocates an instance of H5C_t, + * initializes it, and stores its address in f->shared->cache. + * + * We don't want to use this cache, as it has a bunch of extra + * initialization that may change over time, and in any case + * it will not in general be configured the way we want it. + * + * We used to deal with this problem by storing the file pointer + * in another instance of H5C_t, and then ignoring the original + * version. However, this strategy doesn't work any more, as + * we can't store the file pointer in the instance of H5C_t, + * and we have modified many cache routines to use a file + * pointer to look up the target cache. + * + * Thus we now make note of the address of the instance of + * H5C_t created by the call to H5Fcreate(), set + * file_ptr->shared->cache to NULL, call H5C_create() + * to allocate a new instance of H5C_t for test purposes, + * and store than new instance's address in + * file_ptr->shared->cache. + * + * On shut down, we call H5C_dest on our instance of H5C_t, + * set file_ptr->shared->cache to point to the original + * instance, and then close the file normally. + */ + + HDassert(saved_cache == NULL); + saved_cache = file_ptr->shared->cache; + file_ptr->shared->cache = NULL; + + cache_ptr = H5C_create(max_cache_size, + min_clean_size, + (NUMBER_OF_ENTRY_TYPES - 1), + types, + check_write_permitted, + TRUE, + NULL, + NULL); + + file_ptr->shared->cache = cache_ptr; + } + + if(show_progress) /* 6 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + FUNC, mile_stone++, (int)pass); + + if(pass) { + if(cache_ptr == NULL) { + pass = FALSE; + failure_mssg = "H5C_create() failed."; + + if(verbose) + HDfprintf(stdout, "%s: H5C_create() failed.\n", FUNC); + } + else if(cache_ptr->magic != H5C__H5C_T_MAGIC) { + pass = FALSE; + failure_mssg = "Bad cache_ptr magic."; + + if(verbose) + HDfprintf(stdout, "%s: Bad cache_ptr magic.\n", FUNC); + } + } + + if(show_progress) /* 7 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + FUNC, mile_stone++, (int)pass); + + if(pass) { /* allocate space for test entries */ + actual_base_addr = H5MF_alloc(file_ptr, H5FD_MEM_DEFAULT, (hsize_t)(ADDR_SPACE_SIZE + BASE_ADDR)); + + if(actual_base_addr == HADDR_UNDEF) { + pass = FALSE; + failure_mssg = "H5MF_alloc() failed."; + + if(verbose) + HDfprintf(stdout, "%s: H5MF_alloc() failed.\n", FUNC); + } else if(actual_base_addr > BASE_ADDR) { + /* If this happens, must increase BASE_ADDR so that the + * actual_base_addr is <= BASE_ADDR. This should only happen + * if the size of the superblock is increase. + */ + pass = FALSE; + failure_mssg = "actual_base_addr > BASE_ADDR"; + + if(verbose) + HDfprintf(stdout, "%s: actual_base_addr > BASE_ADDR.\n", FUNC); + } + + saved_actual_base_addr = actual_base_addr; + } + + if(show_progress) /* 8 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + FUNC, mile_stone++, (int)pass); + + if(pass) { + /* Need to set this else all cache tests will fail */ + cache_ptr->ignore_tags = TRUE; + + H5C_stats__reset(cache_ptr); + ret_val = file_ptr; + } + + if(show_progress) /* 9 */ + HDfprintf(stdout, "%s() - %0d -- pass = %d\n", + FUNC, mile_stone++, (int)pass); + + return(ret_val); +} /* setup_cache() */ + + +/*------------------------------------------------------------------------- + * Function: takedown_cache() + * + * Purpose: Flush the specified cache and destroy it. If requested, + * dump stats first. Then close and delete the associate + * file. + * + * If pass is FALSE, do nothing. + * + * Return: void + * + * Programmer: John Mainzer + * 9/14/07 + * + *------------------------------------------------------------------------- + */ + +void +takedown_cache(H5F_t * file_ptr, + hbool_t dump_stats, + hbool_t dump_detailed_stats) +{ + char filename[512]; + + if ( file_ptr != NULL ) { + H5C_t * cache_ptr = file_ptr->shared->cache; + + if ( dump_stats ) { + + H5C_stats(cache_ptr, "test cache", dump_detailed_stats); + } + + if ( H5C_prep_for_file_close(file_ptr) < 0 ) { + + pass = FALSE; + failure_mssg = "unexpected failure of prep for file close.\n"; + } + + flush_cache(file_ptr, TRUE, FALSE, FALSE); + + H5C_dest(file_ptr); + + if ( saved_cache != NULL ) { + + file_ptr->shared->cache = saved_cache; + saved_cache = NULL; + } + + } + + if ( saved_fapl_id != H5P_DEFAULT ) { + + H5Pclose(saved_fapl_id); + saved_fapl_id = H5P_DEFAULT; + } + + if ( saved_fcpl_id != H5P_DEFAULT ) { + H5Pclose(saved_fcpl_id); + saved_fcpl_id = H5P_DEFAULT; + } + + if ( saved_fid != -1 ) { + + if ( H5F_addr_defined(saved_actual_base_addr) ) { + + if ( NULL == file_ptr ) { + file_ptr = (H5F_t *)H5VL_object_verify(saved_fid, H5I_FILE); + HDassert ( file_ptr ); + } + + H5MF_xfree(file_ptr, H5FD_MEM_DEFAULT, saved_actual_base_addr, + (hsize_t)(ADDR_SPACE_SIZE + BASE_ADDR)); + saved_actual_base_addr = HADDR_UNDEF; + } + + if ( H5Fclose(saved_fid) < 0 ) { + + pass = FALSE; + failure_mssg = "couldn't close test file."; + + } else { + + saved_fid = -1; + + } + + /* Pop API context */ + H5CX_pop(); + + if ( ( ! try_core_file_driver ) || ( core_file_driver_failed ) ) { + + if ( h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof(filename)) + == NULL ) { + + pass = FALSE; + failure_mssg = "h5_fixname() failed.\n"; + } + + if ( HDremove(filename) < 0 ) { + + pass = FALSE; + failure_mssg = "couldn't delete test file."; + + } + } + } + + return; + +} /* takedown_cache() */ + /*------------------------------------------------------------------------- * Function: main * diff --git a/test/cache_api.c b/test/cache_api.c index 87b9567..87d0025 100644 --- a/test/cache_api.c +++ b/test/cache_api.c @@ -24,6 +24,11 @@ /* global variable declarations: */ +const char *FILENAME[] = { + "cache_api_test", + NULL +}; + /* macro definitions */ /* private function declarations: */ @@ -207,7 +212,7 @@ check_fapl_mdc_api_calls(unsigned paged, hid_t fcpl_id) /* setup the file name */ if ( pass ) { - if ( h5_fixname(FILENAME[1], H5P_DEFAULT, filename, sizeof(filename)) + if ( h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof(filename)) == NULL ) { pass = FALSE; @@ -355,7 +360,7 @@ check_fapl_mdc_api_calls(unsigned paged, hid_t fcpl_id) /* setup the file name */ if ( pass ) { - if ( h5_fixname(FILENAME[1], H5P_DEFAULT, filename, sizeof(filename)) + if ( h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof(filename)) == NULL ) { pass = FALSE; @@ -688,7 +693,7 @@ check_file_mdc_api_calls(unsigned paged, hid_t fcpl_id) /* setup the file name */ if ( pass ) { - if ( h5_fixname(FILENAME[1], H5P_DEFAULT, filename, sizeof(filename)) + if ( h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof(filename)) == NULL ) { pass = FALSE; @@ -1034,7 +1039,7 @@ mdc_api_call_smoke_check(int express_test, unsigned paged, hid_t fcpl_id) /* setup the file name */ if ( pass ) { - if ( h5_fixname(FILENAME[1], H5P_DEFAULT, filename, sizeof(filename)) + if ( h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof(filename)) == NULL ) { pass = FALSE; @@ -1963,7 +1968,7 @@ check_file_mdc_api_errs(unsigned paged, hid_t fcpl_id) HDfprintf(stdout, "%s: calling h5_fixname().\n", FUNC); } - if ( h5_fixname(FILENAME[1], H5P_DEFAULT, filename, sizeof(filename)) + if ( h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof(filename)) == NULL ) { pass = FALSE; diff --git a/test/cache_common.c b/test/cache_common.c index 8607717..3aff5ec 100644 --- a/test/cache_common.c +++ b/test/cache_common.c @@ -18,52 +18,12 @@ * implemented in H5C.c */ #include "H5CXprivate.h" /* API Contexts */ -#include "H5MFprivate.h" #include "H5MMprivate.h" #include "H5private.h" #include "cache_common.h" - -/* global variable declarations: */ - -const char *FILENAME[] = { - "cache_test", - "cache_api_test", - NULL -}; - -hid_t saved_fapl_id = H5P_DEFAULT; /* store the fapl id here between - * cache setup and takedown. Note - * that if saved_fapl_id == H5P_DEFAULT, - * we assume that there is no fapl to - * close. - */ - -hid_t saved_fcpl_id = H5P_DEFAULT; /* store the fcpl id here between - * cache setup and takedown. Note - * that if saved_fcpl_id == H5P_DEFAULT, - * we assume that there is no fcpl to - * close. - */ -hid_t saved_fid = -1; /* store the file id here between cache setup - * and takedown. - */ - -H5C_t * saved_cache = NULL; /* store the pointer to the instance of - * of H5C_t created by H5Fcreate() - * here between test cache setup and - * shutdown. - */ - -haddr_t saved_actual_base_addr = HADDR_UNDEF; /* Store the address of the - space allocated for cache items in the file between - cache setup & takedown */ - -hbool_t write_permitted = TRUE; hbool_t pass = TRUE; /* set to false on error */ -hbool_t try_core_file_driver = FALSE; -hbool_t core_file_driver_failed = FALSE; const char *failure_mssg = NULL; static test_entry_t *pico_entries = NULL, *orig_pico_entries = NULL; @@ -579,35 +539,6 @@ addr_to_type_and_index(haddr_t addr, /* Call back functions: */ -/*------------------------------------------------------------------------- - * - * Function: check_if_write_permitted - * - * Purpose: Determine if a write is permitted under the current - * circumstances, and set *write_permitted_ptr accordingly. - * As a general rule it is, but when we are running in parallel - * mode with collective I/O, we must ensure that a read cannot - * cause a write. - * - * In the event of failure, the value of *write_permitted_ptr - * is undefined. - * - * Return: Non-negative on success/Negative on failure. - * - * Programmer: John Mainzer, 5/15/04 - * - *------------------------------------------------------------------------- - */ -static herr_t -check_write_permitted(const H5F_t H5_ATTR_UNUSED *f, hbool_t *write_permitted_ptr) -{ - HDassert( write_permitted_ptr ); - - *write_permitted_ptr = write_permitted; - - return(SUCCEED); -} /* check_write_permitted() */ - /*------------------------------------------------------------------------- * Function: get_initial_load_size & friends @@ -3107,404 +3038,6 @@ verify_unprotected(void) } /* verify_unprotected() */ -/***************************************************************************** - * - * Function: setup_cache() - * - * Purpose: Open an HDF file. This will allocate an instance and - * initialize an associated instance of H5C_t. However, - * we want to test an instance of H5C_t, so allocate and - * initialize one with the file ID returned by the call to - * H5Fcreate(). Return a pointer to this instance of H5C_t. - * - * Observe that we open a HDF file because the cache now - * writes directly to file, and we need the file I/O facilities - * associated with the file. - * - * To avoid tripping on error check code, must allocate enough - * space in the file to hold all the test entries and their - * alternates. This is a little sticky, as the addresses of - * all the test entries are determined at compile time. - * - * Deal with this by choosing BASE_ADDR large enough that - * the base address of the allocate space will be less than - * or equal to BASE_ADDR, and then requesting an extra BASE_ADDR - * bytes, so we don't have to wory about exceeding the allocation. - * - * Return: Success: Ptr to H5C_t - * - * Failure: NULL - * - * Programmer: JRM -- 9/13/07 - * - *****************************************************************************/ - -H5F_t * -setup_cache(size_t max_cache_size, - size_t min_clean_size, - unsigned paged) -{ - char filename[512]; - hbool_t show_progress = FALSE; - hbool_t verbose = TRUE; - int mile_stone = 1; - hid_t fid = -1; - H5F_t * file_ptr = NULL; - H5C_t * cache_ptr = NULL; - H5F_t * ret_val = NULL; - haddr_t actual_base_addr; - hid_t fapl_id = H5P_DEFAULT; - hid_t fcpl_id = H5P_DEFAULT; - - if(show_progress) /* 1 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); - - saved_fid = -1; - - if(pass) { - if((fcpl_id = H5Pcreate(H5P_FILE_CREATE)) == FAIL) { - pass = FALSE; - failure_mssg = "H5Pcreate(H5P_FILE_CREATE) failed.\n"; - } - } - - if(pass && paged) { - /* Set up paged aggregation strategy */ - if(H5Pset_file_space_strategy(fcpl_id, H5F_FSPACE_STRATEGY_PAGE, 1, (hsize_t)1) == FAIL) { - pass = FALSE; - failure_mssg = "H5Pset_file_space_strategy() failed.\n"; - H5Pclose(fcpl_id); - fcpl_id = H5P_DEFAULT; - } - } - - if(pass && paged) { - /* Set up file space page size to BASE_ADDR */ - if(H5Pset_file_space_page_size(fcpl_id, (hsize_t)BASE_ADDR) == FAIL) { - pass = FALSE; - failure_mssg = "H5Pset_file_space_page_size() failed.\n"; - H5Pclose(fcpl_id); - fcpl_id = H5P_DEFAULT; - } - } - - if(pass) - saved_fcpl_id = fcpl_id; - - /* setup the file name */ - if(pass) { - if(NULL == h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof(filename))) { - pass = FALSE; - failure_mssg = "h5_fixname() failed.\n"; - } - } - - if(show_progress) /* 2 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); - - if(pass && try_core_file_driver) { - if((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) == FAIL) { - pass = FALSE; - failure_mssg = "H5Pcreate(H5P_FILE_ACCESS) failed.\n"; - } - else if(H5Pset_fapl_core(fapl_id, MAX_ADDR, FALSE) < 0) { - H5Pclose(fapl_id); - fapl_id = H5P_DEFAULT; - pass = FALSE; - failure_mssg = "H5P_set_fapl_core() failed.\n"; - } - else if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_id, fapl_id)) < 0) { - core_file_driver_failed = TRUE; - - if(verbose) - HDfprintf(stdout, "%s: H5Fcreate() with CFD failed.\n", FUNC); - } else { - saved_fapl_id = fapl_id; - } - } - - if(show_progress) /* 3 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); - - /* if we either aren't using the core file driver, or a create - * with the core file driver failed, try again with a regular file. - * If this fails, we are cooked. - */ - if(pass && fid < 0) { - fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_id, fapl_id); - saved_fid = fid; - - if(fid < 0) { - pass = FALSE; - failure_mssg = "H5Fcreate() failed."; - - if(verbose) - HDfprintf(stdout, "%s: H5Fcreate() failed.\n", FUNC); - } /* end if */ - } /* end if */ - - /* Push API context */ - H5CX_push(); - - if(show_progress) /* 4 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); - - if(pass) { - HDassert(fid >= 0); - saved_fid = fid; - if(H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) { - pass = FALSE; - failure_mssg = "H5Fflush() failed."; - - if(verbose) - HDfprintf(stdout, "%s: H5Fflush() failed.\n", FUNC); - } - else { - file_ptr = (H5F_t *)H5VL_object_verify(fid, H5I_FILE); - if(file_ptr == NULL) { - pass = FALSE; - failure_mssg = "Can't get file_ptr."; - - if(verbose) - HDfprintf(stdout, "%s: H5Fflush() failed.\n", FUNC); - } - } - } - - if(show_progress) /* 5 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); - - if(pass) { - - /* A bit of fancy footwork here: - * - * The call to H5Fcreate() allocates an instance of H5C_t, - * initializes it, and stores its address in f->shared->cache. - * - * We don't want to use this cache, as it has a bunch of extra - * initialization that may change over time, and in any case - * it will not in general be configured the way we want it. - * - * We used to deal with this problem by storing the file pointer - * in another instance of H5C_t, and then ignoring the original - * version. However, this strategy doesn't work any more, as - * we can't store the file pointer in the instance of H5C_t, - * and we have modified many cache routines to use a file - * pointer to look up the target cache. - * - * Thus we now make note of the address of the instance of - * H5C_t created by the call to H5Fcreate(), set - * file_ptr->shared->cache to NULL, call H5C_create() - * to allocate a new instance of H5C_t for test purposes, - * and store than new instance's address in - * file_ptr->shared->cache. - * - * On shut down, we call H5C_dest on our instance of H5C_t, - * set file_ptr->shared->cache to point to the original - * instance, and then close the file normally. - */ - - HDassert(saved_cache == NULL); - saved_cache = file_ptr->shared->cache; - file_ptr->shared->cache = NULL; - - cache_ptr = H5C_create(max_cache_size, - min_clean_size, - (NUMBER_OF_ENTRY_TYPES - 1), - types, - check_write_permitted, - TRUE, - NULL, - NULL); - - file_ptr->shared->cache = cache_ptr; - } - - if(show_progress) /* 6 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); - - if(pass) { - if(cache_ptr == NULL) { - pass = FALSE; - failure_mssg = "H5C_create() failed."; - - if(verbose) - HDfprintf(stdout, "%s: H5C_create() failed.\n", FUNC); - } - else if(cache_ptr->magic != H5C__H5C_T_MAGIC) { - pass = FALSE; - failure_mssg = "Bad cache_ptr magic."; - - if(verbose) - HDfprintf(stdout, "%s: Bad cache_ptr magic.\n", FUNC); - } - } - - if(show_progress) /* 7 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); - - if(pass) { /* allocate space for test entries */ - actual_base_addr = H5MF_alloc(file_ptr, H5FD_MEM_DEFAULT, (hsize_t)(ADDR_SPACE_SIZE + BASE_ADDR)); - - if(actual_base_addr == HADDR_UNDEF) { - pass = FALSE; - failure_mssg = "H5MF_alloc() failed."; - - if(verbose) - HDfprintf(stdout, "%s: H5MF_alloc() failed.\n", FUNC); - } else if(actual_base_addr > BASE_ADDR) { - /* If this happens, must increase BASE_ADDR so that the - * actual_base_addr is <= BASE_ADDR. This should only happen - * if the size of the superblock is increase. - */ - pass = FALSE; - failure_mssg = "actual_base_addr > BASE_ADDR"; - - if(verbose) - HDfprintf(stdout, "%s: actual_base_addr > BASE_ADDR.\n", FUNC); - } - - saved_actual_base_addr = actual_base_addr; - } - - if(show_progress) /* 8 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); - - if(pass) { - /* Need to set this else all cache tests will fail */ - cache_ptr->ignore_tags = TRUE; - - H5C_stats__reset(cache_ptr); - ret_val = file_ptr; - } - - if(show_progress) /* 9 */ - HDfprintf(stdout, "%s() - %0d -- pass = %d\n", - FUNC, mile_stone++, (int)pass); - - return(ret_val); -} /* setup_cache() */ - - -/*------------------------------------------------------------------------- - * Function: takedown_cache() - * - * Purpose: Flush the specified cache and destroy it. If requested, - * dump stats first. Then close and delete the associate - * file. - * - * If pass is FALSE, do nothing. - * - * Return: void - * - * Programmer: John Mainzer - * 9/14/07 - * - *------------------------------------------------------------------------- - */ - -void -takedown_cache(H5F_t * file_ptr, - hbool_t dump_stats, - hbool_t dump_detailed_stats) -{ - char filename[512]; - - if ( file_ptr != NULL ) { - H5C_t * cache_ptr = file_ptr->shared->cache; - - if ( dump_stats ) { - - H5C_stats(cache_ptr, "test cache", dump_detailed_stats); - } - - if ( H5C_prep_for_file_close(file_ptr) < 0 ) { - - pass = FALSE; - failure_mssg = "unexpected failure of prep for file close.\n"; - } - - flush_cache(file_ptr, TRUE, FALSE, FALSE); - - H5C_dest(file_ptr); - - if ( saved_cache != NULL ) { - - file_ptr->shared->cache = saved_cache; - saved_cache = NULL; - } - - } - - if ( saved_fapl_id != H5P_DEFAULT ) { - - H5Pclose(saved_fapl_id); - saved_fapl_id = H5P_DEFAULT; - } - - if ( saved_fcpl_id != H5P_DEFAULT ) { - H5Pclose(saved_fcpl_id); - saved_fcpl_id = H5P_DEFAULT; - } - - if ( saved_fid != -1 ) { - - if ( H5F_addr_defined(saved_actual_base_addr) ) { - - if ( NULL == file_ptr ) { - file_ptr = (H5F_t *)H5VL_object_verify(saved_fid, H5I_FILE); - HDassert ( file_ptr ); - } - - H5MF_xfree(file_ptr, H5FD_MEM_DEFAULT, saved_actual_base_addr, - (hsize_t)(ADDR_SPACE_SIZE + BASE_ADDR)); - saved_actual_base_addr = HADDR_UNDEF; - } - - if ( H5Fclose(saved_fid) < 0 ) { - - pass = FALSE; - failure_mssg = "couldn't close test file."; - - } else { - - saved_fid = -1; - - } - - /* Pop API context */ - H5CX_pop(); - - if ( ( ! try_core_file_driver ) || ( core_file_driver_failed ) ) { - - if ( h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof(filename)) - == NULL ) { - - pass = FALSE; - failure_mssg = "h5_fixname() failed.\n"; - } - - if ( HDremove(filename) < 0 ) { - - pass = FALSE; - failure_mssg = "couldn't delete test file."; - - } - } - } - - return; - -} /* takedown_cache() */ - /*------------------------------------------------------------------------- * Function: expunge_entry() diff --git a/test/cache_common.h b/test/cache_common.h index 2604567..969cc2a 100644 --- a/test/cache_common.h +++ b/test/cache_common.h @@ -14,14 +14,14 @@ /* Programmer: John Mainzer * 10/27/05 * - * This file contains common #defines, type definitions, and - * externs for tests of the cache implemented in H5C.c + * This file contains common #defines, type definitions, and + * externs for tests of the cache implemented in H5C.c */ #ifndef _CACHE_COMMON_H #define _CACHE_COMMON_H -#define H5C_FRIEND /*suppress error about including H5Cpkg */ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5C_FRIEND /*suppress error about including H5Cpkg */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ /* Include library header files */ #include "H5ACprivate.h" @@ -36,174 +36,174 @@ /* Macro to make error reporting easier */ #define CACHE_ERROR(s) {failure_mssg = "Line #" H5_TOSTRING(__LINE__) ": " s ; pass = FALSE; goto done;} -#define NO_CHANGE -1 +#define NO_CHANGE -1 /* with apologies for the abuse of terminology... */ -#define PICO_ENTRY_TYPE 0 -#define NANO_ENTRY_TYPE 1 -#define MICRO_ENTRY_TYPE 2 -#define TINY_ENTRY_TYPE 3 -#define SMALL_ENTRY_TYPE 4 -#define MEDIUM_ENTRY_TYPE 5 -#define LARGE_ENTRY_TYPE 6 -#define HUGE_ENTRY_TYPE 7 -#define MONSTER_ENTRY_TYPE 8 -#define VARIABLE_ENTRY_TYPE 9 -#define NOTIFY_ENTRY_TYPE 10 +#define PICO_ENTRY_TYPE 0 +#define NANO_ENTRY_TYPE 1 +#define MICRO_ENTRY_TYPE 2 +#define TINY_ENTRY_TYPE 3 +#define SMALL_ENTRY_TYPE 4 +#define MEDIUM_ENTRY_TYPE 5 +#define LARGE_ENTRY_TYPE 6 +#define HUGE_ENTRY_TYPE 7 +#define MONSTER_ENTRY_TYPE 8 +#define VARIABLE_ENTRY_TYPE 9 +#define NOTIFY_ENTRY_TYPE 10 #define NUMBER_OF_ENTRY_TYPES 11 -#define PICO_ENTRY_SIZE (size_t)1 -#define NANO_ENTRY_SIZE (size_t)4 -#define MICRO_ENTRY_SIZE (size_t)16 -#define TINY_ENTRY_SIZE (size_t)64 -#define SMALL_ENTRY_SIZE (size_t)256 -#define MEDIUM_ENTRY_SIZE (size_t)1024 -#define LARGE_ENTRY_SIZE (size_t)(4 * 1024) -#define HUGE_ENTRY_SIZE (size_t)(16 * 1024) -#define MONSTER_ENTRY_SIZE (size_t)(64 * 1024) -#define VARIABLE_ENTRY_SIZE (size_t)(10 * 1024) -#define NOTIFY_ENTRY_SIZE (size_t)1 - -#define NUM_PICO_ENTRIES (10 * 1024) -#define NUM_NANO_ENTRIES (10 * 1024) -#define NUM_MICRO_ENTRIES (10 * 1024) -#define NUM_TINY_ENTRIES (10 * 1024) -#define NUM_SMALL_ENTRIES (10 * 1024) -#define NUM_MEDIUM_ENTRIES (10 * 1024) -#define NUM_LARGE_ENTRIES (10 * 1024) -#define NUM_HUGE_ENTRIES (10 * 1024) -#define NUM_MONSTER_ENTRIES (10 * 1024) -#define NUM_VARIABLE_ENTRIES (10 * 1024) -#define NUM_NOTIFY_ENTRIES (10 * 1024) - -#define MAX_ENTRIES (10 * 1024) +#define PICO_ENTRY_SIZE (size_t)1 +#define NANO_ENTRY_SIZE (size_t)4 +#define MICRO_ENTRY_SIZE (size_t)16 +#define TINY_ENTRY_SIZE (size_t)64 +#define SMALL_ENTRY_SIZE (size_t)256 +#define MEDIUM_ENTRY_SIZE (size_t)1024 +#define LARGE_ENTRY_SIZE (size_t)(4 * 1024) +#define HUGE_ENTRY_SIZE (size_t)(16 * 1024) +#define MONSTER_ENTRY_SIZE (size_t)(64 * 1024) +#define VARIABLE_ENTRY_SIZE (size_t)(10 * 1024) +#define NOTIFY_ENTRY_SIZE (size_t)1 + +#define NUM_PICO_ENTRIES (10 * 1024) +#define NUM_NANO_ENTRIES (10 * 1024) +#define NUM_MICRO_ENTRIES (10 * 1024) +#define NUM_TINY_ENTRIES (10 * 1024) +#define NUM_SMALL_ENTRIES (10 * 1024) +#define NUM_MEDIUM_ENTRIES (10 * 1024) +#define NUM_LARGE_ENTRIES (10 * 1024) +#define NUM_HUGE_ENTRIES (10 * 1024) +#define NUM_MONSTER_ENTRIES (10 * 1024) +#define NUM_VARIABLE_ENTRIES (10 * 1024) +#define NUM_NOTIFY_ENTRIES (10 * 1024) + +#define MAX_ENTRIES (10 * 1024) /* The choice of the BASE_ADDR below is arbitrary -- it just has to be * larger than the superblock. */ -#define BASE_ADDR (haddr_t)1024 -#define PICO_BASE_ADDR BASE_ADDR -#define NANO_BASE_ADDR (haddr_t)(PICO_BASE_ADDR + \ +#define BASE_ADDR (haddr_t)1024 +#define PICO_BASE_ADDR BASE_ADDR +#define NANO_BASE_ADDR (haddr_t)(PICO_BASE_ADDR + \ (PICO_ENTRY_SIZE * NUM_PICO_ENTRIES)) -#define MICRO_BASE_ADDR (haddr_t)(NANO_BASE_ADDR + \ +#define MICRO_BASE_ADDR (haddr_t)(NANO_BASE_ADDR + \ (NANO_ENTRY_SIZE * NUM_NANO_ENTRIES)) -#define TINY_BASE_ADDR (haddr_t)(MICRO_BASE_ADDR + \ - (MICRO_ENTRY_SIZE * NUM_MICRO_ENTRIES)) -#define SMALL_BASE_ADDR (haddr_t)(TINY_BASE_ADDR + \ +#define TINY_BASE_ADDR (haddr_t)(MICRO_BASE_ADDR + \ + (MICRO_ENTRY_SIZE * NUM_MICRO_ENTRIES)) +#define SMALL_BASE_ADDR (haddr_t)(TINY_BASE_ADDR + \ (TINY_ENTRY_SIZE * NUM_TINY_ENTRIES)) -#define MEDIUM_BASE_ADDR (haddr_t)(SMALL_BASE_ADDR + \ +#define MEDIUM_BASE_ADDR (haddr_t)(SMALL_BASE_ADDR + \ (SMALL_ENTRY_SIZE * NUM_SMALL_ENTRIES)) -#define LARGE_BASE_ADDR (haddr_t)(MEDIUM_BASE_ADDR + \ +#define LARGE_BASE_ADDR (haddr_t)(MEDIUM_BASE_ADDR + \ (MEDIUM_ENTRY_SIZE * NUM_MEDIUM_ENTRIES)) -#define HUGE_BASE_ADDR (haddr_t)(LARGE_BASE_ADDR + \ +#define HUGE_BASE_ADDR (haddr_t)(LARGE_BASE_ADDR + \ (LARGE_ENTRY_SIZE * NUM_LARGE_ENTRIES)) -#define MONSTER_BASE_ADDR (haddr_t)(HUGE_BASE_ADDR + \ +#define MONSTER_BASE_ADDR (haddr_t)(HUGE_BASE_ADDR + \ (HUGE_ENTRY_SIZE * NUM_HUGE_ENTRIES)) -#define VARIABLE_BASE_ADDR (haddr_t)(MONSTER_BASE_ADDR + \ - (MONSTER_ENTRY_SIZE * NUM_MONSTER_ENTRIES)) -#define NOTIFY_BASE_ADDR (haddr_t)(VARIABLE_BASE_ADDR + \ - (VARIABLE_ENTRY_SIZE * NUM_VARIABLE_ENTRIES)) - -#define PICO_ALT_BASE_ADDR (haddr_t)(NOTIFY_BASE_ADDR + \ - (NOTIFY_ENTRY_SIZE * NUM_NOTIFY_ENTRIES)) -#define NANO_ALT_BASE_ADDR (haddr_t)(PICO_ALT_BASE_ADDR + \ +#define VARIABLE_BASE_ADDR (haddr_t)(MONSTER_BASE_ADDR + \ + (MONSTER_ENTRY_SIZE * NUM_MONSTER_ENTRIES)) +#define NOTIFY_BASE_ADDR (haddr_t)(VARIABLE_BASE_ADDR + \ + (VARIABLE_ENTRY_SIZE * NUM_VARIABLE_ENTRIES)) + +#define PICO_ALT_BASE_ADDR (haddr_t)(NOTIFY_BASE_ADDR + \ + (NOTIFY_ENTRY_SIZE * NUM_NOTIFY_ENTRIES)) +#define NANO_ALT_BASE_ADDR (haddr_t)(PICO_ALT_BASE_ADDR + \ (PICO_ENTRY_SIZE * NUM_PICO_ENTRIES)) -#define MICRO_ALT_BASE_ADDR (haddr_t)(NANO_ALT_BASE_ADDR + \ +#define MICRO_ALT_BASE_ADDR (haddr_t)(NANO_ALT_BASE_ADDR + \ (NANO_ENTRY_SIZE * NUM_NANO_ENTRIES)) -#define TINY_ALT_BASE_ADDR (haddr_t)(MICRO_ALT_BASE_ADDR + \ - (MICRO_ENTRY_SIZE * NUM_MICRO_ENTRIES)) -#define SMALL_ALT_BASE_ADDR (haddr_t)(TINY_ALT_BASE_ADDR + \ +#define TINY_ALT_BASE_ADDR (haddr_t)(MICRO_ALT_BASE_ADDR + \ + (MICRO_ENTRY_SIZE * NUM_MICRO_ENTRIES)) +#define SMALL_ALT_BASE_ADDR (haddr_t)(TINY_ALT_BASE_ADDR + \ (TINY_ENTRY_SIZE * NUM_TINY_ENTRIES)) -#define MEDIUM_ALT_BASE_ADDR (haddr_t)(SMALL_ALT_BASE_ADDR + \ +#define MEDIUM_ALT_BASE_ADDR (haddr_t)(SMALL_ALT_BASE_ADDR + \ (SMALL_ENTRY_SIZE * NUM_SMALL_ENTRIES)) -#define LARGE_ALT_BASE_ADDR (haddr_t)(MEDIUM_ALT_BASE_ADDR + \ +#define LARGE_ALT_BASE_ADDR (haddr_t)(MEDIUM_ALT_BASE_ADDR + \ (MEDIUM_ENTRY_SIZE * NUM_MEDIUM_ENTRIES)) -#define HUGE_ALT_BASE_ADDR (haddr_t)(LARGE_ALT_BASE_ADDR + \ +#define HUGE_ALT_BASE_ADDR (haddr_t)(LARGE_ALT_BASE_ADDR + \ (LARGE_ENTRY_SIZE * NUM_LARGE_ENTRIES)) -#define MONSTER_ALT_BASE_ADDR (haddr_t)(HUGE_ALT_BASE_ADDR + \ +#define MONSTER_ALT_BASE_ADDR (haddr_t)(HUGE_ALT_BASE_ADDR + \ (HUGE_ENTRY_SIZE * NUM_HUGE_ENTRIES)) -#define VARIABLE_ALT_BASE_ADDR (haddr_t)(MONSTER_ALT_BASE_ADDR + \ +#define VARIABLE_ALT_BASE_ADDR (haddr_t)(MONSTER_ALT_BASE_ADDR + \ (MONSTER_ENTRY_SIZE * NUM_MONSTER_ENTRIES)) -#define NOTIFY_ALT_BASE_ADDR (haddr_t)(VARIABLE_ALT_BASE_ADDR + \ +#define NOTIFY_ALT_BASE_ADDR (haddr_t)(VARIABLE_ALT_BASE_ADDR + \ (VARIABLE_ENTRY_SIZE * NUM_VARIABLE_ENTRIES)) -#define MAX_ADDR (haddr_t)(NOTIFY_ALT_BASE_ADDR + \ - (NOTIFY_ENTRY_SIZE * NUM_NOTIFY_ENTRIES)) -#define ADDR_SPACE_SIZE (haddr_t)(MAX_ADDR - BASE_ADDR) - -#define MAX_PINS 8 /* Maximum number of entries that can be - * directly pinned by a single entry. - */ - -#define FLUSH_OP__NO_OP 0 -#define FLUSH_OP__DIRTY 1 -#define FLUSH_OP__RESIZE 2 -#define FLUSH_OP__MOVE 3 -#define FLUSH_OP__ORDER 4 -#define FLUSH_OP__EXPUNGE 5 -#define FLUSH_OP__DEST_FLUSH_DEP 6 -#define FLUSH_OP__MAX_OP 6 - -#define MAX_FLUSH_OPS 10 /* Maximum number of flush operations - * that can be associated with a - * cache entry. - */ +#define MAX_ADDR (haddr_t)(NOTIFY_ALT_BASE_ADDR + \ + (NOTIFY_ENTRY_SIZE * NUM_NOTIFY_ENTRIES)) +#define ADDR_SPACE_SIZE (haddr_t)(MAX_ADDR - BASE_ADDR) + +#define MAX_PINS 8 /* Maximum number of entries that can be + * directly pinned by a single entry. + */ + +#define FLUSH_OP__NO_OP 0 +#define FLUSH_OP__DIRTY 1 +#define FLUSH_OP__RESIZE 2 +#define FLUSH_OP__MOVE 3 +#define FLUSH_OP__ORDER 4 +#define FLUSH_OP__EXPUNGE 5 +#define FLUSH_OP__DEST_FLUSH_DEP 6 +#define FLUSH_OP__MAX_OP 6 + +#define MAX_FLUSH_OPS 10 /* Maximum number of flush operations + * that can be associated with a + * cache entry. + */ #define MAX_FLUSH_DEP_PARS 8 /* Maximum number of flush dependency * parents in the test */ typedef struct flush_op { - int op_code; /* integer op code indicating the - * operation to be performed. At - * present it must be one of: - * - * FLUSH_OP__NO_OP - * FLUSH_OP__DIRTY - * FLUSH_OP__RESIZE - * FLUSH_OP__MOVE - * FLUSH_OP__ORDER - */ - int type; /* type code of the cache entry that - * is the target of the operation. - * This value is passed into the - * function implementing the flush - * operation. - */ - int idx; /* index of the cache entry that - * is the target of the operation. - * This value is passed into the + int op_code; /* integer op code indicating the + * operation to be performed. At + * present it must be one of: + * + * FLUSH_OP__NO_OP + * FLUSH_OP__DIRTY + * FLUSH_OP__RESIZE + * FLUSH_OP__MOVE + * FLUSH_OP__ORDER + */ + int type; /* type code of the cache entry that + * is the target of the operation. + * This value is passed into the + * function implementing the flush + * operation. + */ + int idx; /* index of the cache entry that + * is the target of the operation. + * This value is passed into the * function implementing the flush * operation. - */ - hbool_t flag; /* boolean flag passed into the - * function implementing the flush - * operation. The meaning of the - * flag is dependent upon the flush - * operation: - * - * FLUSH_OP__DIRTY: TRUE iff the - * target is pinned, and is to - * be dirtied via the - * H5C_mark_entry_dirty() - * call. - * - * FLUSH_OP__RESIZE: TRUE iff the - * target is pinned, and is to - * be resized via the - * H5C_resize_entry() - * call. - * - * FLUSH_OP__MOVE: TRUE iff the - * target is to be moved to - * its main address. - */ - size_t size; /* New target size in the - * FLUSH_OP__MOVE operation. - * Unused elsewhere. - */ + */ + hbool_t flag; /* boolean flag passed into the + * function implementing the flush + * operation. The meaning of the + * flag is dependent upon the flush + * operation: + * + * FLUSH_OP__DIRTY: TRUE iff the + * target is pinned, and is to + * be dirtied via the + * H5C_mark_entry_dirty() + * call. + * + * FLUSH_OP__RESIZE: TRUE iff the + * target is pinned, and is to + * be resized via the + * H5C_resize_entry() + * call. + * + * FLUSH_OP__MOVE: TRUE iff the + * target is to be moved to + * its main address. + */ + size_t size; /* New target size in the + * FLUSH_OP__MOVE operation. + * Unused elsewhere. + */ unsigned * order_ptr; /* Pointer to outside counter for * recording the order of entries * flushed. @@ -217,135 +217,135 @@ typedef enum test_entry_action_t { typedef struct test_entry_t { - H5C_cache_entry_t header; /* entry data used by the cache - * -- must be first - */ - struct test_entry_t * self; /* pointer to this entry -- used for - * sanity checking. + H5C_cache_entry_t header; /* entry data used by the cache + * -- must be first + */ + struct test_entry_t * self; /* pointer to this entry -- used for + * sanity checking. */ test_entry_action_t action; /* Action being performed on a test entry */ H5F_t * file_ptr; /* pointer to the file in which the * entry resides, or NULL if the entry * is not in a file. */ - H5C_t * cache_ptr; /* pointer to the cache in which - * the entry resides, or NULL if the - * entry is not in cache. - */ - hbool_t written_to_main_addr; - /* Flag indicating whether an image - * of the entry has been written to - * its main address. Since we no - * longer have a flush callback, we - * set this field to true whenever the - * entry is serialized while at its - * main address. - */ - hbool_t written_to_alt_addr; + H5C_t * cache_ptr; /* pointer to the cache in which + * the entry resides, or NULL if the + * entry is not in cache. + */ + hbool_t written_to_main_addr; + /* Flag indicating whether an image + * of the entry has been written to + * its main address. Since we no + * longer have a flush callback, we + * set this field to true whenever the + * entry is serialized while at its + * main address. + */ + hbool_t written_to_alt_addr; /* Flag indicating whether an image - * of the entry has been written to - * its alternate address. Since we no - * longer have a flush callback, we - * set this field to true whenever the - * entry is serialized while at its - * alternate address. - */ - haddr_t addr; /* where the cache thinks this entry + * of the entry has been written to + * its alternate address. Since we no + * longer have a flush callback, we + * set this field to true whenever the + * entry is serialized while at its + * alternate address. + */ + haddr_t addr; /* where the cache thinks this entry * is located */ - hbool_t at_main_addr; /* boolean flag indicating whether - * the entry is supposed to be at - * either its main or alternate - * address. - */ - haddr_t main_addr; /* initial location of the entry + hbool_t at_main_addr; /* boolean flag indicating whether + * the entry is supposed to be at + * either its main or alternate + * address. + */ + haddr_t main_addr; /* initial location of the entry */ - haddr_t alt_addr; /* location to which the entry - * can be relocated or "moved" + haddr_t alt_addr; /* location to which the entry + * can be relocated or "moved" */ - size_t size; /* how big the cache thinks this + size_t size; /* how big the cache thinks this * entry is */ - int32_t type; /* indicates which entry array this - * entry is in + int32_t type; /* indicates which entry array this + * entry is in */ - int32_t index; /* index in its entry array + int32_t index; /* index in its entry array */ - int32_t serializes; /* number of times this entry has - * been serialized. + int32_t serializes; /* number of times this entry has + * been serialized. */ - int32_t deserializes; /* number of times this entry has + int32_t deserializes; /* number of times this entry has * been deserialized */ - hbool_t is_dirty; /* entry has been modified since + hbool_t is_dirty; /* entry has been modified since * last write */ - hbool_t is_protected; /* entry should currently be on - * the cache's protected list. + hbool_t is_protected; /* entry should currently be on + * the cache's protected list. */ - hbool_t is_read_only; /* TRUE iff the entry should be - * protected read only. - */ - int ro_ref_count; /* Number of outstanding read only - * protects on the entry. - */ - hbool_t is_pinned; /* entry is currently pinned in - * the cache. + hbool_t is_read_only; /* TRUE iff the entry should be + * protected read only. + */ + int ro_ref_count; /* Number of outstanding read only + * protects on the entry. + */ + hbool_t is_pinned; /* entry is currently pinned in + * the cache. */ - haddr_t tag; /* the base_addr as tag for corking entries */ - hbool_t is_corked; /* entry is currently corked or not */ - int pinning_ref_count; /* Number of entries that - * pin this entry in the cache. - * When this count drops to zero, - * this entry should be unpinned. - */ - int num_pins; /* Number of entries that this - * entry pins in the cache. This - * value must be in the range - * [0, MAX_PINS]. - */ - int pin_type[MAX_PINS]; /* array of the types of entries - * pinned by this entry. - */ - int pin_idx[MAX_PINS]; /* array of the indicies of - * entries pinned by this entry. - */ - int num_flush_ops; /* integer field containing the - * number of flush operations to - * be executed when the entry is - * flushed. This value must lie in - * the closed interval - * [0, MAX_FLUSH_OPS]. - */ - struct flush_op flush_ops[MAX_FLUSH_OPS]; /* Array of instances - * of struct flush_op detailing the - * flush operations (if any) that - * are to be executed when the entry - * is flushed from the cache. - * - * num_flush_ops contains the number - * of valid entries in this array. - */ - hbool_t flush_op_self_resize_in_progress; /* Boolean flag - * that is set to TRUE iff this - * entry is being flushed, it has - * been resized by a resize flush - * op, and the flush function has - * not yet returned, This field is - * used to turn off overactive santity - * checking code that would otherwise - * cause a false test failure. - */ - hbool_t deserialized; /* entry has been deserialized since - * the last time it was reset. + haddr_t tag; /* the base_addr as tag for corking entries */ + hbool_t is_corked; /* entry is currently corked or not */ + int pinning_ref_count; /* Number of entries that + * pin this entry in the cache. + * When this count drops to zero, + * this entry should be unpinned. + */ + int num_pins; /* Number of entries that this + * entry pins in the cache. This + * value must be in the range + * [0, MAX_PINS]. + */ + int pin_type[MAX_PINS]; /* array of the types of entries + * pinned by this entry. + */ + int pin_idx[MAX_PINS]; /* array of the indicies of + * entries pinned by this entry. + */ + int num_flush_ops; /* integer field containing the + * number of flush operations to + * be executed when the entry is + * flushed. This value must lie in + * the closed interval + * [0, MAX_FLUSH_OPS]. + */ + struct flush_op flush_ops[MAX_FLUSH_OPS]; /* Array of instances + * of struct flush_op detailing the + * flush operations (if any) that + * are to be executed when the entry + * is flushed from the cache. + * + * num_flush_ops contains the number + * of valid entries in this array. + */ + hbool_t flush_op_self_resize_in_progress; /* Boolean flag + * that is set to TRUE iff this + * entry is being flushed, it has + * been resized by a resize flush + * op, and the flush function has + * not yet returned, This field is + * used to turn off overactive santity + * checking code that would otherwise + * cause a false test failure. + */ + hbool_t deserialized; /* entry has been deserialized since + * the last time it was reset. */ - hbool_t serialized; /* entry has been serialized since the + hbool_t serialized; /* entry has been serialized since the * last time it was reset. */ hbool_t destroyed; /* entry has been destroyed since the * last time it was reset. */ - hbool_t expunged; /* entry has been expunged since the + hbool_t expunged; /* entry has been expunged since the * last time it was reset. */ int flush_dep_par_type[MAX_FLUSH_DEP_PARS]; /* Entry types of flush dependency parents */ @@ -353,15 +353,15 @@ typedef struct test_entry_t unsigned flush_dep_npar; /* Number of flush dependency parents */ unsigned flush_dep_nchd; /* Number of flush dependency children */ unsigned flush_dep_ndirty_chd; /* Number of dirty flush dependency children (including granchildren, etc.) */ - hbool_t pinned_from_client; /* entry was pinned by client call */ - hbool_t pinned_from_cache; /* entry was pinned by cache internally */ + hbool_t pinned_from_client; /* entry was pinned by client call */ + hbool_t pinned_from_cache; /* entry was pinned by cache internally */ unsigned flush_order; /* Order that entry was flushed in */ unsigned notify_after_insert_count; /* Count of times that entry was inserted in cache */ unsigned notify_before_evict_count; /* Count of times that entry was removed in cache */ - size_t actual_len; /* Simulate the entry's actual size for a speculative load */ - unsigned max_verify_ct; /* Maximum # of times to verify an entry's checksum */ - unsigned verify_ct; /* Count the # of checksum verification for an entry */ + size_t actual_len; /* Simulate the entry's actual size for a speculative load */ + unsigned max_verify_ct; /* Maximum # of times to verify an entry's checksum */ + unsigned verify_ct; /* Count the # of checksum verification for an entry */ } test_entry_t; /* The following are cut down test versions of the hash table manipulation @@ -509,41 +509,35 @@ if ( ( (cache_ptr) == NULL ) || \ (i).empty_reserve = (e).empty_reserve; \ } - + /* misc type definitions */ struct expected_entry_status { - int entry_type; + int entry_type; int entry_index; size_t size; - hbool_t in_cache; + hbool_t in_cache; hbool_t at_main_addr; - hbool_t is_dirty; - hbool_t is_protected; - hbool_t is_pinned; - hbool_t deserialized; - hbool_t serialized; - hbool_t destroyed; + hbool_t is_dirty; + hbool_t is_protected; + hbool_t is_pinned; + hbool_t deserialized; + hbool_t serialized; + hbool_t destroyed; int flush_dep_par_type[MAX_FLUSH_DEP_PARS]; /* Entry types of flush dependency parents */ int flush_dep_par_idx[MAX_FLUSH_DEP_PARS]; /* Indices of flush dependency parents */ unsigned flush_dep_npar; /* Number of flush dependency parents */ unsigned flush_dep_nchd; /* Number of flush dependency children */ unsigned flush_dep_ndirty_chd; /* Number of dirty flush dependency children */ int flush_order; /* flush order of entry */ - unsigned char is_corked; /* cork status of entry */ + unsigned char is_corked; /* cork status of entry */ }; - -/* global variable externs: */ -H5TEST_DLLVAR H5C_t * saved_cache; - -H5TEST_DLLVAR const char *FILENAME[]; -H5TEST_DLLVAR haddr_t saved_actual_base_addr; -H5TEST_DLLVAR hbool_t write_permitted; +/* global variable externs: */ H5TEST_DLLVAR hbool_t pass; /* set to false on error */ H5TEST_DLLVAR const char *failure_mssg; @@ -557,7 +551,7 @@ H5TEST_DLLVAR const haddr_t alt_base_addrs[NUMBER_OF_ENTRY_TYPES]; H5TEST_DLLVAR const H5C_class_t *types[NUMBER_OF_ENTRY_TYPES]; - + #ifdef __cplusplus extern "C" { #endif @@ -642,8 +636,6 @@ H5TEST_DLL void resize_entry(H5F_t * file_ptr, size_t new_size, hbool_t in_cache); -H5TEST_DLL H5F_t *setup_cache(size_t max_cache_size, size_t min_clean_size, unsigned paged); - H5TEST_DLL void row_major_scan_forward(H5F_t * file_ptr, int32_t max_index, int32_t lag, @@ -728,10 +720,6 @@ H5TEST_DLL void hl_col_major_scan_backward(H5F_t * file_ptr, hbool_t do_inserts, int dirty_unprotects); -H5TEST_DLL void takedown_cache(H5F_t * file_ptr, - hbool_t dump_stats, - hbool_t dump_detailed_stats); - H5TEST_DLL void flush_cache(H5F_t * file_ptr, hbool_t destroy_entries, hbool_t dump_stats, @@ -748,7 +736,7 @@ H5TEST_DLL void unprotect_entry(H5F_t * file_ptr, H5TEST_DLL void verify_clean(void); H5TEST_DLL void verify_entry_status(H5C_t * cache_ptr, - int tag, + int tag, int num_entries, struct expected_entry_status expected[]); diff --git a/test/cork.c b/test/cork.c index 06a520d..78b6b01 100644 --- a/test/cork.c +++ b/test/cork.c @@ -99,8 +99,9 @@ verify_old_dset_cork(void) hsize_t dims[2] = {100, 20}; /* Dataset dimension sizes */ hsize_t max_dims[2] = {100, H5S_UNLIMITED}; /* Dataset maximum dimension sizes */ hsize_t chunk_dims[2] = {2, 5}; /* Dataset chunked dimension sizes */ - int buf[100][20]; /* Data buffer */ - int i = 0, j = 0; /* Local index variable */ + int **buf = NULL; /* Data bufer (pointers to fake 2D array) */ + int *buf_data = NULL; /* Data buffer (actual data) */ + int i = 0, j = 0; /* Local index variables */ H5O_info_t oinfo, oinfo2, oinfo3; /* Object metadata information */ hsize_t dims2[2] = {8, 16}; /* Dataset dimension sizes */ @@ -137,13 +138,21 @@ verify_old_dset_cork(void) if(H5C__verify_cork_tag_test(fid, oinfo.addr, TRUE) < 0) TEST_ERROR + /* Set up data array */ + if(NULL == (buf_data = (int *)HDcalloc(100 * 20, sizeof(int)))) + TEST_ERROR; + if(NULL == (buf = (int **)HDcalloc(100, sizeof(buf_data)))) + TEST_ERROR; + for (i = 0; i < 100; i++) + buf[i] = buf_data + (i * 20); + /* Initialize data buffer */ for(i = 0; i < (int)dims[0]; i++) for(j = 0; j < (int)dims[1]; j++) buf[i][j] = (i + 1) * (j + 1); /* Write to the dataset: DSET_BT1 */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) < 0) TEST_ERROR /* Verify the cork status for DSET_BT1 */ @@ -196,11 +205,6 @@ verify_old_dset_cork(void) if((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) TEST_ERROR - /* Initialize data buffer */ - for(i = 0; i < (int)dims[0]; i++) - for(j = 0; j < (int)dims[1]; j++) - buf[i][j] = (i + 1) * (j + 1); - /* Open and write to the dataset: DSET_BT1 */ if((did = H5Dopen2(fid, DSET_BT1, H5P_DEFAULT)) < 0) TEST_ERROR @@ -249,6 +253,9 @@ verify_old_dset_cork(void) if(H5Fclose(fid) < 0) TEST_ERROR + HDfree(buf); + HDfree(buf_data); + PASSED(); return 0; @@ -265,6 +272,10 @@ error: H5Pclose(dcpl3); H5Fclose(fid); } H5E_END_TRY; + + HDfree(buf); + HDfree(buf_data); + return 1; } /* verify_old_dset_cork */ @@ -496,7 +507,9 @@ verify_dset_cork(hbool_t swmr, hbool_t new_format) hsize_t dims[2] = {100, 20}; /* Dataset dimension sizes */ hsize_t max_dims[2] = {100, H5S_UNLIMITED}; /* Dataset maximum dimension sizes */ hsize_t chunk_dims[2] = {2, 5}; /* Dataset chunked dimension sizes */ - int buf[100][20]; int i = 0, j = 0; /* Data buffer */ + int **buf = NULL; /* Data bufer (pointers to fake 2D array) */ + int *buf_data = NULL; /* Data buffer (actual data) */ + int i = 0, j = 0; /* Local index variables */ H5O_info_t oinfo, oinfo2, oinfo3; /* Object metadata information */ unsigned flags; /* File access flags */ @@ -630,6 +643,14 @@ verify_dset_cork(hbool_t swmr, hbool_t new_format) if((fid = H5Fopen(FILENAME, flags, fapl)) < 0) TEST_ERROR + /* Set up data array */ + if(NULL == (buf_data = (int *)HDcalloc(100 * 20, sizeof(int)))) + TEST_ERROR; + if(NULL == (buf = (int **)HDcalloc(100, sizeof(buf_data)))) + TEST_ERROR; + for (i = 0; i < 100; i++) + buf[i] = buf_data + (i * 20); + /* Initialize data buffer */ for(i = 0; i < (int)dims[0]; i++) for(j = 0; j < (int)dims[1]; j++) @@ -638,7 +659,7 @@ verify_dset_cork(hbool_t swmr, hbool_t new_format) /* Open and write to the dataset: DSET_EA */ if((did = H5Dopen2(fid, DSET_EA, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) < 0) TEST_ERROR /* Verify the cork status for DSET_EA */ @@ -648,7 +669,7 @@ verify_dset_cork(hbool_t swmr, hbool_t new_format) /* Open and write to the dataset: DSET_FA */ if((did2 = H5Dopen2(fid, DSET_FA, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if(H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) < 0) TEST_ERROR /* Cork the dataset: DSET_FA */ @@ -662,7 +683,7 @@ verify_dset_cork(hbool_t swmr, hbool_t new_format) /* Open and write to the dataset: DSET_BT2 */ if((did3 = H5Dopen2(fid, DSET_BT2, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(did3, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if(H5Dwrite(did3, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) < 0) TEST_ERROR /* Verify the cork status for DSET_BT2 */ @@ -689,6 +710,9 @@ verify_dset_cork(hbool_t swmr, hbool_t new_format) if(H5Fclose(fid) < 0) TEST_ERROR + HDfree(buf); + HDfree(buf_data); + PASSED(); return 0; @@ -704,6 +728,10 @@ error: H5Pclose(fapl); H5Fclose(fid); } H5E_END_TRY; + + HDfree(buf); + HDfree(buf_data); + return 1; } /* verify_dset_cork */ @@ -1826,8 +1854,9 @@ test_dset_cork(hbool_t swmr, hbool_t new_format) hsize_t cdims[RANK] = {2,2}; /* Chunk dimensions */ int fillval = 0; /* Fill value */ int i, j, k = 0; /* Local index variables */ - int data[DIMS0][DIMS1]; /* Data buffer */ - int rbuf[DIMS0][DIMS1]; /* Data buffer */ + int **wbuf = NULL; /* Data buffer for writes (pointers to fake 2D array) */ + int *wbuf_data = NULL; /* Data buffer for writes (real data) */ + int *rbuf_data = NULL; /* Data buffer for reads (real data) */ hbool_t corked; /* Cork status of an object */ unsigned flags; /* File access flags */ @@ -1923,13 +1952,21 @@ test_dset_cork(hbool_t swmr, hbool_t new_format) if(corked) TEST_ERROR + /* Set up data array */ + if(NULL == (wbuf_data = (int *)HDcalloc(DIMS0 * DIMS1, sizeof(int)))) + TEST_ERROR; + if(NULL == (wbuf = (int **)HDcalloc(DIMS0, sizeof(wbuf_data)))) + TEST_ERROR; + for (i = 0; i < DIMS0; i++) + wbuf[i] = wbuf_data + (i * DIMS1); + /* Initialize the buffer */ for(i = 0; i < DIMS0;i++) for(j = 0;j < DIMS1;j++) - data[i][j] = k++; + wbuf[i][j] = k++; /* Write to the dataset */ - if(H5Dwrite(did1, tid1, sid, sid, H5P_DEFAULT, data) < 0) + if(H5Dwrite(did1, tid1, sid, sid, H5P_DEFAULT, wbuf_data) < 0) TEST_ERROR /* Flush the dataset */ @@ -1962,8 +1999,12 @@ test_dset_cork(hbool_t swmr, hbool_t new_format) if(corked) TEST_ERROR + /* Set up data array */ + if(NULL == (rbuf_data = (int *)HDcalloc(DIMS0 * DIMS1, sizeof(int)))) + TEST_ERROR; + /* Read from the dataset */ - if(H5Dread(did1, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + if(H5Dread(did1, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf_data) < 0) TEST_ERROR /* Cork the dataset */ @@ -1993,7 +2034,7 @@ test_dset_cork(hbool_t swmr, hbool_t new_format) TEST_ERROR /* Write to the dataset */ - if(H5Dwrite(did1, tid1, sid, sid, H5P_DEFAULT, data) < 0) + if(H5Dwrite(did1, tid1, sid, sid, H5P_DEFAULT, wbuf_data) < 0) TEST_ERROR /* Refresh the dataset */ @@ -2106,6 +2147,10 @@ test_dset_cork(hbool_t swmr, hbool_t new_format) if(H5Pclose(dcpl) < 0) TEST_ERROR + HDfree(wbuf); + HDfree(wbuf_data); + HDfree(rbuf_data); + PASSED(); return 0; @@ -2121,6 +2166,11 @@ error: H5Pclose(fapl); H5Fclose(fid); } H5E_END_TRY; + + HDfree(wbuf); + HDfree(wbuf_data); + HDfree(rbuf_data); + return 1; } /* test_dset_cork() */ diff --git a/test/dsets.c b/test/dsets.c index 2ed2970..db209e2da 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -5293,7 +5293,7 @@ test_types(hid_t file) (space=H5Screate_simple(1, &nelmts, NULL)) < 0 || (dset=H5Dcreate2(grp, "bitfield_1", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - for(i=0; i<sizeof buf; i++) buf[i] = (unsigned char)0xff ^ (unsigned char)i; + for(i=0; i<sizeof buf; i++) buf[i] = (unsigned char)(0xff ^ i); if(H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto error; @@ -5307,7 +5307,7 @@ test_types(hid_t file) (space=H5Screate_simple(1, &nelmts, NULL)) < 0 || (dset=H5Dcreate2(grp, "bitfield_2", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - for(i=0; i<sizeof buf; i++) buf[i] = (unsigned char)0xff ^ (unsigned char)i; + for(i=0; i<sizeof buf; i++) buf[i] = (unsigned char)(0xff ^ i); if(H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto error; if(H5Sclose(space) < 0) goto error; @@ -5322,7 +5322,7 @@ test_types(hid_t file) (dset = H5Dcreate2(grp, "opaque_1", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; for(i = 0; i < sizeof buf; i++) - buf[i] = (unsigned char)0xff ^ (unsigned char)i; + buf[i] = (unsigned char)(0xff ^ i); if(H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto error; if(H5Sclose(space) < 0) goto error; if(H5Tclose(type) < 0) goto error; @@ -5336,7 +5336,7 @@ test_types(hid_t file) (dset = H5Dcreate2(grp, "opaque_2", type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; for(i = 0; i < sizeof buf; i++) - buf[i] = (unsigned char)0xff ^ (unsigned char)i; + buf[i] = (unsigned char)(0xff ^ i); if(H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto error; if(H5Sclose(space) < 0) goto error; if(H5Tclose(type) < 0) goto error; @@ -7065,6 +7065,7 @@ static void make_random_offset_and_increment(long nelts, long *offsetp, long *incp) { long inc; + long maxinc; HDassert(0 < nelts); @@ -7073,7 +7074,7 @@ make_random_offset_and_increment(long nelts, long *offsetp, long *incp) /* `maxinc` is chosen so that for any `x` in [0, nelts - 1], * `x + maxinc` does not overflow a long. */ - const long maxinc = MIN(nelts - 1, LONG_MAX - nelts); + maxinc = MIN(nelts - 1, LONG_MAX - nelts); /* Choose a random number in [1, nelts - 1]. If its greatest divisor * in common with `nelts` is 1, then it will "generate" the additive ring @@ -12775,20 +12776,23 @@ error: } /* end dls_01_write_data() */ static herr_t -dls_01_read_stuff( hid_t fid ) +dls_01_read_stuff(hid_t fid) { int status = 0; hid_t did = 0; H5O_info_t info; - did = H5Dopen2( fid, DLS_01_DATASET, H5P_DEFAULT ); - if ( did <= 0 ) TEST_ERROR + did = H5Dopen2(fid, DLS_01_DATASET, H5P_DEFAULT); + if(did <= 0) + TEST_ERROR - status = H5Oget_info2( did, &info, H5O_INFO_BASIC ); - if ( status != 0 ) TEST_ERROR + status = H5Oget_info2(did, &info, H5O_INFO_BASIC ); + if(status != 0) + TEST_ERROR - status = H5Dclose( did ); - if ( status != 0 ) TEST_ERROR + status = H5Dclose(did); + if(status != 0) + TEST_ERROR return SUCCEED; @@ -13132,7 +13136,7 @@ test_versionbounds(void) return FAIL; } /* end test_versionbounds() */ - + /*----------------------------------------------------------------------------- * Function: test_object_header_minimization_dcpl * diff --git a/test/dtypes.c b/test/dtypes.c index 0175607..891969b 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -1216,8 +1216,8 @@ test_compound_6(void) orig = (unsigned char*)HDmalloc(nelmts * sizeof(struct st)); for (i=0; i<(int)nelmts; i++) { s_ptr = ((struct st*)((void *)orig)) + i; - s_ptr->b = (i*8+1) & 0x7fff; - s_ptr->d = (i*8+6) & 0x7fff; + s_ptr->b = (int16_t)((i*8+1) & 0x7fff); + s_ptr->d = (int16_t)((i*8+6) & 0x7fff); } HDmemcpy(buf, orig, nelmts*sizeof(struct st)); diff --git a/test/external_env.c b/test/external_env.c index 01f2cba..e9c7635 100644 --- a/test/external_env.c +++ b/test/external_env.c @@ -15,7 +15,6 @@ * Purpose: Tests datasets stored in external raw files. */ #include "external_common.h" -#include "external_fname.h" static const char *EXT_ENV_FNAME[] = { "extern_env_dir/env_file_1", @@ -189,7 +188,7 @@ main(void) HDputs("All external storage tests passed."); /* Clean up files used by file set tests */ - if(h5_cleanup(EXT_FNAME, fapl_id_old)) { + if(h5_cleanup(EXT_ENV_FNAME, fapl_id_old)) { HDremove("extern_env_1r.raw"); HDremove("extern_env_2r.raw"); HDremove("extern_env_3r.raw"); diff --git a/test/getname.c b/test/getname.c index 873ceb9..399f364 100644 --- a/test/getname.c +++ b/test/getname.c @@ -2380,7 +2380,7 @@ test_main(hid_t file_id, hid_t fapl) if((size = H5Iget_name(dtype, NULL, 0)) != 0) TEST_ERROR /* Create a link to the object */ - if( H5Olink(dtype, file2_id, "datatype", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Olink(dtype, file2_id, "datatype", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Commit a second datatype with no links to it and commit it */ if((dtype_anon = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR @@ -2405,17 +2405,17 @@ test_main(hid_t file_id, hid_t fapl) /* Check the H5Iget_name does not return an error for anon committed datatypes */ if((dtype_anon = H5Oopen_by_addr(file2_id, oinfo.addr)) < 0) TEST_ERROR - if((size = H5Iget_name(dtype_anon,NULL,0)) != 0) TEST_ERROR + if((size = H5Iget_name(dtype_anon, NULL, 0)) != 0) TEST_ERROR if(H5Tclose(dtype_anon) < 0) TEST_ERROR if(H5Fclose(file2_id) < 0) TEST_ERROR PASSED(); - return(0); + return 0; error: - return(1); + return 1; } static int diff --git a/test/h5test.c b/test/h5test.c index 67c73f1..6a3a5cb 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -1321,8 +1321,7 @@ h5_dump_info_object(MPI_Info info) int flag; int i, nkeys; - HDprintf("Dumping MPI Info Object(%d) (up to %d bytes per item):\n", (int)info, - MPI_MAX_INFO_VAL); + HDprintf("Dumping MPI Info Object (up to %d bytes per item):\n", MPI_MAX_INFO_VAL); if (info==MPI_INFO_NULL){ HDprintf("object is MPI_INFO_NULL\n"); } diff --git a/test/links.c b/test/links.c index 5774f97..4dff1cf 100644 --- a/test/links.c +++ b/test/links.c @@ -31,10 +31,10 @@ #include "h5test.h" #include "H5srcdir.h" -#include "H5FDpkg.h" /* File drivers */ -#include "H5Gpkg.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ +#include "H5FDpkg.h" /* File drivers */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ /* File for external link test. Created with gen_udlinks.c */ #define LINKED_FILE "be_extlink2.h5" @@ -537,9 +537,9 @@ cklinks(hid_t fapl, hbool_t new_format) status = H5Lexists(file, "no_grp1/hard", H5P_DEFAULT); } H5E_END_TRY; if(status >= 0) { - H5_FAILED(); - HDputs(" H5Lexists() should have failed for a path with missing components."); - TEST_ERROR + H5_FAILED(); + HDputs(" H5Lexists() should have failed for a path with missing components."); + TEST_ERROR } /* end if */ H5E_BEGIN_TRY { status = H5Lexists(file, "/no_grp1/hard", H5P_DEFAULT); @@ -635,7 +635,7 @@ cklinks(hid_t fapl, hbool_t new_format) error: return FAIL; -} +} /* end cklinks() */ /*------------------------------------------------------------------------- @@ -686,11 +686,11 @@ ck_new_links(hid_t fapl, hbool_t new_format) if(H5Fclose(file) < 0) TEST_ERROR PASSED(); - return SUCCEED; + return 0; error: - return FAIL; -} + return -1; +} /* end ck_new_links() */ /*------------------------------------------------------------------------- @@ -3456,33 +3456,58 @@ error: static int external_set_elink_fapl2(hid_t fapl, hbool_t new_format) { - hid_t fid = (-1); /* File ID */ - hid_t gid = (-1); /* Group IDs */ - hid_t core_fapl = -1, space = -1, dset = -1, did = -1, dapl_id = -1, dcpl = -1; - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE], - cwdpath[NAME_BUF_SIZE]; - hsize_t dims[2]; - int points[NUM40][NUM40]; - int i, j, n; - h5_stat_size_t filesize, new_filesize; + hid_t fid = H5I_INVALID_HID; + hid_t gid = H5I_INVALID_HID; + hid_t core_fapl = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; + hid_t dset = H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; + hid_t dapl_id = H5I_INVALID_HID; + hid_t dcpl = H5I_INVALID_HID; + char *filename1 = NULL; + char *filename2 = NULL; + char *tmpname = NULL; + char *cwdpath = NULL; + hsize_t dims[2]; + int **points = NULL; + int *points_data = NULL; + int i, j, n; + h5_stat_size_t filesize; + h5_stat_size_t new_filesize; if(new_format) TESTING("H5Pset/get_elink_fapl() with same physical layout (w/new group format)") else TESTING("H5Pset/get_elink_fapl() with same physical layout") + /* Set up file names and paths */ + if(NULL == (filename1 = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + if(NULL == (filename2 = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + if(NULL == (tmpname = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + if(NULL == (cwdpath = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + if((HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) || (NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE))) TEST_ERROR + /* Set up data array */ + if(NULL == (points_data = (int *)HDcalloc(NUM40 * NUM40, sizeof(int)))) + TEST_ERROR; + if(NULL == (points = (int **)HDcalloc(NUM40, sizeof(points_data)))) + TEST_ERROR; + for (i = 0; i < NUM40; i++) + points[i] = points_data + (i * NUM40); + /* * set up name for main file: * Linux: "/CWD/tmp_links/extlinks0" * Windows: "<cur drive>:/CWD/tmp_links/extlinks0" */ fix_ext_filename(tmpname, cwdpath, FILENAME[13]); - h5_fixname(tmpname, fapl, filename1, sizeof filename1); + h5_fixname(tmpname, fapl, filename1, NAME_BUF_SIZE); /* create fapl for the target file to be a "core" file */ core_fapl = h5_fileaccess(); @@ -3490,7 +3515,7 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) /* set up name for external linked target file: "extlinks17" */ /* set up name for target file: "extlinks17" */ - h5_fixname(FILENAME[39], core_fapl, filename2, sizeof filename2); + h5_fixname(FILENAME[39], core_fapl, filename2, NAME_BUF_SIZE); /* Create the target file to be a "core" file */ if((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, core_fapl)) < 0) TEST_ERROR @@ -3505,7 +3530,8 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) dcpl = H5Pcreate(H5P_DATASET_CREATE); else dcpl = H5Pcopy(dcpl_g); - if (0 > dcpl) TEST_ERROR; + if (0 > dcpl) + TEST_ERROR; if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE) < 0) TEST_ERROR; /* create "Dataset" in group "A" of target file */ @@ -3548,7 +3574,7 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) points[i][j] = n++; /* Write the data to the dataset */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0) TEST_ERROR + if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points_data) < 0) TEST_ERROR if(H5Pclose(dapl_id) < 0) TEST_ERROR if(H5Dclose(did) < 0) TEST_ERROR @@ -3561,6 +3587,14 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) if(H5Pclose(core_fapl) < 0) TEST_ERROR + HDfree(points); + HDfree(points_data); + + HDfree(filename1); + HDfree(filename2); + HDfree(tmpname); + HDfree(cwdpath); + PASSED(); return SUCCEED; @@ -3575,6 +3609,15 @@ error: H5Gclose(gid); H5Fclose(fid); } H5E_END_TRY; + + HDfree(points); + HDfree(points_data); + + HDfree(filename1); + HDfree(filename2); + HDfree(tmpname); + HDfree(cwdpath); + return FAIL; } /* end external_set_elink_fapl2() */ @@ -6059,19 +6102,26 @@ static int external_symlink(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) { #ifdef H5_HAVE_SYMLINK - hid_t file1 = -1, file2 = -1, file3 = -1, file4 = -1, file5 = -1; - hid_t group2 = -1, group3 = -1, group4 = -1, group5 = -1; - char filename1[NAME_BUF_SIZE], - filename2a[NAME_BUF_SIZE], - filename2b[NAME_BUF_SIZE], - filename3a[NAME_BUF_SIZE], - filename3b[NAME_BUF_SIZE], - filename4a[NAME_BUF_SIZE], - filename4b[NAME_BUF_SIZE], - filename5a[NAME_BUF_SIZE], - filename5b[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE], - cwdpath[NAME_BUF_SIZE]; + hid_t file1 = H5I_INVALID_HID; + hid_t file2 = H5I_INVALID_HID; + hid_t file3 = H5I_INVALID_HID; + hid_t file4 = H5I_INVALID_HID; + hid_t file5 = H5I_INVALID_HID; + hid_t group2 = H5I_INVALID_HID; + hid_t group3 = H5I_INVALID_HID; + hid_t group4 = H5I_INVALID_HID; + hid_t group5 = H5I_INVALID_HID; + char *filename1 = NULL; + char *filename2a = NULL; + char *filename2b = NULL; + char *filename3a = NULL; + char *filename3b = NULL; + char *filename4a = NULL; + char *filename4b = NULL; + char *filename5a = NULL; + char *filename5b = NULL; + char *tmpname = NULL; + char *cwdpath = NULL; hbool_t have_posix_compat_vfd; /* Whether VFD used is compatible w/POSIX I/O calls */ #endif /* H5_HAVE_SYMLINK */ @@ -6087,144 +6137,179 @@ external_symlink(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) have_posix_compat_vfd = (hbool_t)(!HDstrcmp(env_h5_drvr, "sec2") || !HDstrcmp(env_h5_drvr, "core") || !HDstrcmp(env_h5_drvr, "nomatch")); - if(have_posix_compat_vfd) { - /* set up name for main file: "extlinks21A" */ - h5_fixname(FILENAME[45], fapl, filename1, sizeof(filename1)); + if(!have_posix_compat_vfd) { + SKIPPED(); + HDputs(" Current VFD doesn't support POSIX I/O calls"); + return SUCCEED; + } - /* create tmp_links directory and get current working directory path */ - if(HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) - TEST_ERROR - if(HDmkdir(TMPDIR2, (mode_t)0755) < 0 && errno != EEXIST) - TEST_ERROR - if(NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE)) - TEST_ERROR + if(NULL == (filename1 = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + if(NULL == (filename2a = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + if(NULL == (filename2b = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + if(NULL == (filename3a = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + if(NULL == (filename3b = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + if(NULL == (filename4a = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + if(NULL == (filename4b = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + if(NULL == (filename5a = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + if(NULL == (filename5b = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + if(NULL == (tmpname = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + if(NULL == (cwdpath = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + + /* set up name for main file: "extlinks21A" */ + h5_fixname(FILENAME[45], fapl, filename1, NAME_BUF_SIZE); + + /* create tmp_links directory and get current working directory path */ + if(HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) + TEST_ERROR + if(HDmkdir(TMPDIR2, (mode_t)0755) < 0 && errno != EEXIST) + TEST_ERROR + if(NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE)) + TEST_ERROR - /* Set up names for files in the subdirectories */ + /* Set up names for files in the subdirectories */ - /* set up names for file #2 in temporary directory #2: "tmp2_links/extlinks21B" */ - h5_fixname(FILENAME[46], fapl, filename2a, sizeof(filename2a)); - fix_ext_filename(tmpname, cwdpath, FILENAME[46]); - h5_fixname(tmpname, fapl, filename2b, sizeof(filename2b)); + /* set up names for file #2 in temporary directory #2: "tmp2_links/extlinks21B" */ + h5_fixname(FILENAME[46], fapl, filename2a, NAME_BUF_SIZE); + fix_ext_filename(tmpname, cwdpath, FILENAME[46]); + h5_fixname(tmpname, fapl, filename2b, NAME_BUF_SIZE); - /* Create symbolic link #1 in temporary directory #1 to file #2 in temporary directory #2 */ - /* (i.e. tmp_links/sym1.h5 -> <full path to>/tmp2_links/extlinks21B.h5) */ - if(HDsymlink(filename2b, SYMLINK1) < 0 && errno != EEXIST) TEST_ERROR + /* Create symbolic link #1 in temporary directory #1 to file #2 in temporary directory #2 */ + /* (i.e. tmp_links/sym1.h5 -> <full path to>/tmp2_links/extlinks21B.h5) */ + if(HDsymlink(filename2b, SYMLINK1) < 0 && errno != EEXIST) TEST_ERROR - /* set up name for file #3 in temporary directory #2: "tmp2_links/extlinks21C" */ - h5_fixname(FILENAME[47], fapl, filename3a, sizeof(filename3a)); - h5_fixname(FILENAME[48], fapl, filename3b, sizeof(filename3b)); + /* set up name for file #3 in temporary directory #2: "tmp2_links/extlinks21C" */ + h5_fixname(FILENAME[47], fapl, filename3a, NAME_BUF_SIZE); + h5_fixname(FILENAME[48], fapl, filename3b, NAME_BUF_SIZE); - /* set up name for file #4 in temporary directory #1: "tmp_links/extlinks21D" */ - h5_fixname(FILENAME[49], fapl, filename4a, sizeof(filename4a)); - fix_ext_filename(tmpname, cwdpath, FILENAME[49]); - h5_fixname(tmpname, fapl, filename4b, sizeof(filename4b)); + /* set up name for file #4 in temporary directory #1: "tmp_links/extlinks21D" */ + h5_fixname(FILENAME[49], fapl, filename4a, NAME_BUF_SIZE); + fix_ext_filename(tmpname, cwdpath, FILENAME[49]); + h5_fixname(tmpname, fapl, filename4b, NAME_BUF_SIZE); - /* Create symbolic link #2 in temporary directory #2 to file #4 in temporary directory #1 */ - /* (i.e. tmp2_links/sym2.h5 -> <full path to>/tmp_links/extlinks21D.h5) */ - if(HDsymlink(filename4b, SYMLINK2) < 0 && errno != EEXIST) TEST_ERROR + /* Create symbolic link #2 in temporary directory #2 to file #4 in temporary directory #1 */ + /* (i.e. tmp2_links/sym2.h5 -> <full path to>/tmp_links/extlinks21D.h5) */ + if(HDsymlink(filename4b, SYMLINK2) < 0 && errno != EEXIST) TEST_ERROR - /* set up name for file #5 in temporary directory #1: "tmp_links/extlinks21E" */ - h5_fixname(FILENAME[50], fapl, filename5a, sizeof(filename5a)); - h5_fixname(FILENAME[51], fapl, filename5b, sizeof(filename5b)); + /* set up name for file #5 in temporary directory #1: "tmp_links/extlinks21E" */ + h5_fixname(FILENAME[50], fapl, filename5a, NAME_BUF_SIZE); + h5_fixname(FILENAME[51], fapl, filename5b, NAME_BUF_SIZE); - /* Create file #1 in current directory */ - if((file1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + /* Create file #1 in current directory */ + if((file1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - /* Create external link to file & object in temporary directory #2, using symlink #1 name */ - if(H5Lcreate_external(SYMLINK1, "group2", file1, "extlink2-sym", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + /* Create external link to file & object in temporary directory #2, using symlink #1 name */ + if(H5Lcreate_external(SYMLINK1, "group2", file1, "extlink2-sym", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - /* Close file #1 */ - if(H5Fclose(file1) < 0) TEST_ERROR + /* Close file #1 */ + if(H5Fclose(file1) < 0) TEST_ERROR + + /* Create file #2 in tmp_links directory #2 */ + if((file2 = H5Fcreate(filename2a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if(H5Fclose(file2) < 0) TEST_ERROR - /* Create file #2 in tmp_links directory #2 */ - if((file2 = H5Fcreate(filename2a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if(H5Fclose(file2) < 0) TEST_ERROR + /* Re-open file #2 in tmp_links directory through symlink */ + if((file2 = H5Fopen(SYMLINK1, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - /* Re-open file #2 in tmp_links directory through symlink */ - if((file2 = H5Fopen(SYMLINK1, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR + /* Create group in file #2 in temporary directory */ + if((group2 = H5Gcreate2(file2, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - /* Create group in file #2 in temporary directory */ - if((group2 = H5Gcreate2(file2, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + /* Create external link to file #3 & object in temporary directory #2 */ + if(H5Lcreate_external(filename3b, "group3", group2, "extlink3", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - /* Create external link to file #3 & object in temporary directory #2 */ - if(H5Lcreate_external(filename3b, "group3", group2, "extlink3", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + /* Close group in file #2 */ + if(H5Gclose(group2) < 0) TEST_ERROR - /* Close group in file #2 */ - if(H5Gclose(group2) < 0) TEST_ERROR + /* Close file #2 */ + if(H5Fclose(file2) < 0) TEST_ERROR - /* Close file #2 */ - if(H5Fclose(file2) < 0) TEST_ERROR + /* Create file #3 in temp. directory #2 */ + if((file3 = H5Fcreate(filename3a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - /* Create file #3 in temp. directory #2 */ - if((file3 = H5Fcreate(filename3a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + /* Create group in file #3 */ + if((group3 = H5Gcreate2(file3, "group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - /* Create group in file #3 */ - if((group3 = H5Gcreate2(file3, "group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + /* Create external link to file & object in temporary directory #1, using symlink #2 name */ + if(H5Lcreate_external(SYMLINK2, "group4", group3, "extlink4-sym", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - /* Create external link to file & object in temporary directory #1, using symlink #2 name */ - if(H5Lcreate_external(SYMLINK2, "group4", group3, "extlink4-sym", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + /* Close group in file #3 */ + if(H5Gclose(group3) < 0) TEST_ERROR - /* Close group in file #3 */ - if(H5Gclose(group3) < 0) TEST_ERROR + /* Close file #3 */ + if(H5Fclose(file3) < 0) TEST_ERROR - /* Close file #3 */ - if(H5Fclose(file3) < 0) TEST_ERROR + /* Create file #4 in temporary directory #1 */ + if((file4 = H5Fcreate(filename4b, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - /* Create file #4 in temporary directory #1 */ - if((file4 = H5Fcreate(filename4b, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + /* Create group in file #4 in 'temporary' directory */ + if((group4 = H5Gcreate2(file4, "group4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - /* Create group in file #4 in 'temporary' directory */ - if((group4 = H5Gcreate2(file4, "group4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + /* Create external link to file #5 & object in temporary directory #1 */ + if(H5Lcreate_external(filename5b, "group5", group4, "extlink5", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - /* Create external link to file #5 & object in temporary directory #1 */ - if(H5Lcreate_external(filename5b, "group5", group4, "extlink5", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + /* Close group in file #4 */ + if(H5Gclose(group4) < 0) TEST_ERROR - /* Close group in file #4 */ - if(H5Gclose(group4) < 0) TEST_ERROR + /* Close file #4 */ + if(H5Fclose(file4) < 0) TEST_ERROR - /* Close file #4 */ - if(H5Fclose(file4) < 0) TEST_ERROR + /* Create file #5 in temporary directory #1 */ + if((file5 = H5Fcreate(filename5a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - /* Create file #5 in temporary directory #1 */ - if((file5 = H5Fcreate(filename5a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + /* Create group in file #5 in 'temporary' directory #1 */ + if((group5 = H5Gcreate2(file5, "group5", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if(H5Gclose(group5) < 0) TEST_ERROR - /* Create group in file #5 in 'temporary' directory #1 */ - if((group5 = H5Gcreate2(file5, "group5", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(group5) < 0) TEST_ERROR + /* Close file #5 */ + if(H5Fclose(file5) < 0) TEST_ERROR - /* Close file #5 */ - if(H5Fclose(file5) < 0) TEST_ERROR + /* Actual tests... */ - /* Actual tests... */ + /* Reopen file #1 */ + if((file1 = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - /* Reopen file #1 */ - if((file1 = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR + /* Open group in file #2, through external link w/symlink */ + if((group2 = H5Gopen2(file1, "extlink2-sym", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if(H5Gclose(group2) < 0) TEST_ERROR - /* Open group in file #2, through external link w/symlink */ - if((group2 = H5Gopen2(file1, "extlink2-sym", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(group2) < 0) TEST_ERROR + /* Open group in file #3, through external link w/symlink to external link */ + if((group3 = H5Gopen2(file1, "extlink2-sym/extlink3", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if(H5Gclose(group3) < 0) TEST_ERROR - /* Open group in file #3, through external link w/symlink to external link */ - if((group3 = H5Gopen2(file1, "extlink2-sym/extlink3", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(group3) < 0) TEST_ERROR + /* Open group in file #4, through external link w/symlink to external link w/symlink */ + if((group4 = H5Gopen2(file1, "extlink2-sym/extlink3/extlink4-sym", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if(H5Gclose(group4) < 0) TEST_ERROR - /* Open group in file #4, through external link w/symlink to external link w/symlink */ - if((group4 = H5Gopen2(file1, "extlink2-sym/extlink3/extlink4-sym", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(group4) < 0) TEST_ERROR + /* Open group in file #5, through external link w/symlink to external link w/symlink to external link */ + if((group5 = H5Gopen2(file1, "extlink2-sym/extlink3/extlink4-sym/extlink5", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if(H5Gclose(group5) < 0) TEST_ERROR - /* Open group in file #5, through external link w/symlink to external link w/symlink to external link */ - if((group5 = H5Gopen2(file1, "extlink2-sym/extlink3/extlink4-sym/extlink5", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(group5) < 0) TEST_ERROR + /* Close file #1 */ + if(H5Fclose(file1) < 0) TEST_ERROR - /* Close file #1 */ - if(H5Fclose(file1) < 0) TEST_ERROR + HDfree(filename1); + HDfree(filename2a); + HDfree(filename2b); + HDfree(filename3a); + HDfree(filename3b); + HDfree(filename4a); + HDfree(filename4b); + HDfree(filename5a); + HDfree(filename5b); + HDfree(tmpname); + HDfree(cwdpath); - PASSED(); - } /* end if */ - else { - SKIPPED(); - HDputs(" Current VFD doesn't support POSIX I/O calls"); - } /* end else */ + PASSED(); return SUCCEED; @@ -6240,7 +6325,21 @@ error: H5Fclose(file2); H5Fclose(file1); } H5E_END_TRY; + + HDfree(filename1); + HDfree(filename2a); + HDfree(filename2b); + HDfree(filename3a); + HDfree(filename3b); + HDfree(filename4a); + HDfree(filename4b); + HDfree(filename5a); + HDfree(filename5b); + HDfree(tmpname); + HDfree(cwdpath); + return FAIL; + #else /* H5_HAVE_SYMLINK */ SKIPPED(); HDputs(" Current file system or operating system doesn't support symbolic links"); @@ -7081,7 +7180,7 @@ UD_hard_create(const char H5_ATTR_UNUSED * link_name, hid_t loc_group, const voi addr = *((const haddr_t *)udata); /* Open the object this link points to */ - target_obj= H5Oopen_by_addr(loc_group, addr); + target_obj = H5Oopen_by_addr(loc_group, addr); if(target_obj < 0) { ret_value = -1; goto done; @@ -7173,7 +7272,7 @@ UD_hard_delete(const char H5_ATTR_UNUSED * link_name, hid_t file, const void *ud addr = *((const haddr_t *) udata); /* Open the object this link points to */ - target_obj= H5Oopen_by_addr(file, addr); + target_obj = H5Oopen_by_addr(file, addr); if(target_obj < 0) { ret_value = -1; goto done; @@ -7371,7 +7470,7 @@ error: * Failure: -1 *------------------------------------------------------------------------- */ - /* A traversal function that ignores any udata and simply opens an object +/* A traversal function that ignores any udata and simply opens an object * in the current group named REREG_TARGET_NAME */ static hid_t @@ -7723,7 +7822,7 @@ ud_callbacks(hid_t fapl, hbool_t new_format) if(H5Gclose(gid) < 0) TEST_ERROR /* Query the link to test its query callback */ - if (H5Lget_info(fid, UD_CB_LINK_NAME, &li, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Lget_info(fid, UD_CB_LINK_NAME, &li, H5P_DEFAULT) < 0) TEST_ERROR if(li.u.val_size != 16) TEST_ERROR if (UD_CB_TYPE != li.type) { H5_FAILED(); diff --git a/test/mount.c b/test/mount.c index b7d2858..72973ad 100644 --- a/test/mount.c +++ b/test/mount.c @@ -404,38 +404,41 @@ test_hide(hid_t fapl) char filename1[1024], filename2[1024]; TESTING("name hiding under mount point"); - h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1); - h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2); + h5_fixname(FILENAME[0], fapl, filename1, sizeof(filename1)); + h5_fixname(FILENAME[1], fapl, filename2, sizeof(filename2)); if((file1 = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0 || (file2 = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR /* Get information about file1:/mnt1/file1 for later */ - if(H5Oget_info_by_name2(file1, "/mnt1/file1", &oi1, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if(H5Oget_info_by_name2(file1, "/mnt1/file1", &oi1, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Build the virtual file */ - if(H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if(H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* Original names under file1:/mnt1 should not be accessible */ H5E_BEGIN_TRY { - grp = H5Gopen2(file1, "/mnt1/file1", H5P_DEFAULT); + grp = H5Gopen2(file1, "/mnt1/file1", H5P_DEFAULT); } H5E_END_TRY; if(grp >= 0) { - H5_FAILED(); - HDputs(" Name is still accessible under mount point."); - TEST_ERROR + H5_FAILED(); + HDputs(" Name is still accessible under mount point."); + TEST_ERROR } /* end if */ /* * The original objects under file1:/mnt1 are still accessible by their * other names. This is a rather stupid test but demonstrates a point. */ - if(H5Oget_info_by_name2(file1, "/file1", &oi2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if(H5Oget_info_by_name2(file1, "/file1", &oi2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR if(oi1.fileno != oi2.fileno || H5F_addr_ne(oi1.addr, oi2.addr)) { - H5_FAILED(); - HDputs(" Hard link failed for hidden object."); - TEST_ERROR + H5_FAILED(); + HDputs(" Hard link failed for hidden object."); + TEST_ERROR } /* end if */ /* Unmount and close objects */ @@ -448,9 +451,9 @@ test_hide(hid_t fapl) error: H5E_BEGIN_TRY { - H5Gclose(grp); - H5Fclose(file1); - H5Fclose(file2); + H5Gclose(grp); + H5Fclose(file1); + H5Fclose(file2); } H5E_END_TRY; return 1; } /* end test_hide() */ @@ -490,20 +493,23 @@ test_assoc(hid_t fapl) FAIL_STACK_ERROR /* Get information about the root of file2 */ - if(H5Oget_info2(file2, &oi1, H5O_INFO_BASIC) < 0) FAIL_STACK_ERROR + if(H5Oget_info2(file2, &oi1, H5O_INFO_BASIC) < 0) + FAIL_STACK_ERROR /* Create the virtual file */ - if(H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if(H5Fmount(file1, "/mnt1", file2, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR /* * Get info about the mount point -- should be the same as the root group * of file2. */ - if(H5Oget_info_by_name2(file1, "/mnt1", &oi2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + if(H5Oget_info_by_name2(file1, "/mnt1", &oi2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) + FAIL_STACK_ERROR if(oi1.fileno != oi2.fileno || H5F_addr_ne(oi1.addr, oi2.addr)) { H5_FAILED(); - HDputs(" Association failed."); + HDputs(" Association failed."); TEST_ERROR } /* end if */ @@ -517,8 +523,8 @@ test_assoc(hid_t fapl) error: H5E_BEGIN_TRY { - H5Fclose(file2); - H5Fclose(file1); + H5Fclose(file2); + H5Fclose(file1); } H5E_END_TRY; return 1; } /* end test_assoc() */ diff --git a/test/mtime.c b/test/mtime.c index f7a441d..06f576b 100644 --- a/test/mtime.c +++ b/test/mtime.c @@ -39,9 +39,7 @@ const char *FILENAME[] = { * * Purpose: H5O_mtime_decode() test. * - * Return: Success: - * - * Failure: + * Return: EXIT_SUCCESS/EXIT_FAILURE * * Programmer: Robb Matzke * Thursday, July 30, 1998 @@ -188,10 +186,10 @@ main(void) /* All looks good */ HDputs("All modification time tests passed."); h5_cleanup(FILENAME, fapl); - return 0; + return EXIT_SUCCESS; /* Something broke */ error: - return 1; -} + return EXIT_FAILURE; +} /* end main() */ diff --git a/test/ntypes.c b/test/ntypes.c index 34558f5..f1d2449 100644 --- a/test/ntypes.c +++ b/test/ntypes.c @@ -2484,7 +2484,7 @@ test_opaque_dtype(hid_t file) TEST_ERROR; for(i = 0; i < sizeof(wbuf); i++) - wbuf[i] = (unsigned char)0xff ^ (unsigned char)i; + wbuf[i] = (unsigned char)(0xff ^ i); if(H5Dwrite(dset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0) TEST_ERROR; if(H5Sclose(space) < 0) TEST_ERROR; diff --git a/test/null_vol_connector.c b/test/null_vol_connector.c index 14e1a38..985b576 100644 --- a/test/null_vol_connector.c +++ b/test/null_vol_connector.c @@ -28,101 +28,105 @@ /* The VOL class struct */ static const H5VL_class_t null_vol_g = { - 0, /* version */ - NULL_VOL_CONNECTOR_VALUE, /* value */ - NULL_VOL_CONNECTOR_NAME, /* name */ + 0, /* version */ + NULL_VOL_CONNECTOR_VALUE, /* value */ + NULL_VOL_CONNECTOR_NAME, /* name */ 0, /* capability flags */ - NULL, /* initialize */ - NULL, /* terminate */ + NULL, /* initialize */ + NULL, /* terminate */ { /* info_cls */ - (size_t)0, /* size */ - NULL, /* copy */ - NULL, /* compare */ - NULL, /* free */ - NULL, /* to_str */ - NULL, /* from_str */ + (size_t)0, /* size */ + NULL, /* copy */ + NULL, /* compare */ + NULL, /* free */ + NULL, /* to_str */ + NULL, /* from_str */ }, { /* wrap_cls */ - NULL, /* get_object */ - NULL, /* get_wrap_ctx */ - NULL, /* wrap_object */ - NULL, /* unwrap_object */ - NULL, /* free_wrap_ctx */ + NULL, /* get_object */ + NULL, /* get_wrap_ctx */ + NULL, /* wrap_object */ + NULL, /* unwrap_object */ + NULL, /* free_wrap_ctx */ }, { /* attribute_cls */ - NULL, /* create */ - NULL, /* open */ - NULL, /* read */ - NULL, /* write */ - NULL, /* get */ - NULL, /* specific */ - NULL, /* optional */ - NULL /* close */ + NULL, /* create */ + NULL, /* open */ + NULL, /* read */ + NULL, /* write */ + NULL, /* get */ + NULL, /* specific */ + NULL, /* optional */ + NULL /* close */ }, { /* dataset_cls */ - NULL, /* create */ - NULL, /* open */ - NULL, /* read */ - NULL, /* write */ - NULL, /* get */ - NULL, /* specific */ - NULL, /* optional */ - NULL /* close */ + NULL, /* create */ + NULL, /* open */ + NULL, /* read */ + NULL, /* write */ + NULL, /* get */ + NULL, /* specific */ + NULL, /* optional */ + NULL /* close */ }, { /* datatype_cls */ - NULL, /* commit */ - NULL, /* open */ - NULL, /* get_size */ - NULL, /* specific */ - NULL, /* optional */ - NULL /* close */ + NULL, /* commit */ + NULL, /* open */ + NULL, /* get_size */ + NULL, /* specific */ + NULL, /* optional */ + NULL /* close */ }, { /* file_cls */ - NULL, /* create */ - NULL, /* open */ - NULL, /* get */ - NULL, /* specific */ - NULL, /* optional */ - NULL /* close */ + NULL, /* create */ + NULL, /* open */ + NULL, /* get */ + NULL, /* specific */ + NULL, /* optional */ + NULL /* close */ }, { /* group_cls */ - NULL, /* create */ - NULL, /* open */ - NULL, /* get */ - NULL, /* specific */ - NULL, /* optional */ - NULL /* close */ + NULL, /* create */ + NULL, /* open */ + NULL, /* get */ + NULL, /* specific */ + NULL, /* optional */ + NULL /* close */ }, { /* link_cls */ - NULL, /* create */ - NULL, /* copy */ - NULL, /* move */ - NULL, /* get */ - NULL, /* specific */ - NULL /* optional */ + NULL, /* create */ + NULL, /* copy */ + NULL, /* move */ + NULL, /* get */ + NULL, /* specific */ + NULL /* optional */ }, { /* object_cls */ - NULL, /* open */ - NULL, /* copy */ - NULL, /* get */ - NULL, /* specific */ - NULL /* optional */ + NULL, /* open */ + NULL, /* copy */ + NULL, /* get */ + NULL, /* specific */ + NULL /* optional */ + }, + { /* introspect_cls */ + NULL, /* get_conn_cls */ + NULL, /* opt_query */ }, { /* request_cls */ - NULL, /* wait */ - NULL, /* notify */ - NULL, /* cancel */ - NULL, /* specific */ - NULL, /* optional */ - NULL /* free */ + NULL, /* wait */ + NULL, /* notify */ + NULL, /* cancel */ + NULL, /* specific */ + NULL, /* optional */ + NULL /* free */ }, { /* blob_cls */ - NULL, /* put */ - NULL, /* get */ - NULL, /* specific */ - NULL /* optional */ + NULL, /* put */ + NULL, /* get */ + NULL, /* specific */ + NULL /* optional */ }, - NULL /* optional */ + NULL /* optional */ }; /* These two functions are necessary to load this plugin using diff --git a/test/objcopy.c b/test/objcopy.c index 751fe72..cabdbfd 100644 --- a/test/objcopy.c +++ b/test/objcopy.c @@ -157,6 +157,7 @@ const char *FILENAME[] = { #define NUM_SUB_GROUPS 20 #define NUM_WIDE_LOOP_GROUPS 10 #define NUM_DATASETS 10 +#define ATTR_CMPD_STRING "ThisIsAString" char src_obj_full_name[215]; /* the full path + name of the object to be copied */ @@ -194,9 +195,9 @@ compare_attribute_compound_vlstr(hid_t loc, hid_t loc2); * * Purpose: Add an address to the table. * - * Return: void + * Return: void * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Saturday, November 5, 2005 * *------------------------------------------------------------------------- @@ -228,11 +229,10 @@ addr_insert(H5O_info_t *oi) * * Purpose: Check if address has already been encountered * - * Return: Success: TRUE/FALSE - * - * Failure: (can't fail) + * Return: Success: TRUE/FALSE + * Failure: (can't fail) * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Saturday, November 5, 2005 * *------------------------------------------------------------------------- @@ -257,9 +257,9 @@ addr_lookup(H5O_info_t *oi) * * Purpose: Reset the address tracking data structures * - * Return: void + * Return: void * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Saturday, November 5, 2005 * *------------------------------------------------------------------------- @@ -5784,7 +5784,8 @@ attach_attribute_compound_vlstr(hid_t loc_id) int i; char *v; } s1; - s1 buf; /* Buffer */ + size_t len; + s1 buf = {0, NULL}; /* Buffer */ int ret_value = -1; /* Return value */ /* Create dataspace */ @@ -5814,8 +5815,11 @@ attach_attribute_compound_vlstr(hid_t loc_id) goto done; /* Write to the attribute */ + len = HDstrlen(ATTR_CMPD_STRING) + 1; buf.i = 9; - buf.v = "ThisIsAString"; + if(NULL == (buf.v = (char *)HDcalloc(len, sizeof(char)))) + goto done; + HDstrncpy(buf.v, ATTR_CMPD_STRING, len); if(H5Awrite(aid, cmpd_tid, &buf) < 0) goto done; @@ -5832,6 +5836,9 @@ done: H5Tclose(cmpd_tid); if(aid > 0) H5Aclose(aid); + + HDfree(buf.v); + return ret_value; } /* attach_attribute_compound_vlstr */ @@ -11464,8 +11471,8 @@ error: H5Tclose(f_tid); H5Tclose(g_tid); H5Tclose(anon_tid); - H5Pclose(ocpypl_id); - H5Aclose(aid); + H5Pclose(ocpypl_id); + H5Aclose(aid); H5Dclose(did); H5Sclose(sid); H5Gclose(gid); @@ -11704,14 +11711,14 @@ test_copy_cdt_merge_cdt(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t ds error: H5E_BEGIN_TRY { - H5Pclose(ocpypl_id); - H5Tclose(tid); - H5Tclose(tid1); - H5Tclose(tid2); - H5Tclose(tid3); - H5Tclose(tid4); - H5Tclose(tid5); - H5Aclose(aid); + H5Pclose(ocpypl_id); + H5Tclose(tid); + H5Tclose(tid1); + H5Tclose(tid2); + H5Tclose(tid3); + H5Tclose(tid4); + H5Tclose(tid5); + H5Aclose(aid); H5Sclose(sid); H5Fclose(fid_dst); H5Fclose(fid_src); diff --git a/test/objcopy_ref.c b/test/objcopy_ref.c index 33d1f64..4637f23 100644 --- a/test/objcopy_ref.c +++ b/test/objcopy_ref.c @@ -91,9 +91,9 @@ compare_groups(hid_t gid, hid_t gid2, hid_t pid, int depth, unsigned copy_flags) * * Purpose: Add an address to the table. * - * Return: void + * Return: void * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Saturday, November 5, 2005 * *------------------------------------------------------------------------- @@ -125,11 +125,10 @@ addr_insert(H5O_info_t *oi) * * Purpose: Check if address has already been encountered * - * Return: Success: TRUE/FALSE - * - * Failure: (can't fail) + * Return: Success: TRUE/FALSE + * Failure: (can't fail) * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Saturday, November 5, 2005 * *------------------------------------------------------------------------- @@ -154,9 +153,9 @@ addr_lookup(H5O_info_t *oi) * * Purpose: Reset the address tracking data structures * - * Return: void + * Return: void * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Saturday, November 5, 2005 * *------------------------------------------------------------------------- diff --git a/test/ohdr.c b/test/ohdr.c index 9d2d414..53d2f59 100644 --- a/test/ohdr.c +++ b/test/ohdr.c @@ -50,7 +50,8 @@ const char *FILENAME[] = { * To get this data file, define H5O_ENABLE_BOGUS in src/H5Oprivate, rebuild * the library and simply compile gen_bogus.c with that HDF5 library and run it. */ -#define FILE_BOGUS "tbogus.h5" +#define FILE_BOGUS "tbogus.h5" +#define TESTFILE_LEN 256 /* */ #define FILE_OHDR_SWMR "ohdr_swmr.h5" @@ -473,13 +474,13 @@ test_unknown(unsigned bogus_id, char *filename, hid_t fapl) hid_t fid_bogus = -1; /* bogus file ID */ hid_t gid_bogus = -1; /* bogus group ID */ hid_t loc_bogus = -1; /* location: bogus file or group ID */ - char testfile[256]; + char testfile[TESTFILE_LEN]; /* create a different name for a local copy of the data file to be opened with rd/wr file permissions in case build and test are done in the source directory. */ - HDstrncpy(testfile, FILE_BOGUS, HDstrlen(FILE_BOGUS)); - testfile[HDstrlen(FILE_BOGUS)]='\0'; + HDstrncpy(testfile, FILE_BOGUS, TESTFILE_LEN); + testfile[TESTFILE_LEN - 1]='\0'; HDstrncat(testfile, ".copy", 5); /* Make a copy of the data file from svn. */ @@ -759,7 +760,7 @@ count_attributes(hid_t dset_id) { H5O_info_t info; - if(H5Oget_info2(dset_id, &info, H5O_INFO_ALL) < 0) + if(H5Oget_info2(dset_id, &info, H5O_INFO_NUM_ATTRS) < 0) return -1; else return (int)info.num_attrs; /* should never exceed int bounds */ diff --git a/test/th5s.c b/test/th5s.c index 747e741..7e1e547 100644 --- a/test/th5s.c +++ b/test/th5s.c @@ -1739,12 +1739,12 @@ test_h5s_encode_regular_hyper(H5F_libver_t low, H5F_libver_t high) case CONFIG_16: stride = POWER16 - 1; block = 4; - expected_enc_size = expected_version == 3 ? 2 : 4; + expected_enc_size = (uint8_t)(expected_version == 3 ? 2 : 4); break; case CONFIG_32: stride = POWER32 - 1; block = 4; - expected_enc_size = expected_version == 3 ? 4 : 8; + expected_enc_size = (uint8_t)(expected_version == 3 ? 4 : 8); break; default: @@ -1765,12 +1765,12 @@ test_h5s_encode_regular_hyper(H5F_libver_t low, H5F_libver_t high) case CONFIG_16: stride = POWER16 - 1; block = POWER16 - 2; - expected_enc_size = expected_version == 3 ? 2 : 4; + expected_enc_size = (uint8_t)(expected_version == 3 ? 2 : 4); break; case CONFIG_32: stride = POWER32 - 1; block = POWER32 - 2; - expected_enc_size = expected_version == 3 ? 4 : 8; + expected_enc_size = (uint8_t)(expected_version == 3 ? 4 : 8); break; default: HDassert(0); @@ -1912,7 +1912,7 @@ test_h5s_encode_irregular_hyper(H5F_libver_t low, H5F_libver_t high) for(config = CONFIG_8; config <= CONFIG_32; config++) { hbool_t expected_to_fail = FALSE; /* Whether H5Sencode2 is expected to fail */ uint32_t expected_version = 0; /* Expected version for selection info */ - uint8_t expected_enc_size = 0; /* Expected encoded size for selection info */ + uint32_t expected_enc_size = 0; /* Expected encoded size for selection info */ start = 0; count = 2; @@ -1984,7 +1984,8 @@ test_h5s_encode_irregular_hyper(H5F_libver_t low, H5F_libver_t high) VERIFY(is_regular, FALSE, "H5Sis_regular_hyperslab"); /* Verify the version and encoded size expected for the configuration */ - ret = test_h5s_check_encoding(fapl, sid, expected_version, expected_enc_size, expected_to_fail); + HDassert(expected_enc_size <= 255); + ret = test_h5s_check_encoding(fapl, sid, expected_version, (uint8_t)expected_enc_size, expected_to_fail); CHECK(ret, FAIL, "test_h5s_check_encoding"); } /* for config */ diff --git a/test/titerate.c b/test/titerate.c index 289a46c..669a094 100644 --- a/test/titerate.c +++ b/test/titerate.c @@ -1045,10 +1045,10 @@ test_iterate(void) /* These next tests use the same file */ for(new_format = FALSE; new_format <= TRUE; new_format++) { test_iter_group(new_format ? fapl2 : fapl, new_format); /* Test group iteration */ - test_iter_group_large(new_format ? fapl2 : fapl); /* Test group iteration for large # of objects */ + test_iter_group_large(new_format ? fapl2 : fapl); /* Test group iteration for large # of objects */ test_iter_attr(new_format ? fapl2 : fapl, new_format); /* Test attribute iteration */ - test_grp_memb_funcs(new_format ? fapl2 : fapl); /* Test group member information functions */ - test_links(new_format ? fapl2 : fapl); /* Test soft and hard link iteration */ + test_grp_memb_funcs(new_format ? fapl2 : fapl); /* Test group member information functions */ + test_links(new_format ? fapl2 : fapl); /* Test soft and hard link iteration */ } /* end for */ /* Test the fix for issue HDFFV-10588 */ diff --git a/test/trefer.c b/test/trefer.c index cd09c8e..dec049e 100644 --- a/test/trefer.c +++ b/test/trefer.c @@ -568,7 +568,7 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) hsize_t high[SPACE2_RANK]; /* Selection bounds */ H5R_ref_t *wbuf, /* buffer to write to disk */ *rbuf; /* buffer read from disk */ - H5R_ref_t nvrbuf[3]={{{0}},{{101}},{{255}}}; /* buffer with non-valid refs */ + H5R_ref_t nvrbuf[3]={{{0}},{{101}},{{-128}}}; /* buffer with non-valid refs */ uint8_t *dwbuf, /* Buffer for writing numeric data to disk */ *drbuf; /* Buffer for reading numeric data from disk */ uint8_t *tu8; /* Temporary pointer to uint8 data */ @@ -2516,7 +2516,8 @@ test_reference_perf(void) ret = H5Rdestroy(&wbuf[0]); CHECK(ret, FAIL, "H5Rdestroy"); } - HDprintf("--- Object reference create time: %lfs\n", t / MAX_ITER_CREATE); + if(VERBOSE_MED) + HDprintf("--- Object reference create time: %lfs\n", t / MAX_ITER_CREATE); /* Create reference to dataset */ ret = H5Rcreate_object(fid1, "/Group1/Dataset1", H5P_DEFAULT, &wbuf[0]); @@ -2534,7 +2535,8 @@ test_reference_perf(void) t2 = H5_get_time(); t += t2 - t1; } - HDprintf("--- Object reference write time: %lfs\n", t / MAX_ITER_WRITE); + if(VERBOSE_MED) + HDprintf("--- Object reference write time: %lfs\n", t / MAX_ITER_WRITE); /* Close Dataset */ ret = H5Dclose(dataset); @@ -2552,7 +2554,8 @@ test_reference_perf(void) t2 = H5_get_time(); t += t2 - t1; } - HDprintf("--- Deprecated object reference create time: %lfs\n", t / MAX_ITER_CREATE); + if(VERBOSE_MED) + HDprintf("--- Deprecated object reference create time: %lfs\n", t / MAX_ITER_CREATE); /* Create reference to dataset */ ret = H5Rcreate(&wbuf_deprec[0], fid1, "/Group1/Dataset1", H5R_OBJECT1, H5I_INVALID_HID); @@ -2567,7 +2570,8 @@ test_reference_perf(void) t2 = H5_get_time(); t += t2 - t1; } - HDprintf("--- Deprecated object reference write time: %lfs\n", t / MAX_ITER_WRITE); + if(VERBOSE_MED) + HDprintf("--- Deprecated object reference write time: %lfs\n", t / MAX_ITER_WRITE); /* Close Dataset */ ret = H5Dclose(dataset); @@ -2588,7 +2592,8 @@ test_reference_perf(void) ret = H5Rdestroy(&wbuf_reg[0]); CHECK(ret, FAIL, "H5Rdestroy"); } - HDprintf("--- Region reference create time: %lfs\n", t / MAX_ITER_CREATE); + if(VERBOSE_MED) + HDprintf("--- Region reference create time: %lfs\n", t / MAX_ITER_CREATE); /* Store first dataset region */ ret = H5Rcreate_region(fid1, "/Group1/Dataset1", sid1, H5P_DEFAULT, &wbuf_reg[0]); @@ -2603,7 +2608,8 @@ test_reference_perf(void) t2 = H5_get_time(); t += t2 - t1; } - HDprintf("--- Region reference write time: %lfs\n", t / MAX_ITER_WRITE); + if(VERBOSE_MED) + HDprintf("--- Region reference write time: %lfs\n", t / MAX_ITER_WRITE); /* Close Dataset */ ret = H5Dclose(dataset); @@ -2622,7 +2628,8 @@ test_reference_perf(void) t2 = H5_get_time(); t += t2 - t1; } - HDprintf("--- Deprecated region reference create time: %lfs\n", t / MAX_ITER_CREATE); + if(VERBOSE_MED) + HDprintf("--- Deprecated region reference create time: %lfs\n", t / MAX_ITER_CREATE); t = 0; for(i = 0; i < MAX_ITER_WRITE; i++) { @@ -2633,7 +2640,8 @@ test_reference_perf(void) t2 = H5_get_time(); t += t2 - t1; } - HDprintf("--- Deprecated region reference write time: %lfs\n", t / MAX_ITER_WRITE); + if(VERBOSE_MED) + HDprintf("--- Deprecated region reference write time: %lfs\n", t / MAX_ITER_WRITE); /* Close Dataset */ ret = H5Dclose(dataset); @@ -2666,7 +2674,8 @@ test_reference_perf(void) ret = H5Rdestroy(&rbuf[0]); CHECK(ret, FAIL, "H5Rdestroy"); } - HDprintf("--- Object reference read time: %lfs\n", t / MAX_ITER_READ); + if(VERBOSE_MED) + HDprintf("--- Object reference read time: %lfs\n", t / MAX_ITER_READ); /* Read selection from disk */ ret = H5Dread(dataset, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf); @@ -2711,7 +2720,8 @@ test_reference_perf(void) t2 = H5_get_time(); t += t2 - t1; } - HDprintf("--- Deprecated object reference read time: %lfs\n", t / MAX_ITER_READ); + if(VERBOSE_MED) + HDprintf("--- Deprecated object reference read time: %lfs\n", t / MAX_ITER_READ); /* Close Dataset */ ret = H5Dclose(dataset); @@ -2732,7 +2742,8 @@ test_reference_perf(void) ret = H5Rdestroy(&rbuf_reg[0]); CHECK(ret, FAIL, "H5Rdestroy"); } - HDprintf("--- Region reference read time: %lfs\n", t / MAX_ITER_READ); + if(VERBOSE_MED) + HDprintf("--- Region reference read time: %lfs\n", t / MAX_ITER_READ); /* Read selection from disk */ ret = H5Dread(dataset, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf_reg); @@ -2755,7 +2766,8 @@ test_reference_perf(void) t2 = H5_get_time(); t += t2 - t1; } - HDprintf("--- Deprecated region reference read time: %lfs\n", t / MAX_ITER_READ); + if(VERBOSE_MED) + HDprintf("--- Deprecated region reference read time: %lfs\n", t / MAX_ITER_READ); /* Close Dataset */ ret = H5Dclose(dataset); @@ -2816,7 +2828,7 @@ test_reference(void) for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { /* Invalid combinations, just continue */ - if(high <= H5F_LIBVER_V112 || high < low) + if(high <= H5F_LIBVER_V110 || high < low) continue; test_reference_region(low, high); /* Test basic H5R dataset region reference code */ diff --git a/test/trefer_deprec.c b/test/trefer_deprec.c index 272b866..6322894 100644 --- a/test/trefer_deprec.c +++ b/test/trefer_deprec.c @@ -517,7 +517,7 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) hsize_t high[SPACE2_RANK]; /* Selection bounds */ hdset_reg_ref_t *wbuf, /* buffer to write to disk */ *rbuf; /* buffer read from disk */ - hdset_reg_ref_t nvrbuf[3]={{{0}},{{101}},{{255}}}; /* buffer with non-valid refs */ + hdset_reg_ref_t nvrbuf[3]={{{0}},{{101}},{{-128}}}; /* buffer with non-valid refs */ uint8_t *dwbuf, /* Buffer for writing numeric data to disk */ *drbuf; /* Buffer for reading numeric data from disk */ uint8_t *tu8; /* Temporary pointer to uint8 data */ diff --git a/test/tsohm.c b/test/tsohm.c index a064940..c126608 100644 --- a/test/tsohm.c +++ b/test/tsohm.c @@ -3342,11 +3342,11 @@ test_sohm_extlink(void) static int verify_dataset_extension(hid_t fcpl_id, hbool_t close_reopen) { - hid_t file_id = -1; - hid_t orig_space_id = -1; + hid_t file_id = H5I_INVALID_HID; + hid_t orig_space_id = H5I_INVALID_HID; hid_t space1_id, space2_id, space3_id; - hid_t dcpl_id = -1; - hid_t dset1_id, dset2_id, dset3_id; + hid_t dcpl_id = H5I_INVALID_HID; + hid_t dset1_id, dset2_id = H5I_INVALID_HID, dset3_id = H5I_INVALID_HID; hsize_t dims1[] = {1, 2}; hsize_t max_dims[] = {H5S_UNLIMITED, 2}; hsize_t dims2[] = {5, 2}; diff --git a/test/tvltypes.c b/test/tvltypes.c index acfd0a2..a6ed60e 100644 --- a/test/tvltypes.c +++ b/test/tvltypes.c @@ -465,15 +465,15 @@ test_vltypes_vlen_atomic(void) ret = H5Dvlen_get_buf_size(dataset, tid1, sid1, &size); CHECK(ret, FAIL, "H5Dvlen_get_buf_size"); + /* 10 elements allocated = 1 + 2 + 3 + 4 elements for each array position */ + VERIFY(size,((SPACE1_DIM1*(SPACE1_DIM1+1))/2)*sizeof(unsigned int),"H5Dvlen_get_buf_size"); + /* Try to call H5Dvlen_get_buf with bad dataspace */ H5E_BEGIN_TRY { ret = H5Dvlen_get_buf_size(dataset, tid1, sid2, &size); } H5E_END_TRY VERIFY(ret, FAIL, "H5Dvlen_get_buf_size"); - /* 10 elements allocated = 1 + 2 + 3 + 4 elements for each array position */ - VERIFY(size,((SPACE1_DIM1*(SPACE1_DIM1+1))/2)*sizeof(unsigned int),"H5Dvlen_get_buf_size"); - /* Read dataset from disk */ ret=H5Dread(dataset,tid1,H5S_ALL,H5S_ALL,xfer_pid,rdata); CHECK(ret, FAIL, "H5Dread"); diff --git a/test/unlink.c b/test/unlink.c index 6825dec..5199dcf 100644 --- a/test/unlink.c +++ b/test/unlink.c @@ -441,7 +441,7 @@ check_new_move(hid_t fapl) TESTING("check new move function"); /* Open file */ - h5_fixname(FILENAME[1], fapl, filename, sizeof filename); + h5_fixname(FILENAME[1], fapl, filename, sizeof(filename)); if((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR @@ -458,7 +458,7 @@ check_new_move(hid_t fapl) FAIL_PUTS_ERROR(" Hard link test failed. Link seems not to point to the expected file location.") /* Check soft links */ - if(H5Lget_val(file, "group2/soft", linkval, sizeof linkval, H5P_DEFAULT) < 0) + if(H5Lget_val(file, "group2/soft", linkval, sizeof(linkval), H5P_DEFAULT) < 0) FAIL_STACK_ERROR if(HDstrcmp(linkval, "/group1/group_move")) FAIL_PUTS_ERROR(" Soft link test failed. Wrong link value") @@ -123,6 +123,10 @@ static const H5VL_class_t fake_vol_g = { NULL, /* specific */ NULL /* optional */ }, + { /* introspect_cls */ + NULL, /* get_conn_cls */ + NULL, /* opt_query */ + }, { /* request_cls */ NULL, /* wait */ NULL, /* notify */ |