Skip to content

Commit

Permalink
Suppresses the tcheck_version test's abort dialog on Windows (#477)
Browse files Browse the repository at this point in the history
* Suppresses the tcheck_version test's abort dialog on Windows

Windows raises a modal abort/retry/ignore dialog box when CRT
calls abort(). This change installs a report hook that suppresses
the dialog so that the CMake tests don't time out waiting for a
nonexistent user to click a dialog box.

* Committing clang-format changes

* Removes __cdecl from callback

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
derobins and github-actions[bot] authored Mar 17, 2021
1 parent 00a4e41 commit d0f8075
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/tcheck_version.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@

#include "h5test.h"

#ifdef H5_HAVE_WIN32_API
#include <crtdbg.h>
#endif

#define progname "tcheck_version"

/* prototypes */
Expand Down Expand Up @@ -108,12 +112,31 @@ abort_intercept(int H5_ATTR_UNUSED sig)
HDexit(6);
}

#ifdef H5_HAVE_WIN32_API
/* Turns off the modal dialog that is raised when the Windows CRT calls abort().
*
* Returning TRUE here lets Windows know that we've handled the abort() and that there
* is no need to alert the user with a modal dialog box.
*/
int
handle_crt_abort(int reportType, char *message, int *returnValue)
{
return TRUE;
}
#endif

int
main(int ac, char **av)
{
#ifdef H5_HAVE_WIN32_API
(void)_CrtSetReportHook2(_CRT_RPTHOOK_INSTALL, handle_crt_abort);
#endif
parse(ac, av);
HDsignal(SIGABRT, &abort_intercept);
H5check_version(major, minor, release);
HDsignal(SIGABRT, SIG_DFL);
#ifdef H5_HAVE_WIN32_API
(void)_CrtSetReportHook2(_CRT_RPTHOOK_REMOVE, handle_crt_abort);
#endif
return 0;
}

0 comments on commit d0f8075

Please sign in to comment.