summaryrefslogtreecommitdiffstats
path: root/test/gen_plist.c
diff options
context:
space:
mode:
authorNeil Fortner <nfortne2@hdfgroup.org>2015-09-16 19:55:38 (GMT)
committerNeil Fortner <nfortne2@hdfgroup.org>2015-09-16 19:55:38 (GMT)
commitd23cc2da70510d5c52216234b5d2a7b292a3ab30 (patch)
tree55d0caf28a8a06823ca0c54690f2ab365fbc6710 /test/gen_plist.c
parent52ac462e7c7af08f176e0772914fa16d815d7e16 (diff)
downloadhdf5-d23cc2da70510d5c52216234b5d2a7b292a3ab30.zip
hdf5-d23cc2da70510d5c52216234b5d2a7b292a3ab30.tar.gz
hdf5-d23cc2da70510d5c52216234b5d2a7b292a3ab30.tar.bz2
[svn-r27806] Fix property list serialization for values encoded by H5Pset_chunk_cache to be
compatible between 32 and 64 bit systems. Expand cross platform property list encode/decode testing. Fix warning in H5P__fill_value_enc. Tested: jam, koala, ostrich (h5committest), ummon
Diffstat (limited to 'test/gen_plist.c')
-rw-r--r--test/gen_plist.c81
1 files changed, 63 insertions, 18 deletions
diff --git a/test/gen_plist.c b/test/gen_plist.c
index cd3748b..2746462 100644
--- a/test/gen_plist.c
+++ b/test/gen_plist.c
@@ -25,7 +25,7 @@
#include "H5private.h"
#include "hdf5.h"
-static int encode_plist(hid_t plist_id, int little_endian, const char *filename_le, const char *filename_be);
+static int encode_plist(hid_t plist_id, int little_endian, int word_length, const char *filename_prefix);
int
main(void)
@@ -54,6 +54,7 @@ main(void)
unsigned min_dense;
const char* c_to_f = "x+32";
int little_endian;
+ int word_length;
H5AC_cache_config_t my_cache_config = {
H5AC__CURR_CACHE_CONFIG_VERSION,
1 /*TRUE*/,
@@ -99,6 +100,11 @@ main(void)
little_endian = 0;
}
+ /* check word length */
+ {
+ word_length = 8 * sizeof(void *);
+ }
+
/* Explicitly initialize the library, since we are including the private header file */
H5open();
@@ -106,6 +112,9 @@ main(void)
if((dcpl1 = H5Pcreate(H5P_DATASET_CREATE)) < 0)
assert(dcpl1 > 0);
+ if((ret = encode_plist(dcpl1, little_endian, word_length, "testfiles/plist_files/def_dcpl_")) < 0)
+ assert(ret > 0);
+
if((ret = H5Pset_chunk(dcpl1, 1, &chunk_size)) < 0)
assert(ret > 0);
@@ -131,7 +140,7 @@ main(void)
(hsize_t)(max_size[0] * sizeof(int)/4))) < 0)
assert(ret > 0);
- if((ret = encode_plist(dcpl1, little_endian, "testfiles/plist_files/dcpl_le", "testfiles/plist_files/dcpl_be")) < 0)
+ if((ret = encode_plist(dcpl1, little_endian, word_length, "testfiles/plist_files/dcpl_")) < 0)
assert(ret > 0);
/* release resource */
@@ -143,10 +152,13 @@ main(void)
if((dapl1 = H5Pcreate(H5P_DATASET_ACCESS)) < 0)
assert(dapl1 > 0);
+ if((ret = encode_plist(dapl1, little_endian, word_length, "testfiles/plist_files/def_dapl_")) < 0)
+ assert(ret > 0);
+
if((ret = H5Pset_chunk_cache(dapl1, nslots, nbytes, w0)) < 0)
assert(ret > 0);
- if((ret = encode_plist(dapl1, little_endian, "testfiles/plist_files/dapl_le", "testfiles/plist_files/dapl_be")) < 0)
+ if((ret = encode_plist(dapl1, little_endian, word_length, "testfiles/plist_files/dapl_")) < 0)
assert(ret > 0);
/* release resource */
@@ -156,6 +168,10 @@ main(void)
/******* ENCODE/DECODE DXPLS *****/
if((dxpl1 = H5Pcreate(H5P_DATASET_XFER)) < 0)
assert(dxpl1 > 0);
+
+ if((ret = encode_plist(dxpl1, little_endian, word_length, "testfiles/plist_files/def_dxpl_")) < 0)
+ assert(ret > 0);
+
if((ret = H5Pset_btree_ratios(dxpl1, 0.2f, 0.6f, 0.2f)) < 0)
assert(ret > 0);
if((ret = H5Pset_hyper_vector_size(dxpl1, 5)) < 0)
@@ -177,7 +193,7 @@ main(void)
if((ret = H5Pset_data_transform(dxpl1, c_to_f)) < 0)
assert(ret > 0);
- if((ret = encode_plist(dxpl1, little_endian, "testfiles/plist_files/dxpl_le", "testfiles/plist_files/dxpl_be")) < 0)
+ if((ret = encode_plist(dxpl1, little_endian, word_length, "testfiles/plist_files/dxpl_")) < 0)
assert(ret > 0);
/* release resource */
@@ -189,6 +205,9 @@ main(void)
if((gcpl1 = H5Pcreate(H5P_GROUP_CREATE)) < 0)
assert(gcpl1 > 0);
+ if((ret = encode_plist(gcpl1, little_endian, word_length, "testfiles/plist_files/def_gcpl_")) < 0)
+ assert(ret > 0);
+
if((ret = H5Pset_local_heap_size_hint(gcpl1, 256)) < 0)
assert(ret > 0);
@@ -205,7 +224,7 @@ main(void)
if((ret = H5Pset_link_creation_order(gcpl1, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED))) < 0)
assert(ret > 0);
- if((ret = encode_plist(gcpl1, little_endian, "testfiles/plist_files/gcpl_le", "testfiles/plist_files/gcpl_be")) < 0)
+ if((ret = encode_plist(gcpl1, little_endian, word_length, "testfiles/plist_files/gcpl_")) < 0)
assert(ret > 0);
/* release resource */
@@ -216,10 +235,13 @@ main(void)
if((lcpl1 = H5Pcreate(H5P_LINK_CREATE)) < 0)
assert(lcpl1 > 0);
+ if((ret = encode_plist(lcpl1, little_endian, word_length, "testfiles/plist_files/def_lcpl_")) < 0)
+ assert(ret > 0);
+
if((ret = H5Pset_create_intermediate_group(lcpl1, 1 /*TRUE*/)) < 0)
assert(ret > 0);
- if((ret = encode_plist(lcpl1, little_endian, "testfiles/plist_files/lcpl_le", "testfiles/plist_files/lcpl_be")) < 0)
+ if((ret = encode_plist(lcpl1, little_endian, word_length, "testfiles/plist_files/lcpl_")) < 0)
assert(ret > 0);
/* release resource */
@@ -230,6 +252,9 @@ main(void)
if((ocpypl1 = H5Pcreate(H5P_OBJECT_COPY)) < 0)
assert(ocpypl1 > 0);
+ if((ret = encode_plist(ocpypl1, little_endian, word_length, "testfiles/plist_files/def_ocpypl_")) < 0)
+ assert(ret > 0);
+
ret = H5Pset_copy_object(ocpypl1, H5O_COPY_EXPAND_EXT_LINK_FLAG);
assert(ret >= 0);
@@ -239,7 +264,7 @@ main(void)
ret = H5Padd_merge_committed_dtype_path(ocpypl1, "bar");
assert(ret >= 0);
- if((ret = encode_plist(ocpypl1, little_endian, "testfiles/plist_files/ocpypl_le", "testfiles/plist_files/ocpypl_be")) < 0)
+ if((ret = encode_plist(ocpypl1, little_endian, word_length, "testfiles/plist_files/ocpypl_")) < 0)
assert(ret > 0);
/* release resource */
@@ -250,6 +275,9 @@ main(void)
if((ocpl1 = H5Pcreate(H5P_OBJECT_CREATE)) < 0)
assert(ocpl1 > 0);
+ if((ret = encode_plist(ocpl1, little_endian, word_length, "testfiles/plist_files/def_ocpl_")) < 0)
+ assert(ret > 0);
+
if((ret = H5Pset_attr_creation_order(ocpl1, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED))) < 0)
assert(ret > 0);
@@ -259,7 +287,7 @@ main(void)
if((ret = H5Pset_filter (ocpl1, H5Z_FILTER_FLETCHER32, 0, (size_t)0, NULL)) < 0)
assert(ret > 0);
- if((ret = encode_plist(ocpl1, little_endian, "testfiles/plist_files/ocpl_le", "testfiles/plist_files/ocpl_be")) < 0)
+ if((ret = encode_plist(ocpl1, little_endian, word_length, "testfiles/plist_files/ocpl_")) < 0)
assert(ret > 0);
/* release resource */
@@ -270,6 +298,9 @@ main(void)
if((lapl1 = H5Pcreate(H5P_LINK_ACCESS)) < 0)
assert(lapl1 > 0);
+ if((ret = encode_plist(lapl1, little_endian, word_length, "testfiles/plist_files/def_lapl_")) < 0)
+ assert(ret > 0);
+
if((ret = H5Pset_nlinks(lapl1, (size_t)134)) < 0)
assert(ret > 0);
@@ -292,7 +323,7 @@ main(void)
if((ret = H5Pclose(fapl1)) < 0)
assert(ret > 0);
- if((ret = encode_plist(lapl1, little_endian, "testfiles/plist_files/lapl_le", "testfiles/plist_files/lapl_be")) < 0)
+ if((ret = encode_plist(lapl1, little_endian, word_length, "testfiles/plist_files/lapl_")) < 0)
assert(ret > 0);
/* release resource */
@@ -303,6 +334,9 @@ main(void)
if((fapl1 = H5Pcreate(H5P_FILE_ACCESS)) < 0)
assert(fapl1 > 0);
+ if((ret = encode_plist(fapl1, little_endian, word_length, "testfiles/plist_files/def_fapl_")) < 0)
+ assert(ret > 0);
+
if((ret = H5Pset_family_offset(fapl1, 1024)) < 0)
assert(ret > 0);
if((ret = H5Pset_meta_block_size(fapl1, 2098452)) < 0)
@@ -330,7 +364,7 @@ main(void)
if((ret = H5Pset_core_write_tracking(fapl1, TRUE, (size_t)(1024 * 1024))) < 0)
assert(ret > 0);
- if((ret = encode_plist(fapl1, little_endian, "testfiles/plist_files/fapl_le", "testfiles/plist_files/fapl_be")) < 0)
+ if((ret = encode_plist(fapl1, little_endian, word_length, "testfiles/plist_files/fapl_")) < 0)
assert(ret > 0);
/* release resource */
@@ -341,6 +375,9 @@ main(void)
if((fcpl1 = H5Pcreate(H5P_FILE_CREATE)) < 0)
assert(fcpl1 > 0);
+ if((ret = encode_plist(fcpl1, little_endian, word_length, "testfiles/plist_files/def_fcpl_")) < 0)
+ assert(ret > 0);
+
if((ret = H5Pset_userblock(fcpl1, 1024) < 0))
assert(ret > 0);
@@ -362,7 +399,7 @@ main(void)
if((ret = H5Pset_sizes(fcpl1, 8, 4) < 0))
assert(ret > 0);
- if((ret = encode_plist(fcpl1, little_endian, "testfiles/plist_files/fcpl_le", "testfiles/plist_files/fcpl_be")) < 0)
+ if((ret = encode_plist(fcpl1, little_endian, word_length, "testfiles/plist_files/fcpl_")) < 0)
assert(ret > 0);
/* release resource */
@@ -373,10 +410,13 @@ main(void)
strcpl1 = H5Pcreate(H5P_STRING_CREATE);
assert(strcpl1 > 0);
+ ret = encode_plist(strcpl1, little_endian, word_length, "testfiles/plist_files/def_strcpl_");
+ assert(ret > 0);
+
ret = H5Pset_char_encoding(strcpl1, H5T_CSET_UTF8);
assert(ret >= 0);
- ret = encode_plist(strcpl1, little_endian, "testfiles/plist_files/strcpl_le", "testfiles/plist_files/strcpl_be");
+ ret = encode_plist(strcpl1, little_endian, word_length, "testfiles/plist_files/strcpl_");
assert(ret > 0);
/* release resource */
@@ -387,10 +427,13 @@ main(void)
acpl1 = H5Pcreate(H5P_ATTRIBUTE_CREATE);
assert(acpl1 > 0);
+ ret = encode_plist(acpl1, little_endian, word_length, "testfiles/plist_files/def_acpl_");
+ assert(ret > 0);
+
ret = H5Pset_char_encoding(acpl1, H5T_CSET_UTF8);
assert(ret >= 0);
- ret = encode_plist(acpl1, little_endian, "testfiles/plist_files/acpl_le", "testfiles/plist_files/acpl_be");
+ ret = encode_plist(acpl1, little_endian, word_length, "testfiles/plist_files/acpl_");
assert(ret > 0);
/* release resource */
@@ -401,13 +444,18 @@ main(void)
}
static int
-encode_plist(hid_t plist_id, int little_endian, const char *filename_le, const char *filename_be)
+encode_plist(hid_t plist_id, int little_endian, int word_length, const char *filename_prefix)
{
int fd = 0; /* file descriptor */
herr_t ret = 0;
void *temp_buf = NULL;
size_t temp_size = 0;
ssize_t write_size;
+ char filename[1024];
+
+ /* Generate filename */
+ if((ret = HDsnprintf(filename, sizeof(filename), "%s%d%s", filename_prefix, word_length, little_endian ? "le" : "be")) < 0)
+ assert(ret > 0);
/* first call to encode returns only the size of the buffer needed */
if((ret = H5Pencode(plist_id, NULL, &temp_size)) < 0)
@@ -419,10 +467,7 @@ encode_plist(hid_t plist_id, int little_endian, const char *filename_le, const c
if((ret = H5Pencode(plist_id, temp_buf, &temp_size)) < 0)
assert(ret > 0);
- if(little_endian)
- fd = HDopen(filename_le, O_RDWR | O_CREAT | O_TRUNC, 0666);
- else
- fd = HDopen(filename_be, O_RDWR | O_CREAT | O_TRUNC, 0666);
+ fd = HDopen(filename, O_RDWR | O_CREAT | O_TRUNC, 0666);
assert(fd > 0);
write_size = HDwrite(fd, temp_buf, temp_size);