summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.in15
-rw-r--r--test/dsets.c15
-rw-r--r--test/fillval.c2
-rw-r--r--test/gen_new_mtime.c65
-rw-r--r--test/gen_old_mtime.c66
-rw-r--r--test/istore.c3
-rw-r--r--test/mtime.c68
-rw-r--r--test/ntypes.c1
-rw-r--r--test/ohdr.c13
-rw-r--r--test/tattr.c25
-rw-r--r--test/testhdf5.c2
-rw-r--r--test/testhdf5.h2
-rw-r--r--test/tgenprop.c38
-rw-r--r--test/titerate.c14
-rw-r--r--test/tmtimen.h5bin0 -> 1576 bytes
-rw-r--r--test/tmtimeo.h5bin0 -> 1576 bytes
-rw-r--r--test/trefstr.c378
-rw-r--r--test/ttst.c400
-rw-r--r--test/tvlstr.c9
19 files changed, 1044 insertions, 72 deletions
diff --git a/test/Makefile.in b/test/Makefile.in
index 0ea2fa5..860c4cc 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -65,11 +65,12 @@ TEST_SRC=big.c bittests.c cmpd_dset.c dsets.c dtypes.c extend.c \
external.c fillval.c flush1.c flush2.c gheap.c h5test.c hyperslab.c \
istore.c lheap.c links.c mount.c mtime.c ohdr.c stab.c tarray.c \
tattr.c tconfig.c testhdf5.c testmeta.c tfile.c tgenprop.c th5s.c \
- titerate.c tmeta.c trefer.c tselect.c ttime.c ttbbt.c tvltypes.c \
- tvlstr.c tmisc.c unlink.c enum.c ttsafe.c ttsafe_dcreate.c \
- ttsafe_error.c ttsafe_cancel.c ttsafe_acreate.c gass_write.c \
- gass_read.c gass_append.c srb_read.c srb_write.c srb_append.c \
- stream_test.c set_extent.c getname.c file_handle.c ntypes.c
+ titerate.c tmeta.c trefer.c trefstr.c tselect.c ttime.c ttbbt.c \
+ ttst.c tvltypes.c tvlstr.c tmisc.c unlink.c enum.c ttsafe.c \
+ ttsafe_dcreate.c ttsafe_error.c ttsafe_cancel.c ttsafe_acreate.c \
+ gass_write.c gass_read.c gass_append.c srb_read.c srb_write.c \
+ srb_append.c stream_test.c set_extent.c getname.c file_handle.c \
+ ntypes.c
TEST_OBJ=$(TEST_SRC:.c=.lo)
@@ -90,8 +91,8 @@ timings _timings: $(TIMINGS)
$(TEST_PROGS): $(LIB) $(LIBHDF5)
TESTHDF5_OBJ=testhdf5.lo tarray.lo tattr.lo tconfig.lo tfile.lo tgenprop.lo \
- th5s.lo titerate.lo tmeta.lo ttime.lo trefer.lo tselect.lo ttbbt.lo \
- tvltypes.lo tvlstr.lo tmisc.lo
+ th5s.lo titerate.lo tmeta.lo ttime.lo trefer.lo trefstr.lo tselect.lo \
+ ttbbt.lo ttst.lo tvltypes.lo tvlstr.lo tmisc.lo
TTS_OBJ=ttsafe.lo ttsafe_dcreate.lo ttsafe_error.lo ttsafe_cancel.lo \
ttsafe_acreate.lo
diff --git a/test/dsets.c b/test/dsets.c
index 3a7e561..e41748e 100644
--- a/test/dsets.c
+++ b/test/dsets.c
@@ -327,9 +327,8 @@ test_userblock_offset(hid_t fapl)
{
char filename[32];
hid_t file, fcpl, dataset, space;
- int i, j, n;
+ int i, j;
hsize_t dims[2];
-/* FILE *f;*/
int f;
haddr_t offset;
int rdata[100][200];
@@ -339,19 +338,11 @@ test_userblock_offset(hid_t fapl)
h5_fixname(FILENAME[2], fapl, filename, sizeof filename);
if((fcpl=H5Pcreate(H5P_FILE_CREATE))<0) goto error;
- if(H5Pset_userblock(fcpl, USER_BLOCK)<0) goto error;
+ if(H5Pset_userblock(fcpl, (hsize_t)USER_BLOCK)<0) goto error;
- if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl))<0) {
+ if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl))<0)
goto error;
- }
- /* Initialize the dataset */
- /*for (i = n = 0; i < 100; i++) {
- for (j = 0; j < 200; j++) {
- points[i][j] = n++;
- }
- }*/
-
/* Create the data space */
dims[0] = 100;
dims[1] = 200;
diff --git a/test/fillval.c b/test/fillval.c
index 587999a..d15bfc5 100644
--- a/test/fillval.c
+++ b/test/fillval.c
@@ -1264,7 +1264,7 @@ test_compatible(void)
char *srcdir = getenv("srcdir"); /*where the src code is located*/
char testfile[512]=""; /* test file name */
- TESTING("contiguous dataset compatibility with v. 1.5");
+ TESTING("contiguous dataset compatibility with v. 1.4");
/* Generate correct name for test file by prepending the source path */
if(srcdir && ((strlen(srcdir) + strlen(FILE_COMPATIBLE) + 1) <
diff --git a/test/gen_new_mtime.c b/test/gen_new_mtime.c
new file mode 100644
index 0000000..1bf1ef9
--- /dev/null
+++ b/test/gen_new_mtime.c
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2003 NCSA
+ * All rights reserved.
+ *
+ * Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu>
+ * Friday, January 3, 2003
+ *
+ * Purpose: Create a dataset, which should have the newer mtime information
+ * stored in it.
+ * This program is used to create the test file `tmtimen.h5' which
+ * has the new format for mtime information.
+ * To build the test file, this program MUST be compiled and linked with
+ * the hdf5-1.5+ series of libraries and the generated test file must be
+ * put into the 'test' directory in the 1.5+ branch of the library.
+ */
+
+#include "hdf5.h"
+
+#define TESTFILE "tmtimen.h5"
+
+
+/*-------------------------------------------------------------------------
+ * Function: main
+ *
+ * Purpose:
+ *
+ * Return: Success:
+ *
+ * Failure:
+ *
+ * Programmer: Quincey Koziol
+ * Friday, January 3, 2003
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+main(void)
+{
+ hid_t file, space, dset;
+
+ /* Create the file */
+ file = H5Fcreate(TESTFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ if(file<0)
+ printf("file<0!\n");
+
+ /* Create the dataspace (for dataset) */
+ space = H5Screate(H5S_SCALAR);
+ if(space<0)
+ printf("space<0!\n");
+
+ /* Create the dataset with compound array fields */
+ dset = H5Dcreate(file, "Dataset1", H5T_NATIVE_INT, space, H5P_DEFAULT);
+ if(dset<0)
+ printf("dset<0!\n");
+
+ H5Dclose(dset);
+ H5Sclose(space);
+ H5Fclose(file);
+
+ return 0;
+}
+
+
diff --git a/test/gen_old_mtime.c b/test/gen_old_mtime.c
new file mode 100644
index 0000000..b9a8186
--- /dev/null
+++ b/test/gen_old_mtime.c
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2003 NCSA
+ * All rights reserved.
+ *
+ * Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu>
+ * Friday, January 3, 2003
+ *
+ * Purpose: Create a dataset, which should have the older mtime information
+ * stored in it.
+ * This program is used to create the test file `tmtimeo.h5' which
+ * has the new format for mtime information.
+ * To build the test file, this program MUST be compiled and linked with
+ * the hdf5-1.4+ series of libraries and the generated test file must be
+ * put into the 'test' directory in the 1.5+ branch of the library.
+ */
+
+#include "hdf5.h"
+
+#define TESTFILE "tmtimeo.h5"
+
+
+/*-------------------------------------------------------------------------
+ * Function: main
+ *
+ * Purpose:
+ *
+ * Return: Success:
+ *
+ * Failure:
+ *
+ * Programmer: Quincey Koziol
+ * Friday, January 3, 2003
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+main(void)
+{
+ hid_t file, space, dset;
+
+ /* Create the file */
+ file = H5Fcreate(TESTFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ if(file<0)
+ printf("file<0!\n");
+
+ /* Create the dataspace (for dataset) */
+ space = H5Screate(H5S_SCALAR);
+ if(space<0)
+ printf("space<0!\n");
+
+ /* Create the dataset with compound array fields */
+ dset = H5Dcreate(file, "Dataset1", H5T_NATIVE_INT, space, H5P_DEFAULT);
+ if(dset<0)
+ printf("dset<0!\n");
+
+ H5Dclose(dset);
+ H5Sclose(space);
+ H5Fclose(file);
+
+ return 0;
+}
+
+
+
diff --git a/test/istore.c b/test/istore.c
index e79754a..3dfb8cf 100644
--- a/test/istore.c
+++ b/test/istore.c
@@ -100,6 +100,7 @@ new_object(H5F_t *f, const char *name, unsigned ndims, H5G_entry_t *ent/*out*/)
unsigned u;
/* Create the object header */
+ HDmemset(ent,0,sizeof(H5G_entry_t));
if (H5O_create(f, 64, ent)) {
H5_FAILED();
puts(" H5O_create() = NULL");
@@ -118,7 +119,7 @@ new_object(H5F_t *f, const char *name, unsigned ndims, H5G_entry_t *ent/*out*/)
}
/* Create the root of the B-tree that describes chunked storage */
H5F_istore_create (f, &layout/*in,out*/);
- if (H5O_modify(ent, H5O_LAYOUT, H5O_NEW_MESG, 0, &layout) < 0) {
+ if (H5O_modify(ent, H5O_LAYOUT, H5O_NEW_MESG, 0, 1, &layout) < 0) {
H5_FAILED();
puts(" H5O_modify istore message failure.");
goto error;
diff --git a/test/mtime.c b/test/mtime.c
index 55e0c21..b94cadf 100644
--- a/test/mtime.c
+++ b/test/mtime.c
@@ -17,6 +17,11 @@ const char *FILENAME[] = {
NULL
};
+#define TESTFILE1 "tmtimeo.h5"
+#define MTIME1 1041605080
+#define TESTFILE2 "tmtimen.h5"
+#define MTIME2 1041606478
+
/*-------------------------------------------------------------------------
* Function: main
@@ -31,6 +36,11 @@ const char *FILENAME[] = {
* Thursday, July 30, 1998
*
* Modifications:
+ * Added checks for old and new modification time messages
+ * in pre-created datafiles (generated with gen_old_mtime.c and
+ * gen_new_mtime.c).
+ * Quincey Koziol
+ * Friday, January 3, 2003
*
*-------------------------------------------------------------------------
*/
@@ -101,9 +111,65 @@ main(void)
printf(" got: %s\n ans: %s\n", buf1, buf2);
return 1;
}
+ PASSED();
- /* All looks good */
+ /* Check opening existing file with old-style modification time information
+ * and make certain that the time is correct
+ */
+ TESTING("accessing old modification time messages");
+
+ {
+ char testfile[512]="";
+ char *srcdir = HDgetenv("srcdir");
+ if (srcdir && ((HDstrlen(srcdir) + strlen(TESTFILE1) + 1) < sizeof(testfile))){
+ HDstrcpy(testfile, srcdir);
+ HDstrcat(testfile, "/");
+ }
+ HDstrcat(testfile, TESTFILE1);
+ file = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT);
+ if (file >= 0){
+ if(H5Gget_objinfo(file, "/Dataset1", TRUE, &sb1)<0)
+ return 1;
+ if(sb1.mtime!=MTIME1) return 1;
+ if (H5Fclose(file)<0) return 1;
+ }
+ else {
+ printf("***cannot open the pre-created old modification test file (%s)\n",
+ testfile);
+ return 1;
+ } /* end else */
+ }
PASSED();
+
+ /* Check opening existing file with new-style modification time information
+ * and make certain that the time is correct
+ */
+ TESTING("accessing new modification time messages");
+
+ {
+ char testfile[512]="";
+ char *srcdir = HDgetenv("srcdir");
+ if (srcdir && ((HDstrlen(srcdir) + strlen(TESTFILE2) + 1) < sizeof(testfile))){
+ HDstrcpy(testfile, srcdir);
+ HDstrcat(testfile, "/");
+ }
+ HDstrcat(testfile, TESTFILE2);
+ file = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT);
+ if (file >= 0){
+ if(H5Gget_objinfo(file, "/Dataset1", TRUE, &sb2)<0)
+ return 1;
+ if(sb2.mtime!=MTIME2) return 1;
+ if (H5Fclose(file)<0) return 1;
+ }
+ else {
+ printf("***cannot open the pre-created old modification test file (%s)\n",
+ testfile);
+ return 1;
+ } /* end else */
+ }
+ PASSED();
+
+ /* All looks good */
puts("All modification time tests passed.");
h5_cleanup(FILENAME, fapl);
return 0;
diff --git a/test/ntypes.c b/test/ntypes.c
index 69d56c9..fcdd9fb 100644
--- a/test/ntypes.c
+++ b/test/ntypes.c
@@ -1503,7 +1503,6 @@ test_refer_dtype2(hid_t file)
*drbuf; /* Buffer for reading numeric data from disk */
uint8_t *tu8; /* Temporary pointer to uint8 data */
int i; /* counting variables */
- herr_t ret; /* Generic return value */
/* Output message about test being performed */
TESTING("dataset region reference");
diff --git a/test/ohdr.c b/test/ohdr.c
index 69d7f10..ddd4ed6 100644
--- a/test/ohdr.c
+++ b/test/ohdr.c
@@ -62,6 +62,7 @@ main(void)
* Test object header creation
*/
TESTING("object header creation");
+ HDmemset(&oh_ent,0,sizeof(H5G_entry_t));
if (H5O_create(f, 64, &oh_ent/*out*/)<0) {
H5_FAILED();
H5Eprint(stdout);
@@ -73,7 +74,7 @@ main(void)
TESTING("message creation");
stab.btree_addr = 11111111;
stab.heap_addr = 22222222;
- if (H5O_modify(&oh_ent, H5O_STAB, H5O_NEW_MESG, 0, &stab)<0) {
+ if (H5O_modify(&oh_ent, H5O_STAB, H5O_NEW_MESG, 0, 1, &stab)<0) {
H5_FAILED();
H5Eprint(stdout);
goto error;
@@ -105,7 +106,7 @@ main(void)
TESTING("message modification");
stab.btree_addr = 33333333;
stab.heap_addr = 44444444;
- if (H5O_modify(&oh_ent, H5O_STAB, 0, 0, &stab)<0) {
+ if (H5O_modify(&oh_ent, H5O_STAB, 0, 0, 1, &stab)<0) {
H5_FAILED();
H5Eprint(stdout);
goto error;
@@ -138,7 +139,7 @@ main(void)
TESTING("duplicate message creation");
stab.btree_addr = 55555555;
stab.heap_addr = 66666666;
- if (H5O_modify(&oh_ent, H5O_STAB, H5O_NEW_MESG, 0, &stab)<0) {
+ if (H5O_modify(&oh_ent, H5O_STAB, H5O_NEW_MESG, 0, 1, &stab)<0) {
H5_FAILED();
H5Eprint(stdout);
goto error;
@@ -170,7 +171,7 @@ main(void)
TESTING("duplicate message modification");
stab.btree_addr = 77777777;
stab.heap_addr = 88888888;
- if (H5O_modify(&oh_ent, H5O_STAB, 1, 0, &stab)<0) {
+ if (H5O_modify(&oh_ent, H5O_STAB, 1, 0, 1, &stab)<0) {
H5_FAILED();
H5Eprint(stdout);
goto error;
@@ -204,7 +205,7 @@ main(void)
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, H5O_NEW_MESG, 0, &stab)<0) {
+ if (H5O_modify(&oh_ent, H5O_STAB, H5O_NEW_MESG, 0, 1, &stab)<0) {
H5_FAILED();
H5Eprint(stdout);
goto error;
@@ -225,7 +226,7 @@ main(void)
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, H5O_NEW_MESG, 0, &stab)<0) {
+ if (H5O_modify(&oh_ent, H5O_STAB, H5O_NEW_MESG, 0, 1, &stab)<0) {
H5_FAILED();
H5Eprint(stdout);
goto error;
diff --git a/test/tattr.c b/test/tattr.c
index aea6287..e375ccf 100644
--- a/test/tattr.c
+++ b/test/tattr.c
@@ -100,7 +100,7 @@ test_attr_basic_write(void)
hid_t attr, attr2; /* Attribute ID */
hsize_t attr_size; /* storage size for attribute */
ssize_t attr_name_size; /* size of attribute name */
- char *attr_name; /* name of attribute */
+ char *attr_name=NULL; /* name of attribute */
hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3};
hsize_t dims2[] = {ATTR1_DIM1};
hsize_t dims3[] = {ATTR2_DIM1,ATTR2_DIM2};
@@ -121,6 +121,7 @@ test_attr_basic_write(void)
/* Create a dataset */
dataset=H5Dcreate(fid1,"Dataset1",H5T_NATIVE_UCHAR,sid1,H5P_DEFAULT);
+ CHECK(dataset, FAIL, "H5Dcreate");
/* Create dataspace for attribute */
sid2 = H5Screate_simple(ATTR1_RANK, dims2, NULL);
@@ -161,7 +162,7 @@ test_attr_basic_write(void)
/* Verify values read in */
for(i=0; i<ATTR1_DIM1; i++)
if(attr_data1[i]!=read_data1[i]) {
- printf("attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n",i,attr_data1[i],i,read_data1[i]);
+ printf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n",__LINE__,i,attr_data1[i],i,read_data1[i]);
num_errs++;
} /* end if */
@@ -203,7 +204,7 @@ test_attr_basic_write(void)
/* Verify values read in */
for(i=0; i<ATTR1_DIM1; i++)
if(attr_data1[i]!=read_data1[i]) {
- printf("2. attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n",i,attr_data1[i],i,read_data1[i]);
+ printf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n",__LINE__,i,attr_data1[i],i,read_data1[i]);
num_errs++;
} /* end if */
@@ -238,7 +239,7 @@ test_attr_basic_write(void)
/* Verify values read in */
for(i=0; i<ATTR1_DIM1; i++)
if(attr_data1a[i]!=read_data1[i]) {
- printf("2. attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n",i,attr_data1[i],i,read_data1[i]);
+ printf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n",__LINE__,i,attr_data1[i],i,read_data1[i]);
num_errs++;
} /* end if */
@@ -347,7 +348,7 @@ test_attr_basic_read(void)
/* Verify values read in */
for(i=0; i<ATTR1_DIM1; i++)
if(attr_data1[i]!=read_data1[i]) {
- printf("attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n",i,attr_data1[i],i,read_data1[i]);
+ printf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n",__LINE__,i,attr_data1[i],i,read_data1[i]);
num_errs++;
} /* end if */
@@ -377,7 +378,7 @@ test_attr_basic_read(void)
for(i=0; i<ATTR2_DIM1; i++)
for(j=0; j<ATTR2_DIM2; j++)
if(attr_data2[i][j]!=read_data2[i][j]) {
- printf("attribute data different: attr_data2[%d][%d]=%d, read_data2[%d][%d]=%d\n",i,j,attr_data2[i][j],i,j,read_data1[i]);
+ printf("%d: attribute data different: attr_data2[%d][%d]=%d, read_data2[%d][%d]=%d\n",__LINE__, i,j,attr_data2[i][j],i,j,read_data1[i]);
num_errs++;
} /* end if */
@@ -605,9 +606,9 @@ test_attr_compound_read(void)
for(i=0; i<ATTR4_DIM1; i++)
for(j=0; j<ATTR4_DIM2; j++)
if(HDmemcmp(&attr_data4[i][j],&read_data4[i][j],sizeof(struct attr4_struct))) {
- printf("attribute data different: attr_data4[%d][%d].i=%d, read_data4[%d][%d].i=%d\n",i,j,attr_data4[i][j].i,i,j,read_data4[i][j].i);
- printf("attribute data different: attr_data4[%d][%d].d=%f, read_data4[%d][%d].d=%f\n",i,j,attr_data4[i][j].d,i,j,read_data4[i][j].d);
- printf("attribute data different: attr_data4[%d][%d].c=%c, read_data4[%d][%d].c=%c\n",i,j,attr_data4[i][j].c,i,j,read_data4[i][j].c);
+ printf("%d: attribute data different: attr_data4[%d][%d].i=%d, read_data4[%d][%d].i=%d\n",__LINE__,i,j,attr_data4[i][j].i,i,j,read_data4[i][j].i);
+ printf("%d: attribute data different: attr_data4[%d][%d].d=%f, read_data4[%d][%d].d=%f\n",__LINE__,i,j,attr_data4[i][j].d,i,j,read_data4[i][j].d);
+ printf("%d: attribute data different: attr_data4[%d][%d].c=%c, read_data4[%d][%d].c=%c\n",__LINE__,i,j,attr_data4[i][j].c,i,j,read_data4[i][j].c);
num_errs++;
} /* end if */
@@ -943,7 +944,7 @@ test_attr_mult_read(void)
/* Verify values read in */
for(i=0; i<ATTR1_DIM1; i++)
if(attr_data1[i]!=read_data1[i]) {
- printf("attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n",i,attr_data1[i],i,read_data1[i]);
+ printf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n",__LINE__,i,attr_data1[i],i,read_data1[i]);
num_errs++;
} /* end if */
@@ -1009,7 +1010,7 @@ test_attr_mult_read(void)
for(i=0; i<ATTR2_DIM1; i++)
for(j=0; j<ATTR2_DIM2; j++)
if(attr_data2[i][j]!=read_data2[i][j]) {
- printf("attribute data different: attr_data2[%d][%d]=%d, read_data2[%d][%d]=%d\n",i,j,attr_data2[i][j],i,j,read_data2[i][j]);
+ printf("%d: attribute data different: attr_data2[%d][%d]=%d, read_data2[%d][%d]=%d\n",__LINE__,i,j,attr_data2[i][j],i,j,read_data2[i][j]);
num_errs++;
} /* end if */
@@ -1080,7 +1081,7 @@ test_attr_mult_read(void)
for(j=0; j<ATTR3_DIM2; j++)
for(k=0; k<ATTR3_DIM3; k++)
if(attr_data3[i][j][k]!=read_data3[i][j][k]) {
- printf("attribute data different: attr_data3[%d][%d][%d]=%f, read_data3[%d][%d][%d]=%f\n",i,j,k,attr_data3[i][j][k],i,j,k,read_data3[i][j][k]);
+ printf("%d: attribute data different: attr_data3[%d][%d][%d]=%f, read_data3[%d][%d][%d]=%f\n",__LINE__,i,j,k,attr_data3[i][j][k],i,j,k,read_data3[i][j][k]);
num_errs++;
} /* end if */
diff --git a/test/testhdf5.c b/test/testhdf5.c
index 190cdf3..08d718a 100644
--- a/test/testhdf5.c
+++ b/test/testhdf5.c
@@ -157,6 +157,8 @@ main(int argc, char *argv[])
InitTest("configure", test_configure, cleanup_configure, "Configure definitions");
InitTest("metadata", test_metadata, cleanup_metadata, "Encode/decode metadata code");
InitTest("tbbt", test_tbbt, NULL, "Threaded, Balanced, Binary Trees");
+ InitTest("tst", test_tst, NULL, "Ternary Search Trees");
+ InitTest("refstr", test_refstr, NULL, "Reference Counted Strings");
InitTest("file", test_file, cleanup_file, "Low-Level File I/O");
InitTest("h5s", test_h5s, cleanup_h5s, "Dataspaces");
InitTest("attr", test_attr, cleanup_attr, "Attributes");
diff --git a/test/testhdf5.h b/test/testhdf5.h
index 0868983..f89e1dc 100644
--- a/test/testhdf5.h
+++ b/test/testhdf5.h
@@ -121,6 +121,8 @@ int print_func(const char *,...);
/* Prototypes for the test routines */
void test_metadata(void);
void test_tbbt(void);
+void test_tst(void);
+void test_refstr(void);
void test_file(void);
void test_h5t(void);
void test_h5s(void);
diff --git a/test/tgenprop.c b/test/tgenprop.c
index 4ea91e4..9192a82 100644
--- a/test/tgenprop.c
+++ b/test/tgenprop.c
@@ -33,11 +33,9 @@
/* Property definitions */
#define CLASS1_NAME "Class 1"
#define CLASS1_PATH "root/Class 1"
-#define CLASS1_HASHSIZE 25
#define CLASS2_NAME "Class 2"
#define CLASS2_PATH "root/Class 1/Class 2"
-#define CLASS2_HASHSIZE 25
/* Property definitions */
#define PROP1_NAME "Property 1"
@@ -79,7 +77,7 @@ test_genprop_basic_class(void)
MESSAGE(5, ("Testing Basic Generic Property List Class Creation Functionality\n"));
/* Create a new generic class, derived from the root of the class hierarchy */
- cid1 = H5Pcreate_class(H5P_NO_CLASS,CLASS1_NAME,CLASS1_HASHSIZE,NULL,NULL,NULL,NULL,NULL,NULL);
+ cid1 = H5Pcreate_class(H5P_NO_CLASS,CLASS1_NAME,NULL,NULL,NULL,NULL,NULL,NULL);
CHECK_I(cid1, "H5Pcreate_class");
/* Check class name */
@@ -112,7 +110,7 @@ test_genprop_basic_class(void)
CHECK_I(ret, "H5Pclose_class");
/* Create another new generic class, derived from file creation class */
- cid1 = H5Pcreate_class(H5P_FILE_CREATE,CLASS2_NAME,CLASS2_HASHSIZE,NULL,NULL,NULL,NULL,NULL,NULL);
+ cid1 = H5Pcreate_class(H5P_FILE_CREATE,CLASS2_NAME,NULL,NULL,NULL,NULL,NULL,NULL);
CHECK_I(cid1, "H5Pcreate_class");
/* Check class name */
@@ -171,7 +169,7 @@ test_genprop_basic_class_prop(void)
MESSAGE(5, ("Testing Basic Generic Property List Class Properties Functionality\n"));
/* Create a new generic class, derived from the root of the class hierarchy */
- cid1 = H5Pcreate_class(H5P_NO_CLASS,CLASS1_NAME,CLASS1_HASHSIZE,NULL,NULL,NULL,NULL,NULL,NULL);
+ cid1 = H5Pcreate_class(H5P_NO_CLASS,CLASS1_NAME,NULL,NULL,NULL,NULL,NULL,NULL);
CHECK_I(cid1, "H5Pcreate_class");
/* Check the number of properties in class */
@@ -327,7 +325,7 @@ test_genprop_class_iter(void)
MESSAGE(5, ("Testing Basic Generic Property List Class Property Iteration Functionality\n"));
/* Create a new generic class, derived from the root of the class hierarchy */
- cid1 = H5Pcreate_class(H5P_NO_CLASS,CLASS1_NAME,CLASS1_HASHSIZE,NULL,NULL,NULL,NULL,NULL,NULL);
+ cid1 = H5Pcreate_class(H5P_NO_CLASS,CLASS1_NAME,NULL,NULL,NULL,NULL,NULL,NULL);
CHECK_I(cid1, "H5Pcreate_class");
/* Insert first property into class (with no callbacks) */
@@ -423,7 +421,7 @@ test_genprop_class_callback(void)
MESSAGE(5, ("Testing Basic Generic Property List Class Callback Functionality\n"));
/* Create a new generic class, derived from the root of the class hierarchy */
- cid1 = H5Pcreate_class(H5P_NO_CLASS,CLASS1_NAME,CLASS1_HASHSIZE,test_genprop_cls_cb1,&crt_cb_struct,NULL,NULL,test_genprop_cls_cb1,&cls_cb_struct);
+ cid1 = H5Pcreate_class(H5P_NO_CLASS,CLASS1_NAME,test_genprop_cls_cb1,&crt_cb_struct,NULL,NULL,test_genprop_cls_cb1,&cls_cb_struct);
CHECK_I(cid1, "H5Pcreate_class");
/* Insert first property into class (with no callbacks) */
@@ -522,7 +520,7 @@ test_genprop_basic_list(void)
MESSAGE(5, ("Testing Basic Generic Property List Creation Functionality\n"));
/* Create a new generic class, derived from the root of the class hierarchy */
- cid1 = H5Pcreate_class(H5P_NO_CLASS,CLASS1_NAME,CLASS1_HASHSIZE,NULL,NULL,NULL,NULL,NULL,NULL);
+ cid1 = H5Pcreate_class(H5P_NO_CLASS,CLASS1_NAME,NULL,NULL,NULL,NULL,NULL,NULL);
CHECK_I(cid1, "H5Pcreate_class");
/* Add several properties (w/default values) */
@@ -624,7 +622,7 @@ test_genprop_basic_list_prop(void)
MESSAGE(5, ("Testing Basic Generic Property List Property Functionality\n"));
/* Create a new generic class, derived from the root of the class hierarchy */
- cid1 = H5Pcreate_class(H5P_NO_CLASS,CLASS1_NAME,CLASS1_HASHSIZE,NULL,NULL,NULL,NULL,NULL,NULL);
+ cid1 = H5Pcreate_class(H5P_NO_CLASS,CLASS1_NAME,NULL,NULL,NULL,NULL,NULL,NULL);
CHECK_I(cid1, "H5Pcreate_class");
/* Add several properties (several w/default values) */
@@ -771,17 +769,18 @@ test_genprop_list_iter(void)
const char **names;
} iter_struct;
const char *pnames[4]={ /* Names of properties for iterator */
- PROP1_NAME,
- PROP2_NAME,
PROP3_NAME,
- PROP4_NAME};
+ PROP4_NAME,
+ PROP1_NAME,
+ PROP2_NAME
+ };
herr_t ret; /* Generic return value */
/* Output message about test being performed */
MESSAGE(5, ("Testing Generic Property List Iteration Functionality\n"));
/* Create a new generic class, derived from the root of the class hierarchy */
- cid1 = H5Pcreate_class(H5P_NO_CLASS,CLASS1_NAME,CLASS1_HASHSIZE,NULL,NULL,NULL,NULL,NULL,NULL);
+ cid1 = H5Pcreate_class(H5P_NO_CLASS,CLASS1_NAME,NULL,NULL,NULL,NULL,NULL,NULL);
CHECK_I(cid1, "H5Pcreate_class");
/* Add several properties (several w/default values) */
@@ -1020,7 +1019,7 @@ test_genprop_list_callback(void)
MESSAGE(5, ("Testing Basic Generic Property List Property Callback Functionality\n"));
/* Create a new generic class, derived from the root of the class hierarchy */
- cid1 = H5Pcreate_class(H5P_NO_CLASS,CLASS1_NAME,CLASS1_HASHSIZE,NULL,NULL,test_genprop_cls_cb2,&cop_cb_struct,NULL,NULL);
+ cid1 = H5Pcreate_class(H5P_NO_CLASS,CLASS1_NAME,NULL,NULL,test_genprop_cls_cb2,&cop_cb_struct,NULL,NULL);
CHECK_I(cid1, "H5Pcreate_class");
/* Insert first property into class (with callbacks) */
@@ -1308,7 +1307,7 @@ test_genprop_class_addprop(void)
CHECK(sid, FAIL, "H5Screate");
/* Create a new class, dervied from the dataset creation property list class */
- cid = H5Pcreate_class(H5P_DATASET_CREATE,CLASS1_NAME,CLASS1_HASHSIZE,NULL,NULL,NULL,NULL,NULL,NULL);
+ cid = H5Pcreate_class(H5P_DATASET_CREATE,CLASS1_NAME,NULL,NULL,NULL,NULL,NULL,NULL);
CHECK_I(cid, "H5Pcreate_class");
/* Check existence of an original property */
@@ -1389,8 +1388,7 @@ test_genprop_equal(void)
MESSAGE(5, ("Testing Basic Generic Property List Equal Functionality\n"));
/* Create a new generic class, derived from the root of the class hierarchy */
- /* (Use a hash size of 1 to force the properties into the same hash chain) */
- cid1 = H5Pcreate_class(H5P_NO_CLASS,CLASS1_NAME,1,NULL,NULL,NULL,NULL,NULL,NULL);
+ cid1 = H5Pcreate_class(H5P_NO_CLASS,CLASS1_NAME,NULL,NULL,NULL,NULL,NULL,NULL);
CHECK_I(cid1, "H5Pcreate_class");
/* Insert first property into class (with no callbacks) */
@@ -1438,7 +1436,7 @@ test_genprop_path(void)
MESSAGE(5, ("Testing Generic Property List Class Path Functionality\n"));
/* Create a new generic class, derived from the root of the class hierarchy */
- cid1 = H5Pcreate_class(H5P_NO_CLASS,CLASS1_NAME,CLASS1_HASHSIZE,NULL,NULL,NULL,NULL,NULL,NULL);
+ cid1 = H5Pcreate_class(H5P_NO_CLASS,CLASS1_NAME,NULL,NULL,NULL,NULL,NULL,NULL);
CHECK_I(cid1, "H5Pcreate_class");
/* Insert first property into class (with no callbacks) */
@@ -1455,7 +1453,7 @@ test_genprop_path(void)
free(path);
/* Create another new generic class, derived from first class */
- cid2 = H5Pcreate_class(cid1,CLASS2_NAME,CLASS2_HASHSIZE,NULL,NULL,NULL,NULL,NULL,NULL);
+ cid2 = H5Pcreate_class(cid1,CLASS2_NAME,NULL,NULL,NULL,NULL,NULL,NULL);
CHECK_I(cid2, "H5Pcreate_class");
/* Insert second property into class (with no callbacks) */
@@ -1513,7 +1511,7 @@ test_genprop_refcount(void)
MESSAGE(5, ("Testing Generic Property List Reference Count Functionality\n"));
/* Create a new generic class, derived from the root of the class hierarchy */
- cid1 = H5Pcreate_class(H5P_NO_CLASS,CLASS1_NAME,CLASS1_HASHSIZE,NULL,NULL,NULL,NULL,NULL,NULL);
+ cid1 = H5Pcreate_class(H5P_NO_CLASS,CLASS1_NAME,NULL,NULL,NULL,NULL,NULL,NULL);
CHECK_I(cid1, "H5Pcreate_class");
/* Insert first property into class (with no callbacks) */
diff --git a/test/titerate.c b/test/titerate.c
index 02819a0..8f5d3c8 100644
--- a/test/titerate.c
+++ b/test/titerate.c
@@ -194,12 +194,12 @@ static void test_iter_group(void)
ret = H5Gget_objname_by_idx(root_group, (hsize_t)i, dataset_name, 32);
CHECK(ret, FAIL, "H5Gget_objsname_by_idx");
- ret = H5Gget_objtype_by_idx(root_group, (hsize_t)i);
- CHECK(ret, H5G_UNKNOWN, "H5Gget_objsname_by_idx");
+ ret = (herr_t)H5Gget_objtype_by_idx(root_group, (hsize_t)i);
+ CHECK(ret, FAIL, "H5Gget_objsname_by_idx");
}
H5E_BEGIN_TRY {
- ret = H5Gget_objname_by_idx(root_group, (hsize_t)(NDATASETS+3), dataset_name, 16);
+ ret = (herr_t)H5Gget_objname_by_idx(root_group, (hsize_t)(NDATASETS+3), dataset_name, 16);
} H5E_END_TRY;
VERIFY(ret, FAIL, "H5Gget_objsname_by_idx");
@@ -664,7 +664,7 @@ static void test_grp_memb_funcs(void)
VERIFY(num_membs,NDATASETS+2,"H5Gget_num_objs");
for(i=0; i< (int)num_membs; i++) {
- ret = H5Gget_objname_by_idx(root_group, (hsize_t)i, dataset_name, 32);
+ ret = (herr_t)H5Gget_objname_by_idx(root_group, (hsize_t)i, dataset_name, 32);
CHECK(ret, FAIL, "H5Gget_objsname_by_idx");
/* Keep a copy of the dataset names around for later */
@@ -683,7 +683,7 @@ static void test_grp_memb_funcs(void)
}
H5E_BEGIN_TRY {
- ret = H5Gget_objname_by_idx(root_group, (hsize_t)(NDATASETS+3), dataset_name, 16);
+ ret = (herr_t)H5Gget_objname_by_idx(root_group, (hsize_t)(NDATASETS+3), dataset_name, 16);
} H5E_END_TRY;
VERIFY(ret, FAIL, "H5Gget_objsname_by_idx");
@@ -704,8 +704,10 @@ static void test_grp_memb_funcs(void)
CHECK(ret, FAIL, "H5Fclose");
/* Free the dataset names */
- for(i=0; i< NDATASETS+2; i++)
+ for(i=0; i< NDATASETS+2; i++) {
free(dnames[i]);
+ free(obj_names[i]);
+ }
} /* test_grp_memb_funcs() */
diff --git a/test/tmtimen.h5 b/test/tmtimen.h5
new file mode 100644
index 0000000..96e5fb3
--- /dev/null
+++ b/test/tmtimen.h5
Binary files differ
diff --git a/test/tmtimeo.h5 b/test/tmtimeo.h5
new file mode 100644
index 0000000..8c0f02d
--- /dev/null
+++ b/test/tmtimeo.h5
Binary files differ
diff --git a/test/trefstr.c b/test/trefstr.c
new file mode 100644
index 0000000..374e954
--- /dev/null
+++ b/test/trefstr.c
@@ -0,0 +1,378 @@
+/****************************************************************************
+ * 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$ */
+
+/*
+ FILE
+ refstr.c
+ Test HDF reference counted string routines.
+
+ REMARKS
+
+ DESIGN
+
+ BUGS/LIMITATIONS
+
+ EXPORTED ROUTINES
+
+ AUTHOR
+ Quincey Koziol
+
+ MODIFICATION HISTORY
+ 12/17/02 - Started coding
+ */
+
+#include "testhdf5.h"
+#include "H5FLprivate.h"
+#include "H5RSprivate.h"
+
+/* Declare extern the PQ free list for the wrapped strings */
+H5FL_BLK_EXTERN(str_buf);
+
+/****************************************************************
+**
+** test_refstr_init(): Test basic H5RS (ref-counted strings) code.
+** Initialize data for RS testing
+**
+****************************************************************/
+static void
+test_refstr_init(void)
+{
+} /* end test_refstr_init() */
+
+/****************************************************************
+**
+** test_refstr_create(): Test basic H5RS (ref-counted strings) code.
+** Tests creating and closing ref-counted strings.
+**
+****************************************************************/
+static void
+test_refstr_create(void)
+{
+ H5RS_str_t *rs; /* Ref-counted string created */
+ unsigned count; /* Reference count on string */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing Creating & Closing Ref-Counted Strings\n"));
+
+ /* Try creating a ref-counted string */
+ rs=H5RS_create("foo");
+ CHECK(rs, NULL, "H5RS_create");
+
+ /* Get the reference count on the string */
+ count=H5RS_GET_COUNT(rs);
+ VERIFY(count, 1, "H5RS_GET_COUNT");
+
+ /* Try closing a real ref-counted string */
+ ret=H5RS_decr(rs);
+ CHECK(ret, FAIL, "H5RS_decr");
+
+} /* end test_refstr_create() */
+
+/****************************************************************
+**
+** test_refstr_count(): Test basic H5RS (ref-counted strings) code.
+** Tests reference counting on ref-counted strings.
+**
+****************************************************************/
+static void
+test_refstr_count(void)
+{
+ H5RS_str_t *rs; /* Ref-counted string created */
+ unsigned count; /* Reference count on string */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing Incrementing & Decrementing Ref-Counted Strings\n"));
+
+ /* Try creating a ref-counted string */
+ rs=H5RS_create("foo");
+ CHECK(rs, NULL, "H5RS_create");
+
+ /* Get the reference count on the string */
+ count=H5RS_GET_COUNT(rs);
+ VERIFY(count, 1, "H5RS_GET_COUNT");
+
+ /* Increment reference count */
+ ret=H5RS_incr(rs);
+ CHECK(ret, FAIL, "H5RS_incr");
+
+ /* Get the reference count on the string */
+ count=H5RS_GET_COUNT(rs);
+ VERIFY(count, 2, "H5RS_GET_COUNT");
+
+ /* Decrement reference count for string */
+ ret=H5RS_decr(rs);
+ CHECK(ret, FAIL, "H5RS_decr");
+
+ /* Get the reference count on the string */
+ count=H5RS_GET_COUNT(rs);
+ VERIFY(count, 1, "H5RS_GET_COUNT");
+
+ /* Decrement reference count for string */
+ ret=H5RS_decr(rs);
+ CHECK(ret, FAIL, "H5RS_decr");
+
+} /* end test_refstr_count() */
+
+/****************************************************************
+**
+** test_refstr_dup(): Test basic H5RS (ref-counted strings) code.
+** Tests duplicating ref-counted strings.
+**
+****************************************************************/
+static void
+test_refstr_dup(void)
+{
+ H5RS_str_t *rs1; /* Ref-counted string created */
+ H5RS_str_t *rs2; /* Ref-counted string created */
+ unsigned count; /* Reference count on string */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing Duplicating Ref-Counted Strings\n"));
+
+ /* Try creating a ref-counted string */
+ rs1=H5RS_create("foo");
+ CHECK(rs1, NULL, "H5RS_create");
+
+ /* Get the reference count on the string */
+ count=H5RS_GET_COUNT(rs1);
+ VERIFY(count, 1, "H5RS_GET_COUNT");
+
+ /* Duplicate r-string */
+ rs2=H5RS_dup(rs1);
+ CHECK(rs2, NULL, "H5RS_dup");
+
+ /* Get the reference count on the strings */
+ count=H5RS_GET_COUNT(rs1);
+ VERIFY(count, 2, "H5RS_GET_COUNT");
+ count=H5RS_GET_COUNT(rs2);
+ VERIFY(count, 2, "H5RS_GET_COUNT");
+
+ /* Decrement reference count for string */
+ ret=H5RS_decr(rs2);
+ CHECK(ret, FAIL, "H5RS_decr");
+
+ /* Get the reference count on the string */
+ count=H5RS_GET_COUNT(rs1);
+ VERIFY(count, 1, "H5RS_GET_COUNT");
+
+ /* Decrement reference count for string */
+ ret=H5RS_decr(rs1);
+ CHECK(ret, FAIL, "H5RS_decr");
+
+} /* end test_refstr_dup() */
+
+/****************************************************************
+**
+** test_refstr_cmp(): Test basic H5RS (ref-counted strings) code.
+** Tests comparing ref-counted strings.
+**
+****************************************************************/
+static void
+test_refstr_cmp(void)
+{
+ H5RS_str_t *rs1; /* Ref-counted string created */
+ H5RS_str_t *rs2; /* Ref-counted string created */
+ int cmp; /* Comparison value */
+ ssize_t len; /* Length of string */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing Comparing Ref-Counted Strings\n"));
+
+ /* Create first reference counted string */
+ rs1=H5RS_create("foo");
+ CHECK(rs1, NULL, "H5RS_create");
+
+ /* Create second reference counted string */
+ rs2=H5RS_create("foo2");
+ CHECK(rs2, NULL, "H5RS_create");
+
+ /* Compare the strings in various ways */
+ cmp=H5RS_cmp(rs1,rs1);
+ VERIFY(cmp, 0, "H5RS_cmp");
+ cmp=H5RS_cmp(rs2,rs2);
+ VERIFY(cmp, 0, "H5RS_cmp");
+ cmp=H5RS_cmp(rs1,rs2);
+ if(cmp>=0) {
+ num_errs++;
+ printf("%d: string comparison incorrect!\n",__LINE__);
+ } /* end if */
+
+ /* Check the lengths of the strings also */
+ len=H5RS_len(rs1);
+ VERIFY(len, 3, "H5RS_len");
+ len=H5RS_len(rs2);
+ VERIFY(len, 4, "H5RS_len");
+
+ /* Decrement reference count for strings */
+ ret=H5RS_decr(rs2);
+ CHECK(ret, FAIL, "H5RS_decr");
+ ret=H5RS_decr(rs1);
+ CHECK(ret, FAIL, "H5RS_decr");
+
+} /* end test_refstr_cmp() */
+
+/****************************************************************
+**
+** test_refstr_wrap(): Test basic H5RS (ref-counted strings) code.
+** Tests wrapping ref-counted strings around existing strings.
+**
+****************************************************************/
+static void
+test_refstr_wrap(void)
+{
+ H5RS_str_t *rs; /* Ref-counted string created */
+ const char *s; /* Pointer to raw string in ref-counted string */
+ char buf[16]; /* Buffer to wrap */
+ int cmp; /* Comparison value */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing Wrapping Ref-Counted Strings\n"));
+
+ /* Initialize buffer */
+ HDstrcpy(buf,"foo");
+
+ /* Wrap ref-counted string around existing buffer */
+ rs=H5RS_wrap(buf);
+ CHECK(rs, NULL, "H5RS_wrap");
+
+ /* Get pointer to raw string in ref-counted string */
+ s=H5RS_GET_STR(rs);
+ CHECK(s, NULL, "H5RS_GET_STR");
+ VERIFY(s, buf, "wrapping");
+ cmp=HDstrcmp(s,buf);
+ VERIFY(cmp, 0, "HDstrcmp");
+
+ /* Increment reference count (should duplicate string) */
+ ret=H5RS_incr(rs);
+ CHECK(ret, FAIL, "H5RS_incr");
+
+ /* Change the buffer initially wrapped */
+ buf[0]='F';
+
+ /* Get pointer to raw string in ref-counted string */
+ s=H5RS_GET_STR(rs);
+ CHECK(s, NULL, "H5RS_GET_STR");
+ CHECK(s, buf, "wrapping");
+ cmp=HDstrcmp(s,buf);
+ if(cmp<=0) {
+ num_errs++;
+ printf("%d: string comparison incorrect!\n",__LINE__);
+ } /* end if */
+
+ /* Decrement reference count for string */
+ ret=H5RS_decr(rs);
+ CHECK(ret, FAIL, "H5RS_decr");
+ ret=H5RS_decr(rs);
+ CHECK(ret, FAIL, "H5RS_decr");
+
+} /* end test_refstr_wrap() */
+
+/****************************************************************
+**
+** test_refstr_own(): Test basic H5RS (ref-counted strings) code.
+** Tests transferring ownership of dynamically allocated strings
+** to ref-counted strings.
+**
+****************************************************************/
+static void
+test_refstr_own(void)
+{
+ H5RS_str_t *rs; /* Ref-counted string created */
+ char *s; /* Pointer to string to transfer */
+ const char *t; /* Temporary pointers to string */
+ int cmp; /* Comparison value */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing Transferring Ref-Counted Strings\n"));
+
+ /* Initialize buffer */
+ s = H5FL_BLK_MALLOC(str_buf,HDstrlen("foo") + 1);
+ HDstrcpy(s, "foo");
+
+ /* Transfer ownership of dynamically allocated string to ref-counted string */
+ rs=H5RS_own(s);
+ CHECK(rs, NULL, "H5RS_own");
+
+ /* Get pointer to raw string in ref-counted string */
+ t=H5RS_GET_STR(rs);
+ CHECK(t, NULL, "H5RS_GET_STR");
+ VERIFY(t, s, "transferring");
+ cmp=HDstrcmp(s,t);
+ VERIFY(cmp, 0, "HDstrcmp");
+
+ /* Increment reference count (should NOT duplicate string) */
+ ret=H5RS_incr(rs);
+ CHECK(ret, FAIL, "H5RS_incr");
+
+ /* Change the buffer initially wrapped */
+ *s='F';
+
+ /* Get pointer to raw string in ref-counted string */
+ t=H5RS_GET_STR(rs);
+ CHECK(t, NULL, "H5RS_GET_STR");
+ VERIFY(t, s, "transferring");
+ cmp=HDstrcmp(t,s);
+ VERIFY(cmp, 0, "HDstrcmp");
+
+ /* Decrement reference count for string */
+ ret=H5RS_decr(rs);
+ CHECK(ret, FAIL, "H5RS_decr");
+ ret=H5RS_decr(rs);
+ CHECK(ret, FAIL, "H5RS_decr");
+
+} /* end test_refstr_own() */
+
+/****************************************************************
+**
+** test_refstr_finalize(): Test basic H5RS (ref-counted strings) code.
+** Wrap up data for ref-counted string testing
+**
+****************************************************************/
+static void
+test_refstr_finalize(void)
+{
+} /* end test_refstr_finalize() */
+
+/****************************************************************
+**
+** test_refstr(): Main H5RS testing routine.
+**
+****************************************************************/
+void
+test_refstr(void)
+{
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing Reference Counted Strings\n"));
+
+ /* Initialize ref-counted strings testing data */
+ test_refstr_init();
+
+ /* Actual ref-counted strings tests */
+ test_refstr_create(); /* Test ref-counted string creation */
+ test_refstr_count(); /* Test ref-counted string counting */
+ test_refstr_dup(); /* Test ref-counted string duplication */
+ test_refstr_cmp(); /* Test ref-counted string comparison */
+ test_refstr_wrap(); /* Test ref-counted string wrapping */
+ test_refstr_own(); /* Test ref-counted string ownership transfer */
+
+ /* Finalize ref-counted strings testing data */
+ test_refstr_finalize();
+} /* end test_refstr() */
+
diff --git a/test/ttst.c b/test/ttst.c
new file mode 100644
index 0000000..eb9ebef
--- /dev/null
+++ b/test/ttst.c
@@ -0,0 +1,400 @@
+/****************************************************************************
+ * 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$ */
+
+/*
+ FILE
+ tst.c
+ Test HDF Ternary Search Tree (tst) routines.
+
+ REMARKS
+
+ DESIGN
+
+ BUGS/LIMITATIONS
+
+ EXPORTED ROUTINES
+
+ AUTHOR
+ Quincey Koziol
+
+ MODIFICATION HISTORY
+ 12/9/02 - Started coding
+ */
+
+#include <time.h>
+
+#include "testhdf5.h"
+#include "H5STprivate.h"
+
+/* Test words to insert into s TST */
+static const char *words[]={
+ "We", "hold", "these", "truths", "to", "be", "self-evident,", "that",
+ "all", "men", "are", "created", "equal,", "that", "they", "are", "endowed",
+ "by", "their", "Creator", "with", "certain", "unalienable", "Rights,",
+ "that", "among", "these", "are", "Life,", "Liberty", "and", "the",
+ "pursuit", "of", "Happiness."
+};
+/* Number of words in test words set */
+size_t num_words;
+
+/* Number of unique words in test word set */
+size_t num_uniq_words;
+/* Unique words in test word set */
+char **uniq_words;
+/* Randomized order version of words in test word set */
+char **rand_uniq_words;
+/* Sorted order version of words in test word set */
+char **sort_uniq_words;
+
+static int tst_strcmp(const void *_s1, const void *_s2)
+{
+ return(HDstrcmp(*(const char **)_s1,*(const char **)_s2));
+}
+
+/****************************************************************
+**
+** test_tst_init(): Test basic H5ST (ternary search tree) selection code.
+** Initialize data for TST testing
+**
+****************************************************************/
+static void
+test_tst_init(void)
+{
+ time_t curr_time; /* Current time, for seeding random number generator */
+ char *tmp_word=NULL;/* Temporary pointer to word in word set */
+ size_t u,v,w; /* Local index variables */
+
+ /* Compute the number of words in the test set */
+ num_words=sizeof(words)/sizeof(words[0]);
+
+ /* Determine the number of unique words in test set */
+ /* (Not particularly efficient, be careful if many words are added to set) */
+ num_uniq_words=0;
+ for(u=0; u<num_words; u++) {
+ /* Assume word is unique */
+ num_uniq_words++;
+ for(v=0; v<u; v++)
+ /* If word is already found in words looked at, decrement unique count */
+ if(!HDstrcmp(words[u],words[v])) {
+ num_uniq_words--;
+ break;
+ } /* end if */
+ } /* end for */
+
+ /* Allocate space for the array of unique words */
+ uniq_words=HDmalloc(sizeof(char *)*num_uniq_words);
+
+ /* Allocate space for the array of randomized order unique words also */
+ rand_uniq_words=HDmalloc(sizeof(char *)*num_uniq_words);
+
+ /* Allocate space for the array of sorted order unique words also */
+ sort_uniq_words=HDmalloc(sizeof(char *)*num_uniq_words);
+
+ /* Insert unique words from test set into unique word set */
+ w=0;
+ for(u=0; u<num_words; u++) {
+ /* Assume word is unique */
+ tmp_word=(char *)words[u];
+ for(v=0; v<u; v++)
+ /* If word is already found in words looked at, decrement unique count */
+ if(!HDstrcmp(words[u],words[v])) {
+ tmp_word=NULL;
+ break;
+ } /* end if */
+
+ /* Check if word was actually unique */
+ if(tmp_word!=NULL)
+ uniq_words[w++]=tmp_word;
+ } /* end for */
+
+ /* Create randomized set of unique words */
+ for(u=0; u<num_uniq_words; u++)
+ rand_uniq_words[u]=uniq_words[u];
+ curr_time=time(NULL);
+ srandom((unsigned long)curr_time);
+ for(u=0; u<num_uniq_words; u++) {
+ v=u+(random()%(num_uniq_words-u));
+ if(u!=v) {
+ tmp_word=rand_uniq_words[u];
+ rand_uniq_words[u]=rand_uniq_words[v];
+ rand_uniq_words[v]=tmp_word;
+ } /* end if */
+ } /* end for */
+
+ /* Create sorted set of unique words */
+ for(u=0; u<num_uniq_words; u++)
+ sort_uniq_words[u]=uniq_words[u];
+ HDqsort(sort_uniq_words,num_uniq_words,sizeof(char *),tst_strcmp);
+} /* end test_tst_init() */
+
+/****************************************************************
+**
+** test_tst_create(): Test basic H5ST (ternary search tree) selection code.
+** Tests creating and closing TSTs.
+**
+****************************************************************/
+static void
+test_tst_create(void)
+{
+ H5ST_tree_t *tree; /* TST created */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing Creating & Closing TSTs\n"));
+
+ /* Try closing a NULL tree */
+ tree=NULL;
+ ret=H5ST_close(tree);
+ VERIFY(ret, FAIL, "H5ST_close");
+
+ /* Try creating a TST */
+ tree=H5ST_create();
+ CHECK(tree, NULL, "H5ST_create");
+
+ /* Try closing a real tree */
+ ret=H5ST_close(tree);
+ CHECK(ret, FAIL, "H5ST_close");
+
+} /* end test_tst_create() */
+
+/****************************************************************
+**
+** test_tst_insert(): Test basic H5ST (ternary search tree) selection code.
+** Tests inserting key/value pairs into TST
+**
+****************************************************************/
+static void
+test_tst_insert(void)
+{
+ H5ST_tree_t *tree; /* TST created */
+ H5ST_ptr_t found; /* Pointer to TST node found */
+ void *obj; /* Pointer to object located in TST */
+ size_t u; /* Local index counter */
+ htri_t check; /* Is string in TST? */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing Inserting Values into TSTs\n"));
+
+ /* Create the TST */
+ tree=H5ST_create();
+ CHECK(tree, NULL, "H5ST_create");
+
+ /* Insert unique words into TST, in random order */
+ for(u=0; u<num_uniq_words; u++) {
+ ret=H5ST_insert(tree,rand_uniq_words[u],rand_uniq_words[u]);
+ CHECK(ret, FAIL, "H5ST_insert");
+ } /* end for */
+
+ /* Verify that all words were inserted into TST properly */
+ for(u=0; u<num_uniq_words; u++) {
+ /* Check that the word is present */
+ check=H5ST_search(tree,uniq_words[u]);
+ VERIFY(check, TRUE, "H5ST_search");
+
+ /* Check that the value "payloads" are correct */
+ found=H5ST_find(tree,uniq_words[u]);
+ CHECK(found, NULL, "H5ST_find");
+
+ if(HDstrcmp((const char *)found->eqkid,uniq_words[u])) {
+ num_errs++;
+ printf("%d: TST node values don't match!, found->eqkid=%s, uniq_words[%u]=%s\n",__LINE__,(char *)found->eqkid,(unsigned)u,uniq_words[u]);
+ } /* end if */
+
+ obj=H5ST_locate(tree,uniq_words[u]);
+ CHECK(obj, NULL, "H5ST_locate");
+
+ if(HDstrcmp((const char *)obj,uniq_words[u])) {
+ num_errs++;
+ printf("%d: TST objects don't match!, obj=%s, uniq_words[%u]=%s\n",__LINE__,(char *)obj,(unsigned)u,uniq_words[u]);
+ } /* end if */
+ } /* end for */
+
+ /* Verify that words not in the TST aren't found */
+ check=H5ST_search(tree,"foo");
+ VERIFY(check, FALSE, "H5ST_search");
+ check=H5ST_search(tree,"bar");
+ VERIFY(check, FALSE, "H5ST_search");
+ check=H5ST_search(tree,"baz");
+ VERIFY(check, FALSE, "H5ST_search");
+
+ /* Close the TST */
+ ret=H5ST_close(tree);
+ CHECK(ret, FAIL, "H5ST_close");
+} /* end test_tst_insert() */
+
+/****************************************************************
+**
+** test_tst_iterate(): Test basic H5ST (ternary search tree) code.
+** Tests iterating through key/value pairs in TST
+**
+****************************************************************/
+static void
+test_tst_iterate(void)
+{
+ H5ST_tree_t *tree; /* TST created */
+ H5ST_ptr_t found; /* Pointer to TST node found */
+ size_t u; /* Local index counter */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing Iterating Over TSTs\n"));
+
+ /* Create the TST */
+ tree=H5ST_create();
+ CHECK(tree, NULL, "H5ST_create");
+
+ /* Insert unique words into TST, in random order */
+ for(u=0; u<num_uniq_words; u++) {
+ ret=H5ST_insert(tree,rand_uniq_words[u],rand_uniq_words[u]);
+ CHECK(ret, FAIL, "H5ST_insert");
+ } /* end for */
+
+ /* Use findfirst/findnext calls to iterate through TST */
+ found=H5ST_findfirst(tree);
+ CHECK(found, NULL, "H5ST_findfirst");
+ u=0;
+ do {
+ /* Check that the strings in the TST are in the correct order */
+ if(HDstrcmp((const char *)found->eqkid,sort_uniq_words[u])) {
+ num_errs++;
+ printf("%d: TST node values don't match!, found->eqkid=%s, sort_uniq_words[%u]=%s\n",__LINE__,(char *)found->eqkid,(unsigned)u,sort_uniq_words[u]);
+ } /* end if */
+
+ /* Advance to next string in TST */
+ found=H5ST_findnext(found);
+ u++;
+ } while(found!=NULL);
+
+ /* Close the TST */
+ ret=H5ST_close(tree);
+ CHECK(ret, FAIL, "H5ST_close");
+} /* end test_tst_iterate() */
+
+/****************************************************************
+**
+** test_tst_remove(): Test basic H5ST (ternary search tree) code.
+** Tests removing key/value pairs by string value in TST
+**
+****************************************************************/
+static void
+test_tst_remove(void)
+{
+ H5ST_tree_t *tree; /* TST created */
+ H5ST_ptr_t found; /* Pointer to TST node found */
+ void *obj; /* Pointer to object removed from TST */
+ htri_t check; /* Is string in TST? */
+ size_t u; /* Local index counter */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing Removing String Values from TSTs\n"));
+
+ /* Create the TST */
+ tree=H5ST_create();
+ CHECK(tree, NULL, "H5ST_create");
+
+ /* Insert unique words into TST, in random order */
+ for(u=0; u<num_uniq_words; u++) {
+ ret=H5ST_insert(tree,rand_uniq_words[u],rand_uniq_words[u]);
+ CHECK(ret, FAIL, "H5ST_insert");
+ } /* end for */
+
+ /* Remove strings from TST in random order */
+ for(u=0; u<num_uniq_words; u++) {
+ obj=H5ST_remove(tree,rand_uniq_words[u]);
+ CHECK(obj, NULL, "H5ST_remove");
+
+ /* Check that the correct string was removed from TST */
+ if(HDstrcmp((const char *)obj,rand_uniq_words[u])) {
+ num_errs++;
+ printf("%d: TST node values don't match!, obj=%s, rand_uniq_words[%u]=%s\n",__LINE__,(char *)obj,(unsigned)u,rand_uniq_words[u]);
+ } /* end if */
+
+ /* Check that the string can't be found in the TST any longer */
+ check=H5ST_search(tree,rand_uniq_words[u]);
+ VERIFY(check, FALSE, "H5ST_search");
+ } /* end for */
+
+ /* Re-insert unique words into TST, in random order */
+ for(u=0; u<num_uniq_words; u++) {
+ ret=H5ST_insert(tree,rand_uniq_words[u],rand_uniq_words[u]);
+ CHECK(ret, FAIL, "H5ST_insert");
+ } /* end for */
+
+ /* Remove TST nodes from TST in random order */
+ for(u=0; u<num_uniq_words; u++) {
+ /* Get the pointer to the node to delete */
+ found=H5ST_find(tree,rand_uniq_words[u]);
+ CHECK(found, NULL, "H5ST_find");
+
+ /* Check that the correct object will be removed from TST */
+ if(HDstrcmp((const char *)found->eqkid,rand_uniq_words[u])) {
+ num_errs++;
+ printf("%d: TST node values don't match!, found->eqkid=%s, rand_uniq_words[%u]=%s\n",__LINE__,(char *)found->eqkid,(unsigned)u,rand_uniq_words[u]);
+ } /* end if */
+
+ /* Remove the node */
+ ret=H5ST_delete(tree,found);
+ CHECK(ret, FAIL, "H5ST_delete");
+
+ /* Check that the string can't be found in the TST any longer */
+ check=H5ST_search(tree,rand_uniq_words[u]);
+ VERIFY(check, FALSE, "H5ST_search");
+ } /* end for */
+
+ /* Close the TST */
+ ret=H5ST_close(tree);
+ CHECK(ret, FAIL, "H5ST_close");
+} /* end test_tst_remove() */
+
+/****************************************************************
+**
+** test_tst_finalize(): Test basic H5ST (ternary search tree) selection code.
+** Wrap up data for TST testing
+**
+****************************************************************/
+static void
+test_tst_finalize(void)
+{
+ /* Release memory for unordered, randomized and sorted order unique words */
+ HDfree(uniq_words);
+ HDfree(rand_uniq_words);
+ HDfree(sort_uniq_words);
+} /* end test_tst_finalize() */
+
+/****************************************************************
+**
+** test_tst(): Main H5ST selection testing routine.
+**
+****************************************************************/
+void
+test_tst(void)
+{
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing Ternary Search Trees\n"));
+
+ /* Initialize TST testing data */
+ test_tst_init();
+
+ /* Actual TST tests */
+ test_tst_create(); /* Test TST creation */
+ test_tst_insert(); /* Test TST insertion */
+ test_tst_iterate(); /* Test TST iteration */
+ test_tst_remove(); /* Test TST deletion */
+
+ /* Finalize TST testing data */
+ test_tst_finalize();
+} /* end test_tst() */
+
diff --git a/test/tvlstr.c b/test/tvlstr.c
index cd15fa8..a8cbd84 100644
--- a/test/tvlstr.c
+++ b/test/tvlstr.c
@@ -256,17 +256,12 @@ test_vlstrings_special(void)
const char *wdata[SPACE1_DIM1] = {"one", "two", "", "four"};
const char *wdata2[SPACE1_DIM1] = {NULL, NULL, NULL, NULL};
char *rdata[SPACE1_DIM1]; /* Information read in */
- hid_t dataspace, dataset2;
hid_t fid1; /* HDF5 File IDs */
hid_t dataset; /* Dataset ID */
hid_t sid1; /* Dataspace ID */
hid_t tid1; /* Datatype ID */
- hid_t xfer_pid; /* Dataset transfer property list ID */
hsize_t dims1[] = {SPACE1_DIM1};
- hsize_t size; /* Number of bytes which will be used */
unsigned i; /* counting variable */
- int str_used; /* String data in memory */
- int mem_used=0; /* Memory used during allocation */
herr_t ret; /* Generic return value */
/* Output message about test being performed */
@@ -313,6 +308,10 @@ test_vlstrings_special(void)
} /* end if */
} /* end for */
+ /* Reclaim the read VL data */
+ ret=H5Dvlen_reclaim(tid1,sid1,H5P_DEFAULT,rdata);
+ CHECK(ret, FAIL, "H5Dvlen_reclaim");
+
/* Close Dataset */
ret = H5Dclose(dataset);
CHECK(ret, FAIL, "H5Dclose");