summaryrefslogtreecommitdiffstats
path: root/test/tmisc.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2012-03-21 15:10:17 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2012-03-21 15:10:17 (GMT)
commiteb89d7b53ab95623ab454186a602e1cafc7391f0 (patch)
treeceafe458b3011e38853e765352d3c7e59bbecce1 /test/tmisc.c
parent3e468e6ff65d540a439e99ea568a6bff7add7cea (diff)
downloadhdf5-eb89d7b53ab95623ab454186a602e1cafc7391f0.zip
hdf5-eb89d7b53ab95623ab454186a602e1cafc7391f0.tar.gz
hdf5-eb89d7b53ab95623ab454186a602e1cafc7391f0.tar.bz2
[svn-r22105] Description:
Bring r20557:22085 from trunk to this branch, also fixing some other issues/failures in the branch simultaneously. The h5repack tests are still failing, but Neil will be checking into those, so the branch can be fully functional again. Tested on: Mac OSX/64 10.7.3 (amazon) w/debug
Diffstat (limited to 'test/tmisc.c')
-rw-r--r--test/tmisc.c168
1 files changed, 126 insertions, 42 deletions
diff --git a/test/tmisc.c b/test/tmisc.c
index b7ed202..5539cee 100644
--- a/test/tmisc.c
+++ b/test/tmisc.c
@@ -15,7 +15,7 @@
/***********************************************************
*
-* Test program: tmisc
+* Test program: tmisc
*
* Test miscellaneous features not tested elsewhere. Generally
* regression tests for bugs that are reported and don't
@@ -23,7 +23,7 @@
*
*************************************************************/
-#define H5D_PACKAGE /*suppress error about including H5Dpkg */
+#define H5D_PACKAGE /*suppress error about including H5Dpkg */
/* Define this macro to indicate that the testing APIs should be available */
#define H5D_TESTING
@@ -31,10 +31,10 @@
#include "hdf5.h"
#include "testhdf5.h"
#include "H5srcdir.h"
-#include "H5Dpkg.h" /* Datasets */
+#include "H5Dpkg.h" /* Datasets */
/* Definitions for misc. test #1 */
-#define MISC1_FILE "tmisc1.h5"
+#define MISC1_FILE "tmisc1.h5"
#define MISC1_VAL (13417386) /* 0xccbbaa */
#define MISC1_VAL2 (15654348) /* 0xeeddcc */
#define MISC1_DSET_NAME "/scalar_set"
@@ -166,8 +166,8 @@ typedef struct
/* Definitions for misc. test #12 */
#define MISC12_FILE "tmisc12.h5"
#define MISC12_DSET_NAME "Dataset"
-#define MISC12_SPACE1_RANK 1
-#define MISC12_SPACE1_DIM1 4
+#define MISC12_SPACE1_RANK 1
+#define MISC12_SPACE1_DIM1 4
#define MISC12_CHUNK_SIZE 2
#define MISC12_APPEND_SIZE 5
@@ -239,6 +239,7 @@ unsigned m13_rdata[MISC13_DIM1][MISC13_DIM2]; /* Data read from dataset
#define MISC20_SPACE2_DIM0 8
#define MISC20_SPACE2_DIM1 4
+#ifdef H5_HAVE_FILTER_SZIP
/* Definitions for misc. test #21 */
#define MISC21_FILE "tmisc21.h5"
#define MISC21_DSET_NAME "Dataset"
@@ -256,6 +257,7 @@ unsigned m13_rdata[MISC13_DIM1][MISC13_DIM2]; /* Data read from dataset
#define MISC22_CHUNK_DIM1 512
#define MISC22_SPACE_DIM0 639
#define MISC22_SPACE_DIM1 1308
+#endif /* H5_HAVE_FILTER_SZIP */
/* Definitions for misc. test #23 */
#define MISC23_FILE "tmisc23.h5"
@@ -311,6 +313,9 @@ unsigned m13_rdata[MISC13_DIM1][MISC13_DIM2]; /* Data read from dataset
#define MISC29_COPY_FILE "tmisc29.h5"
#define MISC29_DSETNAME "dset2"
+/* Definitions for misc. test #30 */
+#define MISC30_FILE "tmisc30.h5"
+
/****************************************************************
**
** test_misc1(): test unlinking a dataset from a group and immediately
@@ -448,7 +453,7 @@ static void test_misc2_write_attribute(void)
ret = H5Aread(att1, type, &data_check);
CHECK(ret, FAIL, "H5Aread");
- free(data_check.string);
+ HDfree(data_check.string);
ret = H5Aclose(att1);
CHECK(ret, FAIL, "HAclose");
@@ -459,8 +464,6 @@ static void test_misc2_write_attribute(void)
ret = H5Fclose(file1);
CHECK(ret, FAIL, "H5Fclose");
-
-
root2 = H5Gopen2(file2, "/", H5P_DEFAULT);
CHECK(root2, FAIL, "H5Gopen2");
@@ -475,7 +478,7 @@ static void test_misc2_write_attribute(void)
ret = H5Aread(att2, type, &data_check);
CHECK(ret, FAIL, "H5Aread");
- free(data_check.string);
+ HDfree(data_check.string);
ret = H5Aclose(att2);
CHECK(ret, FAIL, "HAclose");
@@ -492,8 +495,8 @@ static void test_misc2_write_attribute(void)
ret = H5Fclose(file2);
CHECK(ret, FAIL, "H5Fclose");
- free(string_att1);
- free(string_att2);
+ HDfree(string_att1);
+ HDfree(string_att2);
return;
}
@@ -519,7 +522,7 @@ static void test_misc2_read_attribute(const char *filename, const char *att_name
ret = H5Aread(att, type, &data_check);
CHECK(ret, FAIL, "H5Aread");
- free(data_check.string);
+ HDfree(data_check.string);
ret = H5Aclose(att);
CHECK(ret, FAIL, "H5Aclose");
@@ -727,7 +730,7 @@ delete_struct3(misc5_struct3_hndl *str3hndl)
ret=H5Tclose(str3hndl->st3h_base);
CHECK(ret,FAIL,"H5Tclose");
- free(str3hndl);
+ HDfree(str3hndl);
}
static void
@@ -778,7 +781,7 @@ delete_struct2(misc5_struct2_hndl *str2hndl)
H5Tclose(str2hndl->st2h_base);
CHECK(ret,FAIL,"H5Tclose");
- free(str2hndl);
+ HDfree(str2hndl);
}
static void
@@ -789,7 +792,7 @@ set_struct2(misc5_struct2 *buf)
buf->st2_el1=MISC5_DBGELVAL2;
buf->st2_el2.len=MISC5_DBGNELM3;
- buf->st2_el2.p=malloc((buf->st2_el2.len)*sizeof(misc5_struct3));
+ buf->st2_el2.p=HDmalloc((buf->st2_el2.len)*sizeof(misc5_struct3));
CHECK(buf->st2_el2.p,NULL,"malloc");
for(i=0; i<(buf->st2_el2.len); i++)
@@ -799,7 +802,7 @@ set_struct2(misc5_struct2 *buf)
static void
clear_struct2(misc5_struct2 *buf)
{
- free(buf->st2_el2.p);
+ HDfree(buf->st2_el2.p);
}
/*********************** struct1 ***********************/
@@ -844,7 +847,7 @@ delete_struct1(misc5_struct1_hndl *str1hndl)
ret=H5Tclose(str1hndl->st1h_base);
CHECK(ret,FAIL,"H5Tclose");
- free(str1hndl);
+ HDfree(str1hndl);
}
static void
@@ -855,7 +858,7 @@ set_struct1(misc5_struct1 *buf)
buf->st1_el1=MISC5_DBGELVAL1;
buf->st1_el2.len=MISC5_DBGNELM2;
- buf->st1_el2.p=malloc((buf->st1_el2.len)*sizeof(misc5_struct2));
+ buf->st1_el2.p=HDmalloc((buf->st1_el2.len)*sizeof(misc5_struct2));
CHECK(buf->st1_el2.p,NULL,"malloc");
for(i=0; i<(buf->st1_el2.len); i++)
@@ -869,7 +872,7 @@ clear_struct1(misc5_struct1 *buf)
for(i=0;i<buf->st1_el2.len;i++)
clear_struct2(&((( misc5_struct2 *)(buf->st1_el2.p))[i]));
- free(buf->st1_el2.p);
+ HDfree(buf->st1_el2.p);
}
static void
@@ -905,7 +908,7 @@ test_misc5(void)
/* Create the variable-length buffer */
buf.len = MISC5_DBGNELM1;
- buf.p = malloc((buf.len) * sizeof(misc5_struct1));
+ buf.p = HDmalloc((buf.len) * sizeof(misc5_struct1));
CHECK(buf.p, NULL, "malloc");
/* Create the top-level VL information */
@@ -921,7 +924,7 @@ test_misc5(void)
clear_struct1(&(((misc5_struct1 *)(buf.p))[j]));
/* Free the variable-length buffer */
- free(buf.p);
+ HDfree(buf.p);
/* Close dataset */
ret = H5Dclose(dataset_id);
@@ -1231,10 +1234,10 @@ test_misc8(void)
MESSAGE(5, ("Testing dataset storage sizes\n"));
/* Allocate space for the data to write & read */
- wdata=malloc(sizeof(int)*MISC8_DIM0*MISC8_DIM1);
+ wdata=HDmalloc(sizeof(int)*MISC8_DIM0*MISC8_DIM1);
CHECK(wdata,NULL,"malloc");
#ifdef VERIFY_DATA
- rdata=malloc(sizeof(int)*MISC8_DIM0*MISC8_DIM1);
+ rdata=HDmalloc(sizeof(int)*MISC8_DIM0*MISC8_DIM1);
CHECK(rdata,NULL,"malloc");
#endif /* VERIFY_DATA */
@@ -1672,7 +1675,7 @@ test_misc8(void)
CHECK(ret, FAIL, "H5Fclose");
/* Free the read & write buffers */
- free(wdata);
+ HDfree(wdata);
#ifdef VERIFY_DATA
free(rdata);
#endif /* VERIFY_DATA */
@@ -1795,10 +1798,10 @@ test_misc11(void)
unsigned sym_ik; /* Symbol table B-tree initial 'K' value */
unsigned istore_ik; /* Indexed storage B-tree initial 'K' value */
unsigned sym_lk; /* Symbol table B-tree leaf 'K' value */
- unsigned nindexes; /* Shared message number of indexes */
- H5F_info2_t finfo; /* global information about file */
- H5F_file_space_type_t strategy; /* File/free space strategy */
- hsize_t threshold; /* Free-space section threshold */
+ unsigned nindexes; /* Shared message number of indexes */
+ H5F_info2_t finfo; /* global information about file */
+ H5F_file_space_type_t strategy; /* File/free space strategy */
+ hsize_t threshold; /* Free-space section threshold */
herr_t ret; /* Generic return value */
/* Output message about test being performed */
@@ -1953,10 +1956,10 @@ test_misc12(void)
hsize_t dimsn[] = {MISC12_APPEND_SIZE};
hsize_t maxdims1[1] = {H5S_UNLIMITED};
hsize_t chkdims1[1] = {MISC12_CHUNK_SIZE};
- hsize_t newsize[1] = {MISC12_SPACE1_DIM1+MISC12_APPEND_SIZE};
- hsize_t offset[1] = {MISC12_SPACE1_DIM1};
- hsize_t count[1] = {MISC12_APPEND_SIZE};
- int i; /* counting variable */
+ hsize_t newsize[1] = {MISC12_SPACE1_DIM1+MISC12_APPEND_SIZE};
+ hsize_t offset[1] = {MISC12_SPACE1_DIM1};
+ hsize_t count[1] = {MISC12_APPEND_SIZE};
+ int i; /* counting variable */
herr_t ret; /* Generic return value */
/* Output message about test being performed */
@@ -2210,7 +2213,7 @@ create_hdf_file(const char *name)
/* Close the file */
ret = H5Fclose(fid);
- assert(ret >= 0);
+ HDassert(ret >= 0);
CHECK(ret, FAIL, "H5Fclose");
}
@@ -2240,7 +2243,7 @@ insert_user_block(const char *old_name, const char *new_name,const char *str,siz
VERIFY(written, size, "HDfwrite");
/* Open the old file */
- old_fp=fopen(old_name,"rb");
+ old_fp=HDfopen(old_name,"rb");
CHECK(old_fp, NULL, "HDfopen");
/* Allocate space for the copy buffer */
@@ -2263,10 +2266,10 @@ insert_user_block(const char *old_name, const char *new_name,const char *str,siz
VERIFY(ret, 0, "HDfclose");
/* Free the copy buffer */
- free(copy_buf);
+ HDfree(copy_buf);
/* Free the user block */
- free(user_block);
+ HDfree(user_block);
}
static void
@@ -3529,7 +3532,7 @@ test_misc20(void)
and encoder is available.
EIP 2004/8/04
*/
-#if defined H5_HAVE_FILTER_SZIP
+#ifdef H5_HAVE_FILTER_SZIP
/****************************************************************
**
@@ -4447,7 +4450,6 @@ test_misc25a(void)
CHECK(ret, FAIL, "H5Fclose");
-
/* Re-open file */
fid = H5Fopen(MISC25A_FILE, H5F_ACC_RDWR, H5P_DEFAULT);
CHECK(fid, FAIL, "H5Fopen");
@@ -4491,7 +4493,6 @@ test_misc25a(void)
CHECK(ret, FAIL, "H5Fclose");
-
/* Re-open file */
fid = H5Fopen(MISC25A_FILE, H5F_ACC_RDWR, H5P_DEFAULT);
CHECK(fid, FAIL, "H5Fopen");
@@ -5113,6 +5114,87 @@ test_misc29(void)
CHECK(ret, FAIL, "H5Fclose");
} /* end test_misc29() */
+
+static int
+test_misc30_get_info_cb(hid_t loc_id, const char *name, const H5L_info_t UNUSED *info,
+ void UNUSED *op_data)
+{
+ H5O_info_t object_info;
+
+ return H5Oget_info_by_name(loc_id, name, &object_info, H5P_DEFAULT);
+}
+
+static int
+test_misc30_get_info(hid_t loc_id)
+{
+ return H5Literate(loc_id, H5_INDEX_NAME, H5_ITER_INC, NULL, test_misc30_get_info_cb, NULL);
+}
+
+
+/****************************************************************
+**
+** test_misc30(): Exercise local heap code that loads prefix
+** separately from data block, causing the free
+** block information to get lost.
+**
+****************************************************************/
+static void
+test_misc30(void)
+{
+ hsize_t file_size[] = {0, 0}; /* Sizes of file created */
+ hbool_t get_info; /* Whether to perform the get info call */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Local heap dropping free block info\n"));
+
+ for(get_info = FALSE; get_info <= TRUE; get_info++) {
+ hid_t fid; /* File ID */
+ hid_t gid; /* Group ID */
+ int i; /* Local index counter */
+ herr_t ret; /* Generic return value */
+
+ fid = H5Fcreate(MISC30_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(fid, FAIL, "H5Fcreate");
+ gid = H5Gcreate2(fid, "/g0", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(gid, FAIL, "H5Gcreate2");
+
+ ret = H5Gclose(gid);
+ CHECK(ret, FAIL, "H5Gclose");
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ for(i = 0; i < 20; i++) {
+ char gname[32];
+
+ fid = H5Fopen(MISC30_FILE, H5F_ACC_RDWR, H5P_DEFAULT);
+ CHECK(fid, FAIL, "H5Fopen");
+
+ if(get_info) {
+ ret = test_misc30_get_info(fid);
+ CHECK(ret, FAIL, "test_misc30_get_info");
+ }
+
+ sprintf(gname, "/g0/group%d", i);
+ gid = H5Gcreate2(fid, gname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(gid, FAIL, "H5Gcreate2");
+
+ ret = H5Gclose(gid);
+ CHECK(ret, FAIL, "H5Gclose");
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+ }
+
+ fid = H5Fopen(MISC30_FILE, H5F_ACC_RDONLY, H5P_DEFAULT);
+ CHECK(fid, FAIL, "H5Fopen");
+ ret = H5Fget_filesize(fid, &file_size[get_info]);
+ CHECK(fid, FAIL, "H5Fget_filesize");
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+ }
+
+ VERIFY(file_size[0], file_size[1], "test_misc30");
+} /* end test_misc30() */
+
/****************************************************************
**
** test_misc(): Main misc. test routine.
@@ -5144,7 +5226,7 @@ test_misc(void)
test_misc18(); /* Test new object header information in H5O_info_t struct */
test_misc19(); /* Test incrementing & decrementing ref count on IDs */
test_misc20(); /* Test problems with truncated dimensions in version 2 of storage layout message */
-#if defined H5_HAVE_FILTER_SZIP
+#ifdef H5_HAVE_FILTER_SZIP
test_misc21(); /* Test that "late" allocation time is treated the same as "incremental", for chunked datasets w/a filters */
test_misc22(); /* check szip bits per pixel */
#endif /* H5_HAVE_FILTER_SZIP */
@@ -5157,6 +5239,7 @@ test_misc(void)
test_misc27(); /* Test opening file with object that has bad # of object header messages */
test_misc28(); /* Test that chunks are cached appropriately */
test_misc29(); /* Test that speculative metadata reads are handled correctly */
+ test_misc30(); /* Exercise local heap loading bug where free lists were getting dropped */
} /* test_misc() */
@@ -5201,7 +5284,7 @@ cleanup_misc(void)
HDremove(MISC18_FILE);
HDremove(MISC19_FILE);
HDremove(MISC20_FILE);
-#if defined H5_HAVE_FILTER_SZIP
+#ifdef H5_HAVE_FILTER_SZIP
HDremove(MISC21_FILE);
HDremove(MISC22_FILE);
#endif /* H5_HAVE_FILTER_SZIP */
@@ -5212,5 +5295,6 @@ cleanup_misc(void)
HDremove(MISC26_FILE);
HDremove(MISC28_FILE);
HDremove(MISC29_COPY_FILE);
+ HDremove(MISC30_FILE);
}