summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/Makefile50
-rw-r--r--test/testhdf5.c302
-rw-r--r--test/testhdf5.h115
-rw-r--r--test/tfile.c288
-rw-r--r--test/theap.c87
-rw-r--r--test/tmeta.c120
6 files changed, 962 insertions, 0 deletions
diff --git a/test/Makefile b/test/Makefile
new file mode 100644
index 0000000..ec8bcf5
--- /dev/null
+++ b/test/Makefile
@@ -0,0 +1,50 @@
+### Name of target
+TARGET = testhdf5
+
+#
+# PART 2: various choices
+#
+
+### -DDEBUG Debugging options on
+DEFS = -I../src
+
+################################################
+## no changes required below this line ##
+################################################
+
+INCL = ../src/hdf5.h testhdf5.h
+
+OBJ = testhdf5.o tmeta.o tfile.o theap.o
+
+LIBS = ../src/libhdf5.a
+
+$(TARGET): $(OBJ) $(LIBS)
+ $(CC) -o $(TARGET) $(OBJ) $(LIBS)
+
+all: $(TARGET)
+
+test: $(TARGET)
+ ./$(TARGET)
+
+debug: $(OBJ)
+ purify $(CC) -o $(TARGET) $(OBJ) $(LIBS)
+
+clean:
+ -rm -f *.o core *.core $(TARGET)
+ -rm -f *.bak *.h5
+
+###########################################################################
+
+testhdf5.o: testhdf5.c $(INCL)
+ $(CC) $(CFLAGS) $(DEFS) testhdf5.c
+
+tmeta.o: tmeta.c $(INCL)
+ $(CC) $(CFLAGS) $(DEFS) tmeta.c
+
+tfile.o: tfile.c $(INCL)
+ $(CC) $(CFLAGS) $(DEFS) tfile.c
+
+theap.o: theap.c $(INCL)
+ $(CC) $(CFLAGS) $(DEFS) theap.c
+
+
diff --git a/test/testhdf5.c b/test/testhdf5.c
new file mode 100644
index 0000000..60959fa
--- /dev/null
+++ b/test/testhdf5.c
@@ -0,0 +1,302 @@
+/****************************************************************************
+ * 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. *
+ * *
+ ****************************************************************************/
+
+#ifdef RCSID
+static char RcsId[] = "@(#)$Revision$";
+#endif
+
+/* $Id$ */
+
+/*
+ FILE
+ testhdf5.c - HDF5 testing framework main file.
+
+ REMARKS
+ General test wrapper for HDF5 base library test programs
+
+ DESIGN
+ Each test function should be implemented as function having no
+ parameters and returning void (i.e. no return value). They should be put
+ into the list of InitTest() calls in main() below. Functions which depend
+ on other functionality should be placed below the InitTest() call for the
+ base functionality testing.
+ Each test module should include testhdf5.h and define a unique set of
+ names for test files they create.
+
+ BUGS/LIMITATIONS
+
+ EXPORTED ROUTINES/VARIABLES:
+ Two variables are exported: num_errs, and Verbosity.
+
+ */
+
+#if defined __MWERKS__
+#include <console.h>
+#endif
+
+#define MAXNUMOFTESTS 30
+#define HDF5_TEST_MASTER
+
+/* Internal Variables */
+static int Index = 0;
+
+/* ANY new test needs to have a prototype in tproto.h */
+#include "testhdf5.h"
+
+struct TestStruct
+ {
+ int NumErrors;
+ char Description[64];
+ int SkipFlag;
+ char Name[16];
+ VOID (*Call) (void);
+ }
+ Test[MAXNUMOFTESTS];
+
+static void InitTest(const char *TheName, VOID(*TheCall) (void), const char *TheDescr);
+static void usage(void);
+
+static void InitTest(const char *TheName, VOID(*TheCall) (void), const char *TheDescr)
+{
+ if (Index >= MAXNUMOFTESTS)
+ {
+ print_func("Uh-oh, too many tests added, increase MAXNUMOFTEST!\n");
+ exit(0);
+ } /* end if */
+ HDstrcpy(Test[Index].Description, TheDescr);
+ HDstrcpy(Test[Index].Name, TheName);
+ Test[Index].Call = TheCall;
+ Test[Index].NumErrors = -1;
+ Test[Index].SkipFlag = 0;
+ Index++;
+}
+
+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");
+ 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 (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'
+ * 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;
+ uintn major, minor, release, patch;
+
+#if defined __MWERKS__
+ argc = ccommand(&argv);
+#endif
+
+#if !(defined MAC || defined __MWERKS__ || defined SYMANTEC_C)
+ /* Un-buffer the stdout and stderr */
+ setbuf(stderr, NULL);
+ setbuf(stdout, NULL);
+#endif
+
+ /* Tests are generally arranged from least to most complexity... */
+ InitTest("metadata", test_metadata, "Encode/decode metadata code");
+ InitTest("file", test_file, "Low-Level File I/O");
+ InitTest("heap", test_heap, "Object and Name Heaps");
+
+ Verbosity = 4; /* Default Verbosity is Low */
+ H5version(&major, &minor, &release, &patch);
+
+ print_func("\nFor help use: testhdf5 -help\n");
+ print_func("Built with HDF5 Library Version: %u.%ur%u, patch %u\n\n", (unsigned) major,
+ (unsigned) minor, (unsigned) release, (unsigned)patch);
+ 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]);
+ } /* end if */
+ 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;
+
+ 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++)
+ 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++;
+ } /* end while */
+ } /* end if */
+ } /* end for */
+
+#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, print_func("Skipping -- %s \n", Test[Loop].Description);
+ );
+ }
+ else
+ {
+ MESSAGE(2, print_func("Testing -- %s (%s) \n", Test[Loop].Description,
+ Test[Loop].Name);
+ );
+ MESSAGE(5, print_func("===============================================\n");
+ );
+ Test[Loop].NumErrors = num_errs;
+ (*Test[Loop].Call) ();
+ Test[Loop].NumErrors = num_errs - Test[Loop].NumErrors;
+ MESSAGE(5, print_func("===============================================\n");
+ );
+ MESSAGE(5, print_func("There were %d errors detected.\n\n", (int) Test[Loop].NumErrors);
+ );
+ } /* end else */
+ } /* end for */
+
+ MESSAGE(2, print_func("\n\n");
+ )
+ if (num_errs)
+ print_func("!!! %d Error(s) were detected !!!\n\n", (int) num_errs);
+ else
+ print_func("All tests were successful. \n\n");
+
+ if (Summary)
+ {
+ print_func("Summary of Test Results:\n");
+ print_func("Name of Test Errors Description of Test\n");
+ print_func("---------------- ------ --------------------------------------\n");
+
+ 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);
+ } /* end for */
+ print_func("\n\n");
+ } /* end if */
+
+ if (CleanUp)
+ {
+ MESSAGE(2, print_func("\nCleaning Up...\n\n");
+ );
+#if !(defined DOS386 | defined WIN386)
+ system("rm -f *.hdf *.tmp");
+#else /* OLD_WAY */
+ remove("*.hdf");
+ remove("*.tmp");
+#endif /* OLD_WAY */
+ } /* end if */
+ exit(0);
+ return (0);
+} /* end main() */
diff --git a/test/testhdf5.h b/test/testhdf5.h
new file mode 100644
index 0000000..1b482d2
--- /dev/null
+++ b/test/testhdf5.h
@@ -0,0 +1,115 @@
+/****************************************************************************
+ * 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. *
+ * *
+ ****************************************************************************/
+
+/* $Id$ */
+
+/*
+ * This header file contains information required for testing the HDF5 library.
+ */
+
+#ifndef HDF5TEST_H
+#define HDF5TEST_H
+
+/* Include required headers */
+#include "hdf5.h"
+#include <stdarg.h>
+
+/* Define these for use in all the tests */
+#ifndef HDF5_TEST_MASTER
+extern
+#endif
+int num_errs
+#ifdef HDF5_TEST_MASTER
+= 0
+#endif
+, Verbosity
+#ifdef HDF5_TEST_MASTER
+= 0
+#endif
+ ;
+
+/* Use %ld to print the value because long should cover most cases. */
+/* Used to make certain a return value _is_not_ a value */
+#define CHECK(ret, val, where) \
+do {if (Verbosity>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++;} \
+} while(0)
+
+#define CHECK_I(ret,where) { \
+ if (Verbosity>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", \
+ (where), (long)(ret), (int)__LINE__, __FILE__); \
+ num_errs++; \
+ } \
+ } \
+}
+
+#define CHECK_PTR(ret,where) { \
+ if (Verbosity>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",\
+ (where), (int)__LINE__, __FILE__); \
+ num_errs++; \
+ } \
+ } \
+}
+
+/* Used to make certain a return value _is_ a value */
+#define VERIFY(x, val, where) \
+do {if (Verbosity>9) print_func(" Call to routine: %15s at line %4d in %s had value %ld \n",where,(int)__LINE__,__FILE__,(long)x);\
+if(x != val) {print_func("*** UNEXPECTED VALUE from %s is %ld at line %4d in %s\n", where, (long)x,(int)__LINE__,__FILE__); num_errs++;} \
+} while(0)
+
+/* Used to document process through a test and to check for errors */
+#define RESULT(ret,func) \
+do { \
+if (Verbosity>8) print_func(" Call to routine: %15s at line %4d in %s returned %ld \n",func,(int)__LINE__,__FILE__,(long)ret); \
+if (Verbosity>9) HEprint(stdout,0); \
+if(ret == FAIL) {print_func("*** UNEXPECTED RETURN from %s is %ld at line %4d in %s\n", func, (long)ret,(int)__LINE__,__FILE__); num_errs++;} \
+} while(0)
+
+/* Used to document process through a test */
+#define MESSAGE(v,a) {if (Verbosity>v) {a}}
+
+/* definitions for command strings */
+#define VERBOSITY_STR "Verbosity"
+#define SKIP_STR "Skip"
+#define TEST_STR "Test"
+#define CLEAN_STR "Cleanup"
+
+/* System command to use for Cleanup */
+#ifdef VMS
+#define CLEAN_CMD "delete *.hdf;*"
+#else
+# ifdef WIN32
+# define CLEAN_CMD "del *.hdf"
+# else
+/* default is Unix */
+# define CLEAN_CMD "rm -f *.hdf"
+# endif /* WIN32 */
+#endif /*VMS */
+
+/* Prototypes for the support routines */
+int print_func(const char *, ...);
+
+/* Prototypes for the test routines */
+void test_metadata(void);
+void test_file(void);
+void test_heap (void);
+
+#endif /* HDF5TEST_H */
+
diff --git a/test/tfile.c b/test/tfile.c
new file mode 100644
index 0000000..81c8cd2
--- /dev/null
+++ b/test/tfile.c
@@ -0,0 +1,288 @@
+/****************************************************************************
+ * 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. *
+ * *
+ ****************************************************************************/
+
+#ifdef RCSID
+static char RcsId[] = "$Revision$";
+#endif
+
+/* $Id$ */
+
+/***********************************************************
+*
+* Test program: tfile
+*
+* Test the low-level file I/O features.
+*
+*************************************************************/
+
+#include "testhdf5.h"
+
+#define F1_USERBLOCK_SIZE HDF5_USERBLOCK_DEFAULT
+#define F1_OFFSET_SIZE HDF5_OFFSETSIZE_DEFAULT
+#define F1_LENGTH_SIZE HDF5_LENGTHSIZE_DEFAULT
+#define F1_BTREEPAGE_SIZE HDF5_BTREEPAGE_DEFAULT
+#define FILE1 "tfile1.h5"
+
+#define F2_USERBLOCK_SIZE 512
+#define F2_OFFSET_SIZE 8
+#define F2_LENGTH_SIZE 8
+#define F2_BTREEPAGE_SIZE 2048
+#define FILE2 "tfile2.h5"
+
+#define F3_USERBLOCK_SIZE HDF5_USERBLOCK_DEFAULT
+#define F3_OFFSET_SIZE F2_OFFSET_SIZE
+#define F3_LENGTH_SIZE F2_LENGTH_SIZE
+#define F3_BTREEPAGE_SIZE F2_BTREEPAGE_SIZE
+#define FILE3 "tfile3.h5"
+
+/****************************************************************
+**
+** test_file_create(): Low-level file creation I/O test routine.
+**
+****************************************************************/
+static void test_file_create(void)
+{
+ hatom_t fid1,fid2,fid3; /* HDF5 File IDs */
+ hatom_t tmpl1,tmpl2; /* File creation templates */
+ uintn parm; /* File-creation parameters */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, print_func("Testing Low-Level File Creation I/O\n"););
+
+ /* Create first file */
+ fid1=H5Fcreate(FILE1,H5ACC_OVERWRITE,0,0);
+ CHECK(fid1,FAIL,"H5Fcreate");
+
+ /* Try to create first file again (should fail) */
+ fid2=H5Fcreate(FILE1,H5ACC_OVERWRITE,0,0);
+ VERIFY(fid2,FAIL,"H5Fcreate");
+
+ /* Get the file-creation template */
+ tmpl1=H5Fget_create_template(fid1);
+ CHECK(tmpl1,FAIL,"H5Fget_create_template");
+
+ /* Get the file-creation parameters */
+ ret=H5Cgetparm(tmpl1,H5_USERBLOCK_SIZE,&parm);
+printf("USERBLOCK_SIZE=%u\n",parm);
+ CHECK(ret,FAIL,"H5Cgetparm");
+ VERIFY(parm,F1_USERBLOCK_SIZE,"H5Cgetparm");
+
+ ret=H5Cgetparm(tmpl1,H5_OFFSET_SIZE,&parm);
+printf("OFFSET_SIZE=%u\n",parm);
+ CHECK(ret,FAIL,"H5Cgetparm");
+ VERIFY(parm,F1_OFFSET_SIZE,"H5Cgetparm");
+
+ ret=H5Cgetparm(tmpl1,H5_LENGTH_SIZE,&parm);
+printf("LENGTH_SIZE=%u\n",parm);
+ CHECK(ret,FAIL,"H5Cgetparm");
+ VERIFY(parm,F1_LENGTH_SIZE,"H5Cgetparm");
+
+ ret=H5Cgetparm(tmpl1,H5_BTREE_SIZE,&parm);
+printf("BTREE_SIZE=%u\n",parm);
+ CHECK(ret,FAIL,"H5Cgetparm");
+ VERIFY(parm,F1_BTREEPAGE_SIZE,"H5Cgetparm");
+
+ /* Release file-creation template */
+ ret=H5Mrelease(tmpl1);
+ CHECK(ret,FAIL,"H5Mrelease");
+
+ /* Double-check that the atom has been vaporized */
+ ret=H5Mrelease(tmpl1);
+ VERIFY(ret,FAIL,"H5Mrelease");
+
+ /* Create a new file with a non-standard file-creation template */
+ tmpl1=H5Mcreate(fid1,H5_TEMPLATE,NULL);
+ CHECK(tmpl1,FAIL,"H5Mcreate");
+
+ /* Set the new file-creation parameters */
+ parm=F2_USERBLOCK_SIZE;
+ ret=H5Csetparm(tmpl1,H5_USERBLOCK_SIZE,&parm);
+ CHECK(ret,FAIL,"H5Csetparm");
+
+ parm=F2_OFFSET_SIZE;
+ ret=H5Csetparm(tmpl1,H5_OFFSET_SIZE,&parm);
+ CHECK(ret,FAIL,"H5Csetparm");
+
+ parm=F2_LENGTH_SIZE;
+ ret=H5Csetparm(tmpl1,H5_LENGTH_SIZE,&parm);
+ CHECK(ret,FAIL,"H5Csetparm");
+
+ parm=F2_BTREEPAGE_SIZE;
+ ret=H5Csetparm(tmpl1,H5_BTREE_SIZE,&parm);
+ CHECK(ret,FAIL,"H5Csetparm");
+
+ /* Try to create second file, with non-standard file-creation template params */
+ fid2=H5Fcreate(FILE2,H5ACC_OVERWRITE,tmpl1,0);
+ CHECK(fid2,FAIL,"H5Fcreate");
+
+ /* Release file-creation template */
+ ret=H5Mrelease(tmpl1);
+ CHECK(ret,FAIL,"H5Mrelease");
+
+ /* Get the file-creation template */
+ tmpl1=H5Fget_create_template(fid2);
+ CHECK(tmpl1,FAIL,"H5Fget_create_template");
+
+ /* Get the file-creation parameters */
+ ret=H5Cgetparm(tmpl1,H5_USERBLOCK_SIZE,&parm);
+printf("USERBLOCK_SIZE=%u\n",parm);
+ CHECK(ret,FAIL,"H5Cgetparm");
+ VERIFY(parm,F2_USERBLOCK_SIZE,"H5Cgetparm");
+
+ ret=H5Cgetparm(tmpl1,H5_OFFSET_SIZE,&parm);
+printf("OFFSET_SIZE=%u\n",parm);
+ CHECK(ret,FAIL,"H5Cgetparm");
+ VERIFY(parm,F2_LENGTH_SIZE,"H5Cgetparm");
+
+ ret=H5Cgetparm(tmpl1,H5_LENGTH_SIZE,&parm);
+printf("LENGTH_SIZE=%u\n",parm);
+ CHECK(ret,FAIL,"H5Cgetparm");
+ VERIFY(parm,F2_OFFSET_SIZE,"H5Cgetparm");
+
+ ret=H5Cgetparm(tmpl1,H5_BTREE_SIZE,&parm);
+printf("BTREE_SIZE=%u\n",parm);
+ CHECK(ret,FAIL,"H5Cgetparm");
+ VERIFY(parm,F2_BTREEPAGE_SIZE,"H5Cgetparm");
+
+ /* Clone the file-creation template */
+ tmpl2=H5Mcopy(tmpl1);
+ CHECK(tmpl2,FAIL,"H5Mcopy");
+
+ /* Release file-creation template */
+ ret=H5Mrelease(tmpl1);
+ CHECK(ret,FAIL,"H5Mrelease");
+
+ /* Set the new file-creation parameter */
+ parm=F3_USERBLOCK_SIZE;
+ ret=H5Csetparm(tmpl2,H5_USERBLOCK_SIZE,&parm);
+ CHECK(ret,FAIL,"H5Csetparm");
+
+ /* Try to create second file, with non-standard file-creation template params */
+ fid3=H5Fcreate(FILE3,H5ACC_OVERWRITE,tmpl2,0);
+ CHECK(fid3,FAIL,"H5Fcreate");
+
+ /* Release file-creation template */
+ ret=H5Mrelease(tmpl2);
+ CHECK(ret,FAIL,"H5Mrelease");
+
+ /* Get the file-creation template */
+ tmpl1=H5Fget_create_template(fid3);
+ CHECK(tmpl1,FAIL,"H5Fget_create_template");
+
+ /* Get the file-creation parameters */
+ ret=H5Cgetparm(tmpl1,H5_USERBLOCK_SIZE,&parm);
+printf("USERBLOCK_SIZE=%u\n",parm);
+ CHECK(ret,FAIL,"H5Cgetparm");
+ VERIFY(parm,F3_USERBLOCK_SIZE,"H5Cgetparm");
+
+ ret=H5Cgetparm(tmpl1,H5_OFFSET_SIZE,&parm);
+printf("OFFSET_SIZE=%u\n",parm);
+ CHECK(ret,FAIL,"H5Cgetparm");
+ VERIFY(parm,F3_LENGTH_SIZE,"H5Cgetparm");
+
+ ret=H5Cgetparm(tmpl1,H5_LENGTH_SIZE,&parm);
+printf("LENGTH_SIZE=%u\n",parm);
+ CHECK(ret,FAIL,"H5Cgetparm");
+ VERIFY(parm,F3_OFFSET_SIZE,"H5Cgetparm");
+
+ ret=H5Cgetparm(tmpl1,H5_BTREE_SIZE,&parm);
+printf("BTREE_SIZE=%u\n",parm);
+ CHECK(ret,FAIL,"H5Cgetparm");
+ VERIFY(parm,F3_BTREEPAGE_SIZE,"H5Cgetparm");
+
+ /* Release file-creation template */
+ ret=H5Mrelease(tmpl1);
+ CHECK(ret,FAIL,"H5Mrelease");
+
+ /* Close first file */
+ ret=H5Fclose(fid1);
+ CHECK(ret,FAIL,"H5Fclose");
+
+ /* Close second file */
+ ret=H5Fclose(fid2);
+ CHECK(ret,FAIL,"H5Fclose");
+
+ /* Close third file */
+ ret=H5Fclose(fid3);
+ CHECK(ret,FAIL,"H5Fclose");
+} /* test_file_create() */
+
+
+/****************************************************************
+**
+** test_file_open(): Low-level file open I/O test routine.
+**
+****************************************************************/
+static void test_file_open(void)
+{
+ hatom_t fid1,fid2,fid3; /* HDF5 File IDs */
+ hatom_t tmpl1,tmpl2; /* File creation templates */
+ uintn parm; /* File-creation parameters */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, print_func("Testing Low-Level File Opening I/O\n"););
+
+ /* Open second file */
+ fid1=H5Fopen(FILE2,H5ACC_WRITE,0);
+ CHECK(fid1,FAIL,"H5Fooen");
+
+ /* Get the file-creation template */
+ tmpl1=H5Fget_create_template(fid1);
+ CHECK(tmpl1,FAIL,"H5Fget_create_template");
+
+ /* Get the file-creation parameters */
+ ret=H5Cgetparm(tmpl1,H5_USERBLOCK_SIZE,&parm);
+printf("USERBLOCK_SIZE=%u\n",parm);
+ CHECK(ret,FAIL,"H5Cgetparm");
+ VERIFY(parm,F2_USERBLOCK_SIZE,"H5Cgetparm");
+
+ ret=H5Cgetparm(tmpl1,H5_OFFSET_SIZE,&parm);
+printf("OFFSET_SIZE=%u\n",parm);
+ CHECK(ret,FAIL,"H5Cgetparm");
+ VERIFY(parm,F2_OFFSET_SIZE,"H5Cgetparm");
+
+ ret=H5Cgetparm(tmpl1,H5_LENGTH_SIZE,&parm);
+printf("LENGTH_SIZE=%u\n",parm);
+ CHECK(ret,FAIL,"H5Cgetparm");
+ VERIFY(parm,F2_LENGTH_SIZE,"H5Cgetparm");
+
+ ret=H5Cgetparm(tmpl1,H5_BTREE_SIZE,&parm);
+printf("BTREE_SIZE=%u\n",parm);
+ CHECK(ret,FAIL,"H5Cgetparm");
+ VERIFY(parm,F2_BTREEPAGE_SIZE,"H5Cgetparm");
+
+ /* Release file-creation template */
+ ret=H5Mrelease(tmpl1);
+ CHECK(ret,FAIL,"H5Mrelease");
+
+ /* Close first file */
+ ret=H5Fclose(fid1);
+ CHECK(ret,FAIL,"H5Fclose");
+} /* test_file_open() */
+
+
+/****************************************************************
+**
+** test_file(): Main low-level file I/O test routine.
+**
+****************************************************************/
+void test_file(void)
+{
+ /* Output message about test being performed */
+ MESSAGE(5, print_func("Testing Low-Level File I/O\n"););
+
+ test_file_create(); /* Test file creation (also creation templates) */
+ test_file_open(); /* Test file opening */
+} /* test_file() */
+
diff --git a/test/theap.c b/test/theap.c
new file mode 100644
index 0000000..41a9cbc
--- /dev/null
+++ b/test/theap.c
@@ -0,0 +1,87 @@
+/*-------------------------------------------------------------------------
+ * Copyright (C) 1997 National Center for Supercomputing Applications.
+ * All rights reserved.
+ *
+ *-------------------------------------------------------------------------
+ *
+ * Created: theap.c
+ * Jul 17 1997
+ * Robb Matzke <robb@maya.nuance.com>
+ *
+ * Purpose:
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+#include "testhdf5.h"
+
+#include "H5ACprivate.h"
+#include "H5Fprivate.h"
+#include "H5Hprivate.h"
+
+#define NOBJS 40
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_heap
+ *
+ * Purpose: Test name and object heaps.
+ *
+ * Return: void
+ *
+ * Programmer: Robb Matzke
+ * robb@maya.nuance.com
+ * Jul 17 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+void
+test_heap (void)
+{
+ int i, j;
+ hatom_t fid;
+ hdf5_file_t *f;
+ off_t heap;
+ char buf[NOBJS+8];
+ const char *s;
+ off_t obj[NOBJS];
+
+ MESSAGE (5, print_func("Testing Heaps\n"););
+
+ /* Create the file */
+ fid = H5Fcreate ("theap.h5", H5ACC_OVERWRITE, 0, 0);
+ CHECK (fid, FAIL, "H5Fcreate");
+ f = H5Aatom_object (fid);
+ CHECK (f, NULL, "H5Aatom_object");
+
+ /* Create a new heap */
+ heap = H5H_new (f, 0);
+ CHECK_I (heap, "H5H_new");
+
+ /* Add stuff to the heap */
+ for (i=0; i<NOBJS; i++) {
+ fprintf (stderr, "%d\n", i);
+ sprintf (buf, "%03d-", i);
+ for (j=4; j<i; j++) buf[j] = '0' + j%10;
+ if (j>4) buf[j] = '\0';
+
+ obj[i] = H5H_insert (f, heap, strlen(buf)+1, buf);
+ CHECK_I (heap, "H5H_insert");
+ }
+
+ /* Flush the cache and invalidate everything */
+ H5AC_flush (f, NULL, 0, TRUE);
+
+ /* Read the objects back out */
+ for (i=0; i<NOBJS; i++) {
+ s = H5H_peek (f, heap, obj[i]);
+ print_func ("object is `%s'\n", s);
+ }
+
+ /* Close the file */
+ H5Fclose (fid);
+}
+
diff --git a/test/tmeta.c b/test/tmeta.c
new file mode 100644
index 0000000..7ef7d73
--- /dev/null
+++ b/test/tmeta.c
@@ -0,0 +1,120 @@
+/****************************************************************************
+ * 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. *
+ * *
+ ****************************************************************************/
+
+#ifdef RCSID
+static char RcsId[] = "$Revision$";
+#endif
+
+/* $Id$ */
+
+/***********************************************************
+*
+* Test program: tmeta
+*
+* Test the basic meta-data encode/decode macros calls.
+*
+*************************************************************/
+
+#include "testhdf5.h"
+
+#define TEST_INT16_VALUE -7641
+#define TEST_UINT16_VALUE 45002
+#define TEST_INT32_VALUE -981236
+#define TEST_UINT32_VALUE 3476589
+
+uint8 compar_buffer[]={
+ /* Little-endian encoded version of the 16-bit signed integer */
+ (uint8)((TEST_INT16_VALUE)&0xff), (uint8)((TEST_INT16_VALUE>>8)&0xff),
+ /* Little-endian encoded version of the 16-bit unsigned integer */
+ (uint8)((TEST_UINT16_VALUE)&0xff), (uint8)((TEST_UINT16_VALUE>>8)&0xff),
+ /* Little-endian encoded version of the 32-bit signed integer */
+ (uint8)((TEST_INT32_VALUE)&0xff), (uint8)((TEST_INT32_VALUE>>8)&0xff),
+ (uint8)((TEST_INT32_VALUE>>16)&0xff), (uint8)((TEST_INT32_VALUE>>24)&0xff),
+ /* Little-endian encoded version of the 32-bit unsigned integer */
+ (uint8)((TEST_UINT32_VALUE)&0xff), (uint8)((TEST_UINT32_VALUE>>8)&0xff),
+ (uint8)((TEST_UINT32_VALUE>>16)&0xff), (uint8)((TEST_UINT32_VALUE>>24)&0xff),
+ };
+
+uint8 encode_buffer[sizeof(compar_buffer)];
+
+/****************************************************************
+**
+** test_metadata(): Main meta-data encode/decode testing routine.
+**
+****************************************************************/
+void test_metadata(void)
+{
+ int16 ei16=TEST_INT16_VALUE; /* variables to hold the values to encode */
+ uint16 eu16=TEST_UINT16_VALUE;
+ int32 ei32=TEST_INT32_VALUE;
+ uint32 eu32=TEST_UINT32_VALUE;
+ int16 di16; /* variables to hold the decoded values */
+ uint16 du16;
+ int32 di32;
+ uint32 du32;
+ uint8 *p; /* pointer into the buffer being en/de-coded */
+
+ /* Output message about test being performed */
+ MESSAGE(5, print_func("Testing Metadata encode/decode code\n"););
+
+ /* Start by encoding the values above */
+ p=encode_buffer;
+ INT16ENCODE(p,ei16); /* Encode the int16 value */
+ UINT16ENCODE(p,eu16); /* Encode the uint16 value */
+ INT32ENCODE(p,ei32); /* Encode the int32 value */
+ UINT32ENCODE(p,eu32); /* Encode the uint32 value */
+
+ /* Check if we got what we asked for */
+ if(HDmemcmp(encode_buffer,compar_buffer,sizeof(compar_buffer))!=0)
+ {
+ uintn 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 */
+ } /* end for */
+ } /* end if */
+
+ /* Test decoding macros */
+ p=encode_buffer;
+ INT16DECODE(p,di16); /* Decode the int16 value */
+ UINT16DECODE(p,du16); /* Decode the uint16 value */
+ INT32DECODE(p,di32); /* Decode the int32 value */
+ 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\n",(int)TEST_INT16_VALUE,(int)di16);
+ num_errs++;
+ } /* end if */
+ if(du16!=TEST_UINT16_VALUE)
+ {
+ print_func("Error decoding uint16 meta-data wanted: %u, got: %u\n",(unsigned)TEST_UINT16_VALUE,(unsigned)du16);
+ num_errs++;
+ } /* end if */
+ if(di32!=TEST_INT32_VALUE)
+ {
+ print_func("Error decoding int32 meta-data wanted: %ld, got: %ld\n",(long)TEST_INT32_VALUE,(long)di32);
+ num_errs++;
+ } /* end if */
+ if(du32!=TEST_UINT32_VALUE)
+ {
+ print_func("Error decoding uint32 meta-data wanted: %lu, got: %lu\n",(unsigned long)TEST_UINT32_VALUE,(unsigned long)du32);
+ num_errs++;
+ } /* end if */
+} /* test_metadata() */
+