summaryrefslogtreecommitdiffstats
path: root/tools/test
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2018-09-19 05:57:37 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2018-09-19 05:57:37 (GMT)
commiteb78fd88325d58a95c026129f1e2b4c7c50f621a (patch)
treed2c9378cce2afd54945d07127fb7a25302421c3e /tools/test
parent680cf4d946fd10d50e0f7acdc5bc93f91037fb4f (diff)
downloadhdf5-eb78fd88325d58a95c026129f1e2b4c7c50f621a.zip
hdf5-eb78fd88325d58a95c026129f1e2b4c7c50f621a.tar.gz
hdf5-eb78fd88325d58a95c026129f1e2b4c7c50f621a.tar.bz2
Develop normalization with vol_integration.
Mostly peripheral things like the tools and wrappers, with just enough core library code to support that.
Diffstat (limited to 'tools/test')
-rw-r--r--tools/test/h5diff/h5diffgentest.c164
-rw-r--r--tools/test/h5jam/tellub.c182
-rw-r--r--tools/test/h5repack/h5repack.sh.in1
-rw-r--r--tools/test/h5stat/testh5stat.sh.in1
4 files changed, 154 insertions, 194 deletions
diff --git a/tools/test/h5diff/h5diffgentest.c b/tools/test/h5diff/h5diffgentest.c
index 7321c66..4f92cae 100644
--- a/tools/test/h5diff/h5diffgentest.c
+++ b/tools/test/h5diff/h5diffgentest.c
@@ -11,8 +11,6 @@
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#include <stdio.h>
-#include <stdlib.h>
#include "hdf5.h"
#include "H5private.h"
@@ -110,6 +108,10 @@ size_t H5TOOLS_MALLOCSIZE = (128 * 1024 * 1024);
#define SPACE1_DIM1 0
#define SPACE1_DIM2 0
+/* Error macros */
+#define AT() HDprintf("ERROR at %s:%d in %s()...\n", __FILE__, __LINE__, FUNC);
+#define PROGRAM_ERROR {AT(); goto error;}
+
/* A UD link traversal function. Shouldn't actually be called. */
static hid_t
UD_traverse(H5_ATTR_UNUSED const char * link_name, H5_ATTR_UNUSED hid_t cur_group,
@@ -178,7 +180,7 @@ static void write_dset_in(hid_t loc_id, const char* dset_name, hid_t fid, int ma
static void gen_datareg(hid_t fid, int make_diffs);
/* utilities */
static int write_attr(hid_t loc_id, int rank, hsize_t *dims, const char *name, hid_t tid, void *buf);
-static int write_dset(hid_t loc_id, int rank, hsize_t *dims, const char *name, hid_t tid, void *buf);
+static herr_t write_dset(hid_t loc_id, int rank, hsize_t *dims, const char *name, hid_t tid, void *buf);
static int gen_dataset_idx(const char *file, int format);
/*-------------------------------------------------------------------------
@@ -286,7 +288,7 @@ int main(void)
/* string dataset and attribute. HDFFV-10028 */
test_objs_strings(DIFF_STRINGS1, DIFF_STRINGS2);
- return 0;
+ return EXIT_SUCCESS;
}
/*-------------------------------------------------------------------------
@@ -4908,9 +4910,9 @@ out:
* types.
* h5diff should show non-comparable output from these common objects.
*-------------------------------------------------------------------------*/
-static void test_objs_nocomparables(const char *fname1, const char *fname2)
+static void
+test_objs_nocomparables(const char *fname1, const char *fname2)
{
- herr_t status = SUCCEED;
hid_t fid1 = -1;
hid_t fid2 = -1;
hid_t topgid1 = -1;
@@ -4927,110 +4929,90 @@ static void test_objs_nocomparables(const char *fname1, const char *fname2)
* Open file(s) to add objects
*------------------------------------------------------------------------*/
/* file1 */
- fid1 = H5Fopen(fname1, H5F_ACC_RDWR, H5P_DEFAULT);
- if (fid1 < 0) {
- fprintf(stderr, "Error: %s> H5Fopen failed.\n", fname1);
- status = FAIL;
- goto out;
- }
+ if((fid1 = H5Fopen(fname1, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
+ PROGRAM_ERROR
/* file2 */
- fid2 = H5Fopen(fname2, H5F_ACC_RDWR, H5P_DEFAULT);
- if (fid2 < 0) {
- fprintf(stderr, "Error: %s> H5Fopen failed.\n", fname2);
- status = FAIL;
- goto out;
- }
+ if((fid2 = H5Fopen(fname2, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
+ PROGRAM_ERROR
/*-----------------------------------------------------------------------
* in file1 : add member objects
*------------------------------------------------------------------------*/
/* parent group */
- topgid1 = H5Gcreate2(fid1, "diffobjtypes", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- if (topgid1 < 0) {
- fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1);
- status = FAIL;
- goto out;
- }
+ if((topgid1 = H5Gcreate2(fid1, "diffobjtypes", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ PROGRAM_ERROR
/* dataset */
- status = write_dset(topgid1, 1, dims, "obj1", H5T_NATIVE_INT, data1);
- if (status == FAIL) {
- fprintf(stderr, "Error: %s> write_dset failed\n", fname1);
- goto out;
- }
+ if(write_dset(topgid1, 1, dims, "obj1", H5T_NATIVE_INT, data1) < 0)
+ PROGRAM_ERROR
/* group */
- gid1 = H5Gcreate2(topgid1, "obj2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- if (gid1 < 0) {
- fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname1);
- status = FAIL;
- goto out;
- }
+ if((gid1 = H5Gcreate2(topgid1, "obj2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ PROGRAM_ERROR
/* committed type */
- tid1 = H5Tcopy(H5T_NATIVE_INT);
- status = H5Tcommit2(topgid1, "obj3", tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- if (status < 0) {
- fprintf(stderr, "Error: %s> H5Tcommit2 failed.\n", fname1);
- goto out;
- }
+ if((tid1 = H5Tcopy(H5T_NATIVE_INT)) < 0)
+ PROGRAM_ERROR
+ if(H5Tcommit2(topgid1, "obj3", tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0)
+ PROGRAM_ERROR
/*-----------------------------------------------------------------------
* in file2 : add member objects
*------------------------------------------------------------------------*/
/* parent group */
- topgid2 = H5Gcreate2(fid2, "diffobjtypes", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- if (topgid2 < 0) {
- fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2);
- status = FAIL;
- goto out;
- }
+ if((topgid2 = H5Gcreate2(fid2, "diffobjtypes", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ PROGRAM_ERROR
/* group */
- gid2 = H5Gcreate2(topgid2, "obj1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- if (gid2 < 0) {
- fprintf(stderr, "Error: %s> H5Gcreate2 failed.\n", fname2);
- status = FAIL;
- goto out;
- }
+ if((gid2 = H5Gcreate2(topgid2, "obj1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ PROGRAM_ERROR
/* committed type */
- tid2 = H5Tcopy(H5T_NATIVE_INT);
- status = H5Tcommit2(topgid2, "obj2", tid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- if (status < 0) {
- fprintf(stderr, "Error: %s> H5Tcommit2 failed.\n", fname2);
- goto out;
- }
+ if((tid2 = H5Tcopy(H5T_NATIVE_INT)) < 0)
+ PROGRAM_ERROR
+ if(H5Tcommit2(topgid2, "obj2", tid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0)
+ PROGRAM_ERROR
/* dataset */
- status = write_dset(topgid2, 1, dims, "obj3", H5T_NATIVE_INT, data2);
- if (status == FAIL) {
- fprintf(stderr, "Error: %s> write_dset failed\n", fname2);
- goto out;
- }
+ if(write_dset(topgid2, 1, dims, "obj3", H5T_NATIVE_INT, data2) < 0)
+ PROGRAM_ERROR
-out:
/*-----------------------------------------------------------------------
* Close IDs
*-----------------------------------------------------------------------*/
- if (fid1)
+ if(H5Fclose(fid1) < 0)
+ PROGRAM_ERROR
+ if(H5Fclose(fid2) < 0)
+ PROGRAM_ERROR
+ if(H5Gclose(topgid1) < 0)
+ PROGRAM_ERROR
+ if(H5Gclose(topgid2) < 0)
+ PROGRAM_ERROR
+ if(H5Gclose(gid1) < 0)
+ PROGRAM_ERROR
+ if(H5Gclose(gid2) < 0)
+ PROGRAM_ERROR
+ if(H5Tclose(tid1) < 0)
+ PROGRAM_ERROR
+ if(H5Tclose(tid2) < 0)
+ PROGRAM_ERROR
+
+ return;
+
+error:
+ H5E_BEGIN_TRY {
H5Fclose(fid1);
- if (fid2)
H5Fclose(fid2);
- if (topgid1)
H5Gclose(topgid1);
- if (topgid2)
H5Gclose(topgid2);
- if (gid1)
H5Gclose(gid1);
- if (gid2)
H5Gclose(gid2);
- if (tid1)
H5Tclose(tid1);
- if (tid2)
H5Tclose(tid2);
+ } H5E_END_TRY;
+ return;
}
static hid_t mkstr(int size, H5T_str_t pad)
@@ -8085,36 +8067,40 @@ out:
*
*-------------------------------------------------------------------------
*/
-static
-int write_dset(hid_t loc_id, int rank, hsize_t *dims, const char *name, hid_t tid, void *buf)
+static herr_t
+write_dset(hid_t loc_id, int rank, hsize_t *dims, const char *name, hid_t tid, void *buf)
{
hid_t did = -1;
hid_t sid = -1;
/* create a space */
- if ((sid = H5Screate_simple(rank, dims, NULL)) < 0)
- goto out;
+ if((sid = H5Screate_simple(rank, dims, NULL)) < 0)
+ PROGRAM_ERROR
/* create the dataset */
- if ((did = H5Dcreate2(loc_id, name, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- goto out;
+ if((did = H5Dcreate2(loc_id, name, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ PROGRAM_ERROR
/* write */
- if (buf) {
- if (H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
- goto out;
- }
+ if(buf)
+ if(H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
+ PROGRAM_ERROR
/* close */
- H5Dclose(did);
- H5Sclose(sid);
+ if(H5Dclose(did) < 0)
+ PROGRAM_ERROR
+ if(H5Sclose(sid) < 0)
+ PROGRAM_ERROR
return SUCCEED;
-out:
+error:
+
+ H5E_BEGIN_TRY {
+ H5Dclose(did);
+ H5Sclose(sid);
+ } H5E_END_TRY;
- H5Dclose(did);
- H5Sclose(sid);
return FAIL;
-}
+} /* end write_dset() */
diff --git a/tools/test/h5jam/tellub.c b/tools/test/h5jam/tellub.c
index 8e4b3ac..667f2d9 100644
--- a/tools/test/h5jam/tellub.c
+++ b/tools/test/h5jam/tellub.c
@@ -26,9 +26,9 @@
*/
static const char *s_opts = "h";
static struct long_options l_opts[] = {
- {"help", no_arg, 'h'},
- {"hel", no_arg, 'h'},
- {NULL, 0, '\0'}
+ {"help", no_arg, 'h'},
+ {"hel", no_arg, 'h'},
+ {NULL, 0, '\0'}
};
/*-------------------------------------------------------------------------
@@ -37,152 +37,126 @@ static struct long_options l_opts[] = {
* Purpose: Print the usage message
*
* Return: void
- *
- * Programmer:
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static void
usage (const char *prog)
{
- fflush (stdout);
- fprintf (stdout, "usage: %s h5_file\n", prog);
- fprintf (stdout,
- " Check that h5_fil is HDF5 file and print size of user block \n");
- fprintf (stdout, " %s -h\n", prog);
- fprintf (stdout, " Print a usage message and exit\n");
-}
+ HDfflush(stdout);
+ HDfprintf(stdout, "usage: %s h5_file\n", prog);
+ HDfprintf(stdout,
+ " Check that h5_fil is HDF5 file and print size of user block \n");
+ HDfprintf(stdout, " %s -h\n", prog);
+ HDfprintf(stdout, " Print a usage message and exit\n");
+} /* end usage() */
/*-------------------------------------------------------------------------
* Function: parse_command_line
*
* Purpose: Parse the command line for the h5dumper.
*
- * Return: Success:
- *
+ * Return: Success: void
* Failure: Exits program with EXIT_FAILURE value.
- *
- * Programmer:
- *
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static void
parse_command_line (int argc, const char *argv[])
{
- int opt;
-
- /* parse command line options */
- while ((opt = get_option (argc, argv, s_opts, l_opts)) != EOF)
- {
- switch ((char) opt)
- {
- case 'h':
- usage (h5tools_getprogname());
- exit (EXIT_SUCCESS);
- case '?':
- default:
- usage (h5tools_getprogname());
- exit (EXIT_FAILURE);
- }
+ int opt;
+
+ /* parse command line options */
+ while ((opt = get_option (argc, argv, s_opts, l_opts)) != EOF) {
+ switch ((char) opt) {
+ case 'h':
+ usage (h5tools_getprogname());
+ HDexit(EXIT_SUCCESS);
+ case '?':
+ default:
+ usage (h5tools_getprogname());
+ HDexit(EXIT_FAILURE);
+ }
}
- /* check for file name to be processed */
- if (argc <= opt_ind)
- {
- error_msg("missing file name\n");
- usage (h5tools_getprogname());
- exit (EXIT_FAILURE);
+ /* check for file name to be processed */
+ if (argc <= opt_ind) {
+ error_msg("missing file name\n");
+ usage (h5tools_getprogname());
+ HDexit(EXIT_FAILURE);
}
-}
+} /* end parse_command_line() */
/*-------------------------------------------------------------------------
* Function: main
*
* Purpose: HDF5 user block unjammer
*
- * Return: Success: 0
- * Failure: 1
- *
- * Programmer:
- *
- * Modifications:
- *
+ * Return: EXIT_SUCCESS/EXIT_FAILURE
*-------------------------------------------------------------------------
*/
int
main (int argc, const char *argv[])
{
- char *ifname;
- void *edata;
- H5E_auto2_t func;
- hid_t ifile;
- hsize_t usize;
- htri_t testval;
- herr_t status;
- hid_t plist;
-
- h5tools_setprogname(PROGRAMNAME);
- h5tools_setstatus(EXIT_SUCCESS);
-
- /* Initialize h5tools lib */
- h5tools_init();
-
- /* Disable error reporting */
- H5Eget_auto2(H5E_DEFAULT, &func, &edata);
- H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
-
- parse_command_line (argc, argv);
-
- if (argc <= (opt_ind))
- {
- error_msg("missing file name\n");
- usage (h5tools_getprogname());
- return (EXIT_FAILURE);
+ char *ifname;
+ void *edata;
+ H5E_auto2_t func;
+ hid_t ifile;
+ hsize_t usize;
+ htri_t testval;
+ herr_t status;
+ hid_t plist = -1;
+
+ h5tools_setprogname(PROGRAMNAME);
+ h5tools_setstatus(EXIT_SUCCESS);
+
+ /* Initialize h5tools lib */
+ h5tools_init();
+
+ /* Disable error reporting */
+ H5Eget_auto2(H5E_DEFAULT, &func, &edata);
+ H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
+
+ parse_command_line(argc, argv);
+
+ if(argc <= (opt_ind)) {
+ error_msg("missing file name\n");
+ usage (h5tools_getprogname());
+ return EXIT_FAILURE;
}
- ifname = HDstrdup (argv[opt_ind]);
+ ifname = HDstrdup(argv[opt_ind]);
- testval = H5Fis_hdf5 (ifname);
+ testval = H5Fis_hdf5(ifname);
- if (testval <= 0)
- {
- error_msg("Input HDF5 file is not HDF \"%s\"\n", ifname);
- return (EXIT_FAILURE);
+ if(testval <= 0) {
+ error_msg("Input HDF5 file is not HDF \"%s\"\n", ifname);
+ return EXIT_FAILURE;
}
- ifile = H5Fopen (ifname, H5F_ACC_RDONLY, H5P_DEFAULT);
+ ifile = H5Fopen(ifname, H5F_ACC_RDONLY, H5P_DEFAULT);
- if (ifile < 0)
- {
- error_msg("Can't open input HDF5 file \"%s\"\n", ifname);
- return (EXIT_FAILURE);
+ if(ifile < 0) {
+ error_msg("Can't open input HDF5 file \"%s\"\n", ifname);
+ return EXIT_FAILURE;
}
- plist = H5Fget_create_plist (ifile);
- if (plist < 0)
- {
- error_msg("Can't get file creation plist for file \"%s\"\n",
- ifname);
- return (EXIT_FAILURE);
+ plist = H5Fget_create_plist(ifile);
+ if(plist < 0) {
+ error_msg("Can't get file creation plist for file \"%s\"\n", ifname);
+ return EXIT_FAILURE;
}
- status = H5Pget_userblock (plist, &usize);
- if (status < 0)
- {
- error_msg("Can't get user block for file \"%s\"\n", ifname);
- return (EXIT_FAILURE);
+ status = H5Pget_userblock(plist, &usize);
+ if(status < 0) {
+ error_msg("Can't get user block for file \"%s\"\n", ifname);
+ return EXIT_FAILURE;
}
- printf ("%ld\n", (long) usize);
+ HDprintf("%ld\n", (long) usize);
- H5Pclose (plist);
- H5Fclose (ifile);
+ H5Pclose (plist);
+ H5Fclose (ifile);
- return (EXIT_SUCCESS);
-}
+ return EXIT_SUCCESS;
+} /* end main() */
diff --git a/tools/test/h5repack/h5repack.sh.in b/tools/test/h5repack/h5repack.sh.in
index b0a2f99..a36eb08 100644
--- a/tools/test/h5repack/h5repack.sh.in
+++ b/tools/test/h5repack/h5repack.sh.in
@@ -997,6 +997,7 @@ fi
##############################################################################
### T H E T E S T S
##############################################################################
+
# prepare for test
COPY_TESTFILES_TO_TESTDIR
diff --git a/tools/test/h5stat/testh5stat.sh.in b/tools/test/h5stat/testh5stat.sh.in
index 5082daf..0a5127f 100644
--- a/tools/test/h5stat/testh5stat.sh.in
+++ b/tools/test/h5stat/testh5stat.sh.in
@@ -249,7 +249,6 @@ TOOLTEST h5stat_help2.ddl --help
TOOLTEST h5stat_notexist.ddl notexist.h5
TOOLTEST h5stat_nofile.ddl ''
-
# Test file with groups, compressed datasets, user-applied fileters, etc.
# h5stat_filters.h5 is a copy of ../../testfiles/tfilters.h5 as of release 1.8.0-alpha4
TOOLTEST h5stat_filters.ddl h5stat_filters.h5