diff options
Diffstat (limited to 'test/cache_image.c')
-rw-r--r-- | test/cache_image.c | 649 |
1 files changed, 638 insertions, 11 deletions
diff --git a/test/cache_image.c b/test/cache_image.c index de0507b..0e7928a 100644 --- a/test/cache_image.c +++ b/test/cache_image.c @@ -4560,7 +4560,7 @@ cache_image_smoke_check_4(void) * If sufficient zoos have been created, continue to * 10). Otherwise goto 5) * - * 10) Open the file. + * 10) Open the file R/O. * * Verify that the file contains a metadata cache * image superblock extension message. @@ -4571,14 +4571,23 @@ cache_image_smoke_check_4(void) * * 13) Open the file. * - * Verify that the file doesn't contain a metadata cache + * Verify that the file contains a metadata cache * image superblock extension message. * * 14) Validate all the zoos. * * 15) Close the file. * - * 16) Delete the file. + * 16) Open the file. + * + * Verify that the file doesn't contain a metadata cache + * image superblock extension message. + * + * 17) Validate all the zoos. + * + * 18) Close the file. + * + * 19) Delete the file. * * Return: void * @@ -4821,9 +4830,56 @@ cache_image_smoke_check_5(void) } /* end while */ cp += 5; + /* 10) Open the file read only. + * + * Verify that the file contains a metadata cache image + * superblock extension message. + */ + if(pass) { + open_hdf5_file(/* create_file */ FALSE, + /* mdci_sbem_expected */ TRUE, + /* read_only */ TRUE, + /* set_mdci_fapl */ FALSE, + /* config_fsm */ FALSE, + /* hdf_file_name */ filename, + /* cache_image_flags */ 0, + /* file_id_ptr */ &file_id, + /* file_ptr_ptr */ &file_ptr, + /* cache_ptr_ptr */ &cache_ptr); + } + + if(show_progress) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 11) Validate all the zoos. */ + i = min_group; + while(pass && i <= max_group) { + sprintf(process_group_name, "/process_%d", i); + validate_zoo(file_id, process_group_name, i++); + } - - /* 10) Open the file. +#if H5C_COLLECT_CACHE_STATS + if( pass) { + if(cache_ptr->images_loaded == 0) { + pass = FALSE; + failure_mssg = "metadata cache image block not loaded(2)."; + } + } +#endif /* H5C_COLLECT_CACHE_STATS */ + + if(show_progress) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + /* 12) Close the file. */ + if(pass) { + if(H5Fclose(file_id) < 0) { + pass = FALSE; + failure_mssg = "H5Fclose() failed.\n"; + } + } + + /* 13) Open the file R/W. * * Verify that the file contains a metadata cache image * superblock extension message. @@ -4847,7 +4903,7 @@ cache_image_smoke_check_5(void) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 11) Validate all the zoos. */ + /* 14) Validate all the zoos. */ i = min_group; while ( ( pass ) && ( i <= max_group ) ) { @@ -4871,7 +4927,7 @@ cache_image_smoke_check_5(void) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 12) Close the file. */ + /* 15) Close the file. */ if ( pass ) { @@ -4883,7 +4939,7 @@ cache_image_smoke_check_5(void) } - /* 13) Open the file. + /* 16) Open the file. * * Verify that the file doesn't contain a metadata cache image * superblock extension message. @@ -4907,7 +4963,7 @@ cache_image_smoke_check_5(void) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 14) Validate all the zoos. + /* 17) Validate all the zoos. * * Verify that the metadata cache image superblock * extension message has been deleted. @@ -4935,7 +4991,7 @@ cache_image_smoke_check_5(void) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 15) Close the file. */ + /* 18) Close the file. */ if ( pass ) { @@ -4950,7 +5006,7 @@ cache_image_smoke_check_5(void) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 16) Delete the file */ + /* 19) Delete the file */ if ( pass ) { @@ -6444,6 +6500,576 @@ cache_image_api_error_check_3(void) /*------------------------------------------------------------------------- + * Function: cache_image_api_error_check_4() + * + * Purpose: This test is one of a sequence of tests intended + * to verify correct management of API errors. + * + * The object of this test is to verify that a request for + * a cache image when a version 2 superblock is not available/ + * not requested is handled correctly. + * (the cache image request should be ignored silently). + * + * The test is set up as follows: + * + * 1) Create a FAPL requesting a cache image, but WITHOUT + * specifying the latest file format. + * + * 2) Create a HDF5 file using the above FAPL. + * + * 3) Create some datasets in the file. + * + * 4) Close the file. + * + * 5) Open the file read only. Verify that the file doesn't + * contain a cache image. + * + * 6) Verify that the datasets exist and contain the + * expected data + * + * Verify that the cache image was not loaded. + * + * 7) Close the file. + * + * 8) Open the file R/W using the FAPL defined in 1) above. + * Verify that the file does not contain a cache image. + * + * 9) Close the file. + * + * 10) Open the file R/W using the FAPL defined in 1) above. + * Verify that the file does not contain a cache image. + * + * 11) Verify that the data sets contain the expected data + * + * Verify that a cache image was not loaded. + * + * 12) Create several more data sets. + * + * 13) Close the file. + * + * 14) Open the file read write. + * + * Verify that the file does not contain a cache image. + * + * 15) Verify the data sets exist and contain the expected + * data. + * + * Verify that a cache image was not loaded. + * + * 16) Close the file. + * + * 17) Delete the file. + * + * Return: void + * + * Programmer: John Mainzer + * 9/25/15 + * + *------------------------------------------------------------------------- + */ + +static unsigned +cache_image_api_error_check_4(void) +{ + const char * fcn_name = "cache_image_api_error_check_4()"; + char filename[512]; + hbool_t show_progress = FALSE; + hid_t fapl_id = -1; + hid_t file_id = -1; + H5F_t *file_ptr = NULL; + H5C_t *cache_ptr = NULL; + int cp = 0; + H5AC_cache_image_config_t cache_image_config; + + TESTING("metadata cache image api error check 4"); + + pass = TRUE; + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* setup the file name */ + if ( pass ) { + + if ( h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename)) + == NULL ) { + + pass = FALSE; + failure_mssg = "h5_fixname() failed.\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + /* 1) Create a FAPL requesting a cache image, but WITHOUT + * specifying the latest file format. + */ + if ( pass ) { + + fapl_id = H5Pcreate(H5P_FILE_ACCESS); + + if ( fapl_id < 0 ) { + + pass = FALSE; + failure_mssg = "H5Pcreate() failed.\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + if ( pass ) { + + /* set cache image config fields to taste */ + cache_image_config.version = H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION; + cache_image_config.generate_image = TRUE; + cache_image_config.save_resize_status = FALSE; + cache_image_config.entry_ageout = H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE; + + if ( H5Pset_mdc_image_config(fapl_id, &cache_image_config) < 0 ) { + + pass = FALSE; + failure_mssg = "H5Pset_mdc_image_config() failed.\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 2) Create a HDF5 file using the above FAPL. */ + + if ( pass ) { + + file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); + + if ( file_id < 0 ) { + + pass = FALSE; + failure_mssg = "H5Fcreate() failed.\n"; + + } else { + + file_ptr = (struct H5F_t *)H5I_object_verify(file_id, H5I_FILE); + + if ( file_ptr == NULL ) { + + pass = FALSE; + failure_mssg = "Can't get file_ptr."; + + } + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + /* get a pointer to the files internal data structure and then + * to the cache structure + */ + if ( pass ) { + + if ( file_ptr->shared->cache == NULL ) { + + pass = FALSE; + failure_mssg = "can't get cache pointer(1).\n"; + + } else { + + cache_ptr = file_ptr->shared->cache; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 3) Create some datasets in the file. */ + + if ( pass ) { + + create_datasets(file_id, 0, 5); + } + +#if H5C_COLLECT_CACHE_STATS + if ( pass ) { + + HDassert(cache_ptr); + + if ( cache_ptr->images_loaded != 0 ) { + + pass = FALSE; + failure_mssg = "metadata cache image block loaded(1)."; + } + } +#endif /* H5C_COLLECT_CACHE_STATS */ + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 4) Close the file. */ + + if ( pass ) { + + if ( H5Fclose(file_id) < 0 ) { + + pass = FALSE; + failure_mssg = "H5Fclose() failed.\n"; + + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 5) Open the file read only. */ + + if ( pass ) { + + open_hdf5_file(/* create_file */ FALSE, + /* mdci_sbem_expected */ FALSE, + /* read_only */ TRUE, + /* set_mdci_fapl */ FALSE, + /* config_fsm */ FALSE, + /* hdf_file_name */ filename, + /* cache_image_flags */ H5C_CI__ALL_FLAGS, + /* file_id_ptr */ &file_id, + /* file_ptr_ptr */ &file_ptr, + /* cache_ptr_ptr */ &cache_ptr); + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 6) Verify that the datasets exist and contain the + * expected data + */ + + if ( pass ) { + + verify_datasets(file_id, 0, 5); + } + +#if H5C_COLLECT_CACHE_STATS + if ( pass ) { + + if ( cache_ptr->images_loaded != 0 ) { + + pass = FALSE; + failure_mssg = "metadata cache image block loaded(2)."; + } + } +#endif /* H5C_COLLECT_CACHE_STATS */ + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 7) Close the file. */ + + if ( pass ) { + + if ( H5Fclose(file_id) < 0 ) { + + pass = FALSE; + failure_mssg = "H5Fclose() failed.\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 8) Open the file R/W using the FAPL defined in 1) above. + * + * Verify that the file does not contain a cache image. + */ + + if ( pass ) { + + file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl_id); + + if ( file_id < 0 ) { + + pass = FALSE; + failure_mssg = "H5Fopen() failed.\n"; + + } else { + + file_ptr = (struct H5F_t *)H5I_object_verify(file_id, H5I_FILE); + + if ( file_ptr == NULL ) { + + pass = FALSE; + failure_mssg = "Can't get file_ptr."; + + } + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + /* get a pointer to the files internal data structure and then + * to the cache structure + */ + if ( pass ) { + + if ( file_ptr->shared->cache == NULL ) { + + pass = FALSE; + failure_mssg = "can't get cache pointer(1).\n"; + + } else { + + cache_ptr = file_ptr->shared->cache; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + if ( pass ) { + + if ( ( cache_ptr->load_image == TRUE ) || + ( cache_ptr->delete_image == TRUE ) ) { + + pass = FALSE; + failure_mssg = "mdci sb extension message present?\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 9) Close the file. */ + + if ( pass ) { + + if ( H5Fclose(file_id) < 0 ) { + + pass = FALSE; + failure_mssg = "H5Fclose() failed.\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + + /* 10) Open the file R/W using the FAPL defined in 1) above. + * Verify that the file does not contain a cache image. + */ + + if ( pass ) { + + file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl_id); + + if ( file_id < 0 ) { + + pass = FALSE; + failure_mssg = "H5Fopen() failed.\n"; + + } else { + + file_ptr = (struct H5F_t *)H5I_object_verify(file_id, H5I_FILE); + + if ( file_ptr == NULL ) { + + pass = FALSE; + failure_mssg = "Can't get file_ptr."; + + } + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + /* get a pointer to the files internal data structure and then + * to the cache structure + */ + if ( pass ) { + + if ( file_ptr->shared->cache == NULL ) { + + pass = FALSE; + failure_mssg = "can't get cache pointer(1).\n"; + + } else { + + cache_ptr = file_ptr->shared->cache; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + if ( pass ) { + + if ( ( cache_ptr->load_image == TRUE ) || + ( cache_ptr->delete_image == TRUE ) ) { + + pass = FALSE; + failure_mssg = "mdci sb extension message present?\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 11) Verify that the data sets contain the expected data + * + * Verify that a cache image was not loaded. + */ + + if ( pass ) { + + verify_datasets(file_id, 0, 5); + } + +#if H5C_COLLECT_CACHE_STATS + if ( pass ) { + + if ( cache_ptr->images_loaded != 0 ) { + + pass = FALSE; + failure_mssg = "metadata cache image block loaded(2)."; + } + } +#endif /* H5C_COLLECT_CACHE_STATS */ + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 12) Create several more data sets. */ + + if ( pass ) { + + create_datasets(file_id, 6, 10); + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 13) Close the file. */ + + if ( pass ) { + + if ( H5Fclose(file_id) < 0 ) { + + pass = FALSE; + failure_mssg = "H5Fclose() failed.\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 14) Open the file read write. + * + * Verify that the file does not contain a cache image. + */ + + if ( pass ) { + + open_hdf5_file(/* create_file */ FALSE, + /* mdci_sbem_expected */ FALSE, + /* read_only */ FALSE, + /* set_mdci_fapl */ FALSE, + /* config_fsm */ FALSE, + /* hdf_file_name */ filename, + /* cache_image_flags */ H5C_CI__ALL_FLAGS, + /* file_id_ptr */ &file_id, + /* file_ptr_ptr */ &file_ptr, + /* cache_ptr_ptr */ &cache_ptr); + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 15) Verify the data sets exist and contain the expected data. + * + * Verify that a cache image was not loaded. + */ + + if ( pass ) { + + verify_datasets(file_id, 0, 10); + } + +#if H5C_COLLECT_CACHE_STATS + if ( pass ) { + + if ( cache_ptr->images_loaded != 0 ) { + + pass = FALSE; + failure_mssg = "metadata cache image block loaded(2)."; + } + } +#endif /* H5C_COLLECT_CACHE_STATS */ + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 16) Close the file. */ + + if ( pass ) { + + if ( H5Fclose(file_id) < 0 ) { + + pass = FALSE; + failure_mssg = "H5Fclose() failed.\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 17) Delete the file */ + + if ( pass ) { + + if ( HDremove(filename) < 0 ) { + + pass = FALSE; + failure_mssg = "HDremove() failed.\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* tidy up */ + if ( fapl_id != -1 ) + H5Pclose(fapl_id); + + + if ( pass ) { PASSED(); } else { H5_FAILED(); } + + if ( ! pass ) + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", + FUNC, failure_mssg); + + return !pass; + +} /* cache_image_api_error_check_4() */ +/*------------------------------------------------------------------------- * Function: main * * Purpose: Run tests on the cache code contained in H5C.c @@ -6489,6 +7115,7 @@ main(void) nerrs += cache_image_api_error_check_1(); nerrs += cache_image_api_error_check_2(); nerrs += cache_image_api_error_check_3(); + nerrs += cache_image_api_error_check_4(); return(nerrs > 0); |