summaryrefslogtreecommitdiffstats
path: root/test/accum.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/accum.c')
-rw-r--r--test/accum.c536
1 files changed, 284 insertions, 252 deletions
diff --git a/test/accum.c b/test/accum.c
index d76c866..548a04d 100644
--- a/test/accum.c
+++ b/test/accum.c
@@ -20,13 +20,19 @@
#define H5FD_TESTING
#include "H5Fpkg.h"
#include "H5FDpkg.h"
+
+#include "H5CXprivate.h" /* API Contexts */
#include "H5Iprivate.h"
+#include "H5VLprivate.h" /* Virtual Object Layer */
/* Filename */
-#define FILENAME "accum.h5"
+/* (The file names are the same as the define in accum_swmr_reader.c) */
+const char *FILENAME[] = {
+ "accum",
+ "accum_swmr_big",
+ NULL
+};
-/* The file name is the same as the define in accum_swmr_reader.c */
-#define SWMR_FILENAME "accum_swmr_big.h5"
/* The reader forked by test_swmr_write_big() */
#define SWMR_READER "accum_swmr_reader"
@@ -39,33 +45,30 @@
#define RAND_SEG_LEN (1024)
#define RANDOM_BASE_OFF (1024 * 1024)
-/* Make file global to all tests */
-H5F_t * f = NULL;
-
/* Function Prototypes */
-unsigned test_write_read(const H5F_io_info2_t *fio_info);
-unsigned test_write_read_nonacc_front(const H5F_io_info2_t *fio_info);
-unsigned test_write_read_nonacc_end(const H5F_io_info2_t *fio_info);
-unsigned test_accum_overlap(const H5F_io_info2_t *fio_info);
-unsigned test_accum_overlap_clean(const H5F_io_info2_t *fio_info);
-unsigned test_accum_overlap_size(const H5F_io_info2_t *fio_info);
-unsigned test_accum_non_overlap_size(const H5F_io_info2_t *fio_info);
-unsigned test_accum_adjust(const H5F_io_info2_t *fio_info);
-unsigned test_read_after(const H5F_io_info2_t *fio_info);
-unsigned test_free(const H5F_io_info2_t *fio_info);
-unsigned test_big(const H5F_io_info2_t *fio_info);
-unsigned test_random_write(const H5F_io_info2_t *fio_info);
+unsigned test_write_read(H5F_t *f);
+unsigned test_write_read_nonacc_front(H5F_t *f);
+unsigned test_write_read_nonacc_end(H5F_t *f);
+unsigned test_accum_overlap(H5F_t *f);
+unsigned test_accum_overlap_clean(H5F_t *f);
+unsigned test_accum_overlap_size(H5F_t *f);
+unsigned test_accum_non_overlap_size(H5F_t *f);
+unsigned test_accum_adjust(H5F_t *f);
+unsigned test_read_after(H5F_t *f);
+unsigned test_free(H5F_t *f);
+unsigned test_big(H5F_t *f);
+unsigned test_random_write(H5F_t *f);
unsigned test_swmr_write_big(hbool_t newest_format);
/* Helper Function Prototypes */
-void accum_printf(void);
+void accum_printf(const H5F_t *f);
/* Private Test H5Faccum Function Wrappers */
-#define accum_write(a,s,b) H5F_block_write(f, H5FD_MEM_DEFAULT, (haddr_t)(a), (size_t)(s), H5AC_ind_read_dxpl_id, (b))
-#define accum_read(a,s,b) H5F_block_read(f, H5FD_MEM_DEFAULT, (haddr_t)(a), (size_t)(s), H5AC_ind_read_dxpl_id, (b))
-#define accum_free(fio_info,a,s) H5F__accum_free(fio_info, H5FD_MEM_DEFAULT, (haddr_t)(a), (hsize_t)(s))
-#define accum_flush(fio_info) H5F__accum_flush(fio_info)
-#define accum_reset(fio_info) H5F__accum_reset(fio_info, TRUE)
+#define accum_write(a,s,b) H5F_block_write(f, H5FD_MEM_DEFAULT, (haddr_t)(a), (size_t)(s), (b))
+#define accum_read(a,s,b) H5F_block_read(f, H5FD_MEM_DEFAULT, (haddr_t)(a), (size_t)(s), (b))
+#define accum_free(f,a,s) H5F__accum_free(f->shared, H5FD_MEM_DEFAULT, (haddr_t)(a), (hsize_t)(s))
+#define accum_flush(f) H5F__accum_flush(f->shared)
+#define accum_reset(f) H5F__accum_reset(f->shared, TRUE)
/* ================= */
/* Main Test Routine */
@@ -74,12 +77,12 @@ void accum_printf(void);
/*-------------------------------------------------------------------------
* Function: main
- *
+ *
* Purpose: Test the metadata accumulator code
- *
+ *
* Return: Success: SUCCEED
* Failure: FAIL
- *
+ *
* Programmer: Mike McGreevy
* October 7, 2010
*
@@ -88,48 +91,60 @@ void accum_printf(void);
int
main(void)
{
- H5F_io_info2_t fio_info; /* I/O info for operation */
unsigned nerrors = 0; /* track errors */
+ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
hid_t fid = -1;
+ hid_t fapl = -1; /* File access property list */
+ char filename[1024];
+ H5F_t * f = NULL; /* File for all tests */
+
/* Test Setup */
- puts("Testing the metadata accumulator");
+ HDputs("Testing the metadata accumulator");
+
+ /* File access property list */
+ h5_reset();
+ if((fapl = h5_fileaccess()) < 0)
+ FAIL_STACK_ERROR
+ h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
/* Create a test file */
- if((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+ if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR
+
+ /* Push API context */
+ if(H5CX_push() < 0) FAIL_STACK_ERROR
+ api_ctx_pushed = TRUE;
/* Get H5F_t * to internal file structure */
- if(NULL == (f = (H5F_t *)H5I_object(fid))) FAIL_STACK_ERROR
+ if(NULL == (f = (H5F_t *)H5VL_object(fid))) FAIL_STACK_ERROR
/* We'll be writing lots of garbage data, so extend the
file a ways. 10MB should do. */
if(H5FD_set_eoa(f->shared->lf, H5FD_MEM_DEFAULT, (haddr_t)(1024*1024*10)) < 0) FAIL_STACK_ERROR
- /* Set up I/O info for operation */
- fio_info.f = f;
- if(NULL == (fio_info.meta_dxpl = (H5P_genplist_t *)H5I_object(H5AC_ind_read_dxpl_id))) FAIL_STACK_ERROR
- if(NULL == (fio_info.raw_dxpl = (H5P_genplist_t *)H5I_object(H5AC_rawdata_dxpl_id))) FAIL_STACK_ERROR
-
/* Reset metadata accumulator for the file */
- if(accum_reset(&fio_info) < 0) FAIL_STACK_ERROR
+ if(accum_reset(f) < 0) FAIL_STACK_ERROR
/* Test Functions */
- nerrors += test_write_read(&fio_info);
- nerrors += test_write_read_nonacc_front(&fio_info);
- nerrors += test_write_read_nonacc_end(&fio_info);
- nerrors += test_accum_overlap(&fio_info);
- nerrors += test_accum_overlap_clean(&fio_info);
- nerrors += test_accum_overlap_size(&fio_info);
- nerrors += test_accum_non_overlap_size(&fio_info);
- nerrors += test_accum_adjust(&fio_info);
- nerrors += test_read_after(&fio_info);
- nerrors += test_free(&fio_info);
- nerrors += test_big(&fio_info);
- nerrors += test_random_write(&fio_info);
+ nerrors += test_write_read(f);
+ nerrors += test_write_read_nonacc_front(f);
+ nerrors += test_write_read_nonacc_end(f);
+ nerrors += test_accum_overlap(f);
+ nerrors += test_accum_overlap_clean(f);
+ nerrors += test_accum_overlap_size(f);
+ nerrors += test_accum_non_overlap_size(f);
+ nerrors += test_accum_adjust(f);
+ nerrors += test_read_after(f);
+ nerrors += test_free(f);
+ nerrors += test_big(f);
+ nerrors += test_random_write(f);
+
+ /* Pop API context */
+ if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
+ api_ctx_pushed = FALSE;
/* End of test code, close and delete file */
if(H5Fclose(fid) < 0) TEST_ERROR
- HDremove(FILENAME);
/* This test uses a different file */
nerrors += test_swmr_write_big(TRUE);
@@ -137,12 +152,15 @@ main(void)
if(nerrors)
goto error;
- puts("All metadata accumulator tests passed.");
+ HDputs("All metadata accumulator tests passed.");
+ h5_cleanup(FILENAME, fapl);
return 0;
-error:
- puts("*** TESTS FAILED ***");
+error:
+ if(api_ctx_pushed) H5CX_pop();
+
+ HDputs("*** TESTS FAILED ***");
return 1;
} /* end main() */
@@ -153,19 +171,19 @@ error:
/*-------------------------------------------------------------------------
* Function: test_write_read
- *
+ *
* Purpose: Simple test to write to then read from metadata accumulator.
- *
+ *
* Return: Success: SUCCEED
* Failure: FAIL
- *
+ *
* Programmer: Mike McGreevy
* October 7, 2010
*
*-------------------------------------------------------------------------
*/
unsigned
-test_write_read(const H5F_io_info2_t *fio_info)
+test_write_read(H5F_t *f)
{
int i = 0;
int *write_buf, *read_buf;
@@ -188,7 +206,7 @@ test_write_read(const H5F_io_info2_t *fio_info)
if(accum_read(0, 1024, read_buf) < 0) FAIL_STACK_ERROR;
if(HDmemcmp(write_buf, read_buf, (size_t)1024) != 0) TEST_ERROR;
- if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR;
+ if(accum_reset(f) < 0) FAIL_STACK_ERROR;
PASSED();
@@ -204,24 +222,24 @@ error:
HDfree(read_buf);
return 1;
-} /* test_write_read */
+} /* test_write_read */
/*-------------------------------------------------------------------------
* Function: test_write_read_nonacc_front
- *
+ *
* Purpose: Simple test to write to then read from before metadata accumulator.
- *
+ *
* Return: Success: SUCCEED
* Failure: FAIL
- *
+ *
* Programmer: Allen Byrne
* October 8, 2010
*
*-------------------------------------------------------------------------
*/
unsigned
-test_write_read_nonacc_front(const H5F_io_info2_t *fio_info)
+test_write_read_nonacc_front(H5F_t *f)
{
int i = 0;
int *write_buf, *read_buf;
@@ -241,13 +259,13 @@ test_write_read_nonacc_front(const H5F_io_info2_t *fio_info)
/* Do a simple write/read/verify of data */
/* Write 1KB at Address 0 */
if(accum_write(0, 1024, write_buf) < 0) FAIL_STACK_ERROR;
- if(accum_flush(fio_info) < 0) FAIL_STACK_ERROR;
- if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR;
+ if(accum_flush(f) < 0) FAIL_STACK_ERROR;
+ if(accum_reset(f) < 0) FAIL_STACK_ERROR;
if(accum_write(1024, 1024, write_buf) < 0) FAIL_STACK_ERROR;
if(accum_read(0, 1024, read_buf) < 0) FAIL_STACK_ERROR;
if(HDmemcmp(write_buf, read_buf, (size_t)1024) != 0) TEST_ERROR;
- if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR;
+ if(accum_reset(f) < 0) FAIL_STACK_ERROR;
PASSED();
@@ -263,24 +281,24 @@ error:
HDfree(read_buf);
return 1;
-} /* test_write_read */
+} /* test_write_read */
/*-------------------------------------------------------------------------
* Function: test_write_read_nonacc_end
- *
+ *
* Purpose: Simple test to write to then read from after metadata accumulator.
- *
+ *
* Return: Success: SUCCEED
* Failure: FAIL
- *
+ *
* Programmer: Allen Byrne
* October 8, 2010
*
*-------------------------------------------------------------------------
*/
unsigned
-test_write_read_nonacc_end(const H5F_io_info2_t *fio_info)
+test_write_read_nonacc_end(H5F_t *f)
{
int i = 0;
int *write_buf, *read_buf;
@@ -300,13 +318,13 @@ test_write_read_nonacc_end(const H5F_io_info2_t *fio_info)
/* Do a simple write/read/verify of data */
/* Write 1KB at Address 0 */
if(accum_write(1024, 1024, write_buf) < 0) FAIL_STACK_ERROR;
- if(accum_flush(fio_info) < 0) FAIL_STACK_ERROR;
- if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR;
+ if(accum_flush(f) < 0) FAIL_STACK_ERROR;
+ if(accum_reset(f) < 0) FAIL_STACK_ERROR;
if(accum_write(0, 1024, write_buf) < 0) FAIL_STACK_ERROR;
if(accum_read(1024, 1024, read_buf) < 0) FAIL_STACK_ERROR;
if(HDmemcmp(write_buf, read_buf, (size_t)1024) != 0) TEST_ERROR;
- if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR;
+ if(accum_reset(f) < 0) FAIL_STACK_ERROR;
PASSED();
@@ -322,24 +340,24 @@ error:
HDfree(read_buf);
return 1;
-} /* test_write_read */
+} /* test_write_read */
/*-------------------------------------------------------------------------
* Function: test_free
*
* Purpose: Simple test to free metadata accumulator.
- *
+ *
* Return: Success: SUCCEED
* Failure: FAIL
- *
+ *
* Programmer: Raymond Lu
* October 8, 2010
*
*-------------------------------------------------------------------------
*/
unsigned
-test_free(const H5F_io_info2_t *fio_info)
+test_free(H5F_t *f)
{
int i = 0;
int32_t *wbuf = NULL;
@@ -348,7 +366,7 @@ test_free(const H5F_io_info2_t *fio_info)
TESTING("simple freeing metadata accumulator");
- /* Write and free the whole accumulator. */
+ /* Write and free the whole accumulator. */
wbuf = (int32_t *)HDmalloc(256 * sizeof(int32_t));
HDassert(wbuf);
rbuf = (int32_t *)HDmalloc(256 * sizeof(int32_t));
@@ -362,38 +380,38 @@ test_free(const H5F_io_info2_t *fio_info)
if(accum_write(0, 256 * sizeof(int32_t), wbuf) < 0) FAIL_STACK_ERROR;
- if(accum_free(fio_info, 0, 256 * sizeof(int32_t)) < 0) FAIL_STACK_ERROR;
+ if(accum_free(f, 0, 256 * sizeof(int32_t)) < 0) FAIL_STACK_ERROR;
/* Free an empty accumulator */
- if(accum_free(fio_info, 0, 256 * 1024 * sizeof(int32_t)) < 0) FAIL_STACK_ERROR;
+ if(accum_free(f, 0, 256 * 1024 * sizeof(int32_t)) < 0) FAIL_STACK_ERROR;
/* Write second quarter of the accumulator */
if(accum_write(64 * sizeof(int32_t), 64 * sizeof(int32_t), wbuf) < 0) FAIL_STACK_ERROR;
- /* Free the second quarter of the accumulator, the requested area
+ /* Free the second quarter of the accumulator, the requested area
* is bigger than the data region on the right side. */
- if(accum_free(fio_info, 64 * sizeof(int32_t), 65 * sizeof(int32_t)) < 0) FAIL_STACK_ERROR;
+ if(accum_free(f, 64 * sizeof(int32_t), 65 * sizeof(int32_t)) < 0) FAIL_STACK_ERROR;
- /* Write half of the accumulator. */
+ /* Write half of the accumulator. */
if(accum_write(0, 128 * sizeof(int32_t), wbuf) < 0) FAIL_STACK_ERROR;
/* Free the first block of 4B */
- if(accum_free(fio_info, 0, sizeof(int32_t)) < 0) FAIL_STACK_ERROR;
+ if(accum_free(f, 0, sizeof(int32_t)) < 0) FAIL_STACK_ERROR;
/* Check that the accumulator still contains the correct data */
if(accum_read(1 * sizeof(int32_t), 127 * sizeof(int32_t), rbuf) < 0) FAIL_STACK_ERROR;
if(HDmemcmp(wbuf + 1, rbuf, 127 * sizeof(int32_t)) != 0) TEST_ERROR;
/* Free the block of 4B at 127*4B */
- if(accum_free(fio_info, 127 * sizeof(int32_t), sizeof(int32_t)) < 0) FAIL_STACK_ERROR;
+ if(accum_free(f, 127 * sizeof(int32_t), sizeof(int32_t)) < 0) FAIL_STACK_ERROR;
/* Check that the accumulator still contains the correct data */
if(accum_read(1 * sizeof(int32_t), 126 * sizeof(int32_t), rbuf) < 0) FAIL_STACK_ERROR;
if(HDmemcmp(wbuf + 1, rbuf, 126 * sizeof(int32_t)) != 0) TEST_ERROR;
/* Free the block of 4B at 2*4B */
- if(accum_free(fio_info, 2 * sizeof(int32_t), sizeof(int32_t)) < 0) FAIL_STACK_ERROR;
+ if(accum_free(f, 2 * sizeof(int32_t), sizeof(int32_t)) < 0) FAIL_STACK_ERROR;
/* Check that the accumulator still contains the correct data */
if(accum_read(1 * sizeof(int32_t), 1 * sizeof(int32_t), rbuf) < 0) FAIL_STACK_ERROR;
@@ -406,10 +424,10 @@ test_free(const H5F_io_info2_t *fio_info)
* entirely before dirty section */
if(accum_write(64 * sizeof(int32_t), 128 * sizeof(int32_t), wbuf) < 0) FAIL_STACK_ERROR;
HDmemcpy(expect + 64, wbuf, 128 * sizeof(int32_t));
- if(accum_flush(fio_info) < 0) FAIL_STACK_ERROR;
+ if(accum_flush(f) < 0) FAIL_STACK_ERROR;
if(accum_write(68 * sizeof(int32_t), 4 * sizeof(int32_t), wbuf) < 0) FAIL_STACK_ERROR;
HDmemcpy(expect + 68, wbuf, 4 * sizeof(int32_t));
- if(accum_free(fio_info, 62 * sizeof(int32_t), 4 * sizeof(int32_t)) < 0) FAIL_STACK_ERROR;
+ if(accum_free(f, 62 * sizeof(int32_t), 4 * sizeof(int32_t)) < 0) FAIL_STACK_ERROR;
/* Check that the accumulator still contains the correct data */
if(accum_read(66 * sizeof(int32_t), 126 * sizeof(int32_t), rbuf) < 0) FAIL_STACK_ERROR;
@@ -420,10 +438,10 @@ test_free(const H5F_io_info2_t *fio_info)
* completely contains dirty section */
if(accum_write(64 * sizeof(int32_t), 128 * sizeof(int32_t), wbuf) < 0) FAIL_STACK_ERROR;
HDmemcpy(expect + 64, wbuf, 128 * sizeof(int32_t));
- if(accum_flush(fio_info) < 0) FAIL_STACK_ERROR;
+ if(accum_flush(f) < 0) FAIL_STACK_ERROR;
if(accum_write(68 * sizeof(int32_t), 4 * sizeof(int32_t), wbuf) < 0) FAIL_STACK_ERROR;
HDmemcpy(expect + 68, wbuf, 4 * sizeof(int32_t));
- if(accum_free(fio_info, 62 * sizeof(int32_t), 16 * sizeof(int32_t)) < 0) FAIL_STACK_ERROR;
+ if(accum_free(f, 62 * sizeof(int32_t), 16 * sizeof(int32_t)) < 0) FAIL_STACK_ERROR;
/* Check that the accumulator still contains the correct data */
if(accum_read(78 * sizeof(int32_t), 114 * sizeof(int32_t), rbuf) < 0) FAIL_STACK_ERROR;
@@ -434,10 +452,10 @@ test_free(const H5F_io_info2_t *fio_info)
* before dirty section */
if(accum_write(64 * sizeof(int32_t), 128 * sizeof(int32_t), wbuf) < 0) FAIL_STACK_ERROR;
HDmemcpy(expect + 64, wbuf, 128 * sizeof(int32_t));
- if(accum_flush(fio_info) < 0) FAIL_STACK_ERROR;
+ if(accum_flush(f) < 0) FAIL_STACK_ERROR;
if(accum_write(72 * sizeof(int32_t), 4 * sizeof(int32_t), wbuf) < 0) FAIL_STACK_ERROR;
HDmemcpy(expect + 72, wbuf, 4 * sizeof(int32_t));
- if(accum_free(fio_info, 66 * sizeof(int32_t), 4 * sizeof(int32_t)) < 0) FAIL_STACK_ERROR;
+ if(accum_free(f, 66 * sizeof(int32_t), 4 * sizeof(int32_t)) < 0) FAIL_STACK_ERROR;
/* Check that the accumulator still contains the correct data */
if(accum_read(70 * sizeof(int32_t), 122 * sizeof(int32_t), rbuf) < 0) FAIL_STACK_ERROR;
@@ -448,10 +466,10 @@ test_free(const H5F_io_info2_t *fio_info)
* dirty section, and ends in dirty section */
if(accum_write(64 * sizeof(int32_t), 128 * sizeof(int32_t), wbuf) < 0) FAIL_STACK_ERROR;
HDmemcpy(expect + 64, wbuf, 128 * sizeof(int32_t));
- if(accum_flush(fio_info) < 0) FAIL_STACK_ERROR;
+ if(accum_flush(f) < 0) FAIL_STACK_ERROR;
if(accum_write(72 * sizeof(int32_t), 4 * sizeof(int32_t), wbuf) < 0) FAIL_STACK_ERROR;
HDmemcpy(expect + 72, wbuf, 4 * sizeof(int32_t));
- if(accum_free(fio_info, 70 * sizeof(int32_t), 4 * sizeof(int32_t)) < 0) FAIL_STACK_ERROR;
+ if(accum_free(f, 70 * sizeof(int32_t), 4 * sizeof(int32_t)) < 0) FAIL_STACK_ERROR;
/* Check that the accumulator still contains the correct data */
if(accum_read(74 * sizeof(int32_t), 118 * sizeof(int32_t), rbuf) < 0) FAIL_STACK_ERROR;
@@ -462,10 +480,10 @@ test_free(const H5F_io_info2_t *fio_info)
* contains dirty section */
if(accum_write(64 * sizeof(int32_t), 128 * sizeof(int32_t), wbuf) < 0) FAIL_STACK_ERROR;
HDmemcpy(expect + 64, wbuf, 128 * sizeof(int32_t));
- if(accum_flush(fio_info) < 0) FAIL_STACK_ERROR;
+ if(accum_flush(f) < 0) FAIL_STACK_ERROR;
if(accum_write(72 * sizeof(int32_t), 4 * sizeof(int32_t), wbuf) < 0) FAIL_STACK_ERROR;
HDmemcpy(expect + 72, wbuf, 4 * sizeof(int32_t));
- if(accum_free(fio_info, 70 * sizeof(int32_t), 8 * sizeof(int32_t)) < 0) FAIL_STACK_ERROR;
+ if(accum_free(f, 70 * sizeof(int32_t), 8 * sizeof(int32_t)) < 0) FAIL_STACK_ERROR;
/* Check that the accumulator still contains the correct data */
if(accum_read(78 * sizeof(int32_t), 114 * sizeof(int32_t), rbuf) < 0) FAIL_STACK_ERROR;
@@ -476,10 +494,10 @@ test_free(const H5F_io_info2_t *fio_info)
* of dirty section, and ends in dirty section */
if(accum_write(64 * sizeof(int32_t), 128 * sizeof(int32_t), wbuf) < 0) FAIL_STACK_ERROR;
HDmemcpy(expect + 64, wbuf, 128 * sizeof(int32_t));
- if(accum_flush(fio_info) < 0) FAIL_STACK_ERROR;
+ if(accum_flush(f) < 0) FAIL_STACK_ERROR;
if(accum_write(72 * sizeof(int32_t), 8 * sizeof(int32_t), wbuf) < 0) FAIL_STACK_ERROR;
HDmemcpy(expect + 72, wbuf, 8 * sizeof(int32_t));
- if(accum_free(fio_info, 72 * sizeof(int32_t), 4 * sizeof(int32_t)) < 0) FAIL_STACK_ERROR;
+ if(accum_free(f, 72 * sizeof(int32_t), 4 * sizeof(int32_t)) < 0) FAIL_STACK_ERROR;
/* Check that the accumulator still contains the correct data */
if(accum_read(76 * sizeof(int32_t), 116 * sizeof(int32_t), rbuf) < 0) FAIL_STACK_ERROR;
@@ -492,7 +510,7 @@ test_free(const H5F_io_info2_t *fio_info)
HDfree(expect);
expect = NULL;
- if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR;
+ if(accum_reset(f) < 0) FAIL_STACK_ERROR;
PASSED();
@@ -507,26 +525,26 @@ error:
HDfree(expect);
return 1;
-} /* test_free */
+} /* test_free */
/*-------------------------------------------------------------------------
* Function: test_accum_overlap
- *
+ *
* Purpose: This test will write a series of pieces of data
* to the accumulator with the goal of overlapping
* the writes in various different ways.
- *
+ *
* Return: Success: SUCCEED
* Failure: FAIL
- *
+ *
* Programmer: Mike McGreevy
* October 7, 2010
*
*-------------------------------------------------------------------------
*/
unsigned
-test_accum_overlap(const H5F_io_info2_t *fio_info)
+test_accum_overlap(H5F_t *f)
{
int i = 0;
int32_t *wbuf, *rbuf;
@@ -611,9 +629,9 @@ test_accum_overlap(const H5F_io_info2_t *fio_info)
if(accum_write(96, 3 * sizeof(int32_t), wbuf) < 0) FAIL_STACK_ERROR;
if(accum_read(96, 3 * sizeof(int32_t), rbuf) < 0) FAIL_STACK_ERROR;
if(HDmemcmp(wbuf, rbuf, 3 * sizeof(int32_t)) != 0) TEST_ERROR;
-
+
/* Set up expected data buffer and verify contents of
- accumulator as constructed by cases 1-8, above */
+ accumulator as constructed by cases 1-8, above */
for(i = 0; i < 5; i++)
wbuf[i] = 4;
for(i = 5; i < 6; i++)
@@ -662,7 +680,7 @@ test_accum_overlap(const H5F_io_info2_t *fio_info)
if(accum_read(112, 6 * sizeof(int32_t), rbuf) < 0) FAIL_STACK_ERROR;
if(HDmemcmp(wbuf, rbuf, 6 * sizeof(int32_t)) != 0) TEST_ERROR;
- if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR;
+ if(accum_reset(f) < 0) FAIL_STACK_ERROR;
PASSED();
@@ -698,7 +716,7 @@ error:
*-------------------------------------------------------------------------
*/
unsigned
-test_accum_overlap_clean(const H5F_io_info2_t *fio_info)
+test_accum_overlap_clean(H5F_t *f)
{
int i = 0;
int32_t *wbuf, *rbuf;
@@ -724,7 +742,7 @@ test_accum_overlap_clean(const H5F_io_info2_t *fio_info)
/* Case 2: End of new piece aligns with start of clean accumulated data */
/* Write 5 2's at address 20 */
/* @0:| 222221111111111| */
- if(accum_flush(fio_info) < 0) FAIL_STACK_ERROR;
+ if(accum_flush(f) < 0) FAIL_STACK_ERROR;
for(i = 0; i < 5; i++)
wbuf[i] = 2;
if(accum_write(20, 5 * sizeof(int32_t), wbuf) < 0) FAIL_STACK_ERROR;
@@ -764,7 +782,7 @@ test_accum_overlap_clean(const H5F_io_info2_t *fio_info)
/* Case 6: New piece completely within clean accumulated data */
/* Write 3 6's at address 44 */
/* @0:| 333334666511111| */
- if(accum_flush(fio_info) < 0) FAIL_STACK_ERROR;
+ if(accum_flush(f) < 0) FAIL_STACK_ERROR;
for(i = 0; i < 3; i++)
wbuf[i] = 6;
if(accum_write(44, 3 * sizeof(int32_t), wbuf) < 0) FAIL_STACK_ERROR;
@@ -774,7 +792,7 @@ test_accum_overlap_clean(const H5F_io_info2_t *fio_info)
/* Case 7: New piece overlaps start of clean accumulated data */
/* Write 2 7's at address 16 */
/* @0:| 7733334666511111| */
- if(accum_flush(fio_info) < 0) FAIL_STACK_ERROR;
+ if(accum_flush(f) < 0) FAIL_STACK_ERROR;
for(i = 0; i < 2; i++)
wbuf[i] = 7;
if(accum_write(16, 2 * sizeof(int32_t), wbuf) < 0) FAIL_STACK_ERROR;
@@ -794,7 +812,7 @@ test_accum_overlap_clean(const H5F_io_info2_t *fio_info)
/* Case 9: Start of new piece aligns with end of clean accumulated data */
/* Write 3 9's at address 80 */
/* @0:| 88883334666511111999| */
- if(accum_flush(fio_info) < 0) FAIL_STACK_ERROR;
+ if(accum_flush(f) < 0) FAIL_STACK_ERROR;
for(i = 0; i < 3; i++)
wbuf[i] = 9;
if(accum_write(80, 3 * sizeof(int32_t), wbuf) < 0) FAIL_STACK_ERROR;
@@ -804,7 +822,7 @@ test_accum_overlap_clean(const H5F_io_info2_t *fio_info)
/* Case 10: New piece overlaps end of clean accumulated data */
/* Write 3 2's at address 88 */
/* @0:| 888833346665111119922| */
- if(accum_flush(fio_info) < 0) FAIL_STACK_ERROR;
+ if(accum_flush(f) < 0) FAIL_STACK_ERROR;
for(i = 0; i < 2; i++)
wbuf[i] = 2;
if(accum_write(88, 2 * sizeof(int32_t), wbuf) < 0) FAIL_STACK_ERROR;
@@ -842,7 +860,7 @@ test_accum_overlap_clean(const H5F_io_info2_t *fio_info)
if(accum_read(12, 22 * sizeof(int32_t), rbuf) < 0) FAIL_STACK_ERROR;
if(HDmemcmp(wbuf, rbuf, 22 * sizeof(int32_t)) != 0) TEST_ERROR;
- if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR;
+ if(accum_reset(f) < 0) FAIL_STACK_ERROR;
PASSED();
@@ -863,21 +881,21 @@ error:
/*-------------------------------------------------------------------------
* Function: test_accum_non_overlap_size
- *
+ *
* Purpose: This test will write a series of pieces of data
* to the accumulator with the goal of not overlapping
* the writes with a data size larger then the accum size.
- *
+ *
* Return: Success: SUCCEED
* Failure: FAIL
- *
+ *
* Programmer: Allen Byrne
* October 8, 2010
*
*-------------------------------------------------------------------------
*/
unsigned
-test_accum_non_overlap_size(const H5F_io_info2_t *fio_info)
+test_accum_non_overlap_size(H5F_t *f)
{
int i = 0;
int32_t *wbuf, *rbuf;
@@ -909,7 +927,7 @@ test_accum_non_overlap_size(const H5F_io_info2_t *fio_info)
if(accum_read(0, 20 * sizeof(int32_t), rbuf) < 0) FAIL_STACK_ERROR;
if(HDmemcmp(wbuf, rbuf, 20 * sizeof(int32_t)) != 0) TEST_ERROR;
- if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR;
+ if(accum_reset(f) < 0) FAIL_STACK_ERROR;
PASSED();
@@ -932,7 +950,7 @@ error:
*
* Purpose: This test will write a series of pieces of data
* to the accumulator with the goal of overlapping
- * the writes with a data size completely overlapping
+ * the writes with a data size completely overlapping
* the accumulator at both ends.
*
* Return: Success: SUCCEED
@@ -944,7 +962,7 @@ error:
*-------------------------------------------------------------------------
*/
unsigned
-test_accum_overlap_size(const H5F_io_info2_t *fio_info)
+test_accum_overlap_size(H5F_t *f)
{
int i = 0;
int32_t *wbuf, *rbuf;
@@ -976,7 +994,7 @@ test_accum_overlap_size(const H5F_io_info2_t *fio_info)
if(accum_read(60, 72 * sizeof(int32_t), rbuf) < 0) FAIL_STACK_ERROR;
if(HDmemcmp(wbuf, rbuf, 72 * sizeof(int32_t)) != 0) TEST_ERROR;
- if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR;
+ if(accum_reset(f) < 0) FAIL_STACK_ERROR;
PASSED();
@@ -997,32 +1015,32 @@ error:
/*-------------------------------------------------------------------------
* Function: test_accum_adjust
- *
+ *
* Purpose: This test examines the various ways the accumulator might
* adjust itself as a result of data appending or prepending
* to it.
*
- * This test program covers all the code in H5F_accum_adjust,
+ * This test program covers all the code in H5F_accum_adjust,
* but NOT all possible paths through said code. It only covers
* six potential paths through the function. (Again, though, each
* piece of code within an if/else statement in H5F_accum_adjust is
- * covered by one of the paths in this test function). Since there
- * are a ridiculous number of total possible paths through this
+ * covered by one of the paths in this test function). Since there
+ * are a ridiculous number of total possible paths through this
* function due to its large number of embedded if/else statements,
- * that's certainly a lot of different test cases to write by hand.
- * (Though if someone comes across this code and has some free
+ * that's certainly a lot of different test cases to write by hand.
+ * (Though if someone comes across this code and has some free
* time, go for it).
- *
+ *
* Return: Success: SUCCEED
* Failure: FAIL
- *
+ *
* Programmer: Mike McGreevy
* October 11, 2010
*
*-------------------------------------------------------------------------
*/
unsigned
-test_accum_adjust(const H5F_io_info2_t *fio_info)
+test_accum_adjust(H5F_t *f)
{
int i = 0;
int s = 1048576; /* size of buffer */
@@ -1050,7 +1068,7 @@ test_accum_adjust(const H5F_io_info2_t *fio_info)
* an increase in size because it's already at it's maximum size */
if(accum_write((1024 * 1024), (1024 * 1024) - 1, wbuf) < 0) FAIL_STACK_ERROR;
- /* Write a small (1KB) block that prepends to the front of the accumulator. */
+ /* Write a small (1KB) block that prepends to the front of the accumulator. */
/* ==> Accumulator will need more buffer space */
/* ==> Accumulator will try to resize, but see that it's getting too big */
/* ==> Size of new block is less than half maximum size of accumulator */
@@ -1066,9 +1084,9 @@ test_accum_adjust(const H5F_io_info2_t *fio_info)
/* Read back and verify second write */
if(accum_read((1024 * 1024) - 1024, 1024, rbuf) < 0) FAIL_STACK_ERROR;
if(HDmemcmp(wbuf, rbuf, (size_t)1024) != 0) TEST_ERROR;
-
+
/* Reset accumulator for next case */
- if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR;
+ if(accum_reset(f) < 0) FAIL_STACK_ERROR;
/* ================================================================ */
/* Case 2: Prepending large block to large, fully dirty accumulator */
@@ -1097,7 +1115,7 @@ test_accum_adjust(const H5F_io_info2_t *fio_info)
if(HDmemcmp(wbuf, rbuf, (size_t)1048571) != 0) TEST_ERROR;
/* Reset accumulator for next case */
- if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR;
+ if(accum_reset(f) < 0) FAIL_STACK_ERROR;
/* ========================================================= */
/* Case 3: Appending small block to large, clean accumulator */
@@ -1111,7 +1129,7 @@ test_accum_adjust(const H5F_io_info2_t *fio_info)
/* Flush the accumulator -- we want to test the case when
accumulator contains clean data */
- if(accum_flush(fio_info) < 0) FAIL_STACK_ERROR
+ if(accum_flush(f) < 0) FAIL_STACK_ERROR
/* Write a small (1KB) block to the end of the accumulator */
/* ==> Accumulator will need more buffer space */
@@ -1126,13 +1144,13 @@ test_accum_adjust(const H5F_io_info2_t *fio_info)
to disk */
if(accum_write(0, 1, wbuf) < 0) FAIL_STACK_ERROR;
- /* Read in the piece we wrote to disk above, and then verify that
+ /* Read in the piece we wrote to disk above, and then verify that
the data is as expected */
if(accum_read((1024 * 1024) - 1, 1024, rbuf) < 0) FAIL_STACK_ERROR;
if(HDmemcmp(wbuf, rbuf, (size_t)1024) != 0) TEST_ERROR;
/* Reset accumulator for next case */
- if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR;
+ if(accum_reset(f) < 0) FAIL_STACK_ERROR;
/* ==================================================================== */
/* Case 4: Appending small block to large, partially dirty accumulator, */
@@ -1146,7 +1164,7 @@ test_accum_adjust(const H5F_io_info2_t *fio_info)
if(accum_write(0, (1024 * 1024) - 5, wbuf) < 0) FAIL_STACK_ERROR;
/* Flush the accumulator to clean it */
- if(accum_flush(fio_info) < 0) FAIL_STACK_ERROR
+ if(accum_flush(f) < 0) FAIL_STACK_ERROR
/* write to part of the accumulator so just the start of it is dirty */
if(accum_write(0, 5, wbuf) < 0) FAIL_STACK_ERROR;
@@ -1157,7 +1175,7 @@ test_accum_adjust(const H5F_io_info2_t *fio_info)
/* ==> Size of new block is less than than half maximum size of accumulator */
/* ==> New block being appended to accumulator */
/* ==> We can slide the dirty region down, to accomodate the request */
- /* ==> Max Buffer Size - (dirty offset + adjust size) >= 2 * size) */
+ /* ==> Max Buffer Size - (dirty offset + adjust size) >= 2 * size) */
/* ==> Need to adjust location of accumulator while appending */
/* ==> Accumulator will need to be reallocated */
if(accum_write(1048571, 349523, wbuf) < 0) FAIL_STACK_ERROR;
@@ -1166,13 +1184,13 @@ test_accum_adjust(const H5F_io_info2_t *fio_info)
to disk */
if(accum_write(1398900, 1, wbuf) < 0) FAIL_STACK_ERROR;
- /* Read in the piece we wrote to disk above, and then verify that
+ /* Read in the piece we wrote to disk above, and then verify that
the data is as expected */
if(accum_read(1048571, 349523, rbuf) < 0) FAIL_STACK_ERROR;
if(HDmemcmp(wbuf, rbuf, (size_t)349523) != 0) TEST_ERROR;
/* Reset accumulator for next case */
- if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR;
+ if(accum_reset(f) < 0) FAIL_STACK_ERROR;
/* ==================================================================== */
/* Case 5: Appending small block to large, partially dirty accumulator, */
@@ -1183,7 +1201,7 @@ test_accum_adjust(const H5F_io_info2_t *fio_info)
if(accum_write(0, (1024 * 1024) - 5, wbuf) < 0) FAIL_STACK_ERROR;
/* Flush the accumulator to clean it */
- if(accum_flush(fio_info) < 0) FAIL_STACK_ERROR
+ if(accum_flush(f) < 0) FAIL_STACK_ERROR
/* write to part of the accumulator so it's dirty, but not entirely dirty */
/* (just the begging few bytes will be clean) */
@@ -1195,7 +1213,7 @@ test_accum_adjust(const H5F_io_info2_t *fio_info)
/* ==> Size of new block is less than than half maximum size of accumulator */
/* ==> New block being appended to accumulator */
/* ==> We can slide the dirty region down, to accomodate the request */
- /* ==> Max Buffer Size - (dirty offset + adjust size) < 2 * size) */
+ /* ==> Max Buffer Size - (dirty offset + adjust size) < 2 * size) */
/* ==> Need to adjust location of accumulator while appending */
if(accum_write((1024 * 1024) - 5, 10, wbuf) < 0) FAIL_STACK_ERROR;
@@ -1203,13 +1221,13 @@ test_accum_adjust(const H5F_io_info2_t *fio_info)
to disk */
if(accum_write(0, 1, wbuf) < 0) FAIL_STACK_ERROR;
- /* Read in the piece we wrote to disk above, and then verify that
+ /* Read in the piece we wrote to disk above, and then verify that
the data is as expected */
if(accum_read((1024 * 1024) - 5, 10, rbuf) < 0) FAIL_STACK_ERROR;
if(HDmemcmp(wbuf, rbuf, (size_t)10) != 0) TEST_ERROR;
/* Reset accumulator for next case */
- if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR;
+ if(accum_reset(f) < 0) FAIL_STACK_ERROR;
/* ================================================================= */
/* Case 6: Appending small block to large, fully dirty accumulator */
@@ -1235,12 +1253,12 @@ test_accum_adjust(const H5F_io_info2_t *fio_info)
to disk */
if(accum_write(1398900, 1, wbuf) < 0) FAIL_STACK_ERROR;
- /* Read in the piece we wrote to disk above, and then verify that
+ /* Read in the piece we wrote to disk above, and then verify that
the data is as expected */
if(accum_read(1048571, 349523, rbuf) < 0) FAIL_STACK_ERROR;
if(HDmemcmp(wbuf, rbuf, (size_t)349523) != 0) TEST_ERROR;
- if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR;
+ if(accum_reset(f) < 0) FAIL_STACK_ERROR;
PASSED();
@@ -1261,24 +1279,24 @@ error:
/*-------------------------------------------------------------------------
* Function: test_read_after
- *
- * Purpose: This test will verify the case when metadata is read partly
- * from the accumulator and partly from disk. The test will
+ *
+ * Purpose: This test will verify the case when metadata is read partly
+ * from the accumulator and partly from disk. The test will
* write a block of data at address 512, force the data to be
- * written to disk, write new data partially overlapping the
- * original block from below, then read data at address 512.
- * The data read should be partly new and partly original.
- *
+ * written to disk, write new data partially overlapping the
+ * original block from below, then read data at address 512.
+ * The data read should be partly new and partly original.
+ *
* Return: Success: SUCCEED
* Failure: FAIL
- *
+ *
* Programmer: Larry Knox
* October 8, 2010
*
*-------------------------------------------------------------------------
*/
-unsigned
-test_read_after(const H5F_io_info2_t *fio_info)
+unsigned
+test_read_after(H5F_t *f)
{
int i = 0;
int s = 128; /* size of buffer */
@@ -1311,19 +1329,19 @@ test_read_after(const H5F_io_info2_t *fio_info)
of the original block */
if(accum_write(256, 512, wbuf) < 0) FAIL_STACK_ERROR;
- /* Read 128 bytes at the original address, and then */
+ /* Read 128 bytes at the original address, and then */
if(accum_read(512, 512, rbuf) < 0) FAIL_STACK_ERROR;
- /* Set the second half of wbuf back to 1s */
+ /* Set the second half of wbuf back to 1s */
for(i = 64; i < s; i++)
wbuf[i] = 1;
- /* Read in the piece we wrote to disk above, and then verify that
+ /* Read in the piece we wrote to disk above, and then verify that
the data is as expected */
if(accum_read(512, 512, rbuf) < 0) FAIL_STACK_ERROR;
if(HDmemcmp(wbuf, rbuf, (size_t)128) != 0) TEST_ERROR;
- if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR;
+ if(accum_reset(f) < 0) FAIL_STACK_ERROR;
PASSED();
@@ -1344,20 +1362,20 @@ error:
/*-------------------------------------------------------------------------
* Function: test_big
- *
+ *
* Purpose: This test exercises writing large pieces of metadata to the
* file.
- *
+ *
* Return: Success: SUCCEED
* Failure: FAIL
- *
+ *
* Programmer: Quincey Koziol
* October 12, 2010
*
*-------------------------------------------------------------------------
*/
-unsigned
-test_big(const H5F_io_info2_t *fio_info)
+unsigned
+test_big(H5F_t *f)
{
uint8_t *wbuf, *wbuf2, *rbuf, *zbuf; /* Buffers for reading & writing, etc */
unsigned u; /* Local index variable */
@@ -1393,7 +1411,7 @@ test_big(const H5F_io_info2_t *fio_info)
/* Reset data in file back to zeros & reset the read buffer */
if(accum_write(0, BIG_BUF_SIZE, zbuf) < 0) FAIL_STACK_ERROR;
HDmemset(rbuf, 0, (size_t)BIG_BUF_SIZE);
- if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR;
+ if(accum_reset(f) < 0) FAIL_STACK_ERROR;
/* Write small section to middle of accumulator */
@@ -1412,7 +1430,7 @@ test_big(const H5F_io_info2_t *fio_info)
/* Reset data in file back to zeros & reset the read buffer */
if(accum_write(1024, 1024, zbuf) < 0) FAIL_STACK_ERROR;
HDmemset(rbuf, 0, (size_t)BIG_BUF_SIZE);
- if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR;
+ if(accum_reset(f) < 0) FAIL_STACK_ERROR;
/* Write small section to overlap with end of "big" region */
@@ -1430,7 +1448,7 @@ test_big(const H5F_io_info2_t *fio_info)
/* Reset data in file back to zeros & reset the read buffer */
if(accum_write(BIG_BUF_SIZE - 512, 1024, zbuf) < 0) FAIL_STACK_ERROR;
HDmemset(rbuf, 0, (size_t)BIG_BUF_SIZE);
- if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR;
+ if(accum_reset(f) < 0) FAIL_STACK_ERROR;
/* Write small section to overlap with beginning of "big" region */
@@ -1448,7 +1466,7 @@ test_big(const H5F_io_info2_t *fio_info)
/* Reset data in file back to zeros & reset the read buffer */
if(accum_write(0, 1024, zbuf) < 0) FAIL_STACK_ERROR;
HDmemset(rbuf, 0, (size_t)BIG_BUF_SIZE);
- if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR;
+ if(accum_reset(f) < 0) FAIL_STACK_ERROR;
/* Write small section to middle of accumulator */
@@ -1470,7 +1488,7 @@ test_big(const H5F_io_info2_t *fio_info)
/* Reset data in file back to zeros & reset the read buffer */
if(accum_write(0, BIG_BUF_SIZE, zbuf) < 0) FAIL_STACK_ERROR;
HDmemset(rbuf, 0, (size_t)BIG_BUF_SIZE);
- if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR;
+ if(accum_reset(f) < 0) FAIL_STACK_ERROR;
/* Write small section to overlap with end of "big" region */
@@ -1493,7 +1511,7 @@ test_big(const H5F_io_info2_t *fio_info)
/* Reset data in file back to zeros & reset the read buffer */
if(accum_write(0, BIG_BUF_SIZE + 512, zbuf) < 0) FAIL_STACK_ERROR;
HDmemset(rbuf, 0, (size_t)(BIG_BUF_SIZE + 512));
- if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR;
+ if(accum_reset(f) < 0) FAIL_STACK_ERROR;
/* Write small section to be past "big" region */
@@ -1521,7 +1539,7 @@ test_big(const H5F_io_info2_t *fio_info)
/* Reset data in file back to zeros & reset the read buffer */
if(accum_write(0, BIG_BUF_SIZE + 1536, zbuf) < 0) FAIL_STACK_ERROR;
HDmemset(rbuf, 0, (size_t)(BIG_BUF_SIZE + 1024));
- if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR;
+ if(accum_reset(f) < 0) FAIL_STACK_ERROR;
/* Write small section to be past "big" region */
@@ -1549,7 +1567,7 @@ test_big(const H5F_io_info2_t *fio_info)
/* Reset data in file back to zeros & reset the read buffer */
if(accum_write(1536, BIG_BUF_SIZE, zbuf) < 0) FAIL_STACK_ERROR;
HDmemset(rbuf, 0, (size_t)(BIG_BUF_SIZE + 1536));
- if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR;
+ if(accum_reset(f) < 0) FAIL_STACK_ERROR;
/* Write small section before "big" region */
@@ -1576,7 +1594,7 @@ test_big(const H5F_io_info2_t *fio_info)
/* Reset data in file back to zeros & reset the read buffer */
if(accum_write(512, BIG_BUF_SIZE, zbuf) < 0) FAIL_STACK_ERROR;
HDmemset(rbuf, 0, (size_t)(BIG_BUF_SIZE + 512));
- if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR;
+ if(accum_reset(f) < 0) FAIL_STACK_ERROR;
/* Write small section before "big" region */
@@ -1604,7 +1622,7 @@ test_big(const H5F_io_info2_t *fio_info)
/* Reset data in file back to zeros & reset the read buffer */
if(accum_write(0, BIG_BUF_SIZE + 1536, zbuf) < 0) FAIL_STACK_ERROR;
HDmemset(rbuf, 0, (size_t)(BIG_BUF_SIZE + 1536));
- if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR;
+ if(accum_reset(f) < 0) FAIL_STACK_ERROR;
/* Write small section before "big" region */
@@ -1628,7 +1646,7 @@ test_big(const H5F_io_info2_t *fio_info)
if(HDmemcmp(wbuf2, rbuf + 512, (size_t)BIG_BUF_SIZE) != 0) TEST_ERROR;
- if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR;
+ if(accum_reset(f) < 0) FAIL_STACK_ERROR;
PASSED();
@@ -1652,20 +1670,20 @@ error:
/*-------------------------------------------------------------------------
* Function: test_random_write
- *
+ *
* Purpose: This test writes random pieces of data to the file and
* then reads it all back.
- *
+ *
* Return: Success: SUCCEED
* Failure: FAIL
- *
+ *
* Programmer: Quincey Koziol
* October 11, 2010
*
*-------------------------------------------------------------------------
*/
-unsigned
-test_random_write(const H5F_io_info2_t *fio_info)
+unsigned
+test_random_write(H5F_t *f)
{
uint8_t *wbuf, *rbuf; /* Buffers for reading & writing */
unsigned seed = 0; /* Random # seed */
@@ -1765,7 +1783,7 @@ HDfprintf(stderr, "Random # seed was: %u\n", seed);
/* Verify data read back in */
if(HDmemcmp(wbuf, rbuf, (size_t)RANDOM_BUF_SIZE) != 0) TEST_ERROR;
- if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR;
+ if(accum_reset(f) < 0) FAIL_STACK_ERROR;
PASSED();
@@ -1790,28 +1808,29 @@ error:
/*-------------------------------------------------------------------------
* Function: test_swmr_write_big
- *
+ *
* Purpose: A SWMR test: verifies that writing "large" metadata to a file
- * opened with SWMR_WRITE will flush the existing metadata in the
+ * opened with SWMR_WRITE will flush the existing metadata in the
* accumulator to disk first before writing the "large" metadata
- * to disk.
+ * to disk.
* This test will fork and exec a reader "accum_swmr_reader" which
* opens the same file with SWMR_READ and verifies that the correct
* metadata is read from disk.
- *
+ *
* Return: Success: 0
* Failure: 1
- *
+ *
* Programmer: Vailin Choi; April 2013
*
*-------------------------------------------------------------------------
*/
-unsigned
+unsigned
test_swmr_write_big(hbool_t newest_format)
{
hid_t fid = -1; /* File ID */
hid_t fapl = -1; /* File access property list */
H5F_t *rf = NULL; /* File pointer */
+ char filename[1024];
uint8_t *wbuf2 = NULL, *rbuf = NULL; /* Buffers for reading & writing */
uint8_t wbuf[1024]; /* Buffer for reading & writing */
unsigned u; /* Local index variable */
@@ -1819,15 +1838,13 @@ test_swmr_write_big(hbool_t newest_format)
pid_t pid; /* Process ID */
#endif /* H5_HAVE_UNISTD_H */
int status; /* Status returned from child process */
- H5F_io_info2_t fio_info; /* I/O info for operation */
- char *new_argv[] = {NULL};
char *driver = NULL; /* VFD string (from env variable) */
+ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
- if(newest_format) {
- TESTING("SWMR write of large metadata: with latest format");
- } else {
- TESTING("SWMR write of large metadata: with non-latest-format");
- } /* end if */
+ if(newest_format)
+ TESTING("SWMR write of large metadata: with latest format")
+ else
+ TESTING("SWMR write of large metadata: with non-latest-format")
#if !(defined(H5_HAVE_FORK) && defined(H5_HAVE_WAITPID))
@@ -1841,25 +1858,27 @@ test_swmr_write_big(hbool_t newest_format)
* by the environment variable.
*/
driver = HDgetenv("HDF5_DRIVER");
- if (!H5FD_supports_swmr_test(driver)) {
+ if(!H5FD__supports_swmr_test(driver)) {
SKIPPED();
HDputs(" Test skipped due to VFD not supporting SWMR I/O.");
return 0;
- } /* end if */
+ }
/* File access property list */
if((fapl = h5_fileaccess()) < 0)
FAIL_STACK_ERROR
+ h5_fixname(FILENAME[1], fapl, filename, sizeof filename);
/* Both cases will result in v3 superblock and version 2 object header for SWMR */
if(newest_format) { /* latest format */
if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
FAIL_STACK_ERROR
- if((fid = H5Fcreate(SWMR_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
FAIL_STACK_ERROR
- } else { /* non-latest-format */
- if((fid = H5Fcreate(SWMR_FILENAME, H5F_ACC_TRUNC|H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl)) < 0)
+ }
+ else { /* non-latest-format */
+ if((fid = H5Fcreate(filename, H5F_ACC_TRUNC|H5F_ACC_SWMR_WRITE, H5P_DEFAULT, fapl)) < 0)
FAIL_STACK_ERROR
} /* end if */
@@ -1868,18 +1887,15 @@ test_swmr_write_big(hbool_t newest_format)
FAIL_STACK_ERROR
/* Open the file with SWMR_WRITE */
- if((fid = H5Fopen(SWMR_FILENAME, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl)) < 0)
+ if((fid = H5Fopen(filename, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl)) < 0)
FAIL_STACK_ERROR
- /* Get H5F_t * to internal file structure */
- if(NULL == (rf = (H5F_t *)H5I_object(fid))) FAIL_STACK_ERROR
+ /* Push API context */
+ if(H5CX_push() < 0) FAIL_STACK_ERROR
+ api_ctx_pushed = TRUE;
- /* Set up I/O info for operation */
- fio_info.f = rf;
- if(NULL == (fio_info.meta_dxpl = (H5P_genplist_t *)H5I_object(H5AC_ind_read_dxpl_id)))
- FAIL_STACK_ERROR
- if(NULL == (fio_info.raw_dxpl = (H5P_genplist_t *)H5I_object(H5AC_rawdata_dxpl_id)))
- FAIL_STACK_ERROR
+ /* Get H5F_t * to internal file structure */
+ if(NULL == (rf = (H5F_t *)H5VL_object(fid))) FAIL_STACK_ERROR
/* We'll be writing lots of garbage data, so extend the
file a ways. 10MB should do. */
@@ -1890,7 +1906,7 @@ test_swmr_write_big(hbool_t newest_format)
FAIL_STACK_ERROR;
/* Reset metadata accumulator for the file */
- if(accum_reset(&fio_info) < 0)
+ if(accum_reset(rf) < 0)
FAIL_STACK_ERROR;
/* Allocate space for the write & read buffers */
@@ -1904,16 +1920,16 @@ test_swmr_write_big(hbool_t newest_format)
wbuf[u] = (uint8_t)u;
/* Write [1024, 1024] bytes with wbuf */
- if(H5F_block_write(rf, H5FD_MEM_DEFAULT, (haddr_t)1024, (size_t)1024, H5AC_ind_read_dxpl_id, wbuf) < 0)
+ if(H5F_block_write(rf, H5FD_MEM_DEFAULT, (haddr_t)1024, (size_t)1024, wbuf) < 0)
FAIL_STACK_ERROR;
/* Read the data */
- if(H5F_block_read(rf, H5FD_MEM_DEFAULT, (haddr_t)1024, (size_t)1024, H5AC_ind_read_dxpl_id, rbuf) < 0)
+ if(H5F_block_read(rf, H5FD_MEM_DEFAULT, (haddr_t)1024, (size_t)1024, rbuf) < 0)
FAIL_STACK_ERROR;
/* Verify the data read is correct */
if(HDmemcmp(wbuf, rbuf, (size_t)1024) != 0)
TEST_ERROR;
/* Flush the data to disk */
- if(accum_reset(&fio_info) < 0)
+ if(accum_reset(rf) < 0)
FAIL_STACK_ERROR;
/* Initialize wbuf with all 1s */
@@ -1925,10 +1941,10 @@ test_swmr_write_big(hbool_t newest_format)
wbuf2[u] = (uint8_t)(u + 1);
/* Write [1024,1024] with wbuf--all 1s */
- if(H5F_block_write(rf, H5FD_MEM_DEFAULT, (haddr_t)1024, (size_t)1024, H5AC_ind_read_dxpl_id, wbuf) < 0)
+ if(H5F_block_write(rf, H5FD_MEM_DEFAULT, (haddr_t)1024, (size_t)1024, wbuf) < 0)
FAIL_STACK_ERROR;
/* Read the data */
- if(H5F_block_read(rf, H5FD_MEM_DEFAULT, (haddr_t)1024, (size_t)1024, H5AC_ind_read_dxpl_id, rbuf) < 0)
+ if(H5F_block_read(rf, H5FD_MEM_DEFAULT, (haddr_t)1024, (size_t)1024, rbuf) < 0)
FAIL_STACK_ERROR;
/* Verify the data read is correct */
if(HDmemcmp(wbuf, rbuf, (size_t)1024) != 0)
@@ -1936,10 +1952,10 @@ test_swmr_write_big(hbool_t newest_format)
/* The data stays in the accumulator */
/* Write a large piece of metadata [2048, BIG_BUF_SIZE] with wbuf2 */
- if(H5F_block_write(rf, H5FD_MEM_DEFAULT, (haddr_t)2048, (size_t)BIG_BUF_SIZE, H5AC_ind_read_dxpl_id, wbuf2) < 0)
+ if(H5F_block_write(rf, H5FD_MEM_DEFAULT, (haddr_t)2048, (size_t)BIG_BUF_SIZE, wbuf2) < 0)
FAIL_STACK_ERROR;
/* Read the data */
- if(H5F_block_read(rf, H5FD_MEM_DEFAULT, (haddr_t)2048, (size_t)BIG_BUF_SIZE, H5AC_ind_read_dxpl_id, rbuf) < 0)
+ if(H5F_block_read(rf, H5FD_MEM_DEFAULT, (haddr_t)2048, (size_t)BIG_BUF_SIZE, rbuf) < 0)
FAIL_STACK_ERROR;
/* Verify the data read is correct */
if(HDmemcmp(wbuf2, rbuf, (size_t)BIG_BUF_SIZE) != 0)
@@ -1949,10 +1965,18 @@ test_swmr_write_big(hbool_t newest_format)
if((pid = HDfork()) < 0) {
HDperror("fork");
FAIL_STACK_ERROR;
- } else if(0 == pid) { /* Child process */
- /* Run the reader */
- status = HDexecv(SWMR_READER, new_argv);
- printf("errno from execv = %s\n", strerror(errno));
+ }
+ else if(0 == pid) { /* Child process */
+ /* By convention, argv[0] tells the name of program invoked.
+ *
+ * execv on NetBSD 8 will actually return EFAULT if there is a
+ * NULL at argv[0], so we follow the convention unconditionally.
+ */
+ char swmr_reader[] = SWMR_READER;
+ char * const new_argv[] = {swmr_reader, NULL};
+ /* Run the reader */
+ status = HDexecv(SWMR_READER, new_argv);
+ HDprintf("errno from execv = %s\n", strerror(errno));
FAIL_STACK_ERROR;
} /* end if */
@@ -1962,17 +1986,21 @@ test_swmr_write_big(hbool_t newest_format)
/* Check if child process terminates normally and its return value */
if(WIFEXITED(status) && !WEXITSTATUS(status)) {
- /* Flush the accumulator */
- if(accum_reset(&fio_info) < 0)
+ /* Flush the accumulator */
+ if(accum_reset(rf) < 0)
+ FAIL_STACK_ERROR;
+
+ /* Close and remove the file */
+ if(H5Fclose(fid) < 0)
+ FAIL_STACK_ERROR;
+
+ /* Close the property list */
+ if(H5Pclose(fapl) < 0)
FAIL_STACK_ERROR;
- /* Close the property list */
- if(H5Pclose(fapl) < 0)
- FAIL_STACK_ERROR;
- /* Close and remove the file */
- if(H5Fclose(fid) < 0)
- FAIL_STACK_ERROR;
- HDremove(SWMR_FILENAME);
+ /* Pop API context */
+ if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
+ api_ctx_pushed = FALSE;
/* Release memory */
if(wbuf2)
@@ -1985,9 +2013,12 @@ test_swmr_write_big(hbool_t newest_format)
error:
/* Closing and remove the file */
- H5Pclose(fapl);
H5Fclose(fid);
- HDremove(SWMR_FILENAME);
+
+ if(api_ctx_pushed) H5CX_pop();
+
+ H5Pclose(fapl);
+
/* Release memory */
if(wbuf2)
HDfree(wbuf2);
@@ -2003,34 +2034,35 @@ error:
/*-------------------------------------------------------------------------
* Function: accum_printf
- *
+ *
* Purpose: Debug function to print some stats about the accumulator
- *
+ *
* Return: Success: SUCCEED
* Failure: FAIL
- *
+ *
* Programmer: Mike McGreevy
* October 7, 2010
*
*-------------------------------------------------------------------------
*/
void
-accum_printf(void)
+accum_printf(const H5F_t *f)
{
H5F_meta_accum_t * accum = &f->shared->accum;
- printf("\n");
- printf("Current contents of accumulator:\n");
- if (accum->alloc_size == 0) {
- printf("=====================================================\n");
- printf(" No accumulator allocated.\n");
- printf("=====================================================\n");
- } else {
- printf("=====================================================\n");
- printf(" accumulator allocated size == %zu\n", accum->alloc_size);
- printf(" accumulated data size == %zu\n", accum->size);
+ HDprintf("\n");
+ HDprintf("Current contents of accumulator:\n");
+ if(accum->alloc_size == 0) {
+ HDprintf("=====================================================\n");
+ HDprintf(" No accumulator allocated.\n");
+ HDprintf("=====================================================\n");
+ }
+ else {
+ HDprintf("=====================================================\n");
+ HDprintf(" accumulator allocated size == %zu\n", accum->alloc_size);
+ HDprintf(" accumulated data size == %zu\n", accum->size);
HDfprintf(stdout, " accumulator dirty? == %t\n", accum->dirty);
- printf("=====================================================\n");
+ HDprintf("=====================================================\n");
HDfprintf(stdout, " start of accumulated data, loc = %a\n", accum->loc);
if(accum->dirty) {
HDfprintf(stdout, " start of dirty region, loc = %a\n", (haddr_t)(accum->loc + accum->dirty_off));
@@ -2038,8 +2070,8 @@ accum_printf(void)
} /* end if */
HDfprintf(stdout, " end of accumulated data, loc = %a\n", (haddr_t)(accum->loc + accum->size));
HDfprintf(stdout, " end of accumulator allocation, loc = %a\n", (haddr_t)(accum->loc + accum->alloc_size));
- printf("=====================================================\n");
+ HDprintf("=====================================================\n");
}
- printf("\n\n");
+ HDprintf("\n\n");
} /* accum_printf() */