diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/CMakeLists.txt | 8 | ||||
-rw-r--r-- | test/CMakePassthroughVOLTests.cmake | 4 | ||||
-rw-r--r-- | test/CMakeTests.cmake | 10 | ||||
-rw-r--r-- | test/CMakeVFDTests.cmake | 4 | ||||
-rw-r--r-- | test/cache_api.c | 2 | ||||
-rw-r--r-- | test/cache_tagging.c | 8 | ||||
-rw-r--r-- | test/chunk_info.c | 96 | ||||
-rw-r--r-- | test/cork.c | 6 | ||||
-rw-r--r-- | test/dt_arith.c | 24 | ||||
-rw-r--r-- | test/dtypes.c | 2 | ||||
-rw-r--r-- | test/fheap.c | 4 | ||||
-rw-r--r-- | test/filter_plugin.c | 18 | ||||
-rw-r--r-- | test/h5test.c | 2 | ||||
-rw-r--r-- | test/hyperslab.c | 55 | ||||
-rw-r--r-- | test/istore.c | 22 | ||||
-rw-r--r-- | test/lheap.c | 4 | ||||
-rw-r--r-- | test/mf.c | 12 | ||||
-rw-r--r-- | test/objcopy.c | 14 | ||||
-rw-r--r-- | test/objcopy_ref.c | 4 | ||||
-rw-r--r-- | test/ohdr.c | 2 | ||||
-rw-r--r-- | test/stab.c | 29 | ||||
-rw-r--r-- | test/swmr_common.c | 9 | ||||
-rw-r--r-- | test/swmr_common.h | 8 | ||||
-rw-r--r-- | test/swmr_generator.c | 2 | ||||
-rw-r--r-- | test/tattr.c | 14 | ||||
-rw-r--r-- | test/tconfig.c | 5 | ||||
-rw-r--r-- | test/test_swmr.sh.in | 92 | ||||
-rw-r--r-- | test/testframe.c | 39 | ||||
-rw-r--r-- | test/testmeta.c | 8 | ||||
-rw-r--r-- | test/tfile.c | 16 | ||||
-rw-r--r-- | test/th5o.c | 2 | ||||
-rw-r--r-- | test/titerate.c | 8 | ||||
-rw-r--r-- | test/unlink.c | 78 | ||||
-rw-r--r-- | test/vfd.c | 68 |
34 files changed, 369 insertions, 310 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 393040f..e64f32a 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -34,6 +34,9 @@ if (NOT ONLY_SHARED_LIBS) INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>" ) target_compile_options(${HDF5_TEST_LIB_TARGET} PRIVATE "${HDF5_CMAKE_C_FLAGS}") + target_compile_definitions(${HDF5_TEST_LIB_TARGET} + PRIVATE "H5_TEST_EXPRESS_LEVEL_DEFAULT=${H5_TEST_EXPRESS_LEVEL_DEFAULT}" + ) TARGET_C_PROPERTIES (${HDF5_TEST_LIB_TARGET} STATIC) target_link_libraries (${HDF5_TEST_LIB_TARGET} PUBLIC ${LINK_LIBS} ${HDF5_LIB_TARGET} @@ -53,7 +56,10 @@ if (BUILD_SHARED_LIBS) INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>" ) target_compile_options(${HDF5_TEST_LIBSH_TARGET} PRIVATE "${HDF5_CMAKE_C_FLAGS}") - target_compile_definitions(${HDF5_TEST_LIBSH_TARGET} PUBLIC "H5_BUILT_AS_DYNAMIC_LIB") + target_compile_definitions(${HDF5_TEST_LIBSH_TARGET} + PUBLIC "H5_BUILT_AS_DYNAMIC_LIB" + PRIVATE "H5_TEST_EXPRESS_LEVEL_DEFAULT=${H5_TEST_EXPRESS_LEVEL_DEFAULT}" + ) TARGET_C_PROPERTIES (${HDF5_TEST_LIBSH_TARGET} SHARED) target_link_libraries (${HDF5_TEST_LIBSH_TARGET} PUBLIC ${LINK_LIBS} ${HDF5_LIBSH_TARGET} diff --git a/test/CMakePassthroughVOLTests.cmake b/test/CMakePassthroughVOLTests.cmake index e9f1381..94433de 100644 --- a/test/CMakePassthroughVOLTests.cmake +++ b/test/CMakePassthroughVOLTests.cmake @@ -142,7 +142,7 @@ add_custom_target(HDF5_VOLTEST_LIB_files ALL COMMENT "Copying files needed by HD -P "${HDF_RESOURCES_DIR}/volTest.cmake" ) set_tests_properties (VOL-${volname}-${voltest} PROPERTIES - ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${volname};HDF5TestExpress=${HDF_TEST_EXPRESS}" + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${volname}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${volname} ) endif () @@ -199,7 +199,7 @@ add_custom_target(HDF5_VOLTEST_LIB_files ALL COMMENT "Copying files needed by HD ) set_tests_properties (VOL-${volname}-fheap PROPERTIES TIMEOUT ${CTEST_VERY_LONG_TIMEOUT} - ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${volname};HDF5TestExpress=${HDF_TEST_EXPRESS}" + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${volname}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${volname} ) endif () diff --git a/test/CMakeTests.cmake b/test/CMakeTests.cmake index a534e60..72f7a8d 100644 --- a/test/CMakeTests.cmake +++ b/test/CMakeTests.cmake @@ -484,7 +484,7 @@ if (NOT CYGWIN) endif () set_tests_properties (H5TEST-cache PROPERTIES FIXTURES_REQUIRED clear_cache - ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST;HDF5TestExpress=${HDF_TEST_EXPRESS}" + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) set_tests_properties (H5TEST-cache PROPERTIES TIMEOUT ${CTEST_VERY_LONG_TIMEOUT}) @@ -501,7 +501,7 @@ if (TEST_CACHE_IMAGE) add_test (NAME H5TEST_cache_image COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:cache_image>) set_tests_properties (H5TEST-cache_image PROPERTIES FIXTURES_REQUIRED clear_cache_image - ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST;HDF5TestExpress=${HDF_TEST_EXPRESS}" + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) endif () @@ -541,7 +541,7 @@ else () endif () set_tests_properties (H5TEST-external_env PROPERTIES FIXTURES_REQUIRED clear_external_env - ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST;HDF5TestExpress=${HDF_TEST_EXPRESS}" + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) @@ -575,7 +575,7 @@ else () endif () set_tests_properties (H5TEST-vds_env PROPERTIES FIXTURES_REQUIRED clear_vds_env - ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST;HDF5TestExpress=${HDF_TEST_EXPRESS}" + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) @@ -610,7 +610,7 @@ else () endif () set_tests_properties (H5TEST-flush1 PROPERTIES FIXTURES_REQUIRED clear_flush - ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST;HDF5TestExpress=${HDF_TEST_EXPRESS}" + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) if (HDF5_ENABLE_USING_MEMCHECKER) diff --git a/test/CMakeVFDTests.cmake b/test/CMakeVFDTests.cmake index e08e4d2..b371753 100644 --- a/test/CMakeVFDTests.cmake +++ b/test/CMakeVFDTests.cmake @@ -131,7 +131,7 @@ add_custom_target(HDF5_VFDTEST_LIB_files ALL COMMENT "Copying files needed by HD -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" ) set_tests_properties (VFD-${vfdname}-${vfdtest} PROPERTIES - ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${vfdname};HDF5TestExpress=${HDF_TEST_EXPRESS}" + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${vfdname}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${vfdname} ) endif () @@ -186,7 +186,7 @@ add_custom_target(HDF5_VFDTEST_LIB_files ALL COMMENT "Copying files needed by HD ) set_tests_properties (VFD-${vfdname}-fheap PROPERTIES TIMEOUT ${CTEST_VERY_LONG_TIMEOUT} - ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${vfdname};HDF5TestExpress=${HDF_TEST_EXPRESS}" + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${vfdname}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${vfdname} ) endif () diff --git a/test/cache_api.c b/test/cache_api.c index ec0a903..1decef9 100644 --- a/test/cache_api.c +++ b/test/cache_api.c @@ -835,7 +835,7 @@ check_file_mdc_api_calls(unsigned paged, hid_t fcpl_id) * with the cache API calls. * * NOTE: This test takes some time to run and checks the - * HDF5TestExpress environment variable. + * testing express level value. * * Return: Test pass status (TRUE/FALSE) * diff --git a/test/cache_tagging.c b/test/cache_tagging.c index 4d07116..f1571f0 100644 --- a/test/cache_tagging.c +++ b/test/cache_tagging.c @@ -839,7 +839,7 @@ check_multi_group_creation_tags(void) for (i = 0; i < MULTIGROUPS; i++) { - HDsprintf(gname, "%d", i); + HDsnprintf(gname, sizeof(gname), "%d", i); if ((gid = H5Gcreate2(fid, gname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; if (H5Gclose(gid) < 0) @@ -861,7 +861,7 @@ check_multi_group_creation_tags(void) for (i = 0; i < MULTIGROUPS; i++) { /* Re-open the group */ - HDsprintf(gname, "%d", i); + HDsnprintf(gname, sizeof(gname), "%d", i); if ((gid = H5Gopen2(fid, gname, H5P_DEFAULT)) < 0) TEST_ERROR; @@ -988,7 +988,7 @@ check_link_iteration_tags(void) /* Create many datasets in root group */ for (i = 0; i < 500; i++) { - HDsprintf(dsetname, "Dset %d", i); + HDsnprintf(dsetname, sizeof(dsetname), "Dset %d", i); if ((did = H5Dcreate2(fid, dsetname, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; @@ -1151,7 +1151,7 @@ check_dense_attribute_tags(void) for (i = 0; i < 50; i++) { - HDsprintf(attrname, "attr %d", i); + HDsnprintf(attrname, sizeof(attrname), "attr %d", i); if ((aid = H5Acreate2(did, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; if (H5Awrite(aid, H5T_NATIVE_UINT, &i) < 0) diff --git a/test/chunk_info.c b/test/chunk_info.c index b19f3df..f041c46 100644 --- a/test/chunk_info.c +++ b/test/chunk_info.c @@ -179,11 +179,18 @@ verify_get_chunk_info(hid_t dset, hid_t dspace, hsize_t chk_index, hsize_t exp_c if (H5Dget_chunk_info(dset, dspace, chk_index, out_offset, &read_flt_msk, &addr, &size) < 0) TEST_ERROR; - CHECK(addr, HADDR_UNDEF, "H5Dget_chunk_info"); - VERIFY(size, exp_chk_size, "H5Dget_chunk_info, chunk size"); - VERIFY(read_flt_msk, exp_flt_msk, "H5Dget_chunk_info, filter mask"); - VERIFY(out_offset[0], exp_offset[0], "H5Dget_chunk_info, offset[0]"); - VERIFY(out_offset[1], exp_offset[1], "H5Dget_chunk_info, offset[1]"); + + if (HADDR_UNDEF == addr) + FAIL_PUTS_ERROR("address cannot be HADDR_UNDEF"); + if (size != exp_chk_size) + FAIL_PUTS_ERROR("unexpected chunk size"); + if (read_flt_msk != exp_flt_msk) + FAIL_PUTS_ERROR("unexpected filter mask"); + if (out_offset[0] != exp_offset[0]) + FAIL_PUTS_ERROR("unexpected offset[0]"); + if (out_offset[1] != exp_offset[1]) + FAIL_PUTS_ERROR("unexpected offset[1]"); + return SUCCEED; error: @@ -213,9 +220,14 @@ verify_get_chunk_info_by_coord(hid_t dset, hsize_t *offset, hsize_t exp_chk_size /* Get info of the chunk at logical coordinates specified by offset */ if (H5Dget_chunk_info_by_coord(dset, offset, &read_flt_msk, &addr, &size) < 0) TEST_ERROR; - CHECK(addr, HADDR_UNDEF, "H5Dget_chunk_info_by_coord"); - VERIFY(size, exp_chk_size, "H5Dget_chunk_info_by_coord, chunk size"); - VERIFY(read_flt_msk, exp_flt_msk, "H5Dget_chunk_info_by_coord, filter mask"); + + if (HADDR_UNDEF == addr) + FAIL_PUTS_ERROR("address cannot be HADDR_UNDEF"); + if (size != exp_chk_size) + FAIL_PUTS_ERROR("unexpected chunk size"); + if (read_flt_msk != exp_flt_msk) + FAIL_PUTS_ERROR("unexpected filter mask"); + return SUCCEED; error: @@ -245,8 +257,12 @@ verify_empty_chunk_info(hid_t dset, hsize_t *offset) /* Get info of the chunk at logical coordinates specified by offset */ if (H5Dget_chunk_info_by_coord(dset, offset, &read_flt_msk, &addr, &size) < 0) TEST_ERROR; - VERIFY(addr, HADDR_UNDEF, "H5Dget_chunk_info_by_coord, chunk address"); - VERIFY(size, EMPTY_CHK_SIZE, "H5Dget_chunk_info_by_coord, chunk size"); + + if (HADDR_UNDEF != addr) + FAIL_PUTS_ERROR("address was not HADDR_UNDEF"); + if (EMPTY_CHK_SIZE != size) + FAIL_PUTS_ERROR("size was not EMPTY_CHK_SIZE"); + return SUCCEED; error: @@ -428,12 +444,14 @@ verify_idx_nchunks(hid_t dset, hid_t dspace, H5D_chunk_index_t exp_idx_type, hsi /* Get and verify the number of chunks */ if (H5Dget_num_chunks(dset, dspace, &nchunks) < 0) TEST_ERROR; - VERIFY(nchunks, exp_num_chunks, "H5Dget_num_chunks, number of chunks"); + if (nchunks != exp_num_chunks) + FAIL_PUTS_ERROR("unexpected number of chunks"); /* Get and verify the number of chunks again, passing in H5S_ALL */ if (H5Dget_num_chunks(dset, H5S_ALL, &nchunks) < 0) TEST_ERROR; - VERIFY(nchunks, exp_num_chunks, "H5Dget_num_chunks, number of chunks"); + if (nchunks != exp_num_chunks) + FAIL_PUTS_ERROR("unexpected number of chunks"); return SUCCEED; @@ -603,7 +621,8 @@ test_get_chunk_info_highest_v18(hid_t fapl) /* Get and verify the number of chunks written */ if (H5Dget_num_chunks(dset, dspace, &nchunks) < 0) TEST_ERROR; - VERIFY(nchunks, NUM_CHUNKS_WRITTEN, "H5Dget_num_chunks, number of chunks"); + if (NUM_CHUNKS_WRITTEN != nchunks) + FAIL_PUTS_ERROR("unexpected number of chunks"); /* Get and verify info of the last written chunk again, passing in H5S_ALL this time */ @@ -666,7 +685,8 @@ test_get_chunk_info_highest_v18(hid_t fapl) /* Verify that the number of chunks is 0 */ if (H5Dget_num_chunks(dset, dspace, &nchunks) < 0) TEST_ERROR; - VERIFY(nchunks, NO_CHUNK_WRITTEN, "H5Dget_num_chunks, number of chunks"); + if (NO_CHUNK_WRITTEN != nchunks) + FAIL_PUTS_ERROR("unexpected number of chunks"); /* Attempt to get info of a chunk from an empty dataset, should fail */ chk_index = OUTOFRANGE_CHK_INDEX; @@ -1128,7 +1148,8 @@ test_chunk_info_fixed_array(const char *filename, hid_t fapl) /* Get and verify the number of chunks written */ if (H5Dget_num_chunks(dset, dspace, &nchunks) < 0) TEST_ERROR; - VERIFY(nchunks, NUM_CHUNKS_WRITTEN, "H5Dget_num_chunks, number of chunks"); + if (NUM_CHUNKS_WRITTEN != nchunks) + FAIL_PUTS_ERROR("unexpected number of chunks"); /* Get and verify info of each written chunk */ chk_index = 0; @@ -1271,7 +1292,8 @@ test_chunk_info_extensible_array(const char *filename, hid_t fapl) /* Get and verify the number of chunks written */ if (H5Dget_num_chunks(dset, dspace, &nchunks) < 0) TEST_ERROR; - VERIFY(nchunks, NUM_CHUNKS_WRITTEN, "H5Dget_num_chunks, number of chunks"); + if (NUM_CHUNKS_WRITTEN != nchunks) + FAIL_PUTS_ERROR("unexpected number of chunks"); /* Get and verify info of each written chunk */ chk_index = 0; @@ -1419,7 +1441,8 @@ test_chunk_info_version2_btrees(const char *filename, hid_t fapl) /* Get and verify the number of chunks written */ if (H5Dget_num_chunks(dset, dspace, &nchunks) < 0) TEST_ERROR; - VERIFY(nchunks, NUM_CHUNKS_WRITTEN, "H5Dget_num_chunks, number of chunks"); + if (NUM_CHUNKS_WRITTEN != nchunks) + FAIL_PUTS_ERROR("unexpected number of chunks"); /* Go through all written chunks, get their info and verify the values */ chk_index = 0; @@ -1602,7 +1625,8 @@ test_basic_query(hid_t fapl) /* Get the number of chunks and verify that no chunk has been written */ if (H5Dget_num_chunks(dset, dspace, &nchunks) < 0) TEST_ERROR; - VERIFY(nchunks, NO_CHUNK_WRITTEN, "H5Dget_num_chunks, number of chunks"); + if (NO_CHUNK_WRITTEN != nchunks) + FAIL_PUTS_ERROR("unexpected number of chunks"); /* Initialize the array of chunk data for the single chunk */ for (ii = 0; ii < CHUNK_NX; ii++) @@ -1618,7 +1642,8 @@ test_basic_query(hid_t fapl) /* Get and verify that one chunk had been written */ if (H5Dget_num_chunks(dset, dspace, &nchunks) < 0) TEST_ERROR; - VERIFY(nchunks, ONE_CHUNK_WRITTEN, "H5Dget_num_chunks, number of chunks"); + if (ONE_CHUNK_WRITTEN != nchunks) + FAIL_PUTS_ERROR("unexpected number of chunks"); /* Get and verify info of the first and only chunk */ if (verify_get_chunk_info(dset, H5S_ALL, 0, CHK_SIZE, offset, flt_msk) == FAIL) @@ -1649,7 +1674,8 @@ test_basic_query(hid_t fapl) /* Get and verify that two chunks had been written */ if (H5Dget_num_chunks(dset, dspace, &nchunks) < 0) TEST_ERROR; - VERIFY(nchunks, TWO_CHUNKS_WRITTEN, "H5Dget_num_chunks, number of chunks"); + if (TWO_CHUNKS_WRITTEN != nchunks) + FAIL_PUTS_ERROR("unexpected number of chunks"); /* Get and verify info of the first written chunk in the dataset, its offset should be (0,0) */ @@ -1685,20 +1711,28 @@ test_basic_query(hid_t fapl) if (H5Dchunk_iter(dset, H5P_DEFAULT, &iter_cb, &udata) < 0) TEST_ERROR; - VERIFY(udata.last_index, 1, "Iterator did not iterate all chunks"); - VERIFY(chunk_infos[0].offset[0], 0, "Offset mismatch"); - VERIFY(chunk_infos[0].offset[1], 0, "Offset mismatch"); - VERIFY(chunk_infos[0].filter_mask, 0, "Filter mismatch"); - VERIFY(chunk_infos[0].nbytes, 96, "Size mismatch"); + if (udata.last_index != 1) + FAIL_PUTS_ERROR("Iterator did not iterate over all chunks"); + if (chunk_infos[0].offset[0] != 0) + FAIL_PUTS_ERROR("offset[0] mismatch"); + if (chunk_infos[0].offset[1] != 0) + FAIL_PUTS_ERROR("offset[1] mismatch"); + if (chunk_infos[0].filter_mask != 0) + FAIL_PUTS_ERROR("filter mask mismatch"); + if (chunk_infos[0].nbytes != 96) + FAIL_PUTS_ERROR("size mismatch"); - VERIFY(chunk_infos[1].offset[0], 1, "Offset mismatch"); - VERIFY(chunk_infos[1].offset[1], 1, "Offset mismatch"); + if (chunk_infos[1].offset[0] != 1) + FAIL_PUTS_ERROR("offset[0] mismatch"); + if (chunk_infos[1].offset[1] != 1) + FAIL_PUTS_ERROR("offset[1] mismatch"); /* Iterate and stop after one iteration */ cptr = &(chunk_infos[0]); if (H5Dchunk_iter(dset, H5P_DEFAULT, &iter_cb_stop, &cptr) < 0) TEST_ERROR; - VERIFY(cptr, &(chunk_infos[1]), "Verification of halted iterator failed\n"); + if (cptr != &(chunk_infos[1])) + FAIL_PUTS_ERROR("Verification of halted iterator failed"); /* Iterate and fail after one iteration */ cptr = &(chunk_infos[0]); @@ -1709,7 +1743,8 @@ test_basic_query(hid_t fapl) H5E_END_TRY; if (ret >= 0) TEST_ERROR; - VERIFY(cptr, &(chunk_infos[1]), "Verification of halted iterator failed\n"); + if (cptr != &(chunk_infos[1])) + FAIL_PUTS_ERROR("Verification of halted iterator failed"); /* Release resourse */ if (H5Dclose(dset) < 0) @@ -2102,7 +2137,8 @@ test_flt_msk_with_skip_compress(hid_t fapl) /* Get and verify the number of chunks written */ if (H5Dget_num_chunks(dset, H5S_ALL, &nchunks) < 0) TEST_ERROR; - VERIFY(nchunks, ONE_CHUNK_WRITTEN, "H5Dget_num_chunks, number of chunks"); + if (ONE_CHUNK_WRITTEN != nchunks) + FAIL_PUTS_ERROR("unexpected number of chunks"); /* Get and verify info of the first and only chunk */ chk_index = 0; diff --git a/test/cork.c b/test/cork.c index 7628d28..53d9065 100644 --- a/test/cork.c +++ b/test/cork.c @@ -396,7 +396,7 @@ verify_obj_dset_cork(hbool_t swmr) /* Attach 8 attributes to the dataset */ for (i = 0; i < 8; i++) { - HDsprintf(attrname, "attr %d", i); + HDsnprintf(attrname, sizeof(attrname), "attr %d", i); if ((aid = H5Acreate2(did2, attrname, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; if (H5Awrite(aid, H5T_NATIVE_INT, &i) < 0) @@ -864,7 +864,7 @@ verify_group_cork(hbool_t swmr) /* Attach 8 attributes to the third group: GRP3 */ for (i = 0; i < 8; i++) { - HDsprintf(attrname, "attr %d", i); + HDsnprintf(attrname, sizeof(attrname), "attr %d", i); if ((aid = H5Acreate2(gid3, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; if (H5Awrite(aid, H5T_NATIVE_UINT, &i) < 0) @@ -1081,7 +1081,7 @@ verify_named_cork(hbool_t swmr) /* Attach 8 attributes to datatype: DT3 */ for (i = 0; i < 8; i++) { - HDsprintf(attrname, "attr %d", i); + HDsnprintf(attrname, sizeof(attrname), "attr %d", i); if ((aid = H5Acreate2(tid3, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; if (H5Awrite(aid, H5T_NATIVE_UINT, &i) < 0) diff --git a/test/dt_arith.c b/test/dt_arith.c index 3601b95..ae48045 100644 --- a/test/dt_arith.c +++ b/test/dt_arith.c @@ -2462,11 +2462,11 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) break; case INT_LLONG: HDmemcpy(aligned, saved + j * sizeof(long long), sizeof(long long)); - HDfprintf(stdout, " %29" H5_PRINTF_LL_WIDTH "d\n", *((long long *)aligned)); + HDfprintf(stdout, " %29lld\n", *((long long *)aligned)); break; case INT_ULLONG: HDmemcpy(aligned, saved + j * sizeof(unsigned long long), sizeof(unsigned long long)); - HDfprintf(stdout, " %29" H5_PRINTF_LL_WIDTH "u\n", *((unsigned long long *)aligned)); + HDfprintf(stdout, " %29llu\n", *((unsigned long long *)aligned)); break; case FLT_FLOAT: case FLT_DOUBLE: @@ -2516,11 +2516,11 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) break; case INT_LLONG: HDmemcpy(aligned, buf + j * sizeof(long long), sizeof(long long)); - HDfprintf(stdout, " %29" H5_PRINTF_LL_WIDTH "d\n", *((long long *)aligned)); + HDfprintf(stdout, " %29lld\n", *((long long *)aligned)); break; case INT_ULLONG: HDmemcpy(aligned, buf + j * sizeof(long long), sizeof(unsigned long long)); - HDfprintf(stdout, " %29" H5_PRINTF_LL_WIDTH "u\n", *((unsigned long long *)aligned)); + HDfprintf(stdout, " %29llu\n", *((unsigned long long *)aligned)); break; case FLT_FLOAT: case FLT_DOUBLE: @@ -2561,10 +2561,10 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) HDprintf(" %29lu\n", *((unsigned long *)((void *)hw))); break; case INT_LLONG: - HDfprintf(stdout, " %29" H5_PRINTF_LL_WIDTH "d\n", *((long long *)((void *)hw))); + HDfprintf(stdout, " %29lld\n", *((long long *)((void *)hw))); break; case INT_ULLONG: - HDfprintf(stdout, " %29" H5_PRINTF_LL_WIDTH "u\n", *((unsigned long long *)((void *)hw))); + HDfprintf(stdout, " %29llu\n", *((unsigned long long *)((void *)hw))); break; case FLT_FLOAT: case FLT_DOUBLE: @@ -4398,11 +4398,11 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) break; case INT_LLONG: HDmemcpy(aligned, saved + j * sizeof(long long), sizeof(long long)); - HDfprintf(stdout, " %29" H5_PRINTF_LL_WIDTH "d\n", *((long long *)aligned)); + HDfprintf(stdout, " %29lld\n", *((long long *)aligned)); break; case INT_ULLONG: HDmemcpy(aligned, saved + j * sizeof(unsigned long long), sizeof(unsigned long long)); - HDfprintf(stdout, " %29" H5_PRINTF_LL_WIDTH "u\n", *((unsigned long long *)aligned)); + HDfprintf(stdout, " %29llu\n", *((unsigned long long *)aligned)); break; case FLT_FLOAT: HDmemcpy(aligned, saved + j * sizeof(float), sizeof(float)); @@ -4461,11 +4461,11 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) break; case INT_LLONG: HDmemcpy(aligned, buf + j * sizeof(long long), sizeof(long long)); - HDfprintf(stdout, " %29" H5_PRINTF_LL_WIDTH "d\n", *((long long *)aligned)); + HDfprintf(stdout, " %29lld\n", *((long long *)aligned)); break; case INT_ULLONG: HDmemcpy(aligned, buf + j * sizeof(unsigned long long), sizeof(unsigned long long)); - HDfprintf(stdout, " %29" H5_PRINTF_LL_WIDTH "u\n", *((unsigned long long *)aligned)); + HDfprintf(stdout, " %29llu\n", *((unsigned long long *)aligned)); break; case FLT_FLOAT: HDmemcpy(aligned, buf + j * sizeof(float), sizeof(float)); @@ -4515,10 +4515,10 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) HDprintf(" %29lu\n", *((unsigned long *)((void *)hw))); break; case INT_LLONG: - HDfprintf(stdout, " %29" H5_PRINTF_LL_WIDTH "d\n", *((long long *)((void *)hw))); + HDfprintf(stdout, " %29lld\n", *((long long *)((void *)hw))); break; case INT_ULLONG: - HDfprintf(stdout, " %29" H5_PRINTF_LL_WIDTH "u\n", *((unsigned long long *)((void *)hw))); + HDfprintf(stdout, " %29llu\n", *((unsigned long long *)((void *)hw))); break; case FLT_FLOAT: HDprintf(" %29f\n", (double)*((float *)((void *)hw))); diff --git a/test/dtypes.c b/test/dtypes.c index 218c019..f322d03 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -2322,7 +2322,7 @@ test_compound_11(void) ((big_t *)buf)[u].s1 = (char *)HDmalloc((size_t)32); if (!((big_t *)buf)[u].s1) TEST_ERROR; - HDsprintf(((big_t *)buf)[u].s1, "%u", (unsigned)u); + HDsnprintf(((big_t *)buf)[u].s1, 32, "%u", (unsigned)u); } /* end for */ /* Make copy of buffer before conversion */ diff --git a/test/fheap.c b/test/fheap.c index 01de37f..7fec567 100644 --- a/test/fheap.c +++ b/test/fheap.c @@ -7669,7 +7669,7 @@ test_man_incr_insert_remove(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_ if (H5HF_remove(fh, heap_id[j]) < 0) FAIL_STACK_ERROR; - HDsprintf(obj2.b, "%s%2d", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", j); + HDsnprintf(obj2.b, sizeof(obj2.b), "%s%2d", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", j); if (H5HF_insert(fh, (sizeof(obj2)), &obj2, heap_id[j]) < 0) FAIL_STACK_ERROR; } /* end for */ @@ -7680,7 +7680,7 @@ test_man_incr_insert_remove(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_ /* Insert object */ HDmemset(heap_id[i], 0, id_len); - HDsprintf(obj1.b, "%s%2d", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", i); + HDsnprintf(obj1.b, sizeof(obj1.b), "%s%2d", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", i); if (H5HF_insert(fh, (sizeof(obj1)), &obj1, heap_id[i]) < 0) FAIL_STACK_ERROR; } /* end for */ diff --git a/test/filter_plugin.c b/test/filter_plugin.c index abbcc26..4dcf74a 100644 --- a/test/filter_plugin.c +++ b/test/filter_plugin.c @@ -847,7 +847,7 @@ test_creating_groups_using_plugins(hid_t fid) for (i = 0; i < N_SUBGROUPS; i++) { char *sp = subgroup_name; - sp += HDsprintf(subgroup_name, SUBGROUP_PREFIX); + sp += HDsnprintf(subgroup_name, sizeof(subgroup_name), SUBGROUP_PREFIX); HDsprintf(sp, "%d", i); if ((sub_gid = H5Gcreate2(gid, subgroup_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) @@ -906,7 +906,7 @@ test_opening_groups_using_plugins(hid_t fid) for (i = 0; i < N_SUBGROUPS; i++) { char *sp = subgroup_name; - sp += HDsprintf(subgroup_name, SUBGROUP_PREFIX); + sp += HDsnprintf(subgroup_name, sizeof(subgroup_name), SUBGROUP_PREFIX); HDsprintf(sp, "%d", i); if ((sub_gid = H5Gopen2(gid, subgroup_name, H5P_DEFAULT)) < 0) @@ -1015,7 +1015,7 @@ test_path_api_calls(void) /* Add a bunch of paths to the path table */ for (u = 0; u < n_starting_paths; u++) { - HDsprintf(path, "a_path_%u", u); + HDsnprintf(path, sizeof(path), "a_path_%u", u); if (H5PLappend(path) < 0) { HDfprintf(stderr, " at %u: %s\n", u, path); TEST_ERROR; @@ -1081,7 +1081,7 @@ test_path_api_calls(void) /* Get path at the last index */ if ((path_len = H5PLget(n_starting_paths - 1, path, 256)) <= 0) TEST_ERROR; - HDsprintf(temp_name, "a_path_%u", n_starting_paths - 1); + HDsnprintf(temp_name, sizeof(temp_name), "a_path_%u", n_starting_paths - 1); if (HDstrcmp(path, temp_name) != 0) { HDfprintf(stderr, " get %u: %s\n", n_starting_paths - 1, path); TEST_ERROR; @@ -1135,7 +1135,7 @@ test_path_api_calls(void) TESTING(" prepend"); /* Prepend one path */ - HDsprintf(path, "a_path_%d", n_starting_paths + 1); + HDsnprintf(path, sizeof(path), "a_path_%d", n_starting_paths + 1); if (H5PLprepend(path) < 0) { HDfprintf(stderr, " prepend %u: %s\n", n_starting_paths + 1, path); TEST_ERROR; @@ -1158,7 +1158,7 @@ test_path_api_calls(void) /* Verify that the path was inserted at index zero */ if (H5PLget(0, path, 256) <= 0) TEST_ERROR; - HDsprintf(temp_name, "a_path_%d", n_starting_paths + 1); + HDsnprintf(temp_name, sizeof(temp_name), "a_path_%d", n_starting_paths + 1); if (HDstrcmp(path, temp_name) != 0) { HDfprintf(stderr, " get 0: %s\n", path); TEST_ERROR; @@ -1173,7 +1173,7 @@ test_path_api_calls(void) TESTING(" replace"); /* Replace one path at index 1 */ - HDsprintf(path, "a_path_%u", n_starting_paths + 4); + HDsnprintf(path, sizeof(path), "a_path_%u", n_starting_paths + 4); if (H5PLreplace(path, 1) < 0) { HDfprintf(stderr, " replace 1: %s\n", path); TEST_ERROR; @@ -1192,7 +1192,7 @@ test_path_api_calls(void) /* Check path at index 0 */ if (H5PLget(0, path, 256) <= 0) TEST_ERROR; - HDsprintf(temp_name, "a_path_%u", n_starting_paths + 1); + HDsnprintf(temp_name, sizeof(temp_name), "a_path_%u", n_starting_paths + 1); if (HDstrcmp(path, temp_name) != 0) { HDfprintf(stderr, " get 0: %s\n", path); TEST_ERROR; @@ -1240,7 +1240,7 @@ test_path_api_calls(void) TESTING(" insert"); /* Insert one path at index 3*/ - HDsprintf(path, "a_path_%d", n_starting_paths + 5); + HDsnprintf(path, sizeof(path), "a_path_%d", n_starting_paths + 5); if (H5PLinsert(path, 3) < 0) { HDfprintf(stderr, " insert 3: %s\n", path); TEST_ERROR; diff --git a/test/h5test.c b/test/h5test.c index ac15043..f39825c 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -355,7 +355,7 @@ h5_reset(void) * Cause the library to emit some diagnostics early so they don't * interfere with other formatted output. */ - HDsprintf(filename, "/tmp/h5emit-%05d.h5", HDgetpid()); + HDsnprintf(filename, sizeof(filename), "/tmp/h5emit-%05d.h5", HDgetpid()); H5E_BEGIN_TRY { hid_t file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); diff --git a/test/hyperslab.c b/test/hyperslab.c index 36e6b65..b816aae 100644 --- a/test/hyperslab.c +++ b/test/hyperslab.c @@ -163,19 +163,19 @@ test_fill(size_t nx, size_t ny, size_t nz, size_t di, size_t dj, size_t dk, size if (0 == ny) { ndims = 1; ny = nz = 1; - HDsprintf(dim, "%lu", (unsigned long)nx); + HDsnprintf(dim, sizeof(dim), "%lu", (unsigned long)nx); } /* end if */ else { ndims = 2; nz = 1; - HDsprintf(dim, "%lux%lu", (unsigned long)nx, (unsigned long)ny); + HDsnprintf(dim, sizeof(dim), "%lux%lu", (unsigned long)nx, (unsigned long)ny); } /* end else */ } /* end if */ else { ndims = 3; - HDsprintf(dim, "%lux%lux%lu", (unsigned long)nx, (unsigned long)ny, (unsigned long)nz); + HDsnprintf(dim, sizeof(dim), "%lux%lux%lu", (unsigned long)nx, (unsigned long)ny, (unsigned long)nz); } /* end else */ - HDsprintf(s, "Testing hyperslab fill %-11s variable hyperslab", dim); + HDsnprintf(s, sizeof(s), "Testing hyperslab fill %-11s variable hyperslab", dim); HDprintf("%-70s", s); HDfflush(stdout); @@ -321,17 +321,17 @@ test_copy(int mode, size_t nx, size_t ny, size_t nz, size_t di, size_t dj, size_ if (0 == ny) { ndims = 1; ny = nz = 1; - HDsprintf(dim, "%lu", (unsigned long)nx); + HDsnprintf(dim, sizeof(dim), "%lu", (unsigned long)nx); } /* end if */ else { ndims = 2; nz = 1; - HDsprintf(dim, "%lux%lu", (unsigned long)nx, (unsigned long)ny); + HDsnprintf(dim, sizeof(dim), "%lux%lu", (unsigned long)nx, (unsigned long)ny); } /* end else */ } /* end if */ else { ndims = 3; - HDsprintf(dim, "%lux%lux%lu", (unsigned long)nx, (unsigned long)ny, (unsigned long)nz); + HDsnprintf(dim, sizeof(dim), "%lux%lux%lu", (unsigned long)nx, (unsigned long)ny, (unsigned long)nz); } /* end else */ switch (mode) { @@ -364,7 +364,7 @@ test_copy(int mode, size_t nx, size_t ny, size_t nz, size_t di, size_t dj, size_ HDabort(); } /* end switch */ - HDsprintf(s, "Testing hyperslab copy %-11s %s", dim, sub); + HDsnprintf(s, sizeof(s), "Testing hyperslab copy %-11s %s", dim, sub); HDprintf("%-70s", s); HDfflush(stdout); @@ -618,15 +618,15 @@ test_multifill(size_t nx) s[0] = '\0'; for (i = 0; i < nx; i++) { if (dst[i].left != 3333333) - HDsprintf(s, "bad dst[%lu].left", (unsigned long)i); + HDsnprintf(s, sizeof(s), "bad dst[%lu].left", (unsigned long)i); else if (!H5_DBL_ABS_EQUAL(dst[i].mid, fill.mid)) /* Check if two DOUBLE values are equal. If their difference * is smaller than the EPSILON value for double, they are * considered equal. See the definition in h5test.h. */ - HDsprintf(s, "bad dst[%lu].mid", (unsigned long)i); + HDsnprintf(s, sizeof(s), "bad dst[%lu].mid", (unsigned long)i); else if (dst[i].right != 4444444) - HDsprintf(s, "bad dst[%lu].right", (unsigned long)i); + HDsnprintf(s, sizeof(s), "bad dst[%lu].right", (unsigned long)i); if (s[0]) { H5_FAILED(); if (!HDisatty(1)) { @@ -771,7 +771,8 @@ test_transpose(size_t nx, size_t ny) char s[256]; hsize_t i, j; - HDsprintf(s, "Testing 2d transpose by stride %4lux%-lud", (unsigned long)nx, (unsigned long)ny); + HDsnprintf(s, sizeof(s), "Testing 2d transpose by stride %4lux%-lud", (unsigned long)nx, + (unsigned long)ny); HDprintf("%-70s", s); HDfflush(stdout); @@ -869,8 +870,8 @@ test_sub_super(size_t nx, size_t ny) hsize_t i, j; char s[256]; - HDsprintf(s, "Testing image sampling %4lux%-4lu to %4lux%-4lu ", (unsigned long)(2 * nx), - (unsigned long)(2 * ny), (unsigned long)nx, (unsigned long)ny); + HDsnprintf(s, sizeof(s), "Testing image sampling %4lux%-4lu to %4lux%-4lu ", (unsigned long)(2 * nx), + (unsigned long)(2 * ny), (unsigned long)nx, (unsigned long)ny); HDprintf("%-70s", s); HDfflush(stdout); @@ -919,8 +920,8 @@ test_sub_super(size_t nx, size_t ny) * Test replicating pixels to produce an image twice as large in each * dimension. */ - HDsprintf(s, "Testing image sampling %4lux%-4lu to %4lux%-4lu ", (unsigned long)nx, (unsigned long)ny, - (unsigned long)(2 * nx), (unsigned long)(2 * ny)); + HDsnprintf(s, sizeof(s), "Testing image sampling %4lux%-4lu to %4lux%-4lu ", (unsigned long)nx, + (unsigned long)ny, (unsigned long)(2 * nx), (unsigned long)(2 * ny)); HDprintf("%-70s", s); HDfflush(stdout); @@ -946,17 +947,17 @@ test_sub_super(size_t nx, size_t ny) for (i = 0; i < nx; i++) { for (j = 0; j < ny; j++) { if (half[i * ny + j] != twice[4 * i * ny + 2 * j]) - HDsprintf(s, "half[%lu][%lu] != twice[%lu][%lu]", (unsigned long)i, (unsigned long)j, - (unsigned long)i * 2, (unsigned long)j * 2); + HDsnprintf(s, sizeof(s), "half[%lu][%lu] != twice[%lu][%lu]", (unsigned long)i, + (unsigned long)j, (unsigned long)i * 2, (unsigned long)j * 2); else if (half[i * ny + j] != twice[4 * i * ny + 2 * j + 1]) - HDsprintf(s, "half[%lu][%lu] != twice[%lu][%lu]", (unsigned long)i, (unsigned long)j, - (unsigned long)i * 2, (unsigned long)j * 2 + 1); + HDsnprintf(s, sizeof(s), "half[%lu][%lu] != twice[%lu][%lu]", (unsigned long)i, + (unsigned long)j, (unsigned long)i * 2, (unsigned long)j * 2 + 1); else if (half[i * ny + j] != twice[(2 * i + 1) * 2 * ny + 2 * j]) - HDsprintf(s, "half[%lu][%lu] != twice[%lu][%lu]", (unsigned long)i, (unsigned long)j, - (unsigned long)i * 2 + 1, (unsigned long)j * 2); + HDsnprintf(s, sizeof(s), "half[%lu][%lu] != twice[%lu][%lu]", (unsigned long)i, + (unsigned long)j, (unsigned long)i * 2 + 1, (unsigned long)j * 2); else if (half[i * ny + j] != twice[(2 * i + 1) * 2 * ny + 2 * j + 1]) - HDsprintf(s, "half[%lu][%lu] != twice[%lu][%lu]", (unsigned long)i, (unsigned long)j, - (unsigned long)i * 2 + 1, (unsigned long)j * 2 + 1); + HDsnprintf(s, sizeof(s), "half[%lu][%lu] != twice[%lu][%lu]", (unsigned long)i, + (unsigned long)j, (unsigned long)i * 2 + 1, (unsigned long)j * 2 + 1); if (s[0]) { H5_FAILED(); if (!HDisatty(1)) { @@ -1014,7 +1015,7 @@ test_array_fill(size_t lo, size_t hi) size_t u, v, w; /* Local index variables */ char s[256]; - HDsprintf(s, "array filling %4lu-%-4lu elements", (unsigned long)lo, (unsigned long)hi); + HDsnprintf(s, sizeof(s), "array filling %4lu-%-4lu elements", (unsigned long)lo, (unsigned long)hi); TESTING(s); /* Initialize */ @@ -1078,8 +1079,8 @@ test_array_offset_n_calc(size_t n, size_t x, size_t y, size_t z) hsize_t new_coords[ARRAY_OFFSET_NDIMS]; /* X, Y & X coordinates of offset */ char s[256]; - HDsprintf(s, "array offset %4lux%4lux%4lu elements", (unsigned long)z, (unsigned long)y, - (unsigned long)x); + HDsnprintf(s, sizeof(s), "array offset %4lux%4lux%4lu elements", (unsigned long)z, (unsigned long)y, + (unsigned long)x); TESTING(s); /* Initialize */ diff --git a/test/istore.c b/test/istore.c index f198aad..144355e 100644 --- a/test/istore.c +++ b/test/istore.c @@ -271,20 +271,21 @@ test_extend(hid_t f, const char *prefix, size_t nx, size_t ny, size_t nz) if (!ny) { ndims = 1; ny = nz = 1; - HDsprintf(dims, "%lu", (unsigned long)nx); + HDsnprintf(dims, sizeof(dims), "%lu", (unsigned long)nx); } else { ndims = 2; nz = 1; - HDsprintf(dims, "%lux%lu", (unsigned long)nx, (unsigned long)ny); + HDsnprintf(dims, sizeof(dims), "%lux%lu", (unsigned long)nx, (unsigned long)ny); } } else { ndims = 3; - HDsprintf(dims, "%lux%lux%lu", (unsigned long)nx, (unsigned long)ny, (unsigned long)nz); + HDsnprintf(dims, sizeof(dims), "%lux%lux%lu", (unsigned long)nx, (unsigned long)ny, + (unsigned long)nz); } - HDsprintf(s, "istore extend: %s", dims); + HDsnprintf(s, sizeof(s), "istore extend: %s", dims); TESTING(s); buf = (uint8_t *)HDmalloc(nx * ny * nz); check = (uint8_t *)HDmalloc(nx * ny * nz); @@ -298,7 +299,7 @@ test_extend(hid_t f, const char *prefix, size_t nx, size_t ny, size_t nz) max_corner[2] = 0; /* Build the new empty object */ - HDsprintf(name, "%s_%s", prefix, dims); + HDsnprintf(name, sizeof(name), "%s_%s", prefix, dims); if ((dataset = new_object(f, name, ndims, whole_size, whole_size)) < 0) { HDfprintf(stderr, " Cannot create %u-d object `%s'\n", ndims, name); goto error; @@ -468,20 +469,21 @@ test_sparse(hid_t f, const char *prefix, size_t nblocks, size_t nx, size_t ny, s if (!ny) { ndims = 1; ny = nz = 1; - HDsprintf(dims, "%lu", (unsigned long)nx); + HDsnprintf(dims, sizeof(dims), "%lu", (unsigned long)nx); } else { ndims = 2; nz = 1; - HDsprintf(dims, "%lux%lu", (unsigned long)nx, (unsigned long)ny); + HDsnprintf(dims, sizeof(dims), "%lux%lu", (unsigned long)nx, (unsigned long)ny); } } else { ndims = 3; - HDsprintf(dims, "%lux%lux%lu", (unsigned long)nx, (unsigned long)ny, (unsigned long)nz); + HDsnprintf(dims, sizeof(dims), "%lux%lux%lu", (unsigned long)nx, (unsigned long)ny, + (unsigned long)nz); } - HDsprintf(s, "istore sparse: %s", dims); + HDsnprintf(s, sizeof(s), "istore sparse: %s", dims); TESTING(s); if (skip_test) { SKIPPED(); @@ -500,7 +502,7 @@ test_sparse(hid_t f, const char *prefix, size_t nblocks, size_t nx, size_t ny, s size[2] = nz; /* Build the new empty object */ - HDsprintf(name, "%s_%s", prefix, dims); + HDsnprintf(name, sizeof(name), "%s_%s", prefix, dims); if ((dataset = new_object(f, name, ndims, whole_size, chunk_dims)) < 0) { HDprintf(" Cannot create %u-d object `%s'\n", ndims, name); goto error; diff --git a/test/lheap.c b/test/lheap.c index 1c6a6df..c9c6ca9 100644 --- a/test/lheap.c +++ b/test/lheap.c @@ -97,7 +97,7 @@ main(void) goto error; } for (i = 0; i < NOBJS; i++) { - HDsprintf(buf, "%03d-", i); + HDsnprintf(buf, sizeof(buf), "%03d-", i); for (j = 4; j < i; j++) buf[j] = (char)('0' + j % 10); if (j > 4) @@ -137,7 +137,7 @@ main(void) goto error; } for (i = 0; i < NOBJS; i++) { - HDsprintf(buf, "%03d-", i); + HDsnprintf(buf, sizeof(buf), "%03d-", i); for (j = 4; j < i; j++) buf[j] = (char)('0' + j % 10); if (j > 4) @@ -6586,22 +6586,22 @@ error: memb_map[H5FD_MEM_DRAW] = H5FD_MEM_DRAW; \ memb_map[H5FD_MEM_GHEAP] = H5FD_MEM_GHEAP; \ memb_map[H5FD_MEM_LHEAP] = H5FD_MEM_LHEAP; \ - HDsprintf(sv[H5FD_MEM_SUPER], "%%s-%c.h5", 's'); \ + HDsnprintf(sv[H5FD_MEM_SUPER], 64, "%%s-%c.h5", 's'); \ memb_name[H5FD_MEM_SUPER] = sv[H5FD_MEM_SUPER]; \ memb_addr[H5FD_MEM_SUPER] = 0; \ - HDsprintf(sv[H5FD_MEM_BTREE], "%%s-%c.h5", 'b'); \ + HDsnprintf(sv[H5FD_MEM_BTREE], 64, "%%s-%c.h5", 'b'); \ memb_name[H5FD_MEM_BTREE] = sv[H5FD_MEM_BTREE]; \ memb_addr[H5FD_MEM_BTREE] = HADDR_MAX / 6; \ - HDsprintf(sv[H5FD_MEM_DRAW], "%%s-%c.h5", 'r'); \ + HDsnprintf(sv[H5FD_MEM_DRAW], 64, "%%s-%c.h5", 'r'); \ memb_name[H5FD_MEM_DRAW] = sv[H5FD_MEM_DRAW]; \ memb_addr[H5FD_MEM_DRAW] = HADDR_MAX / 3; \ - HDsprintf(sv[H5FD_MEM_GHEAP], "%%s-%c.h5", 'g'); \ + HDsnprintf(sv[H5FD_MEM_GHEAP], 64, "%%s-%c.h5", 'g'); \ memb_name[H5FD_MEM_GHEAP] = sv[H5FD_MEM_GHEAP]; \ memb_addr[H5FD_MEM_GHEAP] = HADDR_MAX / 2; \ - HDsprintf(sv[H5FD_MEM_LHEAP], "%%s-%c.h5", 'l'); \ + HDsnprintf(sv[H5FD_MEM_LHEAP], 64, "%%s-%c.h5", 'l'); \ memb_name[H5FD_MEM_LHEAP] = sv[H5FD_MEM_LHEAP]; \ memb_addr[H5FD_MEM_LHEAP] = HADDR_MAX * 2 / 3; \ - HDsprintf(sv[H5FD_MEM_OHDR], "%%s-%c.h5", 'o'); \ + HDsnprintf(sv[H5FD_MEM_OHDR], 64, "%%s-%c.h5", 'o'); \ memb_name[H5FD_MEM_OHDR] = sv[H5FD_MEM_OHDR]; \ memb_addr[H5FD_MEM_OHDR] = HADDR_MAX * 5 / 6; \ } diff --git a/test/objcopy.c b/test/objcopy.c index cc8f428..62fb22e 100644 --- a/test/objcopy.c +++ b/test/objcopy.c @@ -646,7 +646,7 @@ test_copy_attach_attributes(hid_t loc_id, hid_t type_id) goto done; for (u = 0; u < num_attributes_g; u++) { - HDsprintf(attr_name, "%u attr", u); + HDsnprintf(attr_name, sizeof(attr_name), "%u attr", u); /* Set attribute data */ attr_data[0] = (int)(100 * u); @@ -715,7 +715,7 @@ test_copy_attach_paired_attributes(hid_t loc_id, hid_t loc_id2, hid_t type_id) goto done; for (u = 0; u < num_attributes_g; u++) { - HDsprintf(attr_name, "%u attr", u); + HDsnprintf(attr_name, sizeof(attr_name), "%u attr", u); /* Set attribute data */ attr_data[0] = (int)(100 * u); @@ -7933,17 +7933,17 @@ test_copy_group_deep(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_f /* create nested sub-groups & datasets */ for (i = 0; i < NUM_SUB_GROUPS; i++) { - HDsprintf(objname, "Group #%d", i); + HDsnprintf(objname, sizeof(objname), "Group #%d", i); if ((gid_sub = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; for (j = 0; j < NUM_SUB_GROUPS; j++) { - HDsprintf(objname, "Group #%d", j); + HDsnprintf(objname, sizeof(objname), "Group #%d", j); if ((gid_sub2 = H5Gcreate2(gid_sub, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; for (k = 0; k < NUM_DATASETS; k++) { - HDsprintf(objname, "Dataset #%d", k); + HDsnprintf(objname, sizeof(objname), "Dataset #%d", k); /* add a dataset to the group */ if ((did = H5Dcreate2(gid_sub2, objname, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, @@ -8222,12 +8222,12 @@ test_copy_group_wide_loop(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t /* create wide sub-group hierarchy, with multiple links to higher groups */ for (u = 0; u < NUM_WIDE_LOOP_GROUPS; u++) { - HDsprintf(objname, "%s-%u", NAME_GROUP_SUB, u); + HDsnprintf(objname, sizeof(objname), "%s-%u", NAME_GROUP_SUB, u); if ((gid_sub = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; for (v = 0; v < NUM_WIDE_LOOP_GROUPS; v++) { - HDsprintf(objname, "%s-%u", NAME_GROUP_SUB_SUB2, v); + HDsnprintf(objname, sizeof(objname), "%s-%u", NAME_GROUP_SUB_SUB2, v); if ((gid_sub2 = H5Gcreate2(gid_sub, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; diff --git a/test/objcopy_ref.c b/test/objcopy_ref.c index adc1a84..ef20cb4 100644 --- a/test/objcopy_ref.c +++ b/test/objcopy_ref.c @@ -509,7 +509,7 @@ test_copy_attach_attributes(hid_t loc_id, hid_t type_id) goto done; for (u = 0; u < num_attributes_g; u++) { - HDsprintf(attr_name, "%u attr", u); + HDsnprintf(attr_name, sizeof(attr_name), "%u attr", u); /* Set attribute data */ attr_data[0] = (int)(100 * u); @@ -939,8 +939,10 @@ compare_data(hid_t parent1, hid_t parent2, hid_t pid, hid_t tid, size_t nelmts, H5R_ref_t *ref_buf1, *ref_buf2; /* Aliases for buffers to compare */ /* Loop over elements in buffers */ + H5_GCC_CLANG_DIAG_OFF("cast-qual") ref_buf1 = (H5R_ref_t *)buf1; ref_buf2 = (H5R_ref_t *)buf2; + H5_GCC_CLANG_DIAG_ON("cast-qual") for (u = 0; u < nelmts; u++, ref_buf1++, ref_buf2++) { hid_t obj1_id, obj2_id; /* IDs for objects referenced */ H5O_type_t obj1_type, obj2_type; /* Types of objects referenced */ diff --git a/test/ohdr.c b/test/ohdr.c index 6b31334..dc0497f 100644 --- a/test/ohdr.c +++ b/test/ohdr.c @@ -1883,7 +1883,7 @@ main(void) /* Display info about testing */ low_string = h5_get_version_string(low); high_string = h5_get_version_string(high); - HDsprintf(msg, "Using file format version: (%s, %s)", low_string, high_string); + HDsnprintf(msg, sizeof(msg), "Using file format version: (%s, %s)", low_string, high_string); HDputs(msg); /* test on object continuation block */ diff --git a/test/stab.c b/test/stab.c index d08ebca..b4c92a4 100644 --- a/test/stab.c +++ b/test/stab.c @@ -219,8 +219,9 @@ test_long(hid_t fcpl, hid_t fapl, hbool_t new_format) for (i = 0; i < LONG_NAME_LEN; i++) name1[i] = (char)('A' + i % 26); name1[LONG_NAME_LEN - 1] = '\0'; - name2 = (char *)HDmalloc((size_t)((2 * LONG_NAME_LEN) + 2)); - HDsprintf(name2, "%s/%s", name1, name1); + size_t name2Len = (2 * LONG_NAME_LEN) + 2; + name2 = (char *)HDmalloc(name2Len); + HDsnprintf(name2, name2Len, "%s/%s", name1, name1); /* Create groups */ if ((g1 = H5Gcreate2(fid, name1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) @@ -310,7 +311,7 @@ test_large(hid_t fcpl, hid_t fapl, hbool_t new_format) if (H5G__has_stab_test(cwg) != FALSE) TEST_ERROR; for (i = 0; i < LARGE_NOBJS; i++) { - HDsprintf(name, "%05d%05d", (HDrandom() % 100000), i); + HDsnprintf(name, sizeof(name), "%05d%05d", (HDrandom() % 100000), i); if ((dir = H5Gcreate2(cwg, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; if (H5Gclose(dir) < 0) @@ -452,7 +453,7 @@ lifecycle(hid_t fcpl, hid_t fapl2) TEST_ERROR; /* Create first "bottom" group */ - HDsprintf(objname, LIFECYCLE_BOTTOM_GROUP, (unsigned)0); + HDsnprintf(objname, sizeof(objname), LIFECYCLE_BOTTOM_GROUP, (unsigned)0); if ((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; @@ -475,7 +476,7 @@ lifecycle(hid_t fcpl, hid_t fapl2) /* Create several more bottom groups, to push the top group almost to a symbol table */ /* (Start counting at '1', since we've already created one bottom group */ for (u = 1; u < LIFECYCLE_MAX_COMPACT; u++) { - HDsprintf(objname, LIFECYCLE_BOTTOM_GROUP, u); + HDsnprintf(objname, sizeof(objname), LIFECYCLE_BOTTOM_GROUP, u); if ((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; @@ -511,7 +512,7 @@ lifecycle(hid_t fcpl, hid_t fapl2) TEST_ERROR; /* Create one more "bottom" group, which should push top group into using a symbol table */ - HDsprintf(objname, LIFECYCLE_BOTTOM_GROUP, u); + HDsnprintf(objname, sizeof(objname), LIFECYCLE_BOTTOM_GROUP, u); if ((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; @@ -545,7 +546,7 @@ lifecycle(hid_t fcpl, hid_t fapl2) /* Unlink objects from top group */ while (u >= LIFECYCLE_MIN_DENSE) { - HDsprintf(objname, LIFECYCLE_BOTTOM_GROUP, u); + HDsnprintf(objname, sizeof(objname), LIFECYCLE_BOTTOM_GROUP, u); if (H5Ldelete(gid, objname, H5P_DEFAULT) < 0) FAIL_STACK_ERROR; @@ -562,7 +563,7 @@ lifecycle(hid_t fcpl, hid_t fapl2) TEST_ERROR; /* Unlink one more object from the group, which should transform back to using links */ - HDsprintf(objname, LIFECYCLE_BOTTOM_GROUP, u); + HDsnprintf(objname, sizeof(objname), LIFECYCLE_BOTTOM_GROUP, u); if (H5Ldelete(gid, objname, H5P_DEFAULT) < 0) FAIL_STACK_ERROR; u--; @@ -576,11 +577,11 @@ lifecycle(hid_t fcpl, hid_t fapl2) TEST_ERROR; /* Unlink last two objects from top group */ - HDsprintf(objname, LIFECYCLE_BOTTOM_GROUP, u); + HDsnprintf(objname, sizeof(objname), LIFECYCLE_BOTTOM_GROUP, u); if (H5Ldelete(gid, objname, H5P_DEFAULT) < 0) FAIL_STACK_ERROR; u--; - HDsprintf(objname, LIFECYCLE_BOTTOM_GROUP, u); + HDsnprintf(objname, sizeof(objname), LIFECYCLE_BOTTOM_GROUP, u); if (H5Ldelete(gid, objname, H5P_DEFAULT) < 0) FAIL_STACK_ERROR; @@ -841,7 +842,7 @@ read_old(void) /* Create a bunch of objects in the group */ for (u = 0; u < READ_OLD_NGROUPS; u++) { - HDsprintf(objname, "Group %u", u); + HDsnprintf(objname, sizeof(objname), "Group %u", u); if ((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; @@ -865,7 +866,7 @@ read_old(void) /* Delete new objects from old group */ for (u = 0; u < READ_OLD_NGROUPS; u++) { - HDsprintf(objname, "Group %u", u); + HDsnprintf(objname, sizeof(objname), "Group %u", u); if (H5Ldelete(gid, objname, H5P_DEFAULT) < 0) FAIL_STACK_ERROR; } /* end for */ @@ -977,7 +978,7 @@ no_compact(hid_t fcpl, hid_t fapl2) TEST_ERROR; /* Create first "bottom" group */ - HDsprintf(objname, NO_COMPACT_BOTTOM_GROUP, (unsigned)0); + HDsnprintf(objname, sizeof(objname), NO_COMPACT_BOTTOM_GROUP, (unsigned)0); if ((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; @@ -998,7 +999,7 @@ no_compact(hid_t fcpl, hid_t fapl2) TEST_ERROR; /* Unlink object from top group */ - HDsprintf(objname, NO_COMPACT_BOTTOM_GROUP, (unsigned)0); + HDsnprintf(objname, sizeof(objname), NO_COMPACT_BOTTOM_GROUP, (unsigned)0); if (H5Ldelete(gid, objname, H5P_DEFAULT) < 0) FAIL_STACK_ERROR; diff --git a/test/swmr_common.c b/test/swmr_common.c index b359bc6..9063ddd 100644 --- a/test/swmr_common.c +++ b/test/swmr_common.c @@ -162,6 +162,9 @@ create_symbol_datatype(void) * Buffer for the created name. Must be pre-allocated. * Since the name is formulaic, this isn't considered an issue. * + * size_t name_buf_length + * The length in bytes of the name_buf buffer + * * unsigned level * The dataset's level * @@ -175,11 +178,11 @@ create_symbol_datatype(void) *------------------------------------------------------------------------- */ int -generate_name(char *name_buf, unsigned level, unsigned count) +generate_name(char *name_buf, size_t name_buf_length, unsigned level, unsigned count) { HDassert(name_buf); - HDsprintf(name_buf, "%u-%04u", level, count); + HDsnprintf(name_buf, name_buf_length, "%u-%04u", level, count); return 0; } /* end generate_name() */ @@ -206,7 +209,7 @@ generate_symbols(void) for (v = 0; v < symbol_count[u]; v++) { char name_buf[64]; - generate_name(name_buf, u, v); + generate_name(name_buf, sizeof(name_buf), u, v); symbol_info[u][v].name = HDstrdup(name_buf); symbol_info[u][v].dsid = -1; symbol_info[u][v].nrecords = 0; diff --git a/test/swmr_common.h b/test/swmr_common.h index d0d829d..5fcf923 100644 --- a/test/swmr_common.h +++ b/test/swmr_common.h @@ -66,10 +66,10 @@ extern "C" { H5TEST_DLL symbol_info_t *choose_dataset(void); H5TEST_DLL hid_t create_symbol_datatype(void); -H5TEST_DLL int generate_name(char *name_buf, unsigned level, unsigned count); -H5TEST_DLL int generate_symbols(void); -H5TEST_DLL int shutdown_symbols(void); -H5TEST_DLL int print_metadata_retries_info(hid_t fid); +H5TEST_DLL int generate_name(char *name_buf, size_t name_buf_length, unsigned level, unsigned count); +H5TEST_DLL int generate_symbols(void); +H5TEST_DLL int shutdown_symbols(void); +H5TEST_DLL int print_metadata_retries_info(hid_t fid); #ifdef __cplusplus } diff --git a/test/swmr_generator.c b/test/swmr_generator.c index 93cfa0f..51caa27 100644 --- a/test/swmr_generator.c +++ b/test/swmr_generator.c @@ -188,7 +188,7 @@ gen_skeleton(const char *filename, hbool_t verbose, hbool_t swmr_write, int comp hbool_t move_dataspace_message = FALSE; /* Whether to move the dataspace message out of object header chunk #0 */ - generate_name(name_buf, u, v); + generate_name(name_buf, sizeof(name_buf), u, v); if ((dsid = H5Dcreate2(fid, name_buf, tid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) return -1; diff --git a/test/tattr.c b/test/tattr.c index 2859f4c..d214719 100644 --- a/test/tattr.c +++ b/test/tattr.c @@ -2737,7 +2737,7 @@ test_attr_dense_rename(hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Aclose"); /* Rename attribute */ - HDsprintf(new_attrname, "new attr %02u", u); + HDsnprintf(new_attrname, sizeof(new_attrname), "new attr %02u", u); /* Rename attribute */ ret = H5Arename_by_name(fid, DSET1_NAME, attrname, new_attrname, H5P_DEFAULT); @@ -9015,7 +9015,7 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test"); /* Create new attribute name */ - HDsprintf(attrname2, "new attr %02u", u); + HDsnprintf(attrname2, sizeof(attrname2), "new attr %02u", u); /* Change second dataset's attribute's name */ ret = H5Arename_by_name(fid, DSET2_NAME, attrname, attrname2, H5P_DEFAULT); @@ -10126,7 +10126,7 @@ test_attr_bug2(hid_t fcpl, hid_t fapl) /* Create attributes on group */ for (i = 0; i < BUG2_NATTR; i++) { - HDsprintf(aname, "%03u", i); + HDsnprintf(aname, sizeof(aname), "%03u", i); aid = H5Acreate2(gid, aname, H5T_STD_I32LE, sid, H5P_DEFAULT, H5P_DEFAULT); CHECK(aid, FAIL, "H5Acreate2"); @@ -10136,7 +10136,7 @@ test_attr_bug2(hid_t fcpl, hid_t fapl) /* Delete every other attribute */ for (i = 1; i < BUG2_NATTR; i += 2) { - HDsprintf(aname, "%03u", i); + HDsnprintf(aname, sizeof(aname), "%03u", i); ret = H5Adelete(gid, aname); CHECK(ret, FAIL, "H5Adelete"); } @@ -10160,7 +10160,7 @@ test_attr_bug2(hid_t fcpl, hid_t fapl) /* Open an attribute in the middle */ i = (BUG2_NATTR / 4) * 2; - HDsprintf(aname, "%03u", i); + HDsnprintf(aname, sizeof(aname), "%03u", i); aid = H5Aopen(gid, aname, H5P_DEFAULT); CHECK(aid, FAIL, "H5Aopen"); @@ -10203,7 +10203,7 @@ test_attr_bug2(hid_t fcpl, hid_t fapl) /* Create attributes on group */ for (i = 0; i < BUG2_NATTR2; i++) { - HDsprintf(aname, "%03u", i); + HDsnprintf(aname, sizeof(aname), "%03u", i); aid = H5Acreate2(gid, aname, H5T_STD_I32LE, sid, H5P_DEFAULT, H5P_DEFAULT); CHECK(aid, FAIL, "H5Acreate2"); @@ -10213,7 +10213,7 @@ test_attr_bug2(hid_t fcpl, hid_t fapl) /* Delete every other attribute */ for (i = 0; i < BUG2_NATTR2; i++) { - HDsprintf(aname, "%03u", i); + HDsnprintf(aname, sizeof(aname), "%03u", i); ret = H5Adelete(gid, aname); CHECK(ret, FAIL, "H5Adelete"); } diff --git a/test/tconfig.c b/test/tconfig.c index 8bd625f..8cffd54 100644 --- a/test/tconfig.c +++ b/test/tconfig.c @@ -161,11 +161,6 @@ test_config_ctypes(void) vrfy_cint_type(int_least64_t, uint_least64_t, H5_SIZEOF_INT_LEAST64_T); #endif - /* pseudo standard basic types */ -#if H5_SIZEOF___INT64 > 0 - vrfy_cint_type(__int64, unsigned __int64, H5_SIZEOF___INT64); -#endif - #if H5_SIZEOF_OFF_T > 0 vrfy_ctype(off_t, H5_SIZEOF_OFF_T); #endif diff --git a/test/test_swmr.sh.in b/test/test_swmr.sh.in index e517ddc..012b024 100644 --- a/test/test_swmr.sh.in +++ b/test/test_swmr.sh.in @@ -60,16 +60,16 @@ TESTING() { # This performs similar function as the routine h5_wait_message() in test/h5test.c WAIT_MESSAGE() { message=$1 # Get the name of the message file to wait for - t0=$(date +%s) # Get current time in seconds + t0=`date +%s` # Get current time in seconds difft=0 # Initialize the time difference mexist=0 # Indicate whether the message file is found while [ $difft -lt $MESSAGE_TIMEOUT ] ; # Loop till message times out do - t1=$(date +%s) # Get current time in seconds - difft=$(("$t1" - "$t0")) # Calculate the time difference - if [ -e "$message" ]; then # If message file is found: + t1=`date +%s` # Get current time in seconds + difft=`expr $t1 - $t0` # Calculate the time difference + if [ -e $message ]; then # If message file is found: mexist=1 # indicate the message file is found - rm "$message" # remove the message file + rm $message # remove the message file break # get out of the while loop fi done; @@ -128,7 +128,7 @@ for FILE in swmr*; do *.o) continue ;; ## don't copy the .o files esac if test -f "$FILE" ; then - cp "$FILE" swmr_test + cp $FILE swmr_test fi done @@ -143,12 +143,12 @@ if [ -f .libs/swmr ]; then *.o) continue ;; ## don't copy the .o files esac if test -f "$FILE" ; then - cp "$FILE" swmr_test/.libs + cp $FILE swmr_test/.libs fi done fi -cd swmr_test || exit 1 +cd swmr_test # Loop over index types @@ -171,7 +171,7 @@ do $testdir/swmr_generator -q $compress $index_type if test $? -ne 0; then echo generator had error - nerrors=$((nerrors + 1)) + nerrors=`expr $nerrors + 1` fi # Launch the Generator with SWMR_WRITE @@ -179,7 +179,7 @@ do $testdir/swmr_generator -q -s $compress $index_type if test $? -ne 0; then echo generator had error - nerrors=$((nerrors + 1)) + nerrors=`expr $nerrors + 1` fi # Check for error and exit if one occurred @@ -217,19 +217,19 @@ do seed="" $testdir/swmr_reader -q $Nsecs_add $seed 2>&1 |tee swmr_reader.out.$n & pid_readers="$pid_readers $!" - n=$((n + 1)) + n=`expr $n + 1` done - $DPRINT pid_readers="$pid_readers" + $DPRINT pid_readers=$pid_readers $IFDEBUG ps # Collect exit codes of the readers first because they usually finish # before the writer. for xpid in $pid_readers; do - $DPRINT checked reader "$xpid" - wait "$xpid" + $DPRINT checked reader $xpid + wait $xpid if test $? -ne 0; then echo reader had error - nerrors=$((nerrors + 1)) + nerrors=`expr $nerrors + 1` fi done @@ -238,7 +238,7 @@ do wait $pid_writer if test $? -ne 0; then echo writer had error - nerrors=$((nerrors + 1)) + nerrors=`expr $nerrors + 1` fi # Check for error and exit if one occurred @@ -263,7 +263,7 @@ do $testdir/swmr_generator -q -s $compress $index_type if test $? -ne 0; then echo generator had error - nerrors=$((nerrors + 1)) + nerrors=`expr $nerrors + 1` fi # Remove any possible writer message file before launching writer @@ -289,19 +289,19 @@ do seed="" $testdir/swmr_reader -q $Nsecs_add $seed 2>&1 |tee swmr_reader.out.$n & pid_readers="$pid_readers $!" - n=$((n + 1)) + n=`expr $n + 1` done - $DPRINT pid_readers="$pid_readers" + $DPRINT pid_readers=$pid_readers $IFDEBUG ps # Collect exit code of the readers first because they usually finish # before the writer. for xpid in $pid_readers; do - $DPRINT checked reader "$xpid" - wait "$xpid" + $DPRINT checked reader $xpid + wait $xpid if test $? -ne 0; then echo reader had error - nerrors=$((nerrors + 1)) + nerrors=`expr $nerrors + 1` fi done @@ -310,7 +310,7 @@ do wait $pid_writer if test $? -ne 0; then echo writer had error - nerrors=$((nerrors + 1)) + nerrors=`expr $nerrors + 1` fi # Check for error and exit if one occurred @@ -352,19 +352,19 @@ do seed="" $testdir/swmr_remove_reader -q $Nsecs_rem $seed 2>&1 |tee swmr_reader.out.$n & pid_readers="$pid_readers $!" - n=$((n + 1)) + n=`expr $n + 1` done - $DPRINT pid_readers="$pid_readers" + $DPRINT pid_readers=$pid_readers $IFDEBUG ps # Collect exit code of the readers first because they usually finish # before the writer. for xpid in $pid_readers; do - $DPRINT checked reader "$xpid" - wait "$xpid" + $DPRINT checked reader $xpid + wait $xpid if test $? -ne 0; then echo reader had error - nerrors=$((nerrors + 1)) + nerrors=`expr $nerrors + 1` fi done @@ -373,7 +373,7 @@ do wait $pid_writer if test $? -ne 0; then echo writer had error - nerrors=$((nerrors + 1)) + nerrors=`expr $nerrors + 1` fi # Check for error and exit if one occurred @@ -398,7 +398,7 @@ do $testdir/swmr_generator -q $compress $index_type if test $? -ne 0; then echo generator had error - nerrors=$((nerrors + 1)) + nerrors=`expr $nerrors + 1` fi # Launch the Writer (not in parallel - just to rebuild the datasets) @@ -407,7 +407,7 @@ do $testdir/swmr_writer -q $Nrecords $seed if test $? -ne 0; then echo writer had error - nerrors=$((nerrors + 1)) + nerrors=`expr $nerrors + 1` fi # Remove any possible writer message file before launching writer @@ -433,19 +433,19 @@ do seed="" $testdir/swmr_remove_reader -q $Nsecs_addrem $seed 2>&1 |tee swmr_reader.out.$n & pid_readers="$pid_readers $!" - n=$((n + 1)) + n=`expr $n + 1` done - $DPRINT pid_readers="$pid_readers" + $DPRINT pid_readers=$pid_readers $IFDEBUG ps # Collect exit code of the readers first because they usually finish # before the writer. for xpid in $pid_readers; do - $DPRINT checked reader "$xpid" - wait "$xpid" + $DPRINT checked reader $xpid + wait $xpid if test $? -ne 0; then echo reader had error - nerrors=$((nerrors + 1)) + nerrors=`expr $nerrors + 1` fi done @@ -454,7 +454,7 @@ do wait $pid_writer if test $? -ne 0; then echo writer had error - nerrors=$((nerrors + 1)) + nerrors=`expr $nerrors + 1` fi # Check for error and exit if one occurred @@ -482,7 +482,7 @@ do $testdir/swmr_generator -q $compress $index_type $seed if test $? -ne 0; then echo generator had error - nerrors=$((nerrors + 1)) + nerrors=`expr $nerrors + 1` fi # Remove any possible writer message file before launching writer @@ -504,26 +504,26 @@ do # The sparse reader spits out a LOT of data so it's set to 'quiet' $testdir/swmr_sparse_reader -q $Nrecs_spa 2>&1 |tee swmr_reader.out.$n & pid_readers="$pid_readers $!" - n=$((n + 1)) + n=`expr $n + 1` done - $DPRINT pid_readers="$pid_readers" + $DPRINT pid_readers=$pid_readers $IFDEBUG ps # Collect exit code of the writer - $DPRINT checked writer "$pid_writer" - wait "$pid_writer" + $DPRINT checked writer $pid_writer + wait $pid_writer if test $? -ne 0; then echo writer had error - nerrors=$((nerrors + 1)) + nerrors=`expr $nerrors + 1` fi # Collect exit code of the readers for xpid in $pid_readers; do - $DPRINT checked reader "$xpid" - wait "$xpid" + $DPRINT checked reader $xpid + wait $xpid if test $? -ne 0; then echo reader had error - nerrors=$((nerrors + 1)) + nerrors=`expr $nerrors + 1` fi done diff --git a/test/testframe.c b/test/testframe.c index d3f0211..e7499ed 100644 --- a/test/testframe.c +++ b/test/testframe.c @@ -413,16 +413,20 @@ SetTestVerbosity(int newval) Values: 0: Exhaustive run Tests should take as long as necessary - 1: Full run. Default if HDF5TestExpress is not defined + 1: Full run. Default if H5_TEST_EXPRESS_LEVEL_DEFAULT + and HDF5TestExpress are not defined Tests should take no more than 30 minutes 2: Quick run Tests should take no more than 10 minutes - 3: Smoke test. Default if HDF5TestExpress is set to a value other than 0-3 + 3: Smoke test. + Default if HDF5TestExpress is set to a value other than 0-3 Tests should take less than 1 minute Design: If the environment variable $HDF5TestExpress is defined, - then test programs should skip some tests so that they + or if a default testing level > 1 has been set via + H5_TEST_EXPRESS_LEVEL_DEFAULT, then test programs should + skip some tests so that they complete sooner. Terms: @@ -442,18 +446,27 @@ GetTestExpress(void) /* set it here for now. Should be done in something like h5test_init(). */ if (TestExpress == -1) { + int express_val = 1; + + /* Check if a default test express level is defined (e.g., by build system) */ +#ifdef H5_TEST_EXPRESS_LEVEL_DEFAULT + express_val = H5_TEST_EXPRESS_LEVEL_DEFAULT; +#endif + + /* Check if HDF5TestExpress is set to override the default level */ env_val = HDgetenv("HDF5TestExpress"); + if (env_val) { + if (HDstrcmp(env_val, "0") == 0) + express_val = 0; + else if (HDstrcmp(env_val, "1") == 0) + express_val = 1; + else if (HDstrcmp(env_val, "2") == 0) + express_val = 2; + else + express_val = 3; + } - if (env_val == NULL) - SetTestExpress(1); - else if (HDstrcmp(env_val, "0") == 0) - SetTestExpress(0); - else if (HDstrcmp(env_val, "1") == 0) - SetTestExpress(1); - else if (HDstrcmp(env_val, "2") == 0) - SetTestExpress(2); - else - SetTestExpress(3); + SetTestExpress(express_val); } return (TestExpress); diff --git a/test/testmeta.c b/test/testmeta.c index a3b5160..a62977b 100644 --- a/test/testmeta.c +++ b/test/testmeta.c @@ -83,7 +83,7 @@ main(void) for (i = 0; i < NEXTARRAYS; i++) { /* Create dataset */ - HDsprintf(name, "/ExtArray%06d", i); + HDsnprintf(name, sizeof(name), "/ExtArray%06d", i); dataset_id = H5Dcreate2(file_id, name, H5T_NATIVE_FLOAT, dataspace_id, H5P_DEFAULT, prop_id, H5P_DEFAULT); @@ -108,7 +108,7 @@ main(void) floatval = (float)j; /* Create group to hold data arrays for this object */ - HDsprintf(name, "/DataArray/%06d", j); + HDsnprintf(name, sizeof(name), "/DataArray/%06d", j); group_id = H5Gcreate2(file_id, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (group_id < 0) { HDfprintf(stderr, "Failed to create DataArray group.\n"); @@ -124,7 +124,7 @@ main(void) dataspace_id = H5Screate_simple(1, dims, maxdims); /* Create dataset */ - HDsprintf(name, "DataArray%06d", i); + HDsnprintf(name, sizeof(name), "DataArray%06d", i); dataset_id = H5Dcreate2(group_id, name, H5T_NATIVE_FLOAT, dataspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (dataset_id < 0) { @@ -170,7 +170,7 @@ main(void) /* Extend attribute arrays */ for (i = 0; i < NEXTARRAYS; i++) { /* Open extendable dataset */ - HDsprintf(name, "/ExtArray%06d", i); + HDsnprintf(name, sizeof(name), "/ExtArray%06d", i); dataset_id = H5Dopen2(file_id, name, H5P_DEFAULT); if (dataset_id < 0) { HDfprintf(stderr, "Failed to open ExtArray dataset.\n"); diff --git a/test/tfile.c b/test/tfile.c index 717eb91..caf9c62 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -1111,14 +1111,14 @@ test_get_obj_ids(void) /* creates NGROUPS groups under the root group */ for (m = 0; m < NGROUPS; m++) { - HDsprintf(gname, "group%d", m); + HDsnprintf(gname, sizeof(gname), "group%d", m); gid[m] = H5Gcreate2(fid, gname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(gid[m], FAIL, "H5Gcreate2"); } /* create NDSETS datasets under the root group */ for (n = 0; n < NDSETS; n++) { - HDsprintf(dname, "dataset%d", n); + HDsnprintf(dname, sizeof(dname), "dataset%d", n); dset[n] = H5Dcreate2(fid, dname, H5T_NATIVE_INT, filespace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(dset[n], FAIL, "H5Dcreate2"); } @@ -1178,7 +1178,7 @@ test_get_obj_ids(void) /* Open NDSETS datasets under the root group */ for (n = 0; n < NDSETS; n++) { - HDsprintf(dname, "dataset%d", n); + HDsnprintf(dname, sizeof(dname), "dataset%d", n); dset[n] = H5Dopen2(fid, dname, H5P_DEFAULT); CHECK(dset[n], FAIL, "H5Dcreate2"); } @@ -4473,7 +4473,7 @@ test_file_freespace(const char *env_h5_drvr) /* Create datasets in file */ for (u = 0; u < 10; u++) { - HDsprintf(name, "Dataset %u", u); + HDsnprintf(name, sizeof(name), "Dataset %u", u); dset = H5Dcreate2(file, name, H5T_STD_U32LE, dspace, H5P_DEFAULT, dcpl, H5P_DEFAULT); CHECK(dset, FAIL, "H5Dcreate2"); @@ -4496,7 +4496,7 @@ test_file_freespace(const char *env_h5_drvr) /* Delete datasets in file */ for (k = 9; k >= 0; k--) { - HDsprintf(name, "Dataset %u", (unsigned)k); + HDsnprintf(name, sizeof(name), "Dataset %u", (unsigned)k); ret = H5Ldelete(file, name, H5P_DEFAULT); CHECK(ret, FAIL, "H5Ldelete"); } /* end for */ @@ -4624,7 +4624,7 @@ test_sects_freespace(const char *env_h5_drvr, hbool_t new_format) /* Create datasets in file */ for (u = 0; u < 10; u++) { - HDsprintf(name, "Dataset %u", u); + HDsnprintf(name, sizeof(name), "Dataset %u", u); dset = H5Dcreate2(file, name, H5T_STD_U32LE, dspace, H5P_DEFAULT, dcpl, H5P_DEFAULT); CHECK(dset, FAIL, "H5Dcreate2"); @@ -4642,7 +4642,7 @@ test_sects_freespace(const char *env_h5_drvr, hbool_t new_format) /* Delete odd-numbered datasets in file */ for (u = 0; u < 10; u++) { - HDsprintf(name, "Dataset %u", u); + HDsnprintf(name, sizeof(name), "Dataset %u", u); if (u % 2) { ret = H5Ldelete(file, name, H5P_DEFAULT); CHECK(ret, FAIL, "H5Ldelete"); @@ -7590,7 +7590,7 @@ test_incr_filesize(void) /* Create datasets in file */ for (u = 0; u < 10; u++) { - HDsprintf(name, "Dataset %u", u); + HDsnprintf(name, sizeof(name), "Dataset %u", u); dset = H5Dcreate2(fid, name, H5T_STD_U32LE, dspace, H5P_DEFAULT, dcpl, H5P_DEFAULT); CHECK(dset, FAIL, "H5Dcreate2"); diff --git a/test/th5o.c b/test/th5o.c index 9504f7a..4ffcbef 100644 --- a/test/th5o.c +++ b/test/th5o.c @@ -1738,7 +1738,7 @@ test_h5o_getinfo_visit(void) /* Attach 10 attributes to "group1" */ for (j = 0; j < 10; j++) { /* Create the attribute name */ - HDsprintf(attrname, "attr%u", j); + HDsnprintf(attrname, sizeof(attrname), "attr%u", j); /* Create the attribute */ aid = H5Acreate2(gid1, attrname, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT); CHECK(aid, FAIL, "H5Acreate2"); diff --git a/test/titerate.c b/test/titerate.c index 1d87343..5796f11 100644 --- a/test/titerate.c +++ b/test/titerate.c @@ -156,7 +156,7 @@ test_iter_group(hid_t fapl, hbool_t new_format) CHECK(filespace, FAIL, "H5Screate"); for (i = 0; i < NDATASETS; i++) { - HDsprintf(name, "Dataset %d", i); + HDsnprintf(name, sizeof(name), "Dataset %d", i); dataset = H5Dcreate2(file, name, datatype, filespace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(dataset, FAIL, "H5Dcreate2"); @@ -436,7 +436,7 @@ test_iter_attr(hid_t fapl, hbool_t new_format) CHECK(dataset, FAIL, "H5Dcreate2"); for (i = 0; i < NATTR; i++) { - HDsprintf(name, "Attribute %02d", i); + HDsnprintf(name, sizeof(name), "Attribute %02d", i); attribute = H5Acreate2(dataset, name, H5T_NATIVE_INT, filespace, H5P_DEFAULT, H5P_DEFAULT); CHECK(attribute, FAIL, "H5Acreate2"); @@ -649,7 +649,7 @@ test_iter_group_large(hid_t fapl) /* Create a bunch of groups */ for (i = 0; i < ITER_NGROUPS; i++) { - HDsprintf(gname, "Group_%d", i); + HDsnprintf(gname, sizeof(gname), "Group_%d", i); /* Add the name to the list of objects in the root group */ HDstrcpy(names[i].name, gname); @@ -766,7 +766,7 @@ test_grp_memb_funcs(hid_t fapl) CHECK(filespace, FAIL, "H5Screate"); for (i = 0; i < NDATASETS; i++) { - HDsprintf(name, "Dataset %d", i); + HDsnprintf(name, sizeof(name), "Dataset %d", i); dataset = H5Dcreate2(file, name, datatype, filespace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(dataset, FAIL, "H5Dcreate2"); diff --git a/test/unlink.c b/test/unlink.c index 2527e94..265c497 100644 --- a/test/unlink.c +++ b/test/unlink.c @@ -179,12 +179,12 @@ test_many(hid_t file) /* Create a bunch of names and unlink them in order */ TESTING("forward unlink"); for (i = 0; i < how_many; i++) { - HDsprintf(name, "obj_%05d", i); + HDsnprintf(name, sizeof(name), "obj_%05d", i); if (H5Lcreate_hard(work, "/test_many_foo", H5L_SAME_LOC, name, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR; } /* end for */ for (i = 0; i < how_many; i++) { - HDsprintf(name, "obj_%05d", i); + HDsnprintf(name, sizeof(name), "obj_%05d", i); if (H5Ldelete(work, name, H5P_DEFAULT) < 0) FAIL_STACK_ERROR; } /* end for */ @@ -193,12 +193,12 @@ test_many(hid_t file) /* Create a bunch of names and unlink them in reverse order */ TESTING("backward unlink"); for (i = 0; i < how_many; i++) { - HDsprintf(name, "obj_%05d", i); + HDsnprintf(name, sizeof(name), "obj_%05d", i); if (H5Lcreate_hard(work, "/test_many_foo", H5L_SAME_LOC, name, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR; } /* end for */ for (i = (how_many - 1); i >= 0; --i) { - HDsprintf(name, "obj_%05d", i); + HDsnprintf(name, sizeof(name), "obj_%05d", i); if (H5Ldelete(work, name, H5P_DEFAULT) < 0) FAIL_STACK_ERROR; } /* end for */ @@ -207,15 +207,15 @@ test_many(hid_t file) /* Create a bunch of names and unlink them from both directions */ TESTING("inward unlink"); for (i = 0; i < how_many; i++) { - HDsprintf(name, "obj_%05d", i); + HDsnprintf(name, sizeof(name), "obj_%05d", i); if (H5Lcreate_hard(work, "/test_many_foo", H5L_SAME_LOC, name, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR; } /* end for */ for (i = 0; i < how_many; i++) { if (i % 2) - HDsprintf(name, "obj_%05d", how_many - (1 + i / 2)); + HDsnprintf(name, sizeof(name), "obj_%05d", how_many - (1 + i / 2)); else - HDsprintf(name, "obj_%05d", i / 2); + HDsnprintf(name, sizeof(name), "obj_%05d", i / 2); if (H5Ldelete(work, name, H5P_DEFAULT) < 0) FAIL_STACK_ERROR; } /* end for */ @@ -224,15 +224,15 @@ test_many(hid_t file) /* Create a bunch of names and unlink them from the midle */ TESTING("outward unlink"); for (i = 0; i < how_many; i++) { - HDsprintf(name, "obj_%05d", i); + HDsnprintf(name, sizeof(name), "obj_%05d", i); if (H5Lcreate_hard(work, "/test_many_foo", H5L_SAME_LOC, name, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR; } /* end for */ for (i = (how_many - 1); i >= 0; --i) { if (i % 2) - HDsprintf(name, "obj_%05d", how_many - (1 + i / 2)); + HDsnprintf(name, sizeof(name), "obj_%05d", how_many - (1 + i / 2)); else - HDsprintf(name, "obj_%05d", i / 2); + HDsnprintf(name, sizeof(name), "obj_%05d", i / 2); if (H5Ldelete(work, name, H5P_DEFAULT) < 0) FAIL_STACK_ERROR; } /* end for */ @@ -938,7 +938,7 @@ test_filespace(hid_t fapl) /* Alternate adding attributes to each one */ for (u = 0; u < FILESPACE_NATTR; u++) { /* Set the name of the attribute to create */ - HDsprintf(objname, "%s %u", ATTRNAME, u); + HDsnprintf(objname, sizeof(objname), "%s %u", ATTRNAME, u); /* Create an attribute on the first dataset */ if ((attr = H5Acreate2(dataset, objname, H5T_NATIVE_INT, attr_space, H5P_DEFAULT, H5P_DEFAULT)) < 0) @@ -1070,7 +1070,7 @@ test_filespace(hid_t fapl) /* Create a many groups to remove */ for (u = 0; u < UNLINK_NGROUPS; u++) { - HDsprintf(objname, "%s %u", GROUPNAME, u); + HDsnprintf(objname, sizeof(objname), "%s %u", GROUPNAME, u); if ((group = H5Gcreate2(file, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; if (H5Gclose(group) < 0) @@ -1080,7 +1080,7 @@ test_filespace(hid_t fapl) /* Remove the all the groups */ /* (Remove them in reverse order just to make file size calculation easier -QAK) */ for (u = UNLINK_NGROUPS; u > 0; u--) { - HDsprintf(objname, "%s %u", GROUPNAME, (u - 1)); + HDsnprintf(objname, sizeof(objname), "%s %u", GROUPNAME, (u - 1)); if (H5Ldelete(file, objname, H5P_DEFAULT) < 0) FAIL_STACK_ERROR; } /* end for */ @@ -1148,21 +1148,21 @@ test_filespace(hid_t fapl) /* Create a complex group hierarchy to remove */ for (u = 0; u < FILESPACE_TOP_GROUPS; u++) { /* Create group */ - HDsprintf(objname, "%s %u", GROUPNAME, u); + HDsnprintf(objname, sizeof(objname), "%s %u", GROUPNAME, u); if ((group = H5Gcreate2(file, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; /* Create nested groups inside top groups */ for (v = 0; v < FILESPACE_NESTED_GROUPS; v++) { /* Create group */ - HDsprintf(objname, "%s %u", GROUP2NAME, v); + HDsnprintf(objname, sizeof(objname), "%s %u", GROUP2NAME, v); if ((group2 = H5Gcreate2(group, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; /* Create datasets inside nested groups */ for (w = 0; w < FILESPACE_NDATASETS; w++) { /* Create & close a dataset */ - HDsprintf(objname, "%s %u", DATASETNAME, w); + HDsnprintf(objname, sizeof(objname), "%s %u", DATASETNAME, w); if ((dataset = H5Dcreate2(group2, objname, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; @@ -1184,21 +1184,21 @@ test_filespace(hid_t fapl) /* (Remove them in reverse order just to make file size calculation easier -QAK) */ for (u = FILESPACE_TOP_GROUPS; u > 0; u--) { /* Open group */ - HDsprintf(objname, "%s %u", GROUPNAME, (u - 1)); + HDsnprintf(objname, sizeof(objname), "%s %u", GROUPNAME, (u - 1)); if ((group = H5Gopen2(file, objname, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; /* Open nested groups inside top groups */ for (v = 0; v < FILESPACE_NESTED_GROUPS; v++) { /* Create group */ - HDsprintf(objname, "%s %u", GROUP2NAME, v); + HDsnprintf(objname, sizeof(objname), "%s %u", GROUP2NAME, v); if ((group2 = H5Gopen2(group, objname, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; /* Remove datasets inside nested groups */ for (w = 0; w < FILESPACE_NDATASETS; w++) { /* Remove dataset */ - HDsprintf(objname, "%s %u", DATASETNAME, w); + HDsnprintf(objname, sizeof(objname), "%s %u", DATASETNAME, w); if (H5Ldelete(group2, objname, H5P_DEFAULT) < 0) FAIL_STACK_ERROR; } /* end for */ @@ -1208,7 +1208,7 @@ test_filespace(hid_t fapl) FAIL_STACK_ERROR; /* Remove nested group */ - HDsprintf(objname, "%s %u", GROUP2NAME, v); + HDsnprintf(objname, sizeof(objname), "%s %u", GROUP2NAME, v); if (H5Ldelete(group, objname, H5P_DEFAULT) < 0) FAIL_STACK_ERROR; } /* end for */ @@ -1218,7 +1218,7 @@ test_filespace(hid_t fapl) FAIL_STACK_ERROR; /* Remove top group */ - HDsprintf(objname, "%s %u", GROUPNAME, (u - 1)); + HDsnprintf(objname, sizeof(objname), "%s %u", GROUPNAME, (u - 1)); if (H5Ldelete(file, objname, H5P_DEFAULT) < 0) FAIL_STACK_ERROR; } /* end for */ @@ -1502,7 +1502,7 @@ test_create_unlink(const char *msg, hid_t fapl) /* Create a many groups to remove */ for (u = 0; u < UNLINK_NGROUPS; u++) { - HDsprintf(groupname, "%s %u", GROUPNAME, u); + HDsnprintf(groupname, sizeof(groupname), "%s %u", GROUPNAME, u); if ((group = H5Gcreate2(file, groupname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { H5_FAILED(); HDprintf("group %s creation failed\n", groupname); @@ -1517,7 +1517,7 @@ test_create_unlink(const char *msg, hid_t fapl) /* Remove the all the groups */ for (u = 0; u < UNLINK_NGROUPS; u++) { - HDsprintf(groupname, "%s %u", GROUPNAME, u); + HDsnprintf(groupname, sizeof(groupname), "%s %u", GROUPNAME, u); if (H5Ldelete(file, groupname, H5P_DEFAULT) < 0) { H5_FAILED(); HDprintf("Unlinking group %s failed\n", groupname); @@ -1765,7 +1765,7 @@ test_unlink_rightleaf(hid_t fid) /* Create all the groups */ for (n = 0; n < ngroups; n++) { - HDsprintf(name, "Zone%d", n + 1); + HDsnprintf(name, sizeof(name), "Zone%d", n + 1); if ((gids[n] = H5Gcreate2(rootid, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; } /* end for */ @@ -1774,7 +1774,7 @@ test_unlink_rightleaf(hid_t fid) for (n = 0; n < ngroups; n++) { if (delete_node(rootid, gids[n]) < 0) TEST_ERROR; - HDsprintf(name, "Zone%d", n + 1); + HDsnprintf(name, sizeof(name), "Zone%d", n + 1); if ((gids[n] = H5Gcreate2(rootid, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; } /* end for */ @@ -1854,7 +1854,7 @@ test_unlink_rightnode(hid_t fid) /* Create all the groups */ for (n = 0; n < ngroups; n++) { - HDsprintf(name, "ZoneB%d", n + 1); + HDsnprintf(name, sizeof(name), "ZoneB%d", n + 1); if ((gids[n] = H5Gcreate2(rootid, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; } /* end for */ @@ -1946,7 +1946,7 @@ test_unlink_middlenode(hid_t fid) /* Create all the groups */ for (n = 0; n < ngroups; n++) { - HDsprintf(name, "ZoneC%d", n + 1); + HDsnprintf(name, sizeof(name), "ZoneC%d", n + 1); if ((gids[n] = H5Gcreate2(rootid, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; } /* end for */ @@ -2676,7 +2676,7 @@ test_full_group_compact(hid_t fapl) /* Create several objects to link to */ for (u = 0; u < FULL_GROUP_NUM_KEEP; u++) { - HDsprintf(objname, "keep %u\n", u); + HDsnprintf(objname, sizeof(objname), "keep %u\n", u); if ((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; if (H5Gclose(gid2) < 0) @@ -2713,15 +2713,15 @@ test_full_group_compact(hid_t fapl) /* Create hard links to objects in group to keep */ for (u = 0; u < FULL_GROUP_NUM_KEEP; u++) { - HDsprintf(objname, "/keep/keep %u\n", u); - HDsprintf(objname2, "keep %u\n", u); + HDsnprintf(objname, sizeof(objname), "/keep/keep %u\n", u); + HDsnprintf(objname2, sizeof(objname2), "keep %u\n", u); if (H5Lcreate_hard(file_id, objname, gid, objname2, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR; } /* end for */ /* Create several objects to delete */ for (u = 0; u < FULL_GROUP_NUM_DELETE_COMPACT; u++) { - HDsprintf(objname, "delete %u\n", u); + HDsnprintf(objname, sizeof(objname), "delete %u\n", u); if ((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; if (H5Gclose(gid2) < 0) @@ -2742,7 +2742,7 @@ test_full_group_compact(hid_t fapl) /* Check reference count on objects to keep */ for (u = 0; u < FULL_GROUP_NUM_KEEP; u++) { - HDsprintf(objname, "/keep/keep %u\n", u); + HDsnprintf(objname, sizeof(objname), "/keep/keep %u\n", u); if (H5Oget_info_by_name3(file_id, objname, &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR; if (oi.rc != 2) @@ -2763,7 +2763,7 @@ test_full_group_compact(hid_t fapl) /* Check reference count on objects to keep */ for (u = 0; u < FULL_GROUP_NUM_KEEP; u++) { - HDsprintf(objname, "/keep/keep %u\n", u); + HDsnprintf(objname, sizeof(objname), "/keep/keep %u\n", u); if (H5Oget_info_by_name3(file_id, objname, &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR; if (oi.rc != 1) @@ -2838,7 +2838,7 @@ test_full_group_dense(hid_t fapl) /* Create several objects to link to */ for (u = 0; u < FULL_GROUP_NUM_KEEP; u++) { - HDsprintf(objname, "keep %u\n", u); + HDsnprintf(objname, sizeof(objname), "keep %u\n", u); if ((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; if (H5Gclose(gid2) < 0) @@ -2890,15 +2890,15 @@ test_full_group_dense(hid_t fapl) /* Create hard links to objects in group to keep */ for (u = 0; u < FULL_GROUP_NUM_KEEP; u++) { - HDsprintf(objname, "/keep/keep %u\n", u); - HDsprintf(objname2, "keep %u\n", u); + HDsnprintf(objname, sizeof(objname), "/keep/keep %u\n", u); + HDsnprintf(objname2, sizeof(objname2), "keep %u\n", u); if (H5Lcreate_hard(file_id, objname, gid, objname2, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR; } /* end for */ /* Create several objects to delete */ for (u = 0; u < FULL_GROUP_NUM_DELETE_DENSE; u++) { - HDsprintf(objname, "delete %u\n", u); + HDsnprintf(objname, sizeof(objname), "delete %u\n", u); if ((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; if (H5Gclose(gid2) < 0) @@ -2919,7 +2919,7 @@ test_full_group_dense(hid_t fapl) /* Check reference count on objects to keep */ for (u = 0; u < FULL_GROUP_NUM_KEEP; u++) { - HDsprintf(objname, "/keep/keep %u\n", u); + HDsnprintf(objname, sizeof(objname), "/keep/keep %u\n", u); if (H5Oget_info_by_name3(file_id, objname, &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR; if (oi.rc != 2) @@ -2940,7 +2940,7 @@ test_full_group_dense(hid_t fapl) /* Check reference count on objects to keep */ for (u = 0; u < FULL_GROUP_NUM_KEEP; u++) { - HDsprintf(objname, "/keep/keep %u\n", u); + HDsnprintf(objname, sizeof(objname), "/keep/keep %u\n", u); if (H5Oget_info_by_name3(file_id, objname, &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR; if (oi.rc != 1) @@ -1538,19 +1538,19 @@ test_multi(void) memb_map[H5FD_MEM_BTREE] = H5FD_MEM_BTREE; memb_map[H5FD_MEM_GHEAP] = H5FD_MEM_GHEAP; - HDsprintf(sv[H5FD_MEM_SUPER], "%%s-%c.h5", 's'); + HDsnprintf(sv[H5FD_MEM_SUPER], 32, "%%s-%c.h5", 's'); memb_name[H5FD_MEM_SUPER] = sv[H5FD_MEM_SUPER]; memb_addr[H5FD_MEM_SUPER] = 0; - HDsprintf(sv[H5FD_MEM_BTREE], "%%s-%c.h5", 'b'); + HDsnprintf(sv[H5FD_MEM_BTREE], 32, "%%s-%c.h5", 'b'); memb_name[H5FD_MEM_BTREE] = sv[H5FD_MEM_BTREE]; memb_addr[H5FD_MEM_BTREE] = HADDR_MAX / 4; - HDsprintf(sv[H5FD_MEM_DRAW], "%%s-%c.h5", 'r'); + HDsnprintf(sv[H5FD_MEM_DRAW], 32, "%%s-%c.h5", 'r'); memb_name[H5FD_MEM_DRAW] = sv[H5FD_MEM_DRAW]; memb_addr[H5FD_MEM_DRAW] = HADDR_MAX / 2; - HDsprintf(sv[H5FD_MEM_GHEAP], "%%s-%c.h5", 'g'); + HDsnprintf(sv[H5FD_MEM_GHEAP], 32, "%%s-%c.h5", 'g'); memb_name[H5FD_MEM_GHEAP] = sv[H5FD_MEM_GHEAP]; memb_addr[H5FD_MEM_GHEAP] = (HADDR_MAX / 4) * 3; @@ -1787,12 +1787,12 @@ test_multi_compat(void) memb_map[H5FD_MEM_DRAW] = H5FD_MEM_DRAW; memb_fapl[H5FD_MEM_SUPER] = H5P_DEFAULT; - HDsprintf(sv[H5FD_MEM_SUPER], "%%s-%c.h5", 's'); + HDsnprintf(sv[H5FD_MEM_SUPER], 32, "%%s-%c.h5", 's'); memb_name[H5FD_MEM_SUPER] = sv[H5FD_MEM_SUPER]; memb_addr[H5FD_MEM_SUPER] = 0; memb_fapl[H5FD_MEM_DRAW] = H5P_DEFAULT; - HDsprintf(sv[H5FD_MEM_DRAW], "%%s-%c.h5", 'r'); + HDsnprintf(sv[H5FD_MEM_DRAW], 32, "%%s-%c.h5", 'r'); memb_name[H5FD_MEM_DRAW] = sv[H5FD_MEM_DRAW]; memb_addr[H5FD_MEM_DRAW] = HADDR_MAX / 2; @@ -1804,12 +1804,12 @@ test_multi_compat(void) /* Make copy for the data file in the build directory, to protect the * original file in the source directory */ - HDsprintf(filename_s, "%s-%c.h5", MULTI_COMPAT_BASENAME, 's'); - HDsprintf(newname_s, "%s-%c.h5", FILENAME[9], 's'); + HDsnprintf(filename_s, sizeof(filename_s), "%s-%c.h5", MULTI_COMPAT_BASENAME, 's'); + HDsnprintf(newname_s, sizeof(newname_s), "%s-%c.h5", FILENAME[9], 's'); h5_make_local_copy(filename_s, newname_s); - HDsprintf(filename_r, "%s-%c.h5", MULTI_COMPAT_BASENAME, 'r'); - HDsprintf(newname_r, "%s-%c.h5", FILENAME[9], 'r'); + HDsnprintf(filename_r, sizeof(filename_r), "%s-%c.h5", MULTI_COMPAT_BASENAME, 'r'); + HDsnprintf(newname_r, sizeof(newname_r), "%s-%c.h5", FILENAME[9], 'r'); h5_make_local_copy(filename_r, newname_r); /* Reopen the file for read only. Verify 1.8 library can open file @@ -3581,12 +3581,12 @@ H5FD__ctl_test_vfd_ctl(H5FD_t H5_ATTR_UNUSED *_file, uint64_t op_code, uint64_t switch (op_code) { /* Op code for testing purposes */ - case H5FD_CTL__TEST_OPCODE: + case H5FD_CTL_TEST_OPCODE: break; /* Unknown op code */ default: - if (flags & H5FD_CTL__FAIL_IF_UNKNOWN_FLAG) + if (flags & H5FD_CTL_FAIL_IF_UNKNOWN_FLAG) ret_value = FAIL; break; } @@ -3660,8 +3660,8 @@ run_ctl_test(uint64_t op_code, uint64_t flags, ctl_test_opc_type opc_type, hid_t char filename[1024]; /* Check for a few ctl function flags */ - fail_if_unknown = (flags & H5FD_CTL__FAIL_IF_UNKNOWN_FLAG); - routing_flag_set = (flags & H5FD_CTL__ROUTE_TO_TERMINAL_VFD_FLAG); + fail_if_unknown = (flags & H5FD_CTL_FAIL_IF_UNKNOWN_FLAG); + routing_flag_set = (flags & H5FD_CTL_ROUTE_TO_TERMINAL_VFD_FLAG); /* Determine if the top-level VFD is a passthrough VFD */ if ((driver_id = H5Pget_driver(fapl_id)) < 0) @@ -3761,7 +3761,7 @@ test_ctl(void) TESTING_2("known op code to terminal VFD (without fail on unknown flag)"); - op_code = H5FD_CTL__TEST_OPCODE; + op_code = H5FD_CTL_TEST_OPCODE; flags = 0; /* H5FDctl call should succeed normally */ @@ -3772,8 +3772,8 @@ test_ctl(void) TESTING_2("known op code to terminal VFD (with fail on unknown flag)"); - op_code = H5FD_CTL__TEST_OPCODE; - flags = H5FD_CTL__FAIL_IF_UNKNOWN_FLAG; + op_code = H5FD_CTL_TEST_OPCODE; + flags = H5FD_CTL_FAIL_IF_UNKNOWN_FLAG; /* H5FDctl call should succeed normally */ if (run_ctl_test(op_code, flags, CTL_OPC_KNOWN_TERMINAL, fapl_id) < 0) @@ -3783,8 +3783,8 @@ test_ctl(void) TESTING_2("known op code to terminal VFD (without fail on unknown flag/route to terminal VFD)"); - op_code = H5FD_CTL__TEST_OPCODE; - flags = H5FD_CTL__ROUTE_TO_TERMINAL_VFD_FLAG; + op_code = H5FD_CTL_TEST_OPCODE; + flags = H5FD_CTL_ROUTE_TO_TERMINAL_VFD_FLAG; /* H5FDctl call should succeed normally */ if (run_ctl_test(op_code, flags, CTL_OPC_KNOWN_TERMINAL, fapl_id) < 0) @@ -3794,8 +3794,8 @@ test_ctl(void) TESTING_2("known op code to terminal VFD (with fail on unknown flag/route to terminal VFD)"); - op_code = H5FD_CTL__TEST_OPCODE; - flags = H5FD_CTL__FAIL_IF_UNKNOWN_FLAG | H5FD_CTL__ROUTE_TO_TERMINAL_VFD_FLAG; + op_code = H5FD_CTL_TEST_OPCODE; + flags = H5FD_CTL_FAIL_IF_UNKNOWN_FLAG | H5FD_CTL_ROUTE_TO_TERMINAL_VFD_FLAG; /* H5FDctl call should succeed normally */ if (run_ctl_test(op_code, flags, CTL_OPC_KNOWN_TERMINAL, fapl_id) < 0) @@ -3817,7 +3817,7 @@ test_ctl(void) TESTING_2("unknown op code to terminal VFD (with fail on unknown flag)"); op_code = H5FD_CTL_OPC_RESERVED; - flags = H5FD_CTL__FAIL_IF_UNKNOWN_FLAG; + flags = H5FD_CTL_FAIL_IF_UNKNOWN_FLAG; /* H5FDctl call should fail due to 'fail if unknown' flag being specified */ if (run_ctl_test(op_code, flags, CTL_OPC_UNKNOWN, fapl_id) < 0) @@ -3828,7 +3828,7 @@ test_ctl(void) TESTING_2("unknown op code to terminal VFD (without fail on unknown flag/route to terminal VFD)"); op_code = H5FD_CTL_OPC_RESERVED; - flags = H5FD_CTL__ROUTE_TO_TERMINAL_VFD_FLAG; + flags = H5FD_CTL_ROUTE_TO_TERMINAL_VFD_FLAG; /* H5FDctl call should silently ignore unknown op code and succeed */ if (run_ctl_test(op_code, flags, CTL_OPC_UNKNOWN, fapl_id) < 0) @@ -3839,7 +3839,7 @@ test_ctl(void) TESTING_2("unknown op code to terminal VFD (with fail on unknown flag/route to terminal VFD)"); op_code = H5FD_CTL_OPC_RESERVED; - flags = H5FD_CTL__FAIL_IF_UNKNOWN_FLAG | H5FD_CTL__ROUTE_TO_TERMINAL_VFD_FLAG; + flags = H5FD_CTL_FAIL_IF_UNKNOWN_FLAG | H5FD_CTL_ROUTE_TO_TERMINAL_VFD_FLAG; /* H5FDctl call should fail due to 'fail if unknown' flag being specified */ if (run_ctl_test(op_code, flags, CTL_OPC_UNKNOWN, fapl_id) < 0) @@ -3870,7 +3870,7 @@ test_ctl(void) TESTING_2("known op code through passthrough VFD to terminal VFD (without fail on unknown flag/no " "routing flag)"); - op_code = H5FD_CTL__TEST_OPCODE; + op_code = H5FD_CTL_TEST_OPCODE; flags = 0; /* @@ -3886,8 +3886,8 @@ test_ctl(void) TESTING_2( "known op code through passthrough VFD to terminal VFD (with fail on unknown flag/no routing flag)"); - op_code = H5FD_CTL__TEST_OPCODE; - flags = H5FD_CTL__FAIL_IF_UNKNOWN_FLAG; + op_code = H5FD_CTL_TEST_OPCODE; + flags = H5FD_CTL_FAIL_IF_UNKNOWN_FLAG; /* * H5FDctl call should fail since op code is unknown to @@ -3903,8 +3903,8 @@ test_ctl(void) TESTING_2("known op code through passthrough VFD to terminal VFD (without fail on unknown flag/route to " "terminal VFD)"); - op_code = H5FD_CTL__TEST_OPCODE; - flags = H5FD_CTL__ROUTE_TO_TERMINAL_VFD_FLAG; + op_code = H5FD_CTL_TEST_OPCODE; + flags = H5FD_CTL_ROUTE_TO_TERMINAL_VFD_FLAG; /* * H5Dctl call should succeed since the passthrough VFD @@ -3919,8 +3919,8 @@ test_ctl(void) TESTING_2("known op code through passthrough VFD to terminal VFD (with fail on unknown flag/route to " "terminal VFD)"); - op_code = H5FD_CTL__TEST_OPCODE; - flags = H5FD_CTL__FAIL_IF_UNKNOWN_FLAG | H5FD_CTL__ROUTE_TO_TERMINAL_VFD_FLAG; + op_code = H5FD_CTL_TEST_OPCODE; + flags = H5FD_CTL_FAIL_IF_UNKNOWN_FLAG | H5FD_CTL_ROUTE_TO_TERMINAL_VFD_FLAG; /* * H5Dctl call should succeed since the passthrough VFD @@ -3950,7 +3950,7 @@ test_ctl(void) TESTING_2("unknown op code to passthrough VFD (with fail on unknown flag)"); op_code = H5FD_CTL_OPC_RESERVED; - flags = H5FD_CTL__FAIL_IF_UNKNOWN_FLAG; + flags = H5FD_CTL_FAIL_IF_UNKNOWN_FLAG; /* * H5FDctl call should fail since op code is unknown to @@ -3965,7 +3965,7 @@ test_ctl(void) TESTING_2("unknown op code to passthrough VFD (without fail on unknown flag/route to terminal VFD)"); op_code = H5FD_CTL_OPC_RESERVED; - flags = H5FD_CTL__ROUTE_TO_TERMINAL_VFD_FLAG; + flags = H5FD_CTL_ROUTE_TO_TERMINAL_VFD_FLAG; /* * H5Dctl call should succeed since the passthrough VFD @@ -3983,7 +3983,7 @@ test_ctl(void) TESTING_2("unknown op code to passthrough VFD (with fail on unknown flag/route to terminal VFD)"); op_code = H5FD_CTL_OPC_RESERVED; - flags = H5FD_CTL__FAIL_IF_UNKNOWN_FLAG | H5FD_CTL__ROUTE_TO_TERMINAL_VFD_FLAG; + flags = H5FD_CTL_FAIL_IF_UNKNOWN_FLAG | H5FD_CTL_ROUTE_TO_TERMINAL_VFD_FLAG; /* * H5Dctl call should fail since the passthrough VFD |