summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-12-10 17:43:14 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-12-10 17:43:14 (GMT)
commit9d06256018fbebbefa08879ae9f16696a5bbef19 (patch)
treedb84f4d812d122c8c9fafbcc4b828fc12cbf6a8e /test
parenta4750dfae7e187f95c4515939968e6fce880efed (diff)
downloadhdf5-9d06256018fbebbefa08879ae9f16696a5bbef19.zip
hdf5-9d06256018fbebbefa08879ae9f16696a5bbef19.tar.gz
hdf5-9d06256018fbebbefa08879ae9f16696a5bbef19.tar.bz2
[svn-r17987] Description:
Bring r17945:17986 from trunk to revise_chunks branch (needs to have autotools files regenerated before testing, those will be checked in in a few minutes)
Diffstat (limited to 'test')
-rw-r--r--test/btree2.c4
-rw-r--r--test/cmpd_dset.c7
-rw-r--r--test/dsets.c96
-rw-r--r--test/dt_arith.c2
-rw-r--r--test/dtypes.c11
-rw-r--r--test/external.c45
-rw-r--r--test/hyperslab.c2
-rw-r--r--test/istore.c2
-rw-r--r--test/links.c374
-rw-r--r--test/ntypes.c1315
-rwxr-xr-xtest/objcopy.c16
-rw-r--r--test/pool.c2
-rw-r--r--test/theap.c2
-rw-r--r--test/tskiplist.c2
-rw-r--r--test/ttst.c2
-rw-r--r--test/tunicode.c2
-rw-r--r--test/unlink.c76
-rw-r--r--test/vfd.c5
18 files changed, 1161 insertions, 804 deletions
diff --git a/test/btree2.c b/test/btree2.c
index fb24433..eabd208 100644
--- a/test/btree2.c
+++ b/test/btree2.c
@@ -2770,7 +2770,7 @@ test_insert_lots(hid_t fapl, const H5B2_create_t *cparam,
curr_time=1109170019;
HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time);
#endif /* QAK */
- HDsrandom((unsigned long)curr_time);
+ HDsrandom((unsigned)curr_time);
/*
* Test inserting many records into v2 B-tree
@@ -6445,7 +6445,7 @@ test_remove_lots(const char *env_h5_drvr, hid_t fapl, const H5B2_create_t *cpara
curr_time = 1163537969;
HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time);
#endif /* QAK */
- HDsrandom((unsigned long)curr_time);
+ HDsrandom((unsigned)curr_time);
/*
* Test removing many records into v2 B-tree
diff --git a/test/cmpd_dset.c b/test/cmpd_dset.c
index b154f51..d565e82 100644
--- a/test/cmpd_dset.c
+++ b/test/cmpd_dset.c
@@ -1998,9 +1998,10 @@ error:
static int
test_ooo_order(char *filename)
{
- hid_t file; /* File ID */
- hid_t dtype, dtype_tmp; /* Datatype IDs */
- H5T_t *dt; /* Datatype pointer */
+ hid_t file = -1; /* File ID */
+ hid_t dtype = -1; /* Datatype IDs */
+ hid_t dtype_tmp = -1; /* Temp Datatype ID */
+ H5T_t *dt = NULL; /* Datatype pointer */
TESTING("that compound member insertion order is preserved")
diff --git a/test/dsets.c b/test/dsets.c
index 07ee0d0..84b40bb 100644
--- a/test/dsets.c
+++ b/test/dsets.c
@@ -743,7 +743,9 @@ test_max_compact(hid_t fapl)
compact_size = (SIXTY_FOUR_KB-64)/sizeof(int);
wbuf = (int*)HDmalloc(sizeof(int)*(size_t)compact_size);
+ assert(wbuf);
rbuf = (int*)HDmalloc(sizeof(int)*(size_t)compact_size);
+ assert(rbuf);
n=0;
for(i=0; i<(int)compact_size; i++)
@@ -800,8 +802,9 @@ test_max_compact(hid_t fapl)
if(H5Dclose(dataset) < 0) goto error;
if(H5Fclose(file) < 0) goto error;
HDfree(wbuf);
+ wbuf = NULL;
HDfree(rbuf);
-
+ rbuf = NULL;
/* Test compact dataset of size 64KB */
@@ -835,6 +838,19 @@ test_max_compact(hid_t fapl)
return 0;
error:
+ if(wbuf)
+ HDfree(wbuf);
+ if(rbuf)
+ HDfree(rbuf);
+
+ H5E_BEGIN_TRY {
+ /* Close file */
+ H5Sclose(space);
+ H5Pclose(plist);
+ H5Fclose(file);
+ H5Dclose(dataset);
+ } H5E_END_TRY;
+
return -1;
}
@@ -1006,10 +1022,10 @@ error:
static herr_t
test_tconv(hid_t file)
{
- char *out=NULL, *in=NULL;
- int i;
+ char *out = NULL, *in = NULL;
hsize_t dims[1];
- hid_t space, dataset;
+ hid_t space = -1, dataset = -1;
+ int i;
out = (char *)HDmalloc((size_t)(4 * 1000 * 1000));
HDassert(out);
@@ -1020,11 +1036,11 @@ test_tconv(hid_t file)
/* Initialize the dataset */
for(i = 0; i < 1000000; i++) {
- out[i*4+0] = 0x11;
- out[i*4+1] = 0x22;
- out[i*4+2] = 0x33;
- out[i*4+3] = 0x44;
- }
+ out[i * 4 + 0] = 0x11;
+ out[i * 4 + 1] = 0x22;
+ out[i * 4 + 2] = 0x33;
+ out[i * 4 + 3] = 0x44;
+ } /* end for */
/* Create the data space */
dims[0] = 1000000;
@@ -1041,27 +1057,39 @@ test_tconv(hid_t file)
/* Read data with byte order conversion */
if(H5Dread(dataset, H5T_STD_I32BE, H5S_ALL, H5S_ALL, H5P_DEFAULT, in) < 0)
- goto error;
+ goto error;
/* Check */
for(i = 0; i < 1000000; i++) {
- if(in[4*i+0]!=out[4*i+3] ||
- in[4*i+1]!=out[4*i+2] ||
- in[4*i+2]!=out[4*i+1] ||
- in[4*i+3]!=out[4*i+0]) {
- H5_FAILED();
- puts(" Read with byte order conversion failed.");
- goto error;
- }
+ if(in[4 * i + 0] != out[4 * i + 3] ||
+ in[4 * i + 1] != out[4 * i + 2] ||
+ in[4 * i + 2] != out[4 * i + 1] ||
+ in[4 * i + 3] != out[4 * i + 0]) {
+ H5_FAILED();
+ puts(" Read with byte order conversion failed.");
+ goto error;
+ }
}
if(H5Dclose(dataset) < 0) goto error;
- free (out);
- free (in);
+ if(H5Sclose(space) < 0) goto error;
+ HDfree(out);
+ HDfree(in);
+
puts(" PASSED");
return 0;
- error:
+error:
+ if(out)
+ HDfree(out);
+ if(in)
+ HDfree(in);
+
+ H5E_BEGIN_TRY {
+ H5Dclose(dataset);
+ H5Sclose(space);
+ } H5E_END_TRY;
+
return -1;
}
@@ -1274,19 +1302,19 @@ filter_corrupt(unsigned int flags, size_t cd_nelmts,
const unsigned int *cd_values, size_t nbytes,
size_t *buf_size, void **buf)
{
- size_t ret_value = 0;
+ void *data;
unsigned char *dst = (unsigned char*)(*buf);
unsigned int offset;
unsigned int length;
unsigned int value;
- void *data;
+ size_t ret_value = 0;
- if(cd_nelmts!=3 || !cd_values)
+ if(cd_nelmts != 3 || !cd_values)
return 0;
offset = cd_values[0];
length = cd_values[1];
value = cd_values[2];
- if(offset>nbytes || (offset+length)>nbytes || length<sizeof(unsigned int))
+ if(offset > nbytes || (offset + length) > nbytes || length < sizeof(unsigned int))
return 0;
data = HDmalloc((size_t)length);
@@ -1294,15 +1322,19 @@ filter_corrupt(unsigned int flags, size_t cd_nelmts,
if(flags & H5Z_FLAG_REVERSE) { /* Varify data is actually corrupted during read */
dst += offset;
- if(HDmemcmp(data, dst, (size_t)length)!=0) return 0;
- *buf_size = nbytes;
- ret_value = nbytes;
- } else { /* Write corrupted data */
+ if(HDmemcmp(data, dst, (size_t)length) != 0)
+ ret_value = 0;
+ else {
+ *buf_size = nbytes;
+ ret_value = nbytes;
+ } /* end else */
+ } /* end if */
+ else { /* Write corrupted data */
dst += offset;
HDmemcpy(dst, data, (size_t)length);
*buf_size = nbytes;
- ret_value = *buf_size;
- }
+ ret_value = *buf_size;
+ } /* end else */
if(data)
HDfree(data);
@@ -8218,7 +8250,7 @@ main(void)
envval = "nomatch";
/* Set the random # seed */
- HDsrandom((unsigned long)HDtime(NULL));
+ HDsrandom((unsigned)HDtime(NULL));
/* Testing setup */
h5_reset();
diff --git a/test/dt_arith.c b/test/dt_arith.c
index 43855a8..420570a 100644
--- a/test/dt_arith.c
+++ b/test/dt_arith.c
@@ -5218,7 +5218,7 @@ main(void)
unsigned long nerrors = 0;
/* Set the random # seed */
- HDsrandom((unsigned long)HDtime(NULL));
+ HDsrandom((unsigned)HDtime(NULL));
reset_hdf5();
diff --git a/test/dtypes.c b/test/dtypes.c
index 2619f1b..04f526a 100644
--- a/test/dtypes.c
+++ b/test/dtypes.c
@@ -325,7 +325,10 @@ test_copy(void)
* Saturday, August 30, 2003
*
* Modifications:
- *
+ * Raymond Lu
+ * 8 December 2009
+ * I added a field of VL string in the compound type to test
+ * H5Tdetect_class correctly detect it as string type.
*-------------------------------------------------------------------------
*/
static int
@@ -342,6 +345,7 @@ test_detect(void)
hobj_ref_t arr_r[3][3];
int i;
hvl_t vl_f;
+ hvl_t vl_s;
char c;
short s;
};
@@ -441,6 +445,7 @@ test_detect(void)
if (H5Tinsert(cplx_cmpd_id, "arr_r", HOFFSET(struct complex, arr_r), atom_arr_id) < 0) TEST_ERROR
if (H5Tinsert(cplx_cmpd_id, "i", HOFFSET(struct complex, i), H5T_NATIVE_INT) < 0) TEST_ERROR
if (H5Tinsert(cplx_cmpd_id, "vl_f", HOFFSET(struct complex, vl_f), atom_vlf_id) < 0) TEST_ERROR
+ if (H5Tinsert(cplx_cmpd_id, "vl_s", HOFFSET(struct complex, vl_s), atom_vls_id) < 0) TEST_ERROR
if (H5Tinsert(cplx_cmpd_id, "c", HOFFSET(struct complex, c), H5T_NATIVE_CHAR) < 0) TEST_ERROR
if (H5Tinsert(cplx_cmpd_id, "s", HOFFSET(struct complex, s), H5T_NATIVE_SHORT) < 0) TEST_ERROR
@@ -450,12 +455,12 @@ test_detect(void)
if(H5Tdetect_class(cplx_cmpd_id,H5T_REFERENCE)!=TRUE) TEST_ERROR
if(H5Tdetect_class(cplx_cmpd_id,H5T_INTEGER)!=TRUE) TEST_ERROR
if(H5Tdetect_class(cplx_cmpd_id,H5T_FLOAT)!=TRUE) TEST_ERROR
+ if(H5Tdetect_class(cplx_cmpd_id,H5T_STRING)!=TRUE) TEST_ERROR
if(H5Tdetect_class(cplx_cmpd_id,H5T_VLEN)!=TRUE) TEST_ERROR
/* Make certain that an incorrect class is not detected */
if(H5Tdetect_class(cplx_cmpd_id,H5T_TIME)!=FALSE) TEST_ERROR
if(H5Tdetect_class(cplx_cmpd_id,H5T_ENUM)!=FALSE) TEST_ERROR
- if(H5Tdetect_class(cplx_cmpd_id,H5T_STRING)!=FALSE) TEST_ERROR
/* Close complex compound datatype */
if(H5Tclose(cplx_cmpd_id) < 0) TEST_ERROR
@@ -6332,7 +6337,7 @@ main(void)
hid_t fapl = -1;
/* Set the random # seed */
- HDsrandom((unsigned long)HDtime(NULL));
+ HDsrandom((unsigned)HDtime(NULL));
reset_hdf5();
fapl = h5_fileaccess();
diff --git a/test/external.c b/test/external.c
index 25d465c..b3831ad 100644
--- a/test/external.c
+++ b/test/external.c
@@ -58,21 +58,23 @@ same_contents (const char *name1, const char *name2)
fd1 = HDopen(name1, O_RDONLY, 0666);
fd2 = HDopen(name2, O_RDONLY, 0666);
- assert (fd1>=0 && fd2>=0);
-
- while (1) {
- n1 = HDread(fd1, buf1, sizeof(buf1));
- n2 = HDread(fd2, buf2, sizeof(buf2));
- assert (n1>=0 && (size_t)n1<=sizeof(buf1));
- assert (n2>=0 && (size_t)n2<=sizeof(buf2));
- assert (n1==n2);
-
- if (n1<=0 && n2<=0) break;
- if (memcmp (buf1, buf2, (size_t)n1)) {
- HDclose(fd1);
- HDclose(fd2);
- return 0;
- }
+ assert(fd1 >= 0 && fd2 >= 0);
+
+ while(1) {
+ /* Asserts will catch negative return values */
+ n1 = HDread(fd1, buf1, sizeof(buf1));
+ n2 = HDread(fd2, buf2, sizeof(buf2));
+ assert(n1 >= 0 && (size_t)n1 <= sizeof(buf1));
+ assert(n2 >= 0 && (size_t)n2 <= sizeof(buf2));
+ assert(n1 == n2);
+
+ if(n1 == 0 && n2 == 0)
+ break;
+ if(HDmemcmp(buf1, buf2, (size_t)n1)) {
+ HDclose(fd1);
+ HDclose(fd2);
+ return 0;
+ }
}
HDclose(fd1);
HDclose(fd2);
@@ -838,10 +840,13 @@ test_3 (hid_t fapl)
static int
test_4 (hid_t fapl)
{
- hid_t fid, gid, xid, xid2;
- char filename[1024]; /*file name */
- char pathname[1024];
- char *srcdir = getenv("srcdir"); /*where the src code is located*/
+ hid_t fid = -1;
+ hid_t gid = -1;
+ hid_t xid = -1;
+ hid_t xid2 = -1;
+ char filename[1024]; /*file name */
+ char pathname[1024];
+ char *srcdir = getenv("srcdir"); /*where the src code is located*/
TESTING("opening external link twice");
@@ -911,7 +916,7 @@ test_4 (hid_t fapl)
H5Gclose(gid);
H5Gclose(xid);
H5Gclose(xid2);
- H5Fclose(fid);
+ H5Fclose(fid);
} H5E_END_TRY;
return 1;
}
diff --git a/test/hyperslab.c b/test/hyperslab.c
index 194c0f6..b756449 100644
--- a/test/hyperslab.c
+++ b/test/hyperslab.c
@@ -1234,7 +1234,7 @@ main(int argc, char *argv[])
printf("\n");
/* Set the random # seed */
- HDsrandom((unsigned long)HDtime(NULL));
+ HDsrandom((unsigned)HDtime(NULL));
/*
* Open the library explicitly for thread-safe builds, so per-thread
diff --git a/test/istore.c b/test/istore.c
index fff6706..fb0f3fc 100644
--- a/test/istore.c
+++ b/test/istore.c
@@ -596,7 +596,7 @@ main(int argc, char *argv[])
printf("\n");
/* Set the random # seed */
- HDsrandom((unsigned long)HDtime(NULL));
+ HDsrandom((unsigned)HDtime(NULL));
/* Reset library */
h5_reset();
diff --git a/test/links.c b/test/links.c
index 37b03cf..deae5ef 100644
--- a/test/links.c
+++ b/test/links.c
@@ -3571,8 +3571,8 @@ external_set_elink_fapl1(hid_t fapl, hbool_t new_format)
filename2B[NAME_BUF_SIZE],
tmpname[NAME_BUF_SIZE],
cwdpath[NAME_BUF_SIZE];
- hid_t fam_fapl, multi_fapl;
- hid_t lapl_idA, lapl_idB;
+ hid_t fam_fapl=-1, multi_fapl=-1;
+ hid_t lapl_idA=-1, lapl_idB=-1;
H5FD_mem_t mt, memb_map[H5FD_MEM_NTYPES];
hid_t memb_fapl[H5FD_MEM_NTYPES];
char sv[H5FD_MEM_NTYPES][500];
@@ -3769,11 +3769,11 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format)
{
hid_t fid = (-1); /* File ID */
hid_t gid = (-1); /* Group IDs */
+ hid_t core_fapl = -1, space = -1, dset = -1, did = -1, dapl_id = -1, dcpl = -1;
char filename1[NAME_BUF_SIZE],
filename2[NAME_BUF_SIZE],
tmpname[NAME_BUF_SIZE],
cwdpath[NAME_BUF_SIZE];
- hid_t core_fapl, space, dset, did, dapl_id, dcpl;
hsize_t dims[2];
int points[NUM40][NUM40];
h5_stat_size_t filesize, new_filesize;
@@ -3806,8 +3806,8 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format)
h5_fixname(FILENAME[39], core_fapl, filename2, sizeof filename2);
/* Create the target file to be a "core" file */
- if((fid=H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, core_fapl)) < 0) TEST_ERROR
- if((gid=H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, core_fapl)) < 0) TEST_ERROR
+ if((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
dims[0] = NUM40;
dims[1] = NUM40;
@@ -3848,8 +3848,7 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format)
/* try to open the external linked target dataset */
did = H5Dopen2(fid, "ext_link", dapl_id);
-
- if (did < 0) {
+ if(did < 0) {
H5_FAILED();
puts(" Should succeed in opening the target dataset");
goto error;
@@ -3871,7 +3870,7 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format)
new_filesize = h5_get_file_size(filename2, core_fapl);
/* the file size should remain the same since there is no backing store */
- if (new_filesize != filesize) TEST_ERROR
+ if(new_filesize != filesize) TEST_ERROR
if(H5Pclose(core_fapl) < 0) TEST_ERROR
@@ -3885,8 +3884,9 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format)
H5Dclose(dset);
H5Pclose(core_fapl);
H5Pclose(dapl_id);
- H5Dclose (did);
- H5Fclose (fid);
+ H5Dclose(did);
+ H5Gclose(gid);
+ H5Fclose(fid);
} H5E_END_TRY;
return -1;
} /* end external_set_elink_fapl2() */
@@ -3926,8 +3926,8 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format)
static int
external_set_elink_fapl3(hbool_t new_format)
{
- hid_t core_fapl, stdio_fapl;
- hid_t lapl_id, new_lapl_id, l_fapl, out_fapl;
+ hid_t core_fapl = -1, stdio_fapl = -1;
+ hid_t lapl_id = -1, new_lapl_id = -1, l_fapl = -1, out_fapl;
int ret;
if(new_format)
@@ -3950,43 +3950,43 @@ external_set_elink_fapl3(hbool_t new_format)
/* Verify that the driver for the link's fapl is the "stdio" driver */
if((l_fapl = H5Pget_elink_fapl(lapl_id)) < 0) TEST_ERROR
- if (H5Pget_driver(l_fapl) != H5FD_STDIO) TEST_ERROR
- if (H5Pclose(l_fapl) < 0) TEST_ERROR
+ if(H5Pget_driver(l_fapl) != H5FD_STDIO) TEST_ERROR
+ if(H5Pclose(l_fapl) < 0) TEST_ERROR
/* Set file access property list for link access to use the "core" driver */
if(H5Pset_elink_fapl(lapl_id, core_fapl) < 0) TEST_ERROR
/* Make a copy of the link access property */
- if ((new_lapl_id = H5Pcopy(lapl_id)) < 0) TEST_ERROR
+ if((new_lapl_id = H5Pcopy(lapl_id)) < 0) TEST_ERROR
/* get the fapl set in lapl_id */
- if (H5Pget(lapl_id, "external link fapl", &out_fapl) < 0) TEST_ERROR
- if (H5Pclose(lapl_id) < 0) TEST_ERROR
+ if(H5Pget(lapl_id, "external link fapl", &out_fapl) < 0) TEST_ERROR
+ if(H5Pclose(lapl_id) < 0) TEST_ERROR
/* Try closing out_fapl should fail since H5Pclose(lapl_id) should also close its fapl */
H5E_BEGIN_TRY {
ret = H5Pclose(out_fapl);
} H5E_END_TRY;
- if (ret != FAIL) TEST_ERROR
+ if(ret != FAIL) TEST_ERROR
/* Verify that the driver for the copied link's fapl is the "core" driver */
if((l_fapl = H5Pget_elink_fapl(new_lapl_id)) < 0) TEST_ERROR
- if (H5Pget_driver(l_fapl) != H5FD_CORE) TEST_ERROR
+ if(H5Pget_driver(l_fapl) != H5FD_CORE) TEST_ERROR
/* get the fapl set in new_lapl_id */
- if (H5Pget(new_lapl_id, "external link fapl", &out_fapl) < 0) TEST_ERROR
- if (H5Premove(new_lapl_id, "external link fapl") < 0) TEST_ERROR
+ if(H5Pget(new_lapl_id, "external link fapl", &out_fapl) < 0) TEST_ERROR
+ if(H5Premove(new_lapl_id, "external link fapl") < 0) TEST_ERROR
/* Try closing out_fapl should fail since the property is removed from new_lapl_id */
H5E_BEGIN_TRY {
ret = H5Pclose(out_fapl);
} H5E_END_TRY;
- if (ret != FAIL) TEST_ERROR
+ if(ret != FAIL) TEST_ERROR
- if (H5Pclose(l_fapl) < 0) TEST_ERROR
- if (H5Pclose(new_lapl_id) < 0) TEST_ERROR
- if (H5Pclose(core_fapl) < 0) TEST_ERROR
- if (H5Pclose(stdio_fapl) < 0) TEST_ERROR
+ if(H5Pclose(l_fapl) < 0) TEST_ERROR
+ if(H5Pclose(new_lapl_id) < 0) TEST_ERROR
+ if(H5Pclose(core_fapl) < 0) TEST_ERROR
+ if(H5Pclose(stdio_fapl) < 0) TEST_ERROR
PASSED();
return 0;
@@ -4021,7 +4021,7 @@ external_set_elink_fapl3(hbool_t new_format)
static int
external_set_elink_acc_flags(hid_t fapl, hbool_t new_format)
{
- hid_t file1, file2, group, subgroup, gapl;
+ hid_t file1 = -1, file2 = -1, group = -1, subgroup = -1, gapl = -1;
char filename1[NAME_BUF_SIZE],
filename2[NAME_BUF_SIZE];
unsigned flags;
@@ -4034,70 +4034,70 @@ external_set_elink_acc_flags(hid_t fapl, hbool_t new_format)
/* Create parent and target files, and external link */
h5_fixname(FILENAME[40], fapl, filename1, sizeof filename1);
h5_fixname(FILENAME[41], fapl, filename2, sizeof filename2);
- if ((file1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
- if ((file2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
- if (H5Lcreate_external(filename2, "/", file1, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if((file1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+ if((file2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+ if(H5Lcreate_external(filename2, "/", file1, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
/* Close file2, leave file1 open (should be read-write) */
- if (H5Fclose(file2) < 0) TEST_ERROR
+ if(H5Fclose(file2) < 0) TEST_ERROR
/* Create new gapl, and set elink access flags to be H5F_ACC_RDONLY */
- if ((gapl = H5Pcreate(H5P_GROUP_ACCESS)) < 0) TEST_ERROR
- if (H5Pset_elink_acc_flags(gapl, H5F_ACC_RDONLY) < 0) TEST_ERROR
+ if((gapl = H5Pcreate(H5P_GROUP_ACCESS)) < 0) TEST_ERROR
+ if(H5Pset_elink_acc_flags(gapl, H5F_ACC_RDONLY) < 0) TEST_ERROR
/* Verify "get" routine functionality */
- if (H5Pget_elink_acc_flags(gapl, &flags) < 0) TEST_ERROR
- if (flags != H5F_ACC_RDONLY) TEST_ERROR
+ if(H5Pget_elink_acc_flags(gapl, &flags) < 0) TEST_ERROR
+ if(flags != H5F_ACC_RDONLY) TEST_ERROR
/* Attempt to create a group through the external link using gapl (should fail) */
H5E_BEGIN_TRY {
group = H5Gcreate2(file1, "/ext_link/group", H5P_DEFAULT, H5P_DEFAULT, gapl);
} H5E_END_TRY;
- if (group != FAIL) TEST_ERROR
+ if(group != FAIL) TEST_ERROR
/* Close file1 and reopen with read only access */
- if (H5Fclose(file1) < 0) TEST_ERROR
- if ((file1 = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR
+ if(H5Fclose(file1) < 0) TEST_ERROR
+ if((file1 = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR
/* Set elink access flags on gapl to be H5F_ACC_RDWR */
- if (H5Pset_elink_acc_flags(gapl, H5F_ACC_RDWR) < 0) TEST_ERROR
+ if(H5Pset_elink_acc_flags(gapl, H5F_ACC_RDWR) < 0) TEST_ERROR
/* Create a group through the external link using gapl (should succeed) */
- if ((group = H5Gcreate2(file1, "/ext_link/group", H5P_DEFAULT, H5P_DEFAULT, gapl)) < 0) TEST_ERROR
+ if((group = H5Gcreate2(file1, "/ext_link/group", H5P_DEFAULT, H5P_DEFAULT, gapl)) < 0) TEST_ERROR
/* Unset elink access flags on gapl */
- if (H5Pset_elink_acc_flags(gapl, H5F_ACC_DEFAULT) < 0) TEST_ERROR
+ if(H5Pset_elink_acc_flags(gapl, H5F_ACC_DEFAULT) < 0) TEST_ERROR
/* Attempt to create a group through the external link using gapl (should fail) */
H5E_BEGIN_TRY {
subgroup = H5Gcreate2(file1, "/ext_link/group/subgroup", H5P_DEFAULT, H5P_DEFAULT, gapl);
} H5E_END_TRY;
- if (subgroup != FAIL) TEST_ERROR
+ if(subgroup != FAIL) TEST_ERROR
/* Close file1 and group */
- if (H5Gclose(group) < 0) TEST_ERROR
- if (H5Fclose(file1) < 0) TEST_ERROR
+ if(H5Gclose(group) < 0) TEST_ERROR
+ if(H5Fclose(file1) < 0) TEST_ERROR
/* Verify that H5Fcreate and H5Fopen reject H5F_ACC_DEFAULT */
H5E_BEGIN_TRY {
file1 = H5Fcreate(filename1, H5F_ACC_DEFAULT, H5P_DEFAULT, fapl);
} H5E_END_TRY;
- if (file1 != FAIL) TEST_ERROR
+ if(file1 != FAIL) TEST_ERROR
H5E_BEGIN_TRY {
file1 = H5Fcreate(filename1, H5F_ACC_TRUNC | H5F_ACC_DEFAULT, H5P_DEFAULT, fapl);
} H5E_END_TRY;
- if (file1 != FAIL) TEST_ERROR
+ if(file1 != FAIL) TEST_ERROR
H5E_BEGIN_TRY {
file1 = H5Fopen(filename1, H5F_ACC_DEFAULT, fapl);
} H5E_END_TRY;
- if (file1 != FAIL) TEST_ERROR
+ if(file1 != FAIL) TEST_ERROR
H5E_BEGIN_TRY {
file1 = H5Fopen(filename1, H5F_ACC_RDWR | H5F_ACC_DEFAULT, fapl);
} H5E_END_TRY;
- if (file1 != FAIL) TEST_ERROR
+ if(file1 != FAIL) TEST_ERROR
/* Close gapl */
- if (H5Pclose(gapl) < 0) TEST_ERROR
+ if(H5Pclose(gapl) < 0) TEST_ERROR
PASSED();
return 0;
@@ -4171,7 +4171,7 @@ external_set_elink_cb_cb(const char *parent_file, const char *parent_group,
static int
external_set_elink_cb(hid_t fapl, hbool_t new_format)
{
- hid_t file1, file2, group, gapl, fam_fapl, ret_fapl, base_driver;
+ hid_t file1 = -1, file2 = -1, group = -1, gapl = -1, fam_fapl = -1, ret_fapl = -1, base_driver;
set_elink_cb_t op_data,
*op_data_p;
H5L_elink_traverse_t cb;
@@ -4204,44 +4204,44 @@ external_set_elink_cb(hid_t fapl, hbool_t new_format)
/* Create parent and target files, group, and external link */
h5_fixname(FILENAME[42], fapl, filename1, sizeof filename1);
h5_fixname(FILENAME[43], fam_fapl, filename2, sizeof filename2);
- if ((file1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
- if ((file2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fam_fapl)) < 0) TEST_ERROR
- if ((group = H5Gcreate2(file1, "group1",H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
- if (H5Lcreate_external(filename2, "/", group, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ if((file1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+ if((file2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fam_fapl)) < 0) TEST_ERROR
+ if((group = H5Gcreate2(file1, "group1",H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Lcreate_external(filename2, "/", group, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
/* Close files and group */
- if (H5Fclose(file1) < 0) TEST_ERROR
- if (H5Fclose(file2) < 0) TEST_ERROR
- if (H5Gclose(group) < 0) TEST_ERROR
+ if(H5Fclose(file1) < 0) TEST_ERROR
+ if(H5Fclose(file2) < 0) TEST_ERROR
+ if(H5Gclose(group) < 0) TEST_ERROR
/* Create new gapl, and set elink callback */
- if ((gapl = H5Pcreate(H5P_GROUP_ACCESS)) < 0) TEST_ERROR
- if (H5Pset_elink_cb(gapl, external_set_elink_cb_cb, &op_data) < 0) TEST_ERROR
+ if((gapl = H5Pcreate(H5P_GROUP_ACCESS)) < 0) TEST_ERROR
+ if(H5Pset_elink_cb(gapl, external_set_elink_cb_cb, &op_data) < 0) TEST_ERROR
/* Verify "get" routine functionality */
- if (H5Pget_elink_cb(gapl, &cb, (void **) &op_data_p) < 0) TEST_ERROR
- if (cb != external_set_elink_cb_cb) TEST_ERROR
- if (op_data_p != &op_data) TEST_ERROR
+ if(H5Pget_elink_cb(gapl, &cb, (void **) &op_data_p) < 0) TEST_ERROR
+ if(cb != external_set_elink_cb_cb) TEST_ERROR
+ if(op_data_p != &op_data) TEST_ERROR
/* Open file1 with read only access */
- if ((file1 = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR
+ if((file1 = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR
/* Create a group through the external link using gapl */
- if ((group = H5Gcreate2(file1, "/group1/ext_link/group2", H5P_DEFAULT, H5P_DEFAULT, gapl)) < 0) TEST_ERROR
+ if((group = H5Gcreate2(file1, "/group1/ext_link/group2", H5P_DEFAULT, H5P_DEFAULT, gapl)) < 0) TEST_ERROR
/* Verify that the correct parameters have been set on file2 (somewhat
* redundant as the library would be unable to create the group otherwise)
*/
- if ((file2 = H5Iget_file_id(group)) < 0) TEST_ERROR
- if (H5Fget_intent(file2, &flags) < 0) TEST_ERROR
- if (!(flags & H5F_ACC_RDWR)) TEST_ERROR
- if ((ret_fapl = H5Fget_access_plist(file2)) < 0) TEST_ERROR
- if (H5FD_FAMILY != H5Pget_driver(ret_fapl)) TEST_ERROR
+ if((file2 = H5Iget_file_id(group)) < 0) TEST_ERROR
+ if(H5Fget_intent(file2, &flags) < 0) TEST_ERROR
+ if(!(flags & H5F_ACC_RDWR)) TEST_ERROR
+ if((ret_fapl = H5Fget_access_plist(file2)) < 0) TEST_ERROR
+ if(H5FD_FAMILY != H5Pget_driver(ret_fapl)) TEST_ERROR
- if (H5Gclose(group) < 0) TEST_ERROR
- if (H5Fclose(file2) < 0) TEST_ERROR
- if (H5Pclose(ret_fapl) < 0) TEST_ERROR
- if (H5Pclose(fam_fapl) < 0) TEST_ERROR
+ if(H5Gclose(group) < 0) TEST_ERROR
+ if(H5Fclose(file2) < 0) TEST_ERROR
+ if(H5Pclose(ret_fapl) < 0) TEST_ERROR
+ if(H5Pclose(fam_fapl) < 0) TEST_ERROR
/* Modify the user data structure to cause the callback to fail next time */
op_data.code = 1;
@@ -4250,7 +4250,7 @@ external_set_elink_cb(hid_t fapl, hbool_t new_format)
H5E_BEGIN_TRY {
group = H5Gopen2(file1, "/group1/ext_link/group2", gapl);
} H5E_END_TRY;
- if (group != FAIL) TEST_ERROR
+ if(group != FAIL) TEST_ERROR
/* Modify the user data structure to cause the callback to return invalid flags */
op_data.code = 2;
@@ -4259,11 +4259,11 @@ external_set_elink_cb(hid_t fapl, hbool_t new_format)
H5E_BEGIN_TRY {
group = H5Gopen2(file1, "/group1/ext_link/group2", gapl);
} H5E_END_TRY;
- if (group != FAIL) TEST_ERROR
+ if(group != FAIL) TEST_ERROR
/* Close */
- if (H5Fclose(file1) < 0) TEST_ERROR
- if (H5Pclose(gapl) < 0) TEST_ERROR
+ if(H5Fclose(file1) < 0) TEST_ERROR
+ if(H5Pclose(gapl) < 0) TEST_ERROR
PASSED();
return 0;
@@ -6409,7 +6409,7 @@ error:
*-------------------------------------------------------------------------
*/
static int
-external_symlink(hid_t fapl, hbool_t new_format)
+external_symlink(const char *env_h5_drvr, hid_t fapl, hbool_t new_format)
{
#ifdef H5_HAVE_SYMLINK
hid_t file1 = -1, file2 = -1, file3 = -1, file4 = -1, file5 = -1;
@@ -6425,6 +6425,7 @@ external_symlink(hid_t fapl, hbool_t new_format)
filename5b[NAME_BUF_SIZE],
tmpname[NAME_BUF_SIZE],
cwdpath[NAME_BUF_SIZE];
+ hbool_t have_posix_compat_vfd; /* Whether VFD used is compatible w/POSIX I/O calls */
#endif /* H5_HAVE_SYMLINK */
if(new_format)
@@ -6433,145 +6434,158 @@ external_symlink(hid_t fapl, hbool_t new_format)
TESTING("external links w/symlink files")
#ifdef H5_HAVE_SYMLINK
- /* set up name for main file: "extlinks21A" */
- h5_fixname(FILENAME[45], fapl, filename1, sizeof(filename1));
+ /* Skip test when using VFDs that can't provide a POSIX compatible file
+ * descriptor.
+ */
+ have_posix_compat_vfd = (hbool_t)(!HDstrcmp(env_h5_drvr, "sec2")
+ || !HDstrcmp(env_h5_drvr, "core")
+ || !HDstrcmp(env_h5_drvr, "nomatch"));
+ if(have_posix_compat_vfd) {
+ /* set up name for main file: "extlinks21A" */
+ h5_fixname(FILENAME[45], fapl, filename1, sizeof(filename1));
+
+ /* create tmp directory and get current working directory path */
+ if(HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST)
+ TEST_ERROR
+ if(HDmkdir(TMPDIR2, (mode_t)0755) < 0 && errno != EEXIST)
+ TEST_ERROR
+ if(NULL == HDgetcwd(cwdpath, NAME_BUF_SIZE))
+ TEST_ERROR
- /* create tmp directory and get current working directory path */
- if(HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST)
- TEST_ERROR
- if(HDmkdir(TMPDIR2, (mode_t)0755) < 0 && errno != EEXIST)
- TEST_ERROR
- if(NULL == HDgetcwd(cwdpath, NAME_BUF_SIZE))
- TEST_ERROR
+ /* Set up names for files in the subdirectories */
- /* Set up names for files in the subdirectories */
+ /* set up names for file #2 in temporary directory #2: "tmp2/extlinks21B" */
+ h5_fixname(FILENAME[46], fapl, filename2a, sizeof(filename2a));
+ fix_ext_filename(tmpname, cwdpath, FILENAME[46]);
+ h5_fixname(tmpname, fapl, filename2b, sizeof(filename2b));
- /* set up names for file #2 in temporary directory #2: "tmp2/extlinks21B" */
- h5_fixname(FILENAME[46], fapl, filename2a, sizeof(filename2a));
- fix_ext_filename(tmpname, cwdpath, FILENAME[46]);
- h5_fixname(tmpname, fapl, filename2b, sizeof(filename2b));
+ /* Create symbolic link #1 in temporary directory #1 to file #2 in temporary directory #2 */
+ /* (i.e. tmp/sym1.h5 -> <full path to>/tmp2/extlinks21B.h5) */
+ if(HDsymlink(filename2b, SYMLINK1) < 0 && errno != EEXIST) TEST_ERROR
- /* Create symbolic link #1 in temporary directory #1 to file #2 in temporary directory #2 */
- /* (i.e. tmp/sym1.h5 -> <full path to>/tmp2/extlinks21B.h5) */
- if(HDsymlink(filename2b, SYMLINK1) < 0 && errno != EEXIST) TEST_ERROR
+ /* set up name for file #3 in temporary directory #2: "tmp2/extlinks21C" */
+ h5_fixname(FILENAME[47], fapl, filename3a, sizeof(filename3a));
+ h5_fixname(FILENAME[48], fapl, filename3b, sizeof(filename3b));
- /* set up name for file #3 in temporary directory #2: "tmp2/extlinks21C" */
- h5_fixname(FILENAME[47], fapl, filename3a, sizeof(filename3a));
- h5_fixname(FILENAME[48], fapl, filename3b, sizeof(filename3b));
+ /* set up name for file #4 in temporary directory #1: "tmp/extlinks21D" */
+ h5_fixname(FILENAME[49], fapl, filename4a, sizeof(filename4a));
+ fix_ext_filename(tmpname, cwdpath, FILENAME[49]);
+ h5_fixname(tmpname, fapl, filename4b, sizeof(filename4b));
- /* set up name for file #4 in temporary directory #1: "tmp/extlinks21D" */
- h5_fixname(FILENAME[49], fapl, filename4a, sizeof(filename4a));
- fix_ext_filename(tmpname, cwdpath, FILENAME[49]);
- h5_fixname(tmpname, fapl, filename4b, sizeof(filename4b));
+ /* Create symbolic link #2 in temporary directory #2 to file #4 in temporary directory #1 */
+ /* (i.e. tmp2/sym2.h5 -> <full path to>/tmp/extlinks21D.h5) */
+ if(HDsymlink(filename4b, SYMLINK2) < 0 && errno != EEXIST) TEST_ERROR
- /* Create symbolic link #2 in temporary directory #2 to file #4 in temporary directory #1 */
- /* (i.e. tmp2/sym2.h5 -> <full path to>/tmp/extlinks21D.h5) */
- if(HDsymlink(filename4b, SYMLINK2) < 0 && errno != EEXIST) TEST_ERROR
+ /* set up name for file #5 in temporary directory #1: "tmp/extlinks21E" */
+ h5_fixname(FILENAME[50], fapl, filename5a, sizeof(filename5a));
+ h5_fixname(FILENAME[51], fapl, filename5b, sizeof(filename5b));
- /* set up name for file #5 in temporary directory #1: "tmp/extlinks21E" */
- h5_fixname(FILENAME[50], fapl, filename5a, sizeof(filename5a));
- h5_fixname(FILENAME[51], fapl, filename5b, sizeof(filename5b));
+ /* Create file #1 in current directory */
+ if((file1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
- /* Create file #1 in current directory */
- if((file1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+ /* Create external link to file & object in temporary directory #2, using symlink #1 name */
+ if(H5Lcreate_external(SYMLINK1, "group2", file1, "extlink2-sym", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
- /* Create external link to file & object in temporary directory #2, using symlink #1 name */
- if(H5Lcreate_external(SYMLINK1, "group2", file1, "extlink2-sym", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ /* Close file #1 */
+ if(H5Fclose(file1) < 0) TEST_ERROR
- /* Close file #1 */
- if(H5Fclose(file1) < 0) TEST_ERROR
+ /* Create file #2 in tmp directory #2 */
+ if((file2 = H5Fcreate(filename2a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+ if(H5Fclose(file2) < 0) TEST_ERROR
- /* Create file #2 in tmp directory #2 */
- if((file2 = H5Fcreate(filename2a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
- if(H5Fclose(file2) < 0) TEST_ERROR
+ /* Re-open file #2 in tmp directory through symlink */
+ if((file2 = H5Fopen(SYMLINK1, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR
- /* Re-open file #2 in tmp directory through symlink */
- if((file2 = H5Fopen(SYMLINK1, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR
+ /* Create group in file #2 in temporary directory */
+ if((group2 = H5Gcreate2(file2, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
- /* Create group in file #2 in temporary directory */
- if((group2 = H5Gcreate2(file2, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ /* Create external link to file #3 & object in temporary directory #2 */
+ if(H5Lcreate_external(filename3b, "group3", group2, "extlink3", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
- /* Create external link to file #3 & object in temporary directory #2 */
- if(H5Lcreate_external(filename3b, "group3", group2, "extlink3", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ /* Close group in file #2 */
+ if(H5Gclose(group2) < 0) TEST_ERROR
- /* Close group in file #2 */
- if(H5Gclose(group2) < 0) TEST_ERROR
+ /* Close file #2 */
+ if(H5Fclose(file2) < 0) TEST_ERROR
- /* Close file #2 */
- if(H5Fclose(file2) < 0) TEST_ERROR
+ /* Create file #3 in temp. directory #2 */
+ if((file3 = H5Fcreate(filename3a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
- /* Create file #3 in temp. directory #2 */
- if((file3 = H5Fcreate(filename3a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+ /* Create group in file #3 */
+ if((group3 = H5Gcreate2(file3, "group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
- /* Create group in file #3 */
- if((group3 = H5Gcreate2(file3, "group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ /* Create external link to file & object in temporary directory #1, using symlink #2 name */
+ if(H5Lcreate_external(SYMLINK2, "group4", group3, "extlink4-sym", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
- /* Create external link to file & object in temporary directory #1, using symlink #2 name */
- if(H5Lcreate_external(SYMLINK2, "group4", group3, "extlink4-sym", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ /* Close group in file #3 */
+ if(H5Gclose(group3) < 0) TEST_ERROR
- /* Close group in file #3 */
- if(H5Gclose(group3) < 0) TEST_ERROR
+ /* Close file #3 */
+ if(H5Fclose(file3) < 0) TEST_ERROR
- /* Close file #3 */
- if(H5Fclose(file3) < 0) TEST_ERROR
+ /* Create file #4 in temporary directory #1 */
+ if((file4 = H5Fcreate(filename4b, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
- /* Create file #4 in temporary directory #1 */
- if((file4 = H5Fcreate(filename4b, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+ /* Create group in file #4 in 'temporary' directory */
+ if((group4 = H5Gcreate2(file4, "group4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
- /* Create group in file #4 in 'temporary' directory */
- if((group4 = H5Gcreate2(file4, "group4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ /* Create external link to file #5 & object in temporary directory #1 */
+ if(H5Lcreate_external(filename5b, "group5", group4, "extlink5", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
- /* Create external link to file #5 & object in temporary directory #1 */
- if(H5Lcreate_external(filename5b, "group5", group4, "extlink5", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ /* Close group in file #4 */
+ if(H5Gclose(group4) < 0) TEST_ERROR
- /* Close group in file #4 */
- if(H5Gclose(group4) < 0) TEST_ERROR
+ /* Close file #4 */
+ if(H5Fclose(file4) < 0) TEST_ERROR
- /* Close file #4 */
- if(H5Fclose(file4) < 0) TEST_ERROR
+ /* Create file #5 in temporary directory #1 */
+ if((file5 = H5Fcreate(filename5a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
- /* Create file #5 in temporary directory #1 */
- if((file5 = H5Fcreate(filename5a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+ /* Create group in file #5 in 'temporary' directory #1 */
+ if((group5 = H5Gcreate2(file5, "group5", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
+ if(H5Gclose(group5) < 0) TEST_ERROR
- /* Create group in file #5 in 'temporary' directory #1 */
- if((group5 = H5Gcreate2(file5, "group5", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Gclose(group5) < 0) TEST_ERROR
+ /* Close file #5 */
+ if(H5Fclose(file5) < 0) TEST_ERROR
- /* Close file #5 */
- if(H5Fclose(file5) < 0) TEST_ERROR
+ /* Actual tests... */
- /* Actual tests... */
+ /* Reopen file #1 */
+ if((file1 = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR
- /* Reopen file #1 */
- if((file1 = H5Fopen(filename1, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR
+ /* Open group in file #2, through external link w/symlink */
+ if((group2 = H5Gopen2(file1, "extlink2-sym", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+ if(H5Gclose(group2) < 0) TEST_ERROR
- /* Open group in file #2, through external link w/symlink */
- if((group2 = H5Gopen2(file1, "extlink2-sym", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
- if(H5Gclose(group2) < 0) TEST_ERROR
+ /* Open group in file #3, through external link w/symlink to external link */
+ if((group3 = H5Gopen2(file1, "extlink2-sym/extlink3", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+ if(H5Gclose(group3) < 0) TEST_ERROR
- /* Open group in file #3, through external link w/symlink to external link */
- if((group3 = H5Gopen2(file1, "extlink2-sym/extlink3", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
- if(H5Gclose(group3) < 0) TEST_ERROR
+ /* Open group in file #4, through external link w/symlink to external link w/symlink */
+ if((group4 = H5Gopen2(file1, "extlink2-sym/extlink3/extlink4-sym", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+ if(H5Gclose(group4) < 0) TEST_ERROR
- /* Open group in file #4, through external link w/symlink to external link w/symlink */
- if((group4 = H5Gopen2(file1, "extlink2-sym/extlink3/extlink4-sym", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
- if(H5Gclose(group4) < 0) TEST_ERROR
+ /* Open group in file #5, through external link w/symlink to external link w/symlink to external link */
+ if((group5 = H5Gopen2(file1, "extlink2-sym/extlink3/extlink4-sym/extlink5", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+ if(H5Gclose(group5) < 0) TEST_ERROR
- /* Open group in file #5, through external link w/symlink to external link w/symlink to external link */
- if((group5 = H5Gopen2(file1, "extlink2-sym/extlink3/extlink4-sym/extlink5", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
- if(H5Gclose(group5) < 0) TEST_ERROR
+ /* Close file #1 */
+ if(H5Fclose(file1) < 0) TEST_ERROR
- /* Close file #1 */
- if(H5Fclose(file1) < 0) TEST_ERROR
+ PASSED();
+ } /* end if */
+ else {
+ SKIPPED();
+ puts(" Current VFD doesn't support POSIX I/O calls");
+ } /* end else */
- PASSED();
return 0;
error:
@@ -13510,11 +13524,11 @@ main(void)
hid_t fapl, fapl2; /* File access property lists */
int nerrors = 0;
hbool_t new_format; /* Whether to use the new format or not */
- const char *envval;
+ const char *env_h5_drvr; /* File Driver value from environment */
- envval = HDgetenv("HDF5_DRIVER");
- if(envval == NULL)
- envval = "nomatch";
+ env_h5_drvr = HDgetenv("HDF5_DRIVER");
+ if(env_h5_drvr == NULL)
+ env_h5_drvr = "nomatch";
h5_reset();
fapl = h5_fileaccess();
@@ -13557,8 +13571,8 @@ main(void)
nerrors += external_link_path(my_fapl, new_format) < 0 ? 1 : 0;
nerrors += external_link_mult(my_fapl, new_format) < 0 ? 1 : 0;
#ifndef H5_CANNOT_OPEN_TWICE
- nerrors += external_link_self(envval, my_fapl, new_format) < 0 ? 1 : 0;
- nerrors += external_link_pingpong(envval, my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_self(env_h5_drvr, my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_pingpong(env_h5_drvr, my_fapl, new_format) < 0 ? 1 : 0;
nerrors += external_link_toomany(my_fapl, new_format) < 0 ? 1 : 0;
#endif /* H5_CANNOT_OPEN_TWICE */
nerrors += external_link_dangling(my_fapl, new_format) < 0 ? 1 : 0;
@@ -13569,7 +13583,7 @@ main(void)
nerrors += external_link_move(my_fapl, new_format) < 0 ? 1 : 0;
nerrors += external_link_ride(my_fapl, new_format) < 0 ? 1 : 0;
#ifndef H5_CANNOT_OPEN_TWICE
- nerrors += external_link_closing(envval, my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_link_closing(env_h5_drvr, my_fapl, new_format) < 0 ? 1 : 0;
#endif /* H5_CANNOT_OPEN_TWICE */
nerrors += external_link_endian(new_format) < 0 ? 1 : 0;
nerrors += external_link_strong(my_fapl, new_format) < 0 ? 1 : 0;
@@ -13600,7 +13614,7 @@ main(void)
nerrors += external_link_win8(my_fapl, new_format) < 0 ? 1 : 0;
nerrors += external_link_win9(my_fapl, new_format) < 0 ? 1 : 0;
#endif
- nerrors += external_symlink(my_fapl, new_format) < 0 ? 1 : 0;
+ nerrors += external_symlink(env_h5_drvr, my_fapl, new_format) < 0 ? 1 : 0;
/* These tests assume that external links are a form of UD links,
* so assume that everything that passed for external links
diff --git a/test/ntypes.c b/test/ntypes.c
index a82f051..87484d9 100644
--- a/test/ntypes.c
+++ b/test/ntypes.c
@@ -23,8 +23,8 @@
#include "h5test.h"
const char *FILENAME[] = {
- "ntypes",
- NULL
+ "ntypes",
+ NULL
};
#define DIM0 100
@@ -60,6 +60,7 @@ int ipoints3[DIM0][DIM1][5], icheck3[DIM0][DIM1][5];
#define SPACE2_DIM1 10
#define SPACE2_DIM2 10
+
/*-------------------------------------------------------------------------
* Function: test_atomic_dtype
@@ -80,11 +81,11 @@ int ipoints3[DIM0][DIM1][5], icheck3[DIM0][DIM1][5];
static herr_t
test_atomic_dtype(hid_t file)
{
- hid_t dataset, space;
- hid_t dtype, native_type;
- int i, j, n;
- hsize_t dims[2];
- void *tmp;
+ hid_t dataset = -1, space = -1;
+ hid_t dtype = -1, native_type = -1;
+ int i, j, n;
+ hsize_t dims[2];
+ void *tmp = NULL;
TESTING("atomic datatype");
@@ -101,7 +102,8 @@ test_atomic_dtype(hid_t file)
/*------------------- Test data values ------------------------*/
/* Create the dataset */
if((dataset = H5Dcreate2(file, DSET_ATOMIC_NAME_1, H5T_STD_I32BE, space,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
/* Write the data to the dataset */
if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, ipoints2) < 0)
@@ -127,18 +129,20 @@ test_atomic_dtype(hid_t file)
TEST_ERROR;
/* Read the dataset back. The temporary buffer is for special platforms
- * like Cray. */
- tmp = malloc((size_t)(DIM0 * DIM1 * H5Tget_size(native_type)));
+ * like Cray. */
+ if(NULL == (tmp = HDmalloc((size_t)(DIM0 * DIM1 * H5Tget_size(native_type)))))
+ TEST_ERROR
if(H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0)
TEST_ERROR;
/* Copy data from temporary buffer to destination buffer */
- memcpy(icheck2, tmp, (size_t)(DIM0 * DIM1 * H5Tget_size(native_type)));
- free(tmp);
+ HDmemcpy(icheck2, tmp, (size_t)(DIM0 * DIM1 * H5Tget_size(native_type)));
+ HDfree(tmp);
+ tmp = NULL;
/* Convert to the integer type */
- if(H5Tconvert(native_type, H5T_NATIVE_INT, (DIM0*DIM1), icheck2, NULL, H5P_DEFAULT) < 0)
+ if(H5Tconvert(native_type, H5T_NATIVE_INT, (DIM0 * DIM1), icheck2, NULL, H5P_DEFAULT) < 0)
TEST_ERROR;
/* Check that the values read are the same as the values written */
@@ -159,7 +163,8 @@ test_atomic_dtype(hid_t file)
/* Create the dataset of H5T_STD_I64LE */
if((dataset = H5Dcreate2(file, DSET_ATOMIC_NAME_2, H5T_STD_I64LE, space,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
if((dtype = H5Dget_type(dataset)) < 0) TEST_ERROR;
@@ -181,7 +186,8 @@ test_atomic_dtype(hid_t file)
/* Create the dataset of H5T_STD_I8LE */
if((dataset = H5Dcreate2(file, DSET_ATOMIC_NAME_3, H5T_STD_I8LE, space,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
if((dtype = H5Dget_type(dataset)) < 0) TEST_ERROR;
@@ -203,7 +209,8 @@ test_atomic_dtype(hid_t file)
/* Create the dataset of H5T_IEEE_F32BE */
if((dataset = H5Dcreate2(file, DSET_ATOMIC_NAME_4, H5T_IEEE_F32BE, space,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
if((dtype = H5Dget_type(dataset)) < 0) TEST_ERROR;
@@ -225,7 +232,8 @@ test_atomic_dtype(hid_t file)
/* Create the dataset of H5T_IEEE_F64BE */
if((dataset = H5Dcreate2(file, DSET_ATOMIC_NAME_5, H5T_IEEE_F64BE, space,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
if((dtype = H5Dget_type(dataset)) < 0) TEST_ERROR;
@@ -253,6 +261,16 @@ test_atomic_dtype(hid_t file)
return 0;
error:
+ if(tmp)
+ HDfree(tmp);
+
+ H5E_BEGIN_TRY {
+ H5Dclose(dataset);
+ H5Tclose(native_type);
+ H5Tclose(dtype);
+ H5Sclose(space);
+ } H5E_END_TRY;
+
return -1;
}
@@ -286,14 +304,14 @@ test_compound_dtype2(hid_t file)
s2 st;
unsigned long long l;
} s1;
- hid_t dataset, space;
- hid_t dtype, native_type, tid, tid2, tid_m, tid_m2,
- mem_id, nest_mem_id;
- int i, j, n;
- hsize_t dims[2];
- s1 *temp_point, *temp_check;
- s1 *points=NULL, *check=NULL;
- void *tmp, *bkg;
+ hid_t dataset = -1, space = -1;
+ hid_t dtype = -1, native_type = -1, tid = -1, tid2 = -1, tid_m = -1,
+ tid_m2 = -1, mem_id = -1, nest_mem_id = -1;
+ int i, j, n;
+ hsize_t dims[2];
+ s1 *temp_point = NULL, *temp_check = NULL;
+ s1 *points = NULL, *check = NULL;
+ void *tmp = NULL, *bkg = NULL;
TESTING("nested compound datatype");
@@ -304,15 +322,15 @@ test_compound_dtype2(hid_t file)
TEST_ERROR;
/* Initialize the dataset */
- for (i = n = 0, temp_point=points; i < DIM0; i++) {
- for (j = 0; j < DIM1; j++,temp_point++) {
- temp_point->c = 't';
- temp_point->i = n++;
- temp_point->st.c2 = (short)(i + j);
- temp_point->st.l2 = (i * 5 + j * 50) * n;
- temp_point->l = (unsigned long long)((i * 10 + j * 100) * n);
- }
- }
+ for(i = n = 0, temp_point = points; i < DIM0; i++) {
+ for(j = 0; j < DIM1; j++, temp_point++) {
+ temp_point->c = 't';
+ temp_point->i = n++;
+ temp_point->st.c2 = (short)(i + j);
+ temp_point->st.l2 = (i * 5 + j * 50) * n;
+ temp_point->l = (unsigned long long)((i * 10 + j * 100) * n);
+ } /* end for */
+ } /* end for */
/* Create the data space */
dims[0] = DIM0;
@@ -353,7 +371,8 @@ test_compound_dtype2(hid_t file)
/* Create the dataset */
if((dataset = H5Dcreate2(file, DSET_COMPOUND_NAME_2, tid, space,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
/* Create compound datatype for memory */
if((tid_m2 = H5Tcreate(H5T_COMPOUND, sizeof(s2))) < 0) TEST_ERROR;
@@ -369,7 +388,7 @@ test_compound_dtype2(hid_t file)
/* Write the data to the dataset */
if(H5Dwrite(dataset, tid_m, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0)
- TEST_ERROR;
+ TEST_ERROR;
/* Close dataset */
if(H5Dclose(dataset) < 0) TEST_ERROR;
@@ -451,36 +470,39 @@ test_compound_dtype2(hid_t file)
/* Read the dataset back. Temporary buffer is for special platforms like
* Cray */
- tmp = malloc(DIM0*DIM1*H5Tget_size(native_type));
- if((bkg=calloc(sizeof(s1),DIM0*DIM1))==NULL)
+ if(NULL == (tmp = HDmalloc(DIM0 * DIM1 * H5Tget_size(native_type))))
+ TEST_ERROR
+ if(NULL == (bkg = HDcalloc(sizeof(s1), DIM0 * DIM1)))
TEST_ERROR;
if(H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0)
- TEST_ERROR;
+ TEST_ERROR;
- memcpy(check, tmp, DIM0*DIM1*H5Tget_size(native_type));
- free(tmp);
+ HDmemcpy(check, tmp, DIM0*DIM1*H5Tget_size(native_type));
+ HDfree(tmp);
+ tmp = NULL;
- if(H5Tconvert(native_type, tid_m, (DIM0*DIM1), check, bkg, H5P_DEFAULT))
+ if(H5Tconvert(native_type, tid_m, (DIM0 * DIM1), check, bkg, H5P_DEFAULT) < 0)
TEST_ERROR;
- free(bkg);
+ HDfree(bkg);
+ bkg = NULL;
/* Check that the values read are the same as the values written */
- for (i = 0, temp_point=points, temp_check=check; i < DIM0; i++) {
- for (j = 0; j < DIM1; j++, temp_point++,temp_check++) {
- if(temp_point->c != temp_check->c ||
- temp_point->i != temp_check->i ||
- temp_point->st.c2 != temp_check->st.c2 ||
- temp_point->st.l2 != temp_check->st.l2 ||
- temp_point->l != temp_check->l ) {
- H5_FAILED();
- printf(" Read different values than written.\n");
- printf(" At index %d,%d\n", i, j);
- goto error;
- }
- }
- }
+ for(i = 0, temp_point = points, temp_check = check; i < DIM0; i++) {
+ for(j = 0; j < DIM1; j++, temp_point++, temp_check++) {
+ if(temp_point->c != temp_check->c ||
+ temp_point->i != temp_check->i ||
+ temp_point->st.c2 != temp_check->st.c2 ||
+ temp_point->st.l2 != temp_check->st.l2 ||
+ temp_point->l != temp_check->l ) {
+ H5_FAILED();
+ printf(" Read different values than written.\n");
+ printf(" At index %d,%d\n", i, j);
+ goto error;
+ } /* end if */
+ } /* end for */
+ } /* end for */
/* Close temporary datatypes */
if(H5Tclose(tid2) < 0) TEST_ERROR;
@@ -494,17 +516,35 @@ test_compound_dtype2(hid_t file)
H5Tclose(tid_m);
/* Free memory for test data */
- free(points);
- free(check);
+ HDfree(points);
+ HDfree(check);
PASSED();
return 0;
error:
- if(points!=NULL)
- free(points);
- if(check!=NULL)
- free(check);
+ if(tmp)
+ HDfree(tmp);
+ if(bkg)
+ HDfree(bkg);
+ if(points)
+ HDfree(points);
+ if(check)
+ HDfree(check);
+
+ H5E_BEGIN_TRY {
+ H5Tclose(tid);
+ H5Tclose(tid2);
+ H5Tclose(tid_m);
+ H5Tclose(tid_m2);
+ H5Sclose(space);
+ H5Tclose(mem_id);
+ H5Tclose(nest_mem_id);
+ H5Dclose(dataset);
+ H5Tclose(dtype);
+ H5Tclose(native_type);
+ } H5E_END_TRY;
+
return -1;
}
@@ -533,17 +573,19 @@ test_compound_dtype(hid_t file)
unsigned int i;
long long l;
} s1;
- hid_t dataset, space;
- hid_t dtype, native_type, tid, tid2, mem_id;
- int i, j, n;
- hsize_t dims[2];
- s1 *temp_point, *temp_check;
- s1 *points, *check;
- void *tmp, *bkg;
+ hid_t dataset = -1, space = -1;
+ hid_t dtype = -1, native_type = -1, tid = -1, tid2 = -1, mem_id = -1;
+ int i, j, n;
+ hsize_t dims[2];
+ s1 *temp_point = NULL;
+ s1 *temp_check = NULL;
+ s1 *points = NULL;
+ s1 *check = NULL;
+ void *tmp = NULL;
+ void *bkg = NULL;
TESTING("compound datatype");
-
/* Allocate space for the points & check arrays */
if(NULL == (points = (s1 *)HDmalloc(sizeof(s1) * DIM0 * DIM1)))
TEST_ERROR;
@@ -551,12 +593,12 @@ test_compound_dtype(hid_t file)
TEST_ERROR;
/* Initialize the dataset */
- for(i = n = 0, temp_point=points; i < DIM0; i++)
- for(j = 0; j < DIM1; j++,temp_point++) {
- temp_point->c = 't';
- temp_point->i = (unsigned int)(n++);
- temp_point->l = (i*10+j*100)*n;
- } /* end for */
+ for(i = n = 0, temp_point = points; i < DIM0; i++)
+ for(j = 0; j < DIM1; j++, temp_point++) {
+ temp_point->c = 't';
+ temp_point->i = (unsigned int)(n++);
+ temp_point->l = (i * 10 + j * 100) * n;
+ } /* end for */
/* Create the data space */
dims[0] = DIM0;
@@ -573,7 +615,8 @@ test_compound_dtype(hid_t file)
/* Create the dataset */
if((dataset = H5Dcreate2(file, DSET_COMPOUND_NAME, tid, space,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
/* Create compound datatype for datatype in memory */
if((tid2 = H5Tcreate(H5T_COMPOUND, sizeof(s1))) < 0) TEST_ERROR;
@@ -583,7 +626,7 @@ test_compound_dtype(hid_t file)
/* Write the data to the dataset */
if(H5Dwrite(dataset, tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0)
- TEST_ERROR;
+ TEST_ERROR;
/* Close dataset */
if(H5Dclose(dataset) < 0) TEST_ERROR;
@@ -633,33 +676,35 @@ test_compound_dtype(hid_t file)
/* Read the dataset back. Temporary buffer is for special platforms like
* Cray */
- tmp = malloc(DIM0*DIM1*H5Tget_size(native_type));
- bkg = calloc(sizeof(s1),DIM0*DIM1);
+ if(NULL == (tmp = HDmalloc(DIM0 * DIM1 * H5Tget_size(native_type))))
+ TEST_ERROR
+ if(NULL == (bkg = HDcalloc(sizeof(s1), DIM0 * DIM1)))
+ TEST_ERROR
if(H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0)
- TEST_ERROR;
+ TEST_ERROR;
- memcpy(check, tmp, DIM0*DIM1*H5Tget_size(native_type));
- free(tmp);
+ HDmemcpy(check, tmp, DIM0 * DIM1 * H5Tget_size(native_type));
+ HDfree(tmp);
+ tmp = NULL;
- if(H5Tconvert(native_type, tid2, (DIM0*DIM1), check, bkg, H5P_DEFAULT) < 0)
+ if(H5Tconvert(native_type, tid2, (DIM0 * DIM1), check, bkg, H5P_DEFAULT) < 0)
TEST_ERROR;
- free(bkg);
+ HDfree(bkg);
+ bkg = NULL;
/* Check that the values read are the same as the values written */
- for (i = 0, temp_point=points, temp_check=check; i < DIM0; i++) {
- for (j = 0; j < DIM1; j++, temp_point++,temp_check++) {
- if(temp_point->c != temp_check->c ||
- temp_point->i != temp_check->i ||
- temp_point->l != temp_check->l ) {
- H5_FAILED();
- printf(" Read different values than written.\n");
- printf(" At index %d,%d\n", i, j);
- goto error;
- }
- }
- }
+ for(i = 0, temp_point = points, temp_check = check; i < DIM0; i++)
+ for(j = 0; j < DIM1; j++, temp_point++, temp_check++)
+ if(temp_point->c != temp_check->c ||
+ temp_point->i != temp_check->i ||
+ temp_point->l != temp_check->l ) {
+ H5_FAILED();
+ printf(" Read different values than written.\n");
+ printf(" At index %d,%d\n", i, j);
+ goto error;
+ } /* end if */
/* Close datatype */
if(H5Tclose(tid) < 0) TEST_ERROR;
@@ -670,13 +715,33 @@ test_compound_dtype(hid_t file)
H5Tclose(tid2);
/* Free memory for test data */
- free(points);
- free(check);
+ HDfree(points);
+ HDfree(check);
PASSED();
return 0;
- error:
+error:
+ /* Free memory for test data */
+ if(tmp)
+ HDfree(tmp);
+ if(bkg)
+ HDfree(bkg);
+ if(points)
+ HDfree(points);
+ if(check)
+ HDfree(check);
+
+ H5E_BEGIN_TRY {
+ H5Tclose(tid);
+ H5Sclose(space);
+ H5Tclose(mem_id);
+ H5Dclose(dataset);
+ H5Tclose(dtype);
+ H5Tclose(native_type);
+ H5Tclose(tid2);
+ } H5E_END_TRY;
+
return -1;
}
@@ -705,15 +770,15 @@ test_compound_dtype3(hid_t file)
int a[5];
long long l;
} s1;
- hid_t dataset, space;
- hid_t dtype, native_type, tid, tid2, tid_m, tid_m2,
- mem_id, nest_mem_id;
- hsize_t array_dims[1]={5};
- int i, j, k, n;
- hsize_t dims[2];
- s1 *temp_point, *temp_check;
- s1 *points=NULL, *check=NULL;
- void *tmp, *bkg;
+ hid_t dataset = -1, space = -1;
+ hid_t dtype = -1, native_type = -1, tid = -1, tid2 = -1, tid_m = -1,
+ tid_m2 = -1, mem_id = -1, nest_mem_id = -1;
+ hsize_t array_dims[1] = {5};
+ int i, j, k, n;
+ hsize_t dims[2];
+ s1 *temp_point = NULL, *temp_check = NULL;
+ s1 *points = NULL, *check = NULL;
+ void *tmp = NULL, *bkg = NULL;
TESTING("compound datatype with array as field");
@@ -724,13 +789,13 @@ test_compound_dtype3(hid_t file)
TEST_ERROR;
/* Initialize the dataset */
- for(i = n = 0, temp_point=points; i < DIM0; i++)
- for(j = 0; j < DIM1; j++,temp_point++) {
- temp_point->c = 't';
- temp_point->l = (i*10+j*100)*n;
- for(k = 0; k < 5; k++)
- (temp_point->a)[k] = n++;
- } /* end for */
+ for(i = n = 0, temp_point = points; i < DIM0; i++)
+ for(j = 0; j < DIM1; j++, temp_point++) {
+ temp_point->c = 't';
+ temp_point->l = (i * 10 + j * 100) * n;
+ for(k = 0; k < 5; k++)
+ (temp_point->a)[k] = n++;
+ } /* end for */
/* Create the data space */
dims[0] = DIM0;
@@ -750,7 +815,8 @@ test_compound_dtype3(hid_t file)
/* Create the dataset */
if((dataset = H5Dcreate2(file, DSET_COMPOUND_NAME_3, tid, space,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
/* Create array datatype */
if((tid_m2 = H5Tarray_create2(H5T_NATIVE_INT, 1, array_dims)) < 0) TEST_ERROR;
@@ -763,7 +829,7 @@ test_compound_dtype3(hid_t file)
/* Write the data to the dataset */
if(H5Dwrite(dataset, tid_m, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0)
- TEST_ERROR;
+ TEST_ERROR;
/* Close dataset */
if(H5Dclose(dataset) < 0) TEST_ERROR;
@@ -825,42 +891,44 @@ test_compound_dtype3(hid_t file)
/* Read the dataset back. Temporary buffer is for special platforms like
* Cray */
- tmp = malloc(DIM0*DIM1*H5Tget_size(native_type));
- if((bkg=calloc(sizeof(s1),DIM0*DIM1))==NULL)
+ if(NULL == (tmp = HDmalloc(DIM0 * DIM1 * H5Tget_size(native_type))))
+ TEST_ERROR;
+ if(NULL == (bkg = HDcalloc(sizeof(s1), DIM0 * DIM1)))
TEST_ERROR;
if(H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0)
- TEST_ERROR;
+ TEST_ERROR;
- memcpy(check, tmp, DIM0*DIM1*H5Tget_size(native_type));
- free(tmp);
+ HDmemcpy(check, tmp, DIM0 * DIM1 * H5Tget_size(native_type));
+ HDfree(tmp);
+ tmp = NULL;
- if(H5Tconvert(native_type, tid_m, (DIM0*DIM1), check, bkg, H5P_DEFAULT))
+ if(H5Tconvert(native_type, tid_m, (DIM0 * DIM1), check, bkg, H5P_DEFAULT) < 0)
TEST_ERROR;
- free(bkg);
+ HDfree(bkg);
+ bkg = NULL;
/* Check that the values read are the same as the values written */
- for (i = 0, temp_point=points, temp_check=check; i < DIM0; i++) {
- for (j = 0; j < DIM1; j++, temp_point++,temp_check++) {
- if(temp_point->c != temp_check->c ||
- temp_point->l != temp_check->l ) {
- H5_FAILED();
- printf(" Read different values than written.\n");
- printf(" At index %d,%d\n", i, j);
- goto error;
- }
-
- for (k = 0; k < 5; k++) {
+ for(i = 0, temp_point = points, temp_check = check; i < DIM0; i++)
+ for(j = 0; j < DIM1; j++, temp_point++, temp_check++) {
+ if(temp_point->c != temp_check->c ||
+ temp_point->l != temp_check->l ) {
+ H5_FAILED();
+ printf(" Read different values than written.\n");
+ printf(" At index %d,%d\n", i, j);
+ goto error;
+ } /* end if */
+
+ for(k = 0; k < 5; k++) {
if(temp_point->a[k] != temp_check->a[k]) {
- H5_FAILED();
- printf(" Read different values than written.\n");
- printf(" At index %d,%d,%d\n", i, j, k);
- goto error;
- }
- }
- }
- }
+ H5_FAILED();
+ printf(" Read different values than written.\n");
+ printf(" At index %d,%d,%d\n", i, j, k);
+ goto error;
+ } /* end if */
+ } /* end for */
+ } /* end for */
H5Dclose(dataset);
H5Tclose(dtype);
@@ -869,13 +937,36 @@ test_compound_dtype3(hid_t file)
H5Tclose(tid_m2);
/* Free memory for test data */
- free(points);
- free(check);
+ HDfree(points);
+ HDfree(check);
PASSED();
return 0;
- error:
+error:
+ /* Free memory for test data */
+ if(tmp)
+ HDfree(tmp);
+ if(bkg)
+ HDfree(bkg);
+ if(points)
+ HDfree(points);
+ if(check)
+ HDfree(check);
+
+ H5E_BEGIN_TRY {
+ H5Sclose(space);
+ H5Tclose(mem_id);
+ H5Tclose(nest_mem_id);
+ H5Dclose(dataset);
+ H5Tclose(dtype);
+ H5Tclose(native_type);
+ H5Tclose(tid);
+ H5Tclose(tid2);
+ H5Tclose(tid_m);
+ H5Tclose(tid_m2);
+ } H5E_END_TRY;
+
return -1;
}
@@ -904,14 +995,14 @@ test_compound_opaque(hid_t file)
unsigned char o[5];
long long l;
} s1;
- hid_t dataset, space;
- hid_t dtype, native_type, tid, tid2, tid_m,
- mem_id;
- int i, j, k, n;
- hsize_t dims[2];
- s1 *temp_point, *temp_check;
- s1 *points=NULL, *check=NULL;
- void *tmp, *bkg;
+ hid_t dataset = -1, space = -1;
+ hid_t dtype = -1, native_type = -1, tid = -1, tid2 = -1, tid_m = -1,
+ mem_id = -1;
+ int i, j, k, n;
+ hsize_t dims[2];
+ s1 *temp_point = NULL, *temp_check = NULL;
+ s1 *points = NULL, *check = NULL;
+ void *tmp = NULL, *bkg = NULL;
TESTING("compound datatype with opaque field");
@@ -922,13 +1013,13 @@ test_compound_opaque(hid_t file)
TEST_ERROR;
/* Initialize the dataset */
- for(i = n = 0, temp_point=points; i < DIM0; i++)
- for(j = 0; j < DIM1; j++,temp_point++) {
- temp_point->c = 't';
- temp_point->l = (i*10+j*100)*n;
- for(k = 0; k < 5; k++)
- (temp_point->o)[k] = (unsigned char)(n++);
- } /* end for */
+ for(i = n = 0, temp_point = points; i < DIM0; i++)
+ for(j = 0; j < DIM1; j++, temp_point++) {
+ temp_point->c = 't';
+ temp_point->l = (i * 10 + j * 100) * n;
+ for(k = 0; k < 5; k++)
+ (temp_point->o)[k] = (unsigned char)(n++);
+ } /* end for */
/* Create the data space */
dims[0] = DIM0;
@@ -949,7 +1040,8 @@ test_compound_opaque(hid_t file)
/* Create the dataset */
if((dataset = H5Dcreate2(file, DSET_COMPOUND_NAME_4, tid, space,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
/* Create compound datatype for datatype in memory */
if((tid_m = H5Tcreate(H5T_COMPOUND, sizeof(s1))) < 0) TEST_ERROR;
@@ -959,7 +1051,7 @@ test_compound_opaque(hid_t file)
/* Write the data to the dataset */
if(H5Dwrite(dataset, tid_m, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0)
- TEST_ERROR;
+ TEST_ERROR;
/* Close dataset */
if(H5Dclose(dataset) < 0) TEST_ERROR;
@@ -1014,42 +1106,44 @@ test_compound_opaque(hid_t file)
/* Read the dataset back. Temporary buffer is for special platforms like
* Cray */
- tmp = HDmalloc(DIM0*DIM1*H5Tget_size(native_type));
- if((bkg=HDcalloc(sizeof(s1),DIM0*DIM1))==NULL)
+ if(NULL == (tmp = HDmalloc(DIM0 * DIM1 * H5Tget_size(native_type))))
+ TEST_ERROR;
+ if(NULL == (bkg = HDcalloc(sizeof(s1), DIM0 * DIM1)))
TEST_ERROR;
if(H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0)
- TEST_ERROR;
+ TEST_ERROR;
- HDmemcpy(check, tmp, DIM0*DIM1*H5Tget_size(native_type));
+ HDmemcpy(check, tmp, DIM0 * DIM1 * H5Tget_size(native_type));
HDfree(tmp);
+ tmp = NULL;
- if(H5Tconvert(native_type, tid_m, (DIM0*DIM1), check, bkg, H5P_DEFAULT))
+ if(H5Tconvert(native_type, tid_m, (DIM0 * DIM1), check, bkg, H5P_DEFAULT) < 0)
TEST_ERROR;
HDfree(bkg);
+ bkg = NULL;
/* Check that the values read are the same as the values written */
- for (i = 0, temp_point=points, temp_check=check; i < DIM0; i++) {
- for (j = 0; j < DIM1; j++, temp_point++,temp_check++) {
- if(temp_point->c != temp_check->c ||
- temp_point->l != temp_check->l ) {
- H5_FAILED();
- printf(" Read different values than written.\n");
- printf(" At index %d,%d\n", i, j);
- goto error;
- }
-
- for (k = 0; k < 5; k++) {
+ for(i = 0, temp_point = points, temp_check = check; i < DIM0; i++)
+ for(j = 0; j < DIM1; j++, temp_point++, temp_check++) {
+ if(temp_point->c != temp_check->c ||
+ temp_point->l != temp_check->l ) {
+ H5_FAILED();
+ printf(" Read different values than written.\n");
+ printf(" At index %d,%d\n", i, j);
+ goto error;
+ } /* end if */
+
+ for(k = 0; k < 5; k++) {
if(temp_point->o[k] != temp_check->o[k]) {
- H5_FAILED();
- printf(" Read different values than written.\n");
- printf(" At index %d,%d,%d\n", i, j, k);
- goto error;
- }
- }
- }
- }
+ H5_FAILED();
+ printf(" Read different values than written.\n");
+ printf(" At index %d,%d,%d\n", i, j, k);
+ goto error;
+ } /* end if */
+ } /* end for */
+ } /* end for */
H5Dclose(dataset);
H5Tclose(dtype);
@@ -1063,7 +1157,28 @@ test_compound_opaque(hid_t file)
PASSED();
return 0;
- error:
+error:
+ /* Free memory for test data */
+ if(tmp)
+ HDfree(tmp);
+ if(bkg)
+ HDfree(bkg);
+ if(points)
+ HDfree(points);
+ if(check)
+ HDfree(check);
+
+ H5E_BEGIN_TRY {
+ H5Sclose(space);
+ H5Tclose(mem_id);
+ H5Dclose(dataset);
+ H5Tclose(dtype);
+ H5Tclose(native_type);
+ H5Tclose(tid);
+ H5Tclose(tid2);
+ H5Tclose(tid_m);
+ } H5E_END_TRY;
+
return -1;
}
@@ -1087,28 +1202,28 @@ test_compound_opaque(hid_t file)
static herr_t
test_enum_dtype(hid_t file)
{
- hid_t dataset, space;
- hid_t tid, tid_m, dtype, native_type;
- int i, j, n;
- hsize_t dims[2];
- void *tmp;
- short colors[8];
- unsigned char sub_colors[16];
- const char *mname[] = { "RED",
- "GREEN",
- "BLUE",
- "YELLOW",
- "PINK",
- "PURPLE",
- "ORANGE",
- "WHITE" };
+ hid_t dataset = -1, space = -1;
+ hid_t tid = -1, tid_m = -1, dtype = -1, native_type = -1;
+ int i, j, n;
+ hsize_t dims[2];
+ void *tmp = NULL;
+ short colors[8];
+ unsigned char sub_colors[16];
+ const char *mname[] = { "RED",
+ "GREEN",
+ "BLUE",
+ "YELLOW",
+ "PINK",
+ "PURPLE",
+ "ORANGE",
+ "WHITE" };
TESTING("enum datatype");
/* Initialize the dataset */
for(i = 0; i < DIM0; i++)
for(j = 0, n = 0; j < DIM1; j++, n++)
- spoints2[i][j] = (short)((i * 10 + j * 100 + n) % 8);
+ spoints2[i][j] = (short)((i * 10 + j * 100 + n) % 8);
/* Create the data space */
dims[0] = DIM0;
@@ -1126,7 +1241,8 @@ test_enum_dtype(hid_t file)
/* Create the dataset */
if((dataset = H5Dcreate2(file, DSET_ENUM_NAME, tid, space,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
/* Construct enum type based on native type in memory */
if((tid_m = H5Tenum_create(H5T_NATIVE_SHORT)) < 0) TEST_ERROR;
@@ -1138,7 +1254,7 @@ test_enum_dtype(hid_t file)
/* Write the data to the dataset */
if(H5Dwrite(dataset, tid_m, H5S_ALL, H5S_ALL, H5P_DEFAULT, spoints2) < 0)
- TEST_ERROR;
+ TEST_ERROR;
/* Close dataset */
if(H5Dclose(dataset) < 0) TEST_ERROR;
@@ -1159,30 +1275,30 @@ test_enum_dtype(hid_t file)
/* Read the dataset back. Temporary buffer is for special platforms like
* Cray */
- tmp = malloc(DIM0 * DIM1 * H5Tget_size(native_type));
+ if(NULL == (tmp = HDmalloc(DIM0 * DIM1 * H5Tget_size(native_type))))
+ TEST_ERROR
if(H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0)
- TEST_ERROR;
+ TEST_ERROR;
- memcpy(scheck2, tmp, DIM0 * DIM1 * H5Tget_size(native_type));
- free(tmp);
+ HDmemcpy(scheck2, tmp, DIM0 * DIM1 * H5Tget_size(native_type));
+ HDfree(tmp);
+ tmp = NULL;
- if(H5Tconvert(native_type, tid_m, (DIM0*DIM1), scheck2, NULL, H5P_DEFAULT) < 0)
+ if(H5Tconvert(native_type, tid_m, (DIM0 * DIM1), scheck2, NULL, H5P_DEFAULT) < 0)
TEST_ERROR;
/* Check that the values read are the same as the values written */
- for (i = 0; i < DIM0; i++) {
- for (j = 0; j < DIM1; j++) {
- if(spoints2[i][j] != scheck2[i][j]) {
- H5_FAILED();
- printf(" Read different values than written.\n");
- printf(" At index %d,%d\n", i, j);
+ for(i = 0; i < DIM0; i++)
+ for(j = 0; j < DIM1; j++)
+ if(spoints2[i][j] != scheck2[i][j]) {
+ H5_FAILED();
+ printf(" Read different values than written.\n");
+ printf(" At index %d,%d\n", i, j);
printf(" spoints2[i][j]=%hd, scheck2[i][j]=%hd\n", spoints2[i][j],
scheck2[i][j]);
- goto error;
- }
- }
- }
+ goto error;
+ } /* end if */
H5Dclose(dataset);
H5Tclose(dtype);
@@ -1191,7 +1307,20 @@ test_enum_dtype(hid_t file)
PASSED();
return 0;
- error:
+error:
+ /* Free memory for test data */
+ if(tmp)
+ HDfree(tmp);
+
+ H5E_BEGIN_TRY {
+ H5Sclose(space);
+ H5Dclose(dataset);
+ H5Tclose(dtype);
+ H5Tclose(native_type);
+ H5Tclose(tid);
+ H5Tclose(tid_m);
+ } H5E_END_TRY;
+
return -1;
}
@@ -1220,13 +1349,13 @@ test_array_dtype(hid_t file)
int i;
long long l;
} s1;
- hid_t dataset, space;
- hid_t dtype, native_type, tid, tid2, tid3, tid_m;
- int i, j, k, n;
- hsize_t space_dims[2], array_dims[1]={5};
- s1 *temp_point, *temp_check;
- s1 *points=NULL, *check=NULL;
- void *tmp;
+ hid_t dataset = -1, space = -1;
+ hid_t dtype = -1, native_type = -1, tid = -1, tid2 = -1, tid3 = -1, tid_m = -1;
+ int i, j, k, n;
+ hsize_t space_dims[2], array_dims[1]={5};
+ s1 *temp_point = NULL, *temp_check = NULL;
+ s1 *points = NULL, *check = NULL;
+ void *tmp = NULL;
TESTING("array of compound datatype");
@@ -1237,13 +1366,13 @@ test_array_dtype(hid_t file)
TEST_ERROR;
/* Initialize the dataset */
- for(i = n = 0, temp_point=points; i < DIM0; i++)
- for(j = 0; j < DIM1; j++)
+ for(i = n = 0, temp_point = points; i < DIM0; i++)
+ for(j = 0; j < DIM1; j++)
for(k = 0; k < 5; k++,temp_point++) {
temp_point->c= 't';
temp_point->i= n++;
- temp_point->l= (i*10+j*100)*n;
- }
+ temp_point->l= (i * 10 + j * 100) * n;
+ } /* end for */
/* Create the data space */
space_dims[0] = DIM0;
@@ -1263,7 +1392,8 @@ test_array_dtype(hid_t file)
/* Create the dataset */
if((dataset = H5Dcreate2(file, DSET_ARRAY_NAME, tid, space,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
/* Create compound datatype for datatype in memory */
if((tid3 = H5Tcreate(H5T_COMPOUND, sizeof(s1))) < 0) TEST_ERROR;
@@ -1276,7 +1406,7 @@ test_array_dtype(hid_t file)
/* Write the data to the dataset */
if(H5Dwrite(dataset, tid_m, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0)
- TEST_ERROR;
+ TEST_ERROR;
/* Close dataset */
if(H5Dclose(dataset) < 0) TEST_ERROR;
@@ -1298,32 +1428,31 @@ test_array_dtype(hid_t file)
/* Read the dataset back. Temporary buffer is for special platforms like
* Cray */
- tmp = HDmalloc(DIM0 * DIM1 * H5Tget_size(native_type));
+ if(NULL == (tmp = HDmalloc(DIM0 * DIM1 * H5Tget_size(native_type))))
+ TEST_ERROR
if(H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0)
- TEST_ERROR;
+ TEST_ERROR;
- memcpy(check, tmp, DIM0 * DIM1 * H5Tget_size(native_type));
- free(tmp);
+ HDmemcpy(check, tmp, DIM0 * DIM1 * H5Tget_size(native_type));
+ HDfree(tmp);
+ tmp = NULL;
- if(H5Tconvert(native_type, tid_m, (DIM0*DIM1), check, NULL, H5P_DEFAULT) < 0)
+ if(H5Tconvert(native_type, tid_m, (DIM0 * DIM1), check, NULL, H5P_DEFAULT) < 0)
TEST_ERROR;
/* Check that the values read are the same as the values written */
- for (i = 0, temp_point=points, temp_check=check; i < DIM0; i++) {
- for (j = 0; j < DIM1; j++) {
- for (k = 0; k < 5; k++, temp_point++,temp_check++) {
+ for(i = 0, temp_point = points, temp_check = check; i < DIM0; i++)
+ for(j = 0; j < DIM1; j++)
+ for(k = 0; k < 5; k++, temp_point++, temp_check++)
if(temp_point->c != temp_check->c ||
- temp_point->i != temp_check->i ||
- temp_point->l != temp_check->l ) {
+ temp_point->i != temp_check->i ||
+ temp_point->l != temp_check->l ) {
H5_FAILED();
printf(" Read different values than written.\n");
printf(" At index %d,%d\n", i, j);
goto error;
- }
- }
- }
- }
+ } /* end if */
/* Close HDF5 objects */
if(H5Dclose(dataset)) TEST_ERROR;
@@ -1333,17 +1462,32 @@ test_array_dtype(hid_t file)
if(H5Tclose(tid3) < 0) TEST_ERROR;
/* Free memory for test data */
- free(points);
- free(check);
+ HDfree(points);
+ HDfree(check);
PASSED();
return 0;
error:
- if(points!=NULL)
- free(points);
- if(check!=NULL)
- free(check);
+ /* Free memory for test data */
+ if(tmp)
+ HDfree(tmp);
+ if(points)
+ HDfree(points);
+ if(check)
+ HDfree(check);
+
+ H5E_BEGIN_TRY {
+ H5Sclose(space);
+ H5Dclose(dataset);
+ H5Tclose(dtype);
+ H5Tclose(native_type);
+ H5Tclose(tid);
+ H5Tclose(tid2);
+ H5Tclose(tid3);
+ H5Tclose(tid_m);
+ } H5E_END_TRY;
+
return -1;
}
@@ -1367,17 +1511,17 @@ error:
static herr_t
test_array_dtype2(hid_t file)
{
- hid_t dataset, space;
- hid_t dtype, native_type, tid, tid_m;
- int i, j, k, n;
- hsize_t space_dims[2], array_dims[1]={5};
- void *tmp;
+ hid_t dataset = -1, space = -1;
+ hid_t dtype = -1, native_type = -1, tid = -1, tid_m = -1;
+ int i, j, k, n;
+ hsize_t space_dims[2], array_dims[1] = {5};
+ void *tmp = NULL;
TESTING("array of atomic datatype");
/* Initialize the dataset */
for(i = n = 0;i < DIM0; i++)
- for(j = 0; j < DIM1; j++)
+ for(j = 0; j < DIM1; j++)
for(k = 0; k < 5; k++)
ipoints3[i][j][k] = n++;
@@ -1391,14 +1535,15 @@ test_array_dtype2(hid_t file)
/* Create the dataset */
if((dataset = H5Dcreate2(file, DSET_ARRAY2_NAME, tid, space,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
/* Create array datatype for memory */
if((tid_m = H5Tarray_create2(H5T_NATIVE_INT, 1, array_dims)) < 0) TEST_ERROR;
/* Write the data to the dataset */
if(H5Dwrite(dataset, tid_m, H5S_ALL, H5S_ALL, H5P_DEFAULT, ipoints3) < 0)
- TEST_ERROR;
+ TEST_ERROR;
/* Close dataset */
if(H5Dclose(dataset) < 0) TEST_ERROR;
@@ -1409,7 +1554,6 @@ test_array_dtype2(hid_t file)
/* Close dataspace */
if(H5Sclose(space) < 0) TEST_ERROR;
-
/* Open dataset again to check H5Tget_native_type */
if((dataset = H5Dopen2(file, DSET_ARRAY2_NAME, H5P_DEFAULT)) < 0) TEST_ERROR;
@@ -1420,30 +1564,29 @@ test_array_dtype2(hid_t file)
/* Read the dataset back. Temporary buffer is for special platforms like
* Cray */
- tmp = HDmalloc(DIM0 * DIM1 * H5Tget_size(native_type));
+ if(NULL == (tmp = HDmalloc(DIM0 * DIM1 * H5Tget_size(native_type))))
+ TEST_ERROR
if(H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0)
- TEST_ERROR;
+ TEST_ERROR;
- memcpy(icheck3, tmp, DIM0 * DIM1 * H5Tget_size(native_type));
- free(tmp);
+ HDmemcpy(icheck3, tmp, DIM0 * DIM1 * H5Tget_size(native_type));
+ HDfree(tmp);
+ tmp = NULL;
- if(H5Tconvert(native_type, tid_m, (DIM0*DIM1), icheck3, NULL, H5P_DEFAULT) < 0)
+ if(H5Tconvert(native_type, tid_m, (DIM0 * DIM1), icheck3, NULL, H5P_DEFAULT) < 0)
TEST_ERROR;
/* Check that the values read are the same as the values written */
- for (i = 0; i < DIM0; i++) {
- for (j = 0; j < DIM1; j++) {
- for (k = 0; k < 5; k++) {
+ for(i = 0; i < DIM0; i++)
+ for(j = 0; j < DIM1; j++)
+ for(k = 0; k < 5; k++)
if(icheck3[i][j][k] != ipoints3[i][j][k]) {
H5_FAILED();
printf(" Read different values than written.\n");
printf(" At index %d,%d\n", i, j);
goto error;
- }
- }
- }
- }
+ } /* end if */
/* Close HDF5 objects */
if(H5Dclose(dataset)) TEST_ERROR;
@@ -1455,6 +1598,19 @@ test_array_dtype2(hid_t file)
return 0;
error:
+ /* Free memory for test data */
+ if(tmp)
+ HDfree(tmp);
+
+ H5E_BEGIN_TRY {
+ H5Sclose(space);
+ H5Dclose(dataset);
+ H5Tclose(dtype);
+ H5Tclose(native_type);
+ H5Tclose(tid);
+ H5Tclose(tid_m);
+ } H5E_END_TRY;
+
return -1;
}
@@ -1478,37 +1634,36 @@ error:
static herr_t
test_vl_dtype(hid_t file)
{
- hvl_t wdata[SPACE1_DIM1]; /* Information to write */
- hvl_t rdata[SPACE1_DIM1]; /* Information read in */
- hvl_t *t1, *t2; /* Temporary pointer to VL information */
- hsize_t dims1[] = {SPACE1_DIM1};
- hid_t dataset, space;
- hid_t dtype, native_type, nat_super_type, tid, tid2, tid_m, tid_m2;
- size_t i, j, k;
- void* *tmp;
+ hvl_t wdata[SPACE1_DIM1]; /* Information to write */
+ hvl_t rdata[SPACE1_DIM1]; /* Information read in */
+ hvl_t *t1, *t2; /* Temporary pointer to VL information */
+ hsize_t dims1[] = {SPACE1_DIM1};
+ hid_t dataset = -1, space = -1;
+ hid_t dtype = -1, native_type = -1, nat_super_type = -1, tid = -1, tid2 = -1, tid_m = -1, tid_m2 = -1;
+ size_t i, j, k;
+ void **tmp = NULL;
TESTING("variable length datatype");
/* Allocate and initialize VL data to write */
- for(i=0; i<SPACE1_DIM1; i++) {
+ for(i = 0; i < SPACE1_DIM1; i++) {
wdata[i].p = HDmalloc((i + 1) * sizeof(hvl_t));
- if(wdata[i].p==NULL) {
+ if(NULL == wdata[i].p) {
H5_FAILED();
printf(" Cannot allocate memory for VL data! i=%u\n",(unsigned)i);
goto error;
} /* end if */
- wdata[i].len=i+1;
+ wdata[i].len = i + 1;
for(t1 = (hvl_t *)wdata[i].p, j = 0; j < (i + 1); j++, t1++) {
t1->p = HDmalloc((j + 1) * sizeof(unsigned int));
- if(t1->p==NULL) {
+ if(NULL == t1->p) {
H5_FAILED();
printf(" Cannot allocate memory for VL data! i=%u, j=%u\n",(unsigned)i,(unsigned)j);
goto error;
} /* end if */
- t1->len=j+1;
- for(k=0; k<(j+1); k++) {
- ((unsigned int *)t1->p)[k]=(unsigned int)(i*100+j*10+k);
- }
+ t1->len = j + 1;
+ for(k = 0; k < (j + 1); k++)
+ ((unsigned int *)t1->p)[k] = (unsigned int)(i * 100 + j * 10 + k);
} /* end for */
} /* end for */
@@ -1566,7 +1721,7 @@ test_vl_dtype(hid_t file)
printf(" VL data length don't match!, wdata[%d].len=%d, rdata[%d].len=%d\n",(int)i,(int)wdata[i].len,(int)i,(int)rdata[i].len);
goto error;
} /* end if */
- for(t1 = (hvl_t *)wdata[i].p, t2 = (hvl_t *)rdata[i].p, j = 0; j<rdata[i].len; j++, t1++, t2++) {
+ for(t1 = (hvl_t *)wdata[i].p, t2 = (hvl_t *)rdata[i].p, j = 0; j < rdata[i].len; j++, t1++, t2++) {
if(t1->len != t2->len) {
H5_FAILED();
printf(" VL data length don't match!, wdata[%d].len=%d, rdata[%d].len=%d\n",(int)i,(int)wdata[i].len,(int)i,(int)rdata[i].len);
@@ -1575,36 +1730,38 @@ test_vl_dtype(hid_t file)
/* use temporary buffer to convert datatype. This is for special
* platforms like Cray */
- tmp = (void **)HDmalloc(t2->len * sizeof(unsigned int));
+ if(NULL == (tmp = (void **)HDmalloc(t2->len * sizeof(unsigned int))))
+ TEST_ERROR
HDmemcpy(tmp, t2->p, t2->len * H5Tget_size(nat_super_type));
- if(H5Tconvert(nat_super_type, H5T_NATIVE_UINT, t2->len, tmp, NULL, H5P_DEFAULT))
+ if(H5Tconvert(nat_super_type, H5T_NATIVE_UINT, t2->len, tmp, NULL, H5P_DEFAULT) < 0)
TEST_ERROR;
- for(k=0; k<t2->len; k++) {
- if( ((unsigned int *)t1->p)[k] != ((unsigned int *)tmp)[k] ) {
+ for(k = 0; k < t2->len; k++) {
+ if(((unsigned int *)t1->p)[k] != ((unsigned int *)tmp)[k]) {
H5_FAILED();
printf(" VL data don't match!, wdata[%u].p=%d, rdata[%u].p=%u\n",
- (unsigned)i,((unsigned int*)t1->p)[k],(unsigned)i,((unsigned int*)tmp)[k]);
+ (unsigned)i, ((unsigned int*)t1->p)[k], (unsigned)i, ((unsigned int*)tmp)[k]);
goto error;
- }
+ } /* end if */
} /* end for */
- free(tmp);
+ HDfree(tmp);
} /* end for */
} /* end for */
/* Reclaim the read VL data */
- if(H5Dvlen_reclaim(native_type,space,H5P_DEFAULT,rdata) < 0) TEST_ERROR;
+ if(H5Dvlen_reclaim(native_type, space, H5P_DEFAULT, rdata) < 0) TEST_ERROR;
/* Reclaim the write VL data */
- if(H5Dvlen_reclaim(native_type,space,H5P_DEFAULT,wdata) < 0) TEST_ERROR;
+ if(H5Dvlen_reclaim(native_type, space, H5P_DEFAULT, wdata) < 0) TEST_ERROR;
/* Close Dataset */
if(H5Dclose(dataset) < 0) TEST_ERROR;
/* Close datatype */
if(H5Tclose(native_type) < 0) TEST_ERROR;
+ native_type = -1; /* reset so that error handling can check for VL reclaim */
if(H5Tclose(dtype) < 0) TEST_ERROR;
if(H5Tclose(tid_m) < 0) TEST_ERROR;
if(H5Tclose(tid_m2) < 0) TEST_ERROR;
@@ -1616,7 +1773,27 @@ test_vl_dtype(hid_t file)
PASSED();
return 0;
- error:
+error:
+ /* Free memory for test data */
+ if(tmp)
+ HDfree(tmp);
+
+ H5E_BEGIN_TRY {
+ if(native_type > 0) {
+ H5Dvlen_reclaim(native_type, space, H5P_DEFAULT, rdata);
+ H5Dvlen_reclaim(native_type, space, H5P_DEFAULT, wdata);
+ } /* end if */
+ H5Sclose(space);
+ H5Dclose(dataset);
+ H5Tclose(dtype);
+ H5Tclose(native_type);
+ H5Tclose(nat_super_type);
+ H5Tclose(tid);
+ H5Tclose(tid2);
+ H5Tclose(tid_m);
+ H5Tclose(tid_m2);
+ } H5E_END_TRY;
+
return -1;
} /* end test_vl_type() */
@@ -1641,17 +1818,18 @@ static herr_t
test_vlstr_dtype(hid_t file)
{
const char *wdata[SPACE1_DIM1]= {
- "Four score and seven years ago our forefathers brought forth on this continent a new nation,",
- "conceived in liberty and dedicated to the proposition that all men are created equal.",
- "Now we are engaged in a great civil war,",
- "testing whether that nation or any nation so conceived and so dedicated can long endure."
- }; /* Information to write */
- char *rdata[SPACE1_DIM1]; /* Information read in */
- hid_t dataset; /* Dataset ID */
- hid_t sid1; /* Dataspace ID */
- hid_t tid1,dtype,native_type; /* Datatype ID */
- hsize_t dims1[] = {SPACE1_DIM1};
- unsigned i; /* counting variable */
+ "Four score and seven years ago our forefathers brought forth on this continent a new nation,",
+ "conceived in liberty and dedicated to the proposition that all men are created equal.",
+ "Now we are engaged in a great civil war,",
+ "testing whether that nation or any nation so conceived and so dedicated can long endure."
+ }; /* Information to write */
+ char *rdata[SPACE1_DIM1]; /* Information read in */
+ hbool_t rdata_alloc = FALSE; /* Whether the read data is allocated */
+ hid_t dataset = -1; /* Dataset ID */
+ hid_t sid1 = -1; /* Dataspace ID */
+ hid_t tid1 = -1, dtype = -1, native_type = -1; /* Datatype ID */
+ hsize_t dims1[] = {SPACE1_DIM1};
+ unsigned i; /* counting variable */
/* Output message about test being performed */
TESTING("variable length string datatype");
@@ -1691,19 +1869,20 @@ test_vlstr_dtype(hid_t file)
/* Read dataset from disk */
if(H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata) < 0) TEST_ERROR;
+ rdata_alloc = TRUE;
/* Compare data read in */
for(i = 0; i < SPACE1_DIM1; i++) {
if(HDstrlen(wdata[i]) != HDstrlen(rdata[i])) {
H5_FAILED();
printf(" VL data length don't match!, strlen(wdata[%d])=%d, strlen(rdata[%d])=%d\n",
- (int)i,(int)strlen(wdata[i]),(int)i,(int)strlen(rdata[i]));
+ (int)i, (int)HDstrlen(wdata[i]), (int)i, (int)HDstrlen(rdata[i]));
goto error;
} /* end if */
if(HDstrcmp(wdata[i], rdata[i]) != 0 ) {
H5_FAILED();
printf(" VL data values don't match!, wdata[%d]=%s, rdata[%d]=%s\n",
- (int)i,wdata[i],(int)i,rdata[i]);
+ (int)i, wdata[i], (int)i, rdata[i]);
goto error;
} /* end if */
} /* end for */
@@ -1719,14 +1898,28 @@ test_vlstr_dtype(hid_t file)
if(H5Sclose(sid1) < 0) TEST_ERROR;
/* Free memory for rdata */
- for(i=0; i<SPACE1_DIM1; i++) {
+ for(i = 0; i < SPACE1_DIM1; i++)
HDfree(rdata[i]);
- }
+ rdata_alloc = FALSE;
PASSED();
return 0;
error:
+ if(rdata_alloc) {
+ /* Free memory for rdata */
+ for(i = 0; i < SPACE1_DIM1; i++)
+ HDfree(rdata[i]);
+ } /* end if */
+
+ H5E_BEGIN_TRY {
+ H5Dclose(dataset);
+ H5Tclose(dtype);
+ H5Tclose(native_type);
+ H5Tclose(sid1);
+ H5Tclose(tid1);
+ } H5E_END_TRY;
+
return -1;
} /* end test_vlstr_dtype() */
@@ -1750,18 +1943,18 @@ error:
static herr_t
test_str_dtype(hid_t file)
{
- const char wdata[SPACE1_DIM1][4]= {
- "one",
- "two",
- "3rd",
- "4th"
- }; /* Information to write */
- char rdata[SPACE1_DIM1][4]; /* Information read in */
- hid_t dataset; /* Dataset ID */
- hid_t sid1; /* Dataspace ID */
- hid_t tid1,dtype,native_type; /* Datatype ID */
- hsize_t dims1[] = {SPACE1_DIM1};
- unsigned i; /* counting variable */
+ const char wdata[SPACE1_DIM1][4]= {
+ "one",
+ "two",
+ "3rd",
+ "4th"
+ }; /* Information to write */
+ char rdata[SPACE1_DIM1][4]; /* Information read in */
+ hid_t dataset = -1; /* Dataset ID */
+ hid_t sid1 = -1; /* Dataspace ID */
+ hid_t tid1 = -1, dtype = -1, native_type = -1; /* Datatype ID */
+ hsize_t dims1[] = {SPACE1_DIM1};
+ unsigned i; /* counting variable */
/* Output message about test being performed */
TESTING("fixed-length string datatype");
@@ -1806,13 +1999,13 @@ test_str_dtype(hid_t file)
if(HDstrlen(wdata[i]) != HDstrlen(rdata[i])) {
H5_FAILED();
printf(" data length don't match!, strlen(wdata[%d])=%d, strlen(rdata[%d])=%d\n",
- (int)i,(int)strlen(wdata[i]),(int)i,(int)strlen(rdata[i]));
+ (int)i, (int)HDstrlen(wdata[i]), (int)i, (int)HDstrlen(rdata[i]));
goto error;
} /* end if */
if(HDstrcmp(wdata[i], rdata[i]) != 0 ) {
H5_FAILED();
printf(" data values don't match!, wdata[%d]=%s, rdata[%d]=%s\n",
- (int)i,wdata[i],(int)i,rdata[i]);
+ (int)i, wdata[i], (int)i, rdata[i]);
goto error;
} /* end if */
} /* end for */
@@ -1831,11 +2024,17 @@ test_str_dtype(hid_t file)
return 0;
error:
+ H5E_BEGIN_TRY {
+ H5Dclose(dataset);
+ H5Tclose(dtype);
+ H5Tclose(native_type);
+ H5Tclose(tid1);
+ H5Tclose(sid1);
+ } H5E_END_TRY;
+
return -1;
} /* end test_str_dtype() */
-
-
/*-------------------------------------------------------------------------
* Function: test_refer_dtype
@@ -1856,7 +2055,6 @@ error:
static herr_t
test_refer_dtype(hid_t file)
{
-
/* Compound datatype */
typedef struct s1_t {
unsigned int a;
@@ -1864,21 +2062,23 @@ test_refer_dtype(hid_t file)
float c;
} s1_t;
- hid_t dataset; /* Dataset ID */
- hid_t group; /* Group ID */
- hid_t sid1; /* Dataspace ID */
- hid_t tid1, dtype, native_type; /* Datatype ID */
- hsize_t dims1[] = {1};
- H5O_type_t obj_type; /* Object type */
- hobj_ref_t *wbuf, /* buffer to write to disk */
- *rbuf; /* buffer read from disk */
+ hid_t dataset = -1; /* Dataset ID */
+ hid_t group = -1; /* Group ID */
+ hid_t sid1 = -1; /* Dataspace ID */
+ hid_t tid1 = -1, dtype = -1, native_type = -1; /* Datatype ID */
+ hsize_t dims1[] = {1};
+ H5O_type_t obj_type; /* Object type */
+ hobj_ref_t *wbuf = NULL, /* buffer to write to disk */
+ *rbuf = NULL; /* buffer read from disk */
/* Output message about test being performed */
TESTING("reference datatype");
/* Allocate write & read buffers */
- wbuf = (hobj_ref_t *)HDmalloc(MAX(sizeof(unsigned), sizeof(hobj_ref_t)));
- rbuf = (hobj_ref_t *)HDmalloc(MAX(sizeof(unsigned), sizeof(hobj_ref_t)));
+ if(NULL == (wbuf = (hobj_ref_t *)HDmalloc(MAX(sizeof(unsigned), sizeof(hobj_ref_t)))))
+ TEST_ERROR
+ if(NULL == (rbuf = (hobj_ref_t *)HDmalloc(MAX(sizeof(unsigned), sizeof(hobj_ref_t)))))
+ TEST_ERROR
/* Create dataspace for datasets */
if((sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL)) < 0)
@@ -1937,7 +2137,6 @@ test_refer_dtype(hid_t file)
if(H5Dclose(dataset) < 0)
TEST_ERROR;
-
/* Open the dataset */
if((dataset = H5Dopen2(file, "/Dataset3", H5P_DEFAULT)) < 0)
TEST_ERROR;
@@ -1973,19 +2172,36 @@ test_refer_dtype(hid_t file)
if(H5Tclose(tid1) < 0)
TEST_ERROR;
+ if(H5Tclose(native_type) < 0)
+ TEST_ERROR;
+
/* Close Dataset */
if(H5Dclose(dataset) < 0)
TEST_ERROR;
/* Free memory buffers */
- free(wbuf);
- free(rbuf);
+ HDfree(wbuf);
+ HDfree(rbuf);
PASSED();
return 0;
error:
+ if(wbuf)
+ HDfree(wbuf);
+ if(rbuf)
+ HDfree(rbuf);
+
+ H5E_BEGIN_TRY {
+ H5Sclose(sid1);
+ H5Gclose(group);
+ H5Tclose(tid1);
+ H5Tclose(dtype);
+ H5Tclose(native_type);
+ H5Dclose(dataset);
+ } H5E_END_TRY;
+
return -1;
} /* test_refer_dtype() */
@@ -2009,38 +2225,40 @@ error:
static herr_t
test_refer_dtype2(hid_t file)
{
- hid_t dset1, /* Dataset ID */
- dset2; /* Dereferenced dataset ID */
- hid_t sid1, /* Dataspace ID #1 */
- sid2; /* Dataspace ID #2 */
- hid_t dtype, native_type;
- hsize_t dims1[] = {1},
- dims2[] = {SPACE2_DIM1, SPACE2_DIM2};
- hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */
- hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */
- hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */
- hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */
- hdset_reg_ref_t wbuf, /* buffer to write to disk */
- rbuf; /* buffer read from disk */
- uint8_t *dwbuf, /* Buffer for writing numeric data to disk */
- *drbuf; /* Buffer for reading numeric data from disk */
- uint8_t *tu8; /* Temporary pointer to uint8 data */
- H5O_type_t obj_type; /* Object type */
- int i; /* counting variables */
+ hid_t dset1 = -1, /* Dataset ID */
+ dset2 = -1; /* Dereferenced dataset ID */
+ hid_t sid1 = -1, /* Dataspace ID #1 */
+ sid2 = -1; /* Dataspace ID #2 */
+ hid_t dtype = -1, native_type = -1;
+ hsize_t dims1[] = { 1 }, dims2[] = { SPACE2_DIM1, SPACE2_DIM2 };
+ hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */
+ hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */
+ hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */
+ hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */
+ hdset_reg_ref_t wbuf, /* buffer to write to disk */
+ rbuf; /* buffer read from disk */
+ uint8_t *dwbuf = NULL, /* Buffer for writing numeric data to disk */
+ *drbuf = NULL; /* Buffer for reading numeric data from disk */
+ uint8_t *tu8 = NULL; /* Temporary pointer to uint8 data */
+ H5O_type_t obj_type; /* Object type */
+ int i; /* counting variables */
/* Output message about test being performed */
TESTING("dataset region reference");
/* Allocate write & read buffers */
- dwbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2);
- drbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), SPACE2_DIM1 * SPACE2_DIM2);
+ if(NULL == (dwbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2)))
+ TEST_ERROR
+ if(NULL == (drbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), SPACE2_DIM1 * SPACE2_DIM2)))
+ TEST_ERROR
/* Create dataspace for datasets */
if((sid2 = H5Screate_simple(SPACE2_RANK, dims2, NULL)) < 0)
TEST_ERROR;
/* Create a dataset */
- if((dset2 = H5Dcreate2(file, "Dataset2", H5T_STD_U8LE, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if((dset2 = H5Dcreate2(file, "Dataset2", H5T_STD_U8LE, sid2, H5P_DEFAULT,
+ H5P_DEFAULT, H5P_DEFAULT)) < 0)
TEST_ERROR;
for(tu8 = dwbuf, i = 0; i < SPACE2_DIM1 * SPACE2_DIM2; i++)
@@ -2054,21 +2272,25 @@ test_refer_dtype2(hid_t file)
if(H5Dclose(dset2) < 0)
TEST_ERROR;
-
/* Create dataspace for the reference dataset */
if((sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL)) < 0)
TEST_ERROR;
/* Create a reference dataset */
- if((dset1 = H5Dcreate2(file, "Dataset1", H5T_STD_REF_DSETREG, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if((dset1 = H5Dcreate2(file, "Dataset1", H5T_STD_REF_DSETREG, sid1,
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
TEST_ERROR;
/* Create references */
/* Select 6x6 hyperslab for first reference */
- start[0] = 2; start[1] = 2;
- stride[0] = 1; stride[1] = 1;
- count[0] = 1; count[1] = 1;
- block[0] = 6; block[1] = 6;
+ start[0] = 2;
+ start[1] = 2;
+ stride[0] = 1;
+ stride[1] = 1;
+ count[0] = 1;
+ count[1] = 1;
+ block[0] = 6;
+ block[1] = 6;
if(H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, stride, count, block) < 0)
TEST_ERROR;
@@ -2100,9 +2322,6 @@ test_refer_dtype2(hid_t file)
if(H5Sclose(sid2) < 0)
TEST_ERROR;
-
-
-
/* Open the dataset */
if((dset1 = H5Dopen2(file, "/Dataset1", H5P_DEFAULT)) < 0)
TEST_ERROR;
@@ -2175,13 +2394,28 @@ test_refer_dtype2(hid_t file)
TEST_ERROR;
/* Free memory buffers */
- free(dwbuf);
- free(drbuf);
+ HDfree(dwbuf);
+ HDfree(drbuf);
PASSED();
return 0;
-error:
+error:
+ /* Free memory buffers */
+ if(dwbuf)
+ HDfree(dwbuf);
+ if(drbuf)
+ HDfree(drbuf);
+
+ H5E_BEGIN_TRY {
+ H5Sclose(sid2);
+ H5Sclose(sid1);
+ H5Tclose(dtype);
+ H5Tclose(native_type);
+ H5Dclose(dset2);
+ H5Dclose(dset1);
+ } H5E_END_TRY;
+
return -1;
} /* test_refer_dtype2() */
@@ -2205,21 +2439,21 @@ error:
static herr_t
test_opaque_dtype(hid_t file)
{
- hid_t type=-1, space=-1, dset=-1;
- hid_t dataset, dtype, native_type;
- size_t i;
- unsigned char wbuf[32], rbuf[32];
- hsize_t nelmts;
+ hid_t type = -1, space = -1, dset = -1;
+ hid_t dataset = -1, dtype = -1, native_type = -1;
+ size_t i;
+ unsigned char wbuf[32], rbuf[32];
+ hsize_t nelmts;
TESTING("opaque datatype");
/* opaque_1 */
nelmts = sizeof(wbuf);
- if((type = H5Tcreate(H5T_OPAQUE, 1)) < 0 ||
- H5Tset_tag(type, "testing 1-byte opaque type") < 0 ||
- (space = H5Screate_simple(1, &nelmts, NULL)) < 0 ||
- (dset = H5Dcreate2(file, DSET_OPAQUE_NAME, type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- TEST_ERROR;
+ if((type = H5Tcreate(H5T_OPAQUE, 1)) < 0) TEST_ERROR;
+ if(H5Tset_tag(type, "testing 1-byte opaque type") < 0) TEST_ERROR;
+ if((space = H5Screate_simple(1, &nelmts, NULL)) < 0) TEST_ERROR;
+ if((dset = H5Dcreate2(file, DSET_OPAQUE_NAME, type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
for(i = 0; i < sizeof(wbuf); i++)
wbuf[i] = (unsigned char)0xff ^ (unsigned char)i;
@@ -2243,11 +2477,11 @@ test_opaque_dtype(hid_t file)
TEST_ERROR;
for(i = 0; i < sizeof(rbuf); i++)
- if(rbuf[i] != wbuf[i]) {
- H5_FAILED();
- printf(" Read different values than written.\n");
+ if(rbuf[i] != wbuf[i]) {
+ H5_FAILED();
+ printf(" Read different values than written.\n");
printf(" At index %u\n", (unsigned)i);
- goto error;
+ goto error;
} /* end if */
if(H5Tclose(type) < 0) TEST_ERROR;
@@ -2259,6 +2493,15 @@ test_opaque_dtype(hid_t file)
return 0;
error:
+ H5E_BEGIN_TRY {
+ H5Sclose(space);
+ H5Tclose(type);
+ H5Tclose(dtype);
+ H5Tclose(native_type);
+ H5Dclose(dset);
+ H5Dclose(dataset);
+ } H5E_END_TRY;
+
return -1;
} /* test_opaque_dtype */
@@ -2282,20 +2525,20 @@ error:
static herr_t
test_bitfield_dtype(hid_t file)
{
- hid_t type=-1, space=-1, dset=-1;
- hid_t dataset, dtype, native_type;
- size_t i;
- unsigned char wbuf[32];
- hsize_t nelmts;
+ hid_t type = -1, space = -1, dset = -1;
+ hid_t dataset = -1, dtype = -1, native_type = -1;
+ size_t i;
+ unsigned char wbuf[32];
+ hsize_t nelmts;
TESTING("bitfield datatype");
/* opaque_1 */
nelmts = sizeof(wbuf);
- if((type = H5Tcopy(H5T_STD_B8LE)) < 0 ||
- (space = H5Screate_simple(1, &nelmts, NULL)) < 0 ||
- (dset = H5Dcreate2(file, DSET_BITFIELD_NAME, type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- TEST_ERROR;
+ if((type = H5Tcopy(H5T_STD_B8LE)) < 0) TEST_ERROR;
+ if((space = H5Screate_simple(1, &nelmts, NULL)) < 0) TEST_ERROR;
+ if((dset = H5Dcreate2(file, DSET_BITFIELD_NAME, type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
for(i = 0; i < sizeof(wbuf); i++)
wbuf[i] = (unsigned char)0xff ^ (unsigned char)i;
@@ -2327,6 +2570,15 @@ test_bitfield_dtype(hid_t file)
return 0;
error:
+ H5E_BEGIN_TRY {
+ H5Sclose(space);
+ H5Tclose(type);
+ H5Tclose(dtype);
+ H5Tclose(native_type);
+ H5Dclose(dset);
+ H5Dclose(dataset);
+ } H5E_END_TRY;
+
return -1;
} /* test_bitfield_dtype */
@@ -2350,176 +2602,166 @@ error:
static herr_t
test_ninteger(void)
{
- hid_t fid1=(-1); /* file ID */
- hid_t fid2=(-1); /* file ID */
- hid_t did1=(-1); /* dataset ID */
- hid_t did2=(-1); /* dataset ID */
- hid_t sid1=(-1); /* dataspace ID */
- hid_t dcpl1=(-1); /* dataset creation property list ID */
- hid_t dcpl2=(-1); /* dataset creation property list ID */
- hid_t tid1=(-1); /* file datatype */
- hid_t tid2=(-1); /* file datatype */
- hid_t nid1=(-1); /* native datatype */
- hid_t nid2=(-1); /* native datatype */
- hsize_t dims[1]={DIM3}; /* dataspace dimensions */
+ hid_t fid1 = -1; /* file ID */
+ hid_t fid2 = -1; /* file ID */
+ hid_t did1 = -1; /* dataset ID */
+ hid_t did2 = -1; /* dataset ID */
+ hid_t sid1 = -1; /* dataspace ID */
+ hid_t dcpl1 = -1; /* dataset creation property list ID */
+ hid_t dcpl2 = -1; /* dataset creation property list ID */
+ hid_t tid1 = -1; /* file datatype */
+ hid_t tid2 = -1; /* file datatype */
+ hid_t nid1 = -1; /* native datatype */
+ hid_t nid2 = -1; /* native datatype */
+ hsize_t dims[1] = {DIM3}; /* dataspace dimensions */
hsize_t nelmts; /* number of elements in dataset */
- int rank=1; /* rank of dataset */
+ int rank = 1; /* rank of dataset */
int buf[DIM3];
int chk[DIM3];
int i;
- for (i=0; i<DIM3; i++){
- buf[i]=i;
- }
-
TESTING("native integer ");
- /*-------------------------------------------------------------------------
- * step1: create a file
- *-------------------------------------------------------------------------
- */
+ for(i = 0; i < DIM3; i++)
+ buf[i] = i;
+
+ /*-------------------------------------------------------------------------
+ * step1: create a file
+ *-------------------------------------------------------------------------
+ */
/* create a file using default properties */
- if((fid1=H5Fcreate("tstint1.h5",H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
- goto error;
+ if((fid1 = H5Fcreate("tstint1.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
/* create a data space */
- if((sid1 = H5Screate_simple(rank,dims,NULL)) < 0) goto error;
+ if((sid1 = H5Screate_simple(rank, dims, NULL)) < 0) FAIL_STACK_ERROR
/* create dcpl */
- if((dcpl1 = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error;
+ if((dcpl1 = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR
/* create a dataset */
- if((did1 = H5Dcreate2(fid1, "dset", H5T_NATIVE_INT, sid1, H5P_DEFAULT, dcpl1, H5P_DEFAULT)) < 0) goto error;
+ if((did1 = H5Dcreate2(fid1, "dset", H5T_NATIVE_INT, sid1, H5P_DEFAULT, dcpl1, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* write */
- if(H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
- goto error;
+ if(H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) FAIL_STACK_ERROR
/* close */
- if(H5Sclose(sid1) < 0) goto error;
- if(H5Pclose(dcpl1) < 0) goto error;
- if(H5Dclose(did1) < 0) goto error;
- if(H5Fclose(fid1) < 0) goto error;
+ if(H5Sclose(sid1) < 0) FAIL_STACK_ERROR
+ if(H5Pclose(dcpl1) < 0) FAIL_STACK_ERROR
+ if(H5Dclose(did1) < 0) FAIL_STACK_ERROR
+ if(H5Fclose(fid1) < 0) FAIL_STACK_ERROR
- /*-------------------------------------------------------------------------
- * step 2: open and create another file copying the data from file1
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * step 2: open and create another file copying the data from file1
+ *-------------------------------------------------------------------------
+ */
- /* open */
- if((fid1 = H5Fopen("tstint1.h5", H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) goto error;
+ /* open */
+ if((fid1 = H5Fopen("tstint1.h5", H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* open dataset */
- if((did1 = H5Dopen2(fid1, "dset", H5P_DEFAULT)) < 0) goto error;
+ if((did1 = H5Dopen2(fid1, "dset", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
- if((sid1 = H5Dget_space(did1)) < 0) goto error;
+ if((sid1 = H5Dget_space(did1)) < 0) FAIL_STACK_ERROR
/* get dcpl */
- if((dcpl1 = H5Dget_create_plist(did1)) < 0) goto error;
+ if((dcpl1 = H5Dget_create_plist(did1)) < 0) FAIL_STACK_ERROR
/* get file datatype */
- if((tid1 = H5Dget_type(did1)) < 0) goto error;
+ if((tid1 = H5Dget_type(did1)) < 0) FAIL_STACK_ERROR
/* get native datatype */
- if((nid1 = H5Tget_native_type(tid1, H5T_DIR_DEFAULT)) < 0) goto error;
+ if((nid1 = H5Tget_native_type(tid1, H5T_DIR_DEFAULT)) < 0) FAIL_STACK_ERROR
/* get size */
- if(H5Tget_size(nid1) == 0) goto error;
+ if(H5Tget_size(nid1) == 0) FAIL_STACK_ERROR
/* get rank */
- if((rank = H5Sget_simple_extent_ndims(sid1)) < 0) goto error;
+ if((rank = H5Sget_simple_extent_ndims(sid1)) < 0) FAIL_STACK_ERROR
HDmemset(dims, 0, sizeof dims);
/* get dimension */
- if(H5Sget_simple_extent_dims(sid1, dims, NULL) < 0) goto error;
+ if(H5Sget_simple_extent_dims(sid1, dims, NULL) < 0) FAIL_STACK_ERROR
nelmts = 1;
for(i = 0; i < rank; i++)
- nelmts *= dims[i];
+ nelmts *= dims[i];
/* read */
- if(H5Dread(did1, nid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, chk) < 0)
- goto error;
+ if(H5Dread(did1, nid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, chk) < 0) FAIL_STACK_ERROR
/* create a file using default properties */
- if((fid2 = H5Fcreate("tstint2.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- goto error;
+ if((fid2 = H5Fcreate("tstint2.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* create a dataset using the native type */
- if((did2 = H5Dcreate2(fid2, "dset", nid1, sid1, H5P_DEFAULT, dcpl1, H5P_DEFAULT)) < 0) goto error;
+ if((did2 = H5Dcreate2(fid2, "dset", nid1, sid1, H5P_DEFAULT, dcpl1, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* write */
- if(H5Dwrite(did2, nid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, chk) < 0)
- goto error;
+ if(H5Dwrite(did2, nid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, chk) < 0) FAIL_STACK_ERROR
/* get dcpl */
- if((dcpl2 = H5Dget_create_plist(did2)) < 0)
- goto error;
+ if((dcpl2 = H5Dget_create_plist(did2)) < 0) FAIL_STACK_ERROR
/* get file datatype */
- if((tid2 = H5Dget_type(did2)) < 0)
- goto error;
+ if((tid2 = H5Dget_type(did2)) < 0) FAIL_STACK_ERROR
/* get native datatype */
- if((nid2 = H5Tget_native_type(tid2, H5T_DIR_DEFAULT)) < 0)
- goto error;
+ if((nid2 = H5Tget_native_type(tid2, H5T_DIR_DEFAULT)) < 0) FAIL_STACK_ERROR
/* check */
if(H5Tget_precision(nid1) != H5Tget_precision(nid2)) {
- printf(" Precision differ.\n");
- goto error;
- }
+ printf(" Precision differ.\n");
+ TEST_ERROR
+ } /* end if */
/* compare dataset creation property lists */
if(H5Pequal(dcpl1, dcpl2) <= 0) {
- printf(" Property lists differ.\n");
- goto error;
- }
+ printf(" Property lists differ.\n");
+ TEST_ERROR
+ } /* end if */
/* check */
- for (i = 0; i < DIM3; i++) {
- if(buf[i] != chk[i]) {
- H5_FAILED();
- printf(" Read different values than written.\n");
- printf(" At index %d\n", i);
- goto error;
- }
- }
+ for(i = 0; i < DIM3; i++)
+ if(buf[i] != chk[i]) {
+ H5_FAILED();
+ printf(" Read different values than written.\n");
+ printf(" At index %d\n", i);
+ TEST_ERROR
+ } /* end if */
/* close */
- if(H5Sclose (sid1) < 0) goto error;
- if(H5Pclose (dcpl1) < 0) goto error;
- if(H5Pclose (dcpl2) < 0) goto error;
- if(H5Tclose (tid1) < 0) goto error;
- if(H5Tclose (tid2) < 0) goto error;
- if(H5Tclose (nid1) < 0) goto error;
- if(H5Tclose (nid2) < 0) goto error;
- if(H5Dclose (did1) < 0) goto error;
- if(H5Dclose (did2) < 0) goto error;
- if(H5Fclose (fid1) < 0) goto error;
- if(H5Fclose (fid2) < 0) goto error;
-
+ if(H5Sclose(sid1) < 0) FAIL_STACK_ERROR
+ if(H5Pclose(dcpl1) < 0) FAIL_STACK_ERROR
+ if(H5Pclose(dcpl2) < 0) FAIL_STACK_ERROR
+ if(H5Tclose(tid1) < 0) FAIL_STACK_ERROR
+ if(H5Tclose(tid2) < 0) FAIL_STACK_ERROR
+ if(H5Tclose(nid1) < 0) FAIL_STACK_ERROR
+ if(H5Tclose(nid2) < 0) FAIL_STACK_ERROR
+ if(H5Dclose(did1) < 0) FAIL_STACK_ERROR
+ if(H5Dclose(did2) < 0) FAIL_STACK_ERROR
+ if(H5Fclose(fid1) < 0) FAIL_STACK_ERROR
+ if(H5Fclose(fid2) < 0) FAIL_STACK_ERROR
PASSED();
return 0;
error:
H5E_BEGIN_TRY {
- H5Pclose(dcpl1);
- H5Pclose(dcpl2);
- H5Tclose(tid1);
- H5Tclose(tid2);
- H5Tclose(nid1);
- H5Tclose(nid2);
- H5Dclose(did1);
- H5Dclose(did2);
- H5Sclose(sid1);
- H5Fclose(fid1);
- H5Fclose(fid2);
+ H5Pclose(dcpl1);
+ H5Pclose(dcpl2);
+ H5Tclose(tid1);
+ H5Tclose(tid2);
+ H5Tclose(nid1);
+ H5Tclose(nid2);
+ H5Dclose(did1);
+ H5Dclose(did2);
+ H5Sclose(sid1);
+ H5Fclose(fid1);
+ H5Fclose(fid2);
} H5E_END_TRY;
+
return -1;
} /* end test_ninteger() */
-
/*-------------------------------------------------------------------------
* Function: main
@@ -2536,43 +2778,54 @@ error:
int
main(void)
{
- hid_t file, fapl;
- int nerrors=0;
- char filename[1024];
+ hid_t file, fapl;
+ int nerrors = 0;
+ char filename[1024];
h5_reset();
fapl = h5_fileaccess();
h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
- if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
- goto error;
-
- nerrors += test_atomic_dtype(file) < 0 ?1:0;
- nerrors += test_compound_dtype(file) < 0 ?1:0;
- nerrors += test_compound_dtype2(file) < 0 ?1:0;
- nerrors += test_compound_dtype3(file) < 0 ?1:0;
- nerrors += test_compound_opaque(file) < 0 ?1:0;
- nerrors += test_enum_dtype(file) < 0 ?1:0;
- nerrors += test_array_dtype(file) < 0 ?1:0;
- nerrors += test_array_dtype2(file) < 0 ?1:0;
- nerrors += test_vl_dtype(file) < 0 ?1:0;
- nerrors += test_vlstr_dtype(file) < 0 ?1:0;
- nerrors += test_str_dtype(file) < 0 ?1:0;
- nerrors += test_refer_dtype(file) < 0 ?1:0;
- nerrors += test_refer_dtype2(file) < 0 ?1:0;
- nerrors += test_opaque_dtype(file) < 0 ?1:0;
- nerrors += test_bitfield_dtype(file) < 0 ?1:0;
- nerrors += test_ninteger() < 0 ?1:0;
-
- if(H5Fclose(file) < 0) goto error;
- if(nerrors) goto error;
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ goto error;
+
+ nerrors += test_atomic_dtype(file) < 0 ? 1 : 0;
+ nerrors += test_compound_dtype(file) < 0 ? 1 : 0;
+ nerrors += test_compound_dtype2(file) < 0 ? 1 : 0;
+ nerrors += test_compound_dtype3(file) < 0 ? 1 : 0;
+ nerrors += test_compound_opaque(file) < 0 ? 1 : 0;
+ nerrors += test_enum_dtype(file) < 0 ? 1 : 0;
+ nerrors += test_array_dtype(file) < 0 ? 1 : 0;
+ nerrors += test_array_dtype2(file) < 0 ? 1 : 0;
+ nerrors += test_vl_dtype(file) < 0 ? 1 : 0;
+ nerrors += test_vlstr_dtype(file) < 0 ? 1 : 0;
+ nerrors += test_str_dtype(file) < 0 ? 1 : 0;
+ nerrors += test_refer_dtype(file) < 0 ? 1 : 0;
+ nerrors += test_refer_dtype2(file) < 0 ? 1 : 0;
+ nerrors += test_opaque_dtype(file) < 0 ? 1 : 0;
+ nerrors += test_bitfield_dtype(file) < 0 ? 1 : 0;
+ nerrors += test_ninteger() < 0 ? 1 : 0;
+
+ if(H5Fclose(file) < 0)
+ goto error;
+ if(nerrors)
+ goto error;
+
printf("All native datatype tests passed.\n");
h5_cleanup(FILENAME, fapl);
+
return 0;
- error:
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ h5_cleanup(FILENAME, fapl);
+ } H5E_END_TRY;
+
nerrors = MAX(1, nerrors);
printf("***** %d DATASET TEST%s FAILED! *****\n",
- nerrors, 1 == nerrors ? "" : "S");
+ nerrors, 1 == nerrors ? "" : "S");
+
return 1;
}
+
diff --git a/test/objcopy.c b/test/objcopy.c
index 9d67d3e..493274a 100755
--- a/test/objcopy.c
+++ b/test/objcopy.c
@@ -721,7 +721,9 @@ compare_attribute(hid_t aid, hid_t aid2, hid_t pid, const void *wbuf, hid_t obj_
/* Release raw data buffers */
HDfree(rbuf);
+ rbuf = NULL;
HDfree(rbuf2);
+ rbuf2 = NULL;
/* close the source dataspace */
if(H5Sclose(sid) < 0) TEST_ERROR
@@ -738,11 +740,11 @@ compare_attribute(hid_t aid, hid_t aid2, hid_t pid, const void *wbuf, hid_t obj_
return TRUE;
error:
+ if(rbuf)
+ HDfree(rbuf);
+ if(rbuf2)
+ HDfree(rbuf2);
H5E_BEGIN_TRY {
- if(rbuf)
- HDfree(rbuf);
- if(rbuf2)
- HDfree(rbuf2);
H5Sclose(sid2);
H5Sclose(sid);
H5Tclose(tid2);
@@ -7315,9 +7317,11 @@ static int
test_copy_dataset_contig_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl)
{
hid_t fid_src = -1, fid_dst = -1; /* File IDs */
- hid_t tid = -1, tid2; /* Datatype IDs */
+ hid_t tid = -1; /* Datatype ID */
+ hid_t tid2 = -1; /* Datatype ID */
hid_t sid = -1; /* Dataspace ID */
- hid_t did = -1, did2 = -1; /* Dataset IDs */
+ hid_t did = -1; /* Dataset ID */
+ hid_t did2 = -1; /* Dataset ID */
unsigned int i, j; /* Local index variables */
hsize_t dim1d[1]; /* Dataset dimensions */
cmpd_vl_t buf[DIM_SIZE_1]; /* Buffer for writing data */
diff --git a/test/pool.c b/test/pool.c
index 22658ec..43e9cfd 100644
--- a/test/pool.c
+++ b/test/pool.c
@@ -645,7 +645,7 @@ test_allocate_random(void)
curr_time=1115412944;
HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time);
#endif /* QAK */
- HDsrandom((unsigned long)curr_time);
+ HDsrandom((unsigned)curr_time);
/* Create a memory pool */
if(NULL == (mp = H5MP_create((size_t)MPOOL_PAGE_SIZE, MPOOL_FLAGS)))
diff --git a/test/theap.c b/test/theap.c
index 0c39868..230ec4d 100644
--- a/test/theap.c
+++ b/test/theap.c
@@ -93,7 +93,7 @@ test_heap_init(void)
/* Create randomized set of numbers */
curr_time=time(NULL);
- HDsrandom((unsigned long)curr_time);
+ HDsrandom((unsigned)curr_time);
for(u=0; u<NUM_ELEMS; u++)
/* Generate random numbers from -1000 to 1000 */
rand_num[u].val=(int)(HDrandom()%2001)-1001;
diff --git a/test/tskiplist.c b/test/tskiplist.c
index 7b3dcef..8510db2 100644
--- a/test/tskiplist.c
+++ b/test/tskiplist.c
@@ -71,7 +71,7 @@ test_skiplist_init(void)
/* Initialize random number seed */
curr_time = HDtime(NULL);
- HDsrandom((unsigned long)curr_time);
+ HDsrandom((unsigned)curr_time);
/* Create randomized set of numbers */
for(u=0; u<NUM_ELEMS; u++) {
diff --git a/test/ttst.c b/test/ttst.c
index c267404..4ffe4cd 100644
--- a/test/ttst.c
+++ b/test/ttst.c
@@ -124,7 +124,7 @@ test_tst_init(void)
for(u=0; u<num_uniq_words; u++)
rand_uniq_words[u]=uniq_words[u];
curr_time=HDtime(NULL);
- HDsrandom((unsigned long)curr_time);
+ HDsrandom((unsigned)curr_time);
for(u=0; u<num_uniq_words; u++) {
v=u+(HDrandom()%(num_uniq_words-u));
if(u!=v) {
diff --git a/test/tunicode.c b/test/tunicode.c
index efbf80e..892e563 100644
--- a/test/tunicode.c
+++ b/test/tunicode.c
@@ -807,7 +807,7 @@ void test_unicode(void)
MESSAGE(5, ("Testing UTF-8 Encoding\n"));
/* Create a random string with length NUM_CHARS */
- HDsrandom((unsigned long)HDtime(NULL));
+ HDsrandom((unsigned)HDtime(NULL));
HDmemset(test_string, 0, sizeof(test_string));
for(x=0; x<NUM_CHARS; x++)
diff --git a/test/unlink.c b/test/unlink.c
index 60d6ac5..9bd6f42 100644
--- a/test/unlink.c
+++ b/test/unlink.c
@@ -1487,8 +1487,8 @@ delete_node(hid_t pid, hid_t id)
static int
test_unlink_rightleaf(hid_t fid)
{
- hid_t rootid, /* Group ID for root group */
- *gids; /* Array of IDs for groups created */
+ hid_t rootid = -1, /* Group ID for root group */
+ *gids = NULL; /* Array of IDs for groups created */
int n, /* Local index variable */
ngroups = 150; /* Number of groups to create */
char name[256]; /* Name of object to create */
@@ -1496,7 +1496,7 @@ test_unlink_rightleaf(hid_t fid)
TESTING("deleting right-most child in non-leaf B-tree node");
/* Allocate space for the group IDs */
- if(NULL == (gids = (hid_t *)HDmalloc((size_t)ngroups * sizeof(hid_t)))) TEST_ERROR
+ if(NULL == (gids = (hid_t *)HDcalloc((size_t)ngroups, sizeof(hid_t)))) TEST_ERROR
if((rootid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
@@ -1514,8 +1514,10 @@ test_unlink_rightleaf(hid_t fid)
} /* end for */
/* Close all the groups */
- for (n = 0; n < ngroups; n++)
+ for (n = 0; n < ngroups; n++) {
if(H5Gclose(gids[n]) < 0) TEST_ERROR
+ gids[n] = 0;
+ } /* end for */
/* Close root group ID */
if(H5Gclose(rootid) < 0) TEST_ERROR
@@ -1527,6 +1529,20 @@ test_unlink_rightleaf(hid_t fid)
return 0;
error:
+ if(gids) {
+ /* Close any open groups */
+ for (n = 0; n < ngroups; n++)
+ if(gids[n]) {
+ H5E_BEGIN_TRY {
+ H5Gclose(gids[n]);
+ } H5E_END_TRY;
+ } /* end if */
+ HDfree(gids);
+ } /* end if */
+ H5E_BEGIN_TRY {
+ H5Gclose(rootid);
+ } H5E_END_TRY;
+
return 1;
} /* end test_unlink_rightleaf() */
@@ -1550,8 +1566,8 @@ error:
static int
test_unlink_rightnode(hid_t fid)
{
- hid_t rootid, /* Group ID for root group */
- *gids; /* Array of IDs for groups created */
+ hid_t rootid = -1, /* Group ID for root group */
+ *gids = NULL; /* Array of IDs for groups created */
int n, /* Local index variable */
ngroups = 150; /* Number of groups to create */
char name[256]; /* Name of object to create */
@@ -1559,7 +1575,7 @@ test_unlink_rightnode(hid_t fid)
TESTING("deleting right-most child in non-leaf B-tree node");
/* Allocate space for the group IDs */
- if(NULL == (gids = (hid_t *)HDmalloc((size_t)ngroups * sizeof(hid_t)))) TEST_ERROR
+ if(NULL == (gids = (hid_t *)HDcalloc((size_t)ngroups, sizeof(hid_t)))) TEST_ERROR
if((rootid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
@@ -1570,8 +1586,10 @@ test_unlink_rightnode(hid_t fid)
} /* end for */
/* Close all the groups */
- for (n = 0; n < ngroups; n++)
+ for (n = 0; n < ngroups; n++) {
if(H5Gclose(gids[n]) < 0) FAIL_STACK_ERROR
+ gids[n] = 0;
+ } /* end for */
/* Unlink specific objects to trigger deletion of right leaf in non-leaf node */
if(H5Ldelete(fid, "/ZoneB77", H5P_DEFAULT) < 0) FAIL_STACK_ERROR
@@ -1590,6 +1608,20 @@ test_unlink_rightnode(hid_t fid)
return 0;
error:
+ if(gids) {
+ /* Close any open groups */
+ for (n = 0; n < ngroups; n++)
+ if(gids[n]) {
+ H5E_BEGIN_TRY {
+ H5Gclose(gids[n]);
+ } H5E_END_TRY;
+ } /* end if */
+ HDfree(gids);
+ } /* end if */
+ H5E_BEGIN_TRY {
+ H5Gclose(rootid);
+ } H5E_END_TRY;
+
return 1;
} /* end test_unlink_rightnode() */
@@ -1613,8 +1645,8 @@ error:
static int
test_unlink_middlenode(hid_t fid)
{
- hid_t rootid, /* Group ID for root group */
- *gids; /* Array of IDs for groups created */
+ hid_t rootid = -1, /* Group ID for root group */
+ *gids = NULL; /* Array of IDs for groups created */
int n, /* Local index variable */
ngroups = 250; /* Number of groups to create */
char name[256]; /* Name of object to create */
@@ -1622,7 +1654,7 @@ test_unlink_middlenode(hid_t fid)
TESTING("deleting right-most child in non-leaf B-tree node");
/* Allocate space for the group IDs */
- if(NULL == (gids = (hid_t *)HDmalloc((size_t)ngroups * sizeof(hid_t)))) TEST_ERROR
+ if(NULL == (gids = (hid_t *)HDcalloc((size_t)ngroups, sizeof(hid_t)))) TEST_ERROR
if((rootid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
@@ -1633,8 +1665,10 @@ test_unlink_middlenode(hid_t fid)
} /* end for */
/* Close all the groups */
- for (n = 0; n < ngroups; n++)
+ for (n = 0; n < ngroups; n++) {
if(H5Gclose(gids[n]) < 0) FAIL_STACK_ERROR
+ gids[n] = 0;
+ } /* end for */
/* Unlink specific objects to trigger deletion of all leafs in "interior" non-leaf node */
if(H5Ldelete(fid, "/ZoneC11", H5P_DEFAULT) < 0) FAIL_STACK_ERROR
@@ -1796,6 +1830,20 @@ test_unlink_middlenode(hid_t fid)
return 0;
error:
+ if(gids) {
+ /* Close any open groups */
+ for (n = 0; n < ngroups; n++)
+ if(gids[n]) {
+ H5E_BEGIN_TRY {
+ H5Gclose(gids[n]);
+ } H5E_END_TRY;
+ } /* end if */
+ HDfree(gids);
+ } /* end if */
+ H5E_BEGIN_TRY {
+ H5Gclose(rootid);
+ } H5E_END_TRY;
+
return 1;
} /* end test_unlink_middlenode() */
@@ -1819,7 +1867,7 @@ error:
static int
test_resurrect_dataset(hid_t fapl)
{
- hid_t f =-1, s =-1, d =-1;
+ hid_t f = -1, s = -1, d = -1;
char filename[1024];
TESTING("resurrecting dataset after deletion");
@@ -2404,7 +2452,7 @@ main(void)
double rdcc_w0;
/* Set the random # seed */
- HDsrandom((unsigned long)HDtime(NULL));
+ HDsrandom((unsigned)HDtime(NULL));
/* Open */
h5_reset();
diff --git a/test/vfd.c b/test/vfd.c
index f5a29c5..bd642be 100644
--- a/test/vfd.c
+++ b/test/vfd.c
@@ -808,7 +808,6 @@ test_family_compat(void)
char filename[1024];
char pathname[1024], pathname_individual[1024];
char newname[1024], newname_individual[1024];
- FILE *tmp_fp, *old_fp; /* Pointers to temp & old files */
int counter = 0;
TESTING("FAMILY file driver backward compatibility");
@@ -838,10 +837,6 @@ test_family_compat(void)
sprintf(pathname_individual, pathname, counter);
}
- if ((NULL != (old_fp = HDfopen(pathname_individual,"rb"))) &&
- (NULL != (tmp_fp = HDfopen(newname_individual,"wb"))))
- TEST_ERROR;
-
/* Make sure we can open the file. Use the read and write mode to flush the
* superblock. */
if((file = H5Fopen(newname, H5F_ACC_RDWR, fapl)) < 0)