diff options
author | David Young <dyoung@hdfgroup.org> | 2019-09-23 15:30:14 (GMT) |
---|---|---|
committer | David Young <dyoung@hdfgroup.org> | 2019-09-23 15:30:14 (GMT) |
commit | b4746506450a9202c18f532a66be36bedb7f6cca (patch) | |
tree | cdfd8fd6c3aca1394bc236fe088d7c0996436705 /test | |
parent | 57cfb035ada86e6ae0e165e6dc875bc89f4e57c3 (diff) | |
download | hdf5-b4746506450a9202c18f532a66be36bedb7f6cca.zip hdf5-b4746506450a9202c18f532a66be36bedb7f6cca.tar.gz hdf5-b4746506450a9202c18f532a66be36bedb7f6cca.tar.bz2 |
Don't calloc() the VFD SWMR configuration, just use a local variable.
Combine the VFD SWMR and non-VFD SWMR raw-data test into one
routine that takes a bool parameter to switch on VFD SMWR.
Update my description of the to-be-written metadata test for VFD SWMR.
Diffstat (limited to 'test')
-rw-r--r-- | test/page_buffer.c | 404 |
1 files changed, 71 insertions, 333 deletions
diff --git a/test/page_buffer.c b/test/page_buffer.c index a04e4c5..05b4837 100644 --- a/test/page_buffer.c +++ b/test/page_buffer.c @@ -49,7 +49,8 @@ static unsigned open_file(char *filename, hid_t fapl, hsize_t page_size, size_t /* test routines */ static unsigned test_args(hid_t fapl, const char *env_h5_drvr); -static unsigned test_raw_data_handling(hid_t orig_fapl, const char *env_h5_drvr); +static unsigned test_raw_data_handling(hid_t orig_fapl, const char *env_h5_drvr, + bool); static unsigned test_lru_processing(hid_t orig_fapl, const char *env_h5_drvr); static unsigned test_min_threshold(hid_t orig_fapl, const char *env_h5_drvr); static unsigned test_stats_collection(hid_t orig_fapl, const char *env_h5_drvr); @@ -544,7 +545,9 @@ error: * Function: test_basic_meta_data_handling() * * Purpose: Perform a basic check that metadata is not written - * immediately to the HDF5 file in VFD SWMR mode. + * immediately to the HDF5 file in VFD SWMR mode, but + * it is buffered in the shadow file until max_lag ticks + * have elapsed. * * Return: 0 if test is sucessful * 1 if test fails @@ -553,8 +556,41 @@ error: * 16 Sep 2019 */ + +/* + * Function: test_raw_data_handling() + * + * Purpose: Perform a basic check that raw data is written + * to the HDF5 file when expected whether in VFD SWMR mode or not. + * + * Any data mis-matches or failures reported by the HDF5 + * library result in test failure. + * + * Return: 0 if test is sucessful + * 1 if test fails + * + * Programmer: David Young + * 16 Sep 2019 + * + * Changes: Added base_page_cnt field as supporting code. This allows + * the test to adjust to the number of page buffer pages + * accessed during file open / create. + * + * The test for the value of base_page_cnt just after file + * open exists detect changes in library behavior. Assuming + * any such change is not indicative of other issues, these + * tests can be modified to reflect the change. + * + * JRM -- 2/23/17 + * + * Minor changes to adapt to re-implementation of the + * page buffer. + * + * JRM -- 10/26/18 + */ static unsigned -test_vfd_swmr_raw_data_handling(hid_t orig_fapl, const char *env_h5_drvr) +test_raw_data_handling(hid_t orig_fapl, const char *env_h5_drvr, + bool vfd_swmr_mode) { char filename[FILENAME_LEN]; /* Filename to use */ hid_t file_id = -1; /* File ID */ @@ -566,11 +602,8 @@ test_vfd_swmr_raw_data_handling(hid_t orig_fapl, const char *env_h5_drvr) haddr_t addr = HADDR_UNDEF; int *data = NULL; H5F_t *f = NULL; - H5F_vfd_swmr_config_t *config = NULL; /* Configuration for VFD SWMR */ - const char *dname; - char *tname; - TESTING("VFD SWMR Raw Data Handling"); + TESTING("%sRaw Data Handling", vfd_swmr_mode ? "VFD SWMR " : ""); h5_fixname(FILENAME[0], orig_fapl, filename, sizeof(filename)); @@ -580,9 +613,6 @@ test_vfd_swmr_raw_data_handling(hid_t orig_fapl, const char *env_h5_drvr) if (set_multi_split(env_h5_drvr, fapl, sizeof(int) * 200) != 0) TEST_ERROR; - if ((data = (int *)HDcalloc((size_t)num_elements, sizeof(int))) == NULL) - TEST_ERROR; - if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) TEST_ERROR; if (H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 0, 1) < 0) @@ -592,35 +622,36 @@ test_vfd_swmr_raw_data_handling(hid_t orig_fapl, const char *env_h5_drvr) if (H5Pset_page_buffer_size(fapl, sizeof(int) * 2000, 0, 0) < 0) TEST_ERROR; - /* Allocate memory for the configuration structure */ - config = (H5F_vfd_swmr_config_t *)HDcalloc(1, sizeof(*config)); - if(config == NULL) { - HDfprintf(stderr, "VFD SWMR config allocation failed\n"); - TEST_ERROR; - } + if (vfd_swmr_mode) { + H5F_vfd_swmr_config_t config; /* Configuration for VFD SWMR */ + const char *dname; + char *tname; - config->version = H5F__CURR_VFD_SWMR_CONFIG_VERSION; - config->tick_len = 4; - config->max_lag = 5; - config->vfd_swmr_writer = true; - config->md_pages_reserved = 128; + memset(&config, '\0', sizeof(config)); + + config.version = H5F__CURR_VFD_SWMR_CONFIG_VERSION; + config.tick_len = 4; + config.max_lag = 5; + config.vfd_swmr_writer = true; + config.md_pages_reserved = 128; #if 0 - config->md_open_tries = 1; + config.md_open_tries = 1; #endif - if ((tname = strdup(filename)) == NULL) { - HDfprintf(stderr, "temporary string allocation failed\n"); - TEST_ERROR; - } - dname = dirname(tname); - snprintf(config->md_file_path, sizeof(config->md_file_path), - "%s/my_md_file", dname); - free(tname); - - /* Enable VFD SWMR configuration */ - if(H5Pset_vfd_swmr_config(fapl, config) < 0) { - HDfprintf(stderr, "H5Pset_vrd_swmr_config failed\n"); - TEST_ERROR; + if ((tname = strdup(filename)) == NULL) { + HDfprintf(stderr, "temporary string allocation failed\n"); + TEST_ERROR; + } + dname = dirname(tname); + snprintf(config.md_file_path, sizeof(config.md_file_path), + "%s/my_md_file", dname); + free(tname); + + /* Enable VFD SWMR configuration */ + if(H5Pset_vfd_swmr_config(fapl, &config) < 0) { + HDfprintf(stderr, "H5Pset_vrd_swmr_config failed\n"); + TEST_ERROR; + } } if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) @@ -642,6 +673,9 @@ test_vfd_swmr_raw_data_handling(hid_t orig_fapl, const char *env_h5_drvr) if (HADDR_UNDEF == (addr = H5MF_alloc(f, H5FD_MEM_DRAW, sizeof(int) * (size_t)num_elements))) FAIL_STACK_ERROR; + if ((data = (int *)HDcalloc((size_t)num_elements, sizeof(int))) == NULL) + TEST_ERROR; + /* initialize all the elements to have a value of -1 */ for(i=0 ; i<num_elements ; i++) data[i] = -1; @@ -849,302 +883,6 @@ error: /*------------------------------------------------------------------------- - * Function: test_raw_data_handling() - * - * Purpose: The purpose of this function appears to be a smoke check - * of raw data reads and writes via the page buffer. - * - * Any data mis-matches or failures reported by the HDF5 - * library result in test failure. - * - * Return: 0 if test is sucessful - * 1 if test fails - * - * Programmer: unknown - * ?? / ?? / ?? - * - * Changes: Added base_page_cnt field as supporting code. This allows - * the test to adjust to the number of page buffer pages - * accessed during file open / create. - * - * The test for the value of base_page_cnt just after file - * open exists detect changes in library behavior. Assuming - * any such change is not indicative of other issues, these - * tests can be modified to reflect the change. - * - * JRM -- 2/23/17 - * - * Minor changes to adapt to re-implementation of the - * page buffer. - * - * JRM -- 10/26/18 - * - *------------------------------------------------------------------------- - */ - -/* Changes due to file space page size has a minimum size of 512 */ -static unsigned -test_raw_data_handling(hid_t orig_fapl, const char *env_h5_drvr) -{ - char filename[FILENAME_LEN]; /* Filename to use */ - hid_t file_id = -1; /* File ID */ - hid_t fcpl = -1; - hid_t fapl = -1; - int64_t base_page_cnt; - int64_t page_count = 0; - int i, num_elements = 2000; - haddr_t addr = HADDR_UNDEF; - int *data = NULL; - H5F_t *f = NULL; - - TESTING("Raw Data Handling"); - - h5_fixname(FILENAME[0], orig_fapl, filename, sizeof(filename)); - - if((fapl = H5Pcopy(orig_fapl)) < 0) - TEST_ERROR - - if(set_multi_split(env_h5_drvr, fapl, sizeof(int)*200) != 0) - TEST_ERROR; - - if((data = (int *)HDcalloc((size_t)num_elements, sizeof(int))) == NULL) - TEST_ERROR; - - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) - TEST_ERROR; - if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 0, (hsize_t)1) < 0) - TEST_ERROR; - if(H5Pset_file_space_page_size(fcpl, sizeof(int)*200) < 0) - TEST_ERROR; - if(H5Pset_page_buffer_size(fapl, sizeof(int)*2000, 0, 0) < 0) - TEST_ERROR; - - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) - FAIL_STACK_ERROR; - - /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file_id))) - FAIL_STACK_ERROR; - - /* opening the file inserts one or more pages into the page buffer. - * Get the number of pages inserted, and verify that it is the - * the expected value. - */ - base_page_cnt = f->shared->pb_ptr->curr_pages; - if(base_page_cnt != 2) - TEST_ERROR; - - /* allocate space for a 2000 elements */ - if(HADDR_UNDEF == (addr = H5MF_alloc(f, H5FD_MEM_DRAW, sizeof(int)*(size_t)num_elements))) - FAIL_STACK_ERROR; - - /* initialize all the elements to have a value of -1 */ - for(i=0 ; i<num_elements ; i++) - data[i] = -1; - if(H5F_block_write(f, H5FD_MEM_DRAW, addr, sizeof(int)*(size_t)num_elements, data) < 0) - FAIL_STACK_ERROR; - - /* update the first 50 elements to have values 0-49 - this will be - a page buffer update with 1 page resulting in the page - buffer. */ - /* Changes: 100 */ - for(i=0 ; i<100 ; i++) - data[i] = i; - - if(H5F_block_write(f, H5FD_MEM_DRAW, addr, sizeof(int)*100, data) < 0) - FAIL_STACK_ERROR; - - page_count ++; - - if(f->shared->pb_ptr->curr_pages != page_count + base_page_cnt) - FAIL_STACK_ERROR; - - /* update elements 300 - 450, with values 300 - - this will - bring two more pages into the page buffer. */ - for(i=0 ; i<150 ; i++) - data[i] = i+300; - if(H5F_block_write(f, H5FD_MEM_DRAW, addr+(sizeof(int)*300), sizeof(int)*150, data) < 0) - FAIL_STACK_ERROR; - page_count += 2; - if(f->shared->pb_ptr->curr_pages != page_count + base_page_cnt) - FAIL_STACK_ERROR; - - /* update elements 100 - 300, this will go to disk but also update - existing pages in the page buffer. */ - for(i=0 ; i<200 ; i++) - data[i] = i+100; - if(H5F_block_write(f, H5FD_MEM_DRAW, addr+(sizeof(int)*100), sizeof(int)*200, data) < 0) - FAIL_STACK_ERROR; - if(f->shared->pb_ptr->curr_pages != page_count + base_page_cnt) - FAIL_STACK_ERROR; - - /* Update elements 225-300 - this will update an existing page in the PB */ - /* Changes: 450 - 600; 150 */ - for(i=0 ; i<150 ; i++) - data[i] = i+450; - if(H5F_block_write(f, H5FD_MEM_DRAW, addr+(sizeof(int)*450), sizeof(int)*150, data) < 0) - FAIL_STACK_ERROR; - if(f->shared->pb_ptr->curr_pages != page_count + base_page_cnt) - FAIL_STACK_ERROR; - - /* Do a full page write to block 600-800 - should bypass the PB */ - for(i=0 ; i<200 ; i++) - data[i] = i+600; - if(H5F_block_write(f, H5FD_MEM_DRAW, addr+(sizeof(int)*600), sizeof(int)*200, data) < 0) - FAIL_STACK_ERROR; - if(f->shared->pb_ptr->curr_pages != page_count + base_page_cnt) - FAIL_STACK_ERROR; - - /* read elements 800 - 1200, this should not affect the PB, and should read -1s */ - if(H5F_block_read(f, H5FD_MEM_DRAW, addr+(sizeof(int)*800), sizeof(int)*400, data) < 0) - FAIL_STACK_ERROR; - for (i=0; i < 400; i++) { - if(data[i] != -1) { - HDfprintf(stderr, "Read different values than written\n"); - HDfprintf(stderr, "data[%d] = %d, %d expected.\n", i, data[i], -1); - FAIL_STACK_ERROR; - } - } - if(f->shared->pb_ptr->curr_pages != page_count + base_page_cnt) - FAIL_STACK_ERROR; - - /* read elements 1200 - 1201, this should read -1 and bring in an - * entire page of addr 1200 - */ - if(H5F_block_read(f, H5FD_MEM_DRAW, addr+(sizeof(int)*1200), sizeof(int)*1, data) < 0) - FAIL_STACK_ERROR; - for (i=0; i < 1; i++) { - if(data[i] != -1) { - HDfprintf(stderr, "Read different values than written\n"); - HDfprintf(stderr, "data[%d] = %d, %d expected.\n", i, data[i], -1); - TEST_ERROR; - } - } - page_count ++; - if(f->shared->pb_ptr->curr_pages != page_count + base_page_cnt) - TEST_ERROR; - - /* read elements 175 - 225, this should use the PB existing pages */ - /* Changes: 350 - 450 */ - /* read elements 175 - 225, this should use the PB existing pages */ - if(H5F_block_read(f, H5FD_MEM_DRAW, addr+(sizeof(int)*350), sizeof(int)*100, data) < 0) - FAIL_STACK_ERROR; - for (i=0; i < 100; i++) { - if(data[i] != i+350) { - HDfprintf(stderr, "Read different values than written\n"); - HDfprintf(stderr, "data[%d] = %d, %d expected.\n", i, data[i], - i + 350); - TEST_ERROR; - } - } - if(f->shared->pb_ptr->curr_pages != page_count + base_page_cnt) - TEST_ERROR; - - /* read elements 0 - 800 using the VFD.. this should result in -1s - except for the writes that went through the PB (100-300 & 600-800) */ - if(H5FD_read(f->shared->lf, H5FD_MEM_DRAW, addr, sizeof(int)*800, data) < 0) - FAIL_STACK_ERROR; - i = 0; - while (i < 800) { - if((i>=100 && i<300) || (i>=600)) { - if(data[i] != i) { - HDfprintf(stderr, "Read different values than written\n"); - HDfprintf(stderr, "data[%d] = %d, %d expected.\n", - i, data[i], i); - TEST_ERROR; - } - } - else { - if(data[i] != -1) { - HDfprintf(stderr, "Read different values than written\n"); - HDfprintf(stderr, "data[%d] = %d, %d expected.\n", - i, data[i], -1); - TEST_ERROR; - } - } - i++; - } - - /* read elements 0 - 800 using the PB.. this should result in all - * what we have written so far and should get the updates from the PB - */ - if(H5F_block_read(f, H5FD_MEM_DRAW, addr, sizeof(int)*800, data) < 0) - FAIL_STACK_ERROR; - if(f->shared->pb_ptr->curr_pages != page_count + base_page_cnt) - TEST_ERROR; - for (i=0; i < 800; i++) { - if(data[i] != i) { - HDfprintf(stderr, "Read different values than written\n"); - HDfprintf(stderr, "data[%d] = %d, %d expected.\n", - i, data[i], i); - TEST_ERROR; - } - } - - /* update elements 400 - 1400 to value 0, this will go to disk but - * also evict existing pages from the PB (page 400 & 1200 that are - * existing). - */ - for(i=0 ; i<1000 ; i++) - data[i] = 0; - if(H5F_block_write(f, H5FD_MEM_DRAW, addr+(sizeof(int)*400), sizeof(int)*1000, data) < 0) - FAIL_STACK_ERROR; - page_count -= 2; - if(f->shared->pb_ptr->curr_pages != page_count + base_page_cnt) - TEST_ERROR; - - /* read elements 0 - 1000.. this should go to disk then update the - * buffer result 200-400 with existing pages - */ - if(H5F_block_read(f, H5FD_MEM_DRAW, addr, sizeof(int)*1000, data) < 0) - FAIL_STACK_ERROR; - i=0; - while (i < 1000) { - if(i<400) { - if(data[i] != i) { - HDfprintf(stderr, "Read different values than written\n"); - HDfprintf(stderr, "data[%d] = %d, %d expected.\n", - i, data[i], i); - TEST_ERROR; - } - } - else { - if(data[i] != 0) { - HDfprintf(stderr, "Read different values than written\n"); - HDfprintf(stderr, "data[%d] = %d, %d expected.\n", - i, data[i], 0); - TEST_ERROR; - } - } - i++; - } - if(f->shared->pb_ptr->curr_pages != page_count + base_page_cnt) - TEST_ERROR; - - if(H5Fclose(file_id) < 0) - FAIL_STACK_ERROR; - if(H5Pclose(fcpl) < 0) - FAIL_STACK_ERROR; - if(H5Pclose(fapl) < 0) - FAIL_STACK_ERROR; - HDfree(data); - - PASSED() - return 0; - -error: - H5E_BEGIN_TRY { - H5Pclose(fapl); - H5Pclose(fcpl); - H5Fclose(file_id); - if(data) - HDfree(data); - } H5E_END_TRY; - return 1; -} - - -/*------------------------------------------------------------------------- * Function: test_lru_processing() * * Purpose: Basic set of tests verifying expected page buffer LRU @@ -2703,8 +2441,8 @@ main(void) #else /* H5_HAVE_PARALLEL */ nerrors += test_args(fapl, env_h5_drvr); - nerrors += test_raw_data_handling(fapl, env_h5_drvr); - nerrors += test_vfd_swmr_raw_data_handling(fapl, env_h5_drvr); + nerrors += test_raw_data_handling(fapl, env_h5_drvr, false); + nerrors += test_raw_data_handling(fapl, env_h5_drvr, true); nerrors += test_lru_processing(fapl, env_h5_drvr); nerrors += test_min_threshold(fapl, env_h5_drvr); nerrors += test_stats_collection(fapl, env_h5_drvr); |