summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/Makefile5
-rw-r--r--test/testhdf5.c1
-rw-r--r--test/testhdf5.h1
-rw-r--r--test/theap.c5
-rw-r--r--test/tohdr.c171
5 files changed, 179 insertions, 4 deletions
diff --git a/test/Makefile b/test/Makefile
index ec8bcf5..c967547 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -14,7 +14,7 @@ DEFS = -I../src
INCL = ../src/hdf5.h testhdf5.h
-OBJ = testhdf5.o tmeta.o tfile.o theap.o
+OBJ = testhdf5.o tmeta.o tfile.o theap.o tohdr.o
LIBS = ../src/libhdf5.a
@@ -47,4 +47,7 @@ tfile.o: tfile.c $(INCL)
theap.o: theap.c $(INCL)
$(CC) $(CFLAGS) $(DEFS) theap.c
+tohdr.o: tohdr.c $(INCL)
+ $(CC) $(CFLAGS) $(DEFS) tohdr.c
+
diff --git a/test/testhdf5.c b/test/testhdf5.c
index 60959fa..eaedee8 100644
--- a/test/testhdf5.c
+++ b/test/testhdf5.c
@@ -149,6 +149,7 @@ int main(int argc, char *argv[])
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");
+ InitTest("ohdr", test_ohdr, "Object Headers");
Verbosity = 4; /* Default Verbosity is Low */
H5version(&major, &minor, &release, &patch);
diff --git a/test/testhdf5.h b/test/testhdf5.h
index 1b482d2..63ea109 100644
--- a/test/testhdf5.h
+++ b/test/testhdf5.h
@@ -110,6 +110,7 @@ int print_func(const char *, ...);
void test_metadata(void);
void test_file(void);
void test_heap (void);
+void test_ohdr (void);
#endif /* HDF5TEST_H */
diff --git a/test/theap.c b/test/theap.c
index 41a9cbc..0ab60f5 100644
--- a/test/theap.c
+++ b/test/theap.c
@@ -58,12 +58,11 @@ test_heap (void)
CHECK (f, NULL, "H5Aatom_object");
/* Create a new heap */
- heap = H5H_new (f, 0);
+ heap = H5H_new (f, H5H_LOCAL, 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';
@@ -78,7 +77,7 @@ test_heap (void)
/* 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);
+ MESSAGE (8, print_func ("object is `%s'\n", s););
}
/* Close the file */
diff --git a/test/tohdr.c b/test/tohdr.c
new file mode 100644
index 0000000..2f42f02
--- /dev/null
+++ b/test/tohdr.c
@@ -0,0 +1,171 @@
+/*-------------------------------------------------------------------------
+ * Copyright (C) 1997 National Center for Supercomputing Applications.
+ * All rights reserved.
+ *
+ *-------------------------------------------------------------------------
+ *
+ * Created: tohdr.c
+ * Aug 6 1997
+ * Robb Matzke <robb@maya.nuance.com>
+ *
+ * Purpose:
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+#include "testhdf5.h"
+
+#include "H5ACprivate.h"
+#include "H5Fprivate.h"
+#include "H5Gprivate.h"
+#include "H5Oprivate.h"
+
+
+/*-------------------------------------------------------------------------
+ * Function: test_ohdr
+ *
+ * Purpose: Test object headers.
+ *
+ * Return: void
+ *
+ * Programmer: Robb Matzke
+ * robb@maya.nuance.com
+ * Aug 6 1997
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+void
+test_ohdr (void)
+{
+ hatom_t fid;
+ hdf5_file_t *f;
+ haddr_t oh;
+ H5O_stab_t stab, ro;
+ herr_t status;
+ void *ptr;
+ H5G_entry_t ent;
+ hbool_t ent_mod;
+ int i;
+
+ MESSAGE (5, print_func("Testing Object Headers\n"););
+
+ /* create the file */
+ fid = H5Fcreate ("tohdr.h5", H5ACC_OVERWRITE, 0, 0);
+ CHECK (fid, FAIL, "H5Fcreate");
+ f = H5Aatom_object (fid);
+ CHECK (f, NULL, "H5Aatom_object");
+
+ /* the new object header */
+ MESSAGE (8, print_func("Creating new object header...\n"););
+ oh = H5O_new (f, 1, 64);
+
+ /*
+ * Test creation of a new message.
+ */
+ MESSAGE (8, print_func("Creating new message...\n"););
+ stab.btree = 11111111;
+ stab.heap = 22222222;
+ status = H5O_modify (f, oh, NULL, NULL, H5O_STAB, H5O_NEW_MESG, &stab);
+ CHECK (status, FAIL, "H5O_modify");
+
+ H5AC_flush (f, NULL, 0, TRUE);
+ ptr = H5O_read (f, oh, NULL, H5O_STAB, 0, &ro);
+ CHECK_PTR (ptr, "H5O_read");
+ VERIFY (ptr, &ro, "H5O_read");
+ VERIFY (ro.btree, stab.btree, "H5O_read");
+ VERIFY (ro.heap, stab.heap, "H5O_read");
+
+ /*
+ * Test modification of an existing message.
+ */
+ MESSAGE (8, print_func("Modifying message...\n"););
+ stab.btree = 33333333;
+ stab.heap = 44444444;
+ status = H5O_modify (f, oh, NULL, NULL, H5O_STAB, 0, &stab);
+ CHECK (status, FAIL, "H5O_modify");
+
+ H5AC_flush (f, NULL, 0, TRUE);
+ ptr = H5O_read (f, oh, NULL, H5O_STAB, 0, &ro);
+ CHECK_PTR (ptr, "H5O_read");
+ VERIFY (ptr, &ro, "H5O_read");
+ VERIFY (ro.btree, stab.btree, "H5O_read");
+ VERIFY (ro.heap, stab.heap, "H5O_read");
+
+ /*
+ * Test creation of a second message of the same type with a symbol
+ * table.
+ */
+ MESSAGE (8, print_func("Creating a duplicate message...\n"););
+ ent.header = 0;
+ ent.type = H5G_NOTHING_CACHED;
+ stab.btree = 55555555;
+ stab.heap = 66666666;
+ status = H5O_modify (f, oh, &ent, &ent_mod, H5O_STAB, H5O_NEW_MESG, &stab);
+ CHECK (status, FAIL, "H5O_modify");
+ VERIFY (ent_mod, TRUE, "H5O_modify");
+ VERIFY (ent.type, H5G_CACHED_STAB, "H5O_modify");
+ VERIFY (ent.cache.stab.heap, stab.heap, "H5O_modify");
+ VERIFY (ent.cache.stab.btree, stab.btree, "H5O_modify");
+
+ H5AC_flush (f, NULL, 0, TRUE);
+ ptr = H5O_read (f, oh, NULL, H5O_STAB, 1, &ro);
+ CHECK_PTR (ptr, "H5O_read");
+ VERIFY (ptr, &ro, "H5O_read");
+ VERIFY (ro.btree, stab.btree, "H5O_read");
+ VERIFY (ro.heap, stab.heap, "H5O_read");
+
+ /*
+ * Test modification of the second message with a symbol table.
+ */
+ MESSAGE (8, print_func("Modifying the duplicate message...\n"););
+ stab.btree = 77777777;
+ stab.heap = 88888888;
+ status = H5O_modify (f, oh, &ent, &ent_mod, H5O_STAB, 1, &stab);
+ CHECK (status, FAIL, "H5O_modify");
+ VERIFY (ent_mod, TRUE, "H5O_modify");
+ VERIFY (ent.type, H5G_CACHED_STAB, "H5O_modify");
+ VERIFY (ent.cache.stab.heap, stab.heap, "H5O_modify");
+ VERIFY (ent.cache.stab.btree, stab.btree, "H5O_modify");
+
+ H5AC_flush (f, NULL, 0, TRUE);
+ ptr = H5O_read (f, oh, NULL, H5O_STAB, 1, &ro);
+ CHECK_PTR (ptr, "H5O_read");
+ VERIFY (ptr, &ro, "H5O_read");
+ VERIFY (ro.btree, stab.btree, "H5O_read");
+ VERIFY (ro.heap, stab.heap, "H5O_read");
+
+ /*
+ * Test creation of a bunch of messages one after another to see
+ * what happens when the object header overflows in core.
+ */
+ MESSAGE (8, print_func("Overflowing header in core...\n"););
+ for (i=0; i<40; i++) {
+ stab.btree = (i+1)*1000 + 1;
+ stab.heap = (i+1)*1000 + 2;
+ status = H5O_modify (f, oh, NULL, NULL, H5O_STAB, H5O_NEW_MESG, &stab);
+ CHECK (status, FAIL, "H5O_modify");
+ }
+ H5AC_flush (f, NULL, 0, TRUE);
+
+ /*
+ * Test creation of a bunch of messages one after another to see
+ * what happens when the object header overflows on disk.
+ */
+ MESSAGE (8, print_func("Overflowing header on disk...\n"););
+ for (i=0; i<10; i++) {
+ stab.btree = (i+1)*1000 + 10;
+ stab.heap = (i+1)*1000 + 20;
+ status = H5O_modify (f, oh, NULL, NULL, H5O_STAB, H5O_NEW_MESG, &stab);
+ CHECK (status, FAIL, "H5O_modify");
+ H5AC_flush (f, NULL, 0, TRUE);
+ }
+
+
+
+
+ /* close the file */
+ H5Fclose (fid);
+}