2009-09-28 23:44:35 +08:00
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
|
|
* Copyright by The HDF Group. *
|
|
|
|
* All rights reserved. *
|
|
|
|
* *
|
|
|
|
* This file is part of HDF5. The full HDF5 copyright notice, including *
|
|
|
|
* terms governing use, modification, and redistribution, is contained in *
|
2017-04-18 03:32:16 +08:00
|
|
|
* the COPYING file, which can be found at the root of the source code *
|
2021-02-17 22:52:04 +08:00
|
|
|
* distribution tree, or in https://www.hdfgroup.org/licenses. *
|
2017-04-18 03:32:16 +08:00
|
|
|
* If you do not have access to either file, you may request a copy from *
|
|
|
|
* help@hdfgroup.org. *
|
2009-09-28 23:44:35 +08:00
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2009-10-18 12:51:20 +08:00
|
|
|
#include "h5test.h"
|
2009-09-28 23:44:35 +08:00
|
|
|
|
2021-03-18 03:23:07 +08:00
|
|
|
#ifdef H5_HAVE_WIN32_API
|
|
|
|
#include <crtdbg.h>
|
|
|
|
#endif
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
#define progname "tcheck_version"
|
2009-09-28 23:44:35 +08:00
|
|
|
|
2009-10-18 12:51:20 +08:00
|
|
|
/* prototypes */
|
|
|
|
void showhelp(void);
|
|
|
|
void parse(int ac, char **av);
|
2020-09-30 22:27:10 +08:00
|
|
|
void abort_intercept(int H5_ATTR_UNUSED sig);
|
2009-10-18 12:51:20 +08:00
|
|
|
|
2009-09-28 23:44:35 +08:00
|
|
|
/* global variables */
|
2023-06-19 13:13:38 +08:00
|
|
|
static unsigned major = H5_VERS_MAJOR;
|
|
|
|
static unsigned minor = H5_VERS_MINOR;
|
|
|
|
static unsigned release = H5_VERS_RELEASE;
|
2009-09-28 23:44:35 +08:00
|
|
|
|
|
|
|
void
|
|
|
|
showhelp(void)
|
|
|
|
{
|
2023-06-28 23:31:32 +08:00
|
|
|
printf("Usage: " progname " [-h] [-t<vers>]\n");
|
|
|
|
printf("\t-h\tShow this page and version information\n");
|
|
|
|
printf("\t-t<vers>: Test by changing (adding 1 to) the <vers> to trigger\n");
|
|
|
|
printf("\t\t the warning. <vers> can be:\n");
|
|
|
|
printf("\t\t\tM for Major version number (%d)\n", H5_VERS_MAJOR);
|
|
|
|
printf("\t\t\tm for Minor version number (%d)\n", H5_VERS_MINOR);
|
|
|
|
printf("\t\t\tr for Release number (%d)\n", H5_VERS_RELEASE);
|
2009-09-28 23:44:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
parse(int ac, char **av)
|
|
|
|
{
|
|
|
|
char *pt;
|
|
|
|
|
2020-09-30 22:27:10 +08:00
|
|
|
while (--ac > 0) {
|
|
|
|
pt = *(++av);
|
|
|
|
if (*pt != '-') {
|
2023-06-28 23:31:32 +08:00
|
|
|
fprintf(stderr, "Unknown option(%s). Aborted.\n", *av);
|
2023-06-29 23:18:01 +08:00
|
|
|
exit(EXIT_FAILURE);
|
2019-08-16 05:46:00 +08:00
|
|
|
}
|
2020-09-30 22:27:10 +08:00
|
|
|
else {
|
|
|
|
switch (*(++pt)) {
|
|
|
|
case 't': /* option -t */
|
|
|
|
switch (*(++pt)) {
|
|
|
|
case 'M':
|
|
|
|
major++;
|
|
|
|
break;
|
|
|
|
case 'm':
|
|
|
|
minor++;
|
|
|
|
break;
|
|
|
|
case 'r':
|
|
|
|
release++;
|
|
|
|
break;
|
|
|
|
default:
|
2023-06-28 23:31:32 +08:00
|
|
|
fprintf(stderr, "Unknown -v parameter (%s). Aborted.\n", *av);
|
2023-06-29 23:18:01 +08:00
|
|
|
exit(EXIT_FAILURE);
|
2020-09-30 22:27:10 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'h': /* help page */
|
|
|
|
showhelp();
|
2023-06-29 23:18:01 +08:00
|
|
|
exit(EXIT_SUCCESS);
|
2020-09-30 22:27:10 +08:00
|
|
|
default:
|
2023-06-28 23:31:32 +08:00
|
|
|
fprintf(stderr, "Unknown option(%s). Aborted.\n", *av);
|
2023-06-29 23:18:01 +08:00
|
|
|
exit(EXIT_FAILURE);
|
2020-09-30 22:27:10 +08:00
|
|
|
}
|
|
|
|
}
|
2009-09-28 23:44:35 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-18 12:51:20 +08:00
|
|
|
/* Handler for SIGABRT - catch the abort signal supposedly from check_version()
|
2009-11-05 06:08:49 +08:00
|
|
|
* and exit(6). Would have used 134 is the return code in Unix systems
|
|
|
|
* but some systems (e.g., poe in AIX interprets exit(134) the same as
|
|
|
|
* if the process has really been interrupted by the abort signal and prints
|
|
|
|
* extra messages that confuse test script that is looking for matching output.
|
2009-10-18 12:51:20 +08:00
|
|
|
* This handles the abort signal instead letting it interrupt the OS because
|
|
|
|
* some systems may produce extra messages and/or produce core dump.
|
|
|
|
* This tries to eliminate those side effects.
|
|
|
|
*/
|
2016-06-29 05:53:48 +08:00
|
|
|
H5_ATTR_NORETURN void
|
2020-09-30 22:27:10 +08:00
|
|
|
abort_intercept(int H5_ATTR_UNUSED sig)
|
2009-10-18 12:51:20 +08:00
|
|
|
{
|
2023-06-29 23:18:01 +08:00
|
|
|
exit(6);
|
2009-10-18 12:51:20 +08:00
|
|
|
}
|
|
|
|
|
2021-03-18 03:23:07 +08:00
|
|
|
#ifdef H5_HAVE_WIN32_API
|
|
|
|
/* Turns off the modal dialog that is raised when the Windows CRT calls abort().
|
|
|
|
*
|
2023-09-06 04:11:52 +08:00
|
|
|
* Returning true here lets Windows know that we've handled the abort() and that there
|
2021-03-18 03:23:07 +08:00
|
|
|
* is no need to alert the user with a modal dialog box.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
handle_crt_abort(int reportType, char *message, int *returnValue)
|
|
|
|
{
|
2023-09-06 04:11:52 +08:00
|
|
|
return true;
|
2021-03-18 03:23:07 +08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-09-28 23:44:35 +08:00
|
|
|
int
|
|
|
|
main(int ac, char **av)
|
|
|
|
{
|
2021-03-18 03:23:07 +08:00
|
|
|
#ifdef H5_HAVE_WIN32_API
|
|
|
|
(void)_CrtSetReportHook2(_CRT_RPTHOOK_INSTALL, handle_crt_abort);
|
|
|
|
#endif
|
2009-09-28 23:44:35 +08:00
|
|
|
parse(ac, av);
|
2009-10-18 12:51:20 +08:00
|
|
|
HDsignal(SIGABRT, &abort_intercept);
|
2016-03-09 01:49:38 +08:00
|
|
|
H5check_version(major, minor, release);
|
2009-10-18 12:51:20 +08:00
|
|
|
HDsignal(SIGABRT, SIG_DFL);
|
2021-03-18 03:23:07 +08:00
|
|
|
#ifdef H5_HAVE_WIN32_API
|
|
|
|
(void)_CrtSetReportHook2(_CRT_RPTHOOK_REMOVE, handle_crt_abort);
|
|
|
|
#endif
|
2009-09-28 23:44:35 +08:00
|
|
|
return 0;
|
|
|
|
}
|