From 987f5d5e4de41c02b682464fa8e94252553ed57c Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Fri, 9 Jan 2004 20:41:13 -0500 Subject: [svn-r8048] Purpose: Code cleanup & reorganization Description: Move further in the testing framework cleanup, eliminating all the global variables (moving them into testframe.c as static variables) from the testing framework code and moving it into the libh5test.a. Platforms tested: FreeBSD 4.9 (sleipnir) w & w/o thread-safety, c++ & parallel h5committested --- c++/src/H5Include.h | 2 +- c++/test/Makefile.in | 8 +- c++/test/testhdf5.cpp | 283 ++++---------------------------------- c++/test/th5s.cpp | 3 +- src/hdf5.h | 2 +- test/Makefile.in | 6 +- test/h5test.c | 16 ++- test/h5test.h | 3 +- test/tarray.c | 253 ++++++++++++---------------------- test/tattr.c | 189 +++++++++----------------- test/tconfig.c | 5 +- test/testframe.c | 45 +++++- test/testhdf5.c | 6 +- test/testhdf5.h | 115 ++++++++-------- test/tgenprop.c | 146 +++++++------------- test/th5s.c | 9 +- test/theap.c | 24 ++-- test/titerate.c | 110 ++++++--------- test/tmeta.c | 30 ++-- test/tmisc.c | 170 ++++++++--------------- test/trefer.c | 8 +- test/trefstr.c | 12 +- test/tselect.c | 368 ++++++++++++++++++++------------------------------ test/ttbbt.c | 10 +- test/ttime.c | 26 ++-- test/ttsafe.c | 10 +- test/ttsafe_acreate.c | 158 ++++++++++------------ test/ttsafe_cancel.c | 215 ++++++++++++++--------------- test/ttsafe_dcreate.c | 8 +- test/ttsafe_error.c | 21 +-- test/ttst.c | 30 ++-- test/tvlstr.c | 85 ++++-------- test/tvltypes.c | 184 ++++++++----------------- 33 files changed, 921 insertions(+), 1639 deletions(-) diff --git a/c++/src/H5Include.h b/c++/src/H5Include.h index c432595..b4755c9 100644 --- a/c++/src/H5Include.h +++ b/c++/src/H5Include.h @@ -19,4 +19,4 @@ // This problem is removed. I could replace all #include "H5Include.h" // by #include , but decide not to. BMR - 3/22/01 -#include +#include "hdf5.h" diff --git a/c++/test/Makefile.in b/c++/test/Makefile.in index 094849c..f70b871 100644 --- a/c++/test/Makefile.in +++ b/c++/test/Makefile.in @@ -22,6 +22,7 @@ HDF_CXX="yes" hdf5_srcdir=$(top_srcdir)/src hdf5_builddir=$(top_builddir)/src +hdf5_testdir=$(top_builddir)/test ## Add include directory to the cpp preprocessor flags; note that the ## hdf5/test directory is needed for the use of h5test @@ -30,6 +31,7 @@ CPPFLAGS=-I. -I../src -I$(srcdir)/../src -I$(top_srcdir)/test -I$(hdf5_builddir) ## Add the C++ API library and the hdf5 library to the library lists LIB=../src/libhdf5_cpp.la LIBHDF5=$(hdf5_builddir)/libhdf5.la +LIBH5TEST=$(hdf5_testdir)/libh5test.la ## These are our main targets. They should be listed in the order to be ## executed, generally most specific tests to least specific tests. @@ -47,12 +49,12 @@ TEST_SCRIPTS= DISTCLEAN=$(TEST_PROGS_SRC:.cpp=.lo) $(TEST_PROGS_SRC:.cpp=.o) -$(TEST_PROGS): $(LIB) $(LIBHDF5) +$(TEST_PROGS): $(LIB) $(LIBHDF5) $(LIBH5TEST) testhdf5: $(TEST_OBJ) - @$(LT_LINK_CXX_EXE) $(CXXFLAGS) -o $@ $(TESTHDF5_OBJ) $(LIB) $(LIBHDF5) $(LDFLAGS) $(LIBS) $(DEFAULT_LIBS) + @$(LT_LINK_CXX_EXE) $(CXXFLAGS) -o $@ $(TESTHDF5_OBJ) $(LIB) $(LIBH5TEST) $(LIBHDF5) $(LDFLAGS) $(LIBS) $(DEFAULT_LIBS) dsets: dsets.lo h5cpputil.lo - @$(LT_LINK_CXX_EXE) $(CXXFLAGS) -o $@ dsets.lo h5cpputil.lo $(hdf5_builddir)/../test/h5test.lo $(LIB) $(LIBHDF5) $(LDFLAGS) $(LIBS) $(DEFAULT_LIBS) + @$(LT_LINK_CXX_EXE) $(CXXFLAGS) -o $@ dsets.lo h5cpputil.lo $(hdf5_builddir)/../test/h5test.lo $(LIB) $(LIBH5TEST) $(LIBHDF5) $(LDFLAGS) $(LIBS) $(DEFAULT_LIBS) @CONCLUDE@ diff --git a/c++/test/testhdf5.cpp b/c++/test/testhdf5.cpp index f8aecbd..a532eae 100644 --- a/c++/test/testhdf5.cpp +++ b/c++/test/testhdf5.cpp @@ -35,284 +35,57 @@ ***************************************************************************/ -#ifdef __MWERKS__ -#include -#endif /* __MWERKS__ */ - -#include - -#define MAXNUMOFTESTS 30 -#define HDF5_TEST_MASTER - -/* Internal Variables */ -static int Index = 0; - // Use C version of the header file testhdf5.h instead of re-coding it #include "testhdf5.h" -#ifdef OLD_HEADER_FILENAME -#include -#else -#include -#endif - #include "H5Cpp.h" #ifndef H5_NO_NAMESPACE using namespace H5; #endif /* !H5_NO_NAMESPACE */ -#include "h5cpputil.h" - -struct TestStruct { - int NumErrors; - char Description[64]; - int SkipFlag; - char Name[16]; - void (*Call) (void); - void (*Cleanup) (void); -} Test[MAXNUMOFTESTS]; - -static void InitTest(const char *, void (*) (void), void (*) (void), const char *TheDescr); -static void usage(void); - -static void InitTest(const char *TheName, void (*TheCall) (void), void (*Cleanup) (void), const char *TheDescr) -{ - if (Index >= MAXNUMOFTESTS) { - print_func("Uh-oh, too many tests added, increase MAXNUMOFTEST!\n"); - exit(-1); - } - - HDstrcpy(Test[Index].Description, TheDescr); - HDstrcpy(Test[Index].Name, TheName); - Test[Index].Call = TheCall; - Test[Index].Cleanup = Cleanup; - Test[Index].NumErrors = -1; - Test[Index].SkipFlag = 0; - Index++; -} - -static void -usage(void) -{ - print_func("Usage: testhdf5 [-v[erbose] (l[ow]|m[edium]|h[igh]|0-10)] \n"); - print_func(" [-[e]x[clude] name+] \n"); - print_func(" [-o[nly] name+] \n"); - print_func(" [-b[egin] name] \n"); - print_func(" [-s[ummary]] \n"); - print_func(" [-c[leanoff]] \n"); - print_func(" [-n[ocaching]] \n"); - print_func(" [-h[elp]] \n"); - print_func("\n\n"); - print_func("verbose controls the amount of information displayed\n"); - print_func("exclude to exclude tests by name\n"); - print_func("only to name tests which should be run\n"); - print_func("begin start at the name of the test givin\n"); - print_func("summary prints a summary of test results at the end\n"); - print_func("cleanoff does not delete *.hdf files after execution of tests\n"); - print_func("nocaching do not turn on low-level DD caching\n"); - print_func("help print out this information\n"); - print_func("\n\n"); - print_func("This program currently tests the following: \n\n"); - print_func("%16s %s\n", "Name", "Description"); - print_func("%16s %s\n", "----", "-----------"); - - for (int i = 0; i < Index; i++) - print_func("%16s %s\n", Test[i].Name, Test[i].Description); - - print_func("\n\n"); -} - -/* - * This routine is designed to provide equivalent functionality to 'printf' - * and allow easy replacement for environments which don't have stdin/stdout - * available. (i.e. Windows & the Mac) - */ -int -print_func(const char *format,...) -{ - va_list arglist; - int ret_value; - - va_start(arglist, format); - ret_value = vprintf(format, arglist); - va_end(arglist); - return ret_value; -} - int main(int argc, char *argv[]) { - int CLLoop; /* Command Line Loop */ - int Loop, Loop1; int Summary = 0; int CleanUp = 1; - int Cache = 1; - -#ifdef __MWERKS__ - argc = ccommand(&argv); -#endif /* __MWERKS__ */ - -#if !(defined MAC || defined __MWERKS__ || defined SYMANTEC_C) - /* Un-buffer the stdout and stderr */ - setbuf(stderr, NULL); - setbuf(stdout, NULL); -#endif /* !(MAC || __MWERKS__ || SYMANTEC_C) */ - /* - * Turn off automatic error reporting since we do it ourselves. Besides, - * half the functions this test calls are private, so automatic error - * reporting wouldn't do much good since it's triggered at the API layer. - */ - Exception::dontPrint(); + /* Initialize testing framework */ + TestInit(); // testing file creation and opening in tfile.cpp - InitTest("file", test_file, cleanup_file, "File I/O Operations"); + AddTest("file", test_file, cleanup_file, "File I/O Operations"); // testing dataspace functionalities in th5s.cpp - InitTest("h5s", test_h5s, cleanup_h5s, "Dataspaces"); - - /* Comment out tests that are not done yet. - BMR, Feb 2001 - InitTest("attr", test_attr, cleanup_attr, "Attributes"); - InitTest("select", test_select, cleanup_select, "Selections"); - InitTest("time", test_time, cleanup_time, "Time Datatypes"); - InitTest("reference", test_reference, cleanup_reference, "References"); - InitTest("vltypes", test_vltypes, cleanup_vltypes, "Variable-Length Datatypes"); - InitTest("vlstrings", test_vlstrings, cleanup_vlstrings, "Variable-Length Strings"); - InitTest("iterate", test_iterate, cleanup_iterate, "Group & Attribute Iteration"); - InitTest("array", test_array, cleanup_array, "Array Datatypes"); - InitTest("genprop", test_genprop, cleanup_genprop, "Generic Properties"); + AddTest("h5s", test_h5s, cleanup_h5s, "Dataspaces"); + +/* Comment out tests that are not done yet. - BMR, Feb 2001 + AddTest("attr", test_attr, cleanup_attr, "Attributes"); + AddTest("select", test_select, cleanup_select, "Selections"); + AddTest("time", test_time, cleanup_time, "Time Datatypes"); + AddTest("reference", test_reference, cleanup_reference, "References"); + AddTest("vltypes", test_vltypes, cleanup_vltypes, "Variable-Length Datatypes"); + AddTest("vlstrings", test_vlstrings, cleanup_vlstrings, "Variable-Length Strings"); + AddTest("iterate", test_iterate, cleanup_iterate, "Group & Attribute Iteration"); + AddTest("array", test_array, cleanup_array, "Array Datatypes"); + AddTest("genprop", test_genprop, cleanup_genprop, "Generic Properties"); Comment out tests that are not done yet */ - Verbosity = 4; /* Default Verbosity is Low */ - unsigned major, minor, release; - H5Library::getLibVersion( major, minor, release); - - print_func("\nFor help use: testhdf5 -help\n"); - print_func("Linked with hdf5 version %u.%u release %u\n", - (unsigned)major, (unsigned)minor, (unsigned)release); - - for (CLLoop = 1; CLLoop < argc; CLLoop++) { - if ((argc > CLLoop + 1) && ((HDstrcmp(argv[CLLoop], "-verbose") == 0) || - (HDstrcmp(argv[CLLoop], "-v") == 0))) { - if (argv[CLLoop + 1][0] == 'l') - Verbosity = 4; - else if (argv[CLLoop + 1][0] == 'm') - Verbosity = 6; - else if (argv[CLLoop + 1][0] == 'h') - Verbosity = 10; - else - Verbosity = atoi(argv[CLLoop + 1]); - } - - if ((argc > CLLoop) && ((HDstrcmp(argv[CLLoop], "-summary") == 0) || - (HDstrcmp(argv[CLLoop], "-s") == 0))) - Summary = 1; - - if ((argc > CLLoop) && ((HDstrcmp(argv[CLLoop], "-help") == 0) || - (HDstrcmp(argv[CLLoop], "-h") == 0))) { - usage(); - exit(0); - } - - if ((argc > CLLoop) && ((HDstrcmp(argv[CLLoop], "-cleanoff") == 0) || - (HDstrcmp(argv[CLLoop], "-c") == 0))) - CleanUp = 0; - - if ((argc > CLLoop) && ((HDstrcmp(argv[CLLoop], "-nocache") == 0) || - (HDstrcmp(argv[CLLoop], "-n") == 0))) { - Cache = 0; - printf ("Cache = %d\n", Cache); - } - - if ((argc > CLLoop + 1) && ((HDstrcmp(argv[CLLoop], "-exclude") == 0) || - (HDstrcmp(argv[CLLoop], "-x") == 0))) { - Loop = CLLoop + 1; - - while ((Loop < argc) && (argv[Loop][0] != '-')) { - for (Loop1 = 0; Loop1 < Index; Loop1++) - if (HDstrcmp(argv[Loop], Test[Loop1].Name) == 0) - Test[Loop1].SkipFlag = 1; - - Loop++; - } - } - - if ((argc > CLLoop + 1) && ((HDstrcmp(argv[CLLoop], "-begin") == 0) || - (HDstrcmp(argv[CLLoop], "-b") == 0))) { - Loop = CLLoop + 1; - - while ((Loop < argc) && (argv[Loop][0] != '-')) { - for (Loop1 = 0; Loop1 < Index; Loop1++) { - if (HDstrcmp(argv[Loop], Test[Loop1].Name) != 0) - Test[Loop1].SkipFlag = 1; - if (HDstrcmp(argv[Loop], Test[Loop1].Name) == 0) - Loop1 = Index; - } - - Loop++; - } - } - - if ((argc > CLLoop + 1) && ((HDstrcmp(argv[CLLoop], "-only") == 0) || - (HDstrcmp(argv[CLLoop], "-o") == 0))) { - for (Loop = 0; Loop < Index; Loop++) - Test[Loop].SkipFlag = 1; - Loop = CLLoop + 1; - while ((Loop < argc) && (argv[Loop][0] != '-')) { - for (Loop1 = 0; Loop1 < Index; Loop1++) - if (HDstrcmp(argv[Loop], Test[Loop1].Name) == 0) - Test[Loop1].SkipFlag = 0; - Loop++; - } - } - } - -#ifdef NOT_YET - if (Cache) /* turn on caching, unless we were instucted not to */ - Hcache(CACHE_ALL_FILES, TRUE); -#endif /* NOT_YET */ - - for (Loop = 0; Loop < Index; Loop++) { - if (Test[Loop].SkipFlag) { - MESSAGE(2, ("Skipping -- %s \n", Test[Loop].Description)); - } else { - MESSAGE(2, ("Testing -- %s (%s) \n", Test[Loop].Description, - Test[Loop].Name)); - MESSAGE(5, ("===============================================\n")); - Test[Loop].NumErrors = num_errs; - (*Test[Loop].Call) (); - Test[Loop].NumErrors = num_errs - Test[Loop].NumErrors; - MESSAGE(5, ("===============================================\n")); - MESSAGE(5, ("There were %d errors detected.\n\n", (int) Test[Loop].NumErrors)); - } - } - - MESSAGE(2, ("\n\n")) - test_report(num_errs, string(" HDF5 Base")); - if (Summary) { - print_func("Summary of Test Results:\n"); - print_func("Name of Test Errors Description of Test\n"); - print_func("---------------- ------ --------------------------------------\n"); + /* Display testing information */ + TestInfo(argv[0]); - for (Loop = 0; Loop < Index; Loop++) { - if (Test[Loop].NumErrors == -1) - print_func("%16s %6s %s\n", Test[Loop].Name, "N/A", Test[Loop].Description); - else - print_func("%16s %6d %s\n", Test[Loop].Name, (int) Test[Loop].NumErrors, - Test[Loop].Description); - } + /* Parse command line arguments */ + TestParseCmdLine(argc,argv,&Summary,&CleanUp); - print_func("\n\n"); - } + /* Perform requested testing */ + PerformTests(); - if (CleanUp && !getenv("HDF5_NOCLEANUP")) { - MESSAGE(2, ("\nCleaning Up temp files...\n\n")); + /* Display test summary, if requested */ + if (Summary) + TestSummary(); - /* call individual cleanup routines in each source module */ - for (Loop = 0; Loop < Index; Loop++) - if (!Test[Loop].SkipFlag && Test[Loop].Cleanup!=NULL) - (*Test[Loop].Cleanup) (); - } + /* Clean up test files, if allowed */ + if (CleanUp && !getenv("HDF5_NOCLEANUP")) + TestCleanup(); - return num_errs; + return (GetTestNumErrs()); } diff --git a/c++/test/th5s.cpp b/c++/test/th5s.cpp index 443b310..821a98f 100644 --- a/c++/test/th5s.cpp +++ b/c++/test/th5s.cpp @@ -476,7 +476,8 @@ test_h5s_compound_scalar_read(void) << space4_data.f << ", read_data4.f=" << rdata.f << endl; cout << "scalar data different: space4_data.c1=" << space4_data.c1 << ", read_data4.c1=" << rdata.c2 << endl; - num_errs++; + TestErrPrintf("scalar data different: space4_data.c1=%c, read_data4.c1=%c\n", + space4_data.c1, rdata.c2); } /* end if */ } // end of try block catch (Exception error) diff --git a/src/hdf5.h b/src/hdf5.h index 3ed7203..74a14c9 100644 --- a/src/hdf5.h +++ b/src/hdf5.h @@ -21,7 +21,6 @@ #define _HDF5_H #include "H5public.h" -#include "H5Ipublic.h" /* Interface abstraction */ #include "H5Apublic.h" /* Attributes */ #include "H5ACpublic.h" /* Metadata cache */ #include "H5Bpublic.h" /* B-trees */ @@ -33,6 +32,7 @@ #include "H5Gpublic.h" /* Groups */ #include "H5HGpublic.h" /* Global heaps */ #include "H5HLpublic.h" /* Local heaps */ +#include "H5Ipublic.h" /* ID management */ #include "H5MMpublic.h" /* Memory management */ #include "H5Opublic.h" /* Object headers */ #include "H5Ppublic.h" /* Property lists */ diff --git a/test/Makefile.in b/test/Makefile.in index 09701ad..cde5dde 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -44,7 +44,7 @@ TIMINGS=testmeta ## a single shared library and libhdf5 is much bigger than libh5test. LIBHDF5=../src/libhdf5.la LIB=libh5test.la -LIB_SRC=h5test.c +LIB_SRC=h5test.c testframe.c LIB_OBJ=$(LIB_SRC:.c=.lo) PUB_LIB= @@ -109,11 +109,11 @@ check test _test: $(PROGS) ## How to build the tests... They all depend on the test and hdf5 libraries. $(PROGS): $(LIB) $(LIBHDF5) -TESTHDF5_OBJ=testhdf5.lo testframe.lo tarray.lo tattr.lo tconfig.lo tfile.lo \ +TESTHDF5_OBJ=testhdf5.lo tarray.lo tattr.lo tconfig.lo tfile.lo \ tgenprop.lo th5s.lo theap.lo titerate.lo tmeta.lo ttime.lo trefer.lo \ trefstr.lo tselect.lo ttbbt.lo ttst.lo tvltypes.lo tvlstr.lo tmisc.lo -TTS_OBJ=ttsafe.lo testframe.lo ttsafe_dcreate.lo ttsafe_error.lo \ +TTS_OBJ=ttsafe.lo ttsafe_dcreate.lo ttsafe_error.lo \ ttsafe_cancel.lo ttsafe_acreate.lo testhdf5: $(TESTHDF5_OBJ) diff --git a/test/h5test.c b/test/h5test.c index 3a8e72c..5c21181 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -186,7 +186,7 @@ h5_cleanup(const char *base_name[], hid_t fapl) } else if (driver == H5FD_MULTI) { H5FD_mem_t mt; - assert(strlen(multi_letters)==H5FD_MEM_NTYPES); + assert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES); for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t,mt)) { HDsnprintf(temp, sizeof temp, "%s-%c.h5", @@ -466,9 +466,6 @@ h5_fileaccess(void) const char *name; char s[1024]; hid_t fapl = -1; - hsize_t fam_size = 100*1024*1024; /*100 MB*/ - long log_flags = H5FD_LOG_LOC_IO; - H5FD_mem_t mt; /* First use the environment variable, then the constant */ val = HDgetenv("HDF5_DRIVER"); @@ -505,6 +502,7 @@ h5_fileaccess(void) const char *memb_name[H5FD_MEM_NTYPES]; char sv[H5FD_MEM_NTYPES][1024]; haddr_t memb_addr[H5FD_MEM_NTYPES]; + H5FD_mem_t mt; HDmemset(memb_map, 0, sizeof memb_map); HDmemset(memb_fapl, 0, sizeof memb_fapl); @@ -524,12 +522,16 @@ h5_fileaccess(void) return -1; } } else if (!HDstrcmp(name, "family")) { + hsize_t fam_size = 100*1024*1024; /*100 MB*/ + /* Family of files, each 1MB and using the default driver */ - if ((val=HDstrtok(NULL, " \t\n\r"))) { + if ((val=HDstrtok(NULL, " \t\n\r"))) fam_size = (hsize_t)(HDstrtod(val, NULL) * 1024*1024); - } - if (H5Pset_fapl_family(fapl, fam_size, H5P_DEFAULT)<0) return -1; + if (H5Pset_fapl_family(fapl, fam_size, H5P_DEFAULT)<0) + return -1; } else if (!HDstrcmp(name, "log")) { + long log_flags = H5FD_LOG_LOC_IO; + /* Log file access */ if ((val = HDstrtok(NULL, " \t\n\r"))) log_flags = HDstrtol(val, NULL, 0); diff --git a/test/h5test.h b/test/h5test.h index fac6c26..8a53f0f 100644 --- a/test/h5test.h +++ b/test/h5test.h @@ -21,14 +21,13 @@ #ifndef _H5TEST_H #define _H5TEST_H -#include - #undef NDEBUG #include "hdf5.h" #include "H5private.h" #ifdef H5_STDC_HEADERS # include +# include #endif /* diff --git a/test/tarray.c b/test/tarray.c index 6d9fea6..3dd9137 100644 --- a/test/tarray.c +++ b/test/tarray.c @@ -12,8 +12,6 @@ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* $Id$ */ - /*********************************************************** * * Test program: tarray @@ -145,8 +143,7 @@ test_array_atomic_1d(void) /* Check the array dimensions */ for(i=0; i9) print_func(" Call to routine: %15s at line %4d " \ + if (GetTestVerbosity()>9) print_func(" Call to routine: %15s at line %4d " \ "in %s returned %ld \n", \ where, (int)__LINE__, __FILE__, \ (long)(ret)); \ - if ((ret) == (val)) { \ - print_func("*** UNEXPECTED RETURN from %s is %ld at line %4d " \ - "in %s\n", where, (long)(ret), (int)__LINE__, __FILE__); \ - num_errs++; \ + if ((ret) == (val)) { \ + TestErrPrintf("*** UNEXPECTED RETURN from %s is %ld at line %4d " \ + "in %s\n", where, (long)(ret), (int)__LINE__, __FILE__); \ H5Eprint (stdout); \ } \ } while(0) #define CHECK_I(ret,where) { \ - if (Verbosity>9) { \ + if (GetTestVerbosity()>9) { \ print_func(" Call to routine: %15s at line %4d in %s returned %ld\n", \ (where), (int)__LINE__, __FILE__, (long)(ret)); \ } \ if ((ret)<0) { \ - print_func ("*** UNEXPECTED RETURN from %s is %ld line %4d in %s\n", \ + TestErrPrintf ("*** UNEXPECTED RETURN from %s is %ld line %4d in %s\n", \ (where), (long)(ret), (int)__LINE__, __FILE__); \ H5Eprint (stdout); \ - num_errs++; \ } \ } #define CHECK_PTR(ret,where) { \ - if (Verbosity>9) { \ + if (GetTestVerbosity()>9) { \ print_func(" Call to routine: %15s at line %4d in %s returned %p\n", \ (where), (int)__LINE__, __FILE__, (ret)); \ } \ if (!(ret)) { \ - print_func ("*** UNEXPECTED RETURN from %s is NULL line %4d in %s\n", \ + TestErrPrintf ("*** UNEXPECTED RETURN from %s is NULL line %4d in %s\n", \ (where), (int)__LINE__, __FILE__); \ H5Eprint (stdout); \ - num_errs++; \ } \ } /* Used to make certain a return value _is_ a value */ #define VERIFY(x, val, where) do { \ - if (Verbosity>9) { \ + if (GetTestVerbosity()>9) { \ print_func(" Call to routine: %15s at line %4d in %s had value " \ - "%ld \n", (where), (int)__LINE__, __FILE__, (long)(x)); \ + "%ld \n", (where), (int)__LINE__, __FILE__, (long)(x)); \ } \ if ((x) != (val)) { \ - print_func("*** UNEXPECTED VALUE from %s should be %ld, but is %ld at line %4d " \ - "in %s\n", (where), (long)(val), (long)(x), (int)__LINE__, __FILE__); \ + TestErrPrintf("*** UNEXPECTED VALUE from %s should be %ld, but is %ld at line %4d " \ + "in %s\n", (where), (long)(val), (long)(x), (int)__LINE__, __FILE__); \ H5Eprint (stdout); \ - num_errs++; \ } \ } while(0) /* Used to document process through a test and to check for errors */ #define RESULT(ret,func) do { \ - if (Verbosity>8) { \ + if (GetTestVerbosity()>8) { \ print_func(" Call to routine: %15s at line %4d in %s returned " \ - "%ld\n", func, (int)__LINE__, __FILE__, (long)(ret)); \ + "%ld\n", func, (int)__LINE__, __FILE__, (long)(ret)); \ } \ - if (Verbosity>9) HEEprint(stdout); \ - if ((ret) == FAIL) { \ - print_func("*** UNEXPECTED RETURN from %s is %ld at line %4d " \ - "in %s\n", func, (long)(ret), (int)__LINE__, __FILE__); \ + if (GetTestVerbosity()>9) \ + H5Eprint(stdout); \ + if ((ret) == FAIL) { \ + TestErrPrintf("*** UNEXPECTED RETURN from %s is %ld at line %4d " \ + "in %s\n", func, (long)(ret), (int)__LINE__, __FILE__); \ H5Eprint (stdout); \ - num_errs++; \ } \ } while(0) #else #define CHECK(ret, val, where) do { \ - if (Verbosity>9) print_func(" Call to routine: %15s at line %4d " \ + if (GetTestVerbosity()>9) print_func(" Call to routine: %15s at line %4d " \ "in %s returned %ld \n", \ where, (int)__LINE__, __FILE__, \ (long)(ret)); \ - if ((ret) == (val)) { \ - print_func("*** UNEXPECTED RETURN from %s is %ld at line %4d " \ - "in %s\n", where, (long)(ret), (int)__LINE__, __FILE__); \ - num_errs++; \ - H5Eprint (H5E_DEFAULT, stdout); \ + if ((ret) == (val)) { \ + TestErrPrintf("*** UNEXPECTED RETURN from %s is %ld at line %4d " \ + "in %s\n", where, (long)(ret), (int)__LINE__, __FILE__); \ + H5Eprint (H5E_DEFAULT, stdout); \ } \ } while(0) #define CHECK_I(ret,where) { \ - if (Verbosity>9) { \ + if (GetTestVerbosity()>9) { \ print_func(" Call to routine: %15s at line %4d in %s returned %ld\n", \ (where), (int)__LINE__, __FILE__, (long)(ret)); \ } \ if ((ret)<0) { \ - print_func ("*** UNEXPECTED RETURN from %s is %ld line %4d in %s\n", \ + TestErrPrintf ("*** UNEXPECTED RETURN from %s is %ld line %4d in %s\n", \ (where), (long)(ret), (int)__LINE__, __FILE__); \ - H5Eprint (H5E_DEFAULT, stdout); \ - num_errs++; \ + H5Eprint (H5E_DEFAULT, stdout); \ } \ } #define CHECK_PTR(ret,where) { \ - if (Verbosity>9) { \ + if (GetTestVerbosity()>9) { \ print_func(" Call to routine: %15s at line %4d in %s returned %p\n", \ (where), (int)__LINE__, __FILE__, (ret)); \ } \ if (!(ret)) { \ - print_func ("*** UNEXPECTED RETURN from %s is NULL line %4d in %s\n", \ + TestErrPrintf ("*** UNEXPECTED RETURN from %s is NULL line %4d in %s\n", \ (where), (int)__LINE__, __FILE__); \ - H5Eprint (H5E_DEFAULT, stdout); \ - num_errs++; \ + H5Eprint (H5E_DEFAULT, stdout); \ } \ } /* Used to make certain a return value _is_ a value */ #define VERIFY(x, val, where) do { \ - if (Verbosity>9) { \ + if (GetTestVerbosity()>9) { \ print_func(" Call to routine: %15s at line %4d in %s had value " \ - "%ld \n", (where), (int)__LINE__, __FILE__, (long)(x)); \ + "%ld \n", (where), (int)__LINE__, __FILE__, (long)(x)); \ } \ if ((x) != (val)) { \ - print_func("*** UNEXPECTED VALUE from %s should be %ld, but is %ld at line %4d " \ - "in %s\n", (where), (long)(val), (long)(x), (int)__LINE__, __FILE__); \ - H5Eprint (H5E_DEFAULT, stdout); \ - num_errs++; \ + TestErrPrintf("*** UNEXPECTED VALUE from %s should be %ld, but is %ld at line %4d " \ + "in %s\n", (where), (long)(val), (long)(x), (int)__LINE__, __FILE__); \ + H5Eprint (H5E_DEFAULT, stdout); \ } \ } while(0) /* Used to document process through a test and to check for errors */ #define RESULT(ret,func) do { \ - if (Verbosity>8) { \ + if (GetTestVerbosity()>8) { \ print_func(" Call to routine: %15s at line %4d in %s returned " \ - "%ld\n", func, (int)__LINE__, __FILE__, (long)(ret)); \ + "%ld\n", func, (int)__LINE__, __FILE__, (long)(ret)); \ } \ - if (Verbosity>9) H5Eprint(H5E_DEFAULT, stdout); \ - if ((ret) == FAIL) { \ - print_func("*** UNEXPECTED RETURN from %s is %ld at line %4d " \ - "in %s\n", func, (long)(ret), (int)__LINE__, __FILE__); \ - H5Eprint (H5E_DEFAULT, stdout); \ - num_errs++; \ + if (GetTestVerbosity()>9) \ + H5Eprint(H5E_DEFAULT, stdout); \ + if ((ret) == FAIL) { \ + TestErrPrintf("*** UNEXPECTED RETURN from %s is %ld at line %4d " \ + "in %s\n", func, (long)(ret), (int)__LINE__, __FILE__); \ + H5Eprint (H5E_DEFAULT, stdout); \ } \ } while(0) #endif /* H5_WANT_H5_V1_6_COMPAT */ /* Used to document process through a test */ -#define MESSAGE(V,A) {if (Verbosity>(V)) print_func A;} +#define MESSAGE(V,A) {if (GetTestVerbosity()>(V)) print_func A;} /* definitions for command strings */ #define VERBOSITY_STR "Verbosity" @@ -189,6 +172,10 @@ extern int Verbosity; #define TEST_STR "Test" #define CLEAN_STR "Cleanup" +#ifdef __cplusplus +extern "C" { +#endif + /* Routines for operating on the list of tests (for the "all in one" tests) */ H5TEST_DLL void TestUsage(void); H5TEST_DLL void AddTest(const char *TheName, void (*TheCall) (void), @@ -199,6 +186,9 @@ H5TEST_DLL void PerformTests(void); H5TEST_DLL void TestSummary(void); H5TEST_DLL void TestCleanup(void); H5TEST_DLL void TestInit(void); +H5TEST_DLL int GetTestVerbosity(void); +H5TEST_DLL int GetTestNumErrs(void); +H5TEST_DLL int TestErrPrintf(const char *format, ...); /* Prototypes for the test routines */ void test_metadata(void); @@ -238,4 +228,7 @@ void cleanup_genprop(void); void cleanup_configure(void); void cleanup_misc(void); +#ifdef __cplusplus +} +#endif #endif /* TESTHDF5_H */ diff --git a/test/tgenprop.c b/test/tgenprop.c index 79836de..06f89ab 100644 --- a/test/tgenprop.c +++ b/test/tgenprop.c @@ -85,10 +85,8 @@ test_genprop_basic_class(void) /* Check class name */ name = H5Pget_class_name(cid1); CHECK_PTR(name, "H5Pget_class_name"); - if(HDstrcmp(name,CLASS1_NAME)!=0) { - num_errs++; - printf("Class names don't match!, name=%s, CLASS1_NAME=%s\n",name,CLASS1_NAME); - } /* end if */ + if(HDstrcmp(name,CLASS1_NAME)!=0) + TestErrPrintf("Class names don't match!, name=%s, CLASS1_NAME=%s\n",name,CLASS1_NAME); free(name); /* Check class parent */ @@ -118,10 +116,8 @@ test_genprop_basic_class(void) /* Check class name */ name = H5Pget_class_name(cid1); CHECK_PTR(name, "H5Pget_class_name"); - if(HDstrcmp(name,CLASS2_NAME)!=0) { - num_errs++; - printf("Class names don't match!, name=%s, CLASS2_NAME=%s\n",name,CLASS2_NAME); - } /* end if */ + if(HDstrcmp(name,CLASS2_NAME)!=0) + TestErrPrintf("Class names don't match!, name=%s, CLASS2_NAME=%s\n",name,CLASS2_NAME); free(name); /* Check class parent */ @@ -758,10 +754,8 @@ test_genprop_basic_list_prop(void) /* Check values of temporary properties (set with regular values) */ ret = H5Pget(lid1,PROP3_NAME,&prop3_value); CHECK_I(ret, "H5Pget"); - if(memcmp(&prop3_value,PROP3_DEF_VALUE,PROP3_SIZE)!=0) { - num_errs++; - printf("Property #3 doesn't match!, line=%d\n",__LINE__); - } /* end if */ + if(HDmemcmp(&prop3_value,PROP3_DEF_VALUE,PROP3_SIZE)!=0) + TestErrPrintf("Property #3 doesn't match!, line=%d\n",__LINE__); ret = H5Pget(lid1,PROP4_NAME,&prop4_value); CHECK_I(ret, "H5Pget"); VERIFY(prop4_value, *PROP4_DEF_VALUE, "H5Pget"); @@ -1186,14 +1180,10 @@ test_genprop_list_callback(void) /* Verify creation callback information for properties tracked */ VERIFY(prop1_cb_info.crt_count, 1, "H5Pcreate"); - if(HDstrcmp(prop1_cb_info.crt_name,PROP1_NAME)!=0) { - num_errs++; - printf("Property #1 name doesn't match!, line=%d\n",__LINE__); - } /* end if */ - if(HDmemcmp(prop1_cb_info.crt_value,PROP1_DEF_VALUE,PROP1_SIZE)!=0) { - num_errs++; - printf("Property #1 value doesn't match!, line=%d\n",__LINE__); - } /* end if */ + if(HDstrcmp(prop1_cb_info.crt_name,PROP1_NAME)!=0) + TestErrPrintf("Property #1 name doesn't match!, line=%d\n",__LINE__); + if(HDmemcmp(prop1_cb_info.crt_value,PROP1_DEF_VALUE,PROP1_SIZE)!=0) + TestErrPrintf("Property #1 value doesn't match!, line=%d\n",__LINE__); /* Check values of permanent properties (set with default values) */ ret = H5Pget(lid1,PROP1_NAME,&prop1_value); @@ -1206,10 +1196,8 @@ test_genprop_list_callback(void) /* Check values of temporary properties (set with regular values) */ ret = H5Pget(lid1,PROP3_NAME,&prop3_value); CHECK_I(ret, "H5Pget"); - if(memcmp(&prop3_value,PROP3_DEF_VALUE,PROP3_SIZE)!=0) { - num_errs++; - printf("Property #3 doesn't match!, line=%d\n",__LINE__); - } /* end if */ + if(HDmemcmp(&prop3_value,PROP3_DEF_VALUE,PROP3_SIZE)!=0) + TestErrPrintf("Property #3 doesn't match!, line=%d\n",__LINE__); ret = H5Pget(lid1,PROP4_NAME,&prop4_value); CHECK_I(ret, "H5Pget"); VERIFY(prop4_value, *PROP4_DEF_VALUE, "H5Pget"); @@ -1217,14 +1205,10 @@ test_genprop_list_callback(void) /* Verify get callback information for properties tracked */ VERIFY(prop1_cb_info.get_count, 1, "H5Pget"); VERIFY(prop1_cb_info.get_plist_id, lid1, "H5Pget"); - if(HDstrcmp(prop1_cb_info.get_name,PROP1_NAME)!=0) { - num_errs++; - printf("Property #1 name doesn't match!, line=%d\n",__LINE__); - } /* end if */ - if(HDmemcmp(prop1_cb_info.get_value,PROP1_DEF_VALUE,PROP1_SIZE)!=0) { - num_errs++; - printf("Property #1 value doesn't match!, line=%d\n",__LINE__); - } /* end if */ + if(HDstrcmp(prop1_cb_info.get_name,PROP1_NAME)!=0) + TestErrPrintf("Property #1 name doesn't match!, line=%d\n",__LINE__); + if(HDmemcmp(prop1_cb_info.get_value,PROP1_DEF_VALUE,PROP1_SIZE)!=0) + TestErrPrintf("Property #1 value doesn't match!, line=%d\n",__LINE__); /* Set value of property #1 to different value */ ret = H5Pset(lid1,PROP1_NAME,&prop1_new_value); @@ -1233,14 +1217,10 @@ test_genprop_list_callback(void) /* Verify set callback information for properties tracked */ VERIFY(prop1_cb_info.set_count, 1, "H5Pset"); VERIFY(prop1_cb_info.set_plist_id, lid1, "H5Pset"); - if(HDstrcmp(prop1_cb_info.set_name,PROP1_NAME)!=0) { - num_errs++; - printf("Property #1 name doesn't match!, line=%d\n",__LINE__); - } /* end if */ - if(HDmemcmp(prop1_cb_info.set_value,&prop1_new_value,PROP1_SIZE)!=0) { - num_errs++; - printf("Property #1 value doesn't match!, line=%d\n",__LINE__); - } /* end if */ + if(HDstrcmp(prop1_cb_info.set_name,PROP1_NAME)!=0) + TestErrPrintf("Property #1 name doesn't match!, line=%d\n",__LINE__); + if(HDmemcmp(prop1_cb_info.set_value,&prop1_new_value,PROP1_SIZE)!=0) + TestErrPrintf("Property #1 value doesn't match!, line=%d\n",__LINE__); /* Check new value of tracked properties */ ret = H5Pget(lid1,PROP1_NAME,&prop1_value); @@ -1250,14 +1230,10 @@ test_genprop_list_callback(void) /* Verify get callback information again for properties tracked */ VERIFY(prop1_cb_info.get_count, 2, "H5Pget"); VERIFY(prop1_cb_info.get_plist_id, lid1, "H5Pget"); - if(HDstrcmp(prop1_cb_info.get_name,PROP1_NAME)!=0) { - num_errs++; - printf("Property #1 name doesn't match!, line=%d\n",__LINE__); - } /* end if */ - if(HDmemcmp(prop1_cb_info.get_value,&prop1_new_value,PROP1_SIZE)!=0) { - num_errs++; - printf("Property #1 value doesn't match!, line=%d\n",__LINE__); - } /* end if */ + if(HDstrcmp(prop1_cb_info.get_name,PROP1_NAME)!=0) + TestErrPrintf("Property #1 name doesn't match!, line=%d\n",__LINE__); + if(HDmemcmp(prop1_cb_info.get_value,&prop1_new_value,PROP1_SIZE)!=0) + TestErrPrintf("Property #1 value doesn't match!, line=%d\n",__LINE__); /* Delete property #2 */ ret = H5Premove(lid1,PROP2_NAME); @@ -1266,14 +1242,10 @@ test_genprop_list_callback(void) /* Verify delete callback information for properties tracked */ VERIFY(prop2_cb_info.del_count, 1, "H5Premove"); VERIFY(prop2_cb_info.del_plist_id, lid1, "H5Premove"); - if(HDstrcmp(prop2_cb_info.del_name,PROP2_NAME)!=0) { - num_errs++; - printf("Property #2 name doesn't match!, line=%d\n",__LINE__); - } /* end if */ - if(HDmemcmp(prop2_cb_info.del_value,PROP2_DEF_VALUE,PROP2_SIZE)!=0) { - num_errs++; - printf("Property #2 value doesn't match!, line=%d\n",__LINE__); - } /* end if */ + if(HDstrcmp(prop2_cb_info.del_name,PROP2_NAME)!=0) + TestErrPrintf("Property #2 name doesn't match!, line=%d\n",__LINE__); + if(HDmemcmp(prop2_cb_info.del_value,PROP2_DEF_VALUE,PROP2_SIZE)!=0) + TestErrPrintf("Property #2 value doesn't match!, line=%d\n",__LINE__); /* Copy first list */ lid2 = H5Pcopy(lid1); @@ -1281,14 +1253,10 @@ test_genprop_list_callback(void) /* Verify copy callback information for properties tracked */ VERIFY(prop1_cb_info.cop_count, 1, "H5Pcopy"); - if(HDstrcmp(prop1_cb_info.cop_name,PROP1_NAME)!=0) { - num_errs++; - printf("Property #1 name doesn't match!, line=%d\n",__LINE__); - } /* end if */ - if(HDmemcmp(prop1_cb_info.cop_value,&prop1_new_value,PROP1_SIZE)!=0) { - num_errs++; - printf("Property #1 value doesn't match!, line=%d\n",__LINE__); - } /* end if */ + if(HDstrcmp(prop1_cb_info.cop_name,PROP1_NAME)!=0) + TestErrPrintf("Property #1 name doesn't match!, line=%d\n",__LINE__); + if(HDmemcmp(prop1_cb_info.cop_value,&prop1_new_value,PROP1_SIZE)!=0) + TestErrPrintf("Property #1 value doesn't match!, line=%d\n",__LINE__); /* Verify that the class creation callback occurred */ VERIFY(cop_cb_struct.count, 1, "H5Pcopy"); @@ -1309,14 +1277,10 @@ test_genprop_list_callback(void) /* Verify close callback information for properties tracked */ VERIFY(prop1_cb_info.cls_count, 1, "H5Pclose"); - if(HDstrcmp(prop1_cb_info.cls_name,PROP1_NAME)!=0) { - num_errs++; - printf("Property #1 name doesn't match!, line=%d\n",__LINE__); - } /* end if */ - if(HDmemcmp(prop1_cb_info.cls_value,&prop1_new_value,PROP1_SIZE)!=0) { - num_errs++; - printf("Property #1 value doesn't match!, line=%d\n",__LINE__); - } /* end if */ + if(HDstrcmp(prop1_cb_info.cls_name,PROP1_NAME)!=0) + TestErrPrintf("Property #1 name doesn't match!, line=%d\n",__LINE__); + if(HDmemcmp(prop1_cb_info.cls_value,&prop1_new_value,PROP1_SIZE)!=0) + TestErrPrintf("Property #1 value doesn't match!, line=%d\n",__LINE__); /* Close second list */ ret = H5Pclose(lid2); @@ -1604,11 +1568,9 @@ test_genprop_path(void) /* Get full path for first class */ path=H5P_get_class_path_test(cid1); CHECK_PTR(path, "H5P_get_class_path_test"); - if(HDstrcmp(path,CLASS1_PATH)!=0) { - num_errs++; - printf("Class names don't match!, path=%s, CLASS1_PATH=%s\n",path,CLASS1_PATH); - } /* end if */ - free(path); + if(HDstrcmp(path,CLASS1_PATH)!=0) + TestErrPrintf("Class names don't match!, path=%s, CLASS1_PATH=%s\n",path,CLASS1_PATH); + HDfree(path); /* Create another new generic class, derived from first class */ cid2 = H5Pcreate_class(cid1,CLASS2_NAME,NULL,NULL,NULL,NULL,NULL,NULL); @@ -1625,10 +1587,8 @@ test_genprop_path(void) /* Get full path for second class */ path=H5P_get_class_path_test(cid2); CHECK_PTR(path, "H5P_get_class_path_test"); - if(HDstrcmp(path,CLASS2_PATH)!=0) { - num_errs++; - printf("Class names don't match!, path=%s, CLASS2_PATH=%s\n",path,CLASS2_PATH); - } /* end if */ + if(HDstrcmp(path,CLASS2_PATH)!=0) + TestErrPrintf("Class names don't match!, path=%s, CLASS2_PATH=%s\n",path,CLASS2_PATH); /* Open a copy of the class with the path name */ cid3 = H5P_open_class_path_test(path); @@ -1691,11 +1651,9 @@ test_genprop_refcount(void) /* Check class name */ name = H5Pget_class_name(cid1); CHECK_PTR(name, "H5Pget_class_name"); - if(HDstrcmp(name,CLASS1_NAME)!=0) { - num_errs++; - printf("Class names don't match!, name=%s, CLASS1_NAME=%s\n",name,CLASS1_NAME); - } /* end if */ - free(name); + if(HDstrcmp(name,CLASS1_NAME)!=0) + TestErrPrintf("Class names don't match!, name=%s, CLASS1_NAME=%s\n",name,CLASS1_NAME); + HDfree(name); /* Close class */ ret = H5Pclose_class(cid1); @@ -1712,11 +1670,9 @@ test_genprop_refcount(void) /* Check class name */ name = H5Pget_class_name(cid1); CHECK_PTR(name, "H5Pget_class_name"); - if(HDstrcmp(name,CLASS1_NAME)!=0) { - num_errs++; - printf("Class names don't match!, name=%s, CLASS1_NAME=%s\n",name,CLASS1_NAME); - } /* end if */ - free(name); + if(HDstrcmp(name,CLASS1_NAME)!=0) + TestErrPrintf("Class names don't match!, name=%s, CLASS1_NAME=%s\n",name,CLASS1_NAME); + HDfree(name); /* Close list */ ret = H5Pclose(lid1); @@ -1725,11 +1681,9 @@ test_genprop_refcount(void) /* Check class name */ name = H5Pget_class_name(cid1); CHECK_PTR(name, "H5Pget_class_name"); - if(HDstrcmp(name,CLASS1_NAME)!=0) { - num_errs++; - printf("Class names don't match!, name=%s, CLASS1_NAME=%s\n",name,CLASS1_NAME); - } /* end if */ - free(name); + if(HDstrcmp(name,CLASS1_NAME)!=0) + TestErrPrintf("Class names don't match!, name=%s, CLASS1_NAME=%s\n",name,CLASS1_NAME); + HDfree(name); /* Close class */ ret = H5Pclose_class(cid1); diff --git a/test/th5s.c b/test/th5s.c index e8185db..2f8a19a 100644 --- a/test/th5s.c +++ b/test/th5s.c @@ -452,8 +452,7 @@ test_h5s_compound_scalar_read(void) printf("scalar data different: space4_data.c1=%c, read_data4.c1=%c\n",space4_data.c1,rdata.c1); printf("scalar data different: space4_data.u=%u, read_data4.u=%u\n",space4_data.u,rdata.u); printf("scalar data different: space4_data.f=%f, read_data4.f=%f\n",space4_data.f,rdata.f); - printf("scalar data different: space4_data.c1=%c, read_data4.c1=%c\n",space4_data.c1,rdata.c2); - num_errs++; + TestErrPrintf("scalar data different: space4_data.c1=%c, read_data4.c1=%c\n",space4_data.c1,rdata.c2); } /* end if */ /* Close Dataset */ @@ -549,10 +548,8 @@ test_h5s_chunk(void) for(i=0; i<50000; i++) { for(j=0; j<3; j++) { - if(chunk_data_dbl[i][j]!=chunk_data_flt[i][j]) { - num_errs++; - printf("chunk_data_dbl[%d][%d]=%f, chunk_data_flt[%d][%d]=%f\n",i,j,chunk_data_dbl[i][j],i,j,chunk_data_flt[i][j]); - } /* end if */ + if(chunk_data_dbl[i][j]!=chunk_data_flt[i][j]) + TestErrPrintf("chunk_data_dbl[%d][%d]=%f, chunk_data_flt[%d][%d]=%f\n",i,j,chunk_data_dbl[i][j],i,j,chunk_data_flt[i][j]); } /* end for */ } /* end for */ } /* test_h5s_chunk() */ diff --git a/test/theap.c b/test/theap.c index b02055e..86e0893 100644 --- a/test/theap.c +++ b/test/theap.c @@ -593,16 +593,12 @@ static void test_heap_remove_many_core(H5HP_type_t heap_type, test_obj *arr, siz /* Check that the value is correct, based on the heap type */ if(heap_type==H5HP_MAX_HEAP) { - if(val>last_val) { - num_errs++; - printf("Error on line %d: incorrect value from heap=%d, last_val=%d\n",__LINE__,val,last_val); - } /* end if */ + if(val>last_val) + TestErrPrintf("Error on line %d: incorrect value from heap=%d, last_val=%d\n",__LINE__,val,last_val); } /* end if */ else { - if(vallast_val) { - num_errs++; - printf("Error on line %d: incorrect value from heap=%d, last_val=%d\n",__LINE__,val,last_val); - } /* end if */ + if(val>last_val) + TestErrPrintf("Error on line %d: incorrect value from heap=%d, last_val=%d\n",__LINE__,val,last_val); } /* end if */ else { - if(val0) { - printf("Group iteration function didn't return zero correctly!\n"); - num_errs++; - } + if((ret=H5Giterate(file,"/",&idx,giter_cb,&info))>0) + TestErrPrintf("Group iteration function didn't return zero correctly!\n"); /* Test all objects in group, when callback always returns 1 */ /* This also tests the "restarting" ability, because the index changes */ @@ -286,34 +284,24 @@ static void test_iter_group(void) /* Verify that the correct name is retrieved */ if(idx<=NDATASETS) { - if(strcmp(info.name,dnames[idx-1])!=0) { - printf("Group iteration function didn't return one correctly for dataset #%d!\n",idx); - num_errs++; - } /* end if */ + if(HDstrcmp(info.name,dnames[idx-1])!=0) + TestErrPrintf("Group iteration function didn't return one correctly for dataset #%d!\n",idx); } /* end if */ else if(idx==(NDATASETS+1)) { - if(strcmp(info.name,"dtype")!=0) { - printf("Group iteration function didn't return one correctly for group!\n"); - num_errs++; - } /* end if */ + if(HDstrcmp(info.name,"dtype")!=0) + TestErrPrintf("Group iteration function didn't return one correctly for group!\n"); } /* end if */ else if(idx==(NDATASETS+2)) { - if(strcmp(info.name,"grp")!=0) { - printf("Group iteration function didn't return one correctly for group!\n"); - num_errs++; - } /* end if */ + if(HDstrcmp(info.name,"grp")!=0) + TestErrPrintf("Group iteration function didn't return one correctly for group!\n"); } /* end if */ - else { - printf("Group iteration function walked too far!\n"); - num_errs++; - } /* end else */ + else + TestErrPrintf("Group iteration function walked too far!\n"); } VERIFY(ret,-1,"H5Giterate"); - if(i!=(NDATASETS+2)) { - printf("Group iteration function didn't perform multiple iterations correctly!\n"); - num_errs++; - } /* end if */ + if(i!=(NDATASETS+2)) + TestErrPrintf("Group iteration function didn't perform multiple iterations correctly!\n"); /* Test all objects in group, when callback changes return value */ /* This also tests the "restarting" ability, because the index changes */ @@ -331,41 +319,31 @@ static void test_iter_group(void) /* Verify that the correct name is retrieved */ if(idx<=NDATASETS) { - if(strcmp(info.name,dnames[idx-1])!=0) { - printf("Group iteration function didn't return one correctly for dataset #%d!\n",idx); - num_errs++; - } /* end if */ + if(HDstrcmp(info.name,dnames[idx-1])!=0) + TestErrPrintf("Group iteration function didn't return one correctly for dataset #%d!\n",idx); } /* end if */ else if(idx==(NDATASETS+1)) { - if(strcmp(info.name,"dtype")!=0) { - printf("Group iteration function didn't return one correctly for group!\n"); - num_errs++; - } /* end if */ + if(HDstrcmp(info.name,"dtype")!=0) + TestErrPrintf("Group iteration function didn't return one correctly for group!\n"); } /* end if */ else if(idx==(NDATASETS+2)) { - if(strcmp(info.name,"grp")!=0) { - printf("Group iteration function didn't return one correctly for group!\n"); - num_errs++; - } /* end if */ + if(HDstrcmp(info.name,"grp")!=0) + TestErrPrintf("Group iteration function didn't return one correctly for group!\n"); } /* end if */ - else { - printf("Group iteration function walked too far!\n"); - num_errs++; - } /* end else */ + else + TestErrPrintf("Group iteration function walked too far!\n"); } VERIFY(ret,-1,"H5Giterate"); - if(i!=42 || idx!=52) { - printf("Group iteration function didn't perform multiple iterations correctly!\n"); - num_errs++; - } /* end if */ + if(i!=42 || idx!=52) + TestErrPrintf("Group iteration function didn't perform multiple iterations correctly!\n"); ret=H5Fclose(file); CHECK(ret, FAIL, "H5Fclose"); /* Free the dataset names */ for(i=0; i< NDATASETS; i++) - free(dnames[i]); + HDfree(dnames[i]); } /* test_iter_group() */ @@ -486,10 +464,8 @@ static void test_iter_attr(void) /* Test all attributes on dataset, when callback always returns 0 */ info.command=RET_ZERO; idx=0; - if((ret=H5Aiterate(dataset,&idx,aiter_cb,&info))>0) { - printf("Attribute iteration function didn't return zero correctly!\n"); - num_errs++; - } + if((ret=H5Aiterate(dataset,&idx,aiter_cb,&info))>0) + TestErrPrintf("Attribute iteration function didn't return zero correctly!\n"); /* Test all attributes on dataset, when callback always returns 1 */ /* This also tests the "restarting" ability, because the index changes */ @@ -506,16 +482,12 @@ static void test_iter_attr(void) VERIFY(idx,(unsigned)i,"H5Aiterate"); /* Verify that the correct name is retrieved */ - if(strcmp(info.name,anames[idx-1])!=0) { - printf("Attribute iteration function didn't return one correctly!\n"); - num_errs++; - } /* end if */ + if(HDstrcmp(info.name,anames[idx-1])!=0) + TestErrPrintf("Attribute iteration function didn't return one correctly!\n"); } VERIFY(ret,-1,"H5Aiterate"); - if(i!=50 || idx!=50) { - printf("Group iteration function didn't perform multiple iterations correctly!\n"); - num_errs++; - } /* end if */ + if(i!=50 || idx!=50) + TestErrPrintf("Group iteration function didn't perform multiple iterations correctly!\n"); /* Test all attributes on dataset, when callback changes return value */ @@ -533,16 +505,12 @@ static void test_iter_attr(void) VERIFY(idx,(unsigned)i+10,"H5Aiterate"); /* Verify that the correct name is retrieved */ - if(strcmp(info.name,anames[idx-1])!=0) { - printf("Attribute iteration function didn't return changing correctly!\n"); - num_errs++; - } /* end if */ + if(HDstrcmp(info.name,anames[idx-1])!=0) + TestErrPrintf("Attribute iteration function didn't return changing correctly!\n"); } VERIFY(ret,-1,"H5Aiterate"); - if(i!=40 || idx!=50) { - printf("Group iteration function didn't perform multiple iterations correctly!\n"); - num_errs++; - } /* end if */ + if(i!=40 || idx!=50) + TestErrPrintf("Group iteration function didn't perform multiple iterations correctly!\n"); ret=H5Fclose(file); CHECK(ret, FAIL, "H5Fclose"); @@ -552,7 +520,7 @@ static void test_iter_attr(void) /* Free the attribute names */ for(i=0; i< NATTR; i++) - free(anames[i]); + HDfree(anames[i]); } /* test_iter_attr() */ @@ -577,9 +545,8 @@ herr_t giter_cb2(hid_t loc_id, const char *name, void *opdata) herr_t ret; /* Generic return value */ H5G_stat_t statbuf; - if(strcmp(name,test_info->name)) { - num_errs++; - printf("name=%s, test_info=%s\n",name,test_info->name); + if(HDstrcmp(name,test_info->name)) { + TestErrPrintf("name=%s, test_info=%s\n",name,test_info->name); return(-1); } /* end if */ @@ -590,8 +557,7 @@ herr_t giter_cb2(hid_t loc_id, const char *name, void *opdata) CHECK(ret, FAIL, "H5Gget_objinfo"); if(test_info->type!=statbuf.type) { - num_errs++; - printf("test_info->type=%d, statbuf.type=%d\n",test_info->type,statbuf.type); + TestErrPrintf("test_info->type=%d, statbuf.type=%d\n",test_info->type,statbuf.type); return(-1); } /* end if */ diff --git a/test/tmeta.c b/test/tmeta.c index 5651da9..a78859f 100644 --- a/test/tmeta.c +++ b/test/tmeta.c @@ -81,10 +81,8 @@ test_metadata(void) unsigned u; /* local counting variable */ for (u = 0; u < sizeof(compar_buffer); u++) { - if (compar_buffer[u] != encode_buffer[u]) { - print_func("Error encoding meta-data at offset %u, wanted: %u, got: %u\n", (unsigned) u, (unsigned) compar_buffer[u], (unsigned) encode_buffer[u]); - num_errs++; - } /* end if */ + if (compar_buffer[u] != encode_buffer[u]) + TestErrPrintf("Error encoding meta-data at offset %u, wanted: %u, got: %u\n", (unsigned) u, (unsigned) compar_buffer[u], (unsigned) encode_buffer[u]); } /* end for */ } /* end if */ /* Test decoding macros */ @@ -95,30 +93,22 @@ test_metadata(void) UINT32DECODE(p, du32); /* Decode the uint32 value */ /* Check the values decoded */ - if (di16 != TEST_INT16_VALUE) { - print_func("Error decoding int16 meta-data wanted: %d, got: %d " + if (di16 != TEST_INT16_VALUE) + TestErrPrintf("Error decoding int16 meta-data wanted: %d, got: %d " "at %s:%d\n", (int) TEST_INT16_VALUE, (int) di16, __FILE__, __LINE__); - num_errs++; - } /* end if */ - if (du16 != TEST_UINT16_VALUE) { - print_func("Error decoding uint16 meta-data wanted: %u, got: %u " + if (du16 != TEST_UINT16_VALUE) + TestErrPrintf("Error decoding uint16 meta-data wanted: %u, got: %u " "at %s:%d\n", (unsigned) TEST_UINT16_VALUE, (unsigned) du16, __FILE__, __LINE__); - num_errs++; - } /* end if */ - if (di32 != TEST_INT32_VALUE) { - print_func("Error decoding int32 meta-data wanted: %ld, got: %ld " + if (di32 != TEST_INT32_VALUE) + TestErrPrintf("Error decoding int32 meta-data wanted: %ld, got: %ld " "at %s:%d\n", (long) TEST_INT32_VALUE, (long) di32, __FILE__, __LINE__); - num_errs++; - } /* end if */ - if (du32 != TEST_UINT32_VALUE) { - print_func("Error decoding uint32 meta-data wanted: %lu, got: %lu " + if (du32 != TEST_UINT32_VALUE) + TestErrPrintf("Error decoding uint32 meta-data wanted: %lu, got: %lu " "at %s:%d\n", (unsigned long) TEST_UINT32_VALUE, (unsigned long) du32, __FILE__, __LINE__); - num_errs++; - } /* end if */ } /* test_metadata() */ diff --git a/test/tmisc.c b/test/tmisc.c index 4bfbde4..519000a 100644 --- a/test/tmisc.c +++ b/test/tmisc.c @@ -571,14 +571,10 @@ test_misc4(void) VERIFY(stat1.fileno,stat2.fileno,"H5Gget_objinfo"); /* Verify that the fileno values are not the same between file1 & file2 */ - if(stat1.fileno==stat3.fileno) { - num_errs++; - printf("Error on line %d: stat1.fileno==stat3.fileno\n",__LINE__); - } /* end if */ - if(stat2.fileno==stat3.fileno) { - num_errs++; - printf("Error on line %d: stat1.fileno==stat3.fileno\n",__LINE__); - } /* end if */ + if(stat1.fileno==stat3.fileno) + TestErrPrintf("Error on line %d: stat1.fileno==stat3.fileno\n",__LINE__); + if(stat2.fileno==stat3.fileno) + TestErrPrintf("Error on line %d: stat1.fileno==stat3.fileno\n",__LINE__); /* Close the objects */ ret = H5Gclose(group1); @@ -1401,10 +1397,8 @@ test_misc8(void) tdata2=rdata; for(u=0; u=(MISC8_DIM0*MISC8_DIM1*H5Tget_size(H5T_NATIVE_INT))) { - num_errs++; - printf("Error on line %d: data wasn't compressed! storage_size=%u\n",__LINE__,(unsigned)storage_size); - } + if(storage_size>=(MISC8_DIM0*MISC8_DIM1*H5Tget_size(H5T_NATIVE_INT))) + TestErrPrintf("Error on line %d: data wasn't compressed! storage_size=%u\n",__LINE__,(unsigned)storage_size); #else /* Compression is not configured */ - if(storage_size!=(MISC8_DIM0*MISC8_DIM1*H5Tget_size(H5T_NATIVE_INT))) { - num_errs++; - printf("Error on line %d: wrong storage size! storage_size=%u\n",__LINE__,(unsigned)storage_size); - } + if(storage_size!=(MISC8_DIM0*MISC8_DIM1*H5Tget_size(H5T_NATIVE_INT))) + TestErrPrintf("Error on line %d: wrong storage size! storage_size=%u\n",__LINE__,(unsigned)storage_size); #endif /* H5_HAVE_FILTER_DEFLATE */ /* Close dataset ID */ @@ -1475,15 +1465,11 @@ test_misc8(void) storage_size=H5Dget_storage_size(did); CHECK(storage_size, 0, "H5Dget_storage_size"); #ifdef H5_HAVE_FILTER_DEFLATE - if(storage_size>=(MISC8_DIM0*MISC8_DIM1*H5Tget_size(H5T_NATIVE_INT))) { - num_errs++; - printf("Error on line %d: data wasn't compressed! storage_size=%u\n",__LINE__,(unsigned)storage_size); - } + if(storage_size>=(MISC8_DIM0*MISC8_DIM1*H5Tget_size(H5T_NATIVE_INT))) + TestErrPrintf("Error on line %d: data wasn't compressed! storage_size=%u\n",__LINE__,(unsigned)storage_size); #else /* Compression is not configured */ - if(storage_size!=(MISC8_DIM0*MISC8_DIM1*H5Tget_size(H5T_NATIVE_INT))) { - num_errs++; - printf("Error on line %d: wrong storage size! storage_size=%u\n",__LINE__,(unsigned)storage_size); - } + if(storage_size!=(MISC8_DIM0*MISC8_DIM1*H5Tget_size(H5T_NATIVE_INT))) + TestErrPrintf("Error on line %d: wrong storage size! storage_size=%u\n",__LINE__,(unsigned)storage_size); #endif /* H5_HAVE_FILTER_DEFLATE */ /* Write entire dataset */ @@ -1500,25 +1486,19 @@ test_misc8(void) tdata2=rdata; for(u=0; u=(MISC8_DIM0*MISC8_DIM1*H5Tget_size(H5T_NATIVE_INT))) { - num_errs++; - printf("Error on line %d: data wasn't compressed! storage_size=%u\n",__LINE__,(unsigned)storage_size); - } + if(storage_size>=(MISC8_DIM0*MISC8_DIM1*H5Tget_size(H5T_NATIVE_INT))) + TestErrPrintf("Error on line %d: data wasn't compressed! storage_size=%u\n",__LINE__,(unsigned)storage_size); #else - if(storage_size!=(MISC8_DIM0*MISC8_DIM1*H5Tget_size(H5T_NATIVE_INT))) { - num_errs++; - printf("Error on line %d: wrong storage size! storage_size=%u\n",__LINE__,(unsigned)storage_size); - } + if(storage_size!=(MISC8_DIM0*MISC8_DIM1*H5Tget_size(H5T_NATIVE_INT))) + TestErrPrintf("Error on line %d: wrong storage size! storage_size=%u\n",__LINE__,(unsigned)storage_size); #endif /*H5_HAVE_FILTER_DEFLATE*/ /* Close dataset ID */ @@ -1545,15 +1525,11 @@ test_misc8(void) storage_size=H5Dget_storage_size(did); CHECK(storage_size, 0, "H5Dget_storage_size"); #ifdef H5_HAVE_FILTER_DEFLATE - if(storage_size>=(4*MISC8_CHUNK_DIM0*MISC8_CHUNK_DIM1*H5Tget_size(H5T_NATIVE_INT))) { - num_errs++; - printf("Error on line %d: data wasn't compressed! storage_size=%u\n",__LINE__,(unsigned)storage_size); - } + if(storage_size>=(4*MISC8_CHUNK_DIM0*MISC8_CHUNK_DIM1*H5Tget_size(H5T_NATIVE_INT))) + TestErrPrintf("Error on line %d: data wasn't compressed! storage_size=%u\n",__LINE__,(unsigned)storage_size); #else /* Compression is not configured */ - if(storage_size!=(4*MISC8_CHUNK_DIM0*MISC8_CHUNK_DIM1*H5Tget_size(H5T_NATIVE_INT))) { - num_errs++; - printf("Error on line %d: wrong storage size! storage_size=%u\n",__LINE__,(unsigned)storage_size); - } + if(storage_size!=(4*MISC8_CHUNK_DIM0*MISC8_CHUNK_DIM1*H5Tget_size(H5T_NATIVE_INT))) + TestErrPrintf("Error on line %d: wrong storage size! storage_size=%u\n",__LINE__,(unsigned)storage_size); #endif /* H5_HAVE_FILTER_DEFLATE */ /* Write entire dataset */ @@ -1570,25 +1546,19 @@ test_misc8(void) tdata2=rdata; for(u=0; u=(MISC8_DIM0*MISC8_DIM1*H5Tget_size(H5T_NATIVE_INT))) { - num_errs++; - printf("Error on line %d: data wasn't compressed! storage_size=%u\n",__LINE__,(unsigned)storage_size); - } + if(storage_size>=(MISC8_DIM0*MISC8_DIM1*H5Tget_size(H5T_NATIVE_INT))) + TestErrPrintf("Error on line %d: data wasn't compressed! storage_size=%u\n",__LINE__,(unsigned)storage_size); #else - if(storage_size!=(MISC8_DIM0*MISC8_DIM1*H5Tget_size(H5T_NATIVE_INT))) { - num_errs++; - printf("Error on line %d: wrong storage size! storage_size=%u\n",__LINE__,(unsigned)storage_size); - } + if(storage_size!=(MISC8_DIM0*MISC8_DIM1*H5Tget_size(H5T_NATIVE_INT))) + TestErrPrintf("Error on line %d: wrong storage size! storage_size=%u\n",__LINE__,(unsigned)storage_size); #endif /*H5_HAVE_FILTER_DEFLATE*/ /* Close dataset ID */ @@ -1978,15 +1948,11 @@ test_misc12(void) CHECK(ret, FAIL, "H5Dread"); for(i=0; i=0) { - num_errs++; - printf("%d: string comparison incorrect!\n",__LINE__); - } /* end if */ + if(cmp>=0) + TestErrPrintf("%d: string comparison incorrect!\n",__LINE__); /* Check the lengths of the strings also */ len=H5RS_len(rs1); @@ -270,10 +268,8 @@ test_refstr_wrap(void) CHECK(s, NULL, "H5RS_get_str"); CHECK(s, buf, "wrapping"); cmp=HDstrcmp(s,buf); - if(cmp<=0) { - num_errs++; - printf("%d: string comparison incorrect!\n",__LINE__); - } /* end if */ + if(cmp<=0) + TestErrPrintf("%d: string comparison incorrect!\n",__LINE__); /* Decrement reference count for string */ ret=H5RS_decr(rs); diff --git a/test/tselect.c b/test/tselect.c index 0d42dbb..228002c 100644 --- a/test/tselect.c +++ b/test/tselect.c @@ -858,8 +858,8 @@ test_select_combo(void) MESSAGE(5, ("Testing Combination of Hyperslab & Element Selection Functions\n")); /* Allocate write & read buffers */ - wbuf=malloc(sizeof(uint8_t)*SPACE2_DIM1*SPACE2_DIM2); - rbuf=calloc(sizeof(uint8_t),SPACE3_DIM1*SPACE3_DIM2); + wbuf=HDmalloc(sizeof(uint8_t)*SPACE2_DIM1*SPACE2_DIM2); + rbuf=HDcalloc(sizeof(uint8_t),SPACE3_DIM1*SPACE3_DIM2); /* Initialize write buffer */ for(i=0, tbuf=wbuf; i=start[2] && k<(int)(start[2]+count[2])) && (l>=start[3] && l<(int)(start[3]+count[3])) ) { if(*tbuf!=*tbuf2) { - num_errs++; printf("Error: hyperslab values don't match!\n"); - printf("Line: %d, i=%d, j=%d, k=%d, l=%d, *tbuf=%u,*tbuf2=%u\n",__LINE__,i,j,k,l,(unsigned)*tbuf,(unsigned)*tbuf2); + TestErrPrintf("Line: %d, i=%d, j=%d, k=%d, l=%d, *tbuf=%u,*tbuf2=%u\n",__LINE__,i,j,k,l,(unsigned)*tbuf,(unsigned)*tbuf2); } /* end if */ } /* end if */ else { if(*tbuf2!=0) { - num_errs++; printf("Error: invalid data in read buffer!\n"); - printf("Line: %d, i=%d, j=%d, k=%d, l=%d, *tbuf=%u,*tbuf2=%u\n",__LINE__,i,j,k,l,(unsigned)*tbuf,(unsigned)*tbuf2); + TestErrPrintf("Line: %d, i=%d, j=%d, k=%d, l=%d, *tbuf=%u,*tbuf2=%u\n",__LINE__,i,j,k,l,(unsigned)*tbuf,(unsigned)*tbuf2); } /* end if */ } /* end else */ @@ -1508,8 +1501,8 @@ test_select_hyper_contig3(hid_t dset_type, hid_t xfer_plist) CHECK(ret, FAIL, "H5Fclose"); /* Free memory buffers */ - free(wbuf); - free(rbuf); + HDfree(wbuf); + HDfree(rbuf); } /* test_select_hyper_contig3() */ /**************************************************************** @@ -1542,9 +1535,9 @@ test_select_hyper_copy(void) MESSAGE(5, ("Testing Hyperslabs with Strides Functionality\n")); /* Allocate write & read buffers */ - wbuf=malloc(sizeof(uint16_t)*SPACE2_DIM1*SPACE2_DIM2); - rbuf=calloc(sizeof(uint16_t),SPACE3_DIM1*SPACE3_DIM2); - rbuf2=calloc(sizeof(uint16_t),SPACE3_DIM1*SPACE3_DIM2); + wbuf=HDmalloc(sizeof(uint16_t)*SPACE2_DIM1*SPACE2_DIM2); + rbuf=HDcalloc(sizeof(uint16_t),SPACE3_DIM1*SPACE3_DIM2); + rbuf2=HDcalloc(sizeof(uint16_t),SPACE3_DIM1*SPACE3_DIM2); /* Initialize write buffer */ for(i=0, tbuf=wbuf; i=10 && i<=14) && (j>=5 && j<=14)) || ((i>=5 && i<=9) && (j>=10 && j<=14))) { if(*tbuf!=*tbuf2) - printf("%d: hyperslab values don't match!, i=%d, j=%d, *tbuf=%d, *tbuf2=%d\n",__LINE__,i,j,(int)*tbuf,(int)*tbuf2); + TestErrPrintf("%d: hyperslab values don't match!, i=%d, j=%d, *tbuf=%d, *tbuf2=%d\n",__LINE__,i,j,(int)*tbuf,(int)*tbuf2); tbuf2++; } /* end if */ else { if(*tbuf!=0) - printf("%d: hyperslab element has wrong value!, i=%d, j=%d, *tbuf=%d\n",__LINE__,i,j,(int)*tbuf); + TestErrPrintf("%d: hyperslab element has wrong value!, i=%d, j=%d, *tbuf=%d\n",__LINE__,i,j,(int)*tbuf); } /* end else */ } /* end for */ @@ -3678,8 +3649,8 @@ test_select_hyper_nota_2d(void) CHECK(ret, FAIL, "H5Fclose"); /* Free memory buffers */ - free(wbuf); - free(rbuf); + HDfree(wbuf); + HDfree(rbuf); } /* test_select_hyper_nota_2d() */ /**************************************************************** @@ -3695,8 +3666,7 @@ test_select_hyper_iter2(void *_elem, hid_t UNUSED type_id, hsize_t ndim, hssize_ unsigned u; /* Local counting variable */ if(*tbuf!=**tbuf2) { - num_errs++; - printf("Error in hyperslab iteration!\n"); + TestErrPrintf("Error in hyperslab iteration!\n"); printf("location: { "); for(u=0; u<(unsigned)ndim; u++) { printf("%2d",(int)point[u]); @@ -3743,8 +3713,8 @@ test_select_hyper_union_random_5d(hid_t read_plist) MESSAGE(5, ("Testing Hyperslab Selection Functions with random unions of 5-D hyperslabs\n")); /* Allocate write & read buffers */ - wbuf=malloc(sizeof(int)*SPACE5_DIM1*SPACE5_DIM2*SPACE5_DIM3*SPACE5_DIM4*SPACE5_DIM5); - rbuf=calloc(sizeof(int),SPACE5_DIM1*SPACE5_DIM2*SPACE5_DIM3*SPACE5_DIM4*SPACE5_DIM5); + wbuf=HDmalloc(sizeof(int)*SPACE5_DIM1*SPACE5_DIM2*SPACE5_DIM3*SPACE5_DIM4*SPACE5_DIM5); + rbuf=HDcalloc(sizeof(int),SPACE5_DIM1*SPACE5_DIM2*SPACE5_DIM3*SPACE5_DIM4*SPACE5_DIM5); /* Initialize write buffer */ for(i=0, tbuf=wbuf; i=(int)(start[0]+real_offset[0]) && i<(int)(start[0]+count[0]+real_offset[0])) && (j>=(int)(start[1]+real_offset[1]) && j<(int)(start[1]+count[1]+real_offset[1]))) { - if(*tbuf!=(unsigned short)fill_value) { - num_errs++; - printf("Error! j=%d, i=%d, *tbuf=%u, fill_value=%u\n",j,i,(unsigned)*tbuf,(unsigned)fill_value); - } /* end if */ + if(*tbuf!=(unsigned short)fill_value) + TestErrPrintf("Error! j=%d, i=%d, *tbuf=%u, fill_value=%u\n",j,i,(unsigned)*tbuf,(unsigned)fill_value); } /* end if */ else { - if(*tbuf!=((unsigned short)(i*SPACE7_DIM2)+j)) { - num_errs++; - printf("Error! j=%d, i=%d, *tbuf=%u, should be: %u\n",j,i,(unsigned)*tbuf,(unsigned)((i*SPACE7_DIM2)+j)); - } /* end if */ + if(*tbuf!=((unsigned short)(i*SPACE7_DIM2)+j)) + TestErrPrintf("Error! j=%d, i=%d, *tbuf=%u, should be: %u\n",j,i,(unsigned)*tbuf,(unsigned)((i*SPACE7_DIM2)+j)); } /* end else */ } /* end for */ @@ -5158,7 +5115,7 @@ test_select_fill_hyper_simple(hssize_t *offset) CHECK(ret, FAIL, "H5Sclose"); /* Free memory buffers */ - free(wbuf); + HDfree(wbuf); } /* test_select_fill_hyper_simple() */ /**************************************************************** @@ -5195,7 +5152,7 @@ test_select_fill_hyper_regular(hssize_t *offset) MESSAGE(5, ("Testing Filling Regular 'hyperslab' Selections\n")); /* Allocate memory buffer */ - wbuf=malloc(sizeof(unsigned short)*SPACE7_DIM1*SPACE7_DIM2); + wbuf=HDmalloc(sizeof(unsigned short)*SPACE7_DIM1*SPACE7_DIM2); /* Initialize memory buffer */ for(i=0, tbuf=wbuf; i=((2*SPACE10_CHUNK_SIZE)/3)) { - if(wbuf[i+j]!=rbuf[((SPACE10_DIM1-i)-SPACE10_CHUNK_SIZE)+j]) { - printf("Line: %d - Error! i=%d, j=%d, rbuf=%d, wbuf=%d\n",__LINE__,i,j,rbuf[((SPACE10_DIM1-i)-SPACE10_CHUNK_SIZE)+j],wbuf[i+j]); - num_errs++; - } /* end if */ - } /* end if */ - } /* end for */ - } /* end for */ + if(j<(SPACE10_CHUNK_SIZE/3) || j>=((2*SPACE10_CHUNK_SIZE)/3)) + if(wbuf[i+j]!=rbuf[((SPACE10_DIM1-i)-SPACE10_CHUNK_SIZE)+j]) + TestErrPrintf("Line: %d - Error! i=%d, j=%d, rbuf=%d, wbuf=%d\n",__LINE__,i,j,rbuf[((SPACE10_DIM1-i)-SPACE10_CHUNK_SIZE)+j],wbuf[i+j]); /* Close the memory dataspace */ ret=H5Sclose (msid); diff --git a/test/ttbbt.c b/test/ttbbt.c index dba49aa..b8c00f2 100644 --- a/test/ttbbt.c +++ b/test/ttbbt.c @@ -12,8 +12,6 @@ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* $Id$ */ - /* FILE tbbt.c @@ -100,7 +98,7 @@ test_tbbt(void) swap_arr(rem_arr, i, t); } /* end for */ - if (Verbosity > 9) + if (GetTestVerbosity() > 9) { printf("ins_arr: \n"); for (i = 0; i < test_size; i++) /* print the arrays */ @@ -117,12 +115,12 @@ test_tbbt(void) MESSAGE(9, ("inserting %d\n", (int) ins_arr[i])); H5TB_dins(tree, (void *) &ins_arr[i], NULL); #ifdef H5TB_DEBUG - if(Verbosity>9) + if(GetTestVerbosity()>9) H5TB_dump(tree, -1); #endif /* H5TB_DEBUG */ } #ifdef H5TB_DEBUG - if(Verbosity>9) + if(GetTestVerbosity()>9) H5TB_dump(tree, -1); #endif /* H5TB_DEBUG */ for (i = 0; i < test_size; i++) @@ -134,7 +132,7 @@ test_tbbt(void) MESSAGE(9, ("removing %d\n", (int) key)); H5TB_rem((H5TB_NODE **) tree, (H5TB_NODE *) r, NULL); #ifdef H5TB_DEBUG - if(Verbosity>9) + if(GetTestVerbosity()>9) H5TB_dump(tree, -1); #endif /* H5TB_DEBUG */ } /* end for */ diff --git a/test/ttime.c b/test/ttime.c index 98a0e0f..5f9b5e7 100644 --- a/test/ttime.c +++ b/test/ttime.c @@ -12,8 +12,6 @@ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* $Id$ */ - /*********************************************************** * * Test program: ttime @@ -85,10 +83,8 @@ test_time_commit(void) tid = H5Topen(file_id, "Committed D32LE type"); CHECK(tid, FAIL, "H5Topen"); - if(!H5Tequal(tid, H5T_UNIX_D32LE)) { - num_errs++; - MESSAGE(0, ("H5T_UNIX_D32LE datatype not found")); - } /* end if */ + if(!H5Tequal(tid, H5T_UNIX_D32LE)) + TestErrPrintf("H5T_UNIX_D32LE datatype not found\n"); status = H5Tclose (tid); CHECK(status, FAIL, "H5Tclose"); @@ -96,10 +92,8 @@ test_time_commit(void) tid = H5Topen(file_id, "Committed D32BE type"); CHECK(tid, FAIL, "H5Topen"); - if(!H5Tequal(tid, H5T_UNIX_D32BE)) { - num_errs++; - MESSAGE(0, ("H5T_UNIX_D32BE datatype not found")); - } /* end if */ + if(!H5Tequal(tid, H5T_UNIX_D32BE)) + TestErrPrintf("H5T_UNIX_D32BE datatype not found\n"); status = H5Tclose (tid); CHECK(status, FAIL, "H5Tclose"); @@ -107,10 +101,8 @@ test_time_commit(void) tid = H5Topen(file_id, "Committed D64LE type"); CHECK(tid, FAIL, "H5Topen"); - if(!H5Tequal(tid, H5T_UNIX_D64LE)) { - num_errs++; - MESSAGE(0, ("H5T_UNIX_D64LE datatype not found")); - } /* end if */ + if(!H5Tequal(tid, H5T_UNIX_D64LE)) + TestErrPrintf("H5T_UNIX_D64LE datatype not found"); status = H5Tclose (tid); CHECK(status, FAIL, "H5Tclose"); @@ -118,10 +110,8 @@ test_time_commit(void) tid = H5Topen(file_id, "Committed D64BE type"); CHECK(tid, FAIL, "H5Topen"); - if(!H5Tequal(tid, H5T_UNIX_D64BE)) { - num_errs++; - MESSAGE(0, ("H5T_UNIX_D64BE datatype not found")); - } /* end if */ + if(!H5Tequal(tid, H5T_UNIX_D64BE)) + TestErrPrintf("H5T_UNIX_D64BE datatype not found"); status = H5Tclose (tid); CHECK(status, FAIL, "H5Tclose"); diff --git a/test/ttsafe.c b/test/ttsafe.c index afc84e6..041ceb0 100644 --- a/test/ttsafe.c +++ b/test/ttsafe.c @@ -31,17 +31,11 @@ * BUGS/LIMITATIONS * * EXPORTED ROUTINES/VARIABLES: - * Two variables are exported: num_errs, and Verbosity. + * */ -#if defined __MWERKS__ -#include -#endif - #include "h5test.h" -#define HDF5_TEST_MASTER - /* ANY new test needs to have a prototype in ttsafe.h */ #include "ttsafe.h" @@ -119,6 +113,6 @@ int main(int argc, char *argv[]) if (CleanUp && !getenv("HDF5_NOCLEANUP")) TestCleanup(); - return num_errs; + return GetTestNumErrs(); } /* end main() */ #endif /*H5_HAVE_THREADSAFE*/ diff --git a/test/ttsafe_acreate.c b/test/ttsafe_acreate.c index ac981b0..7a4635b 100644 --- a/test/ttsafe_acreate.c +++ b/test/ttsafe_acreate.c @@ -41,7 +41,7 @@ * * 19 May 2000, Bill Wendling * Changed so that it creates its own HDF5 file and removes it at cleanup - * time. Added num_errs flag. + * time. * ********************************************************************/ @@ -67,88 +67,80 @@ typedef struct acreate_data_struct { void tts_acreate(void) { - /* Pthread declarations */ - pthread_t threads[NUM_THREADS]; - - /* HDF5 data declarations */ - hid_t file, dataset; - hid_t dataspace, datatype; - hid_t attribute; - hsize_t dimsf[1]; /* dataset dimensions */ - - /* data declarations */ - int data; /* data to write */ - int buffer, ret, i; - - ttsafe_name_data_t *attrib_data; - - /* - * Create an HDF5 file using H5F_ACC_TRUNC access, default file - * creation plist and default file access plist - */ - file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - - /* create a simple dataspace for the dataset */ - dimsf[0] = 1; - dataspace = H5Screate_simple(1, dimsf, NULL); - - /* define datatype for the data using native little endian integers */ - datatype = H5Tcopy(H5T_NATIVE_INT); - H5Tset_order(datatype, H5T_ORDER_LE); - - /* create a new dataset within the file */ - dataset = H5Dcreate(file, DATASETNAME, datatype, dataspace, - H5P_DEFAULT); - - /* initialize data for dataset and write value to dataset */ - data = NUM_THREADS; - H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, &data); - - /* - * Simultaneously create a large number of attributes to be associated - * with the dataset - */ - for (i = 0; i < NUM_THREADS; i++) { - attrib_data = malloc(sizeof(ttsafe_name_data_t)); - attrib_data->dataset = dataset; - attrib_data->datatype = datatype; - attrib_data->dataspace = dataspace; - attrib_data->current_index = i; - pthread_create(&threads[i], NULL, tts_acreate_thread, - attrib_data); - } - - for (i = 0; i < NUM_THREADS; i++) - pthread_join(threads[i], NULL); - - /* verify the correctness of the test */ - for (i = 0; i < NUM_THREADS; i++) { - attribute = H5Aopen_name(dataset,gen_name(i)); - - if (attribute < 0) { - fprintf(stderr, - "unable to open appropriate attribute. " - "Test failed!\n"); - num_errs++; - } else { - ret = H5Aread(attribute, H5T_NATIVE_INT, &buffer); - - if (ret < 0 || buffer != i) { - fprintf(stderr, - "wrong data values. Test failed!\n"); - num_errs++; - } - - H5Aclose(attribute); - } - } - - /* close remaining resources */ - H5Sclose(dataspace); - H5Tclose(datatype); - H5Dclose(dataset); - H5Fclose(file); + /* Pthread declarations */ + pthread_t threads[NUM_THREADS]; + + /* HDF5 data declarations */ + hid_t file, dataset; + hid_t dataspace, datatype; + hid_t attribute; + hsize_t dimsf[1]; /* dataset dimensions */ + + /* data declarations */ + int data; /* data to write */ + int buffer, ret, i; + + ttsafe_name_data_t *attrib_data; + + /* + * Create an HDF5 file using H5F_ACC_TRUNC access, default file + * creation plist and default file access plist + */ + file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + + /* create a simple dataspace for the dataset */ + dimsf[0] = 1; + dataspace = H5Screate_simple(1, dimsf, NULL); + + /* define datatype for the data using native little endian integers */ + datatype = H5Tcopy(H5T_NATIVE_INT); + H5Tset_order(datatype, H5T_ORDER_LE); + + /* create a new dataset within the file */ + dataset = H5Dcreate(file, DATASETNAME, datatype, dataspace, H5P_DEFAULT); + + /* initialize data for dataset and write value to dataset */ + data = NUM_THREADS; + H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, + H5P_DEFAULT, &data); + + /* + * Simultaneously create a large number of attributes to be associated + * with the dataset + */ + for (i = 0; i < NUM_THREADS; i++) { + attrib_data = malloc(sizeof(ttsafe_name_data_t)); + attrib_data->dataset = dataset; + attrib_data->datatype = datatype; + attrib_data->dataspace = dataspace; + attrib_data->current_index = i; + pthread_create(&threads[i], NULL, tts_acreate_thread, attrib_data); + } + + for (i = 0; i < NUM_THREADS; i++) + pthread_join(threads[i], NULL); + + /* verify the correctness of the test */ + for (i = 0; i < NUM_THREADS; i++) { + attribute = H5Aopen_name(dataset,gen_name(i)); + + if (attribute < 0) + TestErrPrintf("unable to open appropriate attribute. Test failed!\n"); + else { + ret = H5Aread(attribute, H5T_NATIVE_INT, &buffer); + + if (ret < 0 || buffer != i) + TestErrPrintf("wrong data values. Test failed!\n"); + + H5Aclose(attribute); + } + } + + /* close remaining resources */ + H5Sclose(dataspace); + H5Tclose(datatype); + H5Dclose(dataset); + H5Fclose(file); } void *tts_acreate_thread(void *client_data) diff --git a/test/ttsafe_cancel.c b/test/ttsafe_cancel.c index 4247f07..30e9bfb 100644 --- a/test/ttsafe_cancel.c +++ b/test/ttsafe_cancel.c @@ -40,7 +40,7 @@ * * 19 May 2000, Bill Wendling * Changed so that it creates its own HDF5 file and removes it at cleanup - * time. Added num_errs flag. + * time. * ********************************************************************/ #include "ttsafe.h" @@ -68,117 +68,104 @@ pthread_cond_t cond; void tts_cancel(void) { - pthread_attr_t attribute; - hid_t dataset; - int buffer; + pthread_attr_t attribute; + hid_t dataset; + int buffer; - /* make thread scheduling global */ - pthread_attr_init(&attribute); + /* make thread scheduling global */ + pthread_attr_init(&attribute); #ifdef H5_HAVE_SYSTEM_SCOPE_THREADS - pthread_attr_setscope(&attribute, PTHREAD_SCOPE_SYSTEM); + pthread_attr_setscope(&attribute, PTHREAD_SCOPE_SYSTEM); #endif /* H5_HAVE_SYSTEM_SCOPE_THREADS */ - /* - * Create a hdf5 file using H5F_ACC_TRUNC access, default file - * creation plist and default file access plist - */ - cancel_file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - pthread_create(&childthread, &attribute, tts_cancel_thread, NULL); - tts_cancel_barrier(); - pthread_cancel(childthread); - - dataset = H5Dopen(cancel_file, DATASETNAME); - H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, - &buffer); - - if (buffer != 11) { - fprintf(stderr, - "operation unsuccessful with value at %d instead of 11\n", - buffer); - num_errs++; - } - - H5Dclose(dataset); - H5Fclose(cancel_file); - - /* Destroy the thread attribute */ - pthread_attr_destroy(&attribute); + /* + * Create a hdf5 file using H5F_ACC_TRUNC access, default file + * creation plist and default file access plist + */ + cancel_file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + pthread_create(&childthread, &attribute, tts_cancel_thread, NULL); + tts_cancel_barrier(); + pthread_cancel(childthread); + + dataset = H5Dopen(cancel_file, DATASETNAME); + H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &buffer); + + if (buffer != 11) + TestErrPrintf("operation unsuccessful with value at %d instead of 11\n", buffer); + + H5Dclose(dataset); + H5Fclose(cancel_file); + + /* Destroy the thread attribute */ + pthread_attr_destroy(&attribute); } void *tts_cancel_thread(void UNUSED *arg) { - int datavalue; - int *buffer; - hid_t dataspace, datatype, dataset; - hsize_t dimsf[1]; /* dataset dimensions */ - cancel_cleanup_t *cleanup_structure; - - /* define dataspace for dataset */ - dimsf[0] = 1; - dataspace = H5Screate_simple(1,dimsf,NULL); - - /* define datatype for the data using native little endian integers */ - datatype = H5Tcopy(H5T_NATIVE_INT); - H5Tset_order(datatype, H5T_ORDER_LE); - - /* create a new dataset within the file */ - dataset = H5Dcreate(cancel_file, DATASETNAME, datatype, dataspace, - H5P_DEFAULT); - - /* If thread is cancelled, make cleanup call */ - cleanup_structure = (cancel_cleanup_t*)malloc(sizeof(cancel_cleanup_t)); - cleanup_structure->dataset = dataset; - cleanup_structure->datatype = datatype; - cleanup_structure->dataspace = dataspace; - pthread_cleanup_push(cancellation_cleanup, cleanup_structure); - - datavalue = 1; - H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, - &datavalue); - - buffer = malloc(sizeof(int)); - H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, - buffer); - H5Diterate(buffer, H5T_NATIVE_INT, dataspace, tts_cancel_callback, - &dataset); - - sleep(3); - - datavalue = 100; - H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, - &datavalue); - H5Dclose(dataset); - H5Tclose(datatype); - H5Sclose(dataspace); - - /* - * Required by pthreads. The argument 0 pops the stack but does not - * execute the cleanup routine. - */ - pthread_cleanup_pop(0); - return NULL; + int datavalue; + int *buffer; + hid_t dataspace, datatype, dataset; + hsize_t dimsf[1]; /* dataset dimensions */ + cancel_cleanup_t *cleanup_structure; + + /* define dataspace for dataset */ + dimsf[0] = 1; + dataspace = H5Screate_simple(1,dimsf,NULL); + + /* define datatype for the data using native little endian integers */ + datatype = H5Tcopy(H5T_NATIVE_INT); + H5Tset_order(datatype, H5T_ORDER_LE); + + /* create a new dataset within the file */ + dataset = H5Dcreate(cancel_file, DATASETNAME, datatype, dataspace, H5P_DEFAULT); + + /* If thread is cancelled, make cleanup call */ + cleanup_structure = (cancel_cleanup_t*)malloc(sizeof(cancel_cleanup_t)); + cleanup_structure->dataset = dataset; + cleanup_structure->datatype = datatype; + cleanup_structure->dataspace = dataspace; + pthread_cleanup_push(cancellation_cleanup, cleanup_structure); + + datavalue = 1; + H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &datavalue); + + buffer = malloc(sizeof(int)); + H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buffer); + H5Diterate(buffer, H5T_NATIVE_INT, dataspace, tts_cancel_callback, &dataset); + + sleep(3); + + datavalue = 100; + H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &datavalue); + H5Dclose(dataset); + H5Tclose(datatype); + H5Sclose(dataspace); + + /* + * Required by pthreads. The argument 0 pops the stack but does not + * execute the cleanup routine. + */ + pthread_cleanup_pop(0); + return NULL; } herr_t tts_cancel_callback(void *elem, hid_t UNUSED type_id, hsize_t UNUSED ndim, hssize_t UNUSED *point, void *operator_data) { - int value = *(int *)elem; - hid_t dataset = *(hid_t *)operator_data; - - tts_cancel_barrier(); - sleep(3); - - if (value != 1) { - fprintf(stderr, "Error! Element value should be 1 and not %d\n", - value); - num_errs++; - return -1; - } - - value += 10; - H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, - &value); - return 0; + int value = *(int *)elem; + hid_t dataset = *(hid_t *)operator_data; + + tts_cancel_barrier(); + sleep(3); + + if (value != 1) { + TestErrPrintf("Error! Element value should be 1 and not %d\n", value); + return -1; + } + + value += 10; + H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &value); + return 0; } /* @@ -187,13 +174,13 @@ herr_t tts_cancel_callback(void *elem, hid_t UNUSED type_id, hsize_t UNUSED ndim */ void cancellation_cleanup(void *arg) { - cancel_cleanup_t *cleanup_structure = (cancel_cleanup_t *)arg; - H5Dclose(cleanup_structure->dataset); - H5Tclose(cleanup_structure->datatype); - H5Sclose(cleanup_structure->dataspace); + cancel_cleanup_t *cleanup_structure = (cancel_cleanup_t *)arg; + H5Dclose(cleanup_structure->dataset); + H5Tclose(cleanup_structure->datatype); + H5Sclose(cleanup_structure->dataspace); - /* retained for debugging */ - /* print_func("cancellation noted, cleaning up ... \n"); */ + /* retained for debugging */ + /* print_func("cancellation noted, cleaning up ... \n"); */ } /* @@ -202,18 +189,18 @@ void cancellation_cleanup(void *arg) */ void tts_cancel_barrier(void) { - static int count = 2; + static int count = 2; - pthread_mutex_lock(&mutex); + pthread_mutex_lock(&mutex); - if (count != 1) { - count--; - pthread_cond_wait(&cond, &mutex); - } else { - pthread_cond_signal(&cond); - } + if (count != 1) { + count--; + pthread_cond_wait(&cond, &mutex); + } else { + pthread_cond_signal(&cond); + } - pthread_mutex_unlock(&mutex); + pthread_mutex_unlock(&mutex); } void cleanup_cancel(void) diff --git a/test/ttsafe_dcreate.c b/test/ttsafe_dcreate.c index b351994..22796a8 100644 --- a/test/ttsafe_dcreate.c +++ b/test/ttsafe_dcreate.c @@ -36,7 +36,7 @@ * * 19 May 2000, Bill Wendling * Changed so that it creates its own HDF5 file and removes it at cleanup - * time. Added num_errs flag. + * time. * ********************************************************************/ #include "ttsafe.h" @@ -129,20 +129,18 @@ void tts_dcreate(void) for (i = 0; i < NUM_THREAD; i++) { if ((dataset = H5Dopen(file,dsetname[i])) < 0) { - fprintf(stderr, "Dataset name not found - test failed\n"); + TestErrPrintf("Dataset name not found - test failed\n"); H5Fclose(file); - num_errs++; return; } else { ret=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &datavalue); assert(ret>=0); if (datavalue != i) { - fprintf(stderr, "Wrong value read %d for dataset name %s - test failed\n", + TestErrPrintf(stderr, "Wrong value read %d for dataset name %s - test failed\n", datavalue, dsetname[i]); H5Dclose(dataset); H5Fclose(file); - num_errs++; return; } diff --git a/test/ttsafe_error.c b/test/ttsafe_error.c index 2cf5a92..8f35a84 100644 --- a/test/ttsafe_error.c +++ b/test/ttsafe_error.c @@ -39,8 +39,7 @@ * * 19 May 2000, Bill Wendling * Modified so that it creates a unique HDF5 file and removes it on - * cleanup. Also added the num_errs flag and increment it when necessary - * to report the errors. + * cleanup. * ********************************************************************/ #include "ttsafe.h" @@ -131,23 +130,17 @@ void tts_error(void) for (i = 0; i < NUM_THREAD; i++) pthread_join(threads[i],NULL); - if (error_flag) { - fprintf(stderr, "Threads reporting different error values!\n"); - num_errs++; - } + if (error_flag) + TestErrPrintf("Threads reporting different error values!\n"); - if (error_count != NUM_THREAD - 1) { - fprintf(stderr, "Error: %d threads failed instead of %d\n", error_count, NUM_THREAD-1); - num_errs++; - } + if (error_count != NUM_THREAD - 1) + TestErrPrintf("Error: %d threads failed instead of %d\n", error_count, NUM_THREAD-1); dataset = H5Dopen(error_file, DATASETNAME); H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &value); - if (value != WRITE_NUMBER) { - fprintf(stderr, "Error: Successful thread wrote value %d instead of %d\n", value, WRITE_NUMBER); - num_errs++; - } + if (value != WRITE_NUMBER) + TestErrPrintf("Error: Successful thread wrote value %d instead of %d\n", value, WRITE_NUMBER); H5Dclose(dataset); H5Fclose(error_file); diff --git a/test/ttst.c b/test/ttst.c index 9632cb7..10eb017 100644 --- a/test/ttst.c +++ b/test/ttst.c @@ -208,18 +208,14 @@ test_tst_insert(void) found=H5ST_find(tree,uniq_words[u]); CHECK(found, NULL, "H5ST_find"); - if(HDstrcmp((const char *)found->eqkid,uniq_words[u])) { - num_errs++; - printf("%d: TST node values don't match!, found->eqkid=%s, uniq_words[%u]=%s\n",__LINE__,(char *)found->eqkid,(unsigned)u,uniq_words[u]); - } /* end if */ + if(HDstrcmp((const char *)found->eqkid,uniq_words[u])) + TestErrPrintf("%d: TST node values don't match!, found->eqkid=%s, uniq_words[%u]=%s\n",__LINE__,(char *)found->eqkid,(unsigned)u,uniq_words[u]); obj=H5ST_locate(tree,uniq_words[u]); CHECK(obj, NULL, "H5ST_locate"); - if(HDstrcmp((const char *)obj,uniq_words[u])) { - num_errs++; - printf("%d: TST objects don't match!, obj=%s, uniq_words[%u]=%s\n",__LINE__,(char *)obj,(unsigned)u,uniq_words[u]); - } /* end if */ + if(HDstrcmp((const char *)obj,uniq_words[u])) + TestErrPrintf("%d: TST objects don't match!, obj=%s, uniq_words[%u]=%s\n",__LINE__,(char *)obj,(unsigned)u,uniq_words[u]); } /* end for */ /* Verify that words not in the TST aren't found */ @@ -268,10 +264,8 @@ test_tst_iterate(void) u=0; do { /* Check that the strings in the TST are in the correct order */ - if(HDstrcmp((const char *)found->eqkid,sort_uniq_words[u])) { - num_errs++; - printf("%d: TST node values don't match!, found->eqkid=%s, sort_uniq_words[%u]=%s\n",__LINE__,(char *)found->eqkid,(unsigned)u,sort_uniq_words[u]); - } /* end if */ + if(HDstrcmp((const char *)found->eqkid,sort_uniq_words[u])) + TestErrPrintf("%d: TST node values don't match!, found->eqkid=%s, sort_uniq_words[%u]=%s\n",__LINE__,(char *)found->eqkid,(unsigned)u,sort_uniq_words[u]); /* Advance to next string in TST */ found=H5ST_findnext(found); @@ -318,10 +312,8 @@ test_tst_remove(void) CHECK(obj, NULL, "H5ST_remove"); /* Check that the correct string was removed from TST */ - if(HDstrcmp((const char *)obj,rand_uniq_words[u])) { - num_errs++; - printf("%d: TST node values don't match!, obj=%s, rand_uniq_words[%u]=%s\n",__LINE__,(char *)obj,(unsigned)u,rand_uniq_words[u]); - } /* end if */ + if(HDstrcmp((const char *)obj,rand_uniq_words[u])) + TestErrPrintf("%d: TST node values don't match!, obj=%s, rand_uniq_words[%u]=%s\n",__LINE__,(char *)obj,(unsigned)u,rand_uniq_words[u]); /* Check that the string can't be found in the TST any longer */ check=H5ST_search(tree,rand_uniq_words[u]); @@ -341,10 +333,8 @@ test_tst_remove(void) CHECK(found, NULL, "H5ST_find"); /* Check that the correct object will be removed from TST */ - if(HDstrcmp((const char *)found->eqkid,rand_uniq_words[u])) { - num_errs++; - printf("%d: TST node values don't match!, found->eqkid=%s, rand_uniq_words[%u]=%s\n",__LINE__,(char *)found->eqkid,(unsigned)u,rand_uniq_words[u]); - } /* end if */ + if(HDstrcmp((const char *)found->eqkid,rand_uniq_words[u])) + TestErrPrintf("%d: TST node values don't match!, found->eqkid=%s, rand_uniq_words[%u]=%s\n",__LINE__,(char *)found->eqkid,(unsigned)u,rand_uniq_words[u]); /* Remove the node */ ret=H5ST_delete(tree,found); diff --git a/test/tvlstr.c b/test/tvlstr.c index ef35267..2031865 100644 --- a/test/tvlstr.c +++ b/test/tvlstr.c @@ -12,8 +12,6 @@ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* $Id$ */ - /*********************************************************** * * Test program: tvlstr @@ -191,7 +189,7 @@ test_vlstrings_basic(void) /* Count the actual number of bytes used by the strings */ for(i=0,str_used=0; ilen!=t2->len) { - num_errs++; - printf("%d: VL data length don't match!, i=%d, j=%d, t1->len=%d, t2->len=%d\n",__LINE__,(int)i,(int)j,(int)t1->len,(int)t2->len); + TestErrPrintf("%d: VL data length don't match!, i=%d, j=%d, t1->len=%d, t2->len=%d\n",__LINE__,(int)i,(int)j,(int)t1->len,(int)t2->len); continue; } /* end if */ for(k=0; klen; k++) { if( ((unsigned int *)t1->p)[k] != ((unsigned int *)t2->p)[k] ) { - num_errs++; - printf("VL data values don't match!, t1->p[%d]=%d, t2->p[%d]=%d\n",(int)k, (int)((unsigned int *)t1->p)[k], (int)k, (int)((unsigned int *)t2->p)[k]); + TestErrPrintf("VL data values don't match!, t1->p[%d]=%d, t2->p[%d]=%d\n",(int)k, (int)((unsigned int *)t1->p)[k], (int)k, (int)((unsigned int *)t2->p)[k]); continue; } /* end if */ } /* end for */ @@ -1208,24 +1173,20 @@ test_vltypes_compound_vlen_atomic(void) /* Compare data read in */ for(i=0; ip=HDmalloc((j+1)*sizeof(unsigned int)); if(t1->p==NULL) { - printf("Cannot allocate memory for VL data! i=%u, j=%u\n",i,j); - num_errs++; + TestErrPrintf("Cannot allocate memory for VL data! i=%u, j=%u\n",i,j); return; } /* end if */ t1->len=j+1; @@ -1656,20 +1604,17 @@ test_vltypes_vlen_vlen_atomic(void) /* Compare data read in */ for(i=0; ilen!=t2->len) { - num_errs++; - printf("%d: VL data length don't match!, i=%d, j=%d, t1->len=%d, t2->len=%d\n",__LINE__,(int)i,(int)j,(int)t1->len,(int)t2->len); + TestErrPrintf("%d: VL data length don't match!, i=%d, j=%d, t1->len=%d, t2->len=%d\n",__LINE__,(int)i,(int)j,(int)t1->len,(int)t2->len); continue; } /* end if */ for(k=0; klen; k++) { if( ((unsigned int *)t1->p)[k] != ((unsigned int *)t2->p)[k] ) { - num_errs++; - printf("VL data values don't match!, t1->p[%d]=%d, t2->p[%d]=%d\n",(int)k, (int)((unsigned int *)t1->p)[k], (int)k, (int)((unsigned int *)t2->p)[k]); + TestErrPrintf("VL data values don't match!, t1->p[%d]=%d, t2->p[%d]=%d\n",(int)k, (int)((unsigned int *)t1->p)[k], (int)k, (int)((unsigned int *)t2->p)[k]); continue; } /* end if */ } /* end for */ @@ -1743,16 +1688,14 @@ rewrite_longer_vltypes_vlen_vlen_atomic(void) for(i=0; ip=HDmalloc((j+1)*sizeof(unsigned int)); if(t1->p==NULL) { - printf("Cannot allocate memory for VL data! i=%u, j=%u\n",i,j); - num_errs++; + TestErrPrintf("Cannot allocate memory for VL data! i=%u, j=%u\n",i,j); return; } /* end if */ t1->len=j+1; @@ -1841,20 +1784,18 @@ rewrite_longer_vltypes_vlen_vlen_atomic(void) /* Compare data read in */ for(i=0; ilen!=t2->len) { - num_errs++; - printf("%d: VL data length don't match!, i=%d, j=%d, t1->len=%d, t2->len=%d\n",__LINE__,(int)i,(int)j,(int)t1->len,(int)t2->len); + TestErrPrintf("%d: VL data length don't match!, i=%d, j=%d, t1->len=%d, t2->len=%d\n",__LINE__,(int)i,(int)j,(int)t1->len,(int)t2->len); continue; } /* end if */ for(k=0; klen; k++) { - if( ((unsigned int *)t1->p)[k] != ((unsigned int *)t2->p)[k] ) { num_errs++; - printf("VL data values don't match!, t1->p[%d]=%d, t2->p[%d]=%d\n",(int)k, (int)((unsigned int *)t1->p)[k], (int)k, (int)((unsigned int *)t2->p)[k]); + if( ((unsigned int *)t1->p)[k] != ((unsigned int *)t2->p)[k] ) { + TestErrPrintf("VL data values don't match!, t1->p[%d]=%d, t2->p[%d]=%d\n",(int)k, (int)((unsigned int *)t1->p)[k], (int)k, (int)((unsigned int *)t2->p)[k]); continue; } /* end if */ } /* end for */ @@ -1924,16 +1865,14 @@ rewrite_shorter_vltypes_vlen_vlen_atomic(void) for(i=0; ip=HDmalloc((j+1)*sizeof(unsigned int)); if(t1->p==NULL) { - printf("Cannot allocate memory for VL data! i=%u, j=%u\n",i,j); - num_errs++; + TestErrPrintf("Cannot allocate memory for VL data! i=%u, j=%u\n",i,j); return; } /* end if */ t1->len=j+1; @@ -2022,20 +1961,17 @@ rewrite_shorter_vltypes_vlen_vlen_atomic(void) /* Compare data read in */ for(i=0; ilen!=t2->len) { - num_errs++; - printf("%d: VL data length don't match!, i=%d, j=%d, t1->len=%d, t2->len=%d\n",__LINE__,(int)i,(int)j,(int)t1->len,(int)t2->len); + TestErrPrintf("%d: VL data length don't match!, i=%d, j=%d, t1->len=%d, t2->len=%d\n",__LINE__,(int)i,(int)j,(int)t1->len,(int)t2->len); continue; } /* end if */ for(k=0; klen; k++) { if( ((unsigned int *)t1->p)[k] != ((unsigned int *)t2->p)[k] ) { - num_errs++; - printf("VL data values don't match!, t1->p[%d]=%d, t2->p[%d]=%d\n",(int)k, (int)((unsigned int *)t1->p)[k], (int)k, (int)((unsigned int *)t2->p)[k]); + TestErrPrintf("VL data values don't match!, t1->p[%d]=%d, t2->p[%d]=%d\n",(int)k, (int)((unsigned int *)t1->p)[k], (int)k, (int)((unsigned int *)t2->p)[k]); continue; } /* end if */ } /* end for */ -- cgit v0.12