summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--test/ohdr.c94
-rw-r--r--test/tattr.c183
2 files changed, 221 insertions, 56 deletions
diff --git a/test/ohdr.c b/test/ohdr.c
index 1e60e2d..c706b4b 100644
--- a/test/ohdr.c
+++ b/test/ohdr.c
@@ -64,7 +64,7 @@ main(void)
H5F_t *f=NULL;
char filename[1024];
H5G_entry_t oh_ent;
- H5O_stab_t stab, ro;
+ time_t time_new, ro;
int i;
/* Reset library */
@@ -100,9 +100,8 @@ main(void)
/* create a new message */
TESTING("message creation");
- stab.btree_addr = 11111111;
- stab.heap_addr = 22222222;
- if (H5O_modify(&oh_ent, H5O_STAB_ID, H5O_NEW_MESG, 0, 1, &stab, H5P_DATASET_XFER_DEFAULT)<0) {
+ time_new = 11111111;
+ if (H5O_modify(&oh_ent, H5O_MTIME_ID, H5O_NEW_MESG, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT)<0) {
H5_FAILED();
#ifdef H5_WANT_H5_V1_6_COMPAT
H5Eprint(stdout);
@@ -120,7 +119,7 @@ main(void)
#endif /* H5_WANT_H5_V1_6_COMPAT */
goto error;
}
- if (NULL==H5O_read(&oh_ent, H5O_STAB_ID, 0, &ro, H5P_DATASET_XFER_DEFAULT)) {
+ if (NULL==H5O_read(&oh_ent, H5O_MTIME_ID, 0, &ro, H5P_DATASET_XFER_DEFAULT)) {
H5_FAILED();
#ifdef H5_WANT_H5_V1_6_COMPAT
H5Eprint(stdout);
@@ -129,13 +128,10 @@ main(void)
#endif /* H5_WANT_H5_V1_6_COMPAT */
goto error;
}
- if (H5F_addr_ne(ro.btree_addr, stab.btree_addr) ||
- H5F_addr_ne(ro.heap_addr, stab.heap_addr)) {
+ if (ro!=time_new) {
H5_FAILED();
- HDfprintf(stdout, " got: {%a, %a}\n",
- ro.btree_addr, ro.heap_addr);
- HDfprintf(stdout, " ans: {%a, %a}\n",
- stab.btree_addr, stab.heap_addr);
+ HDfprintf(stdout, " got: {%ld}\n", (long)ro);
+ HDfprintf(stdout, " ans: {%ld}\n", (long)time_new);
goto error;
}
PASSED();
@@ -144,9 +140,8 @@ main(void)
* Test modification of an existing message.
*/
TESTING("message modification");
- stab.btree_addr = 33333333;
- stab.heap_addr = 44444444;
- if (H5O_modify(&oh_ent, H5O_STAB_ID, 0, 0, 1, &stab, H5P_DATASET_XFER_DEFAULT)<0) {
+ time_new = 33333333;
+ if (H5O_modify(&oh_ent, H5O_MTIME_ID, 0, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT)<0) {
H5_FAILED();
#ifdef H5_WANT_H5_V1_6_COMPAT
H5Eprint(stdout);
@@ -164,7 +159,7 @@ main(void)
#endif /* H5_WANT_H5_V1_6_COMPAT */
goto error;
}
- if (NULL==H5O_read(&oh_ent, H5O_STAB_ID, 0, &ro, H5P_DATASET_XFER_DEFAULT)) {
+ if (NULL==H5O_read(&oh_ent, H5O_MTIME_ID, 0, &ro, H5P_DATASET_XFER_DEFAULT)) {
H5_FAILED();
#ifdef H5_WANT_H5_V1_6_COMPAT
H5Eprint(stdout);
@@ -173,13 +168,10 @@ main(void)
#endif /* H5_WANT_H5_V1_6_COMPAT */
goto error;
}
- if (H5F_addr_ne(ro.btree_addr, stab.btree_addr) ||
- H5F_addr_ne(ro.heap_addr, stab.heap_addr)) {
+ if (ro!=time_new) {
H5_FAILED();
- HDfprintf(stdout, " got: {%a, %a}\n",
- ro.btree_addr, ro.heap_addr);
- HDfprintf(stdout, " ans: {%a, %a}\n",
- stab.btree_addr, stab.heap_addr);
+ HDfprintf(stdout, " got: {%ld}\n", (long)ro);
+ HDfprintf(stdout, " ans: {%ld}\n", (long)time_new);
goto error;
}
PASSED();
@@ -189,9 +181,8 @@ main(void)
* Test creation of a second message of the same type.
*/
TESTING("duplicate message creation");
- stab.btree_addr = 55555555;
- stab.heap_addr = 66666666;
- if (H5O_modify(&oh_ent, H5O_STAB_ID, H5O_NEW_MESG, 0, 1, &stab, H5P_DATASET_XFER_DEFAULT)<0) {
+ time_new = 55555555;
+ if (H5O_modify(&oh_ent, H5O_MTIME_ID, H5O_NEW_MESG, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT)<0) {
H5_FAILED();
#ifdef H5_WANT_H5_V1_6_COMPAT
H5Eprint(stdout);
@@ -209,7 +200,7 @@ main(void)
#endif /* H5_WANT_H5_V1_6_COMPAT */
goto error;
}
- if (NULL==H5O_read(&oh_ent, H5O_STAB_ID, 1, &ro, H5P_DATASET_XFER_DEFAULT)) {
+ if (NULL==H5O_read(&oh_ent, H5O_MTIME_ID, 1, &ro, H5P_DATASET_XFER_DEFAULT)) {
H5_FAILED();
#ifdef H5_WANT_H5_V1_6_COMPAT
H5Eprint(stdout);
@@ -218,13 +209,10 @@ main(void)
#endif /* H5_WANT_H5_V1_6_COMPAT */
goto error;
}
- if (H5F_addr_ne(ro.btree_addr, stab.btree_addr) ||
- H5F_addr_ne(ro.heap_addr, stab.heap_addr)) {
+ if (ro!=time_new) {
H5_FAILED();
- HDfprintf(stdout, " got: {%a, %a}\n",
- ro.btree_addr, ro.heap_addr);
- HDfprintf(stdout, " ans: {%a, %a}\n",
- stab.btree_addr, stab.heap_addr);
+ HDfprintf(stdout, " got: {%ld}\n", (long)ro);
+ HDfprintf(stdout, " ans: {%ld}\n", (long)time_new);
goto error;
}
PASSED();
@@ -233,9 +221,8 @@ main(void)
* Test modification of the second message with a symbol table.
*/
TESTING("duplicate message modification");
- stab.btree_addr = 77777777;
- stab.heap_addr = 88888888;
- if (H5O_modify(&oh_ent, H5O_STAB_ID, 1, 0, 1, &stab, H5P_DATASET_XFER_DEFAULT)<0) {
+ time_new = 77777777;
+ if (H5O_modify(&oh_ent, H5O_MTIME_ID, 1, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT)<0) {
H5_FAILED();
#ifdef H5_WANT_H5_V1_6_COMPAT
H5Eprint(stdout);
@@ -253,7 +240,7 @@ main(void)
#endif /* H5_WANT_H5_V1_6_COMPAT */
goto error;
}
- if (NULL==H5O_read(&oh_ent, H5O_STAB_ID, 1, &ro, H5P_DATASET_XFER_DEFAULT)) {
+ if (NULL==H5O_read(&oh_ent, H5O_MTIME_ID, 1, &ro, H5P_DATASET_XFER_DEFAULT)) {
H5_FAILED();
#ifdef H5_WANT_H5_V1_6_COMPAT
H5Eprint(stdout);
@@ -262,13 +249,10 @@ main(void)
#endif /* H5_WANT_H5_V1_6_COMPAT */
goto error;
}
- if (H5F_addr_ne(ro.btree_addr, stab.btree_addr) ||
- H5F_addr_ne(ro.heap_addr, stab.heap_addr)) {
+ if (ro!=time_new) {
H5_FAILED();
- HDfprintf(stdout, " got: {%a, %a}\n",
- ro.btree_addr, ro.heap_addr);
- HDfprintf(stdout, " ans: {%a, %a}\n",
- stab.btree_addr, stab.heap_addr);
+ HDfprintf(stdout, " got: {%ld}\n", (long)ro);
+ HDfprintf(stdout, " ans: {%ld}\n", (long)time_new);
goto error;
}
PASSED();
@@ -279,14 +263,13 @@ main(void)
*/
TESTING("object header overflow in memory");
for (i=0; i<40; i++) {
- stab.btree_addr = (i+1)*1000+1;
- stab.heap_addr = (i+1)*1000+2;
- if (H5O_modify(&oh_ent, H5O_STAB_ID, H5O_NEW_MESG, 0, 1, &stab, H5P_DATASET_XFER_DEFAULT)<0) {
+ time_new = (i+1)*1000+1;
+ if (H5O_modify(&oh_ent, H5O_MTIME_ID, H5O_NEW_MESG, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT)<0) {
H5_FAILED();
#ifdef H5_WANT_H5_V1_6_COMPAT
- H5Eprint(stdout);
+ H5Eprint(stdout);
#else
- H5Eprint(H5E_DEFAULT, stdout);
+ H5Eprint(H5E_DEFAULT, stdout);
#endif /* H5_WANT_H5_V1_6_COMPAT */
goto error;
}
@@ -308,23 +291,22 @@ main(void)
*/
TESTING("object header overflow on disk");
for (i=0; i<10; i++) {
- stab.btree_addr = (i + 1) * 1000 + 10;
- stab.heap_addr = (i + 1) * 1000 + 20;
- if (H5O_modify(&oh_ent, H5O_STAB_ID, H5O_NEW_MESG, 0, 1, &stab, H5P_DATASET_XFER_DEFAULT)<0) {
+ time_new = (i + 1) * 1000 + 10;
+ if (H5O_modify(&oh_ent, H5O_MTIME_ID, H5O_NEW_MESG, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT)<0) {
H5_FAILED();
#ifdef H5_WANT_H5_V1_6_COMPAT
- H5Eprint(stdout);
+ H5Eprint(stdout);
#else
- H5Eprint(H5E_DEFAULT, stdout);
+ H5Eprint(H5E_DEFAULT, stdout);
#endif /* H5_WANT_H5_V1_6_COMPAT */
goto error;
}
if (H5AC_flush(f, H5P_DATASET_XFER_DEFAULT, NULL, HADDR_UNDEF, TRUE)<0) {
H5_FAILED();
#ifdef H5_WANT_H5_V1_6_COMPAT
- H5Eprint(stdout);
+ H5Eprint(stdout);
#else
- H5Eprint(H5E_DEFAULT, stdout);
+ H5Eprint(H5E_DEFAULT, stdout);
#endif /* H5_WANT_H5_V1_6_COMPAT */
goto error;
}
@@ -332,10 +314,10 @@ main(void)
PASSED();
/*
- * Delete all symbol table messages.
+ * Delete all time messages.
*/
TESTING("message deletion");
- if (H5O_remove(&oh_ent, H5O_STAB_ID, H5O_ALL, H5P_DATASET_XFER_DEFAULT)<0) {
+ if (H5O_remove(&oh_ent, H5O_MTIME_ID, H5O_ALL, H5P_DATASET_XFER_DEFAULT)<0) {
H5_FAILED();
#ifdef H5_WANT_H5_V1_6_COMPAT
H5Eprint(stdout);
@@ -344,7 +326,7 @@ main(void)
#endif /* H5_WANT_H5_V1_6_COMPAT */
goto error;
}
- if (H5O_read(&oh_ent, H5O_STAB_ID, 0, &ro, H5P_DATASET_XFER_DEFAULT)) {
+ if (H5O_read(&oh_ent, H5O_MTIME_ID, 0, &ro, H5P_DATASET_XFER_DEFAULT)) {
H5_FAILED();
puts(" H5O_read() should have failed but didn't");
#ifdef H5_WANT_H5_V1_6_COMPAT
diff --git a/test/tattr.c b/test/tattr.c
index 8ea5abc..ff64862 100644
--- a/test/tattr.c
+++ b/test/tattr.c
@@ -21,6 +21,7 @@
*************************************************************/
#include "testhdf5.h"
+#include "h5test.h"
#include "hdf5.h"
#define FILENAME "tattr.h5"
@@ -42,6 +43,9 @@
/* Group Information */
#define GROUP1_NAME "/Group1"
+/* Named Datatype Information */
+#define TYPE1_NAME "/Type"
+
/* Attribute Rank & Dimensions */
#define ATTR1_NAME "Attr1"
#define ATTR1_RANK 1
@@ -1360,6 +1364,182 @@ test_attr_delete(void)
/****************************************************************
**
+** test_attr_dtype_shared(): Test H5A (attribute) code for using
+** shared datatypes in attributes.
+**
+****************************************************************/
+static void
+test_attr_dtype_shared(void)
+{
+ hid_t file_id; /* File ID */
+ hid_t dset_id; /* Dataset ID */
+ hid_t space_id; /* Dataspace ID for dataset & attribute */
+ hid_t type_id; /* Datatype ID for named datatype */
+ hid_t attr_id; /* Attribute ID */
+ int data=8; /* Data to write */
+ int rdata=0; /* Read read in */
+ H5G_stat_t statbuf; /* Object's information */
+ off_t empty_filesize; /* Size of empty file */
+ off_t filesize; /* Size of file after modifications */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing Shared Datatypes with Attributes\n"));
+
+ /* Create a file */
+ file_id=H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(file_id, FAIL, "H5Fopen");
+
+ /* Close file */
+ ret=H5Fclose(file_id);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Get size of file */
+ empty_filesize=h5_get_file_size(FILENAME);
+ if(empty_filesize==0) {
+ printf("Line %d: file size wrong!\n",__LINE__);
+ num_errs++;
+ } /* end if */
+
+ /* Re-open file */
+ file_id=H5Fopen(FILENAME,H5F_ACC_RDWR,H5P_DEFAULT);
+ CHECK(file_id, FAIL, "H5Fopen");
+
+ /* Create a datatype to commit and use */
+ type_id=H5Tcopy(H5T_NATIVE_INT);
+ CHECK(type_id, FAIL, "H5Tcopy");
+
+ /* Commit datatype to file */
+ ret=H5Tcommit(file_id,TYPE1_NAME,type_id);
+ CHECK(ret, FAIL, "H5Tcommit");
+
+ /* Check reference count on named datatype */
+ ret=H5Gget_objinfo(file_id,TYPE1_NAME,0,&statbuf);
+ CHECK(ret, FAIL, "H5Gget_objinfo");
+ VERIFY(statbuf.nlink, 1, "H5Tcommit");
+
+ /* Create dataspace for dataset */
+ space_id=H5Screate(H5S_SCALAR);
+ CHECK(space_id, FAIL, "H5Screate");
+
+ /* Create dataset */
+ dset_id=H5Dcreate(file_id,DSET1_NAME,type_id,space_id,H5P_DEFAULT);
+ CHECK(dset_id, FAIL, "H5Dcreate");
+
+ /* Check reference count on named datatype */
+ ret=H5Gget_objinfo(file_id,TYPE1_NAME,0,&statbuf);
+ CHECK(ret, FAIL, "H5Gget_objinfo");
+ VERIFY(statbuf.nlink, 2, "H5Dcreate");
+
+ /* Create attribute on dataset */
+ attr_id=H5Acreate(dset_id,ATTR1_NAME,type_id,space_id,H5P_DEFAULT);
+ CHECK(attr_id, FAIL, "H5Acreate");
+
+ /* Check reference count on named datatype */
+ ret=H5Gget_objinfo(file_id,TYPE1_NAME,0,&statbuf);
+ CHECK(ret, FAIL, "H5Gget_objinfo");
+ VERIFY(statbuf.nlink, 3, "H5Acreate");
+
+ /* Close attribute */
+ ret=H5Aclose(attr_id);
+ CHECK(ret, FAIL, "H5Aclose");
+
+ /* Delete attribute */
+ ret=H5Adelete(dset_id,ATTR1_NAME);
+ CHECK(ret, FAIL, "H5Adelete");
+
+ /* Check reference count on named datatype */
+ ret=H5Gget_objinfo(file_id,TYPE1_NAME,0,&statbuf);
+ CHECK(ret, FAIL, "H5Gget_objinfo");
+ VERIFY(statbuf.nlink, 2, "H5Adelete");
+
+ /* Create attribute on dataset */
+ attr_id=H5Acreate(dset_id,ATTR1_NAME,type_id,space_id,H5P_DEFAULT);
+ CHECK(attr_id, FAIL, "H5Acreate");
+
+ /* Check reference count on named datatype */
+ ret=H5Gget_objinfo(file_id,TYPE1_NAME,0,&statbuf);
+ CHECK(ret, FAIL, "H5Gget_objinfo");
+ VERIFY(statbuf.nlink, 3, "H5Acreate");
+
+ /* Write data into the attribute */
+ ret=H5Awrite(attr_id,H5T_NATIVE_INT,&data);
+ CHECK(ret, FAIL, "H5Awrite");
+
+ /* Close attribute */
+ ret=H5Aclose(attr_id);
+ CHECK(ret, FAIL, "H5Aclose");
+
+ /* Close dataset */
+ ret=H5Dclose(dset_id);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ /* Close dataspace */
+ ret=H5Sclose(space_id);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ /* Close datatype */
+ ret=H5Tclose(type_id);
+ CHECK(ret, FAIL, "H5Tclose");
+
+ /* Close file */
+ ret=H5Fclose(file_id);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Re-open file */
+ file_id=H5Fopen(FILENAME,H5F_ACC_RDWR,H5P_DEFAULT);
+ CHECK(file_id, FAIL, "H5Fopen");
+
+ /* Open dataset */
+ dset_id=H5Dopen(file_id,DSET1_NAME);
+ CHECK(dset_id, FAIL, "H5Dopen");
+
+ /* Open attribute */
+ attr_id=H5Aopen_name(dset_id,ATTR1_NAME);
+ CHECK(attr_id, FAIL, "H5Aopen_name");
+
+ /* Read data from the attribute */
+ ret=H5Aread(attr_id,H5T_NATIVE_INT,&rdata);
+ CHECK(ret, FAIL, "H5Aread");
+ VERIFY(data, rdata, "H5Aread");
+
+ /* Close attribute */
+ ret=H5Aclose(attr_id);
+ CHECK(ret, FAIL, "H5Aclose");
+
+ /* Close dataset */
+ ret=H5Dclose(dset_id);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ /* Check reference count on named datatype */
+ ret=H5Gget_objinfo(file_id,TYPE1_NAME,0,&statbuf);
+ CHECK(ret, FAIL, "H5Gget_objinfo");
+ VERIFY(statbuf.nlink, 3, "H5Aopen_name");
+
+ /* Unlink the dataset */
+ ret=H5Gunlink(file_id,DSET1_NAME);
+ CHECK(ret, FAIL, "H5Gunlink");
+
+ /* Check reference count on named datatype */
+ ret=H5Gget_objinfo(file_id,TYPE1_NAME,0,&statbuf);
+ CHECK(ret, FAIL, "H5Gget_objinfo");
+ VERIFY(statbuf.nlink, 1, "H5Gunlink");
+
+ /* Unlink the named datatype */
+ ret=H5Gunlink(file_id,TYPE1_NAME);
+ CHECK(ret, FAIL, "H5Gunlink");
+
+ /* Close file */
+ ret=H5Fclose(file_id);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Check size of file */
+ filesize=h5_get_file_size(FILENAME);
+ VERIFY(filesize, empty_filesize, "H5Fclose");
+} /* test_attr_dtype_shared() */
+
+/****************************************************************
+**
** test_attr(): Main H5A (attribute) testing routine.
**
****************************************************************/
@@ -1386,6 +1566,9 @@ test_attr(void)
test_attr_mult_read(); /* Test H5A reading code for multiple attributes */
test_attr_iterate(); /* Test H5A iterator code */
test_attr_delete(); /* Test H5A code for deleting attributes */
+
+ /* This next test use the same file information */
+ test_attr_dtype_shared(); /* Test using shared dataypes in attributes */
} /* test_attr() */