Skip to content

Commit

Permalink
Don't print thread ID when the library isn't multithreaded.
Browse files Browse the repository at this point in the history
Corresponding changes to make error output for regression tests agnostic
to thread setting.

Signed-off-by: Quincey Koziol <[email protected]>
  • Loading branch information
qkoziol committed Apr 20, 2024
1 parent 84e75e2 commit af05f74
Show file tree
Hide file tree
Showing 32 changed files with 124 additions and 110 deletions.
86 changes: 43 additions & 43 deletions java/test/junit.sh.in

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions src/H5CS.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,11 @@ H5CS_print_stack(const H5CS_t *fstack, FILE *stream)
if (!stream)
stream = stderr;

fprintf(stream, "HDF5-DIAG: Function stack from %s ", H5_lib_vers_info_g);
fprintf(stream, "HDF5-DIAG: Function stack from %s", H5_lib_vers_info_g);
/* try show the process or thread id in multiple processes cases*/
fprintf(stream, "thread %" PRIu64 ".", H5TS_thread_id());
#ifdef H5_HAVE_THREADSAFE
fprintf(stream, " thread %" PRIu64 ".", H5TS_thread_id());
#endif
if (fstack && fstack->nused > 0)
fprintf(stream, " Back trace follows.");
fputc('\n', stream);
Expand Down
24 changes: 16 additions & 8 deletions src/H5Eint.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ H5E__walk1_cb(int n, H5E_error1_t *err_desc, void *client_data)
if (cls_ptr->lib_vers)
eprint->cls.lib_vers = cls_ptr->lib_vers;

fprintf(stream, "%s-DIAG: Error detected in %s (%s) ",
fprintf(stream, "%s-DIAG: Error detected in %s (%s)",
(cls_ptr->cls_name ? cls_ptr->cls_name : "(null)"),
(cls_ptr->lib_name ? cls_ptr->lib_name : "(null)"),
(cls_ptr->lib_vers ? cls_ptr->lib_vers : "(null)"));
Expand All @@ -233,13 +233,17 @@ H5E__walk1_cb(int n, H5E_error1_t *err_desc, void *client_data)

if (mpi_initialized && !mpi_finalized) {
MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
fprintf(stream, "MPI-process %d", mpi_rank);
fprintf(stream, " MPI-process %d", mpi_rank);
} /* end if */
#ifdef H5_HAVE_THREADSAFE
else
fprintf(stream, "thread 0");
fprintf(stream, " thread %" PRIu64, H5TS_thread_id());
#endif
} /* end block */
#else
fprintf(stream, "thread %" PRIu64, H5TS_thread_id());
#ifdef H5_HAVE_THREADSAFE
fprintf(stream, " thread %" PRIu64, H5TS_thread_id());
#endif
#endif
fprintf(stream, ":\n");
} /* end if */
Expand Down Expand Up @@ -342,7 +346,7 @@ H5E__walk2_cb(unsigned n, const H5E_error2_t *err_desc, void *client_data)
if (cls_ptr->lib_vers)
eprint->cls.lib_vers = cls_ptr->lib_vers;

fprintf(stream, "%s-DIAG: Error detected in %s (%s) ",
fprintf(stream, "%s-DIAG: Error detected in %s (%s)",
(cls_ptr->cls_name ? cls_ptr->cls_name : "(null)"),
(cls_ptr->lib_name ? cls_ptr->lib_name : "(null)"),
(cls_ptr->lib_vers ? cls_ptr->lib_vers : "(null)"));
Expand All @@ -357,13 +361,17 @@ H5E__walk2_cb(unsigned n, const H5E_error2_t *err_desc, void *client_data)

if (mpi_initialized && !mpi_finalized) {
MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
fprintf(stream, "MPI-process %d", mpi_rank);
fprintf(stream, " MPI-process %d", mpi_rank);
} /* end if */
#ifdef H5_HAVE_THREADSAFE
else
fprintf(stream, "thread 0");
fprintf(stream, " thread %" PRIu64, H5TS_thread_id());
#endif
} /* end block */
#else
fprintf(stream, "thread %" PRIu64, H5TS_thread_id());
#ifdef H5_HAVE_THREADSAFE
fprintf(stream, " thread %" PRIu64, H5TS_thread_id());
#endif
#endif
fprintf(stream, ":\n");
} /* end if */
Expand Down
6 changes: 5 additions & 1 deletion test/h5test.c
Original file line number Diff line number Diff line change
Expand Up @@ -1117,11 +1117,15 @@ h5_show_hostname(void)
MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
printf("MPI-process %d.", mpi_rank);
}
#ifdef H5_HAVE_THREADSAFE
else
printf("thread 0.");
printf("thread %" PRIu64 ".", H5TS_thread_id());
#endif
#else
#ifdef H5_HAVE_THREADSAFE
printf("thread %" PRIu64 ".", H5TS_thread_id());
#endif
#endif
#ifdef H5_HAVE_WIN32_API

err = WSAStartup(MAKEWORD(2, 2), &wsaData);
Expand Down
2 changes: 1 addition & 1 deletion test/test_error.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ TEST() {
fi

# Extract file name, line number, version and thread IDs because they may be different
sed -e 's/thread [0-9]*/thread (IDs)/' -e 's/: .*\.c /: (file name) /' \
sed -e 's/ thread [0-9]*//' -e 's/: .*\.c /: (file name) /' \
-e 's/line [0-9]*/line (number)/' \
-e 's/v[1-9]*\.[0-9]*\./version (number)\./' \
-e 's/[1-9]*\.[0-9]*\.[0-9]*[^)]*/version (number)/' \
Expand Down
8 changes: 4 additions & 4 deletions test/testfiles/err_compat_1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Testing error API based on data I/O
All error API tests passed.
This program tests the Error API compatible with HDF5 version (number). There are supposed to be some error messages
********* Print error stack in HDF5 default way *********
HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
HDF5-DIAG: Error detected in HDF5 (version (number)):
#000: (file name) line (number) in main(): fake error message 1
major: Error API
minor: Bad value
Expand All @@ -12,7 +12,7 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
error #000: (file name) in main(): line (number)
major: Error API
minor: Bad value
HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
HDF5-DIAG: Error detected in HDF5 (version (number)):
#000: (file name) line (number) in H5Dcreate2(): unable to synchronously create dataset
major: Dataset
minor: Unable to create file
Expand Down Expand Up @@ -70,7 +70,7 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
error #003: (file name) in H5Dcreate2(): line (number)
major: Dataset
minor: Unable to create file
HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
HDF5-DIAG: Error detected in HDF5 (version (number)):
#000: (file name) line (number) in H5Dcreate2(): unable to synchronously create dataset
major: Dataset
minor: Unable to create file
Expand All @@ -83,7 +83,7 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
#003: (file name) line (number) in H5VL_vol_object(): invalid identifier type to function
major: Invalid arguments to routine
minor: Inappropriate type
HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
HDF5-DIAG: Error detected in HDF5 (version (number)):
#000: (file name) line (number) in main(): fake error message 2
major: Error API
minor: Unrecognized message
Expand Down
12 changes: 6 additions & 6 deletions test/testfiles/error_test_1
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
This program tests the Error API. There're supposed to be some error messages
********* Print error stack in HDF5 default way *********
Second Test-DIAG: Error detected in Second Program (1.0) thread (IDs):
Second Test-DIAG: Error detected in Second Program (1.0):
#000: (file name) line (number) in main(): Error stack test failed
major: Error in test
minor: Error in error stack
Error Test-DIAG: Error detected in Error Program (1.0) thread (IDs):
Error Test-DIAG: Error detected in Error Program (1.0):
#001: (file name) line (number) in error_stack(): Get number test failed, returned 0
major: Error in API
minor: Error in H5Eget_num
Expand All @@ -20,21 +20,21 @@ Error Test-DIAG: Error detected in Error Program (1.0) thread (IDs):
minor: Error in error stack

Testing error API based on data I/O
HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
HDF5-DIAG: Error detected in HDF5 (version (number)):
#000: (file name) line (number) in H5Dwrite(): can't synchronously write data
major: Dataset
minor: Write failed
#001: (file name) line (number) in H5D__write_api_common(): dset_id is not a dataset ID
major: Invalid arguments to routine
minor: Inappropriate type
Error Test-DIAG: Error detected in Error Program (1.0) thread (IDs):
Error Test-DIAG: Error detected in Error Program (1.0):
#000: (file name) line (number) in main(): Error test failed, it's wrong
major: Error in test
minor: Error in subroutine
#001: (file name) line (number) in test_error(): H5Dwrite failed as supposed to
major: Error in IO
minor: Error in H5Dwrite
HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
HDF5-DIAG: Error detected in HDF5 (version (number)):
#002: (file name) line (number) in H5Dwrite(): can't synchronously write data
major: Dataset
minor: Write failed
Expand All @@ -43,7 +43,7 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
minor: Inappropriate type

Testing error message during data reading when filter isn't registered
HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
HDF5-DIAG: Error detected in HDF5 (version (number)):
#000: (file name) line (number) in H5Dread(): can't synchronously read data
major: Dataset
minor: Read failed
Expand Down
2 changes: 1 addition & 1 deletion tools/test/h5dump/errfiles/tall-1.err
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
HDF5-DIAG: Error detected in HDF5 (version (number)):
#000: (file name) line (number) in H5Oopen(): unable to synchronously open object
major: Object header
minor: Can't open object
Expand Down
2 changes: 1 addition & 1 deletion tools/test/h5dump/errfiles/tall-2A.err
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
HDF5-DIAG: Error detected in HDF5 (version (number)):
#000: (file name) line (number) in H5Oopen(): unable to synchronously open object
major: Object header
minor: Can't open object
Expand Down
2 changes: 1 addition & 1 deletion tools/test/h5dump/errfiles/tall-2A0.err
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
HDF5-DIAG: Error detected in HDF5 (version (number)):
#000: (file name) line (number) in H5Oopen(): unable to synchronously open object
major: Object header
minor: Can't open object
Expand Down
2 changes: 1 addition & 1 deletion tools/test/h5dump/errfiles/tall-2B.err
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
HDF5-DIAG: Error detected in HDF5 (version (number)):
#000: (file name) line (number) in H5Oopen(): unable to synchronously open object
major: Object header
minor: Can't open object
Expand Down
8 changes: 4 additions & 4 deletions tools/test/h5dump/errfiles/tarray1_big.err
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
HDF5-DIAG: Error detected in HDF5 (version (number)):
#000: (file name) line (number) in H5Rget_obj_type3(): unable to get object token
major: References
minor: Can't get value
#001: (file name) line (number) in H5R__get_obj_token(): NULL token size
major: References
minor: Unable to copy object
HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
HDF5-DIAG: Error detected in HDF5 (version (number)):
#000: (file name) line (number) in H5Rget_obj_type3(): unable to get object token
major: References
minor: Can't get value
#001: (file name) line (number) in H5R__get_obj_token(): NULL token size
major: References
minor: Unable to copy object
HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
HDF5-DIAG: Error detected in HDF5 (version (number)):
#000: (file name) line (number) in H5Rget_obj_type3(): unable to get object token
major: References
minor: Can't get value
#001: (file name) line (number) in H5R__get_obj_token(): NULL token size
major: References
minor: Unable to copy object
H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs):
H5tools-DIAG: Error detected in HDF5:tools (version (number)):
#000: (file name) line (number) in h5tools_dump_data(): H5Rget_obj_type3 H5R_OBJECT1 failed
major: Failure in tools library
minor: error in function
Expand Down
2 changes: 1 addition & 1 deletion tools/test/h5dump/errfiles/tattr-3.err
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
HDF5-DIAG: Error detected in HDF5 (version (number)):
#000: (file name) line (number) in H5Aopen(): unable to synchronously open attribute
major: Attribute
minor: Unable to create file
Expand Down
6 changes: 3 additions & 3 deletions tools/test/h5dump/errfiles/tattrregR.err
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
HDF5-DIAG: Error detected in HDF5 (version (number)):
#000: (file name) line (number) in H5Rget_obj_type3(): unable to get object token
major: References
minor: Can't get value
#001: (file name) line (number) in H5R__get_obj_token(): NULL token size
major: References
minor: Unable to copy object
HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
HDF5-DIAG: Error detected in HDF5 (version (number)):
#000: (file name) line (number) in H5Rget_obj_type3(): unable to get object token
major: References
minor: Can't get value
#001: (file name) line (number) in H5R__get_obj_token(): NULL token size
major: References
minor: Unable to copy object
H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs):
H5tools-DIAG: Error detected in HDF5:tools (version (number)):
#000: (file name) line (number) in h5tools_dump_data(): H5Rget_obj_type3 H5R_OBJECT1 failed
major: Failure in tools library
minor: error in function
Expand Down
2 changes: 1 addition & 1 deletion tools/test/h5dump/errfiles/tcomp-3.err
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
HDF5-DIAG: Error detected in HDF5 (version (number)):
#000: (file name) line (number) in H5Topen2(): unable to open named datatype synchronously
major: Datatype
minor: Can't open object
Expand Down
6 changes: 3 additions & 3 deletions tools/test/h5dump/errfiles/tdataregR.err
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
HDF5-DIAG: Error detected in HDF5 (version (number)):
#000: (file name) line (number) in H5Rget_obj_type3(): unable to get object token
major: References
minor: Can't get value
#001: (file name) line (number) in H5R__get_obj_token(): NULL token size
major: References
minor: Unable to copy object
HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
HDF5-DIAG: Error detected in HDF5 (version (number)):
#000: (file name) line (number) in H5Rget_obj_type3(): unable to get object token
major: References
minor: Can't get value
#001: (file name) line (number) in H5R__get_obj_token(): NULL token size
major: References
minor: Unable to copy object
H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs):
H5tools-DIAG: Error detected in HDF5:tools (version (number)):
#000: (file name) line (number) in h5tools_dump_data(): H5Rget_obj_type3 H5R_OBJECT1 failed
major: Failure in tools library
minor: error in function
Expand Down
4 changes: 2 additions & 2 deletions tools/test/h5dump/errfiles/tdset-2.err
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
HDF5-DIAG: Error detected in HDF5 (version (number)):
#000: (file name) line (number) in H5Dopen2(): unable to synchronously open dataset
major: Dataset
minor: Can't open object
Expand Down Expand Up @@ -29,7 +29,7 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
#009: (file name) line (number) in H5G__loc_find_cb(): object 'dset3' doesn't exist
major: Symbol table
minor: Object not found
HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
HDF5-DIAG: Error detected in HDF5 (version (number)):
#000: (file name) line (number) in H5Lget_info2(): unable to get link info
major: Links
minor: Can't get value
Expand Down
4 changes: 2 additions & 2 deletions tools/test/h5dump/errfiles/textlink.err
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
HDF5-DIAG: Error detected in HDF5 (version (number)):
#000: (file name) line (number) in H5Oopen(): unable to synchronously open object
major: Object header
minor: Can't open object
Expand Down Expand Up @@ -35,7 +35,7 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
#011: (file name) line (number) in H5L__extern_traverse(): unable to open external file, external link file name = 'filename'
major: Links
minor: Unable to open file
HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
HDF5-DIAG: Error detected in HDF5 (version (number)):
#000: (file name) line (number) in H5Oopen(): unable to synchronously open object
major: Object header
minor: Can't open object
Expand Down
6 changes: 3 additions & 3 deletions tools/test/h5dump/errfiles/textlinkfar.err
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
HDF5-DIAG: Error detected in HDF5 (version (number)):
#000: (file name) line (number) in H5Oopen(): unable to synchronously open object
major: Object header
minor: Can't open object
Expand Down Expand Up @@ -59,7 +59,7 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
#019: (file name) line (number) in H5G__traverse_slink_cb(): component not found
major: Symbol table
minor: Object not found
HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
HDF5-DIAG: Error detected in HDF5 (version (number)):
#000: (file name) line (number) in H5G_loc_find(): can't find object
major: Symbol table
minor: Object not found
Expand Down Expand Up @@ -156,7 +156,7 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
#031: (file name) line (number) in H5G__traverse_special(): too many links
major: Links
minor: Too many soft links in path
HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
HDF5-DIAG: Error detected in HDF5 (version (number)):
#000: (file name) line (number) in H5G_loc_find(): can't find object
major: Symbol table
minor: Object not found
Expand Down
6 changes: 3 additions & 3 deletions tools/test/h5dump/errfiles/textlinksrc.err
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
HDF5-DIAG: Error detected in HDF5 (version (number)):
#000: (file name) line (number) in H5Oopen(): unable to synchronously open object
major: Object header
minor: Can't open object
Expand Down Expand Up @@ -59,7 +59,7 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
#019: (file name) line (number) in H5G__traverse_slink_cb(): component not found
major: Symbol table
minor: Object not found
HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
HDF5-DIAG: Error detected in HDF5 (version (number)):
#000: (file name) line (number) in H5G_loc_find(): can't find object
major: Symbol table
minor: Object not found
Expand Down Expand Up @@ -156,7 +156,7 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
#031: (file name) line (number) in H5G__traverse_special(): too many links
major: Links
minor: Too many soft links in path
HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
HDF5-DIAG: Error detected in HDF5 (version (number)):
#000: (file name) line (number) in H5G_loc_find(): can't find object
major: Symbol table
minor: Object not found
Expand Down
2 changes: 1 addition & 1 deletion tools/test/h5dump/errfiles/tgroup-2.err
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
HDF5-DIAG: Error detected in HDF5 (version (number)):
#000: (file name) line (number) in H5Gopen2(): unable to synchronously open group
major: Symbol table
minor: Unable to create file
Expand Down
2 changes: 1 addition & 1 deletion tools/test/h5dump/errfiles/torderlinks1.err
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
HDF5-DIAG: Error detected in HDF5 (version (number)):
#000: (file name) line (number) in H5Oopen(): unable to synchronously open object
major: Object header
minor: Can't open object
Expand Down
2 changes: 1 addition & 1 deletion tools/test/h5dump/errfiles/torderlinks2.err
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs):
HDF5-DIAG: Error detected in HDF5 (version (number)):
#000: (file name) line (number) in H5Oopen(): unable to synchronously open object
major: Object header
minor: Can't open object
Expand Down
Loading

0 comments on commit af05f74

Please sign in to comment.