From d1ed626845ff1a17bc1667f32789ea0670408904 Mon Sep 17 00:00:00 2001 From: Jacob Smith Date: Tue, 14 May 2019 13:53:28 -0500 Subject: Fit help message to 80 character width and clarify some details. --- tools/src/h5repack/h5repack_main.c | 71 +++++++++++++++---------- tools/test/h5repack/testfiles/h5repack-help.txt | 71 +++++++++++++++---------- 2 files changed, 88 insertions(+), 54 deletions(-) diff --git a/tools/src/h5repack/h5repack_main.c b/tools/src/h5repack/h5repack_main.c index dec25f9..1852e30 100644 --- a/tools/src/h5repack/h5repack_main.c +++ b/tools/src/h5repack/h5repack_main.c @@ -83,13 +83,17 @@ static void usage(const char *prog) { PRINTVALSTREAM(rawoutstream, " -v, --verbose Verbose mode, print object information\n"); PRINTVALSTREAM(rawoutstream, " -V, --version Print version number and exit\n"); PRINTVALSTREAM(rawoutstream, " -n, --native Use a native HDF5 type when repacking\n"); - PRINTVALSTREAM(rawoutstream, " --enable-error-stack Prints messages from the HDF5 error stack as they occur\n"); + PRINTVALSTREAM(rawoutstream, " --enable-error-stack Prints messages from the HDF5 error stack as they\n"); + PRINTVALSTREAM(rawoutstream, " occur\n"); PRINTVALSTREAM(rawoutstream, " -L, --latest Use latest version of file format\n"); - PRINTVALSTREAM(rawoutstream, " This option will take precedence over the -j and -k options\n"); - PRINTVALSTREAM(rawoutstream, " --low=BOUND The low bound for library release versions to use when creating\n"); - PRINTVALSTREAM(rawoutstream, " objects in the file (default is H5F_LIBVER_EARLIEST)\n"); - PRINTVALSTREAM(rawoutstream, " --high=BOUND The high bound for library release versions to use when creating\n"); - PRINTVALSTREAM(rawoutstream, " objects in the file (default is H5F_LIBVER_LATEST)\n"); + PRINTVALSTREAM(rawoutstream, " This option will take precedence over the options\n"); + PRINTVALSTREAM(rawoutstream, " --low and --high\n"); + PRINTVALSTREAM(rawoutstream, " --low=BOUND The low bound for library release versions to use\n"); + PRINTVALSTREAM(rawoutstream, " when creating objects in the file (default is 0\n"); + PRINTVALSTREAM(rawoutstream, " [H5F_LIBVER_EARLIEST])\n"); + PRINTVALSTREAM(rawoutstream, " --high=BOUND The high bound for library release versions to use\n"); + PRINTVALSTREAM(rawoutstream, " when creating objects in the file (default is 2\n"); + PRINTVALSTREAM(rawoutstream, " [H5F_LIBVER_V110 this release; H5F_LIBVER_LATEST])\n"); PRINTVALSTREAM(rawoutstream, " -c L1, --compact=L1 Maximum number of links in header messages\n"); PRINTVALSTREAM(rawoutstream, " -d L2, --indexed=L2 Minimum number of links in the indexed format\n"); PRINTVALSTREAM(rawoutstream, " -s S[:F], --ssize=S[:F] Shared object header message minimum size\n"); @@ -104,10 +108,14 @@ static void usage(const char *prog) { PRINTVALSTREAM(rawoutstream, " -z Z, --sort_order=Z Sort groups and attributes by order Z\n"); PRINTVALSTREAM(rawoutstream, " -f FILT, --filter=FILT Filter type\n"); PRINTVALSTREAM(rawoutstream, " -l LAYT, --layout=LAYT Layout type\n"); - PRINTVALSTREAM(rawoutstream, " -S FS_STRATEGY, --fs_strategy=FS_STRATEGY File space management strategy for H5Pset_file_space_strategy\n"); - PRINTVALSTREAM(rawoutstream, " -P FS_PERSIST, --fs_persist=FS_PERSIST Persisting or not persisting free-space for H5Pset_file_space_strategy\n"); - PRINTVALSTREAM(rawoutstream, " -T FS_THRESHOLD, --fs_threshold=FS_THRESHOLD Free-space section threshold for H5Pset_file_space_strategy\n"); - PRINTVALSTREAM(rawoutstream, " -G FS_PAGESIZE, --fs_pagesize=FS_PAGESIZE File space page size for H5Pset_file_space_page_size\n"); + PRINTVALSTREAM(rawoutstream, " -S FS_STRATEGY, --fs_strategy=FS_STRATEGY File space management strategy for\n"); + PRINTVALSTREAM(rawoutstream, " H5Pset_file_space_strategy\n"); + PRINTVALSTREAM(rawoutstream, " -P FS_PERSIST, --fs_persist=FS_PERSIST Persisting or not persisting free-\n"); + PRINTVALSTREAM(rawoutstream, " space for H5Pset_file_space_strategy\n"); + PRINTVALSTREAM(rawoutstream, " -T FS_THRESHOLD, --fs_threshold=FS_THRESHOLD Free-space section threshold\n"); + PRINTVALSTREAM(rawoutstream, " for H5Pset_file_space_strategy\n"); + PRINTVALSTREAM(rawoutstream, " -G FS_PAGESIZE, --fs_pagesize=FS_PAGESIZE File space page size for\n"); + PRINTVALSTREAM(rawoutstream, " H5Pset_file_space_page_size\n"); PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, " M - is an integer greater than 1, size of dataset in bytes (default is 0)\n"); PRINTVALSTREAM(rawoutstream, " E - is a filename.\n"); @@ -115,15 +123,17 @@ static void usage(const char *prog) { PRINTVALSTREAM(rawoutstream, " U - is a filename.\n"); PRINTVALSTREAM(rawoutstream, " T - is an integer\n"); PRINTVALSTREAM(rawoutstream, " A - is an integer greater than zero\n"); - PRINTVALSTREAM(rawoutstream, " Q - is the sort index type for the input file. It can be \"name\" or \"creation_order\" (default)\n"); - PRINTVALSTREAM(rawoutstream, " Z - is the sort order type for the input file. It can be \"descending\" or \"ascending\" (default)\n"); + PRINTVALSTREAM(rawoutstream, " Q - is the sort index type for the input file. It can be \"name\" or\n"); + PRINTVALSTREAM(rawoutstream, " \"creation_order\" (default)\n"); + PRINTVALSTREAM(rawoutstream, " Z - is the sort order type for the input file. It can be \"descending\" or\n"); + PRINTVALSTREAM(rawoutstream, " \"ascending\" (default)\n"); PRINTVALSTREAM(rawoutstream, " B - is the user block size, any value that is 512 or greater and is\n"); PRINTVALSTREAM(rawoutstream, " a power of 2 (1024 default)\n"); PRINTVALSTREAM(rawoutstream, " F - is the shared object header message type, any of . If F is not specified, S applies to all messages\n"); PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " BOUND is an integer indicating the library release versions to use when creating\n"); - PRINTVALSTREAM(rawoutstream, " objects in the file (see H5Pset_libver_bounds()):\n"); + PRINTVALSTREAM(rawoutstream, " BOUND is an integer indicating the library release versions to use when\n"); + PRINTVALSTREAM(rawoutstream, " creating objects in the file (see H5Pset_libver_bounds()):\n"); PRINTVALSTREAM(rawoutstream, " 0: This is H5F_LIBVER_EARLIEST in H5F_libver_t struct\n"); PRINTVALSTREAM(rawoutstream, " 1: This is H5F_LIBVER_V18 in H5F_libver_t struct\n"); PRINTVALSTREAM(rawoutstream, " 2: This is H5F_LIBVER_V110 in H5F_libver_t struct\n"); @@ -131,24 +141,31 @@ static void usage(const char *prog) { PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, " FS_STRATEGY is a string indicating the file space strategy used:\n"); PRINTVALSTREAM(rawoutstream, " FSM_AGGR:\n"); - PRINTVALSTREAM(rawoutstream, " The mechanisms used in managing file space are free-space managers, aggregators and virtual file driver.\n"); + PRINTVALSTREAM(rawoutstream, " The mechanisms used in managing file space are free-space\n"); + PRINTVALSTREAM(rawoutstream, " managers, aggregators and virtual file driver.\n"); PRINTVALSTREAM(rawoutstream, " PAGE:\n"); - PRINTVALSTREAM(rawoutstream, " The mechanisms used in managing file space are free-space managers with embedded paged aggregation and virtual file driver.\n"); + PRINTVALSTREAM(rawoutstream, " The mechanisms used in managing file space are free-space\n"); + PRINTVALSTREAM(rawoutstream, " managers with embedded paged aggregation and virtual file driver.\n"); PRINTVALSTREAM(rawoutstream, " AGGR:\n"); - PRINTVALSTREAM(rawoutstream, " The mechanisms used in managing file space are aggregators and virtual file driver.\n"); + PRINTVALSTREAM(rawoutstream, " The mechanisms used in managing file space are aggregators and\n"); + PRINTVALSTREAM(rawoutstream, " virtual file driver.\n"); PRINTVALSTREAM(rawoutstream, " NONE:\n"); - PRINTVALSTREAM(rawoutstream, " The mechanisms used in managing file space are virtual file driver.\n"); - PRINTVALSTREAM(rawoutstream, " The default strategy when not set is FSM_AGGR without persisting free-space.\n"); + PRINTVALSTREAM(rawoutstream, " The mechanisms used in managing file space are virtual file\n"); + PRINTVALSTREAM(rawoutstream, " driver.\n"); + PRINTVALSTREAM(rawoutstream, " The default strategy when not set is FSM_AGGR without persisting free-\n"); + PRINTVALSTREAM(rawoutstream, " space.\n"); PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, " FS_PERSIST is 1 to persisting free-space or 0 to not persisting free-space.\n"); PRINTVALSTREAM(rawoutstream, " The default when not set is not persisting free-space.\n"); PRINTVALSTREAM(rawoutstream, " The value is ignored for AGGR and NONE strategies.\n"); PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " FS_THRESHOLD is the minimum size (in bytes) of free-space sections to be tracked by the library.\n"); + PRINTVALSTREAM(rawoutstream, " FS_THRESHOLD is the minimum size (in bytes) of free-space sections to be\n"); + PRINTVALSTREAM(rawoutstream, " tracked by the library.\n"); PRINTVALSTREAM(rawoutstream, " The default when not set is 1.\n"); PRINTVALSTREAM(rawoutstream, " The value is ignored for AGGR and NONE strategies.\n"); PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " FS_PAGESIZE is the size (in bytes) >=512 that is used by the library when the file space strategy PAGE is used.\n"); + PRINTVALSTREAM(rawoutstream, " FS_PAGESIZE is the size (in bytes) >=512 that is used by the library when\n"); + PRINTVALSTREAM(rawoutstream, " the file space strategy PAGE is used.\n"); PRINTVALSTREAM(rawoutstream, " The default when not set is 4096.\n"); PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, " FILT - is a string with the format:\n"); @@ -176,9 +193,9 @@ static void usage(const char *prog) { PRINTVALSTREAM(rawoutstream, " NBIT (no parameter)\n"); PRINTVALSTREAM(rawoutstream, " SOFF= scale_factor is an integer and scale_type\n"); PRINTVALSTREAM(rawoutstream, " is either IN or DS\n"); - PRINTVALSTREAM(rawoutstream, " UD=\n"); - PRINTVALSTREAM(rawoutstream, " required values for filter_number,filter_flag,cd_value_count,value_1\n"); - PRINTVALSTREAM(rawoutstream, " optional values for value_2 to value_N\n"); + PRINTVALSTREAM(rawoutstream, " UD=\n"); + PRINTVALSTREAM(rawoutstream, " Required values: filter_number, filter_flag, cd_value_count, value1\n"); + PRINTVALSTREAM(rawoutstream, " Optional values: value2 to valueN\n"); PRINTVALSTREAM(rawoutstream, " NONE (no parameter)\n"); PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, " LAYT - is a string with the format:\n"); @@ -215,12 +232,12 @@ static void usage(const char *prog) { PRINTVALSTREAM(rawoutstream, "4) h5repack -L -c 10 -s 20:dtype file1 file2\n"); PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, " Using latest file format with maximum compact group size of 10 and\n"); - PRINTVALSTREAM(rawoutstream, " and minimum shared datatype size of 20\n"); + PRINTVALSTREAM(rawoutstream, " minimum shared datatype size of 20\n"); PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, "5) h5repack --low=0 --high=1 file1 file2\n"); PRINTVALSTREAM(rawoutstream, "\n"); - PRINTVALSTREAM(rawoutstream, " Set low=H5F_LIBVER_EARLIEST and high=H5F_LIBVER_V18 via H5Pset_libver_bounds() when\n"); - PRINTVALSTREAM(rawoutstream, " creating the repacked file: file2\n"); + PRINTVALSTREAM(rawoutstream, " Set low=H5F_LIBVER_EARLIEST and high=H5F_LIBVER_V18 via\n"); + PRINTVALSTREAM(rawoutstream, " H5Pset_libver_bounds() when creating the repacked file, file2\n"); PRINTVALSTREAM(rawoutstream, "\n"); PRINTVALSTREAM(rawoutstream, "5) h5repack -f SHUF -f GZIP=1 file1 file2\n"); PRINTVALSTREAM(rawoutstream, "\n"); diff --git a/tools/test/h5repack/testfiles/h5repack-help.txt b/tools/test/h5repack/testfiles/h5repack-help.txt index 0eef0f5..ad07784 100644 --- a/tools/test/h5repack/testfiles/h5repack-help.txt +++ b/tools/test/h5repack/testfiles/h5repack-help.txt @@ -6,13 +6,17 @@ usage: h5repack [OPTIONS] file1 file2 -v, --verbose Verbose mode, print object information -V, --version Print version number and exit -n, --native Use a native HDF5 type when repacking - --enable-error-stack Prints messages from the HDF5 error stack as they occur + --enable-error-stack Prints messages from the HDF5 error stack as they + occur -L, --latest Use latest version of file format - This option will take precedence over the -j and -k options - --low=BOUND The low bound for library release versions to use when creating - objects in the file (default is H5F_LIBVER_EARLIEST) - --high=BOUND The high bound for library release versions to use when creating - objects in the file (default is H5F_LIBVER_LATEST) + This option will take precedence over the options + --low and --high + --low=BOUND The low bound for library release versions to use + when creating objects in the file (default is 0 + [H5F_LIBVER_EARLIEST]) + --high=BOUND The high bound for library release versions to use + when creating objects in the file (default is 2 + [H5F_LIBVER_V110 this release; H5F_LIBVER_LATEST]) -c L1, --compact=L1 Maximum number of links in header messages -d L2, --indexed=L2 Minimum number of links in the indexed format -s S[:F], --ssize=S[:F] Shared object header message minimum size @@ -27,10 +31,14 @@ usage: h5repack [OPTIONS] file1 file2 -z Z, --sort_order=Z Sort groups and attributes by order Z -f FILT, --filter=FILT Filter type -l LAYT, --layout=LAYT Layout type - -S FS_STRATEGY, --fs_strategy=FS_STRATEGY File space management strategy for H5Pset_file_space_strategy - -P FS_PERSIST, --fs_persist=FS_PERSIST Persisting or not persisting free-space for H5Pset_file_space_strategy - -T FS_THRESHOLD, --fs_threshold=FS_THRESHOLD Free-space section threshold for H5Pset_file_space_strategy - -G FS_PAGESIZE, --fs_pagesize=FS_PAGESIZE File space page size for H5Pset_file_space_page_size + -S FS_STRATEGY, --fs_strategy=FS_STRATEGY File space management strategy for + H5Pset_file_space_strategy + -P FS_PERSIST, --fs_persist=FS_PERSIST Persisting or not persisting free- + space for H5Pset_file_space_strategy + -T FS_THRESHOLD, --fs_threshold=FS_THRESHOLD Free-space section threshold + for H5Pset_file_space_strategy + -G FS_PAGESIZE, --fs_pagesize=FS_PAGESIZE File space page size for + H5Pset_file_space_page_size M - is an integer greater than 1, size of dataset in bytes (default is 0) E - is a filename. @@ -38,15 +46,17 @@ usage: h5repack [OPTIONS] file1 file2 U - is a filename. T - is an integer A - is an integer greater than zero - Q - is the sort index type for the input file. It can be "name" or "creation_order" (default) - Z - is the sort order type for the input file. It can be "descending" or "ascending" (default) + Q - is the sort index type for the input file. It can be "name" or + "creation_order" (default) + Z - is the sort order type for the input file. It can be "descending" or + "ascending" (default) B - is the user block size, any value that is 512 or greater and is a power of 2 (1024 default) F - is the shared object header message type, any of . If F is not specified, S applies to all messages - BOUND is an integer indicating the library release versions to use when creating - objects in the file (see H5Pset_libver_bounds()): + BOUND is an integer indicating the library release versions to use when + creating objects in the file (see H5Pset_libver_bounds()): 0: This is H5F_LIBVER_EARLIEST in H5F_libver_t struct 1: This is H5F_LIBVER_V18 in H5F_libver_t struct 2: This is H5F_LIBVER_V110 in H5F_libver_t struct @@ -54,24 +64,31 @@ usage: h5repack [OPTIONS] file1 file2 FS_STRATEGY is a string indicating the file space strategy used: FSM_AGGR: - The mechanisms used in managing file space are free-space managers, aggregators and virtual file driver. + The mechanisms used in managing file space are free-space + managers, aggregators and virtual file driver. PAGE: - The mechanisms used in managing file space are free-space managers with embedded paged aggregation and virtual file driver. + The mechanisms used in managing file space are free-space + managers with embedded paged aggregation and virtual file driver. AGGR: - The mechanisms used in managing file space are aggregators and virtual file driver. + The mechanisms used in managing file space are aggregators and + virtual file driver. NONE: - The mechanisms used in managing file space are virtual file driver. - The default strategy when not set is FSM_AGGR without persisting free-space. + The mechanisms used in managing file space are virtual file + driver. + The default strategy when not set is FSM_AGGR without persisting free- + space. FS_PERSIST is 1 to persisting free-space or 0 to not persisting free-space. The default when not set is not persisting free-space. The value is ignored for AGGR and NONE strategies. - FS_THRESHOLD is the minimum size (in bytes) of free-space sections to be tracked by the library. + FS_THRESHOLD is the minimum size (in bytes) of free-space sections to be + tracked by the library. The default when not set is 1. The value is ignored for AGGR and NONE strategies. - FS_PAGESIZE is the size (in bytes) >=512 that is used by the library when the file space strategy PAGE is used. + FS_PAGESIZE is the size (in bytes) >=512 that is used by the library when + the file space strategy PAGE is used. The default when not set is 4096. FILT - is a string with the format: @@ -99,9 +116,9 @@ usage: h5repack [OPTIONS] file1 file2 NBIT (no parameter) SOFF= scale_factor is an integer and scale_type is either IN or DS - UD= - required values for filter_number,filter_flag,cd_value_count,value_1 - optional values for value_2 to value_N + UD= + Required values: filter_number, filter_flag, cd_value_count, value1 + Optional values: value2 to valueN NONE (no parameter) LAYT - is a string with the format: @@ -138,12 +155,12 @@ Examples of use: 4) h5repack -L -c 10 -s 20:dtype file1 file2 Using latest file format with maximum compact group size of 10 and - and minimum shared datatype size of 20 + minimum shared datatype size of 20 5) h5repack --low=0 --high=1 file1 file2 - Set low=H5F_LIBVER_EARLIEST and high=H5F_LIBVER_V18 via H5Pset_libver_bounds() when - creating the repacked file: file2 + Set low=H5F_LIBVER_EARLIEST and high=H5F_LIBVER_V18 via + H5Pset_libver_bounds() when creating the repacked file, file2 5) h5repack -f SHUF -f GZIP=1 file1 file2 -- cgit v0.12 From ea8c99cc56ac1ce8a385fab2e142e6cc417536ef Mon Sep 17 00:00:00 2001 From: Jacob Smith Date: Fri, 24 May 2019 16:57:47 -0500 Subject: refactor h5repack_main.c -- remove some redundancy, formatting --- tools/src/h5repack/h5repack_main.c | 307 ++++++++++++++++--------------------- 1 file changed, 134 insertions(+), 173 deletions(-) diff --git a/tools/src/h5repack/h5repack_main.c b/tools/src/h5repack/h5repack_main.c index 1852e30..efab3f0 100644 --- a/tools/src/h5repack/h5repack_main.c +++ b/tools/src/h5repack/h5repack_main.c @@ -23,7 +23,8 @@ static void leave(int ret) H5_ATTR_NORETURN; /* module-scoped variables */ -static int has_i_o = 0; +static int has_i = 0; +static int has_o = 0; const char *infile = NULL; const char *outfile = NULL; @@ -33,34 +34,34 @@ const char *outfile = NULL; */ static const char *s_opts = "hVvf:l:m:e:nLj:k:c:d:s:u:b:M:t:a:i:o:S:P:T:G:q:z:E"; static struct long_options l_opts[] = { - { "help", no_arg, 'h' }, - { "version", no_arg, 'V' }, - { "verbose", no_arg, 'v' }, - { "filter", require_arg, 'f' }, - { "layout", require_arg, 'l' }, - { "minimum", require_arg, 'm' }, - { "file", require_arg, 'e' }, - { "native", no_arg, 'n' }, - { "latest", no_arg, 'L' }, - { "low", require_arg, 'j' }, - { "high", require_arg, 'k' }, - { "compact", require_arg, 'c' }, - { "indexed", require_arg, 'd' }, - { "ssize", require_arg, 's' }, - { "ublock", require_arg, 'u' }, - { "block", require_arg, 'b' }, + { "help", no_arg, 'h' }, + { "version", no_arg, 'V' }, + { "verbose", no_arg, 'v' }, + { "filter", require_arg, 'f' }, + { "layout", require_arg, 'l' }, + { "minimum", require_arg, 'm' }, + { "file", require_arg, 'e' }, + { "native", no_arg, 'n' }, + { "latest", no_arg, 'L' }, + { "low", require_arg, 'j' }, + { "high", require_arg, 'k' }, + { "compact", require_arg, 'c' }, + { "indexed", require_arg, 'd' }, + { "ssize", require_arg, 's' }, + { "ublock", require_arg, 'u' }, + { "block", require_arg, 'b' }, { "metadata_block_size", require_arg, 'M' }, - { "threshold", require_arg, 't' }, - { "alignment", require_arg, 'a' }, - { "infile", require_arg, 'i' }, /* -i for backward compability */ - { "outfile", require_arg, 'o' }, /* -o for backward compability */ - { "fs_strategy", require_arg, 'S' }, - { "fs_persist", require_arg, 'P' }, - { "fs_threshold", require_arg, 'T' }, - { "fs_pagesize", require_arg, 'G' }, - { "sort_by", require_arg, 'q' }, - { "sort_order", require_arg, 'z' }, - { "enable-error-stack", no_arg, 'E' }, + { "threshold", require_arg, 't' }, + { "alignment", require_arg, 'a' }, + { "infile", require_arg, 'i' }, /* for backward compability */ + { "outfile", require_arg, 'o' }, /* for backward compability */ + { "fs_strategy", require_arg, 'S' }, + { "fs_persist", require_arg, 'P' }, + { "fs_threshold", require_arg, 'T' }, + { "fs_pagesize", require_arg, 'G' }, + { "sort_by", require_arg, 'q' }, + { "sort_order", require_arg, 'z' }, + { "enable-error-stack", no_arg, 'E' }, { NULL, 0, '\0' } }; @@ -281,7 +282,8 @@ int read_info(const char *filename, pack_opt_t *options) int i, rc = 1; int ret_value = EXIT_SUCCESS; - if ((fp = HDfopen(filename, "r")) == (FILE *) NULL) { + fp = HDfopen(filename, "r"); + if ((FILE *)NULL == fp) { error_msg("cannot open options file %s\n", filename); h5tools_setstatus(EXIT_FAILURE); ret_value = EXIT_FAILURE; @@ -290,90 +292,46 @@ int read_info(const char *filename, pack_opt_t *options) /* cycle until end of file reached */ while (1) { - rc = fscanf(fp, "%s", stype); - if (rc == -1) - break; - - /*------------------------------------------------------------------------- - * filter - *------------------------------------------------------------------------- - */ - if (HDstrcmp(stype,"-f") == 0) { - /* find begining of info */ - i = 0; - c = '0'; - while (c != ' ') { - if(fscanf(fp, "%c", &c) < 0 && HDferror(fp)) { - error_msg("fscanf error\n"); - h5tools_setstatus(EXIT_FAILURE); - ret_value = EXIT_FAILURE; - goto done; - } /* end if */ - if (HDfeof(fp)) - break; - } - c = '0'; - /* go until end */ - while (c != ' ') { - if(fscanf(fp, "%c", &c) < 0 && HDferror(fp)) { - error_msg("fscanf error\n"); - h5tools_setstatus(EXIT_FAILURE); - ret_value = EXIT_FAILURE; - goto done; - } /* end if */ - comp_info[i] = c; - i++; - if (HDfeof(fp)) - break; - if (c == 10 /*eol*/) - break; - } - comp_info[i - 1] = '\0'; /*cut the last " */ - if (h5repack_addfilter(comp_info, options) == -1) { - error_msg("could not add compression option\n"); + /* Info indicator must be for layout or filter */ + if (HDstrcmp(stype,"-l") && HDstrcmp(stype, "-f")) { + error_msg("bad file format for %s", filename); + h5tools_setstatus(EXIT_FAILURE); + ret_value = EXIT_FAILURE; + goto done; + } + + /* find begining of info */ + i = 0; + c = '0'; + while (c != ' ') { + if (fscanf(fp, "%c", &c) < 0 && HDferror(fp)) { + error_msg("fscanf error\n"); h5tools_setstatus(EXIT_FAILURE); ret_value = EXIT_FAILURE; goto done; } + if (HDfeof(fp)) + break; } - /*------------------------------------------------------------------------- - * layout - *------------------------------------------------------------------------- - */ - else if (HDstrcmp(stype,"-l") == 0) { - - /* find begining of info */ - i = 0; - c = '0'; - while (c != ' ') { - if(fscanf(fp, "%c", &c) < 0 && HDferror(fp)) { - error_msg("fscanf error\n"); - h5tools_setstatus(EXIT_FAILURE); - ret_value = EXIT_FAILURE; - goto done; - } /* end if */ - if (HDfeof(fp)) - break; - } - c = '0'; - /* go until end */ - while (c != ' ') { - if(fscanf(fp, "%c", &c) < 0 && HDferror(fp)) { - error_msg("fscanf error\n"); - h5tools_setstatus(EXIT_FAILURE); - ret_value = EXIT_FAILURE; - goto done; - } /* end if */ - comp_info[i] = c; - i++; - if (HDfeof(fp)) - break; - if (c == 10 /*eol*/) - break; + c = '0'; + /* go until end */ + while (c != ' ') { + if (fscanf(fp, "%c", &c) < 0 && HDferror(fp)) { + error_msg("fscanf error\n"); + h5tools_setstatus(EXIT_FAILURE); + ret_value = EXIT_FAILURE; + goto done; } - comp_info[i - 1] = '\0'; /*cut the last " */ + comp_info[i++] = c; + if (HDfeof(fp)) + break; + if (c == 10 /*eol*/) + break; + } + comp_info[i - 1] = '\0'; /*cut the last " */ + if (!HDstrcmp(stype, "-l")) { if (h5repack_addlayout(comp_info, options) == -1) { error_msg("could not add chunck option\n"); h5tools_setstatus(EXIT_FAILURE); @@ -381,17 +339,15 @@ int read_info(const char *filename, pack_opt_t *options) goto done; } } - /*------------------------------------------------------------------------- - * not valid - *------------------------------------------------------------------------- - */ else { - error_msg("bad file format for %s", filename); - h5tools_setstatus(EXIT_FAILURE); - ret_value = EXIT_FAILURE; - goto done; + if (h5repack_addfilter(comp_info, options) == -1) { + error_msg("could not add compression option\n"); + h5tools_setstatus(EXIT_FAILURE); + ret_value = EXIT_FAILURE; + goto done; + } } - } + } /* end while info-read cycling */ done: if (fp) @@ -415,9 +371,10 @@ set_sort_by(const char *form) { H5_index_t idx_type = H5_INDEX_UNKNOWN; - if (HDstrcmp(form,"name")==0) /* H5_INDEX_NAME */ + if (!HDstrcmp(form, "name")) idx_type = H5_INDEX_NAME; - else if (HDstrcmp(form,"creation_order")==0) /* H5_INDEX_CRT_ORDER */ + else + if (!HDstrcmp(form, "creation_order")) idx_type = H5_INDEX_CRT_ORDER; return idx_type; @@ -438,9 +395,10 @@ set_sort_order(const char *form) { H5_iter_order_t iter_order = H5_ITER_UNKNOWN; - if (HDstrcmp(form,"ascending")==0) /* H5_ITER_INC */ + if (!HDstrcmp(form, "ascending")) iter_order = H5_ITER_INC; - else if (HDstrcmp(form,"descending")==0) /* H5_ITER_DEC */ + else + if (!HDstrcmp(form, "descending")) iter_order = H5_ITER_DEC; return iter_order; @@ -459,19 +417,19 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) int ret_value = 0; /* parse command line options */ - while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { + while (EOF != (opt = get_option(argc, argv, s_opts, l_opts))) { switch ((char) opt) { /* -i for backward compatibility */ case 'i': infile = opt_arg; - has_i_o = 1; + has_i++; break; /* -o for backward compatibility */ case 'o': outfile = opt_arg; - has_i_o = 1; + has_o++; break; case 'h': @@ -536,7 +494,7 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) case 'j': options->low_bound = (H5F_libver_t)HDatoi(opt_arg); - if(options->low_bound < H5F_LIBVER_EARLIEST || options->low_bound > H5F_LIBVER_LATEST) { + if (options->low_bound < H5F_LIBVER_EARLIEST || options->low_bound > H5F_LIBVER_LATEST) { error_msg("in parsing low bound\n"); goto done; } @@ -544,7 +502,7 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) case 'k': options->high_bound = (H5F_libver_t)HDatoi(opt_arg); - if(options->high_bound < H5F_LIBVER_EARLIEST || options->high_bound > H5F_LIBVER_LATEST) { + if (options->high_bound < H5F_LIBVER_EARLIEST || options->high_bound > H5F_LIBVER_LATEST) { error_msg("in parsing high bound\n"); goto done; } @@ -566,10 +524,10 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) { int idx = 0; int ssize = 0; - char *msgPtr = HDstrchr( opt_arg, ':'); + char *msgPtr = HDstrchr(opt_arg, ':'); options->latest = TRUE; /* must use latest format */ if (msgPtr == NULL) { - ssize = HDatoi( opt_arg ); + ssize = HDatoi(opt_arg); for (idx = 0; idx < 5; idx++) options->msg_size[idx] = ssize; } @@ -579,15 +537,19 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) HDstrcpy(msgType, msgPtr + 1); msgPtr[0] = '\0'; ssize = HDatoi( opt_arg ); - if (HDstrncmp(msgType, "dspace",6) == 0) + if (!HDstrncmp(msgType, "dspace", 6)) options->msg_size[0] = ssize; - else if (HDstrncmp(msgType, "dtype", 5) == 0) + else + if (!HDstrncmp(msgType, "dtype", 5)) options->msg_size[1] = ssize; - else if (HDstrncmp(msgType, "fill", 4) == 0) + else + if (!HDstrncmp(msgType, "fill", 4)) options->msg_size[2] = ssize; - else if (HDstrncmp(msgType, "pline", 5) == 0) + else + if (!HDstrncmp(msgType, "pline", 5)) options->msg_size[3] = ssize; - else if (HDstrncmp(msgType, "attr", 4) == 0) + else + if (!HDstrncmp(msgType, "attr", 4)) options->msg_size[4] = ssize; } } @@ -624,13 +586,16 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) char strategy[MAX_NC_NAME]; HDstrcpy(strategy, opt_arg); - if(!HDstrcmp(strategy, "FSM_AGGR")) + if (!HDstrcmp(strategy, "FSM_AGGR")) options->fs_strategy = H5F_FSPACE_STRATEGY_FSM_AGGR; - else if(!HDstrcmp(strategy, "PAGE")) + else + if (!HDstrcmp(strategy, "PAGE")) options->fs_strategy = H5F_FSPACE_STRATEGY_PAGE; - else if(!HDstrcmp(strategy, "AGGR")) + else + if (!HDstrcmp(strategy, "AGGR")) options->fs_strategy = H5F_FSPACE_STRATEGY_AGGR; - else if(!HDstrcmp(strategy, "NONE")) + else + if (!HDstrcmp(strategy, "NONE")) options->fs_strategy = H5F_FSPACE_STRATEGY_NONE; else { error_msg("invalid file space management strategy\n", opt_arg); @@ -638,7 +603,7 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) ret_value = -1; goto done; } - if(options->fs_strategy == (H5F_fspace_strategy_t)0) + if (options->fs_strategy == (H5F_fspace_strategy_t)0) /* To distinguish the "specified" zero value */ options->fs_strategy = (H5F_fspace_strategy_t)-1; } @@ -646,27 +611,27 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) case 'P': options->fs_persist = HDatoi(opt_arg); - if(options->fs_persist == 0) + if (options->fs_persist == 0) /* To distinguish the "specified" zero value */ options->fs_persist = -1; break; case 'T': options->fs_threshold = HDatol(opt_arg); - if(options->fs_threshold == 0) + if (options->fs_threshold == 0) /* To distinguish the "specified" zero value */ options->fs_threshold = -1; break; case 'G': options->fs_pagesize = HDstrtoll(opt_arg, NULL, 0); - if(options->fs_pagesize == 0) + if (options->fs_pagesize == 0) /* To distinguish the "specified" zero value */ options->fs_pagesize = -1; break; case 'q': - if((sort_by = set_sort_by(opt_arg)) < 0) { + if (H5_INDEX_UNKNOWN == set_sort_by(opt_arg)) { error_msg(" failed to set sort by form <%s>\n", opt_arg); h5tools_setstatus(EXIT_FAILURE); ret_value = -1; @@ -675,7 +640,7 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) break; case 'z': - if((sort_order = set_sort_order(opt_arg)) < 0) { + if (H5_ITER_UNKNOWN == set_sort_order(opt_arg)) { error_msg(" failed to set sort order form <%s>\n", opt_arg); h5tools_setstatus(EXIT_FAILURE); ret_value = -1; @@ -690,17 +655,35 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) default: break; } /* switch */ - } /* while */ - - if (has_i_o == 0) { - /* check for file names to be processed */ - if (argc <= opt_ind || argv[opt_ind + 1] == NULL) { - error_msg("missing file names\n"); - usage(h5tools_getprogname()); - h5tools_setstatus(EXIT_FAILURE); - ret_value = -1; - } - } + } /* end while there are more options to parse */ + + /* If neither -i nor -o given, get in and out files positionally */ + if (0 == (has_i + has_o)) { + if (argv[opt_ind] != NULL && argv[opt_ind + 1] != NULL) { + infile = argv[opt_ind]; + outfile = argv[opt_ind + 1]; + + if (!HDstrcmp(infile, outfile)) { + error_msg("file names cannot be the same\n"); + usage(h5tools_getprogname()); + h5tools_setstatus(EXIT_FAILURE); + ret_value = -1; + } + } + else { + error_msg("file names missing\n"); + usage(h5tools_getprogname()); + h5tools_setstatus(EXIT_FAILURE); + ret_value = -1; + } + } + else + if (has_i != 1 || has_o != 1) { + error_msg("filenames must be either both -i -o or both positional\n"); + usage(h5tools_getprogname()); + h5tools_setstatus(EXIT_FAILURE); + ret_value = -1; + } done: return ret_value; @@ -757,28 +740,6 @@ int main(int argc, const char **argv) if (parse_command_line(argc, argv, &options) < 0) goto done; - /* get file names if they were not yet got */ - if (has_i_o == 0) { - - if (argv[opt_ind] != NULL && argv[opt_ind + 1] != NULL) { - infile = argv[opt_ind]; - outfile = argv[opt_ind + 1]; - - if ( HDstrcmp( infile, outfile ) == 0) { - error_msg("file names cannot be the same\n"); - usage(h5tools_getprogname()); - h5tools_setstatus(EXIT_FAILURE); - goto done; - } - } - else { - error_msg("file names missing\n"); - usage(h5tools_getprogname()); - h5tools_setstatus(EXIT_FAILURE); - goto done; - } - } - if (enable_error_stack > 0) { H5Eset_auto2(H5E_DEFAULT, func, edata); H5Eset_auto2(H5tools_ERR_STACK_g, tools_func, tools_edata); -- cgit v0.12 From eb93107f9f413528f4ef4adf277491013193a390 Mon Sep 17 00:00:00 2001 From: Jacob Smith Date: Fri, 24 May 2019 16:58:31 -0500 Subject: Add test that uses the family member FAPL setting. --- test/vfd.c | 112 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) diff --git a/test/vfd.c b/test/vfd.c index 2305593..7c1d9d5 100644 --- a/test/vfd.c +++ b/test/vfd.c @@ -1113,6 +1113,117 @@ error: /*------------------------------------------------------------------------- + * Function: test_family_member_fapl + * + * Purpose: Actually use the member fapl input to the member vfd. + * + * Return: 0 - success + * -1 - failure + * + * Programmer: Jacob Smith + * 21 May 2019 + * + *------------------------------------------------------------------------- + */ +static herr_t +test_family_member_fapl(void) +{ + hid_t file; + hid_t fapl_id; + hid_t memb_fapl_id; + hid_t space; + hid_t dset; + char filename[1024]; + char dname[] = "dataset"; + unsigned i; + unsigned j; + int buf[FAMILY_NUMBER][FAMILY_SIZE]; + hsize_t dims[2] = {FAMILY_NUMBER, FAMILY_SIZE}; + + TESTING("Family member FAPL"); + + fapl_id = H5Pcreate(H5P_FILE_ACCESS); + if (H5I_INVALID_HID == fapl_id) + TEST_ERROR; + memb_fapl_id = H5Pcreate(H5P_FILE_ACCESS); + if (H5I_INVALID_HID == memb_fapl_id) + TEST_ERROR; + if (H5Pset_fapl_sec2(memb_fapl_id) == FAIL) + TEST_ERROR; + if (H5Pset_fapl_family(fapl_id, (hsize_t)FAMILY_SIZE, memb_fapl_id) == FAIL) + TEST_ERROR; + h5_fixname(FILENAME[2], fapl_id, filename, sizeof(filename)); + + file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); + if (H5I_INVALID_HID == file) + TEST_ERROR; + + space = H5Screate_simple(2, dims, NULL); + if (H5I_INVALID_HID == space) + TEST_ERROR; + + /* Create and write to dataset, then close file. + */ + dset = H5Dcreate2( + file, + dname, + H5T_NATIVE_INT, + space, + H5P_DEFAULT, + H5P_DEFAULT, + H5P_DEFAULT); + if (H5I_INVALID_HID == dset) + TEST_ERROR; + for (i = 0; i < FAMILY_NUMBER; i++) + for (j = 0; j < FAMILY_SIZE; j++) + buf[i][j] = (int)((i * 10000) + j); + if (H5Dwrite(dset, + H5T_NATIVE_INT, + H5S_ALL, + H5S_ALL, + H5P_DEFAULT, + buf) + == FAIL) + TEST_ERROR; + if (H5Dclose(dset) == FAIL) TEST_ERROR; + if (H5Sclose(space) == FAIL) TEST_ERROR; + if (H5Fclose(file) == FAIL) TEST_ERROR; + + /* "Close" member FAPL at top level and re-open file. + * Should succeed, with library managing reference count properly + */ + if (H5Pclose(memb_fapl_id) == FAIL) + TEST_ERROR; + + file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id); + if (H5I_INVALID_HID == file) + TEST_ERROR; + + if (H5Fclose(file) == FAIL) + TEST_ERROR; + + h5_delete_test_file(FILENAME[2], fapl_id); + + if (H5Pclose(fapl_id) == FAIL) + TEST_ERROR; + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY{ + H5Sclose(space); + H5Dclose(dset); + H5Pclose(memb_fapl_id); + H5Pclose(fapl_id); + H5Fclose(file); + } H5E_END_TRY; + + return -1; +} /* end test_family_member_fapl() */ + + +/*------------------------------------------------------------------------- * Function: test_multi_opens * * Purpose: Private function for test_multi() to tests wrong ways of @@ -1917,6 +2028,7 @@ main(void) nerrors += test_direct() < 0 ? 1 : 0; nerrors += test_family() < 0 ? 1 : 0; nerrors += test_family_compat() < 0 ? 1 : 0; + nerrors += test_family_member_fapl() < 0 ? 1 : 0; nerrors += test_multi() < 0 ? 1 : 0; nerrors += test_multi_compat() < 0 ? 1 : 0; nerrors += test_log() < 0 ? 1 : 0; -- cgit v0.12 From 132efb2b6943ecabd6f3950a4b52817201bd3513 Mon Sep 17 00:00:00 2001 From: Jacob Smith Date: Fri, 24 May 2019 16:59:14 -0500 Subject: Some minor reformatting. Replace tabs with spaces. --- test/external.c | 434 +++++++++++++++++++++++++++++++------------------------- 1 file changed, 241 insertions(+), 193 deletions(-) diff --git a/test/external.c b/test/external.c index 6aa9d1b..619ca62 100644 --- a/test/external.c +++ b/test/external.c @@ -15,7 +15,7 @@ * Programmer: Robb Matzke * Tuesday, March 3, 1998 * - * Purpose: Tests datasets stored in external raw files. + * Purpose: Tests datasets stored in external raw files. */ #include "external_common.h" @@ -26,7 +26,7 @@ * Purpose: Determines whether two files contain the same data. * * Return: Success: nonzero if same, zero if different. - * Failure: zero + * Failure: zero * * Programmer: Robb Matzke * Wednesday, March 4, 1998 @@ -36,14 +36,19 @@ static hbool_t files_have_same_contents(const char *name1, const char *name2) { - int fd1 = 0, fd2 = 0; - ssize_t n1, n2; - char buf1[1024], buf2[1024]; + int fd1 = 0; + int fd2 = 0; + ssize_t n1; + ssize_t n2; + char buf1[1024]; + char buf2[1024]; hbool_t ret = FALSE; /* not equal until proven otherwise */ - if((fd1 = HDopen(name1, O_RDONLY)) < 0) + fd1 = HDopen(name1, O_RDONLY); + if(fd1 < 0) goto out; - if((fd2 = HDopen(name2, O_RDONLY)) < 0) + fd2 = HDopen(name2, O_RDONLY); + if(fd2 < 0) goto out; /* Loop until files are empty or we encounter a problem */ @@ -96,28 +101,29 @@ out: static int test_non_extendible(hid_t file) { - hid_t dcpl = -1; /* dataset creation properties */ - hid_t space = -1; /* data space */ - hid_t dset = -1; /* dataset */ - hsize_t cur_size[1]; /* data space current size */ - hsize_t max_size[1]; /* data space maximum size */ - int n; /* number of external files */ - char name[256]; /* external file name */ - off_t file_offset; /* external file offset */ - hsize_t file_size; /* sizeof external file segment */ - haddr_t dset_addr; /* address of dataset */ + hid_t dcpl = -1; /* dataset creation properties */ + hid_t space = -1; /* data space */ + hid_t dset = -1; /* dataset */ + hsize_t cur_size[1] = {100}; /* data space current size */ + hsize_t max_size[1] = {100}; /* data space maximum size */ + int n; /* number of external files */ + off_t file_offset; /* external file offset */ + hsize_t file_size; /* sizeof external file segment */ + haddr_t dset_addr; /* address of dataset */ TESTING("fixed-size data space, exact storage"); - /* Create the dataset */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + /* Create the dataset and close */ + dcpl = H5Pcreate(H5P_DATASET_CREATE); + if(dcpl < 0) FAIL_STACK_ERROR - cur_size[0] = max_size[0] = 100; if(H5Pset_external(dcpl, "ext1.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int))) < 0) FAIL_STACK_ERROR - if((space = H5Screate_simple(1, cur_size, max_size)) < 0) + space = H5Screate_simple(1, cur_size, max_size); + if(space < 0) FAIL_STACK_ERROR - if((dset = H5Dcreate2(file, "dset1", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + dset = H5Dcreate2(file, "dset1", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); + if(dset < 0) FAIL_STACK_ERROR if(H5Dclose(dset) < 0) FAIL_STACK_ERROR @@ -127,7 +133,8 @@ test_non_extendible(hid_t file) FAIL_STACK_ERROR /* Read dataset creation information */ - if((dset = H5Dopen2(file, "dset1", H5P_DEFAULT)) < 0) + dset = H5Dopen2(file, "dset1", H5P_DEFAULT); + if(dset < 0) FAIL_STACK_ERROR /* Test dataset address. Should be undefined. */ @@ -138,36 +145,34 @@ test_non_extendible(hid_t file) FAIL_STACK_ERROR /* Check external count */ - if((dcpl = H5Dget_create_plist(dset)) < 0) + dcpl = H5Dget_create_plist(dset); + if(dcpl < 0) FAIL_STACK_ERROR - if((n = H5Pget_external_count(dcpl)) < 0) + n = H5Pget_external_count(dcpl); + if(n < 0) FAIL_STACK_ERROR if(1 != n) { H5_FAILED(); HDputs(" Returned external count is wrong."); printf(" got: %d\n ans: 1\n", n); goto error; - } /* end if */ + } - HDstrcpy(name + sizeof(name) - 4, "..."); - if(H5Pget_external(dcpl, 0, sizeof(name) - 4, name, &file_offset, &file_size) < 0) + /* Verify external file settings */ + if(H5Pget_external(dcpl, 0, 0, NULL, &file_offset, &file_size) < 0) FAIL_STACK_ERROR - - /* Check file offset */ if(file_offset != 0) { H5_FAILED(); HDputs(" Wrong file offset."); printf(" got: %lu\n ans: 0\n", (unsigned long)file_offset); goto error; - } /* end if */ - - /* Check file size */ + } if(file_size != (max_size[0] * sizeof(int))) { H5_FAILED(); HDputs(" Wrong file size."); printf(" got: %lu\n ans: %lu\n", (unsigned long)file_size, (unsigned long)max_size[0]*sizeof(int)); goto error; - } /* end if */ + } /* Done (dataspace was previously closed) */ if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR @@ -194,7 +199,7 @@ test_non_extendible(hid_t file) * Return: Success: 0 * Failure: 1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, November 23, 1998 * *------------------------------------------------------------------------- @@ -202,20 +207,21 @@ test_non_extendible(hid_t file) static int test_too_small(hid_t file) { - hid_t dcpl = -1; /* dataset creation properties */ - hid_t space = -1; /* data space */ - hid_t dset = -1; /* dataset */ - hsize_t cur_size[1]; /* current data space size */ - hsize_t max_size[1]; /* maximum data space size */ + hid_t dcpl = -1; /* dataset creation properties */ + hid_t space = -1; /* data space */ + hid_t dset = -1; /* dataset */ + hsize_t cur_size[1] = {100}; /* current data space size */ + hsize_t max_size[1] = {100}; /* maximum data space size */ TESTING("external storage is too small"); - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + dcpl = H5Pcreate(H5P_DATASET_CREATE); + if(dcpl < 0) FAIL_STACK_ERROR - cur_size[0] = max_size[0] = 100; - if(H5Pset_external(dcpl, "ext1.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int) - 1)) < 0) + if(H5Pset_external(dcpl, "ext1.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int) - 1)) < 0) /* note -1 */ FAIL_STACK_ERROR - if((space = H5Screate_simple(1, cur_size, max_size)) < 0) + space = H5Screate_simple(1, cur_size, max_size); + if(space < 0) FAIL_STACK_ERROR H5E_BEGIN_TRY { @@ -248,10 +254,10 @@ test_too_small(hid_t file) * represent the current data and large enough to represent the * eventual size of the data. * - * Return: Success: 0 - * Failure: 1 + * Return: Success: 0 + * Failure: 1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, November 23, 1998 * *------------------------------------------------------------------------- @@ -259,23 +265,24 @@ test_too_small(hid_t file) static int test_large_enough_current_eventual(hid_t file) { - hid_t dcpl = -1; /* dataset creation properties */ - hid_t space = -1; /* data space */ - hid_t dset = -1; /* dataset */ - hsize_t cur_size[1]; /* current data space size */ - hsize_t max_size[1]; /* maximum data space size */ + hid_t dcpl = -1; /* dataset creation properties */ + hid_t space = -1; /* data space */ + hid_t dset = -1; /* dataset */ + hsize_t cur_size[1] = {100}; /* current data space size */ + hsize_t max_size[1] = {200}; /* maximum data space size */ TESTING("extendible dataspace, exact external size"); - if((dcpl = H5Pcreate (H5P_DATASET_CREATE)) < 0) + dcpl = H5Pcreate (H5P_DATASET_CREATE); + if(dcpl < 0) FAIL_STACK_ERROR - cur_size[0] = 100; - max_size[0] = 200; if(H5Pset_external(dcpl, "ext1.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int))) < 0) FAIL_STACK_ERROR - if((space = H5Screate_simple(1, cur_size, max_size)) < 0) + space = H5Screate_simple(1, cur_size, max_size); + if(space < 0) FAIL_STACK_ERROR - if((dset = H5Dcreate2(file, "dset3", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + dset = H5Dcreate2(file, "dset3", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); + if(dset < 0) FAIL_STACK_ERROR if(H5Dclose(dset) < 0) FAIL_STACK_ERROR @@ -312,21 +319,21 @@ error: static int test_large_enough_current_not_eventual(hid_t file) { - hid_t dcpl = -1; /* dataset creation properties */ - hid_t space = -1; /* data space */ - hid_t dset = -1; /* dataset */ - hsize_t cur_size[1]; /* current data space size */ - hsize_t max_size[1]; /* maximum data space size */ + hid_t dcpl = -1; /* dataset creation properties */ + hid_t space = -1; /* data space */ + hid_t dset = -1; /* dataset */ + hsize_t cur_size[1] = {100}; /* current data space size */ + hsize_t max_size[1] = {200}; /* maximum data space size */ TESTING("extendible dataspace, external storage is too small"); - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + dcpl = H5Pcreate(H5P_DATASET_CREATE); + if(dcpl < 0) FAIL_STACK_ERROR - cur_size[0] = 100; - max_size[0] = 200; - if(H5Pset_external(dcpl, "ext1.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int) - 1)) < 0) + if(H5Pset_external(dcpl, "ext1.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int) - 1)) < 0) /* note -1 */ FAIL_STACK_ERROR - if((space = H5Screate_simple(1, cur_size, max_size)) < 0) + space = H5Screate_simple(1, cur_size, max_size); + if(space < 0) FAIL_STACK_ERROR H5E_BEGIN_TRY { @@ -368,28 +375,28 @@ test_large_enough_current_not_eventual(hid_t file) static int test_unlimited(hid_t file) { - hid_t dcpl = -1; /* dataset creation properties */ - hid_t space = -1; /* data space */ - hid_t dset = -1; /* dataset */ - hsize_t cur_size[1]; /* data space current size */ - hsize_t max_size[1]; /* data space maximum size */ - int n; /* number of external files */ - char name[256]; /* external file name */ - off_t file_offset; /* external file offset */ - hsize_t file_size; /* sizeof external file segment */ + hid_t dcpl = -1; /* dataset creation properties */ + hid_t space = -1; /* data space */ + hid_t dset = -1; /* dataset */ + hsize_t cur_size[1] = {100}; /* data space current size */ + hsize_t max_size[1] = {H5S_UNLIMITED}; /* data space maximum size */ + int n; /* number of external files */ + off_t file_offset; /* external file offset */ + hsize_t file_size; /* sizeof external file segment */ TESTING("unlimited dataspace, unlimited external storage"); /* Create dataset */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + dcpl = H5Pcreate(H5P_DATASET_CREATE); + if(dcpl < 0) FAIL_STACK_ERROR if(H5Pset_external(dcpl, "ext1.data", (off_t)0, H5F_UNLIMITED) < 0) FAIL_STACK_ERROR - cur_size[0] = 100; - max_size[0] = H5S_UNLIMITED; - if((space = H5Screate_simple(1, cur_size, max_size)) < 0) + space = H5Screate_simple(1, cur_size, max_size); + if(space < 0) FAIL_STACK_ERROR - if((dset = H5Dcreate2(file, "dset5", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + dset = H5Dcreate2(file, "dset5", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); + if(dset < 0) FAIL_STACK_ERROR if(H5Dclose(dset) < 0) FAIL_STACK_ERROR @@ -397,11 +404,14 @@ test_unlimited(hid_t file) if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR /* Read dataset creation information */ - if((dset = H5Dopen2(file, "dset5", H5P_DEFAULT)) < 0) + dset = H5Dopen2(file, "dset5", H5P_DEFAULT); + if(dset < 0) FAIL_STACK_ERROR - if((dcpl = H5Dget_create_plist(dset)) < 0) + dcpl = H5Dget_create_plist(dset); + if(dcpl < 0) FAIL_STACK_ERROR - if((n = H5Pget_external_count(dcpl)) < 0) + n = H5Pget_external_count(dcpl); + if(n < 0) FAIL_STACK_ERROR if(1 != n) { H5_FAILED(); @@ -410,22 +420,20 @@ test_unlimited(hid_t file) goto error; } /* end if */ - HDstrcpy(name + sizeof(name) - 4, "..."); - if(H5Pget_external(dcpl, 0, sizeof(name) - 4, name, &file_offset, &file_size) < 0) + if(H5Pget_external(dcpl, 0, 0, NULL, &file_offset, &file_size) < 0) FAIL_STACK_ERROR if(file_offset != 0) { H5_FAILED(); HDputs(" Wrong file offset."); printf(" got: %lu\n ans: 0\n", (unsigned long)file_offset); goto error; - } /* end if */ - + } if(H5F_UNLIMITED != file_size) { H5_FAILED(); HDputs(" Wrong file size."); printf(" got: %lu\n ans: INF\n", (unsigned long)file_size); goto error; - } /* end if */ + } if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR if(H5Dclose(dset) < 0) FAIL_STACK_ERROR @@ -459,35 +467,71 @@ test_unlimited(hid_t file) static int test_multiple_files(hid_t file) { - hid_t dcpl = -1; /* dataset creation properties */ - hid_t space = -1; /* dataspace */ - hid_t dset = -1; /* dataset */ - hsize_t cur_size[1]; /* data space current size */ - hsize_t max_size[1]; /* data space maximum size */ + hid_t dcpl = -1; /* dataset creation properties */ + hid_t space = -1; /* dataspace */ + hid_t dset = -1; /* dataset */ + hsize_t cur_size[1] = {100}; /* data space current size */ + hsize_t max_size[1] = {100}; /* data space maximum size */ + hsize_t max_ext_size; /* maximum size of external files */ + unsigned n_external_files = 4; TESTING("multiple external files"); - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + dcpl = H5Pcreate(H5P_DATASET_CREATE); + if(dcpl < 0) FAIL_STACK_ERROR - cur_size[0] = max_size[0] = 100; + max_ext_size = (hsize_t)(sizeof(int) * max_size[0] / n_external_files); - if(H5Pset_external(dcpl, "ext1.data", (off_t)0, (hsize_t)(max_size[0]*sizeof(int)/4)) < 0) - FAIL_STACK_ERROR - if(H5Pset_external(dcpl, "ext2.data", (off_t)0, (hsize_t)(max_size[0]*sizeof(int)/4)) < 0) - FAIL_STACK_ERROR - if(H5Pset_external(dcpl, "ext3.data", (off_t)0, (hsize_t)(max_size[0]*sizeof(int)/4)) < 0) - FAIL_STACK_ERROR - if(H5Pset_external(dcpl, "ext4.data", (off_t)0, (hsize_t)(max_size[0]*sizeof(int)/4)) < 0) - FAIL_STACK_ERROR - if((space = H5Screate_simple(1, cur_size, max_size)) < 0) + for (unsigned i = 0; i < n_external_files; i++) { + char exname[9] = ""; + HDsnprintf(exname, 9, "ext%d.data", i+1); + if (H5Pset_external(dcpl, exname, (off_t)0, max_ext_size) < 0) { + HDfprintf(stderr, "Problem adding external file %s\n", exname); + fflush(stderr); + FAIL_STACK_ERROR + } + } + + space = H5Screate_simple(1, cur_size, max_size); + if(space < 0) FAIL_STACK_ERROR - if((dset = H5Dcreate2(file, "dset6", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + + dset = H5Dcreate2(file, "dset6", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); + if(dset < 0) FAIL_STACK_ERROR if(H5Dclose(dset) < 0) FAIL_STACK_ERROR - if(H5Sclose(space) < 0) FAIL_STACK_ERROR if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR + /* Re-use space below */ + + /* ---------------------------------------------- + * Verify that too-small external files will fail + */ + dcpl = H5Pcreate(H5P_DATASET_CREATE); + if(dcpl < 0) + FAIL_STACK_ERROR + + max_ext_size -= 1; + + for (unsigned i = 0; i < n_external_files; i++) { + char exname[9] = ""; + HDsnprintf(exname, 9, "ext%d.data", i+1); + if (H5Pset_external(dcpl, exname, (off_t)0, max_ext_size) < 0) { + HDfprintf(stderr, "Problem adding external file %s\n", exname); + fflush(stderr); + FAIL_STACK_ERROR + } + } + + H5E_BEGIN_TRY { + dset = H5Dcreate2(file, "dset7", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); + } H5E_END_TRY; + if(dset >= 0) + FAIL_PUTS_ERROR(" Small external files succeeded instead of failing."); + + if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR + if(H5Sclose(space) < 0) FAIL_STACK_ERROR PASSED(); return 0; @@ -519,13 +563,14 @@ error: static int test_add_to_unlimited(void) { - hid_t dcpl = -1; /* dataset creation properties */ - herr_t status; /* function return status */ - int n; /* number of external files */ + hid_t dcpl = -1; /* dataset creation properties */ + herr_t status; /* function return status */ + int n; /* number of external files */ TESTING("external file following unlimited file"); - if((dcpl = H5Pcreate (H5P_DATASET_CREATE)) < 0) + dcpl = H5Pcreate (H5P_DATASET_CREATE); + if(dcpl < 0) FAIL_STACK_ERROR if(H5Pset_external(dcpl, "ext1.data", (off_t)0, H5F_UNLIMITED) < 0) FAIL_STACK_ERROR @@ -536,7 +581,8 @@ test_add_to_unlimited(void) if(status >= 0) FAIL_PUTS_ERROR(" H5Pset_external() succeeded when it should have failed."); - if((n = H5Pget_external_count(dcpl)) < 0) + n = H5Pget_external_count(dcpl); + if(n < 0) FAIL_STACK_ERROR if(1 != n) FAIL_PUTS_ERROR(" Wrong external file count returned."); @@ -570,12 +616,13 @@ test_add_to_unlimited(void) static int test_overflow(void) { - hid_t dcpl = -1; /* dataset creation properties */ - herr_t status; /* return status */ + hid_t dcpl = -1; /* dataset creation properties */ + herr_t status; /* return status */ TESTING("address overflow in external files"); - if((dcpl=H5Pcreate(H5P_DATASET_CREATE)) < 0) + dcpl = H5Pcreate (H5P_DATASET_CREATE); + if(dcpl < 0) FAIL_STACK_ERROR if(H5Pset_external(dcpl, "ext1.data", (off_t)0, H5F_UNLIMITED-1) < 0) FAIL_STACK_ERROR @@ -615,19 +662,19 @@ test_overflow(void) static int test_read_file_set(hid_t fapl) { - hid_t file = -1; /* file to write to */ - hid_t dcpl = -1; /* dataset creation properties */ - hid_t space = -1; /* data space */ - hid_t dset = -1; /* dataset */ - hid_t grp = -1; /* group to emit diagnostics */ - size_t i; /* miscellaneous counter */ - char filename[1024]; /* file names */ - int part[PART_SIZE]; /* raw data buffer (partial) */ + hid_t file = -1; /* file to write to */ + hid_t dcpl = -1; /* dataset creation properties */ + hid_t space = -1; /* data space */ + hid_t dset = -1; /* dataset */ + hid_t grp = -1; /* group to emit diagnostics */ + size_t i; /* miscellaneous counter */ + char filename[1024]; /* file names */ + int part[PART_SIZE]; /* raw data buffer (partial) */ int whole[TOTAL_SIZE]; /* raw data buffer (total) */ - hsize_t cur_size; /* current data space size */ - hid_t hs_space = -1; /* hyperslab data space */ - hsize_t hs_start = 30; /* hyperslab starting offset */ - hsize_t hs_count = 25; /* hyperslab size */ + hsize_t cur_size; /* current data space size */ + hid_t hs_space = -1; /* hyperslab data space */ + hsize_t hs_start = 30; /* hyperslab starting offset */ + hsize_t hs_count = 25; /* hyperslab size */ TESTING("read external dataset"); @@ -656,7 +703,7 @@ test_read_file_set(hid_t fapl) HDsnprintf(filename, sizeof(filename), "extern_%dr.raw", (int) i + 1); if(H5Pset_external(dcpl, filename, (off_t)(i * GARBAGE_PER_FILE), (hsize_t)sizeof(part)) < 0) FAIL_STACK_ERROR - } /* end for */ + } /* Create the dataspace */ cur_size = TOTAL_SIZE; @@ -733,19 +780,19 @@ test_read_file_set(hid_t fapl) static int test_write_file_set(hid_t fapl) { - hid_t file = -1; /* file to which to write */ - hid_t dcpl = -1; /* dataset creation properties */ - hid_t mem_space = -1; /* memory data space */ - hid_t file_space = -1; /* file data space */ - hid_t dset = -1; /* dataset */ - unsigned i; /* miscellaneous counter */ - int part[PART_SIZE]; /* raw data buffer (partial) */ - int whole[TOTAL_SIZE]; /* raw data buffer (total) */ - hsize_t cur_size = 100; /* current data space size */ - hsize_t max_size = 200; /* maximum data space size */ - hsize_t hs_start = 100; /* hyperslab starting offset */ - hsize_t hs_count = 100; /* hyperslab size */ - char filename[1024]; /* file name */ + hid_t file = -1; /* file to which to write */ + hid_t dcpl = -1; /* dataset creation properties */ + hid_t mem_space = -1; /* memory data space */ + hid_t file_space = -1; /* file data space */ + hid_t dset = -1; /* dataset */ + unsigned i; /* miscellaneous counter */ + int part[PART_SIZE]; /* raw data buffer (partial) */ + int whole[TOTAL_SIZE]; /* raw data buffer (total) */ + hsize_t cur_size = 100; /* current data space size */ + hsize_t max_size = 200; /* maximum data space size */ + hsize_t hs_start = 100; /* hyperslab starting offset */ + hsize_t hs_count = 100; /* hyperslab size */ + char filename[1024]; /* file name */ TESTING("write external dataset"); @@ -858,16 +905,16 @@ test_write_file_set(hid_t fapl) static int test_path_absolute(hid_t fapl) { - hid_t file = -1; /* file to write to */ - hid_t dcpl = -1; /* dataset creation properties */ - hid_t space = -1; /* data space */ - hid_t dset = -1; /* dataset */ - size_t i; /* miscellaneous counter */ - char cwdpath[1024]; /* working directory */ - char filename[1024]; /* file name */ - int part[PART_SIZE]; /* raw data buffer (partial) */ + hid_t file = -1; /* file to write to */ + hid_t dcpl = -1; /* dataset creation properties */ + hid_t space = -1; /* data space */ + hid_t dset = -1; /* dataset */ + size_t i; /* miscellaneous counter */ + char cwdpath[1024]; /* working directory */ + char filename[1024]; /* file name */ + int part[PART_SIZE]; /* raw data buffer (partial) */ int whole[TOTAL_SIZE]; /* raw data buffer (total) */ - hsize_t cur_size; /* current data space size */ + hsize_t cur_size; /* current data space size */ TESTING("absolute filenames for external file"); @@ -948,16 +995,16 @@ error: static int test_path_relative(hid_t fapl) { - hid_t file = -1; /* file to write to */ - hid_t dcpl = -1; /* dataset creation properties */ - hid_t space = -1; /* data space */ - hid_t dset = -1; /* dataset */ - size_t i; /* miscellaneous counters */ - char cwdpath[1024]; /* working directory */ - char filename[1024]; /* file name */ - int part[PART_SIZE]; /* raw data buffer (partial) */ + hid_t file = -1; /* file to write to */ + hid_t dcpl = -1; /* dataset creation properties */ + hid_t space = -1; /* data space */ + hid_t dset = -1; /* dataset */ + size_t i; /* miscellaneous counters */ + char cwdpath[1024]; /* working directory */ + char filename[1024]; /* file name */ + int part[PART_SIZE]; /* raw data buffer (partial) */ int whole[TOTAL_SIZE]; /* raw data buffer (total) */ - hsize_t cur_size; /* current data space size */ + hsize_t cur_size; /* current data space size */ TESTING("filenames relative to current directory for external file"); @@ -1038,21 +1085,21 @@ error: static int test_path_relative_cwd(hid_t fapl) { - hid_t file = -1; /* file to write to */ - hid_t dcpl = -1; /* dataset creation properties */ - hid_t space = -1; /* data space */ - hid_t dapl = -1; /* dataset access property list */ - hid_t dapl2 = -1; /* copy of dapl */ - hid_t dset = -1; /* dataset */ - hid_t dset2 = -1; /* dataset, opened a second time */ - hid_t dset3 = -1; /* dataset, opened with different prefix */ - size_t i; /* miscellaneous counters */ - char cwdpath[1024]; /* working directory */ - char filename[1024]; /* file name */ - int part[PART_SIZE]; /* raw data buffer (partial) */ + hid_t file = -1; /* file to write to */ + hid_t dcpl = -1; /* dataset creation properties */ + hid_t space = -1; /* data space */ + hid_t dapl = -1; /* dataset access property list */ + hid_t dapl2 = -1; /* copy of dapl */ + hid_t dset = -1; /* dataset */ + hid_t dset2 = -1; /* dataset, opened a second time */ + hid_t dset3 = -1; /* dataset, opened with different prefix */ + size_t i; /* miscellaneous counters */ + char cwdpath[1024]; /* working directory */ + char filename[1024]; /* file name */ + int part[PART_SIZE]; /* raw data buffer (partial) */ int whole[TOTAL_SIZE]; /* raw data buffer (total) */ - hsize_t cur_size; /* current data space size */ - char buffer[1024]; /* buffer to read efile_prefix */ + hsize_t cur_size; /* current data space size */ + char buffer[1024]; /* buffer to read efile_prefix */ TESTING("filenames relative to HDF5 file for external file"); @@ -1194,14 +1241,14 @@ error: static int test_h5d_get_access_plist(hid_t fapl_id) { - hid_t fid = -1; /* file to write to */ - hid_t dcpl_id = -1; /* dataset creation properties */ - hid_t dapl_id = -1; /* dataset access properties */ - hid_t sid = -1; /* data space */ - hid_t did = -1; /* dataset */ - hsize_t dims = 0; /* dataset size */ - char *buffer = NULL; /* saved prefix name from dapl */ - char filename[1024]; /* file names */ + hid_t fid = -1; /* file to write to */ + hid_t dcpl_id = -1; /* dataset creation properties */ + hid_t dapl_id = -1; /* dataset access properties */ + hid_t sid = -1; /* data space */ + hid_t did = -1; /* dataset */ + hsize_t dims = 0; /* dataset size */ + char *buffer = NULL; /* saved prefix name from dapl */ + char filename[1024]; /* file names */ TESTING("H5Dget_access_plist() returns correct prefix"); @@ -1284,7 +1331,7 @@ test_h5d_get_access_plist(hid_t fapl_id) * * Return: EXIT_SUCCESS/EXIT_FAILURE * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Tuesday, March 3, 1998 * *------------------------------------------------------------------------- @@ -1292,13 +1339,13 @@ test_h5d_get_access_plist(hid_t fapl_id) int main(void) { - hid_t fapl_id_old = -1; /* file access properties (old format) */ - hid_t fapl_id_new = -1; /* file access properties (new format) */ - hid_t fid = -1; /* file for test_1* functions */ - hid_t gid = -1; /* group to emit diagnostics */ - char filename[1024]; /* file name for test_1* funcs */ - unsigned latest_format; /* default or latest file format */ - int nerrors = 0; /* number of errors */ + hid_t fapl_id_old = -1; /* file access properties (old format) */ + hid_t fapl_id_new = -1; /* file access properties (new format) */ + hid_t fid = -1; /* file for test_1* functions */ + hid_t gid = -1; /* group to emit diagnostics */ + char filename[1024]; /* file name for test_1* funcs */ + unsigned latest_format; /* default or latest file format */ + int nerrors = 0; /* number of errors */ h5_reset(); @@ -1324,11 +1371,11 @@ main(void) if(latest_format) { HDputs("\nTesting with the latest file format:"); current_fapl_id = fapl_id_new; - } /* end if */ + } else { HDputs("Testing with the default file format:"); current_fapl_id = fapl_id_old; - } /* end else */ + } /* Create the common file used by some of the tests */ if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, current_fapl_id)) < 0) @@ -1364,7 +1411,7 @@ main(void) /* Close the common file */ if(H5Fclose(fid) < 0) FAIL_STACK_ERROR - } /* end for */ + } /* end for old and new format */ if(nerrors > 0) goto error; @@ -1386,7 +1433,7 @@ main(void) HDremove("extern_4w.raw"); HDrmdir("extern_dir"); - } /* end if */ + } return EXIT_SUCCESS; @@ -1401,3 +1448,4 @@ error: printf("%d TEST%s FAILED.\n", nerrors, 1 == nerrors ? "" : "s"); return EXIT_FAILURE; } /* end main() */ + -- cgit v0.12 From 449d6807d5f81eff9db7356eed918d459154ee6c Mon Sep 17 00:00:00 2001 From: Jacob Smith Date: Tue, 28 May 2019 14:12:30 -0500 Subject: Modify code comments for clarity. Some minor reformatting. --- tools/src/h5repack/h5repack.c | 363 +++++++++++++++++++++++++----------------- 1 file changed, 218 insertions(+), 145 deletions(-) diff --git a/tools/src/h5repack/h5repack.c b/tools/src/h5repack/h5repack.c index a63e56f..a8b1458 100644 --- a/tools/src/h5repack/h5repack.c +++ b/tools/src/h5repack/h5repack.c @@ -41,7 +41,9 @@ static int have_request(pack_opt_t *options); * Return: 0, ok, -1, fail *------------------------------------------------------------------------- */ -int h5repack(const char* infile, const char* outfile, pack_opt_t *options) { +int +h5repack(const char* infile, const char* outfile, pack_opt_t *options) +{ /* check input */ if (check_options(options) < 0) return -1; @@ -55,7 +57,7 @@ int h5repack(const char* infile, const char* outfile, pack_opt_t *options) { return -1; return 0; -} +} /* end h5repack() */ /*------------------------------------------------------------------------- * Function: h5repack_init @@ -86,7 +88,7 @@ h5repack_init(pack_opt_t *options, int verbose, hbool_t latest) } return (options_table_init(&(options->op_tbl))); -} +} /* end h5repack_init() */ /*------------------------------------------------------------------------- * Function: h5repack_end @@ -95,9 +97,11 @@ h5repack_init(pack_opt_t *options, int verbose, hbool_t latest) *------------------------------------------------------------------------- */ -int h5repack_end(pack_opt_t *options) { +int +h5repack_end(pack_opt_t *options) +{ return options_table_free(options->op_tbl); -} +} /* end h5repack_end() */ /*------------------------------------------------------------------------- * Function: h5repack_addfilter @@ -138,7 +142,7 @@ h5repack_addfilter(const char *str, pack_opt_t *options) HDfree(obj_list); return 0; -} +} /* end h5repack_addfilter() */ /*------------------------------------------------------------------------- * Function: h5repack_addlayout @@ -175,7 +179,7 @@ h5repack_addlayout(const char *str, pack_opt_t *options) if (pack.layout == H5D_CHUNKED) { /* -2 means the NONE option, remove chunking and set the global layout to contiguous */ - if (pack.chunk.rank == -2) + if (pack.chunk.rank == -2) /* TODO: fix 'magic number' */ options->layout_g = H5D_CONTIGUOUS; /* otherwise set the global chunking type */ else { @@ -192,10 +196,10 @@ h5repack_addlayout(const char *str, pack_opt_t *options) HDfree(obj_list); ret_value = 0; - } + } /* end if obj_list exists */ return ret_value; -} +} /* end h5repack_addlayout() */ /* Note: The below copy_named_datatype(), named_datatype_free(), copy_attr() * were located in h5repack_copy.c as static prior to bugfix1726. @@ -215,8 +219,13 @@ h5repack_addlayout(const char *str, pack_opt_t *options) * to free the stack. *------------------------------------------------------------------------- */ -hid_t copy_named_datatype(hid_t type_in, hid_t fidout, - named_dt_t **named_dt_head_p, trav_table_t *travt, pack_opt_t *options) { +hid_t +copy_named_datatype(hid_t type_in, + hid_t fidout, + named_dt_t **named_dt_head_p, + trav_table_t *travt, + pack_opt_t *options) +{ named_dt_t *dt = *named_dt_head_p; /* Stack pointer */ named_dt_t *dt_ret = NULL; /* Datatype to return */ H5O_info_t oinfo; /* Object info of input dtype */ @@ -238,8 +247,10 @@ hid_t copy_named_datatype(hid_t type_in, hid_t fidout, for (i = 0; i < travt->nobjs; i++) { if (travt->objs[i].type == H5TRAV_TYPE_NAMED_DATATYPE) { /* Push onto the stack */ - if (NULL == (dt = (named_dt_t *)HDmalloc(sizeof(named_dt_t)))) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "buffer allocation failed failed"); + dt = (named_dt_t *)HDmalloc(sizeof(named_dt_t)); + if (NULL == dt) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, + "buffer allocation failed failed"); dt->next = *named_dt_head_p; *named_dt_head_p = dt; @@ -250,13 +261,14 @@ hid_t copy_named_datatype(hid_t type_in, hid_t fidout, /* Check if this type is the one requested */ if (oinfo.addr == dt->addr_in) { dt_ret = dt; - } /* end if */ - } /* end if */ - } /* end for */ - } /* end else */ + } + } /* end if named datatype */ + } /* end for each object in traversal table */ + } /* end else (create the stack) */ /* Handle the case that the requested datatype was not found. This is - * possible if the datatype was committed anonymously in the input file. */ + * possible if the datatype was committed anonymously in the input file. + */ if (!dt_ret) { /* Push the new datatype onto the stack */ if (NULL == (dt_ret = (named_dt_t *)HDmalloc(sizeof(named_dt_t)))) @@ -267,31 +279,35 @@ hid_t copy_named_datatype(hid_t type_in, hid_t fidout, /* Update the address and id */ dt_ret->addr_in = oinfo.addr; dt_ret->id_out = -1; - } /* end if */ + } /* end if requested datatype not found */ /* If the requested datatype does not yet exist in the output file, copy it - * anonymously */ + * anonymously + */ if (dt_ret->id_out < 0) { if (options->use_native == 1) dt_ret->id_out = H5Tget_native_type(type_in, H5T_DIR_DEFAULT); else dt_ret->id_out = H5Tcopy(type_in); if (dt_ret->id_out < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_native_type-H5Tcopy failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, + "H5Tget_native_type-H5Tcopy failed"); if (H5Tcommit_anon(fidout, dt_ret->id_out, H5P_DEFAULT, H5P_DEFAULT) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tcommit_anon failed"); - } /* end if */ + } /* end if named datatype not yet in output file */ /* Set return value */ ret_value = dt_ret->id_out; - /* Increment the ref count on id_out, because the calling function will try to close it */ - if(H5Iinc_ref(ret_value) < 0) + /* Increment the ref count on id_out, because the calling function will try + * to close it. (TODO: fix scope envy) + */ + if (H5Iinc_ref(ret_value) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Iinc_ref failed"); done: return ret_value; -} /* end copy_named_datatype */ +} /* end copy_named_datatype() */ /*------------------------------------------------------------------------- * Function: named_datatype_free @@ -299,7 +315,9 @@ done: * Purpose: Frees the stack of named datatypes. *------------------------------------------------------------------------- */ -int named_datatype_free(named_dt_t **named_dt_head_p, int ignore_err) { +int +named_datatype_free(named_dt_t **named_dt_head_p, int ignore_err) +{ named_dt_t *dt = *named_dt_head_p; int ret_value = -1; @@ -310,13 +328,13 @@ int named_datatype_free(named_dt_t **named_dt_head_p, int ignore_err) { dt = dt->next; HDfree(*named_dt_head_p); *named_dt_head_p = dt; - } /* end while */ + } ret_value = 0; done: return (ret_value); -} /* end named_datatype_free */ +} /* end named_datatype_free() */ /*------------------------------------------------------------------------- * Function: copy_attr @@ -330,8 +348,12 @@ done: *------------------------------------------------------------------------- */ int -copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, - trav_table_t *travt, pack_opt_t *options) +copy_attr( + hid_t loc_in, + hid_t loc_out, + named_dt_t **named_dt_head_p, + trav_table_t *travt, + pack_opt_t *options) { int ret_value = 0; hid_t attr_id = -1; /* attr ID */ @@ -361,42 +383,58 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, */ for (u = 0; u < (unsigned) oinfo.num_attrs; u++) { /* open attribute */ - if ((attr_id = H5Aopen_by_idx(loc_in, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t) u, H5P_DEFAULT, H5P_DEFAULT)) < 0) + attr_id = H5Aopen_by_idx( + loc_in, + ".", + H5_INDEX_CRT_ORDER, + H5_ITER_INC, + (hsize_t) u, + H5P_DEFAULT, + H5P_DEFAULT); + if (attr_id < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aopen_by_idx failed"); - /* get name */ if (H5Aget_name(attr_id, (size_t) 255, name) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed"); - /* get the file datatype */ - if ((ftype_id = H5Aget_type(attr_id)) < 0) + ftype_id = H5Aget_type(attr_id); + if (ftype_id < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_type failed"); /* Check if the datatype is committed */ - if ((is_named = H5Tcommitted(ftype_id)) < 0) + is_named = H5Tcommitted(ftype_id); + if (is_named < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tcommitted failed"); if (is_named && travt) { hid_t fidout = -1; /* Create out file id */ - if ((fidout = H5Iget_file_id(loc_out)) < 0) + fidout = H5Iget_file_id(loc_out); + if (fidout < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Iget_file_id failed"); /* Copy named dt */ - if ((wtype_id = copy_named_datatype(ftype_id, fidout, named_dt_head_p, travt, options)) < 0) { + wtype_id = copy_named_datatype( + ftype_id, + fidout, + named_dt_head_p, + travt, + options); + if (wtype_id < 0) { H5Fclose(fidout); - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "copy_named_datatype failed"); - } /* end if */ + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, + "copy_named_datatype failed"); + } if (H5Fclose(fidout) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fclose failed"); - } /* end if */ + } else { if (options->use_native == 1) wtype_id = H5Tget_native_type(ftype_id, H5T_DIR_DEFAULT); else wtype_id = H5Tcopy(ftype_id); - } /* end else */ + } /* get the dataspace handle */ if ((space_id = H5Aget_space(attr_id)) < 0) @@ -404,7 +442,8 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, /* get dimensions */ if ((rank = H5Sget_simple_extent_dims(space_id, dims, NULL)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, + "H5Sget_simple_extent_dims failed"); nelmts = 1; for (j = 0; j < rank; j++) @@ -413,12 +452,12 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, if ((msize = H5Tget_size(wtype_id)) == 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_size failed"); - /*------------------------------------------------------------------------- - * object references are a special case. We cannot just copy the buffers, - * but instead we recreate the reference. - * This is done on a second sweep of the file that just copies the referenced - * objects at copy_refs_attr() - *------------------------------------------------------------------------- + /*--------------------------------------------------------------------- + * object references are a special case. We cannot just copy the + * buffers, but instead we recreate the reference. + * This is done on a second sweep of the file that just copies the + * referenced objects at copy_refs_attr(). + *--------------------------------------------------------------------- */ type_class = H5Tget_class(wtype_id); is_ref = (type_class == H5T_REFERENCE); @@ -429,7 +468,7 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, is_ref = (is_ref || (H5Tget_class(base_type) == H5T_REFERENCE)); if (H5Tclose(base_type) < 0) H5TOOLS_INFO(H5E_tools_min_id_g, "H5Tclose base_type failed"); - } + } /* end if type_class is variable length or array */ if (type_class == H5T_COMPOUND) { int nmembers = H5Tget_nmembers(wtype_id); @@ -444,13 +483,13 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, is_ref = 1; break; } - } /* for (j=0; iverbose) printf(FORMAT_OBJ_ATTR, "attr", name); - /*------------------------------------------------------------------------- + /*--------------------------------------------------------------------- * close - *------------------------------------------------------------------------- + *--------------------------------------------------------------------- */ if (H5Sclose(space_id) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose failed"); @@ -501,19 +540,18 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, if (H5Aclose(attr_id) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aclose failed"); attr_id = -1; - } /* for u */ + } /* for u (each attribute) */ done: H5E_BEGIN_TRY { if (buf) { - /* Check if we have VL data and string in the attribute's datatype that must - * be reclaimed */ + /* Check if we have VL data and string in the attribute's + * datatype that must be reclaimed + */ if (TRUE == h5tools_detect_vlen(wtype_id)) H5Dvlen_reclaim(wtype_id, space_id, H5P_DEFAULT, buf); - - /* Free buf */ HDfree(buf); - } /* end if */ + } H5Aclose(attr_out); H5Sclose(space_id); @@ -525,25 +563,27 @@ done: return ret_value; } /* end copy_attr() */ -/*------------------------------------------------------------------------- +/*----------------------------------------------------------------------------- * Function: check_options * * Purpose: print options, checks for invalid options * * Return: void, return -1 on error - *------------------------------------------------------------------------- + *----------------------------------------------------------------------------- */ -static int check_options(pack_opt_t *options) { +static int +check_options(pack_opt_t *options) +{ int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ unsigned int i; int k, j, has_cp = 0, has_ck = 0; char slayout[30]; /*------------------------------------------------------------------------- - * objects to layout - *------------------------------------------------------------------------- - */ - if (options->verbose && have_request(options) /* only print if requested */) { + * Objects to layout + *------------------------------------------------------------------------- + */ + if (options->verbose && have_request(options)) { if (options->all_layout == 1) { printf("All objects to modify layout are...\n"); switch (options->layout_g) { @@ -577,7 +617,7 @@ static int check_options(pack_opt_t *options) { } else printf("No all objects to modify layout\n"); - }/* verbose */ + } /* end if verbose */ for (i = 0; i < options->op_tbl->nelems; i++) { char* name = options->op_tbl->objs[i].path; @@ -586,27 +626,28 @@ static int check_options(pack_opt_t *options) { if (options->verbose) { printf(" <%s> with chunk size ", name); for (k = 0; k < options->op_tbl->objs[i].chunk.rank; k++) - printf("%d ", (int) options->op_tbl->objs[i].chunk.chunk_lengths[k]); + printf("%d ", (int)options->op_tbl->objs[i].chunk.chunk_lengths[k]); printf("\n"); } has_ck = 1; } - else if (options->op_tbl->objs[i].chunk.rank == -2) { + else if (options->op_tbl->objs[i].chunk.rank == -2) { /* TODO: replace 'magic number' */ if (options->verbose) printf(" <%s> %s\n", name, "NONE (contiguous)"); has_ck = 1; } - } + } /* end for each object in options */ if (options->all_layout == 1 && has_ck) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "invalid chunking input: 'all' option is present with other objects"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, + "invalid chunking input: 'all' option is present with other objects"); /*------------------------------------------------------------------------- - * objects to filter - *------------------------------------------------------------------------- - */ + * Objects to filter + *------------------------------------------------------------------------- + */ - if (options->verbose && have_request(options) /* only print if requested */) { + if (options->verbose && have_request(options)) { if (options->all_filter == 1) { printf("All objects to apply filter are...\n"); for (k = 0; k < options->n_filter_g; k++) { @@ -625,13 +666,15 @@ static int check_options(pack_opt_t *options) { break; case H5Z_FILTER_SZIP: case H5Z_FILTER_DEFLATE: - printf(" All with %s, parameter %d\n", get_sfilter(filtn), options->filter_g[k].cd_values[0]); + printf(" All with %s, parameter %d\n", + get_sfilter(filtn), + options->filter_g[k].cd_values[0]); break; default: printf(" User Defined %d\n", filtn); break; - } /* k */ - }; + } + } } else printf("No all objects to apply filter\n"); @@ -643,39 +686,50 @@ static int check_options(pack_opt_t *options) { for (j = 0; j < pack.nfilters; j++) { if (options->verbose) { - if(pack.filter[j].filtn >= 0) { - if(pack.filter[j].filtn > H5Z_FILTER_SCALEOFFSET) - printf(" <%s> with %s filter %d\n", name, get_sfilter(pack.filter[j].filtn), pack.filter[j].filtn); + if (pack.filter[j].filtn >= 0) { + if (pack.filter[j].filtn > H5Z_FILTER_SCALEOFFSET) + printf(" <%s> with %s filter %d\n", + name, + get_sfilter(pack.filter[j].filtn), + pack.filter[j].filtn); else - printf(" <%s> with %s filter\n", name, get_sfilter(pack.filter[j].filtn)); + printf(" <%s> with %s filter\n", + name, + get_sfilter(pack.filter[j].filtn)); } } has_cp = 1; - } /* j */ - } /* i */ + } /* for each filter */ + } /* end for each object in options table */ if (options->all_filter == 1 && has_cp) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "invalid compression input: 'all' option is present with other objects"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, + "invalid compression input: 'all' option is present with " \ + "other objects"); /*------------------------------------------------------------------------- - * check options for the latest format - *------------------------------------------------------------------------- - */ + * Check options for the latest format + *------------------------------------------------------------------------- + */ if (options->grp_compact < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "invalid maximum number of links to store as header messages"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, + "invalid maximum number of links to store as header messages"); if (options->grp_indexed < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "invalid minimum number of links to store in the indexed format"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, + "invalid minimum number of links to store in indexed format"); if (options->grp_indexed > options->grp_compact) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "minimum indexed size is greater than the maximum compact size"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, + "minimum indexed size is greater than maximum compact size"); for (i = 0; i < 8; i++) if (options->msg_size[i] < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "invalid shared message size"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, + "invalid shared message size"); - /*-------------------------------------------------------------------------------- - * verify new user userblock options; file name must be present - *--------------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------ + * Verify new user userblock options; file name must be present + *------------------------------------------------------------------------ + */ if (options->ublock_filename != NULL && options->ublock_size == 0) { if (options->verbose) { printf("Warning: user block size missing for file %s. Assigning a default size of 1024...\n", options->ublock_filename); @@ -684,37 +738,41 @@ static int check_options(pack_opt_t *options) { } if (options->ublock_filename == NULL && options->ublock_size != 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file name missing for user block", options->ublock_filename); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, + "file name missing for user block", options->ublock_filename); - /*-------------------------------------------------------------------------------- - * verify alignment options; threshold is zero default but alignment not - *--------------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------ + * Verify alignment options; threshold is zero default but alignment not + *------------------------------------------------------------------------ + */ if (options->alignment == 0 && options->threshold != 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "alignment for H5Pset_alignment missing"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, + "alignment for H5Pset_alignment missing"); done: return ret_value; -} +} /* end check_options() */ /*------------------------------------------------------------------------- * Function: check_objects * - * Purpose: locate all HDF5 objects in the file and compare with user - * supplied list + * Purpose: Locate all HDF5 objects in the file and compare with user-supplied + * list. * * Return: 0, ok, -1 no *------------------------------------------------------------------------- */ -static int check_objects(const char* fname, pack_opt_t *options) { - int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ +static int +check_objects(const char* fname, pack_opt_t *options) +{ hid_t fid = -1; hid_t did = -1; hid_t sid = -1; unsigned int i; unsigned int uf; trav_table_t *travt = NULL; + int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ /* nothing to do */ if (options->op_tbl->nelems == 0) @@ -724,8 +782,10 @@ static int check_objects(const char* fname, pack_opt_t *options) { * open the file *------------------------------------------------------------------------- */ - if ((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, 0)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "h5tools_fopen failed <%s>: %s", fname, H5FOPENERROR); + fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, 0); + if (fid < 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, + "h5tools_fopen failed <%s>: %s", fname, H5FOPENERROR); /*------------------------------------------------------------------------- * get the list of objects in the file @@ -734,7 +794,6 @@ static int check_objects(const char* fname, pack_opt_t *options) { /* Initialize indexing options */ h5trav_set_index(sort_by, sort_order); - /* init table */ trav_table_init(&travt); /* get the list of objects in the file */ @@ -747,68 +806,80 @@ static int check_objects(const char* fname, pack_opt_t *options) { */ if (options->verbose) - printf("Opening file. Searching %d objects to modify ...\n", travt->nobjs); + printf("Opening file. Searching %lu objects to modify ...\n", + travt->nobjs); for (i = 0; i < options->op_tbl->nelems; i++) { - char* name = options->op_tbl->objs[i].path; + pack_info_t obj = options->op_tbl->objs[i]; + char* name = obj.path; if (options->verbose) printf(" <%s>", name); /* the input object names are present in the file and are valid */ if (h5trav_getindext(name, travt) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "%s Could not find <%s> in file <%s>. Exiting...\n", + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, + "%s Could not find <%s> in file <%s>. Exiting...\n", (options->verbose ? "\n" : ""), name, fname); if (options->verbose) printf("...Found\n"); - for (uf = 0; uf < options->op_tbl->objs[i].nfilters; uf++) { - if (options->op_tbl->objs[i].filter[uf].filtn < 0) + for (uf = 0; uf < obj.nfilters; uf++) { + if (obj.filter[uf].filtn < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "invalid filter"); /* check for extra filter conditions */ - switch (options->op_tbl->objs[i].filter[uf].filtn) { + switch (obj.filter[uf].filtn) { /* chunk size must be smaller than pixels per block */ case H5Z_FILTER_SZIP: { int j; hsize_t csize = 1; - unsigned ppb = options->op_tbl->objs[i].filter[uf].cd_values[0]; + unsigned ppb = obj.filter[uf].cd_values[0]; hsize_t dims[H5S_MAX_RANK]; int rank; - if (options->op_tbl->objs[i].chunk.rank > 0) { - rank = options->op_tbl->objs[i].chunk.rank; + if (obj.chunk.rank > 0) { + rank = obj.chunk.rank; for (j = 0; j < rank; j++) - csize *= options->op_tbl->objs[i].chunk.chunk_lengths[j]; + csize *= obj.chunk.chunk_lengths[j]; } else { - if ((did = H5Dopen2(fid, name, H5P_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed"); - if ((sid = H5Dget_space(did)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed"); - if ((rank = H5Sget_simple_extent_ndims(sid)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed"); + did = H5Dopen2(fid, name, H5P_DEFAULT); + if (did < 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, + "H5Dopen2 failed"); + sid = H5Dget_space(did); + if (sid < 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, + "H5Dget_space failed"); + rank = H5Sget_simple_extent_ndims(sid); + if (rank < 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, + "H5Sget_simple_extent_ndims failed"); HDmemset(dims, 0, sizeof dims); if (H5Sget_simple_extent_dims(sid, dims, NULL) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, + "H5Sget_simple_extent_dims failed"); for (j = 0; j < rank; j++) csize *= dims[j]; if (H5Sclose(sid) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, + "H5Sclose failed"); if (H5Dclose(did) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed"); - } + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, + "H5Dclose failed"); + } /* end else (chunk rank is 0) */ if (csize < ppb) { printf(" \n"); HGOTO_DONE(0); } - } + } /* end SZIP */ break; default: break; - } - } /* for uf */ - } /* for i */ + } /* end switch */ + } /* for uf (each user-defined filter) */ + } /* for i (each object in options traversal table) */ done: H5E_BEGIN_TRY { @@ -819,7 +890,7 @@ done: if (travt) trav_table_free(travt); return ret_value; -} +} /* end check_objects() */ /*------------------------------------------------------------------------- * Function: have_request @@ -829,14 +900,15 @@ done: * Return: 1 yes, 0 no *------------------------------------------------------------------------- */ -static int have_request(pack_opt_t *options) { +static int +have_request(pack_opt_t *options) +{ if (options->all_filter || options->all_layout || options->op_tbl->nelems) return 1; return 0; - -} +} /* end have_request() */ /*------------------------------------------------------------------------- * Function: get_sfilter @@ -846,8 +918,9 @@ static int have_request(pack_opt_t *options) { * Return: name of filter, exit on error *------------------------------------------------------------------------- */ - -static const char* get_sfilter(H5Z_filter_t filtn) { +static const char * +get_sfilter(H5Z_filter_t filtn) +{ if (filtn < 0) return NULL; else if (filtn == H5Z_FILTER_NONE) @@ -866,5 +939,5 @@ static const char* get_sfilter(H5Z_filter_t filtn) { return "SOFF"; else return "UD"; -} +} /* end get_sfilter() */ -- cgit v0.12 From a648183cc38e71f7393702c3ad11bf5ccb7a74a4 Mon Sep 17 00:00:00 2001 From: Jacob Smith Date: Thu, 30 May 2019 15:45:53 -0500 Subject: Add initial failing test for h5repack copying external data into new file. --- MANIFEST | 1 + tools/test/h5repack/Makefile.am | 2 + tools/test/h5repack/h5repack.sh.in | 93 ++++++++++++++++++++- tools/test/h5repack/h5repackgentest.c | 83 ++++++++++++++++++ tools/test/h5repack/testfiles/h5repack_int32le.h5 | Bin 0 -> 4096 bytes .../h5repack/testfiles/h5repack_int32le_ex-0.dat | Bin 0 -> 2048 bytes .../test/h5repack/testfiles/h5repack_int32le_ex.h5 | Bin 0 -> 1472 bytes 7 files changed, 178 insertions(+), 1 deletion(-) create mode 100644 tools/test/h5repack/h5repackgentest.c create mode 100644 tools/test/h5repack/testfiles/h5repack_int32le.h5 create mode 100644 tools/test/h5repack/testfiles/h5repack_int32le_ex-0.dat create mode 100644 tools/test/h5repack/testfiles/h5repack_int32le_ex.h5 diff --git a/MANIFEST b/MANIFEST index c3dc0e9..7a4257e 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1478,6 +1478,7 @@ ./tools/test/h5repack/dynlib_rpk.c ./tools/test/h5repack/dynlib_vrpk.c ./tools/test/h5repack/h5repack.sh.in +./tools/test/h5repack/h5repackgentest.c ./tools/test/h5repack/h5repack_plugin.sh.in ./tools/test/h5repack/h5repacktst.c ./tools/test/h5repack/testh5repack_detect_szip.c diff --git a/tools/test/h5repack/Makefile.am b/tools/test/h5repack/Makefile.am index 59d7a6a..ff950e4 100644 --- a/tools/test/h5repack/Makefile.am +++ b/tools/test/h5repack/Makefile.am @@ -22,10 +22,12 @@ include $(top_srcdir)/config/commence.am AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/test -I$(top_srcdir)/tools/lib -I$(top_srcdir)/tools/src/h5repack # Test programs and scripts +TEST_PROG=h5repackgentest TEST_SCRIPT=h5repack.sh noinst_PROGRAMS=h5repacktst testh5repack_detect_szip +check_PROGRAMS=$(TEST_PROG) SCRIPT_DEPEND=../../src/h5repack/h5repack$(EXEEXT) h5repacktst$(EXEEXT) if HAVE_SHARED_CONDITIONAL if USE_PLUGINS_CONDITIONAL diff --git a/tools/test/h5repack/h5repack.sh.in b/tools/test/h5repack/h5repack.sh.in index 282ba76..9851e89 100644 --- a/tools/test/h5repack/h5repack.sh.in +++ b/tools/test/h5repack/h5repack.sh.in @@ -115,6 +115,8 @@ $SRC_H5REPACK_TESTFILES/h5repack_fsm_aggr_persist.h5 $SRC_H5REPACK_TESTFILES/h5repack_none.h5 $SRC_H5REPACK_TESTFILES/h5repack_paged_nopersist.h5 $SRC_H5REPACK_TESTFILES/h5repack_paged_persist.h5 +$SRC_H5REPACK_TESTFILES/h5repack_int32le.h5 +$SRC_H5REPACK_TESTFILES/h5repack_int32le_ex.h5 $SRC_H5DIFF_TESTFILES/h5diff_attr1.h5 $SRC_TOOLS_TESTFILES/tfamily00000.h5 $SRC_TOOLS_TESTFILES/tfamily00001.h5 @@ -160,6 +162,7 @@ $SRC_H5REPACK_TESTFILES/ublock.bin $SRC_H5REPACK_TESTFILES/h5repack.info $SRC_H5REPACK_TESTFILES/crtorder.tordergr.h5.ddl $SRC_H5REPACK_TESTFILES/deflate_limit.h5repack_layout.h5.ddl +$SRC_H5REPACK_TESTFILES/h5repack_int32le_ex-0.dat $SRC_H5REPACK_TESTFILES/h5repack_layout.h5.ddl $SRC_H5REPACK_TESTFILES/h5repack_filters.h5-gzip_verbose_filters.tst $SRC_H5REPACK_TESTFILES/h5repack_layout.h5-dset2_chunk_20x10-errstk.tst @@ -599,8 +602,91 @@ VERIFY_INVALIDBOUNDS() } # end of VERIFY_INVALIDBOUNDS +# ----------------------------------------------------------------------------- +# Expect h5diff to fail +# ----------------------------------------------------------------------------- +DIFFFAIL() +{ + VERIFY h5diff unequal $@ + ( + cd $TESTDIR + $RUNSERIAL $H5DIFF_BIN -q "$@" + ) + RET=$? + if [ $RET == 0 ] ; then + echo "*FAILED*" + nerrors="`expr $nerrors + 1`" + else + echo " PASSED" + fi +} + +# ----------------------------------------------------------------------------- +# Catchall test for repacking with external files +# Loops over all (internally-listed) cases and applies the given arguments +# to h5repack. +# Expects case files to be of format: +# + h5repack_.h5 +# + h5repack__ex.h5 +# + h5repack__ex-.dat +# ...where NAME is part of the internal list, and N is a positive decimal +# number; multiple external files (*.dat) are allowed per file, but they must +# follow the same pattern and be in numerical sequence starting at 0. +# ----------------------------------------------------------------------------- +VERIFY_EXTERNAL_CONSOLIDATION() +{ + for name in int32le + do + basename="h5repack_${name}" + base_ext="${basename}_ex" + base_rpkg="${basename}_rp" + canonical="${basename}.h5" + external="${base_ext}.h5" + ex_dat="${base_ext}-0.dat" + ex_dat_mv="__${ext_dat}" + repacked="${base_rpkg}.h5" + prev_nerrors=$nerrors + + TESTING external consolidation on $name with h5repack $@ + echo " . . ." + + # baseline comparison of known files + DIFFTEST $canonical $external + + # repack the external file, verify integrity + ( cd $TESTDIR + $H5REPACK_BIN $@ $external $repacked + ) + DIFFTEST $repacked $canonical + DIFFTEST $repacked $external + + # invalidate external file by moving its data file; verify + ( cd $TESTDIR + mv $ex_dat $ex_dat_mv + ) + DIFFFAIL $canonical $external + DIFFFAIL $repacked $external + DIFFTEST $canonical $repacked + + # reset test state for re-runs with different h5repack arguments + ( cd $TESTDIR + mv $ex_dat_mv $ex_dat + rm $repacked + ) + + # flag if any of the above checks failed + if [ $prev_nerrors != $nerrors ]; then + echo ". . . *FAILED*" + nerrors="`expr $prev_nerrors + 1`" + else + echo ". . . PASSED" + fi + done +} # end VERIFY_EXTERNAL_CONSOLIDATION + +# ----------------------------------------------------------------------------- # same as TOOLTEST, but it uses the old syntax -i input_file -o output_file -# +# ----------------------------------------------------------------------------- TOOLTEST0() { infile=$2 @@ -1464,6 +1550,11 @@ VERIFY_SUPERBLOCK 2 2 3 h5repack_layout.h5 -j 2 -k 2 h5repack_layout.h5 # -j 0 -k 1, file cannot be opened VERIFY_INVALIDBOUNDS 0 1 bounds_latest_latest.h5 +# +# Testing external storage +# +VERIFY_EXTERNAL_CONSOLIDATION + # Clean up temporary files/directories CLEAN_TESTFILES_AND_TESTDIR diff --git a/tools/test/h5repack/h5repackgentest.c b/tools/test/h5repack/h5repackgentest.c new file mode 100644 index 0000000..8076b42 --- /dev/null +++ b/tools/test/h5repack/h5repackgentest.c @@ -0,0 +1,83 @@ +#include "hdf5.h" +#include "H5private.h" + +#define MAX_NAME_SIZE 256 +#define FILE_INT32LE "h5repack_int32le" + + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + */ +static void +generate_external_int32le(hbool_t external) +{ + char filename[MAX_NAME_SIZE]; + hid_t file; + hid_t dspace; + hid_t dset; + hid_t dcpl = H5P_DEFAULT; + hsize_t dims[] = {8, 8, 8}; + int32_t wdata[512]; /* 8^3 */ + int32_t n; + int i; + int j; + int k; + + /* generate values, alternating positive and negative + */ + for (i=0, n=0; i < 8; i++) + for (j=0; j < 8; j++) + for (k=0; k < 8; k++, n++) + wdata[n] = (k + j*512 + i*4096) * ((n&1) ? (-1) : (1)); + + snprintf(filename, + MAX_NAME_SIZE, + "%s%s.h5", + FILE_INT32LE, + (external) ? "_ex" : ""); + + file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + HDassert(file >= 0); + + dspace = H5Screate_simple(3, dims, NULL); + HDassert(dspace >= 0); + + if (external) { + char name[MAX_NAME_SIZE]; + dcpl = H5Pcreate(H5P_DATASET_CREATE); + HDassert(dcpl >= 0); + snprintf(name, MAX_NAME_SIZE, "%s_ex-0.dat", FILE_INT32LE); + HDassert(H5Pset_external(dcpl, name, 0, H5F_UNLIMITED) >= 0); + } + + dset = H5Dcreate2( + file, + "dset", + H5T_STD_I32LE, + dspace, + H5P_DEFAULT, + dcpl, + H5P_DEFAULT); + HDassert(dset >= 0); + + HDassert(H5Dwrite(dset, H5T_STD_I32LE, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata) + >= 0); + + if (external) + HDassert(H5Pclose(dcpl) >= 0); + HDassert(H5Dclose(dset) >= 0); + HDassert(H5Sclose(dspace) >= 0); + HDassert(H5Fclose(file) >= 0); +} /* end generate_external_int32le() */ + + +/* ---------------------------------------------------------------------------- + */ +int +main(void) +{ + generate_external_int32le(FALSE); + generate_external_int32le(TRUE); + return 0; +} /* end main() */ + + diff --git a/tools/test/h5repack/testfiles/h5repack_int32le.h5 b/tools/test/h5repack/testfiles/h5repack_int32le.h5 new file mode 100644 index 0000000..fb00579 Binary files /dev/null and b/tools/test/h5repack/testfiles/h5repack_int32le.h5 differ diff --git a/tools/test/h5repack/testfiles/h5repack_int32le_ex-0.dat b/tools/test/h5repack/testfiles/h5repack_int32le_ex-0.dat new file mode 100644 index 0000000..b505eb4 Binary files /dev/null and b/tools/test/h5repack/testfiles/h5repack_int32le_ex-0.dat differ diff --git a/tools/test/h5repack/testfiles/h5repack_int32le_ex.h5 b/tools/test/h5repack/testfiles/h5repack_int32le_ex.h5 new file mode 100644 index 0000000..337b297 Binary files /dev/null and b/tools/test/h5repack/testfiles/h5repack_int32le_ex.h5 differ -- cgit v0.12 From cb6029196af9a960872c627db53fcbc4cf89d923 Mon Sep 17 00:00:00 2001 From: Jacob Smith Date: Thu, 30 May 2019 15:46:39 -0500 Subject: Formatting changes, mostly. --- tools/src/h5repack/h5repack_copy.c | 183 +++++++++++++++++++++++++------------ 1 file changed, 125 insertions(+), 58 deletions(-) diff --git a/tools/src/h5repack/h5repack_copy.c b/tools/src/h5repack/h5repack_copy.c index 0567269..544793a 100644 --- a/tools/src/h5repack/h5repack_copy.c +++ b/tools/src/h5repack/h5repack_copy.c @@ -80,8 +80,8 @@ static herr_t walk_error_callback(H5_ATTR_UNUSED unsigned n, const H5E_error2_t * -1 no *------------------------------------------------------------------------- */ - -int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options) +int +copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options) { int ret_value = 0; hid_t fidin = -1; @@ -387,7 +387,7 @@ done: trav_table_free(travt); return ret_value; -} +} /* end copy_objects() */ /*------------------------------------------------------------------------- * Function: Get_hyperslab @@ -543,7 +543,7 @@ Get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[], done: return ret_value; -} +} /* end Get_hyperslab() */ /*------------------------------------------------------------------------- * Function: do_copy_objects @@ -599,7 +599,8 @@ done: *------------------------------------------------------------------------- */ -int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, +int +do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *options) /* repack options */ { int ret_value = 0; @@ -699,7 +700,11 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, } else { if (options->grp_compact > 0 || options->grp_indexed > 0) - if (H5Pset_link_phase_change(gcpl_out, (unsigned) options->grp_compact, (unsigned) options->grp_indexed) < 0) + if (H5Pset_link_phase_change( + gcpl_out, + (unsigned) options->grp_compact, + (unsigned) options->grp_indexed) + < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_link_phase_change failed"); if ((grp_out = H5Gcreate2(fidout, travt->objs[i].name, H5P_DEFAULT, gcpl_out, H5P_DEFAULT)) < 0) @@ -780,6 +785,9 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, if (H5Dclose(dset_in) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed"); +/* TODO: be smart about external storage */ +/* can we use the dcpl_in/out to adjust any external storage? */ +/* what about the case with just H5Ocopy? */ /*------------------------------------------------------------------------- * check if we should use H5Ocopy or not * if there is a request for filters/layout, we read/write the object @@ -819,7 +827,7 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, wtype_id = H5Tget_native_type(ftype_id, H5T_DIR_DEFAULT); else wtype_id = H5Tcopy(ftype_id); - } /* end if */ + } if ((msize = H5Tget_size(wtype_id)) == 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_size failed"); @@ -858,12 +866,20 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, /* apply the filter */ if (apply_s) - if (apply_filters(travt->objs[i].name, rank, dims, msize, dcpl_out, options, &has_filter) < 0) + if (apply_filters( + travt->objs[i].name, + rank, + dims, + msize, + dcpl_out, + options, + &has_filter) + < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "apply_filters failed"); /* only if layout change requested for entire file or * individual obj */ - if (options->all_layout > 0 || req_obj_layout == 1) + if (options->all_layout > 0 || req_obj_layout == 1) { /*------------------------------------------------- * Unset the unlimited max dims if convert to other * than chunk layouts, because unlimited max dims @@ -883,14 +899,14 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, /* if convert to COMPACT */ if (options->layout_g == H5D_COMPACT) - /* should be smaller than 64K */ if (size_dset > MAX_COMPACT_DSIZE) limit_maxdims = FALSE; /* unset unlimited max dims */ if (limit_maxdims) H5Sset_extent_simple(f_space_id, rank, dims, NULL); - } + } /* if not chunked */ + } /* if layout change requested for entire file or individual object */ /*------------------------------------------------------------------------- * create the output dataset; @@ -898,16 +914,36 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, * modified dcpl; in that case use the original instead *------------------------------------------------------------------------- */ - dset_out = H5Dcreate2(fidout, travt->objs[i].name, wtype_id, f_space_id, H5P_DEFAULT, dcpl_out, H5P_DEFAULT); - if (dset_out == FAIL) { - H5Epush2(H5tools_ERR_STACK_g, __FILE__, FUNC, __LINE__, H5tools_ERR_CLS_g, H5E_tools_g, H5E_tools_min_id_g, "H5Dcreate2 failed"); + dset_out = H5Dcreate2(fidout, + travt->objs[i].name, + wtype_id, + f_space_id, + H5P_DEFAULT, + dcpl_out, + H5P_DEFAULT); + if (dset_out < 0) { + H5Epush2(H5tools_ERR_STACK_g, + __FILE__, + FUNC, + __LINE__, + H5tools_ERR_CLS_g, + H5E_tools_g, + H5E_tools_min_id_g, + "H5Dcreate2 failed"); if (options->verbose) - printf(" warning: could not create dataset <%s>. Applying original settings\n", travt->objs[i].name); - - if ((dset_out = H5Dcreate2(fidout, travt->objs[i].name, wtype_id, f_space_id, H5P_DEFAULT, dcpl_in, H5P_DEFAULT)) < 0) + printf(" warning: could not create dataset <%s>. Applying original settings\n", + travt->objs[i].name); + dset_out = H5Dcreate2(fidout, + travt->objs[i].name, + wtype_id, + f_space_id, + H5P_DEFAULT, + dcpl_in, + H5P_DEFAULT); + if (dset_out < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dcreate2 failed"); apply_f = 0; - } + } /* if opening dataset with original DCPL (retry) */ /*------------------------------------------------------------------------- * read/write @@ -931,8 +967,8 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, if (TRUE == H5Tdetect_class(wtype_id, H5T_VLEN)) if (H5Dvlen_reclaim(wtype_id, f_space_id, H5P_DEFAULT, buf) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dvlen_reclaim failed"); - /* free */ - if (buf != NULL) { + + if (buf != NULL) { /* TODO: is buf potentially released by H5Dvlen_reclaim()? */ HDfree(buf); buf = NULL; } @@ -968,17 +1004,25 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, dset_layout = H5Pget_layout(dcpl_out); if (dset_layout == H5D_CHUNKED) dcpl_tmp = dcpl_out; /* writing dataset */ - else { /* if reading dataset is chunked */ + else { dset_layout = H5Pget_layout(dcpl_in); if (dset_layout == H5D_CHUNKED) dcpl_tmp = dcpl_in; /* reading dataset */ } - /* get hyperslab dims and size in byte */ - if (Get_hyperslab(dcpl_tmp, rank, dims, p_type_nbytes, hslab_dims, &hslab_nbytes) < 0) + if (Get_hyperslab( + dcpl_tmp, + rank, + dims, + p_type_nbytes, + hslab_dims, + &hslab_nbytes) + < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Get_hyperslab failed"); hslab_buf = HDmalloc((size_t)hslab_nbytes); + if (hslab_buf == NULL) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "can't allocate space for hyperslab"); hslab_nelmts = hslab_nbytes / p_type_nbytes; hslab_space = H5Screate_simple(1, &hslab_nelmts, NULL); @@ -996,28 +1040,57 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, */ for (k = 0, hs_select_nelmts = 1; k < rank; k++) { /* MIN() is used to get the remaining edge portion if exist. - * "dims[k] - hs_sel_offset[k]" is remaining edge portion that is smaller then the hyperslab.*/ + * "dims[k] - hs_sel_offset[k]" is remaining edge portion that is + * smaller then the hyperslab. + */ hs_sel_count[k] = MIN(dims[k] - hs_sel_offset[k], hslab_dims[k]); hs_select_nelmts *= hs_sel_count[k]; } - if (H5Sselect_hyperslab(f_space_id, H5S_SELECT_SET, hs_sel_offset, NULL, hs_sel_count, NULL) < 0) + if (H5Sselect_hyperslab( + f_space_id, + H5S_SELECT_SET, + hs_sel_offset, + NULL, + hs_sel_count, + NULL) + < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sselect_hyperslab failed"); - if (H5Sselect_hyperslab(hslab_space, H5S_SELECT_SET, zero, NULL, &hs_select_nelmts, NULL) < 0) + if (H5Sselect_hyperslab( + hslab_space, + H5S_SELECT_SET, + zero, + NULL, + &hs_select_nelmts, + NULL) + < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sselect_hyperslab failed"); - } + } /* end if rank > 0 */ else { H5Sselect_all(f_space_id); H5Sselect_all(hslab_space); hs_select_nelmts = 1; - } /* rank */ - - if(H5Dread(dset_in, wtype_id, hslab_space, f_space_id, H5P_DEFAULT, hslab_buf) < 0) + } /* rank == 0 */ + + if (H5Dread( + dset_in, + wtype_id, + hslab_space, + f_space_id, + H5P_DEFAULT, + hslab_buf) + < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed"); - if(H5Dwrite(dset_out, wtype_id, hslab_space, f_space_id, H5P_DEFAULT, hslab_buf) < 0) + if (H5Dwrite( + dset_out, + wtype_id, + hslab_space, + f_space_id, + H5P_DEFAULT, + hslab_buf) + < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dwrite failed"); - /* reclaim any VL memory, if necessary */ if (vl_data) H5Dvlen_reclaim(wtype_id, hslab_space, H5P_DEFAULT, hslab_buf); @@ -1029,20 +1102,19 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, hs_sel_offset[k - 1] = 0; else carry = 0; - } /* k */ - } /* elmtno */ + } + } /* hyperslab selection loop */ H5Sclose(hslab_space); - /* free */ if (hslab_buf != NULL) { HDfree(hslab_buf); hslab_buf = NULL; } - } /* hyperslab read */ - } /* if (nelmts>0 && space_status==H5D_SPACE_STATUS_NOT_ALLOCATED) */ + } /* end if reading/writing by hyperslab */ + } /* if (nelmts > 0 && space_status != H5D_SPACE_STATUS_NOT_ALLOCATED) */ /*------------------------------------------------------------------------- - * amount of compression used + * print amount of compression used *------------------------------------------------------------------------- */ if (options->verbose) { @@ -1062,14 +1134,16 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, print_dataset_info(dcpl_in, travt->objs[i].name, ratio, 0); /* print a message that the filter was not applied - (in case there was a filter) + * (in case there was a filter) */ if (has_filter && apply_s == 0) - printf(" \n", travt->objs[i].name, (int) options->min_comp); + printf(" \n", + travt->objs[i].name, + (int) options->min_comp); if (has_filter && apply_f == 0) printf(" \n", travt->objs[i].name); - } /* verbose */ + } /* if verbose (print compression) */ /*------------------------------------------------------------------------- * copy attrs @@ -1078,11 +1152,10 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, if (copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "copy_attr failed"); - /*close */ if (H5Dclose(dset_out) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed"); - }/*!H5T_REFERENCE*/ - }/*h5tools_canreadf*/ + } /* !H5T_REFERENCE */ + } /* if h5tools_canreadf (filter availability check) */ /*------------------------------------------------------------------------- * close @@ -1116,11 +1189,6 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, if (H5Pset_copy_object(pid, H5O_COPY_WITHOUT_ATTR_FLAG) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_copy_object failed"); - /*------------------------------------------------------------------------- - * do the copy - *------------------------------------------------------------------------- - */ - if (H5Ocopy(fidin, /* Source file or group identifier */ travt->objs[i].name, /* Name of the source object to be copied */ fidout, /* Destination file or group identifier */ @@ -1129,7 +1197,6 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, H5P_DEFAULT) < 0) /* Properties which apply to the new hard link */ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Ocopy failed"); - /* close property */ if (H5Pclose(pid) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed"); @@ -1151,7 +1218,7 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, if (options->verbose) printf(FORMAT_OBJ, "dset", travt->objs[i].name); - } /* end do we have request for filter/chunking */ + } /* end whether we have request for filter/chunking */ break; /*------------------------------------------------------------------------- @@ -1211,8 +1278,8 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, default: HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Object type not found"); } /* switch */ - } /* end for */ - } /* end if */ + } /* end for each object to traverse */ + } /* end if there are objects */ done: @@ -1250,7 +1317,7 @@ done: HDfree(hslab_buf); return ret_value; -} +} /* end do_copy_objects() */ /*------------------------------------------------------------------------- * Function: print_dataset_info @@ -1345,7 +1412,7 @@ print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int pr) HDstrcat(strfilter, "UD "); break; } /* switch */ - }/*i*/ + } /* for each filter */ if (!pr) printf(FORMAT_OBJ, "dset", objname); @@ -1358,7 +1425,7 @@ print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int pr) HDstrcat(str, temp); printf(FORMAT_OBJ, str, objname); } -} +} /* end print_dataset_info() */ /*------------------------------------------------------------------------- * Function: copy_user_block @@ -1428,7 +1495,7 @@ done: HDclose(outfid); return ret_value; -} +} /* end copy_user_block() */ /*------------------------------------------------------------------------- * Function: print_user_block @@ -1501,6 +1568,6 @@ done: HDclose(fh); return; -} +} /* end print_user_block() */ #endif -- cgit v0.12 From ad2a7f47896cf636b42fbc73b96781b2d5200f56 Mon Sep 17 00:00:00 2001 From: Jacob Smith Date: Fri, 31 May 2019 17:24:26 -0500 Subject: First pass at repack consolidating external storage if layout given. Checks out manually, tests still complain. --- tools/src/h5repack/h5repack_copy.c | 15 ++++++++++++--- tools/test/h5repack/Makefile.am | 3 ++- tools/test/h5repack/h5repack.sh.in | 3 ++- tools/test/h5repack/h5repackgentest.c | 8 ++++---- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/tools/src/h5repack/h5repack_copy.c b/tools/src/h5repack/h5repack_copy.c index 544793a..c638f3d 100644 --- a/tools/src/h5repack/h5repack_copy.c +++ b/tools/src/h5repack/h5repack_copy.c @@ -807,8 +807,17 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_type failed"); if ((dcpl_in = H5Dget_create_plist(dset_in)) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist failed"); - if ((dcpl_out = H5Pcopy(dcpl_in)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcopy failed"); + /* If the input dataset has external storage, it must be contiguous. + * Accordingly, there would be no filter or chunk properties to preserve. + */ + if (H5Pget_external_count(dcpl_in)) { + if ((dcpl_out = H5Pcreate(H5P_DATASET_CREATE)) < 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcreate failed"); + } + else { + if ((dcpl_out = H5Pcopy(dcpl_in)) < 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcopy failed"); + } if ((rank = H5Sget_simple_extent_ndims(f_space_id)) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed"); HDmemset(dims, 0, sizeof dims); @@ -1175,7 +1184,7 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed"); } /*------------------------------------------------------------------------- - * we do not have request for filter/chunking use H5Ocopy instead + * we do not have request for filter/chunking; use H5Ocopy instead *------------------------------------------------------------------------- */ else { diff --git a/tools/test/h5repack/Makefile.am b/tools/test/h5repack/Makefile.am index ff950e4..38f7b2f 100644 --- a/tools/test/h5repack/Makefile.am +++ b/tools/test/h5repack/Makefile.am @@ -59,7 +59,8 @@ endif # Temporary files. *.h5 are generated by h5repack. They should # copied to the testfiles/ directory if update is required. -CHECK_CLEANFILES+=*.h5 *.bin testfiles/h5diff_attr1.h5 testfiles/tfamily*.h5 +# *.dat files may be created by h5repackgentest. +CHECK_CLEANFILES+=*.h5 *.dat *.bin testfiles/h5diff_attr1.h5 testfiles/tfamily*.h5 DISTCLEANFILES=h5repack.sh h5repack_plugin.sh include $(top_srcdir)/config/conclude.am diff --git a/tools/test/h5repack/h5repack.sh.in b/tools/test/h5repack/h5repack.sh.in index 9851e89..56df3c8 100644 --- a/tools/test/h5repack/h5repack.sh.in +++ b/tools/test/h5repack/h5repack.sh.in @@ -675,7 +675,8 @@ VERIFY_EXTERNAL_CONSOLIDATION() ) # flag if any of the above checks failed - if [ $prev_nerrors != $nerrors ]; then + if [ $prev_nerrors != $nerrors ] + then echo ". . . *FAILED*" nerrors="`expr $prev_nerrors + 1`" else diff --git a/tools/test/h5repack/h5repackgentest.c b/tools/test/h5repack/h5repackgentest.c index 8076b42..0eec88c 100644 --- a/tools/test/h5repack/h5repackgentest.c +++ b/tools/test/h5repack/h5repackgentest.c @@ -8,7 +8,7 @@ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ static void -generate_external_int32le(hbool_t external) +generate_int32le(hbool_t external) { char filename[MAX_NAME_SIZE]; hid_t file; @@ -67,7 +67,7 @@ generate_external_int32le(hbool_t external) HDassert(H5Dclose(dset) >= 0); HDassert(H5Sclose(dspace) >= 0); HDassert(H5Fclose(file) >= 0); -} /* end generate_external_int32le() */ +} /* end generate_int32le() */ /* ---------------------------------------------------------------------------- @@ -75,8 +75,8 @@ generate_external_int32le(hbool_t external) int main(void) { - generate_external_int32le(FALSE); - generate_external_int32le(TRUE); + generate_int32le(FALSE); + generate_int32le(TRUE); return 0; } /* end main() */ -- cgit v0.12 From 2ba7b8f5e0c406376d90b344dadee385e69ca987 Mon Sep 17 00:00:00 2001 From: Jacob Smith Date: Wed, 19 Jun 2019 17:13:54 -0500 Subject: Fix failing automated reporting. Add 8-bit big-endian testfile. --- tools/test/h5repack/CMakeTests.cmake | 13 ++ tools/test/h5repack/h5repack.sh.in | 12 +- tools/test/h5repack/h5repackgentest.c | 160 ++++++++++++++++++--- tools/test/h5repack/testfiles/h5repack_int32le.h5 | Bin 4096 -> 4096 bytes .../test/h5repack/testfiles/h5repack_int32le_ex.h5 | Bin 1472 -> 1472 bytes tools/test/h5repack/testfiles/h5repack_uint8be.h5 | Bin 0 -> 2560 bytes .../h5repack/testfiles/h5repack_uint8be_ex-0.dat | Bin 0 -> 64 bytes .../h5repack/testfiles/h5repack_uint8be_ex-1.dat | 1 + .../h5repack/testfiles/h5repack_uint8be_ex-2.dat | 1 + .../h5repack/testfiles/h5repack_uint8be_ex-3.dat | 1 + .../h5repack/testfiles/h5repack_uint8be_ex-4.dat | Bin 0 -> 64 bytes .../h5repack/testfiles/h5repack_uint8be_ex-5.dat | Bin 0 -> 64 bytes .../h5repack/testfiles/h5repack_uint8be_ex-6.dat | Bin 0 -> 64 bytes .../h5repack/testfiles/h5repack_uint8be_ex-7.dat | Bin 0 -> 64 bytes .../test/h5repack/testfiles/h5repack_uint8be_ex.h5 | Bin 0 -> 1912 bytes 15 files changed, 164 insertions(+), 24 deletions(-) create mode 100644 tools/test/h5repack/testfiles/h5repack_uint8be.h5 create mode 100644 tools/test/h5repack/testfiles/h5repack_uint8be_ex-0.dat create mode 100644 tools/test/h5repack/testfiles/h5repack_uint8be_ex-1.dat create mode 100644 tools/test/h5repack/testfiles/h5repack_uint8be_ex-2.dat create mode 100644 tools/test/h5repack/testfiles/h5repack_uint8be_ex-3.dat create mode 100644 tools/test/h5repack/testfiles/h5repack_uint8be_ex-4.dat create mode 100644 tools/test/h5repack/testfiles/h5repack_uint8be_ex-5.dat create mode 100644 tools/test/h5repack/testfiles/h5repack_uint8be_ex-6.dat create mode 100644 tools/test/h5repack/testfiles/h5repack_uint8be_ex-7.dat create mode 100644 tools/test/h5repack/testfiles/h5repack_uint8be_ex.h5 diff --git a/tools/test/h5repack/CMakeTests.cmake b/tools/test/h5repack/CMakeTests.cmake index 7dbf2a1..f6cf9bf 100644 --- a/tools/test/h5repack/CMakeTests.cmake +++ b/tools/test/h5repack/CMakeTests.cmake @@ -30,6 +30,9 @@ ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_filters.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_fletcher.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_hlink.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_int32le.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_int32le_ex.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_int32le_ex-0.dat ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_layout.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_layouto.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_layout2.h5 @@ -51,6 +54,16 @@ ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_none.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_paged_nopersist.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_paged_persist.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_uint8be.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_uint8be_ex.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_uint8be_ex-0.dat + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_uint8be_ex-1.dat + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_uint8be_ex-2.dat + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_uint8be_ex-3.dat + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_uint8be_ex-4.dat + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_uint8be_ex-5.dat + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_uint8be_ex-6.dat + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_uint8be_ex-7.dat # h5diff/testfile ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_attr1.h5 # tools/testfiles diff --git a/tools/test/h5repack/h5repack.sh.in b/tools/test/h5repack/h5repack.sh.in index 56df3c8..04f04f2 100644 --- a/tools/test/h5repack/h5repack.sh.in +++ b/tools/test/h5repack/h5repack.sh.in @@ -625,17 +625,19 @@ DIFFFAIL() # Catchall test for repacking with external files # Loops over all (internally-listed) cases and applies the given arguments # to h5repack. +# Each test file family must be listed in the for loop at the start of the +# 'function'. # Expects case files to be of format: # + h5repack_.h5 # + h5repack__ex.h5 # + h5repack__ex-.dat # ...where NAME is part of the internal list, and N is a positive decimal # number; multiple external files (*.dat) are allowed per file, but they must -# follow the same pattern and be in numerical sequence starting at 0. +# follow the pattern and be in contiguous numerical sequence starting at 0. # ----------------------------------------------------------------------------- VERIFY_EXTERNAL_CONSOLIDATION() { - for name in int32le + for name in int32le uint8be do basename="h5repack_${name}" base_ext="${basename}_ex" @@ -1551,10 +1553,10 @@ VERIFY_SUPERBLOCK 2 2 3 h5repack_layout.h5 -j 2 -k 2 h5repack_layout.h5 # -j 0 -k 1, file cannot be opened VERIFY_INVALIDBOUNDS 0 1 bounds_latest_latest.h5 -# +######################################## # Testing external storage -# -VERIFY_EXTERNAL_CONSOLIDATION +######################################## +VERIFY_EXTERNAL_CONSOLIDATION -l CONTI # Clean up temporary files/directories CLEAN_TESTFILES_AND_TESTDIR diff --git a/tools/test/h5repack/h5repackgentest.c b/tools/test/h5repack/h5repackgentest.c index 0eec88c..27f6009 100644 --- a/tools/test/h5repack/h5repackgentest.c +++ b/tools/test/h5repack/h5repackgentest.c @@ -1,26 +1,50 @@ #include "hdf5.h" #include "H5private.h" +/* For generating files for verifying h5repack with external storage. . . + * + * Each case file should follow the format of: + * + h5repack_.h5 + * + h5repack__ex.h5 + * + h5repack__ex-.dat + * ...where NAME idenfities the type, and N is a positive decimal number; + * multiple external files (*.dat) are allowed per file, but they must + * follow the pattern and be in contiguous numerical sequence starting at 0. + * + * Each file typename must be added to the listing for + * `VERIFY_EXTERNAL_CONSOLIDATION` in h5repack.sh + * + * There is no restriction on the name, number, or structure of datasets and + * groups in HDF5 file. + * + * The generated files will need to be moved "by hand" into the testfiles + * directory. (TODO) + */ + #define MAX_NAME_SIZE 256 #define FILE_INT32LE "h5repack_int32le" +#define FILE_UINT8BE "h5repack_uint8be" /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * TODO: error handling is a joke, but this seems normal for the tools' + * gentest operations. */ static void generate_int32le(hbool_t external) { char filename[MAX_NAME_SIZE]; hid_t file; - hid_t dspace; hid_t dset; hid_t dcpl = H5P_DEFAULT; + hid_t dspace; hsize_t dims[] = {8, 8, 8}; int32_t wdata[512]; /* 8^3 */ int32_t n; int i; int j; int k; + herr_t ret; /* error-checking */ /* generate values, alternating positive and negative */ @@ -35,20 +59,21 @@ generate_int32le(hbool_t external) FILE_INT32LE, (external) ? "_ex" : ""); - file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - HDassert(file >= 0); - - dspace = H5Screate_simple(3, dims, NULL); - HDassert(dspace >= 0); - if (external) { char name[MAX_NAME_SIZE]; dcpl = H5Pcreate(H5P_DATASET_CREATE); - HDassert(dcpl >= 0); + HDassert(dcpl != H5I_INVALID_HID); snprintf(name, MAX_NAME_SIZE, "%s_ex-0.dat", FILE_INT32LE); - HDassert(H5Pset_external(dcpl, name, 0, H5F_UNLIMITED) >= 0); + ret = H5Pset_external(dcpl, name, 0, H5F_UNLIMITED); + HDassert(ret >= 0); } + dspace = H5Screate_simple(3, dims, NULL); + HDassert(dspace != H5I_INVALID_HID); + + file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + HDassert(file != H5I_INVALID_HID); + dset = H5Dcreate2( file, "dset", @@ -57,26 +82,123 @@ generate_int32le(hbool_t external) H5P_DEFAULT, dcpl, H5P_DEFAULT); - HDassert(dset >= 0); + HDassert(dset != H5I_INVALID_HID); - HDassert(H5Dwrite(dset, H5T_STD_I32LE, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata) - >= 0); + ret = H5Dwrite( + dset, + H5T_STD_I32LE, + H5S_ALL, + H5S_ALL, + H5P_DEFAULT, + wdata); + HDassert(ret >= 0); + + if (dcpl != H5P_DEFAULT) { + ret = H5Pclose(dcpl); + HDassert(ret >= 0); + } + ret = H5Dclose(dset); + HDassert(ret >= 0); + ret = H5Fclose(file); + HDassert(ret >= 0); + ret = H5Sclose(dspace); + HDassert(ret >= 0); - if (external) - HDassert(H5Pclose(dcpl) >= 0); - HDassert(H5Dclose(dset) >= 0); - HDassert(H5Sclose(dspace) >= 0); - HDassert(H5Fclose(file) >= 0); } /* end generate_int32le() */ +static void +generate_uint8be(hbool_t external) +{ + char filename[MAX_NAME_SIZE]; + hid_t file; + hid_t dset; + hid_t dcpl = H5P_DEFAULT; + hid_t dspace; + hsize_t dims[] = {8, 8, 8}; + uint8_t wdata[512]; /* 8^3 */ + uint8_t n; + int i; + int j; + int k; + herr_t ret; /* error-checking */ + + /* Generate values, alternating positive and negative + * The latter half of the dataset is "overflow garbage" (TODO?) + */ + for (i=0, n=0; i < 8; i++) + for (j=0; j < 8; j++) + for (k=0; k < 8; k++, n++) + wdata[n] = n * ((n&1) ? (-1) : (1)); + + snprintf(filename, + MAX_NAME_SIZE, + "%s%s.h5", + FILE_UINT8BE, + (external) ? "_ex" : ""); + + if (external) { + char name[MAX_NAME_SIZE]; + dcpl = H5Pcreate(H5P_DATASET_CREATE); + HDassert(dcpl != H5I_INVALID_HID); + for (i = 0; i < 8; i++) { + snprintf(name, MAX_NAME_SIZE, "%s_ex-%d.dat", FILE_UINT8BE, i); + ret = H5Pset_external(dcpl, name, 0, 64 * sizeof(char)); + HDassert(ret >= 0); + } + } + + dspace = H5Screate_simple(3, dims, NULL); + HDassert(dspace != H5I_INVALID_HID); + + file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + HDassert(file != H5I_INVALID_HID); + + dset = H5Dcreate2( + file, + "dset", + H5T_STD_U8BE, + dspace, + H5P_DEFAULT, + dcpl, + H5P_DEFAULT); + HDassert(dset != H5I_INVALID_HID); + + ret = H5Dwrite( + dset, + H5T_STD_U8BE, + H5S_ALL, + H5S_ALL, + H5P_DEFAULT, + wdata); + HDassert(ret >= 0); + + if (dcpl != H5P_DEFAULT) { + ret = H5Pclose(dcpl); + HDassert(ret >= 0); + } + ret = H5Dclose(dset); + HDassert(ret >= 0); + ret = H5Fclose(file); + HDassert(ret >= 0); + ret = H5Sclose(dspace); + HDassert(ret >= 0); + +} /* end generate_uint8be() */ + + /* ---------------------------------------------------------------------------- */ int main(void) { - generate_int32le(FALSE); - generate_int32le(TRUE); + int i; + + for (i=0; i < 2; i++) { + hbool_t external = (i&1) ? TRUE : FALSE; + generate_int32le(external); + generate_uint8be(external); + } return 0; } /* end main() */ diff --git a/tools/test/h5repack/testfiles/h5repack_int32le.h5 b/tools/test/h5repack/testfiles/h5repack_int32le.h5 index fb00579..4e9500f 100644 Binary files a/tools/test/h5repack/testfiles/h5repack_int32le.h5 and b/tools/test/h5repack/testfiles/h5repack_int32le.h5 differ diff --git a/tools/test/h5repack/testfiles/h5repack_int32le_ex.h5 b/tools/test/h5repack/testfiles/h5repack_int32le_ex.h5 index 337b297..8c8b644 100644 Binary files a/tools/test/h5repack/testfiles/h5repack_int32le_ex.h5 and b/tools/test/h5repack/testfiles/h5repack_int32le_ex.h5 differ diff --git a/tools/test/h5repack/testfiles/h5repack_uint8be.h5 b/tools/test/h5repack/testfiles/h5repack_uint8be.h5 new file mode 100644 index 0000000..f89bc03 Binary files /dev/null and b/tools/test/h5repack/testfiles/h5repack_uint8be.h5 differ diff --git a/tools/test/h5repack/testfiles/h5repack_uint8be_ex-0.dat b/tools/test/h5repack/testfiles/h5repack_uint8be_ex-0.dat new file mode 100644 index 0000000..f95b90a Binary files /dev/null and b/tools/test/h5repack/testfiles/h5repack_uint8be_ex-0.dat differ diff --git a/tools/test/h5repack/testfiles/h5repack_uint8be_ex-1.dat b/tools/test/h5repack/testfiles/h5repack_uint8be_ex-1.dat new file mode 100644 index 0000000..011ab48 --- /dev/null +++ b/tools/test/h5repack/testfiles/h5repack_uint8be_ex-1.dat @@ -0,0 +1 @@ +@¿B½D»F¹H·JµL³N±P¯R­T«V©X§Z¥\£^¡`Ÿbd›f™h—j•l“n‘prt‹v‰x‡z…|ƒ~ \ No newline at end of file diff --git a/tools/test/h5repack/testfiles/h5repack_uint8be_ex-2.dat b/tools/test/h5repack/testfiles/h5repack_uint8be_ex-2.dat new file mode 100644 index 0000000..069b96d --- /dev/null +++ b/tools/test/h5repack/testfiles/h5repack_uint8be_ex-2.dat @@ -0,0 +1 @@ +€‚}„{†yˆwŠuŒsŽqo’m”k–i˜gšeœcža _¢]¤[¦Y¨WªU¬S®Q°O²M´K¶I¸GºE¼C¾A \ No newline at end of file diff --git a/tools/test/h5repack/testfiles/h5repack_uint8be_ex-3.dat b/tools/test/h5repack/testfiles/h5repack_uint8be_ex-3.dat new file mode 100644 index 0000000..240d8ca --- /dev/null +++ b/tools/test/h5repack/testfiles/h5repack_uint8be_ex-3.dat @@ -0,0 +1 @@ +À?Â=Ä;Æ9È7Ê5Ì3Î1Ð/Ò-Ô+Ö)Ø'Ú%Ü#Þ!àâäæèêìîðò ô ö øúüþ \ No newline at end of file diff --git a/tools/test/h5repack/testfiles/h5repack_uint8be_ex-4.dat b/tools/test/h5repack/testfiles/h5repack_uint8be_ex-4.dat new file mode 100644 index 0000000..b5c4e7c Binary files /dev/null and b/tools/test/h5repack/testfiles/h5repack_uint8be_ex-4.dat differ diff --git a/tools/test/h5repack/testfiles/h5repack_uint8be_ex-5.dat b/tools/test/h5repack/testfiles/h5repack_uint8be_ex-5.dat new file mode 100644 index 0000000..b77f32c Binary files /dev/null and b/tools/test/h5repack/testfiles/h5repack_uint8be_ex-5.dat differ diff --git a/tools/test/h5repack/testfiles/h5repack_uint8be_ex-6.dat b/tools/test/h5repack/testfiles/h5repack_uint8be_ex-6.dat new file mode 100644 index 0000000..1e335eb Binary files /dev/null and b/tools/test/h5repack/testfiles/h5repack_uint8be_ex-6.dat differ diff --git a/tools/test/h5repack/testfiles/h5repack_uint8be_ex-7.dat b/tools/test/h5repack/testfiles/h5repack_uint8be_ex-7.dat new file mode 100644 index 0000000..3dadb7d Binary files /dev/null and b/tools/test/h5repack/testfiles/h5repack_uint8be_ex-7.dat differ diff --git a/tools/test/h5repack/testfiles/h5repack_uint8be_ex.h5 b/tools/test/h5repack/testfiles/h5repack_uint8be_ex.h5 new file mode 100644 index 0000000..6f8c3fe Binary files /dev/null and b/tools/test/h5repack/testfiles/h5repack_uint8be_ex.h5 differ -- cgit v0.12 From 63fc460c137e871d21941de8fedc4371be229d42 Mon Sep 17 00:00:00 2001 From: Jacob Smith Date: Thu, 20 Jun 2019 12:30:20 -0500 Subject: Add forgotten files to include from h5repack testfiles for tests. --- tools/test/h5repack/h5repack.sh.in | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/test/h5repack/h5repack.sh.in b/tools/test/h5repack/h5repack.sh.in index 04f04f2..1af4fd0 100644 --- a/tools/test/h5repack/h5repack.sh.in +++ b/tools/test/h5repack/h5repack.sh.in @@ -117,6 +117,8 @@ $SRC_H5REPACK_TESTFILES/h5repack_paged_nopersist.h5 $SRC_H5REPACK_TESTFILES/h5repack_paged_persist.h5 $SRC_H5REPACK_TESTFILES/h5repack_int32le.h5 $SRC_H5REPACK_TESTFILES/h5repack_int32le_ex.h5 +$SRC_H5REPACK_TESTFILES/h5repack_uint8be.h5 +$SRC_H5REPACK_TESTFILES/h5repack_uint8be_ex.h5 $SRC_H5DIFF_TESTFILES/h5diff_attr1.h5 $SRC_TOOLS_TESTFILES/tfamily00000.h5 $SRC_TOOLS_TESTFILES/tfamily00001.h5 @@ -167,6 +169,14 @@ $SRC_H5REPACK_TESTFILES/h5repack_layout.h5.ddl $SRC_H5REPACK_TESTFILES/h5repack_filters.h5-gzip_verbose_filters.tst $SRC_H5REPACK_TESTFILES/h5repack_layout.h5-dset2_chunk_20x10-errstk.tst $SRC_H5REPACK_TESTFILES/h5repack_layout.h5-plugin_test.ddl +$SRC_H5REPACK_TESTFILES/h5repack_uint8be_ex-0.dat +$SRC_H5REPACK_TESTFILES/h5repack_uint8be_ex-1.dat +$SRC_H5REPACK_TESTFILES/h5repack_uint8be_ex-2.dat +$SRC_H5REPACK_TESTFILES/h5repack_uint8be_ex-3.dat +$SRC_H5REPACK_TESTFILES/h5repack_uint8be_ex-4.dat +$SRC_H5REPACK_TESTFILES/h5repack_uint8be_ex-5.dat +$SRC_H5REPACK_TESTFILES/h5repack_uint8be_ex-6.dat +$SRC_H5REPACK_TESTFILES/h5repack_uint8be_ex-7.dat $SRC_H5REPACK_TESTFILES/plugin_test.h5repack_layout.h5.tst $SRC_H5REPACK_TESTFILES/1_vds.h5-vds_dset_chunk20x10x5-v.ddl $SRC_H5REPACK_TESTFILES/2_vds.h5-vds_chunk3x6x9-v.ddl -- cgit v0.12 From 9103fd59530cc45cef39cba81e0f1330a94b4807 Mon Sep 17 00:00:00 2001 From: Jacob Smith Date: Fri, 21 Jun 2019 12:05:54 -0500 Subject: Undo some formatting modifications. Update MANIFEST. --- MANIFEST | 13 +++++++++++++ tools/src/h5repack/h5repack.c | 40 +++++++++++++++----------------------- tools/src/h5repack/h5repack_copy.c | 32 ++++++++++++++---------------- tools/src/h5repack/h5repack_main.c | 12 +++++++++--- 4 files changed, 53 insertions(+), 44 deletions(-) diff --git a/MANIFEST b/MANIFEST index bf1b35a..2704ced 100644 --- a/MANIFEST +++ b/MANIFEST @@ -2557,6 +2557,9 @@ ./tools/test/h5repack/testfiles/h5repack_fsm_aggr_persist.h5 ./tools/test/h5repack/testfiles/h5repack_hlink.h5 ./tools/test/h5repack/testfiles/h5repack.info +./tools/test/h5repack/testfiles/h5repack_int32le.h5 +./tools/test/h5repack/testfiles/h5repack_int32le_ex-0.dat +./tools/test/h5repack/testfiles/h5repack_int32le_ex.h5 ./tools/test/h5repack/testfiles/h5repack_layout.h5 ./tools/test/h5repack/testfiles/h5repack_layouto.h5 ./tools/test/h5repack/testfiles/h5repack_layout2.h5 @@ -2574,6 +2577,16 @@ ./tools/test/h5repack/testfiles/h5repack_shuffle.h5 ./tools/test/h5repack/testfiles/h5repack_soffset.h5 ./tools/test/h5repack/testfiles/h5repack_szip.h5 +./tools/test/h5repack/testfiles/h5repack_uint8be.h5 +./tools/test/h5repack/testfiles/h5repack_uint8be_ex-0.dat +./tools/test/h5repack/testfiles/h5repack_uint8be_ex-1.dat +./tools/test/h5repack/testfiles/h5repack_uint8be_ex-2.dat +./tools/test/h5repack/testfiles/h5repack_uint8be_ex-3.dat +./tools/test/h5repack/testfiles/h5repack_uint8be_ex-4.dat +./tools/test/h5repack/testfiles/h5repack_uint8be_ex-5.dat +./tools/test/h5repack/testfiles/h5repack_uint8be_ex-6.dat +./tools/test/h5repack/testfiles/h5repack_uint8be_ex-7.dat +./tools/test/h5repack/testfiles/h5repack_uint8be_ex.h5 ./tools/test/h5repack/testfiles/ublock.bin ./tools/test/h5repack/testfiles/crtorder.tordergr.h5.ddl ./tools/test/h5repack/testfiles/deflate_limit.h5repack_layout.h5.ddl diff --git a/tools/src/h5repack/h5repack.c b/tools/src/h5repack/h5repack.c index a8b1458..7dc38e6 100644 --- a/tools/src/h5repack/h5repack.c +++ b/tools/src/h5repack/h5repack.c @@ -247,8 +247,7 @@ copy_named_datatype(hid_t type_in, for (i = 0; i < travt->nobjs; i++) { if (travt->objs[i].type == H5TRAV_TYPE_NAMED_DATATYPE) { /* Push onto the stack */ - dt = (named_dt_t *)HDmalloc(sizeof(named_dt_t)); - if (NULL == dt) + if (NULL == (dt = (named_dt_t *)HDmalloc(sizeof(named_dt_t)))) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "buffer allocation failed failed"); dt->next = *named_dt_head_p; @@ -397,20 +396,17 @@ copy_attr( if (H5Aget_name(attr_id, (size_t) 255, name) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed"); - ftype_id = H5Aget_type(attr_id); - if (ftype_id < 0) + if ((ftype_id = H5Aget_type(attr_id)) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_type failed"); /* Check if the datatype is committed */ - is_named = H5Tcommitted(ftype_id); - if (is_named < 0) + if ((is_named = H5Tcommitted(ftype_id)) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tcommitted failed"); if (is_named && travt) { hid_t fidout = -1; /* Create out file id */ - fidout = H5Iget_file_id(loc_out); - if (fidout < 0) + if ((fidout = H5Iget_file_id(loc_out)) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Iget_file_id failed"); /* Copy named dt */ @@ -428,13 +424,13 @@ copy_attr( if (H5Fclose(fidout) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fclose failed"); - } + } /* end if datatype is committed and we have a traversal table */ else { if (options->use_native == 1) wtype_id = H5Tget_native_type(ftype_id, H5T_DIR_DEFAULT); else wtype_id = H5Tcopy(ftype_id); - } + } /* end else: uncommitted datatype and/or no traversal table */ /* get the dataspace handle */ if ((space_id = H5Aget_space(attr_id)) < 0) @@ -673,12 +669,12 @@ check_options(pack_opt_t *options) default: printf(" User Defined %d\n", filtn); break; - } - } - } + } /* end switch */ + } /* end for each filter */ + } /* end if options->all_filter == 1 (TODO: meaning) */ else printf("No all objects to apply filter\n"); - } /* verbose */ + } /* end if verbose */ for (i = 0; i < options->op_tbl->nelems; i++) { pack_info_t pack = options->op_tbl->objs[i]; @@ -699,7 +695,7 @@ check_options(pack_opt_t *options) } } has_cp = 1; - } /* for each filter */ + } /* end for each filter */ } /* end for each object in options table */ if (options->all_filter == 1 && has_cp) @@ -782,8 +778,7 @@ check_objects(const char* fname, pack_opt_t *options) * open the file *------------------------------------------------------------------------- */ - fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, 0); - if (fid < 0) + if ((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, 0)) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "h5tools_fopen failed <%s>: %s", fname, H5FOPENERROR); @@ -843,16 +838,13 @@ check_objects(const char* fname, pack_opt_t *options) csize *= obj.chunk.chunk_lengths[j]; } else { - did = H5Dopen2(fid, name, H5P_DEFAULT); - if (did < 0) + if ((did = H5Dopen2(fid, name, H5P_DEFAULT)) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed"); - sid = H5Dget_space(did); - if (sid < 0) + if ((sid = H5Dget_space(did)) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed"); - rank = H5Sget_simple_extent_ndims(sid); - if (rank < 0) + if ((rank = H5Sget_simple_extent_ndims(sid)) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed"); HDmemset(dims, 0, sizeof dims); @@ -873,7 +865,7 @@ check_objects(const char* fname, pack_opt_t *options) printf(" \n"); HGOTO_DONE(0); } - } /* end SZIP */ + } /* end case SZIP */ break; default: break; diff --git a/tools/src/h5repack/h5repack_copy.c b/tools/src/h5repack/h5repack_copy.c index c638f3d..0d6a6c5 100644 --- a/tools/src/h5repack/h5repack_copy.c +++ b/tools/src/h5repack/h5repack_copy.c @@ -785,9 +785,6 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, if (H5Dclose(dset_in) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed"); -/* TODO: be smart about external storage */ -/* can we use the dcpl_in/out to adjust any external storage? */ -/* what about the case with just H5Ocopy? */ /*------------------------------------------------------------------------- * check if we should use H5Ocopy or not * if there is a request for filters/layout, we read/write the object @@ -914,8 +911,8 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, /* unset unlimited max dims */ if (limit_maxdims) H5Sset_extent_simple(f_space_id, rank, dims, NULL); - } /* if not chunked */ - } /* if layout change requested for entire file or individual object */ + } /* end if not chunked */ + } /* end if layout change requested for entire file or individual object */ /*------------------------------------------------------------------------- * create the output dataset; @@ -930,6 +927,7 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, H5P_DEFAULT, dcpl_out, H5P_DEFAULT); + /* if unable to create, retry with original DCPL */ if (dset_out < 0) { H5Epush2(H5tools_ERR_STACK_g, __FILE__, @@ -952,7 +950,7 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, if (dset_out < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dcreate2 failed"); apply_f = 0; - } /* if opening dataset with original DCPL (retry) */ + } /* end if retry dataset create */ /*------------------------------------------------------------------------- * read/write @@ -1079,7 +1077,7 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, H5Sselect_all(f_space_id); H5Sselect_all(hslab_space); hs_select_nelmts = 1; - } /* rank == 0 */ + } /* end (else) rank == 0 */ if (H5Dread( dset_in, @@ -1112,7 +1110,7 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, else carry = 0; } - } /* hyperslab selection loop */ + } /* end for (hyperslab selection loop) */ H5Sclose(hslab_space); if (hslab_buf != NULL) { @@ -1120,7 +1118,7 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, hslab_buf = NULL; } } /* end if reading/writing by hyperslab */ - } /* if (nelmts > 0 && space_status != H5D_SPACE_STATUS_NOT_ALLOCATED) */ + } /* end if (nelmts > 0 && space_status != H5D_SPACE_STATUS_NOT_ALLOCATED) */ /*------------------------------------------------------------------------- * print amount of compression used @@ -1152,7 +1150,7 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, if (has_filter && apply_f == 0) printf(" \n", travt->objs[i].name); - } /* if verbose (print compression) */ + } /* end if verbose (print compression) */ /*------------------------------------------------------------------------- * copy attrs @@ -1163,11 +1161,11 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, if (H5Dclose(dset_out) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed"); - } /* !H5T_REFERENCE */ - } /* if h5tools_canreadf (filter availability check) */ + } /* end if not a reference */ + } /* end if h5tools_canreadf (filter availability check) */ /*------------------------------------------------------------------------- - * close + * Close *------------------------------------------------------------------------- */ if (H5Tclose(ftype_id) < 0) @@ -1184,7 +1182,7 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed"); } /*------------------------------------------------------------------------- - * we do not have request for filter/chunking; use H5Ocopy instead + * We do not have request for filter/chunking; use H5Ocopy instead *------------------------------------------------------------------------- */ else { @@ -1210,7 +1208,7 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed"); /*------------------------------------------------------------------------- - * copy attrs manually + * Copy attrs manually *------------------------------------------------------------------------- */ if ((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) @@ -1420,8 +1418,8 @@ print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int pr) default: HDstrcat(strfilter, "UD "); break; - } /* switch */ - } /* for each filter */ + } /* end switch */ + } /* end for each filter */ if (!pr) printf(FORMAT_OBJ, "dset", objname); diff --git a/tools/src/h5repack/h5repack_main.c b/tools/src/h5repack/h5repack_main.c index efab3f0..19eabd0 100644 --- a/tools/src/h5repack/h5repack_main.c +++ b/tools/src/h5repack/h5repack_main.c @@ -282,8 +282,7 @@ int read_info(const char *filename, pack_opt_t *options) int i, rc = 1; int ret_value = EXIT_SUCCESS; - fp = HDfopen(filename, "r"); - if ((FILE *)NULL == fp) { + if (NULL == (fp = HDfopen(filename, "r"))) { error_msg("cannot open options file %s\n", filename); h5tools_setstatus(EXIT_FAILURE); ret_value = EXIT_FAILURE; @@ -417,7 +416,14 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) int ret_value = 0; /* parse command line options */ +#if 0 while (EOF != (opt = get_option(argc, argv, s_opts, l_opts))) { +#else + for (opt = get_option(argc, argv, s_opts, l_opts); + opt != EOF; + opt = get_option(argc, argv, s_opts, l_opts)) + { +#endif switch ((char) opt) { /* -i for backward compatibility */ @@ -654,7 +660,7 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) default: break; - } /* switch */ + } /* end switch */ } /* end while there are more options to parse */ /* If neither -i nor -o given, get in and out files positionally */ -- cgit v0.12 From 7ff3a63d5f6c74210a7e5ee064086306436c4062 Mon Sep 17 00:00:00 2001 From: Jacob Smith Date: Mon, 22 Jul 2019 16:55:37 -0500 Subject: Minor formatting adjustments. --- test/external.c | 121 +++++++++--------------- test/vfd.c | 85 ++++++++++------- tools/src/h5repack/h5repack.c | 18 +--- tools/src/h5repack/h5repack_main.c | 8 +- tools/test/h5repack/testfiles/h5repack-help.txt | 8 +- 5 files changed, 110 insertions(+), 130 deletions(-) diff --git a/test/external.c b/test/external.c index 619ca62..09e1e20 100644 --- a/test/external.c +++ b/test/external.c @@ -38,17 +38,15 @@ files_have_same_contents(const char *name1, const char *name2) { int fd1 = 0; int fd2 = 0; - ssize_t n1; - ssize_t n2; + ssize_t n1 = 0; + ssize_t n2 = 0; char buf1[1024]; char buf2[1024]; hbool_t ret = FALSE; /* not equal until proven otherwise */ - fd1 = HDopen(name1, O_RDONLY); - if(fd1 < 0) + if ((fd1 = HDopen(name1, O_RDONLY)) < 0) goto out; - fd2 = HDopen(name2, O_RDONLY); - if(fd2 < 0) + if ((fd2 = HDopen(name2, O_RDONLY)) < 0) goto out; /* Loop until files are empty or we encounter a problem */ @@ -101,29 +99,26 @@ out: static int test_non_extendible(hid_t file) { - hid_t dcpl = -1; /* dataset creation properties */ - hid_t space = -1; /* data space */ - hid_t dset = -1; /* dataset */ - hsize_t cur_size[1] = {100}; /* data space current size */ - hsize_t max_size[1] = {100}; /* data space maximum size */ - int n; /* number of external files */ - off_t file_offset; /* external file offset */ - hsize_t file_size; /* sizeof external file segment */ - haddr_t dset_addr; /* address of dataset */ + hid_t dcpl = -1; /* dataset creation properties */ + hid_t space = -1; /* data space */ + hid_t dset = -1; /* dataset */ + hsize_t cur_size[1] = {100}; /* data space current size */ + hsize_t max_size[1] = {100}; /* data space maximum size */ + int n = 0; /* number of external files */ + off_t file_offset = 0; /* external file offset */ + hsize_t file_size = 0; /* sizeof external file segment */ + haddr_t dset_addr = HADDR_UNDEF; /* address of dataset */ TESTING("fixed-size data space, exact storage"); /* Create the dataset and close */ - dcpl = H5Pcreate(H5P_DATASET_CREATE); - if(dcpl < 0) + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR if(H5Pset_external(dcpl, "ext1.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int))) < 0) FAIL_STACK_ERROR - space = H5Screate_simple(1, cur_size, max_size); - if(space < 0) + if((space = H5Screate_simple(1, cur_size, max_size)) < 0) FAIL_STACK_ERROR - dset = H5Dcreate2(file, "dset1", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); - if(dset < 0) + if((dset = H5Dcreate2(file, "dset1", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR if(H5Dclose(dset) < 0) FAIL_STACK_ERROR @@ -133,8 +128,7 @@ test_non_extendible(hid_t file) FAIL_STACK_ERROR /* Read dataset creation information */ - dset = H5Dopen2(file, "dset1", H5P_DEFAULT); - if(dset < 0) + if((dset = H5Dopen2(file, "dset1", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Test dataset address. Should be undefined. */ @@ -145,11 +139,9 @@ test_non_extendible(hid_t file) FAIL_STACK_ERROR /* Check external count */ - dcpl = H5Dget_create_plist(dset); - if(dcpl < 0) + if((dcpl = H5Dget_create_plist(dset)) < 0) FAIL_STACK_ERROR - n = H5Pget_external_count(dcpl); - if(n < 0) + if((n = H5Pget_external_count(dcpl)) < 0) FAIL_STACK_ERROR if(1 != n) { H5_FAILED(); @@ -215,13 +207,11 @@ test_too_small(hid_t file) TESTING("external storage is too small"); - dcpl = H5Pcreate(H5P_DATASET_CREATE); - if(dcpl < 0) + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR if(H5Pset_external(dcpl, "ext1.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int) - 1)) < 0) /* note -1 */ FAIL_STACK_ERROR - space = H5Screate_simple(1, cur_size, max_size); - if(space < 0) + if((space = H5Screate_simple(1, cur_size, max_size)) < 0) FAIL_STACK_ERROR H5E_BEGIN_TRY { @@ -273,16 +263,13 @@ test_large_enough_current_eventual(hid_t file) TESTING("extendible dataspace, exact external size"); - dcpl = H5Pcreate (H5P_DATASET_CREATE); - if(dcpl < 0) + if((dcpl = H5Pcreate (H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR if(H5Pset_external(dcpl, "ext1.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int))) < 0) FAIL_STACK_ERROR - space = H5Screate_simple(1, cur_size, max_size); - if(space < 0) + if((space = H5Screate_simple(1, cur_size, max_size)) < 0) FAIL_STACK_ERROR - dset = H5Dcreate2(file, "dset3", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); - if(dset < 0) + if((dset = H5Dcreate2(file, "dset3", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR if(H5Dclose(dset) < 0) FAIL_STACK_ERROR @@ -327,13 +314,11 @@ test_large_enough_current_not_eventual(hid_t file) TESTING("extendible dataspace, external storage is too small"); - dcpl = H5Pcreate(H5P_DATASET_CREATE); - if(dcpl < 0) + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR if(H5Pset_external(dcpl, "ext1.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int) - 1)) < 0) /* note -1 */ FAIL_STACK_ERROR - space = H5Screate_simple(1, cur_size, max_size); - if(space < 0) + if((space = H5Screate_simple(1, cur_size, max_size)) < 0) FAIL_STACK_ERROR H5E_BEGIN_TRY { @@ -387,16 +372,13 @@ test_unlimited(hid_t file) TESTING("unlimited dataspace, unlimited external storage"); /* Create dataset */ - dcpl = H5Pcreate(H5P_DATASET_CREATE); - if(dcpl < 0) + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR if(H5Pset_external(dcpl, "ext1.data", (off_t)0, H5F_UNLIMITED) < 0) FAIL_STACK_ERROR - space = H5Screate_simple(1, cur_size, max_size); - if(space < 0) + if((space = H5Screate_simple(1, cur_size, max_size)) < 0) FAIL_STACK_ERROR - dset = H5Dcreate2(file, "dset5", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); - if(dset < 0) + if((dset = H5Dcreate2(file, "dset5", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR if(H5Dclose(dset) < 0) FAIL_STACK_ERROR @@ -404,14 +386,11 @@ test_unlimited(hid_t file) if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR /* Read dataset creation information */ - dset = H5Dopen2(file, "dset5", H5P_DEFAULT); - if(dset < 0) + if((dset = H5Dopen2(file, "dset5", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - dcpl = H5Dget_create_plist(dset); - if(dcpl < 0) + if((dcpl = H5Dget_create_plist(dset)) < 0) FAIL_STACK_ERROR - n = H5Pget_external_count(dcpl); - if(n < 0) + if((n = H5Pget_external_count(dcpl)) < 0) FAIL_STACK_ERROR if(1 != n) { H5_FAILED(); @@ -493,12 +472,10 @@ test_multiple_files(hid_t file) } } - space = H5Screate_simple(1, cur_size, max_size); - if(space < 0) + if((space = H5Screate_simple(1, cur_size, max_size)) < 0) FAIL_STACK_ERROR - dset = H5Dcreate2(file, "dset6", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); - if(dset < 0) + if((dset = H5Dcreate2(file, "dset6", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR if(H5Dclose(dset) < 0) FAIL_STACK_ERROR @@ -508,8 +485,7 @@ test_multiple_files(hid_t file) /* ---------------------------------------------- * Verify that too-small external files will fail */ - dcpl = H5Pcreate(H5P_DATASET_CREATE); - if(dcpl < 0) + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR max_ext_size -= 1; @@ -522,7 +498,7 @@ test_multiple_files(hid_t file) fflush(stderr); FAIL_STACK_ERROR } - } + } /* end for each external file */ H5E_BEGIN_TRY { dset = H5Dcreate2(file, "dset7", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); @@ -564,13 +540,12 @@ static int test_add_to_unlimited(void) { hid_t dcpl = -1; /* dataset creation properties */ - herr_t status; /* function return status */ - int n; /* number of external files */ + herr_t status = FAIL; /* function return status */ + int n = 0; /* number of external files */ TESTING("external file following unlimited file"); - dcpl = H5Pcreate (H5P_DATASET_CREATE); - if(dcpl < 0) + if((dcpl = H5Pcreate (H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR if(H5Pset_external(dcpl, "ext1.data", (off_t)0, H5F_UNLIMITED) < 0) FAIL_STACK_ERROR @@ -581,8 +556,7 @@ test_add_to_unlimited(void) if(status >= 0) FAIL_PUTS_ERROR(" H5Pset_external() succeeded when it should have failed."); - n = H5Pget_external_count(dcpl); - if(n < 0) + if((n = H5Pget_external_count(dcpl)) < 0) FAIL_STACK_ERROR if(1 != n) FAIL_PUTS_ERROR(" Wrong external file count returned."); @@ -617,12 +591,11 @@ static int test_overflow(void) { hid_t dcpl = -1; /* dataset creation properties */ - herr_t status; /* return status */ + herr_t status = FAIL; /* return status */ TESTING("address overflow in external files"); - dcpl = H5Pcreate (H5P_DATASET_CREATE); - if(dcpl < 0) + if((dcpl = H5Pcreate (H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR if(H5Pset_external(dcpl, "ext1.data", (off_t)0, H5F_UNLIMITED-1) < 0) FAIL_STACK_ERROR @@ -667,7 +640,7 @@ test_read_file_set(hid_t fapl) hid_t space = -1; /* data space */ hid_t dset = -1; /* dataset */ hid_t grp = -1; /* group to emit diagnostics */ - size_t i; /* miscellaneous counter */ + size_t i = 0; /* miscellaneous counter */ char filename[1024]; /* file names */ int part[PART_SIZE]; /* raw data buffer (partial) */ int whole[TOTAL_SIZE]; /* raw data buffer (total) */ @@ -785,7 +758,7 @@ test_write_file_set(hid_t fapl) hid_t mem_space = -1; /* memory data space */ hid_t file_space = -1; /* file data space */ hid_t dset = -1; /* dataset */ - unsigned i; /* miscellaneous counter */ + unsigned i = 0; /* miscellaneous counter */ int part[PART_SIZE]; /* raw data buffer (partial) */ int whole[TOTAL_SIZE]; /* raw data buffer (total) */ hsize_t cur_size = 100; /* current data space size */ @@ -909,7 +882,7 @@ test_path_absolute(hid_t fapl) hid_t dcpl = -1; /* dataset creation properties */ hid_t space = -1; /* data space */ hid_t dset = -1; /* dataset */ - size_t i; /* miscellaneous counter */ + size_t i = 0; /* miscellaneous counter */ char cwdpath[1024]; /* working directory */ char filename[1024]; /* file name */ int part[PART_SIZE]; /* raw data buffer (partial) */ @@ -999,7 +972,7 @@ test_path_relative(hid_t fapl) hid_t dcpl = -1; /* dataset creation properties */ hid_t space = -1; /* data space */ hid_t dset = -1; /* dataset */ - size_t i; /* miscellaneous counters */ + size_t i = 0; /* miscellaneous counters */ char cwdpath[1024]; /* working directory */ char filename[1024]; /* file name */ int part[PART_SIZE]; /* raw data buffer (partial) */ @@ -1093,7 +1066,7 @@ test_path_relative_cwd(hid_t fapl) hid_t dset = -1; /* dataset */ hid_t dset2 = -1; /* dataset, opened a second time */ hid_t dset3 = -1; /* dataset, opened with different prefix */ - size_t i; /* miscellaneous counters */ + size_t i = 0; /* miscellaneous counters */ char cwdpath[1024]; /* working directory */ char filename[1024]; /* file name */ int part[PART_SIZE]; /* raw data buffer (partial) */ diff --git a/test/vfd.c b/test/vfd.c index 7c1d9d5..e7c133b 100644 --- a/test/vfd.c +++ b/test/vfd.c @@ -1113,54 +1113,60 @@ error: /*------------------------------------------------------------------------- - * Function: test_family_member_fapl + * Function: test_family_member_fapl * - * Purpose: Actually use the member fapl input to the member vfd. + * Purpose: Actually use the member fapl input to the member vfd. * - * Return: 0 - success - * -1 - failure + * Return: Success: 0 + * Failure: -1 * - * Programmer: Jacob Smith - * 21 May 2019 + * Programmer: Jacob Smith + * 21 May 2019 * *------------------------------------------------------------------------- */ static herr_t test_family_member_fapl(void) { - hid_t file; - hid_t fapl_id; - hid_t memb_fapl_id; - hid_t space; - hid_t dset; + hid_t file = H5I_INVALID_HID; + hid_t fapl_id = H5I_INVALID_HID; + hid_t memb_fapl_id = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; + hid_t dset = H5I_INVALID_HID; char filename[1024]; - char dname[] = "dataset"; - unsigned i; - unsigned j; + char dname[] = "dataset"; + unsigned i = 0; + unsigned j = 0; int buf[FAMILY_NUMBER][FAMILY_SIZE]; - hsize_t dims[2] = {FAMILY_NUMBER, FAMILY_SIZE}; + hsize_t dims[2] = {FAMILY_NUMBER, FAMILY_SIZE}; TESTING("Family member FAPL"); fapl_id = H5Pcreate(H5P_FILE_ACCESS); - if (H5I_INVALID_HID == fapl_id) + if (H5I_INVALID_HID == fapl_id) { TEST_ERROR; + } memb_fapl_id = H5Pcreate(H5P_FILE_ACCESS); - if (H5I_INVALID_HID == memb_fapl_id) + if (H5I_INVALID_HID == memb_fapl_id) { TEST_ERROR; - if (H5Pset_fapl_sec2(memb_fapl_id) == FAIL) + } + if (H5Pset_fapl_sec2(memb_fapl_id) == FAIL) { TEST_ERROR; - if (H5Pset_fapl_family(fapl_id, (hsize_t)FAMILY_SIZE, memb_fapl_id) == FAIL) + } + if (H5Pset_fapl_family(fapl_id, (hsize_t)FAMILY_SIZE, memb_fapl_id) == FAIL) { TEST_ERROR; + } h5_fixname(FILENAME[2], fapl_id, filename, sizeof(filename)); file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); - if (H5I_INVALID_HID == file) + if (H5I_INVALID_HID == file) { TEST_ERROR; + } space = H5Screate_simple(2, dims, NULL); - if (H5I_INVALID_HID == space) + if (H5I_INVALID_HID == space) { TEST_ERROR; + } /* Create and write to dataset, then close file. */ @@ -1172,11 +1178,14 @@ test_family_member_fapl(void) H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if (H5I_INVALID_HID == dset) + if (H5I_INVALID_HID == dset) { TEST_ERROR; - for (i = 0; i < FAMILY_NUMBER; i++) - for (j = 0; j < FAMILY_SIZE; j++) + } + for (i = 0; i < FAMILY_NUMBER; i++) { + for (j = 0; j < FAMILY_SIZE; j++) { buf[i][j] = (int)((i * 10000) + j); + } + } if (H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, @@ -1184,34 +1193,46 @@ test_family_member_fapl(void) H5P_DEFAULT, buf) == FAIL) + { TEST_ERROR; - if (H5Dclose(dset) == FAIL) TEST_ERROR; - if (H5Sclose(space) == FAIL) TEST_ERROR; - if (H5Fclose(file) == FAIL) TEST_ERROR; + } + if (H5Dclose(dset) == FAIL) { + TEST_ERROR; + } + if (H5Sclose(space) == FAIL) { + TEST_ERROR; + } + if (H5Fclose(file) == FAIL) { + TEST_ERROR; + } /* "Close" member FAPL at top level and re-open file. * Should succeed, with library managing reference count properly */ - if (H5Pclose(memb_fapl_id) == FAIL) + if (H5Pclose(memb_fapl_id) == FAIL) { TEST_ERROR; + } file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id); - if (H5I_INVALID_HID == file) + if (H5I_INVALID_HID == file) { TEST_ERROR; + } - if (H5Fclose(file) == FAIL) + if (H5Fclose(file) == FAIL) { TEST_ERROR; + } h5_delete_test_file(FILENAME[2], fapl_id); - if (H5Pclose(fapl_id) == FAIL) + if (H5Pclose(fapl_id) == FAIL) { TEST_ERROR; + } PASSED(); return 0; error: - H5E_BEGIN_TRY{ + H5E_BEGIN_TRY { H5Sclose(space); H5Dclose(dset); H5Pclose(memb_fapl_id); diff --git a/tools/src/h5repack/h5repack.c b/tools/src/h5repack/h5repack.c index 7dc38e6..c9cc020 100644 --- a/tools/src/h5repack/h5repack.c +++ b/tools/src/h5repack/h5repack.c @@ -382,15 +382,7 @@ copy_attr( */ for (u = 0; u < (unsigned) oinfo.num_attrs; u++) { /* open attribute */ - attr_id = H5Aopen_by_idx( - loc_in, - ".", - H5_INDEX_CRT_ORDER, - H5_ITER_INC, - (hsize_t) u, - H5P_DEFAULT, - H5P_DEFAULT); - if (attr_id < 0) + if((attr_id = H5Aopen_by_idx(loc_in, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t) u, H5P_DEFAULT, H5P_DEFAULT)) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aopen_by_idx failed"); if (H5Aget_name(attr_id, (size_t) 255, name) < 0) @@ -410,13 +402,7 @@ copy_attr( HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Iget_file_id failed"); /* Copy named dt */ - wtype_id = copy_named_datatype( - ftype_id, - fidout, - named_dt_head_p, - travt, - options); - if (wtype_id < 0) { + if ((wtype_id = copy_named_datatype(ftype_id, fidout, named_dt_head_p, travt, options)) < 0) { H5Fclose(fidout); HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "copy_named_datatype failed"); diff --git a/tools/src/h5repack/h5repack_main.c b/tools/src/h5repack/h5repack_main.c index 19eabd0..b4e5470 100644 --- a/tools/src/h5repack/h5repack_main.c +++ b/tools/src/h5repack/h5repack_main.c @@ -90,11 +90,11 @@ static void usage(const char *prog) { PRINTVALSTREAM(rawoutstream, " This option will take precedence over the options\n"); PRINTVALSTREAM(rawoutstream, " --low and --high\n"); PRINTVALSTREAM(rawoutstream, " --low=BOUND The low bound for library release versions to use\n"); - PRINTVALSTREAM(rawoutstream, " when creating objects in the file (default is 0\n"); - PRINTVALSTREAM(rawoutstream, " [H5F_LIBVER_EARLIEST])\n"); + PRINTVALSTREAM(rawoutstream, " when creating objects in the file\n"); + PRINTVALSTREAM(rawoutstream, " (default is H5F_LIBVER_EARLIEST)\n"); PRINTVALSTREAM(rawoutstream, " --high=BOUND The high bound for library release versions to use\n"); - PRINTVALSTREAM(rawoutstream, " when creating objects in the file (default is 2\n"); - PRINTVALSTREAM(rawoutstream, " [H5F_LIBVER_V110 this release; H5F_LIBVER_LATEST])\n"); + PRINTVALSTREAM(rawoutstream, " when creating objects in the file\n"); + PRINTVALSTREAM(rawoutstream, " (default is H5F_LIBVER_LATEST)\n"); PRINTVALSTREAM(rawoutstream, " -c L1, --compact=L1 Maximum number of links in header messages\n"); PRINTVALSTREAM(rawoutstream, " -d L2, --indexed=L2 Minimum number of links in the indexed format\n"); PRINTVALSTREAM(rawoutstream, " -s S[:F], --ssize=S[:F] Shared object header message minimum size\n"); diff --git a/tools/test/h5repack/testfiles/h5repack-help.txt b/tools/test/h5repack/testfiles/h5repack-help.txt index ad07784..03553dd 100644 --- a/tools/test/h5repack/testfiles/h5repack-help.txt +++ b/tools/test/h5repack/testfiles/h5repack-help.txt @@ -12,11 +12,11 @@ usage: h5repack [OPTIONS] file1 file2 This option will take precedence over the options --low and --high --low=BOUND The low bound for library release versions to use - when creating objects in the file (default is 0 - [H5F_LIBVER_EARLIEST]) + when creating objects in the file + (default is H5F_LIBVER_EARLIEST) --high=BOUND The high bound for library release versions to use - when creating objects in the file (default is 2 - [H5F_LIBVER_V110 this release; H5F_LIBVER_LATEST]) + when creating objects in the file + (default is H5F_LIBVER_LATEST) -c L1, --compact=L1 Maximum number of links in header messages -d L2, --indexed=L2 Minimum number of links in the indexed format -s S[:F], --ssize=S[:F] Shared object header message minimum size -- cgit v0.12 From ded30348ae923a15f287b9a2f49a97ce5ac10da0 Mon Sep 17 00:00:00 2001 From: Jacob Smith Date: Mon, 22 Jul 2019 17:34:01 -0500 Subject: Add copyright/disclaimer to repack gentest. Minor formatting tweaks. --- tools/src/h5repack/h5repack_main.c | 7 ---- tools/test/h5repack/h5repackgentest.c | 74 +++++++++++++++++++++-------------- 2 files changed, 45 insertions(+), 36 deletions(-) diff --git a/tools/src/h5repack/h5repack_main.c b/tools/src/h5repack/h5repack_main.c index b4e5470..a146499 100644 --- a/tools/src/h5repack/h5repack_main.c +++ b/tools/src/h5repack/h5repack_main.c @@ -416,14 +416,7 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) int ret_value = 0; /* parse command line options */ -#if 0 while (EOF != (opt = get_option(argc, argv, s_opts, l_opts))) { -#else - for (opt = get_option(argc, argv, s_opts, l_opts); - opt != EOF; - opt = get_option(argc, argv, s_opts, l_opts)) - { -#endif switch ((char) opt) { /* -i for backward compatibility */ diff --git a/tools/test/h5repack/h5repackgentest.c b/tools/test/h5repack/h5repackgentest.c index 27f6009..c236d71 100644 --- a/tools/test/h5repack/h5repackgentest.c +++ b/tools/test/h5repack/h5repackgentest.c @@ -1,5 +1,15 @@ -#include "hdf5.h" -#include "H5private.h" +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* For generating files for verifying h5repack with external storage. . . * @@ -16,11 +26,11 @@ * * There is no restriction on the name, number, or structure of datasets and * groups in HDF5 file. - * - * The generated files will need to be moved "by hand" into the testfiles - * directory. (TODO) */ +#include "hdf5.h" +#include "H5private.h" + #define MAX_NAME_SIZE 256 #define FILE_INT32LE "h5repack_int32le" #define FILE_UINT8BE "h5repack_uint8be" @@ -34,24 +44,27 @@ static void generate_int32le(hbool_t external) { char filename[MAX_NAME_SIZE]; - hid_t file; - hid_t dset; + hid_t file = H5I_INVALID_HID; + hid_t dset = H5I_INVALID_HID; hid_t dcpl = H5P_DEFAULT; - hid_t dspace; + hid_t dspace = H5I_INVALID_HID; hsize_t dims[] = {8, 8, 8}; - int32_t wdata[512]; /* 8^3 */ - int32_t n; - int i; - int j; - int k; - herr_t ret; /* error-checking */ + int32_t wdata[512]; /* 8^3, from dims */ + int32_t n = 0; + int i = 0; + int j = 0; + int k = 0; + herr_t ret = FAIL; /* error-checking */ /* generate values, alternating positive and negative */ - for (i=0, n=0; i < 8; i++) - for (j=0; j < 8; j++) - for (k=0; k < 8; k++, n++) + for (i=0, n=0; i < 8; i++) { + for (j=0; j < 8; j++) { + for (k=0; k < 8; k++, n++) { wdata[n] = (k + j*512 + i*4096) * ((n&1) ? (-1) : (1)); + } + } + } snprintf(filename, MAX_NAME_SIZE, @@ -111,25 +124,28 @@ static void generate_uint8be(hbool_t external) { char filename[MAX_NAME_SIZE]; - hid_t file; - hid_t dset; + hid_t file = H5I_INVALID_HID; + hid_t dset = H5I_INVALID_HID; hid_t dcpl = H5P_DEFAULT; - hid_t dspace; + hid_t dspace = H5I_INVALID_HID; hsize_t dims[] = {8, 8, 8}; - uint8_t wdata[512]; /* 8^3 */ - uint8_t n; - int i; - int j; - int k; + uint8_t wdata[512]; /* 8^3, from dims */ + uint8_t n = 0; + int i = 0; + int j = 0; + int k = 0; herr_t ret; /* error-checking */ /* Generate values, alternating positive and negative * The latter half of the dataset is "overflow garbage" (TODO?) */ - for (i=0, n=0; i < 8; i++) - for (j=0; j < 8; j++) - for (k=0; k < 8; k++, n++) + for (i=0, n=0; i < 8; i++) { + for (j=0; j < 8; j++) { + for (k=0; k < 8; k++, n++) { wdata[n] = n * ((n&1) ? (-1) : (1)); + } + } + } snprintf(filename, MAX_NAME_SIZE, @@ -192,7 +208,7 @@ generate_uint8be(hbool_t external) int main(void) { - int i; + int i = 0; for (i=0; i < 2; i++) { hbool_t external = (i&1) ? TRUE : FALSE; -- cgit v0.12 From 7d3e17076312ddf8083d749e51629f0ef90b38c7 Mon Sep 17 00:00:00 2001 From: Jacob Smith Date: Mon, 29 Jul 2019 14:58:39 -0500 Subject: Refactoring. --- tools/test/h5repack/h5repackgentest.c | 235 ++++++++++++++++++++++------------ 1 file changed, 156 insertions(+), 79 deletions(-) diff --git a/tools/test/h5repack/h5repackgentest.c b/tools/test/h5repack/h5repackgentest.c index c236d71..7242ebf 100644 --- a/tools/test/h5repack/h5repackgentest.c +++ b/tools/test/h5repack/h5repackgentest.c @@ -35,26 +35,104 @@ #define FILE_INT32LE "h5repack_int32le" #define FILE_UINT8BE "h5repack_uint8be" +#define H5REPACKGENTEST_OOPS ret_value = -1; goto done; + +#define H5REPACKGENTEST_COMMON_CLEANUP(dcpl, file, space) { \ + if ((dcpl) != H5P_DEFAULT && (dcpl) != H5I_INVALID_HID) { \ + (void)H5Pclose((dcpl)); \ + } \ + if ((file) != H5I_INVALID_HID) { (void)H5Fclose((file)); } \ + if ((space) != H5I_INVALID_HID) { (void)H5Sclose((space)); } \ +} + + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Helper function to create and write a dataset to file. + * Returns 0 on success, -1 on failure. + */ +static int +make_dataset( + hid_t file, + const char *dset_name, + hid_t mem_type_id, + hid_t space, + hid_t dcpl, + void *wdata) +{ + hid_t dset = H5I_INVALID_HID; + int ret_value = 0; + + dset = H5Dcreate2( + file, + "dset", + mem_type_id, + space, + H5P_DEFAULT, + dcpl, + H5P_DEFAULT); + if (dset == H5I_INVALID_HID) { + H5REPACKGENTEST_OOPS; + } + + if (H5Dwrite( + dset, + mem_type_id, + H5S_ALL, + H5S_ALL, + H5P_DEFAULT, + wdata) + < 0) + { + H5REPACKGENTEST_OOPS; + } + +done: + if (dset != H5I_INVALID_HID) { (void)H5Dclose(dset); } + return ret_value; +} /* end make_dataset() */ + + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Helper function to populate the DCPL external storage list. + * Returns 0 on success, -1 on failure. + */ +static int +set_dcpl_external_list( + hid_t dcpl, + const char *filename, + hsize_t n_external_files, + hsize_t n_elts, + hsize_t elt_size) +{ + hsize_t i = 0; + char name[MAX_NAME_SIZE]; + + for (i = 0; i < n_external_files; i++) { + snprintf(name, MAX_NAME_SIZE, "%s_ex-%llu.dat", filename, i); + if (H5Pset_external(dcpl, name, 0, n_elts * elt_size) < 0) { + return -1; + } + } + return 0; +} /* end set_dcpl_external_list() */ + /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * TODO: error handling is a joke, but this seems normal for the tools' - * gentest operations. */ -static void +static int generate_int32le(hbool_t external) { char filename[MAX_NAME_SIZE]; hid_t file = H5I_INVALID_HID; - hid_t dset = H5I_INVALID_HID; hid_t dcpl = H5P_DEFAULT; - hid_t dspace = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; hsize_t dims[] = {8, 8, 8}; int32_t wdata[512]; /* 8^3, from dims */ int32_t n = 0; int i = 0; int j = 0; int k = 0; - herr_t ret = FAIL; /* error-checking */ + int ret_value = 0; /* generate values, alternating positive and negative */ @@ -73,68 +151,66 @@ generate_int32le(hbool_t external) (external) ? "_ex" : ""); if (external) { - char name[MAX_NAME_SIZE]; dcpl = H5Pcreate(H5P_DATASET_CREATE); - HDassert(dcpl != H5I_INVALID_HID); - snprintf(name, MAX_NAME_SIZE, "%s_ex-0.dat", FILE_INT32LE); - ret = H5Pset_external(dcpl, name, 0, H5F_UNLIMITED); - HDassert(ret >= 0); + if (dcpl == H5I_INVALID_HID) { + H5REPACKGENTEST_OOPS; + } + if (set_dcpl_external_list( + dcpl, + FILE_INT32LE, + 1, + 512, + sizeof(int32_t)) + < 0) + { + H5REPACKGENTEST_OOPS; + } } - dspace = H5Screate_simple(3, dims, NULL); - HDassert(dspace != H5I_INVALID_HID); + space = H5Screate_simple(3, dims, NULL); + if (space == H5I_INVALID_HID) { + H5REPACKGENTEST_OOPS; + } file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - HDassert(file != H5I_INVALID_HID); + if (file == H5I_INVALID_HID) { + H5REPACKGENTEST_OOPS; + } - dset = H5Dcreate2( + if (make_dataset( file, "dset", H5T_STD_I32LE, - dspace, - H5P_DEFAULT, + space, dcpl, - H5P_DEFAULT); - HDassert(dset != H5I_INVALID_HID); - - ret = H5Dwrite( - dset, - H5T_STD_I32LE, - H5S_ALL, - H5S_ALL, - H5P_DEFAULT, - wdata); - HDassert(ret >= 0); - - if (dcpl != H5P_DEFAULT) { - ret = H5Pclose(dcpl); - HDassert(ret >= 0); + wdata) + < 0) + { + H5REPACKGENTEST_OOPS; } - ret = H5Dclose(dset); - HDassert(ret >= 0); - ret = H5Fclose(file); - HDassert(ret >= 0); - ret = H5Sclose(dspace); - HDassert(ret >= 0); +done: + H5REPACKGENTEST_COMMON_CLEANUP(dcpl, file, space); + return ret_value; } /* end generate_int32le() */ -static void +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + */ +static int generate_uint8be(hbool_t external) { char filename[MAX_NAME_SIZE]; hid_t file = H5I_INVALID_HID; - hid_t dset = H5I_INVALID_HID; hid_t dcpl = H5P_DEFAULT; - hid_t dspace = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; hsize_t dims[] = {8, 8, 8}; uint8_t wdata[512]; /* 8^3, from dims */ uint8_t n = 0; int i = 0; int j = 0; int k = 0; - herr_t ret; /* error-checking */ + int ret_value = 0; /* Generate values, alternating positive and negative * The latter half of the dataset is "overflow garbage" (TODO?) @@ -154,52 +230,47 @@ generate_uint8be(hbool_t external) (external) ? "_ex" : ""); if (external) { - char name[MAX_NAME_SIZE]; dcpl = H5Pcreate(H5P_DATASET_CREATE); - HDassert(dcpl != H5I_INVALID_HID); - for (i = 0; i < 8; i++) { - snprintf(name, MAX_NAME_SIZE, "%s_ex-%d.dat", FILE_UINT8BE, i); - ret = H5Pset_external(dcpl, name, 0, 64 * sizeof(char)); - HDassert(ret >= 0); + if (dcpl == H5I_INVALID_HID) { + H5REPACKGENTEST_OOPS; + } + if (set_dcpl_external_list( + dcpl, + FILE_UINT8BE, + 8, + 64, + sizeof(uint8_t)) + < 0) + { + H5REPACKGENTEST_OOPS; } } - dspace = H5Screate_simple(3, dims, NULL); - HDassert(dspace != H5I_INVALID_HID); + space = H5Screate_simple(3, dims, NULL); + if (space == H5I_INVALID_HID) { + H5REPACKGENTEST_OOPS; + } file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - HDassert(file != H5I_INVALID_HID); + if (file == H5I_INVALID_HID) { + H5REPACKGENTEST_OOPS; + } - dset = H5Dcreate2( + if (make_dataset( file, "dset", H5T_STD_U8BE, - dspace, - H5P_DEFAULT, + space, dcpl, - H5P_DEFAULT); - HDassert(dset != H5I_INVALID_HID); - - ret = H5Dwrite( - dset, - H5T_STD_U8BE, - H5S_ALL, - H5S_ALL, - H5P_DEFAULT, - wdata); - HDassert(ret >= 0); - - if (dcpl != H5P_DEFAULT) { - ret = H5Pclose(dcpl); - HDassert(ret >= 0); + wdata) + < 0) + { + H5REPACKGENTEST_OOPS; } - ret = H5Dclose(dset); - HDassert(ret >= 0); - ret = H5Fclose(file); - HDassert(ret >= 0); - ret = H5Sclose(dspace); - HDassert(ret >= 0); +done: + H5REPACKGENTEST_COMMON_CLEANUP(dcpl, file, space); + return ret_value; } /* end generate_uint8be() */ @@ -208,14 +279,20 @@ generate_uint8be(hbool_t external) int main(void) { - int i = 0; + int i = 0; /* loop variable */ + int ret_value = 0; for (i=0; i < 2; i++) { hbool_t external = (i&1) ? TRUE : FALSE; - generate_int32le(external); - generate_uint8be(external); + if (ret_value == 0) { ret_value -= generate_int32le(external); } + if (ret_value == 0) { ret_value -= generate_uint8be(external); } + } /* end for external data storage or not */ + + if (ret_value != 0) { + /* TODO: print warning message? */ } - return 0; + + return ret_value; } /* end main() */ -- cgit v0.12 From aa797af31b41773281ee55dab47cca278244f933 Mon Sep 17 00:00:00 2001 From: Jacob Smith Date: Mon, 23 Sep 2019 16:21:37 -0500 Subject: Refactor h5repackgentest to have more modular internals, for easier addition of new tests. Update manifest and test script for new hdf5 external-storage .h5 files. --- MANIFEST | 20 +- tools/test/h5repack/h5repack.sh.in | 24 +- tools/test/h5repack/h5repackgentest.c | 355 ++++++++++++++------- tools/test/h5repack/testfiles/h5repack_f32le.h5 | Bin 0 -> 2336 bytes .../h5repack/testfiles/h5repack_f32le_ex-0.dat | Bin 0 -> 288 bytes tools/test/h5repack/testfiles/h5repack_f32le_ex.h5 | Bin 0 -> 1464 bytes tools/test/h5repack/testfiles/h5repack_int32le.h5 | Bin 4096 -> 0 bytes .../test/h5repack/testfiles/h5repack_int32le_1d.h5 | Bin 0 -> 2096 bytes .../testfiles/h5repack_int32le_1d_ex-0.dat | 1 + .../testfiles/h5repack_int32le_1d_ex-1.dat | Bin 0 -> 24 bytes .../h5repack/testfiles/h5repack_int32le_1d_ex.h5 | Bin 0 -> 1504 bytes .../test/h5repack/testfiles/h5repack_int32le_2d.h5 | Bin 0 -> 2304 bytes .../testfiles/h5repack_int32le_2d_ex-0.dat | Bin 0 -> 256 bytes .../h5repack/testfiles/h5repack_int32le_2d_ex.h5 | Bin 0 -> 1472 bytes .../test/h5repack/testfiles/h5repack_int32le_3d.h5 | Bin 0 -> 4096 bytes .../testfiles/h5repack_int32le_3d_ex-0.dat | Bin 0 -> 2048 bytes .../h5repack/testfiles/h5repack_int32le_3d_ex.h5 | Bin 0 -> 1472 bytes .../h5repack/testfiles/h5repack_int32le_ex-0.dat | Bin 2048 -> 0 bytes .../test/h5repack/testfiles/h5repack_int32le_ex.h5 | Bin 1472 -> 0 bytes tools/test/h5repack/testfiles/h5repack_uint8be.h5 | Bin 2560 -> 2304 bytes .../h5repack/testfiles/h5repack_uint8be_ex-4.dat | Bin 64 -> 0 bytes .../h5repack/testfiles/h5repack_uint8be_ex-5.dat | Bin 64 -> 0 bytes .../h5repack/testfiles/h5repack_uint8be_ex-6.dat | Bin 64 -> 0 bytes .../h5repack/testfiles/h5repack_uint8be_ex-7.dat | Bin 64 -> 0 bytes .../test/h5repack/testfiles/h5repack_uint8be_ex.h5 | Bin 1912 -> 1608 bytes 25 files changed, 262 insertions(+), 138 deletions(-) create mode 100644 tools/test/h5repack/testfiles/h5repack_f32le.h5 create mode 100644 tools/test/h5repack/testfiles/h5repack_f32le_ex-0.dat create mode 100644 tools/test/h5repack/testfiles/h5repack_f32le_ex.h5 delete mode 100644 tools/test/h5repack/testfiles/h5repack_int32le.h5 create mode 100644 tools/test/h5repack/testfiles/h5repack_int32le_1d.h5 create mode 100644 tools/test/h5repack/testfiles/h5repack_int32le_1d_ex-0.dat create mode 100644 tools/test/h5repack/testfiles/h5repack_int32le_1d_ex-1.dat create mode 100644 tools/test/h5repack/testfiles/h5repack_int32le_1d_ex.h5 create mode 100644 tools/test/h5repack/testfiles/h5repack_int32le_2d.h5 create mode 100644 tools/test/h5repack/testfiles/h5repack_int32le_2d_ex-0.dat create mode 100644 tools/test/h5repack/testfiles/h5repack_int32le_2d_ex.h5 create mode 100644 tools/test/h5repack/testfiles/h5repack_int32le_3d.h5 create mode 100644 tools/test/h5repack/testfiles/h5repack_int32le_3d_ex-0.dat create mode 100644 tools/test/h5repack/testfiles/h5repack_int32le_3d_ex.h5 delete mode 100644 tools/test/h5repack/testfiles/h5repack_int32le_ex-0.dat delete mode 100644 tools/test/h5repack/testfiles/h5repack_int32le_ex.h5 delete mode 100644 tools/test/h5repack/testfiles/h5repack_uint8be_ex-4.dat delete mode 100644 tools/test/h5repack/testfiles/h5repack_uint8be_ex-5.dat delete mode 100644 tools/test/h5repack/testfiles/h5repack_uint8be_ex-6.dat delete mode 100644 tools/test/h5repack/testfiles/h5repack_uint8be_ex-7.dat diff --git a/MANIFEST b/MANIFEST index 98ca487..df29b8f 100644 --- a/MANIFEST +++ b/MANIFEST @@ -2552,16 +2552,26 @@ ./tools/test/h5repack/testfiles/h5repack_early.h5 ./tools/test/h5repack/testfiles/h5repack_ext.bin ./tools/test/h5repack/testfiles/h5repack_ext.h5 +./tools/test/h5repack/testfiles/h5repack_f32le.h5 +./tools/test/h5repack/testfiles/h5repack_f32le_ex-0.dat +./tools/test/h5repack/testfiles/h5repack_f32le_ex.h5 ./tools/test/h5repack/testfiles/h5repack_fill.h5 ./tools/test/h5repack/testfiles/h5repack_filters.h5 ./tools/test/h5repack/testfiles/h5repack_fletcher.h5 ./tools/test/h5repack/testfiles/h5repack_fsm_aggr_nopersist.h5 ./tools/test/h5repack/testfiles/h5repack_fsm_aggr_persist.h5 ./tools/test/h5repack/testfiles/h5repack_hlink.h5 +./tools/test/h5repack/testfiles/h5repack_int32le_1d.h5 +./tools/test/h5repack/testfiles/h5repack_int32le_1d_ex-0.dat +./tools/test/h5repack/testfiles/h5repack_int32le_1d_ex-1.dat +./tools/test/h5repack/testfiles/h5repack_int32le_1d_ex.h5 +./tools/test/h5repack/testfiles/h5repack_int32le_2d.h5 +./tools/test/h5repack/testfiles/h5repack_int32le_2d_ex-0.dat +./tools/test/h5repack/testfiles/h5repack_int32le_2d_ex.h5 +./tools/test/h5repack/testfiles/h5repack_int32le_3d.h5 +./tools/test/h5repack/testfiles/h5repack_int32le_3d_ex-0.dat +./tools/test/h5repack/testfiles/h5repack_int32le_3d_ex.h5 ./tools/test/h5repack/testfiles/h5repack.info -./tools/test/h5repack/testfiles/h5repack_int32le.h5 -./tools/test/h5repack/testfiles/h5repack_int32le_ex-0.dat -./tools/test/h5repack/testfiles/h5repack_int32le_ex.h5 ./tools/test/h5repack/testfiles/h5repack_layout.h5 ./tools/test/h5repack/testfiles/h5repack_layouto.h5 ./tools/test/h5repack/testfiles/h5repack_layout2.h5 @@ -2584,10 +2594,6 @@ ./tools/test/h5repack/testfiles/h5repack_uint8be_ex-1.dat ./tools/test/h5repack/testfiles/h5repack_uint8be_ex-2.dat ./tools/test/h5repack/testfiles/h5repack_uint8be_ex-3.dat -./tools/test/h5repack/testfiles/h5repack_uint8be_ex-4.dat -./tools/test/h5repack/testfiles/h5repack_uint8be_ex-5.dat -./tools/test/h5repack/testfiles/h5repack_uint8be_ex-6.dat -./tools/test/h5repack/testfiles/h5repack_uint8be_ex-7.dat ./tools/test/h5repack/testfiles/h5repack_uint8be_ex.h5 ./tools/test/h5repack/testfiles/ublock.bin ./tools/test/h5repack/testfiles/crtorder.tordergr.h5.ddl diff --git a/tools/test/h5repack/h5repack.sh.in b/tools/test/h5repack/h5repack.sh.in index 1af4fd0..1232b33 100644 --- a/tools/test/h5repack/h5repack.sh.in +++ b/tools/test/h5repack/h5repack.sh.in @@ -115,8 +115,14 @@ $SRC_H5REPACK_TESTFILES/h5repack_fsm_aggr_persist.h5 $SRC_H5REPACK_TESTFILES/h5repack_none.h5 $SRC_H5REPACK_TESTFILES/h5repack_paged_nopersist.h5 $SRC_H5REPACK_TESTFILES/h5repack_paged_persist.h5 -$SRC_H5REPACK_TESTFILES/h5repack_int32le.h5 -$SRC_H5REPACK_TESTFILES/h5repack_int32le_ex.h5 +$SRC_H5REPACK_TESTFILES/h5repack_f32le.h5 +$SRC_H5REPACK_TESTFILES/h5repack_f32le_ex.h5 +$SRC_H5REPACK_TESTFILES/h5repack_int32le_1d.h5 +$SRC_H5REPACK_TESTFILES/h5repack_int32le_1d_ex.h5 +$SRC_H5REPACK_TESTFILES/h5repack_int32le_2d.h5 +$SRC_H5REPACK_TESTFILES/h5repack_int32le_2d_ex.h5 +$SRC_H5REPACK_TESTFILES/h5repack_int32le_3d.h5 +$SRC_H5REPACK_TESTFILES/h5repack_int32le_3d_ex.h5 $SRC_H5REPACK_TESTFILES/h5repack_uint8be.h5 $SRC_H5REPACK_TESTFILES/h5repack_uint8be_ex.h5 $SRC_H5DIFF_TESTFILES/h5diff_attr1.h5 @@ -164,7 +170,11 @@ $SRC_H5REPACK_TESTFILES/ublock.bin $SRC_H5REPACK_TESTFILES/h5repack.info $SRC_H5REPACK_TESTFILES/crtorder.tordergr.h5.ddl $SRC_H5REPACK_TESTFILES/deflate_limit.h5repack_layout.h5.ddl -$SRC_H5REPACK_TESTFILES/h5repack_int32le_ex-0.dat +$SRC_H5REPACK_TESTFILES/h5repack_f32le_ex-0.dat +$SRC_H5REPACK_TESTFILES/h5repack_int32le_1d_ex-0.dat +$SRC_H5REPACK_TESTFILES/h5repack_int32le_1d_ex-1.dat +$SRC_H5REPACK_TESTFILES/h5repack_int32le_2d_ex-0.dat +$SRC_H5REPACK_TESTFILES/h5repack_int32le_3d_ex-0.dat $SRC_H5REPACK_TESTFILES/h5repack_layout.h5.ddl $SRC_H5REPACK_TESTFILES/h5repack_filters.h5-gzip_verbose_filters.tst $SRC_H5REPACK_TESTFILES/h5repack_layout.h5-dset2_chunk_20x10-errstk.tst @@ -173,10 +183,6 @@ $SRC_H5REPACK_TESTFILES/h5repack_uint8be_ex-0.dat $SRC_H5REPACK_TESTFILES/h5repack_uint8be_ex-1.dat $SRC_H5REPACK_TESTFILES/h5repack_uint8be_ex-2.dat $SRC_H5REPACK_TESTFILES/h5repack_uint8be_ex-3.dat -$SRC_H5REPACK_TESTFILES/h5repack_uint8be_ex-4.dat -$SRC_H5REPACK_TESTFILES/h5repack_uint8be_ex-5.dat -$SRC_H5REPACK_TESTFILES/h5repack_uint8be_ex-6.dat -$SRC_H5REPACK_TESTFILES/h5repack_uint8be_ex-7.dat $SRC_H5REPACK_TESTFILES/plugin_test.h5repack_layout.h5.tst $SRC_H5REPACK_TESTFILES/1_vds.h5-vds_dset_chunk20x10x5-v.ddl $SRC_H5REPACK_TESTFILES/2_vds.h5-vds_chunk3x6x9-v.ddl @@ -647,7 +653,7 @@ DIFFFAIL() # ----------------------------------------------------------------------------- VERIFY_EXTERNAL_CONSOLIDATION() { - for name in int32le uint8be + for name in f32le int32le_1d int32le_2d int32le_3d uint8be do basename="h5repack_${name}" base_ext="${basename}_ex" @@ -672,7 +678,7 @@ VERIFY_EXTERNAL_CONSOLIDATION() DIFFTEST $repacked $canonical DIFFTEST $repacked $external - # invalidate external file by moving its data file; verify + # invalidate external file by moving its first data file; verify ( cd $TESTDIR mv $ex_dat $ex_dat_mv ) diff --git a/tools/test/h5repack/h5repackgentest.c b/tools/test/h5repack/h5repackgentest.c index 7242ebf..6e2c6bf 100644 --- a/tools/test/h5repack/h5repackgentest.c +++ b/tools/test/h5repack/h5repackgentest.c @@ -32,8 +32,11 @@ #include "H5private.h" #define MAX_NAME_SIZE 256 -#define FILE_INT32LE "h5repack_int32le" +#define FILE_INT32LE_1 "h5repack_int32le_1d" +#define FILE_INT32LE_2 "h5repack_int32le_2d" +#define FILE_INT32LE_3 "h5repack_int32le_3d" #define FILE_UINT8BE "h5repack_uint8be" +#define FILE_F32LE "h5repack_f32le" #define H5REPACKGENTEST_OOPS ret_value = -1; goto done; @@ -45,37 +48,43 @@ if ((space) != H5I_INVALID_HID) { (void)H5Sclose((space)); } \ } +struct external_def { + hsize_t type_size; + unsigned n_elts_per_file; + unsigned n_elts_total; +}; + /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * Helper function to create and write a dataset to file. * Returns 0 on success, -1 on failure. */ static int -make_dataset( - hid_t file, +__make_dataset( + hid_t file_id, const char *dset_name, hid_t mem_type_id, - hid_t space, - hid_t dcpl, + hid_t space_id, + hid_t dcpl_id, void *wdata) { - hid_t dset = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; int ret_value = 0; - dset = H5Dcreate2( - file, - "dset", + dset_id = H5Dcreate2( + file_id, + dset_name, mem_type_id, - space, + space_id, H5P_DEFAULT, - dcpl, + dcpl_id, H5P_DEFAULT); - if (dset == H5I_INVALID_HID) { + if (dset_id == H5I_INVALID_HID) { H5REPACKGENTEST_OOPS; } if (H5Dwrite( - dset, + dset_id, mem_type_id, H5S_ALL, H5S_ALL, @@ -87,102 +96,116 @@ make_dataset( } done: - if (dset != H5I_INVALID_HID) { (void)H5Dclose(dset); } + if (dset_id != H5I_INVALID_HID) { (void)H5Dclose(dset_id); } return ret_value; -} /* end make_dataset() */ +} /* end __make_dataset() */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * Helper function to populate the DCPL external storage list. + * Creates external files for the DCPL, with each file name following the + * convention "_ex-.dat". Will append `n_external_files` to + * the filename list, with each file having space for `n_elts` items of the + * type (of size `elt_size`). The numeric inputs are not sanity-checked. * Returns 0 on success, -1 on failure. */ static int -set_dcpl_external_list( +__set_dcpl_external_list( hid_t dcpl, const char *filename, - hsize_t n_external_files, - hsize_t n_elts, - hsize_t elt_size) + unsigned n_elts_per_file, + unsigned n_elts_total, + hsize_t elt_size) { - hsize_t i = 0; - char name[MAX_NAME_SIZE]; + char name[MAX_NAME_SIZE]; + unsigned n_external_files = 0; + unsigned i = 0; + + if (NULL == filename || '\0' == *filename) { + return -1; + } + + n_external_files = n_elts_total / n_elts_per_file; + if (n_elts_total != (n_external_files * n_elts_per_file)) { + return -1; + } for (i = 0; i < n_external_files; i++) { - snprintf(name, MAX_NAME_SIZE, "%s_ex-%llu.dat", filename, i); - if (H5Pset_external(dcpl, name, 0, n_elts * elt_size) < 0) { + if (snprintf(name, MAX_NAME_SIZE, "%s_ex-%u.dat", filename, i) >= MAX_NAME_SIZE) { + return -1; + } + if (H5Pset_external(dcpl, name, 0, n_elts_per_file * elt_size) < 0) { return -1; } } return 0; -} /* end set_dcpl_external_list() */ +} /* end __set_dcpl_external_list() */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Generalized utility function to write a file with the specified data and + * dataset configuration. If `ext` is provided, will attempt to use external + * storage. + * Returns 0 on success, -1 on failure. */ static int -generate_int32le(hbool_t external) +__make_file( + const char *basename, + struct external_def *ext, + hid_t type_id, + hsize_t rank, + hsize_t *dims, + void *wdata) { char filename[MAX_NAME_SIZE]; - hid_t file = H5I_INVALID_HID; - hid_t dcpl = H5P_DEFAULT; - hid_t space = H5I_INVALID_HID; - hsize_t dims[] = {8, 8, 8}; - int32_t wdata[512]; /* 8^3, from dims */ - int32_t n = 0; - int i = 0; - int j = 0; - int k = 0; + hid_t file_id = H5I_INVALID_HID; + hid_t dcpl_id = H5P_DEFAULT; + hid_t space_id = H5I_INVALID_HID; int ret_value = 0; - /* generate values, alternating positive and negative - */ - for (i=0, n=0; i < 8; i++) { - for (j=0; j < 8; j++) { - for (k=0; k < 8; k++, n++) { - wdata[n] = (k + j*512 + i*4096) * ((n&1) ? (-1) : (1)); - } - } - } - - snprintf(filename, + if (snprintf(filename, MAX_NAME_SIZE, "%s%s.h5", - FILE_INT32LE, - (external) ? "_ex" : ""); + basename, + (NULL != ext) ? "_ex" : "") + >= MAX_NAME_SIZE) + { + H5REPACKGENTEST_OOPS; + } - if (external) { - dcpl = H5Pcreate(H5P_DATASET_CREATE); - if (dcpl == H5I_INVALID_HID) { + if (NULL != ext) { + dcpl_id = H5Pcreate(H5P_DATASET_CREATE); + if (dcpl_id == H5I_INVALID_HID) { H5REPACKGENTEST_OOPS; } - if (set_dcpl_external_list( - dcpl, - FILE_INT32LE, - 1, - 512, - sizeof(int32_t)) + if (__set_dcpl_external_list( + dcpl_id, + basename, + ext->n_elts_per_file, + ext->n_elts_total, + ext->type_size) < 0) { H5REPACKGENTEST_OOPS; } } - space = H5Screate_simple(3, dims, NULL); - if (space == H5I_INVALID_HID) { + space_id = H5Screate_simple(rank, dims, NULL); + if (space_id == H5I_INVALID_HID) { H5REPACKGENTEST_OOPS; } - file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - if (file == H5I_INVALID_HID) { + file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + if (file_id == H5I_INVALID_HID) { H5REPACKGENTEST_OOPS; } - if (make_dataset( - file, + if (__make_dataset( + file_id, "dset", - H5T_STD_I32LE, - space, - dcpl, + type_id, + space_id, + dcpl_id, wdata) < 0) { @@ -190,106 +213,194 @@ generate_int32le(hbool_t external) } done: - H5REPACKGENTEST_COMMON_CLEANUP(dcpl, file, space); + H5REPACKGENTEST_COMMON_CLEANUP(dcpl_id, file_id, space_id); return ret_value; -} /* end generate_int32le() */ +} /* end __make_file() */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Returns 0 on success, -1 on failure. */ static int -generate_uint8be(hbool_t external) +generate_int32le_1d(hbool_t external) { - char filename[MAX_NAME_SIZE]; - hid_t file = H5I_INVALID_HID; - hid_t dcpl = H5P_DEFAULT; - hid_t space = H5I_INVALID_HID; - hsize_t dims[] = {8, 8, 8}; - uint8_t wdata[512]; /* 8^3, from dims */ - uint8_t n = 0; + int32_t wdata[12]; + hsize_t dims[] = {12}; + struct external_def *def_ptr = NULL; + struct external_def def = { (hsize_t)sizeof(int32_t), 6, 12 }; + int32_t n = 0; + int ret_value = 0; + + /* Generate values + */ + for (n = 0; n < 12; n++) { + wdata[n] = n-6; + } + + def_ptr = (TRUE == external) ? (&def) : NULL; + if (__make_file(FILE_INT32LE_1, def_ptr, H5T_STD_I32LE, 1, dims, wdata) < 0) { + ret_value = -1; + } + + return ret_value; +} /* end generate_int32le_1d() */ + + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Returns 0 on success, -1 on failure. + */ +static int +generate_int32le_2d(hbool_t external) +{ + int32_t wdata[64]; + hsize_t dims[] = {8, 8}; + struct external_def *def_ptr = NULL; + struct external_def def = { (hsize_t)sizeof(int32_t), 64, 64 }; + int32_t n = 0; + int ret_value = 0; + + /* Generate values + */ + for (n = 0; n < 64; n++) { + wdata[n] = n-32; + } + + def_ptr = (TRUE == external) ? (&def) : NULL; + if (__make_file(FILE_INT32LE_2, def_ptr, H5T_STD_I32LE, 2, dims, wdata) < 0) { + ret_value = -1; + } + + return ret_value; +} /* end generate_int32le_2d() */ + + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Returns 0 on success, -1 on failure. + */ +static int +generate_int32le_3d(hbool_t external) +{ + hsize_t dims[] = {8, 8, 8}; + int32_t wdata[512]; /* 8^3, from dims */ + struct external_def *def_ptr = NULL; + struct external_def def = { (hsize_t)sizeof(int32_t), 512, 512 }; + int32_t n = 0; int i = 0; int j = 0; int k = 0; int ret_value = 0; - /* Generate values, alternating positive and negative - * The latter half of the dataset is "overflow garbage" (TODO?) + /* generate values, alternating positive and negative */ - for (i=0, n=0; i < 8; i++) { - for (j=0; j < 8; j++) { - for (k=0; k < 8; k++, n++) { - wdata[n] = n * ((n&1) ? (-1) : (1)); + for (i=0, n=0; i < dims[0]; i++) { + for (j=0; j < dims[1]; j++) { + for (k=0; k < dims[2]; k++, n++) { + wdata[n] = (k + j*512 + i*4096) * ((n&1) ? (-1) : (1)); } } } - snprintf(filename, - MAX_NAME_SIZE, - "%s%s.h5", - FILE_UINT8BE, - (external) ? "_ex" : ""); + def_ptr = (TRUE == external) ? (&def) : NULL; + if (__make_file(FILE_INT32LE_3, def_ptr, H5T_STD_I32LE, 3, dims, wdata) < 0) { + ret_value = -1; + } - if (external) { - dcpl = H5Pcreate(H5P_DATASET_CREATE); - if (dcpl == H5I_INVALID_HID) { - H5REPACKGENTEST_OOPS; - } - if (set_dcpl_external_list( - dcpl, - FILE_UINT8BE, - 8, - 64, - sizeof(uint8_t)) - < 0) - { - H5REPACKGENTEST_OOPS; + return ret_value; +} /* end generate_int32le_3d() */ + + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Returns 0 on success, -1 on failure. + */ +static int +generate_uint8be(hbool_t external) +{ + hsize_t dims[] = {4, 8, 8}; + uint8_t wdata[256]; /* 4*8*8, from dims */ + struct external_def *def_ptr = NULL; + struct external_def def = { (hsize_t)sizeof(uint8_t), 64, 256 }; + uint8_t n = 0; + int i = 0; + int j = 0; + int k = 0; + int ret_value = 0; + + /* Generate values, ping-pong from ends of range + */ + for (i=0, n=0; i < dims[0]; i++) { + for (j=0; j < dims[1]; j++) { + for (k=0; k < dims[2]; k++, n++) { + wdata[n] = n * ((n&1) ? (-1) : (1)); + } } } - space = H5Screate_simple(3, dims, NULL); - if (space == H5I_INVALID_HID) { - H5REPACKGENTEST_OOPS; + def_ptr = (TRUE == external) ? (&def) : NULL; + if (__make_file(FILE_UINT8BE, def_ptr, H5T_STD_U8BE, 3, dims, wdata) < 0) { + ret_value = -1; } - file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - if (file == H5I_INVALID_HID) { - H5REPACKGENTEST_OOPS; + return ret_value; +} /* end generate_uint8be() */ + + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Returns 0 on success, -1 on failure. + */ +static int +generate_f32le(hbool_t external) +{ + hsize_t dims[] = {12, 6}; + float wdata[72]; /* 12*6, from dims */ + struct external_def *def_ptr = NULL; + struct external_def def = { + (hsize_t)sizeof(float), + 72, + 72 + }; + float n = 0; + int i = 0; + int j = 0; + int k = 0; + int ret_value = 0; + + /* Generate values */ + for (i=0, k=0, n=0; i < dims[0]; i++) { + for (j=0; j < dims[1]; j++, k++, n++) { + wdata[k] = n * 801.1 * ((k % 5 == 1) ? (-1) : (1)); + } } - if (make_dataset( - file, - "dset", - H5T_STD_U8BE, - space, - dcpl, - wdata) - < 0) - { - H5REPACKGENTEST_OOPS; + def_ptr = (TRUE == external) ? (&def) : NULL; + if (__make_file(FILE_F32LE, def_ptr, H5T_IEEE_F32LE, 2, dims, wdata) < 0) { + ret_value = -1; } -done: - H5REPACKGENTEST_COMMON_CLEANUP(dcpl, file, space); return ret_value; -} /* end generate_uint8be() */ +} /* end generate_f32le() */ /* ---------------------------------------------------------------------------- + * Create files. + * Return 0 on success, nonzero on failure. */ int main(void) { - int i = 0; /* loop variable */ + int i = 0; int ret_value = 0; for (i=0; i < 2; i++) { hbool_t external = (i&1) ? TRUE : FALSE; - if (ret_value == 0) { ret_value -= generate_int32le(external); } + if (ret_value == 0) { ret_value -= generate_int32le_1d(external); } + if (ret_value == 0) { ret_value -= generate_int32le_2d(external); } + if (ret_value == 0) { ret_value -= generate_int32le_3d(external); } if (ret_value == 0) { ret_value -= generate_uint8be(external); } + if (ret_value == 0) { ret_value -= generate_f32le(external); } } /* end for external data storage or not */ if (ret_value != 0) { - /* TODO: print warning message? */ + HDprintf("A problem occurred!\n"); } return ret_value; diff --git a/tools/test/h5repack/testfiles/h5repack_f32le.h5 b/tools/test/h5repack/testfiles/h5repack_f32le.h5 new file mode 100644 index 0000000..03a9b57 Binary files /dev/null and b/tools/test/h5repack/testfiles/h5repack_f32le.h5 differ diff --git a/tools/test/h5repack/testfiles/h5repack_f32le_ex-0.dat b/tools/test/h5repack/testfiles/h5repack_f32le_ex-0.dat new file mode 100644 index 0000000..8378fc2 Binary files /dev/null and b/tools/test/h5repack/testfiles/h5repack_f32le_ex-0.dat differ diff --git a/tools/test/h5repack/testfiles/h5repack_f32le_ex.h5 b/tools/test/h5repack/testfiles/h5repack_f32le_ex.h5 new file mode 100644 index 0000000..ca6c49d Binary files /dev/null and b/tools/test/h5repack/testfiles/h5repack_f32le_ex.h5 differ diff --git a/tools/test/h5repack/testfiles/h5repack_int32le.h5 b/tools/test/h5repack/testfiles/h5repack_int32le.h5 deleted file mode 100644 index 4e9500f..0000000 Binary files a/tools/test/h5repack/testfiles/h5repack_int32le.h5 and /dev/null differ diff --git a/tools/test/h5repack/testfiles/h5repack_int32le_1d.h5 b/tools/test/h5repack/testfiles/h5repack_int32le_1d.h5 new file mode 100644 index 0000000..7d60566 Binary files /dev/null and b/tools/test/h5repack/testfiles/h5repack_int32le_1d.h5 differ diff --git a/tools/test/h5repack/testfiles/h5repack_int32le_1d_ex-0.dat b/tools/test/h5repack/testfiles/h5repack_int32le_1d_ex-0.dat new file mode 100644 index 0000000..f75ada5 --- /dev/null +++ b/tools/test/h5repack/testfiles/h5repack_int32le_1d_ex-0.dat @@ -0,0 +1 @@ +úÿÿÿûÿÿÿüÿÿÿýÿÿÿþÿÿÿÿÿÿÿ \ No newline at end of file diff --git a/tools/test/h5repack/testfiles/h5repack_int32le_1d_ex-1.dat b/tools/test/h5repack/testfiles/h5repack_int32le_1d_ex-1.dat new file mode 100644 index 0000000..1f8f3b6 Binary files /dev/null and b/tools/test/h5repack/testfiles/h5repack_int32le_1d_ex-1.dat differ diff --git a/tools/test/h5repack/testfiles/h5repack_int32le_1d_ex.h5 b/tools/test/h5repack/testfiles/h5repack_int32le_1d_ex.h5 new file mode 100644 index 0000000..ba4b534 Binary files /dev/null and b/tools/test/h5repack/testfiles/h5repack_int32le_1d_ex.h5 differ diff --git a/tools/test/h5repack/testfiles/h5repack_int32le_2d.h5 b/tools/test/h5repack/testfiles/h5repack_int32le_2d.h5 new file mode 100644 index 0000000..2f32bd1 Binary files /dev/null and b/tools/test/h5repack/testfiles/h5repack_int32le_2d.h5 differ diff --git a/tools/test/h5repack/testfiles/h5repack_int32le_2d_ex-0.dat b/tools/test/h5repack/testfiles/h5repack_int32le_2d_ex-0.dat new file mode 100644 index 0000000..c6bfc64 Binary files /dev/null and b/tools/test/h5repack/testfiles/h5repack_int32le_2d_ex-0.dat differ diff --git a/tools/test/h5repack/testfiles/h5repack_int32le_2d_ex.h5 b/tools/test/h5repack/testfiles/h5repack_int32le_2d_ex.h5 new file mode 100644 index 0000000..f6cce59 Binary files /dev/null and b/tools/test/h5repack/testfiles/h5repack_int32le_2d_ex.h5 differ diff --git a/tools/test/h5repack/testfiles/h5repack_int32le_3d.h5 b/tools/test/h5repack/testfiles/h5repack_int32le_3d.h5 new file mode 100644 index 0000000..7a61ef5 Binary files /dev/null and b/tools/test/h5repack/testfiles/h5repack_int32le_3d.h5 differ diff --git a/tools/test/h5repack/testfiles/h5repack_int32le_3d_ex-0.dat b/tools/test/h5repack/testfiles/h5repack_int32le_3d_ex-0.dat new file mode 100644 index 0000000..b505eb4 Binary files /dev/null and b/tools/test/h5repack/testfiles/h5repack_int32le_3d_ex-0.dat differ diff --git a/tools/test/h5repack/testfiles/h5repack_int32le_3d_ex.h5 b/tools/test/h5repack/testfiles/h5repack_int32le_3d_ex.h5 new file mode 100644 index 0000000..7c4b750 Binary files /dev/null and b/tools/test/h5repack/testfiles/h5repack_int32le_3d_ex.h5 differ diff --git a/tools/test/h5repack/testfiles/h5repack_int32le_ex-0.dat b/tools/test/h5repack/testfiles/h5repack_int32le_ex-0.dat deleted file mode 100644 index b505eb4..0000000 Binary files a/tools/test/h5repack/testfiles/h5repack_int32le_ex-0.dat and /dev/null differ diff --git a/tools/test/h5repack/testfiles/h5repack_int32le_ex.h5 b/tools/test/h5repack/testfiles/h5repack_int32le_ex.h5 deleted file mode 100644 index 8c8b644..0000000 Binary files a/tools/test/h5repack/testfiles/h5repack_int32le_ex.h5 and /dev/null differ diff --git a/tools/test/h5repack/testfiles/h5repack_uint8be.h5 b/tools/test/h5repack/testfiles/h5repack_uint8be.h5 index f89bc03..0e25211 100644 Binary files a/tools/test/h5repack/testfiles/h5repack_uint8be.h5 and b/tools/test/h5repack/testfiles/h5repack_uint8be.h5 differ diff --git a/tools/test/h5repack/testfiles/h5repack_uint8be_ex-4.dat b/tools/test/h5repack/testfiles/h5repack_uint8be_ex-4.dat deleted file mode 100644 index b5c4e7c..0000000 Binary files a/tools/test/h5repack/testfiles/h5repack_uint8be_ex-4.dat and /dev/null differ diff --git a/tools/test/h5repack/testfiles/h5repack_uint8be_ex-5.dat b/tools/test/h5repack/testfiles/h5repack_uint8be_ex-5.dat deleted file mode 100644 index b77f32c..0000000 Binary files a/tools/test/h5repack/testfiles/h5repack_uint8be_ex-5.dat and /dev/null differ diff --git a/tools/test/h5repack/testfiles/h5repack_uint8be_ex-6.dat b/tools/test/h5repack/testfiles/h5repack_uint8be_ex-6.dat deleted file mode 100644 index 1e335eb..0000000 Binary files a/tools/test/h5repack/testfiles/h5repack_uint8be_ex-6.dat and /dev/null differ diff --git a/tools/test/h5repack/testfiles/h5repack_uint8be_ex-7.dat b/tools/test/h5repack/testfiles/h5repack_uint8be_ex-7.dat deleted file mode 100644 index 3dadb7d..0000000 Binary files a/tools/test/h5repack/testfiles/h5repack_uint8be_ex-7.dat and /dev/null differ diff --git a/tools/test/h5repack/testfiles/h5repack_uint8be_ex.h5 b/tools/test/h5repack/testfiles/h5repack_uint8be_ex.h5 index 6f8c3fe..8787188 100644 Binary files a/tools/test/h5repack/testfiles/h5repack_uint8be_ex.h5 and b/tools/test/h5repack/testfiles/h5repack_uint8be_ex.h5 differ -- cgit v0.12 From 1070468dac5d0fd5e02b69514d7a0dfacfd28606 Mon Sep 17 00:00:00 2001 From: Jacob Smith Date: Mon, 23 Sep 2019 16:25:25 -0500 Subject: Change print calls to HD-wrapped. Minor formatting tweaks (inc. regressions and in-file style-matching). --- test/external.c | 5 ++- tools/src/h5repack/h5repack.c | 63 ++++++++++++++++++------------------ tools/src/h5repack/h5repack_copy.c | 66 +++++++++++++++++++++----------------- 3 files changed, 70 insertions(+), 64 deletions(-) diff --git a/test/external.c b/test/external.c index 56cc816..50d94ab 100644 --- a/test/external.c +++ b/test/external.c @@ -457,8 +457,7 @@ test_multiple_files(hid_t file) TESTING("multiple external files"); - dcpl = H5Pcreate(H5P_DATASET_CREATE); - if(dcpl < 0) + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR max_ext_size = (hsize_t)(sizeof(int) * max_size[0] / n_external_files); @@ -596,7 +595,7 @@ test_overflow(void) TESTING("address overflow in external files"); - if((dcpl = H5Pcreate (H5P_DATASET_CREATE)) < 0) + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR if(H5Pset_external(dcpl, "ext1.data", (off_t)0, H5F_UNLIMITED-1) < 0) FAIL_STACK_ERROR diff --git a/tools/src/h5repack/h5repack.c b/tools/src/h5repack/h5repack.c index d49a16b..f12c3b4 100644 --- a/tools/src/h5repack/h5repack.c +++ b/tools/src/h5repack/h5repack.c @@ -382,7 +382,8 @@ copy_attr( */ for (u = 0; u < (unsigned) oinfo.num_attrs; u++) { /* open attribute */ - if((attr_id = H5Aopen_by_idx(loc_in, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t) u, H5P_DEFAULT, H5P_DEFAULT)) < 0) + attr_id = H5Aopen_by_idx(loc_in, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t) u, H5P_DEFAULT, H5P_DEFAULT); + if (attr_id < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aopen_by_idx failed"); if (H5Aget_name(attr_id, (size_t) 255, name) < 0) @@ -504,7 +505,7 @@ copy_attr( } /*H5T_REFERENCE*/ if (options->verbose) - printf(FORMAT_OBJ_ATTR, "attr", name); + HDprintf(FORMAT_OBJ_ATTR, "attr", name); /*--------------------------------------------------------------------- * close @@ -567,7 +568,7 @@ check_options(pack_opt_t *options) */ if (options->verbose && have_request(options)) { if (options->all_layout == 1) { - printf("All objects to modify layout are...\n"); + HDprintf("All objects to modify layout are...\n"); switch (options->layout_g) { case H5D_COMPACT: strcpy(slayout, "compact"); @@ -588,17 +589,17 @@ check_options(pack_opt_t *options) strcpy(slayout, "invalid layout\n"); HGOTO_DONE(FAIL); } - printf(" Apply %s layout to all", slayout); + HDprintf(" Apply %s layout to all", slayout); if (H5D_CHUNKED == options->layout_g) { - printf("with dimension [ "); + HDprintf("with dimension [ "); for (j = 0; j < options->chunk_g.rank; j++) - printf("%d ", (int) options->chunk_g.chunk_lengths[j]); - printf("]"); + HDprintf("%d ", (int) options->chunk_g.chunk_lengths[j]); + HDprintf("]"); } - printf("\n"); + HDprintf("\n"); } else - printf("No all objects to modify layout\n"); + HDprintf("No all objects to modify layout\n"); } /* end if verbose */ for (i = 0; i < options->op_tbl->nelems; i++) { @@ -606,16 +607,16 @@ check_options(pack_opt_t *options) if (options->op_tbl->objs[i].chunk.rank > 0) { if (options->verbose) { - printf(" <%s> with chunk size ", name); + HDprintf(" <%s> with chunk size ", name); for (k = 0; k < options->op_tbl->objs[i].chunk.rank; k++) - printf("%d ", (int)options->op_tbl->objs[i].chunk.chunk_lengths[k]); - printf("\n"); + HDprintf("%d ", (int)options->op_tbl->objs[i].chunk.chunk_lengths[k]); + HDprintf("\n"); } has_ck = 1; } else if (options->op_tbl->objs[i].chunk.rank == -2) { /* TODO: replace 'magic number' */ if (options->verbose) - printf(" <%s> %s\n", name, "NONE (contiguous)"); + HDprintf(" <%s> %s\n", name, "NONE (contiguous)"); has_ck = 1; } } /* end for each object in options */ @@ -631,35 +632,35 @@ check_options(pack_opt_t *options) if (options->verbose && have_request(options)) { if (options->all_filter == 1) { - printf("All objects to apply filter are...\n"); + HDprintf("All objects to apply filter are...\n"); for (k = 0; k < options->n_filter_g; k++) { H5Z_filter_t filtn = options->filter_g[k].filtn; if (filtn < 0) { - printf(" Unknown\n"); + HDprintf(" Unknown\n"); continue; } switch (filtn) { case H5Z_FILTER_NONE: - printf(" Uncompress all\n"); + HDprintf(" Uncompress all\n"); break; case H5Z_FILTER_SHUFFLE: case H5Z_FILTER_FLETCHER32: - printf(" All with %s\n", get_sfilter(filtn)); + HDprintf(" All with %s\n", get_sfilter(filtn)); break; case H5Z_FILTER_SZIP: case H5Z_FILTER_DEFLATE: - printf(" All with %s, parameter %d\n", + HDprintf(" All with %s, parameter %d\n", get_sfilter(filtn), options->filter_g[k].cd_values[0]); break; default: - printf(" User Defined %d\n", filtn); + HDprintf(" User Defined %d\n", filtn); break; } /* end switch */ } /* end for each filter */ } /* end if options->all_filter == 1 (TODO: meaning) */ else - printf("No all objects to apply filter\n"); + HDprintf("No all objects to apply filter\n"); } /* end if verbose */ for (i = 0; i < options->op_tbl->nelems; i++) { @@ -669,15 +670,16 @@ check_options(pack_opt_t *options) for (j = 0; j < pack.nfilters; j++) { if (options->verbose) { if (pack.filter[j].filtn >= 0) { - if (pack.filter[j].filtn > H5Z_FILTER_SCALEOFFSET) - printf(" <%s> with %s filter %d\n", - name, + if (pack.filter[j].filtn > H5Z_FILTER_SCALEOFFSET) { + HDprintf(" <%s> with %s filter %d\n", name, get_sfilter(pack.filter[j].filtn), pack.filter[j].filtn); - else - printf(" <%s> with %s filter\n", + } + else { + HDprintf(" <%s> with %s filter\n", name, get_sfilter(pack.filter[j].filtn)); + } } } has_cp = 1; @@ -714,7 +716,7 @@ check_options(pack_opt_t *options) */ if (options->ublock_filename != NULL && options->ublock_size == 0) { if (options->verbose) { - printf("Warning: user block size missing for file %s. Assigning a default size of 1024...\n", options->ublock_filename); + HDprintf("Warning: user block size missing for file %s. Assigning a default size of 1024...\n", options->ublock_filename); options->ublock_size = 1024; } } @@ -787,15 +789,14 @@ check_objects(const char* fname, pack_opt_t *options) */ if (options->verbose) - printf("Opening file. Searching %zu objects to modify ...\n", - travt->nobjs); + HDprintf("Opening file. Searching %zu objects to modify ...\n", travt->nobjs); for (i = 0; i < options->op_tbl->nelems; i++) { pack_info_t obj = options->op_tbl->objs[i]; char* name = obj.path; if (options->verbose) - printf(" <%s>", name); + HDprintf(" <%s>", name); /* the input object names are present in the file and are valid */ if (h5trav_getindext(name, travt) < 0) @@ -803,7 +804,7 @@ check_objects(const char* fname, pack_opt_t *options) "%s Could not find <%s> in file <%s>. Exiting...\n", (options->verbose ? "\n" : ""), name, fname); if (options->verbose) - printf("...Found\n"); + HDprintf("...Found\n"); for (ifil = 0; ifil < obj.nfilters; ifil++) { if (obj.filter[ifil].filtn < 0) @@ -849,7 +850,7 @@ check_objects(const char* fname, pack_opt_t *options) } /* end else (chunk rank is 0) */ if (csize < ppb) { - printf(" \n"); + HDprintf(" \n"); HGOTO_DONE(0); } } /* end case SZIP */ diff --git a/tools/src/h5repack/h5repack_copy.c b/tools/src/h5repack/h5repack_copy.c index 5939df4..07defa5 100644 --- a/tools/src/h5repack/h5repack_copy.c +++ b/tools/src/h5repack/h5repack_copy.c @@ -296,7 +296,7 @@ print_user_block(fnamein, fidin); *------------------------------------------------------------------------- */ if (options->verbose) - printf("Making new file ...\n"); + HDprintf("Making new file ...\n"); if ((fidout = H5Fcreate(fnameout, H5F_ACC_TRUNC, fcpl, fapl)) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fcreate could not create file <%s>:", fnameout); @@ -625,9 +625,9 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, */ if (options->verbose) { - printf("-----------------------------------------\n"); - printf(" Type Filter (Compression) Name\n"); - printf("-----------------------------------------\n"); + HDprintf("-----------------------------------------\n"); + HDprintf(" Type Filter (Compression) Name\n"); + HDprintf("-----------------------------------------\n"); } if (travt->objs) { @@ -646,7 +646,7 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, */ case H5TRAV_TYPE_GROUP: if (options->verbose) - printf(FORMAT_OBJ, "group", travt->objs[i].name); + HDprintf(FORMAT_OBJ, "group", travt->objs[i].name); /* open input group */ if ((grp_in = H5Gopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) @@ -782,17 +782,6 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_type failed"); if ((dcpl_in = H5Dget_create_plist(dset_in)) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist failed"); - /* If the input dataset has external storage, it must be contiguous. - * Accordingly, there would be no filter or chunk properties to preserve. - */ - if (H5Pget_external_count(dcpl_in)) { - if ((dcpl_out = H5Pcreate(H5P_DATASET_CREATE)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcreate failed"); - } - else { - if ((dcpl_out = H5Pcopy(dcpl_in)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcopy failed"); - } if ((rank = H5Sget_simple_extent_ndims(f_space_id)) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed"); HDmemset(dims, 0, sizeof dims); @@ -801,6 +790,20 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, if (H5Dget_space_status(dset_in, &space_status) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space_status failed"); + /* If the input dataset has external storage, it must be contiguous. + * Accordingly, there would be no filter or chunk properties to preserve, + * so create a new DCPL. + * Otherwise, copy dcpl_in. + */ + if (H5Pget_external_count(dcpl_in)) { + if ((dcpl_out = H5Pcreate(H5P_DATASET_CREATE)) < 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcreate failed"); + } + else + if ((dcpl_out = H5Pcopy(dcpl_in)) < 0) { + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcopy failed"); + } + nelmts = 1; for (j = 0; j < rank; j++) nelmts *= dims[j]; @@ -844,12 +847,14 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, * changing to COMPACT. For the reference, COMPACT is limited * by size 64K by library. */ - if (options->layout_g != H5D_COMPACT) - if (size_dset < options->min_comp) + if (options->layout_g != H5D_COMPACT) { + if (size_dset < options->min_comp) { apply_s = 0; + } + } /* apply the filter */ - if (apply_s) + if (apply_s) { if (apply_filters( travt->objs[i].name, rank, @@ -860,6 +865,7 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, &has_filter) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "apply_filters failed"); + } /* only if layout change requested for entire file or * individual obj */ @@ -916,7 +922,7 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, H5E_tools_min_id_g, "H5Dcreate2 failed"); if (options->verbose) - printf(" warning: could not create dataset <%s>. Applying original settings\n", + HDprintf(" warning: could not create dataset <%s>. Applying original settings\n", travt->objs[i].name); dset_out = H5Dcreate2(fidout, travt->objs[i].name, @@ -1122,12 +1128,12 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, * (in case there was a filter) */ if (has_filter && apply_s == 0) - printf(" \n", + HDprintf(" \n", travt->objs[i].name, (int) options->min_comp); if (has_filter && apply_f == 0) - printf(" \n", travt->objs[i].name); + HDprintf(" \n", travt->objs[i].name); } /* end if verbose (print compression) */ /*------------------------------------------------------------------------- @@ -1201,7 +1207,7 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed"); if (options->verbose) - printf(FORMAT_OBJ, "dset", travt->objs[i].name); + HDprintf(FORMAT_OBJ, "dset", travt->objs[i].name); } /* end whether we have request for filter/chunking */ break; @@ -1212,7 +1218,7 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, */ case H5TRAV_TYPE_NAMED_DATATYPE: if (options->verbose) - printf(FORMAT_OBJ, "type", travt->objs[i].name); + HDprintf(FORMAT_OBJ, "type", travt->objs[i].name); if ((type_in = H5Topen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Topen2 failed"); @@ -1251,13 +1257,13 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, case H5TRAV_TYPE_LINK: case H5TRAV_TYPE_UDLINK: if (options->verbose) - printf(FORMAT_OBJ, "link", travt->objs[i].name); + HDprintf(FORMAT_OBJ, "link", travt->objs[i].name); if (H5Lcopy(fidin, travt->objs[i].name, fidout, travt->objs[i].name, H5P_DEFAULT, H5P_DEFAULT) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Lcopy failed"); if (options->verbose) - printf(FORMAT_OBJ, "link", travt->objs[i].name); + HDprintf(FORMAT_OBJ, "link", travt->objs[i].name); break; default: @@ -1400,7 +1406,7 @@ print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int pr) } /* end for each filter */ if (!pr) - printf(FORMAT_OBJ, "dset", objname); + HDprintf(FORMAT_OBJ, "dset", objname); else { char str[512], temp[512]; @@ -1408,7 +1414,7 @@ print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int pr) HDstrcat(str, strfilter); sprintf(temp, " (%.3f:1)", ratio); HDstrcat(str, temp); - printf(FORMAT_OBJ, str, objname); + HDprintf(FORMAT_OBJ, str, objname); } } /* end print_dataset_info() */ @@ -1535,10 +1541,10 @@ print_user_block(const char *filename, hid_t fid) for (i = 0; i < nread; i++) { - printf("%c ", rbuf[i]); + HDprintf("%c ", rbuf[i]); } - printf("\n"); + HDprintf("\n"); if (nread < 0) { HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "nread < 0"); -- cgit v0.12 From 1f7d556ccd7fd0421352dd91c7c934c206dcdc6d Mon Sep 17 00:00:00 2001 From: Jacob Smith Date: Tue, 24 Sep 2019 15:22:38 -0500 Subject: Revert else-if to single line. --- tools/src/h5repack/h5repack_main.c | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/tools/src/h5repack/h5repack_main.c b/tools/src/h5repack/h5repack_main.c index c94a0bd..8c887a2 100644 --- a/tools/src/h5repack/h5repack_main.c +++ b/tools/src/h5repack/h5repack_main.c @@ -373,8 +373,7 @@ set_sort_by(const char *form) if (!HDstrcmp(form, "name")) idx_type = H5_INDEX_NAME; - else - if (!HDstrcmp(form, "creation_order")) + else if (!HDstrcmp(form, "creation_order")) idx_type = H5_INDEX_CRT_ORDER; return idx_type; @@ -397,8 +396,7 @@ set_sort_order(const char *form) if (!HDstrcmp(form, "ascending")) iter_order = H5_ITER_INC; - else - if (!HDstrcmp(form, "descending")) + else if (!HDstrcmp(form, "descending")) iter_order = H5_ITER_DEC; return iter_order; @@ -539,17 +537,13 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) ssize = HDatoi( opt_arg ); if (!HDstrncmp(msgType, "dspace", 6)) options->msg_size[0] = ssize; - else - if (!HDstrncmp(msgType, "dtype", 5)) + else if (!HDstrncmp(msgType, "dtype", 5)) options->msg_size[1] = ssize; - else - if (!HDstrncmp(msgType, "fill", 4)) + else if (!HDstrncmp(msgType, "fill", 4)) options->msg_size[2] = ssize; - else - if (!HDstrncmp(msgType, "pline", 5)) + else if (!HDstrncmp(msgType, "pline", 5)) options->msg_size[3] = ssize; - else - if (!HDstrncmp(msgType, "attr", 4)) + else if (!HDstrncmp(msgType, "attr", 4)) options->msg_size[4] = ssize; } } @@ -588,14 +582,11 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) HDstrcpy(strategy, opt_arg); if (!HDstrcmp(strategy, "FSM_AGGR")) options->fs_strategy = H5F_FSPACE_STRATEGY_FSM_AGGR; - else - if (!HDstrcmp(strategy, "PAGE")) + else if (!HDstrcmp(strategy, "PAGE")) options->fs_strategy = H5F_FSPACE_STRATEGY_PAGE; - else - if (!HDstrcmp(strategy, "AGGR")) + else if (!HDstrcmp(strategy, "AGGR")) options->fs_strategy = H5F_FSPACE_STRATEGY_AGGR; - else - if (!HDstrcmp(strategy, "NONE")) + else if (!HDstrcmp(strategy, "NONE")) options->fs_strategy = H5F_FSPACE_STRATEGY_NONE; else { error_msg("invalid file space management strategy\n", opt_arg); @@ -640,7 +631,7 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) break; case 'z': - if (H5_ITER_UNKNOWN == set_sort_order(opt_arg)) { + if (set_sort_order(opt_arg) == H5_ITER_UNKNOWN) { error_msg(" failed to set sort order form <%s>\n", opt_arg); h5tools_setstatus(EXIT_FAILURE); ret_value = -1; @@ -662,7 +653,7 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) if (argv[opt_ind] != NULL && argv[opt_ind + 1] != NULL) { infile = argv[opt_ind]; outfile = argv[opt_ind + 1]; - + if (!HDstrcmp(infile, outfile)) { error_msg("file names cannot be the same\n"); usage(h5tools_getprogname()); @@ -677,8 +668,7 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) ret_value = -1; } } - else - if (has_i != 1 || has_o != 1) { + else if (has_i != 1 || has_o != 1) { error_msg("filenames must be either both -i -o or both positional\n"); usage(h5tools_getprogname()); h5tools_setstatus(EXIT_FAILURE); -- cgit v0.12 From 4ecc50bc136e71329593bef9fc675b6044bcff86 Mon Sep 17 00:00:00 2001 From: Jacob Smith Date: Tue, 24 Sep 2019 15:29:56 -0500 Subject: Update to current external file population. --- tools/test/h5repack/CMakeTests.cmake | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/tools/test/h5repack/CMakeTests.cmake b/tools/test/h5repack/CMakeTests.cmake index eae1a7f..072dad2 100644 --- a/tools/test/h5repack/CMakeTests.cmake +++ b/tools/test/h5repack/CMakeTests.cmake @@ -26,13 +26,23 @@ ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_deflate.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_early.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_ext.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_f32le.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_f32le_ex-0.dat + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_f32le_ex.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_fill.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_filters.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_fletcher.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_hlink.h5 - ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_int32le.h5 - ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_int32le_ex.h5 - ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_int32le_ex-0.dat + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_int32le_1d.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_int32le_1d_ex-0.dat + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_int32le_1d_ex-1.dat + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_int32le_1d_ex.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_int32le_2d.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_int32le_2d_ex-0.dat + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_int32le_2d_ex.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_int32le_3d.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_int32le_3d_ex-0.dat + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_int32le_3d_ex.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_layout.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_layouto.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_layout2.h5 @@ -47,6 +57,12 @@ ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_shuffle.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_soffset.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_szip.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_uint8be.h5 + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_uint8be_ex-0.dat + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_uint8be_ex-1.dat + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_uint8be_ex-2.dat + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_uint8be_ex-3.dat + ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_uint8be_ex.h5 # fsm ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_aggr.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_fsm_aggr_nopersist.h5 @@ -54,16 +70,6 @@ ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_none.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_paged_nopersist.h5 ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_paged_persist.h5 - ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_uint8be.h5 - ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_uint8be_ex.h5 - ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_uint8be_ex-0.dat - ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_uint8be_ex-1.dat - ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_uint8be_ex-2.dat - ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_uint8be_ex-3.dat - ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_uint8be_ex-4.dat - ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_uint8be_ex-5.dat - ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_uint8be_ex-6.dat - ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testfiles/h5repack_uint8be_ex-7.dat # h5diff/testfile ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_attr1.h5 # tools/testfiles -- cgit v0.12