summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2021-03-22 18:50:26 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2021-03-22 18:50:26 (GMT)
commit904315962c7a4e69b46143e556723cfb1e9a8d97 (patch)
treefcd770cc7e66095d161ffa651f9883babfdd45c1 /test
parentf695908160bbd455492d91ca9acb414c90c33d73 (diff)
downloadhdf5-904315962c7a4e69b46143e556723cfb1e9a8d97.zip
hdf5-904315962c7a4e69b46143e556723cfb1e9a8d97.tar.gz
hdf5-904315962c7a4e69b46143e556723cfb1e9a8d97.tar.bz2
Brings the tcheck_version test changes from develop
Diffstat (limited to 'test')
-rw-r--r--test/tcheck_version.c129
1 files changed, 76 insertions, 53 deletions
diff --git a/test/tcheck_version.c b/test/tcheck_version.c
index 2611178..70f49da 100644
--- a/test/tcheck_version.c
+++ b/test/tcheck_version.c
@@ -11,35 +11,39 @@
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-/*
- * This tests the h5check_version() function.
- *
- * The default is to call the h5check_version() with the version information
- * in the header file and should incur no warnings or abort.
- * Options provided to call it with incorrect versions to test
- * if it will indeed issue the warning message and aborts. With environment
- * variable $HDF5_DISABLE_VERSION_CHECK sets to 1, it should issue warnings
- * but no abort. If it is 2, no warning or abort.
- *
- * Programmer: Albert Cheng
- * September 20, 2009
- * Modifications:
- * Added abort signal intercept. AKC - 2009/10/16 -
- */
+ /*
+ * This tests the h5check_version() function.
+ *
+ * The default is to call the h5check_version() with the version information
+ * in the header file and should incur no warnings or abort.
+ * Options provided to call it with incorrect versions to test
+ * if it will indeed issue the warning message and aborts. With environment
+ * variable $HDF5_DISABLE_VERSION_CHECK sets to 1, it should issue warnings
+ * but no abort. If it is 2, no warning or abort.
+ *
+ * Programmer: Albert Cheng
+ * September 20, 2009
+ * Modifications:
+ * Added abort signal intercept. AKC - 2009/10/16 -
+ */
#include "h5test.h"
-#define progname "tcheck_version"
+#ifdef H5_HAVE_WIN32_API
+#include <crtdbg.h>
+#endif
-/* prototypes */
+#define progname "tcheck_version"
+
+ /* prototypes */
void showhelp(void);
-void parse(int ac, char **av);
-void abort_intercept (int H5_ATTR_UNUSED sig);
+void parse(int ac, char** av);
+void abort_intercept(int H5_ATTR_UNUSED sig);
/* global variables */
-unsigned major = H5_VERS_MAJOR;
-unsigned minor = H5_VERS_MINOR;
-unsigned release = H5_VERS_RELEASE;
+unsigned major = H5_VERS_MAJOR;
+unsigned minor = H5_VERS_MINOR;
+unsigned release = H5_VERS_RELEASE;
void
showhelp(void)
@@ -53,44 +57,44 @@ showhelp(void)
HDprintf("\t\t\tr for Release number (%d)\n", H5_VERS_RELEASE);
}
-
void
-parse(int ac, char **av)
+parse(int ac, char** av)
{
- char *pt;
+ char* pt;
- while (--ac > 0){
- pt = *(++av);
- if (*pt != '-') {
- HDfprintf(stderr, "Unknown option(%s). Aborted.\n", *av);
- HDexit(EXIT_FAILURE);
- }else{
- switch(*(++pt)) {
- case 't': /* option -t */
- switch(*(++pt)) {
- case 'M':
- major++;
- break;
- case 'm':
- minor++;
- break;
- case 'r':
- release++;
+ while (--ac > 0) {
+ pt = *(++av);
+ if (*pt != '-') {
+ HDfprintf(stderr, "Unknown option(%s). Aborted.\n", *av);
+ HDexit(EXIT_FAILURE);
+ }
+ else {
+ switch (*(++pt)) {
+ case 't': /* option -t */
+ switch (*(++pt)) {
+ case 'M':
+ major++;
+ break;
+ case 'm':
+ minor++;
+ break;
+ case 'r':
+ release++;
+ break;
+ default:
+ HDfprintf(stderr, "Unknown -v parameter (%s). Aborted.\n", *av);
+ HDexit(EXIT_FAILURE);
+ }
break;
+ case 'h': /* help page */
+ showhelp();
+ HDexit(EXIT_SUCCESS);
default:
- HDfprintf(stderr, "Unknown -v parameter (%s). Aborted.\n", *av);
+ HDfprintf(stderr, "Unknown option(%s). Aborted.\n", *av);
HDexit(EXIT_FAILURE);
}
- break;
- case 'h': /* help page */
- showhelp();
- HDexit(EXIT_SUCCESS);
- default:
- HDfprintf(stderr, "Unknown option(%s). Aborted.\n", *av);
- HDexit(EXIT_FAILURE);
}
}
- }
}
/* Handler for SIGABRT - catch the abort signal supposedly from check_version()
@@ -103,17 +107,36 @@ parse(int ac, char **av)
* This tries to eliminate those side effects.
*/
H5_ATTR_NORETURN void
-abort_intercept (int H5_ATTR_UNUSED sig)
+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)
+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;
}