diff options
author | David Young <dyoung@hdfgroup.org> | 2019-12-09 16:30:58 (GMT) |
---|---|---|
committer | David Young <dyoung@hdfgroup.org> | 2019-12-09 16:30:58 (GMT) |
commit | c8f533cfc33ac743227cbed8eba361c715a2976f (patch) | |
tree | bcae5320f80bac774647cacbbd8493604f9384d2 /hl/test | |
parent | adcf8a315e82c0848d126e7e46b662930c081896 (diff) | |
download | hdf5-c8f533cfc33ac743227cbed8eba361c715a2976f.zip hdf5-c8f533cfc33ac743227cbed8eba361c715a2976f.tar.gz hdf5-c8f533cfc33ac743227cbed8eba361c715a2976f.tar.bz2 |
Merge all of my changes from merge-back-to-feature-vfd_swmr-attempt-1,
including the merge of `hdffv/hdf5/develop`, back to the branch that Vailin and
I share.
Now I need to put this branch on a fork with a less confusing name than
vchoi_fork!
Diffstat (limited to 'hl/test')
-rw-r--r-- | hl/test/CMakeLists.txt | 68 | ||||
-rw-r--r-- | hl/test/CMakeTests.cmake | 88 | ||||
-rw-r--r-- | hl/test/gen_test_ds.c | 22 | ||||
-rw-r--r-- | hl/test/h5hltest.h | 4 | ||||
-rw-r--r-- | hl/test/test_ds.c | 138 | ||||
-rw-r--r-- | hl/test/test_dset_append.c | 1088 | ||||
-rw-r--r-- | hl/test/test_file_image.c | 90 | ||||
-rw-r--r-- | hl/test/test_h5do_compat.c | 50 | ||||
-rw-r--r-- | hl/test/test_image.c | 62 | ||||
-rw-r--r-- | hl/test/test_ld.c | 1134 | ||||
-rw-r--r-- | hl/test/test_lite.c | 90 | ||||
-rw-r--r-- | hl/test/test_packet.c | 30 | ||||
-rw-r--r-- | hl/test/test_packet_vlen.c | 810 | ||||
-rw-r--r-- | hl/test/test_table.c | 146 |
14 files changed, 1909 insertions, 1911 deletions
diff --git a/hl/test/CMakeLists.txt b/hl/test/CMakeLists.txt index 238b5e1..2959c6c 100644 --- a/hl/test/CMakeLists.txt +++ b/hl/test/CMakeLists.txt @@ -17,29 +17,26 @@ configure_file (${HDF5_HL_TEST_SOURCE_DIR}/H5srcdir_str.h.in H5srcdir_str.h @ON # -------------------------------------------------------------------- # Macro used to add a unit test # -------------------------------------------------------------------- -MACRO (HL_ADD_EXE hl_name) +macro (HL_ADD_EXE hl_name) add_executable (hl_${hl_name} ${hl_name}.c) - target_include_directories(hl_${hl_name} PRIVATE "${HDF5_TEST_SRC_DIR};${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") - TARGET_C_PROPERTIES (hl_${hl_name} STATIC) - target_link_libraries (hl_${hl_name} PRIVATE - ${HDF5_HL_LIB_TARGET} - ${HDF5_TEST_LIB_TARGET} - ${HDF5_LIB_TARGET} - ) - set_target_properties (hl_${hl_name} PROPERTIES FOLDER test/hl) -ENDMACRO () - -MACRO (HL_ADD_SHEXE hl_name) - add_executable (hl_${hl_name} ${hl_name}.c) - target_include_directories(hl_${hl_name} PRIVATE "${HDF5_TEST_SRC_DIR};${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") - TARGET_C_PROPERTIES (hl_${hl_name} SHARED) - target_link_libraries (hl_${hl_name} PRIVATE - ${HDF5_HL_LIBSH_TARGET} - ${HDF5_TEST_LIBSH_TARGET} - ${HDF5_LIBSH_TARGET} - ) + target_include_directories (hl_${hl_name} PRIVATE "${HDF5_TEST_SRC_DIR};${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + if (NOT BUILD_SHARED_LIBS) + TARGET_C_PROPERTIES (hl_${hl_name} STATIC) + target_link_libraries (hl_${hl_name} PRIVATE + ${HDF5_HL_LIB_TARGET} + ${HDF5_TEST_LIB_TARGET} + ${HDF5_LIB_TARGET} + ) + else () + TARGET_C_PROPERTIES (hl_${hl_name} SHARED) + target_link_libraries (hl_${hl_name} PRIVATE + ${HDF5_HL_LIBSH_TARGET} + ${HDF5_TEST_LIBSH_TARGET} + ${HDF5_LIBSH_TARGET} + ) + endif () set_target_properties (hl_${hl_name} PROPERTIES FOLDER test/hl) -ENDMACRO () +endmacro () HL_ADD_EXE (test_lite) HL_ADD_EXE (test_image) @@ -52,22 +49,31 @@ HL_ADD_EXE (test_h5do_compat) # test_packet has two source files add_executable (hl_test_packet test_packet.c test_packet_vlen.c) -target_include_directories(hl_test_packet PRIVATE "${HDF5_TEST_SRC_DIR};${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") -TARGET_C_PROPERTIES (hl_test_packet STATIC) -target_link_libraries (hl_test_packet PRIVATE - ${HDF5_HL_LIB_TARGET} - ${HDF5_TEST_LIB_TARGET} - ${HDF5_LIB_TARGET} -) +target_include_directories (hl_test_packet PRIVATE "${HDF5_TEST_SRC_DIR};${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") +if (NOT BUILD_SHARED_LIBS) + TARGET_C_PROPERTIES (hl_test_packet STATIC) + target_link_libraries (hl_test_packet PRIVATE + ${HDF5_HL_LIB_TARGET} + ${HDF5_TEST_LIB_TARGET} + ${HDF5_LIB_TARGET} + ) +else () + TARGET_C_PROPERTIES (hl_test_packet SHARED) + target_link_libraries (hl_test_packet PRIVATE + ${HDF5_HL_LIBSH_TARGET} + ${HDF5_TEST_LIBSH_TARGET} + ${HDF5_LIBSH_TARGET} + ) +endif () set_target_properties (hl_test_packet PROPERTIES FOLDER test/hl) # -------------------------------------------------------------------- # This executable is used to generate test files for the test_ds test. # It should only be run during development when new test files are needed # -------------------------------------------------------------------- -if (HDF5_BUILD_GENERATORS) +if (HDF5_BUILD_GENERATORS AND NOT ONLY_SHARED_LIBS) add_executable (hl_gen_test_ds gen_test_ds.c) - target_include_directories(hl_gen_test_ds PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + target_include_directories (hl_gen_test_ds PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") TARGET_C_PROPERTIES (hl_gen_test_ds STATIC) target_link_libraries (hl_gen_test_ds PRIVATE ${HDF5_HL_LIB_TARGET} @@ -77,7 +83,7 @@ if (HDF5_BUILD_GENERATORS) set_target_properties (hl_gen_test_ds PROPERTIES FOLDER test/hl/gen) add_executable (hl_gen_test_ld gen_test_ld.c) - target_include_directories(hl_gen_test_ld PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + target_include_directories (hl_gen_test_ld PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") TARGET_C_PROPERTIES (hl_gen_test_ld STATIC) target_link_libraries (hl_gen_test_ld PRIVATE ${HDF5_HL_LIB_TARGET} diff --git a/hl/test/CMakeTests.cmake b/hl/test/CMakeTests.cmake index 4e945bc..716a3d7 100644 --- a/hl/test/CMakeTests.cmake +++ b/hl/test/CMakeTests.cmake @@ -43,14 +43,53 @@ foreach (h5_file ${HL_REFERENCE_TEST_FILES}) endforeach () add_custom_target(hl_test_files ALL COMMENT "Copying files needed by hl_test tests" DEPENDS ${hl_test_files_list}) +# Remove any output file left over from previous test run +set (test_hl_CLEANFILES + combine_tables1.h5 + combine_tables2.h5 + file_img1.h5 + file_img2.h5 + test_append.h5 + h5do_compat.h5 + test_detach.h5 + test_ds1.h5 + test_ds2.h5 + test_ds3.h5 + test_ds4.h5 + test_ds5.h5 + test_ds6.h5 + test_ds7.h5 + test_ds8.h5 + test_ds9.h5 + test_ds10.h5 + test_image1.h5 + test_image2.h5 + test_image3.h5 + test_lite1.h5 + test_lite2.h5 + test_lite3.h5 + test_lite4.h5 + test_packet_compress.h5 + test_packet_table.h5 + test_packet_table_vlen.h5 + testfl_packet_table_vlen.h5 + test_table.h5 +) +add_test ( + NAME HL_test-clear-objects + COMMAND ${CMAKE_COMMAND} -E remove ${test_hl_CLEANFILES} +) +set_tests_properties (HL_test-clear-objects PROPERTIES FIXTURES_SETUP clear_test_hl) + # -------------------------------------------------------------------- # Macro used to add a unit test # -------------------------------------------------------------------- macro (HL_ADD_TEST hl_name) if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME HL_${hl_name} COMMAND $<TARGET_FILE:hl_${hl_name}>) + add_test (NAME HL_${hl_name} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:hl_${hl_name}>) else () add_test (NAME HL_${hl_name} COMMAND "${CMAKE_COMMAND}" + -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" -D "TEST_PROGRAM=$<TARGET_FILE:hl_${hl_name}>" -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" @@ -61,54 +100,13 @@ macro (HL_ADD_TEST hl_name) -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) endif () - if (NOT "${last_test}" STREQUAL "") - set_tests_properties (HL_${hl_name} PROPERTIES DEPENDS ${last_test} + set_tests_properties (HL_${hl_name} PROPERTIES + FIXTURES_REQUIRED clear_test_hl ENVIRONMENT "srcdir=${HDF5_HL_TEST_BINARY_DIR}" WORKING_DIRECTORY ${HDF5_HL_TEST_BINARY_DIR} - ) - endif () + ) endmacro () -# Remove any output file left over from previous test run -add_test ( - NAME HL_test-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - combine_tables1.h5 - combine_tables2.h5 - file_img1.h5 - file_img2.h5 - test_append.h5 - h5do_compat.h5 - test_detach.h5 - test_ds1.h5 - test_ds2.h5 - test_ds3.h5 - test_ds4.h5 - test_ds5.h5 - test_ds6.h5 - test_ds7.h5 - test_ds8.h5 - test_ds9.h5 - test_ds10.h5 - test_image1.h5 - test_image2.h5 - test_image3.h5 - test_lite1.h5 - test_lite2.h5 - test_lite3.h5 - test_lite4.h5 - test_packet_compress.h5 - test_packet_table.h5 - test_packet_table_vlen.h5 - testfl_packet_table_vlen.h5 - test_table.h5 -) -if (NOT "${last_test}" STREQUAL "") - set_tests_properties (HL_test-clear-objects PROPERTIES DEPENDS ${last_test}) -endif () -set (last_test "HL_test-clear-objects") - HL_add_test (test_lite ) HL_add_test (test_image) HL_add_test (test_file_image) diff --git a/hl/test/gen_test_ds.c b/hl/test/gen_test_ds.c index f8f1d39..285ab77 100644 --- a/hl/test/gen_test_ds.c +++ b/hl/test/gen_test_ds.c @@ -79,12 +79,12 @@ int main(int argc , char **argv) if (argc < 2) { - printf("Usage: gen_test [le | be]\n"); + HDprintf("Usage: gen_test [le | be]\n"); return 1; } if ( argv[1] && (strcmp("le",argv[1])!=0) && (strcmp("be",argv[1])!=0) ) { - printf("Usage: gen_test [le | be]\n"); + HDprintf("Usage: gen_test [le | be]\n"); return 1; } @@ -103,11 +103,11 @@ int main(int argc , char **argv) nerrors += test_long_scalenames(filename) < 0 ? 1 : 0; if(nerrors) goto error; - printf("Dimension scales file generation passed.\n"); + HDprintf("Dimension scales file generation passed.\n"); return 0; error: - printf("***** %d DIMENSION SCALES FILE GENERATION FAILED! *****\n",nerrors); + HDprintf("***** %d DIMENSION SCALES FILE GENERATION FAILED! *****\n",nerrors); return 1; } @@ -188,11 +188,11 @@ herr_t test_attach_scale(hid_t fid, hid_t did, const char *name, unsigned int id if(H5DSis_attached(did, dsid, idx) == 0) { if(H5DSattach_scale(did, dsid, idx) >= 0) { if(H5DSis_attached(did, dsid, idx) > 0) { - /* printf(" scale attached "); */ + /* HDprintf(" scale attached "); */ ret_value = SUCCEED; } else if(H5DSis_attached(did, dsid, idx) == 0) { - printf(" scale not attached "); + HDprintf(" scale not attached "); } } } @@ -281,7 +281,7 @@ static int test_long_attachscales(const char *filename) strcpy(dsname, DATASET_NAME); strcat(dsname, "al"); - TESTING2("test_long_attachscales"); + HL_TESTING2("test_long_attachscales"); if((fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) goto out; @@ -342,7 +342,7 @@ static int test_duplicatelong_attachscales(const char *filename) strcpy(dsname, DATASET_NAME); strcat(dsname, "al2"); - TESTING2("test_duplicatelong_attachscales"); + HL_TESTING2("test_duplicatelong_attachscales"); if((fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) goto out; @@ -406,7 +406,7 @@ static int test_long_scalenames(const char *filename) { if((fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) goto out; - TESTING2("set long scale/cmp scale name"); + HL_TESTING2("set long scale/cmp scale name"); if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { strcpy(scalename, DS_1_NAME); strcat(scalename, "al"); @@ -483,7 +483,7 @@ static int test_samelong_scalenames(const char *filename) { if((fid = open_test_file(filename)) < 0) goto out; - TESTING2("set same long scale/cmp scale name"); + HL_TESTING2("set same long scale/cmp scale name"); if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { strcpy(scalename, DS_1_NAME); strcat(scalename, "al"); @@ -554,7 +554,7 @@ static int test_foreign_scaleattached(const char *filename) hid_t did = -1; hid_t dsid = -1; - TESTING2("test_foreign_scaleattached"); + HL_TESTING2("test_foreign_scaleattached"); if((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) goto out; diff --git a/hl/test/h5hltest.h b/hl/test/h5hltest.h index f368b8e..85f47bd 100644 --- a/hl/test/h5hltest.h +++ b/hl/test/h5hltest.h @@ -28,8 +28,8 @@ #include "H5HLprivate2.h" /* Macros used in HL tests */ -#define TESTING2(WHAT) {printf("%-70s", "Testing " WHAT); fflush(stdout);} -#define TESTING3(WHAT) {printf("%-70s", "" WHAT); fflush(stdout);} +#define HL_TESTING2(WHAT) {HDprintf("Testing %-62s", WHAT); HDfflush(stdout);} +#define HL_TESTING3(WHAT) {HDprintf("Testing %-62s", WHAT); HDfflush(stdout);} /* Implements verbose 'assert' with 'goto error' exit */ #define VERIFY(condition, string) do { if (!(condition)) FAIL_PUTS_ERROR(string) } while(0) diff --git a/hl/test/test_ds.c b/hl/test/test_ds.c index 95178fc..79e6f45 100644 --- a/hl/test/test_ds.c +++ b/hl/test/test_ds.c @@ -1049,7 +1049,7 @@ herr_t test_attach_scale(hid_t fid, hid_t did, const char *name, unsigned int id ret_value = SUCCEED; } else if(H5DSis_attached(did, dsid, idx) == 0) { - printf(" scale not attached "); + HDprintf(" scale not attached "); } } } @@ -1138,7 +1138,7 @@ static int test_detachscales(void) int rank3 = 3; hsize_t dims[] = {1,2,3}; /*some bogus numbers, not important for the test*/ int *buf = NULL; - char dname[10]; + char dname[16]; int i; /* This tests creates two three dimensional datasets; then it creates @@ -1146,21 +1146,21 @@ static int test_detachscales(void) and detach them to check that at the end there is no attributes REFERENCE_LIST on a dimension scale and DIMENSION_LIST on a dataset */ - TESTING2("test_detachscales"); + HL_TESTING2("test_detachscales"); if((fid = H5Fcreate("test_detach.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* make datasets; they are three dimensional*/ for (i=0; i < 2; i++) { - sprintf(dname,"D%d", i); + HDsprintf(dname,"D%d", i); if(H5LTmake_dataset_int(fid, dname, rank3, dims, buf) < 0) goto out; } /* create datasets and make them dim. scales */ for (i=0; i < 4; i++) { - sprintf(dname, "DS%d", i); + HDsprintf(dname, "DS%d", i); if(H5LTmake_dataset_int(fid, dname, rank1, dims, buf) < 0) goto out; } @@ -1280,7 +1280,7 @@ static int test_char_attachscales(const char *fileext) HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "ac"); - TESTING2("test_char_attachscales"); + HL_TESTING2("test_char_attachscales"); if((fid = open_test_file(fileext)) < 0) goto out; @@ -1333,7 +1333,7 @@ static int test_short_attachscales(const char *fileext) HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "as"); - TESTING2("test_short_attachscales"); + HL_TESTING2("test_short_attachscales"); if((fid = open_test_file(fileext)) < 0) goto out; @@ -1410,7 +1410,7 @@ static int test_int_attachscales(const char *fileext) HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "a"); - TESTING2("test_int_attachscales"); + HL_TESTING2("test_int_attachscales"); if((fid = open_test_file(fileext)) < 0) goto out; @@ -1471,7 +1471,7 @@ static int test_long_attachscales(const char *fileext) HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "al"); - TESTING2("test_long_attachscales"); + HL_TESTING2("test_long_attachscales"); if((fid = open_test_file(fileext)) < 0) goto out; @@ -1528,7 +1528,7 @@ static int test_duplicatelong_attachscales(const char *fileext) HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "al2"); - TESTING2("test_duplicatelong_attachscales"); + HL_TESTING2("test_duplicatelong_attachscales"); if((fid = open_test_file(fileext)) < 0) goto out; @@ -1585,7 +1585,7 @@ static int test_float_attachscales(const char *fileext) HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "af"); - TESTING2("test_float_attachscales"); + HL_TESTING2("test_float_attachscales"); if((fid = open_test_file(fileext)) < 0) goto out; @@ -1647,7 +1647,7 @@ static int test_numberofscales(const char *fileext) HDsnprintf(dsname, sizeof(dsname), "%s%s", DATASET_NAME, "a"); - TESTING2("test_numberofscales"); + HL_TESTING2("test_numberofscales"); if((fid = open_test_file(fileext)) < 0) goto out; @@ -1729,7 +1729,7 @@ static int test_char_scalenames(const char *fileext) { if((fid = open_test_file(fileext)) < 0) goto out; - TESTING2("set char scale/cmp scale name"); + HL_TESTING2("set char scale/cmp scale name"); if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "ac"); HDsnprintf(name, sizeof(name), "%s%s", SCALE_1_NAME, "ac"); @@ -1789,7 +1789,7 @@ static int test_short_scalenames(const char *fileext) { if((fid = open_test_file(fileext)) < 0) goto out; - TESTING2("set short scale/cmp scale name"); + HL_TESTING2("set short scale/cmp scale name"); if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "as"); HDsnprintf(name, sizeof(name), "%s%s", SCALE_1_NAME, "as"); @@ -1897,7 +1897,7 @@ static int test_int_scalenames(const char *fileext) { if((fid = open_test_file(fileext)) < 0) goto out; - TESTING2("set int scale/cmp scale name"); + HL_TESTING2("set int scale/cmp scale name"); if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "a"); HDsnprintf(name, sizeof(name), "%s%s", SCALE_1_NAME, "a"); @@ -1973,7 +1973,7 @@ static int test_long_scalenames(const char *fileext) { if((fid = open_test_file(fileext)) < 0) goto out; - TESTING2("set long scale/cmp scale name"); + HL_TESTING2("set long scale/cmp scale name"); if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "al"); HDsnprintf(name, sizeof(name), "%s%s", SCALE_1_NAME, "al"); @@ -2041,7 +2041,7 @@ static int test_samelong_scalenames(const char *fileext) { if((fid = open_test_file(fileext)) < 0) goto out; - TESTING2("set same long scale/cmp scale name"); + HL_TESTING2("set same long scale/cmp scale name"); if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "al"); HDsnprintf(name, sizeof(name), "%s%s", DS_1_NAME, "al"); @@ -2109,7 +2109,7 @@ static int test_float_scalenames(const char *fileext) { if((fid = open_test_file(fileext)) < 0) goto out; - TESTING2("set float scale/cmp scale name"); + HL_TESTING2("set float scale/cmp scale name"); if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) { HDsnprintf(scalename, sizeof(scalename), "%s%s", DS_1_NAME, "af"); HDsnprintf(name, sizeof(name), "%s%s", SCALE_1_NAME, "af"); @@ -2181,7 +2181,7 @@ static int test_foreign_scaleattached(const char *fileforeign) hid_t dsid = -1; const char *filename = H5_get_srcdir_filename(fileforeign); - TESTING2("test_foreign_scaleattached"); + HL_TESTING2("test_foreign_scaleattached"); if((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) goto out; @@ -2255,7 +2255,7 @@ static int test_simple(void) char snames[3]; int i, j; - printf("Testing API functions\n"); + HDprintf("Testing API functions\n"); /*------------------------------------------------------------------------- * create a file for the test @@ -2426,7 +2426,7 @@ static int test_simple(void) *------------------------------------------------------------------------- */ - TESTING2("detach scales "); + HL_TESTING2("detach scales "); /*------------------------------------------------------------------------- @@ -2919,7 +2919,7 @@ static int test_simple(void) if((did = H5Dopen2(gid, dname, H5P_DEFAULT)) < 0) goto out; for(j = 0; j < 5; j++) { - sprintf(sname, "ds_%d", j); + HDsprintf(sname, "ds_%d", j); if((dsid = H5Dopen2(gid, sname, H5P_DEFAULT)) < 0) goto out; if(H5DSdetach_scale(did, dsid, DIM0) < 0) @@ -2942,7 +2942,7 @@ static int test_simple(void) if((did = H5Dopen2(gid,dname, H5P_DEFAULT)) < 0) goto out; for(j=0; j<5; j++) { - sprintf(sname,"ds_%d",j); + HDsprintf(sname,"ds_%d",j); if((dsid = H5Dopen2(gid,sname, H5P_DEFAULT)) < 0) goto out; if(H5DSattach_scale(did,dsid,DIM0) < 0) @@ -3013,7 +3013,7 @@ static int test_simple(void) *------------------------------------------------------------------------- */ - TESTING2("set/get label"); + HL_TESTING2("set/get label"); if((did = H5Dopen2(fid,"dset_a", H5P_DEFAULT)) < 0) goto out; @@ -3103,7 +3103,7 @@ static int test_simple(void) */ - TESTING2("set scale/get scale name"); + HL_TESTING2("set scale/get scale name"); if((dsid = H5Dopen2(fid,"ds_a_1", H5P_DEFAULT)) < 0) goto out; if(H5DSset_scale(dsid,"Latitude set 0") < 0) @@ -3205,7 +3205,7 @@ static int test_simple(void) */ - TESTING2("iterate scales"); + HL_TESTING2("iterate scales"); /*------------------------------------------------------------------------- @@ -3740,7 +3740,7 @@ static int test_errors(void) hid_t sidds = -1; /* space ID */ hsize_t pal_dims[] = {9,3}; - printf("Testing error conditions\n"); + HDprintf("Testing error conditions\n"); /*------------------------------------------------------------------------- * create a file, spaces, dataset and group ids @@ -3771,7 +3771,7 @@ static int test_errors(void) *------------------------------------------------------------------------- */ - TESTING2("attach a dataset to itself"); + HL_TESTING2("attach a dataset to itself"); if(H5DSattach_scale(did, did, 0) == SUCCEED) goto out; @@ -3782,7 +3782,7 @@ static int test_errors(void) * attempt to attach a group with a dataset, it should fail *------------------------------------------------------------------------- */ - TESTING2("attach a group with a dataset"); + HL_TESTING2("attach a group with a dataset"); if(H5DSattach_scale(gid,dsid,0)==SUCCEED) goto out; @@ -3793,7 +3793,7 @@ static int test_errors(void) * attempt to attach a dataset with a group, it should fail *------------------------------------------------------------------------- */ - TESTING2("attach a dataset with a group"); + HL_TESTING2("attach a dataset with a group"); if(H5DSattach_scale(did,gid,0)==SUCCEED) goto out; @@ -3804,7 +3804,7 @@ static int test_errors(void) * attempt to set scale for a group, it should fail *------------------------------------------------------------------------- */ - TESTING2("set scale for a group"); + HL_TESTING2("set scale for a group"); if(H5DSset_scale(gid,"scale 1")==SUCCEED) goto out; @@ -3834,7 +3834,7 @@ static int test_errors(void) *------------------------------------------------------------------------- */ - TESTING2("attach a scale that has scales"); + HL_TESTING2("attach a scale that has scales"); /* create the data space for the scale */ if((sidds = H5Screate_simple(rankds, s1_dim, NULL)) < 0) @@ -3903,7 +3903,7 @@ static int test_errors(void) *------------------------------------------------------------------------- */ - TESTING2("attach to a dataset that is a scale"); + HL_TESTING2("attach to a dataset that is a scale"); /* open the previous written "ds_b", that is a scale */ if((dsid = H5Dopen2(fid,"ds_b", H5P_DEFAULT)) < 0) @@ -3930,7 +3930,7 @@ static int test_errors(void) *------------------------------------------------------------------------- */ - TESTING2("attach to a dataset that is a reserved class dataset"); + HL_TESTING2("attach to a dataset that is a reserved class dataset"); /* make an image */ if(H5IMmake_image_8bit(fid,"image",(hsize_t)100,(hsize_t)50,NULL) < 0) @@ -3965,7 +3965,7 @@ static int test_errors(void) *------------------------------------------------------------------------- */ - TESTING2("is scale"); + HL_TESTING2("is scale"); /* open a non scale dataset */ if((did = H5Dopen2(fid,"dset_a", H5P_DEFAULT)) < 0) @@ -3999,7 +3999,7 @@ static int test_errors(void) *------------------------------------------------------------------------- */ - TESTING2("detach scale from dataset it is not attached to"); + HL_TESTING2("detach scale from dataset it is not attached to"); /* open the previous written "ds_a" */ if((dsid = H5Dopen2(fid,"ds_a", H5P_DEFAULT)) < 0) @@ -4027,7 +4027,7 @@ static int test_errors(void) *------------------------------------------------------------------------- */ - TESTING2("detach scale from group"); + HL_TESTING2("detach scale from group"); /* open the previous written "ds_a" */ if((dsid = H5Dopen2(fid,"ds_a", H5P_DEFAULT)) < 0) @@ -4055,7 +4055,7 @@ static int test_errors(void) *------------------------------------------------------------------------- */ - TESTING2("detach scale when scale is group"); + HL_TESTING2("detach scale when scale is group"); /* open the previous written "dset_a" */ if((did = H5Dopen2(fid,"dset_a", H5P_DEFAULT)) < 0) @@ -4119,7 +4119,7 @@ static int test_iterators(void) char dname[30]; /* dataset name */ int i; - printf("Testing iterators\n"); + HDprintf("Testing iterators\n"); /*------------------------------------------------------------------------- * create a file, spaces, dataset and group ids @@ -4147,7 +4147,7 @@ static int test_iterators(void) *------------------------------------------------------------------------- */ - TESTING2("iterate when the dataset has no scales "); + HL_TESTING2("iterate when the dataset has no scales "); /* get the dataset id for "dset_a" */ if((did = H5Dopen2(fid,"dset_a", H5P_DEFAULT)) < 0) @@ -4169,7 +4169,7 @@ static int test_iterators(void) *------------------------------------------------------------------------- */ - TESTING2("iterate on dimension that is outside the rank "); + HL_TESTING2("iterate on dimension that is outside the rank "); /* get the dataset id for "dset_a" */ if((did = H5Dopen2(fid,"dset_a", H5P_DEFAULT)) < 0) @@ -4190,7 +4190,7 @@ static int test_iterators(void) *------------------------------------------------------------------------- */ - TESTING2("iterate for dimension with many scales "); + HL_TESTING2("iterate for dimension with many scales "); /* open the previously written "dset_a" */ if((did = H5Dopen2(fid,"dset_a", H5P_DEFAULT)) < 0) @@ -4198,7 +4198,7 @@ static int test_iterators(void) for(i=0; i<100; i++) { /* make a DS */ - sprintf(dname,"ds_%d",i); + HDsprintf(dname,"ds_%d",i); if(H5LTmake_dataset_int(fid,dname,rankds,s1_dim,NULL) < 0) goto out; /* open */ @@ -4227,7 +4227,7 @@ static int test_iterators(void) *------------------------------------------------------------------------- */ - TESTING2("iterate on group "); + HL_TESTING2("iterate on group "); /* open */ if((gid = H5Gopen2(fid, "grp", H5P_DEFAULT)) < 0) @@ -4249,7 +4249,7 @@ static int test_iterators(void) *------------------------------------------------------------------------- */ - TESTING2("iterate in deleted scales "); + HL_TESTING2("iterate in deleted scales "); if(H5Ldelete(fid, "ds_0", H5P_DEFAULT) < 0) goto out; @@ -4311,7 +4311,7 @@ static int test_rank(void) float buff[1]={1}; int i; - printf("Testing ranks\n"); + HDprintf("Testing ranks\n"); /*------------------------------------------------------------------------- * create a file, a dataset, scales @@ -4343,13 +4343,13 @@ static int test_rank(void) *------------------------------------------------------------------------- */ - TESTING2("attach"); + HL_TESTING2("attach"); if((did = H5Dopen2(fid,"dset_a", H5P_DEFAULT)) < 0) goto out; for(i=0; i<3; i++) { - sprintf(name,"ds_a_%d",i); + HDsprintf(name,"ds_a_%d",i); if((dsid = H5Dopen2(fid,name, H5P_DEFAULT)) < 0) goto out; if(H5DSattach_scale(did,dsid,(unsigned)i) < 0) @@ -4371,13 +4371,13 @@ static int test_rank(void) *------------------------------------------------------------------------- */ - TESTING2("detach"); + HL_TESTING2("detach"); if((did = H5Dopen2(fid,"dset_a", H5P_DEFAULT)) < 0) goto out; for(i=0; i<3; i++) { - sprintf(name,"ds_a_%d",i); + HDsprintf(name,"ds_a_%d",i); if((dsid = H5Dopen2(fid,name, H5P_DEFAULT)) < 0) goto out; if(H5DSdetach_scale(did,dsid,(unsigned)i) < 0) @@ -4397,13 +4397,13 @@ static int test_rank(void) *------------------------------------------------------------------------- */ - TESTING2("attach, set, get names, labels"); + HL_TESTING2("attach, set, get names, labels"); if((did = H5Dopen2(fid,"dset_a", H5P_DEFAULT)) < 0) goto out; for(i=0; i<3; i++) { - sprintf(name,"ds_a_%d",i); + HDsprintf(name,"ds_a_%d",i); if((dsid = H5Dopen2(fid,name, H5P_DEFAULT)) < 0) goto out; if(H5DSset_scale(dsid,name) < 0) @@ -4436,7 +4436,7 @@ static int test_rank(void) *------------------------------------------------------------------------- */ - TESTING2("attach a scalar scale"); + HL_TESTING2("attach a scalar scale"); /* create the data space for the dataset */ if((sid = H5Screate_simple(2, dimss, NULL)) < 0) @@ -4517,7 +4517,7 @@ static int test_types(void) const char *s1_str = "ABC"; const char *s2_str = "ABCD"; - printf("Testing scales with several datatypes\n"); + HDprintf("Testing scales with several datatypes\n"); /*------------------------------------------------------------------------- * create a file for the test @@ -4549,7 +4549,7 @@ static int test_types(void) *------------------------------------------------------------------------- */ - TESTING2("floating point and short scales"); + HL_TESTING2("floating point and short scales"); /* get the dataset id for "dset_a" */ if((did = H5Dopen2(fid,"dset_a", H5P_DEFAULT)) < 0) @@ -4612,7 +4612,7 @@ static int test_types(void) *------------------------------------------------------------------------- */ - TESTING2("string scales"); + HL_TESTING2("string scales"); /* get the dataset id for "dset_b" */ if((did = H5Dopen2(fid,"dset_b", H5P_DEFAULT)) < 0) @@ -4694,7 +4694,7 @@ static int test_data(void) float fill=-99; /* fill value */ - printf("Testing reading ASCII data and generate HDF5 data with scales\n"); + HDprintf("Testing reading ASCII data and generate HDF5 data with scales\n"); /*------------------------------------------------------------------------- * create a file for the test @@ -4709,7 +4709,7 @@ static int test_data(void) *------------------------------------------------------------------------- */ - TESTING2("generating scales"); + HL_TESTING2("generating scales"); /*------------------------------------------------------------------------- * create datasets: 1 "data" dataset and 2 dimension scales @@ -4870,18 +4870,18 @@ static int read_data( const char* fname, /* read first data file */ f = HDfopen(data_file, "r"); if( f == NULL ) { - printf( "Could not open file %s\n", data_file ); + HDprintf( "Could not open file %s\n", data_file ); return -1; } for(i=0, nelms=1; i < ndims; i++) { if(fscanf( f, "%s %u", str, &j) && HDferror(f)) { - printf( "fscanf error in file %s\n", data_file ); + HDprintf( "fscanf error in file %s\n", data_file ); HDfclose(f); return -1; } /* end if */ if(fscanf( f, "%d",&n ) < 0 && HDferror(f)) { - printf( "fscanf error in file %s\n", data_file ); + HDprintf( "fscanf error in file %s\n", data_file ); HDfclose(f); return -1; } /* end if */ @@ -4892,14 +4892,14 @@ static int read_data( const char* fname, *buf = (float*) HDmalloc (nelms * sizeof( float )); if ( *buf == NULL ) { - printf( "memory allocation failed\n" ); + HDprintf( "memory allocation failed\n" ); HDfclose(f); return -1; } for(j = 0; j < nelms; j++) { if(fscanf( f, "%f",&val ) < 0 && HDferror(f)) { - printf( "fscanf error in file %s\n", data_file ); + HDprintf( "fscanf error in file %s\n", data_file ); HDfclose(f); return -1; } /* end if */ @@ -4930,7 +4930,7 @@ static int test_errors2(void) int nscales; /* number of scales in DIM */ int count; /* visitor data */ - printf("Testing parameter errors\n"); + HDprintf("Testing parameter errors\n"); /*------------------------------------------------------------------------- * create a file, a dataset, scales @@ -4954,7 +4954,7 @@ static int test_errors2(void) goto out; - TESTING2("attach scales"); + HL_TESTING2("attach scales"); /*------------------------------------------------------------------------- @@ -4977,7 +4977,7 @@ static int test_errors2(void) PASSED(); - TESTING2("detach scales"); + HL_TESTING2("detach scales"); /*------------------------------------------------------------------------- * detach with invalid indices @@ -4998,7 +4998,7 @@ static int test_errors2(void) PASSED(); - TESTING2("set/get label"); + HL_TESTING2("set/get label"); /*------------------------------------------------------------------------- * set/get label invalid indices @@ -5023,7 +5023,7 @@ static int test_errors2(void) PASSED(); - TESTING2("iterate scales"); + HL_TESTING2("iterate scales"); /*------------------------------------------------------------------------- @@ -5122,7 +5122,7 @@ static int test_attach_detach(void) hid_t var1_id, var2_id, var3_id; /* DS component name */ hsize_t dims[RANK1] = {DIM1}; - TESTING2("permutations of attaching and detaching"); + HL_TESTING2("permutations of attaching and detaching"); if((fid = H5Fcreate(FILE8, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; diff --git a/hl/test/test_dset_append.c b/hl/test/test_dset_append.c index d890481..1914a08 100644 --- a/hl/test/test_dset_append.c +++ b/hl/test/test_dset_append.c @@ -11,38 +11,39 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +#include <math.h> #include <stdlib.h> #include <string.h> + #include "h5hltest.h" #include "H5DOpublic.h" -#include <math.h> -#if defined(H5_HAVE_ZLIB_H) && !defined(H5_ZLIB_HEADER) +#if defined(H5_HAVE_ZLIB_H) && !defined(H5_ZLIB_HEADER) # define H5_ZLIB_HEADER "zlib.h" #endif #if defined(H5_ZLIB_HEADER) -# include H5_ZLIB_HEADER /* "zlib.h" */ +#include H5_ZLIB_HEADER /* "zlib.h" */ #endif -#define FILE "test_append.h5" -#define DNAME_NOTSET "dataset_notset" -#define DNAME_UNLIM "dataset_unlim" -#define DNAME_LESS "dataset_less" -#define DNAME_VARY "dataset_vary" -#define DNAME_ROW "dataset_row" -#define DNAME_COLUMN "dataset_column" -#define DBUGNAME1 "dataset_bug1" -#define DBUGNAME2 "dataset_bug2" +#define FILENAME "test_append.h5" +#define DNAME_NOTSET "dataset_notset" +#define DNAME_UNLIM "dataset_unlim" +#define DNAME_LESS "dataset_less" +#define DNAME_VARY "dataset_vary" +#define DNAME_ROW "dataset_row" +#define DNAME_COLUMN "dataset_column" +#define DBUGNAME1 "dataset_bug1" +#define DBUGNAME2 "dataset_bug2" /*------------------------------------------------------------------------- - * Function: test_dataset_append_notset + * Function: test_dataset_append_notset * - * Purpose: Verify that H5DOappend works properly with default dapl. - * That is, H5Pset_append_flush() is not used to set boundary - * and callback in dapl. + * Purpose: Verify that H5DOappend works properly with default dapl. + * That is, H5Pset_append_flush() is not used to set boundary + * and callback in dapl. * - * Return: Success: 0 - * Failure: 1 + * Return: Success: 0 + * Failure: 1 * * Programmer: Vailin Choi; Aug 2016 * @@ -51,68 +52,68 @@ static int test_dataset_append_notset(hid_t fid) { - hid_t did = -1; /* Dataset ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t dcpl = -1; /* A copy of dataset creation property */ - hid_t ffapl = -1; /* The file's file access property list */ + hid_t did = -1; /* Dataset ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t dcpl = -1; /* A copy of dataset creation property */ + hid_t ffapl = -1; /* The file's file access property list */ - hsize_t dims[2] = {0, 10}; /* Current dimension sizes */ - hsize_t maxdims[2] = {H5S_UNLIMITED, 20}; /* Maximum dimension sizes */ - hsize_t chunk_dims[2] = {2,5}; /* Chunk dimension sizes */ - int lbuf[10]; /* The data buffers */ - int i, j; /* Local index variables */ - h5_stat_t sb1, sb2; /* File info */ + hsize_t dims[2] = {0, 10}; /* Current dimension sizes */ + hsize_t maxdims[2] = {H5S_UNLIMITED, 20}; /* Maximum dimension sizes */ + hsize_t chunk_dims[2] = {2,5}; /* Chunk dimension sizes */ + int lbuf[10]; /* The data buffers */ + int i, j; /* Local index variables */ + h5_stat_t sb1, sb2; /* File info */ - TESTING("Append flush with H5DOappend()--append rows with default dapl"); + HL_TESTING2("Append flush with H5DOappend()--append rows with default dapl"); /* Get the file's file access property list */ if((ffapl = H5Fget_access_plist(fid)) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Set to create a chunked dataset with extendible dimensions */ - if((sid = H5Screate_simple(2, dims, maxdims)) < 0) - FAIL_STACK_ERROR; - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - FAIL_STACK_ERROR; + if((sid = H5Screate_simple(2, dims, maxdims)) < 0) + FAIL_STACK_ERROR; + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR; if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Create the dataset */ - if((did = H5Dcreate2(fid, DNAME_NOTSET, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR; + if((did = H5Dcreate2(fid, DNAME_NOTSET, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; /* Append 6 rows to the dataset */ for(i = 0; i < 6; i++) { - for(j = 0; j < 10; j++) - lbuf[j] = (i * 10) + (j + 1); - /* Append without boundary, callback and flush */ - if(H5DOappend(did, H5P_DEFAULT, 0, (size_t)1, H5T_NATIVE_INT, lbuf) < 0) - FAIL_STACK_ERROR; + for(j = 0; j < 10; j++) + lbuf[j] = (i * 10) + (j + 1); + /* Append without boundary, callback and flush */ + if(H5DOappend(did, H5P_DEFAULT, 0, (size_t)1, H5T_NATIVE_INT, lbuf) < 0) + FAIL_STACK_ERROR; } /* end for */ /* File size when not flushed */ - if(HDstat(FILE, &sb1) < 0) - TEST_ERROR; + if(HDstat(FILENAME, &sb1) < 0) + TEST_ERROR; /* Close the dataset */ if(H5Dclose(did) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* File size after flushing */ - if(HDstat(FILE, &sb2) < 0) - TEST_ERROR; + if(HDstat(FILENAME, &sb2) < 0) + TEST_ERROR; /* File size before flushing should be less */ - if(sb1.st_size > sb2.st_size) - TEST_ERROR; + if(sb1.st_size > sb2.st_size) + TEST_ERROR; /* Closing */ if(H5Sclose(sid) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(H5Pclose(dcpl) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(H5Pclose(ffapl) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; PASSED(); @@ -120,10 +121,10 @@ test_dataset_append_notset(hid_t fid) error: H5E_BEGIN_TRY { - H5Pclose(dcpl); - H5Pclose(sid); - H5Dclose(did); - H5Pclose(ffapl); + H5Pclose(dcpl); + H5Pclose(sid); + H5Dclose(did); + H5Pclose(ffapl); } H5E_END_TRY; return 1; @@ -148,14 +149,14 @@ append_func(hid_t H5_ATTR_UNUSED dset_id, hsize_t H5_ATTR_UNUSED *cur_dims, void } /*------------------------------------------------------------------------- - * Function: test_dataset_append_rows_columns + * Function: test_dataset_append_rows_columns * - * Purpose: Verify that the object flush property and the append flush property - * are working properly when appending rows and columns to a dataset - * with 2 extendible dimensions. + * Purpose: Verify that the object flush property and the append flush property + * are working properly when appending rows and columns to a dataset + * with 2 extendible dimensions. * - * Return: Success: 0 - * Failure: 1 + * Return: Success: 0 + * Failure: 1 * * Programmer: Vailin Choi; Jan 2014 * @@ -164,91 +165,91 @@ append_func(hid_t H5_ATTR_UNUSED dset_id, hsize_t H5_ATTR_UNUSED *cur_dims, void static int test_dataset_append_rows_columns(hid_t fid) { - hid_t did = -1; /* Dataset ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t dcpl = -1; /* A copy of dataset creation property */ - hid_t dapl = -1; /* A copy of dataset access property */ - hid_t ffapl = -1; /* The file's file access property list */ + hid_t did = -1; /* Dataset ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t dcpl = -1; /* A copy of dataset creation property */ + hid_t dapl = -1; /* A copy of dataset access property */ + hid_t ffapl = -1; /* The file's file access property list */ - hsize_t dims[2] = {0, 10}; /* Current dimension sizes */ - hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Maximum dimension sizes */ - hsize_t chunk_dims[2] = {2,5}; /* Chunk dimension sizes */ - int lbuf[10], cbuf[6]; /* The data buffers */ - int buf[6][13], rbuf[6][13]; /* The data buffers */ + hsize_t dims[2] = {0, 10}; /* Current dimension sizes */ + hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Maximum dimension sizes */ + hsize_t chunk_dims[2] = {2,5}; /* Chunk dimension sizes */ + int lbuf[10], cbuf[6]; /* The data buffers */ + int buf[6][13], rbuf[6][13]; /* The data buffers */ - hsize_t boundary[2] = {1, 1}; /* Boundary sizes */ - unsigned append_ct = 0; /* The # of appends */ - unsigned *flush_ptr; /* Points to the flush counter */ + hsize_t boundary[2] = {1, 1}; /* Boundary sizes */ + unsigned append_ct = 0; /* The # of appends */ + unsigned *flush_ptr; /* Points to the flush counter */ - int i, j; /* Local index variables */ + int i, j; /* Local index variables */ - TESTING("Append flush with H5DOappend()--append rows & columns"); + HL_TESTING2("Append flush with H5DOappend()--append rows & columns"); /* Get the file's file access property list */ if((ffapl = H5Fget_access_plist(fid)) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Set to create a chunked dataset with 2 extendible dimensions */ - if((sid = H5Screate_simple(2, dims, maxdims)) < 0) - FAIL_STACK_ERROR; - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - FAIL_STACK_ERROR; + if((sid = H5Screate_simple(2, dims, maxdims)) < 0) + FAIL_STACK_ERROR; + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR; if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Set append flush property */ - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) - FAIL_STACK_ERROR; + if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + FAIL_STACK_ERROR; if(H5Pset_append_flush(dapl, 2, boundary, append_func, &append_ct) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Create the dataset */ - if((did = H5Dcreate2(fid, DNAME_UNLIM, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0) - TEST_ERROR; + if((did = H5Dcreate2(fid, DNAME_UNLIM, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0) + TEST_ERROR; /* Append 6 rows to the dataset */ for(i = 0; i < 6; i++) { - for(j = 0; j < 10; j++) - lbuf[j] = buf[i][j] = (i * 10) + (j + 1); - if(H5DOappend(did, H5P_DEFAULT, 0, (size_t)1, H5T_NATIVE_INT, lbuf) < 0) - TEST_ERROR; + for(j = 0; j < 10; j++) + lbuf[j] = buf[i][j] = (i * 10) + (j + 1); + if(H5DOappend(did, H5P_DEFAULT, 0, (size_t)1, H5T_NATIVE_INT, lbuf) < 0) + TEST_ERROR; } /* end for */ /* Verify the # of appends */ if(append_ct != 6) - TEST_ERROR; + TEST_ERROR; /* Retrieve and verify object flush counts */ if(H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(*flush_ptr != 6) - TEST_ERROR; + TEST_ERROR; /* Append 3 columns to the dataset */ for(i = 0; i < 3; i++) { - for(j = 0; j < 6; j++) - cbuf[j] = buf[j][i + 10] = ((i * 6) + (j + 1)) * -1; - if(H5DOappend(did, H5P_DEFAULT, 1, (size_t)1, H5T_NATIVE_INT, cbuf) < 0) - TEST_ERROR; + for(j = 0; j < 6; j++) + cbuf[j] = buf[j][i + 10] = ((i * 6) + (j + 1)) * -1; + if(H5DOappend(did, H5P_DEFAULT, 1, (size_t)1, H5T_NATIVE_INT, cbuf) < 0) + TEST_ERROR; } /* end for */ /* Verify the # of appends */ if(append_ct != 9) - TEST_ERROR; + TEST_ERROR; /* Retrieve and verify object flush counts */ if(H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(*flush_ptr != 9) - TEST_ERROR; + TEST_ERROR; /* Read the dataset */ if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) - FAIL_STACK_ERROR; - + FAIL_STACK_ERROR; + /* Verify the data */ for(i = 0; i < 6; i++) - for(j = 0; j < 13; j++) + for(j = 0; j < 13; j++) if(buf[i][j] != rbuf[i][j]) TEST_ERROR; @@ -257,33 +258,33 @@ test_dataset_append_rows_columns(hid_t fid) /* Close the dataset */ if(H5Dclose(did) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Open the dataset again */ if((did = H5Dopen2(fid, DNAME_UNLIM, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Read the dataset */ if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Verify the data */ for(i = 0; i < 6; i++) - for(j = 0; j < 13; j++) + for(j = 0; j < 13; j++) if(buf[i][j] != rbuf[i][j]) TEST_ERROR; /* Closing */ if(H5Dclose(did) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(H5Sclose(sid) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(H5Pclose(dapl) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(H5Pclose(dcpl) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(H5Pclose(ffapl) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; PASSED(); @@ -291,25 +292,25 @@ test_dataset_append_rows_columns(hid_t fid) error: H5E_BEGIN_TRY { - H5Pclose(dapl); - H5Pclose(dcpl); - H5Pclose(sid); - H5Dclose(did); - H5Pclose(ffapl); + H5Pclose(dapl); + H5Pclose(dcpl); + H5Pclose(sid); + H5Dclose(did); + H5Pclose(ffapl); } H5E_END_TRY; return 1; } /* test_dataset_append_rows_columns() */ /*------------------------------------------------------------------------- - * Function: test_dataset_append_rows + * Function: test_dataset_append_rows * - * Purpose: Verify that the object flush property and the append flush property - * are working properly when appending rows to a dataset with - * one extendible dimension (row). + * Purpose: Verify that the object flush property and the append flush property + * are working properly when appending rows to a dataset with + * one extendible dimension (row). * - * Return: Success: 0 - * Failure: 1 + * Return: Success: 0 + * Failure: 1 * * Programmer: Vailin Choi; Jan 2014 * @@ -318,71 +319,71 @@ error: static int test_dataset_append_rows(hid_t fid) { - hid_t did = -1; /* Dataset ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t dcpl = -1; /* A copy of dataset creation property */ - hid_t dapl = -1; /* A copy of dataset access property */ - hid_t ffapl = -1; /* The file's file access property list */ + hid_t did = -1; /* Dataset ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t dcpl = -1; /* A copy of dataset creation property */ + hid_t dapl = -1; /* A copy of dataset access property */ + hid_t ffapl = -1; /* The file's file access property list */ - hsize_t dims[2] = {0, 10}; /* Current dimension sizes */ - hsize_t maxdims[2] = {H5S_UNLIMITED, 10}; /* Maximum dimension sizes */ - hsize_t chunk_dims[2] = {2,5}; /* Chunk dimension sizes */ - int lbuf[10]; /* The data buffer */ - int buf[6][10], rbuf[6][10]; /* The data buffers */ - int i, j; /* Local index variables */ + hsize_t dims[2] = {0, 10}; /* Current dimension sizes */ + hsize_t maxdims[2] = {H5S_UNLIMITED, 10}; /* Maximum dimension sizes */ + hsize_t chunk_dims[2] = {2,5}; /* Chunk dimension sizes */ + int lbuf[10]; /* The data buffer */ + int buf[6][10], rbuf[6][10]; /* The data buffers */ + int i, j; /* Local index variables */ - hsize_t boundary[2] = {1, 0}; /* Boundary sizes */ - unsigned append_ct = 0; /* The # of appends */ - unsigned *flush_ptr; /* Points to the flush counter */ + hsize_t boundary[2] = {1, 0}; /* Boundary sizes */ + unsigned append_ct = 0; /* The # of appends */ + unsigned *flush_ptr; /* Points to the flush counter */ - TESTING("Append flush with H5DOappend()--append rows"); + HL_TESTING2("Append flush with H5DOappend()--append rows"); /* Get the file's file access property list */ if((ffapl = H5Fget_access_plist(fid)) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Set to create a chunked dataset with 1 extendible dimension */ - if((sid = H5Screate_simple(2, dims, maxdims)) < 0) - FAIL_STACK_ERROR; - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - FAIL_STACK_ERROR; + if((sid = H5Screate_simple(2, dims, maxdims)) < 0) + FAIL_STACK_ERROR; + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR; if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Set append flush property */ - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) - FAIL_STACK_ERROR; + if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + FAIL_STACK_ERROR; if(H5Pset_append_flush(dapl, 2, boundary, append_func, &append_ct) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Create the dataset */ - if((did = H5Dcreate2(fid, DNAME_ROW, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0) - TEST_ERROR; + if((did = H5Dcreate2(fid, DNAME_ROW, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0) + TEST_ERROR; /* Append 6 rows to the dataset */ for(i = 0; i < 6; i++) { - for(j = 0; j < 10; j++) - lbuf[j] = buf[i][j] = (i * 10) + (j + 1); - if(H5DOappend(did, H5P_DEFAULT, 0, (size_t)1, H5T_NATIVE_INT, lbuf) < 0) - TEST_ERROR; + for(j = 0; j < 10; j++) + lbuf[j] = buf[i][j] = (i * 10) + (j + 1); + if(H5DOappend(did, H5P_DEFAULT, 0, (size_t)1, H5T_NATIVE_INT, lbuf) < 0) + TEST_ERROR; } /* end for */ /* Verify the # of appends */ if(append_ct != 6) - TEST_ERROR; + TEST_ERROR; if(H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(*flush_ptr != 6) - TEST_ERROR; + TEST_ERROR; /* Read the dataset */ if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) - FAIL_STACK_ERROR; - + FAIL_STACK_ERROR; + /* Verify the data */ for(i = 0; i < 6; i++) - for(j = 0; j < 10; j++) + for(j = 0; j < 10; j++) if(buf[i][j] != rbuf[i][j]) TEST_ERROR; @@ -391,33 +392,33 @@ test_dataset_append_rows(hid_t fid) /* Close the dataset */ if(H5Dclose(did) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Open the dataset again */ if((did = H5Dopen2(fid, DNAME_ROW, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Read the dataset */ if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Verify the data */ for(i = 0; i < 6; i++) - for(j = 0; j < 10; j++) + for(j = 0; j < 10; j++) if(buf[i][j] != rbuf[i][j]) TEST_ERROR; /* Closing */ if(H5Dclose(did) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(H5Sclose(sid) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(H5Pclose(dapl) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(H5Pclose(dcpl) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(H5Pclose(ffapl) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; PASSED(); @@ -425,25 +426,25 @@ test_dataset_append_rows(hid_t fid) error: H5E_BEGIN_TRY { - H5Pclose(dapl); - H5Pclose(dcpl); - H5Pclose(sid); - H5Dclose(did); - H5Pclose(ffapl); + H5Pclose(dapl); + H5Pclose(dcpl); + H5Pclose(sid); + H5Dclose(did); + H5Pclose(ffapl); } H5E_END_TRY; return 1; } /* test_dataset_append_rows() */ /*------------------------------------------------------------------------- - * Function: test_dataset_append_columns + * Function: test_dataset_append_columns * - * Purpose: Verify that the object flush property and the append flush property - * are working properly when appending columns to a dataset - * with one extendible dimension (column). + * Purpose: Verify that the object flush property and the append flush property + * are working properly when appending columns to a dataset + * with one extendible dimension (column). * - * Return: Success: 0 - * Failure: 1 + * Return: Success: 0 + * Failure: 1 * * Programmer: Vailin Choi; Jan 2014 * @@ -452,72 +453,72 @@ error: static int test_dataset_append_columns(hid_t fid) { - hid_t did = -1; /* Dataset ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t dcpl = -1; /* A copy of dataset creation property */ - hid_t dapl = -1; /* A copy of dataset access property */ - hid_t ffapl = -1; /* The file's file access property list */ + hid_t did = -1; /* Dataset ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t dcpl = -1; /* A copy of dataset creation property */ + hid_t dapl = -1; /* A copy of dataset access property */ + hid_t ffapl = -1; /* The file's file access property list */ - hsize_t dims[2] = {6, 0}; /* Current dimension sizes */ - hsize_t maxdims[2] = {6, H5S_UNLIMITED}; /* Maximum dimension sizes */ - hsize_t chunk_dims[2] = {2,5}; /* Chunk dimension sizes */ - int cbuf[6]; /* The data buffer */ - int buf[6][3], rbuf[6][3]; /* The data buffers */ - int i, j; /* Local index variable */ + hsize_t dims[2] = {6, 0}; /* Current dimension sizes */ + hsize_t maxdims[2] = {6, H5S_UNLIMITED}; /* Maximum dimension sizes */ + hsize_t chunk_dims[2] = {2,5}; /* Chunk dimension sizes */ + int cbuf[6]; /* The data buffer */ + int buf[6][3], rbuf[6][3]; /* The data buffers */ + int i, j; /* Local index variable */ - hsize_t boundary[2] = {0, 1}; /* Boundary sizes */ - unsigned append_ct = 0; /* The # of appends */ - unsigned *flush_ptr; /* Points to the flush counter */ + hsize_t boundary[2] = {0, 1}; /* Boundary sizes */ + unsigned append_ct = 0; /* The # of appends */ + unsigned *flush_ptr; /* Points to the flush counter */ - TESTING("Append flush with H5DOappend()--append columns"); + HL_TESTING2("Append flush with H5DOappend()--append columns"); /* Get the file's file access property list */ if((ffapl = H5Fget_access_plist(fid)) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Set to create a chunked dataset with 1 extendible dimension */ - if((sid = H5Screate_simple(2, dims, maxdims)) < 0) - FAIL_STACK_ERROR; - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - FAIL_STACK_ERROR; + if((sid = H5Screate_simple(2, dims, maxdims)) < 0) + FAIL_STACK_ERROR; + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR; if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Set append flush property */ - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) - FAIL_STACK_ERROR; + if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + FAIL_STACK_ERROR; if(H5Pset_append_flush(dapl, 2, boundary, append_func, &append_ct) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Create the dataset */ - if((did = H5Dcreate2(fid, DNAME_COLUMN, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0) - TEST_ERROR; + if((did = H5Dcreate2(fid, DNAME_COLUMN, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0) + TEST_ERROR; /* Append 3 columns to the dataset */ for(i = 0; i < 3; i++) { - for(j = 0; j < 6; j++) - cbuf[j] = buf[j][i] = ((i * 6) + (j + 1)) * -1; - if(H5DOappend(did, H5P_DEFAULT, 1, (size_t)1, H5T_NATIVE_INT, cbuf) < 0) - TEST_ERROR; + for(j = 0; j < 6; j++) + cbuf[j] = buf[j][i] = ((i * 6) + (j + 1)) * -1; + if(H5DOappend(did, H5P_DEFAULT, 1, (size_t)1, H5T_NATIVE_INT, cbuf) < 0) + TEST_ERROR; } /* end for */ /* Verify the # of appends */ if(append_ct != 3) - TEST_ERROR; + TEST_ERROR; /* Retrieve and verify object flush counts */ if(H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(*flush_ptr != 3) - TEST_ERROR; + TEST_ERROR; /* Read the dataset */ if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) - FAIL_STACK_ERROR; - + FAIL_STACK_ERROR; + /* Verify the data */ for(i = 0; i < 6; i++) - for(j = 0; j < 3; j++) + for(j = 0; j < 3; j++) if(buf[i][j] != rbuf[i][j]) TEST_ERROR; @@ -526,33 +527,33 @@ test_dataset_append_columns(hid_t fid) /* Close the dataset */ if(H5Dclose(did) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Open the dataset again */ if((did = H5Dopen2(fid, DNAME_COLUMN, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Read the dataset */ if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Verify the data */ for(i = 0; i < 6; i++) - for(j = 0; j < 3; j++) + for(j = 0; j < 3; j++) if(buf[i][j] != rbuf[i][j]) TEST_ERROR; /* Closing */ if(H5Dclose(did) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(H5Sclose(sid) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(H5Pclose(dapl) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(H5Pclose(dcpl) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(H5Pclose(ffapl) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; PASSED(); @@ -560,33 +561,34 @@ test_dataset_append_columns(hid_t fid) error: H5E_BEGIN_TRY { - H5Pclose(dapl); - H5Pclose(dcpl); - H5Pclose(sid); - H5Dclose(did); - H5Pclose(ffapl); + H5Pclose(dapl); + H5Pclose(dcpl); + H5Pclose(sid); + H5Dclose(did); + H5Pclose(ffapl); } H5E_END_TRY; return 1; } /* test_dataset_append_columns() */ /*------------------------------------------------------------------------- - * Function: test_dataset_append_BUG1 + * Function: test_dataset_append_BUG1 * - * Purpose: Verify that the object flush property and the append flush property + * Purpose: Verify that the object flush property and the append flush property * are working properly when appending rows and columns to an * extendible dataset. - * A BUG occurs: - * when the extendible dataset is set up as follows: - * hsize_t dims[2] = {0, 10}; - * hsize_t maxdims[2] = {H5S_UNLIMITED, 50}; - * when append 6 rows and 3 columns to the dataset; - * The data is correct when the dataset is read at this point; - * The data is incorrect when the dataset is closed, opened again, and read at this point; - * NOTE: the problem does not occur when H5Dflush() is not performed for each row/column. * - * Return: Success: 0 - * Failure: 1 + * A BUG occurs: + * when the extendible dataset is set up as follows: + * hsize_t dims[2] = {0, 10}; + * hsize_t maxdims[2] = {H5S_UNLIMITED, 50}; + * when append 6 rows and 3 columns to the dataset; + * The data is correct when the dataset is read at this point; + * The data is incorrect when the dataset is closed, opened again, and read at this point; + * NOTE: the problem does not occur when H5Dflush() is not performed for each row/column. + * + * Return: Success: 0 + * Failure: 1 * * Programmer: Vailin Choi; Jan 2014 * @@ -595,126 +597,124 @@ error: static int test_dataset_append_BUG1(hid_t fid) { - hid_t did = -1; /* Dataset ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t dcpl = -1; /* Dataset creation property */ - hid_t dapl = -1; /* Dataset access property */ - hid_t ffapl = -1; /* The file's file access property list */ - - hsize_t dims[2] = {0, 10}; /* Current dimension sizes */ - hsize_t maxdims[2] = {H5S_UNLIMITED, 50}; /* Maximum dimension sizes */ - hsize_t chunk_dims[2] = {2,5}; /* Chunk dimension sizes */ - int lbuf[10], cbuf[6]; /* The data buffers */ - int buf[6][13], rbuf[6][13]; /* The data buffers */ - int i, j; /* Local index variables */ - - hsize_t boundary[2] = {1, 1}; /* Boundary sizes */ - unsigned append_ct = 0; /* The # of appends */ - unsigned *flush_ptr; /* Points to the flush counter */ - - TESTING("Append flush with H5DOappend()--append rows & columns--BUG1"); - + hid_t did = -1; /* Dataset ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t dcpl = -1; /* Dataset creation property */ + hid_t dapl = -1; /* Dataset access property */ + hid_t ffapl = -1; /* The file's file access property list */ + + hsize_t dims[2] = {0, 10}; /* Current dimension sizes */ + hsize_t maxdims[2] = {H5S_UNLIMITED, 50}; /* Maximum dimension sizes */ + hsize_t chunk_dims[2] = {2,5}; /* Chunk dimension sizes */ + int lbuf[10], cbuf[6]; /* The data buffers */ + int buf[6][13], rbuf[6][13]; /* The data buffers */ + int i, j; /* Local index variables */ + + hsize_t boundary[2] = {1, 1}; /* Boundary sizes */ + unsigned append_ct = 0; /* The # of appends */ + unsigned *flush_ptr; /* Points to the flush counter */ + + HL_TESTING2("Append flush with H5DOappend()--append rows & columns--BUG1"); + /* Get the file's file access property list */ if((ffapl = H5Fget_access_plist(fid)) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Set to create a chunked dataset with 2 extendible dimensions */ - if((sid = H5Screate_simple(2, dims, maxdims)) < 0) - FAIL_STACK_ERROR; - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - FAIL_STACK_ERROR; + if((sid = H5Screate_simple(2, dims, maxdims)) < 0) + FAIL_STACK_ERROR; + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR; if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Set append flush property */ - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) - FAIL_STACK_ERROR; + if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + FAIL_STACK_ERROR; if(H5Pset_append_flush(dapl, 2, boundary, append_func, &append_ct) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Create the dataset */ - if((did = H5Dcreate2(fid, DBUGNAME1, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0) - TEST_ERROR; + if((did = H5Dcreate2(fid, DBUGNAME1, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0) + TEST_ERROR; /* Append 6 rows to the dataset */ for(i = 0; i < 6; i++) { - for(j = 0; j < 10; j++) - lbuf[j] = buf[i][j] = (i * 10) + (j + 1); - if(H5DOappend(did, H5P_DEFAULT, 0, (size_t)1, H5T_NATIVE_INT, lbuf) < 0) - TEST_ERROR; + for(j = 0; j < 10; j++) + lbuf[j] = buf[i][j] = (i * 10) + (j + 1); + if(H5DOappend(did, H5P_DEFAULT, 0, (size_t)1, H5T_NATIVE_INT, lbuf) < 0) + TEST_ERROR; } /* end for */ /* Verify the # of appends */ if(append_ct != 6) - TEST_ERROR; + TEST_ERROR; /* Retrieve and verify object flush counts */ if(H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(*flush_ptr != 6) - TEST_ERROR; + TEST_ERROR; /* Append 3 columns to the dataset */ for(i = 0; i < 3; i++) { - for(j = 0; j < 6; j++) - cbuf[j] = buf[j][i+10] = ((i * 6) + (j + 1)) * -1; - if(H5DOappend(did, H5P_DEFAULT, 1, (size_t)1, H5T_NATIVE_INT, cbuf) < 0) - TEST_ERROR; + for(j = 0; j < 6; j++) + cbuf[j] = buf[j][i+10] = ((i * 6) + (j + 1)) * -1; + if(H5DOappend(did, H5P_DEFAULT, 1, (size_t)1, H5T_NATIVE_INT, cbuf) < 0) + TEST_ERROR; } /* end for */ /* Verify the # of appends */ if(append_ct != 9) - TEST_ERROR; + TEST_ERROR; /* Retrieve and verify object flush counts */ if(H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(*flush_ptr != 9) - TEST_ERROR; + TEST_ERROR; /* Read the dataset */ if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) - FAIL_STACK_ERROR; - + FAIL_STACK_ERROR; + /* Verify the data */ for(i = 0; i < 6; i++) - for(j = 0; j < 13; j++) + for(j = 0; j < 13; j++) if(buf[i][j] != rbuf[i][j]) TEST_ERROR; -#ifdef BUG1 HDmemset(rbuf, 0, sizeof(rbuf)); /* Close the dataset */ if(H5Dclose(did) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Open the dataset again */ - if((did = H5Dopen(fid, DBUGNAME1, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR; + if((did = H5Dopen2(fid, DBUGNAME1, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; /* Read the dataset */ if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Verify the data */ for(i = 0; i < 6; i++) - for(j = 0; j < 13; j++) + for(j = 0; j < 13; j++) if(buf[i][j] != rbuf[i][j]) TEST_ERROR; -#endif /* Closing */ if(H5Dclose(did) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(H5Sclose(sid) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(H5Pclose(dapl) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(H5Pclose(dcpl) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(H5Pclose(ffapl) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; PASSED(); @@ -722,33 +722,34 @@ test_dataset_append_BUG1(hid_t fid) error: H5E_BEGIN_TRY { - H5Pclose(dcpl); - H5Pclose(dapl); - H5Pclose(sid); - H5Dclose(did); - H5Pclose(ffapl); + H5Pclose(dcpl); + H5Pclose(dapl); + H5Pclose(sid); + H5Dclose(did); + H5Pclose(ffapl); } H5E_END_TRY; return 1; } /* test_dataset_append_BUG1() */ /*------------------------------------------------------------------------- - * Function: test_dataset_append_BUG2 + * Function: test_dataset_append_BUG2 * - * Purpose: Verify that the object flush property and the append flush property + * Purpose: Verify that the object flush property and the append flush property * are working properly when appending rows and columns to an * extendible dataset. - * A BUG occurs: - * when the extendible dataset is set up as follows: - * hsize_t dims[2] = {0, 10}; - * hsize_t maxdims[2] = {50, H5S_UNLIMITED}; - * when append 6 rows and 3 columns to the dataset; - * The data is correct when the dataset is read at this point; - * The data is incorrect when the dataset is closed, opened again, and read at this point; - * NOTE: the problem does not occur when H5Dflush() is not performed for each row/column. * - * Return: Success: 0 - * Failure: 1 + * A BUG occurs: + * when the extendible dataset is set up as follows: + * hsize_t dims[2] = {0, 10}; + * hsize_t maxdims[2] = {50, H5S_UNLIMITED}; + * when append 6 rows and 3 columns to the dataset; + * The data is correct when the dataset is read at this point; + * The data is incorrect when the dataset is closed, opened again, and read at this point; + * NOTE: the problem does not occur when H5Dflush() is not performed for each row/column. + * + * Return: Success: 0 + * Failure: 1 * * Programmer: Vailin Choi; Jan 2014 * @@ -757,127 +758,125 @@ error: static int test_dataset_append_BUG2(hid_t fid) { - hid_t did = -1; /* Dataset ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t dcpl = -1; /* Dataset creation property */ - hid_t dapl = -1; /* Dataset access property */ - hid_t ffapl = -1; /* The file's file access property list */ - - hsize_t dims[2] = {0, 10}; /* Current dimension sizes */ - hsize_t maxdims[2] = {50, H5S_UNLIMITED}; /* Maximum dimension sizes */ - hsize_t chunk_dims[2] = {2,5}; /* Chunk dimension sizes */ - int lbuf[10], cbuf[6]; /* Data buffers */ - int buf[6][13], rbuf[6][13]; /* Data buffers */ - int i, j; /* Local index variables */ - - hsize_t boundary[2] = {1, 1}; /* Boundary sizes */ - unsigned append_ct = 0; /* The # of appends */ - unsigned *flush_ptr; /* Points to the flush counter */ - - TESTING("Append flush with H5DOappend()--append rows & columns--BUG2"); - + hid_t did = -1; /* Dataset ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t dcpl = -1; /* Dataset creation property */ + hid_t dapl = -1; /* Dataset access property */ + hid_t ffapl = -1; /* The file's file access property list */ + + hsize_t dims[2] = {0, 10}; /* Current dimension sizes */ + hsize_t maxdims[2] = {50, H5S_UNLIMITED}; /* Maximum dimension sizes */ + hsize_t chunk_dims[2] = {2,5}; /* Chunk dimension sizes */ + int lbuf[10], cbuf[6]; /* Data buffers */ + int buf[6][13], rbuf[6][13]; /* Data buffers */ + int i, j; /* Local index variables */ + + hsize_t boundary[2] = {1, 1}; /* Boundary sizes */ + unsigned append_ct = 0; /* The # of appends */ + unsigned *flush_ptr; /* Points to the flush counter */ + + HL_TESTING2("Append flush with H5DOappend()--append rows & columns--BUG2"); + /* Get the file's file access property list */ if((ffapl = H5Fget_access_plist(fid)) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Set to create a chunked dataset with 2 extendible dimensions */ - if((sid = H5Screate_simple(2, dims, maxdims)) < 0) - FAIL_STACK_ERROR; - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - FAIL_STACK_ERROR; + if((sid = H5Screate_simple(2, dims, maxdims)) < 0) + FAIL_STACK_ERROR; + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR; if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Set append flush property */ - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) - FAIL_STACK_ERROR; + if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + FAIL_STACK_ERROR; if(H5Pset_append_flush(dapl, 2, boundary, append_func, &append_ct) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Create the dataset */ - if((did = H5Dcreate2(fid, DBUGNAME2, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0) - TEST_ERROR; + if((did = H5Dcreate2(fid, DBUGNAME2, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0) + TEST_ERROR; /* Append 6 rows to the dataset */ for(i = 0; i < 6; i++) { - for(j = 0; j < 10; j++) - lbuf[j] = buf[i][j] = (i * 10) + (j + 1); - if(H5DOappend(did, H5P_DEFAULT, 0, (size_t)1, H5T_NATIVE_INT, lbuf) < 0) - TEST_ERROR; + for(j = 0; j < 10; j++) + lbuf[j] = buf[i][j] = (i * 10) + (j + 1); + if(H5DOappend(did, H5P_DEFAULT, 0, (size_t)1, H5T_NATIVE_INT, lbuf) < 0) + TEST_ERROR; } /* end for */ /* Verify the # of appends */ if(append_ct != 6) - TEST_ERROR; + TEST_ERROR; /* Retrieve and verify object flush counts */ if(H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(*flush_ptr != 6) - TEST_ERROR; + TEST_ERROR; /* Append 3 columns to the dataset */ for(i = 0; i < 3; i++) { - for(j = 0; j < 6; j++) - cbuf[j] = buf[j][i+10] = ((i * 6) + (j + 1)) * -1; - if(H5DOappend(did, H5P_DEFAULT, 1, (size_t)1, H5T_NATIVE_INT, cbuf) < 0) - TEST_ERROR; + for(j = 0; j < 6; j++) + cbuf[j] = buf[j][i+10] = ((i * 6) + (j + 1)) * -1; + if(H5DOappend(did, H5P_DEFAULT, 1, (size_t)1, H5T_NATIVE_INT, cbuf) < 0) + TEST_ERROR; } /* end for */ /* Verify the # of appends */ if(append_ct != 9) - TEST_ERROR; + TEST_ERROR; /* Retrieve and verify object flush counts */ if(H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(*flush_ptr != 9) - TEST_ERROR; + TEST_ERROR; /* Read the dataset */ if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) - FAIL_STACK_ERROR; - + FAIL_STACK_ERROR; + /* Verify the data */ for(i = 0; i < 6; i++) - for(j = 0; j < 13; j++) + for(j = 0; j < 13; j++) if(buf[i][j] != rbuf[i][j]) TEST_ERROR; -#ifdef BUG2 HDmemset(rbuf, 0, sizeof(rbuf)); /* Close the dataset */ if(H5Dclose(did) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Open the dataset again */ - if((did = H5Dopen(fid, DBUGNAME2, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR; + if((did = H5Dopen2(fid, DBUGNAME2, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; /* Read the dataset */ if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Verify the data */ for(i = 0; i < 6; i++) - for(j = 0; j < 13; j++) + for(j = 0; j < 13; j++) if(buf[i][j] != rbuf[i][j]) TEST_ERROR; -#endif /* Closing */ if(H5Dclose(did) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(H5Sclose(sid) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(H5Pclose(dapl) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(H5Pclose(dcpl) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(H5Pclose(ffapl) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; PASSED(); @@ -885,11 +884,11 @@ test_dataset_append_BUG2(hid_t fid) error: H5E_BEGIN_TRY { - H5Pclose(dcpl); - H5Pclose(dapl); - H5Pclose(sid); - H5Dclose(did); - H5Pclose(ffapl); + H5Pclose(dcpl); + H5Pclose(dapl); + H5Pclose(sid); + H5Dclose(did); + H5Pclose(ffapl); } H5E_END_TRY; return 1; @@ -897,15 +896,15 @@ error: /*------------------------------------------------------------------------- - * Function: test_dataset_append_less + * Function: test_dataset_append_less * - * Purpose: Verify that the object flush property and the append flush property - * are working properly when appending rows and columns to an - * extendible dataset where the append size is less than the boundary - * size. + * Purpose: Verify that the object flush property and the append flush property + * are working properly when appending rows and columns to an + * extendible dataset where the append size is less than the boundary + * size. * - * Return: Success: 0 - * Failure: 1 + * Return: Success: 0 + * Failure: 1 * * Programmer: Vailin Choi; Jan 2014 * @@ -914,93 +913,93 @@ error: static int test_dataset_append_less(hid_t fid) { - hid_t did = -1; /* Dataset ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t dcpl = -1; /* A copy of dataset creation property */ - hid_t dapl = -1; /* A copy of dataset access property */ - hid_t ffapl = -1; /* The file's file access property list */ + hid_t did = -1; /* Dataset ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t dcpl = -1; /* A copy of dataset creation property */ + hid_t dapl = -1; /* A copy of dataset access property */ + hid_t ffapl = -1; /* The file's file access property list */ - hsize_t dims[2] = {0, 10}; /* Current dimension sizes */ - hsize_t maxdims[2] = {100, 100}; /* Maximum dimension sizes */ - hsize_t chunk_dims[2] = {2,5}; /* Chunk dimension sizes */ - int lbuf[20], cbuf[6][3]; /* Data buffers */ - int buf[6][13], rbuf[6][13]; /* Data buffers */ - int i, j, k; /* Local index variables */ + hsize_t dims[2] = {0, 10}; /* Current dimension sizes */ + hsize_t maxdims[2] = {100, 100}; /* Maximum dimension sizes */ + hsize_t chunk_dims[2] = {2,5}; /* Chunk dimension sizes */ + int lbuf[20], cbuf[6][3]; /* Data buffers */ + int buf[6][13], rbuf[6][13]; /* Data buffers */ + int i, j, k; /* Local index variables */ - hsize_t boundary[2] = {3, 3}; /* Boundary sizes */ - unsigned append_ct = 0; /* The # of appends */ - unsigned *flush_ptr; /* Points to the flush counter */ + hsize_t boundary[2] = {3, 3}; /* Boundary sizes */ + unsigned append_ct = 0; /* The # of appends */ + unsigned *flush_ptr; /* Points to the flush counter */ - TESTING("Append flush with H5DOappend()--append size < boundary size"); + HL_TESTING2("Append flush with H5DOappend()--append size < boundary size"); /* Get the file's file access property list */ if((ffapl = H5Fget_access_plist(fid)) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Set to create a chunked dataset with 2 extendible dimensions */ - if((sid = H5Screate_simple(2, dims, maxdims)) < 0) - FAIL_STACK_ERROR; - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - FAIL_STACK_ERROR; + if((sid = H5Screate_simple(2, dims, maxdims)) < 0) + FAIL_STACK_ERROR; + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR; if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Set append flush property */ - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) - FAIL_STACK_ERROR; + if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + FAIL_STACK_ERROR; if(H5Pset_append_flush(dapl, 2, boundary, append_func, &append_ct) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Create the dataset */ - if((did = H5Dcreate2(fid, DNAME_LESS, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0) - TEST_ERROR; + if((did = H5Dcreate2(fid, DNAME_LESS, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0) + TEST_ERROR; /* Append to the dataset 2 rows at a time for 3 times */ for(i = 0, k = 0; i < 6; i++) { - for(j = 0; j < 10; j++, k++) - buf[i][j] = lbuf[k] = (i * 10) + (j + 1); - - if((i + 1) % 2 == 0) { - if(H5DOappend(did, H5P_DEFAULT, 0, (size_t)2, H5T_NATIVE_INT, lbuf) < 0) - TEST_ERROR; - k = 0; - } /* end if */ + for(j = 0; j < 10; j++, k++) + buf[i][j] = lbuf[k] = (i * 10) + (j + 1); + + if((i + 1) % 2 == 0) { + if(H5DOappend(did, H5P_DEFAULT, 0, (size_t)2, H5T_NATIVE_INT, lbuf) < 0) + TEST_ERROR; + k = 0; + } /* end if */ } /* end for */ /* Verify the # of appends */ if(append_ct != 2) - TEST_ERROR; + TEST_ERROR; /* Retrieve and verify object flush counts */ if(H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(*flush_ptr != 2) - TEST_ERROR; + TEST_ERROR; /* Append 3 columns to the dataset, once */ for(i = 0; i < 3; i++) - for(j = 0; j < 6; j++, k++) - cbuf[j][i] = buf[j][i + 10] = ((i * 6) + (j + 1)) * -1; + for(j = 0; j < 6; j++, k++) + cbuf[j][i] = buf[j][i + 10] = ((i * 6) + (j + 1)) * -1; if(H5DOappend(did, H5P_DEFAULT, 1, (size_t)3, H5T_NATIVE_INT, cbuf) < 0) - TEST_ERROR; + TEST_ERROR; /* Verify the # of appends */ if(append_ct != 3) - TEST_ERROR; + TEST_ERROR; /* Retrieve and verify object flush counts */ if(H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(*flush_ptr != 3) - TEST_ERROR; + TEST_ERROR; /* Read the dataset */ if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) - FAIL_STACK_ERROR; - + FAIL_STACK_ERROR; + /* Verify the data */ for(i = 0; i < 6; i++) - for(j = 0; j < 13; j++) + for(j = 0; j < 13; j++) if(buf[i][j] != rbuf[i][j]) TEST_ERROR; @@ -1009,33 +1008,33 @@ test_dataset_append_less(hid_t fid) /* Close the dataset */ if(H5Dclose(did) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Open the dataset again */ if((did = H5Dopen2(fid, DNAME_LESS, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Read the dataset */ if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Verify the data */ for(i = 0; i < 6; i++) - for(j = 0; j < 13; j++) + for(j = 0; j < 13; j++) if(buf[i][j] != rbuf[i][j]) TEST_ERROR; /* Closing */ if(H5Dclose(did) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(H5Sclose(sid) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(H5Pclose(dapl) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(H5Pclose(dcpl) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(H5Pclose(ffapl) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; PASSED(); @@ -1043,29 +1042,29 @@ test_dataset_append_less(hid_t fid) error: H5E_BEGIN_TRY { - H5Pclose(dapl); - H5Pclose(dcpl); - H5Pclose(sid); - H5Dclose(did); - H5Pclose(ffapl); + H5Pclose(dapl); + H5Pclose(dcpl); + H5Pclose(sid); + H5Dclose(did); + H5Pclose(ffapl); } H5E_END_TRY; return 1; } /* test_dataset_append_less() */ /*------------------------------------------------------------------------- - * Function: test_dataset_append_vary + * Function: test_dataset_append_vary * - * Purpose: Verify that the object flush property and the append flush property - * are working properly when appending rows and columns to an - * extendible dataset where - * row: the append size is 3 times of the boundary size - * the append callback/flush is performed on the 1st boundary hit - * column: the boundary is greater than the append size - * the boundary is not hit at all + * Purpose: Verify that the object flush property and the append flush property + * are working properly when appending rows and columns to an + * extendible dataset where + * row: the append size is 3 times of the boundary size + * the append callback/flush is performed on the 1st boundary hit + * column: the boundary is greater than the append size + * the boundary is not hit at all * - * Return: Success: 0 - * Failure: 1 + * Return: Success: 0 + * Failure: 1 * * Programmer: Vailin Choi; Jan 2014 * @@ -1074,88 +1073,88 @@ error: static int test_dataset_append_vary(hid_t fid) { - hid_t did = -1; /* Dataset ID */ - hid_t sid = -1; /* Dataspace ID */ - hid_t dcpl = -1; /* A copy of dataset creation property */ - hid_t dapl = -1; /* A copy of dataset access property */ - hid_t ffapl = -1; /* The file's file access property list */ + hid_t did = -1; /* Dataset ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t dcpl = -1; /* A copy of dataset creation property */ + hid_t dapl = -1; /* A copy of dataset access property */ + hid_t ffapl = -1; /* The file's file access property list */ - hsize_t dims[2] = {0, 10}; /* Current dimension sizes */ - hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Maximum dimension sizes */ - hsize_t chunk_dims[2] = {2,5}; /* Chunk dimension sizes */ - int lbuf[60], cbuf[6][3]; /* Data buffers */ - int buf[6][13], rbuf[6][13]; /* Data buffers */ - int i, j, k; /* Local index variables */ + hsize_t dims[2] = {0, 10}; /* Current dimension sizes */ + hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Maximum dimension sizes */ + hsize_t chunk_dims[2] = {2,5}; /* Chunk dimension sizes */ + int lbuf[60], cbuf[6][3]; /* Data buffers */ + int buf[6][13], rbuf[6][13]; /* Data buffers */ + int i, j, k; /* Local index variables */ - hsize_t boundary[2] = {3, 7}; /* Boundary sizes */ - unsigned append_ct = 0; /* The # of appends */ - unsigned *flush_ptr; /* Points to the flush counter */ + hsize_t boundary[2] = {3, 7}; /* Boundary sizes */ + unsigned append_ct = 0; /* The # of appends */ + unsigned *flush_ptr; /* Points to the flush counter */ - TESTING("Append flush with H5DOappend()--append & boundary size vary"); + HL_TESTING2("Append flush with H5DOappend()--append & boundary size vary"); /* Get the file's file access property list */ if((ffapl = H5Fget_access_plist(fid)) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Set to create a chunked dataset with 2 extendible dimensions */ - if((sid = H5Screate_simple(2, dims, maxdims)) < 0) - FAIL_STACK_ERROR; - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - FAIL_STACK_ERROR; + if((sid = H5Screate_simple(2, dims, maxdims)) < 0) + FAIL_STACK_ERROR; + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR; if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Set append flush property */ - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) - FAIL_STACK_ERROR; + if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + FAIL_STACK_ERROR; if(H5Pset_append_flush(dapl, 2, boundary, append_func, &append_ct) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Create the dataset */ - if((did = H5Dcreate2(fid, DNAME_VARY, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0) - TEST_ERROR; + if((did = H5Dcreate2(fid, DNAME_VARY, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl)) < 0) + TEST_ERROR; /* Append 6 rows to the dataset, once */ for(i = 0, k = 0; i < 6; i++) - for(j = 0; j < 10; j++, k++) - buf[i][j] = lbuf[k] = (i * 10) + (j + 1); + for(j = 0; j < 10; j++, k++) + buf[i][j] = lbuf[k] = (i * 10) + (j + 1); if(H5DOappend(did, H5P_DEFAULT, 0, (size_t)6, H5T_NATIVE_INT, lbuf) < 0) - TEST_ERROR; + TEST_ERROR; /* Verify the # of appends */ if(append_ct != 1) - TEST_ERROR; + TEST_ERROR; /* Retrieve and verify object flush counts */ if(H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(*flush_ptr != 1) - TEST_ERROR; + TEST_ERROR; /* Append 3 columns to the dataset, once */ for(i = 0; i < 3; i++) - for(j = 0; j < 6; j++, k++) - cbuf[j][i] = buf[j][i + 10] = ((i * 6) + (j + 1)) * -1; + for(j = 0; j < 6; j++, k++) + cbuf[j][i] = buf[j][i + 10] = ((i * 6) + (j + 1)) * -1; if(H5DOappend(did, H5P_DEFAULT, 1, (size_t)3, H5T_NATIVE_INT, cbuf) < 0) - TEST_ERROR; + TEST_ERROR; /* Verify the # of appends */ if(append_ct != 1) - TEST_ERROR; + TEST_ERROR; /* Retrieve and verify object flush counts */ if(H5Pget_object_flush_cb(ffapl, NULL, (void **)&flush_ptr) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(*flush_ptr != 1) - TEST_ERROR; + TEST_ERROR; /* Read the dataset */ if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) - FAIL_STACK_ERROR; - + FAIL_STACK_ERROR; + /* Verify the data */ for(i = 0; i < 6; i++) - for(j = 0; j < 13; j++) + for(j = 0; j < 13; j++) if(buf[i][j] != rbuf[i][j]) TEST_ERROR; @@ -1164,33 +1163,33 @@ test_dataset_append_vary(hid_t fid) /* Close the dataset */ if(H5Dclose(did) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Open the dataset again */ if((did = H5Dopen2(fid, DNAME_VARY, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Read the dataset */ if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Verify the data */ for(i = 0; i < 6; i++) - for(j = 0; j < 13; j++) + for(j = 0; j < 13; j++) if(buf[i][j] != rbuf[i][j]) TEST_ERROR; /* Closing */ if(H5Dclose(did) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(H5Sclose(sid) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(H5Pclose(dapl) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(H5Pclose(dcpl) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(H5Pclose(ffapl) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; PASSED(); @@ -1198,24 +1197,23 @@ test_dataset_append_vary(hid_t fid) error: H5E_BEGIN_TRY { - H5Pclose(dapl); - H5Pclose(dcpl); - H5Pclose(sid); - H5Dclose(did); - H5Pclose(ffapl); + H5Pclose(dapl); + H5Pclose(dcpl); + H5Pclose(sid); + H5Dclose(did); + H5Pclose(ffapl); } H5E_END_TRY; return 1; } /* test_dataset_append_vary() */ /*------------------------------------------------------------------------- - * Function: Main function + * Function: Main function * - * Purpose: Test H5Pset/get_object_flush_cb() and H5Pset/get_append_flush() - * along with H5DOappend(). + * Purpose: Test H5Pset/get_object_flush_cb() and H5Pset/get_append_flush() + * along with H5DOappend(). * - * Return: Success: 0 - * Failure: 1 + * Return: EXIT_SUCCESS/EXIT_FAILURE * * Programmer: Vailin Choi; Jan 2014 * @@ -1223,69 +1221,67 @@ error: */ int main(void) { - hid_t fid = -1; /* File ID */ - hid_t fapl = -1; /* File access property list */ - unsigned flush_ct = 0; /* The # of flushes */ - int nerrors = 0; /* The # of errors encountered */ + hid_t fid = -1; /* File ID */ + hid_t fapl = -1; /* File access property list */ + unsigned flush_ct = 0; /* The # of flushes */ + int nerrors = 0; /* The # of errors encountered */ /* Get a copy of file access property list */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) - FAIL_STACK_ERROR; + if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + FAIL_STACK_ERROR; /* Set to use the latest library format */ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Set object flush property */ if(H5Pset_object_flush_cb(fapl, flush_func, &flush_ct) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Create the test file */ - if((fid = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - FAIL_STACK_ERROR; + if((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR; nerrors += test_dataset_append_notset(fid); nerrors += test_dataset_append_rows(fid); - flush_ct = 0; /* Reset flush counter */ + flush_ct = 0; /* Reset flush counter */ nerrors += test_dataset_append_columns(fid); - flush_ct = 0; /* Reset flush counter */ + flush_ct = 0; /* Reset flush counter */ nerrors += test_dataset_append_rows_columns(fid); -#ifdef BUG1_BUG2 /* * The following tests illustrate the scenarios when H5DOappend does not work with extensible array indexing: - * - when the the dataset has 1 unlimited dimension and the other dimension is fixed but extendible - * - the dataset expands along 1 dimension and then expands along the other dimension + * - when the the dataset has 1 unlimited dimension and the other dimension is fixed but extendible + * - the dataset expands along 1 dimension and then expands along the other dimension */ - flush_ct = 0; /* Reset flush counter */ - nerrors += test_dataset_append_BUG1(fid); + flush_ct = 0; /* Reset flush counter */ + nerrors += test_dataset_append_BUG1(fid); - flush_ct = 0; /* Reset flush counter */ - nerrors += test_dataset_append_BUG2(fid); -#endif + flush_ct = 0; /* Reset flush counter */ + nerrors += test_dataset_append_BUG2(fid); - flush_ct = 0; /* Reset flush counter */ + flush_ct = 0; /* Reset flush counter */ nerrors += test_dataset_append_less(fid); - flush_ct = 0; /* Reset flush counter */ + flush_ct = 0; /* Reset flush counter */ nerrors += test_dataset_append_vary(fid); /* Closing */ if(H5Pclose(fapl) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(H5Fclose(fid) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Check for errors */ if(nerrors) goto error; - return 0; + return EXIT_SUCCESS; error: - return 1; + return EXIT_FAILURE; } diff --git a/hl/test/test_file_image.c b/hl/test/test_file_image.c index a98642c..fd2d0d2 100644 --- a/hl/test/test_file_image.c +++ b/hl/test/test_file_image.c @@ -44,10 +44,10 @@ extend the image, and then performs writes that extend the images. The fifth loop reads the extended images and verify that the content are correct. The sixth and final loop closes the file images and deallocates the image - buffers if appropriate. */ + buffers if appropriate. */ /*------------------------------------------------------------------------- -* test file image operations +* test file image operations *------------------------------------------------------------------------- */ static int @@ -67,11 +67,11 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) void **buf_ptr; /* pointer to array of pointers to image buffers */ char **filename; /* pointer to array of pointers to filenames */ unsigned *input_flags; /* pointer to array of flag combinations */ - size_t i, j, k, nrow, n_values; + size_t i, j, k, nrow, n_values; herr_t status1; void *handle_ptr = NULL; /* pointers to driver buffer */ - unsigned char **core_buf_ptr_ptr = NULL; - + unsigned char **core_buf_ptr_ptr = NULL; + VERIFY(open_images > 1 , "The number of open images must be greater than 1"); VERIFY(nflags > 0, "The number of flag combinations must be greater than 0"); @@ -100,7 +100,7 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) if (NULL == (dset_id = (hid_t *)HDmalloc(sizeof(hid_t) * open_images))) FAIL_PUTS_ERROR("malloc() failed"); - TESTING("get file images"); + HL_TESTING2("get file images"); /* create several file images */ for (i = 0; i < open_images; i++) { @@ -112,17 +112,17 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) filename[i] = (char *)HDmalloc(sizeof(char) * 32); /* create file name */ - sprintf(filename[i], "image_file%d.h5", (int)i); + HDsprintf(filename[i], "image_file%d.h5", (int)i); /* create file */ if ((file_id[i] = H5Fcreate(filename[i], H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_PUTS_ERROR("H5Fcreate() failed"); - /* define dataspace for the dataset */ - if ((file_space = H5Screate_simple(RANK, dims1, max_dims)) < 0) + /* define dataspace for the dataset */ + if ((file_space = H5Screate_simple(RANK, dims1, max_dims)) < 0) FAIL_PUTS_ERROR("H5Screate_simple() failed"); - /* create dataset property list */ + /* create dataset property list */ if ((plist = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_PUTS_ERROR("H5Pcreate() failed"); @@ -133,8 +133,8 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) /* create and write an integer type dataset named "dset" */ if ((dset_id[i] = H5Dcreate2(file_id[i], DSET_NAME, H5T_NATIVE_INT, file_space, H5P_DEFAULT, plist, H5P_DEFAULT)) < 0) FAIL_PUTS_ERROR("H5Dcreate() failed"); - - /* dataset in open image 1 is written with "wrong" data */ + + /* dataset in open image 1 is written with "wrong" data */ if (i == 1) { if (H5Dwrite(dset_id[i], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data2) < 0) FAIL_PUTS_ERROR("H5Dwrite() failed"); @@ -144,7 +144,7 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) if (H5Dwrite(dset_id[i], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data1) < 0) FAIL_PUTS_ERROR("H5Dwrite() failed"); } /* end else */ - + /* flush into the file */ if (H5Fflush(file_id[i], H5F_SCOPE_LOCAL) < 0) FAIL_PUTS_ERROR("H5Fflush() failed"); @@ -152,7 +152,7 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) /* close dataset property list */ if (H5Pclose(plist) < 0) FAIL_PUTS_ERROR("H5Pclose() failed"); - + /* close dataspace */ if (H5Sclose(file_space) < 0) FAIL_PUTS_ERROR("H5Sclose() failed"); @@ -172,7 +172,7 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) /* buffer for file image 2 is filled with counter data (non-valid image) */ if (i == 2) { for (j = 0; j < (size_t)buf_size[i]; j++) - ((char*)(buf_ptr[i]))[j] = (char)j; + ((char*)(buf_ptr[i]))[j] = (char)j; } /* end if */ /* buffers for the rest of the file images are filled with data from the respective files */ else { @@ -187,14 +187,14 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) PASSED(); - TESTING("open file images and check image copies"); - - /* open the file images with the core driver for data access */ + HL_TESTING2("open file images and check image copies"); + + /* open the file images with the core driver for data access */ for (i = 0; i < open_images; i++) { /* open file image 2 filled with counter data (non-valid image) */ if (i == 2) { H5E_BEGIN_TRY { - /* attempt to set file image in the core driver */ + /* attempt to set file image in the core driver */ file_id[i] = H5LTopen_file_image(buf_ptr[i], (size_t)buf_size[i], input_flags[i]); } H5E_END_TRY @@ -202,7 +202,7 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) } /* end if */ /* open rest of valid file images */ else { - /* set file image in the core driver */ + /* set file image in the core driver */ if ((file_id[i] = H5LTopen_file_image(buf_ptr[i], (size_t)buf_size[i], input_flags[i])) < 0) FAIL_PUTS_ERROR("H5LTopen_file_image() failed"); @@ -218,7 +218,7 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) else VERIFY(*core_buf_ptr_ptr != buf_ptr[i], "vfd buffer and user buffer should be different"); - /* + /* * When the vfd and user buffers are different and H5LT_FILE_IMAGE_OPEN_RW is enabled, * status_flags in the superblock needs to be cleared in the vfd buffer for * the comparison to proceed as expected. The user buffer as returned from H5Fget_file_image() @@ -249,7 +249,7 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) PASSED(); - TESTING("read file images"); + HL_TESTING2("read file images"); /* read open file images and verify data */ for (i = 0; i < open_images; i++) { @@ -259,7 +259,7 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) continue; } /* end if */ - /* open dataset in file image */ + /* open dataset in file image */ if ((dset_id[i] = H5Dopen2(file_id[i], DSET_NAME, H5P_DEFAULT)) < 0) FAIL_PUTS_ERROR("H5Dopen() failed"); @@ -274,8 +274,8 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) /* read dataset */ if (H5Dread(dset_id[i], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data3) < 0) FAIL_PUTS_ERROR("H5Dread() failed"); - - /* compute number of elements in dataset */ + + /* compute number of elements in dataset */ n_values = (size_t)(dims3[0] * dims3[1]); /* determine the number of rows in dataset */ @@ -297,15 +297,15 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) if (data3[j * nrow + k ] != data1[j * nrow + k ]) FAIL_PUTS_ERROR("comparison of image values with original data failed"); } /* end else */ - - /* close dataspace */ + + /* close dataspace */ if (H5Sclose (file_space) < 0) FAIL_PUTS_ERROR("H5Sclose() failed"); } /* end for */ - PASSED(); + PASSED(); - TESTING("write and extend file images"); + HL_TESTING2("write and extend file images"); /* write open file images and verify data */ for (i = 0; i < open_images; i++) { @@ -365,7 +365,7 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) hid_t attr_space_id = -1; hid_t attr_id = -1; herr_t status2; - size_t l; + size_t l; if ((attr_space_id = H5Screate_simple(attr_rank, attr_dims, attr_dims)) < 0) FAIL_PUTS_ERROR("attr_space H5Screate_simple() failed"); @@ -396,9 +396,9 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) H5Aclose(attr_id); } H5E_END_TRY; #endif - if (H5Dclose(dset_id[i]) < 0) - FAIL_PUTS_ERROR("H5Dclose() failed"); - dset_id[i] = -1; + if (H5Dclose(dset_id[i]) < 0) + FAIL_PUTS_ERROR("H5Dclose() failed"); + dset_id[i] = -1; } /* end if */ else { /* write dataset without extending it */ @@ -422,7 +422,7 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) PASSED(); - TESTING("read extended file images"); + HL_TESTING2("read extended file images"); /* read open file images and verify data */ for (i = 0; i < open_images; i++) { @@ -430,7 +430,7 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) if ((dset_id[i] < 0) || (file_id[i] < 0) || (!(input_flags[i] & H5LT_FILE_IMAGE_OPEN_RW ))) continue; - /* open dataset in file image */ + /* open dataset in file image */ if ((dset_id[i] = H5Dopen2(file_id[i], DSET_NAME, H5P_DEFAULT)) < 0) FAIL_PUTS_ERROR("H5Dopen() failed"); @@ -445,8 +445,8 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) /* read dataset */ if (H5Dread(dset_id[i], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data3) < 0) FAIL_PUTS_ERROR("H5Dread() failed"); - - /* compute number of elements in dataset */ + + /* compute number of elements in dataset */ n_values = (size_t)(dims3[0] * dims3[1]); /* determine the number of rows in dataset */ @@ -457,8 +457,8 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) for (k = 0; k < nrow; k++) if (data3[j * nrow + k ] != data4[j * nrow + k ]) FAIL_PUTS_ERROR("comparison of image values with original data failed"); - - /* close dataspace */ + + /* close dataspace */ if (H5Sclose (file_space) < 0) FAIL_PUTS_ERROR("H5Sclose() failed"); @@ -469,7 +469,7 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) PASSED() - TESTING("close file images"); + HL_TESTING2("close file images"); /* close file images and release buffer if appropriate */ for (i = 0; i < open_images; i++) { @@ -489,7 +489,7 @@ test_file_image(size_t open_images, size_t nflags, unsigned *flags) VERIFY(buf_ptr[i] != NULL, "buffer pointer must be non NULL"); HDfree(buf_ptr[i]); } /* end if */ - + } /* end for */ /* release temporary working buffers */ @@ -521,8 +521,8 @@ int main( void ) size_t open_images = 10; /* number of open file images */ size_t nflags = 8; /* number of flag combinations */ unsigned flags[8]; /* array with flag combinations */ - - /* set flag combinations for testing */ + + /* set flag combinations for testing */ flags[0] = 0; flags[1] = H5LT_FILE_IMAGE_DONT_RELEASE; flags[2] = H5LT_FILE_IMAGE_DONT_COPY; @@ -536,11 +536,11 @@ int main( void ) nerrors += test_file_image(open_images, nflags, flags) < 0? 1 : 0; if (nerrors) goto error; - printf("File image tests passed.\n"); + HDprintf("File image tests passed.\n"); return 0; error: - printf("***** %d IMAGE TEST%s FAILED! *****\n",nerrors, 1 == nerrors ? "" : "S"); + HDprintf("***** %d IMAGE TEST%s FAILED! *****\n",nerrors, 1 == nerrors ? "" : "S"); return 1; } diff --git a/hl/test/test_h5do_compat.c b/hl/test/test_h5do_compat.c index 4df5eef..75028fb 100644 --- a/hl/test/test_h5do_compat.c +++ b/hl/test/test_h5do_compat.c @@ -26,14 +26,14 @@ #define NX 8 #define CHUNK_NX 4 - + /*------------------------------------------------------------------------- - * Function: test_direct_chunk_write + * Function: test_direct_chunk_write * - * Purpose: Test the basic functionality of H5DOwrite_chunk + * Purpose: Test the basic functionality of H5DOwrite_chunk * - * Return: Success: An identifer for the dataset used in the tests - * Failure: H5I_INVALID_HID + * Return: Success: An identifer for the dataset used in the tests + * Failure: H5I_INVALID_HID * *------------------------------------------------------------------------- */ @@ -65,7 +65,7 @@ create_dataset(hid_t fid) /* Initialize the data */ for (i = 0; i < NX; i++) - data[i] = i; + data[i] = i; /* Write the initialized data */ if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0) @@ -91,14 +91,14 @@ create_dataset(hid_t fid) } /* end create_dataset() */ - + /*------------------------------------------------------------------------- - * Function: test_direct_chunk_write + * Function: test_direct_chunk_write * - * Purpose: Test the basic functionality of H5DOwrite_chunk + * Purpose: Test the basic functionality of H5DOwrite_chunk * - * Return: Success: 0 - * Failure: 1 + * Return: Success: 0 + * Failure: 1 * *------------------------------------------------------------------------- */ @@ -111,7 +111,7 @@ test_direct_chunk_write(hid_t did) size_t data_size; int i; - TESTING("H5DOwrite_chunk wrapper"); + HL_TESTING2("H5DOwrite_chunk wrapper"); /* Set the size of the chunk data */ data_size = CHUNK_NX * sizeof(int); @@ -120,9 +120,9 @@ test_direct_chunk_write(hid_t did) for (i = 0; i < CHUNK_NX; i++) chunk_data[i] = (i * 10) + i; - /* Write the direct chunk data repeatedly to cover all the chunks in the + /* Write the direct chunk data repeatedly to cover all the chunks in the * dataset, using the direct writing function. - */ + */ offset[0] = 0; for (i = 0; i < NX/CHUNK_NX; i++) { if (H5DOwrite_chunk(did, H5P_DEFAULT, filter_mask, offset, data_size, chunk_data) < 0) @@ -138,14 +138,14 @@ error: return 1; } /* test_direct_chunk_write() */ - + /*------------------------------------------------------------------------- - * Function: test_direct_chunk_read + * Function: test_direct_chunk_read * - * Purpose: Test the basic functionality of H5DOread_chunk + * Purpose: Test the basic functionality of H5DOread_chunk * - * Return: Success: 0 - * Failure: 1 + * Return: Success: 0 + * Failure: 1 * *------------------------------------------------------------------------- */ @@ -169,7 +169,7 @@ test_direct_chunk_read(hid_t did) int i,j; - TESTING("H5DOread_chunk wrapper"); + HL_TESTING2("H5DOread_chunk wrapper"); /* Create dataspaces for reading */ if ((mem_sid = H5Screate_simple(1, chunk_dims, NULL)) < 0) @@ -232,15 +232,15 @@ error: #endif /* H5_NO_DEPRECATED_SYMBOLS */ - + /*------------------------------------------------------------------------- - * Function: main + * Function: main * - * Purpose: Test direct chunk write function H5DOwrite_chunk and + * Purpose: Test direct chunk write function H5DOwrite_chunk and * chunk direct read function H5DOread_chunk * - * Return: Success: 0 - * Failure: 1 + * Return: Success: 0 + * Failure: 1 * *------------------------------------------------------------------------- */ diff --git a/hl/test/test_image.c b/hl/test/test_image.c index c30b572..6d13419 100644 --- a/hl/test/test_image.c +++ b/hl/test/test_image.c @@ -75,11 +75,11 @@ int main(void) nerrors += test_generate()<0 ?1:0; if (nerrors) goto error; - printf("All image tests passed.\n"); + HDprintf("All image tests passed.\n"); return 0; error: - printf("***** %d IMAGE TEST%s FAILED! *****\n",nerrors, 1 == nerrors ? "" : "S"); + HDprintf("***** %d IMAGE TEST%s FAILED! *****\n",nerrors, 1 == nerrors ? "" : "S"); return 1; } @@ -169,7 +169,7 @@ static int test_simple(void) *------------------------------------------------------------------------- */ - TESTING("indexed image"); + HL_TESTING2("indexed image"); /* Write image */ if ( H5IMmake_image_8bit( fid, IMAGE1_NAME, width, height, buf1 ) < 0 ) @@ -205,7 +205,7 @@ static int test_simple(void) *------------------------------------------------------------------------- */ - TESTING("true color image"); + HL_TESTING2("true color image"); /* Write image */ if ( H5IMmake_image_24bit( fid, IMAGE2_NAME, width, height, "INTERLACE_PIXEL", buf2 ) ) @@ -232,7 +232,7 @@ static int test_simple(void) *------------------------------------------------------------------------- */ - TESTING("pallete functions"); + HL_TESTING2("pallete functions"); if ( H5IMget_npalettes( fid, IMAGE1_NAME, &npals ) < 0 ) goto out; @@ -344,14 +344,14 @@ static int test_data(void) if ((fid=H5Fcreate(FILE2,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT))<0) goto out; - printf("Testing read ascii image data and generate images\n"); + HDprintf("Testing read ascii image data and generate images\n"); /*------------------------------------------------------------------------- * read 8bit image data *------------------------------------------------------------------------- */ - TESTING2("make indexed image"); + HL_TESTING2("make indexed image"); /* read first data file */ if (read_data(DATA_FILE1,&width,&height)<0) @@ -364,7 +364,7 @@ static int test_data(void) PASSED(); - TESTING2("attaching palettes"); + HL_TESTING2("attaching palettes"); /*------------------------------------------------------------------------- * palette #1. rainbow palette. data is contained in "pal_rgb.h" @@ -464,7 +464,7 @@ static int test_data(void) *------------------------------------------------------------------------- */ - TESTING2("make true color image with pixel interlace"); + HL_TESTING2("make true color image with pixel interlace"); /* read second data file */ if ((read_data(DATA_FILE2,&width,&height))<0) @@ -481,7 +481,7 @@ static int test_data(void) *------------------------------------------------------------------------- */ - TESTING2("make true color image with plane interlace"); + HL_TESTING2("make true color image with plane interlace"); /* read third data file */ if ((read_data(DATA_FILE3,&width,&height))<0) @@ -551,7 +551,7 @@ static int test_generate(void) if ((fid=H5Fcreate(FILE3,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT))<0) goto out; - printf("Testing read and process data and make indexed images\n"); + HDprintf("Testing read and process data and make indexed images\n"); /*------------------------------------------------------------------------- * read data; the file data format is described below @@ -561,7 +561,7 @@ static int test_generate(void) f = HDfopen( data_file, "r" ) ; if ( f == NULL ) { - printf( "Could not find file %s. Try set $srcdir \n", data_file ); + HDprintf( "Could not find file %s. Try set $srcdir \n", data_file ); goto out; } @@ -602,11 +602,11 @@ static int test_generate(void) if(fscanf( f, "%d %d %d", &imax, &jmax, &kmax ) < 0 && HDferror(f)) { - printf( "fscanf error in file %s.\n", data_file ); + HDprintf( "fscanf error in file %s.\n", data_file ); goto out; } /* end if */ if(fscanf( f, "%f %f %f", &valex, &xmin, &xmax ) < 0 && HDferror(f)) { - printf( "fscanf error in file %s.\n", data_file ); + HDprintf( "fscanf error in file %s.\n", data_file ); goto out; } /* end if */ @@ -627,7 +627,7 @@ static int test_generate(void) goto out; if(n_elements > INT_MAX / (int)sizeof(float)) goto out; - + data = (float *)HDmalloc((size_t)n_elements * sizeof(float)); if(NULL == data) goto out; @@ -638,7 +638,7 @@ static int test_generate(void) for ( i = 0; i < n_elements; i++ ) { if(fscanf( f, "%f ", &value ) < 0 && HDferror(f)) { - printf( "fscanf error in file %s.\n", data_file ); + HDprintf( "fscanf error in file %s.\n", data_file ); goto out; } /* end if */ data[i] = value; @@ -652,7 +652,7 @@ static int test_generate(void) *------------------------------------------------------------------------- */ - TESTING2("make indexed image from all the data"); + HL_TESTING2("make indexed image from all the data"); for ( i = 0; i < n_elements; i++ ) image_data[i] = (unsigned char)(( 255 * (data[i] - xmin ) ) / (xmax - xmin )); @@ -669,7 +669,7 @@ static int test_generate(void) *------------------------------------------------------------------------- */ - TESTING2("make indexed image from land data"); + HL_TESTING2("make indexed image from land data"); for ( i = 0; i < n_elements; i++ ) { @@ -691,7 +691,7 @@ static int test_generate(void) *------------------------------------------------------------------------- */ - TESTING2("make indexed image from sea data"); + HL_TESTING2("make indexed image from sea data"); for ( i = 0; i < n_elements; i++ ) { @@ -712,7 +712,7 @@ static int test_generate(void) *------------------------------------------------------------------------- */ - TESTING2("attaching palettes"); + HL_TESTING2("attaching palettes"); /* make a palette */ if ((H5IMmake_palette(fid,PAL1_NAME,pal_dims,pal_rgb))<0) @@ -797,37 +797,37 @@ static int read_data(const char* fname, /*IN*/ */ if(NULL == (f = HDfopen(data_file, "r"))) { - printf( "Could not open file %s. Try set $srcdir \n", data_file ); + HDprintf( "Could not open file %s. Try set $srcdir \n", data_file ); goto out; } if(fscanf(f, "%s", str) < 0 && HDferror(f)) { - printf( "fscanf error in file %s.\n", data_file ); + HDprintf( "fscanf error in file %s.\n", data_file ); goto out; } /* end if */ if(fscanf(f, "%d", &color_planes) < 0 && HDferror(f)) { - printf( "fscanf error in file %s.\n", data_file ); + HDprintf( "fscanf error in file %s.\n", data_file ); goto out; } /* end if */ if(fscanf(f, "%s", str) < 0 && HDferror(f)) { - printf( "fscanf error in file %s.\n", data_file ); + HDprintf( "fscanf error in file %s.\n", data_file ); goto out; } /* end if */ - + if(fscanf(f, "%d", &h) < 0 && HDferror(f)) { - printf( "fscanf error in file %s.\n", data_file ); + HDprintf( "fscanf error in file %s.\n", data_file ); goto out; } /* end if */ if(fscanf(f, "%s", str) < 0 && HDferror(f)) { - printf( "fscanf error in file %s.\n", data_file ); + HDprintf( "fscanf error in file %s.\n", data_file ); goto out; } /* end if */ if(fscanf(f, "%d", &w) < 0 && HDferror(f)) { - printf( "fscanf error in file %s.\n", data_file ); + HDprintf( "fscanf error in file %s.\n", data_file ); goto out; } /* end if */ @@ -861,7 +861,7 @@ static int read_data(const char* fname, /*IN*/ /* Read data elements */ for(i = 0; i < n_elements; i++) { if(fscanf(f, "%d", &n) < 0 && HDferror(f)) { - printf( "fscanf error in file %s.\n", data_file ); + HDprintf( "fscanf error in file %s.\n", data_file ); goto out; } /* end if */ image_data[i] = (unsigned char)n; @@ -870,7 +870,7 @@ static int read_data(const char* fname, /*IN*/ /* Indicate success */ ret_val = 1; -out: +out: if(f) HDfclose(f); @@ -917,7 +917,7 @@ static int read_palette(const char* fname, /* open the input file */ if (!(file = HDfopen(data_file, "r"))) { - printf( "Could not open file %s. Try set $srcdir \n", data_file ); + HDprintf( "Could not open file %s. Try set $srcdir \n", data_file ); return -1; } diff --git a/hl/test/test_ld.c b/hl/test/test_ld.c index 12a226a..e3cde5d 100644 --- a/hl/test/test_ld.c +++ b/hl/test/test_ld.c @@ -29,12 +29,12 @@ #define DSET_ONE "DSET_ONE" #define DSET_ALLOC_LATE "DSET_ALLOC_LATE" #define DSET_ALLOC_EARLY "DSET_ALLOC_EARLY" -#define DSET_TWO "DSET_TWO" -#define TWO_DIM_1 4 -#define TWO_DIM_2 10 -#define DSET_CMPD "DSET_CMPD" -#define DSET_CMPD_ESC "DSET_CMPD_ESC" -#define DSET_CMPD_TWO "DSET_CMPD_TWO" +#define DSET_TWO "DSET_TWO" +#define TWO_DIM_1 4 +#define TWO_DIM_2 10 +#define DSET_CMPD "DSET_CMPD" +#define DSET_CMPD_ESC "DSET_CMPD_ESC" +#define DSET_CMPD_TWO "DSET_CMPD_TWO" #define DSET_NULL "DSET_NULL" #define DSET_SCALAR "DSET_SCALAR" @@ -53,63 +53,63 @@ #define INVALID_ESC_FIELDS2 "field2\\..\\,b.a,field2\\..\\\\c,field4\\,.b\\,." #define INVALID_ESC_FIELDS3 "field2\\..\\,,b.a,field2\\..\\\\c,field4\\,.b\\," -/* +/* * Test variations (retained original) for one-dimensional dataset: - * Varies from 10->13; 10->9, 10->10, 10->1, 10->11 + * Varies from 10->13; 10->9, 10->10, 10->1, 10->11 */ #define ONE_NTESTS 5 int one_tests[ONE_NTESTS] = {3, -1, 0, -9, 1}; -/* +/* * Test variations (retained original) for two-dimensional dataset: - * Varies from {4,10}->{6,12}; {4,10}->{6,9}; {4,10}->{6,10}; - * {4,10}->{3,12}; {4,10}->{3,9}; {4,10}->{3,10}; - * {4,10}->{4,12}; {4,10}->{4,9}; {4,10}->{4,10} + * Varies from {4,10}->{6,12}; {4,10}->{6,9}; {4,10}->{6,10}; + * {4,10}->{3,12}; {4,10}->{3,9}; {4,10}->{3,10}; + * {4,10}->{4,12}; {4,10}->{4,9}; {4,10}->{4,10} */ -#define TWO_NTESTS 9 +#define TWO_NTESTS 9 int two_tests[TWO_NTESTS][2] = { {2,2}, {2,-1}, {2,0}, - {-1,2}, {-1,-1}, {-1,0}, - {0,2}, {0,-1}, {0,0} }; + {-1,2}, {-1,-1}, {-1,0}, + {0,2}, {0,-1}, {0,0} }; /* Verify that the two input values are the same */ -#define VERIFY_EQUAL(_x, _y) \ -{ \ - long __x = (long)_x, __y = (long)_y; \ - if(__x != __y) TEST_ERROR \ +#define VERIFY_EQUAL(_x, _y) \ +{ \ + long __x = (long)_x, __y = (long)_y; \ + if(__x != __y) TEST_ERROR \ } /* Temporary buffer for reading in the test file */ -#define TMP_BUF_SIZE 2048 +#define TMP_BUF_SIZE 2048 char g_tmp_buf[TMP_BUF_SIZE]; /* Macros for verifying compound fields */ /* Verify all fields */ -#define VERIFY_ELMTS_ALL(ent1, ent2) { \ - VERIFY_EQUAL(ent1.field1, ent2.field1); \ - VERIFY_EQUAL(ent1.field2.a, ent2.field2.a); \ - VERIFY_EQUAL(ent1.field2.b.a, ent2.field2.b.a); \ - VERIFY_EQUAL(ent1.field2.b.b, ent2.field2.b.b); \ - VERIFY_EQUAL(ent1.field2.b.c, ent2.field2.b.c); \ - VERIFY_EQUAL(ent1.field2.c, ent2.field2.c); \ - VERIFY_EQUAL(ent1.field3, ent2.field3); \ - VERIFY_EQUAL(ent1.field4.a, ent2.field4.a); \ +#define VERIFY_ELMTS_ALL(ent1, ent2) { \ + VERIFY_EQUAL(ent1.field1, ent2.field1); \ + VERIFY_EQUAL(ent1.field2.a, ent2.field2.a); \ + VERIFY_EQUAL(ent1.field2.b.a, ent2.field2.b.a); \ + VERIFY_EQUAL(ent1.field2.b.b, ent2.field2.b.b); \ + VERIFY_EQUAL(ent1.field2.b.c, ent2.field2.b.c); \ + VERIFY_EQUAL(ent1.field2.c, ent2.field2.c); \ + VERIFY_EQUAL(ent1.field3, ent2.field3); \ + VERIFY_EQUAL(ent1.field4.a, ent2.field4.a); \ } /* Verify fields selected in VALID_FIELDS1 */ -#define VERIFY_ELMTS_VALID1(ent1, ent2) { \ - VERIFY_EQUAL(ent1.field1, ent2.field1); \ - VERIFY_EQUAL(ent1.field2_a, ent2.field2.a); \ - VERIFY_EQUAL(ent1.field3, ent2.field3); \ - VERIFY_EQUAL(ent1.field4.a, ent2.field4.a); \ - VERIFY_EQUAL(ent1.field4.b, ent2.field4.b); \ +#define VERIFY_ELMTS_VALID1(ent1, ent2) { \ + VERIFY_EQUAL(ent1.field1, ent2.field1); \ + VERIFY_EQUAL(ent1.field2_a, ent2.field2.a); \ + VERIFY_EQUAL(ent1.field3, ent2.field3); \ + VERIFY_EQUAL(ent1.field4.a, ent2.field4.a); \ + VERIFY_EQUAL(ent1.field4.b, ent2.field4.b); \ } /* Verify fields selected in VALID_FIELDS2 */ -#define VERIFY_ELMTS_VALID2(ent1, ent2) { \ - VERIFY_EQUAL(ent1.field2_b_a, ent2.field2.b.a); \ - VERIFY_EQUAL(ent1.field2_c, ent2.field2.c); \ - VERIFY_EQUAL(ent1.field4_b, ent2.field4.b); \ +#define VERIFY_ELMTS_VALID2(ent1, ent2) { \ + VERIFY_EQUAL(ent1.field2_b_a, ent2.field2.b.a); \ + VERIFY_EQUAL(ent1.field2_c, ent2.field2.c); \ + VERIFY_EQUAL(ent1.field4_b, ent2.field4.b); \ } /* The types of 2-dimensional dataset: DSET_TWO or DSET_CMPD_TWO */ @@ -118,34 +118,34 @@ char g_tmp_buf[TMP_BUF_SIZE]; #define TWO_CMPD_VALID1 2 /* DSET_CMPD_TWO with VALID_FIELDS1 or VALID_ESC_FIELDS1 */ #define TWO_CMPD_VALID2 3 /* DSET_CMPD_TWO with VALID_FIELDS2 or VALID_ESC_FIELDS2 */ -#define VERIFY_ELMTS(type, k, ind, _ldbuf, _buf) { \ - if(type == TWO_NONE) { \ - int *iib = (int *)_ldbuf; \ - int *ib = (int *)_buf; \ - \ - VERIFY_EQUAL(iib[k], ib[ind + n]) \ - } else if(type == TWO_CMPD_NULL) { \ - set_t *ccb = (set_t *)_ldbuf; \ - set_t *cb = (set_t *)_buf; \ - \ - VERIFY_ELMTS_ALL(ccb[k], cb[ind + n]) \ - } else if(type == TWO_CMPD_VALID1) { \ - test_valid_fields1 *vb1 = (test_valid_fields1 *)_ldbuf; \ - set_t *cb = (set_t *)_buf; \ - \ - VERIFY_ELMTS_VALID1(vb1[k], cb[ind + n]) \ - } else if(type == TWO_CMPD_VALID2) { \ - test_valid_fields2 *vb2 = (test_valid_fields2 *)_ldbuf; \ - set_t *cb = (set_t *)_buf; \ - \ - VERIFY_ELMTS_VALID2(vb2[k], cb[ind + n]) \ - } \ +#define VERIFY_ELMTS(type, k, ind, _ldbuf, _buf) { \ + if(type == TWO_NONE) { \ + int *iib = (int *)_ldbuf; \ + int *ib = (int *)_buf; \ + \ + VERIFY_EQUAL(iib[k], ib[ind + n]) \ + } else if(type == TWO_CMPD_NULL) { \ + set_t *ccb = (set_t *)_ldbuf; \ + set_t *cb = (set_t *)_buf; \ + \ + VERIFY_ELMTS_ALL(ccb[k], cb[ind + n]) \ + } else if(type == TWO_CMPD_VALID1) { \ + test_valid_fields1 *vb1 = (test_valid_fields1 *)_ldbuf; \ + set_t *cb = (set_t *)_buf; \ + \ + VERIFY_ELMTS_VALID1(vb1[k], cb[ind + n]) \ + } else if(type == TWO_CMPD_VALID2) { \ + test_valid_fields2 *vb2 = (test_valid_fields2 *)_ldbuf; \ + set_t *cb = (set_t *)_buf; \ + \ + VERIFY_ELMTS_VALID2(vb2[k], cb[ind + n]) \ + } \ } /* Tests for test_LD_elmts_pipe() */ -#define ONE_TESTS 3 +#define ONE_TESTS 3 int onetests[ONE_TESTS] = {3, 9, 1}; -#define TWO_TESTS 5 +#define TWO_TESTS 5 int twotests[TWO_TESTS][2] = { {2,2}, {2,-1}, {2,0}, {-1,2}, {0,2} }; @@ -185,9 +185,9 @@ typedef struct set_t { sub4_t field4; } set_t; -/* NOTE: - * This will fail on heiwa and amani when VALID_FIELDS1 is "field1,field3,field4" - * because of alignment problems: +/* NOTE: + * This will fail on heiwa and amani when VALID_FIELDS1 is "field1,field3,field4" + * because of alignment problems: * amani and heiwa - 8 byte alignment * jam - 4 byte alignemnt * This will need to be fixed in the library for H5Tget_native_type(). @@ -211,185 +211,185 @@ typedef struct test_valid_fields2 { /* Temporary buffers for tests: test_LD_elmts_one() & test_LD_elmts_two() */ -#define TEST_BUF_SIZE 100 -int *iibuf; /* buffer for storing retrieved elements */ -int *ibuf; /* buffer for storing retrieved elements (integer) */ -set_t *cbuf; /* buffer for storing retrieved elemnets (compound) */ -set_t *ccbuf; /* buffer for storing retrieved elemnets (compound) */ -test_valid_fields1 *vbuf1; /* buffer for storing retrieved elements (FIELDS1) */ -test_valid_fields2 *vbuf2; /* buffer for storing retrieved elements (FIELDS2) */ - - -/* +#define TEST_BUF_SIZE 100 +int *iibuf; /* buffer for storing retrieved elements */ +int *ibuf; /* buffer for storing retrieved elements (integer) */ +set_t *cbuf; /* buffer for storing retrieved elemnets (compound) */ +set_t *ccbuf; /* buffer for storing retrieved elemnets (compound) */ +test_valid_fields1 *vbuf1; /* buffer for storing retrieved elements (FIELDS1) */ +test_valid_fields2 *vbuf2; /* buffer for storing retrieved elements (FIELDS2) */ + + +/* ********************************************************************************* * * Testing for the High Level public routine: H5LDget_dset_dims() - * 1) An invalid dataset id - * 2) "DSET_ALLOC_EARLY": NULL cur_dims - * 3) "DSET_ALLOC_LATE": nonNULL cur_dims - * 4) "DSET_CMPD_TWO": nonNULL cur_dims - * 5) "DSET_NULL": nonNULL cur_dims - * 6) "DSET_SCALAR": nonNULL cur_dims + * 1) An invalid dataset id + * 2) "DSET_ALLOC_EARLY": NULL cur_dims + * 3) "DSET_ALLOC_LATE": nonNULL cur_dims + * 4) "DSET_CMPD_TWO": nonNULL cur_dims + * 5) "DSET_NULL": nonNULL cur_dims + * 6) "DSET_SCALAR": nonNULL cur_dims * ********************************************************************************* */ static herr_t test_LD_dims_params(const char *file) { - hid_t fid=-1; /* file identifier */ - hid_t did=-1; /* dataset identifier */ - hsize_t one_cur_dims[1]; /* current dimension sizes for 1-dimensonal dataset */ - hsize_t two_cur_dims[2]; /* current dimension sizes for 2-dimensional dataset */ + hid_t fid=-1; /* file identifier */ + hid_t did=-1; /* dataset identifier */ + hsize_t one_cur_dims[1]; /* current dimension sizes for 1-dimensonal dataset */ + hsize_t two_cur_dims[2]; /* current dimension sizes for 2-dimensional dataset */ hid_t invalid_id = -1; - herr_t ret; /* return value */ + herr_t ret; /* return value */ const char *filename = H5_get_srcdir_filename(file); - TESTING("H5LDget_dset_dims"); + HL_TESTING2("H5LDget_dset_dims"); /* Open the copied file */ if((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR - /* + /* * 1. Verify failure with negative dataset id */ H5E_BEGIN_TRY { - ret = H5LDget_dset_dims(invalid_id, one_cur_dims); + ret = H5LDget_dset_dims(invalid_id, one_cur_dims); } H5E_END_TRY; VERIFY_EQUAL(ret, FAIL) - /* + /* * 2. Verify failure for NULL cur_dims */ if((did = H5Dopen2(fid, DSET_ALLOC_EARLY, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR H5E_BEGIN_TRY { - ret = H5LDget_dset_dims(did, NULL); + ret = H5LDget_dset_dims(did, NULL); } H5E_END_TRY; VERIFY_EQUAL(ret, FAIL) if(H5Dclose(did) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR - /* + /* * 3. Verify for nonNULL cur_dims */ if((did = H5Dopen2(fid, DSET_ALLOC_LATE, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5LDget_dset_dims(did, one_cur_dims) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR VERIFY_EQUAL(one_cur_dims[0], 10) if(H5Dclose(did) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR - /* + /* * 4. Verify nonNULL cur_dims for a 2-dimensional dataset */ if((did = H5Dopen2(fid, DSET_CMPD_TWO, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5LDget_dset_dims(did, two_cur_dims) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR VERIFY_EQUAL(two_cur_dims[0], TWO_DIM_1) VERIFY_EQUAL(two_cur_dims[1], TWO_DIM_2) if(H5Dclose(did) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR - /* + /* * 5. Verify nonNULL cur_dims for dataset with H5S_NULL dataspace */ one_cur_dims[0] = 0; if((did = H5Dopen2(fid, DSET_NULL, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5LDget_dset_dims(did, one_cur_dims) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR VERIFY_EQUAL(one_cur_dims[0], 0) if(H5Dclose(did) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR - /* + /* * 6. Verify nonNULL cur_dims for dataset with H5S_SCALAR dataspace */ one_cur_dims[0] = 0; if((did = H5Dopen2(fid, DSET_SCALAR, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5LDget_dset_dims(did, one_cur_dims) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR VERIFY_EQUAL(one_cur_dims[0], 0) if(H5Dclose(did) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Close the file */ if(H5Fclose(fid) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR PASSED(); return 0; error: H5E_BEGIN_TRY { - H5Dclose(did); - H5Fclose(fid); + H5Dclose(did); + H5Fclose(fid); } H5E_END_TRY; return(-1); } /* test_LD_dims_params() */ - -/* + +/* ********************************************************************************* * * Testing for the High Level public routine: H5LDget_dset_dims() * Verify that the dimension sizes retrieved via H5LDget_dset_dims() are correct * for the following cases: * - * DSET_ONE: one-dimensional dataset - * 1. Increase dims[0] - * 2. Decrease dims[0] - * 3. same dims[0] - * 4. Decrease dims[0] - * 5. Increase dims[0] + * DSET_ONE: one-dimensional dataset + * 1. Increase dims[0] + * 2. Decrease dims[0] + * 3. same dims[0] + * 4. Decrease dims[0] + * 5. Increase dims[0] * - * one_tests[ONE_NTESTS] = {3, -1, 0, -9, 1} - * Varies from 10->3; 10->9, 10->10, 10->1, 10->11 + * one_tests[ONE_NTESTS] = {3, -1, 0, -9, 1} + * Varies from 10->3; 10->9, 10->10, 10->1, 10->11 * - * DSET_TWO: two-dimensional dataset - * 1. Increase dims[0], increase dims[1] - * 2. Increase dims[0], decrease dims[1] - * 3. Increase dims[0], same dims[1] - * 4. Decrease dims[0], increase dims[1] - * 5. Decrease dims[0], decrease dims[1] - * 6. Decrease dims[0], same dims[1] - * 7. same dims[0], increase dims[1] - * 8. same dims[0], decrease dims[1] - * 9. same dims[0], same dims[1] + * DSET_TWO: two-dimensional dataset + * 1. Increase dims[0], increase dims[1] + * 2. Increase dims[0], decrease dims[1] + * 3. Increase dims[0], same dims[1] + * 4. Decrease dims[0], increase dims[1] + * 5. Decrease dims[0], decrease dims[1] + * 6. Decrease dims[0], same dims[1] + * 7. same dims[0], increase dims[1] + * 8. same dims[0], decrease dims[1] + * 9. same dims[0], same dims[1] * - * two_tests[TWO_NTESTS][2] = { {2,2}, {2,-1}, {2,0}, - * {-1,2}, {-1,-1}, {-1,0}, - * {0,2}, {0,-1}, {0,0} } - * Varies from {4,10}->{6,12}; {4,10}->{6,9}; {4,10}->{6,10}; - * {4,10}->{3,12}; {4,10}->{3,9}; {4,10}->{3,10}; - * {4,10}->{4,12}; {4,10}->{4,9}; {4,10}->{4,10} + * two_tests[TWO_NTESTS][2] = { {2,2}, {2,-1}, {2,0}, + * {-1,2}, {-1,-1}, {-1,0}, + * {0,2}, {0,-1}, {0,0} } + * Varies from {4,10}->{6,12}; {4,10}->{6,9}; {4,10}->{6,10}; + * {4,10}->{3,12}; {4,10}->{3,9}; {4,10}->{3,10}; + * {4,10}->{4,12}; {4,10}->{4,9}; {4,10}->{4,10} * ********************************************************************************* */ static herr_t test_LD_dims(const char *file) { - hid_t fid=-1; /* file identifier */ - hid_t did=-1; /* dataset identifier */ - hsize_t one_prev_dims[1]; /* original dimension sizes for 1-dimensonal dataset */ - hsize_t one_cur_dims[1]; /* current dimension sizes for 1-dimensonal dataset */ - hsize_t one_ext_dims[1]; /* extended dimension sizes for 1-dimensonal dataset */ - hsize_t two_prev_dims[2]; /* original dimension sizes for 2-dimensional dataset */ - hsize_t two_cur_dims[2]; /* current dimension sizes for 2-dimensional dataset */ - hsize_t two_ext_dims[2]; /* extended dimension sizes for 2-dimensional dataset*/ - int i; /* local index variable */ - - TESTING("H5LDget_dset_dims with H5Dset_extent"); + hid_t fid=-1; /* file identifier */ + hid_t did=-1; /* dataset identifier */ + hsize_t one_prev_dims[1]; /* original dimension sizes for 1-dimensonal dataset */ + hsize_t one_cur_dims[1]; /* current dimension sizes for 1-dimensonal dataset */ + hsize_t one_ext_dims[1]; /* extended dimension sizes for 1-dimensonal dataset */ + hsize_t two_prev_dims[2]; /* original dimension sizes for 2-dimensional dataset */ + hsize_t two_cur_dims[2]; /* current dimension sizes for 2-dimensional dataset */ + hsize_t two_ext_dims[2]; /* extended dimension sizes for 2-dimensional dataset*/ + int i; /* local index variable */ + + HL_TESTING2("H5LDget_dset_dims with H5Dset_extent"); /* Make a copy of the test file */ if(h5_make_local_copy(file, COPY_FILENAME) < 0) @@ -397,75 +397,75 @@ test_LD_dims(const char *file) /* Open the copied file */ if((fid = H5Fopen(COPY_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR - /* + /* * Testing with one-dimensional dataset: DSET_ONE */ if((did = H5Dopen2(fid, DSET_ONE, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Retrieve dimension sizes */ if(H5LDget_dset_dims(did, one_prev_dims) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR for(i = 0; i < ONE_NTESTS; i++) { - /* Set up the extended dimension sizes */ - one_ext_dims[0] = (hsize_t)((int)one_prev_dims[0] + one_tests[i]); + /* Set up the extended dimension sizes */ + one_ext_dims[0] = (hsize_t)((int)one_prev_dims[0] + one_tests[i]); - /* Change the dimension size */ - if(H5Dset_extent(did, one_ext_dims) < 0) - FAIL_STACK_ERROR + /* Change the dimension size */ + if(H5Dset_extent(did, one_ext_dims) < 0) + FAIL_STACK_ERROR - /* Retrieve the dimension size */ - if(H5LDget_dset_dims(did, one_cur_dims) < 0) - FAIL_STACK_ERROR + /* Retrieve the dimension size */ + if(H5LDget_dset_dims(did, one_cur_dims) < 0) + FAIL_STACK_ERROR - /* Verify that the retrieved dimension size is correct as expected */ - VERIFY_EQUAL(one_cur_dims[0], one_ext_dims[0]) + /* Verify that the retrieved dimension size is correct as expected */ + VERIFY_EQUAL(one_cur_dims[0], one_ext_dims[0]) } /* Close the dataset */ if(H5Dclose(did) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR - /* + /* * Testing with two-dimensional dataset: DSET_TWO */ if((did = H5Dopen2(fid, DSET_TWO, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Retrieve the dimension sizes */ if(H5LDget_dset_dims(did, two_prev_dims) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR for(i = 0; i < TWO_NTESTS; i++) { - /* Set up the extended dimension sizes */ - two_ext_dims[0] = (hsize_t)((int)two_prev_dims[0] + two_tests[i][0]); - two_ext_dims[1] = (hsize_t) ((int)two_prev_dims[1] + two_tests[i][1]); + /* Set up the extended dimension sizes */ + two_ext_dims[0] = (hsize_t)((int)two_prev_dims[0] + two_tests[i][0]); + two_ext_dims[1] = (hsize_t) ((int)two_prev_dims[1] + two_tests[i][1]); - /* Change the dimension sizes */ - if(H5Dset_extent(did, two_ext_dims) < 0) - FAIL_STACK_ERROR + /* Change the dimension sizes */ + if(H5Dset_extent(did, two_ext_dims) < 0) + FAIL_STACK_ERROR - /* Retrieve the dimension sizes */ - if(H5LDget_dset_dims(did, two_cur_dims) < 0) - FAIL_STACK_ERROR + /* Retrieve the dimension sizes */ + if(H5LDget_dset_dims(did, two_cur_dims) < 0) + FAIL_STACK_ERROR - /* Verify that the retrieved dimension sizes are correct as expected */ - VERIFY_EQUAL(two_cur_dims[0], two_ext_dims[0]) - VERIFY_EQUAL(two_cur_dims[1], two_ext_dims[1]) + /* Verify that the retrieved dimension sizes are correct as expected */ + VERIFY_EQUAL(two_cur_dims[0], two_ext_dims[0]) + VERIFY_EQUAL(two_cur_dims[1], two_ext_dims[1]) } /* end TWO_NTESTS */ /* Close the dataset */ if(H5Dclose(did) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Close the file */ if(H5Fclose(fid) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Remove the copied file */ HDremove(COPY_FILENAME); @@ -475,172 +475,172 @@ test_LD_dims(const char *file) error: H5E_BEGIN_TRY { - H5Dclose(did); - H5Fclose(fid); + H5Dclose(did); + H5Fclose(fid); } H5E_END_TRY; return(-1); } /* test_LD_dims() */ - -/* + +/* ********************************************************************************** * * Testing for the High Level public routine: H5LDget_dset_type_size() * Verify that the data type size returned via H5LDget_dset_type_size() * are correct for the following cases: * - * Verify failure for an invalid dataset id + * Verify failure for an invalid dataset id * - * DSET_CMPD: one-dimensional dataset with compound type - * 1. The whole element - * 2. VALID_FIELDS1: "field1,field2.a,field3,field4" - * 3. VALID_FIELDS2: "field2.b.a,field2.c,field4.b" - * 4. INVALID_FIELDS1: "field2.k.a,field2.c,field4.k" - * 5. INVALID_FIELDS2: "field2.b.a,field2.c,field4.b." - * 6. INVALID_FIELDS3: "field2.b.a,,field2.c,field4.b" + * DSET_CMPD: one-dimensional dataset with compound type + * 1. The whole element + * 2. VALID_FIELDS1: "field1,field2.a,field3,field4" + * 3. VALID_FIELDS2: "field2.b.a,field2.c,field4.b" + * 4. INVALID_FIELDS1: "field2.k.a,field2.c,field4.k" + * 5. INVALID_FIELDS2: "field2.b.a,field2.c,field4.b." + * 6. INVALID_FIELDS3: "field2.b.a,,field2.c,field4.b" * - * DSET_CMPD_ESC: one-dimensional dataset with compound type and - * member names with escape/separator characters - * 1. The whole element - * 2. VALID_ESC_FIELDS1: "field\\,1,field2\\..\\.a,field\\\\3,field4\\," - * 3. VALID_ESC_FIELDS2: "field2\\..\\,b.a,field2\\..\\\\c,field4\\,.b\\," - * 4. INVALID_ESC_FIELDS1: "field2\\..\\,k.a,field2\\..\\\\c,field4\\,.k\\," - * 5. INVALID_ESC_FIELDS2: "field2\\..\\,b.a,field2\\..\\\\c,field4\\,.b\\,." - * 6. INVALID_ESC_FIELDS3: "field2\\..\\,,b.a,field2\\..\\\\c,field4\\,.b\\," + * DSET_CMPD_ESC: one-dimensional dataset with compound type and + * member names with escape/separator characters + * 1. The whole element + * 2. VALID_ESC_FIELDS1: "field\\,1,field2\\..\\.a,field\\\\3,field4\\," + * 3. VALID_ESC_FIELDS2: "field2\\..\\,b.a,field2\\..\\\\c,field4\\,.b\\," + * 4. INVALID_ESC_FIELDS1: "field2\\..\\,k.a,field2\\..\\\\c,field4\\,.k\\," + * 5. INVALID_ESC_FIELDS2: "field2\\..\\,b.a,field2\\..\\\\c,field4\\,.b\\,." + * 6. INVALID_ESC_FIELDS3: "field2\\..\\,,b.a,field2\\..\\\\c,field4\\,.b\\," * ********************************************************************************** */ static int test_LD_size(const char *file) { - hid_t fid=-1; /* file identifier */ - hid_t did=-1; /* dataset identifier */ - hid_t dtid=-1; /* dataset's datatype identifier */ + hid_t fid=-1; /* file identifier */ + hid_t did=-1; /* dataset identifier */ + hid_t dtid=-1; /* dataset's datatype identifier */ hid_t invalid_id=-1; - hid_t memb0_tid=-1; /* type identifier for a member in the compound type */ - hid_t memb1_tid=-1; /* type identifier for a member in the compound type */ - hid_t memb2_tid=-1; /* type identifier for a member in the compound type */ - hid_t memb3_tid=-1; /* type identifier for a member in the compound type */ - hid_t memb_tid=-1; /* type identifier for a member in the compound type */ - hid_t memb_tid2=-1; /* type identifier for a member in the compound type */ - size_t dsize; /* size of the dataset's datatype */ - size_t ck_dsize; /* size of the dataset's datatype to be checked against */ + hid_t memb0_tid=-1; /* type identifier for a member in the compound type */ + hid_t memb1_tid=-1; /* type identifier for a member in the compound type */ + hid_t memb2_tid=-1; /* type identifier for a member in the compound type */ + hid_t memb3_tid=-1; /* type identifier for a member in the compound type */ + hid_t memb_tid=-1; /* type identifier for a member in the compound type */ + hid_t memb_tid2=-1; /* type identifier for a member in the compound type */ + size_t dsize; /* size of the dataset's datatype */ + size_t ck_dsize; /* size of the dataset's datatype to be checked against */ const char *filename = H5_get_srcdir_filename(file); - TESTING("H5LDget_dset_type_size"); + HL_TESTING2("H5LDget_dset_type_size"); /* Open the file */ if((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR - /* + /* * Verify failure with an invalid dataset id */ H5E_BEGIN_TRY { - dsize = H5LDget_dset_type_size(invalid_id, NULL); + dsize = H5LDget_dset_type_size(invalid_id, NULL); } H5E_END_TRY; VERIFY_EQUAL(dsize, 0) - /* + /* * Testing one-dimensional dataset with compound datatype: - * DSET_CMPD + * DSET_CMPD */ /* Open dataset DSET_CMPD */ if((did = H5Dopen2(fid, DSET_CMPD, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Return size of the whole element */ if((dsize = H5LDget_dset_type_size(did, NULL)) == 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Get the dataset's datatype and then its datatype size */ if((dtid = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0) FAIL_STACK_ERROR if((ck_dsize = H5Tget_size(dtid)) == 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Verify case #1 */ VERIFY_EQUAL(dsize, ck_dsize) /* Get datatype id for each member */ if((memb0_tid = H5Tget_member_type(dtid, 0)) < 0) /* "field1" */ - FAIL_STACK_ERROR + FAIL_STACK_ERROR if((memb1_tid = H5Tget_member_type(dtid, 1)) < 0) /* "field2" */ - FAIL_STACK_ERROR + FAIL_STACK_ERROR if((memb2_tid = H5Tget_member_type(dtid, 2)) < 0) /* "field3" */ - FAIL_STACK_ERROR + FAIL_STACK_ERROR if((memb3_tid = H5Tget_member_type(dtid, 3)) < 0) /* "field4" */ - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Obtain size for VALID_FIELDS1: "field1,field2.a,field3,field4" */ if((dsize = H5LDget_dset_type_size(did, VALID_FIELDS1)) == 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Get the datatype size for "field1" */ if((ck_dsize = H5Tget_size(memb0_tid)) == 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Add the datatype size for "field2.a" */ if((memb_tid = H5Tget_member_type(memb1_tid, 0)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if((ck_dsize += H5Tget_size(memb_tid)) == 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5Tclose(memb_tid) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Add the datatype size for "field3" */ if((ck_dsize += H5Tget_size(memb2_tid)) == 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Add the datatype size for "field4" */ if((ck_dsize += H5Tget_size(memb3_tid)) == 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Verify case #2 */ VERIFY_EQUAL(dsize, ck_dsize) /* Obtain datatype size for VALID_FIELDS2: "field2.b.a,field2.c,field4.b" */ if((dsize = H5LDget_dset_type_size(did, VALID_FIELDS2)) == 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Get the datatype size for "field2.b.a" */ if((memb_tid = H5Tget_member_type(memb1_tid, 1)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if((memb_tid2 = H5Tget_member_type(memb_tid, 0)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if((ck_dsize = H5Tget_size(memb_tid2)) == 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5Tclose(memb_tid) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5Tclose(memb_tid2) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Add the datatype size for "field2.c" */ if((memb_tid = H5Tget_member_type(memb1_tid, 2)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if((ck_dsize += H5Tget_size(memb_tid)) == 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5Tclose(memb_tid) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Add the datatype size for "field4.b" */ if((memb_tid = H5Tget_member_type(memb3_tid, 1)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if((ck_dsize += H5Tget_size(memb_tid)) == 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5Tclose(memb_tid) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Verify case #3 */ VERIFY_EQUAL(dsize, ck_dsize) /* - * Verify failure for the following invalid nested fields: - * INVALID_FIELDS1: "field2.k.a,field2.c,field4.k" + * Verify failure for the following invalid nested fields: + * INVALID_FIELDS1: "field2.k.a,field2.c,field4.k" * INVALID_FIELDS2: "field2.b.a,field2.c,field4.b." * INVALID_FIELDS3: "field2.b.a,,field2.c,field4.b" */ @@ -655,119 +655,119 @@ test_LD_size(const char *file) /* Verify failure for case #6 */ dsize = H5LDget_dset_type_size(did, INVALID_FIELDS3); VERIFY_EQUAL(dsize, 0) - + /* Closing */ if(H5Tclose(memb0_tid) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5Tclose(memb1_tid) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5Tclose(memb2_tid) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5Tclose(memb3_tid) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5Tclose(dtid) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5Dclose(did) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR - /* + /* * Testing one-dimensional dataset with compound datatype and - * member names consisting of escape/separator characters: - * DSET_CMPD_ESC + * member names consisting of escape/separator characters: + * DSET_CMPD_ESC */ /* Open dataset DSET_CMPD_ESC */ if((did = H5Dopen2(fid, DSET_CMPD_ESC, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Return size of the whole element */ if((dsize = H5LDget_dset_type_size(did, NULL)) == 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Get the dataset's datatype and then its datatype size */ if((dtid = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0) FAIL_STACK_ERROR if((ck_dsize = H5Tget_size(dtid)) == 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Verify case #1 */ VERIFY_EQUAL(dsize, ck_dsize) /* Get datatype id for each member */ if((memb0_tid = H5Tget_member_type(dtid, 0)) < 0) /* "field,1" */ - FAIL_STACK_ERROR + FAIL_STACK_ERROR if((memb1_tid = H5Tget_member_type(dtid, 1)) < 0) /* "field2." */ - FAIL_STACK_ERROR + FAIL_STACK_ERROR if((memb2_tid = H5Tget_member_type(dtid, 2)) < 0) /* "field\3" */ - FAIL_STACK_ERROR + FAIL_STACK_ERROR if((memb3_tid = H5Tget_member_type(dtid, 3)) < 0) /* "field4," */ - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Obtain size for VALID_ESC_FIELDS1: "field\\,1,field2\\..\\.a,field\\\\3,field4\\," */ if((dsize = H5LDget_dset_type_size(did, VALID_ESC_FIELDS1)) == 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Get the datatype size for "field\\,1" */ if((ck_dsize = H5Tget_size(memb0_tid)) == 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Add the datatype size for "field2\\..\\.a" */ if((memb_tid = H5Tget_member_type(memb1_tid, 0)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if((ck_dsize += H5Tget_size(memb_tid)) == 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5Tclose(memb_tid) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Add the datatype size for "field\\\\3" */ if((ck_dsize += H5Tget_size(memb2_tid)) == 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Add the datatype size for "field4\\," */ if((ck_dsize += H5Tget_size(memb3_tid)) == 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Verify case #2 */ VERIFY_EQUAL(dsize, ck_dsize) - /* Obtain datatype size for VALID_ESC_FIELDS2: - "field2\\..\\,b.a,field2\\..\\\\c,field4\\,.b\\," */ + /* Obtain datatype size for VALID_ESC_FIELDS2: + "field2\\..\\,b.a,field2\\..\\\\c,field4\\,.b\\," */ if((dsize = H5LDget_dset_type_size(did, VALID_ESC_FIELDS2)) == 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Get the datatype size for "field2\..,b.a" */ if((memb_tid = H5Tget_member_type(memb1_tid, 1)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if((memb_tid2 = H5Tget_member_type(memb_tid, 0)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if((ck_dsize = H5Tget_size(memb_tid2)) == 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5Tclose(memb_tid) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5Tclose(memb_tid2) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Add the datatype size for "field2\..\\c" */ if((memb_tid = H5Tget_member_type(memb1_tid, 2)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if((ck_dsize += H5Tget_size(memb_tid)) == 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5Tclose(memb_tid) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Add the datatype size for "field4\,.b\," */ if((memb_tid = H5Tget_member_type(memb3_tid, 1)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if((ck_dsize += H5Tget_size(memb_tid)) == 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5Tclose(memb_tid) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Verify case #3 */ VERIFY_EQUAL(dsize, ck_dsize) /* - * Verify failure for the following invalid nested fields: + * Verify failure for the following invalid nested fields: * INVALID_ESC_FIELDS1: "field2\..\,k.a,field2\..\\c,field4\,.k\," * INVALID_ESC_FIELDS2: "field2\..\,b.a,field2\..\\c,field4\,.b\,." * INVALID_ESC_FIELDS3: "field2\..\,,b.a,field2\..\\c,field4\,.b\," @@ -786,90 +786,90 @@ test_LD_size(const char *file) /* Closing */ if(H5Tclose(memb0_tid) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5Tclose(memb1_tid) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5Tclose(memb2_tid) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5Tclose(memb3_tid) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5Tclose(dtid) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5Dclose(did) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR if(H5Fclose(fid) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR PASSED(); return 0; error: H5E_BEGIN_TRY { - H5Tclose(memb0_tid); - H5Tclose(memb1_tid); - H5Tclose(memb2_tid); - H5Tclose(memb3_tid); - H5Tclose(memb_tid); - H5Tclose(memb_tid2); - H5Tclose(dtid); - H5Dclose(did); - H5Fclose(fid); + H5Tclose(memb0_tid); + H5Tclose(memb1_tid); + H5Tclose(memb2_tid); + H5Tclose(memb3_tid); + H5Tclose(memb_tid); + H5Tclose(memb_tid2); + H5Tclose(dtid); + H5Dclose(did); + H5Fclose(fid); } H5E_END_TRY; return(-1); } /* test_LD_size() */ - -/* + +/* ************************************************************************************** * Testing for the High Level public routine: H5LDget_dset_elmts() - * Verify failures when calling H5LDget_dset_elmts() with the following - * invalid conditions: + * Verify failures when calling H5LDget_dset_elmts() with the following + * invalid conditions: * - * A. DSET_TWO: two-dimensional dataset - * 1. CUR_DIMS and PREV_DIMS are NULL - * 2. PREV_DIMS is NULL - * 3. CUR_DIMS is NULL - * 4. FIELDS is nonnull but the dataset is not compound datatype - * 5. BUF is NULL - * 6. CUR_DIMS is not greater than PREV_DIMS + * A. DSET_TWO: two-dimensional dataset + * 1. CUR_DIMS and PREV_DIMS are NULL + * 2. PREV_DIMS is NULL + * 3. CUR_DIMS is NULL + * 4. FIELDS is nonnull but the dataset is not compound datatype + * 5. BUF is NULL + * 6. CUR_DIMS is not greater than PREV_DIMS * - * B. DSET_CMPD: one-dimensional dataset with compound type - * 1. Invalid dataset id - * 2. FIELDS are not valid members in the compound type + * B. DSET_CMPD: one-dimensional dataset with compound type + * 1. Invalid dataset id + * 2. FIELDS are not valid members in the compound type * ************************************************************************************** */ static int test_LD_elmts_invalid(const char *file) { - hid_t fid=-1; /* file identifier */ - hid_t did=-1; /* dataset identifier */ - hid_t sid=-1; /* dataspace identifier */ + hid_t fid=-1; /* file identifier */ + hid_t did=-1; /* dataset identifier */ + hid_t sid=-1; /* dataspace identifier */ hid_t invalid_id=-1; - int ret; /* return value */ - hsize_t cur_dims[2]; /* current dimension sizes of the dataset */ - hsize_t prev_dims[2]; /* previous dimension sizes of the dataset */ - char tbuf[2]; /* temporary buffer for testing */ - int ndims; /* # of dimension sizes */ - int i; /* local index variable */ + int ret; /* return value */ + hsize_t cur_dims[2]; /* current dimension sizes of the dataset */ + hsize_t prev_dims[2]; /* previous dimension sizes of the dataset */ + char tbuf[2]; /* temporary buffer for testing */ + int ndims; /* # of dimension sizes */ + int i; /* local index variable */ const char *filename = H5_get_srcdir_filename(file); - TESTING("H5LDget_dset_elmts on invalid conditions"); + HL_TESTING2("H5LDget_dset_elmts on invalid conditions"); /* Open the copied file */ if((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR - /* + /* * Testing two-dimensional dataset: DSET_TWO */ /* Open dataset: DSET_TWO */ if((did = H5Dopen2(fid, DSET_TWO, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Verify failure from case #1: cur_dims and prev_dims are NULL */ ret = H5LDget_dset_elmts(did, NULL, NULL, NULL, NULL); @@ -884,15 +884,15 @@ test_LD_elmts_invalid(const char *file) VERIFY_EQUAL(ret, FAIL) if((sid = H5Dget_space(did)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Get the # of dimensions and current dimension sizes */ if((ndims = H5Sget_simple_extent_dims(sid, cur_dims, NULL)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Set up valid cur_dims and prev_dims */ for(i = 0; i < ndims; i++) - prev_dims[i] = cur_dims[i] - 1; + prev_dims[i] = cur_dims[i] - 1; /* Verify failure from case #4: FIELDS is nonNULL but the dataset is not compound datatype */ ret = H5LDget_dset_elmts(did, prev_dims, cur_dims, "field1", tbuf); @@ -910,26 +910,26 @@ test_LD_elmts_invalid(const char *file) /* Close DSET_TWO */ if(H5Dclose(did) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR - /* + /* * Testing one-dimensional dataset with compound datatype: - * DSET_CMPD + * DSET_CMPD */ /* Verify failure from case #1: an invalid dataset id */ H5E_BEGIN_TRY { - ret = H5LDget_dset_elmts(invalid_id, prev_dims, cur_dims, NULL, tbuf); + ret = H5LDget_dset_elmts(invalid_id, prev_dims, cur_dims, NULL, tbuf); } H5E_END_TRY; VERIFY_EQUAL(ret, FAIL) /* Open dataset: DSET_CMPD */ if((did = H5Dopen2(fid, DSET_CMPD, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Retrieve the current dimension sizes */ if(H5LDget_dset_dims(did, cur_dims) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Set up valid cur_dims, prev_dims */ prev_dims[0] = cur_dims[0] - 1; @@ -940,118 +940,118 @@ test_LD_elmts_invalid(const char *file) /* Close DSET_CMPD */ if(H5Dclose(did) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Close the file */ if(H5Fclose(fid) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR PASSED(); return 0; error: H5E_BEGIN_TRY { - H5Sclose(sid); - H5Dclose(did); - H5Fclose(fid); + H5Sclose(sid); + H5Dclose(did); + H5Fclose(fid); } H5E_END_TRY; return(-1); } /* test_LD_elmts_invalid() */ - -/* + +/* ************************************************************************************** * Testing for the High Level public routine: H5LDget_dset_elmts() - * Verify elements retrieved via H5LDget_dset_elmts() are correct as expected - * when the dataset's dimension sizes are changed according to one_tests[]: + * Verify elements retrieved via H5LDget_dset_elmts() are correct as expected + * when the dataset's dimension sizes are changed according to one_tests[]: * - * one-dimensional dataset : - * DSET_ONE with NULL fields - * DSET_CMPD with fields: NULL, VALID_FIELDS1, VALID_FIELDS2 - * DSET_CMPD_ESC with fields: NULL, VALID_ESC_FIELDS1, VALID_ESC_FIELDS2 - * - * case #1. increase dims[0] - * case #2. decrease dims[0] (failure) - * case #3. same dims[0] (failure) - * case #4. decrease dims[0] (failure) - * case #5. increase dims[0] + * one-dimensional dataset : + * DSET_ONE with NULL fields + * DSET_CMPD with fields: NULL, VALID_FIELDS1, VALID_FIELDS2 + * DSET_CMPD_ESC with fields: NULL, VALID_ESC_FIELDS1, VALID_ESC_FIELDS2 + * + * case #1. increase dims[0] + * case #2. decrease dims[0] (failure) + * case #3. same dims[0] (failure) + * case #4. decrease dims[0] (failure) + * case #5. increase dims[0] * ************************************************************************************** */ static herr_t test_LD_elmts_one(const char *file, const char *dname, const char *fields) { - hid_t fid=-1; /* file identifier */ - hid_t did=-1; /* dataset identifier */ - hid_t dtype=-1; /* dataset's data type */ - hsize_t ext_dims[1]; /* extended dimension sizes of the dataset */ - hsize_t prev_dims[1]; /* previous dimension sizes of the dataset */ - int i, j; /* local index variable */ - int ret = 0; /* return value */ + hid_t fid=-1; /* file identifier */ + hid_t did=-1; /* dataset identifier */ + hid_t dtype=-1; /* dataset's data type */ + hsize_t ext_dims[1]; /* extended dimension sizes of the dataset */ + hsize_t prev_dims[1]; /* previous dimension sizes of the dataset */ + int i, j; /* local index variable */ + int ret = 0; /* return value */ - TESTING("H5LDget_dset_elmts: one-dimensional dataset"); + HL_TESTING2("H5LDget_dset_elmts: one-dimensional dataset"); /* Copy the test file */ if(h5_make_local_copy(file, COPY_FILENAME) < 0) TEST_ERROR for(i = 0; i < TEST_BUF_SIZE; i++) { - cbuf[i].field1 = i; - cbuf[i].field2.a = i; - cbuf[i].field2.b.a = i; - cbuf[i].field2.b.b = i; - cbuf[i].field2.b.c = i; - cbuf[i].field2.c = i; - cbuf[i].field3 = (double)i; - cbuf[i].field4.a = i; - cbuf[i].field4.b = i; - ibuf[i] = i; + cbuf[i].field1 = i; + cbuf[i].field2.a = i; + cbuf[i].field2.b.a = i; + cbuf[i].field2.b.b = i; + cbuf[i].field2.b.c = i; + cbuf[i].field2.c = i; + cbuf[i].field3 = (double)i; + cbuf[i].field4.a = i; + cbuf[i].field4.b = i; + ibuf[i] = i; } /* end for */ /* Open the copied file */ if((fid = H5Fopen(COPY_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Open the dataset */ if((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Get the dataset's data type */ if((dtype = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Get current dimension sizes before extending the dataset's dimension sizes */ if(H5LDget_dset_dims(did, prev_dims) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Loop through different variations of extending the dataset */ for(i = 0; i < ONE_NTESTS; i++) { - HDmemset(vbuf1, 0, TEST_BUF_SIZE * sizeof(test_valid_fields1)); - HDmemset(vbuf2, 0, TEST_BUF_SIZE * sizeof(test_valid_fields2)); - HDmemset(ccbuf, 0, TEST_BUF_SIZE * sizeof(set_t)); - HDmemset(iibuf, 0, TEST_BUF_SIZE * sizeof(int)); - - ext_dims[0] = (hsize_t)((int)prev_dims[0] + one_tests[i]); - - /* Change the dimension sizes of the dataset */ - if(H5Dset_extent(did, ext_dims) < 0) - FAIL_STACK_ERROR - - /* Initialize data */ - if(!HDstrcmp(dname, DSET_CMPD) || !HDstrcmp(dname, DSET_CMPD_ESC)) { - if(H5Dwrite(did, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, cbuf) < 0) - FAIL_STACK_ERROR - } /* end if */ + HDmemset(vbuf1, 0, TEST_BUF_SIZE * sizeof(test_valid_fields1)); + HDmemset(vbuf2, 0, TEST_BUF_SIZE * sizeof(test_valid_fields2)); + HDmemset(ccbuf, 0, TEST_BUF_SIZE * sizeof(set_t)); + HDmemset(iibuf, 0, TEST_BUF_SIZE * sizeof(int)); + + ext_dims[0] = (hsize_t)((int)prev_dims[0] + one_tests[i]); + + /* Change the dimension sizes of the dataset */ + if(H5Dset_extent(did, ext_dims) < 0) + FAIL_STACK_ERROR + + /* Initialize data */ + if(!HDstrcmp(dname, DSET_CMPD) || !HDstrcmp(dname, DSET_CMPD_ESC)) { + if(H5Dwrite(did, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, cbuf) < 0) + FAIL_STACK_ERROR + } /* end if */ else if(!HDstrcmp(dname, DSET_ONE)) { - if(H5Dwrite(did, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, ibuf) < 0) - FAIL_STACK_ERROR - } /* end if */ - - /* There are changes in dimension sizes */ - if(one_tests[i] > 0) { - if(!HDstrcmp(dname, DSET_CMPD) || !HDstrcmp(dname, DSET_CMPD_ESC)) { - if(fields) { + if(H5Dwrite(did, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, ibuf) < 0) + FAIL_STACK_ERROR + } /* end if */ + + /* There are changes in dimension sizes */ + if(one_tests[i] > 0) { + if(!HDstrcmp(dname, DSET_CMPD) || !HDstrcmp(dname, DSET_CMPD_ESC)) { + if(fields) { if(!HDstrcmp(fields, VALID_FIELDS1) || !HDstrcmp(fields, VALID_ESC_FIELDS1)) { /* Retrieve the elmemts in BUF */ if(H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, vbuf1) < 0) @@ -1067,24 +1067,24 @@ test_LD_elmts_one(const char *file, const char *dname, const char *fields) VERIFY_ELMTS_VALID2(vbuf2[j], cbuf[prev_dims[0] + (hsize_t)j]) } /* end else-if */ else - TEST_ERROR - } /* end if */ + TEST_ERROR + } /* end if */ else { - /* Retrieve the elmemts in BUF */ - if(H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, ccbuf) < 0) - TEST_ERROR - for(j = 0; j < one_tests[i]; j++) - VERIFY_ELMTS_ALL(ccbuf[j], cbuf[prev_dims[0] + (hsize_t)j]) - } /* end else-if */ - } /* end if */ + /* Retrieve the elmemts in BUF */ + if(H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, ccbuf) < 0) + TEST_ERROR + for(j = 0; j < one_tests[i]; j++) + VERIFY_ELMTS_ALL(ccbuf[j], cbuf[prev_dims[0] + (hsize_t)j]) + } /* end else-if */ + } /* end if */ else { - /* Retrieve the elmemts in BUF */ - if(H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, iibuf) < 0) - TEST_ERROR - for(j = 0; j < one_tests[i]; j++) - VERIFY_EQUAL(iibuf[j], ibuf[prev_dims[0] + (hsize_t)j]) - } /* end else */ - } /* end if */ + /* Retrieve the elmemts in BUF */ + if(H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, iibuf) < 0) + TEST_ERROR + for(j = 0; j < one_tests[i]; j++) + VERIFY_EQUAL(iibuf[j], ibuf[prev_dims[0] + (hsize_t)j]) + } /* end else */ + } /* end if */ else { /* Verify failure when changes between prev_dims and ext_dims are same/decrease */ ret = H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, iibuf); @@ -1108,56 +1108,56 @@ test_LD_elmts_one(const char *file, const char *dname, const char *fields) error: H5E_BEGIN_TRY { - H5Tclose(dtype); - H5Dclose(did); - H5Fclose(fid); + H5Tclose(dtype); + H5Dclose(did); + H5Fclose(fid); } H5E_END_TRY; return(-1); } /* test_LD_elmts_one() */ - + /* ************************************************************************************** * - * Helper routine to verify elements of a 2-dimensional dataset - * _ldbuf contains the elements retrieved via H5LDget_dset_elmts() - * _buf contains the data written to the dataset + * Helper routine to verify elements of a 2-dimensional dataset + * _ldbuf contains the elements retrieved via H5LDget_dset_elmts() + * _buf contains the data written to the dataset * - * e.g. prev_dims[2] = {4, 6}; ext_dims[2] = {6, 10} - * elements marked in 'v' in _buf are compared to elements in _ldbuf - * 0 1 2 3 4 5 | 6 7 8 9 - * 0 | v v v v - * 1 | v v v v - * 2 | v v v v - * 3 | v v v v - * --------------------- - * 4 v v v v v v v v v v - * 5 v v v v v v v v v v + * e.g. prev_dims[2] = {4, 6}; ext_dims[2] = {6, 10} + * elements marked in 'v' in _buf are compared to elements in _ldbuf + * 0 1 2 3 4 5 | 6 7 8 9 + * 0 | v v v v + * 1 | v v v v + * 2 | v v v v + * 3 | v v v v + * --------------------- + * 4 v v v v v v v v v v + * 5 v v v v v v v v v v * ************************************************************************************** */ static herr_t verify_elmts_two(int type, hsize_t *ext_dims, hsize_t *prev_dims, void *_ldbuf, void *_buf) { - int k, m; /* Local index variable */ + int k, m; /* Local index variable */ - k = 0; + k = 0; for(m = 0; m < (int)ext_dims[0]; m++) { - int n, ind; /* Local index variable */ - - ind = m * (int)ext_dims[1]; - if(m < (int)prev_dims[0]) { - for(n = (int)prev_dims[1]; n < (int)ext_dims[1]; n++) { - VERIFY_ELMTS(type, k, ind, _ldbuf, _buf) - ++k; - } /* end for */ - } /* end if */ - else { - for(n = 0; n < (int)ext_dims[1]; n++) { - VERIFY_ELMTS(type, k, ind, _ldbuf, _buf) - ++k; - } /* end for */ - } /* end else */ + int n, ind; /* Local index variable */ + + ind = m * (int)ext_dims[1]; + if(m < (int)prev_dims[0]) { + for(n = (int)prev_dims[1]; n < (int)ext_dims[1]; n++) { + VERIFY_ELMTS(type, k, ind, _ldbuf, _buf) + ++k; + } /* end for */ + } /* end if */ + else { + for(n = 0; n < (int)ext_dims[1]; n++) { + VERIFY_ELMTS(type, k, ind, _ldbuf, _buf) + ++k; + } /* end for */ + } /* end else */ } /* end for */ return(0); @@ -1166,106 +1166,106 @@ error: return(-1); } /* verify_elmts_two() */ - -/* + +/* ************************************************************************************** * Testing for the High Level public routine: H5LDget_dset_elmts() - * Verify elements retrieved via H5LDget_dset_elmts() are correct as expected when - * the datset's dimension sizes are changed accordingly to two_tests[]: + * Verify elements retrieved via H5LDget_dset_elmts() are correct as expected when + * the datset's dimension sizes are changed accordingly to two_tests[]: * - * two-dimensional dataset: DSET_TWO with NULL fields - * DSET_CMPD_TWO with fields: NULL, VALID_FIELDS1, VALID_FIELDS2 + * two-dimensional dataset: DSET_TWO with NULL fields + * DSET_CMPD_TWO with fields: NULL, VALID_FIELDS1, VALID_FIELDS2 + * + * dims[0] dims[1] + * ------- ------- + * case #1: increase increase + * case #2: increase decrease + * case #3: increase same + * case #4: decrease increase + * case #5: decrease decrease (failure) + * case #6: decrease same (failure) + * case #7: same increase + * case #8: same decrease (failure) + * case #9: same same (failure) * - * dims[0] dims[1] - * ------- ------- - * case #1: increase increase - * case #2: increase decrease - * case #3: increase same - * case #4: decrease increase - * case #5: decrease decrease (failure) - * case #6: decrease same (failure) - * case #7: same increase - * case #8: same decrease (failure) - * case #9: same same (failure) - * ************************************************************************************** */ static herr_t test_LD_elmts_two(const char *file, const char *dname, const char *fields) { - hid_t fid=-1; /* file identifier */ - hid_t did=-1; /* dataset identifier */ - hid_t dtype=-1; /* dataset's data type */ - hsize_t ext_dims[2]; /* extended dimension sizes of the dataset */ - hsize_t prev_dims[2]; /* previous dimension sizes of the dataset */ - int i; /* local index variable */ - int ret = 0; /* return value */ + hid_t fid=-1; /* file identifier */ + hid_t did=-1; /* dataset identifier */ + hid_t dtype=-1; /* dataset's data type */ + hsize_t ext_dims[2]; /* extended dimension sizes of the dataset */ + hsize_t prev_dims[2]; /* previous dimension sizes of the dataset */ + int i; /* local index variable */ + int ret = 0; /* return value */ - TESTING("H5LDget_dset_elmts: two-dimensional dataset"); + HL_TESTING2("H5LDget_dset_elmts: two-dimensional dataset"); /* Copy the test file */ if(h5_make_local_copy(file, COPY_FILENAME) < 0) TEST_ERROR for(i = 0; i < TEST_BUF_SIZE; i++) { - cbuf[i].field1 = i; - cbuf[i].field2.a = i; - cbuf[i].field2.b.a = i; - cbuf[i].field2.b.b = i; - cbuf[i].field2.b.c = i; - cbuf[i].field2.c = i; - cbuf[i].field3 = (double)i; - cbuf[i].field4.a = i; - cbuf[i].field4.b = i; - ibuf[i] = i; + cbuf[i].field1 = i; + cbuf[i].field2.a = i; + cbuf[i].field2.b.a = i; + cbuf[i].field2.b.b = i; + cbuf[i].field2.b.c = i; + cbuf[i].field2.c = i; + cbuf[i].field3 = (double)i; + cbuf[i].field4.a = i; + cbuf[i].field4.b = i; + ibuf[i] = i; } /* end for */ /* Open the copied file */ if((fid = H5Fopen(COPY_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Open the dataset */ if((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Get the dataset's data type */ if((dtype = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Get current dimension sizes before extending the dataset's dimension sizes */ if(H5LDget_dset_dims(did, prev_dims) < 0) - FAIL_STACK_ERROR + FAIL_STACK_ERROR /* Loop through different variations of extending the dataset */ for(i = 0; i < TWO_NTESTS; i++) { - HDmemset(vbuf1, 0, TEST_BUF_SIZE * sizeof(test_valid_fields1)); - HDmemset(vbuf2, 0, TEST_BUF_SIZE * sizeof(test_valid_fields2)); - HDmemset(ccbuf, 0, TEST_BUF_SIZE * sizeof(set_t)); - HDmemset(iibuf, 0, TEST_BUF_SIZE * sizeof(int)); - - ext_dims[0] = (hsize_t)((int)prev_dims[0] + two_tests[i][0]); - ext_dims[1] = (hsize_t)((int)prev_dims[1] + two_tests[i][1]); - - /* Change the dimension sizes of the dataset */ - if(H5Dset_extent(did, ext_dims) < 0) - FAIL_STACK_ERROR - - /* Initialize data */ - if(!HDstrcmp(dname, DSET_CMPD_TWO)) { - if(H5Dwrite(did, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, cbuf) < 0) - FAIL_STACK_ERROR - } /* end if */ + HDmemset(vbuf1, 0, TEST_BUF_SIZE * sizeof(test_valid_fields1)); + HDmemset(vbuf2, 0, TEST_BUF_SIZE * sizeof(test_valid_fields2)); + HDmemset(ccbuf, 0, TEST_BUF_SIZE * sizeof(set_t)); + HDmemset(iibuf, 0, TEST_BUF_SIZE * sizeof(int)); + + ext_dims[0] = (hsize_t)((int)prev_dims[0] + two_tests[i][0]); + ext_dims[1] = (hsize_t)((int)prev_dims[1] + two_tests[i][1]); + + /* Change the dimension sizes of the dataset */ + if(H5Dset_extent(did, ext_dims) < 0) + FAIL_STACK_ERROR + + /* Initialize data */ + if(!HDstrcmp(dname, DSET_CMPD_TWO)) { + if(H5Dwrite(did, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, cbuf) < 0) + FAIL_STACK_ERROR + } /* end if */ else if(!HDstrcmp(dname, DSET_TWO)) { - if(H5Dwrite(did, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, ibuf) < 0) - FAIL_STACK_ERROR - } /* end else-if */ + if(H5Dwrite(did, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, ibuf) < 0) + FAIL_STACK_ERROR + } /* end else-if */ else TEST_ERROR - /* There are changes in dimension sizes */ - if(two_tests[i][0] > 0 || two_tests[i][1] > 0) { - if(!HDstrcmp(dname, DSET_CMPD_TWO)) { - if(fields) { + /* There are changes in dimension sizes */ + if(two_tests[i][0] > 0 || two_tests[i][1] > 0) { + if(!HDstrcmp(dname, DSET_CMPD_TWO)) { + if(fields) { if(!HDstrcmp(fields, VALID_FIELDS1) || !HDstrcmp(fields, VALID_ESC_FIELDS1)) { /* Retrieve the elmemts in BUF */ if(H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, vbuf1) < 0) @@ -1282,37 +1282,37 @@ test_LD_elmts_two(const char *file, const char *dname, const char *fields) } /* end else-if */ else TEST_ERROR - } /* end if */ + } /* end if */ else { - /* Retrieve the elmemts in BUF */ - if(H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, ccbuf) < 0) - TEST_ERROR - if(verify_elmts_two(TWO_CMPD_NULL, ext_dims, prev_dims, ccbuf, cbuf) < 0) - TEST_ERROR - } /* end else */ - } /* end if */ + /* Retrieve the elmemts in BUF */ + if(H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, ccbuf) < 0) + TEST_ERROR + if(verify_elmts_two(TWO_CMPD_NULL, ext_dims, prev_dims, ccbuf, cbuf) < 0) + TEST_ERROR + } /* end else */ + } /* end if */ else { /* DSET_TWO */ - /* Retrieve the elmemts in BUF */ - if(H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, iibuf) < 0) - TEST_ERROR - if(verify_elmts_two(TWO_NONE, ext_dims, prev_dims, iibuf, ibuf) < 0) - TEST_ERROR - } /* end else */ - } /* end if */ + /* Retrieve the elmemts in BUF */ + if(H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, iibuf) < 0) + TEST_ERROR + if(verify_elmts_two(TWO_NONE, ext_dims, prev_dims, iibuf, ibuf) < 0) + TEST_ERROR + } /* end else */ + } /* end if */ else { - /* Verify failure when changes between prev_dims and ext_dims are same/decrease */ - ret = H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, iibuf); - VERIFY_EQUAL(ret, FAIL) - } /* end else */ + /* Verify failure when changes between prev_dims and ext_dims are same/decrease */ + ret = H5LDget_dset_elmts(did, prev_dims, ext_dims, fields, iibuf); + VERIFY_EQUAL(ret, FAIL) + } /* end else */ } /* end for */ /* Closing */ if(H5Tclose(dtype) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(H5Dclose(did) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(H5Fclose(fid) < 0) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; /* Remove the copied file */ HDremove(COPY_FILENAME); @@ -1322,16 +1322,16 @@ test_LD_elmts_two(const char *file, const char *dname, const char *fields) error: H5E_BEGIN_TRY { - H5Tclose(dtype); - H5Dclose(did); - H5Fclose(fid); + H5Tclose(dtype); + H5Dclose(did); + H5Fclose(fid); } H5E_END_TRY; return(-1); } /* test_LD_elmts_two() */ /* - * Tests for High Level routines: - * H5LDget_dset_dims(), H5LDget_dset_elmts, H5LDget_dset_type_size() + * Tests for High Level routines: + * H5LDget_dset_dims(), H5LDget_dset_elmts, H5LDget_dset_type_size() */ int main(void) { @@ -1339,60 +1339,60 @@ int main(void) /* Set up temporary buffers for tests: test_LD_elmts_one() & test_LD_elmts_two() */ if(NULL == (ibuf = (int *)HDmalloc(sizeof(int) * TEST_BUF_SIZE))) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(NULL == (iibuf = (int *)HDmalloc(sizeof(int) * TEST_BUF_SIZE))) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(NULL == (cbuf = (set_t *)HDmalloc(sizeof(set_t) * TEST_BUF_SIZE))) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(NULL == (ccbuf = (set_t *)HDmalloc(sizeof(set_t) * TEST_BUF_SIZE))) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(NULL == (vbuf1 = (test_valid_fields1 *)HDmalloc(sizeof(test_valid_fields1) * TEST_BUF_SIZE))) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; if(NULL == (vbuf2 = (test_valid_fields2 *)HDmalloc(sizeof(test_valid_fields2) * TEST_BUF_SIZE))) - FAIL_STACK_ERROR; + FAIL_STACK_ERROR; - /* - * Testing H5LDget_dset_dims() + /* + * Testing H5LDget_dset_dims() */ nerrors += test_LD_dims_params(FILE); nerrors += test_LD_dims(FILE); - /* - * Testing H5LDget_dset_type_size() + /* + * Testing H5LDget_dset_type_size() */ nerrors += test_LD_size(FILE); - /* + /* * Testing invalid conditions for H5LDget_dset_elmts() */ nerrors += test_LD_elmts_invalid(FILE); - /* - * Testing H5LDget_dset_elmts(): - * 1-dimensional dataset + /* + * Testing H5LDget_dset_elmts(): + * 1-dimensional dataset */ nerrors += test_LD_elmts_one(FILE, DSET_ONE, NULL); - /* - * Testing H5LDget_dset_elmts(): - * 1-dimensional dataset w/ compound datatype + /* + * Testing H5LDget_dset_elmts(): + * 1-dimensional dataset w/ compound datatype */ nerrors += test_LD_elmts_one(FILE, DSET_CMPD, NULL); nerrors += test_LD_elmts_one(FILE, DSET_CMPD, VALID_FIELDS1); nerrors += test_LD_elmts_one(FILE, DSET_CMPD, VALID_FIELDS2); - /* + /* * Testing H5LDget_dset_elmts(): - * 1-dimensional dataset with compound datatype and - * member names with escape/separator characters + * 1-dimensional dataset with compound datatype and + * member names with escape/separator characters */ nerrors += test_LD_elmts_one(FILE, DSET_CMPD_ESC, NULL); nerrors += test_LD_elmts_one(FILE, DSET_CMPD_ESC, VALID_ESC_FIELDS1); nerrors += test_LD_elmts_one(FILE, DSET_CMPD_ESC, VALID_ESC_FIELDS2); - /* + /* * Testing H5LDget_dset_elmts() for 2-dimensional datasets */ nerrors += test_LD_elmts_two(FILE, DSET_TWO, NULL); @@ -1416,7 +1416,7 @@ int main(void) /* check for errors */ if(nerrors) - goto error; + goto error; puts("All tests for H5LD high level routines passed."); diff --git a/hl/test/test_lite.c b/hl/test/test_lite.c index 51ab72b..e6b4668 100644 --- a/hl/test/test_lite.c +++ b/hl/test/test_lite.c @@ -87,7 +87,7 @@ static int test_dsets( void ) *------------------------------------------------------------------------- */ - TESTING("H5LTmake_dataset"); + HL_TESTING2("H5LTmake_dataset"); /* Make dataset */ if ( H5LTmake_dataset( file_id, DSET0_NAME, rank, dims, H5T_NATIVE_INT, data_int_in ) < 0 ) @@ -118,7 +118,7 @@ static int test_dsets( void ) *------------------------------------------------------------------------- */ - TESTING("H5LTread_dataset"); + HL_TESTING2("H5LTread_dataset"); if ( H5LTread_dataset( file_id, DSET0_NAME, H5T_NATIVE_INT, data_int_out ) < 0 ) goto out; @@ -143,7 +143,7 @@ static int test_dsets( void ) *------------------------------------------------------------------------- */ - TESTING("H5LTmake_dataset_char"); + HL_TESTING2("H5LTmake_dataset_char"); /* Make dataset char */ if ( H5LTmake_dataset_char( file_id, DSET1_NAME, rank, dims, data_char_in ) < 0 ) @@ -179,7 +179,7 @@ static int test_dsets( void ) *------------------------------------------------------------------------- */ - TESTING("H5LTmake_dataset_short"); + HL_TESTING2("H5LTmake_dataset_short"); /* Make dataset short */ if ( H5LTmake_dataset_short( file_id, DSET2_NAME, rank, dims, data_short_in ) < 0 ) @@ -214,7 +214,7 @@ static int test_dsets( void ) *------------------------------------------------------------------------- */ - TESTING("H5LTmake_dataset_int"); + HL_TESTING2("H5LTmake_dataset_int"); /* Make dataset int */ if ( H5LTmake_dataset_int( file_id, DSET3_NAME, rank, dims, data_int_in ) < 0 ) @@ -250,7 +250,7 @@ static int test_dsets( void ) *------------------------------------------------------------------------- */ - TESTING("H5LTmake_dataset_long"); + HL_TESTING2("H5LTmake_dataset_long"); /* Make dataset long */ if ( H5LTmake_dataset_long( file_id, DSET4_NAME, rank, dims, data_long_in ) < 0 ) @@ -286,7 +286,7 @@ static int test_dsets( void ) *------------------------------------------------------------------------- */ - TESTING("H5LTmake_dataset_float"); + HL_TESTING2("H5LTmake_dataset_float"); /* Make dataset float */ if ( H5LTmake_dataset_float( file_id, DSET5_NAME, rank, dims, data_float_in ) < 0 ) @@ -322,7 +322,7 @@ static int test_dsets( void ) *------------------------------------------------------------------------- */ - TESTING("H5LTmake_dataset_double"); + HL_TESTING2("H5LTmake_dataset_double"); /* Make dataset double */ if ( H5LTmake_dataset_double( file_id, DSET6_NAME, rank, dims, data_double_in ) < 0 ) @@ -358,7 +358,7 @@ static int test_dsets( void ) *------------------------------------------------------------------------- */ - TESTING("H5LTmake_dataset_string"); + HL_TESTING2("H5LTmake_dataset_string"); /* Make dataset string */ if ( H5LTmake_dataset_string(file_id,DSET7_NAME,data_string_in) < 0 ) @@ -517,7 +517,7 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) *------------------------------------------------------------------------- */ - TESTING("H5LTset_attribute_string"); + HL_TESTING2("H5LTset_attribute_string"); /* Set the attribute */ if ( H5LTset_attribute_string( loc_id, obj_name, ATTR1_NAME, attr_str_in ) < 0 ) @@ -530,7 +530,7 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) *------------------------------------------------------------------------- */ - TESTING("H5LTget_attribute_string"); + HL_TESTING2("H5LTget_attribute_string"); /* Get the attribute */ @@ -550,7 +550,7 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) *------------------------------------------------------------------------- */ - TESTING("H5LTset_attribute_char"); + HL_TESTING2("H5LTset_attribute_char"); /* Set the attribute */ if ( H5LTset_attribute_char( loc_id, obj_name, ATTR2_NAME, attr_char_in, (size_t)5 ) < 0 ) @@ -563,7 +563,7 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) *------------------------------------------------------------------------- */ - TESTING("H5LTget_attribute_char"); + HL_TESTING2("H5LTget_attribute_char"); /* Get the attribute */ if ( H5LTget_attribute_char( loc_id, obj_name, ATTR2_NAME, attr_char_out ) < 0 ) @@ -594,7 +594,7 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) *------------------------------------------------------------------------- */ - TESTING("H5LTset_attribute_short"); + HL_TESTING2("H5LTset_attribute_short"); /* Set the attribute */ if ( H5LTset_attribute_short( loc_id, obj_name, ATTR3_NAME, attr_short_in, (size_t)5 ) < 0 ) @@ -608,7 +608,7 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) *------------------------------------------------------------------------- */ - TESTING("H5LTget_attribute_short"); + HL_TESTING2("H5LTget_attribute_short"); /* Get the attribute */ if ( H5LTget_attribute_short( loc_id, obj_name, ATTR3_NAME, attr_short_out ) < 0 ) @@ -640,7 +640,7 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) *------------------------------------------------------------------------- */ - TESTING("H5LTset_attribute_int"); + HL_TESTING2("H5LTset_attribute_int"); /* Set the attribute */ if ( H5LTset_attribute_int( loc_id, obj_name, ATTR4_NAME, attr_int_in, (size_t)5 ) < 0 ) @@ -661,7 +661,7 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) *------------------------------------------------------------------------- */ - TESTING("H5LTget_attribute_int"); + HL_TESTING2("H5LTget_attribute_int"); /* Get the attribute */ if ( H5LTget_attribute_int( loc_id, obj_name, ATTR4_NAME, attr_int_out ) < 0 ) @@ -712,7 +712,7 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) *------------------------------------------------------------------------- */ - TESTING("H5LTset_attribute_long"); + HL_TESTING2("H5LTset_attribute_long"); /* Set the attribute */ if ( H5LTset_attribute_long( loc_id, obj_name, ATTR5_NAME, attr_long_in, (size_t)5 ) < 0 ) @@ -725,7 +725,7 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) *------------------------------------------------------------------------- */ - TESTING("H5LTget_attribute_long"); + HL_TESTING2("H5LTget_attribute_long"); /* Get the attribute */ if ( H5LTget_attribute_long( loc_id, obj_name, ATTR5_NAME, attr_long_out ) < 0 ) @@ -756,7 +756,7 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) *------------------------------------------------------------------------- */ - TESTING("H5LTset_attribute_uchar"); + HL_TESTING2("H5LTset_attribute_uchar"); /* Set the attribute */ if ( H5LTset_attribute_uchar( loc_id, obj_name, ATTR6_NAME, attr_uchar_in, (size_t)5 ) < 0 ) @@ -769,7 +769,7 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) *------------------------------------------------------------------------- */ - TESTING("H5LTget_attribute_uchar"); + HL_TESTING2("H5LTget_attribute_uchar"); /* Get the attribute */ if ( H5LTget_attribute_uchar( loc_id, obj_name, ATTR6_NAME, attr_uchar_out ) < 0 ) @@ -800,7 +800,7 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) *------------------------------------------------------------------------- */ - TESTING("H5LTset_attribute_ushort"); + HL_TESTING2("H5LTset_attribute_ushort"); /* Set the attribute */ if ( H5LTset_attribute_ushort( loc_id, obj_name, ATTR7_NAME, attr_ushort_in, (size_t)5 ) < 0 ) @@ -814,7 +814,7 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) *------------------------------------------------------------------------- */ - TESTING("H5LTget_attribute_ushort"); + HL_TESTING2("H5LTget_attribute_ushort"); /* Get the attribute */ if ( H5LTget_attribute_ushort( loc_id, obj_name, ATTR7_NAME, attr_ushort_out ) < 0 ) @@ -846,7 +846,7 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) *------------------------------------------------------------------------- */ - TESTING("H5LTset_attribute_uint"); + HL_TESTING2("H5LTset_attribute_uint"); /* Set the attribute */ if ( H5LTset_attribute_uint( loc_id, obj_name, ATTR8_NAME, attr_uint_in, (size_t)5 ) < 0 ) @@ -859,7 +859,7 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) *------------------------------------------------------------------------- */ - TESTING("H5LTget_attribute_uint"); + HL_TESTING2("H5LTget_attribute_uint"); /* Get the attribute */ if ( H5LTget_attribute_uint( loc_id, obj_name, ATTR8_NAME, attr_uint_out ) < 0 ) @@ -890,7 +890,7 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) *------------------------------------------------------------------------- */ - TESTING("H5LTset_attribute_ulong"); + HL_TESTING2("H5LTset_attribute_ulong"); /* Set the attribute */ if ( H5LTset_attribute_ulong( loc_id, obj_name, ATTR9_NAME, attr_ulong_in, (size_t)5 ) < 0 ) @@ -903,7 +903,7 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) *------------------------------------------------------------------------- */ - TESTING("H5LTget_attribute_ulong"); + HL_TESTING2("H5LTget_attribute_ulong"); /* Get the attribute */ if ( H5LTget_attribute_ulong( loc_id, obj_name, ATTR9_NAME, attr_ulong_out ) < 0 ) @@ -935,7 +935,7 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) *------------------------------------------------------------------------- */ - TESTING("H5LTset_attribute_float"); + HL_TESTING2("H5LTset_attribute_float"); /* Set the attribute */ if ( H5LTset_attribute_float( loc_id, obj_name, ATTR10_NAME, attr_float_in, (size_t)5 ) < 0 ) @@ -948,7 +948,7 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) *------------------------------------------------------------------------- */ - TESTING("H5LTget_attribute_float"); + HL_TESTING2("H5LTget_attribute_float"); /* Get the attribute */ @@ -980,7 +980,7 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) *------------------------------------------------------------------------- */ - TESTING("H5LTset_attribute_double"); + HL_TESTING2("H5LTset_attribute_double"); /* Set the attribute */ if ( H5LTset_attribute_double( loc_id, obj_name, ATTR11_NAME, attr_double_in, (size_t)5 ) < 0 ) @@ -993,7 +993,7 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) *------------------------------------------------------------------------- */ - TESTING("H5LTget_attribute_double"); + HL_TESTING2("H5LTget_attribute_double"); /* Get the attribute */ if ( H5LTget_attribute_double( loc_id, obj_name, ATTR11_NAME, attr_double_out ) < 0 ) @@ -1026,7 +1026,7 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) */ - TESTING("H5LTget_attribute_ndims"); + HL_TESTING2("H5LTget_attribute_ndims"); if ( H5LTget_attribute_ndims( loc_id, obj_name, ATTR2_NAME, &rank_out ) < 0 ) return -1; @@ -1042,7 +1042,7 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) *------------------------------------------------------------------------- */ - TESTING("H5LTget_attribute_info"); + HL_TESTING2("H5LTget_attribute_info"); if(NULL==(dims_out = (hsize_t*) HDmalloc( sizeof(hsize_t) * (size_t)rank_out ))) return -1; @@ -1079,7 +1079,7 @@ static int test_integers(void) char* dt_str; size_t str_len; - TESTING3("\n text for integer types"); + HL_TESTING3("\n text for integer types"); if((dtype = H5LTtext_to_dtype("H5T_NATIVE_INT\n", H5LT_DDL))<0) goto out; @@ -1136,7 +1136,7 @@ static int test_fps(void) char* dt_str; size_t str_len; - TESTING3(" text for floating-point types"); + HL_TESTING3(" text for floating-point types"); if((dtype = H5LTtext_to_dtype("H5T_NATIVE_LDOUBLE\n", H5LT_DDL))<0) goto out; @@ -1197,7 +1197,7 @@ static int test_strings(void) char* dt_str = NULL; size_t str_len; - TESTING3(" text for string types"); + HL_TESTING3(" text for string types"); if((dtype = H5LTtext_to_dtype("H5T_STRING { STRSIZE 13; STRPAD H5T_STR_NULLTERM; CSET H5T_CSET_ASCII; CTYPE H5T_C_S1; }", H5LT_DDL))<0) goto out; @@ -1328,7 +1328,7 @@ static int test_opaques(void) char* dt_str; size_t str_len; - TESTING3(" text for opaque types"); + HL_TESTING3(" text for opaque types"); if((dtype = H5LTtext_to_dtype("H5T_OPAQUE { OPQ_SIZE 19; OPQ_TAG \"This is a tag for opaque type\"; }", H5LT_DDL))<0) goto out; @@ -1385,7 +1385,7 @@ static int test_enums(void) char* dt_str; size_t str_len; - TESTING3(" text for enum types"); + HL_TESTING3(" text for enum types"); if((dtype = H5LTtext_to_dtype("H5T_ENUM { H5T_STD_I32LE; \"RED\" 5; \"GREEN\" 6; \"BLUE\" 7; \"WHITE\" 8; }", H5LT_DDL))<0) goto out; @@ -1457,7 +1457,7 @@ static int test_variables(void) char* dt_str; size_t str_len; - TESTING3(" text for variable types"); + HL_TESTING3(" text for variable types"); if((dtype = H5LTtext_to_dtype("H5T_VLEN { H5T_NATIVE_CHAR }\n", H5LT_DDL))<0) goto out; @@ -1518,7 +1518,7 @@ static int test_arrays(void) char* dt_str; size_t str_len; - TESTING3(" text for array types"); + HL_TESTING3(" text for array types"); if((dtype = H5LTtext_to_dtype("H5T_ARRAY { [5][7][13] H5T_ARRAY { [17][19] H5T_COMPOUND { H5T_STD_I8BE \"arr_compound_1\"; H5T_STD_I32BE \"arr_compound_2\"; } } }", H5LT_DDL))<0) goto out; @@ -1579,7 +1579,7 @@ static int test_compounds(void) char* dt_str; size_t str_len; - TESTING3(" text for compound types"); + HL_TESTING3(" text for compound types"); if((dtype = H5LTtext_to_dtype("H5T_COMPOUND { H5T_STD_I16BE \"one_field\" : 2; H5T_STD_U8LE \"two_field\" : 6; }", H5LT_DDL))<0) goto out; @@ -1673,7 +1673,7 @@ static int test_compound_bug(void) " } } \"sub\" : 8;\n" "}\n"; - TESTING3(" text for compound type of bug fix"); + HL_TESTING3(" text for compound type of bug fix"); if((dtype = H5LTtext_to_dtype(text, H5LT_DDL))<0) goto out; @@ -1765,7 +1765,7 @@ static int test_complicated_compound(void) size_t size = 1024; const char *filename = H5_get_srcdir_filename(INPUT_FILE); - TESTING3(" text for complicated compound types"); + HL_TESTING3(" text for complicated compound types"); /* Open input file */ fp = HDfopen(filename, "r"); @@ -1834,7 +1834,7 @@ out: */ static int test_text_dtype(void) { - TESTING("H5LTtext_to_dtype"); + HL_TESTING2("H5LTtext_to_dtype"); if(test_integers()<0) goto out; @@ -1882,7 +1882,7 @@ static int test_valid_path(void) htri_t path_valid; const char *data_string_in = "test"; - TESTING("H5LTpath_valid"); + HL_TESTING2("H5LTpath_valid"); /* Create a new file using default properties. */ diff --git a/hl/test/test_packet.c b/hl/test/test_packet.c index 7003b26..61aebc7 100644 --- a/hl/test/test_packet.c +++ b/hl/test/test_packet.c @@ -178,7 +178,7 @@ static int test_create_close(hid_t fid) hid_t table; hid_t part_t; - TESTING("H5PTcreate_fl and H5PTclose"); + HL_TESTING2("H5PTcreate_fl and H5PTclose"); /* Create a datatype for the particle struct */ part_t = make_particle_type(); @@ -188,11 +188,11 @@ static int test_create_close(hid_t fid) /* Create the table */ table = H5PTcreate_fl(fid, PT_NAME, part_t, (hsize_t)100, -1); if (H5Tclose(part_t) < 0) - goto error; + goto error; if( H5PTis_valid(table) < 0) - goto error; + goto error; if( H5PTis_varlen(table) != 0) - goto error; + goto error; /* Close the table */ err = H5PTclose(table); @@ -219,7 +219,7 @@ static int test_open(hid_t fid) herr_t err; hid_t table; - TESTING("H5PTopen"); + HL_TESTING2("H5PTopen"); /* Open the table */ table = H5PTopen(fid, PT_NAME); @@ -255,7 +255,7 @@ static int test_append(hid_t fid) hid_t table; hsize_t count = 0; - TESTING("H5PTappend"); + HL_TESTING2("H5PTappend"); /* Open the table */ table = H5PTopen(fid, PT_NAME); @@ -322,7 +322,7 @@ static int test_read(hid_t fid) particle_t readBuf[NRECORDS]; size_t c; - TESTING("H5PTread_packets"); + HL_TESTING2("H5PTread_packets"); /* Open the table */ table = H5PTopen(fid, PT_NAME); @@ -383,7 +383,7 @@ static int test_get_next(hid_t fid) particle_t readBuf2[NRECORDS]; size_t c; - TESTING("H5PTget_next"); + HL_TESTING2("H5PTget_next"); /* Open the table */ table = H5PTopen(fid, PT_NAME); @@ -454,7 +454,7 @@ static int test_big_table(hid_t fid) particle_t readPart; hsize_t count; - TESTING("large packet table"); + HL_TESTING2("large packet table"); /* Create a datatype for the particle struct */ part_t = make_particle_type(); @@ -528,7 +528,7 @@ static int test_opaque(hid_t fid) size_t c; particle_t readBuf[NRECORDS]; - TESTING("opaque data"); + HL_TESTING2("opaque data"); /* Create an opaque datatype for the particle struct */ if ((part_t = H5Tcreate (H5T_OPAQUE, sizeof(particle_t) )) < 0 ) @@ -602,7 +602,7 @@ test_compress(void) particle_t readPart[1]; hsize_t count; - TESTING("packet table compression"); + HL_TESTING2("packet table compression"); /* Create a file. */ if((fid1 = H5Fcreate(TEST_COMPRESS_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; @@ -739,7 +739,7 @@ static int test_rw_nonnative_dt(hid_t fid) int writeBuffer[5]; int readBuffer[5]; - TESTING("reading/writing non-native packet table"); + HL_TESTING2("reading/writing non-native packet table"); /* Initialize buffers */ for(x=0; x<5; x++) { @@ -794,7 +794,7 @@ static int test_rw_nonnative_dt(hid_t fid) /* Close the packet table */ if( (err = H5PTclose(ptable)) < 0) goto error; - + PASSED(); return SUCCEED; @@ -819,7 +819,7 @@ static int test_error(hid_t fid) int id_open=0; particle_t readBuf[1]; - TESTING("error conditions"); + HL_TESTING2("error conditions"); /* Create a HL table */ if(create_hl_table(fid) < 0) @@ -981,7 +981,7 @@ int main(void) /* Close the file */ if (H5Fclose(fid) < 0) - status = 1; + status = 1; return status; } diff --git a/hl/test/test_packet_vlen.c b/hl/test/test_packet_vlen.c index 1d6231e..b41e73d 100644 --- a/hl/test/test_packet_vlen.c +++ b/hl/test/test_packet_vlen.c @@ -46,101 +46,101 @@ static int verify_attribute(hid_t fid, const char *table_name, const char *attr_ /*------------------------------------------------------------------------- * test_VLof_atomic(): Test that a packet table with VL datatypes of atomic - * datatypes can be created and written correctly. (HDFFV-442) + * datatypes can be created and written correctly. (HDFFV-442) * * 2016/01/27 -BMR *------------------------------------------------------------------------- */ static int test_VLof_atomic(void) { - hid_t fid=H5I_INVALID_HID; /* Test file identifier */ - hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */ - hid_t vltype=H5I_INVALID_HID; /* Variable length datatype */ - hsize_t count; /* Number of records in the table */ - unsigned uu, vv; /* Loop variables */ - hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */ - hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */ - char msg[80]; /* For error message */ - herr_t ret; /* Returned status from a callee */ - - TESTING3(" with vlen of atomic"); + hid_t fid=H5I_INVALID_HID; /* Test file identifier */ + hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */ + hid_t vltype=H5I_INVALID_HID; /* Variable length datatype */ + hsize_t count; /* Number of records in the table */ + unsigned uu, vv; /* Loop variables */ + hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */ + hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */ + char msg[80]; /* For error message */ + herr_t ret; /* Returned status from a callee */ + + HL_TESTING3(" with vlen of atomic"); /* Allocate and initialize VL data to write (copied from C test) */ for (uu = 0; uu < NRECORDS; uu++) { writeBuf[uu].p = HDmalloc((uu + 1) * sizeof(unsigned int)); if (writeBuf[uu].p == NULL) { - fprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu); + HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu); goto error; - } + } writeBuf[uu].len = uu + 1; for (vv = 0; vv < (uu + 1); vv++) - ((unsigned int *)writeBuf[uu].p)[vv] = uu * 10 + vv; + ((unsigned int *)writeBuf[uu].p)[vv] = uu * 10 + vv; } /* end for */ /* Open the file */ fid = H5Fopen(TEST_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT); if (fid < 0) - goto error; + goto error; /* Create a vlen type that uses an atomic datatype as its base type */ vltype = H5Tvlen_create (H5T_NATIVE_UINT); if (vltype < 0) - goto error; + goto error; /* Create a packet table that uses a vlen datatype of an atomic type */ ptable = H5PTcreate(fid, PT_VLEN_ATOMIC, vltype, (hsize_t)1, H5P_DEFAULT); /* Ensure that PT is created successfully */ if (ptable == H5I_INVALID_HID) - goto error; + goto error; /* Close the vlen datatype */ if (H5Tclose(vltype) < 0) - goto error; + goto error; /* Write the entire buffer to the packet table */ ret = H5PTappend(ptable, (size_t)NRECORDS, writeBuf); if (ret < 0) - goto error; + goto error; /* Get the number of packets in the packet table, should be NRECORDS. */ ret = H5PTget_num_packets(ptable, &count); if (ret < 0) - goto error; + goto error; - sprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS); + HDsprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS); VERIFY(count == NRECORDS, msg); /* Read all five packets back */ ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)NRECORDS, (void*)readBuf ); if (ret < 0) - goto error; + goto error; for (uu = 0; uu < NRECORDS; uu++) for (vv = 0; vv < (uu + 1); vv++) { - if (((unsigned int *)readBuf[uu].p)[vv] != ((unsigned int *)writeBuf[uu].p)[vv]) { - printf("Packet %u's value should be %d\n", uu, ((unsigned int *)writeBuf[uu].p)[vv]); - printf("Packet %u's value in readBuf is %d\n", uu, ((unsigned int *)readBuf[uu].p)[vv]); - } + if (((unsigned int *)readBuf[uu].p)[vv] != ((unsigned int *)writeBuf[uu].p)[vv]) { + HDprintf("Packet %u's value should be %d\n", uu, ((unsigned int *)writeBuf[uu].p)[vv]); + HDprintf("Packet %u's value in readBuf is %d\n", uu, ((unsigned int *)readBuf[uu].p)[vv]); + } } /* Free the buffers */ ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf ); if (ret < 0) - goto error; + goto error; ret = H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf); if (ret < 0) - goto error; + goto error; /* Close the packet table */ ret = H5PTclose(ptable); if (ret < 0) - goto error; + goto error; /* Close the file */ if (H5Fclose(fid) < 0) - goto error; + goto error; PASSED(); return SUCCEED; @@ -157,7 +157,7 @@ error: /* An error has occurred. Clean up and exit. */ /*------------------------------------------------------------------------- * test_VLof_comptype(): Test that a packet table with VL datatypes of - * compound datatypes can be created and written correctly. (HDFFV-442) + * compound datatypes can be created and written correctly. (HDFFV-442) * * 2016/01/27 -BMR *------------------------------------------------------------------------- @@ -169,26 +169,26 @@ static int test_VLof_comptype(void) unsigned u; float f; } VLcomp_t; - hid_t fid=H5I_INVALID_HID; /* Test file identifier */ - hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */ - hid_t vltype=H5I_INVALID_HID; /* Variable length datatype */ - hid_t cmptype=H5I_INVALID_HID; /* Compound datatype */ - hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */ - hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */ - hsize_t count; /* Number of records in the table */ - unsigned uu, vv; /* Loop variables */ - char msg[80]; /* For error message */ + hid_t fid=H5I_INVALID_HID; /* Test file identifier */ + hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */ + hid_t vltype=H5I_INVALID_HID; /* Variable length datatype */ + hid_t cmptype=H5I_INVALID_HID; /* Compound datatype */ + hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */ + hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */ + hsize_t count; /* Number of records in the table */ + unsigned uu, vv; /* Loop variables */ + char msg[80]; /* For error message */ herr_t ret; - TESTING3(" with vlen of compound datatypes"); + HL_TESTING3(" with vlen of compound datatypes"); /* Allocate and initialize VL data to write (copied from C test) */ for (uu = 0; uu < NRECORDS; uu++) { writeBuf[uu].p = HDmalloc((uu + 1) * sizeof(VLcomp_t)); if(writeBuf[uu].p == NULL) { - fprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu); + HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu); goto error; - } + } writeBuf[uu].len = uu + 1; for (vv = 0; vv < (uu + 1); vv++) { ((VLcomp_t *)writeBuf[uu].p)[vv].u = uu + vv; @@ -199,88 +199,88 @@ static int test_VLof_comptype(void) /* Open the file */ fid = H5Fopen(TEST_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT); if (fid < 0) - goto error; + goto error; /* Create the base compound type */ cmptype = H5Tcreate(H5T_COMPOUND, sizeof(VLcomp_t)); if (cmptype < 0) - goto error; + goto error; /* Insert fields */ ret = H5Tinsert(cmptype, "u", HOFFSET(VLcomp_t, u), H5T_NATIVE_UINT); if (ret < 0) - goto error; + goto error; ret = H5Tinsert(cmptype, "f", HOFFSET(VLcomp_t, f), H5T_NATIVE_FLOAT); if (ret < 0) - goto error; + goto error; /* Create a variable length type that uses the VLcomp_t as its base type */ vltype = H5Tvlen_create(cmptype); if (vltype < 0) - goto error; + goto error; /* Create a packet table that uses a vlen datatype of compound datatype */ ptable = H5PTcreate(fid, PT_VLEN_COMP, vltype, (hsize_t)1, H5P_DEFAULT); /* Ensure that PT is created successfully */ if (ptable == H5I_INVALID_HID) - goto error; + goto error; /* Release the datatypes */ if (H5Tclose(cmptype) < 0) - goto error; + goto error; if (H5Tclose(vltype) < 0) - goto error; + goto error; /* Write the entire buffer to the packet table */ ret = H5PTappend(ptable, (size_t)5, writeBuf ); if (ret < 0) - goto error; + goto error; /* Get the number of packets in the packet table, should be NRECORDS. */ ret = H5PTget_num_packets(ptable, &count); if (ret < 0) - goto error; + goto error; - sprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS); + HDsprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS); VERIFY(count == NRECORDS, msg); /* Read all five packets back */ ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)5, (void*)readBuf ); if (ret < 0) - goto error; + goto error; /* Compare data read in */ for (uu = 0; uu < NRECORDS; uu++) { if (writeBuf[uu].len != readBuf[uu].len) { - fprintf(stderr, "%d: VL data length don't match!, writeBuf[%u].len=%d, readBuf[%u].len=%d\n", __LINE__, uu, (int)writeBuf[uu].len, uu, (int)readBuf[uu].len); - continue; - } /* write len != read len */ + HDfprintf(stderr, "%d: VL data length don't match!, writeBuf[%u].len=%d, readBuf[%u].len=%d\n", __LINE__, uu, (int)writeBuf[uu].len, uu, (int)readBuf[uu].len); + continue; + } /* write len != read len */ for (vv = 0; vv < (uu + 1); vv++) { if (((unsigned int *)writeBuf[uu].p)[vv] != ((unsigned int *)readBuf[uu].p)[vv] ) { - fprintf(stderr, "VL data values don't match!, writeBuf[uu].p[%d]=%d, readBuf[uu].p[%d]=%d\n", vv, (int)((unsigned int *)writeBuf[uu].p)[vv], vv, (int)((unsigned int *)readBuf[uu].p)[vv]); + HDfprintf(stderr, "VL data values don't match!, writeBuf[uu].p[%d]=%d, readBuf[uu].p[%d]=%d\n", vv, (int)((unsigned int *)writeBuf[uu].p)[vv], vv, (int)((unsigned int *)readBuf[uu].p)[vv]); continue; - } /* write value != read value */ - } + } /* write value != read value */ + } } /* end for */ /* Free the buffers */ ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); if (ret < 0) - goto error; + goto error; ret = H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf); if (ret < 0) - goto error; + goto error; /* Close the packet table */ ret = H5PTclose(ptable); if (ret < 0) - goto error; + goto error; /* Close the file */ if (H5Fclose(fid) < 0) - goto error; + goto error; PASSED(); return SUCCEED; @@ -298,8 +298,8 @@ error: /* An error has occurred. Clean up and exit. */ /*------------------------------------------------------------------------- * test_compound_VL_VL(): Test that a packet table of compound datatypes - * containing VL datatypes can be created and written - * correctly. (HDFFV-442) + * containing VL datatypes can be created and written + * correctly. (HDFFV-442) * * 2016/01/27 -BMR *------------------------------------------------------------------------- @@ -310,23 +310,23 @@ static int test_compound_VL_VLtype(void) typedef struct { unsigned u; float f; - hvl_t v; + hvl_t v; } compVLVL_t; - hid_t fid=H5I_INVALID_HID; /* Test file identifier */ - hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */ - hid_t vlatomic=H5I_INVALID_HID; /* Variable length datatype */ - hid_t vlofvl=H5I_INVALID_HID; /* Variable length datatype */ - hid_t comp_vlvl=H5I_INVALID_HID; /* ID of a compound datatype containing - a VL of VL of atomic datatype */ - hsize_t count; /* Number of records in the table */ + hid_t fid=H5I_INVALID_HID; /* Test file identifier */ + hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */ + hid_t vlatomic=H5I_INVALID_HID; /* Variable length datatype */ + hid_t vlofvl=H5I_INVALID_HID; /* Variable length datatype */ + hid_t comp_vlvl=H5I_INVALID_HID; /* ID of a compound datatype containing + a VL of VL of atomic datatype */ + hsize_t count; /* Number of records in the table */ compVLVL_t writeBuf[NRECORDS];/* Buffer to hold data to be written */ compVLVL_t readBuf[NRECORDS]; /* Buffer to hold read data */ hvl_t *t1, *t2; - unsigned uu, vv, ww; /* Loop variables */ - char msg[80]; /* For error message */ - herr_t ret; /* Returned status from a callee */ + unsigned uu, vv, ww; /* Loop variables */ + char msg[80]; /* For error message */ + herr_t ret; /* Returned status from a callee */ - TESTING3(" with compound datatype containing vlen datatype"); + HL_TESTING3(" with compound datatype containing vlen datatype"); /* Allocate and initialize VL data to write (copied from C test) */ for (uu = 0; uu < NRECORDS; uu++) { @@ -334,17 +334,17 @@ static int test_compound_VL_VLtype(void) writeBuf[uu].f = (float)(uu * 20) / 3.0F; writeBuf[uu].v.p = HDmalloc((uu + L1_INCM) * sizeof(hvl_t)); if (writeBuf[uu].v.p == NULL) { - fprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu); + HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu); goto error; - } + } writeBuf[uu].v.len = uu + L1_INCM; for (t1 = (hvl_t *)((writeBuf[uu].v).p), vv = 0; vv < (uu + L1_INCM); vv++, t1++) - { + { t1->p = HDmalloc((vv + L2_INCM) * sizeof(unsigned int)); - if (t1->p == NULL) { - fprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu); - goto error; - } + if (t1->p == NULL) { + HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu); + goto error; + } t1->len = vv + L2_INCM; for (ww = 0; ww < vv + L2_INCM; ww++) ((unsigned int *)t1->p)[ww] = uu * 100 + vv * 10 + ww; @@ -354,91 +354,91 @@ static int test_compound_VL_VLtype(void) /* Open the file */ fid = H5Fopen(TEST_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT); if (fid < 0) - goto error; + goto error; /* Create a VL datatype of an atomic type */ vlatomic = H5Tvlen_create (H5T_NATIVE_UINT); if (vlatomic < 0) - goto error; + goto error; /* Create a VL datatype of the VL of atomic datatype */ vlofvl = H5Tvlen_create (vlatomic); if (vlofvl < 0) - goto error; + goto error; /* Create the base compound type */ comp_vlvl = H5Tcreate(H5T_COMPOUND, sizeof(compVLVL_t)); if (comp_vlvl < 0) - goto error; + goto error; /* Insert fields: atomic, atomic, vlen */ ret = H5Tinsert(comp_vlvl, "u", HOFFSET(compVLVL_t, u), H5T_NATIVE_UINT); if (ret < 0) - goto error; + goto error; ret = H5Tinsert(comp_vlvl, "f", HOFFSET(compVLVL_t, f), H5T_NATIVE_FLOAT); if (ret < 0) - goto error; + goto error; ret = H5Tinsert(comp_vlvl, "v", HOFFSET(compVLVL_t, v), vlofvl); if (ret < 0) - goto error; + goto error; /* Create a packet table that uses a compound datatype of vlen datatype */ ptable = H5PTcreate(fid, PT_COMP_VLEN, comp_vlvl, (hsize_t)1, H5P_DEFAULT); /* Ensure that PT is created successfully */ if (ptable == H5I_INVALID_HID) - goto error; + goto error; /* Release datatypes */ if (H5Tclose(vlatomic) < 0) - goto error; + goto error; if (H5Tclose(vlofvl) < 0) - goto error; + goto error; if (H5Tclose(comp_vlvl) < 0) - goto error; + goto error; /* Write the entire buffer to the packet table */ ret = H5PTappend(ptable, (size_t)NRECORDS, writeBuf ); if (ret < 0) - goto error; + goto error; /* Get the number of packets in the packet table, should be NRECORDS. */ ret = H5PTget_num_packets(ptable, &count); if (ret < 0) - goto error; + goto error; - sprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS); + HDsprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS); VERIFY(count == NRECORDS, msg); /* Read all five packets back */ ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)NRECORDS, (void*)readBuf ); if (ret < 0) - goto error; + goto error; /* Compare data read in */ for (uu = 0; uu < NRECORDS; uu++) { if (writeBuf[uu].u != readBuf[uu].u) { - fprintf(stderr, "Integer components don't match!, writeBuf[%u].u=%u, readBuf[%u].u=%u\n", uu, writeBuf[uu].u, uu, readBuf[uu].u); + HDfprintf(stderr, "Integer components don't match!, writeBuf[%u].u=%u, readBuf[%u].u=%u\n", uu, writeBuf[uu].u, uu, readBuf[uu].u); continue; } /* end if */ if (!H5_FLT_ABS_EQUAL(writeBuf[uu].f,readBuf[uu].f)) { - fprintf(stderr, "Float components don't match!, writeBuf[%u].f=%f, readBuf[%u].f=%f\n", uu, (double)writeBuf[uu].f, uu, (double)readBuf[uu].f); + HDfprintf(stderr, "Float components don't match!, writeBuf[%u].f=%f, readBuf[%u].f=%f\n", uu, (double)writeBuf[uu].f, uu, (double)readBuf[uu].f); continue; } /* end if */ if (writeBuf[uu].v.len != readBuf[uu].v.len) { - fprintf(stderr, "%d: VL data length don't match!, writeBuf[%d].v.len=%zu, readBuf[%d].v.len=%zu\n", __LINE__, uu, writeBuf[uu].v.len, uu, readBuf[uu].v.len); + HDfprintf(stderr, "%d: VL data length don't match!, writeBuf[%d].v.len=%zu, readBuf[%d].v.len=%zu\n", __LINE__, uu, writeBuf[uu].v.len, uu, readBuf[uu].v.len); continue; } /* end if */ for (t1 = (hvl_t *)(writeBuf[uu].v.p), t2 = (hvl_t *)(readBuf[uu].v.p), vv = 0; (size_t)vv < readBuf[uu].v.len; vv++, t1++, t2++) { if (t1->len != t2->len) { - fprintf(stderr, "%d: VL data length don't match!, uu=%u, vv=%u, t1->len=%zu, t2->len=%zu\n", __LINE__, uu, vv, t1->len, t2->len); + HDfprintf(stderr, "%d: VL data length don't match!, uu=%u, vv=%u, t1->len=%zu, t2->len=%zu\n", __LINE__, uu, vv, t1->len, t2->len); continue; } /* end if */ for (ww = 0; (size_t)ww < t2->len; ww++) { if (((unsigned int *)t1->p)[ww] != ((unsigned int *)t2->p)[ww] ) { - fprintf(stderr, "VL data values don't match!, t1->p[%u]=%u, t2->p[%u]=%u\n", ww, ((unsigned int *)t1->p)[ww], ww, ((unsigned int *)t2->p)[ww]); + HDfprintf(stderr, "VL data values don't match!, t1->p[%u]=%u, t2->p[%u]=%u\n", ww, ((unsigned int *)t1->p)[ww], ww, ((unsigned int *)t2->p)[ww]); continue; } /* end if */ } /* end for */ @@ -448,19 +448,19 @@ static int test_compound_VL_VLtype(void) /* Free the buffers */ ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); if (ret < 0) - goto error; + goto error; ret = H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf); if (ret < 0) - goto error; + goto error; /* Close the packet table */ ret = H5PTclose(ptable); if (ret < 0) - goto error; + goto error; /* Close the file */ if (H5Fclose(fid) < 0) - goto error; + goto error; PASSED(); return SUCCEED; @@ -479,43 +479,43 @@ error: /* An error has occurred. Clean up and exit. */ /*------------------------------------------------------------------------- * test_VLof_VLtype(): Test that a packet table of VL datatype with VL - * datatypes of atomic datatypes can be created and written - * correctly. (HDFFV-442) + * datatypes of atomic datatypes can be created and written + * correctly. (HDFFV-442) * * 2016/01/27 -BMR *------------------------------------------------------------------------- */ static int test_VLof_VLtype(void) { - hid_t fid=H5I_INVALID_HID; /* Test file identifier */ - hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */ - hid_t vlatomic=H5I_INVALID_HID; /* Variable length datatype */ - hid_t vlofvl=H5I_INVALID_HID; /* VL datatype of VL datatypes */ - hsize_t count; /* Number of records in the table */ - hvl_t *t1; /* pointer to advance */ - unsigned uu, vv, ww; /* Loop variables */ - hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */ - hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */ - char msg[80]; /* For error message */ - herr_t ret; /* Returned status from a callee */ - - TESTING3(" with vlen datatype of vlen datatype"); + hid_t fid=H5I_INVALID_HID; /* Test file identifier */ + hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */ + hid_t vlatomic=H5I_INVALID_HID; /* Variable length datatype */ + hid_t vlofvl=H5I_INVALID_HID; /* VL datatype of VL datatypes */ + hsize_t count; /* Number of records in the table */ + hvl_t *t1; /* pointer to advance */ + unsigned uu, vv, ww; /* Loop variables */ + hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */ + hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */ + char msg[80]; /* For error message */ + herr_t ret; /* Returned status from a callee */ + + HL_TESTING3(" with vlen datatype of vlen datatype"); /* Allocate and initialize VL data to write (copied from C test) */ for (uu = 0; uu < NRECORDS; uu++) { writeBuf[uu].p = HDmalloc((uu + 1) * sizeof(hvl_t)); if (writeBuf[uu].p == NULL) { - fprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu); + HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu); goto error; } /* end if */ writeBuf[uu].len = uu + 1; for (t1=(hvl_t *)(writeBuf[uu].p), vv = 0; vv < (uu + 1); vv++, t1++) - { + { t1->p = HDmalloc((vv + 1) * sizeof(unsigned int)); - if (t1->p == NULL) { - fprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu); - goto error; - } + if (t1->p == NULL) { + HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu); + goto error; + } t1->len = vv * 1; for (ww = 0; ww < (vv * 1); ww++) ((unsigned int *)t1->p)[ww] = uu * 100 + vv * 10 + ww; @@ -525,64 +525,64 @@ static int test_VLof_VLtype(void) /* Open the file */ fid = H5Fopen(TEST_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT); if (fid < 0) - goto error; + goto error; /* Create a VL datatype of an atomic type */ vlatomic = H5Tvlen_create (H5T_NATIVE_UINT); if (vlatomic < 0) - goto error; + goto error; vlofvl = H5Tvlen_create (vlatomic); if (vlofvl < 0) - goto error; + goto error; /* Create a packet table that uses a vlen datatype of vlen datatype */ ptable = H5PTcreate(fid, PT_VLEN_VLEN, vlofvl, (hsize_t)1, H5P_DEFAULT); /* Ensure that PT is created successfully */ if (ptable == H5I_INVALID_HID) - goto error; + goto error; /* Release datatypes */ if (H5Tclose(vlatomic) < 0) - goto error; + goto error; if (H5Tclose(vlofvl) < 0) - goto error; + goto error; /* Write the entire buffer to the packet table */ ret = H5PTappend(ptable, (size_t)5, writeBuf ); if (ret < 0) - goto error; + goto error; /* Get the number of packets in the packet table, should be NRECORDS. */ ret = H5PTget_num_packets(ptable, &count); if (ret < 0) - goto error; + goto error; - sprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS); + HDsprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS); VERIFY(count == NRECORDS, msg); /* Read all five packets back */ ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)5, (void*)readBuf ); if (ret < 0) - goto error; + goto error; /* Free the buffers */ ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); if (ret < 0) - goto error; + goto error; ret = H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf); if (ret < 0) - goto error; + goto error; /* Close the packet table */ ret = H5PTclose(ptable); if (ret < 0) - goto error; + goto error; /* Close the file */ if (H5Fclose(fid) < 0) - goto error; + goto error; PASSED(); return SUCCEED; @@ -600,41 +600,41 @@ error: /* An error has occurred. Clean up and exit. */ /*------------------------------------------------------------------------- * verify_ptlengthtype() - helper function, verifies that the named packet - * table is a fixed-length or variable-length as indicated by the last - * argument. + * table is a fixed-length or variable-length as indicated by the last + * argument. * * 2016/01/27 -BMR *------------------------------------------------------------------------- */ static int verify_ptlengthtype(hid_t fid, const char *table_name, herr_t expected_value) { - hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */ + hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */ herr_t is_varlen = 0; herr_t ret = FAIL; /* Open the named packet table */ if( (ptable = H5PTopen(fid, table_name)) < 0) - goto error; + goto error; /* Verify the value returned from H5PTis_varlen is as expected */ is_varlen = H5PTis_varlen(ptable); if (is_varlen == FAIL) - goto error; + goto error; else if (is_varlen == expected_value) - ret = SUCCEED; + ret = SUCCEED; else { - char lenthtype[20]; - HDstrcpy(lenthtype, "fixed-length"); - if (expected_value == 1) - HDstrcpy(lenthtype, "variable-length"); - fprintf(stderr, "\nPacket table '%s' should be %s but is not\n", table_name, lenthtype); - ret = FAIL; + char lenthtype[20]; + HDstrcpy(lenthtype, "fixed-length"); + if (expected_value == 1) + HDstrcpy(lenthtype, "variable-length"); + HDfprintf(stderr, "\nPacket table '%s' should be %s but is not\n", table_name, lenthtype); + ret = FAIL; } /* Close the packet table */ if (H5PTclose(ptable) < 0) - goto error; + goto error; return ret; @@ -645,71 +645,71 @@ error: /* An error has occurred. Clean up and exit. */ /*------------------------------------------------------------------------- * test_H5PTis_varlen(): Test that H5PTis_varlen works correctly on both - * fixed- and variable-length packet tables. + * fixed- and variable-length packet tables. * * Description: - * - Added a fixed-length packet table to the file for variety - * - Use the helper funtion verify_ptlengthtype to test H5PTis_varlen - * on each packet table. + * - Added a fixed-length packet table to the file for variety + * - Use the helper funtion verify_ptlengthtype to test H5PTis_varlen + * on each packet table. * * 2016/01/27 -BMR *------------------------------------------------------------------------- */ static int test_H5PTis_varlen(void) { - hid_t fid=H5I_INVALID_HID; /* Test file identifier */ - hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */ - herr_t ret; /* Returned status from a callee */ + hid_t fid=H5I_INVALID_HID; /* Test file identifier */ + hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */ + herr_t ret; /* Returned status from a callee */ - TESTING("H5PTis_varlen"); + HL_TESTING2("H5PTis_varlen"); /* Open the file */ fid = H5Fopen(TEST_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT); if (fid < 0) - goto error; + goto error; /* Create a new table */ ptable = H5PTcreate(fid, PT_FIXED_LEN, H5T_STD_I32BE, (hsize_t)100, H5P_DEFAULT); /* Ensure that PT is created successfully */ if (ptable == H5I_INVALID_HID) - goto error; + goto error; /* Close the packet table */ ret = H5PTclose(ptable); if (ret < 0) - goto error; + goto error; /* Close the file */ if (H5Fclose(fid) < 0) - goto error; + goto error; /* Open the file */ fid = H5Fopen(TEST_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT); if (fid < 0) - goto error; + goto error; /* Open each packet table, and verify that H5PTis_varlen returns correct type for each table */ ret = verify_ptlengthtype(fid, PT_VLEN_ATOMIC, 1); /* vlen of atomic */ if (ret < 0) - goto error; + goto error; ret = verify_ptlengthtype(fid, PT_VLEN_COMP, 1); /* vlen of compound */ if (ret < 0) - goto error; + goto error; ret = verify_ptlengthtype(fid, PT_COMP_VLEN, 0); /* compound of vlen, no vlen */ if (ret < 0) - goto error; + goto error; ret = verify_ptlengthtype(fid, PT_VLEN_VLEN, 1); /* vlen of vlen */ if (ret < 0) - goto error; + goto error; ret = verify_ptlengthtype(fid, PT_FIXED_LEN, 0); /* no vlen */ if (ret < 0) - goto error; + goto error; /* Close the file */ if (H5Fclose(fid) < 0) - goto error; + goto error; PASSED(); return SUCCEED; @@ -722,11 +722,11 @@ error: /* An error has occurred. Clean up and exit. */ /*------------------------------------------------------------------------- * adding_attribute() - helper function, adds an attribute to the named - * packet table. + * packet table. * Note: - * For simplicity, the attributes that are added to the packet tables - * have the same characteristics except their names. They have the - * same type, space, and values. + * For simplicity, the attributes that are added to the packet tables + * have the same characteristics except their names. They have the + * same type, space, and values. * * 2016/01/27 -BMR *------------------------------------------------------------------------- @@ -737,47 +737,47 @@ int attr_data[ATTR_DIM]={256,11945,-22107}; /* values to be written to attr */ static int adding_attribute(hid_t fid, const char *table_name, const char *attr_name) { - hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */ - hid_t space_id = H5I_INVALID_HID; /* Dataspace for the attribute */ - hid_t attr_id = H5I_INVALID_HID; /* Attribute identifier */ - hid_t dset_id = H5I_INVALID_HID; /* Dataset identifier */ - hsize_t dims[] = {ATTR_DIM}; /* Dimension for dataspace */ - int ret = FAIL; /* Returned status from a callee */ + hid_t ptable = H5I_INVALID_HID; /* Packet table identifier */ + hid_t space_id = H5I_INVALID_HID; /* Dataspace for the attribute */ + hid_t attr_id = H5I_INVALID_HID; /* Attribute identifier */ + hid_t dset_id = H5I_INVALID_HID; /* Dataset identifier */ + hsize_t dims[] = {ATTR_DIM}; /* Dimension for dataspace */ + int ret = FAIL; /* Returned status from a callee */ /* Create dataspace for attribute */ space_id = H5Screate_simple(ATTR_RANK, dims, NULL); if (space_id < 0) - goto error; + goto error; /* Open the named packet table */ if( (ptable = H5PTopen(fid, table_name)) < 0) - goto error; + goto error; dset_id = H5PTget_dataset(ptable); if (dset_id < 0) - goto error; + goto error; /* Add the specified attribute to it */ attr_id = H5Acreate2(dset_id, attr_name, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT); if (attr_id < 0) - goto error; + goto error; /* Write attribute values */ ret = H5Awrite(attr_id, H5T_NATIVE_INT, attr_data); if (ret < 0) - goto error; + goto error; /* Close the attribute */ if (H5Aclose(attr_id) < 0) - goto error; + goto error; /* Close the dataspace */ if (H5Sclose(space_id) < 0) - goto error; + goto error; /* Close the packet table */ if (H5PTclose(ptable) < 0) - goto error; + goto error; return SUCCEED; @@ -790,39 +790,39 @@ error: /* An error has occurred. Clean up and exit. */ /*------------------------------------------------------------------------- * verify_attribute() - helper function, verifies the named attribute can - * be read correctly. + * be read correctly. * * 2016/01/27 -BMR *------------------------------------------------------------------------- */ static herr_t verify_attribute(hid_t fid, const char *table_name, const char *attr_name) { - hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */ - hid_t attr_id=H5I_INVALID_HID; /* Attribute identifier */ - hid_t dset_id=H5I_INVALID_HID; /* Dataset associated with the pt */ - int read_data[ATTR_DIM]; /* Output buffer */ + hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */ + hid_t attr_id=H5I_INVALID_HID; /* Attribute identifier */ + hid_t dset_id=H5I_INVALID_HID; /* Dataset associated with the pt */ + int read_data[ATTR_DIM]; /* Output buffer */ int ii; - herr_t ret = FAIL; /* Returned status from a callee */ + herr_t ret = FAIL; /* Returned status from a callee */ /* Open the named packet table */ ptable = H5PTopen(fid, table_name); if (ptable < 0) - goto error; + goto error; /* Get the dataset id of this packet table */ dset_id = H5PTget_dataset(ptable); if (dset_id < 0) - goto error; + goto error; /* Open first attribute for the dataset */ attr_id = H5Aopen(dset_id, attr_name, H5P_DEFAULT); if (attr_id < 0) - goto error; + goto error; /* Read attribute values */ ret = H5Aread(attr_id, H5T_NATIVE_INT, read_data); if (ret < 0) - goto error; + goto error; /* Verify values read in */ for (ii = 0; ii < ATTR_DIM; ii++) @@ -831,11 +831,11 @@ static herr_t verify_attribute(hid_t fid, const char *table_name, const char *at /* Close the attribute */ if (H5Aclose(attr_id) < 0) - goto error; + goto error; /* Close the packet table */ if (H5PTclose(ptable) < 0) - goto error; + goto error; return SUCCEED; @@ -849,58 +849,58 @@ error: /* An error has occurred. Clean up and exit. */ * test_attributes(): Test adding attributes to packet tables * * Description: - * Added attributes to some random packet tables in the file. + * Added attributes to some random packet tables in the file. * * 2016/01/27 -BMR *------------------------------------------------------------------------- */ static int test_attributes(void) { - hid_t fid=H5I_INVALID_HID; /* File identifier */ - hid_t attr_id=H5I_INVALID_HID; /* Attribute identifier */ - herr_t ret = FAIL; /* Returned status from a callee */ + hid_t fid=H5I_INVALID_HID; /* File identifier */ + hid_t attr_id=H5I_INVALID_HID; /* Attribute identifier */ + herr_t ret = FAIL; /* Returned status from a callee */ - TESTING("adding attributes to packet tables"); + HL_TESTING2("adding attributes to packet tables"); /* Open the file */ fid = H5Fopen(TEST_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT); if (fid < 0) - goto error; + goto error; /* Add an arbitrary attribute to a few packet tables, using helper func */ attr_id = adding_attribute(fid, PT_VLEN_ATOMIC, "Attribute 1"); if (attr_id < 0) - goto error; + goto error; attr_id = adding_attribute(fid, PT_VLEN_COMP, "Attribute 2"); if (attr_id < 0) - goto error; + goto error; attr_id = adding_attribute(fid, PT_COMP_VLEN, "Attribute 3"); if (attr_id < 0) - goto error; + goto error; /* Close the file */ if (H5Fclose(fid) < 0) - goto error; + goto error; /* Open the file again */ fid = H5Fopen(TEST_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT); if (fid < 0) - goto error; + goto error; /* Read each attribute and verify the values, using helper function */ ret = verify_attribute(fid, PT_VLEN_ATOMIC, "Attribute 1"); if (ret < 0) - goto error; + goto error; ret = verify_attribute(fid, PT_VLEN_COMP, "Attribute 2"); if (ret < 0) - goto error; + goto error; ret = verify_attribute(fid, PT_COMP_VLEN, "Attribute 3"); if (ret < 0) - goto error; + goto error; /* Close the file */ if (H5Fclose(fid) < 0) - goto error; + goto error; PASSED(); return(ret); @@ -913,17 +913,17 @@ error: /* An error has occurred. Clean up and exit. */ /*------------------------------------------------------------------------- * verify_accessors() - helper function, verifies that various info can be - * retrieved correctly using the info returned by the accessor functions. + * retrieved correctly using the info returned by the accessor functions. * * Description: - * Testing functions H5PTget_dataset and H5PTget_type + * Testing functions H5PTget_dataset and H5PTget_type * - * - Opens the named packet table - * - Gets its associated dataset ID then calls a C function on that ID - * to verify the dataset name - * - Gets its associated datatype ID then calls a C function on that ID - * to verify that the packet table is variable- or fixed-length as - * indicated by the expected_value argument + * - Opens the named packet table + * - Gets its associated dataset ID then calls a C function on that ID + * to verify the dataset name + * - Gets its associated datatype ID then calls a C function on that ID + * to verify that the packet table is variable- or fixed-length as + * indicated by the expected_value argument * * 2016/01/27 -BMR *------------------------------------------------------------------------- @@ -990,18 +990,18 @@ error: /* An error has occurred. Clean up and exit. */ * test_accessors(): Test the accessor functions * * Description: - * Retrieves the dataset and datatype IDs and verifies various info - * to ensure these IDs are correct. + * Retrieves the dataset and datatype IDs and verifies various info + * to ensure these IDs are correct. * * 2016/01/27 -BMR *------------------------------------------------------------------------- */ static int test_accessors(void) { - hid_t fid=H5I_INVALID_HID; /* File identifier */ - herr_t ret = FAIL; /* Returned status from a callee */ + hid_t fid=H5I_INVALID_HID; /* File identifier */ + herr_t ret = FAIL; /* Returned status from a callee */ - TESTING("accessor functions"); + HL_TESTING2("accessor functions"); /* Open the file */ fid = H5Fopen(TEST_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT); @@ -1031,109 +1031,109 @@ error: /* An error has occurred. Clean up and exit. */ } /* test_accessors */ /************************************************************************** - Test set for deprecated function H5PTcreate_fl - Each test in this set is the same as the corresponding one in the - set for H5PTcreate, as of Mar 2016 + Test set for deprecated function H5PTcreate_fl + Each test in this set is the same as the corresponding one in the + set for H5PTcreate, as of Mar 2016 **************************************************************************/ /*------------------------------------------------------------------------- * testfl_VLof_atomic(): Test that a packet table with VL datatypes of atomic - * datatypes can be created and written correctly. (HDFFV-442) + * datatypes can be created and written correctly. (HDFFV-442) * * 2016/01/27 -BMR *------------------------------------------------------------------------- */ static int testfl_VLof_atomic(void) { - hid_t fid=H5I_INVALID_HID; /* Test file identifier */ - hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */ - hid_t vltype=H5I_INVALID_HID; /* Variable length datatype */ - hsize_t count; /* Number of records in the table */ - unsigned uu, vv; /* Loop variables */ - hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */ - hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */ - char msg[80]; /* For error message */ - herr_t ret; /* Returned status from a callee */ - - TESTING3(" with vlen of atomic"); + hid_t fid=H5I_INVALID_HID; /* Test file identifier */ + hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */ + hid_t vltype=H5I_INVALID_HID; /* Variable length datatype */ + hsize_t count; /* Number of records in the table */ + unsigned uu, vv; /* Loop variables */ + hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */ + hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */ + char msg[80]; /* For error message */ + herr_t ret; /* Returned status from a callee */ + + HL_TESTING3(" with vlen of atomic"); /* Allocate and initialize VL data to write (copied from C test) */ for (uu = 0; uu < NRECORDS; uu++) { writeBuf[uu].p = HDmalloc((uu + 1) * sizeof(unsigned int)); if (writeBuf[uu].p == NULL) { - fprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu); + HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu); goto error; - } + } writeBuf[uu].len = uu + 1; for (vv = 0; vv < (uu + 1); vv++) - ((unsigned int *)writeBuf[uu].p)[vv] = uu * 10 + vv; + ((unsigned int *)writeBuf[uu].p)[vv] = uu * 10 + vv; } /* end for */ /* Open the file */ fid = H5Fopen(TESTFL_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT); if (fid < 0) - goto error; + goto error; /* Create a vlen type that uses an atomic datatype as its base type */ vltype = H5Tvlen_create (H5T_NATIVE_UINT); if (vltype < 0) - goto error; + goto error; /* Create a packet table that uses a vlen datatype of an atomic type */ ptable = H5PTcreate_fl(fid, PT_VLEN_ATOMIC, vltype, (hsize_t)1, 0); /* Ensure that PT is created successfully */ if (ptable == H5I_INVALID_HID) - goto error; + goto error; /* Close the vlen datatype */ if (H5Tclose(vltype) < 0) - goto error; + goto error; /* Write the entire buffer to the packet table */ ret = H5PTappend(ptable, (size_t)NRECORDS, writeBuf); if (ret < 0) - goto error; + goto error; /* Get the number of packets in the packet table, should be NRECORDS. */ ret = H5PTget_num_packets(ptable, &count); if (ret < 0) - goto error; + goto error; - sprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS); + HDsprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS); VERIFY(count == NRECORDS, msg); /* Read all five packets back */ ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)NRECORDS, (void*)readBuf ); if (ret < 0) - goto error; + goto error; for (uu = 0; uu < NRECORDS; uu++) for (vv = 0; vv < (uu + 1); vv++) { - if (((unsigned int *)readBuf[uu].p)[vv] != ((unsigned int *)writeBuf[uu].p)[vv]) { - printf("Packet %d's value should be %d\n", uu, ((unsigned int *)writeBuf[uu].p)[vv]); - printf("Packet %d's value in readBuf is %d\n", uu, ((unsigned int *)readBuf[uu].p)[vv]); - } + if (((unsigned int *)readBuf[uu].p)[vv] != ((unsigned int *)writeBuf[uu].p)[vv]) { + HDprintf("Packet %d's value should be %d\n", uu, ((unsigned int *)writeBuf[uu].p)[vv]); + HDprintf("Packet %d's value in readBuf is %d\n", uu, ((unsigned int *)readBuf[uu].p)[vv]); + } } /* Free the buffers */ ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf ); if (ret < 0) - goto error; + goto error; ret = H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf); if (ret < 0) - goto error; + goto error; /* Close the packet table */ ret = H5PTclose(ptable); if (ret < 0) - goto error; + goto error; /* Close the file */ if (H5Fclose(fid) < 0) - goto error; + goto error; PASSED(); return SUCCEED; @@ -1150,7 +1150,7 @@ error: /* An error has occurred. Clean up and exit. */ /*------------------------------------------------------------------------- * testfl_VLof_comptype(): Test that a packet table with VL datatypes of - * compound datatypes can be created and written correctly. (HDFFV-442) + * compound datatypes can be created and written correctly. (HDFFV-442) * * 2016/01/27 -BMR *------------------------------------------------------------------------- @@ -1162,26 +1162,26 @@ static int testfl_VLof_comptype(void) unsigned u; float f; } VLcomp_t; - hid_t fid=H5I_INVALID_HID; /* Test file identifier */ - hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */ - hid_t vltype=H5I_INVALID_HID; /* Variable length datatype */ - hid_t cmptype=H5I_INVALID_HID; /* Compound datatype */ - hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */ - hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */ - hsize_t count; /* Number of records in the table */ - unsigned uu, vv; /* Loop variables */ - char msg[80]; /* For error message */ + hid_t fid=H5I_INVALID_HID; /* Test file identifier */ + hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */ + hid_t vltype=H5I_INVALID_HID; /* Variable length datatype */ + hid_t cmptype=H5I_INVALID_HID; /* Compound datatype */ + hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */ + hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */ + hsize_t count; /* Number of records in the table */ + unsigned uu, vv; /* Loop variables */ + char msg[80]; /* For error message */ herr_t ret; - TESTING3(" with vlen of compound datatypes"); + HL_TESTING3(" with vlen of compound datatypes"); /* Allocate and initialize VL data to write (copied from C test) */ for (uu = 0; uu < NRECORDS; uu++) { writeBuf[uu].p = HDmalloc((uu + 1) * sizeof(VLcomp_t)); if(writeBuf[uu].p == NULL) { - fprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu); + HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu); goto error; - } + } writeBuf[uu].len = uu + 1; for (vv = 0; vv < (uu + 1); vv++) { ((VLcomp_t *)writeBuf[uu].p)[vv].u = uu + vv; @@ -1192,88 +1192,88 @@ static int testfl_VLof_comptype(void) /* Open the file */ fid = H5Fopen(TESTFL_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT); if (fid < 0) - goto error; + goto error; /* Create the base compound type */ cmptype = H5Tcreate(H5T_COMPOUND, sizeof(VLcomp_t)); if (cmptype < 0) - goto error; + goto error; /* Insert fields */ ret = H5Tinsert(cmptype, "u", HOFFSET(VLcomp_t, u), H5T_NATIVE_UINT); if (ret < 0) - goto error; + goto error; ret = H5Tinsert(cmptype, "f", HOFFSET(VLcomp_t, f), H5T_NATIVE_FLOAT); if (ret < 0) - goto error; + goto error; /* Create a variable length type that uses the VLcomp_t as its base type */ vltype = H5Tvlen_create(cmptype); if (vltype < 0) - goto error; + goto error; /* Create a packet table that uses a vlen datatype of compound datatype */ ptable = H5PTcreate_fl(fid, PT_VLEN_COMP, vltype, (hsize_t)1, 0); /* Ensure that PT is created successfully */ if (ptable == H5I_INVALID_HID) - goto error; + goto error; /* Release the datatypes */ if (H5Tclose(cmptype) < 0) - goto error; + goto error; if (H5Tclose(vltype) < 0) - goto error; + goto error; /* Write the entire buffer to the packet table */ ret = H5PTappend(ptable, (size_t)5, writeBuf ); if (ret < 0) - goto error; + goto error; /* Get the number of packets in the packet table, should be NRECORDS. */ ret = H5PTget_num_packets(ptable, &count); if (ret < 0) - goto error; + goto error; - sprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS); + HDsprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS); VERIFY(count == NRECORDS, msg); /* Read all five packets back */ ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)5, (void*)readBuf ); if (ret < 0) - goto error; + goto error; /* Compare data read in */ for (uu = 0; uu < NRECORDS; uu++) { if (writeBuf[uu].len != readBuf[uu].len) { - fprintf(stderr, "%d: VL data length don't match!, writeBuf[%u].len=%zu, readBuf[%u].len=%zu\n",__LINE__, uu, writeBuf[uu].len, uu, readBuf[uu].len); - continue; - } /* write len != read len */ + HDfprintf(stderr, "%d: VL data length don't match!, writeBuf[%u].len=%zu, readBuf[%u].len=%zu\n",__LINE__, uu, writeBuf[uu].len, uu, readBuf[uu].len); + continue; + } /* write len != read len */ for (vv = 0; vv < (uu + 1); vv++) { if (((unsigned int *)writeBuf[uu].p)[vv] != ((unsigned int *)readBuf[uu].p)[vv] ) { - fprintf(stderr, "VL data values don't match!, writeBuf[uu].p[%u]=%u, readBuf[uu].p[%u]=%u\n", vv, ((unsigned int *)writeBuf[uu].p)[vv], vv, ((unsigned int *)readBuf[uu].p)[vv]); + HDfprintf(stderr, "VL data values don't match!, writeBuf[uu].p[%u]=%u, readBuf[uu].p[%u]=%u\n", vv, ((unsigned int *)writeBuf[uu].p)[vv], vv, ((unsigned int *)readBuf[uu].p)[vv]); continue; - } /* write value != read value */ - } + } /* write value != read value */ + } } /* end for */ /* Free the buffers */ ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); if (ret < 0) - goto error; + goto error; ret = H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf); if (ret < 0) - goto error; + goto error; /* Close the packet table */ ret = H5PTclose(ptable); if (ret < 0) - goto error; + goto error; /* Close the file */ if (H5Fclose(fid) < 0) - goto error; + goto error; PASSED(); return SUCCEED; @@ -1291,8 +1291,8 @@ error: /* An error has occurred. Clean up and exit. */ /*------------------------------------------------------------------------- * testfl_compound_VL_VL(): Test that a packet table of compound datatypes - * containing VL datatypes can be created and written - * correctly. (HDFFV-442) + * containing VL datatypes can be created and written + * correctly. (HDFFV-442) * * 2016/01/27 -BMR *------------------------------------------------------------------------- @@ -1303,23 +1303,23 @@ static int testfl_compound_VL_VLtype(void) typedef struct { unsigned u; float f; - hvl_t v; + hvl_t v; } compVLVL_t; - hid_t fid=H5I_INVALID_HID; /* Test file identifier */ - hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */ - hid_t vlatomic=H5I_INVALID_HID; /* Variable length datatype */ - hid_t vlofvl=H5I_INVALID_HID; /* Variable length datatype */ - hid_t comp_vlvl=H5I_INVALID_HID; /* ID of a compound datatype containing - a VL of VL of atomic datatype */ - hsize_t count; /* Number of records in the table */ + hid_t fid=H5I_INVALID_HID; /* Test file identifier */ + hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */ + hid_t vlatomic=H5I_INVALID_HID; /* Variable length datatype */ + hid_t vlofvl=H5I_INVALID_HID; /* Variable length datatype */ + hid_t comp_vlvl=H5I_INVALID_HID; /* ID of a compound datatype containing + a VL of VL of atomic datatype */ + hsize_t count; /* Number of records in the table */ compVLVL_t writeBuf[NRECORDS];/* Buffer to hold data to be written */ compVLVL_t readBuf[NRECORDS]; /* Buffer to hold read data */ hvl_t *t1, *t2; - unsigned uu, vv, ww; /* Loop variables */ - char msg[80]; /* For error message */ - herr_t ret; /* Returned status from a callee */ + unsigned uu, vv, ww; /* Loop variables */ + char msg[80]; /* For error message */ + herr_t ret; /* Returned status from a callee */ - TESTING3(" with compound datatype containing vlen datatype"); + HL_TESTING3(" with compound datatype containing vlen datatype"); /* Allocate and initialize VL data to write (copied from C test) */ for (uu = 0; uu < NRECORDS; uu++) { @@ -1327,17 +1327,17 @@ static int testfl_compound_VL_VLtype(void) writeBuf[uu].f = (float)(uu * 20) / 3.0F; writeBuf[uu].v.p = HDmalloc((uu + L1_INCM) * sizeof(hvl_t)); if (writeBuf[uu].v.p == NULL) { - fprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu); + HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu); goto error; - } + } writeBuf[uu].v.len = uu + L1_INCM; for (t1 = (hvl_t *)((writeBuf[uu].v).p), vv = 0; vv < (uu + L1_INCM); vv++, t1++) - { + { t1->p = HDmalloc((vv + L2_INCM) * sizeof(unsigned int)); - if (t1->p == NULL) { - fprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu); - goto error; - } + if (t1->p == NULL) { + HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu); + goto error; + } t1->len = vv + L2_INCM; for (ww = 0; ww < vv + L2_INCM; ww++) ((unsigned int*)t1->p)[ww] = uu * 100 + vv * 10 + ww; @@ -1347,91 +1347,91 @@ static int testfl_compound_VL_VLtype(void) /* Open the file */ fid = H5Fopen(TESTFL_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT); if (fid < 0) - goto error; + goto error; /* Create a VL datatype of an atomic type */ vlatomic = H5Tvlen_create (H5T_NATIVE_UINT); if (vlatomic < 0) - goto error; + goto error; /* Create a VL datatype of the VL of atomic datatype */ vlofvl = H5Tvlen_create (vlatomic); if (vlofvl < 0) - goto error; + goto error; /* Create the base compound type */ comp_vlvl = H5Tcreate(H5T_COMPOUND, sizeof(compVLVL_t)); if (comp_vlvl < 0) - goto error; + goto error; /* Insert fields: atomic, atomic, vlen */ ret = H5Tinsert(comp_vlvl, "u", HOFFSET(compVLVL_t, u), H5T_NATIVE_UINT); if (ret < 0) - goto error; + goto error; ret = H5Tinsert(comp_vlvl, "f", HOFFSET(compVLVL_t, f), H5T_NATIVE_FLOAT); if (ret < 0) - goto error; + goto error; ret = H5Tinsert(comp_vlvl, "v", HOFFSET(compVLVL_t, v), vlofvl); if (ret < 0) - goto error; + goto error; /* Create a packet table that uses a compound datatype of vlen datatype */ ptable = H5PTcreate_fl(fid, PT_COMP_VLEN, comp_vlvl, (hsize_t)1, 0); /* Ensure that PT is created successfully */ if (ptable == H5I_INVALID_HID) - goto error; + goto error; /* Release datatypes */ if (H5Tclose(vlatomic) < 0) - goto error; + goto error; if (H5Tclose(vlofvl) < 0) - goto error; + goto error; if (H5Tclose(comp_vlvl) < 0) - goto error; + goto error; /* Write the entire buffer to the packet table */ ret = H5PTappend(ptable, (size_t)NRECORDS, writeBuf ); if (ret < 0) - goto error; + goto error; /* Get the number of packets in the packet table, should be NRECORDS. */ ret = H5PTget_num_packets(ptable, &count); if (ret < 0) - goto error; + goto error; - sprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS); + HDsprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS); VERIFY(count == NRECORDS, msg); /* Read all five packets back */ ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)NRECORDS, (void*)readBuf ); if (ret < 0) - goto error; + goto error; /* Compare data read in */ for (uu = 0; uu < NRECORDS; uu++) { if (writeBuf[uu].u != readBuf[uu].u) { - fprintf(stderr, "Integer components don't match!, writeBuf[%u].u=%u, readBuf[%u].u=%u\n", uu, writeBuf[uu].u, uu, readBuf[uu].u); + HDfprintf(stderr, "Integer components don't match!, writeBuf[%u].u=%u, readBuf[%u].u=%u\n", uu, writeBuf[uu].u, uu, readBuf[uu].u); continue; } /* end if */ if (!H5_FLT_ABS_EQUAL(writeBuf[uu].f, readBuf[uu].f)) { - fprintf(stderr, "Float components don't match!, writeBuf[%u].f=%f, readBuf[%u].f=%f\n", uu, (double)writeBuf[uu].f, uu, (double)readBuf[uu].f); + HDfprintf(stderr, "Float components don't match!, writeBuf[%u].f=%f, readBuf[%u].f=%f\n", uu, (double)writeBuf[uu].f, uu, (double)readBuf[uu].f); continue; } /* end if */ if (writeBuf[uu].v.len != readBuf[uu].v.len) { - fprintf(stderr, "%d: VL data length don't match!, writeBuf[%u].v.len=%zu, readBuf[%u].v.len=%zu\n", __LINE__, uu, writeBuf[uu].v.len, uu, readBuf[uu].v.len); + HDfprintf(stderr, "%d: VL data length don't match!, writeBuf[%u].v.len=%zu, readBuf[%u].v.len=%zu\n", __LINE__, uu, writeBuf[uu].v.len, uu, readBuf[uu].v.len); continue; } /* end if */ for (t1 = (hvl_t *)(writeBuf[uu].v.p), t2 = (hvl_t *)(readBuf[uu].v.p), vv = 0; (size_t)vv < readBuf[uu].v.len; vv++, t1++, t2++) { if (t1->len != t2->len) { - fprintf(stderr, "%d: VL data length don't match!, uu=%u, vv=%u, t1->len=%zu, t2->len=%zu\n", __LINE__, uu, vv, t1->len, t2->len); + HDfprintf(stderr, "%d: VL data length don't match!, uu=%u, vv=%u, t1->len=%zu, t2->len=%zu\n", __LINE__, uu, vv, t1->len, t2->len); continue; } /* end if */ for (ww = 0; (size_t)ww < t2->len; ww++) { if (((unsigned int *)t1->p)[ww] != ((unsigned int *)t2->p)[ww] ) { - fprintf(stderr, "VL data values don't match!, t1->p[%u]=%u, t2->p[%u]=%u\n", ww, ((unsigned int *)t1->p)[ww], ww, ((unsigned int *)t2->p)[ww]); + HDfprintf(stderr, "VL data values don't match!, t1->p[%u]=%u, t2->p[%u]=%u\n", ww, ((unsigned int *)t1->p)[ww], ww, ((unsigned int *)t2->p)[ww]); continue; } /* end if */ } /* end for */ @@ -1441,19 +1441,19 @@ static int testfl_compound_VL_VLtype(void) /* Free the buffers */ ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); if (ret < 0) - goto error; + goto error; ret = H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf); if (ret < 0) - goto error; + goto error; /* Close the packet table */ ret = H5PTclose(ptable); if (ret < 0) - goto error; + goto error; /* Close the file */ if (H5Fclose(fid) < 0) - goto error; + goto error; PASSED(); return SUCCEED; @@ -1472,43 +1472,43 @@ error: /* An error has occurred. Clean up and exit. */ /*------------------------------------------------------------------------- * testfl_VLof_VLtype(): Test that a packet table of VL datatype with VL - * datatypes of atomic datatypes can be created and written - * correctly. (HDFFV-442) + * datatypes of atomic datatypes can be created and written + * correctly. (HDFFV-442) * * 2016/01/27 -BMR *------------------------------------------------------------------------- */ static int testfl_VLof_VLtype(void) { - hid_t fid=H5I_INVALID_HID; /* Test file identifier */ - hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */ - hid_t vlatomic=H5I_INVALID_HID; /* Variable length datatype */ - hid_t vlofvl=H5I_INVALID_HID; /* VL datatype of VL datatypes */ - hsize_t count; /* Number of records in the table */ - hvl_t *t1; /* pointer to advance */ - unsigned uu, vv, ww; /* Loop variables */ - hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */ - hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */ - char msg[80]; /* For error message */ - herr_t ret; /* Returned status from a callee */ - - TESTING3(" with vlen datatype of vlen datatype"); + hid_t fid=H5I_INVALID_HID; /* Test file identifier */ + hid_t ptable=H5I_INVALID_HID; /* Packet table identifier */ + hid_t vlatomic=H5I_INVALID_HID; /* Variable length datatype */ + hid_t vlofvl=H5I_INVALID_HID; /* VL datatype of VL datatypes */ + hsize_t count; /* Number of records in the table */ + hvl_t *t1; /* pointer to advance */ + unsigned uu, vv, ww; /* Loop variables */ + hvl_t writeBuf[NRECORDS]; /* Buffer to hold data to be written */ + hvl_t readBuf[NRECORDS]; /* Buffer to hold read data */ + char msg[80]; /* For error message */ + herr_t ret; /* Returned status from a callee */ + + HL_TESTING3(" with vlen datatype of vlen datatype"); /* Allocate and initialize VL data to write (copied from C test) */ for (uu = 0; uu < NRECORDS; uu++) { writeBuf[uu].p = HDmalloc((uu + 1) * sizeof(hvl_t)); if (writeBuf[uu].p == NULL) { - fprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu); + HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu); goto error; } /* end if */ writeBuf[uu].len = uu + 1; for (t1 = (hvl_t *)(writeBuf[uu].p), vv = 0; vv < (uu + 1); vv++, t1++) - { + { t1->p = HDmalloc((vv + 1) * sizeof(unsigned int)); - if (t1->p == NULL) { - fprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu); - goto error; - } + if (t1->p == NULL) { + HDfprintf(stderr, "Cannot allocate memory for VL data! uu=%u\n", uu); + goto error; + } t1->len = vv + 1; for (ww = 0; ww < (vv + 1); ww++) ((unsigned int *)t1->p)[ww] = uu * 100 + vv * 10 + ww; @@ -1518,64 +1518,64 @@ static int testfl_VLof_VLtype(void) /* Open the file */ fid = H5Fopen(TESTFL_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT); if (fid < 0) - goto error; + goto error; /* Create a VL datatype of an atomic type */ vlatomic = H5Tvlen_create (H5T_NATIVE_UINT); if (vlatomic < 0) - goto error; + goto error; vlofvl = H5Tvlen_create (vlatomic); if (vlofvl < 0) - goto error; + goto error; /* Create a packet table that uses a vlen datatype of vlen datatype */ ptable = H5PTcreate_fl(fid, PT_VLEN_VLEN, vlofvl, (hsize_t)1, 0); /* Ensure that PT is created successfully */ if (ptable == H5I_INVALID_HID) - goto error; + goto error; /* Release datatypes */ if (H5Tclose(vlatomic) < 0) - goto error; + goto error; if (H5Tclose(vlofvl) < 0) - goto error; + goto error; /* Write the entire buffer to the packet table */ ret = H5PTappend(ptable, (size_t)5, writeBuf ); if (ret < 0) - goto error; + goto error; /* Get the number of packets in the packet table, should be NRECORDS. */ ret = H5PTget_num_packets(ptable, &count); if (ret < 0) - goto error; + goto error; - sprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS); + HDsprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS); VERIFY(count == NRECORDS, msg); /* Read all five packets back */ ret = H5PTread_packets(ptable, (hsize_t)0, (size_t)5, (void*)readBuf ); if (ret < 0) - goto error; + goto error; /* Free the buffers */ ret = H5PTfree_vlen_buff(ptable, NRECORDS, readBuf); if (ret < 0) - goto error; + goto error; ret = H5PTfree_vlen_buff(ptable, NRECORDS, writeBuf); if (ret < 0) - goto error; + goto error; /* Close the packet table */ ret = H5PTclose(ptable); if (ret < 0) - goto error; + goto error; /* Close the file */ if (H5Fclose(fid) < 0) - goto error; + goto error; PASSED(); return SUCCEED; @@ -1593,25 +1593,25 @@ error: /* An error has occurred. Clean up and exit. */ /*------------------------------------------------------------------------- * test_packet_table_with_varlen(): Invokes individual tests to ensure that - * packet tables with variable length are created and written correctly - * without the specific VL PT functionality. (HDFFV-442) + * packet tables with variable length are created and written correctly + * without the specific VL PT functionality. (HDFFV-442) * * 2016/01/27 -BMR *------------------------------------------------------------------------- */ int test_packet_table_with_varlen(void) { - hid_t fid=H5I_INVALID_HID; /* File identifier */ + hid_t fid=H5I_INVALID_HID; /* File identifier */ int status = SUCCEED; /* Create a file using default properties */ fid = H5Fcreate(TEST_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid < 0) - return FAIL; + return FAIL; /* Close the file. The file will be opened by each test function below */ if (H5Fclose(fid) < 0) - return FAIL; + return FAIL; HDputs("Testing packet table with various variable-length datatypes"); @@ -1620,46 +1620,46 @@ int test_packet_table_with_varlen(void) /* Test variable length of a simple type */ if (test_VLof_atomic() < 0) - status = FAIL; + status = FAIL; /* Test variable length of a compound type */ if (test_VLof_comptype() < 0) - status = FAIL; + status = FAIL; /* Test compound type with variable length */ if (test_compound_VL_VLtype() < 0) - status = FAIL; + status = FAIL; /* Test variable length of a variable length */ if (test_VLof_VLtype() < 0) - status = FAIL; + status = FAIL; /* Test variable length of a variable length */ if (test_H5PTis_varlen() < 0) - status = FAIL; + status = FAIL; /* Test adding attributes to packet table */ if (test_attributes() < 0) - status = FAIL; + status = FAIL; /* Test accessor functions */ if (test_accessors() < 0) - status = FAIL; + status = FAIL; /************************************************************************** - Calling test functions for deprecated function H5PTcreate_fl - Mar 2016, -BMR + Calling test functions for deprecated function H5PTcreate_fl + Mar 2016, -BMR **************************************************************************/ /* Create a file using default properties */ fid = H5Fcreate(TESTFL_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid < 0) - return FAIL; + return FAIL; /* Close the file. The file will be opened by each test function below */ if (H5Fclose(fid) < 0) - return FAIL; + return FAIL; HDputs("Testing packet table with various variable-length datatypes - H5PTcreate_fl"); @@ -1668,19 +1668,19 @@ int test_packet_table_with_varlen(void) /* Test variable length of a simple type */ if (testfl_VLof_atomic() < 0) - status = FAIL; + status = FAIL; /* Test variable length of a compound type */ if (testfl_VLof_comptype() < 0) - status = FAIL; + status = FAIL; /* Test compound type with variable length */ if (testfl_compound_VL_VLtype() < 0) - status = FAIL; + status = FAIL; /* Test variable length of a variable length */ if (testfl_VLof_VLtype() < 0) - status = FAIL; + status = FAIL; return(status); } diff --git a/hl/test/test_table.c b/hl/test/test_table.c index 0215697..1d6bcec 100644 --- a/hl/test/test_table.c +++ b/hl/test/test_table.c @@ -51,8 +51,6 @@ #define NRECORDS 8 #define NRECORDS_ADD 3 -#define TESTING2(WHAT) {printf("%-70s", "Testing " WHAT); fflush(stdout);} - /*------------------------------------------------------------------------- * structure used for all tests, a particle with properties *------------------------------------------------------------------------- @@ -117,7 +115,7 @@ typedef struct particle3_t *------------------------------------------------------------------------- */ -/* Push current alignment rule forcing 4-byte alignment boundary +/* Push current alignment rule forcing 4-byte alignment boundary * to the internal stack ... */ #pragma pack(push,4) @@ -129,7 +127,7 @@ typedef struct particle3_t float aty[3]; float rro[2]; } particle4_t; -/* +/* * ... and restore original alignment rules from stack */ #pragma pack(pop) @@ -164,14 +162,14 @@ static int cmp_par(hsize_t i, hsize_t j, particle_t *rbuf, particle_t *wbuf ) if ( ( HDstrcmp( rbuf[i].name, wbuf[j].name ) != 0 ) || rbuf[i].lati != wbuf[j].lati || rbuf[i].longi != wbuf[j].longi || - !H5_FLT_ABS_EQUAL(rbuf[i].pressure,wbuf[j].pressure) || - !H5_DBL_ABS_EQUAL(rbuf[i].temperature,wbuf[j].temperature) ) + !H5_FLT_ABS_EQUAL(rbuf[i].pressure,wbuf[j].pressure) || + !H5_DBL_ABS_EQUAL(rbuf[i].temperature,wbuf[j].temperature) ) { HDfprintf(stderr,"read and write buffers have differences\n"); HDfprintf(stderr,"%s %ld %f %f %d\n", - rbuf[i].name,rbuf[i].longi,(double)rbuf[i].pressure,rbuf[i].temperature,rbuf[i].lati); + rbuf[i].name,rbuf[i].longi,(double)rbuf[i].pressure,rbuf[i].temperature,rbuf[i].lati); HDfprintf(stderr,"%s %ld %f %f %d\n", - wbuf[j].name,wbuf[j].longi,(double)wbuf[j].pressure,wbuf[j].temperature,wbuf[j].lati); + wbuf[j].name,wbuf[j].longi,(double)wbuf[j].pressure,wbuf[j].temperature,wbuf[j].lati); return -1; } return 0; @@ -424,7 +422,7 @@ static int test_table(hid_t fid, int do_write) sizeof( rbuf[0].lati) }; - const char *field_names4[NFIELDS+1] = + const char *field_names4[NFIELDS+1] = { "F1", "F2", "F3", "F4", "F5", "F6"}; hid_t field_type4[NFIELDS+1]; particle4_t fill_data[1] = { {9999999, -9999999, 999999, {999,999,999},{999,999,999}, {999,999}} }; @@ -458,7 +456,7 @@ static int test_table(hid_t fid, int do_write) */ if (do_write) { - TESTING2("making table"); + HL_TESTING2("making table"); if (H5TBmake_table(TITLE,fid,"table1",FIELDS,RECORDS,type_size_mem, field_names,field_offset,field_type, @@ -467,7 +465,7 @@ static int test_table(hid_t fid, int do_write) PASSED(); } - TESTING2("reading table"); + HL_TESTING2("reading table"); /*------------------------------------------------------------------------- * read the table @@ -497,7 +495,7 @@ static int test_table(hid_t fid, int do_write) */ if (do_write) { - TESTING2("writing records"); + HL_TESTING2("writing records"); /* create an empty table */ if (H5TBmake_table(TITLE,fid,"table2",FIELDS,RECORDS,type_size_mem, @@ -540,7 +538,7 @@ static int test_table(hid_t fid, int do_write) *------------------------------------------------------------------------- */ - TESTING2("reading records"); + HL_TESTING2("reading records"); /*------------------------------------------------------------------------- * read records, start at 0, read 8 @@ -584,7 +582,7 @@ static int test_table(hid_t fid, int do_write) */ if (do_write) { - TESTING2("appending records"); + HL_TESTING2("appending records"); /*------------------------------------------------------------------------- * append 2 records @@ -630,7 +628,7 @@ static int test_table(hid_t fid, int do_write) */ if (do_write) { - TESTING2("inserting records"); + HL_TESTING2("inserting records"); /*------------------------------------------------------------------------- * insert 2 records @@ -690,7 +688,7 @@ static int test_table(hid_t fid, int do_write) */ if (do_write) { - TESTING2("deleting records"); + HL_TESTING2("deleting records"); /*------------------------------------------------------------------------- * Create a table @@ -883,54 +881,54 @@ static int test_table(hid_t fid, int do_write) /*------------------------------------------------------------------------ * Functions tested: * - * H5TBdelete_record -- With differing memory layout from machine memory + * H5TBdelete_record -- With differing memory layout from machine memory * layout. HDFFV-8055 * *------------------------------------------------------------------------- */ if (do_write) { - TESTING2("deleting records (differing memory layout)"); + HL_TESTING2("deleting records (differing memory layout)"); - dims = 3; - arry3_32f = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, &dims); + dims = 3; + arry3_32f = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, &dims); - dims = 2; - arry2_32f = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, &dims); + dims = 2; + arry2_32f = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, &dims); - /* Initialize the field field_type */ - field_type4[0] = H5T_NATIVE_UINT32; - field_type4[1] = H5T_NATIVE_DOUBLE; - field_type4[2] = H5T_NATIVE_DOUBLE; - field_type4[3] = arry3_32f; - field_type4[4] = arry3_32f; - field_type4[5] = arry2_32f; + /* Initialize the field field_type */ + field_type4[0] = H5T_NATIVE_UINT32; + field_type4[1] = H5T_NATIVE_DOUBLE; + field_type4[2] = H5T_NATIVE_DOUBLE; + field_type4[3] = arry3_32f; + field_type4[4] = arry3_32f; + field_type4[5] = arry2_32f; - /* Make the table */ - if (H5TBmake_table("Table Title",fid,"table",NFIELDS+1,(hsize_t)NRECORDS, + /* Make the table */ + if (H5TBmake_table("Table Title",fid,"table",NFIELDS+1,(hsize_t)NRECORDS, tbl_size, field_names4, tbl_offset, field_type4, chunk_size, fill_data, compress, p_data)<0) - goto out; - /* Delete records */ - start = 3; - nrecords = 3; - if (H5TBdelete_record(fid, "table", start, nrecords)<0) - goto out;; - /* Get table info */ - if (H5TBget_table_info(fid,"table", &nfields_out, &nrecords_out)<0) - goto out; - /* check */ - if( (int)nfields_out != (int)NFIELDS+1) - goto out; - - if( (int)nrecords_out != (int)NRECORDS-3) - goto out; - - /* close type */ - H5Tclose(arry3_32f); - H5Tclose(arry2_32f); - - PASSED(); + goto out; + /* Delete records */ + start = 3; + nrecords = 3; + if (H5TBdelete_record(fid, "table", start, nrecords)<0) + goto out;; + /* Get table info */ + if (H5TBget_table_info(fid,"table", &nfields_out, &nrecords_out)<0) + goto out; + /* check */ + if( (int)nfields_out != (int)NFIELDS+1) + goto out; + + if( (int)nrecords_out != (int)NRECORDS-3) + goto out; + + /* close type */ + H5Tclose(arry3_32f); + H5Tclose(arry2_32f); + + PASSED(); } /*------------------------------------------------------------------------- @@ -945,7 +943,7 @@ static int test_table(hid_t fid, int do_write) if (do_write) { - TESTING2("adding records"); + HL_TESTING2("adding records"); /* create 2 tables */ if (H5TBmake_table(TITLE,fid,"table4",FIELDS,RECORDS,type_size_mem, @@ -1005,7 +1003,7 @@ static int test_table(hid_t fid, int do_write) if (do_write) { - TESTING2("combining tables"); + HL_TESTING2("combining tables"); /* create 2 tables */ if (H5TBmake_table(TITLE,fid,"table6",FIELDS,RECORDS,type_size_mem, @@ -1100,7 +1098,7 @@ static int test_table(hid_t fid, int do_write) */ if (do_write) { - TESTING2("writing fields by name"); + HL_TESTING2("writing fields by name"); /* make an empty table with fill values */ if (H5TBmake_table(TITLE,fid,"table9",FIELDS,RECORDS,type_size_mem, @@ -1138,10 +1136,10 @@ static int test_table(hid_t fid, int do_write) { if ( rbuf[i].lati != position_in[i-NRECORDS_ADD+1].lati || rbuf[i].longi != position_in[i-NRECORDS_ADD+1].longi || - !H5_FLT_ABS_EQUAL(rbuf[i].pressure,pressure_in[i-NRECORDS_ADD+1]) ) + !H5_FLT_ABS_EQUAL(rbuf[i].pressure,pressure_in[i-NRECORDS_ADD+1]) ) { HDfprintf(stderr,"%ld %f %d\n", - rbuf[i].longi,(double)rbuf[i].pressure,rbuf[i].lati); + rbuf[i].longi,(double)rbuf[i].pressure,rbuf[i].lati); HDfprintf(stderr,"%ld %f %d\n", position_in[i].longi,(double)pressure_in[i],position_in[i].lati); goto out; @@ -1163,7 +1161,7 @@ static int test_table(hid_t fid, int do_write) * *------------------------------------------------------------------------- */ - TESTING2("reading fields by name"); + HL_TESTING2("reading fields by name"); /*------------------------------------------------------------------------- * write and read the "Pressure" field @@ -1191,7 +1189,7 @@ static int test_table(hid_t fid, int do_write) if ( H5TBread_fields_name(fid,"table10","DoesNotExist",start,nrecords, sizeof(float),0,field_sizes_pre,pressure_out) >=0) goto out; - + /* read the "Pressure" field */ if ( H5TBread_fields_name(fid,"table10","Pressure",start,nrecords, sizeof(float),0,field_sizes_pre,pressure_out)<0) @@ -1263,7 +1261,7 @@ static int test_table(hid_t fid, int do_write) for( i = 0; i < NRECORDS; i++ ) { if ( ( HDstrcmp( namepre_out[i].name, namepre_in[i].name ) != 0 ) || - !H5_FLT_ABS_EQUAL(namepre_out[i].pressure,namepre_in[i].pressure) ) { + !H5_FLT_ABS_EQUAL(namepre_out[i].pressure,namepre_in[i].pressure) ) { goto out; } } @@ -1292,7 +1290,7 @@ static int test_table(hid_t fid, int do_write) { hsize_t iistart = start; if ( ( HDstrcmp( namepre_out[i].name, namepre_in[iistart+i].name ) != 0 ) || - !H5_FLT_ABS_EQUAL(namepre_out[i].pressure, namepre_in[iistart+i].pressure) ) { + !H5_FLT_ABS_EQUAL(namepre_out[i].pressure, namepre_in[iistart+i].pressure) ) { goto out; } } @@ -1311,7 +1309,7 @@ static int test_table(hid_t fid, int do_write) */ if (do_write) { - TESTING2("writing fields by index"); + HL_TESTING2("writing fields by index"); /* make an empty table */ if (H5TBmake_table(TITLE,fid,"table11",FIELDS,RECORDS,type_size_mem, @@ -1351,7 +1349,7 @@ static int test_table(hid_t fid, int do_write) { if ( rbuf[i].lati != position_in[i-NRECORDS_ADD+1].lati || rbuf[i].longi != position_in[i-NRECORDS_ADD+1].longi || - !H5_FLT_ABS_EQUAL(rbuf[i].pressure,pressure_in[i-NRECORDS_ADD+1]) ) + !H5_FLT_ABS_EQUAL(rbuf[i].pressure,pressure_in[i-NRECORDS_ADD+1]) ) goto out; } } @@ -1369,7 +1367,7 @@ static int test_table(hid_t fid, int do_write) *------------------------------------------------------------------------- */ - TESTING2("reading fields by index"); + HL_TESTING2("reading fields by index"); if (do_write) { @@ -1470,8 +1468,8 @@ static int test_table(hid_t fid, int do_write) for( i = 0; i < NRECORDS; i++ ) { if ( ( HDstrcmp( namepre_out[i].name, namepre_in[i].name ) != 0 ) || - !H5_FLT_ABS_EQUAL(namepre_out[i].pressure,namepre_in[i].pressure) ) { - goto out; + !H5_FLT_ABS_EQUAL(namepre_out[i].pressure,namepre_in[i].pressure) ) { + goto out; } } @@ -1501,7 +1499,7 @@ static int test_table(hid_t fid, int do_write) { int iistart = (int) start; if ( ( HDstrcmp( namepre_out[i].name, wbuf[iistart+(int)i].name ) != 0 ) || - !H5_FLT_ABS_EQUAL(namepre_out[i].pressure, wbuf[iistart+(int)i].pressure) ) { + !H5_FLT_ABS_EQUAL(namepre_out[i].pressure, wbuf[iistart+(int)i].pressure) ) { goto out; } } @@ -1520,7 +1518,7 @@ static int test_table(hid_t fid, int do_write) if (do_write) { - TESTING2("inserting fields"); + HL_TESTING2("inserting fields"); /* make a table */ if (H5TBmake_table(TITLE,fid,"table13",FIELDS,RECORDS,type_size_mem, @@ -1544,8 +1542,8 @@ static int test_table(hid_t fid, int do_write) if ( ( HDstrcmp( rbuf2[i].name, wbuf[i].name ) != 0 ) || rbuf2[i].lati != wbuf[i].lati || rbuf2[i].longi != wbuf[i].longi || - !H5_FLT_ABS_EQUAL(rbuf2[i].pressure,wbuf[i].pressure) || - !H5_DBL_ABS_EQUAL(rbuf2[i].temperature,wbuf[i].temperature) || + !H5_FLT_ABS_EQUAL(rbuf2[i].pressure,wbuf[i].pressure) || + !H5_DBL_ABS_EQUAL(rbuf2[i].temperature,wbuf[i].temperature) || rbuf2[i].new_field != buf_new[i] ) { goto out; } @@ -1563,7 +1561,7 @@ static int test_table(hid_t fid, int do_write) */ if (do_write) { - TESTING2("deleting fields"); + HL_TESTING2("deleting fields"); /* make a table */ if (H5TBmake_table(TITLE,fid,"table14",FIELDS,RECORDS,type_size_mem, @@ -1585,7 +1583,7 @@ static int test_table(hid_t fid, int do_write) if ( ( HDstrcmp( rbuf3[i].name, wbuf[i].name ) != 0 ) || rbuf3[i].lati != wbuf[i].lati || rbuf3[i].longi != wbuf[i].longi || - !H5_DBL_ABS_EQUAL(rbuf3[i].temperature,wbuf[i].temperature) ) { + !H5_DBL_ABS_EQUAL(rbuf3[i].temperature,wbuf[i].temperature) ) { goto out; } } @@ -1603,7 +1601,7 @@ static int test_table(hid_t fid, int do_write) *------------------------------------------------------------------------- */ - TESTING2("getting table info"); + HL_TESTING2("getting table info"); /* get table info */ if ( H5TBget_table_info (fid, "table1", &rfields, &rrecords ) < 0 ) @@ -1624,7 +1622,7 @@ static int test_table(hid_t fid, int do_write) *------------------------------------------------------------------------- */ - TESTING2("getting field info"); + HL_TESTING2("getting field info"); /* alocate */ names_out = (char**) HDmalloc( sizeof(char*) * (size_t)NFIELDS ); |