diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2019-09-23 20:30:07 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2019-09-23 20:30:07 (GMT) |
commit | a4d6a270783d69c663357c31fcd6196b98706dfb (patch) | |
tree | ce4cd3ff16aa0a3918c4e999d3b6ba63a35a41fe /tools/h5diff | |
parent | a0947d808fb3b0af98032beb1a4f5353443c8aa3 (diff) | |
download | hdf5-a4d6a270783d69c663357c31fcd6196b98706dfb.zip hdf5-a4d6a270783d69c663357c31fcd6196b98706dfb.tar.gz hdf5-a4d6a270783d69c663357c31fcd6196b98706dfb.tar.bz2 |
HDFFV-10903 merge S3 from dev
Diffstat (limited to 'tools/h5diff')
-rw-r--r-- | tools/h5diff/h5diffgentest.c | 162 | ||||
-rw-r--r-- | tools/h5diff/ph5diff_main.c | 26 |
2 files changed, 89 insertions, 99 deletions
diff --git a/tools/h5diff/h5diffgentest.c b/tools/h5diff/h5diffgentest.c index f59cb47..e6b5103 100644 --- a/tools/h5diff/h5diffgentest.c +++ b/tools/h5diff/h5diffgentest.c @@ -106,10 +106,16 @@ 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, +static hid_t +UD_traverse(H5_ATTR_UNUSED const char * link_name, H5_ATTR_UNUSED hid_t cur_group, H5_ATTR_UNUSED const void * udata, - H5_ATTR_UNUSED size_t udata_size, H5_ATTR_UNUSED hid_t lapl_id) { + H5_ATTR_UNUSED size_t udata_size, H5_ATTR_UNUSED hid_t lapl_id) +{ return -1; } @@ -270,7 +276,7 @@ int main(void) /* string dataset and attribute. HDFFV-10028 */ test_objs_strings(DIFF_STRINGS1, DIFF_STRINGS2); - return 0; + return EXIT_SUCCESS; } /*------------------------------------------------------------------------- @@ -4802,9 +4808,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; @@ -4821,110 +4827,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) { - HDfprintf(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) { - HDfprintf(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) { - HDfprintf(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) { - HDfprintf(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) { - HDfprintf(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) { - HDfprintf(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) { - HDfprintf(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) { - HDfprintf(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) { - HDfprintf(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) { - HDfprintf(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) @@ -7986,29 +7972,33 @@ int write_dset(hid_t loc_id, int rank, hsize_t *dims, const char *name, hid_t ti 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/h5diff/ph5diff_main.c b/tools/h5diff/ph5diff_main.c index 83240cb..380ab3b 100644 --- a/tools/h5diff/ph5diff_main.c +++ b/tools/h5diff/ph5diff_main.c @@ -68,7 +68,7 @@ int main(int argc, const char *argv[]) if(g_nTasks == 1) { - printf("Only 1 task available...doing serial diff\n"); + HDprintf("Only 1 task available...doing serial diff\n"); g_Parallel = 0; @@ -148,12 +148,12 @@ ph5diff_worker(int nID) /* Open the files */ if ((file1_id = H5Fopen (filenames[0], H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) { - printf ("h5diff Task [%d]: <%s>: unable to open file\n", nID, filenames[0]); + HDprintf("h5diff Task [%d]: <%s>: unable to open file\n", nID, filenames[0]); MPI_Abort(MPI_COMM_WORLD, 0); } if ((file2_id = H5Fopen (filenames[1], H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) { - printf ("h5diff Task [%d]: <%s>: unable to open file\n", nID, filenames[1]); + HDprintf("h5diff Task [%d]: <%s>: unable to open file\n", nID, filenames[1]); MPI_Abort(MPI_COMM_WORLD, 0); } /* enable error reporting */ @@ -170,7 +170,7 @@ ph5diff_worker(int nID) /* Make certain we've received the filenames and opened the files already */ if(file1_id < 0 || file2_id < 0) { - printf("ph5diff_worker: ERROR: work received before/without filenames\n"); + HDprintf("ph5diff_worker: ERROR: work received before/without filenames\n"); break; } @@ -199,7 +199,7 @@ ph5diff_worker(int nID) char out_data[PRINT_DATA_MAX_SIZE]; int tmp; - memset(out_data, 0, PRINT_DATA_MAX_SIZE); + HDmemset(out_data, 0, PRINT_DATA_MAX_SIZE); i=0; rewind(overflow_file); @@ -210,7 +210,7 @@ ph5diff_worker(int nID) { MPI_Send(out_data, PRINT_DATA_MAX_SIZE, MPI_BYTE, 0, MPI_TAG_PRINT_DATA, MPI_COMM_WORLD); i=0; - memset(out_data, 0, PRINT_DATA_MAX_SIZE); + HDmemset(out_data, 0, PRINT_DATA_MAX_SIZE); } } @@ -221,8 +221,8 @@ ph5diff_worker(int nID) overflow_file = NULL; } - fflush(stdout); - memset(outBuff, 0, OUTBUFF_SIZE); + HDfflush(stdout); + HDmemset(outBuff, 0, OUTBUFF_SIZE); outBuffOffset = 0; MPI_Send(&diffs, sizeof(diffs), MPI_BYTE, 0, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD); @@ -238,7 +238,7 @@ ph5diff_worker(int nID) } else { - printf("ph5diff_worker: ERROR: invalid tag (%d) received\n", Status.MPI_TAG); + HDprintf("ph5diff_worker: ERROR: invalid tag (%d) received\n", Status.MPI_TAG); break; } @@ -266,14 +266,14 @@ void print_manager_output(void) /* If there was something we buffered, let's print it now */ if( (outBuffOffset>0) && g_Parallel) { - printf("%s", outBuff); + HDprintf("%s", outBuff); if(overflow_file) { int tmp; rewind(overflow_file); - while((tmp = getc(overflow_file)) >= 0) - putchar(tmp); + while((tmp = HDgetc(overflow_file)) >= 0) + HDputchar(tmp); fclose(overflow_file); overflow_file = NULL; } @@ -321,6 +321,6 @@ void h5diff_exit(int status) /* Always exit(0), since MPI implementations do weird stuff when they * receive a non-zero exit value. - QAK */ - exit(0); + HDexit(0); } |