summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2006-08-21 23:27:11 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2006-08-21 23:27:11 (GMT)
commit5fe34046c00065fdc10eb1b6b04309aaaf110331 (patch)
tree94a62100b7a8499c511430f0e8bda33434f8bee2 /test
parent6bbe1283673ab7b151d751cb2df409f5babb47b4 (diff)
downloadhdf5-5fe34046c00065fdc10eb1b6b04309aaaf110331.zip
hdf5-5fe34046c00065fdc10eb1b6b04309aaaf110331.tar.gz
hdf5-5fe34046c00065fdc10eb1b6b04309aaaf110331.tar.bz2
[svn-r12605] Description:
Break out a bunch of the misc. routines that were in src/H5.c into more specific modules. Add optimized fletcher32 checksum routine, for checksumming metadata as well as raw data. Tested On: Linux/32 2.6 (chicago) Linux/64 2.6 (chicago2) Will test further after checkin...
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.am7
-rw-r--r--test/Makefile.in5
-rw-r--r--test/tchecksum.c194
-rw-r--r--test/testhdf5.c3
-rw-r--r--test/testhdf5.h3
-rw-r--r--test/tmeta.c4
6 files changed, 207 insertions, 9 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index 4e7818b..1dd037f 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -115,8 +115,9 @@ CHECK_CLEANFILES+=cmpd_dset.h5 compact_dataset.h5 dataset.h5 extend.h5 istore.h5
objcopy_src.h5 objcopy_dst.h5 objcopy_ext.dat
# Sources for testhdf5 executable
-testhdf5_SOURCES=testhdf5.c tarray.c tattr.c tconfig.c tfile.c tgenprop.c \
- th5o.c th5s.c theap.c tid.c titerate.c tmeta.c tmisc.c ttime.c trefer.c trefstr.c \
- tselect.c tskiplist.c ttst.c tunicode.c tvltypes.c tvlstr.c
+testhdf5_SOURCES=testhdf5.c tarray.c tattr.c tchecksum.c tconfig.c tfile.c \
+ tgenprop.c th5o.c th5s.c theap.c tid.c titerate.c tmeta.c tmisc.c ttime.c \
+ trefer.c trefstr.c tselect.c tskiplist.c ttst.c tunicode.c tvltypes.c \
+ tvlstr.c
include $(top_srcdir)/config/conclude.am
diff --git a/test/Makefile.in b/test/Makefile.in
index 0d491be..58ccf99 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -290,7 +290,7 @@ stream_test_OBJECTS = stream_test.$(OBJEXT)
stream_test_LDADD = $(LDADD)
stream_test_DEPENDENCIES = libh5test.la $(am__DEPENDENCIES_1)
am_testhdf5_OBJECTS = testhdf5.$(OBJEXT) tarray.$(OBJEXT) \
- tattr.$(OBJEXT) tconfig.$(OBJEXT) tfile.$(OBJEXT) \
+ tattr.$(OBJEXT) tchecksum.$(OBJEXT) tconfig.$(OBJEXT) tfile.$(OBJEXT) \
tgenprop.$(OBJEXT) th5o.$(OBJEXT) th5s.$(OBJEXT) \
theap.$(OBJEXT) tid.$(OBJEXT) titerate.$(OBJEXT) \
tmeta.$(OBJEXT) tmisc.$(OBJEXT) ttime.$(OBJEXT) \
@@ -657,7 +657,7 @@ ttsafe_SOURCES = ttsafe.c ttsafe_dcreate.c ttsafe_error.c ttsafe_cancel.c
VFD_LIST = sec2 stdio core split multi family
# Sources for testhdf5 executable
-testhdf5_SOURCES = testhdf5.c tarray.c tattr.c tconfig.c tfile.c tgenprop.c \
+testhdf5_SOURCES = testhdf5.c tarray.c tattr.c tchecksum.c tconfig.c tfile.c tgenprop.c \
th5o.c th5s.c theap.c tid.c titerate.c tmeta.c tmisc.c ttime.c trefer.c trefstr.c \
tselect.c tskiplist.c ttst.c tunicode.c tvltypes.c tvlstr.c
@@ -958,6 +958,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stream_test.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tarray.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tattr.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tchecksum.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tconfig.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testframe.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testhdf5.Po@am__quote@
diff --git a/test/tchecksum.c b/test/tchecksum.c
new file mode 100644
index 0000000..ff49294
--- /dev/null
+++ b/test/tchecksum.c
@@ -0,0 +1,194 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*-------------------------------------------------------------------------
+ *
+ * Created: tchecksum.c
+ * Aug 21 2006
+ * Quincey Koziol <koziol@hdfgroup.org>
+ *
+ * Purpose: Test internal checksum routine(s)
+ *
+ *-------------------------------------------------------------------------
+ */
+
+/***********/
+/* Headers */
+/***********/
+#include "testhdf5.h"
+
+/**********/
+/* Macros */
+/**********/
+#define BUF_LEN 3093 /* No particular value */
+
+/*******************/
+/* Local variables */
+/*******************/
+uint8_t large_buf[BUF_LEN];
+
+
+/****************************************************************
+**
+** test_chksum_size_one(): Checksum 1 byte buffer
+**
+****************************************************************/
+static void
+test_chksum_size_one(void)
+{
+ uint8_t buf[1] = {23}; /* Buffer to checksum */
+ uint32_t chksum; /* Checksum value */
+
+ /* Buffer w/real data */
+ chksum = H5_fletcher32(buf, sizeof(buf));
+ VERIFY(chksum, 0x17001700, "H5_fletcher32");
+
+ /* Buffer w/zero(s) for data */
+ HDmemset(buf, 0, sizeof(buf));
+ chksum = H5_fletcher32(buf, sizeof(buf));
+ VERIFY(chksum, 0xffffffff, "H5_fletcher32");
+} /* test_chksum_size_one() */
+
+
+/****************************************************************
+**
+** test_chksum_size_two(): Checksum 2 byte buffer
+**
+****************************************************************/
+static void
+test_chksum_size_two(void)
+{
+ uint8_t buf[2] = {23, 187}; /* Buffer to checksum */
+ uint32_t chksum; /* Checksum value */
+
+ /* Buffer w/real data */
+ chksum = H5_fletcher32(buf, sizeof(buf));
+ VERIFY(chksum, 0x17bb17bb, "H5_fletcher32");
+
+ /* Buffer w/zero(s) for data */
+ HDmemset(buf, 0, sizeof(buf));
+ chksum = H5_fletcher32(buf, sizeof(buf));
+ VERIFY(chksum, 0xffffffff, "H5_fletcher32");
+} /* test_chksum_size_two() */
+
+
+/****************************************************************
+**
+** test_chksum_size_three(): Checksum 3 byte buffer
+**
+****************************************************************/
+static void
+test_chksum_size_three(void)
+{
+ uint8_t buf[3] = {23, 187, 98}; /* Buffer to checksum */
+ uint32_t chksum; /* Checksum value */
+
+ /* Buffer w/real data */
+ chksum = H5_fletcher32(buf, sizeof(buf));
+ VERIFY(chksum, 0x917679bb, "H5_fletcher32");
+
+ /* Buffer w/zero(s) for data */
+ HDmemset(buf, 0, sizeof(buf));
+ chksum = H5_fletcher32(buf, sizeof(buf));
+ VERIFY(chksum, 0xffffffff, "H5_fletcher32");
+} /* test_chksum_size_three() */
+
+
+/****************************************************************
+**
+** test_chksum_size_four(): Checksum 4 byte buffer
+**
+****************************************************************/
+static void
+test_chksum_size_four(void)
+{
+ uint8_t buf[4] = {23, 187, 98, 217};/* Buffer to checksum */
+ uint32_t chksum; /* Checksum value */
+
+ /* Buffer w/real data */
+ chksum = H5_fletcher32(buf, sizeof(buf));
+ VERIFY(chksum, 0x924f7a94, "H5_fletcher32");
+
+ /* Buffer w/zero(s) for data */
+ HDmemset(buf, 0, sizeof(buf));
+ chksum = H5_fletcher32(buf, sizeof(buf));
+ VERIFY(chksum, 0xffffffff, "H5_fletcher32");
+} /* test_chksum_size_four() */
+
+
+/****************************************************************
+**
+** test_chksum_large(): Checksum larger buffer
+**
+****************************************************************/
+static void
+test_chksum_large(void)
+{
+ uint32_t chksum; /* Checksum value */
+ size_t u; /* Local index variable */
+
+ /* Initialize buffer w/known data */
+ for(u = 0; u < BUF_LEN; u++)
+ large_buf[u] = u * 3;
+
+ /* Buffer w/real data */
+ chksum = H5_fletcher32(large_buf, sizeof(large_buf));
+ VERIFY(chksum, 0x85b4e2a, "H5_fletcher32");
+
+ /* Buffer w/zero(s) for data */
+ HDmemset(large_buf, 0, sizeof(large_buf));
+ chksum = H5_fletcher32(large_buf, sizeof(large_buf));
+ VERIFY(chksum, 0xffffffff, "H5_fletcher32");
+} /* test_chksum_large() */
+
+
+/****************************************************************
+**
+** test_checksum(): Main checksum testing routine.
+**
+****************************************************************/
+void
+test_checksum(void)
+{
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing checksum algorithm\n"));
+
+ /* Various checks for fletcher32 checksum algorithm */
+ test_chksum_size_one(); /* Test buffer w/only 1 byte */
+ test_chksum_size_two(); /* Test buffer w/only 2 bytes */
+ test_chksum_size_three(); /* Test buffer w/only 3 bytes */
+ test_chksum_size_four(); /* Test buffer w/only 4 bytes */
+ test_chksum_large(); /* Test buffer w/larger # of bytes */
+
+} /* test_checksum() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: cleanup_checksum
+ *
+ * Purpose: Cleanup temporary test files
+ *
+ * Return: none
+ *
+ * Programmer: Quincey Koziol
+ * August 21, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+void
+cleanup_checksum(void)
+{
+ /* no file to clean */
+}
+
diff --git a/test/testhdf5.c b/test/testhdf5.c
index eadc2bd..1d5cb64 100644
--- a/test/testhdf5.c
+++ b/test/testhdf5.c
@@ -44,7 +44,8 @@ main(int argc, char *argv[])
/* Tests are generally arranged from least to most complexity... */
AddTest("config", test_configure, cleanup_configure, "Configure definitions", NULL);
- AddTest("metadata", test_metadata, cleanup_metadata, "Encode/decode metadata code", NULL);
+ AddTest("metadata", test_metadata, cleanup_metadata, "Encoding/decoding metadata", NULL);
+ AddTest("checksum", test_checksum, cleanup_checksum, "Checksum algorithm", NULL);
AddTest("tst", test_tst, NULL, "Ternary Search Trees", NULL);
AddTest("heap", test_heap, NULL, "Memory Heaps", NULL);
AddTest("skiplist", test_skiplist, NULL, "Skip Lists", NULL);
diff --git a/test/testhdf5.h b/test/testhdf5.h
index b4f1342..c085b5a 100644
--- a/test/testhdf5.h
+++ b/test/testhdf5.h
@@ -123,6 +123,7 @@ extern "C" {
/* Prototypes for the test routines */
void test_metadata(void);
+void test_checksum(void);
void test_tst(void);
void test_heap(void);
void test_refstr(void);
@@ -148,6 +149,7 @@ void test_unicode(void);
/* Prototypes for the cleanup routines */
void cleanup_metadata(void);
+void cleanup_checksum(void);
void cleanup_file(void);
void cleanup_h5o(void);
void cleanup_h5s(void);
@@ -168,3 +170,4 @@ void cleanup_unicode(void);
}
#endif
#endif /* TESTHDF5_H */
+
diff --git a/test/tmeta.c b/test/tmeta.c
index 886ded2..ce5d65c 100644
--- a/test/tmeta.c
+++ b/test/tmeta.c
@@ -21,8 +21,6 @@
*************************************************************/
#include "testhdf5.h"
-
-#include "H5private.h"
#include "H5Fprivate.h"
#define TEST_INT16_VALUE -7641
@@ -65,7 +63,7 @@ test_metadata(void)
uint8_t *p; /* pointer into the buffer being en/de-coded */
/* Output message about test being performed */
- MESSAGE(5, ("Testing Metadata encode/decode code\n"));
+ MESSAGE(5, ("Testing Metadata Encoding/decoding\n"));
/* Start by encoding the values above */
p = encode_buffer;