From adae34607538e7d0bcfc7ed5623cf31ff3721d9e Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Sat, 13 Apr 2002 20:15:45 -0500 Subject: [svn-r5182] Purpose: Feature Description: Added test to verify H5_MALLOC_WORKS (malloc zero byte) macro Platforms tested: Eirene --- test/tconfig.c | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/test/tconfig.c b/test/tconfig.c index 57cf3d4..01fc2df 100644 --- a/test/tconfig.c +++ b/test/tconfig.c @@ -27,13 +27,14 @@ /* verify C type sizes */ #define vrfy_ctype(ctype, ctype_macro) \ if (sizeof(ctype) != ctype_macro){ \ - print_func("Error verfying %s expected: %d, got: %d\n", \ + print_func("Error verifying %s expected: %d, got: %d\n", \ #ctype_macro, ctype_macro, sizeof(ctype)); \ num_errs++; \ } /* local routine prototypes */ void test_config_ctypes(void); +void test_config_malloc(void); /*------------------------------------------------------------------------- @@ -56,6 +57,7 @@ test_configure(void) /* Output message about test being performed */ MESSAGE(5, ("Testing configure definitions\n")); test_config_ctypes(); + test_config_malloc(); } @@ -180,3 +182,42 @@ test_config_ctypes(void) #endif } + + +/*------------------------------------------------------------------------- + * Function: test_config_malloc + * + * Purpose: test C language malloc function + * + * Return: none (error is fed back via global variable num_errs) + * + * Programmer: Albert Cheng + * April 13, 2002 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +void +test_config_malloc(void) +{ + char *pt; + size_t n; + + /* verify H5_MALLOC_WORKS (malloc zero byte) macros */ + pt = malloc(0); + +#ifdef H5_MALLOC_WORKS + if (pt==NULL){ + print_func("Error verifying H5_MALLOC_WORKS: " + "expected non-NULL, got NULL\n"); + num_errs++; + } +#else + if (pt!=NULL){ + print_func("Error verifying H5_MALLOC_WORKS: " + "expected NULL, got non-NULL\n"); + num_errs++; + } +#endif +} -- cgit v0.12