diff options
41 files changed, 2120 insertions, 2032 deletions
@@ -69,7 +69,7 @@ # define GB8LL 0 /*cannot do the test*/ #endif -/* Define Small, Large, Extra Large, Huge File which +/* Define Small, Large, Extra Large, Huge File which * corrspond to less than 2GB, 2GB, 4GB, and tens of GB file size. * NO_FILE stands for "no file" to be tested. */ @@ -281,8 +281,7 @@ error: * 'name' in the code below, but early (4.4.7, at least) gcc only * allows diagnostic pragmas to be toggled outside of functions. */ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wformat-nonliteral" +H5_GCC_DIAG_OFF(format-nonliteral) static int enough_room(hid_t fapl) { @@ -323,7 +322,7 @@ done: return ret_value; } -#pragma GCC diagnostic pop +H5_GCC_DIAG_ON(format-nonliteral) /*------------------------------------------------------------------------- @@ -634,7 +633,7 @@ error: return 1; } /* end test_sec2() */ -static int +static int test_stdio(hid_t fapl) { char filename[1024]; diff --git a/test/cache.c b/test/cache.c index 1573e97..49bb303 100644 --- a/test/cache.c +++ b/test/cache.c @@ -13932,7 +13932,7 @@ check_move_entry(unsigned paged) takedown_cache(file_ptr, FALSE, FALSE); if(pass) - PASSED() + PASSED(); else H5_FAILED() @@ -17061,7 +17061,7 @@ check_move_entry_errs(unsigned paged) takedown_cache(file_ptr, FALSE, FALSE); if(pass) - PASSED() + PASSED(); else { H5_FAILED() @@ -19914,7 +19914,7 @@ check_auto_cache_resize(hbool_t cork_ageout, unsigned paged) /* NOTE: upper_hr_threshold MUST be type double (not float) * or the cache test will fail on 64-bit systems. */ - auto_size_ctl.upper_hr_threshold = H5_DOUBLE(0.999); /* for ease of testing */ + auto_size_ctl.upper_hr_threshold = 0.999; /* for ease of testing */ auto_size_ctl.decrement = 0.5f; @@ -30716,7 +30716,7 @@ done: takedown_cache(file_ptr, FALSE, FALSE); if(pass) - PASSED() + PASSED(); else { H5_FAILED(); HDfprintf(stdout, "%s.\n", failure_mssg); @@ -30939,7 +30939,7 @@ done: takedown_cache(file_ptr, FALSE, FALSE); if(pass) - PASSED() + PASSED(); else { H5_FAILED(); HDfprintf(stdout, "%s.\n", failure_mssg); @@ -33511,7 +33511,7 @@ done: takedown_cache(file_ptr, FALSE, FALSE); if(pass) - PASSED() + PASSED(); else { H5_FAILED(); HDfprintf(stdout, "%s.\n", failure_mssg); @@ -33714,7 +33714,7 @@ done: takedown_cache(file_ptr, FALSE, FALSE); if(pass) - PASSED() + PASSED(); else { H5_FAILED(); HDfprintf(stdout, "%s.\n", failure_mssg); @@ -36895,7 +36895,6 @@ takedown_cache(H5F_t * file_ptr, } /* takedown_cache() */ - /*------------------------------------------------------------------------- * Function: main * diff --git a/test/dtransform.c b/test/dtransform.c index 6f7e8a4..bc61232 100644 --- a/test/dtransform.c +++ b/test/dtransform.c @@ -700,7 +700,7 @@ test_trivial(const hid_t dxpl_id_simple) FAIL_PUTS_ERROR(" ERROR: Conversion failed to match computed data\n"); } - PASSED() + PASSED(); TESTING("data transform, trivial transform, with type conversion") if(H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, @@ -712,7 +712,7 @@ test_trivial(const hid_t dxpl_id_simple) FAIL_PUTS_ERROR(" ERROR: Conversion failed to match computed data\n") } - PASSED() + PASSED(); return 0; error: @@ -739,7 +739,7 @@ test_getset(const hid_t dxpl_id_c_to_f) if(HDstrcmp(c_to_f, ptrgetTest) != 0) FAIL_PUTS_ERROR(" ERROR: Data transform failed to match what was set\n") - PASSED() + PASSED(); HDfree(ptrgetTest); ptrgetTest = NULL; @@ -759,7 +759,7 @@ test_getset(const hid_t dxpl_id_c_to_f) FAIL_PUTS_ERROR(" ERROR: Conversion failed to match computed data\n") } - PASSED() + PASSED(); TESTING("H5Pget_data_transform, after resetting transform property") @@ -770,7 +770,7 @@ test_getset(const hid_t dxpl_id_c_to_f) if(HDstrcmp(simple, ptrgetTest) != 0) FAIL_PUTS_ERROR(" ERROR: Data transform failed to match what was set\n") - PASSED() + PASSED(); HDfree(ptrgetTest); ptrgetTest = NULL; @@ -806,7 +806,7 @@ test_set(void) H5Eset_auto2(H5E_DEFAULT, NULL, NULL); if(H5Pget_data_transform(dxpl_id, ptrgetTest, HDstrlen(str) + 1) < 0) - PASSED() + PASSED(); else FAIL_PUTS_ERROR(" ERROR: Data transform get before set succeeded (it shouldn't have)\n"); diff --git a/test/earray.c b/test/earray.c index 4087648..acb4f76 100644 --- a/test/earray.c +++ b/test/earray.c @@ -767,7 +767,7 @@ test_create(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t H5_ATTR_UNUSE TEST_ERROR } /* end if */ - PASSED() + PASSED(); } #else /* NDEBUG */ SKIPPED(); @@ -783,7 +783,7 @@ test_create(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t H5_ATTR_UNUSE if(create_array(f, cparam, &ea, &ea_addr, NULL) < 0) TEST_ERROR - PASSED() + PASSED(); /* Verify the creation parameters */ TESTING("verify array creation parameters"); @@ -797,7 +797,7 @@ test_create(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t H5_ATTR_UNUSE TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return 0; @@ -867,7 +867,7 @@ test_reopen(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam) TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return 0; @@ -971,7 +971,7 @@ test_open_twice(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam) TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return 0; @@ -1111,7 +1111,7 @@ test_open_twice_diff(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tpa TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return 0; @@ -1232,7 +1232,7 @@ test_delete_open(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam) TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return 0; @@ -2233,7 +2233,7 @@ test_set_elmts(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam, TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return 0; @@ -2390,7 +2390,7 @@ test_skip_elmts(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam, TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return 0; diff --git a/test/enum.c b/test/enum.c index 26e64fd..109f7c3 100644 --- a/test/enum.c +++ b/test/enum.c @@ -128,7 +128,7 @@ test_conv(hid_t file) { hid_t cwg=-1, type=-1, space=-1, dset=-1; c_e1 val; - /* Some values are out of range for testing. The library should accept them */ + /* Some values are out of range for testing. The library should accept them */ static c_e1 data1[]={E1_RED, E1_GREEN, E1_BLUE, E1_GREEN, E1_WHITE, E1_WHITE, E1_BLACK, E1_GREEN, E1_BLUE, E1_RED, E1_RED, E1_BLUE, E1_GREEN, E1_BLACK, E1_WHITE, diff --git a/test/evict_on_close.c b/test/evict_on_close.c index 9d23f2f..f5ce803 100644 --- a/test/evict_on_close.c +++ b/test/evict_on_close.c @@ -72,7 +72,7 @@ const char *FILENAMES[] = { #define SUBGROUP_NAME_SIZE 16 /* Prototypes */ -static hbool_t verify_tag_not_in_cache(H5F_t *f, haddr_t tag); +static hbool_t verify_tag_not_in_cache(const H5F_t *f, haddr_t tag); static herr_t check_evict_on_close_api(void); static hid_t generate_eoc_test_file(hid_t fapl_id); static herr_t check_dset_scheme(hid_t fid, const char *dset_name); @@ -89,8 +89,8 @@ static herr_t check_group_layout(hid_t fid, const char *group_name); * *------------------------------------------------------------------------- */ -static hbool_t -verify_tag_not_in_cache(H5F_t *f, haddr_t tag) +static H5_ATTR_PURE hbool_t +verify_tag_not_in_cache(const H5F_t *f, haddr_t tag) { H5C_t *cache_ptr = NULL; /* cache pointer */ int i = 0; /* iterator */ @@ -743,7 +743,7 @@ check_dset_scheme(hid_t fid, const char *dset_name) TEST_ERROR; /* Record the number of cache entries */ - during = file_ptr->shared->cache->index_len; + during = file_ptr->shared->cache->index_len; #ifdef EOC_MANUAL_INSPECTION HDprintf("\nCACHE AFTER DATA READ (WHILE OPEN):\n"); diff --git a/test/extend.c b/test/extend.c index a31ac0e..1e2b5b5 100644 --- a/test/extend.c +++ b/test/extend.c @@ -25,11 +25,16 @@ const char *FILENAME[] = { NULL }; -#define NX 100 /* USE AN EVEN NUMBER!*/ -#define NY 100 /* USE AN EVEN NUMBER!*/ +#define N1X 100 /* USE AN EVEN NUMBER! */ +#define N1Y 100 /* USE AN EVEN NUMBER! */ +#define N2X (N1X / 2) +#define N2Y (N1Y / 2) /* Data buffers */ -static int buf1[NY][NX], buf2[NX / 2][NY / 2]; +static int **buf1 = NULL; +static int *buf1_data = NULL; +static int **buf2 = NULL; +static int *buf2_data = NULL; /*------------------------------------------------------------------------- @@ -49,8 +54,8 @@ static int write_data(const char *msg, hid_t file, const char *name, hid_t cparms, hid_t mem_space) { hid_t dataset, file_space, half_space; - static const hsize_t dims[2] = {NX, NY}; - static const hsize_t half_dims[2] = {NX / 2, NY / 2}; + static const hsize_t dims[2] = {N1X, N1Y}; + static const hsize_t half_dims[2] = {N2X, N2Y}; hsize_t size[2]; hsize_t max_size[2] = {0, 0}; hsize_t offset[2]; @@ -63,13 +68,13 @@ write_data(const char *msg, hid_t file, const char *name, hid_t cparms, hid_t me /* Write the data */ for(i = 0; i < 5; i++) - for(j = 0; j < 5; j++) { + for(j = 0; j < 5; j++) { - /* Extend the dataset */ - offset[0] = (hsize_t)(i * NX); - offset[1] = (hsize_t)(j * NY); - size[0] = offset[0] + NX; - size[1] = offset[1] + NY; + /* Extend the dataset */ + offset[0] = (hsize_t)(i * N1X); + offset[1] = (hsize_t)(j * N1Y); + size[0] = offset[0] + N1X; + size[1] = offset[1] + N1Y; if(size[0] > max_size[0] || size[1] > max_size[1]) { if(size[0] > max_size[0]) max_size[0] = size[0]; @@ -78,42 +83,41 @@ write_data(const char *msg, hid_t file, const char *name, hid_t cparms, hid_t me if(H5Dset_extent(dataset, max_size) < 0) TEST_ERROR; } /* end if */ - /* Select a hyperslab */ + /* Select a hyperslab */ if((file_space = H5Dget_space(dataset)) < 0) TEST_ERROR; - if(H5Sselect_hyperslab(file_space, H5S_SELECT_SET, offset, NULL, dims, NULL) < 0) TEST_ERROR; + if(H5Sselect_hyperslab(file_space, H5S_SELECT_SET, offset, NULL, dims, NULL) < 0) TEST_ERROR; - /* Write to the hyperslab */ - if(H5Dwrite(dataset, H5T_NATIVE_INT, mem_space, file_space, H5P_DEFAULT, buf1) < 0) TEST_ERROR; + /* Write to the hyperslab */ + if(H5Dwrite(dataset, H5T_NATIVE_INT, mem_space, file_space, H5P_DEFAULT, buf1_data) < 0) TEST_ERROR; if(H5Sclose(file_space) < 0) TEST_ERROR; - } /* end for */ + } /* end for */ /* Read the data */ if((half_space = H5Screate_simple(2, half_dims, NULL)) < 0) TEST_ERROR; if((file_space = H5Dget_space(dataset)) < 0) TEST_ERROR; for(i = 0; i < 10; i++) { - for(j = 0; j < 10; j++) { - - /* Select a hyperslab */ - offset[0] = (hsize_t)(i * (NX / 2)); - offset[1] = (hsize_t)(j * (NY / 2)); - if(H5Sselect_hyperslab(file_space, H5S_SELECT_SET, offset, NULL, half_dims, NULL) < 0) TEST_ERROR; - - /* Read */ - if(H5Dread(dataset, H5T_NATIVE_INT, half_space, file_space, H5P_DEFAULT, buf2) < 0) TEST_ERROR; - - /* Compare */ - for(k = 0; k < (NX / 2); k++) - for(m = 0; m < (NY / 2); m++) - if(buf2[k][m] != buf1[(i % 2) * (NX / 2) + k][(j % 2) * (NY / 2) + m]) { - HDprintf(" i=%d, j=%d, k=%d, m=%d\n", i, j, k, m); - HDprintf(" buf2[%d][%d]=%d\n", k, m, buf2[k][m]); - HDprintf(" buf1[%d][%d]=%d\n", (i % 2) * (NX / 2) + k, (j % 2) * (NY / 2) + m, buf1[(i % 2) * (NX / 2) + k][(j % 2) * (NY / 2) + m]); - TEST_ERROR; - } /* end if */ - } /* end for */ + for(j = 0; j < 10; j++) { + + /* Select a hyperslab */ + offset[0] = (hsize_t)(i * N2X); + offset[1] = (hsize_t)(j * N2Y); + if(H5Sselect_hyperslab(file_space, H5S_SELECT_SET, offset, NULL, half_dims, NULL) < 0) TEST_ERROR; + + /* Read */ + if(H5Dread(dataset, H5T_NATIVE_INT, half_space, file_space, H5P_DEFAULT, buf2_data) < 0) TEST_ERROR; + + /* Compare */ + for(k = 0; k < N2X; k++) + for(m = 0; m < N2Y; m++) + if(buf2[k][m] != buf1[(i % 2) * N2X + k][(j % 2) * N2Y + m]) { + HDprintf(" i=%d, j=%d, k=%d, m=%d\n", i, j, k, m); + HDprintf(" buf2[%d][%d]=%d\n", k, m, buf2[k][m]); + HDprintf(" buf1[%d][%d]=%d\n", (i % 2) * N2X + k, (j % 2) * N2Y + m, buf1[(i % 2) * N2X + k][(j % 2) * N2Y + m]); + TEST_ERROR; + } /* end if */ + } /* end for */ } /* end for */ - /* Cleanup */ if(H5Dclose(dataset) < 0) TEST_ERROR; if(H5Sclose(file_space) < 0) TEST_ERROR; @@ -146,8 +150,8 @@ static int write_data_deprec(const char *msg, hid_t file, const char *name, hid_t cparms, hid_t mem_space) { hid_t dataset, file_space, half_space; - static const hsize_t dims[2] = {NX, NY}; - static const hsize_t half_dims[2] = {NX / 2, NY / 2}; + static const hsize_t dims[2] = {N1X, N1Y}; + static const hsize_t half_dims[2] = {N2X, N2Y}; static hsize_t size[2]; hsize_t offset[2]; int i, j, k, m; @@ -159,48 +163,48 @@ write_data_deprec(const char *msg, hid_t file, const char *name, hid_t cparms, h /* Write the data */ for(i = 0; i < 5; i++) - for(j = 0; j < 5; j++) { + for(j = 0; j < 5; j++) { - /* Extend the dataset */ - offset[0] = (hsize_t)(i * NX); - offset[1] = (hsize_t)(j * NY); - size[0] = offset[0] + NX; - size[1] = offset[1] + NY; - if(H5Dextend(dataset, size) < 0) TEST_ERROR; + /* Extend the dataset */ + offset[0] = (hsize_t)(i * N1X); + offset[1] = (hsize_t)(j * N1Y); + size[0] = offset[0] + N1X; + size[1] = offset[1] + N1Y; + if(H5Dextend(dataset, size) < 0) TEST_ERROR; - /* Select a hyperslab */ + /* Select a hyperslab */ if((file_space = H5Dget_space(dataset)) < 0) TEST_ERROR; - if(H5Sselect_hyperslab(file_space, H5S_SELECT_SET, offset, NULL, dims, NULL) < 0) TEST_ERROR; + if(H5Sselect_hyperslab(file_space, H5S_SELECT_SET, offset, NULL, dims, NULL) < 0) TEST_ERROR; - /* Write to the hyperslab */ - if(H5Dwrite(dataset, H5T_NATIVE_INT, mem_space, file_space, H5P_DEFAULT, buf1) < 0) TEST_ERROR; + /* Write to the hyperslab */ + if(H5Dwrite(dataset, H5T_NATIVE_INT, mem_space, file_space, H5P_DEFAULT, buf1_data) < 0) TEST_ERROR; if(H5Sclose(file_space) < 0) TEST_ERROR; - } /* end for */ + } /* end for */ /* Read the data */ if((half_space = H5Screate_simple(2, half_dims, NULL)) < 0) TEST_ERROR; if((file_space = H5Dget_space(dataset)) < 0) TEST_ERROR; for(i = 0; i < 10; i++) { - for(j = 0; j < 10; j++) { - - /* Select a hyperslab */ - offset[0] = (hsize_t)(i * (NX / 2)); - offset[1] = (hsize_t)(j * (NY / 2)); - if(H5Sselect_hyperslab(file_space, H5S_SELECT_SET, offset, NULL, half_dims, NULL) < 0) TEST_ERROR; - - /* Read */ - if(H5Dread(dataset, H5T_NATIVE_INT, half_space, file_space, H5P_DEFAULT, buf2) < 0) TEST_ERROR; - - /* Compare */ - for(k = 0; k < (NX / 2); k++) - for(m = 0; m < (NY / 2); m++) - if(buf2[k][m] != buf1[(i % 2) * (NX / 2) + k][(j % 2) * (NY / 2) + m]) { - HDprintf(" i=%d, j=%d, k=%d, m=%d\n", i, j, k, m); - HDprintf(" buf2[%d][%d]=%d\n", k, m, buf2[k][m]); - HDprintf(" buf1[%d][%d]=%d\n", (i % 2) * (NX / 2) + k, (j % 2) * (NY / 2) + m, buf1[(i % 2) * (NX / 2) + k][(j % 2) * (NY / 2) + m]); - TEST_ERROR; - } /* end if */ - } /* end for */ + for(j = 0; j < 10; j++) { + + /* Select a hyperslab */ + offset[0] = (hsize_t)(i * N2X); + offset[1] = (hsize_t)(j * N2Y); + if(H5Sselect_hyperslab(file_space, H5S_SELECT_SET, offset, NULL, half_dims, NULL) < 0) TEST_ERROR; + + /* Read */ + if(H5Dread(dataset, H5T_NATIVE_INT, half_space, file_space, H5P_DEFAULT, buf2_data) < 0) TEST_ERROR; + + /* Compare */ + for(k = 0; k < N2X; k++) + for(m = 0; m < N2Y; m++) + if(buf2[k][m] != buf1[(i % 2) * N2X + k][(j % 2) * N2Y + m]) { + HDprintf(" i=%d, j=%d, k=%d, m=%d\n", i, j, k, m); + HDprintf(" buf2[%d][%d]=%d\n", k, m, buf2[k][m]); + HDprintf(" buf1[%d][%d]=%d\n", (i % 2) * N2X + k, (j % 2) * N2Y + m, buf1[(i % 2) * N2X + k][(j % 2) * N2Y + m]); + TEST_ERROR; + } /* end if */ + } /* end for */ } /* end for */ @@ -236,8 +240,8 @@ main (void) hid_t file, mem_space, cparms; hid_t fapl; int nerrors = 0; - static const hsize_t dims[2] = {NX, NY}; - static const hsize_t chunk_dims[2] = {NX/2, NY/2}; + static const hsize_t dims[2] = {N1X, N1Y}; + static const hsize_t chunk_dims[2] = {N2X, N2Y}; static hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; char filename[1024]; int i, j; @@ -246,9 +250,23 @@ main (void) fapl = h5_fileaccess(); /* Initialize buffer and space */ - for(i = 0; i < NX; i++) - for(j = 0; j < NY; j++) - buf1[i][j] = i * NY + j; + if(NULL == (buf1_data = (int *)HDcalloc(N1X * N1Y, sizeof(int)))) + TEST_ERROR; + if(NULL == (buf1 = (int **)HDcalloc(N1X, sizeof(buf1_data)))) + TEST_ERROR; + for (i = 0; i < N1X; i++) + buf1[i] = buf1_data + (i * N1Y); + + if(NULL == (buf2_data = (int *)HDcalloc(N2X * N2Y, sizeof(int)))) + TEST_ERROR; + if(NULL == (buf2 = (int **)HDcalloc(N2X, sizeof(buf2_data)))) + TEST_ERROR; + for (i = 0; i < N2X; i++) + buf2[i] = buf2_data + (i * N2Y); + + for(i = 0; i < N1X; i++) + for(j = 0; j < N1Y; j++) + buf1[i][j] = i * N1Y + j; if((mem_space = H5Screate_simple(2, dims, maxdims)) < 0) TEST_ERROR; @@ -288,9 +306,20 @@ main (void) HDprintf("All extend tests passed.\n"); h5_cleanup(FILENAME, fapl); + HDfree(buf1); + HDfree(buf1_data); + HDfree(buf2); + HDfree(buf2_data); + HDexit(EXIT_SUCCESS); error: + + HDfree(buf1); + HDfree(buf1_data); + HDfree(buf2); + HDfree(buf2_data); + HDprintf("*** One or more extend tests failed ***\n"); HDexit(EXIT_FAILURE); } /* end main() */ diff --git a/test/farray.c b/test/farray.c index eb9ac42..7b316a8 100644 --- a/test/farray.c +++ b/test/farray.c @@ -142,7 +142,7 @@ init_cparam(H5FA_create_t *cparam, farray_test_param_t *tparam) * Purpose: Create file and retrieve pointer to internal file object * * Return: SUCCEED/FAIL - * + * *------------------------------------------------------------------------- */ static herr_t @@ -261,7 +261,7 @@ set_fa_state(const H5FA_create_t *cparam, farray_state_t *state) *------------------------------------------------------------------------- */ static int -reopen_file(hid_t *fid, H5F_t **f, hid_t fapl_id, +reopen_file(hid_t *fid, H5F_t **f, hid_t fapl_id, H5FA_t **fa, haddr_t fa_addr, const farray_test_param_t *tparam) { /* Check for closing & re-opening the array */ @@ -499,7 +499,7 @@ test_create(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t H5_ATTR_UNUSE TEST_ERROR } /* end if */ - PASSED() + PASSED(); } #else /* NDEBUG */ SKIPPED(); @@ -515,7 +515,7 @@ test_create(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t H5_ATTR_UNUSE if(create_array(f, cparam, &fa, &fa_addr) < 0) TEST_ERROR - PASSED() + PASSED(); /* Verify the creation parameters */ TESTING("verify array creation parameters"); @@ -529,7 +529,7 @@ test_create(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t H5_ATTR_UNUSE TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return 0; @@ -596,7 +596,7 @@ test_reopen(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam) TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return 0; @@ -695,7 +695,7 @@ test_open_twice(hid_t fapl_id, H5FA_create_t *cparam, farray_test_param_t *tpara TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return 0; @@ -828,7 +828,7 @@ test_open_twice_diff(hid_t fapl_id, H5FA_create_t *cparam, farray_test_param_t * TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return 0; @@ -946,7 +946,7 @@ test_delete_open(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam) TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return 0; @@ -1486,7 +1486,7 @@ test_set_elmts(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam, TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return 0; @@ -1613,7 +1613,7 @@ test_skip_elmts(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam, TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return 0; diff --git a/test/fheap.c b/test/fheap.c index 7968f50..771081b 100644 --- a/test/fheap.c +++ b/test/fheap.c @@ -82,7 +82,7 @@ /* The number of settings for testing: page buffering, file space strategy and persisting free-space */ #define NUM_PB_FS 6 -#define PAGE_BUFFER_PAGE_SIZE 4096 +#define PAGE_BUFFER_PAGE_SIZE 4096 const char *FILENAME[] = { "fheap", @@ -545,8 +545,7 @@ get_fill_size(const fheap_test_param_t *tparam) * test_desc in the code below, but early (4.4.7, at least) gcc only * allows diagnostic pragmas to be toggled outside of functions. */ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wformat-nonliteral" +H5_GCC_DIAG_OFF(format-nonliteral) static int begin_test(fheap_test_param_t *tparam, const char *base_desc, fheap_heap_ids_t *keep_ids, size_t *fill_size) @@ -575,7 +574,7 @@ begin_test(fheap_test_param_t *tparam, const char *base_desc, /* Success */ return(0); } /* end begin_test() */ -#pragma GCC diagnostic pop +H5_GCC_DIAG_ON(format-nonliteral) /*------------------------------------------------------------------------- @@ -1904,7 +1903,7 @@ test_create(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) HDmemset(&state, 0, sizeof(fheap_heap_state_t)); if(check_stats(fh, &state)) TEST_ERROR - PASSED() + PASSED(); /* Query the type of address mapping */ TESTING("query heap creation parameters"); @@ -1936,7 +1935,7 @@ test_create(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return 0; @@ -2088,7 +2087,7 @@ test_reopen(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -2261,7 +2260,7 @@ test_open_twice(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return 0; @@ -2436,7 +2435,7 @@ test_delete_open(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return 0; @@ -2782,7 +2781,7 @@ test_id_limits(hid_t fapl, H5HF_create_t *cparam, hid_t fcpl) FAIL_STACK_ERROR /* All tests passed */ - PASSED() + PASSED(); return 0; @@ -2905,7 +2904,7 @@ test_filtered_create(hid_t fapl, H5HF_create_t *cparam, hid_t fcpl) H5O_msg_reset(H5O_PLINE_ID, &test_cparam.pline); /* All tests passed */ - PASSED() + PASSED(); return 0; @@ -3045,7 +3044,7 @@ test_size(hid_t fapl, H5HF_create_t *cparam, hid_t fcpl) FAIL_STACK_ERROR /* All tests passed */ - PASSED() + PASSED(); return 0; @@ -3182,7 +3181,7 @@ test_reopen_hdr(hid_t fapl, H5HF_create_t *cparam, hid_t fcpl) FAIL_STACK_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -3293,7 +3292,7 @@ test_man_insert_weird(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpa FAIL_STACK_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -3394,7 +3393,7 @@ test_man_insert_first(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpa TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -3488,7 +3487,7 @@ test_man_insert_second(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tp TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -3585,7 +3584,7 @@ test_man_insert_root_mult(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -3690,7 +3689,7 @@ test_man_insert_force_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_par TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -3795,7 +3794,7 @@ test_man_insert_fill_second(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_ TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -3906,7 +3905,7 @@ test_man_insert_third_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -4001,7 +4000,7 @@ test_man_fill_first_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *t TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -4103,7 +4102,7 @@ test_man_start_second_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -4202,7 +4201,7 @@ test_man_fill_second_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t * TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -4312,7 +4311,7 @@ test_man_start_third_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t * TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -4409,7 +4408,7 @@ test_man_fill_fourth_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t * TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -4504,7 +4503,7 @@ test_man_fill_all_root_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_para TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -4604,7 +4603,7 @@ test_man_first_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_ TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -4713,7 +4712,7 @@ test_man_second_direct_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fhe TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -4814,7 +4813,7 @@ test_man_fill_first_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_ TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -4923,7 +4922,7 @@ test_man_second_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -5030,7 +5029,7 @@ test_man_fill_second_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -5129,7 +5128,7 @@ test_man_fill_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fheap_te TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -5237,7 +5236,7 @@ test_man_start_2nd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -5338,7 +5337,7 @@ test_man_recursive_indirect_two_deep(hid_t fapl, H5HF_create_t *cparam, fheap_te TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -5447,7 +5446,7 @@ test_man_start_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -5557,7 +5556,7 @@ test_man_fill_first_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fh TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -5663,7 +5662,7 @@ test_man_fill_3rd_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fhea TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -5769,7 +5768,7 @@ test_man_fill_all_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fhea TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -5883,7 +5882,7 @@ test_man_start_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -6002,7 +6001,7 @@ test_man_fill_first_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fh TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -6113,7 +6112,7 @@ test_man_fill_4th_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fhea TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -6224,7 +6223,7 @@ test_man_fill_all_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fhea TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -6358,7 +6357,7 @@ test_man_start_5th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -6512,7 +6511,7 @@ HDfprintf(stderr, "Random # seed was: %lu\n", seed); TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -6676,7 +6675,7 @@ test_man_remove_one(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpara TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -6868,7 +6867,7 @@ test_man_remove_two(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpara TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -7036,7 +7035,7 @@ test_man_remove_one_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -7279,7 +7278,7 @@ HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -7582,7 +7581,7 @@ HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -7617,7 +7616,8 @@ test_man_incr_insert_remove(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_ H5F_t *f = NULL; /* Internal file object pointer */ H5HF_t *fh = NULL; /* Fractal heap wrapper */ haddr_t fh_addr; /* Address of fractal heap */ - unsigned char heap_id[100][MAX_HEAP_ID_LEN]; /* Heap ID for object inserted */ + unsigned char **heap_id = NULL; + unsigned char *heap_id_data = NULL; struct a_type_t1 { char a[10]; char b[40]; @@ -7629,6 +7629,14 @@ test_man_incr_insert_remove(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_ /* Set the filename to use for this test (dependent on fapl) */ h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); + /* Set up data array */ + if(NULL == (heap_id_data = (unsigned char *)HDcalloc(100 * MAX_HEAP_ID_LEN, sizeof(unsigned char)))) + TEST_ERROR; + if(NULL == (heap_id = (unsigned char **)HDcalloc(100, sizeof(heap_id_data)))) + TEST_ERROR; + for (i = 0; i < 100; i++) + heap_id[i] = heap_id_data + (i * MAX_HEAP_ID_LEN); + /* Create the file to work on */ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, tparam->my_fcpl, fapl)) < 0) FAIL_STACK_ERROR @@ -7657,7 +7665,7 @@ test_man_incr_insert_remove(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_ FAIL_STACK_ERROR /* - * Test incremental insert and removal + * Test incremental insert and removal */ TESTING("incremental object insertion and removal") @@ -7683,7 +7691,7 @@ test_man_incr_insert_remove(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_ if(H5HF_insert(fh, (sizeof(obj1)), &obj1, heap_id[i]) < 0) FAIL_STACK_ERROR } /* end for */ - + /* Close the fractal heap */ if(H5HF_close(fh) < 0) TEST_ERROR @@ -7693,9 +7701,12 @@ test_man_incr_insert_remove(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_ TEST_ERROR /* All tests passed */ - PASSED() + PASSED(); - return(0); + HDfree(heap_id); + HDfree(heap_id_data); + + return 0; error: H5E_BEGIN_TRY { @@ -7703,7 +7714,11 @@ error: H5HF_close(fh); H5Fclose(file); } H5E_END_TRY; - return(1); + + HDfree(heap_id); + HDfree(heap_id_data); + + return 1; } /* test_man_incr_insert_remove() */ #endif /* QAK */ @@ -7765,7 +7780,7 @@ test_man_remove_root_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_ H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -7853,7 +7868,7 @@ test_man_remove_two_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -7923,7 +7938,7 @@ test_man_remove_first_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -7995,7 +8010,7 @@ test_man_remove_first_two_rows(hid_t fapl, H5HF_create_t *cparam, fheap_test_par H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -8071,7 +8086,7 @@ test_man_remove_first_four_rows(hid_t fapl, H5HF_create_t *cparam, fheap_test_pa H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -8141,7 +8156,7 @@ test_man_remove_all_root_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_pa H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -8215,7 +8230,7 @@ test_man_remove_2nd_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -8293,7 +8308,7 @@ test_man_remove_3rd_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_param H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -8374,7 +8389,7 @@ test_man_skip_start_block(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -8471,7 +8486,7 @@ test_man_skip_start_block_add_back(hid_t fapl, H5HF_create_t *cparam, fheap_test H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -8580,7 +8595,7 @@ test_man_skip_start_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_t H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -8673,7 +8688,7 @@ test_man_skip_2nd_block(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *t H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -8815,7 +8830,7 @@ test_man_skip_2nd_block_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_tes H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -8981,7 +8996,7 @@ test_man_fill_one_partial_skip_2nd_block_add_skipped(hid_t fapl, H5HF_create_t * H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -9110,7 +9125,7 @@ test_man_fill_row_skip_add_skipped(hid_t fapl, H5HF_create_t *cparam, fheap_test H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -9237,7 +9252,7 @@ test_man_skip_direct_skip_indirect_two_rows_add_skipped(hid_t fapl, H5HF_create_ H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -9359,7 +9374,7 @@ test_man_fill_direct_skip_indirect_start_block_add_skipped(hid_t fapl, H5HF_crea H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -9486,7 +9501,7 @@ test_man_fill_direct_skip_2nd_indirect_start_block_add_skipped(hid_t fapl, H5HF_ H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -9628,7 +9643,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -9802,7 +9817,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -9953,7 +9968,7 @@ test_man_fill_direct_skip_indirect_two_rows_add_skipped(hid_t fapl, H5HF_create_ H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -10133,7 +10148,7 @@ test_man_fill_direct_skip_indirect_two_rows_skip_indirect_row_add_skipped(hid_t H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -10259,7 +10274,7 @@ test_man_fill_2nd_direct_skip_start_block_add_skipped(hid_t fapl, H5HF_create_t H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -10397,7 +10412,7 @@ test_man_fill_2nd_direct_skip_2nd_indirect_start_block_add_skipped(hid_t fapl, H H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -10547,7 +10562,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -10708,7 +10723,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -10869,7 +10884,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -11037,7 +11052,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -11196,7 +11211,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -11373,7 +11388,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -11585,7 +11600,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -11781,7 +11796,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -12013,7 +12028,7 @@ HDfprintf(stderr, "obj_size = %Zu\n", obj_size); H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -12147,7 +12162,7 @@ test_man_frag_simple(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpar H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -12316,7 +12331,7 @@ test_man_frag_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpar H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -12428,7 +12443,7 @@ HDfprintf(stderr, "num_first_indirect_rows = %u\n", num_first_indirect_rows); H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -12546,7 +12561,7 @@ test_man_frag_3rd_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t * H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -12699,7 +12714,7 @@ HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -12930,7 +12945,7 @@ HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -13236,7 +13251,7 @@ HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -13661,7 +13676,7 @@ HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -13879,7 +13894,7 @@ HDfprintf(stderr, "empty_size = %lu, file_size = %lu\n", (unsigned long)empty_si H5MM_xfree(heap_id); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -14030,7 +14045,7 @@ HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -14261,7 +14276,7 @@ HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -14866,7 +14881,7 @@ HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -15054,7 +15069,7 @@ HDfprintf(stderr, "empty_size = %lu, file_size = %lu\n", (unsigned long)empty_si H5O_msg_reset(H5O_PLINE_ID, &tmp_cparam.pline); /* Release the I/O pipeline filter information */ /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -15382,7 +15397,7 @@ HDfprintf(stderr, "empty_size = %lu, file_size = %lu\n", (unsigned long)empty_si H5O_msg_reset(H5O_PLINE_ID, &tmp_cparam.pline); /* Release the I/O pipeline filter information */ /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -15582,7 +15597,7 @@ HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -15798,7 +15813,7 @@ HDfprintf(stderr, "file_size = %lu\n", (unsigned long)file_size); H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -16084,7 +16099,7 @@ test_write(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) H5MM_xfree(rewrite_obj); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -16262,7 +16277,7 @@ test_bug1(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) H5MM_xfree(keep_ids.offs); /* All tests passed */ - PASSED() + PASSED(); return(0); @@ -16326,7 +16341,7 @@ main(void) def_fapl = h5_fileaccess(); ExpressMode = GetTestExpress(); - /* + /* * Caution when turning on ExpressMode 0: * It will activate testing with different combinations of * page buffering and file space strategy and the @@ -16376,12 +16391,12 @@ main(void) for(v = 0; v < num_pb_fs; v++) { /* Skip test when: a) multi/split drivers and - b) persisting free-space or using paged aggregation strategy + b) persisting free-space or using paged aggregation strategy because the library will fail file creation (temporary) for the above conditions */ if(!contig_addr_vfd && v) break; - if((fcpl = H5Pcopy(def_fcpl)) < 0) + if((fcpl = H5Pcopy(def_fcpl)) < 0) TEST_ERROR switch(v) { @@ -16395,14 +16410,14 @@ main(void) TEST_ERROR fapl = def_fapl; /* This is a fix for the daily test failure from the checkin for libver bounds. */ - /* + /* * Many tests failed the file size check when comparing (a) and (b) as below: * --Create a file and close the file. Got the initial file size (a). * --Reopen the file, perform fractal heap operations, and close the file. * Got the file size (b). * The cause for the file size differences: - * When the file is initially created with persisting free-space and with - * (earliest, latest) libver bounds, the file will have version 2 superblock + * When the file is initially created with persisting free-space and with + * (earliest, latest) libver bounds, the file will have version 2 superblock * due to non-default free-space handling. As the low bound is earliest, * the library uses version 1 object header when creating the superblock * extension message. @@ -16416,7 +16431,7 @@ main(void) * The fix: * Set libver bounds in fapl to (v18, latest) so that the file created in the * test routines will have low bound set to v18. This will cause the - * library to use version 2 object header for the superblock extension + * library to use version 2 object header for the superblock extension * message. */ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_V18, H5F_LIBVER_LATEST) < 0) diff --git a/test/flush1.c b/test/flush1.c index d7d578b..a831b46 100644 --- a/test/flush1.c +++ b/test/flush1.c @@ -99,7 +99,7 @@ create_file(const char *filename, hid_t fapl_id, hbool_t swmr) if(H5Gclose(top_gid) < 0) STACK_ERROR - + return fid; error: @@ -185,7 +185,7 @@ error: * a variety of situations. * * Part 1 of a two-part H5Fflush() test. - * + * * Return: EXIT_SUCCESS/EXIT_FAILURE * * Programmer: Robb Matzke diff --git a/test/flush2.c b/test/flush2.c index 519f1b2..d58eefd 100644 --- a/test/flush2.c +++ b/test/flush2.c @@ -266,7 +266,7 @@ main(void) h5_fixname(FILENAME[0], fapl_id, filename, sizeof(filename)); check_second_dset = FALSE; if(file_ok(filename, fapl_id, check_second_dset)) - PASSED() + PASSED(); else TEST_ERROR @@ -279,7 +279,7 @@ main(void) if(clear_status_flags(filename, fapl_id) < 0) TEST_ERROR if(file_ok(filename, fapl_id, check_second_dset)) - PASSED() + PASSED(); else TEST_ERROR } /* end if */ @@ -305,7 +305,7 @@ main(void) #endif } /* end if */ else - PASSED() + PASSED(); /* Turn the error stack back on */ if(H5Eset_auto2(H5E_DEFAULT, func, NULL) < 0) FAIL_STACK_ERROR @@ -332,7 +332,7 @@ main(void) #endif } /* end if */ else - PASSED() + PASSED(); /* Turn the error stack back on */ if(H5Eset_auto2(H5E_DEFAULT, func, NULL) < 0) FAIL_STACK_ERROR @@ -348,13 +348,13 @@ main(void) check_second_dset = TRUE; h5_fixname(FILENAME[4], fapl_id, filename, sizeof(filename)); if(file_ok(filename, fapl_id, check_second_dset)) - PASSED() + PASSED(); else TEST_ERROR /* TEST 6 */ /* Check the case where the file was flushed, but more data was - * added afterward and then flushed (w/SWMR) + * added afterward and then flushed (w/SWMR) */ TESTING("H5Fflush (part2 with flush and later addition and another flush + SWMR)"); if(vfd_supports_swmr) { @@ -363,7 +363,7 @@ main(void) if(clear_status_flags(filename, fapl_id) < 0) TEST_ERROR if(file_ok(filename, fapl_id, check_second_dset)) - PASSED() + PASSED(); else TEST_ERROR } /* end if */ @@ -391,7 +391,7 @@ main(void) #endif } /* end if */ else - PASSED() + PASSED(); /* Turn the error stack back on */ if(H5Eset_auto2(H5E_DEFAULT, func, NULL) < 0) FAIL_STACK_ERROR diff --git a/test/freespace.c b/test/freespace.c index c0fbb76..9156061 100644 --- a/test/freespace.c +++ b/test/freespace.c @@ -546,7 +546,7 @@ test_fs_create(hid_t fapl) if(file_size != empty_size) TEST_ERROR - PASSED() + PASSED(); return 0; @@ -673,7 +673,7 @@ test_fs_sect_add(hid_t fapl) if (tmp_file_size <= (file_size+fr_meta_size)) TEST_ERROR - PASSED() + PASSED(); TESTING("adding a section via H5FS_sect_add() to free-space with H5FS_CLS_GHOST_OBJ: test 2"); @@ -735,7 +735,7 @@ test_fs_sect_add(hid_t fapl) if (tmp_file_size != (file_size+fr_meta_size)) TEST_ERROR - PASSED() + PASSED(); TESTING("adding a section via H5FS_sect_add() to free-space: test 3"); @@ -804,7 +804,7 @@ test_fs_sect_add(hid_t fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); TESTING("adding a section via H5FS_sect_add() to free-space: test 4"); @@ -883,7 +883,7 @@ test_fs_sect_add(hid_t fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); return 0; @@ -981,7 +981,7 @@ test_fs_sect_find(hid_t fapl) FAIL_STACK_ERROR frsp = NULL; - PASSED() + PASSED(); TESTING("H5FS_sect_find() a section equal to requested-size from free-space"); @@ -1109,7 +1109,7 @@ test_fs_sect_find(hid_t fapl) FAIL_STACK_ERROR frsp = NULL; - PASSED() + PASSED(); TESTING("H5FS_sect_find() a section greater than requested-size from free-space"); @@ -1189,7 +1189,7 @@ test_fs_sect_find(hid_t fapl) FAIL_STACK_ERROR frsp = NULL; - PASSED() + PASSED(); TESTING("H5FS_sect_find(): cannot find a section with requested-size from free-space"); @@ -1252,7 +1252,7 @@ test_fs_sect_find(hid_t fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); return 0; @@ -1452,7 +1452,7 @@ test_fs_sect_merge(hid_t fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); /* * TEST 2 @@ -1554,7 +1554,7 @@ test_fs_sect_merge(hid_t fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); /* * TEST 3 @@ -1722,7 +1722,7 @@ test_fs_sect_merge(hid_t fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); return 0; @@ -1893,7 +1893,7 @@ test_fs_sect_shrink(hid_t fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); TESTING("shrinking of sections when H5FS_sect_add() to free-space: test 2"); @@ -1995,7 +1995,7 @@ test_fs_sect_shrink(hid_t fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); TESTING("shrinking of sections when H5FS_sect_add() to free-space: test 3"); @@ -2086,7 +2086,7 @@ test_fs_sect_shrink(hid_t fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); return 0; @@ -2239,7 +2239,7 @@ test_fs_sect_change_class(hid_t fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); /* * TEST 2 @@ -2361,7 +2361,7 @@ test_fs_sect_change_class(hid_t fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); return 0; @@ -2514,7 +2514,7 @@ test_fs_sect_extend(hid_t fapl) FAIL_STACK_ERROR fs_addr = HADDR_UNDEF; - PASSED() + PASSED(); /* * TEST 2 @@ -2587,7 +2587,7 @@ test_fs_sect_extend(hid_t fapl) FAIL_STACK_ERROR fs_addr = HADDR_UNDEF; - PASSED() + PASSED(); /* * Test 3 @@ -2661,7 +2661,7 @@ test_fs_sect_extend(hid_t fapl) FAIL_STACK_ERROR fs_addr = HADDR_UNDEF; - PASSED() + PASSED(); /* * TEST 4 @@ -2734,7 +2734,7 @@ test_fs_sect_extend(hid_t fapl) FAIL_STACK_ERROR fs_addr = HADDR_UNDEF; - PASSED() + PASSED(); /* Close the file */ if(H5Fclose(file) < 0) @@ -2842,7 +2842,7 @@ test_fs_sect_iterate(hid_t fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); return 0; @@ -2861,14 +2861,8 @@ main(void) { hid_t fapl = -1; /* File access property list for data files */ unsigned nerrors = 0; /* Cumulative error count */ - const char *env_h5_drvr = NULL; /* File Driver value from environment */ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ - /* Get the VFD to use */ - env_h5_drvr = HDgetenv("HDF5_DRIVER"); - if(env_h5_drvr == NULL) - env_h5_drvr = "nomatch"; - h5_reset(); if((fapl = h5_fileaccess()) < 0) { diff --git a/test/getname.c b/test/getname.c index 873ceb9..7933608 100644 --- a/test/getname.c +++ b/test/getname.c @@ -101,7 +101,7 @@ test_main(hid_t file_id, hid_t fapl) hid_t space_id; hid_t type_id, type2_id; hsize_t dims[1] = { 5 }; - size_t name_len; /* Name length */ + size_t name_len; /* Name length */ H5O_info_t oinfo; /* Object info structs */ hid_t dtype; /* Object identifier for testing */ hid_t dtype_anon; /* Object identifier for testing anonymous */ @@ -2375,12 +2375,12 @@ test_main(hid_t file_id, hid_t fapl) } H5E_END_TRY; if(H5Tcommit_anon(file2_id, dtype, H5P_DEFAULT, H5P_DEFAULT)) TEST_ERROR - + /* Test H5Iget_name with anonymously created datatype, should pass because committed */ 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 @@ -2400,22 +2400,22 @@ test_main(hid_t file_id, hid_t fapl) if(H5Fclose(file2_id) < 0) TEST_ERROR /* Re-open the file and check that the anonymous datatypes persist */ - if( (file2_id = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((file2_id = H5Fopen(filename2, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR /* 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 @@ -2585,10 +2585,10 @@ test_obj_ref(hid_t fapl) /* Make sure size parameter is ignored */ namelen = H5Rget_name(dataset, H5R_OBJECT, &wbuf[0], NULL, 200); if(namelen != 9) TEST_ERROR - + namelen = H5Rget_name(dataset, H5R_OBJECT, &wbuf[0], (char*)buf, sizeof(buf)); if(!((HDstrcmp(buf, "/Dataset3") == 0) &&(namelen == 9))) TEST_ERROR - PASSED() + PASSED(); HDmemset(buf, 0, sizeof(buf)); TESTING("getting path to dataset in /Group1"); @@ -2600,7 +2600,7 @@ test_obj_ref(hid_t fapl) *buf = '\0'; namelen = H5Rget_name(dataset, H5R_OBJECT, &wbuf[1], (char*)buf, sizeof(buf)); if(!((HDstrcmp(buf, "/Group1/Dataset2") == 0) &&(namelen == 16))) TEST_ERROR - PASSED() + PASSED(); HDmemset(buf, 0, sizeof(buf)); TESTING("getting path to /Group1"); @@ -2612,7 +2612,7 @@ test_obj_ref(hid_t fapl) *buf = '\0'; namelen = H5Rget_name(dataset, H5R_OBJECT, &wbuf[2], (char*)buf, sizeof(buf)); if(!((HDstrcmp(buf, "/Group1") == 0) &&(namelen == 7))) TEST_ERROR - PASSED() + PASSED(); HDmemset(buf, 0, sizeof(buf)); TESTING("getting path to datatype in /Group1"); @@ -2624,7 +2624,7 @@ test_obj_ref(hid_t fapl) *buf = '\0'; namelen = H5Rget_name(dataset, H5R_OBJECT, &wbuf[3], (char*)buf, sizeof(buf)); if(!((HDstrcmp(buf, "/Group1/Datatype1") == 0) &&(namelen == 17))) TEST_ERROR - PASSED() + PASSED(); HDmemset(buf, 0, sizeof(buf)); TESTING("getting path to dataset in nested group"); @@ -2636,7 +2636,7 @@ test_obj_ref(hid_t fapl) *buf = '\0'; namelen = H5Rget_name(dataset, H5R_OBJECT, &wbuf[4], (char*)buf, sizeof(buf)); if(!((HDstrcmp(buf, "/Group1/Group2/Dataset4") == 0) &&(namelen == 23))) TEST_ERROR - PASSED() + PASSED(); HDmemset(buf, 0, sizeof(buf)); TESTING("getting path to nested group"); @@ -2648,7 +2648,7 @@ test_obj_ref(hid_t fapl) *buf = '\0'; namelen = H5Rget_name(dataset, H5R_OBJECT, &wbuf[5], (char*)buf, sizeof(buf)); if(!((HDstrcmp(buf, "/Group1/Group2") == 0) &&(namelen == 14))) TEST_ERROR - PASSED() + PASSED(); HDmemset(buf, 0, sizeof(buf)); TESTING("getting path to dataset created via hard link"); @@ -2660,7 +2660,7 @@ test_obj_ref(hid_t fapl) *buf = '\0'; namelen = H5Rget_name(dataset, H5R_OBJECT, &wbuf[6], (char*)buf, sizeof(buf)); if(!((HDstrcmp(buf, "/Group1/Dataset5") == 0) &&(namelen == 16))) TEST_ERROR - PASSED() + PASSED(); HDmemset(buf, 0, sizeof(buf)); TESTING("getting path to root group"); @@ -2672,7 +2672,7 @@ test_obj_ref(hid_t fapl) *buf = '\0'; namelen = H5Rget_name(dataset, H5R_OBJECT, &wbuf[7], (char*)buf, sizeof(buf)); if(!((HDstrcmp(buf, "/") == 0) &&(namelen == 1))) TEST_ERROR - PASSED() + PASSED(); /* Now we mount fid2 at /Group2 and look for dataset4. It shouldn't be found */ if(H5Fmount(fid1, "/Group1/Group2", fid2, H5P_DEFAULT) < 0) @@ -2687,7 +2687,7 @@ test_obj_ref(hid_t fapl) *buf = '\0'; namelen = H5Rget_name(dataset, H5R_OBJECT, &wbuf[4], (char*)buf, sizeof(buf)); if(namelen != 0) TEST_ERROR - PASSED() + PASSED(); /* Now we try unlinking dataset2 from the file and searching for it. It shouldn't be found */ if((dataset2 = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, &wbuf[1])) < 0) @@ -2703,7 +2703,7 @@ test_obj_ref(hid_t fapl) *buf = '\0'; namelen = H5Rget_name(dataset, H5R_OBJECT, &wbuf[1], (char*)buf, sizeof(buf)); if(namelen != 0) TEST_ERROR - PASSED() + PASSED(); /* Close disk dataspace */ if(H5Sclose(sid1) < 0) @@ -2830,7 +2830,7 @@ test_reg_ref(hid_t fapl) name_size1 = H5Rget_name(dsetr_id, H5R_DATASET_REGION, &ref_out[0], (char*)buf1, NAME_BUF_SIZE ); if(!((HDstrcmp(buf1, "/MATRIX") == 0) &&(name_size1 == 7))) TEST_ERROR - PASSED() + PASSED(); TESTING("H5Iget_name to get name from region reference(hyperslab)"); @@ -2844,14 +2844,14 @@ test_reg_ref(hid_t fapl) if(H5Dclose(dsetv_id) < 0) TEST_ERROR - PASSED() + PASSED(); /* Get name of the dataset the second region reference points to using H5Rget_name */ TESTING("H5Rget_name to get name from region reference(pnt selec)"); *buf1 = '\0'; name_size1 = H5Rget_name(dsetr_id, H5R_DATASET_REGION, &ref_out[1], (char*)buf1, NAME_BUF_SIZE); if(!((HDstrcmp(buf1, "/MATRIX") == 0) &&(name_size1 == 7))) TEST_ERROR - PASSED() + PASSED(); TESTING("H5Iget_name to get name from region reference(pnt selec)"); @@ -2865,7 +2865,7 @@ test_reg_ref(hid_t fapl) if(H5Dclose(dsetv_id) < 0) TEST_ERROR - PASSED() + PASSED(); if(H5Dclose(dsetr_id) < 0) TEST_ERROR diff --git a/test/h5test.h b/test/h5test.h index 23991ad..9d57bde 100644 --- a/test/h5test.h +++ b/test/h5test.h @@ -103,7 +103,7 @@ H5TEST_DLLVAR MPI_Info h5_io_info_g; /* MPI INFO object for IO */ */ #define TESTING(WHAT) {HDprintf("Testing %-62s",WHAT); HDfflush(stdout);} #define TESTING_2(WHAT) {HDprintf(" Testing %-60s",WHAT); HDfflush(stdout);} -#define PASSED() {HDputs(" PASSED");HDfflush(stdout);} +#define PASSED() do {HDputs(" PASSED");HDfflush(stdout);} while (0) #define H5_FAILED() {HDputs("*FAILED*");HDfflush(stdout);} #define H5_WARNING() {HDputs("*WARNING*");HDfflush(stdout);} #define SKIPPED() {HDputs(" -SKIP-");HDfflush(stdout);} diff --git a/test/hyperslab.c b/test/hyperslab.c index d22a689..e702023 100644 --- a/test/hyperslab.c +++ b/test/hyperslab.c @@ -265,7 +265,7 @@ test_fill(size_t nx, size_t ny, size_t nz, } /* end for */ } /* end for */ - PASSED() + PASSED(); HDfree(dst); @@ -545,7 +545,7 @@ test_copy(int mode, } /* end for */ } /* end for */ - PASSED() + PASSED(); HDfree(src); HDfree(dst); @@ -666,7 +666,7 @@ test_multifill(size_t nx) } /* end if */ } /* end for */ - PASSED() + PASSED(); HDfree(src); HDfree(dst); @@ -753,7 +753,7 @@ test_endian(size_t nx) } /* end for */ } /* end for */ - PASSED() + PASSED(); HDfree(src); HDfree(dst); @@ -819,12 +819,8 @@ test_transpose(size_t nx, size_t ny) dst_stride[1] = (hsize_t)(nx * sizeof(*src)); /* Copy and transpose */ - if(nx == ny) - H5VM_stride_copy(2, (hsize_t)sizeof(*src), size, dst_stride, dst, - src_stride, src); - else - H5VM_stride_copy(2, (hsize_t)sizeof(*src), size, dst_stride, dst, - src_stride, src); + H5VM_stride_copy(2, (hsize_t)sizeof(*src), size, dst_stride, dst, + src_stride, src); /* Check */ for(i = 0; i < nx; i++) { @@ -854,7 +850,7 @@ test_transpose(size_t nx, size_t ny) } /* end for */ } /* end for */ - PASSED() + PASSED(); HDfree(src); HDfree(dst); @@ -947,7 +943,7 @@ test_sub_super(size_t nx, size_t ny) } /* end if */ } /* end for */ } /* end for */ - PASSED() + PASSED(); /* * Test replicating pixels to produce an image twice as large in each @@ -1011,7 +1007,7 @@ test_sub_super(size_t nx, size_t ny) } /* end for */ } /* end for */ - PASSED() + PASSED(); HDfree(full); HDfree(half); @@ -317,7 +317,7 @@ test_mf_eoa(const char *env_h5_drvr, hid_t fapl) if(H5Pclose(fapl_new) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -459,7 +459,7 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl) if(new_file_size != file_size) TEST_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -507,7 +507,7 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl) if(new_file_size != (file_size + TBLOCK_SIZE30)) TEST_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -551,7 +551,7 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl) if(new_file_size != (file_size + TBLOCK_SIZE30)) TEST_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -599,7 +599,7 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl) if(H5Pclose(fapl_new) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -737,7 +737,7 @@ test_mf_eoa_extend(const char *env_h5_drvr, hid_t fapl) if(new_file_size != (file_size + TBLOCK_SIZE30 + TBLOCK_SIZE50)) TEST_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -800,7 +800,7 @@ test_mf_eoa_extend(const char *env_h5_drvr, hid_t fapl) if(H5Pclose(fapl_new) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -998,7 +998,7 @@ test_mf_tmp(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) if(new_file_size != file_size) TEST_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -1092,7 +1092,7 @@ test_mf_fs_start(hid_t fapl) if(H5Pclose(fapl_new) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); return(0); @@ -1241,7 +1241,7 @@ test_mf_fs_alloc_free(hid_t fapl) if (new_file_size != file_size) TEST_ERROR - PASSED() + PASSED(); TESTING("H5MF_alloc()/H5MF_xfree() of free-space manager:test 2"); @@ -1316,7 +1316,7 @@ test_mf_fs_alloc_free(hid_t fapl) if (new_file_size != file_size) TEST_ERROR - PASSED() + PASSED(); TESTING("H5MF_alloc()/H5MF_xfree() of free-space manager:test 3"); @@ -1404,7 +1404,7 @@ test_mf_fs_alloc_free(hid_t fapl) if(H5Pclose(fapl_new) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); return(0); @@ -1597,7 +1597,7 @@ test_mf_fs_extend(hid_t fapl) if (new_file_size != file_size) TEST_ERROR - PASSED() + PASSED(); TESTING("H5MF_try_extend() of free-space manager:test 2"); @@ -1699,7 +1699,7 @@ test_mf_fs_extend(hid_t fapl) if (new_file_size != file_size) TEST_ERROR - PASSED() + PASSED(); TESTING("H5MF_try_extend() of free-space manager:test 3"); @@ -1801,7 +1801,7 @@ test_mf_fs_extend(hid_t fapl) if (new_file_size != file_size) TEST_ERROR - PASSED() + PASSED(); TESTING("H5MF_try_extend() of free-space manager:test 4"); @@ -1910,7 +1910,7 @@ test_mf_fs_extend(hid_t fapl) if(H5Pclose(fapl_new) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); return(0); @@ -2022,7 +2022,7 @@ test_mf_fs_absorb(const char *env_h5_drvr, hid_t fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -2083,7 +2083,7 @@ test_mf_fs_absorb(const char *env_h5_drvr, hid_t fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -2225,7 +2225,7 @@ test_mf_aggr_alloc1(const char *env_h5_drvr, hid_t fapl) if(H5Pclose(fcpl) < 0) TEST_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -2367,7 +2367,7 @@ test_mf_aggr_alloc2(const char *env_h5_drvr, hid_t fapl) if (new_file_size != file_size) TEST_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -2527,7 +2527,7 @@ test_mf_aggr_alloc3(const char *env_h5_drvr, hid_t fapl) if(new_file_size != file_size) TEST_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -2694,7 +2694,7 @@ test_mf_aggr_alloc4(const char *env_h5_drvr, hid_t fapl) if(new_file_size != file_size) TEST_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -2817,7 +2817,7 @@ test_mf_aggr_alloc5(const char *env_h5_drvr, hid_t fapl) if(new_file_size != file_size) TEST_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -2973,7 +2973,7 @@ test_mf_aggr_alloc6(const char *env_h5_drvr, hid_t fapl) if(new_file_size != file_size) TEST_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -3157,7 +3157,7 @@ test_mf_aggr_alloc7(const char *env_h5_drvr, hid_t fapl) if (file_size != empty_size) TEST_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -3311,7 +3311,7 @@ test_mf_aggr_extend(const char *env_h5_drvr, hid_t fapl) if (file_size != empty_size) TEST_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -3381,7 +3381,7 @@ test_mf_aggr_extend(const char *env_h5_drvr, hid_t fapl) if(file_size != empty_size) TEST_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -3449,7 +3449,7 @@ test_mf_aggr_extend(const char *env_h5_drvr, hid_t fapl) if(file_size != empty_size) TEST_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -3558,7 +3558,7 @@ test_mf_aggr_absorb(const char *env_h5_drvr, hid_t fapl) if(file_size != empty_size) TEST_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -3617,7 +3617,7 @@ test_mf_aggr_absorb(const char *env_h5_drvr, hid_t fapl) if(file_size != empty_size) TEST_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -3679,7 +3679,7 @@ test_mf_aggr_absorb(const char *env_h5_drvr, hid_t fapl) if(file_size != empty_size) TEST_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -3846,7 +3846,7 @@ test_mf_align_eoa(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) if (new_file_size != file_size) TEST_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -3901,7 +3901,7 @@ test_mf_align_eoa(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) if (new_file_size != (file_size-TBLOCK_SIZE50)) TEST_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -3957,7 +3957,7 @@ test_mf_align_eoa(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) if (new_file_size != (file_size+TBLOCK_SIZE30)) TEST_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -4094,7 +4094,7 @@ test_mf_align_fs(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); TESTING("H5MF_alloc() of free-space manager with alignment: test 2"); @@ -4169,7 +4169,7 @@ test_mf_align_fs(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); TESTING("H5MF_alloc() of free-space manager with alignment: test 3"); @@ -4244,7 +4244,7 @@ test_mf_align_fs(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -4514,7 +4514,7 @@ test_mf_align_alloc1(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -4800,7 +4800,7 @@ test_mf_align_alloc2(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -5176,7 +5176,7 @@ test_mf_align_alloc3(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -5385,7 +5385,7 @@ test_mf_align_alloc4(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -5608,7 +5608,7 @@ test_mf_align_alloc5(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -5914,7 +5914,7 @@ test_mf_align_alloc6(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); } /* end if */ else { SKIPPED(); @@ -6077,7 +6077,7 @@ test_mf_bug1(const char *env_h5_drvr, hid_t fapl) * the previous */ if((addr2 - addr1) != (3 * align)) TEST_ERROR - PASSED() + PASSED(); /* Close file */ if(H5Fclose(file) < 0) @@ -6357,7 +6357,7 @@ test_mf_fs_persist_split(void) if(H5Pclose(fcpl) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); return(0); @@ -6710,7 +6710,7 @@ test_mf_fs_persist_multi(void) if(H5Pclose(fcpl) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); return(0); @@ -6887,7 +6887,7 @@ test_mf_fs_persist(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) if(H5Pclose(fapl2) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); } else { SKIPPED(); @@ -7085,7 +7085,7 @@ test_mf_fs_gone(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) if(H5Pclose(fapl2) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); } else { SKIPPED(); @@ -7258,7 +7258,7 @@ test_mf_strat_thres_persist(const char *env_h5_drvr, hid_t fapl, hbool_t new_for if(H5Pclose(fapl2) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); return(0); @@ -7362,10 +7362,9 @@ test_mf_strat_thres_gone(const char *env_h5_drvr, hid_t fapl, hbool_t new_format H5MF__alloc_to_fs_type(f, type, TBLOCK_SIZE6, (H5F_mem_page_t *)&tt); /* For paged aggregation, the section in the page at EOF for small meta fs is not shrunk away */ - if(fs_type == H5F_FSPACE_STRATEGY_PAGE) { + if(fs_type == H5F_FSPACE_STRATEGY_PAGE) if(H5FS_stat_info(f, f->shared->fs_man[tt], &fs_state) < 0) FAIL_STACK_ERROR - } /* Put block #3, #5 to H5FD_MEM_SUPER free-space manager */ if(H5MF_xfree(f, type, addr3, (hsize_t)TBLOCK_SIZE3) < 0) @@ -7444,7 +7443,7 @@ test_mf_strat_thres_gone(const char *env_h5_drvr, hid_t fapl, hbool_t new_format if(H5Pclose(fapl2) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); return(0); @@ -7533,7 +7532,7 @@ test_dichotomy(hid_t fapl) if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); return(0); @@ -7552,7 +7551,7 @@ error: *------------------------------------------------------------------------- */ static int -set_multi_split(hid_t fapl, hsize_t pagesize, hbool_t multi, hbool_t split) +set_multi_split(hid_t fapl, hsize_t pagesize, hbool_t is_multi_or_split) { H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; hid_t memb_fapl_arr[H5FD_MEM_NTYPES]; @@ -7561,7 +7560,7 @@ set_multi_split(hid_t fapl, hsize_t pagesize, hbool_t multi, hbool_t split) hbool_t relax; H5FD_mem_t mt; - HDassert(multi || split); + HDassert(is_multi_or_split); HDmemset(memb_name, 0, sizeof memb_name); @@ -7569,7 +7568,7 @@ set_multi_split(hid_t fapl, hsize_t pagesize, hbool_t multi, hbool_t split) if(H5Pget_fapl_multi(fapl, memb_map, memb_fapl_arr, memb_name, memb_addr, &relax) < 0) TEST_ERROR - if(split) { + if(is_multi_or_split) { /* Set memb_addr aligned */ memb_addr[H5FD_MEM_SUPER] = ((memb_addr[H5FD_MEM_SUPER] + pagesize - 1) / pagesize) * pagesize; memb_addr[H5FD_MEM_DRAW] = ((memb_addr[H5FD_MEM_DRAW] + pagesize - 1) / pagesize) * pagesize; @@ -7638,7 +7637,7 @@ test_page_alloc_xfree(const char *env_h5_drvr, hid_t fapl) if((fapl_new = H5Pcopy(fapl)) < 0) TEST_ERROR if(multi || split) - if(set_multi_split(fapl_new, 4096, multi, split) < 0) + if(set_multi_split(fapl_new, 4096, split) < 0) TEST_ERROR; /* Test with TRUE or FALSE for persisting free-space */ @@ -7703,7 +7702,6 @@ test_page_alloc_xfree(const char *env_h5_drvr, hid_t fapl) H5MF_xfree(f, H5FD_MEM_DRAW, gaddr1, (hsize_t)TBLOCK_SIZE5000); if(!fs_persist) { - H5MF__alloc_to_fs_type(f, H5FD_MEM_DRAW, TBLOCK_SIZE5000, (H5F_mem_page_t *)&fs_type); /* Verify that the freed block with gaddr1 is found from the large data manager */ @@ -7799,7 +7797,7 @@ test_page_alloc_xfree(const char *env_h5_drvr, hid_t fapl) if(H5Pclose(fapl_new) < 0) TEST_ERROR - PASSED() + PASSED(); } else { SKIPPED(); @@ -7923,7 +7921,7 @@ test_page_try_shrink(const char *env_h5_drvr, hid_t fapl) if(H5Pclose(fcpl) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); } else { SKIPPED(); @@ -8078,7 +8076,7 @@ test_page_small_try_extend(const char *env_h5_drvr, hid_t fapl) if(H5Pclose(fcpl) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); } else { SKIPPED(); @@ -8219,7 +8217,7 @@ test_page_large_try_extend(const char *env_h5_drvr, hid_t fapl) if(H5Pclose(fcpl) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); } else { SKIPPED(); @@ -8372,7 +8370,7 @@ test_page_large(const char *env_h5_drvr, hid_t fapl) if(file_size % TBLOCK_SIZE4096) TEST_ERROR - PASSED() + PASSED(); } else { SKIPPED(); @@ -8535,7 +8533,7 @@ test_page_small(const char *env_h5_drvr, hid_t fapl) if(H5Pclose(fcpl) < 0) FAIL_STACK_ERROR - PASSED() + PASSED(); } else { SKIPPED(); @@ -8841,7 +8839,7 @@ test_page_alignment(const char *env_h5_drvr, hid_t fapl) if(H5Pclose(fapl_new) < 0) TEST_ERROR - PASSED() + PASSED(); } else { SKIPPED(); diff --git a/test/ohdr.c b/test/ohdr.c index f97254e..1dd038c 100644 --- a/test/ohdr.c +++ b/test/ohdr.c @@ -15,7 +15,9 @@ * Tuesday, November 24, 1998 */ #include "h5test.h" -#include "H5Iprivate.h" + +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Iprivate.h" /* Identifiers */ /* * This file needs to access private datatypes from the H5O package. @@ -31,8 +33,6 @@ #define H5G_FRIEND /* suppress error about including H5Gpkg */ #include "H5Gpkg.h" -#include "H5CXprivate.h" /* API Contexts */ - const char *FILENAME[] = { "ohdr", "ohdr_min_a", @@ -49,7 +49,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" @@ -57,885 +58,6 @@ const char *FILENAME[] = { #define OBJ_VERSION_LATEST 2 /* - * Set an attribute with the given information. - * If the out parameter `attr_id` is negative, a new attribute will be - * created with the given information. Else, it will attempt to update the - * attribute with the new value. - * - * `dataspace_id` ignored if `attribute_id` >= 0 - */ -static herr_t -put_attribute(hid_t loc_id, const char *attrname, const void *attrvalue, hid_t datatype_id, hid_t dataspace_id, hid_t *attribute_id) -{ - if((*attribute_id) < 0) { - hid_t id = -1; - id = H5Acreate2(loc_id, attrname, datatype_id, dataspace_id, H5P_DEFAULT, H5P_DEFAULT); - if(id < 0) - return FAIL; - *attribute_id = id; - } - return H5Awrite(*attribute_id, datatype_id, attrvalue); -} /* put_attribute */ - -/* - * Count the number of attributes attached to an object. - * Returns negative in event of error. - */ -static int -count_attributes(hid_t dset_id) -{ - H5O_info_t info; - - if(H5Oget_info2(dset_id, &info, H5O_INFO_ALL) < 0) - return -1; - else - return (int)info.num_attrs; /* should never exceed int bounds */ -} /* count_attributes */ - -/* - * Get the total space used by the object header. - * Used by oh_compare() - * On success, stores size in `size_out` pointer. - */ -static herr_t -_oh_getsize(hid_t did, hsize_t *size_out) -{ - H5O_info_t info; - if(FAIL == H5Oget_info2(did, &info, H5O_INFO_HDR)) - return FAIL; - *size_out = info.hdr.space.total; - return SUCCEED; -} /* _oh_getsize */ - -/* - * Compare the TOTAL space used by datasets' object headers. - * Returns negative value if an error occurred, - * else positive #defined indicator value EQ, LT, GT. - */ -static int -oh_compare(hid_t did1, hid_t did2) -{ - hsize_t space1 = 0; - hsize_t space2 = 0; - - if(FAIL == _oh_getsize(did1, &space1)) - return -1; - if(FAIL == _oh_getsize(did2, &space2)) - return -2; - - if(space1 < space2) - return LT; - else if(space1 > space2) - return GT; - else - return EQ; -} /* oh_compare() */ - -/* - * Demonstrate attribute addition to datasets. - * Conduct additions side-by-side with a standard datataset and one with - * minimized dataset object headers. - */ -static herr_t -test_minimized_dset_ohdr_attribute_addition(hid_t fapl_id) -{ - hsize_t array_10[1] = {10}; /* dataspace extent */ - char buffer[10] = ""; /* to inspect string attribute */ - int a_out = 0; - char filename[512] = ""; - hid_t int_type_id = -1; - hid_t char_type_id = -1; - hid_t dcpl_id = -1; - hid_t dspace_id = -1; - hid_t dspace_scalar_id = -1; - hid_t dset_id = -1; - hid_t mindset_id = -1; - hid_t attr_1_id = -1; - hid_t attr_1a_id = -1; - hid_t attr_2_id = -1; - hid_t attr_2a_id = -1; - hid_t attr_3_id = -1; - hid_t attr_3a_id = -1; - hid_t file_id = -1; - herr_t ret; - int count = 0; - - TESTING("minimized dset object headers attribute additions") - - /********* - * SETUP * - *********/ - - if(h5_fixname(FILENAME[1], fapl_id, filename, sizeof(filename)) == NULL) - TEST_ERROR - - dspace_id = H5Screate_simple(1, array_10, NULL); - if(dspace_id < 0) TEST_ERROR - - dspace_scalar_id = H5Screate(H5S_SCALAR); - if(dspace_scalar_id < 0) TEST_ERROR - - char_type_id = H5Tcopy(H5T_NATIVE_CHAR); - if(char_type_id < 0) TEST_ERROR - - int_type_id = H5Tcopy(H5T_NATIVE_INT); - if(int_type_id < 0) TEST_ERROR - - dcpl_id = H5Pcreate(H5P_DATASET_CREATE); - if(dcpl_id < 0) TEST_ERROR - - ret = H5Pset_dset_no_attrs_hint(dcpl_id, TRUE); - if(ret < 0) TEST_ERROR - - file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); - if(file_id < 0) TEST_ERROR - - H5E_BEGIN_TRY { - count = count_attributes(dset_id); - } H5E_END_TRY; - if(count != -1) TEST_ERROR - - dset_id = H5Dcreate2(file_id, "dataset", int_type_id, dspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if(dset_id < 0) TEST_ERROR - - mindset_id = H5Dcreate2(file_id, "mindataset", int_type_id, dspace_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); - if(mindset_id < 0) TEST_ERROR - - /******************** - * TEST/DEMONSTRATE * - ********************/ - - /* ------------------- - * no attributes added - */ - - count = count_attributes(dset_id); - if(count != 0) TEST_ERROR - count = count_attributes(mindset_id); - if(count != 0) TEST_ERROR - - /* ----------------- - * add one attribute - */ - ret = put_attribute(dset_id, "PURPOSE", "DEMO", char_type_id, dspace_id, &attr_1_id); - if(ret < 0) TEST_ERROR - - ret = put_attribute(mindset_id, "PURPOSE", "DEMO", char_type_id, dspace_id, &attr_1a_id); - if(ret < 0) TEST_ERROR - - count = count_attributes(dset_id); - if(count != 1) TEST_ERROR - count = count_attributes(mindset_id); - if(count != 1) TEST_ERROR - - ret = H5Aread(attr_1_id, char_type_id, buffer); - if(ret < 0) TEST_ERROR - if(HDstrcmp("DEMO", buffer)) TEST_ERROR - - ret = H5Aread(attr_1a_id, char_type_id, buffer); - if(ret < 0) TEST_ERROR - if(HDstrcmp("DEMO", buffer)) TEST_ERROR - - /* ----------------- - * modify one attribute - */ - - ret = put_attribute(dset_id, "PURPOSE", "REWRITE", char_type_id, -1, &attr_1_id); - if(ret < 0) TEST_ERROR - - ret = put_attribute(mindset_id, "PURPOSE", "REWRITE", char_type_id, -1, &attr_1a_id); - if(ret < 0) TEST_ERROR - - count = count_attributes(dset_id); - if(count != 1) TEST_ERROR - count = count_attributes(mindset_id); - if(count != 1) TEST_ERROR - - ret = H5Aread(attr_1_id, char_type_id, buffer); - if(ret < 0) TEST_ERROR - if(HDstrcmp("REWRITE", buffer)) TEST_ERROR - - ret = H5Aread(attr_1a_id, char_type_id, buffer); - if(ret < 0) TEST_ERROR - if(HDstrcmp("REWRITE", buffer)) TEST_ERROR - - /* ----------------- - * add second attribute - */ - - a_out = 5; - ret = put_attribute(dset_id, "RANK", &a_out, int_type_id, dspace_scalar_id, &attr_2_id); - if(ret < 0) TEST_ERROR - - a_out = 3; - ret = put_attribute(mindset_id, "RANK", &a_out, int_type_id, dspace_scalar_id, &attr_2a_id); - if(ret < 0) TEST_ERROR - - count = count_attributes(dset_id); - if(count != 2) TEST_ERROR - count = count_attributes(mindset_id); - if(count != 2) TEST_ERROR - - ret = H5Aread(attr_2_id, int_type_id, &a_out); - if(ret < 0) TEST_ERROR - if(a_out != 5) TEST_ERROR - - ret = H5Aread(attr_2a_id, int_type_id, &a_out); - if(ret < 0) TEST_ERROR - if(a_out != 3) TEST_ERROR - - /* ----------------- - * add third attribute - */ - - a_out = -86; - ret = put_attribute(dset_id, "FLAVOR", &a_out, int_type_id, dspace_scalar_id, &attr_3_id); - if(ret < 0) TEST_ERROR - - a_out = 2185; - ret = put_attribute(mindset_id, "FLAVOR", &a_out, int_type_id, dspace_scalar_id, &attr_3a_id); - if(ret < 0) TEST_ERROR - - count = count_attributes(dset_id); - if(count != 3) TEST_ERROR - count = count_attributes(mindset_id); - if(count != 3) TEST_ERROR - - ret = H5Aread(attr_3_id, int_type_id, &a_out); - if(ret < 0) TEST_ERROR - if(a_out != -86) TEST_ERROR - - ret = H5Aread(attr_3a_id, int_type_id, &a_out); - if(ret < 0) TEST_ERROR - if(a_out != 2185) TEST_ERROR - - /************ - * TEARDOWN * - ************/ - - if(H5Tclose(int_type_id) < 0) TEST_ERROR - if(H5Tclose(char_type_id) < 0) TEST_ERROR - if(H5Pclose(dcpl_id) < 0) TEST_ERROR - if(H5Sclose(dspace_id) < 0) TEST_ERROR - if(H5Dclose(dset_id) < 0) TEST_ERROR - if(H5Dclose(mindset_id) < 0) TEST_ERROR - if(H5Aclose(attr_1_id) < 0) TEST_ERROR - if(H5Aclose(attr_1a_id) < 0) TEST_ERROR - if(H5Aclose(attr_2_id) < 0) TEST_ERROR - if(H5Aclose(attr_2a_id) < 0) TEST_ERROR - if(H5Aclose(attr_3_id) < 0) TEST_ERROR - if(H5Aclose(attr_3a_id) < 0) TEST_ERROR - if(H5Fclose(file_id) < 0) TEST_ERROR - - PASSED() - return SUCCEED; - -error : - H5E_BEGIN_TRY { - (void)H5Tclose(int_type_id); - (void)H5Tclose(char_type_id); - (void)H5Pclose(dcpl_id); - (void)H5Sclose(dspace_id); - (void)H5Dclose(dset_id); - (void)H5Dclose(mindset_id); - (void)H5Aclose(attr_1_id); - (void)H5Aclose(attr_1a_id); - (void)H5Aclose(attr_2_id); - (void)H5Aclose(attr_2a_id); - (void)H5Aclose(attr_3_id); - (void)H5Aclose(attr_3a_id); - (void)H5Fclose(file_id); - } H5E_END_TRY; - return FAIL; -} /* test_minimized_dset_ohdr_attribute_addition */ - -/* - * Compare header sizes against when headers have been minimized. - * Repeats tests with headers "compact" and normal. - */ -static herr_t -test_minimized_dset_ohdr_size_comparisons(hid_t fapl_id) -{ - hsize_t array_10[1] = {10}; /* dataspace extents */ - unsigned compact = 0; - - /* IDs that are file-agnostic */ - hid_t dspace_id = -1; - hid_t int_type_id = -1; - hid_t dcpl_minimize = -1; - hid_t dcpl_dontmin = -1; - hid_t dcpl_default = -1; - - /* IDs for non-minimized file open */ - hid_t file_f_id = -1; /* lower 'f' for standard file setting */ - hid_t dset_f_x_id = -1; /* 'x' for default */ - hid_t dset_f_N_id = -1; /* 'N' for explcit non-minimized dset */ - hid_t dset_f_Y_id = -1; /* 'Y' for minimized dset */ - - /* IDs for minimized file open */ - hid_t file_F_id = -1; /* upper 'F' for minimized file setting */ - hid_t dset_F_x_id = -1; /* 'x' for default */ - hid_t dset_F_N_id = -1; /* 'N' for explcit non-minimized dset */ - hid_t dset_F_Y_id = -1; /* 'Y' for minimized dset */ - - char filename_a[512] = ""; - char filename_b[512] = ""; - - herr_t ret; - - /* dataset suffixes: - * | default | minimize | don't minimize (dcpl-set) - * ---------------+---------+----------+--------------- - * file-default | f_x | f_Y | f_N - * ---------------+---------+----------+--------------- - * file-minimized | F_x | F_Y | F_N - */ - - TESTING("minimized dset object headers size comparisons"); - - /********* - * SETUP * - *********/ - - if(h5_fixname(FILENAME[1], fapl_id, filename_a, sizeof(filename_a)) == NULL) - TEST_ERROR - - if(h5_fixname(FILENAME[2], fapl_id, filename_b, sizeof(filename_b)) == NULL) - TEST_ERROR - - for (compact = 0; compact < 2; compact++) { /* 0 or 1 */ - dcpl_default = H5Pcreate(H5P_DATASET_CREATE); - if(dcpl_default < 0) TEST_ERROR - - dcpl_minimize = H5Pcreate(H5P_DATASET_CREATE); - if(dcpl_minimize < 0) TEST_ERROR - ret = H5Pset_dset_no_attrs_hint(dcpl_minimize, TRUE); - if(ret < 0) TEST_ERROR - - dcpl_dontmin = H5Pcreate(H5P_DATASET_CREATE); - if(dcpl_dontmin < 0) TEST_ERROR - ret = H5Pset_dset_no_attrs_hint(dcpl_dontmin, FALSE); - if(ret < 0) TEST_ERROR - - if(compact) { - HDprintf("...compact "); - ret = H5Pset_layout(dcpl_default, H5D_COMPACT); - if(ret < 0) TEST_ERROR - ret = H5Pset_layout(dcpl_minimize, H5D_COMPACT); - if(ret < 0) TEST_ERROR - ret = H5Pset_layout(dcpl_dontmin, H5D_COMPACT); - if(ret < 0) TEST_ERROR - } else - HDprintf("...not compact "); - - dspace_id = H5Screate_simple(1, array_10, NULL); - if(dspace_id < 0) TEST_ERROR - - int_type_id = H5Tcopy(H5T_NATIVE_INT); - if(int_type_id < 0) TEST_ERROR - - file_f_id = H5Fcreate(filename_a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); - if(file_f_id < 0) TEST_ERROR - - dset_f_x_id = H5Dcreate2(file_f_id, "default", int_type_id, dspace_id, H5P_DEFAULT, dcpl_default, H5P_DEFAULT); - if(dset_f_x_id < 0) TEST_ERROR - - dset_f_N_id = H5Dcreate2(file_f_id, "dsetNOT", int_type_id, dspace_id, H5P_DEFAULT, dcpl_dontmin, H5P_DEFAULT); - if(dset_f_N_id < 0) TEST_ERROR - - dset_f_Y_id = H5Dcreate2(file_f_id, "dsetMIN", int_type_id, dspace_id, H5P_DEFAULT, dcpl_minimize, H5P_DEFAULT); - if(dset_f_x_id < 0) TEST_ERROR - - file_F_id = H5Fcreate(filename_b, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); - if(file_F_id < 0) TEST_ERROR - ret = H5Fset_dset_no_attrs_hint(file_F_id, TRUE); - if(ret < 0) TEST_ERROR - - dset_F_x_id = H5Dcreate2(file_F_id, "default", int_type_id, dspace_id, H5P_DEFAULT, dcpl_default, H5P_DEFAULT); - if(dset_F_x_id < 0) TEST_ERROR - - dset_F_N_id = H5Dcreate2(file_F_id, "dsetNOT", int_type_id, dspace_id, H5P_DEFAULT, dcpl_dontmin, H5P_DEFAULT); - if(dset_F_N_id < 0) TEST_ERROR - - dset_F_Y_id = H5Dcreate2(file_F_id, "dsetMIN", int_type_id, dspace_id, H5P_DEFAULT, dcpl_minimize, H5P_DEFAULT); - if(dset_F_Y_id < 0) TEST_ERROR - - /********* - * TESTS * - *********/ - - if(oh_compare(dset_f_x_id, dset_f_x_id) != EQ) TEST_ERROR /* identity */ - - if(oh_compare(dset_f_x_id, dset_f_N_id) != EQ) TEST_ERROR - if(oh_compare(dset_f_x_id, dset_f_Y_id) != GT) TEST_ERROR - if(oh_compare(dset_f_N_id, dset_f_Y_id) != GT) TEST_ERROR - - if(oh_compare(dset_F_x_id, dset_F_N_id) != EQ) TEST_ERROR - if(oh_compare(dset_F_x_id, dset_F_Y_id) != EQ) TEST_ERROR - if(oh_compare(dset_F_N_id, dset_F_Y_id) != EQ) TEST_ERROR - - if(oh_compare(dset_F_x_id, dset_f_Y_id) != EQ) TEST_ERROR - if(oh_compare(dset_F_x_id, dset_f_x_id) != LT) TEST_ERROR - - /************ - * TEARDOWN * - ************/ - - if(H5Sclose(dspace_id) < 0) TEST_ERROR - if(H5Tclose(int_type_id) < 0) TEST_ERROR - if(H5Pclose(dcpl_default) < 0) TEST_ERROR - if(H5Pclose(dcpl_minimize) < 0) TEST_ERROR - if(H5Pclose(dcpl_dontmin) < 0) TEST_ERROR - - if(H5Fclose(file_f_id) < 0) TEST_ERROR - if(H5Dclose(dset_f_x_id) < 0) TEST_ERROR - if(H5Dclose(dset_f_N_id) < 0) TEST_ERROR - if(H5Dclose(dset_f_Y_id) < 0) TEST_ERROR - - if(H5Fclose(file_F_id) < 0) TEST_ERROR - if(H5Dclose(dset_F_x_id) < 0) TEST_ERROR - if(H5Dclose(dset_F_N_id) < 0) TEST_ERROR - if(H5Dclose(dset_F_Y_id) < 0) TEST_ERROR - - } /* compact and non-compact */ - - PASSED() - return SUCCEED; - -error : - H5E_BEGIN_TRY { - (void)H5Pclose(dcpl_default); - (void)H5Pclose(dcpl_minimize); - (void)H5Pclose(dcpl_dontmin); - (void)H5Sclose(dspace_id); - (void)H5Tclose(int_type_id); - - (void)H5Fclose(file_f_id); - (void)H5Dclose(dset_f_x_id); - (void)H5Dclose(dset_f_N_id); - (void)H5Dclose(dset_f_Y_id); - - (void)H5Fclose(file_F_id); - (void)H5Dclose(dset_F_x_id); - (void)H5Dclose(dset_F_N_id); - (void)H5Dclose(dset_F_Y_id); - } H5E_END_TRY; - return FAIL; -} /* test_minimized_dset_ohdr_size_comparisons */ - -/* - * Test minimized dataset object header with filter/pipeline message - */ -static herr_t -test_minimized_dset_ohdr_with_filter(hid_t fapl_id) -{ - char filename[512] = ""; - const hsize_t extents[1] = {1024}; /* extents of dataspace */ - const unsigned filter_values[] = {0}; /* TBD */ - const hsize_t chunk_dim[] = {32}; /* needed for filter */ - const int ndims = 1; - hid_t dspace_id = -1; - hid_t dtype_id = -1; - hid_t dcpl_xZ_id = -1; - hid_t dcpl_mx_id = -1; - hid_t dcpl_mZ_id = -1; - hid_t dset_xx_id = -1; - hid_t dset_xZ_id = -1; - hid_t dset_mx_id = -1; - hid_t dset_mZ_id = -1; - hid_t file_id = -1; - herr_t ret; - - /* dcpl suffixes: - * | default | minimize - * ----------+---------+--------- - * no filter | xx | mx - * ----------+---------+--------- - * filter | xZ | mZ - */ - - TESTING("minimized dset object headers with filter message"); - - /********* - * SETUP * - *********/ - - if(h5_fixname(FILENAME[1], fapl_id, filename, sizeof(filename)) == NULL) - TEST_ERROR - - dcpl_mx_id = H5Pcreate(H5P_DATASET_CREATE); - if(dcpl_mx_id < 0) TEST_ERROR - ret = H5Pset_dset_no_attrs_hint(dcpl_mx_id, TRUE); - if(ret < 0) TEST_ERROR - - dcpl_xZ_id = H5Pcreate(H5P_DATASET_CREATE); - if(dcpl_xZ_id < 0) TEST_ERROR - ret = H5Pset_chunk(dcpl_xZ_id, ndims, chunk_dim); - if(ret < 0) TEST_ERROR - ret = H5Pset_filter(dcpl_xZ_id, H5Z_FILTER_DEFLATE, H5Z_FLAG_OPTIONAL, 0, filter_values); - if(ret < 0) TEST_ERROR - dcpl_mZ_id = H5Pcreate(H5P_DATASET_CREATE); - if(dcpl_mZ_id < 0) TEST_ERROR - ret = H5Pset_dset_no_attrs_hint(dcpl_mZ_id, TRUE); - if(ret < 0) TEST_ERROR - ret = H5Pset_chunk(dcpl_mZ_id, ndims, chunk_dim); - if(ret < 0) TEST_ERROR - ret = H5Pset_filter( dcpl_mZ_id, H5Z_FILTER_DEFLATE, H5Z_FLAG_OPTIONAL, 0, filter_values); - if(ret < 0) TEST_ERROR - - dspace_id = H5Screate_simple(1, extents, extents); - if(dspace_id < 0) TEST_ERROR - - dtype_id = H5Tcopy(H5T_NATIVE_INT); - if(dtype_id < 0) TEST_ERROR - - file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); - if(file_id < 0) TEST_ERROR - - dset_xx_id = H5Dcreate2(file_id, "xx", dtype_id, dspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if(dset_xx_id < 0) TEST_ERROR - - dset_mx_id = H5Dcreate2(file_id, "Mx", dtype_id, dspace_id, H5P_DEFAULT, dcpl_mx_id, H5P_DEFAULT); - if(dset_mx_id < 0) TEST_ERROR - - dset_xZ_id = H5Dcreate2(file_id, "xZ", dtype_id, dspace_id, H5P_DEFAULT, dcpl_xZ_id, H5P_DEFAULT); - if(dset_xZ_id < 0) TEST_ERROR - - dset_mZ_id = H5Dcreate2(file_id, "MZ", dtype_id, dspace_id, H5P_DEFAULT, dcpl_mZ_id, H5P_DEFAULT); - if(dset_mZ_id < 0) TEST_ERROR - - /********* - * TESTS * - *********/ - - if(oh_compare(dset_mx_id, dset_xx_id) != LT) TEST_ERROR - if(oh_compare(dset_mx_id, dset_xZ_id) != LT) TEST_ERROR - if(oh_compare(dset_mZ_id, dset_mx_id) != GT) TEST_ERROR - if(oh_compare(dset_mZ_id, dset_xZ_id) != LT) TEST_ERROR - - /************ - * TEARDOWN * - ************/ - - if(H5Sclose(dspace_id) < 0) TEST_ERROR - if(H5Tclose(dtype_id) < 0) TEST_ERROR - if(H5Pclose(dcpl_xZ_id) < 0) TEST_ERROR - if(H5Pclose(dcpl_mx_id) < 0) TEST_ERROR - if(H5Pclose(dcpl_mZ_id) < 0) TEST_ERROR - if(H5Dclose(dset_xx_id) < 0) TEST_ERROR - if(H5Dclose(dset_xZ_id) < 0) TEST_ERROR - if(H5Dclose(dset_mx_id) < 0) TEST_ERROR - if(H5Dclose(dset_mZ_id) < 0) TEST_ERROR - if(H5Fclose(file_id) < 0) TEST_ERROR - - PASSED() - return SUCCEED; - -error: - H5E_BEGIN_TRY { - (void)H5Sclose(dspace_id); - (void)H5Tclose(dtype_id); - (void)H5Pclose(dcpl_xZ_id); - (void)H5Pclose(dcpl_mx_id); - (void)H5Pclose(dcpl_mZ_id); - (void)H5Dclose(dset_xx_id); - (void)H5Dclose(dset_xZ_id); - (void)H5Dclose(dset_mx_id); - (void)H5Dclose(dset_mZ_id); - (void)H5Fclose(file_id); - } H5E_END_TRY; - return FAIL; -} /* test_minimized_dset_ohdr_with_filter */ - -/* - * Test minimized dataset object header and recording modification times. - */ -static herr_t -test_minimized_dset_ohdr_modification_times(hid_t _fapl_id) -{ - /* test-local structure for parameterized testing - */ - struct testcase { - unsigned oh_version; - }; - - char filename[512] = ""; - const hsize_t extents[1] = {128}; /* extents of dataspace */ - hid_t dspace_id = -1; - hid_t dtype_id = -1; - hid_t dcpl_xT_id = -1; /* Track modtime */ - hid_t dcpl_mx_id = -1; /* minimized */ - hid_t dcpl_mT_id = -1; /* minimized, Track */ - hid_t dcpl_mN_id = -1; /* minimized, do Not track */ - hid_t dset_xx_id = -1; - hid_t dset_xT_id = -1; - hid_t dset_mx_id = -1; - hid_t dset_mT_id = -1; - hid_t dset_mN_id = -1; - hid_t file_id = -1; - hid_t fapl_id = -1; - herr_t ret; - - unsigned i = 0; /* for testcase loop */ - unsigned n_cases = 2; /* must match `cases` array size below */ - struct testcase cases[2] = { - { 1, }, /* version 1 object header */ - { 2, }, /* version 2 object header */ - }; - - /* dcpl suffixes: - * | default | minimize - * ------------+---------+--------- - * default | xx | mx - * ------------+---------+--------- - * don't track | xN | mN - * ------------+---------+--------- - * track | xT | mT - */ - - TESTING("minimized dset object headers with modification times"); - - /********* - * SETUP * - *********/ - - if(h5_fixname(FILENAME[1], _fapl_id, filename, sizeof(filename)) == NULL) - TEST_ERROR - - dcpl_mx_id = H5Pcreate(H5P_DATASET_CREATE); - if(dcpl_mx_id < 0) TEST_ERROR - ret = H5Pset_dset_no_attrs_hint(dcpl_mx_id, TRUE); - if(ret < 0) TEST_ERROR - - dcpl_xT_id = H5Pcreate(H5P_DATASET_CREATE); - if(dcpl_xT_id < 0) TEST_ERROR - ret = H5Pset_obj_track_times(dcpl_xT_id, TRUE); - if(ret < 0) TEST_ERROR - - dcpl_mT_id = H5Pcreate(H5P_DATASET_CREATE); - if(dcpl_mT_id < 0) TEST_ERROR - ret = H5Pset_dset_no_attrs_hint(dcpl_mT_id, TRUE); - if(ret < 0) TEST_ERROR - ret = H5Pset_obj_track_times(dcpl_mT_id, TRUE); - if(ret < 0) TEST_ERROR - - dcpl_mN_id = H5Pcreate(H5P_DATASET_CREATE); - if(dcpl_mN_id < 0) TEST_ERROR - ret = H5Pset_dset_no_attrs_hint(dcpl_mN_id, TRUE); - if(ret < 0) TEST_ERROR - ret = H5Pset_obj_track_times(dcpl_mN_id, FALSE); - if(ret < 0) TEST_ERROR - - dspace_id = H5Screate_simple(1, extents, extents); - if(dspace_id < 0) TEST_ERROR - - dtype_id = H5Tcopy(H5T_NATIVE_INT); - if(dtype_id < 0) TEST_ERROR - - for (i = 0; i < n_cases; i++) { - - /* -------------- * - * per-case setup * - * -------------- */ - - if(cases[i].oh_version > 1) { - fapl_id = H5Pcreate(H5P_FILE_ACCESS); - if(fapl_id < 0) TEST_ERROR - ret = H5Pset_libver_bounds(fapl_id, H5F_LIBVER_V18, H5F_LIBVER_V110); - if(ret < 0) TEST_ERROR - } else { - fapl_id = H5Pcopy(_fapl_id); - if(fapl_id < 0) TEST_ERROR - } - - file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); - if(file_id < 0) TEST_ERROR - - dset_xx_id = H5Dcreate2( file_id, "xx", dtype_id, dspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if(dset_xx_id < 0) TEST_ERROR - - dset_mx_id = H5Dcreate2(file_id, "mx", dtype_id, dspace_id, H5P_DEFAULT, dcpl_mx_id, H5P_DEFAULT); - if(dset_mx_id < 0) TEST_ERROR - - dset_xT_id = H5Dcreate2(file_id, "xT", dtype_id, dspace_id, H5P_DEFAULT, dcpl_xT_id, H5P_DEFAULT); - if(dset_xT_id < 0) TEST_ERROR - dset_mT_id = H5Dcreate2(file_id, "mT", dtype_id, dspace_id, H5P_DEFAULT, dcpl_mT_id, H5P_DEFAULT); - if(dset_mT_id < 0) TEST_ERROR - - dset_mN_id = H5Dcreate2(file_id, "mN", dtype_id, dspace_id, H5P_DEFAULT, dcpl_mN_id, H5P_DEFAULT); - if(dset_mN_id < 0) TEST_ERROR - - /* ----- * - * TESTS * - * ----- */ - - /* sanity check */ - if(oh_compare(dset_mx_id, dset_xx_id) != LT) TEST_ERROR - if(oh_compare(dset_mx_id, dset_xT_id) != LT) TEST_ERROR - - if(oh_compare(dset_xx_id, dset_xT_id) != EQ) TEST_ERROR - if(oh_compare(dset_mx_id, dset_mT_id) != EQ) TEST_ERROR - if(oh_compare(dset_mN_id, dset_mT_id) != LT) TEST_ERROR - - if(oh_compare(dset_mT_id, dset_xT_id) != LT) TEST_ERROR - - /* ----------------- * - * per-case teardown * - * ----------------- */ - - if(H5Dclose(dset_xx_id) < 0) TEST_ERROR - if(H5Dclose(dset_xT_id) < 0) TEST_ERROR - if(H5Dclose(dset_mx_id) < 0) TEST_ERROR - if(H5Dclose(dset_mT_id) < 0) TEST_ERROR - if(H5Dclose(dset_mN_id) < 0) TEST_ERROR - if(H5Fclose(file_id) < 0) TEST_ERROR - if(H5Pclose(fapl_id) < 0) TEST_ERROR - - } /* for each version tested */ - - /************ - * TEARDOWN * - ************/ - - if(H5Sclose(dspace_id) < 0) TEST_ERROR - if(H5Tclose(dtype_id) < 0) TEST_ERROR - if(H5Pclose(dcpl_xT_id) < 0) TEST_ERROR - if(H5Pclose(dcpl_mx_id) < 0) TEST_ERROR - if(H5Pclose(dcpl_mT_id) < 0) TEST_ERROR - if(H5Pclose(dcpl_mN_id) < 0) TEST_ERROR - - PASSED() - return SUCCEED; - -error: - H5E_BEGIN_TRY { - (void)H5Sclose(dspace_id); - (void)H5Tclose(dtype_id); - (void)H5Pclose(dcpl_xT_id); - (void)H5Pclose(dcpl_mx_id); - (void)H5Pclose(dcpl_mT_id); - (void)H5Pclose(dcpl_mN_id); - (void)H5Dclose(dset_xx_id); - (void)H5Dclose(dset_xT_id); - (void)H5Dclose(dset_mx_id); - (void)H5Dclose(dset_mT_id); - (void)H5Dclose(dset_mN_id); - (void)H5Fclose(file_id); - (void)H5Pclose(fapl_id); - } H5E_END_TRY; - return FAIL; -} /* test_minimized_dset_ohdr_modification_times */ - -/* - * Test minimized dataset object header with a fill value set. - */ -static herr_t -test_minimized_dset_ohdr_fillvalue_backwards_compatability(hid_t _fapl_id) -{ - char filename[512] = ""; - const hsize_t extents[1] = {64}; /* extents of dataspace */ - const int fill[1] = {343}; /* fill value of dataset */ - hid_t file_id = -1; - hid_t dtype_id = -1; - hid_t dspace_id = -1; - hid_t dcpl_id = -1; - hid_t fapl_id = -1; - hid_t dset_0_id = -1; - hid_t dset_1_id = -1; - herr_t ret; - - /********* - * SETUP * - *********/ - - TESTING("minimized dset object headers with fill values and different libver support"); - - if(h5_fixname(FILENAME[1], _fapl_id, filename, sizeof(filename)) == NULL) - TEST_ERROR - - dspace_id = H5Screate_simple(1, extents, extents); - if(dspace_id < 0) TEST_ERROR - - dtype_id = H5Tcopy(H5T_NATIVE_INT); - if(dtype_id < 0) TEST_ERROR - - dcpl_id = H5Pcreate(H5P_DATASET_CREATE); - if(dcpl_id < 0) TEST_ERROR - - ret = H5Pset_dset_no_attrs_hint(dcpl_id, TRUE); - if(ret == FAIL) TEST_ERROR; - - ret = H5Pset_fill_value(dcpl_id, dtype_id, fill); - if(ret == FAIL) TEST_ERROR; - - fapl_id = H5Pcopy(_fapl_id); - if(fapl_id < 0) TEST_ERROR - - ret = H5Pset_libver_bounds(fapl_id, H5F_LIBVER_EARLIEST, H5F_LIBVER_LATEST); - if(ret == FAIL) TEST_ERROR; - - file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); - if(file_id < 0) TEST_ERROR - - dset_0_id = H5Dcreate2(file_id, "fullrange", dtype_id, dspace_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); - if(dset_0_id < 0) TEST_ERROR - - /* Close file and re-open with different libver bounds. - * Dataset "fullrange" must also be closed for expected reopen behavior. - */ - if(H5Fclose(file_id) < 0) TEST_ERROR; - if(H5Dclose(dset_0_id) < 0) TEST_ERROR - - ret = H5Pset_libver_bounds(fapl_id, H5F_LIBVER_V18, H5F_LIBVER_LATEST); - if(ret == FAIL) TEST_ERROR; - - file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl_id); - if(file_id < 0) TEST_ERROR - - dset_1_id = H5Dcreate2(file_id, "upperrange", dtype_id, dspace_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); - if(dset_1_id < 0) TEST_ERROR - - /* re-open "fullrange" dataset - */ - dset_0_id = H5Dopen2(file_id, "fullrange", H5P_DEFAULT); - if(dset_0_id < 0) TEST_ERROR - - /********* - * TESTS * - *********/ - - /* dset not supporting pre-1.08 should be smaller? */ - if(oh_compare(dset_1_id, dset_0_id) != LT) TEST_ERROR - - /************ - * TEARDOWN * - ************/ - - if(H5Sclose(dspace_id) < 0) TEST_ERROR - if(H5Tclose(dtype_id) < 0) TEST_ERROR - if(H5Pclose(dcpl_id) < 0) TEST_ERROR - if(H5Pclose(fapl_id) < 0) TEST_ERROR - if(H5Dclose(dset_0_id) < 0) TEST_ERROR - if(H5Dclose(dset_1_id) < 0) TEST_ERROR - if(H5Fclose(file_id) < 0) TEST_ERROR; - - PASSED() - return SUCCEED; - -error: - H5E_BEGIN_TRY { - (void)H5Sclose(dspace_id); - (void)H5Tclose(dtype_id); - (void)H5Pclose(dcpl_id); - (void)H5Pclose(fapl_id); - (void)H5Dclose(dset_0_id); - (void)H5Dclose(dset_1_id); - (void)H5Fclose(file_id); - } H5E_END_TRY; - return FAIL; -} /* test_minimized_dset_ohdr_fillvalue_backwards_compatability */ - -/* * Verify that messages are moved forward into a "continuation message": * Create an object header with several continuation chunks * Remove a message in the last chunk @@ -1351,13 +473,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. */ @@ -1371,7 +493,7 @@ test_unknown(unsigned bogus_id, char *filename, hid_t fapl) FAIL_STACK_ERROR /* Open FILE_BOGUS */ - if((fid_bogus = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if((fid_bogus = H5Fopen(testfile, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR /* Set up location ID depending on bogus_id */ @@ -1628,6 +750,835 @@ error: return FAIL; } /* test_unknown() */ +/* + * Count the number of attributes attached to an object. + * Returns negative in event of error. + */ +static int +count_attributes(hid_t dset_id) +{ + H5O_info_t info; + + if(H5Oget_info2(dset_id, &info, H5O_INFO_NUM_ATTRS) < 0) + return -1; + else + return (int)info.num_attrs; /* should never exceed int bounds */ +} /* count_attributes */ + +/* + * Get the total space used by the object header. + * Used by oh_compare() + * On success, stores size in `size_out` pointer. + */ +static herr_t +_oh_getsize(hid_t did, hsize_t *size_out) +{ + H5O_info_t info; + + if(FAIL == H5Oget_info2(did, &info, H5O_INFO_HDR)) + return FAIL; + + *size_out = info.hdr.space.total; + + return SUCCEED; +} /* _oh_getsize */ + +/* + * Compare the TOTAL space used by datasets' object headers. + * Returns negative value if an error occurred, + * else positive #defined indicator value EQ, LT, GT. + */ +static int +oh_compare(hid_t did1, hid_t did2) +{ + hsize_t space1 = 0; + hsize_t space2 = 0; + + if(FAIL == _oh_getsize(did1, &space1)) + return -1; + if(FAIL == _oh_getsize(did2, &space2)) + return -2; + + if(space1 < space2) + return LT; + else if(space1 > space2) + return GT; + else + return EQ; +} /* oh_compare() */ + +/* + * Demonstrate attribute addition to datasets. + * Conduct additions side-by-side with a standard datataset and one with + * minimized dataset object headers. + */ +#define ATTR_NAME_MAX 64 +#define ATTR_SHORT "first" +#define ATTR_LONG "second" +#define N_ATTRS 64 +static herr_t +test_minimized_dset_ohdr_attribute_addition(hid_t fapl_id) +{ + hsize_t dims[1] = {0}; /* dataspace extent */ + char filename[512] = ""; + char attr_name[ATTR_NAME_MAX] = ""; + hid_t fid = H5I_INVALID_HID; + hid_t dcpl_id = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; + hid_t aid = H5I_INVALID_HID; + char *in_buf = NULL; + char *out_buf = NULL; + size_t buf_size = 0; + int out_val = 0; + int in_val = 0; + int i; + + TESTING("adding attributes to datasets created with H5Pset_dset_no_attrs_hint()") + + /* Create the test file */ + if(NULL == h5_fixname(FILENAME[1], fapl_id, filename, sizeof(filename))) + TEST_ERROR; + if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) == H5I_INVALID_HID) + TEST_ERROR; + + /* Set the 'no attrs' hint on the dcpl */ + if((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) == H5I_INVALID_HID) + TEST_ERROR; + if(H5Pset_dset_no_attrs_hint(dcpl_id, TRUE) < 0) + TEST_ERROR; + + /* The dataset doesn't need to contain data */ + dims[0] = 0; + if((sid = H5Screate_simple(1, dims, NULL)) == H5I_INVALID_HID) + TEST_ERROR; + + /* Create the dataset */ + if((did = H5Dcreate2(fid, "H5Pset_dset_no_attrs_hint", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) == H5I_INVALID_HID) + TEST_ERROR; + + /* Close */ + if(H5Pclose(dcpl_id) < 0) + TEST_ERROR; + if(H5Sclose(sid) < 0) + TEST_ERROR; + + /********************************************** + * ADD A (STRING) ATTRIBUTE AND MANIPULATE IT * + **********************************************/ + + buf_size = HDstrlen(ATTR_LONG) + 1; + if(NULL == (in_buf = (char *)HDcalloc(buf_size, sizeof(char)))) + TEST_ERROR; + if(NULL == (out_buf = (char *)HDcalloc(buf_size, sizeof(char)))) + TEST_ERROR; + + /* Create a string attribute on the dataset + * + * It has to be long enough to hold the longest string we're going to write + * to it. + */ + dims[0] = buf_size; + if((sid = H5Screate_simple(1, dims, NULL)) == H5I_INVALID_HID) + TEST_ERROR; + if((aid = H5Acreate2(did, "string_attr", H5T_NATIVE_CHAR, sid, H5P_DEFAULT, H5P_DEFAULT)) == H5I_INVALID_HID) + TEST_ERROR; + + /* Write attribute data */ + HDstrcpy(in_buf, ATTR_SHORT); + if(H5Awrite(aid, H5T_NATIVE_CHAR, in_buf) < 0) + TEST_ERROR; + + /* Make sure the count is correct */ + if(count_attributes(did) != 1) + TEST_ERROR; + + /* Read the data back and verify */ + if(H5Aread(aid, H5T_NATIVE_CHAR, out_buf) < 0) + TEST_ERROR; + if(HDstrcmp(in_buf, out_buf)) + TEST_ERROR; + + /* modify the string attribute */ + HDmemset(in_buf, 0, buf_size); + HDstrcpy(in_buf, ATTR_LONG); + if(H5Awrite(aid, H5T_NATIVE_CHAR, in_buf) < 0) + TEST_ERROR; + + if(count_attributes(did) != 1) + TEST_ERROR; + + /* Read the data back and verify */ + if(H5Aread(aid, H5T_NATIVE_CHAR, out_buf) < 0) + TEST_ERROR; + if(HDstrcmp(in_buf, out_buf)) + TEST_ERROR; + + /* Close */ + if(H5Sclose(sid) < 0) + TEST_ERROR; + if(H5Aclose(aid) < 0) + TEST_ERROR; + + /*************************************** + * ADD A BUNCH OF (INTEGER) ATTRIBUTES * + ***************************************/ + + if((sid = H5Screate(H5S_SCALAR)) == H5I_INVALID_HID) + TEST_ERROR; + + /* Loop over a reasonable number of attributes */ + for(i = 0; i < N_ATTRS; i++) { + + /* Set the attribute's name */ + if(HDsnprintf(attr_name, ATTR_NAME_MAX, "int_attr_%d", i) < 0) + TEST_ERROR; + + /* Create an integer attribute on the dataset */ + if((aid = H5Acreate2(did, attr_name, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) == H5I_INVALID_HID) + TEST_ERROR; + + /* Write attribute data */ + in_val = i; + if(H5Awrite(aid, H5T_NATIVE_INT, &in_val) < 0) + TEST_ERROR; + + /* Make sure the count is correct (already has one attribute) */ + if(count_attributes(did) != i + 2) + TEST_ERROR; + + /* Read the data back and verify */ + if(H5Aread(aid, H5T_NATIVE_INT, &out_val) < 0) + TEST_ERROR; + if(in_val != out_val) + TEST_ERROR; + + /* Close */ + if(H5Aclose(aid) < 0) + TEST_ERROR; + } + + /* Close */ + if(H5Sclose(sid) < 0) + TEST_ERROR; + + /* Close the remaining IDs */ + if(H5Dclose(did) < 0) + TEST_ERROR; + if(H5Fclose(fid) < 0) + TEST_ERROR; + + /* Free memory */ + HDfree(in_buf); + HDfree(out_buf); + + PASSED(); + return SUCCEED; + +error : + H5E_BEGIN_TRY { + (void)H5Pclose(dcpl_id); + (void)H5Sclose(sid); + (void)H5Dclose(did); + (void)H5Aclose(aid); + (void)H5Fclose(fid); + } H5E_END_TRY; + + HDfree(in_buf); + HDfree(out_buf); + + return FAIL; +} /* test_minimized_dset_ohdr_attribute_addition */ + +/* + * Compare header sizes against when headers have been minimized. + * Repeats tests with headers "compact" and normal. + */ +static herr_t +test_minimized_dset_ohdr_size_comparisons(hid_t fapl_id) +{ + hsize_t array_10[1] = {10}; /* dataspace extents */ + unsigned compact = 0; + + /* IDs that are file-agnostic */ + hid_t dspace_id = -1; + hid_t int_type_id = -1; + hid_t dcpl_minimize = -1; + hid_t dcpl_dontmin = -1; + hid_t dcpl_default = -1; + + /* IDs for non-minimized file open */ + hid_t file_f_id = -1; /* lower 'f' for standard file setting */ + hid_t dset_f_x_id = -1; /* 'x' for default */ + hid_t dset_f_N_id = -1; /* 'N' for explcit non-minimized dset */ + hid_t dset_f_Y_id = -1; /* 'Y' for minimized dset */ + + /* IDs for minimized file open */ + hid_t file_F_id = -1; /* upper 'F' for minimized file setting */ + hid_t dset_F_x_id = -1; /* 'x' for default */ + hid_t dset_F_N_id = -1; /* 'N' for explcit non-minimized dset */ + hid_t dset_F_Y_id = -1; /* 'Y' for minimized dset */ + + char filename_a[512] = ""; + char filename_b[512] = ""; + + herr_t ret; + + /* dataset suffixes: + * | default | minimize | don't minimize (dcpl-set) + * ---------------+---------+----------+--------------- + * file-default | f_x | f_Y | f_N + * ---------------+---------+----------+--------------- + * file-minimized | F_x | F_Y | F_N + */ + + + /********* + * SETUP * + *********/ + + /* Set filenames (not in a test, can't use TEST_ERROR) */ + if(h5_fixname(FILENAME[1], fapl_id, filename_a, sizeof(filename_a)) == NULL) + return FAIL; + if(h5_fixname(FILENAME[2], fapl_id, filename_b, sizeof(filename_b)) == NULL) + return FAIL; + + for (compact = 0; compact < 2; compact++) { /* 0 or 1 */ + + if(compact) + TESTING("minimized dset object headers size comparisons (compact)") + else + TESTING("minimized dset object headers size comparisons") + + dcpl_default = H5Pcreate(H5P_DATASET_CREATE); + if(dcpl_default < 0) TEST_ERROR + + dcpl_minimize = H5Pcreate(H5P_DATASET_CREATE); + if(dcpl_minimize < 0) TEST_ERROR + ret = H5Pset_dset_no_attrs_hint(dcpl_minimize, TRUE); + if(ret < 0) TEST_ERROR + + dcpl_dontmin = H5Pcreate(H5P_DATASET_CREATE); + if(dcpl_dontmin < 0) TEST_ERROR + ret = H5Pset_dset_no_attrs_hint(dcpl_dontmin, FALSE); + if(ret < 0) TEST_ERROR + + if(compact) { + ret = H5Pset_layout(dcpl_default, H5D_COMPACT); + if(ret < 0) TEST_ERROR + ret = H5Pset_layout(dcpl_minimize, H5D_COMPACT); + if(ret < 0) TEST_ERROR + ret = H5Pset_layout(dcpl_dontmin, H5D_COMPACT); + if(ret < 0) TEST_ERROR + } + + dspace_id = H5Screate_simple(1, array_10, NULL); + if(dspace_id < 0) TEST_ERROR + + int_type_id = H5Tcopy(H5T_NATIVE_INT); + if(int_type_id < 0) TEST_ERROR + + file_f_id = H5Fcreate(filename_a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); + if(file_f_id < 0) TEST_ERROR + + dset_f_x_id = H5Dcreate2(file_f_id, "default", int_type_id, dspace_id, H5P_DEFAULT, dcpl_default, H5P_DEFAULT); + if(dset_f_x_id < 0) TEST_ERROR + + dset_f_N_id = H5Dcreate2(file_f_id, "dsetNOT", int_type_id, dspace_id, H5P_DEFAULT, dcpl_dontmin, H5P_DEFAULT); + if(dset_f_N_id < 0) TEST_ERROR + + dset_f_Y_id = H5Dcreate2(file_f_id, "dsetMIN", int_type_id, dspace_id, H5P_DEFAULT, dcpl_minimize, H5P_DEFAULT); + if(dset_f_x_id < 0) TEST_ERROR + + file_F_id = H5Fcreate(filename_b, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); + if(file_F_id < 0) TEST_ERROR + ret = H5Fset_dset_no_attrs_hint(file_F_id, TRUE); + if(ret < 0) TEST_ERROR + + dset_F_x_id = H5Dcreate2(file_F_id, "default", int_type_id, dspace_id, H5P_DEFAULT, dcpl_default, H5P_DEFAULT); + if(dset_F_x_id < 0) TEST_ERROR + + dset_F_N_id = H5Dcreate2(file_F_id, "dsetNOT", int_type_id, dspace_id, H5P_DEFAULT, dcpl_dontmin, H5P_DEFAULT); + if(dset_F_N_id < 0) TEST_ERROR + + dset_F_Y_id = H5Dcreate2(file_F_id, "dsetMIN", int_type_id, dspace_id, H5P_DEFAULT, dcpl_minimize, H5P_DEFAULT); + if(dset_F_Y_id < 0) TEST_ERROR + + /********* + * TESTS * + *********/ + + if(oh_compare(dset_f_x_id, dset_f_x_id) != EQ) TEST_ERROR /* identity */ + + if(oh_compare(dset_f_x_id, dset_f_N_id) != EQ) TEST_ERROR + if(oh_compare(dset_f_x_id, dset_f_Y_id) != GT) TEST_ERROR + if(oh_compare(dset_f_N_id, dset_f_Y_id) != GT) TEST_ERROR + + if(oh_compare(dset_F_x_id, dset_F_N_id) != EQ) TEST_ERROR + if(oh_compare(dset_F_x_id, dset_F_Y_id) != EQ) TEST_ERROR + if(oh_compare(dset_F_N_id, dset_F_Y_id) != EQ) TEST_ERROR + + if(oh_compare(dset_F_x_id, dset_f_Y_id) != EQ) TEST_ERROR + if(oh_compare(dset_F_x_id, dset_f_x_id) != LT) TEST_ERROR + + /************ + * TEARDOWN * + ************/ + + if(H5Sclose(dspace_id) < 0) TEST_ERROR + if(H5Tclose(int_type_id) < 0) TEST_ERROR + if(H5Pclose(dcpl_default) < 0) TEST_ERROR + if(H5Pclose(dcpl_minimize) < 0) TEST_ERROR + if(H5Pclose(dcpl_dontmin) < 0) TEST_ERROR + + if(H5Fclose(file_f_id) < 0) TEST_ERROR + if(H5Dclose(dset_f_x_id) < 0) TEST_ERROR + if(H5Dclose(dset_f_N_id) < 0) TEST_ERROR + if(H5Dclose(dset_f_Y_id) < 0) TEST_ERROR + + if(H5Fclose(file_F_id) < 0) TEST_ERROR + if(H5Dclose(dset_F_x_id) < 0) TEST_ERROR + if(H5Dclose(dset_F_N_id) < 0) TEST_ERROR + if(H5Dclose(dset_F_Y_id) < 0) TEST_ERROR + + PASSED(); + + } /* compact and non-compact */ + + return SUCCEED; + +error : + H5E_BEGIN_TRY { + (void)H5Pclose(dcpl_default); + (void)H5Pclose(dcpl_minimize); + (void)H5Pclose(dcpl_dontmin); + (void)H5Sclose(dspace_id); + (void)H5Tclose(int_type_id); + + (void)H5Fclose(file_f_id); + (void)H5Dclose(dset_f_x_id); + (void)H5Dclose(dset_f_N_id); + (void)H5Dclose(dset_f_Y_id); + + (void)H5Fclose(file_F_id); + (void)H5Dclose(dset_F_x_id); + (void)H5Dclose(dset_F_N_id); + (void)H5Dclose(dset_F_Y_id); + } H5E_END_TRY; + return FAIL; +} /* test_minimized_dset_ohdr_size_comparisons */ + +/* + * Test minimized dataset object header with filter/pipeline message + */ +static herr_t +test_minimized_dset_ohdr_with_filter(hid_t fapl_id) +{ + char filename[512] = ""; + const hsize_t extents[1] = {1024}; /* extents of dataspace */ + const unsigned filter_values[] = {0}; /* TBD */ + const hsize_t chunk_dim[] = {32}; /* needed for filter */ + const int ndims = 1; + hid_t dspace_id = -1; + hid_t dtype_id = -1; + hid_t dcpl_xZ_id = -1; + hid_t dcpl_mx_id = -1; + hid_t dcpl_mZ_id = -1; + hid_t dset_xx_id = -1; + hid_t dset_xZ_id = -1; + hid_t dset_mx_id = -1; + hid_t dset_mZ_id = -1; + hid_t file_id = -1; + herr_t ret; + + /* dcpl suffixes: + * | default | minimize + * ----------+---------+--------- + * no filter | xx | mx + * ----------+---------+--------- + * filter | xZ | mZ + */ + + TESTING("minimized dset object headers with filter message"); + + /********* + * SETUP * + *********/ + + if(h5_fixname(FILENAME[1], fapl_id, filename, sizeof(filename)) == NULL) + TEST_ERROR + + dcpl_mx_id = H5Pcreate(H5P_DATASET_CREATE); + if(dcpl_mx_id < 0) TEST_ERROR + ret = H5Pset_dset_no_attrs_hint(dcpl_mx_id, TRUE); + if(ret < 0) TEST_ERROR + + dcpl_xZ_id = H5Pcreate(H5P_DATASET_CREATE); + if(dcpl_xZ_id < 0) TEST_ERROR + ret = H5Pset_chunk(dcpl_xZ_id, ndims, chunk_dim); + if(ret < 0) TEST_ERROR + ret = H5Pset_filter(dcpl_xZ_id, H5Z_FILTER_DEFLATE, H5Z_FLAG_OPTIONAL, 0, filter_values); + if(ret < 0) TEST_ERROR + dcpl_mZ_id = H5Pcreate(H5P_DATASET_CREATE); + if(dcpl_mZ_id < 0) TEST_ERROR + ret = H5Pset_dset_no_attrs_hint(dcpl_mZ_id, TRUE); + if(ret < 0) TEST_ERROR + ret = H5Pset_chunk(dcpl_mZ_id, ndims, chunk_dim); + if(ret < 0) TEST_ERROR + ret = H5Pset_filter( dcpl_mZ_id, H5Z_FILTER_DEFLATE, H5Z_FLAG_OPTIONAL, 0, filter_values); + if(ret < 0) TEST_ERROR + + dspace_id = H5Screate_simple(1, extents, extents); + if(dspace_id < 0) TEST_ERROR + + dtype_id = H5Tcopy(H5T_NATIVE_INT); + if(dtype_id < 0) TEST_ERROR + + file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); + if(file_id < 0) TEST_ERROR + + dset_xx_id = H5Dcreate2(file_id, "xx", dtype_id, dspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if(dset_xx_id < 0) TEST_ERROR + + dset_mx_id = H5Dcreate2(file_id, "Mx", dtype_id, dspace_id, H5P_DEFAULT, dcpl_mx_id, H5P_DEFAULT); + if(dset_mx_id < 0) TEST_ERROR + + dset_xZ_id = H5Dcreate2(file_id, "xZ", dtype_id, dspace_id, H5P_DEFAULT, dcpl_xZ_id, H5P_DEFAULT); + if(dset_xZ_id < 0) TEST_ERROR + + dset_mZ_id = H5Dcreate2(file_id, "MZ", dtype_id, dspace_id, H5P_DEFAULT, dcpl_mZ_id, H5P_DEFAULT); + if(dset_mZ_id < 0) TEST_ERROR + + /********* + * TESTS * + *********/ + + if(oh_compare(dset_mx_id, dset_xx_id) != LT) TEST_ERROR + if(oh_compare(dset_mx_id, dset_xZ_id) != LT) TEST_ERROR + if(oh_compare(dset_mZ_id, dset_mx_id) != GT) TEST_ERROR + if(oh_compare(dset_mZ_id, dset_xZ_id) != LT) TEST_ERROR + + /************ + * TEARDOWN * + ************/ + + if(H5Sclose(dspace_id) < 0) TEST_ERROR + if(H5Tclose(dtype_id) < 0) TEST_ERROR + if(H5Pclose(dcpl_xZ_id) < 0) TEST_ERROR + if(H5Pclose(dcpl_mx_id) < 0) TEST_ERROR + if(H5Pclose(dcpl_mZ_id) < 0) TEST_ERROR + if(H5Dclose(dset_xx_id) < 0) TEST_ERROR + if(H5Dclose(dset_xZ_id) < 0) TEST_ERROR + if(H5Dclose(dset_mx_id) < 0) TEST_ERROR + if(H5Dclose(dset_mZ_id) < 0) TEST_ERROR + if(H5Fclose(file_id) < 0) TEST_ERROR + + PASSED(); + return SUCCEED; + +error: + H5E_BEGIN_TRY { + (void)H5Sclose(dspace_id); + (void)H5Tclose(dtype_id); + (void)H5Pclose(dcpl_xZ_id); + (void)H5Pclose(dcpl_mx_id); + (void)H5Pclose(dcpl_mZ_id); + (void)H5Dclose(dset_xx_id); + (void)H5Dclose(dset_xZ_id); + (void)H5Dclose(dset_mx_id); + (void)H5Dclose(dset_mZ_id); + (void)H5Fclose(file_id); + } H5E_END_TRY; + return FAIL; +} /* test_minimized_dset_ohdr_with_filter */ + +/* + * Test minimized dataset object header and recording modification times. + */ +static herr_t +test_minimized_dset_ohdr_modification_times(hid_t _fapl_id) +{ + /* test-local structure for parameterized testing + */ + struct testcase { + unsigned oh_version; + }; + + char filename[512] = ""; + const hsize_t extents[1] = {128}; /* extents of dataspace */ + hid_t dspace_id = -1; + hid_t dtype_id = -1; + hid_t dcpl_xT_id = -1; /* Track modtime */ + hid_t dcpl_mx_id = -1; /* minimized */ + hid_t dcpl_mT_id = -1; /* minimized, Track */ + hid_t dcpl_mN_id = -1; /* minimized, do Not track */ + hid_t dset_xx_id = -1; + hid_t dset_xT_id = -1; + hid_t dset_mx_id = -1; + hid_t dset_mT_id = -1; + hid_t dset_mN_id = -1; + hid_t file_id = -1; + hid_t fapl_id = -1; + herr_t ret; + + unsigned i = 0; /* for testcase loop */ + unsigned n_cases = 2; /* must match `cases` array size below */ + struct testcase cases[2] = { + { 1, }, /* version 1 object header */ + { 2, }, /* version 2 object header */ + }; + + /* dcpl suffixes: + * | default | minimize + * ------------+---------+--------- + * default | xx | mx + * ------------+---------+--------- + * don't track | xN | mN + * ------------+---------+--------- + * track | xT | mT + */ + + TESTING("minimized dset object headers with modification times"); + + /********* + * SETUP * + *********/ + + if(h5_fixname(FILENAME[1], _fapl_id, filename, sizeof(filename)) == NULL) + TEST_ERROR + + dcpl_mx_id = H5Pcreate(H5P_DATASET_CREATE); + if(dcpl_mx_id < 0) TEST_ERROR + ret = H5Pset_dset_no_attrs_hint(dcpl_mx_id, TRUE); + if(ret < 0) TEST_ERROR + + dcpl_xT_id = H5Pcreate(H5P_DATASET_CREATE); + if(dcpl_xT_id < 0) TEST_ERROR + ret = H5Pset_obj_track_times(dcpl_xT_id, TRUE); + if(ret < 0) TEST_ERROR + + dcpl_mT_id = H5Pcreate(H5P_DATASET_CREATE); + if(dcpl_mT_id < 0) TEST_ERROR + ret = H5Pset_dset_no_attrs_hint(dcpl_mT_id, TRUE); + if(ret < 0) TEST_ERROR + ret = H5Pset_obj_track_times(dcpl_mT_id, TRUE); + if(ret < 0) TEST_ERROR + + dcpl_mN_id = H5Pcreate(H5P_DATASET_CREATE); + if(dcpl_mN_id < 0) TEST_ERROR + ret = H5Pset_dset_no_attrs_hint(dcpl_mN_id, TRUE); + if(ret < 0) TEST_ERROR + ret = H5Pset_obj_track_times(dcpl_mN_id, FALSE); + if(ret < 0) TEST_ERROR + + dspace_id = H5Screate_simple(1, extents, extents); + if(dspace_id < 0) TEST_ERROR + + dtype_id = H5Tcopy(H5T_NATIVE_INT); + if(dtype_id < 0) TEST_ERROR + + for (i = 0; i < n_cases; i++) { + + /* -------------- * + * per-case setup * + * -------------- */ + + fapl_id = H5Pcopy(_fapl_id); + if(fapl_id < 0) TEST_ERROR + + if(cases[i].oh_version > 1) { + ret = H5Pset_libver_bounds(fapl_id, H5F_LIBVER_V18, H5F_LIBVER_V110); + if(ret < 0) TEST_ERROR + } + + file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); + if(file_id < 0) TEST_ERROR + + dset_xx_id = H5Dcreate2( file_id, "xx", dtype_id, dspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if(dset_xx_id < 0) TEST_ERROR + + dset_mx_id = H5Dcreate2(file_id, "mx", dtype_id, dspace_id, H5P_DEFAULT, dcpl_mx_id, H5P_DEFAULT); + if(dset_mx_id < 0) TEST_ERROR + + dset_xT_id = H5Dcreate2(file_id, "xT", dtype_id, dspace_id, H5P_DEFAULT, dcpl_xT_id, H5P_DEFAULT); + if(dset_xT_id < 0) TEST_ERROR + dset_mT_id = H5Dcreate2(file_id, "mT", dtype_id, dspace_id, H5P_DEFAULT, dcpl_mT_id, H5P_DEFAULT); + if(dset_mT_id < 0) TEST_ERROR + + dset_mN_id = H5Dcreate2(file_id, "mN", dtype_id, dspace_id, H5P_DEFAULT, dcpl_mN_id, H5P_DEFAULT); + if(dset_mN_id < 0) TEST_ERROR + + /* ----- * + * TESTS * + * ----- */ + + /* sanity check */ + if(oh_compare(dset_mx_id, dset_xx_id) != LT) TEST_ERROR + if(oh_compare(dset_mx_id, dset_xT_id) != LT) TEST_ERROR + + if(oh_compare(dset_xx_id, dset_xT_id) != EQ) TEST_ERROR + if(oh_compare(dset_mx_id, dset_mT_id) != EQ) TEST_ERROR + if(oh_compare(dset_mN_id, dset_mT_id) != LT) TEST_ERROR + + if(oh_compare(dset_mT_id, dset_xT_id) != LT) TEST_ERROR + + /* ----------------- * + * per-case teardown * + * ----------------- */ + + if(H5Dclose(dset_xx_id) < 0) TEST_ERROR + if(H5Dclose(dset_xT_id) < 0) TEST_ERROR + if(H5Dclose(dset_mx_id) < 0) TEST_ERROR + if(H5Dclose(dset_mT_id) < 0) TEST_ERROR + if(H5Dclose(dset_mN_id) < 0) TEST_ERROR + if(H5Fclose(file_id) < 0) TEST_ERROR + if(H5Pclose(fapl_id) < 0) TEST_ERROR + + } /* for each version tested */ + + /************ + * TEARDOWN * + ************/ + + if(H5Sclose(dspace_id) < 0) TEST_ERROR + if(H5Tclose(dtype_id) < 0) TEST_ERROR + if(H5Pclose(dcpl_xT_id) < 0) TEST_ERROR + if(H5Pclose(dcpl_mx_id) < 0) TEST_ERROR + if(H5Pclose(dcpl_mT_id) < 0) TEST_ERROR + if(H5Pclose(dcpl_mN_id) < 0) TEST_ERROR + + PASSED(); + return SUCCEED; + +error: + H5E_BEGIN_TRY { + (void)H5Sclose(dspace_id); + (void)H5Tclose(dtype_id); + (void)H5Pclose(dcpl_xT_id); + (void)H5Pclose(dcpl_mx_id); + (void)H5Pclose(dcpl_mT_id); + (void)H5Pclose(dcpl_mN_id); + (void)H5Dclose(dset_xx_id); + (void)H5Dclose(dset_xT_id); + (void)H5Dclose(dset_mx_id); + (void)H5Dclose(dset_mT_id); + (void)H5Dclose(dset_mN_id); + (void)H5Fclose(file_id); + (void)H5Pclose(fapl_id); + } H5E_END_TRY; + return FAIL; +} /* test_minimized_dset_ohdr_modification_times */ + +/* + * Test minimized dataset object header with a fill value set. + */ +static herr_t +test_minimized_dset_ohdr_fillvalue_backwards_compatability(hid_t _fapl_id) +{ + char filename[512] = ""; + const hsize_t extents[1] = {64}; /* extents of dataspace */ + const int fill[1] = {343}; /* fill value of dataset */ + hid_t file_id = -1; + hid_t dtype_id = -1; + hid_t dspace_id = -1; + hid_t dcpl_id = -1; + hid_t fapl_id = -1; + hid_t dset_0_id = -1; + hid_t dset_1_id = -1; + herr_t ret; + + /********* + * SETUP * + *********/ + + TESTING("minimized dset object headers with fill values and different libver support"); + + fapl_id = H5Pcopy(_fapl_id); + if(fapl_id < 0) TEST_ERROR + + if(h5_fixname(FILENAME[1], fapl_id, filename, sizeof(filename)) == NULL) + TEST_ERROR + + dspace_id = H5Screate_simple(1, extents, extents); + if(dspace_id < 0) TEST_ERROR + + dtype_id = H5Tcopy(H5T_NATIVE_INT); + if(dtype_id < 0) TEST_ERROR + + dcpl_id = H5Pcreate(H5P_DATASET_CREATE); + if(dcpl_id < 0) TEST_ERROR + + ret = H5Pset_dset_no_attrs_hint(dcpl_id, TRUE); + if(ret == FAIL) TEST_ERROR; + + ret = H5Pset_fill_value(dcpl_id, dtype_id, fill); + if(ret == FAIL) TEST_ERROR; + + ret = H5Pset_libver_bounds(fapl_id, H5F_LIBVER_EARLIEST, H5F_LIBVER_LATEST); + if(ret == FAIL) TEST_ERROR; + + file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); + if(file_id < 0) TEST_ERROR + + dset_0_id = H5Dcreate2(file_id, "fullrange", dtype_id, dspace_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); + if(dset_0_id < 0) TEST_ERROR + + /* Close file and re-open with different libver bounds. + * Dataset "fullrange" must also be closed for expected reopen behavior. + */ + if(H5Fclose(file_id) < 0) TEST_ERROR; + if(H5Dclose(dset_0_id) < 0) TEST_ERROR + + ret = H5Pset_libver_bounds(fapl_id, H5F_LIBVER_V18, H5F_LIBVER_LATEST); + if(ret == FAIL) TEST_ERROR; + + file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl_id); + if(file_id < 0) TEST_ERROR + + dset_1_id = H5Dcreate2(file_id, "upperrange", dtype_id, dspace_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); + if(dset_1_id < 0) TEST_ERROR + + /* re-open "fullrange" dataset + */ + dset_0_id = H5Dopen2(file_id, "fullrange", H5P_DEFAULT); + if(dset_0_id < 0) TEST_ERROR + + /********* + * TESTS * + *********/ + + /* dset not supporting pre-1.08 should be smaller? */ + if(oh_compare(dset_1_id, dset_0_id) != LT) TEST_ERROR + + /************ + * TEARDOWN * + ************/ + + if(H5Sclose(dspace_id) < 0) TEST_ERROR + if(H5Tclose(dtype_id) < 0) TEST_ERROR + if(H5Pclose(dcpl_id) < 0) TEST_ERROR + if(H5Pclose(fapl_id) < 0) TEST_ERROR + if(H5Dclose(dset_0_id) < 0) TEST_ERROR + if(H5Dclose(dset_1_id) < 0) TEST_ERROR + if(H5Fclose(file_id) < 0) TEST_ERROR; + + PASSED(); + return SUCCEED; + +error: + H5E_BEGIN_TRY { + (void)H5Sclose(dspace_id); + (void)H5Tclose(dtype_id); + (void)H5Pclose(dcpl_id); + (void)H5Pclose(fapl_id); + (void)H5Dclose(dset_0_id); + (void)H5Dclose(dset_1_id); + (void)H5Fclose(file_id); + } H5E_END_TRY; + return FAIL; +} /* test_minimized_dset_ohdr_fillvalue_backwards_compatability */ + + /*------------------------------------------------------------------------- * Function: main * @@ -1647,6 +1598,8 @@ main(void) hid_t fapl = -1; hid_t file = -1; H5F_t *f = NULL; + const char *env_h5_drvr; /* File driver value from environment */ + hbool_t single_file_vfd; /* Whether VFD used stores data in a single file */ char filename[1024]; H5O_hdr_info_t hdr_info; /* Object info */ H5O_loc_t oh_loc; /* Object header locations */ @@ -1656,6 +1609,14 @@ main(void) hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ herr_t ret; /* Generic return value */ + /* Get the VFD to use */ + env_h5_drvr = HDgetenv("HDF5_DRIVER"); + if(env_h5_drvr == NULL) + env_h5_drvr = "nomatch"; + + /* Check for VFD which stores data in multiple files */ + single_file_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && HDstrcmp(env_h5_drvr, "family")); + /* Reset library */ h5_reset(); fapl = h5_fileaccess(); @@ -1668,8 +1629,8 @@ main(void) /* Loop through all the combinations of low/high library format bounds */ for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { - char *low_string = NULL; /* Message for library version low bound */ - char *high_string = NULL; /* Message for library version high bound */ + const char *low_string; /* Message for library version low bound */ + const char *high_string; /* Message for library version high bound */ char msg[80]; /* Message for file format version */ /* Set version bounds before opening the file */ @@ -1873,11 +1834,23 @@ main(void) * and the various "fail/mark if unknown" object header message flags */ HDputs("Accessing objects with unknown header messages: H5O_BOGUS_VALID_ID"); - if(test_unknown(H5O_BOGUS_VALID_ID, filename, fapl) < 0) - TEST_ERROR + if(single_file_vfd) { + if(test_unknown(H5O_BOGUS_VALID_ID, filename, fapl) < 0) + TEST_ERROR + } /* end if */ + else { + SKIPPED(); + HDputs(" Unknown header message test not supported with the current VFD."); + } /* end else */ HDputs("Accessing objects with unknown header messages: H5O_BOGUS_INVALID_ID"); - if(test_unknown(H5O_BOGUS_INVALID_ID, filename, fapl) < 0) - TEST_ERROR + if(single_file_vfd) { + if(test_unknown(H5O_BOGUS_INVALID_ID, filename, fapl) < 0) + TEST_ERROR + } /* end if */ + else { + SKIPPED(); + HDputs(" Unknown header message test not supported with the current VFD."); + } /* end else */ /* Test object header creation metadata cache issues */ if(test_ohdr_cache(filename, fapl) < 0) diff --git a/test/page_buffer.c b/test/page_buffer.c index 73088de..b07ea3f 100644 --- a/test/page_buffer.c +++ b/test/page_buffer.c @@ -37,23 +37,25 @@ #define FILENAME_LEN 1024 + +/* test routines */ +#ifdef H5_HAVE_PARALLEL +static unsigned verify_page_buffering_disabled(hid_t orig_fapl, + const char *env_h5_drvr); +#else #define NUM_DSETS 5 #define NX 100 #define NY 50 -/* helper routines */ -static unsigned create_file(char *filename, hid_t fcpl, hid_t fapl); -static unsigned open_file(char *filename, hid_t fapl, hsize_t page_size, size_t page_buffer_size); - -/* 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_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); -#ifdef H5_HAVE_PARALLEL -static unsigned verify_page_buffering_disabled(hid_t orig_fapl, - const char *env_h5_drvr); + +/* helper routines */ +static unsigned create_file(char *filename, hid_t fcpl, hid_t fapl); +static unsigned open_file(char *filename, hid_t fapl, hsize_t page_size, size_t page_buffer_size); #endif /* H5_HAVE_PARALLEL */ const char *FILENAME[] = { @@ -61,6 +63,7 @@ const char *FILENAME[] = { NULL }; +#ifndef H5_HAVE_PARALLEL /*------------------------------------------------------------------------- * Function: create_file() @@ -68,9 +71,9 @@ const char *FILENAME[] = { * Purpose: The purpose of this function appears to be a smoke check * intended to exercise the page buffer. * - * Specifically, the function creates a file, and then goes - * through a loop in which it creates four data sets, write - * data to one of them, verifies the data written, and then + * Specifically, the function creates a file, and then goes + * through a loop in which it creates four data sets, write + * data to one of them, verifies the data written, and then * deletes the three that it didn't write to. * * Any data mis-matches or failures reported by the HDF5 @@ -154,7 +157,7 @@ create_file(char *filename, hid_t fcpl, hid_t fapl) HDmemset(data, 0, (size_t)num_elements * sizeof(int)); if((dset_id = H5Dopen2(grp_id, dset_name, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) FAIL_STACK_ERROR; if(H5Dclose(dset_id) < 0) @@ -209,7 +212,7 @@ error: * Purpose: The purpose of this function appears to be a smoke check * intended to exercise the page buffer. * - * Specifically, the function opens a file (created by + * Specifically, the function opens a file (created by * create_file()?), and verify the contents of its datasets. * * Any data mis-matches or failures reported by the HDF5 @@ -224,7 +227,7 @@ error: *------------------------------------------------------------------------- */ static unsigned -open_file(char *filename, hid_t fapl, hsize_t page_size, +open_file(char *filename, hid_t fapl, hsize_t page_size, size_t page_buffer_size) { hid_t file_id = -1; @@ -295,6 +298,7 @@ error: } H5E_END_TRY; return 1; } +#endif /* H5_HAVE_PARALLEL */ /* * @@ -356,6 +360,7 @@ error: } /* set_multi_split() */ +#ifndef H5_HAVE_PARALLEL /*------------------------------------------------------------------------- * Function: test_args() @@ -364,7 +369,7 @@ error: * * 1) verifying that API errors are caught. * - * 2) verifying that the page buffer behaves more or less + * 2) verifying that the page buffer behaves more or less * as advertized. * * Any data mis-matches or unexpected failures or successes @@ -397,8 +402,8 @@ test_args(hid_t orig_fapl, const char *env_h5_drvr) TEST_ERROR; - /* Test setting a page buffer without Paged Aggregation enabled - - * should fail + /* Test setting a page buffer without Paged Aggregation enabled - + * should fail */ if(H5Pset_page_buffer_size(fapl, 512, 0, 0) < 0) TEST_ERROR; @@ -411,8 +416,8 @@ test_args(hid_t orig_fapl, const char *env_h5_drvr) TEST_ERROR; - /* Test setting a page buffer with a size smaller than a single - * page size - should fail + /* Test setting a page buffer with a size smaller than a single + * page size - should fail */ if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 0, (hsize_t)1) < 0) TEST_ERROR; @@ -431,8 +436,8 @@ test_args(hid_t orig_fapl, const char *env_h5_drvr) TEST_ERROR; - /* Test setting a page buffer with sum of min meta and raw - * data percentage > 100 - should fail + /* Test setting a page buffer with sum of min meta and raw + * data percentage > 100 - should fail */ H5E_BEGIN_TRY { ret = H5Pset_page_buffer_size(fapl, 512, 50, 51); @@ -461,8 +466,8 @@ test_args(hid_t orig_fapl, const char *env_h5_drvr) TEST_ERROR; - /* Test setting a page buffer with a size slightly larger than a - * single page size + /* Test setting a page buffer with a size slightly larger than a + * single page size */ if(H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_PAGE, 0, (hsize_t)1) < 0) TEST_ERROR; @@ -522,7 +527,7 @@ test_args(hid_t orig_fapl, const char *env_h5_drvr) if(H5Pclose(fapl) < 0) FAIL_STACK_ERROR; - PASSED() + PASSED(); return 0; error: @@ -548,14 +553,14 @@ error: * * 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 + * 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 + * any such change is not indicative of other issues, these * tests can be modified to reflect the change. * * JRM -- 2/23/17 @@ -608,7 +613,7 @@ test_raw_data_handling(hid_t orig_fapl, const char *env_h5_drvr) 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 + * Get the number of pages inserted, and verify that it is the * the expected value. */ base_page_cnt = H5SL_count(f->shared->page_buf->slist_ptr); @@ -688,8 +693,8 @@ test_raw_data_handling(hid_t orig_fapl, const char *env_h5_drvr) if(H5SL_count(f->shared->page_buf->slist_ptr) != 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 + /* 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; @@ -739,7 +744,7 @@ test_raw_data_handling(hid_t orig_fapl, const char *env_h5_drvr) } /* 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 + * 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; @@ -754,7 +759,7 @@ test_raw_data_handling(hid_t orig_fapl, const char *env_h5_drvr) /* 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). + * existing). */ for(i=0 ; i<1000 ; i++) data[i] = 0; @@ -796,7 +801,7 @@ test_raw_data_handling(hid_t orig_fapl, const char *env_h5_drvr) FAIL_STACK_ERROR; HDfree(data); - PASSED() + PASSED(); return 0; error: @@ -825,14 +830,14 @@ error: * * 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 + * 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 + * any such change is not indicative of other issues, these * tests can be modified to reflect the change. * * JRM -- 2/23/17 @@ -891,7 +896,7 @@ test_lru_processing(hid_t orig_fapl, const char *env_h5_drvr) 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 + * Get the number of pages inserted, and verify that it is the * the expected value. */ base_page_cnt = H5SL_count(f->shared->page_buf->slist_ptr); @@ -911,7 +916,7 @@ test_lru_processing(hid_t orig_fapl, const char *env_h5_drvr) /* update the first 100 elements to have values 0-99 - this will be * a page buffer update with 1 page resulting in the page - * buffer. + * buffer. */ for(i=0 ; i<100 ; i++) data[i] = i; @@ -925,7 +930,7 @@ test_lru_processing(hid_t orig_fapl, const char *env_h5_drvr) TEST_ERROR; /* update elements 300 - 450, with values 300 - 449 - this will - * bring two pages into the page buffer and evict 0. + * bring two pages into the page buffer and evict 0. */ for(i=0 ; i<150 ; i++) data[i] = i+300; @@ -1049,7 +1054,7 @@ test_lru_processing(hid_t orig_fapl, const char *env_h5_drvr) FAIL_STACK_ERROR; HDfree(data); - PASSED() + PASSED(); return 0; error: @@ -1067,7 +1072,7 @@ error: /*------------------------------------------------------------------------- * Function: test_min_threshold() * - * Purpose: Tests verifying observation of minimum and maximum + * Purpose: Tests verifying observation of minimum and maximum * raw and metadata page counts in the page buffer. * * Any data mis-matches or failures reported by the HDF5 @@ -1078,16 +1083,16 @@ error: * * Programmer: unknown * ?? / ?? / ?? - * + * * Changes: Added the base_raw_cnt and base_meta_cnt fields and - * supporting code. This allows the test to adjust to the - * number of page buffer pages accessed during file open / + * supporting code. This allows the test to adjust to the + * number of page buffer pages accessed during file open / * create. * * The tests for the values of base_raw_cnt and base_meta_cnt - * just after file open exist detect changes in library - * behavior. Assuming any such change is not indicative of - * other issues, these tests can be modified to reflect the + * just after file open exist 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 @@ -1179,7 +1184,7 @@ test_min_threshold(hid_t orig_fapl, const char *env_h5_drvr) if(HADDR_UNDEF == (raw_addr = H5MF_alloc(f, H5FD_MEM_DRAW, sizeof(int)*(size_t)num_elements))) FAIL_STACK_ERROR; - /* write all raw data, this would end up in page buffer since there + /* write all raw data, this would end up in page buffer since there * is no metadata yet * * Not necessarily -- opening the file may may load a metadata page. @@ -1237,7 +1242,7 @@ test_min_threshold(hid_t orig_fapl, const char *env_h5_drvr) /* write and read more raw data and make sure that they don't end up in * page buffer since the minimum metadata is actually the entire - * page buffer + * page buffer */ if(H5F_block_write(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*200), sizeof(int)*100, data) < 0) FAIL_STACK_ERROR; @@ -1313,7 +1318,7 @@ test_min_threshold(hid_t orig_fapl, const char *env_h5_drvr) if(HADDR_UNDEF == (raw_addr = H5MF_alloc(f, H5FD_MEM_DRAW, sizeof(int)*(size_t)num_elements))) TEST_ERROR; - /* write all meta data, this would end up in page buffer since there + /* write all meta data, this would end up in page buffer since there * is no raw data yet */ for(i=0 ; i<100 ; i++) @@ -1368,7 +1373,7 @@ test_min_threshold(hid_t orig_fapl, const char *env_h5_drvr) /* write and read more meta data and make sure that they don't end up in * page buffer since the minimum metadata is actually the entire - * page buffer + * page buffer */ if(H5F_block_write(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*100), sizeof(int)*50, data) < 0) FAIL_STACK_ERROR; @@ -1400,8 +1405,8 @@ test_min_threshold(hid_t orig_fapl, const char *env_h5_drvr) HDprintf("\tMinimum metadata threshold = 40%%, Minimum rawdata threshold = 40%%\n"); page_count = 0; - /* keep 5 pages at max in the page buffer 2 meta pages, 2 raw pages - * minimum + /* keep 5 pages at max in the page buffer 2 meta pages, 2 raw pages + * minimum */ if(H5Pset_page_buffer_size(fapl, sizeof(int)*1000, 40, 40) < 0) TEST_ERROR; @@ -1416,8 +1421,8 @@ test_min_threshold(hid_t orig_fapl, const char *env_h5_drvr) /* opening the file inserts one or more pages into the page buffer. * - * However, with the current 1 metadata page inserted into the - * the page buffer, it is not necessary to track the base raw and + * However, with the current 1 metadata page inserted into the + * the page buffer, it is not necessary to track the base raw and * metadata entry counts. */ @@ -1496,8 +1501,8 @@ test_min_threshold(hid_t orig_fapl, const char *env_h5_drvr) if(f->shared->page_buf->raw_count != 2) TEST_ERROR; - /* adding more meta entires should replace meta entries since raw data - * is at its minimum + /* adding more meta entires should replace meta entries since raw data + * is at its minimum */ if(H5F_block_write(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*600), sizeof(int)*100, data) < 0) FAIL_STACK_ERROR; @@ -1515,8 +1520,8 @@ test_min_threshold(hid_t orig_fapl, const char *env_h5_drvr) if(H5F_block_read(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*750), sizeof(int)*100, data) < 0) FAIL_STACK_ERROR; - /* adding 2 raw entries (even with 1 call) should only evict 1 meta - * entry and another raw entry + /* adding 2 raw entries (even with 1 call) should only evict 1 meta + * entry and another raw entry */ if(H5F_block_read(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*350), sizeof(int)*100, data) < 0) FAIL_STACK_ERROR; @@ -1640,8 +1645,8 @@ test_min_threshold(hid_t orig_fapl, const char *env_h5_drvr) if(f->shared->page_buf->raw_count != 4) TEST_ERROR; - /* write one more raw entry which should replace another raw entry - * keeping min threshold of meta entries + /* write one more raw entry which should replace another raw entry + * keeping min threshold of meta entries */ if(H5F_block_write(f, H5FD_MEM_DRAW, raw_addr+(sizeof(int)*300), sizeof(int)*100, data) < 0) FAIL_STACK_ERROR; @@ -1655,8 +1660,8 @@ test_min_threshold(hid_t orig_fapl, const char *env_h5_drvr) if(f->shared->page_buf->raw_count != 4) TEST_ERROR; - /* write a metadata entry that should replace the metadata entry - * at the bottom of the LRU + /* write a metadata entry that should replace the metadata entry + * at the bottom of the LRU */ if(H5F_block_write(f, H5FD_MEM_SUPER, meta_addr+(sizeof(int)*500), sizeof(int)*100, data) < 0) FAIL_STACK_ERROR; @@ -1681,7 +1686,7 @@ test_min_threshold(hid_t orig_fapl, const char *env_h5_drvr) HDfree(data); - PASSED() + PASSED(); return 0; @@ -1714,16 +1719,16 @@ error: * * Programmer: unknown * ?? / ?? / ?? - * + * * Changes: Added the base_raw_cnt and base_meta_cnt fields and - * supporting code. This allows the test to adjust to the - * number of page buffer pages accessed during file open / + * supporting code. This allows the test to adjust to the + * number of page buffer pages accessed during file open / * create. * * The tests for the values of base_raw_cnt and base_meta_cnt - * just after file open exist detect changes in library - * behavior. Assuming any such change is not indicative of - * other issues, these tests can be modified to reflect the + * just after file open exist 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 @@ -1780,7 +1785,7 @@ test_stats_collection(hid_t orig_fapl, const char *env_h5_drvr) FAIL_STACK_ERROR; /* opening the file inserts one or more pages into the page buffer. - * Get the raw and meta counts now, so we can adjust the expected + * Get the raw and meta counts now, so we can adjust the expected * statistics accordingly. */ HDassert(f); @@ -1987,7 +1992,7 @@ test_stats_collection(hid_t orig_fapl, const char *env_h5_drvr) HDfree(data); - PASSED() + PASSED(); return 0; error: @@ -2001,12 +2006,13 @@ error: return 1; } /* test_stats_collection */ +#endif /* #ifndef H5_HAVE_PARALLEL */ /*------------------------------------------------------------------------- * Function: verify_page_buffering_disabled() * - * Purpose: This function should only be called in parallel + * Purpose: This function should only be called in parallel * builds. * * At present, page buffering should be disabled in parallel @@ -2017,7 +2023,7 @@ error: * * Programmer: John Mainzer * 03/21/17 - * + * * Changes: None. * *------------------------------------------------------------------------- @@ -2064,7 +2070,7 @@ verify_page_buffering_disabled(hid_t orig_fapl, const char *env_h5_drvr) if(file_id >= 0) TEST_ERROR; - /* now, create a file, close it, and then try to open it with page + /* now, create a file, close it, and then try to open it with page * buffering enabled. */ if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) @@ -2084,7 +2090,7 @@ verify_page_buffering_disabled(hid_t orig_fapl, const char *env_h5_drvr) if(H5Fclose(file_id) < 0) FAIL_STACK_ERROR; - /* try to open the file using the fapl prepared above which enables + /* try to open the file using the fapl prepared above which enables * page buffering. Should fail. */ H5E_BEGIN_TRY { @@ -2100,7 +2106,7 @@ verify_page_buffering_disabled(hid_t orig_fapl, const char *env_h5_drvr) if(H5Pclose(fapl) < 0) FAIL_STACK_ERROR; - PASSED() + PASSED(); return 0; @@ -2150,7 +2156,7 @@ main(void) * Page buffering depends on paged aggregation which is * currently disabled for multi/split drivers. */ - if((0 == HDstrcmp(env_h5_drvr, "multi")) || + if((0 == HDstrcmp(env_h5_drvr, "multi")) || (0 == HDstrcmp(env_h5_drvr, "split"))) { SKIPPED() @@ -2167,7 +2173,7 @@ main(void) if(H5CX_push() < 0) FAIL_STACK_ERROR api_ctx_pushed = TRUE; -#ifdef H5_HAVE_PARALLEL +#ifdef H5_HAVE_PARALLEL HDputs("Page Buffering is disabled for parallel."); nerrors += verify_page_buffering_disabled(fapl, env_h5_drvr); diff --git a/test/swmr_addrem_writer.c b/test/swmr_addrem_writer.c index df984b1..71e4929 100644 --- a/test/swmr_addrem_writer.c +++ b/test/swmr_addrem_writer.c @@ -337,7 +337,7 @@ int main(int argc, const char *argv[]) verbose = 0; u++; break; - + /* Random # seed */ case 'r': use_seed = 1; diff --git a/test/swmr_check_compat_vfd.c b/test/swmr_check_compat_vfd.c index 1589f6e..03dd1b7 100644 --- a/test/swmr_check_compat_vfd.c +++ b/test/swmr_check_compat_vfd.c @@ -13,7 +13,7 @@ /* Purpose: This is a small program that checks if the HDF5_DRIVER * environment variable is set to a value that supports SWMR. - * + * * It is intended for use in shell scripts. */ diff --git a/test/swmr_common.c b/test/swmr_common.c index b323769..7ae1fad 100644 --- a/test/swmr_common.c +++ b/test/swmr_common.c @@ -26,6 +26,7 @@ #include "h5test.h" #include "swmr_common.h" +#include "vds_swmr.h" /*******************/ /* Local Variables */ @@ -73,6 +74,27 @@ unsigned symbol_count[NLEVELS] = {100, 200, 400, 800, 1600}; /* Array of dataset information entries (1 per dataset) */ symbol_info_t *symbol_info[NLEVELS]; +hsize_t PLANES[N_SOURCES][RANK] = { + {1, SM_HEIGHT, WIDTH}, + {1, LG_HEIGHT, WIDTH}, + {1, SM_HEIGHT, WIDTH}, + {1, LG_HEIGHT, WIDTH}, + {1, SM_HEIGHT, WIDTH}, + {1, LG_HEIGHT, WIDTH} +}; + +char FILE_NAMES[N_SOURCES][NAME_LEN] = { + {"vds_swmr_src_a.h5"}, + {"vds_swmr_src_b.h5"}, + {"vds_swmr_src_c.h5"}, + {"vds_swmr_src_d.h5"}, + {"vds_swmr_src_e.h5"}, + {"vds_swmr_src_f.h5"} +}; + +char VDS_FILE_NAME[NAME_LEN] = "vds_swmr.h5"; +char SOURCE_DSET_PATH[NAME_LEN] = "/source_dset"; +char VDS_DSET_NAME[NAME_LEN] = "vds_dset"; /*------------------------------------------------------------------------- * Function: choose_dataset diff --git a/test/swmr_common.h b/test/swmr_common.h index 99d1cb2..a0bc581 100644 --- a/test/swmr_common.h +++ b/test/swmr_common.h @@ -26,7 +26,7 @@ #define NLEVELS 5 /* # of datasets in the SWMR test file */ -#define NMAPPING 9 +#define NMAPPING 9 #define FILENAME "swmr_data.h5" /* SWMR test file name */ #define DTYPE_SIZE 150 /* Data size in opaque type */ diff --git a/test/swmr_generator.c b/test/swmr_generator.c index 1e00f1d..c3b01fa 100644 --- a/test/swmr_generator.c +++ b/test/swmr_generator.c @@ -358,7 +358,7 @@ int main(int argc, const char *argv[]) HDfprintf(stderr, "\tcompression level = %d\n", comp_level); HDfprintf(stderr, "\tindex type = %s\n", index_type); } /* end if */ - + /* Set the random seed */ if(!use_seed) { struct timeval t; diff --git a/test/swmr_reader.c b/test/swmr_reader.c index cb354a7..ee263e3 100644 --- a/test/swmr_reader.c +++ b/test/swmr_reader.c @@ -329,7 +329,7 @@ read_records(const char *filename, hbool_t verbose, FILE *verbose_file, /* Emit informational message */ if(verbose) HDfprintf(verbose_file, "Closing file\n"); - + /* Close the file */ if(H5Fclose(fid) < 0) return -1; diff --git a/test/swmr_remove_reader.c b/test/swmr_remove_reader.c index 9ca6045..b02d16f 100644 --- a/test/swmr_remove_reader.c +++ b/test/swmr_remove_reader.c @@ -371,7 +371,7 @@ usage(void) HDprintf("and will generate a random seed (no -r given).\n"); HDprintf("\n"); HDexit(EXIT_FAILURE); -} +} int main(int argc, const char *argv[]) { diff --git a/test/swmr_remove_writer.c b/test/swmr_remove_writer.c index e6d23de..2bebab9 100644 --- a/test/swmr_remove_writer.c +++ b/test/swmr_remove_writer.c @@ -272,7 +272,7 @@ int main(int argc, const char *argv[]) verbose = 0; u++; break; - + /* Random # seed */ case 'r': use_seed = 1; diff --git a/test/swmr_sparse_reader.c b/test/swmr_sparse_reader.c index f190777..2d558df 100644 --- a/test/swmr_sparse_reader.c +++ b/test/swmr_sparse_reader.c @@ -162,7 +162,7 @@ check_dataset(hid_t fid, unsigned verbose, const symbol_info_t *symbol, symbol_t * The amount of time to sleep (s). * * unsigned reopen_count - * + * * * Return: Success: 0 * Failure: -1 @@ -185,7 +185,7 @@ read_records(const char *filename, unsigned verbose, unsigned long nrecords, HDassert(filename); HDassert(poll_time != 0); - + /* Create file access property list */ if((fapl = h5_fileaccess()) < 0) return -1; diff --git a/test/swmr_start_write.c b/test/swmr_start_write.c index c4222ad..fc7e7a5 100644 --- a/test/swmr_start_write.c +++ b/test/swmr_start_write.c @@ -53,11 +53,11 @@ static void usage(void); * Purpose: Creates the HDF5 file (without SWMR access) which * which will be used for testing H5Fstart_swmr_write(). * - * Parameters: + * Parameters: * filename: The SWMR test file's name. * verbose: whether verbose console output is desired. * verbose_file: file pointer for verbose output - * random_seed: The random seed to store in the file. + * random_seed: The random seed to store in the file. * The sparse tests use this value. * * Return: Success: the file ID @@ -134,10 +134,10 @@ create_file(const char *filename, hbool_t verbose, FILE *verbose_file, /*------------------------------------------------------------------------- * Function: create_datasets * - * Purpose: Create datasets (and keep them opened) which will be used for testing + * Purpose: Create datasets (and keep them opened) which will be used for testing * H5Fstart_swmr_write(). * - * Parameters: + * Parameters: * fid: file ID for the SWMR test file * comp_level: the compresssion level * index_type: The chunk index type (b1 | b2 | ea | fa) @@ -212,7 +212,7 @@ create_datasets(hid_t fid, int comp_level, hbool_t verbose, FILE *verbose_file, * Purpose: Writes a specified number of records to random datasets in * the SWMR test file. * - * Parameters: + * Parameters: * fid: The file ID of the SWMR HDF5 file * verbose: Whether or not to emit verbose console messages * verbose_file: file pointer for verbose output @@ -419,7 +419,7 @@ int main(int argc, const char *argv[]) verbose = FALSE; u++; break; - + /* Random # seed */ case 'r': use_seed = TRUE; diff --git a/test/swmr_writer.c b/test/swmr_writer.c index 4c3e64a..d4387aa 100644 --- a/test/swmr_writer.c +++ b/test/swmr_writer.c @@ -328,7 +328,7 @@ int main(int argc, const char *argv[]) verbose = FALSE; u++; break; - + /* Random # seed */ case 'r': use_seed = TRUE; diff --git a/test/unlink.c b/test/unlink.c index 6825dec..89c59c3 100644 --- a/test/unlink.c +++ b/test/unlink.c @@ -433,15 +433,15 @@ test_new_move(hid_t fapl) static int check_new_move(hid_t fapl) { - hid_t file; - H5O_info_t oi_hard1, oi_hard2; - char filename[1024]; - char linkval[1024]; + H5O_info_t oi_hard1, oi_hard2; + hid_t file; + char filename[1024]; + char linkval[1024]; 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") @@ -2156,7 +2156,7 @@ test_full_group_compact(hid_t fapl) { hid_t file_id = -1; hid_t gid = -1, gid2 = -1; /* Group IDs */ - H5O_info_t oi; /* Stat buffer for object */ + H5O_info_t oi; /* Stat buffer for object */ char objname[128]; /* Buffer for name of objects to create */ char objname2[128]; /* Buffer for name of objects to create */ char filename[1024]; /* Buffer for filename */ @@ -2290,7 +2290,7 @@ test_full_group_dense(hid_t fapl) hid_t file_id = -1; hid_t gcpl = (-1); /* Group creation property list ID */ hid_t gid = -1, gid2 = -1; /* Group IDs */ - H5O_info_t oi; /* Stat buffer for object */ + H5O_info_t oi; /* Stat buffer for object */ char objname[128]; /* Buffer for name of objects to create */ char objname2[128]; /* Buffer for name of objects to create */ char filename[1024]; /* Buffer for filename */ diff --git a/test/unregister.c b/test/unregister.c index ff116cf..a2a507d 100644 --- a/test/unregister.c +++ b/test/unregister.c @@ -55,7 +55,7 @@ const H5Z_class2_t H5Z_DUMMY[1] = {{ * Function: do_nothing * * Purpose: A dummy compression method that doesn't do anything. This - * filter is only for test_unregister_filters. Please don't + * filter is only for test_unregister_filters. Please don't * use it for other tests because it may mess up this test. * * Return: Data chunk size @@ -95,11 +95,20 @@ test_unregister_filters(hid_t fapl_id) char filename[FILENAME_BUF_SIZE]; const hsize_t chunk_dims[2] = {FILTER_CHUNK_DIM1, FILTER_CHUNK_DIM2}; /* Chunk dimensions */ hsize_t dims[2]; - int data[DSET_DIM1][DSET_DIM2]; + int **buf = NULL; + int *buf_data = NULL; herr_t ret; TESTING("Unregistering filter"); + /* Set up data array */ + if(NULL == (buf_data = (int *)HDcalloc(DSET_DIM1 * DSET_DIM2, sizeof(int)))) + TEST_ERROR; + if(NULL == (buf = (int **)HDcalloc(DSET_DIM1, sizeof(buf_data)))) + TEST_ERROR; + for (i = 0; i < DSET_DIM1; i++) + buf[i] = buf_data + (i * DSET_DIM2); + /* Create first file */ h5_fixname(FILENAME[0], fapl_id, filename, sizeof(filename)); if((fid1 = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) @@ -115,12 +124,12 @@ test_unregister_filters(hid_t fapl_id) goto error; if (H5Zfilter_avail(H5Z_FILTER_DUMMY) != TRUE) goto error; - + /******************* * PART 1 - GROUPS * *******************/ - /* Use DUMMY filter for creating groups */ + /* Use DUMMY filter for creating groups */ if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) goto error; if(H5Pset_filter(gcpl_id, H5Z_FILTER_DUMMY, H5Z_FLAG_MANDATORY, (size_t)0, NULL) < 0) @@ -136,7 +145,7 @@ test_unregister_filters(hid_t fapl_id) if((gid_loop = H5Gcreate2(gid, group_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; if(H5Gclose(gid_loop) < 0) - goto error; + goto error; } /* Flush the file containing the groups */ @@ -165,7 +174,7 @@ test_unregister_filters(hid_t fapl_id) * PART 2 - DATASETS * *********************/ - /* Use DUMMY filter for creating datasets */ + /* Use DUMMY filter for creating datasets */ if((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; if(H5Pset_chunk(dcpl_id, 2, chunk_dims) < 0) @@ -176,7 +185,7 @@ test_unregister_filters(hid_t fapl_id) /* Initialize the data for writing */ for(i = n = 0; i < DSET_DIM1; i++) for(j = 0; j < DSET_DIM2; j++) - data[i][j] = n++; + buf[i][j] = n++; /* Create the dataspace */ dims[0] = DSET_DIM1; @@ -189,7 +198,7 @@ test_unregister_filters(hid_t fapl_id) goto error; /* Write the data to the dataset */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) < 0) goto error; /* Unregister the filter before closing the dataset. It should fail */ @@ -211,14 +220,14 @@ test_unregister_filters(hid_t fapl_id) goto error; /* Write the data to the dataset */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) + if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) < 0) goto error; /* Close the dataset in the second file */ if(H5Dclose(did) < 0) goto error; - /* Unregister the filter after closing all objects but before closing files. + /* Unregister the filter after closing all objects but before closing files. * It should flush all files. */ if(H5Zunregister(H5Z_FILTER_DUMMY) < 0) @@ -232,6 +241,9 @@ test_unregister_filters(hid_t fapl_id) if(H5Fclose(fid2) < 0) goto error; + HDfree(buf); + HDfree(buf_data); + PASSED(); return SUCCEED; @@ -247,6 +259,9 @@ error: H5Sclose(sid); } H5E_END_TRY; + HDfree(buf); + HDfree(buf_data); + return FAIL; } @@ -16,48 +16,46 @@ #include "h5test.h" /* Macro definitions */ -#define Hgoto_error(val) {ret_value=val; goto done;} -#define Hgoto_done {goto done;} -#define Chunksize_DFT 256 /* chunksize default */ -#define ErrorReportMax 10 /* max number of errors reported */ +#define Hgoto_error(val) {ret_value=val; goto done;} +#define Hgoto_done {goto done;} +#define Chunksize_DFT 256 /* chunksize default */ +#define ErrorReportMax 10 /* max number of errors reported */ /* these two definitions must match each other */ -#define UC_DATATYPE H5T_NATIVE_SHORT /* use case HDF5 data type */ -#define UC_CTYPE short /* use case C data type */ -#define UC_RANK 3 /* use case dataset rank */ +#define UC_DATATYPE H5T_NATIVE_SHORT /* use case HDF5 data type */ +#define UC_CTYPE short /* use case C data type */ +#define UC_RANK 3 /* use case dataset rank */ /* Name of message file that is sent by the writer */ #define WRITER_MESSAGE "USE_WRITER_MESSAGE" /* type declarations */ typedef enum part_t { - UC_READWRITE =0, /* both writer and reader */ - UC_WRITER, /* writer only */ - UC_READER /* reader only */ + UC_READWRITE = 0, /* both writer and reader */ + UC_WRITER, /* writer only */ + UC_READER /* reader only */ } part_t; typedef struct options_t { - hsize_t chunksize; /* chunks are chunksize^2 planes */ - hsize_t chunkplanes; /* number of planes per chunk, default 1 */ + hsize_t chunksize; /* chunks are chunksize^2 planes */ + hsize_t chunkplanes; /* number of planes per chunk, default 1 */ hsize_t chunkdims[UC_RANK]; /* chunk dims is (chunkplan, chunksize, chunksize) */ hsize_t dims[UC_RANK]; /* dataset initial dims */ hsize_t max_dims[UC_RANK]; /* dataset max dims */ - hsize_t nplanes; /* number of planes to write, default proportional to chunksize */ - char *filename; /* use case data filename */ - part_t launch; /* launch writer, reader or both */ - hbool_t use_swmr; /* use swmr open (1) or not */ - int iterations; /* iterations, default 1 */ + hsize_t nplanes; /* number of planes to write, default proportional to chunksize */ + char *filename; /* use case data filename */ + part_t launch; /* launch writer, reader or both */ + hbool_t use_swmr; /* use swmr open (1) or not */ + int iterations; /* iterations, default 1 */ + hid_t fapl_id; /* instance-specific FAPL ID */ + const char *progname; /* Program name (used in usage and dset name) */ } options_t; -/* global variables declarations */ -extern options_t UC_opts; /* Use Case Options */ -extern const char *progname_g; /* Program name */ - /* prototype declarations */ -int parse_option(int argc, char * const argv[]); -int setup_parameters(int argc, char * const argv[]); -void show_parameters(void); +int parse_option(int argc, char * const argv[], options_t * opts); +int setup_parameters(int argc, char * const argv[], options_t * opts); +void show_parameters(options_t * opts); void usage(const char *prog); -int create_uc_file(void); -int write_uc_file(hbool_t tosend, hid_t fid); -int read_uc_file(hbool_t towait); +int create_uc_file(options_t * opts); +int write_uc_file(hbool_t tosend, hid_t file_id, options_t * opts); +int read_uc_file(hbool_t towait, options_t * opts); diff --git a/test/use_append_chunk.c b/test/use_append_chunk.c index 6b34f1e..8fcf0d3 100644 --- a/test/use_append_chunk.c +++ b/test/use_append_chunk.c @@ -11,7 +11,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Use Case 1.7 Appending a single chunk + * Use Case 1.7 Appending a single chunk * Description: * Appending a single chunk of raw data to a dataset along an unlimited * dimension within a pre-created file and reading the new data back. @@ -24,35 +24,36 @@ * Level: * User Level * Guarantees: - * o Readers will see the modified dimension sizes after the Writer - * finishes HDF5 metadata updates and issues H5Fflush or H5Oflush calls. - * o Readers will see newly appended data after the Writer finishes - * the flush operation. - * + * o Readers will see the modified dimension sizes after the Writer + * finishes HDF5 metadata updates and issues H5Fflush or H5Oflush calls. + * o Readers will see newly appended data after the Writer finishes + * the flush operation. + * * Preconditions: - * o Readers are not allowed to modify the file. o All datasets - * that are modified by the Writer exist when the Writer opens the file. - * o All datasets that are modified by the Writer exist when a Reader - * opens the file. o Data is written by a hyperslab contained in - * one chunk. - * + * o Readers are not allowed to modify the file. + * o All datasets that are modified by the Writer exist when the Writer + * opens the file. + * o All datasets that are modified by the Writer exist when a Reader + * opens the file. + * o Data is written by a hyperslab contained in one chunk. + * * Main Success Scenario: - * 1. An application creates a file with required objects (groups, - * datasets, and attributes). - * 2. The Writer application opens the file and datasets in the file - * and starts adding data along the unlimited dimension using a hyperslab - * selection that corresponds to an HDF5 chunk. - * 3. A Reader opens the file and a dataset in a file, and queries - * the sizes of the dataset; if the extent of the dataset has changed, - * reads the appended data back. - * + * 1. An application creates a file with required objects (groups, + * datasets, and attributes). + * 2. The Writer application opens the file and datasets in the file + * and starts adding data along the unlimited dimension using a hyperslab + * selection that corresponds to an HDF5 chunk. + * 3. A Reader opens the file and a dataset in a file, and queries + * the sizes of the dataset; if the extent of the dataset has changed, + * reads the appended data back. + * * Discussion points: - * 1. Since the new data is written to the file, and metadata update - * operation of adding pointer to the newly written chunk is atomic and - * happens after the chunk is on the disk, only two things may happen - * to the Reader: - * o The Reader will not see new data. - * o The Reader will see all new data written by Writer. + * 1. Since the new data is written to the file, and metadata update + * operation of adding pointer to the newly written chunk is atomic and + * happens after the chunk is on the disk, only two things may happen + * to the Reader: + * o The Reader will not see new data. + * o The Reader will see all new data written by Writer. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* Created: Albert Cheng, 2013/5/28 */ @@ -68,46 +69,43 @@ #include "use.h" -/* Global Variable definitions */ -options_t UC_opts; /* Use Case Options */ -const char *progname_g="use_append_chunk"; /* program name */ +#define USE_APPEND_CHUNK_PROGNAME "use_append_chunk" + +static options_t UC_opts; /* Use Case Options */ /* Setup parameters for the use case. * Return: 0 succeed; -1 fail. */ -int setup_parameters(int argc, char * const argv[]) +int +setup_parameters(int argc, char * const argv[], options_t * opts) { /* use case defaults */ - HDmemset(&UC_opts, 0, sizeof(options_t)); - UC_opts.chunksize = Chunksize_DFT; - UC_opts.use_swmr = TRUE; /* use swmr open */ - UC_opts.iterations = 1; - UC_opts.chunkplanes = 1; - - /* parse options */ - if (parse_option(argc, argv) < 0) - return(-1); - - /* set chunk dims */ - UC_opts.chunkdims[0] = UC_opts.chunkplanes; - UC_opts.chunkdims[1] = UC_opts.chunkdims[2] = UC_opts.chunksize; - - /* set dataset initial and max dims */ - UC_opts.dims[0] = 0; - UC_opts.max_dims[0] = H5S_UNLIMITED; - UC_opts.dims[1] = UC_opts.dims[2] = UC_opts.max_dims[1] = UC_opts.max_dims[2] = UC_opts.chunksize; - - /* set nplanes */ - if (UC_opts.nplanes == 0) - UC_opts.nplanes = (hsize_t)UC_opts.chunksize; - - /* show parameters and return */ - show_parameters(); + HDmemset(opts, 0, sizeof(options_t)); + opts->chunksize = Chunksize_DFT; + opts->use_swmr = TRUE; /* use swmr open */ + opts->iterations = 1; + opts->chunkplanes = 1; + opts->progname = USE_APPEND_CHUNK_PROGNAME; + + if (parse_option(argc, argv, opts) < 0) + return(-1); + + opts->chunkdims[0] = opts->chunkplanes; + opts->chunkdims[1] = opts->chunkdims[2] = opts->chunksize; + + opts->dims[0] = 0; + opts->max_dims[0] = H5S_UNLIMITED; + opts->dims[1] = opts->dims[2] = opts->max_dims[1] = opts->max_dims[2] = opts->chunksize; + + if (opts->nplanes == 0) + opts->nplanes = (hsize_t)opts->chunksize; + + show_parameters(opts); return(0); -} +} /* setup_parameters() */ -/* Overall Algorithm: +/* Overall Algorithm: * Parse options from user; * Generate/pre-created test files needed and close it; * fork: child process becomes the reader process; @@ -119,22 +117,20 @@ main(int argc, char *argv[]) { pid_t childpid=0; pid_t mypid, tmppid; - int child_status; + int child_status; int child_wait_option=0; int ret_value = 0; int child_ret_value; hbool_t send_wait = FALSE; hid_t fapl = -1; /* File access property list */ hid_t fid = -1; /* File ID */ - char *name; /* Test file name */ - /* initialization */ - if (setup_parameters(argc, argv) < 0){ + if (setup_parameters(argc, argv, &UC_opts) < 0) { Hgoto_error(1); } /* Determine the need to send/wait message file*/ - if(UC_opts.launch == UC_READWRITE) { + if (UC_opts.launch == UC_READWRITE) { HDunlink(WRITER_MESSAGE); send_wait = TRUE; } @@ -144,38 +140,63 @@ main(int argc, char *argv[]) /* UC_WRITER: create datafile, skip reader, launch writer. */ /* UC_READER: skip create, launch reader, exit. */ /* ==============================================================*/ - /* ============*/ + /* =========== */ /* Create file */ - /* ============*/ - if (UC_opts.launch != UC_READER){ + /* =========== */ + if (UC_opts.launch != UC_READER) { HDprintf("Creating skeleton data file for test...\n"); - if (create_uc_file() < 0){ + if ((UC_opts.fapl_id = h5_fileaccess()) < 0) { + HDfprintf(stderr, "can't create creation FAPL\n"); + Hgoto_error(1); + } + if (H5Pset_libver_bounds(UC_opts.fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) { + HDfprintf(stderr, "can't set creation FAPL libver bounds\n"); + Hgoto_error(1); + } + if (create_uc_file(&UC_opts) < 0) { HDfprintf(stderr, "***encounter error\n"); Hgoto_error(1); - }else + } else { HDprintf("File created.\n"); + } + /* Close FAPL to prevent issues with forking later */ + if (H5Pclose(UC_opts.fapl_id) < 0) { + HDfprintf(stderr, "can't close creation FAPL\n"); + Hgoto_error(1); + } + UC_opts.fapl_id = H5I_INVALID_HID; } - if (UC_opts.launch==UC_READWRITE){ - /* fork process */ - if((childpid = HDfork()) < 0) { + /* ============ */ + /* Fork process */ + /* ============ */ + if (UC_opts.launch == UC_READWRITE) { + if ((childpid = HDfork()) < 0) { HDperror("fork"); Hgoto_error(1); - }; - }; + } + } mypid = HDgetpid(); /* ============= */ /* launch reader */ /* ============= */ - if (UC_opts.launch != UC_WRITER){ + if (UC_opts.launch != UC_WRITER) { /* child process launch the reader */ - if(0 == childpid) { + if (0 == childpid) { HDprintf("%d: launch reader process\n", mypid); - if (read_uc_file(send_wait) < 0){ + if ((UC_opts.fapl_id = h5_fileaccess()) < 0) { + HDfprintf(stderr, "can't create read FAPL\n"); + HDexit(EXIT_FAILURE); + } + if (read_uc_file(send_wait, &UC_opts) < 0) { HDfprintf(stderr, "read_uc_file encountered error\n"); HDexit(EXIT_FAILURE); } + if (H5Pclose(UC_opts.fapl_id) < 0) { + HDfprintf(stderr, "can't close read FAPL\n"); + HDexit(EXIT_FAILURE); + } HDexit(EXIT_SUCCESS); } } @@ -186,65 +207,63 @@ main(int argc, char *argv[]) /* this process continues to launch the writer */ HDprintf("%d: continue as the writer process\n", mypid); - name = UC_opts.filename; - - /* Set file access proeprty list */ - if((fapl = h5_fileaccess()) < 0) + if ((fapl = h5_fileaccess()) < 0) { + HDfprintf(stderr, "can't create write FAPL\n"); Hgoto_error(1); + } - if(UC_opts.use_swmr) - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (UC_opts.use_swmr) { + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) { + HDfprintf(stderr, "can't set write FAPL libver bounds\n"); Hgoto_error(1); + } + } - /* Open the file */ - if((fid = H5Fopen(name, H5F_ACC_RDWR | (UC_opts.use_swmr ? H5F_ACC_SWMR_WRITE : 0), fapl)) < 0) { + if ((fid = H5Fopen(UC_opts.filename, H5F_ACC_RDWR | (UC_opts.use_swmr ? H5F_ACC_SWMR_WRITE : 0), fapl)) < 0) { HDfprintf(stderr, "H5Fopen failed\n"); Hgoto_error(1); } - if(write_uc_file(send_wait, fid) < 0) { + if (write_uc_file(send_wait, fid, &UC_opts) < 0) { HDfprintf(stderr, "write_uc_file encountered error\n"); Hgoto_error(1); } + if (H5Fclose(fid) < 0) { + HDfprintf(stderr, "Failed to close write\n"); + Hgoto_error(1); + } + + if (H5Pclose(fapl) < 0) { + HDfprintf(stderr, "can't close write FAPL\n"); + Hgoto_error(1); + } + /* ================================================ */ /* If readwrite, collect exit code of child process */ /* ================================================ */ - if (UC_opts.launch == UC_READWRITE){ - if ((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0){ + if (UC_opts.launch == UC_READWRITE) { + if ((tmppid = HDwaitpid(childpid, &child_status, child_wait_option)) < 0) { HDperror("waitpid"); Hgoto_error(1); } - /* Close the file */ - if(H5Fclose(fid) < 0) { - HDfprintf(stderr, "Failed to close file id\n"); - Hgoto_error(1); - } - - /* Close the property list */ - if(H5Pclose(fapl) < 0) { - HDfprintf(stderr, "Failed to close the property list\n"); - Hgoto_error(1); - } - - if (WIFEXITED(child_status)){ - if ((child_ret_value=WEXITSTATUS(child_status)) != 0){ + if (WIFEXITED(child_status)) { + if ((child_ret_value = WEXITSTATUS(child_status)) != 0) { HDprintf("%d: child process exited with non-zero code (%d)\n", mypid, child_ret_value); Hgoto_error(2); } - } else { - HDprintf("%d: child process terminated abnormally\n", mypid); - Hgoto_error(2); - } + } else { + HDprintf("%d: child process terminated abnormally\n", mypid); + Hgoto_error(2); + } } - + done: - /* Print result and exit */ - if (ret_value != 0){ + if (ret_value != 0) { HDprintf("Error(s) encountered\n"); - }else{ + } else { HDprintf("All passed\n"); } diff --git a/test/use_append_mchunks.c b/test/use_append_mchunks.c index b7d45a4..2eb5a1d 100644 --- a/test/use_append_mchunks.c +++ b/test/use_append_mchunks.c @@ -29,14 +29,14 @@ * finishes HDF5 metadata updates and issues H5Fflush or H5Oflush calls. * o Readers will see newly appended data after the Writer finishes * the flush operation. - * + * * Preconditions: * o Readers are not allowed to modify the file. * o All datasets that are modified by the Writer exist when the * Writer opens the file. * o All datasets that are modified by the Writer exist when a Reader * opens the file. - * + * * Main Success Scenario: * 1. An application creates a file with required objects (groups, * datasets, and attributes). @@ -45,7 +45,7 @@ * spans several chunks. * 3. A Reader opens the file and a dataset in a file; if the size of * the unlimited dimension has changed, reads the appended data back. - * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* Created: Albert Cheng, 2013/6/1 */ @@ -61,46 +61,45 @@ #include "use.h" -/* Global Variable definitions */ -options_t UC_opts; /* Use Case Options */ -const char *progname_g="use_append_mchunks"; /* program name */ +#define USE_APPEND_MCHUNKS_PROGNAME "use_append_mchunks" + +static options_t UC_opts; /* Use Case Options */ /* Setup parameters for the use case. * Return: 0 succeed; -1 fail. */ -int setup_parameters(int argc, char * const argv[]) +int +setup_parameters(int argc, char * const argv[], options_t * opts) { /* use case defaults */ - HDmemset(&UC_opts, 0, sizeof(options_t)); - UC_opts.chunksize = Chunksize_DFT; - UC_opts.use_swmr = 1; /* use swmr open */ - UC_opts.iterations = 1; - UC_opts.chunkplanes = 1; - - /* parse options */ - if (parse_option(argc, argv) < 0){ - return(-1); + HDmemset(opts, 0, sizeof(options_t)); + opts->chunksize = Chunksize_DFT; + opts->use_swmr = 1; /* use swmr open */ + opts->iterations = 1; + opts->chunkplanes = 1; + opts->progname = USE_APPEND_MCHUNKS_PROGNAME; + opts->fapl_id = H5I_INVALID_HID; + + if (parse_option(argc, argv, opts) < 0) { + return(-1); } - /* set chunk dims */ - UC_opts.chunkdims[0] = (hsize_t)UC_opts.chunkplanes; - UC_opts.chunkdims[1] = UC_opts.chunkdims[2] = (hsize_t)UC_opts.chunksize; - /* set dataset initial and max dims */ - UC_opts.dims[0] = 0; - UC_opts.max_dims[0] = H5S_UNLIMITED; - UC_opts.dims[1] = UC_opts.dims[2] = UC_opts.max_dims[1] = UC_opts.max_dims[2] = 2 * (hsize_t)UC_opts.chunksize; + opts->chunkdims[0] = (hsize_t)opts->chunkplanes; + opts->chunkdims[1] = opts->chunkdims[2] = (hsize_t)opts->chunksize; + + opts->dims[0] = 0; + opts->max_dims[0] = H5S_UNLIMITED; + opts->dims[1] = opts->dims[2] = opts->max_dims[1] = opts->max_dims[2] = 2 * (hsize_t)opts->chunksize; - /* set nplanes */ - if (UC_opts.nplanes == 0) - UC_opts.nplanes = 2 * (hsize_t)UC_opts.chunksize; + if (opts->nplanes == 0) + opts->nplanes = 2 * (hsize_t)opts->chunksize; - /* show parameters and return */ - show_parameters(); + show_parameters(opts); return(0); -} +} /* end setup_parameters() */ -/* Overall Algorithm: +/* Overall Algorithm: * Parse options from user; * Generate/pre-created test files needed and close it; * fork: child process becomes the reader process; @@ -112,22 +111,20 @@ main(int argc, char *argv[]) { pid_t childpid=0; pid_t mypid, tmppid; - int child_status; + int child_status; int child_wait_option=0; int ret_value = 0; int child_ret_value; hbool_t send_wait = 0; hid_t fapl = -1; /* File access property list */ hid_t fid = -1; /* File ID */ - char *name; /* Test file name */ - /* initialization */ - if (setup_parameters(argc, argv) < 0){ + if (setup_parameters(argc, argv, &UC_opts) < 0) { Hgoto_error(1); } /* Determine the need to send/wait message file*/ - if(UC_opts.launch == UC_READWRITE) { + if (UC_opts.launch == UC_READWRITE) { HDunlink(WRITER_MESSAGE); send_wait = 1; } @@ -137,38 +134,63 @@ main(int argc, char *argv[]) /* UC_WRITER: create datafile, skip reader, launch writer. */ /* UC_READER: skip create, launch reader, exit. */ /* ==============================================================*/ - /* ============*/ + /* =========== */ /* Create file */ - /* ============*/ - if (UC_opts.launch != UC_READER){ + /* =========== */ + if (UC_opts.launch != UC_READER) { HDprintf("Creating skeleton data file for test...\n"); - if (create_uc_file() < 0){ - HDfprintf(stderr, "***encounter error\n"); - Hgoto_error(1); - }else - HDprintf("File created.\n"); + if ((UC_opts.fapl_id = h5_fileaccess()) < 0) { + HDfprintf(stderr, "can't create creation FAPL\n"); + Hgoto_error(1); + } + if (H5Pset_libver_bounds(UC_opts.fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) { + HDfprintf(stderr, "can't set creation FAPL libver bounds\n"); + Hgoto_error(1); + } + if (create_uc_file(&UC_opts) < 0) { + HDfprintf(stderr, "***encounter error\n"); + Hgoto_error(1); + } else { + HDprintf("File created.\n"); + } + /* Close FAPL to prevent issues with forking later */ + if (H5Pclose(UC_opts.fapl_id) < 0) { + HDfprintf(stderr, "can't close creation FAPL\n"); + Hgoto_error(1); + } + UC_opts.fapl_id = H5I_INVALID_HID; } - if (UC_opts.launch==UC_READWRITE){ - /* fork process */ - if((childpid = fork()) < 0) { + /* ============ */ + /* Fork process */ + /* ============ */ + if (UC_opts.launch==UC_READWRITE) { + if ((childpid = fork()) < 0) { perror("fork"); Hgoto_error(1); - }; - }; + } + } mypid = getpid(); /* ============= */ /* launch reader */ /* ============= */ - if (UC_opts.launch != UC_WRITER){ + if (UC_opts.launch != UC_WRITER) { /* child process launch the reader */ - if(0 == childpid) { + if (0 == childpid) { HDprintf("%d: launch reader process\n", mypid); - if (read_uc_file(send_wait) < 0){ + if ((UC_opts.fapl_id = h5_fileaccess()) < 0) { + HDfprintf(stderr, "can't create read FAPL\n"); + HDexit(EXIT_FAILURE); + } + if (read_uc_file(send_wait, &UC_opts) < 0) { HDfprintf(stderr, "read_uc_file encountered error\n"); HDexit(EXIT_FAILURE); } + if (H5Pclose(UC_opts.fapl_id) < 0) { + HDfprintf(stderr, "can't close read FAPL\n"); + HDexit(EXIT_FAILURE); + } HDexit(EXIT_SUCCESS); } } @@ -179,51 +201,50 @@ main(int argc, char *argv[]) /* this process continues to launch the writer */ HDprintf("%d: continue as the writer process\n", mypid); - name = UC_opts.filename; - /* Set the file access property list */ - if((fapl = h5_fileaccess()) < 0) + if ((fapl = h5_fileaccess()) < 0) { + HDfprintf(stderr, "can't get write FAPL\n"); Hgoto_error(1); + } - if(UC_opts.use_swmr) - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + if (UC_opts.use_swmr) { + if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) { + HDfprintf(stderr, "can't set write FAPL libver bounds\n"); Hgoto_error(1); + } + } - /* Open the file */ - if((fid = H5Fopen(name, H5F_ACC_RDWR | (UC_opts.use_swmr ? H5F_ACC_SWMR_WRITE : 0), fapl)) < 0) { + if ((fid = H5Fopen(UC_opts.filename, H5F_ACC_RDWR | (UC_opts.use_swmr ? H5F_ACC_SWMR_WRITE : 0), fapl)) < 0) { HDfprintf(stderr, "H5Fopen failed\n"); Hgoto_error(1); } - if(write_uc_file(send_wait, fid) < 0) { + if (write_uc_file(send_wait, fid, &UC_opts) < 0) { HDfprintf(stderr, "write_uc_file encountered error\n"); Hgoto_error(1); } + if (H5Fclose(fid) < 0) { + HDfprintf(stderr, "Failed to close file id\n"); + Hgoto_error(1); + } + + if (H5Pclose(fapl) < 0) { + HDfprintf(stderr, "can't close write FAPL\n"); + Hgoto_error(1); + } /* ================================================ */ /* If readwrite, collect exit code of child process */ /* ================================================ */ - if (UC_opts.launch == UC_READWRITE){ - if ((tmppid = waitpid(childpid, &child_status, child_wait_option)) < 0){ + if (UC_opts.launch == UC_READWRITE) { + if ((tmppid = waitpid(childpid, &child_status, child_wait_option)) < 0) { perror("waitpid"); Hgoto_error(1); } - /* Close the file */ - if(H5Fclose(fid) < 0) { - HDfprintf(stderr, "Failed to close file id\n"); - Hgoto_error(1); - } - - /* Close the property list */ - if(H5Pclose(fapl) < 0) { - HDfprintf(stderr, "Failed to close the property list\n"); - Hgoto_error(1); - } - - if (WIFEXITED(child_status)){ - if ((child_ret_value=WEXITSTATUS(child_status)) != 0){ + if (WIFEXITED(child_status)) { + if ((child_ret_value=WEXITSTATUS(child_status)) != 0) { HDprintf("%d: child process exited with non-zero code (%d)\n", mypid, child_ret_value); Hgoto_error(1); @@ -233,17 +254,16 @@ main(int argc, char *argv[]) Hgoto_error(2); } } - + done: - /* Print result and exit */ - if (ret_value != 0){ + if (ret_value != 0) { HDprintf("Error(s) encountered\n"); - }else{ + } else { HDprintf("All passed\n"); } return(ret_value); -} +} /* end main() */ #else /* H5_HAVE_FORK */ diff --git a/test/use_common.c b/test/use_common.c index 9effa06..7e19167 100644 --- a/test/use_common.c +++ b/test/use_common.c @@ -21,10 +21,11 @@ #include "use.h" -#define H5D_FRIEND /*suppress error about including H5Dpkg */ -#define H5D_TESTING -#include "H5Dpkg.h" - +/* ---------------------------------------------------------------------------- + * Print a common/shared usage message. + * Receives program name to show default test file name (<program_name>.h5). + * ---------------------------------------------------------------------------- + */ void usage(const char *prog) { @@ -41,10 +42,13 @@ usage(const char *prog) HDfprintf(stderr, "\n"); } /* end usage() */ -/* Setup Use Case parameters by parsing command line options. -* Setup default values if not set by options. */ +/* ---------------------------------------------------------------------------- + * Setup Use Case parameters by parsing command line options. + * Includes default values for unspecified options. + * ---------------------------------------------------------------------------- + */ int -parse_option(int argc, char * const argv[]) +parse_option(int argc, char * const argv[], options_t * opts) { int ret_value=0; int c; @@ -56,367 +60,373 @@ parse_option(int argc, char * const argv[]) /* suppress getopt from printing error */ opterr = 0; - while (1){ - c = getopt (argc, argv, nagg_options); - if (-1 == c) - break; - switch (c) { - case 'h': - usage(progname_g); - HDexit(EXIT_SUCCESS); - break; - case 'f': /* usecase data file name */ - UC_opts.filename = optarg; - break; - case 'i': /* iterations */ - if ((UC_opts.iterations = HDatoi(optarg)) <= 0) { - HDfprintf(stderr, "bad iterations number %s, must be a positive integer\n", optarg); - usage(progname_g); - Hgoto_error(-1); - }; - break; - case 'l': /* launch reader or writer only */ - switch (*optarg) { - case 'r': /* reader only */ - UC_opts.launch = UC_READER; - break; - case 'w': /* writer only */ - UC_opts.launch = UC_WRITER; - break; + while (1) { + c = getopt(argc, argv, nagg_options); + if (-1 == c) + break; + switch (c) { + case 'h': + usage(opts->progname); + exit(EXIT_SUCCESS); + break; + case 'f': /* usecase data file name */ + opts->filename = HDstrdup(optarg); + break; + case 'i': /* iterations */ + if ((opts->iterations = HDatoi(optarg)) <= 0) { + HDfprintf(stderr, "bad iterations number %s, must be a positive integer\n", optarg); + usage(opts->progname); + Hgoto_error(-1); + } + break; + case 'l': /* launch reader or writer only */ + switch (*optarg) { + case 'r': /* reader only */ + opts->launch = UC_READER; + break; + case 'w': /* writer only */ + opts->launch = UC_WRITER; + break; + default: + HDfprintf(stderr, "launch value(%c) should be w or r only.\n", *optarg); + usage(opts->progname); + Hgoto_error(-1); + break; + } /* end switch (reader/writer-only mode toggle) */ + break; + case 'n': /* number of planes to write/read */ + if ((opts->nplanes = HDstrtoul(optarg, NULL, 0)) <= 0) { + HDfprintf(stderr, "bad number of planes %s, must be a positive integer\n", optarg); + usage(opts->progname); + Hgoto_error(-1); + } + break; + case 's': /* use swmr file open mode */ + use_swmr = HDatoi(optarg); + if (use_swmr != 0 && use_swmr != 1) { + HDfprintf(stderr, "swmr value should be 0(no) or 1(yes)\n"); + usage(opts->progname); + Hgoto_error(-1); + } + opts->use_swmr = (hbool_t)use_swmr; + break; + case 'y': /* Number of planes per chunk */ + if ((opts->chunkplanes = HDstrtoul(optarg, NULL, 0)) <= 0) { + HDfprintf(stderr, "bad number of planes per chunk %s, must be a positive integer\n", optarg); + usage(opts->progname); + Hgoto_error(-1); + } + break; + case 'z': /* size of chunk=(z,z) */ + if ((opts->chunksize = HDstrtoull(optarg, NULL, 0)) <= 0) { + HDfprintf(stderr, "bad chunksize %s, must be a positive integer\n", optarg); + usage(opts->progname); + Hgoto_error(-1); + } + break; + case '?': + HDfprintf(stderr, "getopt returned '%c'.\n", c); + Hgoto_error(-1); default: - HDfprintf(stderr, "launch value(%c) should be w or r only.\n", *optarg); - usage(progname_g); - Hgoto_error(-1); - break; - } - break; - case 'n': /* number of planes to write/read */ - if ((UC_opts.nplanes = HDstrtoul(optarg, NULL, 0)) <= 0) { - HDfprintf(stderr, "bad number of planes %s, must be a positive integer\n", optarg); - usage(progname_g); - Hgoto_error(-1); - }; - break; - case 's': /* use swmr file open mode */ - use_swmr = HDatoi(optarg); - if (use_swmr != 0 && use_swmr != 1) { - HDfprintf(stderr, "swmr value should be 0(no) or 1(yes)\n"); - usage(progname_g); + HDfprintf(stderr, "getopt returned unexpected value.\n"); + HDfprintf(stderr, "Unexpected value is %d\n", c); Hgoto_error(-1); - } - UC_opts.use_swmr = (hbool_t)use_swmr; - break; - case 'y': /* Number of planes per chunk */ - if ((UC_opts.chunkplanes = HDstrtoul(optarg, NULL, 0)) <= 0) { - HDfprintf(stderr, "bad number of planes per chunk %s, must be a positive integer\n", optarg); - usage(progname_g); - Hgoto_error(-1); - }; - break; - case 'z': /* size of chunk=(z,z) */ - if ((UC_opts.chunksize = HDstrtoull(optarg, NULL, 0)) <= 0) { - HDfprintf(stderr, "bad chunksize %s, must be a positive integer\n", optarg); - usage(progname_g); - Hgoto_error(-1); - }; - break; - case '?': - HDfprintf(stderr, "getopt returned '%c'.\n", c); - Hgoto_error(-1); - default: - HDfprintf(stderr, "getopt returned unexpected value.\n"); - HDfprintf(stderr, "Unexpected value is %d\n", c); - Hgoto_error(-1); - } - } + } /* end switch (argument symbol) */ + } /* end while (there are still arguments) */ /* set test file name if not given */ - if (!UC_opts.filename){ - /* default data file name is <progname>.h5 */ - if ((UC_opts.filename=(char*)HDmalloc(HDstrlen(progname_g)+4))==NULL) { - HDfprintf(stderr, "malloc: failed\n"); - Hgoto_error(-1); - }; - HDstrcpy(UC_opts.filename, progname_g); - HDstrcat(UC_opts.filename, ".h5"); + if (!opts->filename) { + /* default data file name is <progname>.h5 */ + if ((opts->filename=(char*)HDmalloc(HDstrlen(opts->progname)+4))==NULL) { + HDfprintf(stderr, "malloc: failed\n"); + Hgoto_error(-1); + } + HDstrcpy(opts->filename, opts->progname); + HDstrcat(opts->filename, ".h5"); } done: - /* All done. */ return(ret_value); -} +} /* end parse_option() */ -/* Show parameters used for this use case */ -void show_parameters(void){ +/* ---------------------------------------------------------------------------- + * Show parameters used for this use case. + * ---------------------------------------------------------------------------- + */ +void +show_parameters(options_t * opts) +{ HDprintf("===Parameters used:===\n"); - printf("chunk dims=(%llu, %llu, %llu)\n", (unsigned long long)UC_opts.chunkdims[0], - (unsigned long long)UC_opts.chunkdims[1], (unsigned long long)UC_opts.chunkdims[2]); - printf("dataset max dims=(%llu, %llu, %llu)\n", (unsigned long long)UC_opts.max_dims[0], - (unsigned long long)UC_opts.max_dims[1], (unsigned long long)UC_opts.max_dims[2]); - HDprintf("number of planes to write=%llu\n", (unsigned long long)UC_opts.nplanes); - HDprintf("using SWMR mode=%s\n", UC_opts.use_swmr ? "yes(1)" : "no(0)"); - HDprintf("data filename=%s\n", UC_opts.filename); + HDprintf("chunk dims=(%llu, %llu, %llu)\n", (unsigned long long)opts->chunkdims[0], + (unsigned long long)opts->chunkdims[1], (unsigned long long)opts->chunkdims[2]); + HDprintf("dataset max dims=(%llu, %llu, %llu)\n", (unsigned long long)opts->max_dims[0], + (unsigned long long)opts->max_dims[1], (unsigned long long)opts->max_dims[2]); + HDprintf("number of planes to write=%llu\n", (unsigned long long)opts->nplanes); + HDprintf("using SWMR mode=%s\n", opts->use_swmr ? "yes(1)" : "no(0)"); + HDprintf("data filename=%s\n", opts->filename); HDprintf("launch part="); - switch (UC_opts.launch){ - case UC_READWRITE: - printf("Reader/Writer\n"); - break; - case UC_WRITER: - printf("Writer\n"); - break; - case UC_READER: - printf("Reader\n"); - break; - default: - /* should not happen */ - printf("Illegal part(%d)\n", UC_opts.launch); - }; - HDprintf("number of iterations=%d (not used yet)\n", UC_opts.iterations); + switch (opts->launch) { + case UC_READWRITE: + HDprintf("Reader/Writer\n"); + break; + case UC_WRITER: + HDprintf("Writer\n"); + break; + case UC_READER: + HDprintf("Reader\n"); + break; + default: + /* should not happen */ + HDprintf("Illegal part(%d)\n", opts->launch); + } + HDprintf("number of iterations=%d (not used yet)\n", opts->iterations); HDprintf("===Parameters shown===\n"); -} +} /* end show_parameters() */ -/* Create the skeleton use case file for testing. +/* ---------------------------------------------------------------------------- + * Create the skeleton use case file for testing. * It has one 3d dataset using chunked storage. * The dataset is (unlimited, chunksize, chunksize). * Dataset type is 2 bytes integer. * It starts out "empty", i.e., first dimension is 0. * * Return: 0 succeed; -1 fail. + * ---------------------------------------------------------------------------- */ -int create_uc_file(void) +int +create_uc_file(options_t * opts) { - hsize_t dims[3]; /* Dataset starting dimensions */ - hid_t fid; /* File ID for new HDF5 file */ - hid_t dcpl; /* Dataset creation property list */ - hid_t sid; /* Dataspace ID */ - hid_t dsid; /* Dataset ID */ - hid_t fapl; /* File access property list */ + hsize_t dims[3]; /* Dataset starting dimensions */ + hid_t fid; /* File ID for new HDF5 file */ + hid_t dcpl; /* Dataset creation property list */ + hid_t sid; /* Dataspace ID */ + hid_t dsid; /* Dataset ID */ H5D_chunk_index_t idx_type; /* Chunk index type */ - /* Create the file */ - if((fapl = h5_fileaccess()) < 0) - return -1; - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) - return -1; - if((fid = H5Fcreate(UC_opts.filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if ((fid = H5Fcreate(opts->filename, H5F_ACC_TRUNC, H5P_DEFAULT, opts->fapl_id)) < 0) return -1; /* Set up dimension sizes */ dims[0] = 0; - dims[1] = dims[2] = UC_opts.max_dims[1]; + dims[1] = dims[2] = opts->max_dims[1]; /* Create dataspace for creating datasets */ - if((sid = H5Screate_simple(3, dims, UC_opts.max_dims)) < 0) + if ((sid = H5Screate_simple(3, dims, opts->max_dims)) < 0) return -1; /* Create dataset creation property list */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) return -1; - if(H5Pset_chunk(dcpl, 3, UC_opts.chunkdims) < 0) + if (H5Pset_chunk(dcpl, 3, opts->chunkdims) < 0) return -1; /* create dataset of progname */ - if((dsid = H5Dcreate2(fid, progname_g, UC_DATATYPE, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) - return -1; + if ((dsid = H5Dcreate2(fid, opts->progname, UC_DATATYPE, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + return -1; /* Check that the chunk index type is not version 1 B-tree. * Version 1 B-trees are not supported under SWMR. */ - if(H5D__layout_idx_type_test(dsid, &idx_type) < 0) + if (H5Dget_chunk_index_type(dsid, &idx_type) < 0) return -1; - if(idx_type == H5D_CHUNK_IDX_BTREE) { + if (idx_type == H5D_CHUNK_IDX_BTREE) { HDfprintf(stderr, "ERROR: Chunk index is version 1 B-tree: aborting.\n"); return -1; } /* Close everything */ - if(H5Dclose(dsid) < 0) - return -1; - if(H5Pclose(fapl) < 0) + if (H5Dclose(dsid) < 0) return -1; - if(H5Pclose(dcpl) < 0) + if (H5Pclose(dcpl) < 0) return -1; - if(H5Sclose(sid) < 0) + if (H5Sclose(sid) < 0) return -1; - if(H5Fclose(fid) < 0) + if (H5Fclose(fid) < 0) return -1; return 0; -} +} /* end create_uc_file() */ -/* Append planes, each of (1,2*chunksize,2*chunksize) to the dataset. +/* ---------------------------------------------------------------------------- + * Append planes, each of (1,2*chunksize,2*chunksize) to the dataset. * In other words, 4 chunks are appended to the dataset at a time. * Fill each plan with the plane number and then write it at the nth plane. * Increase the plane number and repeat till the end of dataset, when it * reaches chunksize long. End product is a (2*chunksize)^3 cube. * * Return: 0 succeed; -1 fail. + * ---------------------------------------------------------------------------- */ -int write_uc_file(hbool_t tosend, hid_t fid) +int +write_uc_file(hbool_t tosend, hid_t file_id, options_t * opts) { - hid_t dsid; /* dataset ID */ - hid_t dcpl; /* Dataset creation property list */ - UC_CTYPE *buffer, *bufptr; /* data buffer */ - hsize_t cz=UC_opts.chunksize; /* Chunk size */ - hid_t f_sid; /* dataset file space id */ - hid_t m_sid; /* memory space id */ - int rank; /* rank */ - hsize_t chunk_dims[3]; /* Chunk dimensions */ - hsize_t dims[3]; /* Dataspace dimensions */ - hsize_t memdims[3]; /* Memory space dimensions */ - hsize_t start[3] = {0,0,0}, count[3]; /* Hyperslab selection values */ - hsize_t i, j, k; - - if(tosend) + hid_t dsid; /* dataset ID */ + hid_t dcpl; /* Dataset creation property list */ + UC_CTYPE *buffer, *bufptr; /* data buffer */ + hsize_t cz=opts->chunksize; /* Chunk size */ + hid_t f_sid; /* dataset file space id */ + hid_t m_sid; /* memory space id */ + int rank; /* rank */ + hsize_t chunk_dims[3]; /* Chunk dimensions */ + hsize_t dims[3]; /* Dataspace dimensions */ + hsize_t memdims[3]; /* Memory space dimensions */ + hsize_t start[3] = {0,0,0}, count[3]; /* Hyperslab selection values */ + hsize_t i, j, k; + + if (TRUE == tosend) { /* Send a message that H5Fopen is complete--releasing the file lock */ h5_send_message(WRITER_MESSAGE, NULL, NULL); + } /* Open the dataset of the program name */ - if((dsid = H5Dopen2(fid, progname_g, H5P_DEFAULT)) < 0){ + if ((dsid = H5Dopen2(file_id, opts->progname, H5P_DEFAULT)) < 0) { HDfprintf(stderr, "H5Dopen2 failed\n"); return -1; } /* Find chunksize used */ - if ((dcpl = H5Dget_create_plist(dsid)) < 0){ + if ((dcpl = H5Dget_create_plist(dsid)) < 0) { HDfprintf(stderr, "H5Dget_create_plist failed\n"); return -1; } - if (H5D_CHUNKED != H5Pget_layout(dcpl)){ + if (H5D_CHUNKED != H5Pget_layout(dcpl)) { HDfprintf(stderr, "storage layout is not chunked\n"); return -1; } - if ((rank = H5Pget_chunk(dcpl, 3, chunk_dims)) != 3){ + if ((rank = H5Pget_chunk(dcpl, 3, chunk_dims)) != 3) { HDfprintf(stderr, "storage rank is not 3\n"); return -1; } /* verify chunk_dims against set paramenters */ - if (chunk_dims[0]!=UC_opts.chunkdims[0] || chunk_dims[1] != cz || chunk_dims[2] != cz){ + if (chunk_dims[0]!=opts->chunkdims[0] || chunk_dims[1] != cz || chunk_dims[2] != cz) { HDfprintf(stderr, "chunk size is not as expected. Got dims=(%llu,%llu,%llu)\n", - (unsigned long long)chunk_dims[0], (unsigned long long)chunk_dims[1], + (unsigned long long)chunk_dims[0], (unsigned long long)chunk_dims[1], (unsigned long long)chunk_dims[2]); return -1; } /* allocate space for data buffer 1 X dims[1] X dims[2] of UC_CTYPE */ memdims[0]=1; - memdims[1] = UC_opts.dims[1]; - memdims[2] = UC_opts.dims[2]; + memdims[1] = opts->dims[1]; + memdims[2] = opts->dims[2]; if ((buffer=(UC_CTYPE*)HDmalloc((size_t)memdims[1]*(size_t)memdims[2]*sizeof(UC_CTYPE)))==NULL) { HDfprintf(stderr, "malloc: failed\n"); return -1; - }; + } /* * Get dataset rank and dimension. */ f_sid = H5Dget_space(dsid); /* Get filespace handle first. */ rank = H5Sget_simple_extent_ndims(f_sid); - if (rank != UC_RANK){ + if (rank != UC_RANK) { HDfprintf(stderr, "rank(%d) of dataset does not match\n", rank); return -1; } - if (H5Sget_simple_extent_dims(f_sid, dims, NULL) < 0){ + if (H5Sget_simple_extent_dims(f_sid, dims, NULL) < 0) { HDfprintf(stderr, "H5Sget_simple_extent_dims got error\n"); return -1; } HDprintf("dataset rank %d, dimensions %llu x %llu x %llu\n", - rank, (unsigned long long)(dims[0]), (unsigned long long)(dims[1]), + rank, (unsigned long long)(dims[0]), (unsigned long long)(dims[1]), (unsigned long long)(dims[2])); /* verify that file space dims are as expected and are consistent with memory space dims */ - if (dims[0] != 0 || dims[1] != memdims[1] || dims[2] != memdims[2]){ + if (dims[0] != 0 || dims[1] != memdims[1] || dims[2] != memdims[2]) { HDfprintf(stderr, "dataset is not empty. Got dims=(%llu,%llu,%llu)\n", - (unsigned long long)dims[0], (unsigned long long)dims[1], + (unsigned long long)dims[0], (unsigned long long)dims[1], (unsigned long long)dims[2]); return -1; } /* setup mem-space for buffer */ - if ((m_sid=H5Screate_simple(rank, memdims, NULL))<0){ + if ((m_sid=H5Screate_simple(rank, memdims, NULL))<0) { HDfprintf(stderr, "H5Screate_simple for memory failed\n"); return -1; - }; + } /* write planes */ count[0]=1; count[1]=dims[1]; count[2]=dims[2]; - for (i=0; i<UC_opts.nplanes; i++){ - /* fill buffer with value i+1 */ - bufptr = buffer; - for (j=0; j<dims[1]; j++) - for (k=0; k<dims[2]; k++) - *bufptr++ = (UC_CTYPE)i; + for (i=0; i < opts->nplanes; i++) { + /* fill buffer with value i+1 */ + bufptr = buffer; + for (j=0; j < dims[1]; j++) { + for (k=0; k < dims[2]; k++) { + *bufptr++ = (UC_CTYPE)i; + } + } /* Cork the dataset's metadata in the cache, if SWMR is enabled */ - if(UC_opts.use_swmr) - if(H5Odisable_mdc_flushes(dsid) < 0) { + if (opts->use_swmr) { + if (H5Odisable_mdc_flushes(dsid) < 0) { HDfprintf(stderr, "H5Odisable_mdc_flushes failed\n"); return -1; } + } - /* extend the dataset by one for new plane */ - dims[0]=i+1; - if(H5Dset_extent(dsid, dims) < 0){ + /* extend the dataset by one for new plane */ + dims[0]=i+1; + if (H5Dset_extent(dsid, dims) < 0) { HDfprintf(stderr, "H5Dset_extent failed\n"); return -1; - } + } /* Get the dataset's dataspace */ - if((f_sid = H5Dget_space(dsid)) < 0){ + if ((f_sid = H5Dget_space(dsid)) < 0) { HDfprintf(stderr, "H5Dset_extent failed\n"); return -1; - } + } - start[0]=i; + start[0]=i; /* Choose the next plane to write */ - if(H5Sselect_hyperslab(f_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0){ + if (H5Sselect_hyperslab(f_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) { HDfprintf(stderr, "Failed H5Sselect_hyperslab\n"); return -1; - } + } /* Write plane to the dataset */ - if(H5Dwrite(dsid, UC_DATATYPE, m_sid, f_sid, H5P_DEFAULT, buffer) < 0){ + if (H5Dwrite(dsid, UC_DATATYPE, m_sid, f_sid, H5P_DEFAULT, buffer) < 0) { HDfprintf(stderr, "Failed H5Dwrite\n"); return -1; - } + } /* Uncork the dataset's metadata from the cache, if SWMR is enabled */ - if(UC_opts.use_swmr) - if(H5Oenable_mdc_flushes(dsid) < 0) { + if (opts->use_swmr) { + if (H5Oenable_mdc_flushes(dsid) < 0) { HDfprintf(stderr, "H5Oenable_mdc_flushes failed\n"); return -1; } + } - /* flush file to make the just written plane available. */ - if(H5Dflush(dsid) < 0) - { - HDfprintf(stderr, "Failed to H5Fflush file\n"); - return -1; - } - } + /* flush file to make the just written plane available. */ + if (H5Dflush(dsid) < 0) { + HDfprintf(stderr, "Failed to H5Fflush file\n"); + return -1; + } + } /* end for each plane to write */ /* Done writing. Free/Close all resources including data file */ HDfree(buffer); - if (H5Dclose(dsid) < 0){ + if (H5Dclose(dsid) < 0) { HDfprintf(stderr, "Failed to close datasete\n"); return -1; } - if (H5Sclose(m_sid) < 0){ + if (H5Sclose(m_sid) < 0) { HDfprintf(stderr, "Failed to close memory space\n"); return -1; } - if (H5Sclose(f_sid) < 0){ + if (H5Sclose(f_sid) < 0) { HDfprintf(stderr, "Failed to close file space\n"); return -1; } return 0; -} - +} /* end write_uc_file() */ -/* Read planes from the dataset. +/* ---------------------------------------------------------------------------- + * Read planes from the dataset. * It expects the dataset is being changed (growing). * It checks the unlimited dimension (1st one). When it increases, * it will read in the new planes, one by one, and verify the data correctness. @@ -425,61 +435,51 @@ int write_uc_file(hbool_t tosend, hid_t fid) * that is the expected end of data, the reader exits. * * Return: 0 succeed; -1 fail. + * ---------------------------------------------------------------------------- */ -int read_uc_file(hbool_t towait) +int +read_uc_file(hbool_t towait, options_t * opts) { - hid_t fapl; /* file access property list ID */ - hid_t fid; /* File ID for new HDF5 file */ - hid_t dsid; /* dataset ID */ - char *name; - UC_CTYPE *buffer, *bufptr; /* read data buffer */ - hid_t f_sid; /* dataset file space id */ - hid_t m_sid; /* memory space id */ - int rank; /* rank */ - hsize_t dims[3]; /* Dataspace dimensions */ - hsize_t memdims[3]; /* Memory space dimensions */ - hsize_t nplane=0, nplane_old=0; /* nth plane, last nth plane */ - hsize_t start[3] = {0,0,0}, count[3]; /* Hyperslab selection values */ - hsize_t j, k; - int nreadererr=0; - int nerrs; - int nonewplane; + hid_t fid; /* File ID for new HDF5 file */ + hid_t dsid; /* dataset ID */ + UC_CTYPE *buffer, *bufptr; /* read data buffer */ + hid_t f_sid; /* dataset file space id */ + hid_t m_sid; /* memory space id */ + int rank; /* rank */ + hsize_t dims[3]; /* Dataspace dimensions */ + hsize_t memdims[3]; /* Memory space dimensions */ + hsize_t nplane=0, nplanes_seen=0; /* nth plane, last nth plane */ + hsize_t start[3] = {0,0,0}, count[3]; /* Hyperslab selection values */ + hsize_t j, k; + int nreadererr=0; + int nerrs; + int loops_waiting_for_plane; /* Before reading, wait for the message that H5Fopen is complete--file lock is released */ - if(towait && h5_wait_message(WRITER_MESSAGE) < 0) { + if (towait && h5_wait_message(WRITER_MESSAGE) < 0) { HDfprintf(stderr, "Cannot find writer message file...failed\n"); return -1; } - name = UC_opts.filename; - - /* Open the file */ - if((fapl = h5_fileaccess()) < 0) - return -1; - if((fid = H5Fopen(name, H5F_ACC_RDONLY | (UC_opts.use_swmr ? H5F_ACC_SWMR_READ : 0), fapl)) < 0){ + HDfprintf(stderr, "Opening to read %s\n", opts->filename); + if ((fid = H5Fopen(opts->filename, H5F_ACC_RDONLY | (opts->use_swmr ? H5F_ACC_SWMR_READ : 0), opts->fapl_id)) < 0) { HDfprintf(stderr, "H5Fopen failed\n"); return -1; } - if (H5Pclose(fapl) < 0){ - HDfprintf(stderr, "Failed to property list\n"); - return -1; - } - - /* Open the dataset of the program name */ - if((dsid = H5Dopen2(fid, progname_g, H5P_DEFAULT)) < 0){ + if ((dsid = H5Dopen2(fid, opts->progname, H5P_DEFAULT)) < 0) { HDfprintf(stderr, "H5Dopen2 failed\n"); return -1; } - /* allocate space for data buffer 1 X dims[1] X dims[2] of UC_CTYPE */ - memdims[0]=1; - memdims[1] = UC_opts.dims[1]; - memdims[2] = UC_opts.dims[2]; + /* Allocate space for data buffer 1 X dims[1] X dims[2] of UC_CTYPE */ + memdims[0] = 1; + memdims[1] = opts->dims[1]; + memdims[2] = opts->dims[2]; if ((buffer=(UC_CTYPE*)HDmalloc((size_t)memdims[1]*(size_t)memdims[2]*sizeof(UC_CTYPE)))==NULL) { HDfprintf(stderr, "malloc: failed\n"); return -1; - }; + } /* * Get dataset rank and dimension. @@ -487,11 +487,11 @@ int read_uc_file(hbool_t towait) */ f_sid = H5Dget_space(dsid); /* Get filespace handle first. */ rank = H5Sget_simple_extent_ndims(f_sid); - if (rank != UC_RANK){ + if (rank != UC_RANK) { HDfprintf(stderr, "rank(%d) of dataset does not match\n", rank); return -1; } - if (H5Sget_simple_extent_dims(f_sid, dims, NULL) < 0){ + if (H5Sget_simple_extent_dims(f_sid, dims, NULL) < 0) { HDfprintf(stderr, "H5Sget_simple_extent_dims got error\n"); return -1; } @@ -499,7 +499,7 @@ int read_uc_file(hbool_t towait) rank, (unsigned long long)(dims[0]), (unsigned long long)(dims[1]), (unsigned long long)(dims[2])); /* verify that file space dims are as expected and are consistent with memory space dims */ - if (dims[1] != memdims[1] || dims[2] != memdims[2]){ + if (dims[1] != memdims[1] || dims[2] != memdims[2]) { HDfprintf(stderr, "dataset dimension is not as expected. Got dims=(%llu,%llu,%llu)\n", (unsigned long long)dims[0], (unsigned long long)dims[1], (unsigned long long)dims[2]); @@ -509,120 +509,101 @@ int read_uc_file(hbool_t towait) return -1; } - /* setup mem-space for buffer */ - if ((m_sid=H5Screate_simple(rank, memdims, NULL))<0){ + /* Setup mem-space for buffer */ + if ((m_sid=H5Screate_simple(rank, memdims, NULL)) < 0) { HDfprintf(stderr, "H5Screate_simple for memory failed\n"); return -1; - }; + } - /* Read 1 plane at a time whenever the dataset grows larger - * (along dim[0]) */ - count[0]=1; - count[1]=dims[1]; - count[2]=dims[2]; + /* Read 1 plane at a time whenever the dataset grows larger (along dim[0]) */ + count[0] = 1; + count[1] = dims[1]; + count[2] = dims[2]; /* quit when all nplanes have been read */ - nonewplane=0; - while (nplane_old < UC_opts.nplanes ){ - /* print progress message according to if new planes are availalbe */ - if (nplane_old < dims[0]) { - if (nonewplane){ - /* end the previous message */ - HDprintf("\n"); - nonewplane=0; - } - HDprintf("reading planes %llu to %llu\n", (unsigned long long)nplane_old, + loops_waiting_for_plane=0; + while (nplanes_seen < opts->nplanes) { + /* print progress message according to if new planes are availalbe */ + if (nplanes_seen < dims[0]) { + if (loops_waiting_for_plane) { + /* end the previous message */ + HDprintf("\n"); + loops_waiting_for_plane=0; + } + HDprintf("reading planes %llu to %llu\n", (unsigned long long)nplanes_seen, (unsigned long long)dims[0]); - }else{ - if (nonewplane){ - HDprintf("."); - if (nonewplane>=30){ - HDfprintf(stderr, "waited too long for new plane, quit.\n"); - return -1; - } - }else{ - /* print mesg only the first time; dots still no new plane */ - HDprintf("no new planes to read "); } - nonewplane++; - /* pause for a second */ - HDsleep(1); - } - for (nplane=nplane_old; nplane < dims[0]; nplane++){ - /* read planes between last old nplanes and current extent */ - /* Get the dataset's dataspace */ - if((f_sid = H5Dget_space(dsid)) < 0){ - HDfprintf(stderr, "H5Dget_space failed\n"); - return -1; + else { + if (loops_waiting_for_plane) { + HDprintf("."); + if (loops_waiting_for_plane>=30) { + HDfprintf(stderr, "waited too long for new plane, quit.\n"); + return -1; + } + } + else { + /* print mesg only the first time; dots still no new plane */ + HDprintf("waiting for new planes to read "); + } + loops_waiting_for_plane++; + /* pause for a second */ + HDsleep(1); } - start[0]=nplane; - /* Choose the next plane to read */ - if(H5Sselect_hyperslab(f_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0){ - HDfprintf(stderr, "H5Sselect_hyperslab failed\n"); - return -1; - } + for (nplane=nplanes_seen; nplane < dims[0]; nplane++) { + /* read planes between last old nplanes and current extent */ + /* Get the dataset's dataspace */ + if ((f_sid = H5Dget_space(dsid)) < 0) { + HDfprintf(stderr, "H5Dget_space failed\n"); + return -1; + } - /* Read the plane from the dataset */ - if(H5Dread(dsid, UC_DATATYPE, m_sid, f_sid, H5P_DEFAULT, buffer) < 0){ - HDfprintf(stderr, "H5Dread failed\n"); - return -1; - } + start[0]=nplane; + /* Choose the next plane to read */ + if (H5Sselect_hyperslab(f_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) { + HDfprintf(stderr, "H5Sselect_hyperslab failed\n"); + return -1; + } - /* compare read data with expected data value which is nplane */ - bufptr = buffer; - nerrs=0; - for (j=0; j<dims[1]; j++){ - for (k=0; k<dims[2]; k++){ - if ((hsize_t)*bufptr++ != nplane){ - if (++nerrs < ErrorReportMax){ - HDfprintf(stderr, - "found error %llu plane(%llu,%llu), expected %llu, got %d\n", - (unsigned long long)nplane, (unsigned long long)j, - (unsigned long long)k, (unsigned long long)nplane, (int)*(bufptr-1)); - } - } + /* Read the plane from the dataset */ + if (H5Dread(dsid, UC_DATATYPE, m_sid, f_sid, H5P_DEFAULT, buffer) < 0) { + HDfprintf(stderr, "H5Dread failed\n"); + return -1; } - } - if (nerrs){ - nreadererr++; - HDfprintf(stderr, "found %d unexpected values in plane %llu\n", nerrs, + + /* compare read data with expected data value which is nplane */ + bufptr = buffer; + nerrs=0; + for (j=0; j < dims[1]; j++) { + for (k=0; k < dims[2]; k++) { + if ((hsize_t)*bufptr++ != nplane) { + if (++nerrs < ErrorReportMax) { + HDfprintf(stderr, + "found error %llu plane(%llu,%llu), expected %llu, got %d\n", + (unsigned long long)nplane, (unsigned long long)j, + (unsigned long long)k, (unsigned long long)nplane, (int)*(bufptr-1)); + } /* end if should print error */ + } /* end if value mismatch */ + } /* end for plane second dimension */ + } /* end for plane first dimension */ + if (nerrs) { + nreadererr++; + HDfprintf(stderr, "found %d unexpected values in plane %llu\n", nerrs, (unsigned long long)nplane); - } - } - /* Have read all current planes */ - nplane_old=dims[0]; + } + } /* end for each plane added since last read */ - /* check if dataset has grown since last time */ -#if 0 - /* close dsid and file, then reopen them */ - if (H5Dclose(dsid) < 0){ - HDfprintf(stderr, "H5Dclose failed\n"); - return -1; - } - if (H5Fclose(fid) < 0){ - HDfprintf(stderr, "H5Fclose failed\n"); - return -1; - } - if((fid = H5Fopen(name, H5F_ACC_RDONLY | (UC_opts.use_swmr ? H5F_ACC_SWMR_READ : 0), H5P_DEFAULT)) < 0){ - HDfprintf(stderr, "H5Fopen failed\n"); - return -1; - } - if((dsid = H5Dopen2(fid, progname_g, H5P_DEFAULT)) < 0){ - HDfprintf(stderr, "H5Dopen2 failed\n"); - return -1; - } -#else - H5Drefresh(dsid); -#endif - f_sid = H5Dget_space(dsid); /* Get filespace handle first. */ - if (H5Sget_simple_extent_dims(f_sid, dims, NULL) < 0){ - HDfprintf(stderr, "H5Sget_simple_extent_dims got error\n"); - return -1; - } - } + nplanes_seen=dims[0]; + + /* check if dataset has grown since last time (update dims) */ + H5Drefresh(dsid); + f_sid = H5Dget_space(dsid); /* Get filespace handle first. */ + if (H5Sget_simple_extent_dims(f_sid, dims, NULL) < 0) { + HDfprintf(stderr, "H5Sget_simple_extent_dims got error\n"); + return -1; + } + } /* end while (expecting more planes to read) */ - /* Close the file */ - if(H5Fclose(fid) < 0) { + if (H5Fclose(fid) < 0) { HDfprintf(stderr, "H5Fclose failed\n"); return -1; } @@ -631,7 +612,7 @@ int read_uc_file(hbool_t towait) return -1; else return 0; -} /* read_uc_file() */ +} /* end read_uc_file() */ #endif /* H5_HAVE_FORK */ diff --git a/test/use_disable_mdc_flushes.c b/test/use_disable_mdc_flushes.c index 9cd202c..32a8244 100644 --- a/test/use_disable_mdc_flushes.c +++ b/test/use_disable_mdc_flushes.c @@ -108,7 +108,7 @@ parse_option(int argc, char * const argv[]) filename_g = optarg; break; case 'n': /* number of planes to write/read */ - if ((nplanes_g = HDatoi(optarg)) <= 0){ + if ((nplanes_g = (hsize_t)HDatoi(optarg)) <= 0){ HDfprintf(stderr, "bad number of planes %s, must be a positive integer\n", optarg); usage(progname_g); Hgoto_error(-1); @@ -193,17 +193,17 @@ setup_parameters(int argc, char * const argv[]) return(-1); } /* set chunk dims */ - chunkdims_g[0] = chunkplanes_g; - chunkdims_g[1]= chunkdims_g[2] = chunksize_g; + chunkdims_g[0] = (hsize_t)chunkplanes_g; + chunkdims_g[1]= chunkdims_g[2] = (hsize_t)chunksize_g; /* set dataset initial and max dims */ dims_g[0] = 0; max_dims_g[0] = H5S_UNLIMITED; - dims_g[1] = dims_g[2] = max_dims_g[1] = max_dims_g[2] = chunksize_g; + dims_g[1] = dims_g[2] = max_dims_g[1] = max_dims_g[2] = (hsize_t)chunksize_g; /* set nplanes */ if (nplanes_g == 0) - nplanes_g = chunksize_g; + nplanes_g = (hsize_t)chunksize_g; /* show parameters and return */ show_parameters(); @@ -299,7 +299,7 @@ write_file(void) hid_t dcpl; /* Dataset creation property list */ char *name; UC_CTYPE *buffer, *bufptr; /* data buffer */ - hsize_t cz=chunksize_g; /* Chunk size */ + hsize_t cz=(hsize_t)chunksize_g; /* Chunk size */ hid_t f_sid; /* dataset file space id */ hid_t m_sid; /* memory space id */ int rank; /* rank */ @@ -413,8 +413,13 @@ write_file(void) /* fill buffer with value i+1 */ bufptr = buffer; for (j=0; j<dims[1]; j++) - for (k=0; k<dims[2]; k++) - *bufptr++ = i; + for (k=0; k<dims[2]; k++) { + if(i > SHRT_MAX) { + HDfprintf(stderr, "rank(%d) of dataset overflow\n", rank); + return -1; + } + *bufptr++ = (short)i; + } /* extend the dataset by one for new plane */ dims[0]=i+1; diff --git a/test/vds_env.c b/test/vds_env.c index bc3bd59..3d5b5dd 100644 --- a/test/vds_env.c +++ b/test/vds_env.c @@ -299,24 +299,56 @@ test_vds_prefix_second(unsigned config, hid_t fapl) int main(void) { - hid_t fapl; - int test_api_config; + hid_t fapl, my_fapl; unsigned bit_config; H5F_libver_t low, high; /* Low and high bounds */ - unsigned latest = FALSE; /* Using the latest library version bound */ int nerrors = 0; /* Testing setup */ h5_reset(); fapl = h5_fileaccess(); - for(bit_config = 0; bit_config < TEST_IO_NTESTS; bit_config++) { - HDprintf("Config: %s%s%s\n", bit_config & TEST_IO_CLOSE_SRC ? "closed source dataset, " : "", bit_config & TEST_IO_DIFFERENT_FILE ? "different source file" : "same source file", bit_config & TEST_IO_REOPEN_VIRT ? ", reopen virtual file" : ""); - nerrors += test_vds_prefix_second(bit_config, fapl); - } + /* Set to use the latest file format */ + if((my_fapl = H5Pcopy(fapl)) < 0) TEST_ERROR + + /* Loop through all the combinations of low/high version bounds */ + for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + char msg[80]; /* Message for file version bounds */ + const char *low_string; /* The low bound string */ + const char *high_string; /* The high bound string */ + + /* Invalid combinations, just continue */ + if(high == H5F_LIBVER_EARLIEST || high < low) + continue; + + /* Test virtual dataset only for V110 and above */ + if(high < H5F_LIBVER_V110) + continue; + + /* Set the low/high version bounds */ + if(H5Pset_libver_bounds(my_fapl, low, high) < 0) + TEST_ERROR - /* Verify symbol table messages are cached */ - nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0); + /* Display testing info */ + low_string = h5_get_version_string(low); + high_string = h5_get_version_string(high); + HDsprintf(msg, "Testing virtual dataset with file version bounds: (%s, %s):", low_string, high_string); + HDputs(msg); + + for(bit_config = 0; bit_config < TEST_IO_NTESTS; bit_config++) { + HDprintf("Config: %s%s%s\n", bit_config & TEST_IO_CLOSE_SRC ? "closed source dataset, " : "", bit_config & TEST_IO_DIFFERENT_FILE ? "different source file" : "same source file", bit_config & TEST_IO_REOPEN_VIRT ? ", reopen virtual file" : ""); + nerrors += test_vds_prefix_second(bit_config, fapl); + } + + /* Verify symbol table messages are cached */ + nerrors += (h5_verify_cached_stabs(FILENAME, my_fapl) < 0 ? 1 : 0); + + } /* end for high */ + } /* end for low */ + + if(H5Pclose(my_fapl) < 0) + TEST_ERROR if(nerrors) goto error; diff --git a/test/vds_swmr.h b/test/vds_swmr.h index f2e7a6d..0a194ff 100644 --- a/test/vds_swmr.h +++ b/test/vds_swmr.h @@ -77,86 +77,23 @@ /* Dataset dimensions */ #define SM_HEIGHT 2 /* K */ #define LG_HEIGHT 4 /* N */ -#define SM_LG_HEIGHT 6 /* SM_HEIGHT + LG_HEIGHT */ #define FULL_HEIGHT 18 /* (3 * K) + (3 * N) */ -#define HALF_HEIGHT 9 #define WIDTH 8 /* M */ -#define HALF_WIDTH 4 - -/* Max number of planes in the dataset */ -#define N_MAX_PLANES H5S_UNLIMITED /* Number of planes each writer will write */ #define N_PLANES_TO_WRITE 25 -/* Dataset datatypes */ -#define SOURCE_DATATYPE H5T_STD_I32LE -#define VDS_DATATYPE H5T_STD_I32LE - -/* Starting size of datasets, both source and VDS */ -static hsize_t DIMS[N_SOURCES][RANK] = { - {0, SM_HEIGHT, WIDTH}, - {0, LG_HEIGHT, WIDTH}, - {0, SM_HEIGHT, WIDTH}, - {0, LG_HEIGHT, WIDTH}, - {0, SM_HEIGHT, WIDTH}, - {0, LG_HEIGHT, WIDTH} -}; -static hsize_t VDS_DIMS[RANK] = {0, FULL_HEIGHT, WIDTH}; - -/* Maximum size of datasets, both source and VDS. - * NOTE: Theoretical (i.e.: H5S_UNLIMITED), not the actual max - * number of planes written out by the writers before they stop. - * That number is specified separately. - */ -static hsize_t MAX_DIMS[N_SOURCES][RANK] = { - {N_MAX_PLANES, SM_HEIGHT, WIDTH}, - {N_MAX_PLANES, LG_HEIGHT, WIDTH}, - {N_MAX_PLANES, SM_HEIGHT, WIDTH}, - {N_MAX_PLANES, LG_HEIGHT, WIDTH}, - {N_MAX_PLANES, SM_HEIGHT, WIDTH}, - {N_MAX_PLANES, LG_HEIGHT, WIDTH} -}; -static hsize_t VDS_MAX_DIMS[RANK] = {N_MAX_PLANES, FULL_HEIGHT, WIDTH}; - /* Planes */ -static hsize_t PLANES[N_SOURCES][RANK] = { - {1, SM_HEIGHT, WIDTH}, - {1, LG_HEIGHT, WIDTH}, - {1, SM_HEIGHT, WIDTH}, - {1, LG_HEIGHT, WIDTH}, - {1, SM_HEIGHT, WIDTH}, - {1, LG_HEIGHT, WIDTH} -}; +H5TEST_DLLVAR hsize_t PLANES[N_SOURCES][RANK]; /* File names for source datasets */ -static char FILE_NAMES[N_SOURCES][NAME_LEN] = { - {"vds_swmr_src_a.h5"}, - {"vds_swmr_src_b.h5"}, - {"vds_swmr_src_c.h5"}, - {"vds_swmr_src_d.h5"}, - {"vds_swmr_src_e.h5"}, - {"vds_swmr_src_f.h5"} -}; +H5TEST_DLLVAR char FILE_NAMES[N_SOURCES][NAME_LEN]; /* VDS file name */ -static char VDS_FILE_NAME[NAME_LEN] = "vds_swmr.h5"; +H5TEST_DLLVAR char VDS_FILE_NAME[NAME_LEN]; /* Dataset names */ -static char SOURCE_DSET_NAME[NAME_LEN] = "source_dset"; -static char SOURCE_DSET_PATH[NAME_LEN] = "/source_dset"; -static char VDS_DSET_NAME[NAME_LEN] = "vds_dset"; - -/* Fill values */ -static int32_t FILL_VALUES[N_SOURCES] = { - -1, - -2, - -3, - -4, - -5, - -6 -}; -static int32_t VDS_FILL_VALUE = -9; - +H5TEST_DLLVAR char SOURCE_DSET_PATH[NAME_LEN]; +H5TEST_DLLVAR char VDS_DSET_NAME[NAME_LEN]; #endif /* VDS_SWMR_H */ diff --git a/test/vds_swmr_gen.c b/test/vds_swmr_gen.c index 1cb9744..b14ecc2 100644 --- a/test/vds_swmr_gen.c +++ b/test/vds_swmr_gen.c @@ -14,6 +14,52 @@ #include "h5test.h" #include "vds_swmr.h" +/* Max number of planes in the dataset */ +#define N_MAX_PLANES H5S_UNLIMITED + +/* Dataset datatypes */ +#define SOURCE_DATATYPE H5T_STD_I32LE +#define VDS_DATATYPE H5T_STD_I32LE + +/* Starting size of datasets, both source and VDS */ +static hsize_t DIMS[N_SOURCES][RANK] = { + {0, SM_HEIGHT, WIDTH}, + {0, LG_HEIGHT, WIDTH}, + {0, SM_HEIGHT, WIDTH}, + {0, LG_HEIGHT, WIDTH}, + {0, SM_HEIGHT, WIDTH}, + {0, LG_HEIGHT, WIDTH} +}; +static hsize_t VDS_DIMS[RANK] = {0, FULL_HEIGHT, WIDTH}; + +/* Maximum size of datasets, both source and VDS. + * NOTE: Theoretical (i.e.: H5S_UNLIMITED), not the actual max + * number of planes written out by the writers before they stop. + * That number is specified separately. + */ +static hsize_t MAX_DIMS[N_SOURCES][RANK] = { + {N_MAX_PLANES, SM_HEIGHT, WIDTH}, + {N_MAX_PLANES, LG_HEIGHT, WIDTH}, + {N_MAX_PLANES, SM_HEIGHT, WIDTH}, + {N_MAX_PLANES, LG_HEIGHT, WIDTH}, + {N_MAX_PLANES, SM_HEIGHT, WIDTH}, + {N_MAX_PLANES, LG_HEIGHT, WIDTH} +}; +static hsize_t VDS_MAX_DIMS[RANK] = {N_MAX_PLANES, FULL_HEIGHT, WIDTH}; + +static char SOURCE_DSET_NAME[NAME_LEN] = "source_dset"; + +static int32_t FILL_VALUES[N_SOURCES] = { + -1, + -2, + -3, + -4, + -5, + -6 +}; + +static int32_t VDS_FILL_VALUE = -9; + int main(void) { @@ -99,11 +145,13 @@ main(void) if(H5Sselect_hyperslab(src_sid, H5S_SELECT_SET, start, NULL, MAX_DIMS[i], NULL) < 0) TEST_ERROR - start[1] = map_start; + start[1] = (hsize_t)map_start; if(H5Sselect_hyperslab(vds_sid, H5S_SELECT_SET, start, NULL, MAX_DIMS[i], NULL) < 0) TEST_ERROR - map_start += PLANES[i][1]; + if(PLANES[i][1] > INT_MAX) + TEST_ERROR + map_start += (int)PLANES[i][1]; /* Add VDS mapping */ if(H5Pset_virtual(vds_dcplid, vds_sid, FILE_NAMES[i], diff --git a/test/vds_swmr_reader.c b/test/vds_swmr_reader.c index eb9a82b..1ee65a0 100644 --- a/test/vds_swmr_reader.c +++ b/test/vds_swmr_reader.c @@ -45,8 +45,10 @@ main(void) TEST_ERROR /* Create the read buffer */ - n_elements = VDS_PLANE[1] * VDS_PLANE[2]; - size = n_elements * sizeof(int); + if(VDS_PLANE[1] * VDS_PLANE[2] > INT_MAX) + TEST_ERROR + n_elements = (int)(VDS_PLANE[1] * VDS_PLANE[2]); + size = (size_t)n_elements * sizeof(int); if(NULL == (buffer = (int *)HDmalloc(size))) TEST_ERROR diff --git a/test/vds_swmr_writer.c b/test/vds_swmr_writer.c index d62ecaf..d70352d 100644 --- a/test/vds_swmr_writer.c +++ b/test/vds_swmr_writer.c @@ -43,7 +43,7 @@ main(int argc, char *argv[]) ******************************/ /* The file number is passed on the command line. - * This is an integer index into the FILE_NAMES array. + * This is an integer index into the FILE_NAMES array. */ if(argc != 2) { HDfprintf(stderr, "ERROR: Must pass the source file number on the command line.\n"); |