diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/h5dump/CMakeLists.txt | 12 | ||||
-rw-r--r-- | tools/h5dump/h5dumpgentest.c | 60 | ||||
-rw-r--r-- | tools/h5dump/testh5dump.sh.in | 4 | ||||
-rw-r--r-- | tools/h5stat/testh5stat.sh.in | 14 | ||||
-rw-r--r-- | tools/lib/h5tools_dump.c | 50 | ||||
-rw-r--r-- | tools/lib/h5tools_dump.h | 3 | ||||
-rw-r--r-- | tools/testfiles/tscalarstring.ddl | 28 | ||||
-rw-r--r-- | tools/testfiles/tscalarstring.h5 | bin | 0 -> 2208 bytes |
8 files changed, 139 insertions, 32 deletions
diff --git a/tools/h5dump/CMakeLists.txt b/tools/h5dump/CMakeLists.txt index 8766eb6..c3d3e1b 100644 --- a/tools/h5dump/CMakeLists.txt +++ b/tools/h5dump/CMakeLists.txt @@ -161,6 +161,7 @@ IF (BUILD_TESTING) ${HDF5_TOOLS_SRC_DIR}/testfiles/tsaf.ddl ${HDF5_TOOLS_SRC_DIR}/testfiles/tscalarintsize.ddl ${HDF5_TOOLS_SRC_DIR}/testfiles/tscalarattrintsize.ddl + ${HDF5_TOOLS_SRC_DIR}/testfiles/tscalarstring.ddl ${HDF5_TOOLS_SRC_DIR}/testfiles/tscaleoffset.ddl ${HDF5_TOOLS_SRC_DIR}/testfiles/tshuffle.ddl ${HDF5_TOOLS_SRC_DIR}/testfiles/tslink-1.ddl @@ -264,6 +265,7 @@ IF (BUILD_TESTING) ${HDF5_TOOLS_SRC_DIR}/testfiles/tsaf.h5 ${HDF5_TOOLS_SRC_DIR}/testfiles/tscalarintsize.h5 ${HDF5_TOOLS_SRC_DIR}/testfiles/tscalarattrintsize.h5 + ${HDF5_TOOLS_SRC_DIR}/testfiles/tscalarstring.h5 ${HDF5_TOOLS_SRC_DIR}/testfiles/tslink.h5 ${HDF5_TOOLS_SRC_DIR}/testfiles/tsplit_file-m.h5 ${HDF5_TOOLS_SRC_DIR}/testfiles/tsplit_file-r.h5 @@ -1024,6 +1026,8 @@ IF (BUILD_TESTING) tscalarintsize.out.err tscalarattrintsize.out tscalarattrintsize.out.err + tscalarstring.out + tscalarstring.out.err tscaleoffset.out tscaleoffset.out.err tshuffle.out @@ -1088,15 +1092,15 @@ IF (BUILD_TESTING) # test for compound signed/unsigned datasets ADD_H5_TEST (tcmpdintsize 0 --enable-error-stack tcmpdintsize.h5) # test for signed/unsigned scalar datasets - # TODO: failed on mac with intel compiler. (Allen will work on it) - #ADD_H5_TEST (tscalarintsize 0 --enable-error-stack tscalarintsize.h5) + ADD_H5_TEST (tscalarintsize 0 --enable-error-stack tscalarintsize.h5) # test for signed/unsigned attributes ADD_H5_TEST (tattrintsize 0 --enable-error-stack tattrintsize.h5) # test for compound signed/unsigned attributes ADD_H5_TEST (tcmpdattrintsize 0 --enable-error-stack tcmpdattrintsize.h5) # test for signed/unsigned scalar attributes - # TODO: failed on mac with intel compiler. (Allen will work on it) - #ADD_H5_TEST (tscalarattrintsize 0 --enable-error-stack tscalarattrintsize.h5) + ADD_H5_TEST (tscalarattrintsize 0 --enable-error-stack tscalarattrintsize.h5) + # test for string scalar dataset and attribute + ADD_H5_TEST (tscalarstring 0 --enable-error-stack tscalarstring.h5) # test for displaying groups ADD_H5_TEST (tgroup-1 0 --enable-error-stack tgroup.h5) # test for displaying the selected groups diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c index 1bbb9f9..ac74637 100644 --- a/tools/h5dump/h5dumpgentest.c +++ b/tools/h5dump/h5dumpgentest.c @@ -104,6 +104,7 @@ #define FILE72 "tnestedcmpddt.h5" #define FILE73 "tscalarintsize.h5" #define FILE74 "tscalarattrintsize.h5" +#define FILE75 "tscalarstring.h5" /*------------------------------------------------------------------------- * prototypes @@ -8118,7 +8119,7 @@ static void gent_nested_compound_dt(void) { /* test nested data type */ /*------------------------------------------------------------------------- * Function: gent_intscalars * - * Purpose: Generate a file to be used in the h5dump tests. + * Purpose: Generate a file to be used in the h5dump scalar tests. * Four datasets of 1, 2, 4 and 8 bytes of unsigned int types are created. * Four more datasets of 1, 2, 4 and 8 bytes of signed int types are created. * Fill them with raw data such that no bit will be all zero in a dataset. @@ -8313,9 +8314,9 @@ gent_intscalars(void) } /*------------------------------------------------------------------------- - * Function: gent_attr_packedbits + * Function: gent_attr_intscalars * - * Purpose: Generate a file to be used in the h5dump packed bits tests. + * Purpose: Generate a file to be used in the h5dump attribute scalar tests. * Four attributes of 1, 2, 4 and 8 bytes of unsigned int types are created. * Four more datasets of 1, 2, 4 and 8 bytes of signed int types are created. * Fill them with raw data such that no bit will be all zero in a dataset. @@ -8514,6 +8515,58 @@ gent_attr_intscalars(void) } /*------------------------------------------------------------------------- + * Function: gent_string_scalars + * + * Purpose: Generate a file to be used in the h5dump string scalar tests. + * A dataset of string types are created. + * An attribute of string types are created. + * Fill them with raw data such that no bit will be all zero in a dataset. + *------------------------------------------------------------------------- + */ +static void +gent_string_scalars(void) +{ + hid_t fid, attr, dataset, space, tid, root; + hsize_t dims[2]; + char string[F73_XDIM][F73_YDIM8]; + unsigned int i, j; + + fid = H5Fcreate(FILE75, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + root = H5Gopen2(fid, "/", H5P_DEFAULT); + + /* string scalar */ + dims[0] = F73_XDIM; dims[1] = F73_YDIM8; + space = H5Screate(H5S_SCALAR); + tid = H5Tcopy(H5T_C_S1); + H5Tset_size(tid, F73_XDIM * F73_YDIM8); + + memset(string, ' ', F73_XDIM * F73_YDIM8); + for(i = 0; i < dims[0]; i++) { + string[i][0] = 'A' + i; + for(j = 1; j < dims[1]; j++) { + string[i][j] = string[i][j-1] + 1; + } + } + string[dims[0]-1][dims[1]-1] = 0; + + /* Dataset of string scalar */ + dataset = H5Dcreate2(fid, "the_str", tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + + H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, string); + H5Dclose(dataset); + + /* attribute of string scalar */ + attr = H5Acreate2(root, "attr_str", tid, space, H5P_DEFAULT, H5P_DEFAULT); + H5Awrite(attr, tid, string); + + H5Sclose(space); + H5Aclose(attr); + + H5Gclose(root); + H5Fclose(fid); +} + +/*------------------------------------------------------------------------- * Function: main * *------------------------------------------------------------------------- @@ -8597,6 +8650,7 @@ int main(void) gent_nested_compound_dt(); gent_intscalars(); gent_attr_intscalars(); + gent_string_scalars(); return 0; } diff --git a/tools/h5dump/testh5dump.sh.in b/tools/h5dump/testh5dump.sh.in index c90c364..8a2483b 100644 --- a/tools/h5dump/testh5dump.sh.in +++ b/tools/h5dump/testh5dump.sh.in @@ -145,6 +145,7 @@ $SRC_H5DUMP_TESTFILES/tordergr.h5 $SRC_H5DUMP_TESTFILES/tsaf.h5 $SRC_H5DUMP_TESTFILES/tscalarintsize.h5 $SRC_H5DUMP_TESTFILES/tscalarattrintsize.h5 +$SRC_H5DUMP_TESTFILES/tscalarstring.h5 $SRC_H5DUMP_TESTFILES/tslink.h5 $SRC_H5DUMP_TESTFILES/tsplit_file-m.h5 $SRC_H5DUMP_TESTFILES/tsplit_file-r.h5 @@ -281,6 +282,7 @@ $SRC_H5DUMP_TESTFILES/treference.ddl $SRC_H5DUMP_TESTFILES/tsaf.ddl $SRC_H5DUMP_TESTFILES/tscalarintsize.ddl $SRC_H5DUMP_TESTFILES/tscalarattrintsize.ddl +$SRC_H5DUMP_TESTFILES/tscalarstring.ddl $SRC_H5DUMP_TESTFILES/tscaleoffset.ddl $SRC_H5DUMP_TESTFILES/tshuffle.ddl $SRC_H5DUMP_TESTFILES/tslink-1.ddl @@ -690,6 +692,8 @@ TOOLTEST tattrintsize.ddl --enable-error-stack tattrintsize.h5 TOOLTEST tcmpdattrintsize.ddl --enable-error-stack tcmpdattrintsize.h5 # test for signed/unsigned scalar attributes TOOLTEST tscalarattrintsize.ddl --enable-error-stack tscalarattrintsize.h5 +# test for string scalar dataset attribute +TOOLTEST tscalarstring.ddl --enable-error-stack tscalarstring.h5 # test for displaying groups TOOLTEST tgroup-1.ddl --enable-error-stack tgroup.h5 # test for displaying the selected groups diff --git a/tools/h5stat/testh5stat.sh.in b/tools/h5stat/testh5stat.sh.in index 74071d0..ab97698 100644 --- a/tools/h5stat/testh5stat.sh.in +++ b/tools/h5stat/testh5stat.sh.in @@ -133,6 +133,9 @@ TESTING() { echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012' } +# Source in the output filter function definitions. +. $srcdir/../../bin/output_filter.sh + # Run a test and print PASS or *FAIL*. If a test fails then increment # the `nerrors' global variable and (if $verbose is set) display the # difference between the actual output and the expected output. The @@ -145,6 +148,8 @@ TOOLTEST() { expect="$TESTDIR/$1" actual="$TESTDIR/`basename $1 .ddl`.out" actual_err="$TESTDIR/`basename $1 .ddl`.err" + actual_sav=${actual}-sav + actual_err_sav=${actual_err}-sav shift # Run test. @@ -156,8 +161,13 @@ TOOLTEST() { cd $TESTDIR $RUNSERIAL $STAT_BIN $@ ) >$actual 2>$actual_err - cat $actual_err >> $actual + # save actual and actual_err in case they are needed later. + cp $actual $actual_sav + STDOUT_FILTER $actual + cp $actual_err $actual_err_sav + STDERR_FILTER $actual_err + cat $actual_err >> $actual if [ ! -f $expect ]; then # Create the expect file if it doesn't yet exist. @@ -174,7 +184,7 @@ TOOLTEST() { # Clean up output file if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actual_err + rm -f $actual $actual_err $actual_sav $actual_err_sav fi } diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c index c2add9a..c68c699 100644 --- a/tools/lib/h5tools_dump.c +++ b/tools/lib/h5tools_dump.c @@ -30,10 +30,6 @@ #include "h5tools_utils.h" #include "H5private.h" -#define SANITY_CHECK - -#define ALIGN(A,Z) ((((A) + (Z) - 1) / (Z)) * (Z)) - h5tool_format_t h5tools_dataformat = { 0, /*raw */ @@ -214,6 +210,12 @@ hbool_t h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id, hsize_t *curr_pos/*total data element position*/, size_t ncols, hsize_t region_elmt_counter/*element counter*/, hsize_t elmt_counter); + +void h5tools_print_dims(h5tools_str_t *buffer, hsize_t *s, int dims); + +void h5tools_dump_subsetting_header(FILE *stream, const h5tool_format_t *info, + h5tools_context_t *ctx, struct subset_t *sset, int dims); + void h5tools_dump_init(void) { @@ -627,7 +629,11 @@ h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id, alloc_size = nblocks * ndims * 2 * sizeof(ptdata[0]); HDassert(alloc_size == (hsize_t) ((size_t) alloc_size)); /*check for overflow*/ if((ptdata = (hsize_t*) HDmalloc((size_t) alloc_size)) == NULL) - HGOTO_ERROR(dimension_break, H5E_tools_min_id_g, "Could not allocate buffer for ptdata"); +{ + HERROR(H5E_tools_g, H5E_tools_min_id_g, "Could not allocate buffer for ptdata"); + HGOTO_DONE(dimension_break); + //HGOTO_ERROR(dimension_break, H5E_tools_min_id_g, "Could not allocate buffer for ptdata"); +} H5_CHECK_OVERFLOW(nblocks, hssize_t, hsize_t); if(H5Sget_select_hyper_blocklist(region_space, (hsize_t) 0, (hsize_t) nblocks, ptdata) < 0) @@ -688,7 +694,7 @@ h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id, h5tools_str_reset(buffer); h5tools_str_append(buffer, "%s ", h5tools_dump_header_format->dataspacebegin); - h5tools_print_dataspace(stream, buffer, info, ctx, region_space); + h5tools_print_dataspace(buffer, region_space); if (HDstrlen(h5tools_dump_header_format->dataspaceblockend)) { h5tools_str_append(buffer, "%s", h5tools_dump_header_format->dataspaceblockend); @@ -1007,7 +1013,7 @@ h5tools_dump_region_data_points(hid_t region_space, hid_t region_id, ctx->need_prefix = TRUE; h5tools_str_append(buffer, "%s ", h5tools_dump_header_format->dataspacebegin); - h5tools_print_dataspace(stream, buffer, info, ctx, region_space); + h5tools_print_dataspace(buffer, region_space); if (HDstrlen(h5tools_dump_header_format->dataspaceblockend)) { h5tools_str_append(buffer, "%s", h5tools_dump_header_format->dataspaceblockend); @@ -2211,7 +2217,7 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_ /* Check C variable-length string first. Are the two types equal? */ if (H5Tequal(tmp_type, str_type)) { h5tools_str_append(buffer, "H5T_C_S1;"); - goto done; + goto found_string_type; } /* Change the endianness and see if they're equal. */ @@ -2223,7 +2229,7 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_ if (H5Tequal(tmp_type, str_type)) { h5tools_str_append(buffer, "H5T_C_S1;"); - goto done; + goto found_string_type; } /* If not equal to C variable-length string, check Fortran type. */ @@ -2238,7 +2244,7 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_ /* Are the two types equal? */ if (H5Tequal(tmp_type, str_type)) { h5tools_str_append(buffer, "H5T_FORTRAN_S1;"); - goto done; + goto found_string_type; } /* Change the endianness and see if they're equal. */ @@ -2250,13 +2256,13 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_ if (H5Tequal(tmp_type, str_type)) { h5tools_str_append(buffer, "H5T_FORTRAN_S1;"); - goto done; + goto found_string_type; } /* Type doesn't match any of above. */ h5tools_str_append(buffer, "unknown_one_character_type;"); - done: + found_string_type: h5tools_render_element(stream, info, ctx, buffer, &curr_pos, ncols, 0, 0); ctx->indent_level--; @@ -2307,7 +2313,10 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_ h5tools_render_element(stream, info, ctx, buffer, &curr_pos, ncols, 0, 0); ctx->indent_level++; { - char *ttag = H5Tget_tag(type); + char *ttag; + + if(NULL == (ttag = H5Tget_tag(type))) + H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_tag failed"); ctx->need_prefix = TRUE; h5tools_simple_prefix(stream, info, ctx, 0, 0); @@ -2316,8 +2325,7 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_ h5tools_str_append(buffer, "OPAQUE_TAG \"%s\";", ttag); h5tools_render_element(stream, info, ctx, buffer, &curr_pos, ncols, 0, 0); - if (ttag) - HDfree(ttag); + HDfree(ttag); } ctx->indent_level--; @@ -2478,8 +2486,7 @@ CATCH *------------------------------------------------------------------------- */ int -h5tools_print_dataspace(FILE *stream, h5tools_str_t *buffer, const h5tool_format_t *info, - h5tools_context_t *ctx, hid_t space) +h5tools_print_dataspace(h5tools_str_t *buffer, hid_t space) { HERR_INIT(int, SUCCEED) hsize_t size[H5TOOLS_DUMP_MAX_RANK]; @@ -2769,7 +2776,7 @@ h5tools_dump_dataspace(FILE *stream, const h5tool_format_t *info, h5tools_str_append(&buffer, "%s ", h5tools_dump_header_format->dataspacebegin); - h5tools_print_dataspace(stream, &buffer, info, ctx, type); + h5tools_print_dataspace(&buffer, type); if (HDstrlen(h5tools_dump_header_format->dataspaceblockend)) { h5tools_str_append(&buffer, "%s", h5tools_dump_header_format->dataspaceblockend); @@ -2841,7 +2848,6 @@ h5tools_print_fill_value(h5tools_str_t *buffer/*in,out*/, const h5tool_format_t { size_t size; hid_t n_type; - hsize_t nelmts = 1; void *buf = NULL; n_type = h5tools_get_native_type(type_id); @@ -3563,7 +3569,8 @@ h5tools_print_dims(h5tools_str_t *buffer, hsize_t *s, int dims) for (i = 0; i < dims; i++) { h5tools_str_append(buffer, HSIZE_T_FORMAT, s[i]); - if (i + 1 != dims) h5tools_str_append(buffer, ", "); + if (i + 1 != dims) + h5tools_str_append(buffer, ", "); } } @@ -3866,7 +3873,7 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, buf = HDmalloc((size_t)alloc_size); HDassert(buf); - if (H5Aread(obj_id, p_type, buf) >= 0) + if (H5Aread(obj_id, p_type, buf) >= 0) { if (display_char && H5Tget_size(type) == 1 && H5Tget_class(type) == H5T_INTEGER) { /* * Print 1-byte integer data as an ASCII character string @@ -3895,6 +3902,7 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, } else datactx.need_prefix = TRUE; + } status = h5tools_dump_mem(stream, info, &datactx, obj_id, p_type, space, buf); if (display_char && H5Tget_size(type) == 1 && H5Tget_class(type) == H5T_INTEGER) { diff --git a/tools/lib/h5tools_dump.h b/tools/lib/h5tools_dump.h index 55e046b..86f9f99 100644 --- a/tools/lib/h5tools_dump.h +++ b/tools/lib/h5tools_dump.h @@ -67,8 +67,7 @@ H5TOOLS_DLL void h5tools_dump_data(FILE *stream, const h5tool_format_t *info, H5TOOLS_DLL int h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer/*in,out*/, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, hid_t type, int object_search); -H5TOOLS_DLL int h5tools_print_dataspace(FILE *stream, h5tools_str_t *buffer/*in,out*/, - const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, +H5TOOLS_DLL int h5tools_print_dataspace(h5tools_str_t *buffer/*in,out*/, hid_t space); H5TOOLS_DLL int h5tools_print_enum(FILE *stream, h5tools_str_t *buffer/*in,out*/, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, diff --git a/tools/testfiles/tscalarstring.ddl b/tools/testfiles/tscalarstring.ddl new file mode 100644 index 0000000..4ba7093 --- /dev/null +++ b/tools/testfiles/tscalarstring.ddl @@ -0,0 +1,28 @@ +HDF5 "tscalarstring.h5" { +GROUP "/" { + ATTRIBUTE "attr_str" { + DATATYPE H5T_STRING { + STRSIZE 64; + STRPAD H5T_STR_NULLTERM; + CSET H5T_CSET_ASCII; + CTYPE H5T_C_S1; + } + DATASPACE SCALAR + DATA { + (0): "ABCDEFGHBCDEFGHICDEFGHIJDEFGHIJKEFGHIJKLFGHIJKLMGHIJKLMNHIJKLMNO" + } + } + DATASET "the_str" { + DATATYPE H5T_STRING { + STRSIZE 64; + STRPAD H5T_STR_NULLTERM; + CSET H5T_CSET_ASCII; + CTYPE H5T_C_S1; + } + DATASPACE SCALAR + DATA { + (0): "ABCDEFGHBCDEFGHICDEFGHIJDEFGHIJKEFGHIJKLFGHIJKLMGHIJKLMNHIJKLMNO" + } + } +} +} diff --git a/tools/testfiles/tscalarstring.h5 b/tools/testfiles/tscalarstring.h5 Binary files differnew file mode 100644 index 0000000..b0993ef --- /dev/null +++ b/tools/testfiles/tscalarstring.h5 |