diff options
author | Dana Robinson <derobins@hdfgroup.org> | 2020-08-01 16:36:13 (GMT) |
---|---|---|
committer | Dana Robinson <derobins@hdfgroup.org> | 2020-08-01 16:36:13 (GMT) |
commit | 7a80f551a69ce6e9a98c0b8704204617ceb7a114 (patch) | |
tree | f55feeace86fe01d0b1ebb8eef6e71c1b714354a /test | |
parent | ddb2e961ee084ff5c11c03e2257a63069279a8fe (diff) | |
parent | bfe04875838d8c3baea58c3fbfb16d9ee88d3beb (diff) | |
download | hdf5-7a80f551a69ce6e9a98c0b8704204617ceb7a114.zip hdf5-7a80f551a69ce6e9a98c0b8704204617ceb7a114.tar.gz hdf5-7a80f551a69ce6e9a98c0b8704204617ceb7a114.tar.bz2 |
Merge pull request #2724 in HDFFV/hdf5 from ~DEROBINS/hdf5_der:1_10_normalization to hdf5_1_10
* commit 'bfe04875838d8c3baea58c3fbfb16d9ee88d3beb':
Normalization and warning fixes from develop
Diffstat (limited to 'test')
-rw-r--r-- | test/chunk_info.c | 119 | ||||
-rw-r--r-- | test/cork.c | 114 | ||||
-rw-r--r-- | test/dtypes.c | 16 | ||||
-rw-r--r-- | test/efc.c | 44 | ||||
-rw-r--r-- | test/file_image.c | 5 | ||||
-rw-r--r-- | test/fillval.c | 39 | ||||
-rw-r--r-- | test/gen_new_super.c | 36 | ||||
-rw-r--r-- | test/gen_nullspace.c | 29 | ||||
-rw-r--r-- | test/links.c | 521 | ||||
-rw-r--r-- | test/mtime.c | 10 | ||||
-rw-r--r-- | test/objcopy.c | 23 | ||||
-rw-r--r-- | test/set_extent.c | 3 | ||||
-rw-r--r-- | test/stab.c | 2 | ||||
-rw-r--r-- | test/tchecksum.c | 2 | ||||
-rw-r--r-- | test/tconfig.c | 6 | ||||
-rw-r--r-- | test/th5o.c | 30 | ||||
-rw-r--r-- | test/th5s.c | 3 | ||||
-rw-r--r-- | test/titerate.c | 6 | ||||
-rw-r--r-- | test/tmeta.c | 2 | ||||
-rw-r--r-- | test/tmisc.c | 137 | ||||
-rw-r--r-- | test/trefer.c | 64 | ||||
-rw-r--r-- | test/tselect.c | 4 | ||||
-rw-r--r-- | test/vds.c | 104 | ||||
-rw-r--r-- | test/vfd.c | 125 |
24 files changed, 947 insertions, 497 deletions
diff --git a/test/chunk_info.c b/test/chunk_info.c index 7cb2368..adb9df3 100644 --- a/test/chunk_info.c +++ b/test/chunk_info.c @@ -10,10 +10,7 @@ * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - /* - * Programmer: Pedro Vicente <pvn@hdfgroup.edu> - * April 7, 2008 * * Purpose: Tests chunk query API functions * @@ -136,12 +133,12 @@ void reinit_vars(unsigned *read_flt_msk, haddr_t *addr, hsize_t *size) } /*------------------------------------------------------------------------- - * Function: test_get_chunk_info_highest18 + * Function: test_get_chunk_info_highest18 * - * Purpose: Test getting various chunk information + * Purpose: Test getting various chunk information * - * Return: Success: SUCCEED - * Failure: FAIL + * Return: Success: SUCCEED + * Failure: FAIL * * Note: Note that the dataspace argument in these new functions are * currently not used. The functionality involved the dataspace @@ -206,7 +203,7 @@ test_get_chunk_info_highest18(hid_t fapl) if(chunkfile < 0) TEST_ERROR - /* Create the file and memory dataspaces */ + /* Create the file and memory dataspace */ if((dspace = H5Screate_simple(RANK, dims, maxdims)) < 0) TEST_ERROR @@ -389,7 +386,7 @@ test_get_chunk_info_highest18(hid_t fapl) if(H5Dclose(dset) < 0) TEST_ERROR /************************************************************************ - * Test empty dataset with H5P_ALLOC_TIME_EARLY * + * Test empty dataset with H5D_ALLOC_TIME_EARLY * ************************************************************************/ /* Set space allocation to early so that chunk query functions will @@ -417,9 +414,11 @@ test_get_chunk_info_highest18(hid_t fapl) ret = H5Dget_chunk_info(dset, dspace, index, out_offset, &read_flt_msk, &addr, &size); if(ret < 0) TEST_ERROR - /* Because of H5P_ALLOC_TIME_EARLY, addr cannot be HADDR_UNDEF and size not 0 */ - if(addr == HADDR_UNDEF) TEST_ERROR - if(size == 0) TEST_ERROR + /* Because of H5D_ALLOC_TIME_EARLY, addr cannot be HADDR_UNDEF and size not 0 */ + if(addr == HADDR_UNDEF) + TEST_ERROR + if(size == 0) + TEST_ERROR index = 10; reinit_vars(&read_flt_msk, &addr, &size); @@ -427,8 +426,10 @@ test_get_chunk_info_highest18(hid_t fapl) if(ret < 0) TEST_ERROR /* Because of H5P_ALLOC_TIME_EARLY, addr cannot be HADDR_UNDEF and size not 0 */ - if(addr == HADDR_UNDEF) TEST_ERROR - if(size == 0) TEST_ERROR + if(addr == HADDR_UNDEF) + TEST_ERROR + if(size == 0) + TEST_ERROR /* Attempt to get info of a chunk given its coords from an empty dataset, verify the returned address and size */ @@ -437,8 +438,10 @@ test_get_chunk_info_highest18(hid_t fapl) if(H5Dget_chunk_info_by_coord(dset, offset, &read_flt_msk, &addr, &size) < 0) TEST_ERROR /* Because of H5P_ALLOC_TIME_EARLY, addr cannot be HADDR_UNDEF and size not 0 */ - if(addr == HADDR_UNDEF) TEST_ERROR - if(size == 0) TEST_ERROR + if(addr == HADDR_UNDEF) + TEST_ERROR + if(size == 0) + TEST_ERROR if(H5Dclose(dset) < 0) TEST_ERROR @@ -463,13 +466,13 @@ error: } /* test_get_chunk_info_highest18() */ /*------------------------------------------------------------------------- - * Function: test_chunk_info_single_chunk + * Function: test_chunk_info_single_chunk * - * Purpose: Test getting various chunk information when Single Chunk + * Purpose: Test getting various chunk information when Single Chunk * index type is used * - * Return: Success: SUCCEED - * Failure: FAIL + * Return: Success: SUCCEED + * Failure: FAIL * * Note: Note that the dataspace argument in these new functions are * currently not used. The functionality involved the dataspace @@ -527,7 +530,7 @@ test_chunk_info_single_chunk(char *filename, hid_t fapl) if(idx_type != H5D_CHUNK_IDX_SINGLE) FAIL_PUTS_ERROR("should be using Single Chunk index type"); - /* Close the dataset then... */ + /* Close the dataset */ if(H5Dclose(dset) < 0) TEST_ERROR /* ...open it again to test the chunk query functions on a single empty @@ -590,13 +593,13 @@ error: } /* test_chunk_info_single_chunk() */ /*------------------------------------------------------------------------- - * Function: test_chunk_info_implicit + * Function: test_chunk_info_implicit * - * Purpose: Test getting various chunk information when Implicit + * Purpose: Test getting various chunk information when Implicit * index type is used * - * Return: Success: SUCCEED - * Failure: FAIL + * Return: Success: SUCCEED + * Failure: FAIL * * Note: Note that the dataspace argument in these new functions are * currently not used. The functionality involved the dataspace @@ -648,6 +651,7 @@ test_chunk_info_implicit(char *filename, hid_t fapl) if(H5Pset_chunk(cparms, RANK, chunk_dims) < 0) TEST_ERROR + /* Set allocation time to early */ if(H5Pset_alloc_time(cparms, H5D_ALLOC_TIME_EARLY) < 0) TEST_ERROR @@ -813,13 +817,13 @@ error: } /* test_chunk_info_implicit() */ /*------------------------------------------------------------------------- - * Function: test_chunk_info_fixed_array + * Function: test_chunk_info_fixed_array * - * Purpose: Test getting various chunk information when Fixed Array + * Purpose: Test getting various chunk information when Fixed Array * index type is used * - * Return: Success: SUCCEED - * Failure: FAIL + * Return: Success: SUCCEED + * Failure: FAIL * * Note: Note that the dataspace argument in these new functions are * currently not used. The functionality involved the dataspace @@ -1022,13 +1026,13 @@ error: } /* test_chunk_info_fixed_array() */ /*------------------------------------------------------------------------- - * Function: test_chunk_info_extensible_array + * Function: test_chunk_info_extensible_array * - * Purpose: Test getting various chunk information when Extensible Array + * Purpose: Test getting various chunk information when Extensible Array * index type is used * - * Return: Success: SUCCEED - * Failure: FAIL + * Return: Success: SUCCEED + * Failure: FAIL * * Note: Note that the dataspace argument in these new functions are * currently not used. The functionality involved the dataspace @@ -1041,13 +1045,13 @@ error: static herr_t test_chunk_info_extensible_array(char *filename, hid_t fapl) { - hid_t chunkfile = -1; /* File ID */ - hid_t dspace = -1; /* Dataspace ID */ - hid_t dset = -1; /* Dataset ID */ - hid_t cparms = -1; /* Creation plist */ - hsize_t dims[2] = {NX, NY};/* Dataset dimensions */ - hsize_t chunk_dims[2] = {CHUNK_NX, CHUNK_NY}; /* Chunk dimensions */ - hsize_t maxdims[2] = {H5S_UNLIMITED, NY}; /* One unlimited dimension */ + hid_t chunkfile = H5I_INVALID_HID; /* File ID */ + hid_t dspace = H5I_INVALID_HID; /* Dataspace ID */ + hid_t dset = H5I_INVALID_HID; /* Dataset ID */ + hid_t cparms = H5I_INVALID_HID; /* Creation plist */ + hsize_t dims[2] = {NX, NY}; /* Dataset dimensions */ + hsize_t chunk_dims[2] = {CHUNK_NX, CHUNK_NY}; /* Chunk dimensions */ + hsize_t maxdims[2] = {H5S_UNLIMITED, NY}; /* One unlimited dimension */ int direct_buf[NUM_CHUNKS][CHUNK_NX][CHUNK_NY];/* Data in chunks */ int out_buf[NX][NY]; /* Buffer to read data in */ size_t buf_size = CHUNK_NX*CHUNK_NY*sizeof(int); /* Buffer size of a chk */ @@ -1229,13 +1233,13 @@ error: } /* test_chunk_info_extensible_array() */ /*------------------------------------------------------------------------- - * Function: test_chunk_info_version2_btrees + * Function: test_chunk_info_version2_btrees * - * Purpose: Test getting various chunk information when Version 2 B-trees + * Purpose: Test getting various chunk information when Version 2 B-trees * index type is used * - * Return: Success: SUCCEED - * Failure: FAIL + * Return: Success: SUCCEED + * Failure: FAIL * * Note: Note that the dataspace argument in these new functions are * currently not used. The functionality involved the dataspace @@ -1248,10 +1252,10 @@ error: static herr_t test_chunk_info_version2_btrees(char *filename, hid_t fapl) { - hid_t chunkfile = -1; /* File ID */ - hid_t dspace = -1; /* Dataspace ID */ - hid_t dset = -1; /* Dataset ID */ - hid_t cparms = -1; /* Creation plist */ + hid_t chunkfile = H5I_INVALID_HID; /* File ID */ + hid_t dspace = H5I_INVALID_HID; /* Dataspace ID */ + hid_t dset = H5I_INVALID_HID; /* Dataset ID */ + hid_t cparms = H5I_INVALID_HID; /* Creation plist */ hsize_t dims[2] = {NX, NY};/* Dataset dimensions */ hsize_t chunk_dims[2] = {CHUNK_NX, CHUNK_NY}; /* Chunk dimensions */ hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Two unlimited dims */ @@ -1437,12 +1441,12 @@ error: /*------------------------------------------------------------------------- - * Function: test_get_chunk_info_110 + * Function: test_get_chunk_info_110 * - * Purpose: Test getting various chunk information in version 1.10. + * Purpose: Test getting various chunk information in version 1.10. * - * Return: Success: SUCCEED - * Failure: FAIL + * Return: Success: SUCCEED + * Failure: FAIL * * Note: Note that the dataspace argument in these new functions are * currently not used. The functionality involved the dataspace @@ -1533,7 +1537,7 @@ error: * later time, so it is kept here. * -BMR, November 5, 2018 * - * Programmer: Pedro Vicente <pvn@hdfgroup.edu> + * Programmer: Pedro Vicente * April 7, 2008 * *------------------------------------------------------------------------- @@ -1645,8 +1649,7 @@ error: * * Purpose: Tests functions related to chunk information * - * Return: Success: SUCCEED - * Failure: FAIL + * Return: EXIT_SUCCESS/EXIT_FAILURE * * Programmer: Binh-Minh Ribler * November 5, 2018 @@ -1656,7 +1659,7 @@ error: int main(void) { - hid_t fapl = -1; /* File access property list */ + hid_t fapl = H5I_INVALID_HID; /* File access property list */ int nerrors = 0; /* Number of errors so far */ h5_reset(); @@ -1681,13 +1684,13 @@ main(void) h5_cleanup(FILENAME, fapl); - return SUCCEED; + return EXIT_SUCCESS; error: nerrors = MAX(1, nerrors); HDprintf("***** %d QUERY CHUNK INFO TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S"); - return FAIL; + return EXIT_FAILURE; } /**************************************************************************** diff --git a/test/cork.c b/test/cork.c index 06a520d..5e17aba 100644 --- a/test/cork.c +++ b/test/cork.c @@ -99,9 +99,10 @@ verify_old_dset_cork(void) hsize_t dims[2] = {100, 20}; /* Dataset dimension sizes */ hsize_t max_dims[2] = {100, H5S_UNLIMITED}; /* Dataset maximum dimension sizes */ hsize_t chunk_dims[2] = {2, 5}; /* Dataset chunked dimension sizes */ - int buf[100][20]; /* Data buffer */ - int i = 0, j = 0; /* Local index variable */ - H5O_info_t oinfo, oinfo2, oinfo3; /* Object metadata information */ + int **buf = NULL; /* Data bufer (pointers to fake 2D array) */ + int *buf_data = NULL; /* Data buffer (actual data) */ + int i = 0, j = 0; /* Local index variables */ + H5O_info_t oinfo, oinfo2, oinfo3; /* Object metadata information */ hsize_t dims2[2] = {8, 16}; /* Dataset dimension sizes */ /* Testing Macro */ @@ -137,13 +138,21 @@ verify_old_dset_cork(void) if(H5C__verify_cork_tag_test(fid, oinfo.addr, TRUE) < 0) TEST_ERROR + /* Set up data array */ + if(NULL == (buf_data = (int *)HDcalloc(100 * 20, sizeof(int)))) + TEST_ERROR; + if(NULL == (buf = (int **)HDcalloc(100, sizeof(buf_data)))) + TEST_ERROR; + for (i = 0; i < 100; i++) + buf[i] = buf_data + (i * 20); + /* Initialize data buffer */ for(i = 0; i < (int)dims[0]; i++) for(j = 0; j < (int)dims[1]; j++) buf[i][j] = (i + 1) * (j + 1); /* Write to the dataset: DSET_BT1 */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) < 0) TEST_ERROR /* Verify the cork status for DSET_BT1 */ @@ -196,11 +205,6 @@ verify_old_dset_cork(void) if((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) TEST_ERROR - /* Initialize data buffer */ - for(i = 0; i < (int)dims[0]; i++) - for(j = 0; j < (int)dims[1]; j++) - buf[i][j] = (i + 1) * (j + 1); - /* Open and write to the dataset: DSET_BT1 */ if((did = H5Dopen2(fid, DSET_BT1, H5P_DEFAULT)) < 0) TEST_ERROR @@ -249,6 +253,9 @@ verify_old_dset_cork(void) if(H5Fclose(fid) < 0) TEST_ERROR + HDfree(buf); + HDfree(buf_data); + PASSED(); return 0; @@ -265,6 +272,10 @@ error: H5Pclose(dcpl3); H5Fclose(fid); } H5E_END_TRY; + + HDfree(buf); + HDfree(buf_data); + return 1; } /* verify_old_dset_cork */ @@ -496,9 +507,11 @@ verify_dset_cork(hbool_t swmr, hbool_t new_format) hsize_t dims[2] = {100, 20}; /* Dataset dimension sizes */ hsize_t max_dims[2] = {100, H5S_UNLIMITED}; /* Dataset maximum dimension sizes */ hsize_t chunk_dims[2] = {2, 5}; /* Dataset chunked dimension sizes */ - int buf[100][20]; int i = 0, j = 0; /* Data buffer */ - H5O_info_t oinfo, oinfo2, oinfo3; /* Object metadata information */ - unsigned flags; /* File access flags */ + int **buf = NULL; /* Data bufer (pointers to fake 2D array) */ + int *buf_data = NULL; /* Data buffer (actual data) */ + int i = 0, j = 0; /* Local index variables */ + H5O_info_t oinfo, oinfo2, oinfo3; /* Object metadata information */ + unsigned flags; /* File access flags */ /* Testing Macro */ if(swmr) { @@ -630,6 +643,14 @@ verify_dset_cork(hbool_t swmr, hbool_t new_format) if((fid = H5Fopen(FILENAME, flags, fapl)) < 0) TEST_ERROR + /* Set up data array */ + if(NULL == (buf_data = (int *)HDcalloc(100 * 20, sizeof(int)))) + TEST_ERROR; + if(NULL == (buf = (int **)HDcalloc(100, sizeof(buf_data)))) + TEST_ERROR; + for (i = 0; i < 100; i++) + buf[i] = buf_data + (i * 20); + /* Initialize data buffer */ for(i = 0; i < (int)dims[0]; i++) for(j = 0; j < (int)dims[1]; j++) @@ -638,7 +659,7 @@ verify_dset_cork(hbool_t swmr, hbool_t new_format) /* Open and write to the dataset: DSET_EA */ if((did = H5Dopen2(fid, DSET_EA, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) < 0) TEST_ERROR /* Verify the cork status for DSET_EA */ @@ -648,7 +669,7 @@ verify_dset_cork(hbool_t swmr, hbool_t new_format) /* Open and write to the dataset: DSET_FA */ if((did2 = H5Dopen2(fid, DSET_FA, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if(H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) < 0) TEST_ERROR /* Cork the dataset: DSET_FA */ @@ -662,7 +683,7 @@ verify_dset_cork(hbool_t swmr, hbool_t new_format) /* Open and write to the dataset: DSET_BT2 */ if((did3 = H5Dopen2(fid, DSET_BT2, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dwrite(did3, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if(H5Dwrite(did3, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) < 0) TEST_ERROR /* Verify the cork status for DSET_BT2 */ @@ -689,6 +710,9 @@ verify_dset_cork(hbool_t swmr, hbool_t new_format) if(H5Fclose(fid) < 0) TEST_ERROR + HDfree(buf); + HDfree(buf_data); + PASSED(); return 0; @@ -704,6 +728,10 @@ error: H5Pclose(fapl); H5Fclose(fid); } H5E_END_TRY; + + HDfree(buf); + HDfree(buf_data); + return 1; } /* verify_dset_cork */ @@ -729,11 +757,11 @@ verify_group_cork(hbool_t swmr) hid_t fid = -1; /* File ID */ hid_t fapl = -1; /* File access property list */ hid_t gid = -1, gid2 = -1, gid3 = -1; /* Group IDs */ - H5O_info_t oinfo, oinfo2, oinfo3; /* Object metadata information */ - hid_t aid; /* Attribute ID */ - hid_t sid; /* Dataspace ID */ + H5O_info_t oinfo, oinfo2, oinfo3; /* Object metadata information */ + hid_t aid; /* Attribute ID */ + hid_t sid; /* Dataspace ID */ char attrname[500]; /* Name of attribute */ - unsigned flags; /* File access flags */ + unsigned flags; /* File access flags */ int i = 0; /* Local index variable */ /* Testing Macro */ @@ -898,11 +926,11 @@ verify_named_cork(hbool_t swmr) hid_t tid = -1, tid2 = -1, tid3 = -1; /* Datatype IDs */ hid_t gid = -1, gid2 = -1; /* Group IDs */ H5O_info_t oinfo, oinfo2, oinfo3, oinfo4; /* Object metadata information */ - hid_t aid = -1; /* Attribute ID */ - hid_t sid; /* Dataspace ID */ - hid_t did; /* Dataset ID */ + hid_t aid = -1; /* Attribute ID */ + hid_t sid; /* Dataspace ID */ + hid_t did; /* Dataset ID */ char attrname[500]; /* Name of attribute */ - unsigned flags; /* File access flags */ + unsigned flags; /* File access flags */ int i = 0; /* Local index variable */ /* Testing Macro */ @@ -1179,9 +1207,9 @@ verify_multiple_cork(hbool_t swmr) hid_t aidt1 = -1, aidt2 = -1; /* Attribute ID */ hid_t sid = -1; /* Dataspace ID */ H5O_info_t oinfo1, oinfo2, oinfo3; /* Object metadata information */ - hsize_t dim[1] = {5}; /* Dimension sizes */ - unsigned flags; /* File access flags */ - hbool_t corked; /* Cork status */ + hsize_t dim[1] = {5}; /* Dimension sizes */ + unsigned flags; /* File access flags */ + hbool_t corked; /* Cork status */ herr_t ret; /* Return value */ /* Testing Macro */ @@ -1826,8 +1854,9 @@ test_dset_cork(hbool_t swmr, hbool_t new_format) hsize_t cdims[RANK] = {2,2}; /* Chunk dimensions */ int fillval = 0; /* Fill value */ int i, j, k = 0; /* Local index variables */ - int data[DIMS0][DIMS1]; /* Data buffer */ - int rbuf[DIMS0][DIMS1]; /* Data buffer */ + int **wbuf = NULL; /* Data buffer for writes (pointers to fake 2D array) */ + int *wbuf_data = NULL; /* Data buffer for writes (real data) */ + int *rbuf_data = NULL; /* Data buffer for reads (real data) */ hbool_t corked; /* Cork status of an object */ unsigned flags; /* File access flags */ @@ -1923,13 +1952,21 @@ test_dset_cork(hbool_t swmr, hbool_t new_format) if(corked) TEST_ERROR + /* Set up data array */ + if(NULL == (wbuf_data = (int *)HDcalloc(DIMS0 * DIMS1, sizeof(int)))) + TEST_ERROR; + if(NULL == (wbuf = (int **)HDcalloc(DIMS0, sizeof(wbuf_data)))) + TEST_ERROR; + for (i = 0; i < DIMS0; i++) + wbuf[i] = wbuf_data + (i * DIMS1); + /* Initialize the buffer */ for(i = 0; i < DIMS0;i++) for(j = 0;j < DIMS1;j++) - data[i][j] = k++; + wbuf[i][j] = k++; /* Write to the dataset */ - if(H5Dwrite(did1, tid1, sid, sid, H5P_DEFAULT, data) < 0) + if(H5Dwrite(did1, tid1, sid, sid, H5P_DEFAULT, wbuf_data) < 0) TEST_ERROR /* Flush the dataset */ @@ -1962,8 +1999,12 @@ test_dset_cork(hbool_t swmr, hbool_t new_format) if(corked) TEST_ERROR + /* Set up data array */ + if(NULL == (rbuf_data = (int *)HDcalloc(DIMS0 * DIMS1, sizeof(int)))) + TEST_ERROR; + /* Read from the dataset */ - if(H5Dread(did1, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + if(H5Dread(did1, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf_data) < 0) TEST_ERROR /* Cork the dataset */ @@ -1993,7 +2034,7 @@ test_dset_cork(hbool_t swmr, hbool_t new_format) TEST_ERROR /* Write to the dataset */ - if(H5Dwrite(did1, tid1, sid, sid, H5P_DEFAULT, data) < 0) + if(H5Dwrite(did1, tid1, sid, sid, H5P_DEFAULT, wbuf_data) < 0) TEST_ERROR /* Refresh the dataset */ @@ -2106,6 +2147,10 @@ test_dset_cork(hbool_t swmr, hbool_t new_format) if(H5Pclose(dcpl) < 0) TEST_ERROR + HDfree(wbuf); + HDfree(wbuf_data); + HDfree(rbuf_data); + PASSED(); return 0; @@ -2121,6 +2166,11 @@ error: H5Pclose(fapl); H5Fclose(fid); } H5E_END_TRY; + + HDfree(wbuf); + HDfree(wbuf_data); + HDfree(rbuf_data); + return 1; } /* test_dset_cork() */ diff --git a/test/dtypes.c b/test/dtypes.c index 6d81392..c89688c 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -659,8 +659,8 @@ error: * destination are the same except for the order of the * elements. * - * Return: Success: 0 - * Failure: number of errors + * Return: Success: 0 + * Failure: number of errors * * Programmer: Robb Matzke * Thursday, June 17, 1999 @@ -6099,7 +6099,8 @@ test_int_float_except(void) /* Convert second buffer */ HDmemset(&e, 0, sizeof(except_info_t)); - if(H5Tconvert(H5T_NATIVE_INT, H5T_NATIVE_FLOAT, (size_t)CONVERT_SIZE, buf2, NULL, dxpl) < 0) TEST_ERROR + if(H5Tconvert(H5T_NATIVE_INT, H5T_NATIVE_FLOAT, (size_t)CONVERT_SIZE, buf2, NULL, dxpl) < 0) + TEST_ERROR /* Check the buffer after conversion, as floats */ for(u = 0; u < CONVERT_SIZE; u++) { @@ -6116,7 +6117,8 @@ test_int_float_except(void) /* Convert buffer */ HDmemset(&e, 0, sizeof(except_info_t)); - if(H5Tconvert(H5T_NATIVE_FLOAT, H5T_NATIVE_INT, (size_t)CONVERT_SIZE, buf2, NULL, dxpl) < 0) TEST_ERROR + if(H5Tconvert(H5T_NATIVE_FLOAT, H5T_NATIVE_INT, (size_t)CONVERT_SIZE, buf2, NULL, dxpl) < 0) + TEST_ERROR /* Check the buffer after conversion, as integers */ for(u = 0; u < CONVERT_SIZE; u++) { @@ -6660,7 +6662,7 @@ static void create_del_obj_named_test_file(const char *filename, hid_t fapl, hid_t my_fapl; /* Copy of file access property list ID */ hid_t dcpl; /* Dataset creation property list ID */ unsigned use_at_least_v18;/* Whether to use old or new format */ - herr_t status; /* Generic return value */ + herr_t H5_ATTR_NDEBUG_UNUSED status; /* Generic return value */ /* Make copy of FAPL */ my_fapl = H5Pcopy(fapl); @@ -7757,8 +7759,8 @@ error: int main(void) { - long nerrors = 0; - hid_t fapl = -1; + long nerrors = 0; + hid_t fapl = H5I_INVALID_HID; /* Set the random # seed */ HDsrandom((unsigned)HDtime(NULL)); @@ -31,8 +31,14 @@ const char *FILENAME[] = { NULL }; +/* Windows doesn't have PATH_MAX */ +#ifndef PATH_MAX +#define PATH_MAX 4096 +#endif /* !PATH_MAX */ + /* Global patched filename buffer */ -static char filename[6][1024]; +#define N_FILENAMES 6 +static char *filename[N_FILENAMES]; /* Global property lists - just copies of the defaults (necessary to use * internal functions */ @@ -2895,8 +2901,9 @@ error: int main(void) { - unsigned nerrors = 0; /* track errors */ - hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + unsigned nerrors = 0; /* track errors */ + hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + int i; /* iterator */ /* Test Setup */ HDputs("Testing the external file cache"); @@ -2905,13 +2912,18 @@ main(void) fcpl_id = H5Pcreate(H5P_FILE_CREATE); fapl_id = h5_fileaccess(); + /* Allocate memory for filenames */ + for(i = 0; i < N_FILENAMES; i++) { + filename[i] = (char *)HDcalloc(PATH_MAX, sizeof(char)); + } + /* Patch filenames */ - h5_fixname(FILENAME[0], fapl_id, filename[0], sizeof(filename[0])); - h5_fixname(FILENAME[1], fapl_id, filename[1], sizeof(filename[1])); - h5_fixname(FILENAME[2], fapl_id, filename[2], sizeof(filename[2])); - h5_fixname(FILENAME[3], fapl_id, filename[3], sizeof(filename[3])); - h5_fixname(FILENAME[4], fapl_id, filename[4], sizeof(filename[4])); - h5_fixname(FILENAME[5], fapl_id, filename[5], sizeof(filename[5])); + h5_fixname(FILENAME[0], fapl_id, filename[0], PATH_MAX); + h5_fixname(FILENAME[1], fapl_id, filename[1], PATH_MAX); + h5_fixname(FILENAME[2], fapl_id, filename[2], PATH_MAX); + h5_fixname(FILENAME[3], fapl_id, filename[3], PATH_MAX); + h5_fixname(FILENAME[4], fapl_id, filename[4], PATH_MAX); + h5_fixname(FILENAME[5], fapl_id, filename[5], PATH_MAX); /* Push API context */ if(H5CX_push() < 0) FAIL_STACK_ERROR @@ -2930,7 +2942,8 @@ main(void) nerrors += (h5_verify_cached_stabs(FILENAME, fapl_id) < 0 ? 1 : 0); /* Pop API context */ - if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR + if(api_ctx_pushed && H5CX_pop() < 0) + FAIL_STACK_ERROR api_ctx_pushed = FALSE; if(nerrors) @@ -2940,6 +2953,10 @@ main(void) h5_clean_files(FILENAME, fapl_id); + for(i = 0; i < N_FILENAMES; i++) { + HDfree(filename[i]); + } + return EXIT_SUCCESS; error: @@ -2949,7 +2966,12 @@ error: H5Pclose(fapl_id); } H5E_END_TRY - if(api_ctx_pushed) H5CX_pop(); + if(api_ctx_pushed) + H5CX_pop(); + + for(i = 0; i < N_FILENAMES; i++) { + HDfree(filename[i]); + } return EXIT_FAILURE; } /* end main() */ diff --git a/test/file_image.c b/test/file_image.c index 87967b7..4898b92 100644 --- a/test/file_image.c +++ b/test/file_image.c @@ -677,8 +677,7 @@ error: * 'member_file_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 test_get_file_image(const char * test_banner, const int file_name_num, @@ -945,7 +944,7 @@ test_get_file_image(const char * test_banner, error: return 1; } /* end test_get_file_image() */ -#pragma GCC diagnostic pop +H5_GCC_DIAG_ON(format-nonliteral) /****************************************************************************** diff --git a/test/fillval.c b/test/fillval.c index 0454bde..106bb20 100644 --- a/test/fillval.c +++ b/test/fillval.c @@ -758,10 +758,15 @@ test_rdwr_cases(hid_t file, hid_t dcpl, const char *dname, void *_fillval, int fillval=(-1), val_rd, should_be; int i, j, *buf=NULL, odd; unsigned u; - comp_datatype rd_c, fill_c, should_be_c; + comp_datatype rd_c, fill_c, should_be_c; comp_datatype *buf_c=NULL; H5D_space_status_t allocation; + fill_c.a = 0; + fill_c.x = 0; + fill_c.y = 0; + fill_c.z = 0; + if(datatype == H5T_INTEGER) { fillval = *(int*)_fillval; } @@ -822,7 +827,7 @@ test_rdwr_cases(hid_t file, hid_t dcpl, const char *dname, void *_fillval, hs_offset[0], hs_offset[1], hs_offset[2], hs_offset[3], hs_offset[4], (double)rd_c.a, rd_c.x, rd_c.y, rd_c.z, - (double)fill_c.a, fill_c.x, fill_c.y, fill_c.z); + (double)fill_c.a, fill_c.x, fill_c.y, fill_c.z); goto error; } } @@ -1448,12 +1453,16 @@ test_extend_cases(hid_t file, hid_t _dcpl, const char *dset_name, void *val_rd, *odd_val; const void *init_val, *should_be, *even_val; int val_rd_i, init_val_i = 9999; - comp_vl_datatype init_val_c = {87, "baz", "mumble", 129}; + comp_vl_datatype init_val_c = {87, NULL, NULL, 129}; comp_vl_datatype val_rd_c; void *buf = NULL; unsigned odd; /* Whether an odd or even coord. was read */ unsigned i, j; /* Local index variables */ + /* Set vl datatype init value strings */ + init_val_c.a = HDstrdup("baz"); + init_val_c.b = HDstrdup("mumble"); + /* Make copy of dataset creation property list */ if((dcpl = H5Pcopy(_dcpl)) < 0) TEST_ERROR @@ -1797,6 +1806,9 @@ test_extend_cases(hid_t file, hid_t _dcpl, const char *dset_name, /* Release elements & memory buffer */ for(i = 0; i < nelmts; i++) release_rtn((void *)((char *)buf + (val_size * i))); + + HDfree(init_val_c.a); + HDfree(init_val_c.b); HDfree(buf); buf = NULL; @@ -1808,8 +1820,10 @@ test_extend_cases(hid_t file, hid_t _dcpl, const char *dset_name, return 0; error: - if(buf) - HDfree(buf); + HDfree(init_val_c.a); + HDfree(init_val_c.b); + HDfree(buf); + H5E_BEGIN_TRY { H5Pclose(dcpl); H5Dclose(dset); @@ -1851,7 +1865,7 @@ test_extend(hid_t fapl, const char *base_name, H5D_layout_t layout) #else int fillval_i = 0x4c70f1cd; #endif - comp_vl_datatype fillval_c = {32, "foo", "bar", 64}; /* Fill value for compound+vl datatype tests */ + comp_vl_datatype fillval_c = {32, NULL, NULL, 64}; /* Fill value for compound+vl datatype tests */ char filename[1024]; /* Print testing message */ @@ -1860,6 +1874,10 @@ test_extend(hid_t fapl, const char *base_name, H5D_layout_t layout) else TESTING("contiguous dataset extend") + /* Set vl datatype fill value strings */ + fillval_c.a = HDstrdup("foo"); + fillval_c.b = HDstrdup("bar"); + /* Create dataset creation property list */ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR if(H5D_CHUNKED == layout) @@ -1940,11 +1958,17 @@ test_extend(hid_t fapl, const char *base_name, H5D_layout_t layout) if(H5Pclose(dcpl) < 0) TEST_ERROR if(H5Fclose(file) < 0) TEST_ERROR + HDfree(fillval_c.a); + HDfree(fillval_c.b); + PASSED(); return 0; error: + HDfree(fillval_c.a); + HDfree(fillval_c.b); + H5E_BEGIN_TRY { H5Tclose(cmpd_vl_tid); H5Pclose(dcpl); @@ -1953,6 +1977,9 @@ error: return 1; skip: + HDfree(fillval_c.a); + HDfree(fillval_c.b); + H5E_BEGIN_TRY { H5Pclose(dcpl); H5Fclose(file); diff --git a/test/gen_new_super.c b/test/gen_new_super.c index f6ce589..d371f5f 100644 --- a/test/gen_new_super.c +++ b/test/gen_new_super.c @@ -23,26 +23,22 @@ * put into the 'test' directory in the 1.4+ branch of the library. */ -#include <assert.h> -#include "hdf5.h" +#include "h5test.h" #define TESTFILE "tsupern.h5" #define ISTORE_IK 64 /*------------------------------------------------------------------------- - * Function: main + * Function: main * - * Purpose: Create a file with a new version (>0) of the superblock + * Purpose: Create a file with a new version (>0) of the superblock * - * Return: Success: - * Failure: + * Return: EXIT_SUCCESS * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Tuesday, July 15, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ int @@ -50,31 +46,31 @@ main(void) { hid_t file; /* File IDs for old & new files */ hid_t fcpl; /* File creation property list */ - herr_t ret; /* Generic return value */ + herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Create a file creation property list */ fcpl = H5Pcreate(H5P_FILE_CREATE); - assert(fcpl>=0); + HDassert(fcpl >= 0); - ret=H5Pset_istore_k(fcpl,ISTORE_IK); - assert(ret>=0); + ret = H5Pset_istore_k(fcpl,ISTORE_IK); + HDassert(ret >= 0); /* Creating a file with the non-default file creation property list should * create a version 1 superblock */ /* Create file with custom file creation property list */ - file= H5Fcreate(TESTFILE, H5F_ACC_TRUNC , fcpl, H5P_DEFAULT); - assert(file>=0); + file = H5Fcreate(TESTFILE, H5F_ACC_TRUNC , fcpl, H5P_DEFAULT); + HDassert(file >= 0); /* Close FCPL */ - ret=H5Pclose(fcpl); - assert(ret>=0); + ret = H5Pclose(fcpl); + HDassert(ret >= 0); /* Close file */ - ret=H5Fclose(file); - assert(ret>=0); + ret = H5Fclose(file); + HDassert(ret >= 0); - return 0; + return EXIT_SUCCESS; } diff --git a/test/gen_nullspace.c b/test/gen_nullspace.c index 9d76deb..26df3f1 100644 --- a/test/gen_nullspace.c +++ b/test/gen_nullspace.c @@ -12,7 +12,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu> + * Programmer: Quincey Koziol * Saturday, April 17, 2004 * * Purpose: Create a dataset with a null dataspace and an attribute @@ -24,8 +24,7 @@ * put into the 'test' directory in the 1.6.x branch of the library. */ -#include "hdf5.h" -#include <assert.h> +#include "h5test.h" #define NULLFILE "tnullspace.h5" #define NULLDATASET "null_dataset" @@ -39,48 +38,48 @@ main(void) hid_t sid; /* Dataspace ID */ hid_t did; /* Dataset ID */ hid_t attr; /* Attribute ID */ - herr_t ret; /* Generic return value */ + herr_t H5_ATTR_NDEBUG_UNUSED ret; /* Generic return value */ /* Create the file */ fid = H5Fcreate(NULLFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - assert(fid>0); + HDassert(fid > 0); sid = H5Screate(H5S_NULL); - assert(sid>0); + HDassert(sid > 0); /* Create dataset */ did = H5Dcreate2(fid, NULLDATASET, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - assert(did>0); + HDassert(did > 0); /* Close the dataset */ ret = H5Dclose(did); - assert(ret>=0); + HDassert(ret >= 0); /* Open the root group */ gid = H5Gopen2(fid, "/", H5P_DEFAULT); - assert(gid > 0); + HDassert(gid > 0); /* Create an attribute for the group */ attr = H5Acreate2(gid, NULLATTR, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT); - assert(attr > 0); + HDassert(attr > 0); /* Close attribute */ ret = H5Aclose(attr); - assert(ret>=0); + HDassert(ret >= 0); /* Close the group */ ret = H5Gclose(gid); - assert(ret>=0); + HDassert(ret >= 0); /* Close the dataspace */ ret = H5Sclose(sid); - assert(ret>=0); + HDassert(ret >= 0); /* Close the file */ ret = H5Fclose(fid); - assert(ret>=0); + HDassert(ret >= 0); - return 0; + return EXIT_SUCCESS; } diff --git a/test/links.c b/test/links.c index 0c10b44..8011cca 100644 --- a/test/links.c +++ b/test/links.c @@ -31,10 +31,10 @@ #include "h5test.h" #include "H5srcdir.h" -#include "H5FDpkg.h" /* File drivers */ -#include "H5Gpkg.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ +#include "H5FDpkg.h" /* File drivers */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ /* File for external link test. Created with gen_udlinks.c */ #define LINKED_FILE "be_extlink2.h5" @@ -314,7 +314,93 @@ typedef struct { static hid_t dcpl_g; /* for [un]minimized dataset object headers */ +static herr_t +UD_hard_create(const char *link_name, hid_t loc_group, const void *udata, + size_t udata_size, hid_t lcpl_id); +static hid_t +UD_hard_traverse(const char *link_name, hid_t cur_group, + const void *udata, size_t udata_size, hid_t lapl_id, + hid_t dxpl_id); +static herr_t +UD_hard_delete(const char *link_name, hid_t file, const void *udata, + size_t udata_size); + +/* User-defined link class */ +const H5L_class_t UD_hard_class[1] = {{ + H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ + (H5L_type_t)UD_HARD_TYPE, /* Link type id number */ + "UD_hard_link", /* Link class name for debugging */ + UD_hard_create, /* Creation callback */ + NULL, /* Move/rename callback */ + NULL, /* Copy callback */ + UD_hard_traverse, /* The actual traversal function */ + UD_hard_delete, /* Deletion callback */ + NULL /* Query callback */ +}}; + +static hid_t +UD_rereg_traverse(const char *link_name, hid_t cur_group, + const void *udata, size_t udata_size, hid_t lapl_id, + hid_t dxpl_id); + +/* This link class has the same ID number as the UD hard links but + * has a very different traversal function */ +const H5L_class_t UD_rereg_class[1] = {{ + H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ + (H5L_type_t)UD_HARD_TYPE, /* Link type id number */ + "UD_reregistered_type", /* Link class name for debugging */ + NULL, /* Creation callback */ + NULL, /* Move/rename callback */ + NULL, /* Copy callback */ + UD_rereg_traverse, /* The actual traversal function */ + NULL, /* Deletion callback */ + NULL /* Query callback */ +}}; +static herr_t +UD_cb_create(const char * link_name, hid_t loc_group, const void *udata, + size_t udata_size, hid_t lcpl_id); +static herr_t +UD_cb_move(const char *new_name, hid_t new_loc, const void *udata, + size_t udata_size); +static hid_t +UD_cb_traverse(const char * link_name, hid_t cur_group, const void *udata, + size_t udata_size, hid_t lapl_id, hid_t dxpl_id); +static herr_t +UD_cb_delete(const char *link_name, hid_t file, const void *udata, + size_t udata_size); +static ssize_t +UD_cb_query(const char * link_name, const void *udata, size_t udata_size, + void *buf, size_t buf_size); + +const H5L_class_t UD_cb_class[1] = {{ + H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ + (H5L_type_t)UD_CB_TYPE, /* Link type id number */ + NULL, /* NULL name (to make sure this doesn't break anything */ + UD_cb_create, /* Creation callback */ + UD_cb_move, /* Move/rename callback */ + UD_cb_move, /* Copy callback */ + UD_cb_traverse, /* The actual traversal function */ + UD_cb_delete, /* Deletion callback */ + UD_cb_query /* Query callback */ +}}; + +static hid_t +UD_plist_traverse(const char *link_name, hid_t cur_group, + const void *udata, size_t udata_size, hid_t lapl_id, + hid_t dxpl_id); + +const H5L_class_t UD_plist_class[1] = {{ + H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ + (H5L_type_t)UD_PLIST_TYPE, /* Link type id number */ + "UD_plist_link", /* Link class name for debugging */ + NULL, /* Creation callback */ + NULL, /* Move/rename callback */ + NULL, /* Copy callback */ + UD_plist_traverse, /* The actual traversal function */ + NULL, /* Deletion callback */ + NULL /* Query callback */ +}}; /*------------------------------------------------------------------------- * Function: fix_ext_filename @@ -635,7 +721,7 @@ cklinks(hid_t fapl, hbool_t new_format) error: return FAIL; -} +} /* end cklinks() */ /*------------------------------------------------------------------------- @@ -686,11 +772,11 @@ ck_new_links(hid_t fapl, hbool_t new_format) if(H5Fclose(file) < 0) TEST_ERROR PASSED(); - return SUCCEED; + return 0; error: - return FAIL; -} + return -1; +} /* end ck_new_links() */ /*------------------------------------------------------------------------- @@ -3460,12 +3546,13 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) hid_t did = H5I_INVALID_HID; hid_t dapl_id = H5I_INVALID_HID; hid_t dcpl = H5I_INVALID_HID; - char filename1[NAME_BUF_SIZE], - filename2[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE], - cwdpath[NAME_BUF_SIZE]; + char *filename1 = NULL; + char *filename2 = NULL; + char *tmpname = NULL; + char *cwdpath = NULL; hsize_t dims[2]; - int points[NUM40][NUM40]; + int **points = NULL; + int *points_data = NULL; int i, j, n; h5_stat_size_t filesize; h5_stat_size_t new_filesize; @@ -3475,16 +3562,34 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) else TESTING("H5Pset/get_elink_fapl() with same physical layout") + /* Set up file names and paths */ + if(NULL == (filename1 = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + if(NULL == (filename2 = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + if(NULL == (tmpname = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + if(NULL == (cwdpath = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + if((HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) || (NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE))) TEST_ERROR + /* Set up data array */ + if(NULL == (points_data = (int *)HDcalloc(NUM40 * NUM40, sizeof(int)))) + TEST_ERROR; + if(NULL == (points = (int **)HDcalloc(NUM40, sizeof(points_data)))) + TEST_ERROR; + for (i = 0; i < NUM40; i++) + points[i] = points_data + (i * NUM40); + /* * set up name for main file: * Linux: "/CWD/tmp_links/extlinks0" * Windows: "<cur drive>:/CWD/tmp_links/extlinks0" */ fix_ext_filename(tmpname, cwdpath, FILENAME[13]); - h5_fixname(tmpname, fapl, filename1, sizeof filename1); + h5_fixname(tmpname, fapl, filename1, NAME_BUF_SIZE); /* create fapl for the target file to be a "core" file */ core_fapl = h5_fileaccess(); @@ -3492,7 +3597,7 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) /* set up name for external linked target file: "extlinks17" */ /* set up name for target file: "extlinks17" */ - h5_fixname(FILENAME[39], core_fapl, filename2, sizeof filename2); + h5_fixname(FILENAME[39], core_fapl, filename2, NAME_BUF_SIZE); /* Create the target file to be a "core" file */ if((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, core_fapl)) < 0) TEST_ERROR @@ -3551,7 +3656,7 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) points[i][j] = n++; /* Write the data to the dataset */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0) TEST_ERROR + if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points_data) < 0) TEST_ERROR if(H5Pclose(dapl_id) < 0) TEST_ERROR if(H5Dclose(did) < 0) TEST_ERROR @@ -3564,6 +3669,14 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) if(H5Pclose(core_fapl) < 0) TEST_ERROR + HDfree(points); + HDfree(points_data); + + HDfree(filename1); + HDfree(filename2); + HDfree(tmpname); + HDfree(cwdpath); + PASSED(); return SUCCEED; @@ -3578,6 +3691,15 @@ error: H5Gclose(gid); H5Fclose(fid); } H5E_END_TRY; + + HDfree(points); + HDfree(points_data); + + HDfree(filename1); + HDfree(filename2); + HDfree(tmpname); + HDfree(cwdpath); + return FAIL; } /* end external_set_elink_fapl2() */ @@ -6062,19 +6184,26 @@ static int external_symlink(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) { #ifdef H5_HAVE_SYMLINK - hid_t file1 = -1, file2 = -1, file3 = -1, file4 = -1, file5 = -1; - hid_t group2 = -1, group3 = -1, group4 = -1, group5 = -1; - char filename1[NAME_BUF_SIZE], - filename2a[NAME_BUF_SIZE], - filename2b[NAME_BUF_SIZE], - filename3a[NAME_BUF_SIZE], - filename3b[NAME_BUF_SIZE], - filename4a[NAME_BUF_SIZE], - filename4b[NAME_BUF_SIZE], - filename5a[NAME_BUF_SIZE], - filename5b[NAME_BUF_SIZE], - tmpname[NAME_BUF_SIZE], - cwdpath[NAME_BUF_SIZE]; + hid_t file1 = H5I_INVALID_HID; + hid_t file2 = H5I_INVALID_HID; + hid_t file3 = H5I_INVALID_HID; + hid_t file4 = H5I_INVALID_HID; + hid_t file5 = H5I_INVALID_HID; + hid_t group2 = H5I_INVALID_HID; + hid_t group3 = H5I_INVALID_HID; + hid_t group4 = H5I_INVALID_HID; + hid_t group5 = H5I_INVALID_HID; + char *filename1 = NULL; + char *filename2a = NULL; + char *filename2b = NULL; + char *filename3a = NULL; + char *filename3b = NULL; + char *filename4a = NULL; + char *filename4b = NULL; + char *filename5a = NULL; + char *filename5b = NULL; + char *tmpname = NULL; + char *cwdpath = NULL; hbool_t have_posix_compat_vfd; /* Whether VFD used is compatible w/POSIX I/O calls */ #endif /* H5_HAVE_SYMLINK */ @@ -6090,144 +6219,179 @@ external_symlink(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) have_posix_compat_vfd = (hbool_t)(!HDstrcmp(env_h5_drvr, "sec2") || !HDstrcmp(env_h5_drvr, "core") || !HDstrcmp(env_h5_drvr, "nomatch")); - if(have_posix_compat_vfd) { - /* set up name for main file: "extlinks21A" */ - h5_fixname(FILENAME[45], fapl, filename1, sizeof(filename1)); + if(!have_posix_compat_vfd) { + SKIPPED(); + HDputs(" Current VFD doesn't support POSIX I/O calls"); + return SUCCEED; + } - /* create tmp_links directory and get current working directory path */ - if(HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) - TEST_ERROR - if(HDmkdir(TMPDIR2, (mode_t)0755) < 0 && errno != EEXIST) - TEST_ERROR - if(NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE)) - TEST_ERROR + if(NULL == (filename1 = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + if(NULL == (filename2a = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + if(NULL == (filename2b = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + if(NULL == (filename3a = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + if(NULL == (filename3b = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + if(NULL == (filename4a = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + if(NULL == (filename4b = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + if(NULL == (filename5a = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + if(NULL == (filename5b = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + if(NULL == (tmpname = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; + if(NULL == (cwdpath = (char *)HDcalloc(NAME_BUF_SIZE, sizeof(char)))) + TEST_ERROR; - /* Set up names for files in the subdirectories */ + /* set up name for main file: "extlinks21A" */ + h5_fixname(FILENAME[45], fapl, filename1, NAME_BUF_SIZE); - /* set up names for file #2 in temporary directory #2: "tmp2_links/extlinks21B" */ - h5_fixname(FILENAME[46], fapl, filename2a, sizeof(filename2a)); - fix_ext_filename(tmpname, cwdpath, FILENAME[46]); - h5_fixname(tmpname, fapl, filename2b, sizeof(filename2b)); + /* create tmp_links directory and get current working directory path */ + if(HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) + TEST_ERROR + if(HDmkdir(TMPDIR2, (mode_t)0755) < 0 && errno != EEXIST) + TEST_ERROR + if(NULL == HDgetcwd(cwdpath, (size_t)NAME_BUF_SIZE)) + TEST_ERROR - /* Create symbolic link #1 in temporary directory #1 to file #2 in temporary directory #2 */ - /* (i.e. tmp_links/sym1.h5 -> <full path to>/tmp2_links/extlinks21B.h5) */ - if(HDsymlink(filename2b, SYMLINK1) < 0 && errno != EEXIST) TEST_ERROR + /* Set up names for files in the subdirectories */ - /* set up name for file #3 in temporary directory #2: "tmp2_links/extlinks21C" */ - h5_fixname(FILENAME[47], fapl, filename3a, sizeof(filename3a)); - h5_fixname(FILENAME[48], fapl, filename3b, sizeof(filename3b)); + /* set up names for file #2 in temporary directory #2: "tmp2_links/extlinks21B" */ + h5_fixname(FILENAME[46], fapl, filename2a, NAME_BUF_SIZE); + fix_ext_filename(tmpname, cwdpath, FILENAME[46]); + h5_fixname(tmpname, fapl, filename2b, NAME_BUF_SIZE); - /* set up name for file #4 in temporary directory #1: "tmp_links/extlinks21D" */ - h5_fixname(FILENAME[49], fapl, filename4a, sizeof(filename4a)); - fix_ext_filename(tmpname, cwdpath, FILENAME[49]); - h5_fixname(tmpname, fapl, filename4b, sizeof(filename4b)); + /* Create symbolic link #1 in temporary directory #1 to file #2 in temporary directory #2 */ + /* (i.e. tmp_links/sym1.h5 -> <full path to>/tmp2_links/extlinks21B.h5) */ + if(HDsymlink(filename2b, SYMLINK1) < 0 && errno != EEXIST) TEST_ERROR - /* Create symbolic link #2 in temporary directory #2 to file #4 in temporary directory #1 */ - /* (i.e. tmp2_links/sym2.h5 -> <full path to>/tmp_links/extlinks21D.h5) */ - if(HDsymlink(filename4b, SYMLINK2) < 0 && errno != EEXIST) TEST_ERROR + /* set up name for file #3 in temporary directory #2: "tmp2_links/extlinks21C" */ + h5_fixname(FILENAME[47], fapl, filename3a, NAME_BUF_SIZE); + h5_fixname(FILENAME[48], fapl, filename3b, NAME_BUF_SIZE); - /* set up name for file #5 in temporary directory #1: "tmp_links/extlinks21E" */ - h5_fixname(FILENAME[50], fapl, filename5a, sizeof(filename5a)); - h5_fixname(FILENAME[51], fapl, filename5b, sizeof(filename5b)); + /* set up name for file #4 in temporary directory #1: "tmp_links/extlinks21D" */ + h5_fixname(FILENAME[49], fapl, filename4a, NAME_BUF_SIZE); + fix_ext_filename(tmpname, cwdpath, FILENAME[49]); + h5_fixname(tmpname, fapl, filename4b, NAME_BUF_SIZE); - /* Create file #1 in current directory */ - if((file1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + /* Create symbolic link #2 in temporary directory #2 to file #4 in temporary directory #1 */ + /* (i.e. tmp2_links/sym2.h5 -> <full path to>/tmp_links/extlinks21D.h5) */ + if(HDsymlink(filename4b, SYMLINK2) < 0 && errno != EEXIST) TEST_ERROR - /* Create external link to file & object in temporary directory #2, using symlink #1 name */ - if(H5Lcreate_external(SYMLINK1, "group2", file1, "extlink2-sym", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + /* set up name for file #5 in temporary directory #1: "tmp_links/extlinks21E" */ + h5_fixname(FILENAME[50], fapl, filename5a, NAME_BUF_SIZE); + h5_fixname(FILENAME[51], fapl, filename5b, NAME_BUF_SIZE); - /* Close file #1 */ - if(H5Fclose(file1) < 0) TEST_ERROR + /* Create file #1 in current directory */ + if((file1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + + /* Create external link to file & object in temporary directory #2, using symlink #1 name */ + if(H5Lcreate_external(SYMLINK1, "group2", file1, "extlink2-sym", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + + /* Close file #1 */ + if(H5Fclose(file1) < 0) TEST_ERROR - /* Create file #2 in tmp_links directory #2 */ - if((file2 = H5Fcreate(filename2a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if(H5Fclose(file2) < 0) TEST_ERROR + /* Create file #2 in tmp_links directory #2 */ + if((file2 = H5Fcreate(filename2a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if(H5Fclose(file2) < 0) TEST_ERROR - /* Re-open file #2 in tmp_links directory through symlink */ - if((file2 = H5Fopen(SYMLINK1, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR + /* Re-open file #2 in tmp_links directory through symlink */ + if((file2 = H5Fopen(SYMLINK1, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - /* Create group in file #2 in temporary directory */ - if((group2 = H5Gcreate2(file2, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + /* Create group in file #2 in temporary directory */ + if((group2 = H5Gcreate2(file2, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - /* Create external link to file #3 & object in temporary directory #2 */ - if(H5Lcreate_external(filename3b, "group3", group2, "extlink3", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + /* Create external link to file #3 & object in temporary directory #2 */ + if(H5Lcreate_external(filename3b, "group3", group2, "extlink3", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - /* Close group in file #2 */ - if(H5Gclose(group2) < 0) TEST_ERROR + /* Close group in file #2 */ + if(H5Gclose(group2) < 0) TEST_ERROR - /* Close file #2 */ - if(H5Fclose(file2) < 0) TEST_ERROR + /* Close file #2 */ + if(H5Fclose(file2) < 0) TEST_ERROR - /* Create file #3 in temp. directory #2 */ - if((file3 = H5Fcreate(filename3a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + /* Create file #3 in temp. directory #2 */ + if((file3 = H5Fcreate(filename3a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - /* Create group in file #3 */ - if((group3 = H5Gcreate2(file3, "group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + /* Create group in file #3 */ + if((group3 = H5Gcreate2(file3, "group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - /* Create external link to file & object in temporary directory #1, using symlink #2 name */ - if(H5Lcreate_external(SYMLINK2, "group4", group3, "extlink4-sym", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + /* Create external link to file & object in temporary directory #1, using symlink #2 name */ + if(H5Lcreate_external(SYMLINK2, "group4", group3, "extlink4-sym", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - /* Close group in file #3 */ - if(H5Gclose(group3) < 0) TEST_ERROR + /* Close group in file #3 */ + if(H5Gclose(group3) < 0) TEST_ERROR - /* Close file #3 */ - if(H5Fclose(file3) < 0) TEST_ERROR + /* Close file #3 */ + if(H5Fclose(file3) < 0) TEST_ERROR - /* Create file #4 in temporary directory #1 */ - if((file4 = H5Fcreate(filename4b, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + /* Create file #4 in temporary directory #1 */ + if((file4 = H5Fcreate(filename4b, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - /* Create group in file #4 in 'temporary' directory */ - if((group4 = H5Gcreate2(file4, "group4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + /* Create group in file #4 in 'temporary' directory */ + if((group4 = H5Gcreate2(file4, "group4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - /* Create external link to file #5 & object in temporary directory #1 */ - if(H5Lcreate_external(filename5b, "group5", group4, "extlink5", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + /* Create external link to file #5 & object in temporary directory #1 */ + if(H5Lcreate_external(filename5b, "group5", group4, "extlink5", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - /* Close group in file #4 */ - if(H5Gclose(group4) < 0) TEST_ERROR + /* Close group in file #4 */ + if(H5Gclose(group4) < 0) TEST_ERROR - /* Close file #4 */ - if(H5Fclose(file4) < 0) TEST_ERROR + /* Close file #4 */ + if(H5Fclose(file4) < 0) TEST_ERROR - /* Create file #5 in temporary directory #1 */ - if((file5 = H5Fcreate(filename5a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + /* Create file #5 in temporary directory #1 */ + if((file5 = H5Fcreate(filename5a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - /* Create group in file #5 in 'temporary' directory #1 */ - if((group5 = H5Gcreate2(file5, "group5", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(group5) < 0) TEST_ERROR + /* Create group in file #5 in 'temporary' directory #1 */ + if((group5 = H5Gcreate2(file5, "group5", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if(H5Gclose(group5) < 0) TEST_ERROR - /* Close file #5 */ - if(H5Fclose(file5) < 0) TEST_ERROR + /* Close file #5 */ + if(H5Fclose(file5) < 0) TEST_ERROR - /* Actual tests... */ + /* Actual tests... */ - /* Reopen file #1 */ - if((file1 = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR + /* Reopen file #1 */ + if((file1 = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR - /* Open group in file #2, through external link w/symlink */ - if((group2 = H5Gopen2(file1, "extlink2-sym", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(group2) < 0) TEST_ERROR + /* Open group in file #2, through external link w/symlink */ + if((group2 = H5Gopen2(file1, "extlink2-sym", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if(H5Gclose(group2) < 0) TEST_ERROR - /* Open group in file #3, through external link w/symlink to external link */ - if((group3 = H5Gopen2(file1, "extlink2-sym/extlink3", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(group3) < 0) TEST_ERROR + /* Open group in file #3, through external link w/symlink to external link */ + if((group3 = H5Gopen2(file1, "extlink2-sym/extlink3", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if(H5Gclose(group3) < 0) TEST_ERROR - /* Open group in file #4, through external link w/symlink to external link w/symlink */ - if((group4 = H5Gopen2(file1, "extlink2-sym/extlink3/extlink4-sym", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(group4) < 0) TEST_ERROR + /* Open group in file #4, through external link w/symlink to external link w/symlink */ + if((group4 = H5Gopen2(file1, "extlink2-sym/extlink3/extlink4-sym", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if(H5Gclose(group4) < 0) TEST_ERROR - /* Open group in file #5, through external link w/symlink to external link w/symlink to external link */ - if((group5 = H5Gopen2(file1, "extlink2-sym/extlink3/extlink4-sym/extlink5", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(group5) < 0) TEST_ERROR + /* Open group in file #5, through external link w/symlink to external link w/symlink to external link */ + if((group5 = H5Gopen2(file1, "extlink2-sym/extlink3/extlink4-sym/extlink5", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if(H5Gclose(group5) < 0) TEST_ERROR - /* Close file #1 */ - if(H5Fclose(file1) < 0) TEST_ERROR + /* Close file #1 */ + if(H5Fclose(file1) < 0) TEST_ERROR - PASSED(); - } /* end if */ - else { - SKIPPED(); - HDputs(" Current VFD doesn't support POSIX I/O calls"); - } /* end else */ + HDfree(filename1); + HDfree(filename2a); + HDfree(filename2b); + HDfree(filename3a); + HDfree(filename3b); + HDfree(filename4a); + HDfree(filename4b); + HDfree(filename5a); + HDfree(filename5b); + HDfree(tmpname); + HDfree(cwdpath); + + PASSED(); return SUCCEED; @@ -6243,7 +6407,21 @@ error: H5Fclose(file2); H5Fclose(file1); } H5E_END_TRY; + + HDfree(filename1); + HDfree(filename2a); + HDfree(filename2b); + HDfree(filename3a); + HDfree(filename3b); + HDfree(filename4a); + HDfree(filename4b); + HDfree(filename5a); + HDfree(filename5b); + HDfree(tmpname); + HDfree(cwdpath); + return FAIL; + #else /* H5_HAVE_SYMLINK */ SKIPPED(); HDputs(" Current file system or operating system doesn't support symbolic links"); @@ -7226,18 +7404,6 @@ done: return ret_value; } /* end UD_hard_delete() */ -const H5L_class_t UD_hard_class[1] = {{ - H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ - (H5L_type_t)UD_HARD_TYPE, /* Link type id number */ - "UD_hard_link", /* Link class name for debugging */ - UD_hard_create, /* Creation callback */ - NULL, /* Move/rename callback */ - NULL, /* Copy callback */ - UD_hard_traverse, /* The actual traversal function */ - UD_hard_delete, /* Deletion callback */ - NULL /* Query callback */ -}}; - static int ud_hard_links(hid_t fapl) { @@ -7368,7 +7534,7 @@ error: * Failure: -1 *------------------------------------------------------------------------- */ - /* A traversal function that ignores any udata and simply opens an object +/* A traversal function that ignores any udata and simply opens an object * in the current group named REREG_TARGET_NAME */ static hid_t @@ -7386,20 +7552,6 @@ error: return FAIL; } /* end UD_rereg_traverse() */ -/* This link class has the same ID number as the UD hard links but - * has a very different traversal function */ -const H5L_class_t UD_rereg_class[1] = {{ - H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ - (H5L_type_t)UD_HARD_TYPE, /* Link type id number */ - "UD_reregistered_type", /* Link class name for debugging */ - NULL, /* Creation callback */ - NULL, /* Move/rename callback */ - NULL, /* Copy callback */ - UD_rereg_traverse, /* The actual traversal function */ - NULL, /* Deletion callback */ - NULL /* Query callback */ -}}; - static int ud_link_reregister(hid_t fapl) { @@ -7459,7 +7611,7 @@ ud_link_reregister(hid_t fapl) /* Verify that we can't create any new links of this type */ H5E_BEGIN_TRY { if(H5Lcreate_ud(fid, "ud_link2", (H5L_type_t)UD_HARD_TYPE, &(li.u.address), - sizeof(li.u.address), H5P_DEFAULT, H5P_DEFAULT) >= 0) + sizeof(li.u.address), H5P_DEFAULT, H5P_DEFAULT) >= 0) TEST_ERROR } H5E_END_TRY @@ -7541,7 +7693,7 @@ error: /*------------------------------------------------------------------------- - * Function: ud_callbacks + * Function: UD_cb_create * * Purpose: Check that all callbacks are called and are given the correct * information. @@ -7657,18 +7809,6 @@ error: return FAIL; } /* end UD_cb_query() */ -const H5L_class_t UD_cb_class[1] = {{ - H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ - (H5L_type_t)UD_CB_TYPE, /* Link type id number */ - NULL, /* NULL name (to make sure this doesn't break anything */ - UD_cb_create, /* Creation callback */ - UD_cb_move, /* Move/rename callback */ - UD_cb_move, /* Copy callback */ - UD_cb_traverse, /* The actual traversal function */ - UD_cb_delete, /* Deletion callback */ - UD_cb_query /* Query callback */ -}}; - static int ud_callbacks(hid_t fapl, hbool_t new_format) { @@ -7822,18 +7962,6 @@ error: return FAIL; } /* end UD_plist_traverse() */ -const H5L_class_t UD_plist_class[1] = {{ - H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ - (H5L_type_t)UD_PLIST_TYPE, /* Link type id number */ - "UD_plist_link", /* Link class name for debugging */ - NULL, /* Creation callback */ - NULL, /* Move/rename callback */ - NULL, /* Copy callback */ - UD_plist_traverse, /* The actual traversal function */ - NULL, /* Deletion callback */ - NULL /* Query callback */ -}}; - static int lapl_udata(hid_t fapl, hbool_t new_format) { @@ -8129,12 +8257,12 @@ const H5L_class_t UD_error4_class[1] = {{ static int ud_link_errors(hid_t fapl, hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1; /* Group IDs */ - char group_name[NAME_BUF_SIZE]; - char filename[NAME_BUF_SIZE]; - char query_buf[NAME_BUF_SIZE]; - H5L_info_t li; /* Link information */ + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group IDs */ + char group_name[NAME_BUF_SIZE]; + char filename[NAME_BUF_SIZE]; + char query_buf[NAME_BUF_SIZE]; + H5L_info_t li; /* Link information */ if(new_format) TESTING("user-defined link error conditions (w/new group format)") @@ -8485,12 +8613,12 @@ error: static int linkinfo(hid_t fapl, hbool_t new_format) { - hid_t fid = -1; /* File ID */ - hid_t gid = -1; /* Group ID */ - hid_t tid = -1; /* Type ID */ - hid_t sid = -1, did = -1; /* Dataspace and dataset IDs */ - H5L_info_t li; /* Link information */ - char filename[NAME_BUF_SIZE]; + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group ID */ + hid_t tid = -1; /* Type ID */ + hid_t sid = -1, did = -1; /* Dataspace and dataset IDs */ + H5L_info_t li; /* Link information */ + char filename[NAME_BUF_SIZE]; if(new_format) TESTING("link type field in H5Lget_info (w/new group format)") @@ -14099,7 +14227,8 @@ main(void) nerrors += group_info_old(fapl) < 0 ? 1 : 0; if (minimize_dset_oh) { - if (H5Pclose(dcpl_g) < 0) TEST_ERROR; + if (H5Pclose(dcpl_g) < 0) + TEST_ERROR; dcpl_g = -1; } } /* [un]minimized dataset object headers */ @@ -14137,5 +14266,5 @@ main(void) error: HDputs("*** TESTS FAILED ***"); HDexit(EXIT_FAILURE); -} +} /* end main() */ diff --git a/test/mtime.c b/test/mtime.c index f7a441d..06f576b 100644 --- a/test/mtime.c +++ b/test/mtime.c @@ -39,9 +39,7 @@ const char *FILENAME[] = { * * Purpose: H5O_mtime_decode() test. * - * Return: Success: - * - * Failure: + * Return: EXIT_SUCCESS/EXIT_FAILURE * * Programmer: Robb Matzke * Thursday, July 30, 1998 @@ -188,10 +186,10 @@ main(void) /* All looks good */ HDputs("All modification time tests passed."); h5_cleanup(FILENAME, fapl); - return 0; + return EXIT_SUCCESS; /* Something broke */ error: - return 1; -} + return EXIT_FAILURE; +} /* end main() */ diff --git a/test/objcopy.c b/test/objcopy.c index 94d81bf..6f66ad8 100644 --- a/test/objcopy.c +++ b/test/objcopy.c @@ -11448,8 +11448,8 @@ error: H5Tclose(f_tid); H5Tclose(g_tid); H5Tclose(anon_tid); - H5Pclose(ocpypl_id); - H5Aclose(aid); + H5Pclose(ocpypl_id); + H5Aclose(aid); H5Dclose(did); H5Sclose(sid); H5Gclose(gid); @@ -11688,14 +11688,14 @@ test_copy_cdt_merge_cdt(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t ds error: H5E_BEGIN_TRY { - H5Pclose(ocpypl_id); - H5Tclose(tid); - H5Tclose(tid1); - H5Tclose(tid2); - H5Tclose(tid3); - H5Tclose(tid4); - H5Tclose(tid5); - H5Aclose(aid); + H5Pclose(ocpypl_id); + H5Tclose(tid); + H5Tclose(tid1); + H5Tclose(tid2); + H5Tclose(tid3); + H5Tclose(tid4); + H5Tclose(tid5); + H5Aclose(aid); H5Sclose(sid); H5Fclose(fid_dst); H5Fclose(fid_src); @@ -13419,8 +13419,7 @@ test_copy_iterate(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl /* Iterate over links in the root group, copying each object */ if((gid = H5Gopen2(fid1, "/", H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Literate(gid, H5_INDEX_NAME, H5_ITER_INC, NULL, test_copy_iterate_cb, - &fid2) < 0) + if(H5Literate(gid, H5_INDEX_NAME, H5_ITER_INC, NULL, test_copy_iterate_cb, &fid2) < 0) TEST_ERROR /* Close */ diff --git a/test/set_extent.c b/test/set_extent.c index 6c582ef..2a7dd90 100644 --- a/test/set_extent.c +++ b/test/set_extent.c @@ -2013,8 +2013,7 @@ static int test_external(hid_t fapl) { if (H5Fclose(fid) < 0) FAIL_STACK_ERROR - PASSED() - ; + PASSED(); return 0; diff --git a/test/stab.c b/test/stab.c index 80c8b06..9afe28e 100644 --- a/test/stab.c +++ b/test/stab.c @@ -70,8 +70,10 @@ const char *FILENAME[] = { #define GCPL_ON_ROOT_MAX_COMPACT 4 #define GCPL_ON_ROOT_MIN_DENSE 2 +#ifndef H5_NO_DEPRECATED_SYMBOLS /* Definitions for 'old_api' test */ #define OLD_API_GROUP "/old_api" +#endif /* H5_NO_DEPRECATED_SYMBOLS */ /* Definitions for 'corrupt_stab_msg' test */ #define CORRUPT_STAB_FILE "corrupt_stab_msg.h5" diff --git a/test/tchecksum.c b/test/tchecksum.c index ffbab45..6e509fb 100644 --- a/test/tchecksum.c +++ b/test/tchecksum.c @@ -252,7 +252,7 @@ test_checksum(void) * *------------------------------------------------------------------------- */ -H5_ATTR_PURE H5_ATTR_CONST void +void cleanup_checksum(void) { /* no file to clean */ diff --git a/test/tconfig.c b/test/tconfig.c index b652ca4..1a81d50 100644 --- a/test/tconfig.c +++ b/test/tconfig.c @@ -83,7 +83,7 @@ test_configure(void) * *------------------------------------------------------------------------- */ -H5_ATTR_PURE void +void cleanup_configure(void) { /* no file to clean */ @@ -106,7 +106,7 @@ cleanup_configure(void) * *------------------------------------------------------------------------- */ -H5_ATTR_PURE void +void test_config_ctypes(void) { /* standard C89 basic types */ @@ -215,7 +215,7 @@ test_config_ctypes(void) * *------------------------------------------------------------------------- */ -H5_ATTR_PURE void +void test_exit_definitions(void) { /* Verify the EXIT_SUCCESS and EXIT_FAILURE are 0 and 1 respectively. */ diff --git a/test/th5o.c b/test/th5o.c index 009cc2c..1e6084f 100644 --- a/test/th5o.c +++ b/test/th5o.c @@ -241,10 +241,10 @@ test_h5o_open_by_addr(void) { hid_t fid; /* HDF5 File ID */ hid_t grp, dset, dtype, dspace; /* Object identifiers */ - H5L_info_t li; /* Buffer for H5Lget_info */ - haddr_t grp_addr; /* Addresses for objects */ - haddr_t dset_addr; - haddr_t dtype_addr; + H5L_info_t li; /* Buffer for H5Lget_info */ + haddr_t grp_addr; /* Addresses for objects */ + haddr_t dset_addr; + haddr_t dtype_addr; hsize_t dims[RANK]; H5I_type_t id_type; /* Type of IDs returned from H5Oopen */ H5G_info_t ginfo; /* Group info struct */ @@ -1491,18 +1491,18 @@ test_h5o(void) /* Output message about test being performed */ MESSAGE(5, ("Testing Objects\n")); - test_h5o_open(); /* Test generic open function */ - test_h5o_open_by_addr(); /* Test opening objects by address */ - test_h5o_close(); /* Test generic close function */ - test_h5o_refcount(); /* Test incrementing and decrementing reference count */ - test_h5o_plist(); /* Test object creation properties */ - test_h5o_link(); /* Test object link routine */ - test_h5o_comment(); /* Test routines for comment */ - test_h5o_comment_by_name(); /* Test routines for comment by name */ - test_h5o_getinfo_same_file(); /* Test info for objects in the same file */ + test_h5o_open(); /* Test generic open function */ + test_h5o_open_by_addr(); /* Test opening objects by address */ + test_h5o_close(); /* Test generic close function */ + test_h5o_refcount(); /* Test incrementing and decrementing reference count */ + test_h5o_plist(); /* Test object creation properties */ + test_h5o_link(); /* Test object link routine */ + test_h5o_comment(); /* Test routines for comment */ + test_h5o_comment_by_name(); /* Test routines for comment by name */ + test_h5o_getinfo_same_file(); /* Test info for objects in the same file */ #ifndef H5_NO_DEPRECATED_SYMBOLS - test_h5o_getinfo_visit(); /* Test object info for H5Oget_info/2 and H5Ovisit */ -#endif + test_h5o_getinfo_visit(); /* Test object info for H5Oget_info/2 and H5Ovisit */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ } /* test_h5o() */ diff --git a/test/th5s.c b/test/th5s.c index 2afe473..9f9f99d 100644 --- a/test/th5s.c +++ b/test/th5s.c @@ -1284,6 +1284,7 @@ test_h5s_encode(void) CHECK(null_sbuf, NULL, "HDcalloc"); } + /* Encode the null dataspace in the buffer */ ret = H5Sencode(sid2, null_sbuf, &null_size); CHECK(ret, FAIL, "H5Sencode"); @@ -1319,6 +1320,7 @@ test_h5s_encode(void) CHECK(scalar_buf, NULL, "HDcalloc"); } + /* Encode the scalar dataspace in the buffer */ ret = H5Sencode(sid3, scalar_buf, &scalar_size); CHECK(ret, FAIL, "H5Sencode"); @@ -2836,6 +2838,7 @@ test_h5s(void) test_h5s_basic(); /* Test basic H5S code */ test_h5s_null(); /* Test Null dataspace H5S code */ test_h5s_zero_dim(); /* Test dataspace with zero dimension size */ + test_h5s_encode(); /* Test encoding and decoding */ test_h5s_encode_regular_exceed32(); /* Test encoding regular hyperslab selection that exceeds 32 bits */ test_h5s_encode_irregular_exceed32(); /* Testing encoding irregular hyperslab selection that exceeds 32 bits */ diff --git a/test/titerate.c b/test/titerate.c index 2f70226..efc6e37 100644 --- a/test/titerate.c +++ b/test/titerate.c @@ -1045,10 +1045,10 @@ test_iterate(void) /* These next tests use the same file */ for(new_format = FALSE; new_format <= TRUE; new_format++) { test_iter_group(new_format ? fapl2 : fapl, new_format); /* Test group iteration */ - test_iter_group_large(new_format ? fapl2 : fapl); /* Test group iteration for large # of objects */ + test_iter_group_large(new_format ? fapl2 : fapl); /* Test group iteration for large # of objects */ test_iter_attr(new_format ? fapl2 : fapl, new_format); /* Test attribute iteration */ - test_grp_memb_funcs(new_format ? fapl2 : fapl); /* Test group member information functions */ - test_links(new_format ? fapl2 : fapl); /* Test soft and hard link iteration */ + test_grp_memb_funcs(new_format ? fapl2 : fapl); /* Test group member information functions */ + test_links(new_format ? fapl2 : fapl); /* Test soft and hard link iteration */ } /* end for */ /* Test the fix for issue HDFFV-10588 */ diff --git a/test/tmeta.c b/test/tmeta.c index 7eeb493..ceb7d2b 100644 --- a/test/tmeta.c +++ b/test/tmeta.c @@ -121,7 +121,7 @@ test_metadata(void) * *------------------------------------------------------------------------- */ -H5_ATTR_PURE H5_ATTR_CONST void +void cleanup_metadata(void) { /* no file to clean */ diff --git a/test/tmisc.c b/test/tmisc.c index b1c20dc..7d6eb4e 100644 --- a/test/tmisc.c +++ b/test/tmisc.c @@ -128,15 +128,19 @@ typedef struct /* Definitions for misc. test #8 */ #define MISC8_FILE "tmisc8.h5" #define MISC8_DSETNAME1 "Dataset1" -#define MISC8_DSETNAME2 "Dataset2" -#define MISC8_DSETNAME3 "Dataset3" #define MISC8_DSETNAME4 "Dataset4" #define MISC8_DSETNAME5 "Dataset5" +#define MISC8_DSETNAME8 "Dataset8" + +#ifndef H5_HAVE_PARALLEL +#define MISC8_DSETNAME2 "Dataset2" +#define MISC8_DSETNAME3 "Dataset3" #define MISC8_DSETNAME6 "Dataset6" #define MISC8_DSETNAME7 "Dataset7" -#define MISC8_DSETNAME8 "Dataset8" #define MISC8_DSETNAME9 "Dataset9" #define MISC8_DSETNAME10 "Dataset10" +#endif + #define MISC8_RANK 2 #define MISC8_DIM0 50 #define MISC8_DIM1 50 @@ -309,6 +313,7 @@ typedef struct /* Definitions for misc. test #30 */ #define MISC30_FILE "tmisc30.h5" +#ifndef H5_NO_DEPRECATED_SYMBOLS /* Definitions for misc. test #31 */ #define MISC31_FILE "tmisc31.h5" #define MISC31_DSETNAME "dset" @@ -317,12 +322,21 @@ typedef struct #define MISC31_GROUPNAME "group" #define MISC31_PROPNAME "misc31_prop" #define MISC31_DTYPENAME "dtype" +#endif /* H5_NO_DEPRECATED_SYMBOLS */ /* Definitions for misc. test #33 */ /* Note that this test file is generated by "gen_bad_offset.c" */ /* and bad offset values are written to that file for testing */ #define MISC33_FILE "bad_offset.h5" +/* Definitions for misc. test #35 */ +#define MISC35_SPACE_RANK 3 +#define MISC35_SPACE_DIM1 3 +#define MISC35_SPACE_DIM2 15 +#define MISC35_SPACE_DIM3 13 +#define MISC35_NPOINTS 10 + + /**************************************************************** ** ** test_misc1(): test unlinking a dataset from a group and immediately @@ -5324,6 +5338,7 @@ test_misc30(void) static void test_misc31(void) { +#ifndef H5_NO_DEPRECATED_SYMBOLS hid_t file_id; /* File id */ hid_t space_id; /* Dataspace id */ hid_t dset_id; /* Dataset id */ @@ -5331,6 +5346,7 @@ test_misc31(void) hid_t group_id; /* Group id */ hid_t dtype_id; /* Datatype id */ herr_t ret; /* Generic return value */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ /* Output message about test being performed */ MESSAGE(5, ("Deprecated routines initialize after H5close()\n")); @@ -5588,6 +5604,118 @@ test_misc34(void) /**************************************************************** ** +** test_misc35(): Check operation of free-list routines +** +****************************************************************/ +static void +test_misc35(void) +{ + hid_t sid = H5I_INVALID_HID; /* Dataspace ID */ + hsize_t dims[] = {MISC35_SPACE_DIM1, MISC35_SPACE_DIM2, MISC35_SPACE_DIM3}; /* Dataspace dims */ + hsize_t coord[MISC35_NPOINTS][MISC35_SPACE_RANK] = /* Coordinates for point selection */ + {{0,10, 5}, + {1, 2, 7}, + {2, 4, 9}, + {0, 6,11}, + {1, 8,13}, + {2,12, 0}, + {0,14, 2}, + {1, 0, 4}, + {2, 1, 6}, + {0, 3, 8}}; + size_t reg_size_start; /* Initial amount of regular memory allocated */ + size_t arr_size_start; /* Initial amount of array memory allocated */ + size_t blk_size_start; /* Initial amount of block memory allocated */ + size_t fac_size_start; /* Initial amount of factory memory allocated */ + size_t reg_size_final; /* Final amount of regular memory allocated */ + size_t arr_size_final; /* Final amount of array memory allocated */ + size_t blk_size_final; /* Final amount of block memory allocated */ + size_t fac_size_final; /* Final amount of factory memory allocated */ + H5_alloc_stats_t alloc_stats; /* Memory stats */ + herr_t ret; /* Return value */ + + /* Output message about test being performed */ + MESSAGE(5, ("Free-list API calls")); + + /* Create dataspace */ + /* (Allocates array free-list nodes) */ + sid = H5Screate_simple(MISC35_SPACE_RANK, dims, NULL); + CHECK(sid, H5I_INVALID_HID, "H5Screate_simple"); + + /* Select sequence of ten points */ + ret = H5Sselect_elements(sid, H5S_SELECT_SET, (size_t)MISC35_NPOINTS, (const hsize_t *)coord); + CHECK(ret, FAIL, "H5Sselect_elements"); + + /* Close dataspace */ + ret = H5Sclose(sid); + CHECK(ret, FAIL, "H5Sclose"); + + + /* Retrieve initial free list values */ + ret = H5get_free_list_sizes(®_size_start, &arr_size_start, &blk_size_start, &fac_size_start); + CHECK(ret, FAIL, "H5get_free_list_sizes"); + +#if !defined H5_USING_MEMCHECKER + /* All the free list values should be >0 */ + CHECK(reg_size_start, 0, "H5get_free_list_sizes"); + CHECK(arr_size_start, 0, "H5get_free_list_sizes"); + CHECK(blk_size_start, 0, "H5get_free_list_sizes"); + CHECK(fac_size_start, 0, "H5get_free_list_sizes"); +#else /* H5_MEMORY_ALLOC_SANITY_CHECK */ + /* All the values should be == 0 */ + VERIFY(reg_size_start, 0, "H5get_free_list_sizes"); + VERIFY(arr_size_start, 0, "H5get_free_list_sizes"); + VERIFY(blk_size_start, 0, "H5get_free_list_sizes"); + VERIFY(fac_size_start, 0, "H5get_free_list_sizes"); +#endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ + + /* Garbage collect the free lists */ + ret = H5garbage_collect(); + CHECK(ret, FAIL, "H5garbage_collect"); + + /* Retrieve free list values again */ + ret = H5get_free_list_sizes(®_size_final, &arr_size_final, &blk_size_final, &fac_size_final); + CHECK(ret, FAIL, "H5get_free_list_sizes"); + + /* All the free list values should be <= previous values */ + if(reg_size_final > reg_size_start) + ERROR("reg_size_final > reg_size_start"); + if(arr_size_final > arr_size_start) + ERROR("arr_size_final > arr_size_start"); + if(blk_size_final > blk_size_start) + ERROR("blk_size_final > blk_size_start"); + if(fac_size_final > fac_size_start) + ERROR("fac_size_final > fac_size_start"); + + /* Retrieve memory allocation statistics */ + ret = H5get_alloc_stats(&alloc_stats); + CHECK(ret, FAIL, "H5get_alloc_stats"); + +#if defined H5_MEMORY_ALLOC_SANITY_CHECK + /* All the values should be >0 */ + CHECK(alloc_stats.total_alloc_bytes, 0, "H5get_alloc_stats"); + CHECK(alloc_stats.curr_alloc_bytes, 0, "H5get_alloc_stats"); + CHECK(alloc_stats.peak_alloc_bytes, 0, "H5get_alloc_stats"); + CHECK(alloc_stats.max_block_size, 0, "H5get_alloc_stats"); + CHECK(alloc_stats.total_alloc_blocks_count, 0, "H5get_alloc_stats"); + CHECK(alloc_stats.curr_alloc_blocks_count, 0, "H5get_alloc_stats"); + CHECK(alloc_stats.peak_alloc_blocks_count, 0, "H5get_alloc_stats"); +#else /* H5_MEMORY_ALLOC_SANITY_CHECK */ + /* All the values should be == 0 */ + VERIFY(alloc_stats.total_alloc_bytes, 0, "H5get_alloc_stats"); + VERIFY(alloc_stats.curr_alloc_bytes, 0, "H5get_alloc_stats"); + VERIFY(alloc_stats.peak_alloc_bytes, 0, "H5get_alloc_stats"); + VERIFY(alloc_stats.max_block_size, 0, "H5get_alloc_stats"); + VERIFY(alloc_stats.total_alloc_blocks_count, 0, "H5get_alloc_stats"); + VERIFY(alloc_stats.curr_alloc_blocks_count, 0, "H5get_alloc_stats"); + VERIFY(alloc_stats.peak_alloc_blocks_count, 0, "H5get_alloc_stats"); +#endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ + +} /* end test_misc35() */ + + +/**************************************************************** +** ** test_misc(): Main misc. test routine. ** ****************************************************************/ @@ -5635,6 +5763,7 @@ test_misc(void) test_misc32(); /* Test filter memory allocation functions */ test_misc33(); /* Test to verify that H5HL_offset_into() returns error if offset exceeds heap block */ test_misc34(); /* Test behavior of 0 and NULL in H5MM API calls */ + test_misc35(); /* Test behavior of free-list & allocation statistics API calls */ } /* test_misc() */ @@ -5688,6 +5817,8 @@ cleanup_misc(void) HDremove(MISC28_FILE); HDremove(MISC29_COPY_FILE); HDremove(MISC30_FILE); +#ifndef H5_NO_DEPRECATED_SYMBOLS HDremove(MISC31_FILE); +#endif /* H5_NO_DEPRECATED_SYMBOLS */ } /* end cleanup_misc() */ diff --git a/test/trefer.c b/test/trefer.c index 426f549..504498c 100644 --- a/test/trefer.c +++ b/test/trefer.c @@ -65,23 +65,23 @@ typedef struct s1_t { static void test_reference_params(void) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset, /* Dataset ID */ - dset2; /* Dereferenced dataset ID */ - hid_t group; /* Group ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1; /* Datatype ID */ - hid_t dapl_id; /* Dataset access property list */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset, /* Dataset ID */ + dset2; /* Dereferenced dataset ID */ + hid_t group; /* Group ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1; /* Datatype ID */ + hid_t dapl_id; /* Dataset access property list */ hsize_t dims1[] = {SPACE1_DIM1}; - hobj_ref_t *wbuf, /* buffer to write to disk */ - *rbuf, /* buffer read from disk */ - *tbuf; /* temp. buffer read from disk */ + hobj_ref_t *wbuf, /* buffer to write to disk */ + *rbuf, /* buffer read from disk */ + *tbuf; /* temp. buffer read from disk */ unsigned *tu32; /* Temporary pointer to uint32 data */ - int i; /* counting variables */ - const char *write_comment = "Foo!"; /* Comments for group */ - hid_t ret_id; /* Generic hid_t return value */ - ssize_t name_size; /* Size of reference name */ - herr_t ret; /* Generic return value */ + int i; /* Counters */ + const char *write_comment = "Foo!"; /* Comments for group */ + hid_t ret_id; /* Generic hid_t return value */ + ssize_t name_size; /* Size of reference name */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Reference Parameters\n")); @@ -234,7 +234,7 @@ test_reference_params(void) HDfree(wbuf); HDfree(rbuf); HDfree(tbuf); -} /* test_reference_obj() */ +} /* test_reference_params() */ /**************************************************************** ** @@ -245,25 +245,25 @@ test_reference_params(void) static void test_reference_obj(void) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset, /* Dataset ID */ - dset2; /* Dereferenced dataset ID */ - hid_t group; /* Group ID */ - hid_t sid1; /* Dataspace ID */ - hid_t tid1; /* Datatype ID */ - hsize_t dims1[] = {SPACE1_DIM1}; - hid_t dapl_id; /* Dataset access property list */ - hobj_ref_t *wbuf, /* buffer to write to disk */ - *rbuf, /* buffer read from disk */ - *tbuf; /* temp. buffer read from disk */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset, /* Dataset ID */ + dset2; /* Dereferenced dataset ID */ + hid_t group; /* Group ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1; /* Datatype ID */ + hsize_t dims1[] = {SPACE1_DIM1}; + hid_t dapl_id; /* Dataset access property list */ + hobj_ref_t *wbuf, /* buffer to write to disk */ + *rbuf, /* buffer read from disk */ + *tbuf; /* temp. buffer read from disk */ hobj_ref_t nvrbuf[3]={0,101,1000000000}; /* buffer with non-valid refs */ - unsigned *tu32; /* Temporary pointer to uint32 data */ - int i, j; /* counting variables */ + unsigned *tu32; /* Temporary pointer to uint32 data */ + int i, j; /* Counters */ const char *write_comment="Foo!"; /* Comments for group */ char read_comment[10]; - H5O_type_t obj_type; /* Object type */ - ssize_t size; /* Comment length */ - herr_t ret; /* Generic return value */ + H5O_type_t obj_type; /* Object type */ + ssize_t size; /* Comment length */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Object Reference Functions\n")); diff --git a/test/tselect.c b/test/tselect.c index 770b78a..8abe898 100644 --- a/test/tselect.c +++ b/test/tselect.c @@ -15167,14 +15167,14 @@ test_hyper_io_1d(void) /* Get the dataset's dataspace */ sid = H5Dget_space(did); - CHECK(sid, H5I_INVALID_HID, "H5Pcreate"); + CHECK(sid, H5I_INVALID_HID, "H5Dget_space"); ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Set up contiguous memory dataspace for the selected elements */ dimsm[0] = count[0]; mid = H5Screate_simple(RANK, dimsm, NULL); - CHECK(mid, H5I_INVALID_HID, "H5Screate"); + CHECK(mid, H5I_INVALID_HID, "H5Screate_simple"); /* Read all the selected 10th elements in the dataset into "rdata" */ ret = H5Dread(did, H5T_NATIVE_INT, mid, sid, H5P_DEFAULT, rdata); @@ -1389,12 +1389,12 @@ test_vds_prefix_first(unsigned config, hid_t fapl) static int test_basic_io(unsigned config, hid_t fapl) { - char srcfilename[FILENAME_BUF_SIZE]; - char srcfilename_map[FILENAME_BUF_SIZE]; - char vfilename[FILENAME_BUF_SIZE]; - char vfilename2[FILENAME_BUF_SIZE]; - char srcfilenamepct[FILENAME_BUF_SIZE]; - char srcfilenamepct_map[FILENAME_BUF_SIZE]; + char *srcfilename = NULL; + char *srcfilename_map = NULL; + char *vfilename = NULL; + char *vfilename2 = NULL; + char *srcfilenamepct = NULL; + char *srcfilenamepct_map = NULL; const char *srcfilenamepct_map_orig = "vds%%%%_src"; hid_t srcfile[4] = {-1, -1, -1, -1}; /* Files with source dsets */ hid_t vfile = -1; /* File with virtual dset */ @@ -1422,12 +1422,25 @@ test_basic_io(unsigned config, hid_t fapl) TESTING("basic virtual dataset I/O") - h5_fixname(FILENAME[0], fapl, vfilename, sizeof vfilename); - h5_fixname(FILENAME[1], fapl, vfilename2, sizeof vfilename2); - h5_fixname(FILENAME[2], fapl, srcfilename, sizeof srcfilename); - h5_fixname_printf(FILENAME[2], fapl, srcfilename_map, sizeof srcfilename_map); - h5_fixname(FILENAME[4], fapl, srcfilenamepct, sizeof srcfilenamepct); - h5_fixname_printf(srcfilenamepct_map_orig, fapl, srcfilenamepct_map, sizeof srcfilenamepct_map); + if((srcfilename = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + TEST_ERROR; + if((srcfilename_map = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + TEST_ERROR; + if((vfilename = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + TEST_ERROR; + if((vfilename2 = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + TEST_ERROR; + if((srcfilenamepct = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + TEST_ERROR; + if((srcfilenamepct_map = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + TEST_ERROR; + + h5_fixname(FILENAME[0], fapl, vfilename, FILENAME_BUF_SIZE); + h5_fixname(FILENAME[1], fapl, vfilename2, FILENAME_BUF_SIZE); + h5_fixname(FILENAME[2], fapl, srcfilename, FILENAME_BUF_SIZE); + h5_fixname_printf(FILENAME[2], fapl, srcfilename_map, FILENAME_BUF_SIZE); + h5_fixname(FILENAME[4], fapl, srcfilenamepct, FILENAME_BUF_SIZE); + h5_fixname_printf(srcfilenamepct_map_orig, fapl, srcfilenamepct_map, FILENAME_BUF_SIZE); /* Create DCPL */ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) @@ -6571,15 +6584,15 @@ error: static int test_printf(unsigned config, hid_t fapl) { - char srcfilename[FILENAME_BUF_SIZE]; - char srcfilename_map[FILENAME_BUF_SIZE]; - char srcfilename2[FILENAME_BUF_SIZE]; - char srcfilename2_map[FILENAME_BUF_SIZE]; - char vfilename[FILENAME_BUF_SIZE]; - char printf_srcfilename_map[FILENAME_BUF_SIZE]; + char *srcfilename = NULL; + char *srcfilename_map = NULL; + char *srcfilename2 = NULL; + char *srcfilename2_map = NULL; + char *vfilename = NULL; + char *printf_srcfilename_map = NULL; + char *srcfilenamepct = NULL; + char *srcfilenamepct_map = NULL; const char *printf_srcfilename_map_orig = "vds_src_%b"; - char srcfilenamepct[FILENAME_BUF_SIZE]; - char srcfilenamepct_map[FILENAME_BUF_SIZE]; const char *srcfilenamepct_map_orig = "vds%%%%_src"; hid_t srcfile[4] = {-1, -1, -1, -1}; /* Files with source dsets */ hid_t vfile = -1; /* File with virtual dset */ @@ -6607,14 +6620,31 @@ test_printf(unsigned config, hid_t fapl) TESTING("virtual dataset I/O with printf source") - h5_fixname(FILENAME[0], fapl, vfilename, sizeof vfilename); - h5_fixname(FILENAME[2], fapl, srcfilename, sizeof srcfilename); - h5_fixname_printf(FILENAME[2], fapl, srcfilename_map, sizeof srcfilename_map); - h5_fixname(FILENAME[3], fapl, srcfilename2, sizeof srcfilename2); - h5_fixname_printf(FILENAME[2], fapl, srcfilename2_map, sizeof srcfilename2_map); - h5_fixname_printf(printf_srcfilename_map_orig, fapl, printf_srcfilename_map, sizeof printf_srcfilename_map); - h5_fixname(FILENAME[4], fapl, srcfilenamepct, sizeof srcfilenamepct); - h5_fixname_printf(srcfilenamepct_map_orig, fapl, srcfilenamepct_map, sizeof srcfilenamepct_map); + if((srcfilename = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + TEST_ERROR; + if((srcfilename_map = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + TEST_ERROR; + if((srcfilename2 = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + TEST_ERROR; + if((srcfilename2_map = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + TEST_ERROR; + if((vfilename = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + TEST_ERROR; + if((printf_srcfilename_map = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + TEST_ERROR; + if((srcfilenamepct = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + TEST_ERROR; + if((srcfilenamepct_map = (char *)HDcalloc(FILENAME_BUF_SIZE, sizeof(char))) == NULL) + TEST_ERROR; + + h5_fixname(FILENAME[0], fapl, vfilename, FILENAME_BUF_SIZE); + h5_fixname(FILENAME[2], fapl, srcfilename, FILENAME_BUF_SIZE); + h5_fixname_printf(FILENAME[2], fapl, srcfilename_map, FILENAME_BUF_SIZE); + h5_fixname(FILENAME[3], fapl, srcfilename2, FILENAME_BUF_SIZE); + h5_fixname_printf(FILENAME[2], fapl, srcfilename2_map, FILENAME_BUF_SIZE); + h5_fixname_printf(printf_srcfilename_map_orig, fapl, printf_srcfilename_map, FILENAME_BUF_SIZE); + h5_fixname(FILENAME[4], fapl, srcfilenamepct, FILENAME_BUF_SIZE); + h5_fixname_printf(srcfilenamepct_map_orig, fapl, srcfilenamepct_map, FILENAME_BUF_SIZE); /* Create DCPL */ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) @@ -10225,6 +10255,15 @@ test_printf(unsigned config, hid_t fapl) TEST_ERROR memspace = -1; + HDfree(srcfilename); + HDfree(srcfilename_map); + HDfree(srcfilename2); + HDfree(srcfilename2_map); + HDfree(vfilename); + HDfree(printf_srcfilename_map); + HDfree(srcfilenamepct); + HDfree(srcfilenamepct_map); + PASSED(); return 0; @@ -10245,6 +10284,15 @@ error: H5Pclose(dapl); } H5E_END_TRY; + HDfree(srcfilename); + HDfree(srcfilename_map); + HDfree(srcfilename2); + HDfree(srcfilename2_map); + HDfree(vfilename); + HDfree(printf_srcfilename_map); + HDfree(srcfilenamepct); + HDfree(srcfilenamepct_map); + return 1; } /* end test_printf() */ @@ -562,6 +562,7 @@ test_direct(void) size_t mbound; size_t fbsize; size_t cbsize; + void *proto_points = NULL, *proto_check = NULL; int *points = NULL, *check = NULL, *p1 = NULL, *p2 = NULL; int wdata2[DSET2_DIM] = {11,12,13,14}; int rdata2[DSET2_DIM]; @@ -633,10 +634,12 @@ test_direct(void) /* Allocate aligned memory for data set 1. For data set 1, everything is aligned including * memory address, size of data, and file address. */ - if(0 != HDposix_memalign(&points, (size_t)FBSIZE, (size_t)(DSET1_DIM1 * DSET1_DIM2 * sizeof(int)))) + if(0 != HDposix_memalign(&proto_points, (size_t)FBSIZE, (size_t)(DSET1_DIM1 * DSET1_DIM2 * sizeof(int)))) TEST_ERROR; - if(0 != HDposix_memalign(&check, (size_t)FBSIZE, (size_t)(DSET1_DIM1 * DSET1_DIM2 * sizeof(int)))) + points = proto_points; + if(0 != HDposix_memalign(&proto_check, (size_t)FBSIZE, (size_t)(DSET1_DIM1 * DSET1_DIM2 * sizeof(int)))) TEST_ERROR; + check = proto_check; /* Initialize the dset1 */ p1 = points; @@ -746,10 +749,10 @@ error: H5Fclose(file); } H5E_END_TRY; - if(points) - HDfree(points); - if(check) - HDfree(check); + if(proto_points) + HDfree(proto_points); + if(proto_check) + HDfree(proto_check); return -1; #endif /*H5_HAVE_DIRECT*/ @@ -776,8 +779,7 @@ error: * 'first_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 herr_t test_family_opens(char *fname, hid_t fa_pl) { @@ -834,7 +836,7 @@ test_family_opens(char *fname, hid_t fa_pl) error: return -1; } /* end test_family_opens() */ -#pragma GCC diagnostic pop +H5_GCC_DIAG_ON(format-nonliteral) /*------------------------------------------------------------------------- @@ -842,8 +844,7 @@ error: * * Purpose: Tests the file handle interface for FAMILY driver * - * Return: Success: 0 - * Failure: -1 + * Return: SUCCEED/FAIL * * Programmer: Raymond Lu * Tuesday, Sept 24, 2002 @@ -858,15 +859,24 @@ test_family(void) hid_t driver_id = -1; /* ID for this VFD */ unsigned long driver_flags = 0; /* VFD feature flags */ char filename[1024]; - char dname[]="dataset"; + char dname[] = "dataset"; unsigned int i, j; int *fhandle=NULL, *fhandle2=NULL; - int buf[FAMILY_NUMBER][FAMILY_SIZE]; + int **buf = NULL; + int *buf_data = NULL; hsize_t dims[2]={FAMILY_NUMBER, FAMILY_SIZE}; hsize_t file_size; TESTING("FAMILY file driver"); + /* Set up data array */ + if(NULL == (buf_data = (int *)HDcalloc(FAMILY_NUMBER * FAMILY_SIZE, sizeof(int)))) + TEST_ERROR; + if(NULL == (buf = (int **)HDcalloc(FAMILY_NUMBER, sizeof(buf_data)))) + TEST_ERROR; + for (i = 0; i < FAMILY_NUMBER; i++) + buf[i] = buf_data + (i * FAMILY_SIZE); + /* Set property list and file name for FAMILY driver */ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; @@ -890,7 +900,7 @@ test_family(void) | H5FD_FEAT_AGGREGATE_SMALLDATA)) TEST_ERROR - if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR; if(H5Fclose(file) < 0) @@ -905,7 +915,7 @@ test_family(void) if(H5Pset_fapl_family(fapl, (hsize_t)H5F_FAMILY_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; - if((file=H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR; /* Check file size API */ @@ -917,7 +927,7 @@ test_family(void) TEST_ERROR; /* Create and write dataset */ - if((space=H5Screate_simple(2, dims, NULL)) < 0) + if((space = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR; /* Retrieve the access property list... */ @@ -932,14 +942,14 @@ test_family(void) if (H5Pclose(access_fapl) < 0) TEST_ERROR; - if((dset=H5Dcreate2(file, dname, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if((dset = H5Dcreate2(file, dname, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; for(i = 0; i < FAMILY_NUMBER; i++) for(j = 0; j < FAMILY_SIZE; j++) buf[i][j] = (int)((i * 10000) + j); - if(H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if(H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) < 0) TEST_ERROR; /* check file handle API */ @@ -1004,8 +1014,11 @@ test_family(void) if(H5Pclose(fapl) < 0) TEST_ERROR; + HDfree(buf); + HDfree(buf_data); + PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -1015,8 +1028,12 @@ error: H5Pclose(fapl2); H5Fclose(file); } H5E_END_TRY; - return -1; -} + + HDfree(buf); + HDfree(buf_data); + + return FAIL; +} /* end test_family() */ /*------------------------------------------------------------------------- @@ -1043,8 +1060,7 @@ error: * 'newname_individual', etc. 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 herr_t test_family_compat(void) { @@ -1128,7 +1144,7 @@ error: return -1; } /* end test_family_compat() */ -#pragma GCC diagnostic pop +H5_GCC_DIAG_ON(format-nonliteral) /*------------------------------------------------------------------------- @@ -1150,8 +1166,7 @@ error: * 'sf_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 herr_t test_multi_opens(char *fname) { @@ -1169,7 +1184,7 @@ test_multi_opens(char *fname) return(fid >= 0 ? FAIL : SUCCEED); } /* end test_multi_opens() */ -#pragma GCC diagnostic pop +H5_GCC_DIAG_ON(format-nonliteral) /*------------------------------------------------------------------------- @@ -1205,10 +1220,19 @@ test_multi(void) char dname[]="dataset"; char meta[] = "this is some metadata on this file"; int i, j; - int buf[MULTI_SIZE][MULTI_SIZE]; + int **buf = NULL; + int *buf_data = NULL; TESTING("MULTI file driver"); + /* Set up data array */ + if(NULL == (buf_data = (int *)HDcalloc(MULTI_SIZE * MULTI_SIZE, sizeof(int)))) + TEST_ERROR; + if(NULL == (buf = (int **)HDcalloc(MULTI_SIZE, sizeof(buf_data)))) + TEST_ERROR; + for (i = 0; i < MULTI_SIZE; i++) + buf[i] = buf_data + (i * MULTI_SIZE); + /* Set file access property list for MULTI driver */ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; @@ -1311,7 +1335,7 @@ test_multi(void) for(i=0; i<MULTI_SIZE; i++) for(j=0; j<MULTI_SIZE; j++) buf[i][j] = i*10000+j; - if(H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if(H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) < 0) TEST_ERROR; if((fapl2=H5Pcreate(H5P_FILE_ACCESS)) < 0) @@ -1389,6 +1413,9 @@ test_multi(void) if(H5Pclose(fapl) < 0) TEST_ERROR; + HDfree(buf); + HDfree(buf_data); + PASSED(); return SUCCEED; @@ -1402,6 +1429,10 @@ error: H5Fclose(file); H5Aclose(attr); } H5E_END_TRY; + + HDfree(buf); + HDfree(buf_data); + return FAIL; } /* end test_multi() */ @@ -1440,10 +1471,19 @@ test_multi_compat(void) char sv[H5FD_MEM_NTYPES][32]; hsize_t dims[2]={MULTI_SIZE, MULTI_SIZE}; int i, j; - int buf[MULTI_SIZE][MULTI_SIZE]; + int **buf = NULL; + int *buf_data = NULL; TESTING("MULTI file driver backward compatibility"); + /* Set up data array */ + if(NULL == (buf_data = (int *)HDcalloc(MULTI_SIZE * MULTI_SIZE, sizeof(int)))) + TEST_ERROR; + if(NULL == (buf = (int **)HDcalloc(MULTI_SIZE, sizeof(buf_data)))) + TEST_ERROR; + for (i = 0; i < MULTI_SIZE; i++) + buf[i] = buf_data + (i * MULTI_SIZE); + /* Set file access property list for MULTI driver */ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; @@ -1527,7 +1567,7 @@ test_multi_compat(void) for(i=0; i<MULTI_SIZE; i++) for(j=0; j<MULTI_SIZE; j++) buf[i][j] = i*10000+j; - if(H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if(H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_data) < 0) TEST_ERROR; if(H5Dclose(dset) < 0) @@ -1565,9 +1605,12 @@ test_multi_compat(void) if(H5Pclose(fapl) < 0) TEST_ERROR; + HDfree(buf); + HDfree(buf_data); + PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -1576,8 +1619,12 @@ error: H5Pclose(fapl); H5Fclose(file); } H5E_END_TRY; - return -1; -} + + HDfree(buf); + HDfree(buf_data); + + return FAIL; +} /* end test_multi_compat() */ /*------------------------------------------------------------------------- @@ -2020,11 +2067,7 @@ error: * * Purpose: Tests the basic features of Virtual File Drivers * - * Return: Success: 0 - * Failure: 1 - * - * Programmer: Raymond Lu - * Tuesday, Sept 24, 2002 + * Return: EXIT_SUCCESS/EXIT_FAILURE * *------------------------------------------------------------------------- */ @@ -2052,11 +2095,11 @@ main(void) if(nerrors) { HDprintf("***** %d Virtual File Driver TEST%s FAILED! *****\n", nerrors, nerrors > 1 ? "S" : ""); - return 1; + return EXIT_FAILURE; } /* end if */ HDprintf("All Virtual File Driver tests passed.\n"); - return 0; + return EXIT_SUCCESS; } /* end main() */ |