diff options
author | Bill Wendling <wendling@ncsa.uiuc.edu> | 2001-03-05 23:09:59 (GMT) |
---|---|---|
committer | Bill Wendling <wendling@ncsa.uiuc.edu> | 2001-03-05 23:09:59 (GMT) |
commit | e99887cc669f3dccba8a4869a21b8cc1a8e3a3b6 (patch) | |
tree | 0c34fb56c41bf3aded23edea449ee97c23b5341d /c++/test | |
parent | 659945ecb58ad2ad3d7e6c5bc988cba146cba85d (diff) | |
download | hdf5-e99887cc669f3dccba8a4869a21b8cc1a8e3a3b6.zip hdf5-e99887cc669f3dccba8a4869a21b8cc1a8e3a3b6.tar.gz hdf5-e99887cc669f3dccba8a4869a21b8cc1a8e3a3b6.tar.bz2 |
[svn-r3549] Purpose:
Adding Test
Description:
- Add the tests to the Makefile so that they'll be executed.
- Fixed a few bugs in dsets.cpp
* Some buffers should have been char *'s instead of void *'s.
* An iterator for a loop wasn't declared properly.
- Formatting changes
Solution:
- Changed the void *'s to char *'s.
- Declared the loop iterator.
NOTE: Doesn't work just yet. There's a conflict with a C++ keyword
(delete) in the H5Pprivate.h header file. Quincey's looking into
this.
Platforms tested:
Linux
Diffstat (limited to 'c++/test')
-rw-r--r-- | c++/test/Makefile.in | 26 | ||||
-rw-r--r-- | c++/test/dsets.cpp | 29 | ||||
-rw-r--r-- | c++/test/testhdf5.cpp | 123 | ||||
-rw-r--r-- | c++/test/tfile.cpp | 109 |
4 files changed, 147 insertions, 140 deletions
diff --git a/c++/test/Makefile.in b/c++/test/Makefile.in index 50eac99..0eda5be 100644 --- a/c++/test/Makefile.in +++ b/c++/test/Makefile.in @@ -14,26 +14,36 @@ hdf5_builddir=$(top_builddir)/src ## Add include directory to the C preprocessor flags and the h5test and hdf5 ## libraries to the library list. +CPPFLAGS=-I. -I../src -I$(srcdir)/../src -I$(top_srcdir)/test -I$(hdf5_builddir) -I$(hdf5_srcdir) @CPPFLAGS@ + +## These are our main targets. They should be listed in the order to be +## executed, generally most specific tests to least specific tests. +RUNTEST=$(LT_RUN) + +## Add include directory to the C preprocessor flags and the h5test and hdf5 +## libraries to the library list. LT_LINK_LIB=$(LT) --mode=link $(CXX) -rpath $(libdir) LIB=../src/libhdf5_cpp.la -CPPFLAGS=-I. -I../src -I$(srcdir)/../src -I$(hdf5_builddir) -I$(hdf5_srcdir) @CPPFLAGS@ -HDF5LIB=$(hdf5_builddir)/libhdf5.la +LIBHDF5=$(hdf5_builddir)/libhdf5.la ## These are our main targets. They should be listed in the order to be ## executed, generally most specific tests to least specific tests. RUNTEST=$(LT_RUN) -TEST_PROGS_SRC= -TEST_PROGS= - -TEST_SRC= +TEST_SRC=dsets.cpp testhdf5.cpp tfile.cpp TEST_OBJ=$(TEST_SRC:.cpp=.lo) +TEST_PROGS=$(TEST_SRC:.cpp=) TEST_SCRIPTS= DISTCLEAN=$(TEST_PROGS_SRC:.cpp=.lo) $(TEST_PROGS_SRC:.cpp=.o) *.h5 -$(TEST_PROGS): $(LIB) - @echo No C++ test as of yet. +$(TEST_PROGS): $(LIB) $(LIBHDF5) + +testhdf5: $(TEST_OBJ) + @$(LT_LINK_EXE) $(CFLAGS) -o $@ $(TESTHDF5_OBJ) $(LIB) $(LIBHDF5) $(LDFLAGS) $(LIBS) + +dsets: dsets.lo + @$(LT_LINK_EXE) $(CFLAGS) -o $@ dsets.lo $(hdf5_builddir)/../test/h5test.lo $(LIB) $(LIBHDF5) $(LDFLAGS) $(LIBS) @CONCLUDE@ diff --git a/c++/test/dsets.cpp b/c++/test/dsets.cpp index df5be42..38357b7 100644 --- a/c++/test/dsets.cpp +++ b/c++/test/dsets.cpp @@ -18,9 +18,9 @@ * *************************************************************/ -#include <h5test.h> -#include <testhdf5.h> -#include <H5Cpp.h> +#include "h5test.h" +#include "testhdf5.h" +#include "H5Cpp.h" #ifndef H5_NO_NAMESPACE using namespace H5; @@ -92,7 +92,7 @@ test_create( H5File& file) dataset = new DataSet (file.createDataSet (DSET_DEFAULT_NAME, PredType::NATIVE_DOUBLE, space)); // continuation here, that means no exception has been thrown - FAILED(); + H5_FAILED(); cout << " Library allowed overwrite of existing dataset." << endl; goto error; } @@ -115,7 +115,7 @@ test_create( H5File& file) try { dataset = new DataSet (file.openDataSet( "does_not_exist" )); // continuation here, that means no exception has been thrown - FAILED(); + H5_FAILED(); cout << " Opened a non-existent dataset." << endl; goto error; } @@ -182,7 +182,7 @@ check_values (hsize_t i, hsize_t j, int apoint, int acheck) { if (apoint != acheck) { - FAILED(); + H5_FAILED(); cout << " Read different values than written.\n" << endl; cout << " At index " << (unsigned long)i << "," << (unsigned long)j << endl; @@ -227,7 +227,7 @@ test_simple_io( H5File& file) } } - void* tconv_buf = new char [1000]; + char* tconv_buf = new char [1000]; try { /* Create the data space */ @@ -327,13 +327,13 @@ test_tconv( H5File& file) dataset.read ((void*) in, PredType::STD_I32BE); /* Check */ - for (i = 0; i < 1000000; i++) { + for (int i = 0; i < 1000000; i++) { if (in[4*i+0]!=out[4*i+3] || in[4*i+1]!=out[4*i+2] || in[4*i+2]!=out[4*i+1] || in[4*i+3]!=out[4*i+0]) { - FAILED(); + H5_FAILED(); cout << " Read with byte order conversion failed." << endl; goto error; } @@ -423,7 +423,7 @@ test_compression(H5File& file) points[i][j] = n++; } } - void* tconv_buf = new char [1000]; + char* tconv_buf = new char [1000]; try { @@ -468,7 +468,7 @@ test_compression(H5File& file) for (i=0; i<size[0]; i++) { for (j=0; j<size[1]; j++) { if (0!=check[i][j]) { - FAILED(); + H5_FAILED(); cout << " Read a non-zero value." << endl; cout << " At index " << (unsigned long)i << "," << (unsigned long)j << endl; @@ -622,7 +622,7 @@ test_compression(H5File& file) for (j=0; j<hs_size[1]; j++) { if (points[hs_offset[0]+i][hs_offset[1]+j] != check[hs_offset[0]+i][hs_offset[1]+j]) { - FAILED(); + H5_FAILED(); cout << " Read different values than written.\n" << endl; cout << " At index " << (unsigned long)(hs_offset[0]+i) << "," << (unsigned long)(hs_offset[1]+j) << endl; @@ -751,7 +751,7 @@ test_multiopen (H5File& file) space->getSimpleExtentDims (tmp_size); if (cur_size[0]!=tmp_size[0]) { - FAILED(); + H5_FAILED(); cout << " Got " << (int)tmp_size[0] << " instead of " << (int)cur_size[0] << "!" << endl; delete space; @@ -981,8 +981,8 @@ main(void) fapl_id = h5_fileaccess(); // in h5test.c, returns a file access template // should create an object from this id - BMR -/* BMR: leave paralell stuff out! #if 0 +/* BMR: leave paralell stuff out! */ { // Turn off raw data cache int mdc_nelmts; @@ -990,7 +990,6 @@ main(void) (H5Pset_cache(fapl_id, mdc_nelmts, 0, 0, 0.0)<0) goto error; } #endif -*/ char filename[1024]; h5_fixname(FILENAME[0], fapl_id, filename, sizeof filename); diff --git a/c++/test/testhdf5.cpp b/c++/test/testhdf5.cpp index 28d6a54..6b3a64e 100644 --- a/c++/test/testhdf5.cpp +++ b/c++/test/testhdf5.cpp @@ -1,18 +1,12 @@ -/**************************************************************************** - * NCSA HDF * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * * - * For conditions of distribution and use, see the accompanying * - * hdf/COPYING file. * - * * - ****************************************************************************/ +/* + * Copyright (C) 2001 National Center for Supercomputing Applications + * All rights reserved. + * + */ /* FILE - testhdf5.c - HDF5 testing framework main file. + testhdf5.cpp - HDF5 testing framework main file. REMARKS General test wrapper for HDF5 base library test programs @@ -33,9 +27,9 @@ */ -#if defined __MWERKS__ +#ifdef __MWERKS__ #include <console.h> -#endif +#endif /* __MWERKS__ */ #include <stdarg.h> @@ -43,19 +37,19 @@ #define HDF5_TEST_MASTER /* Internal Variables */ -static int Index = 0; +static int Index = 0; /* Global variables */ -int num_errs = 0; -int Verbosity; +int num_errs = 0; +int Verbosity; // Use C version of the header file testhdf5.h instead of re-coding it -#include <testhdf5.h> -#include <H5Cpp.h> +#include "testhdf5.h" +#include "H5Cpp.h" #ifndef H5_NO_NAMESPACE using namespace H5; -#endif +#endif /* !H5_NO_NAMESPACE */ struct TestStruct { int NumErrors; @@ -66,16 +60,16 @@ struct TestStruct { void (*Cleanup) (void); } Test[MAXNUMOFTESTS]; -static void InitTest(const char *TheName, void (*TheCall) (void), void (*Cleanup) (void), const char *TheDescr); -static void usage(void); +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) +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); - } /* end if */ + } + HDstrcpy(Test[Index].Description, TheDescr); HDstrcpy(Test[Index].Name, TheName); Test[Index].Call = TheCall; @@ -88,8 +82,6 @@ InitTest(const char *TheName, void (*TheCall) (void), void (*Cleanup) (void), co static void usage(void) { - intn i; - 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"); @@ -111,10 +103,12 @@ usage(void) print_func("This program currently tests the following: \n\n"); print_func("%16s %s\n", "Name", "Description"); print_func("%16s %s\n", "----", "-----------"); - for (i = 0; i < Index; i++) + + for (int i = 0; i < Index; i++) print_func("%16s %s\n", Test[i].Name, Test[i].Description); + print_func("\n\n"); -} /* end usage() */ +} /* * This routine is designed to provide equivalent functionality to 'printf' @@ -124,37 +118,38 @@ usage(void) int print_func(const char *format,...) { - va_list arglist; - int ret_value; + va_list arglist; + int ret_value; va_start(arglist, format); ret_value = vprintf(format, arglist); va_end(arglist); - return (ret_value); + return ret_value; } void test_tbbt(void) -{ } +{ +} int main(int argc, char *argv[]) { - int CLLoop; /* Command Line Loop */ - int Loop, Loop1; - int Summary = 0; - int CleanUp = 1; - int Cache = 1; + int CLLoop; /* Command Line Loop */ + int Loop, Loop1; + int Summary = 0; + int CleanUp = 1; + int Cache = 1; -#if defined __MWERKS__ +#ifdef __MWERKS__ argc = ccommand(&argv); -#endif +#endif /* __MWERKS__ */ #if !(defined MAC || defined __MWERKS__ || defined SYMANTEC_C) /* Un-buffer the stdout and stderr */ setbuf(stderr, NULL); setbuf(stdout, NULL); -#endif +#endif /* !(MAC || __MWERKS__ || SYMANTEC_C) */ /* * Turn off automatic error reporting since we do it ourselves. Besides, @@ -184,13 +179,14 @@ main(int argc, char *argv[]) //InitTest("array", test_array, cleanup_array, "Array Datatypes"); //InitTest("genprop", test_genprop, cleanup_genprop, "Generic Properties"); - Verbosity = 4; /* Default Verbosity is Low */ + Verbosity = 4; /* Default Verbosity is Low */ uintn 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))) { @@ -202,7 +198,8 @@ main(int argc, char *argv[]) Verbosity = 10; else Verbosity = atoi(argv[CLLoop + 1]); - } /* end if */ + } + if ((argc > CLLoop) && ((HDstrcmp(argv[CLLoop], "-summary") == 0) || (HDstrcmp(argv[CLLoop], "-s") == 0))) Summary = 1; @@ -212,6 +209,7 @@ main(int argc, char *argv[]) usage(); exit(0); } + if ((argc > CLLoop) && ((HDstrcmp(argv[CLLoop], "-cleanoff") == 0) || (HDstrcmp(argv[CLLoop], "-c") == 0))) CleanUp = 0; @@ -225,26 +223,32 @@ main(int argc, char *argv[]) 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++; - } /* end while */ - } /* end if */ + } + } + 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; - } /* end for */ + } + Loop++; - } /* end while */ - } /* end if */ + } + } + if ((argc > CLLoop + 1) && ((HDstrcmp(argv[CLLoop], "-only") == 0) || (HDstrcmp(argv[CLLoop], "-o") == 0))) { for (Loop = 0; Loop < Index; Loop++) @@ -255,9 +259,9 @@ main(int argc, char *argv[]) if (HDstrcmp(argv[Loop], Test[Loop1].Name) == 0) Test[Loop1].SkipFlag = 0; Loop++; - } /* end while */ - } /* end if */ - } /* end for */ + } + } + } #ifdef NOT_YET if (Cache) /* turn on caching, unless we were instucted not to */ @@ -276,11 +280,12 @@ main(int argc, char *argv[]) Test[Loop].NumErrors = num_errs - Test[Loop].NumErrors; MESSAGE(5, ("===============================================\n")); MESSAGE(5, ("There were %d errors detected.\n\n", (int) Test[Loop].NumErrors)); - } /* end else */ - } /* end for */ + } + } MESSAGE(2, ("\n\n")) - if (num_errs) + + if (num_errs) print_func("!!! %d Error(s) were detected !!!\n\n", (int) num_errs); else print_func("All tests were successful. \n\n"); @@ -296,9 +301,11 @@ main(int argc, char *argv[]) else print_func("%16s %6d %s\n", Test[Loop].Name, (int) Test[Loop].NumErrors, Test[Loop].Description); - } /* end for */ + } + print_func("\n\n"); - } /* end if */ + } + if (CleanUp && !getenv("HDF5_NOCLEANUP")) { MESSAGE(2, ("\nCleaning Up temp files...\n\n")); @@ -307,6 +314,6 @@ main(int argc, char *argv[]) if (!Test[Loop].SkipFlag && Test[Loop].Cleanup!=NULL) (*Test[Loop].Cleanup) (); } - return (num_errs); -} /* end main() */ + return num_errs; +} diff --git a/c++/test/tfile.cpp b/c++/test/tfile.cpp index f359eb7..4acacc0 100644 --- a/c++/test/tfile.cpp +++ b/c++/test/tfile.cpp @@ -1,54 +1,46 @@ -/**************************************************************************** - * NCSA HDF * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * * - * For conditions of distribution and use, see the accompanying * - * hdf/COPYING file. * - * * - ****************************************************************************/ - -/*********************************************************** -* -* Test program: tfile -* -* Test the low-level file I/O features. -* -*************************************************************/ - -#include <testhdf5.h> -#include <H5Cpp.h> +/* + * Copyright (C) 2001 National Center for Supercomputing Applications + * All rights reserved. + * + */ + +/* + * Test program: tfile + * + * Test the low-level file I/O features. + */ + +#include "H5private.h" +#include "H5Bprivate.h" +#include "H5Pprivate.h" + +#include "testhdf5.h" +#include "H5Cpp.h" #ifndef H5_NO_NAMESPACE using namespace H5; -#endif - -#include <H5private.h> -#include <H5Bprivate.h> -#include <H5Pprivate.h> - -#define F1_USERBLOCK_SIZE (hsize_t)0 -#define F1_OFFSET_SIZE sizeof(haddr_t) -#define F1_LENGTH_SIZE sizeof(hsize_t) -#define F1_SYM_LEAF_K 4 -#define F1_SYM_INTERN_K 16 -#define FILE1 "tfile1.h5" - -#define F2_USERBLOCK_SIZE (hsize_t)512 -#define F2_OFFSET_SIZE 8 -#define F2_LENGTH_SIZE 8 -#define F2_SYM_LEAF_K 8 -#define F2_SYM_INTERN_K 32 -#define FILE2 "tfile2.h5" - -#define F3_USERBLOCK_SIZE (hsize_t)0 -#define F3_OFFSET_SIZE F2_OFFSET_SIZE -#define F3_LENGTH_SIZE F2_LENGTH_SIZE -#define F3_SYM_LEAF_K F2_SYM_LEAF_K -#define F3_SYM_INTERN_K F2_SYM_INTERN_K -#define FILE3 "tfile3.h5" +#endif /* !H5_NO_NAMESPACE */ + +#define F1_USERBLOCK_SIZE (hsize_t)0 +#define F1_OFFSET_SIZE sizeof(haddr_t) +#define F1_LENGTH_SIZE sizeof(hsize_t) +#define F1_SYM_LEAF_K 4 +#define F1_SYM_INTERN_K 16 +#define FILE1 "tfile1.h5" + +#define F2_USERBLOCK_SIZE (hsize_t)512 +#define F2_OFFSET_SIZE 8 +#define F2_LENGTH_SIZE 8 +#define F2_SYM_LEAF_K 8 +#define F2_SYM_INTERN_K 32 +#define FILE2 "tfile2.h5" + +#define F3_USERBLOCK_SIZE (hsize_t)0 +#define F3_OFFSET_SIZE F2_OFFSET_SIZE +#define F3_LENGTH_SIZE F2_LENGTH_SIZE +#define F3_SYM_LEAF_K F2_SYM_LEAF_K +#define F3_SYM_INTERN_K F2_SYM_INTERN_K +#define FILE3 "tfile3.h5" /*------------------------------------------------------------------------- @@ -68,9 +60,9 @@ using namespace H5; static void test_file_create(void) { - hid_t tmpl1, tmpl2; /*file creation templates */ - int iparm, iparm2; - herr_t ret; /*generic return value */ + hid_t tmpl1, tmpl2; /*file creation templates */ + int iparm, iparm2; + herr_t ret; /*generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Low-Level File Creation I/O\n")); @@ -227,7 +219,7 @@ test_file_create(void) catch( FileIException error ) { CHECK(-1, FAIL, error.getCDetailMesg()); } -} /* test_file_create() */ +} /* test_file_create() */ /*------------------------------------------------------------------------- @@ -280,7 +272,7 @@ test_file_open(void) catch( PropListIException error ) { CHECK(FAIL, FAIL, error.getCDetailMesg()); } -} /* test_file_open() */ +} /* test_file_open() */ /*------------------------------------------------------------------------- @@ -291,7 +283,7 @@ test_file_open(void) * Return: None * * Programmer: Binh-Minh Ribler - * January, 2001 + * January 2001 * * Modifications: * @@ -305,7 +297,7 @@ test_file(void) test_file_create(); /* Test file creation (also creation templates) */ test_file_open(); /* Test file opening */ -} /* test_file() */ +} /* test_file() */ /*------------------------------------------------------------------------- @@ -315,8 +307,8 @@ test_file(void) * * Return: none * - * Programmer: Albert Cheng - * July 2, 1998 + * Programmer: Binh-Minh Ribler + * January 2001 * * Modifications: * @@ -328,5 +320,4 @@ cleanup_file(void) remove(FILE1); remove(FILE2); remove(FILE3); -} - +} /* cleanup_file */ |