From d0f807527f9aed62643254afb69e1889eac3390e Mon Sep 17 00:00:00 2001 From: Dana Robinson <43805+derobins@users.noreply.github.com> Date: Wed, 17 Mar 2021 12:23:07 -0700 Subject: Suppresses the tcheck_version test's abort dialog on Windows (#477) * 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> --- test/tcheck_version.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/tcheck_version.c b/test/tcheck_version.c index 49c86c2..bfc8daf 100644 --- a/test/tcheck_version.c +++ b/test/tcheck_version.c @@ -29,6 +29,10 @@ #include "h5test.h" +#ifdef H5_HAVE_WIN32_API +#include +#endif + #define progname "tcheck_version" /* prototypes */ @@ -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; } -- cgit v0.12