testhdf5.h

00001 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00002  * Copyright by The HDF Group.                                               *
00003  * Copyright by the Board of Trustees of the University of Illinois.         *
00004  * All rights reserved.                                                      *
00005  *                                                                           *
00006  * This file is part of HDF5.  The full HDF5 copyright notice, including     *
00007  * terms governing use, modification, and redistribution, is contained in    *
00008  * the files COPYING and Copyright.html.  COPYING can be found at the root   *
00009  * of the source code distribution tree; Copyright.html can be found at the  *
00010  * root level of an installed copy of the electronic HDF5 document set and   *
00011  * is linked from the top-level documents page.  It can also be found at     *
00012  * http://hdfgroup.org/HDF5/doc/Copyright.html.  If you do not have          *
00013  * access to either file, you may request a copy from help@hdfgroup.org.     *
00014  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00015 
00016 /*
00017  * This header file contains information required for testing the HDF5 library.
00018  */
00019 
00020 #ifndef TESTHDF5_H
00021 #define TESTHDF5_H
00022 
00023 /*
00024  * Include required headers.  This file tests internal library functions,
00025  * so we include the private headers here.
00026  */
00027 #include "H5private.h"
00028 #include "H5Eprivate.h"
00029 
00030 /* Include generic testing header also */
00031 #include "h5test.h"
00032 
00033 /* Use %ld to print the value because long should cover most cases. */
00034 /* Used to make certain a return value _is_not_ a value */
00035 #define CHECK(ret, val, where) do {                                           \
00036     if (VERBOSE_HI) print_func("   Call to routine: %15s at line %4d " \
00037                                 "in %s returned %ld \n",                      \
00038                                 where, (int)__LINE__, __FILE__,               \
00039                                 (long)(ret));                                 \
00040     if ((ret) == (val)) {                                                     \
00041         TestErrPrintf("*** UNEXPECTED RETURN from %s is %ld at line %4d "     \
00042                    "in %s\n", where, (long)(ret), (int)__LINE__, __FILE__);   \
00043         H5Eprint2(H5E_DEFAULT, stdout);                               \
00044     }                                                                         \
00045 } while(0)
00046 
00047 #define CHECK_I(ret,where) {                                                  \
00048    if (VERBOSE_HI) {                                                  \
00049       print_func("   Call to routine: %15s at line %4d in %s returned %ld\n", \
00050                  (where), (int)__LINE__, __FILE__, (long)(ret));              \
00051    }                                                                          \
00052    if ((ret)<0) {                                                             \
00053       TestErrPrintf ("*** UNEXPECTED RETURN from %s is %ld line %4d in %s\n", \
00054                   (where), (long)(ret), (int)__LINE__, __FILE__);             \
00055       H5Eprint2(H5E_DEFAULT, stdout);                                 \
00056    }                                                                          \
00057 }
00058 
00059 #define CHECK_PTR(ret,where) {                                                \
00060    if (VERBOSE_HI) {                                          \
00061       print_func("   Call to routine: %15s at line %4d in %s returned %p\n",  \
00062                  (where), (int)__LINE__, __FILE__, (ret));                    \
00063    }                                                                          \
00064    if (!(ret)) {                                                              \
00065       TestErrPrintf ("*** UNEXPECTED RETURN from %s is NULL line %4d in %s\n", \
00066                   (where), (int)__LINE__, __FILE__);                          \
00067       H5Eprint2(H5E_DEFAULT, stdout);                                 \
00068    }                                                                          \
00069 }
00070 
00071 /* Used to make certain a return value _is_ a value */
00072 #define VERIFY(_x, _val, where) do {                                          \
00073     long __x = (long)_x, __val = (long)_val;                                  \
00074     if(VERBOSE_HI) {                                  \
00075         print_func("   Call to routine: %15s at line %4d in %s had value "    \
00076                    "%ld \n", (where), (int)__LINE__, __FILE__, __x);          \
00077     }                                                                         \
00078     if((__x) != (__val)) {                                                    \
00079         TestErrPrintf("*** UNEXPECTED VALUE from %s should be %ld, but is %ld at line %4d " \
00080                    "in %s\n", (where), __val, __x, (int)__LINE__, __FILE__);  \
00081         H5Eprint2(H5E_DEFAULT, stdout);                                       \
00082     }                                                                         \
00083 } while(0)
00084 
00085 /* Used to make certain a (non-'long' type's) return value _is_ a value */
00086 #define VERIFY_TYPE(_x, _val, _type, _format, where) do {                                             \
00087     _type __x = (_type)_x, __val = (_type)_val;                               \
00088     if(VERBOSE_HI) {                                  \
00089         print_func("   Call to routine: %15s at line %4d in %s had value "    \
00090                    _format " \n", (where), (int)__LINE__, __FILE__, __x);             \
00091     }                                                                         \
00092     if((__x) != (__val)) {                                                    \
00093         TestErrPrintf("*** UNEXPECTED VALUE from %s should be " _format ", but is " _format " at line %4d " \
00094                    "in %s\n", (where), __val, __x, (int)__LINE__, __FILE__);  \
00095         H5Eprint2(H5E_DEFAULT, stdout);                                       \
00096     }                                                                         \
00097 } while(0)
00098 
00099 /* Used to make certain a string return value _is_ a value */
00100 #define VERIFY_STR(x, val, where) do {                                        \
00101     if (VERBOSE_HI) {                                         \
00102         print_func("   Call to routine: %15s at line %4d in %s had value "    \
00103                    "%s \n", (where), (int)__LINE__, __FILE__, x);    \
00104     }                                                                         \
00105     if (HDstrcmp(x, val)) {                                                   \
00106         TestErrPrintf("*** UNEXPECTED VALUE from %s should be %s, but is %s at line %4d " \
00107                    "in %s\n", where, val, x, (int)__LINE__, __FILE__);        \
00108         H5Eprint2(H5E_DEFAULT, stdout);                               \
00109     }                                                                         \
00110 } while(0)
00111 
00112 /* Used to document process through a test and to check for errors */
00113 #define RESULT(ret,func) do {                                                 \
00114     if (VERBOSE_MED) {                                        \
00115         print_func("   Call to routine: %15s at line %4d in %s returned "     \
00116                    "%ld\n", func, (int)__LINE__, __FILE__, (long)(ret));      \
00117     }                                                                         \
00118     if (VERBOSE_HI)                                           \
00119         H5Eprint2(H5E_DEFAULT, stdout);                               \
00120     if ((ret) == FAIL) {                                                      \
00121         TestErrPrintf("*** UNEXPECTED RETURN from %s is %ld at line %4d "     \
00122                    "in %s\n", func, (long)(ret), (int)__LINE__, __FILE__);    \
00123         H5Eprint2(H5E_DEFAULT, stdout);                               \
00124     }                                                                         \
00125 } while(0)
00126 
00127 /* Used to document process through a test */
00128 #define MESSAGE(V,A) {if (HDGetTestVerbosity()>(V)) print_func A;}
00129 
00130 /* Used to indicate an error that is complex to check for */
00131 #define ERROR(where) do {                                                     \
00132     if(VERBOSE_HI)                                                            \
00133         print_func("   Call to routine: %15s at line %4d in %s returned "     \
00134            "invalid result\n", where, (int)__LINE__, __FILE__);               \
00135     TestErrPrintf("*** UNEXPECTED RESULT from %s at line %4d in %s\n"         \
00136                where, (int)__LINE__, __FILE__);                               \
00137 } while(0)
00138 
00139 /* definitions for command strings */
00140 #define VERBOSITY_STR   "Verbosity"
00141 #define SKIP_STR        "Skip"
00142 #define TEST_STR        "Test"
00143 #define CLEAN_STR       "Cleanup"
00144 
00145 #ifdef __cplusplus
00146 extern "C" {
00147 #endif
00148 
00149 /* Prototypes for the test routines */
00150 void                    test_metadata(void);
00151 void                    test_checksum(void);
00152 void                    test_tst(void);
00153 void                    test_heap(void);
00154 void                    test_refstr(void);
00155 void                    test_file(void);
00156 void                    test_h5o(void);
00157 void                    test_h5t(void);
00158 void                    test_h5s(void);
00159 void                    test_coords(void);
00160 void                    test_h5d(void);
00161 void                    test_attr(void);
00162 void                    test_select(void);
00163 void                    test_time(void);
00164 void                    test_reference(void);
00165 void                    test_vltypes(void);
00166 void                    test_vlstrings(void);
00167 void                    test_iterate(void);
00168 void                    test_array(void);
00169 void                    test_genprop(void);
00170 void                    test_configure(void);
00171 void                    test_misc(void);
00172 void                    test_ids(void);
00173 void                    test_skiplist(void);
00174 void                    test_sohm(void);
00175 void                    test_unicode(void);
00176 
00177 /* Prototypes for the cleanup routines */
00178 void                    cleanup_metadata(void);
00179 void                    cleanup_checksum(void);
00180 void                    cleanup_file(void);
00181 void                    cleanup_h5o(void);
00182 void                    cleanup_h5s(void);
00183 void                    cleanup_coords(void);
00184 void                    cleanup_attr(void);
00185 void                    cleanup_select(void);
00186 void                    cleanup_time(void);
00187 void                    cleanup_reference(void);
00188 void                    cleanup_vltypes(void);
00189 void                    cleanup_vlstrings(void);
00190 void                    cleanup_iterate(void);
00191 void                    cleanup_array(void);
00192 void                    cleanup_genprop(void);
00193 void                    cleanup_configure(void);
00194 void                    cleanup_sohm(void);
00195 void                    cleanup_misc(void);
00196 void                    cleanup_unicode(void);
00197 
00198 #ifdef __cplusplus
00199 }
00200 #endif
00201 #endif /* TESTHDF5_H */