From bdce66f69a4f976fd3013c54b0f8f9f137bff8f5 Mon Sep 17 00:00:00 2001 From: Robb Matzke Date: Tue, 21 Jul 1998 11:11:56 -0500 Subject: [svn-r523] Changes since 19980720 ---------------------- ./test/dtypes.c We try to detect whether floating point overflow generates a SIGFPE and if it does we don't test overflow cases. ./test/H5Sprivate.h ./test/H5S.c ./test/H5Oattr.c Added an H5S_debug() which is called from H5O_attr_debug() and which has a switch statement to handle the various data type messages. --- src/H5Oattr.c | 2 +- src/H5S.c | 46 ++++++++++++++++++++ src/H5Sprivate.h | 2 + test/.distdep | 56 ++++++++++++------------ test/dtypes.c | 128 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 5 files changed, 199 insertions(+), 35 deletions(-) diff --git a/src/H5Oattr.c b/src/H5Oattr.c index 99551ee..eaa80ba 100644 --- a/src/H5Oattr.c +++ b/src/H5Oattr.c @@ -429,7 +429,7 @@ H5O_attr_debug(H5F_t *f, const void *_mesg, FILE * stream, intn indent, "Data space size:", (unsigned long)(mesg->ds_size)); fprintf(stream, "%*sData space...\n", indent, ""); - (H5O_SDSPACE->debug)(f, mesg->ds, stream, indent+3, MAX(0, fwidth-3)); + H5S_debug(f, mesg->ds, stream, indent+3, MAX(0, fwidth-3)); FUNC_LEAVE(SUCCEED); } diff --git a/src/H5S.c b/src/H5S.c index 56e411a..215267b 100644 --- a/src/H5S.c +++ b/src/H5S.c @@ -1429,3 +1429,49 @@ H5Screate_simple (int rank, const hsize_t *dims, const hsize_t *maxdims) if (ret_value<0 && space) H5S_close(space); FUNC_LEAVE(ret_value); } + + +/*------------------------------------------------------------------------- + * Function: H5S_debug + * + * Purpose: Prints debugging information about a data space. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Tuesday, July 21, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5S_debug(H5F_t *f, const void *_mesg, FILE *stream, intn indent, intn fwidth) +{ + const H5S_t *mesg = (const H5S_t*)_mesg; + + FUNC_ENTER(H5S_debug, FAIL); + + switch (mesg->extent.type) { + case H5S_SCALAR: + fprintf(stream, "%*s%-*s H5S_SCALAR\n", indent, "", fwidth, + "Space class:"); + break; + + case H5S_SIMPLE: + fprintf(stream, "%*s%-*s H5S_SIMPLE\n", indent, "", fwidth, + "Space class:"); + (H5O_SDSPACE->debug)(f, &(mesg->extent.u.simple), stream, + indent+3, MAX(0, fwidth-3)); + break; + + default: + fprintf(stream, "%*s%-*s **UNKNOWN-%ld**\n", indent, "", fwidth, + "Space class:", (long)(mesg->extent.type)); + break; + } + + FUNC_LEAVE(SUCCEED); +} diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h index 35371ba..e5aeabc 100644 --- a/src/H5Sprivate.h +++ b/src/H5Sprivate.h @@ -226,6 +226,8 @@ hsize_t H5S_select_npoints (const H5S_t *space); intn H5S_extend (H5S_t *space, const hsize_t *size); herr_t H5S_set_extent_simple (H5S_t *space, int rank, const hsize_t *dims, const hsize_t *max); +herr_t H5S_debug(H5F_t *f, const void *_mesg, FILE *stream, intn indent, + intn fwidth); /* Conversion functions for simple data spaces */ size_t H5S_simp_init (const struct H5O_layout_t *layout, diff --git a/test/.distdep b/test/.distdep index a451de2..dad6bc8 100644 --- a/test/.distdep +++ b/test/.distdep @@ -390,34 +390,6 @@ big.o: \ ../src/H5Spublic.h \ ../src/H5Tpublic.h \ ../src/H5private.h -dtypes.o: \ - dtypes.c \ - ../src/hdf5.h \ - ../src/H5public.h \ - ../src/H5config.h \ - ../src/H5Ipublic.h \ - ../src/H5Apublic.h \ - ../src/H5ACpublic.h \ - ../src/H5Bpublic.h \ - ../src/H5Dpublic.h \ - ../src/H5Epublic.h \ - ../src/H5Fpublic.h \ - ../src/H5Gpublic.h \ - ../src/H5HGpublic.h \ - ../src/H5HLpublic.h \ - ../src/H5MFpublic.h \ - ../src/H5MMpublic.h \ - ../src/H5Opublic.h \ - ../src/H5Ppublic.h \ - ../src/H5Zpublic.h \ - ../src/H5Spublic.h \ - ../src/H5Tpublic.h \ - ../src/H5Tpkg.h \ - ../src/H5HGprivate.h \ - ../src/H5Fprivate.h \ - ../src/H5private.h \ - ../src/H5Tprivate.h \ - ../src/H5Gprivate.h testhdf5.o: \ testhdf5.c \ testhdf5.h \ @@ -470,3 +442,31 @@ dsets.o: \ ../src/H5Zpublic.h \ ../src/H5Spublic.h \ ../src/H5Tpublic.h +dtypes.o: \ + dtypes.c \ + ../src/hdf5.h \ + ../src/H5public.h \ + ../src/H5config.h \ + ../src/H5Ipublic.h \ + ../src/H5Apublic.h \ + ../src/H5ACpublic.h \ + ../src/H5Bpublic.h \ + ../src/H5Dpublic.h \ + ../src/H5Epublic.h \ + ../src/H5Fpublic.h \ + ../src/H5Gpublic.h \ + ../src/H5HGpublic.h \ + ../src/H5HLpublic.h \ + ../src/H5MFpublic.h \ + ../src/H5MMpublic.h \ + ../src/H5Opublic.h \ + ../src/H5Ppublic.h \ + ../src/H5Zpublic.h \ + ../src/H5Spublic.h \ + ../src/H5Tpublic.h \ + ../src/H5Tpkg.h \ + ../src/H5HGprivate.h \ + ../src/H5Fprivate.h \ + ../src/H5private.h \ + ../src/H5Tprivate.h \ + ../src/H5Gprivate.h diff --git a/test/dtypes.c b/test/dtypes.c index 4963d35..f06c8bb 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -8,6 +8,7 @@ * Purpose: Tests the data type interface (H5T) */ #include +#include #include #include #include @@ -60,16 +61,22 @@ typedef enum flt_t { /* Count the number of overflows */ static int noverflows_g = 0; +/* Skip overflow tests if non-zero */ +static int skip_overflow_tests_g = 0; + /* - * Some machines generate SIGFPE on floating point overflows. According to - * the Posix standard, we cannot assume that we can continue from such a - * signal. Therefore, if the following constant is defined then tests that - * might raise SIGFPE are executed in a child process. + * Although we check whether a floating point overflow generates a SIGFPE and + * turn off overflow tests in that case, it might still be possible for an + * overflow condition to occur. Once a SIGFPE is raised the program cannot + * be allowed to continue (cf. Posix signals) so in order to recover from a + * SIGFPE we run tests that might generate one in a child process. */ #if defined(HAVE_FORK) && defined(HAVE_WAITPID) # define HANDLE_SIGFPE #endif +void some_dummy_func(float x); + /*------------------------------------------------------------------------- * Function: fpe_handler @@ -89,7 +96,7 @@ static void fpe_handler(int __unused__ signo) { puts(" -SKIP-"); - puts(" Test skipped due to SIGFPE from probable overflow."); + puts(" Test skipped due to SIGFPE."); #ifndef HANDLE_SIGFPE puts(" Remaining tests could not be run."); puts(" Please turn off SIGFPE on overflows and try again."); @@ -124,6 +131,88 @@ overflow_handler(hid_t __unused__ src_id, hid_t __unused__ dst_id, /*------------------------------------------------------------------------- + * Function: some_dummy_func + * + * Purpose: A dummy function to help check for overflow. + * + * Note: DO NOT DECLARE THIS FUNCTION STATIC OR THE COMPILER MIGHT + * PROMOTE ARGUMENT `x' TO DOUBLE AND DEFEAT THE OVERFLOW + * CHECKING. + * + * Return: void + * + * Programmer: Robb Matzke + * Tuesday, July 21, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +void +some_dummy_func(float x) +{ + char s[128]; + sprintf(s, "%g", x); +} + + +/*------------------------------------------------------------------------- + * Function: generates_sigfpe + * + * Purpose: Determines if SIGFPE is generated from overflows. We must be + * able to fork() and waitpid() in order for this test to work + * properly. Sets skip_overflow_tests_g to non-zero if they + * would generate SIGBUS, zero otherwise. + * + * Programmer: Robb Matzke + * Tuesday, July 21, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static void +generates_sigfpe(void) +{ +#if defined(HAVE_FORK) && defined(HAVE_WAITPID) + pid_t pid; + int status; + size_t i, j; + double d; + unsigned char *dp = (unsigned char*)&d; + float f; + + fflush(stdout); + fflush(stderr); + if ((pid=fork())<0) { + perror("fork"); + exit(1); + } else if (0==pid) { + for (i=0; i<2000; i++) { + for (j=0; j