From 35c049d6a4a9ebea49f23dc79f41b065df883036 Mon Sep 17 00:00:00 2001 From: David Young Date: Thu, 26 Sep 2019 16:43:01 -0500 Subject: Write test data from a different buffer than we read into, since I anticipate comparing the written buffer with the read buffer. Don't initialize variables prematurely so that the compiler has a chance to warn about variables read before they are written. Repeatedly flush the page buffer, once each time we end the tick. Write errors to stdout instead of stderr. --- test/page_buffer.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/test/page_buffer.c b/test/page_buffer.c index f0b63c1..6a47f09 100644 --- a/test/page_buffer.c +++ b/test/page_buffer.c @@ -565,9 +565,8 @@ test_basic_metadata_handling(hid_t orig_fapl, const char *env_h5_drvr) int64_t base_page_cnt; int64_t page_count = 0; size_t i, num_elements = 2000; - haddr_t addr = HADDR_UNDEF; - int *data = NULL; - H5F_t *f = NULL; + int *data, *odata; + H5F_t *f; H5F_vfd_swmr_config_t config; /* Configuration for VFD SWMR */ const char *dname; char *tname; @@ -633,27 +632,31 @@ test_basic_metadata_handling(hid_t orig_fapl, const char *env_h5_drvr) if (base_page_cnt != 2) TEST_ERROR; + const haddr_t addr = H5MF_alloc(f, H5FD_MEM_BTREE, + sizeof(int) * num_elements); /* allocate space for 2000 elements */ - if (HADDR_UNDEF == (addr = H5MF_alloc(f, H5FD_MEM_BTREE, - sizeof(int) * num_elements))) + if (HADDR_UNDEF == addr) FAIL_STACK_ERROR; + if ((odata = (int *)HDcalloc(num_elements, sizeof(int))) == NULL) + TEST_ERROR; + if ((data = (int *)HDcalloc(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; + odata[i] = -1; + if (H5F_block_write(f, H5FD_MEM_BTREE, addr, sizeof(int) * num_elements, - data) < 0) + odata) < 0) FAIL_STACK_ERROR; -#if 0 - for (i = 0; i < config.max_lag + 1; i++) + for (i = 0; i < config.max_lag + 1; i++) { H5Fvfd_swmr_end_tick(file_id); -#endif - - H5PB_flush(f); + if (H5PB_flush(f) < 0) + FAIL_STACK_ERROR; + } /* read all elements using the VFD.. this should result in -1s. */ if (H5FD_read(f->shared->lf, H5FD_MEM_BTREE, addr, @@ -662,7 +665,7 @@ test_basic_metadata_handling(hid_t orig_fapl, const char *env_h5_drvr) for (i = 0; i < num_elements; i++) { if (data[i] != -1) { - fprintf(stderr, "Read %d at data[%d], expected -1\n", data[i], i); + printf("Read %d at data[%d], expected -1\n", data[i], i); TEST_ERROR; } } -- cgit v0.12