1997-08-08 03:23:41 +08:00
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* 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:
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
1997-08-16 00:53:11 +08:00
|
|
|
|
#include <testhdf5.h>
|
1997-08-08 03:23:41 +08:00
|
|
|
|
|
1997-08-16 00:53:11 +08:00
|
|
|
|
#include <H5private.h>
|
|
|
|
|
#include <H5ACprivate.h>
|
|
|
|
|
#include <H5Fprivate.h>
|
|
|
|
|
#include <H5Gprivate.h>
|
|
|
|
|
#include <H5Oprivate.h>
|
1997-08-08 03:23:41 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* 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;
|
|
|
|
|
int i;
|
|
|
|
|
|
1997-08-30 00:59:28 +08:00
|
|
|
|
MESSAGE (5, ("Testing Object Headers\n"));
|
1997-08-08 03:23:41 +08:00
|
|
|
|
|
|
|
|
|
/* 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 */
|
1997-08-30 00:59:28 +08:00
|
|
|
|
MESSAGE (8, ("Creating new object header...\n"));
|
1997-08-08 03:23:41 +08:00
|
|
|
|
oh = H5O_new (f, 1, 64);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Test creation of a new message.
|
|
|
|
|
*/
|
1997-08-30 00:59:28 +08:00
|
|
|
|
MESSAGE (8, ("Creating new message...\n"));
|
1997-09-11 03:58:12 +08:00
|
|
|
|
stab.btree_addr = 11111111;
|
|
|
|
|
stab.heap_addr = 22222222;
|
1997-09-20 00:36:59 +08:00
|
|
|
|
status = H5O_modify (f, oh, NULL, H5O_STAB, H5O_NEW_MESG, &stab);
|
1997-08-30 00:59:28 +08:00
|
|
|
|
VERIFY (status, 0, "H5O_modify");
|
1997-08-08 03:23:41 +08:00
|
|
|
|
|
|
|
|
|
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");
|
1997-09-11 03:58:12 +08:00
|
|
|
|
VERIFY (ro.btree_addr, stab.btree_addr, "H5O_read");
|
|
|
|
|
VERIFY (ro.heap_addr, stab.heap_addr, "H5O_read");
|
1997-08-08 03:23:41 +08:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Test modification of an existing message.
|
|
|
|
|
*/
|
1997-08-30 00:59:28 +08:00
|
|
|
|
MESSAGE (8, ("Modifying message...\n"));
|
1997-09-11 03:58:12 +08:00
|
|
|
|
stab.btree_addr = 33333333;
|
|
|
|
|
stab.heap_addr = 44444444;
|
1997-09-20 00:36:59 +08:00
|
|
|
|
status = H5O_modify (f, oh, NULL, H5O_STAB, 0, &stab);
|
1997-08-30 00:59:28 +08:00
|
|
|
|
VERIFY (status, 0, "H5O_modify");
|
1997-08-08 03:23:41 +08:00
|
|
|
|
|
|
|
|
|
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");
|
1997-09-11 03:58:12 +08:00
|
|
|
|
VERIFY (ro.btree_addr, stab.btree_addr, "H5O_read");
|
|
|
|
|
VERIFY (ro.heap_addr, stab.heap_addr, "H5O_read");
|
1997-08-08 03:23:41 +08:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Test creation of a second message of the same type with a symbol
|
|
|
|
|
* table.
|
|
|
|
|
*/
|
1997-08-30 00:59:28 +08:00
|
|
|
|
MESSAGE (8, ("Creating a duplicate message...\n"));
|
1997-08-08 03:23:41 +08:00
|
|
|
|
ent.header = 0;
|
|
|
|
|
ent.type = H5G_NOTHING_CACHED;
|
1997-09-20 00:36:59 +08:00
|
|
|
|
ent.dirty = FALSE;
|
1997-09-11 03:58:12 +08:00
|
|
|
|
stab.btree_addr = 55555555;
|
|
|
|
|
stab.heap_addr = 66666666;
|
1997-09-20 00:36:59 +08:00
|
|
|
|
status = H5O_modify (f, oh, &ent, H5O_STAB, H5O_NEW_MESG, &stab);
|
1997-08-30 00:59:28 +08:00
|
|
|
|
VERIFY (status, 1, "H5O_modify");
|
1997-09-20 00:36:59 +08:00
|
|
|
|
VERIFY (ent.dirty, TRUE, "H5O_modify");
|
1997-08-08 03:23:41 +08:00
|
|
|
|
VERIFY (ent.type, H5G_CACHED_STAB, "H5O_modify");
|
1997-09-11 03:58:12 +08:00
|
|
|
|
VERIFY (ent.cache.stab.heap_addr, stab.heap_addr, "H5O_modify");
|
|
|
|
|
VERIFY (ent.cache.stab.btree_addr, stab.btree_addr, "H5O_modify");
|
1997-08-08 03:23:41 +08:00
|
|
|
|
|
|
|
|
|
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");
|
1997-09-11 03:58:12 +08:00
|
|
|
|
VERIFY (ro.btree_addr, stab.btree_addr, "H5O_read");
|
|
|
|
|
VERIFY (ro.heap_addr, stab.heap_addr, "H5O_read");
|
1997-08-08 03:23:41 +08:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Test modification of the second message with a symbol table.
|
|
|
|
|
*/
|
1997-08-30 00:59:28 +08:00
|
|
|
|
MESSAGE (8, ("Modifying the duplicate message...\n"));
|
1997-09-20 00:36:59 +08:00
|
|
|
|
ent.dirty = FALSE;
|
1997-09-11 03:58:12 +08:00
|
|
|
|
stab.btree_addr = 77777777;
|
|
|
|
|
stab.heap_addr = 88888888;
|
1997-09-20 00:36:59 +08:00
|
|
|
|
status = H5O_modify (f, oh, &ent, H5O_STAB, 1, &stab);
|
1997-08-30 00:59:28 +08:00
|
|
|
|
VERIFY (status, 1, "H5O_modify");
|
1997-09-20 00:36:59 +08:00
|
|
|
|
VERIFY (ent.dirty, TRUE, "H5O_modify");
|
1997-08-08 03:23:41 +08:00
|
|
|
|
VERIFY (ent.type, H5G_CACHED_STAB, "H5O_modify");
|
1997-09-11 03:58:12 +08:00
|
|
|
|
VERIFY (ent.cache.stab.heap_addr, stab.heap_addr, "H5O_modify");
|
|
|
|
|
VERIFY (ent.cache.stab.btree_addr, stab.btree_addr, "H5O_modify");
|
1997-08-08 03:23:41 +08:00
|
|
|
|
|
|
|
|
|
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");
|
1997-09-11 03:58:12 +08:00
|
|
|
|
VERIFY (ro.btree_addr, stab.btree_addr, "H5O_read");
|
|
|
|
|
VERIFY (ro.heap_addr, stab.heap_addr, "H5O_read");
|
1997-08-08 03:23:41 +08:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Test creation of a bunch of messages one after another to see
|
|
|
|
|
* what happens when the object header overflows in core.
|
|
|
|
|
*/
|
1997-08-30 00:59:28 +08:00
|
|
|
|
MESSAGE (8, ("Overflowing header in core...\n"));
|
1997-08-08 03:23:41 +08:00
|
|
|
|
for (i=0; i<40; i++) {
|
1997-09-11 03:58:12 +08:00
|
|
|
|
stab.btree_addr = (i+1)*1000 + 1;
|
|
|
|
|
stab.heap_addr = (i+1)*1000 + 2;
|
1997-09-20 00:36:59 +08:00
|
|
|
|
status = H5O_modify (f, oh, NULL, H5O_STAB, H5O_NEW_MESG, &stab);
|
1997-08-30 00:59:28 +08:00
|
|
|
|
VERIFY (status, 2+i, "H5O_modify");
|
1997-08-08 03:23:41 +08:00
|
|
|
|
}
|
|
|
|
|
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.
|
|
|
|
|
*/
|
1997-08-30 00:59:28 +08:00
|
|
|
|
MESSAGE (8, ("Overflowing header on disk...\n"));
|
1997-08-08 03:23:41 +08:00
|
|
|
|
for (i=0; i<10; i++) {
|
1997-09-11 03:58:12 +08:00
|
|
|
|
stab.btree_addr = (i+1)*1000 + 10;
|
|
|
|
|
stab.heap_addr = (i+1)*1000 + 20;
|
1997-09-20 00:36:59 +08:00
|
|
|
|
status = H5O_modify (f, oh, NULL, H5O_STAB, H5O_NEW_MESG, &stab);
|
1997-08-30 00:59:28 +08:00
|
|
|
|
VERIFY (status, 42+i, "H5O_modify");
|
1997-08-08 03:23:41 +08:00
|
|
|
|
H5AC_flush (f, NULL, 0, TRUE);
|
|
|
|
|
}
|
|
|
|
|
|
1997-08-30 06:23:22 +08:00
|
|
|
|
/*
|
|
|
|
|
* Delete all symbol table messages.
|
|
|
|
|
*/
|
1997-09-20 00:36:59 +08:00
|
|
|
|
status = H5O_remove (f, oh, NULL, H5O_STAB, H5O_ALL);
|
1997-08-30 06:23:22 +08:00
|
|
|
|
CHECK_I (status, "H5O_remove");
|
1997-08-08 03:23:41 +08:00
|
|
|
|
|
|
|
|
|
/* close the file */
|
|
|
|
|
H5Fclose (fid);
|
|
|
|
|
}
|